Ticket #5866: hdpvr-v4lchannel-tweak.patch
File hdpvr-v4lchannel-tweak.patch, 4.8 KB (added by , 15 years ago) |
---|
-
libs/libmythtv/v4lchannel.h
103 103 VidModV4L2 videomode_v4l2; ///< Current video mode if 'usingv4l2' is true 104 104 105 105 int defaultFreqTable; 106 int prev_inputNumV4L; 107 v4l2_std_id prev_vid_mode; 106 108 }; 107 109 108 110 #endif -
libs/libmythtv/v4lchannel.cpp
40 40 device_name(QString::null), driver_name(QString::null), 41 41 curList(NULL), totalChannels(0), 42 42 currentFormat(""), is_dtv(false), 43 usingv4l2(false), defaultFreqTable(1) 43 usingv4l2(false), defaultFreqTable(1), 44 prev_inputNumV4L(-1), prev_vid_mode(-1) 44 45 { 45 46 } 46 47 … … 795 796 { 796 797 VERBOSE(VB_CHANNEL, LOC + msg + "(v4l v2)"); 797 798 798 int ioctlval = ioctl(videofd, VIDIOC_S_INPUT, &inputNumV4L); 799 int ioctlval; 800 bool streamingDisabled = false; 801 int streamType = V4L2_BUF_TYPE_VIDEO_CAPTURE; 799 802 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) 805 804 { 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 807 829 if (ioctlval < 0) 808 830 { 809 831 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); 811 833 812 834 ok = false; 813 ioctlval = 0;814 835 } 815 else816 {817 streamingDisabled = true;818 836 819 // Resend the input switch ioctl. 820 ioctlval = ioctl(videofd, VIDIOC_S_INPUT, &inputNumV4L); 821 } 837 prev_inputNumV4L = inputNumV4L; 822 838 } 823 839 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 832 840 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);838 841 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) 845 843 { 846 ioctlval = ioctl(videofd, VIDIOC_S TREAMON, &streamType);844 ioctlval = ioctl(videofd, VIDIOC_S_STD, &vid_mode); 847 845 if (ioctlval < 0) 848 846 { 849 847 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); 851 849 852 850 ok = false; 853 851 } 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; 854 868 } 855 869 } 856 870