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: Introduce uvc_mapping_v4l2_size

Centralize the calculation for the v4l2_size of a mapping.

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-14-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
dc6d7e05 1fde21ea

+11 -4
+11 -4
drivers/media/usb/uvc/uvc_ctrl.c
··· 1471 1471 return 0; 1472 1472 } 1473 1473 1474 + static size_t uvc_mapping_v4l2_size(struct uvc_control_mapping *mapping) 1475 + { 1476 + if (uvc_ctrl_mapping_is_compound(mapping)) 1477 + return DIV_ROUND_UP(mapping->size, 8); 1478 + 1479 + return sizeof(s32); 1480 + } 1481 + 1474 1482 static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain, 1475 1483 struct uvc_control *ctrl, 1476 1484 struct uvc_control_mapping *mapping, ··· 1520 1512 v4l2_ctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; 1521 1513 } 1522 1514 1523 - v4l2_ctrl->elem_size = sizeof(s32); 1515 + v4l2_ctrl->elem_size = uvc_mapping_v4l2_size(mapping); 1524 1516 v4l2_ctrl->elems = 1; 1525 1517 1526 1518 if (v4l2_ctrl->type >= V4L2_CTRL_COMPOUND_TYPES) { ··· 2152 2144 return -EINVAL; 2153 2145 } 2154 2146 2155 - size = DIV_ROUND_UP(mapping->size, 8); 2147 + size = uvc_mapping_v4l2_size(mapping); 2156 2148 if (xctrl->size < size) { 2157 2149 xctrl->size = size; 2158 2150 return -ENOSPC; ··· 2335 2327 struct v4l2_ext_control *xctrl) 2336 2328 { 2337 2329 u8 *data __free(kfree) = NULL; 2338 - size_t size; 2330 + size_t size = uvc_mapping_v4l2_size(mapping); 2339 2331 2340 - size = DIV_ROUND_UP(mapping->size, 8); 2341 2332 if (xctrl->size != size) 2342 2333 return -EINVAL; 2343 2334