From: Ricardo Ribalda <ribalda@chromium.org>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans de Goede <hdegoede@redhat.com>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Hans Verkuil <hverkuil@xs4all.nl>
Cc: Yunke Cao <yunkec@chromium.org>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Ricardo Ribalda <ribalda@chromium.org>,
Yunke Cao <yunkec@google.com>
Subject: [PATCH v17 13/17] media: uvcvideo: let v4l2_query_v4l2_ctrl() work with v4l2_query_ext_ctrl
Date: Mon, 03 Feb 2025 11:55:49 +0000 [thread overview]
Message-ID: <20250203-uvc-roi-v17-13-5900a9fed613@chromium.org> (raw)
In-Reply-To: <20250203-uvc-roi-v17-0-5900a9fed613@chromium.org>
v4l2_query_ext_ctrl contains information that is missing in
v4l2_queryctrl, like elem_size and elems.
With this change we can handle all the element_size information inside
uvc_ctrl.c.
Now that we are at it, remove the memset of the reserved fields, the
v4l2 ioctl handler should do that for us.
There is no functional change expected from this change.
Reviewed-by: Yunke Cao <yunkec@google.com>
Tested-by: Yunke Cao <yunkec@google.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
drivers/media/usb/uvc/uvc_ctrl.c | 24 ++++++++++++++----------
drivers/media/usb/uvc/uvc_v4l2.c | 35 +++++++++++++++--------------------
drivers/media/usb/uvc/uvcvideo.h | 2 +-
3 files changed, 30 insertions(+), 31 deletions(-)
diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index 4e29db334b2d..d50137d19561 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -1259,7 +1259,8 @@ static int __uvc_query_v4l2_class(struct uvc_video_chain *chain, u32 req_id,
}
static int uvc_query_v4l2_class(struct uvc_video_chain *chain, u32 req_id,
- u32 found_id, struct v4l2_queryctrl *v4l2_ctrl)
+ u32 found_id,
+ struct v4l2_query_ext_ctrl *v4l2_ctrl)
{
int idx;
@@ -1407,7 +1408,7 @@ static u32 uvc_get_ctrl_bitmap(struct uvc_control *ctrl,
static int __uvc_queryctrl_boundaries(struct uvc_video_chain *chain,
struct uvc_control *ctrl,
struct uvc_control_mapping *mapping,
- struct v4l2_queryctrl *v4l2_ctrl)
+ struct v4l2_query_ext_ctrl *v4l2_ctrl)
{
if (!ctrl->cached) {
int ret = uvc_ctrl_populate_cache(chain, ctrl);
@@ -1473,7 +1474,7 @@ static int __uvc_queryctrl_boundaries(struct uvc_video_chain *chain,
static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
struct uvc_control *ctrl,
struct uvc_control_mapping *mapping,
- struct v4l2_queryctrl *v4l2_ctrl)
+ struct v4l2_query_ext_ctrl *v4l2_ctrl)
{
struct uvc_control_mapping *master_map = NULL;
struct uvc_control *master_ctrl = NULL;
@@ -1511,6 +1512,9 @@ static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
v4l2_ctrl->flags |= V4L2_CTRL_FLAG_INACTIVE;
}
+ v4l2_ctrl->elem_size = sizeof(s32);
+ v4l2_ctrl->elems = 1;
+
if (v4l2_ctrl->type >= V4L2_CTRL_COMPOUND_TYPES) {
v4l2_ctrl->flags |= V4L2_CTRL_FLAG_HAS_PAYLOAD;
v4l2_ctrl->default_value = 0;
@@ -1524,7 +1528,7 @@ static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
}
int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
- struct v4l2_queryctrl *v4l2_ctrl)
+ struct v4l2_query_ext_ctrl *v4l2_ctrl)
{
struct uvc_control *ctrl;
struct uvc_control_mapping *mapping;
@@ -1650,7 +1654,7 @@ static void uvc_ctrl_fill_event(struct uvc_video_chain *chain,
struct uvc_control_mapping *mapping,
s32 value, u32 changes)
{
- struct v4l2_queryctrl v4l2_ctrl;
+ struct v4l2_query_ext_ctrl v4l2_ctrl;
__uvc_query_v4l2_ctrl(chain, ctrl, mapping, &v4l2_ctrl);
@@ -2175,7 +2179,7 @@ static int uvc_mapping_get_xctrl_std(struct uvc_video_chain *chain,
struct uvc_control_mapping *mapping,
u32 which, struct v4l2_ext_control *xctrl)
{
- struct v4l2_queryctrl qc;
+ struct v4l2_query_ext_ctrl qec;
int ret;
switch (which) {
@@ -2189,19 +2193,19 @@ static int uvc_mapping_get_xctrl_std(struct uvc_video_chain *chain,
return -EINVAL;
}
- ret = __uvc_queryctrl_boundaries(chain, ctrl, mapping, &qc);
+ ret = __uvc_queryctrl_boundaries(chain, ctrl, mapping, &qec);
if (ret < 0)
return ret;
switch (which) {
case V4L2_CTRL_WHICH_DEF_VAL:
- xctrl->value = qc.default_value;
+ xctrl->value = qec.default_value;
break;
case V4L2_CTRL_WHICH_MIN_VAL:
- xctrl->value = qc.minimum;
+ xctrl->value = qec.minimum;
break;
case V4L2_CTRL_WHICH_MAX_VAL:
- xctrl->value = qc.maximum;
+ xctrl->value = qec.maximum;
break;
}
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index ff7d0fd9e458..41430720ed47 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -963,40 +963,35 @@ static int uvc_ioctl_s_input(struct file *file, void *fh, unsigned int input)
return ret;
}
-static int uvc_ioctl_queryctrl(struct file *file, void *fh,
- struct v4l2_queryctrl *qc)
+static int uvc_ioctl_query_ext_ctrl(struct file *file, void *fh,
+ struct v4l2_query_ext_ctrl *qec)
{
struct uvc_fh *handle = fh;
struct uvc_video_chain *chain = handle->chain;
- return uvc_query_v4l2_ctrl(chain, qc);
+ return uvc_query_v4l2_ctrl(chain, qec);
}
-static int uvc_ioctl_query_ext_ctrl(struct file *file, void *fh,
- struct v4l2_query_ext_ctrl *qec)
+static int uvc_ioctl_queryctrl(struct file *file, void *fh,
+ struct v4l2_queryctrl *qc)
{
struct uvc_fh *handle = fh;
struct uvc_video_chain *chain = handle->chain;
- struct v4l2_queryctrl qc = { qec->id };
+ struct v4l2_query_ext_ctrl qec = { qc->id };
int ret;
- ret = uvc_query_v4l2_ctrl(chain, &qc);
+ ret = uvc_query_v4l2_ctrl(chain, &qec);
if (ret)
return ret;
- qec->id = qc.id;
- qec->type = qc.type;
- strscpy(qec->name, qc.name, sizeof(qec->name));
- qec->minimum = qc.minimum;
- qec->maximum = qc.maximum;
- qec->step = qc.step;
- qec->default_value = qc.default_value;
- qec->flags = qc.flags;
- qec->elem_size = 4;
- qec->elems = 1;
- qec->nr_of_dims = 0;
- memset(qec->dims, 0, sizeof(qec->dims));
- memset(qec->reserved, 0, sizeof(qec->reserved));
+ qc->id = qec.id;
+ qc->type = qec.type;
+ strscpy(qc->name, qec.name, sizeof(qc->name));
+ qc->minimum = qec.minimum;
+ qc->maximum = qec.maximum;
+ qc->step = qec.step;
+ qc->default_value = qec.default_value;
+ qc->flags = qec.flags;
return 0;
}
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index 2f9a1bf8b48a..6fc1cb9e99d1 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -771,7 +771,7 @@ void uvc_status_put(struct uvc_device *dev);
extern const struct v4l2_subscribed_event_ops uvc_ctrl_sub_ev_ops;
int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
- struct v4l2_queryctrl *v4l2_ctrl);
+ struct v4l2_query_ext_ctrl *v4l2_ctrl);
int uvc_query_v4l2_menu(struct uvc_video_chain *chain,
struct v4l2_querymenu *query_menu);
--
2.48.1.362.g079036d154-goog
next prev parent reply other threads:[~2025-02-03 11:56 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-03 11:55 [PATCH v17 00/17] media: uvcvideo: Implement UVC v1.5 ROI Ricardo Ribalda
2025-02-03 11:55 ` [PATCH v17 01/17] media: v4l2_ctrl: Add V4L2_CTRL_TYPE_RECT Ricardo Ribalda
2025-02-03 11:55 ` [PATCH v17 02/17] media: v4l2-ctrls: add support for V4L2_CTRL_WHICH_MIN/MAX_VAL Ricardo Ribalda
2025-02-03 11:55 ` [PATCH v17 03/17] media: vivid: Add a rectangle control Ricardo Ribalda
2025-02-03 11:55 ` [PATCH v17 04/17] media: uvcvideo: Handle uvc menu translation inside uvc_get_le_value Ricardo Ribalda
2025-02-03 11:55 ` [PATCH v17 05/17] media: uvcvideo: Handle uvc menu translation inside uvc_set_le_value Ricardo Ribalda
2025-02-03 11:55 ` [PATCH v17 06/17] media: uvcvideo: refactor uvc_ioctl_g_ext_ctrls Ricardo Ribalda
2025-02-03 11:55 ` [PATCH v17 07/17] media: uvcvideo: uvc_ioctl_(g|s)_ext_ctrls: handle NoP case Ricardo Ribalda
2025-02-03 11:55 ` [PATCH v17 08/17] media: uvcvideo: Support any size for mapping get/set Ricardo Ribalda
2025-02-03 11:55 ` [PATCH v17 09/17] media: uvcvideo: Factor out clamping from uvc_ctrl_set Ricardo Ribalda
2025-02-03 11:55 ` [PATCH v17 10/17] media: uvcvideo: add support for compound controls Ricardo Ribalda
2025-02-03 11:55 ` [PATCH v17 11/17] media: uvcvideo: Factor out query_boundaries from query_ctrl Ricardo Ribalda
2025-02-03 11:55 ` [PATCH v17 12/17] media: uvcvideo: support V4L2_CTRL_WHICH_MIN/MAX_VAL Ricardo Ribalda
2025-02-03 11:55 ` Ricardo Ribalda [this message]
2025-02-03 11:55 ` [PATCH v17 14/17] media: uvcvideo: Introduce uvc_mapping_v4l2_size Ricardo Ribalda
2025-02-03 11:55 ` [PATCH v17 15/17] media: uvcvideo: Add sanity check to uvc_ioctl_xu_ctrl_map Ricardo Ribalda
2025-02-03 11:55 ` [PATCH v17 16/17] media: uvcvideo: implement UVC v1.5 ROI Ricardo Ribalda
2025-03-03 13:32 ` Hans Verkuil
2025-03-03 14:02 ` Hans de Goede
2025-03-03 14:58 ` Hans Verkuil
2025-03-03 16:06 ` Ricardo Ribalda
2025-02-03 11:55 ` [PATCH v17 17/17] media: uvcvideo: document " Ricardo Ribalda
2025-02-10 16:07 ` [PATCH v17 00/17] media: uvcvideo: Implement " Hans de Goede
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=20250203-uvc-roi-v17-13-5900a9fed613@chromium.org \
--to=ribalda@chromium.org \
--cc=hdegoede@redhat.com \
--cc=hverkuil@xs4all.nl \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=yunkec@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®