media: v4l2: Fix the _MPLANE format check in v4l_enum_fmt()

CAP_M2M_MPLANE means the device supports _MPLANE formats for both
capture and output. Adjust the check to avoid EINVAL errors on
such devices.

Reported-by: Maxime Jourdan <mjourdan@baylibre.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
Boris Brezillon 2019-06-05 12:46:25 -04:00 committed by Mauro Carvalho Chehab
parent edadd68031
commit f0d2b7a891

View File

@ -1385,6 +1385,7 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,
struct video_device *vdev = video_devdata(file); struct video_device *vdev = video_devdata(file);
struct v4l2_fmtdesc *p = arg; struct v4l2_fmtdesc *p = arg;
int ret = check_fmt(file, p->type); int ret = check_fmt(file, p->type);
u32 cap_mask;
if (ret) if (ret)
return ret; return ret;
@ -1393,7 +1394,9 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,
switch (p->type) { switch (p->type) {
case V4L2_BUF_TYPE_VIDEO_CAPTURE: case V4L2_BUF_TYPE_VIDEO_CAPTURE:
case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
if (!!(vdev->device_caps & V4L2_CAP_VIDEO_CAPTURE_MPLANE) != cap_mask = V4L2_CAP_VIDEO_CAPTURE_MPLANE |
V4L2_CAP_VIDEO_M2M_MPLANE;
if (!!(vdev->device_caps & cap_mask) !=
(p->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)) (p->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE))
break; break;
@ -1408,7 +1411,9 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,
break; break;
case V4L2_BUF_TYPE_VIDEO_OUTPUT: case V4L2_BUF_TYPE_VIDEO_OUTPUT:
case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
if (!!(vdev->device_caps & V4L2_CAP_VIDEO_OUTPUT_MPLANE) != cap_mask = V4L2_CAP_VIDEO_OUTPUT_MPLANE |
V4L2_CAP_VIDEO_M2M_MPLANE;
if (!!(vdev->device_caps & cap_mask) !=
(p->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)) (p->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE))
break; break;