All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ricardo Ribalda <ribalda@chromium.org>
To: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Guenter Roeck <linux@roeck-us.net>,
	Max Staudt <mstaudt@google.com>,
	linux-media@vger.kernel.org, Tomasz Figa <tfiga@chromium.org>,
	linux-kernel@vger.kernel.org,
	Alan Stern <stern@rowland.harvard.edu>,
	Ricardo Ribalda <ribalda@chromium.org>,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>
Subject: [PATCH v2 1/8] media: uvcvideo: Only create input devs if hw supports it
Date: Tue, 25 Oct 2022 16:34:22 +0200	[thread overview]
Message-ID: <20220920-resend-powersave-v2-1-5135d1bb1c38@chromium.org> (raw)
In-Reply-To: <20220920-resend-powersave-v2-0-5135d1bb1c38@chromium.org>

Examine the stream headers to figure out if the device has a button and
can be used as an input.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>

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;

-- 
b4 0.11.0-dev-d93f8

  reply	other threads:[~2022-10-25 14:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-25 14:34 [PATCH v2 0/8] [RESEND] media: uvcvideo: Implement granular power management Ricardo Ribalda
2022-10-25 14:34 ` Ricardo Ribalda [this message]
2022-10-25 14:34 ` [PATCH v2 2/8] media: uvcvideo: Refactor streamon/streamoff Ricardo Ribalda
2022-10-25 14:34 ` [PATCH v2 3/8] media: uvcvideo: Do power management granularly Ricardo Ribalda
2022-10-25 14:34 ` [PATCH v2 4/8] media: uvcvideo: Cancel async worker earlier Ricardo Ribalda
2022-10-25 14:34 ` [PATCH v2 5/8] media: uvcvideo: Lock video streams and queues while unregistering Ricardo Ribalda
2022-10-25 14:34 ` [PATCH v2 6/8] media: uvcvideo: Release stream queue when unregistering video device Ricardo Ribalda
2022-10-25 14:34 ` [PATCH v2 7/8] media: uvcvideo: Protect uvc queue file operations against disconnect Ricardo Ribalda
2022-10-25 14:34 ` [PATCH v2 8/8] media: uvcvideo: Only call status ep if hw supports it Ricardo Ribalda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220920-resend-powersave-v2-1-5135d1bb1c38@chromium.org \
    --to=ribalda@chromium.org \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=mchehab@kernel.org \
    --cc=mstaudt@google.com \
    --cc=stern@rowland.harvard.edu \
    --cc=tfiga@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.