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.pinch...@ideasonboard.com>
---
 drivers/media/usb/uvc/uvc_ctrl.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

Hi James,

Does this patch fix your problem ?

diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index 3e0b66e..516a5b1 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,
                if (step == 0)
                        step = 1;
 
-               xctrl->value = min + (xctrl->value - min + step/2) / step * 
step;
-               xctrl->value = clamp(xctrl->value, min, max);
+               xctrl->value = min + ((u32)(xctrl->value - min) + step / 2)
+                            / 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;
                break;
 
-- 
Regards,

Laurent Pinchart

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to