From 679182db691def3b37f16877813048af46aa7a78 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 4 Dec 2017 18:06:01 -0500 Subject: [PATCH] UPSTREAM: media: uvcvideo: Report V4L2 device caps through the video_device structure The V4L2 core populates the struct v4l2_capability device_caps field from the same field in video_device. There's no need to handle that manually in the driver. Change-Id: I5a98bd1ba87a4029e3de74b3ac4c21e90fe6e3a2 Signed-off-by: Laurent Pinchart Reviewed-by: Guennadi Liakhovetski Tested-by: Guennadi Liakhovetski Signed-off-by: Mauro Carvalho Chehab Signed-off-by: William Wu (cherry picked from commit 94c53e26dc74744cc4f9a8ddc593b7aef96ba764) --- drivers/media/usb/uvc/uvc_driver.c | 11 +++++++++++ drivers/media/usb/uvc/uvc_v4l2.c | 4 ---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index a5fcbdcac1dd..60276d3eba09 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -1886,6 +1886,17 @@ int uvc_register_video_device(struct uvc_device *dev, vdev->vfl_dir = VFL_DIR_TX; else vdev->vfl_dir = VFL_DIR_RX; + + switch (type) { + case V4L2_BUF_TYPE_VIDEO_CAPTURE: + default: + vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; + break; + case V4L2_BUF_TYPE_VIDEO_OUTPUT: + vdev->device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING; + break; + } + strlcpy(vdev->name, dev->name, sizeof vdev->name); /* diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index 0e7d16fe84d4..16971cab03a6 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c @@ -558,10 +558,6 @@ static int uvc_ioctl_querycap(struct file *file, void *fh, usb_make_path(stream->dev->udev, cap->bus_info, sizeof(cap->bus_info)); cap->capabilities = V4L2_CAP_DEVICE_CAPS | V4L2_CAP_STREAMING | chain->caps; - if (stream->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) - cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; - else - cap->device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING; return 0; }