diff mbox

[v1,11/19] uvcvideo: Support V4L2_CTRL_TYPE_BITMASK controls.

Message ID 1377829038-4726-12-git-send-email-posciak@chromium.org (mailing list archive)
State New, archived
Headers show

Commit Message

Pawel Osciak Aug. 30, 2013, 2:17 a.m. UTC
Signed-off-by: Pawel Osciak <posciak@chromium.org>
---
 drivers/media/usb/uvc/uvc_ctrl.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Laurent Pinchart Nov. 10, 2013, 10:57 p.m. UTC | #1
Hi Pawel,

Thank you for the patcj.

On Friday 30 August 2013 11:17:10 Pawel Osciak wrote:

Maybe a commit message here too ?

> Signed-off-by: Pawel Osciak <posciak@chromium.org>
> ---
>  drivers/media/usb/uvc/uvc_ctrl.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/drivers/media/usb/uvc/uvc_ctrl.c
> b/drivers/media/usb/uvc/uvc_ctrl.c index b0a19b9..a0493d6 100644
> --- a/drivers/media/usb/uvc/uvc_ctrl.c
> +++ b/drivers/media/usb/uvc/uvc_ctrl.c
> @@ -1550,6 +1550,24 @@ int uvc_ctrl_set(struct uvc_video_chain *chain,
> struct v4l2_ext_control *xctrl,
> 
>  		break;
> 
> +	case V4L2_CTRL_TYPE_BITMASK:
> +		value = xctrl->value;
> +
> +		/* If GET_RES is supported, it will return a bitmask of bits
> +		 * that can be set. If it isn't, allow any value.
> +		 */
> +		if (ctrl->info.flags & UVC_CTRL_FLAG_GET_RES) {
> +			if (!ctrl->cached) {
> +				ret = uvc_ctrl_populate_cache(chain, ctrl);
> +				if (ret < 0)
> +					return ret;
> +			}
> +			step = mapping->get(mapping, UVC_GET_RES,
> +					uvc_ctrl_data(ctrl, UVC_CTRL_DATA_RES));
> +			if (value & ~step)
> +				return -ERANGE;
> +		}

Missing break ?

> +
>  	default:
>  		value = xctrl->value;
>  		break;
diff mbox

Patch

diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index b0a19b9..a0493d6 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -1550,6 +1550,24 @@  int uvc_ctrl_set(struct uvc_video_chain *chain, struct v4l2_ext_control *xctrl,
 
 		break;
 
+	case V4L2_CTRL_TYPE_BITMASK:
+		value = xctrl->value;
+
+		/* If GET_RES is supported, it will return a bitmask of bits
+		 * that can be set. If it isn't, allow any value.
+		 */
+		if (ctrl->info.flags & UVC_CTRL_FLAG_GET_RES) {
+			if (!ctrl->cached) {
+				ret = uvc_ctrl_populate_cache(chain, ctrl);
+				if (ret < 0)
+					return ret;
+			}
+			step = mapping->get(mapping, UVC_GET_RES,
+					uvc_ctrl_data(ctrl, UVC_CTRL_DATA_RES));
+			if (value & ~step)
+				return -ERANGE;
+		}
+
 	default:
 		value = xctrl->value;
 		break;