Skip to content

Commit ae4a0d9

Browse files
author
Desnes Nunes
committed
media: uvcvideo: let v4l2_query_v4l2_ctrl() work with v4l2_query_ext_ctrl
JIRA: https://issues.redhat.com/browse/RHEL-78934 commit 1fde21e Author: Ricardo Ribalda <ribalda@chromium.org> Date: Mon, 3 Feb 2025 11:55:49 +0000 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> Link: https://lore.kernel.org/r/20250203-uvc-roi-v17-13-5900a9fed613@chromium.org Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Desnes Nunes <desnesn@redhat.com>
1 parent 8e76cce commit ae4a0d9

File tree

3 files changed

+30
-31
lines changed

3 files changed

+30
-31
lines changed

drivers/media/usb/uvc/uvc_ctrl.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,8 @@ static int __uvc_query_v4l2_class(struct uvc_video_chain *chain, u32 req_id,
12591259
}
12601260

12611261
static int uvc_query_v4l2_class(struct uvc_video_chain *chain, u32 req_id,
1262-
u32 found_id, struct v4l2_queryctrl *v4l2_ctrl)
1262+
u32 found_id,
1263+
struct v4l2_query_ext_ctrl *v4l2_ctrl)
12631264
{
12641265
int idx;
12651266

@@ -1407,7 +1408,7 @@ static u32 uvc_get_ctrl_bitmap(struct uvc_control *ctrl,
14071408
static int __uvc_queryctrl_boundaries(struct uvc_video_chain *chain,
14081409
struct uvc_control *ctrl,
14091410
struct uvc_control_mapping *mapping,
1410-
struct v4l2_queryctrl *v4l2_ctrl)
1411+
struct v4l2_query_ext_ctrl *v4l2_ctrl)
14111412
{
14121413
if (!ctrl->cached) {
14131414
int ret = uvc_ctrl_populate_cache(chain, ctrl);
@@ -1473,7 +1474,7 @@ static int __uvc_queryctrl_boundaries(struct uvc_video_chain *chain,
14731474
static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
14741475
struct uvc_control *ctrl,
14751476
struct uvc_control_mapping *mapping,
1476-
struct v4l2_queryctrl *v4l2_ctrl)
1477+
struct v4l2_query_ext_ctrl *v4l2_ctrl)
14771478
{
14781479
struct uvc_control_mapping *master_map = NULL;
14791480
struct uvc_control *master_ctrl = NULL;
@@ -1511,6 +1512,9 @@ static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
15111512
v4l2_ctrl->flags |= V4L2_CTRL_FLAG_INACTIVE;
15121513
}
15131514

1515+
v4l2_ctrl->elem_size = sizeof(s32);
1516+
v4l2_ctrl->elems = 1;
1517+
15141518
if (v4l2_ctrl->type >= V4L2_CTRL_COMPOUND_TYPES) {
15151519
v4l2_ctrl->flags |= V4L2_CTRL_FLAG_HAS_PAYLOAD;
15161520
v4l2_ctrl->default_value = 0;
@@ -1524,7 +1528,7 @@ static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
15241528
}
15251529

15261530
int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
1527-
struct v4l2_queryctrl *v4l2_ctrl)
1531+
struct v4l2_query_ext_ctrl *v4l2_ctrl)
15281532
{
15291533
struct uvc_control *ctrl;
15301534
struct uvc_control_mapping *mapping;
@@ -1650,7 +1654,7 @@ static void uvc_ctrl_fill_event(struct uvc_video_chain *chain,
16501654
struct uvc_control_mapping *mapping,
16511655
s32 value, u32 changes)
16521656
{
1653-
struct v4l2_queryctrl v4l2_ctrl;
1657+
struct v4l2_query_ext_ctrl v4l2_ctrl;
16541658

16551659
__uvc_query_v4l2_ctrl(chain, ctrl, mapping, &v4l2_ctrl);
16561660

@@ -2175,7 +2179,7 @@ static int uvc_mapping_get_xctrl_std(struct uvc_video_chain *chain,
21752179
struct uvc_control_mapping *mapping,
21762180
u32 which, struct v4l2_ext_control *xctrl)
21772181
{
2178-
struct v4l2_queryctrl qc;
2182+
struct v4l2_query_ext_ctrl qec;
21792183
int ret;
21802184

21812185
switch (which) {
@@ -2189,19 +2193,19 @@ static int uvc_mapping_get_xctrl_std(struct uvc_video_chain *chain,
21892193
return -EINVAL;
21902194
}
21912195

2192-
ret = __uvc_queryctrl_boundaries(chain, ctrl, mapping, &qc);
2196+
ret = __uvc_queryctrl_boundaries(chain, ctrl, mapping, &qec);
21932197
if (ret < 0)
21942198
return ret;
21952199

21962200
switch (which) {
21972201
case V4L2_CTRL_WHICH_DEF_VAL:
2198-
xctrl->value = qc.default_value;
2202+
xctrl->value = qec.default_value;
21992203
break;
22002204
case V4L2_CTRL_WHICH_MIN_VAL:
2201-
xctrl->value = qc.minimum;
2205+
xctrl->value = qec.minimum;
22022206
break;
22032207
case V4L2_CTRL_WHICH_MAX_VAL:
2204-
xctrl->value = qc.maximum;
2208+
xctrl->value = qec.maximum;
22052209
break;
22062210
}
22072211

drivers/media/usb/uvc/uvc_v4l2.c

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -963,40 +963,35 @@ static int uvc_ioctl_s_input(struct file *file, void *fh, unsigned int input)
963963
return ret;
964964
}
965965

966-
static int uvc_ioctl_queryctrl(struct file *file, void *fh,
967-
struct v4l2_queryctrl *qc)
966+
static int uvc_ioctl_query_ext_ctrl(struct file *file, void *fh,
967+
struct v4l2_query_ext_ctrl *qec)
968968
{
969969
struct uvc_fh *handle = fh;
970970
struct uvc_video_chain *chain = handle->chain;
971971

972-
return uvc_query_v4l2_ctrl(chain, qc);
972+
return uvc_query_v4l2_ctrl(chain, qec);
973973
}
974974

975-
static int uvc_ioctl_query_ext_ctrl(struct file *file, void *fh,
976-
struct v4l2_query_ext_ctrl *qec)
975+
static int uvc_ioctl_queryctrl(struct file *file, void *fh,
976+
struct v4l2_queryctrl *qc)
977977
{
978978
struct uvc_fh *handle = fh;
979979
struct uvc_video_chain *chain = handle->chain;
980-
struct v4l2_queryctrl qc = { qec->id };
980+
struct v4l2_query_ext_ctrl qec = { qc->id };
981981
int ret;
982982

983-
ret = uvc_query_v4l2_ctrl(chain, &qc);
983+
ret = uvc_query_v4l2_ctrl(chain, &qec);
984984
if (ret)
985985
return ret;
986986

987-
qec->id = qc.id;
988-
qec->type = qc.type;
989-
strscpy(qec->name, qc.name, sizeof(qec->name));
990-
qec->minimum = qc.minimum;
991-
qec->maximum = qc.maximum;
992-
qec->step = qc.step;
993-
qec->default_value = qc.default_value;
994-
qec->flags = qc.flags;
995-
qec->elem_size = 4;
996-
qec->elems = 1;
997-
qec->nr_of_dims = 0;
998-
memset(qec->dims, 0, sizeof(qec->dims));
999-
memset(qec->reserved, 0, sizeof(qec->reserved));
987+
qc->id = qec.id;
988+
qc->type = qec.type;
989+
strscpy(qc->name, qec.name, sizeof(qc->name));
990+
qc->minimum = qec.minimum;
991+
qc->maximum = qec.maximum;
992+
qc->step = qec.step;
993+
qc->default_value = qec.default_value;
994+
qc->flags = qec.flags;
1000995

1001996
return 0;
1002997
}

drivers/media/usb/uvc/uvcvideo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ void uvc_status_put(struct uvc_device *dev);
771771
extern const struct v4l2_subscribed_event_ops uvc_ctrl_sub_ev_ops;
772772

773773
int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
774-
struct v4l2_queryctrl *v4l2_ctrl);
774+
struct v4l2_query_ext_ctrl *v4l2_ctrl);
775775
int uvc_query_v4l2_menu(struct uvc_video_chain *chain,
776776
struct v4l2_querymenu *query_menu);
777777

0 commit comments

Comments
 (0)