aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-09-26 07:15:24 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-11-28 07:31:14 -0500
commit64ae9958a623708336ed67fe38c33571390aed1e (patch)
tree5627e3ef1ab2e1dbe6093f60b9705cbe119d41ef /drivers/media
parent8be8ec6ea58bd77338f6ffa2f6d2acfc88b835f4 (diff)
[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: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/usb/uvc/uvc_ctrl.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index 3e0b66efc9ba..516a5b188ea5 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -1455,8 +1455,12 @@ int uvc_ctrl_set(struct uvc_video_chain *chain,
1455 if (step == 0) 1455 if (step == 0)
1456 step = 1; 1456 step = 1;
1457 1457
1458 xctrl->value = min + (xctrl->value - min + step/2) / step * step; 1458 xctrl->value = min + ((u32)(xctrl->value - min) + step / 2)
1459 xctrl->value = clamp(xctrl->value, min, max); 1459 / step * step;
1460 if (mapping->data_type == UVC_CTRL_DATA_TYPE_SIGNED)
1461 xctrl->value = clamp(xctrl->value, min, max);
1462 else
1463 xctrl->value = clamp_t(u32, xctrl->value, min, max);
1460 value = xctrl->value; 1464 value = xctrl->value;
1461 break; 1465 break;
1462 1466