Ticket #5866: hdpvr-v4lchannel-tweak.patch

File hdpvr-v4lchannel-tweak.patch, 4.8 KB (added by jppoet@…, 15 years ago)

hack to keep v4lchannel from aborting on HD-PVR channel changes

  • libs/libmythtv/v4lchannel.h

     
    103103    VidModV4L2  videomode_v4l2; ///< Current video mode if 'usingv4l2' is true
    104104
    105105    int         defaultFreqTable;
     106    int         prev_inputNumV4L;
     107    v4l2_std_id prev_vid_mode;
    106108};
    107109
    108110#endif
  • libs/libmythtv/v4lchannel.cpp

     
    4040      device_name(QString::null),   driver_name(QString::null),
    4141      curList(NULL),                totalChannels(0),
    4242      currentFormat(""),            is_dtv(false),
    43       usingv4l2(false),             defaultFreqTable(1)
     43      usingv4l2(false),             defaultFreqTable(1),
     44      prev_inputNumV4L(-1),         prev_vid_mode(-1)
    4445{
    4546}
    4647
     
    795796    {
    796797        VERBOSE(VB_CHANNEL, LOC + msg + "(v4l v2)");
    797798
    798         int ioctlval = ioctl(videofd, VIDIOC_S_INPUT, &inputNumV4L);
     799        int ioctlval;
     800        bool streamingDisabled = false;
     801        int  streamType = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    799802
    800         // ConvertX (wis-go7007) requires streaming to be disabled
    801         // before an input switch, do this if initial switch failed.
    802         bool streamingDisabled = false;
    803         int  streamType = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    804         if ((ioctlval < 0) && (errno == EBUSY))
     803        if (prev_inputNumV4L != inputNumV4L)
    805804        {
    806             ioctlval = ioctl(videofd, VIDIOC_STREAMOFF, &streamType);
     805            ioctlval = ioctl(videofd, VIDIOC_S_INPUT, &inputNumV4L);
     806
     807            // ConvertX (wis-go7007) requires streaming to be disabled
     808            // before an input switch, do this if initial switch failed.
     809            if ((ioctlval < 0) && (errno == EBUSY))
     810            {
     811                ioctlval = ioctl(videofd, VIDIOC_STREAMOFF, &streamType);
     812                if (ioctlval < 0)
     813                {
     814                    VERBOSE(VB_IMPORTANT, LOC_ERR + msg +
     815                            "\n\t\t\twhile disabling streaming (v4l v2)" + ENO);
     816
     817                    ok = false;
     818                    ioctlval = 0;
     819                }
     820                else
     821                {
     822                    streamingDisabled = true;
     823
     824                    // Resend the input switch ioctl.
     825                    ioctlval = ioctl(videofd, VIDIOC_S_INPUT, &inputNumV4L);
     826                }
     827            }
     828
    807829            if (ioctlval < 0)
    808830            {
    809831                VERBOSE(VB_IMPORTANT, LOC_ERR + msg +
    810                         "\n\t\t\twhile disabling streaming (v4l v2)" + ENO);
     832                        "\n\t\t\twhile setting input (v4l v2)" + ENO);
    811833
    812834                ok = false;
    813                 ioctlval = 0;
    814835            }
    815             else
    816             {
    817                 streamingDisabled = true;
    818836
    819                 // Resend the input switch ioctl.
    820                 ioctlval = ioctl(videofd, VIDIOC_S_INPUT, &inputNumV4L);
    821             }
     837            prev_inputNumV4L = inputNumV4L;
    822838        }
    823839
    824         if (ioctlval < 0)
    825         {
    826             VERBOSE(VB_IMPORTANT, LOC_ERR + msg +
    827                     "\n\t\t\twhile setting input (v4l v2)" + ENO);
    828 
    829             ok = false;
    830         }
    831 
    832840        v4l2_std_id vid_mode = format_to_mode(newFmt, 2);
    833         ioctlval = ioctl(videofd, VIDIOC_S_STD, &vid_mode);
    834         if (ioctlval < 0)
    835         {
    836             VERBOSE(VB_IMPORTANT, LOC_ERR + msg +
    837                     "\n\t\t\twhile setting format (v4l v2)" + ENO);
    838841
    839             ok = false;
    840         }
    841 
    842         // ConvertX (wis-go7007) requires streaming to be disabled
    843         // before an input switch, here we try to re-enable streaming.
    844         if (streamingDisabled)
     842        if (prev_vid_mode != vid_mode)
    845843        {
    846             ioctlval = ioctl(videofd, VIDIOC_STREAMON, &streamType);
     844            ioctlval = ioctl(videofd, VIDIOC_S_STD, &vid_mode);
    847845            if (ioctlval < 0)
    848846            {
    849847                VERBOSE(VB_IMPORTANT, LOC_ERR + msg +
    850                         "\n\t\t\twhile reenabling streaming (v4l v2)" + ENO);
     848                        "\n\t\t\twhile setting format (v4l v2)" + ENO);
    851849
    852850                ok = false;
    853851            }
     852
     853            // ConvertX (wis-go7007) requires streaming to be disabled
     854            // before an input switch, here we try to re-enable streaming.
     855            if (streamingDisabled)
     856            {
     857                ioctlval = ioctl(videofd, VIDIOC_STREAMON, &streamType);
     858                if (ioctlval < 0)
     859                {
     860                    VERBOSE(VB_IMPORTANT, LOC_ERR + msg +
     861                            "\n\t\t\twhile reenabling streaming (v4l v2)" +
     862                            ENO);
     863
     864                    ok = false;
     865                }
     866            }
     867            prev_vid_mode = vid_mode;
    854868        }
    855869    }
    856870