Commit 64ae9958 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

[media] uvcvideo: Fix control value clamping for unsigned integer controls

V4L2 integer controls are stored in signed 32-bit values. However, UVC
controls can be either signed or unsigned. Take the UVC control
signedness into account when clamping the control value to the min-max
range.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 8be8ec6e
...@@ -1455,8 +1455,12 @@ int uvc_ctrl_set(struct uvc_video_chain *chain, ...@@ -1455,8 +1455,12 @@ int uvc_ctrl_set(struct uvc_video_chain *chain,
if (step == 0) if (step == 0)
step = 1; step = 1;
xctrl->value = min + (xctrl->value - min + step/2) / step * step; xctrl->value = min + ((u32)(xctrl->value - min) + step / 2)
xctrl->value = clamp(xctrl->value, min, max); / step * step;
if (mapping->data_type == UVC_CTRL_DATA_TYPE_SIGNED)
xctrl->value = clamp(xctrl->value, min, max);
else
xctrl->value = clamp_t(u32, xctrl->value, min, max);
value = xctrl->value; value = xctrl->value;
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment