diff options
| author | Hans Verkuil <hans.verkuil@cisco.com> | 2015-03-30 12:54:13 -0400 |
|---|---|---|
| committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-04-02 22:57:19 -0400 |
| commit | bbc9fa2ece0f2bb1db9b195d7a6ac88468cd45d4 (patch) | |
| tree | 1a2e06147646a9f293f1e4e6208b1fe7fd9b4145 | |
| parent | 4db4ca7450f97c300ebf74f5dca69015ad0d5ed3 (diff) | |
[media] ivtv: replace crop by selection
Replace the old g/s_crop ioctls by the new g/s_selection ioctls.
This solves a v4l2-compliance failure, and it is something that needs
to be done anyway to eventually be able to remove the old g/s_crop
ioctl ops.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
| -rw-r--r-- | drivers/media/pci/ivtv/ivtv-ioctl.c | 115 |
1 files changed, 69 insertions, 46 deletions
diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c b/drivers/media/pci/ivtv/ivtv-ioctl.c index fa875655ede6..683beb4f1951 100644 --- a/drivers/media/pci/ivtv/ivtv-ioctl.c +++ b/drivers/media/pci/ivtv/ivtv-ioctl.c | |||
| @@ -816,80 +816,103 @@ static int ivtv_cropcap(struct file *file, void *fh, struct v4l2_cropcap *cropca | |||
| 816 | { | 816 | { |
| 817 | struct ivtv_open_id *id = fh2id(fh); | 817 | struct ivtv_open_id *id = fh2id(fh); |
| 818 | struct ivtv *itv = id->itv; | 818 | struct ivtv *itv = id->itv; |
| 819 | struct yuv_playback_info *yi = &itv->yuv_info; | ||
| 820 | int streamtype; | ||
| 821 | |||
| 822 | streamtype = id->type; | ||
| 823 | 819 | ||
| 824 | if (cropcap->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) | ||
| 825 | return -EINVAL; | ||
| 826 | cropcap->bounds.top = cropcap->bounds.left = 0; | ||
| 827 | cropcap->bounds.width = 720; | ||
| 828 | if (cropcap->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { | 820 | if (cropcap->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { |
| 829 | cropcap->bounds.height = itv->is_50hz ? 576 : 480; | ||
| 830 | cropcap->pixelaspect.numerator = itv->is_50hz ? 59 : 10; | 821 | cropcap->pixelaspect.numerator = itv->is_50hz ? 59 : 10; |
| 831 | cropcap->pixelaspect.denominator = itv->is_50hz ? 54 : 11; | 822 | cropcap->pixelaspect.denominator = itv->is_50hz ? 54 : 11; |
| 832 | } else if (streamtype == IVTV_DEC_STREAM_TYPE_YUV) { | 823 | } else if (cropcap->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { |
| 833 | if (yi->track_osd) { | ||
| 834 | cropcap->bounds.width = yi->osd_full_w; | ||
| 835 | cropcap->bounds.height = yi->osd_full_h; | ||
| 836 | } else { | ||
| 837 | cropcap->bounds.width = 720; | ||
| 838 | cropcap->bounds.height = | ||
| 839 | itv->is_out_50hz ? 576 : 480; | ||
| 840 | } | ||
| 841 | cropcap->pixelaspect.numerator = itv->is_out_50hz ? 59 : 10; | 824 | cropcap->pixelaspect.numerator = itv->is_out_50hz ? 59 : 10; |
| 842 | cropcap->pixelaspect.denominator = itv->is_out_50hz ? 54 : 11; | 825 | cropcap->pixelaspect.denominator = itv->is_out_50hz ? 54 : 11; |
| 843 | } else { | 826 | } else { |
| 844 | cropcap->bounds.height = itv->is_out_50hz ? 576 : 480; | 827 | return -EINVAL; |
| 845 | cropcap->pixelaspect.numerator = itv->is_out_50hz ? 59 : 10; | ||
| 846 | cropcap->pixelaspect.denominator = itv->is_out_50hz ? 54 : 11; | ||
| 847 | } | 828 | } |
| 848 | cropcap->defrect = cropcap->bounds; | ||
| 849 | return 0; | 829 | return 0; |
| 850 | } | 830 | } |
| 851 | 831 | ||
| 852 | static int ivtv_s_crop(struct file *file, void *fh, const struct v4l2_crop *crop) | 832 | static int ivtv_s_selection(struct file *file, void *fh, |
| 833 | struct v4l2_selection *sel) | ||
| 853 | { | 834 | { |
| 854 | struct ivtv_open_id *id = fh2id(fh); | 835 | struct ivtv_open_id *id = fh2id(fh); |
| 855 | struct ivtv *itv = id->itv; | 836 | struct ivtv *itv = id->itv; |
| 856 | struct yuv_playback_info *yi = &itv->yuv_info; | 837 | struct yuv_playback_info *yi = &itv->yuv_info; |
| 857 | int streamtype; | 838 | struct v4l2_rect r = { 0, 0, 720, 0 }; |
| 839 | int streamtype = id->type; | ||
| 858 | 840 | ||
| 859 | streamtype = id->type; | 841 | if (sel->type != V4L2_BUF_TYPE_VIDEO_OUTPUT || |
| 842 | !(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) | ||
| 843 | return -EINVAL; | ||
| 860 | 844 | ||
| 861 | if (crop->type == V4L2_BUF_TYPE_VIDEO_OUTPUT && | 845 | if (sel->target != V4L2_SEL_TGT_COMPOSE) |
| 862 | (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) { | ||
| 863 | if (streamtype == IVTV_DEC_STREAM_TYPE_YUV) { | ||
| 864 | yi->main_rect = crop->c; | ||
| 865 | return 0; | ||
| 866 | } else { | ||
| 867 | if (!ivtv_vapi(itv, CX2341X_OSD_SET_FRAMEBUFFER_WINDOW, 4, | ||
| 868 | crop->c.width, crop->c.height, crop->c.left, crop->c.top)) { | ||
| 869 | itv->main_rect = crop->c; | ||
| 870 | return 0; | ||
| 871 | } | ||
| 872 | } | ||
| 873 | return -EINVAL; | 846 | return -EINVAL; |
| 847 | |||
| 848 | |||
| 849 | if (sel->type != V4L2_BUF_TYPE_VIDEO_OUTPUT || | ||
| 850 | !(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) | ||
| 851 | return -EINVAL; | ||
| 852 | |||
| 853 | r.height = itv->is_out_50hz ? 576 : 480; | ||
| 854 | if (streamtype == IVTV_DEC_STREAM_TYPE_YUV && yi->track_osd) { | ||
| 855 | r.width = yi->osd_full_w; | ||
| 856 | r.height = yi->osd_full_h; | ||
| 857 | } | ||
| 858 | sel->r.width = clamp(sel->r.width, 16U, r.width); | ||
| 859 | sel->r.height = clamp(sel->r.height, 16U, r.height); | ||
| 860 | sel->r.left = clamp_t(unsigned, sel->r.left, 0, r.width - sel->r.width); | ||
| 861 | sel->r.top = clamp_t(unsigned, sel->r.top, 0, r.height - sel->r.height); | ||
| 862 | |||
| 863 | if (streamtype == IVTV_DEC_STREAM_TYPE_YUV) { | ||
| 864 | yi->main_rect = sel->r; | ||
| 865 | return 0; | ||
| 866 | } | ||
| 867 | if (!ivtv_vapi(itv, CX2341X_OSD_SET_FRAMEBUFFER_WINDOW, 4, | ||
| 868 | sel->r.width, sel->r.height, sel->r.left, sel->r.top)) { | ||
| 869 | itv->main_rect = sel->r; | ||
| 870 | return 0; | ||
| 874 | } | 871 | } |
| 875 | return -EINVAL; | 872 | return -EINVAL; |
| 876 | } | 873 | } |
| 877 | 874 | ||
| 878 | static int ivtv_g_crop(struct file *file, void *fh, struct v4l2_crop *crop) | 875 | static int ivtv_g_selection(struct file *file, void *fh, |
| 876 | struct v4l2_selection *sel) | ||
| 879 | { | 877 | { |
| 880 | struct ivtv_open_id *id = fh2id(fh); | 878 | struct ivtv_open_id *id = fh2id(fh); |
| 881 | struct ivtv *itv = id->itv; | 879 | struct ivtv *itv = id->itv; |
| 882 | struct yuv_playback_info *yi = &itv->yuv_info; | 880 | struct yuv_playback_info *yi = &itv->yuv_info; |
| 883 | int streamtype; | 881 | struct v4l2_rect r = { 0, 0, 720, 0 }; |
| 882 | int streamtype = id->type; | ||
| 883 | |||
| 884 | if (sel->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { | ||
| 885 | switch (sel->target) { | ||
| 886 | case V4L2_SEL_TGT_CROP_DEFAULT: | ||
| 887 | case V4L2_SEL_TGT_CROP_BOUNDS: | ||
| 888 | sel->r.top = sel->r.left = 0; | ||
| 889 | sel->r.width = 720; | ||
| 890 | sel->r.height = itv->is_50hz ? 576 : 480; | ||
| 891 | return 0; | ||
| 892 | default: | ||
| 893 | return -EINVAL; | ||
| 894 | } | ||
| 895 | } | ||
| 884 | 896 | ||
| 885 | streamtype = id->type; | 897 | if (sel->type != V4L2_BUF_TYPE_VIDEO_OUTPUT || |
| 898 | !(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) | ||
| 899 | return -EINVAL; | ||
| 886 | 900 | ||
| 887 | if (crop->type == V4L2_BUF_TYPE_VIDEO_OUTPUT && | 901 | switch (sel->target) { |
| 888 | (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) { | 902 | case V4L2_SEL_TGT_COMPOSE: |
| 889 | if (streamtype == IVTV_DEC_STREAM_TYPE_YUV) | 903 | if (streamtype == IVTV_DEC_STREAM_TYPE_YUV) |
| 890 | crop->c = yi->main_rect; | 904 | sel->r = yi->main_rect; |
| 891 | else | 905 | else |
| 892 | crop->c = itv->main_rect; | 906 | sel->r = itv->main_rect; |
| 907 | return 0; | ||
| 908 | case V4L2_SEL_TGT_COMPOSE_DEFAULT: | ||
| 909 | case V4L2_SEL_TGT_COMPOSE_BOUNDS: | ||
| 910 | r.height = itv->is_out_50hz ? 576 : 480; | ||
| 911 | if (streamtype == IVTV_DEC_STREAM_TYPE_YUV && yi->track_osd) { | ||
| 912 | r.width = yi->osd_full_w; | ||
| 913 | r.height = yi->osd_full_h; | ||
| 914 | } | ||
| 915 | sel->r = r; | ||
| 893 | return 0; | 916 | return 0; |
| 894 | } | 917 | } |
| 895 | return -EINVAL; | 918 | return -EINVAL; |
| @@ -1837,8 +1860,8 @@ static const struct v4l2_ioctl_ops ivtv_ioctl_ops = { | |||
| 1837 | .vidioc_enum_output = ivtv_enum_output, | 1860 | .vidioc_enum_output = ivtv_enum_output, |
| 1838 | .vidioc_enumaudout = ivtv_enumaudout, | 1861 | .vidioc_enumaudout = ivtv_enumaudout, |
| 1839 | .vidioc_cropcap = ivtv_cropcap, | 1862 | .vidioc_cropcap = ivtv_cropcap, |
| 1840 | .vidioc_s_crop = ivtv_s_crop, | 1863 | .vidioc_s_selection = ivtv_s_selection, |
| 1841 | .vidioc_g_crop = ivtv_g_crop, | 1864 | .vidioc_g_selection = ivtv_g_selection, |
| 1842 | .vidioc_g_input = ivtv_g_input, | 1865 | .vidioc_g_input = ivtv_g_input, |
| 1843 | .vidioc_s_input = ivtv_s_input, | 1866 | .vidioc_s_input = ivtv_s_input, |
| 1844 | .vidioc_g_output = ivtv_g_output, | 1867 | .vidioc_g_output = ivtv_g_output, |
