Ticket #1757: 1757.patch
File 1757.patch, 4.4 KB (added by , 18 years ago) |
---|
-
libs/libmythtv/channel.cpp
777 777 bool usingv4l1 = !usingv4l2; 778 778 bool ok = true; 779 779 780 QString msg = 781 QString("SetInputAndFormat(%1, %2) ").arg(inputNum).arg(newFmt); 782 780 783 if (usingv4l2) 781 784 { 785 VERBOSE(VB_CHANNEL, LOC + msg + "(v4l v2)"); 786 782 787 int ioctlval = ioctl(videofd, VIDIOC_S_INPUT, &inputNumV4L); 788 789 // ConvertX (wis-go7007) requires streaming to be disabled 790 // before an input switch, do this if initial switch failed. 791 bool streamingDisabled = false; 792 int streamType = V4L2_BUF_TYPE_VIDEO_CAPTURE; 793 if ((ioctlval < 0) && (errno == EBUSY)) 794 { 795 ioctlval = ioctl(videofd, VIDIOC_STREAMOFF, &streamType); 796 if (ioctlval < 0) 797 { 798 VERBOSE(VB_IMPORTANT, LOC_ERR + msg + 799 "\n\t\t\twhile disabling streaming (v4l v2)" + ENO); 800 801 ok = false; 802 ioctlval = 0; 803 } 804 else 805 { 806 streamingDisabled = true; 807 808 // Resend the input switch ioctl. 809 ioctlval = ioctl(videofd, VIDIOC_S_INPUT, &inputNumV4L); 810 } 811 } 812 783 813 if (ioctlval < 0) 784 814 { 785 VERBOSE(VB_IMPORTANT, LOC_ERR + QString( 786 "SetInputAndFormat(%1, %2) " 787 "\n\t\t\twhile setting input (v4l v2)") 788 .arg(inputNum).arg(newFmt) + ENO); 815 VERBOSE(VB_IMPORTANT, LOC_ERR + msg + 816 "\n\t\t\twhile setting input (v4l v2)" + ENO); 817 789 818 ok = false; 790 819 } 791 820 792 VERBOSE(VB_CHANNEL, LOC + QString(793 "SetInputAndFormat(%1, %2) v4l v2")794 .arg(inputNum).arg(newFmt));795 796 821 v4l2_std_id vid_mode = format_to_mode(newFmt, 2); 797 822 ioctlval = ioctl(videofd, VIDIOC_S_STD, &vid_mode); 798 823 if (ioctlval < 0) 799 824 { 800 VERBOSE(VB_IMPORTANT, LOC_ERR + QString( 801 "SetInputAndFormat(%1, %2) " 802 "\n\t\t\twhile setting format (v4l v2)") 803 .arg(inputNum).arg(newFmt) + ENO); 825 VERBOSE(VB_IMPORTANT, LOC_ERR + msg + 826 "\n\t\t\twhile setting format (v4l v2)" + ENO); 804 827 805 828 // Fall through to try v4l version 1, pcHDTV 1.4 (for HD-2000) 806 829 // drivers don't work with VIDIOC_S_STD ioctl. 807 830 usingv4l1 = true; 808 831 ok = false; 809 832 } 833 834 // ConvertX (wis-go7007) requires streaming to be disabled 835 // before an input switch, here we try to re-enable streaming. 836 if (streamingDisabled) 837 { 838 ioctlval = ioctl(videofd, VIDIOC_STREAMON, &streamType); 839 if (ioctlval < 0) 840 { 841 VERBOSE(VB_IMPORTANT, LOC_ERR + msg + 842 "\n\t\t\twhile reenabling streaming (v4l v2)" + ENO); 843 844 ok = false; 845 } 846 } 810 847 } 811 848 812 849 if (usingv4l1) 813 850 { 814 VERBOSE(VB_CHANNEL, LOC + QString( 815 "SetInputAndFormat(%1, %2) v4l v1") 816 .arg(inputNum).arg(newFmt)); 851 VERBOSE(VB_CHANNEL, LOC + msg + "(v4l v1)"); 817 852 818 853 // read in old settings 819 854 struct video_channel set; … … 825 860 set.norm = format_to_mode(newFmt, 1); 826 861 int ioctlval = ioctl(videofd, VIDIOCSCHAN, &set); 827 862 828 if (ioctlval < 0) 863 ok = (ioctlval >= 0); 864 if (!ok) 829 865 { 830 VERBOSE(VB_IMPORTANT, LOC_ERR + QString( 831 "SetInputAndFormat(%1, %2) " 832 "\n\t\t\twhile setting format (v4l v1)") 833 .arg(inputNum).arg(newFmt) + ENO); 834 ok = false; 866 VERBOSE(VB_IMPORTANT, LOC_ERR + msg + 867 "\n\t\t\twhile setting format (v4l v1)" + ENO); 835 868 } 836 869 else if (usingv4l2) 837 870 { 838 VERBOSE(VB_IMPORTANT, LOC + QString( 839 "SetInputAndFormat(%1, %2) " 840 "\n\t\t\tSetting video mode with v4l version 1 worked") 841 .arg(inputNum).arg(newFmt)); 842 ok = true; 871 VERBOSE(VB_IMPORTANT, LOC + msg + 872 "\n\t\t\tSetting video mode with v4l version 1 worked"); 843 873 } 844 874 } 845 875 return ok;