mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ricardo Ribalda <ribalda@chromium.org>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	tfiga@chromium.org, senozhatsky@chromium.org, yunkec@google.com
Cc: Ricardo Ribalda <ribalda@chromium.org>
Subject: [PATCH v7 3/8] media: uvcvideo: Support minimum for V4L2_CTRL_TYPE_MENU
Date: Fri, 17 Jun 2022 12:36:40 +0200	[thread overview]
Message-ID: <20220617103645.71560-4-ribalda@chromium.org> (raw)
In-Reply-To: <20220617103645.71560-1-ribalda@chromium.org>

Currently all mappings of type V4L2_CTRL_TYPE_MENU, have a minimum of 0,
but there are some controls (limited powerline), that start with a value
different than 0.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/usb/uvc/uvc_ctrl.c | 5 +++--
 drivers/media/usb/uvc/uvcvideo.h | 1 +
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index 092decfdaa62..3b20b23abd1e 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -1144,7 +1144,7 @@ static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
 
 	switch (mapping->v4l2_type) {
 	case V4L2_CTRL_TYPE_MENU:
-		v4l2_ctrl->minimum = 0;
+		v4l2_ctrl->minimum = mapping->menu_min;
 		v4l2_ctrl->maximum = mapping->menu_count - 1;
 		v4l2_ctrl->step = 1;
 
@@ -1264,7 +1264,8 @@ int uvc_query_v4l2_menu(struct uvc_video_chain *chain,
 		goto done;
 	}
 
-	if (query_menu->index >= mapping->menu_count) {
+	if (query_menu->index < mapping->menu_min ||
+	    query_menu->index >= mapping->menu_count) {
 		ret = -EINVAL;
 		goto done;
 	}
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index fff5c5c99a3d..6ceb7f7b964d 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -254,6 +254,7 @@ struct uvc_control_mapping {
 	u32 data_type;
 
 	const struct uvc_menu_info *menu_info;
+	u32 menu_min;
 	u32 menu_count;
 
 	u32 master_id;
-- 
2.36.1.476.g0c4daa206d-goog


  parent reply	other threads:[~2022-06-17 10:37 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-17 10:36 [PATCH v7 0/8] uvcvideo: Fix handling of power_line_frequency Ricardo Ribalda
2022-06-17 10:36 ` [PATCH v7 1/8] media: uvcvideo: Add missing value for power_line_frequency Ricardo Ribalda
2022-06-17 10:36 ` [PATCH v7 2/8] media: uvcvideo: Add support for per-device control mapping overrides Ricardo Ribalda
2022-06-17 13:44   ` Laurent Pinchart
2022-06-17 14:07     ` Ricardo Ribalda
2022-06-17 14:40   ` kernel test robot
2022-06-30 11:07   ` Dan Carpenter
2022-06-30 23:16     ` Ricardo Ribalda
2022-07-01  2:31       ` [kbuild-all] " Philip Li
2022-07-01  7:26       ` Dan Carpenter
2022-06-17 10:36 ` Ricardo Ribalda [this message]
2022-06-17 13:49   ` [PATCH v7 3/8] media: uvcvideo: Support minimum for V4L2_CTRL_TYPE_MENU Laurent Pinchart
2022-06-17 13:55     ` Ricardo Ribalda
2022-06-17 14:11       ` Laurent Pinchart
2022-06-17 14:15         ` Ricardo Ribalda
2022-06-17 10:36 ` [PATCH v7 4/8] media: uvcvideo: Limit power line control for Quanta UVC Webcam Ricardo Ribalda
2022-06-17 14:01   ` Laurent Pinchart
2022-06-17 14:18     ` Ricardo Ribalda
2022-06-17 10:36 ` [PATCH v7 5/8] media: uvcvideo: Limit power line control for Chicony Easycamera Ricardo Ribalda
2022-06-17 10:36 ` [PATCH v7 6/8] " Ricardo Ribalda
2022-06-17 10:36 ` [PATCH v7 7/8] media: uvcvideo: Limit power line control for Quanta cameras Ricardo Ribalda
2022-06-17 10:36 ` [PATCH v7 8/8] media: uvcvideo: Limit power line control for Acer EasyCamera 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=20220617103645.71560-4-ribalda@chromium.org \
    --to=ribalda@chromium.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=senozhatsky@chromium.org \
    --cc=tfiga@chromium.org \
    --cc=yunkec@google.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®