diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2015-04-03 05:53:42 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-04-10 09:26:02 -0400 |
commit | 1461fe7ab6e61c4ad59f54e308872c0bae09d609 (patch) | |
tree | 2beb3957c7edc8c425ed6a5e45f7a2f88e9acae3 /drivers/media/usb/uvc/uvc_v4l2.c | |
parent | befd25a2bd61f1706508280f705e18be8b283e3e (diff) |
[media] uvcvideo: fix cropcap v4l2-compliance failure
The v4l2-compliance tool expects that if VIDIOC_CROPCAP is defined, then
VIDIOC_G_SELECTION for TGT_CROP_BOUNDS/DEFAULT is also defined (or COMPOSE
in the case of an output device).
In fact, all that a driver has to do to implement cropcap is to support
those two targets since the v4l2 core will implement cropcap and fill in
the pixelaspect to 1/1 by default.
Implementing cropcap is only needed if the pixelaspect isn't square.
So implement g_selection instead of cropcap in uvc to fix the v4l2-compliance
failure.
[Added blank lines for improved readability]
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/usb/uvc/uvc_v4l2.c')
-rw-r--r-- | drivers/media/usb/uvc/uvc_v4l2.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index b6a09835e7aa..927d579e574a 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c | |||
@@ -1018,26 +1018,37 @@ static int uvc_ioctl_querymenu(struct file *file, void *fh, | |||
1018 | return uvc_query_v4l2_menu(chain, qm); | 1018 | return uvc_query_v4l2_menu(chain, qm); |
1019 | } | 1019 | } |
1020 | 1020 | ||
1021 | static int uvc_ioctl_cropcap(struct file *file, void *fh, | 1021 | static int uvc_ioctl_g_selection(struct file *file, void *fh, |
1022 | struct v4l2_cropcap *ccap) | 1022 | struct v4l2_selection *sel) |
1023 | { | 1023 | { |
1024 | struct uvc_fh *handle = fh; | 1024 | struct uvc_fh *handle = fh; |
1025 | struct uvc_streaming *stream = handle->stream; | 1025 | struct uvc_streaming *stream = handle->stream; |
1026 | 1026 | ||
1027 | if (ccap->type != stream->type) | 1027 | if (sel->type != stream->type) |
1028 | return -EINVAL; | 1028 | return -EINVAL; |
1029 | 1029 | ||
1030 | ccap->bounds.left = 0; | 1030 | switch (sel->target) { |
1031 | ccap->bounds.top = 0; | 1031 | case V4L2_SEL_TGT_CROP_DEFAULT: |
1032 | case V4L2_SEL_TGT_CROP_BOUNDS: | ||
1033 | if (stream->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
1034 | return -EINVAL; | ||
1035 | break; | ||
1036 | case V4L2_SEL_TGT_COMPOSE_DEFAULT: | ||
1037 | case V4L2_SEL_TGT_COMPOSE_BOUNDS: | ||
1038 | if (stream->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) | ||
1039 | return -EINVAL; | ||
1040 | break; | ||
1041 | default: | ||
1042 | return -EINVAL; | ||
1043 | } | ||
1044 | |||
1045 | sel->r.left = 0; | ||
1046 | sel->r.top = 0; | ||
1032 | mutex_lock(&stream->mutex); | 1047 | mutex_lock(&stream->mutex); |
1033 | ccap->bounds.width = stream->cur_frame->wWidth; | 1048 | sel->r.width = stream->cur_frame->wWidth; |
1034 | ccap->bounds.height = stream->cur_frame->wHeight; | 1049 | sel->r.height = stream->cur_frame->wHeight; |
1035 | mutex_unlock(&stream->mutex); | 1050 | mutex_unlock(&stream->mutex); |
1036 | 1051 | ||
1037 | ccap->defrect = ccap->bounds; | ||
1038 | |||
1039 | ccap->pixelaspect.numerator = 1; | ||
1040 | ccap->pixelaspect.denominator = 1; | ||
1041 | return 0; | 1052 | return 0; |
1042 | } | 1053 | } |
1043 | 1054 | ||
@@ -1452,7 +1463,7 @@ const struct v4l2_ioctl_ops uvc_ioctl_ops = { | |||
1452 | .vidioc_s_ext_ctrls = uvc_ioctl_s_ext_ctrls, | 1463 | .vidioc_s_ext_ctrls = uvc_ioctl_s_ext_ctrls, |
1453 | .vidioc_try_ext_ctrls = uvc_ioctl_try_ext_ctrls, | 1464 | .vidioc_try_ext_ctrls = uvc_ioctl_try_ext_ctrls, |
1454 | .vidioc_querymenu = uvc_ioctl_querymenu, | 1465 | .vidioc_querymenu = uvc_ioctl_querymenu, |
1455 | .vidioc_cropcap = uvc_ioctl_cropcap, | 1466 | .vidioc_g_selection = uvc_ioctl_g_selection, |
1456 | .vidioc_g_parm = uvc_ioctl_g_parm, | 1467 | .vidioc_g_parm = uvc_ioctl_g_parm, |
1457 | .vidioc_s_parm = uvc_ioctl_s_parm, | 1468 | .vidioc_s_parm = uvc_ioctl_s_parm, |
1458 | .vidioc_enum_framesizes = uvc_ioctl_enum_framesizes, | 1469 | .vidioc_enum_framesizes = uvc_ioctl_enum_framesizes, |