diff options
author | Ricardo Ribalda <ribalda@chromium.org> | 2022-09-20 17:09:50 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2023-01-16 00:45:09 +0300 |
commit | 3bc22dc66a4f386393119118169ed0b78c389898 (patch) | |
tree | eebadfd5ebd533c266192783159470eb18530203 /drivers/media/usb/uvc | |
parent | 41ddb251c68ac75c101d3a50a68c4629c9055e4c (diff) | |
download | linux-3bc22dc66a4f386393119118169ed0b78c389898.tar.xz |
media: uvcvideo: Only create input devs if hw supports it
Examine the stream headers to figure out if the device has a button and
can be used as an input.
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'drivers/media/usb/uvc')
-rw-r--r-- | drivers/media/usb/uvc/uvc_status.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/media/usb/uvc/uvc_status.c b/drivers/media/usb/uvc/uvc_status.c index 7518ffce22ed..cb90aff344bc 100644 --- a/drivers/media/usb/uvc/uvc_status.c +++ b/drivers/media/usb/uvc/uvc_status.c @@ -18,11 +18,34 @@ * Input device */ #ifdef CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV + +static bool uvc_input_has_button(struct uvc_device *dev) +{ + struct uvc_streaming *stream; + + /* + * The device has button events if both bTriggerSupport and + * bTriggerUsage are one. Otherwise the camera button does not + * exist or is handled automatically by the camera without host + * driver or client application intervention. + */ + list_for_each_entry(stream, &dev->streams, list) { + if (stream->header.bTriggerSupport == 1 && + stream->header.bTriggerUsage == 1) + return true; + } + + return false; +} + static int uvc_input_init(struct uvc_device *dev) { struct input_dev *input; int ret; + if (!uvc_input_has_button(dev)) + return 0; + input = input_allocate_device(); if (input == NULL) return -ENOMEM; |