UPSTREAM: 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> (cherry picked from commit dc6d7e050c1dc2f76d95953dba5217b5b5965640) Bug: 381493003 Bug: 408968367 Change-Id: Ifad8dee78be55281c26995b912c1a0d99b89f3c6 Signed-off-by: Ricardo Ribalda <ribalda@google.com>
This commit is contained in:
committed by
Carlos Llamas
parent
bda9af2d35
commit
4eff0942d4
@@ -1471,6 +1471,14 @@ static int __uvc_queryctrl_boundaries(struct uvc_video_chain *chain,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t uvc_mapping_v4l2_size(struct uvc_control_mapping *mapping)
|
||||
{
|
||||
if (uvc_ctrl_mapping_is_compound(mapping))
|
||||
return DIV_ROUND_UP(mapping->size, 8);
|
||||
|
||||
return sizeof(s32);
|
||||
}
|
||||
|
||||
static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
|
||||
struct uvc_control *ctrl,
|
||||
struct uvc_control_mapping *mapping,
|
||||
@@ -1512,7 +1520,7 @@ 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->elem_size = uvc_mapping_v4l2_size(mapping);
|
||||
v4l2_ctrl->elems = 1;
|
||||
|
||||
if (v4l2_ctrl->type >= V4L2_CTRL_COMPOUND_TYPES) {
|
||||
@@ -2141,7 +2149,7 @@ static int uvc_mapping_get_xctrl_compound(struct uvc_video_chain *chain,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
size = DIV_ROUND_UP(mapping->size, 8);
|
||||
size = uvc_mapping_v4l2_size(mapping);
|
||||
if (xctrl->size < size) {
|
||||
xctrl->size = size;
|
||||
return -ENOSPC;
|
||||
@@ -2324,9 +2332,8 @@ static int uvc_mapping_set_xctrl_compound(struct uvc_control *ctrl,
|
||||
struct v4l2_ext_control *xctrl)
|
||||
{
|
||||
u8 *data __free(kfree) = NULL;
|
||||
size_t size;
|
||||
size_t size = uvc_mapping_v4l2_size(mapping);
|
||||
|
||||
size = DIV_ROUND_UP(mapping->size, 8);
|
||||
if (xctrl->size != size)
|
||||
return -EINVAL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user