Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

media: uvcvideo: let v4l2_query_v4l2_ctrl() work with v4l2_query_ext_ctrl

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>

authored by

Ricardo Ribalda and committed by
Hans Verkuil
1fde21ea 39d2c891

+34 -35
+14 -10
drivers/media/usb/uvc/uvc_ctrl.c
··· 1259 1259 } 1260 1260 1261 1261 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) 1263 1264 { 1264 1265 int idx; 1265 1266 ··· 1408 1407 static int __uvc_queryctrl_boundaries(struct uvc_video_chain *chain, 1409 1408 struct uvc_control *ctrl, 1410 1409 struct uvc_control_mapping *mapping, 1411 - struct v4l2_queryctrl *v4l2_ctrl) 1410 + struct v4l2_query_ext_ctrl *v4l2_ctrl) 1412 1411 { 1413 1412 if (!ctrl->cached) { 1414 1413 int ret = uvc_ctrl_populate_cache(chain, ctrl); ··· 1474 1473 static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain, 1475 1474 struct uvc_control *ctrl, 1476 1475 struct uvc_control_mapping *mapping, 1477 - struct v4l2_queryctrl *v4l2_ctrl) 1476 + struct v4l2_query_ext_ctrl *v4l2_ctrl) 1478 1477 { 1479 1478 struct uvc_control_mapping *master_map = NULL; 1480 1479 struct uvc_control *master_ctrl = NULL; ··· 1512 1511 v4l2_ctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; 1513 1512 } 1514 1513 1514 + v4l2_ctrl->elem_size = sizeof(s32); 1515 + v4l2_ctrl->elems = 1; 1516 + 1515 1517 if (v4l2_ctrl->type >= V4L2_CTRL_COMPOUND_TYPES) { 1516 1518 v4l2_ctrl->flags |= V4L2_CTRL_FLAG_HAS_PAYLOAD; 1517 1519 v4l2_ctrl->default_value = 0; ··· 1528 1524 } 1529 1525 1530 1526 int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain, 1531 - struct v4l2_queryctrl *v4l2_ctrl) 1527 + struct v4l2_query_ext_ctrl *v4l2_ctrl) 1532 1528 { 1533 1529 struct uvc_control *ctrl; 1534 1530 struct uvc_control_mapping *mapping; ··· 1654 1650 struct uvc_control_mapping *mapping, 1655 1651 s32 value, u32 changes) 1656 1652 { 1657 - struct v4l2_queryctrl v4l2_ctrl; 1653 + struct v4l2_query_ext_ctrl v4l2_ctrl; 1658 1654 1659 1655 __uvc_query_v4l2_ctrl(chain, ctrl, mapping, &v4l2_ctrl); 1660 1656 ··· 2179 2175 struct uvc_control_mapping *mapping, 2180 2176 u32 which, struct v4l2_ext_control *xctrl) 2181 2177 { 2182 - struct v4l2_queryctrl qc; 2178 + struct v4l2_query_ext_ctrl qec; 2183 2179 int ret; 2184 2180 2185 2181 switch (which) { ··· 2193 2189 return -EINVAL; 2194 2190 } 2195 2191 2196 - ret = __uvc_queryctrl_boundaries(chain, ctrl, mapping, &qc); 2192 + ret = __uvc_queryctrl_boundaries(chain, ctrl, mapping, &qec); 2197 2193 if (ret < 0) 2198 2194 return ret; 2199 2195 2200 2196 switch (which) { 2201 2197 case V4L2_CTRL_WHICH_DEF_VAL: 2202 - xctrl->value = qc.default_value; 2198 + xctrl->value = qec.default_value; 2203 2199 break; 2204 2200 case V4L2_CTRL_WHICH_MIN_VAL: 2205 - xctrl->value = qc.minimum; 2201 + xctrl->value = qec.minimum; 2206 2202 break; 2207 2203 case V4L2_CTRL_WHICH_MAX_VAL: 2208 - xctrl->value = qc.maximum; 2204 + xctrl->value = qec.maximum; 2209 2205 break; 2210 2206 } 2211 2207
+19 -24
drivers/media/usb/uvc/uvc_v4l2.c
··· 963 963 return ret; 964 964 } 965 965 966 - static int uvc_ioctl_queryctrl(struct file *file, void *fh, 967 - struct v4l2_queryctrl *qc) 968 - { 969 - struct uvc_fh *handle = fh; 970 - struct uvc_video_chain *chain = handle->chain; 971 - 972 - return uvc_query_v4l2_ctrl(chain, qc); 973 - } 974 - 975 966 static int uvc_ioctl_query_ext_ctrl(struct file *file, void *fh, 976 967 struct v4l2_query_ext_ctrl *qec) 977 968 { 978 969 struct uvc_fh *handle = fh; 979 970 struct uvc_video_chain *chain = handle->chain; 980 - struct v4l2_queryctrl qc = { qec->id }; 971 + 972 + return uvc_query_v4l2_ctrl(chain, qec); 973 + } 974 + 975 + static int uvc_ioctl_queryctrl(struct file *file, void *fh, 976 + struct v4l2_queryctrl *qc) 977 + { 978 + struct uvc_fh *handle = fh; 979 + struct uvc_video_chain *chain = handle->chain; 980 + struct v4l2_query_ext_ctrl qec = { qc->id }; 981 981 int ret; 982 982 983 - ret = uvc_query_v4l2_ctrl(chain, &qc); 983 + ret = uvc_query_v4l2_ctrl(chain, &qec); 984 984 if (ret) 985 985 return ret; 986 986 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; 1000 995 1001 996 return 0; 1002 997 }
+1 -1
drivers/media/usb/uvc/uvcvideo.h
··· 771 771 extern const struct v4l2_subscribed_event_ops uvc_ctrl_sub_ev_ops; 772 772 773 773 int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain, 774 - struct v4l2_queryctrl *v4l2_ctrl); 774 + struct v4l2_query_ext_ctrl *v4l2_ctrl); 775 775 int uvc_query_v4l2_menu(struct uvc_video_chain *chain, 776 776 struct v4l2_querymenu *query_menu); 777 777