Skip to content

Commit 4ae060a

Browse files
author
Desnes Nunes
committed
media: uvcvideo: Introduce uvc_mapping_v4l2_size
JIRA: https://issues.redhat.com/browse/RHEL-78934 commit dc6d7e0 Author: Ricardo Ribalda <ribalda@chromium.org> Date: Mon, 3 Feb 2025 11:55:50 +0000 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> Signed-off-by: Desnes Nunes <desnesn@redhat.com>
1 parent ae4a0d9 commit 4ae060a

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

drivers/media/usb/uvc/uvc_ctrl.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,6 +1471,14 @@ static int __uvc_queryctrl_boundaries(struct uvc_video_chain *chain,
14711471
return 0;
14721472
}
14731473

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+
14741482
static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
14751483
struct uvc_control *ctrl,
14761484
struct uvc_control_mapping *mapping,
@@ -1512,7 +1520,7 @@ static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
15121520
v4l2_ctrl->flags |= V4L2_CTRL_FLAG_INACTIVE;
15131521
}
15141522

1515-
v4l2_ctrl->elem_size = sizeof(s32);
1523+
v4l2_ctrl->elem_size = uvc_mapping_v4l2_size(mapping);
15161524
v4l2_ctrl->elems = 1;
15171525

15181526
if (v4l2_ctrl->type >= V4L2_CTRL_COMPOUND_TYPES) {
@@ -2144,7 +2152,7 @@ static int uvc_mapping_get_xctrl_compound(struct uvc_video_chain *chain,
21442152
return -EINVAL;
21452153
}
21462154

2147-
size = DIV_ROUND_UP(mapping->size, 8);
2155+
size = uvc_mapping_v4l2_size(mapping);
21482156
if (xctrl->size < size) {
21492157
xctrl->size = size;
21502158
return -ENOSPC;
@@ -2327,9 +2335,8 @@ static int uvc_mapping_set_xctrl_compound(struct uvc_control *ctrl,
23272335
struct v4l2_ext_control *xctrl)
23282336
{
23292337
u8 *data __free(kfree) = NULL;
2330-
size_t size;
2338+
size_t size = uvc_mapping_v4l2_size(mapping);
23312339

2332-
size = DIV_ROUND_UP(mapping->size, 8);
23332340
if (xctrl->size != size)
23342341
return -EINVAL;
23352342

0 commit comments

Comments
 (0)