| 749 | static bool convertx_hack( |
| 750 | const QString &loc_err_msg, |
| 751 | int videofd, int inputNumV4L, int &ioctlval, bool &undo_convertx_hack) |
| 752 | { |
| 753 | bool ok = true; |
| 754 | undo_convertx_hack = false; |
| 755 | |
| 756 | // ConvertX (wis-go7007) requires streaming to be disabled |
| 757 | // before an input switch, do this if initial switch failed. |
| 758 | int streamType = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
| 759 | |
| 760 | ioctlval = ioctl(videofd, VIDIOC_STREAMOFF, &streamType); |
| 761 | if (ioctlval < 0) |
| 762 | { |
| 763 | VERBOSE(VB_IMPORTANT, loc_err_msg + |
| 764 | "\n\t\t\twhile disabling streaming (v4l v2)" + ENO); |
| 765 | |
| 766 | ok = false; |
| 767 | ioctlval = 0; |
| 768 | } |
| 769 | else |
| 770 | { |
| 771 | undo_convertx_hack = true; |
| 772 | |
| 773 | // Resend the input switch ioctl. |
| 774 | ioctlval = ioctl(videofd, VIDIOC_S_INPUT, &inputNumV4L); |
| 775 | } |
| 776 | |
| 777 | return ok; |
| 778 | } |
| 779 | |
| 780 | static bool convertx_unhack(const QString &loc_err_msg, int videofd) |
| 781 | { |
| 782 | bool ok = true; |
| 783 | |
| 784 | // ConvertX (wis-go7007) requires streaming to be disabled |
| 785 | // before an input switch, here we try to re-enable streaming. |
| 786 | int streamType = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
| 787 | |
| 788 | int ioctlval = ioctl(videofd, VIDIOC_STREAMON, &streamType); |
| 789 | if (ioctlval < 0) |
| 790 | { |
| 791 | VERBOSE(VB_IMPORTANT, loc_err_msg + |
| 792 | "\n\t\t\twhile reenabling ivtv streaming (v4l v2)" + ENO); |
| 793 | |
| 794 | ok = false; |
| 795 | } |
| 796 | |
| 797 | return ok; |
| 798 | } |
| 799 | |
| 800 | static bool ivtv_hack( |
| 801 | const QString &loc_err_msg, |
| 802 | int videofd, int inputNumV4L, int &ioctlval, bool &undo_ivtv_hack) |
| 803 | { |
| 804 | bool ok = true; |
| 805 | undo_ivtv_hack = false; |
| 806 | |
| 807 | // The ivtv 0.10.6+ drivers require streaming to be disabled |
| 808 | // before an input switch, do this if initial switch failed. |
| 809 | struct v4l2_encoder_cmd command; |
| 810 | memset(&command, 0, sizeof(struct v4l2_encoder_cmd)); |
| 811 | command.cmd = V4L2_ENC_CMD_PAUSE; |
| 812 | command.flags = V4L2_ENC_CMD_STOP_AT_GOP_END; |
| 813 | |
| 814 | ioctlval = ioctl(videofd, VIDIOC_ENCODER_CMD, &command); |
| 815 | if (ioctlval < 0) |
| 816 | { |
| 817 | VERBOSE(VB_IMPORTANT, loc_err_msg + |
| 818 | "\n\t\t\twhile disabling ivtv streaming (v4l v2)" + ENO); |
| 819 | |
| 820 | ok = false; |
| 821 | ioctlval = 0; |
| 822 | } |
| 823 | else |
| 824 | { |
| 825 | undo_ivtv_hack = true; |
| 826 | |
| 827 | // Resend the input switch ioctl. |
| 828 | ioctlval = ioctl(videofd, VIDIOC_S_INPUT, &inputNumV4L); |
| 829 | } |
| 830 | |
| 831 | return ok; |
| 832 | } |
| 833 | |
| 834 | static bool ivtv_unhack(const QString &loc_err_msg, int videofd) |
| 835 | { |
| 836 | bool ok = true; |
| 837 | |
| 838 | // The ivtv 0.10.6+ drivers require streaming to be disabled |
| 839 | // before an input switch, here we try to re-enable streaming. |
| 840 | struct v4l2_encoder_cmd command; |
| 841 | memset(&command, 0, sizeof(struct v4l2_encoder_cmd)); |
| 842 | command.cmd = V4L2_ENC_CMD_RESUME; |
| 843 | |
| 844 | int ioctlval = ioctl(videofd, VIDIOC_ENCODER_CMD, &command); |
| 845 | if (ioctlval < 0) |
| 846 | { |
| 847 | VERBOSE(VB_IMPORTANT, loc_err_msg + |
| 848 | "\n\t\t\twhile reenabling ivtv streaming (v4l v2)" + ENO); |
| 849 | |
| 850 | ok = false; |
| 851 | } |
| 852 | |
| 853 | return ok; |
| 854 | } |
| 855 | |
774 | | ioctlval = ioctl(videofd, VIDIOC_STREAMOFF, &streamType); |
775 | | if (ioctlval < 0) |
776 | | { |
777 | | VERBOSE(VB_IMPORTANT, LOC_ERR + msg + |
778 | | "\n\t\t\twhile disabling streaming (v4l v2)" + ENO); |
779 | | |
780 | | ok = false; |
781 | | ioctlval = 0; |
782 | | } |
783 | | else |
784 | | { |
785 | | streamingDisabled = true; |
786 | | |
787 | | // Resend the input switch ioctl. |
788 | | ioctlval = ioctl(videofd, VIDIOC_S_INPUT, &inputNumV4L); |
789 | | } |
| 879 | ok = ivtv_hack(LOC_ERR + msg, videofd, inputNumV4L, |
| 880 | ioctlval, undo_ivtv_hack); |