All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: uvcvideo: Prevent setting unavailable flags
@ 2018-03-21 15:43 Kieran Bingham
  2018-03-21 22:04 ` Laurent Pinchart
  2018-04-11 19:32 ` Guennadi Liakhovetski
  0 siblings, 2 replies; 3+ messages in thread
From: Kieran Bingham @ 2018-03-21 15:43 UTC (permalink / raw)
  To: linux-media, Laurent Pinchart, Edgar Thier
  Cc: Kieran Bingham, Mauro Carvalho Chehab, open list

The addition of an extra operation to use the GET_INFO command
overwrites all existing flags from the uvc_ctrls table. This includes
setting all controls as supporting  GET_MIN, GET_MAX, GET_RES, and
GET_DEF regardless of whether they do or not.

Move the initialisation of these control capabilities directly to the
uvc_ctrl_fill_xu_info() call where they were originally located in that
use case, and ensure that the new functionality in uvc_ctrl_get_flags()
will only set flags based on their reported capability from the GET_INFO
call.

Fixes: 859086ae3636 ("media: uvcvideo: Apply flags from device to actual
properties")

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 drivers/media/usb/uvc/uvc_ctrl.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index 1daf444371be..4042cbdb721b 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -1607,14 +1607,12 @@ static int uvc_ctrl_get_flags(struct uvc_device *dev,
 	ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id, dev->intfnum,
 			     info->selector, data, 1);
 	if (!ret)
-		info->flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX
-			    | UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF
-			    | (data[0] & UVC_CONTROL_CAP_GET ?
-			       UVC_CTRL_FLAG_GET_CUR : 0)
-			    | (data[0] & UVC_CONTROL_CAP_SET ?
-			       UVC_CTRL_FLAG_SET_CUR : 0)
-			    | (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ?
-			       UVC_CTRL_FLAG_AUTO_UPDATE : 0);
+		info->flags |= (data[0] & UVC_CONTROL_CAP_GET ?
+				UVC_CTRL_FLAG_GET_CUR : 0)
+			    |  (data[0] & UVC_CONTROL_CAP_SET ?
+				UVC_CTRL_FLAG_SET_CUR : 0)
+			    |  (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ?
+				UVC_CTRL_FLAG_AUTO_UPDATE : 0);
 
 	kfree(data);
 	return ret;
@@ -1689,6 +1687,9 @@ static int uvc_ctrl_fill_xu_info(struct uvc_device *dev,
 
 	info->size = le16_to_cpup((__le16 *)data);
 
+	info->flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX
+		    | UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF;
+
 	ret = uvc_ctrl_get_flags(dev, ctrl, info);
 	if (ret < 0) {
 		uvc_trace(UVC_TRACE_CONTROL,
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] media: uvcvideo: Prevent setting unavailable flags
  2018-03-21 15:43 [PATCH] media: uvcvideo: Prevent setting unavailable flags Kieran Bingham
@ 2018-03-21 22:04 ` Laurent Pinchart
  2018-04-11 19:32 ` Guennadi Liakhovetski
  1 sibling, 0 replies; 3+ messages in thread
From: Laurent Pinchart @ 2018-03-21 22:04 UTC (permalink / raw)
  To: Kieran Bingham; +Cc: linux-media, Edgar Thier, Mauro Carvalho Chehab, open list

Hi Kieran,

Thank you for the patch.

On Wednesday, 21 March 2018 17:43:08 EET Kieran Bingham wrote:
> The addition of an extra operation to use the GET_INFO command
> overwrites all existing flags from the uvc_ctrls table. This includes
> setting all controls as supporting  GET_MIN, GET_MAX, GET_RES, and
> GET_DEF regardless of whether they do or not.
> 
> Move the initialisation of these control capabilities directly to the
> uvc_ctrl_fill_xu_info() call where they were originally located in that
> use case, and ensure that the new functionality in uvc_ctrl_get_flags()
> will only set flags based on their reported capability from the GET_INFO
> call.
> 
> Fixes: 859086ae3636 ("media: uvcvideo: Apply flags from device to actual
> properties")
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

And applied to my tree.

Mauro, this fixes a regression in your master branch queued for v4.17. Do you 
want a pull request now, or after the merge window for -rc2 ?

> ---
>  drivers/media/usb/uvc/uvc_ctrl.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/media/usb/uvc/uvc_ctrl.c
> b/drivers/media/usb/uvc/uvc_ctrl.c index 1daf444371be..4042cbdb721b 100644
> --- a/drivers/media/usb/uvc/uvc_ctrl.c
> +++ b/drivers/media/usb/uvc/uvc_ctrl.c
> @@ -1607,14 +1607,12 @@ static int uvc_ctrl_get_flags(struct uvc_device
> *dev, ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id,
> dev->intfnum, info->selector, data, 1);
>  	if (!ret)
> -		info->flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX
> -			    | UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF
> -			    | (data[0] & UVC_CONTROL_CAP_GET ?
> -			       UVC_CTRL_FLAG_GET_CUR : 0)
> -			    | (data[0] & UVC_CONTROL_CAP_SET ?
> -			       UVC_CTRL_FLAG_SET_CUR : 0)
> -			    | (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ?
> -			       UVC_CTRL_FLAG_AUTO_UPDATE : 0);
> +		info->flags |= (data[0] & UVC_CONTROL_CAP_GET ?
> +				UVC_CTRL_FLAG_GET_CUR : 0)
> +			    |  (data[0] & UVC_CONTROL_CAP_SET ?
> +				UVC_CTRL_FLAG_SET_CUR : 0)
> +			    |  (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ?
> +				UVC_CTRL_FLAG_AUTO_UPDATE : 0);
> 
>  	kfree(data);
>  	return ret;
> @@ -1689,6 +1687,9 @@ static int uvc_ctrl_fill_xu_info(struct uvc_device
> *dev,
> 
>  	info->size = le16_to_cpup((__le16 *)data);
> 
> +	info->flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX
> +		    | UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF;
> +
>  	ret = uvc_ctrl_get_flags(dev, ctrl, info);
>  	if (ret < 0) {
>  		uvc_trace(UVC_TRACE_CONTROL,


-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] media: uvcvideo: Prevent setting unavailable flags
  2018-03-21 15:43 [PATCH] media: uvcvideo: Prevent setting unavailable flags Kieran Bingham
  2018-03-21 22:04 ` Laurent Pinchart
@ 2018-04-11 19:32 ` Guennadi Liakhovetski
  1 sibling, 0 replies; 3+ messages in thread
From: Guennadi Liakhovetski @ 2018-04-11 19:32 UTC (permalink / raw)
  To: Kieran Bingham
  Cc: linux-media, Laurent Pinchart, Edgar Thier,
	Mauro Carvalho Chehab, open list

Hi Kieran,

Thanks for the patch, it fixed a problem I was having with media master, 
working with a Logitech UVC 1.5 camera.

On Wed, 21 Mar 2018, Kieran Bingham wrote:

> The addition of an extra operation to use the GET_INFO command
> overwrites all existing flags from the uvc_ctrls table. This includes
> setting all controls as supporting  GET_MIN, GET_MAX, GET_RES, and
> GET_DEF regardless of whether they do or not.
> 
> Move the initialisation of these control capabilities directly to the
> uvc_ctrl_fill_xu_info() call where they were originally located in that
> use case, and ensure that the new functionality in uvc_ctrl_get_flags()
> will only set flags based on their reported capability from the GET_INFO
> call.
> 
> Fixes: 859086ae3636 ("media: uvcvideo: Apply flags from device to actual
> properties")
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

Tested-by: Guennadi Liakhovetski <guennadi.liakhovetski@intel.com>

Thanks
Guennadi

> ---
>  drivers/media/usb/uvc/uvc_ctrl.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
> index 1daf444371be..4042cbdb721b 100644
> --- a/drivers/media/usb/uvc/uvc_ctrl.c
> +++ b/drivers/media/usb/uvc/uvc_ctrl.c
> @@ -1607,14 +1607,12 @@ static int uvc_ctrl_get_flags(struct uvc_device *dev,
>  	ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id, dev->intfnum,
>  			     info->selector, data, 1);
>  	if (!ret)
> -		info->flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX
> -			    | UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF
> -			    | (data[0] & UVC_CONTROL_CAP_GET ?
> -			       UVC_CTRL_FLAG_GET_CUR : 0)
> -			    | (data[0] & UVC_CONTROL_CAP_SET ?
> -			       UVC_CTRL_FLAG_SET_CUR : 0)
> -			    | (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ?
> -			       UVC_CTRL_FLAG_AUTO_UPDATE : 0);
> +		info->flags |= (data[0] & UVC_CONTROL_CAP_GET ?
> +				UVC_CTRL_FLAG_GET_CUR : 0)
> +			    |  (data[0] & UVC_CONTROL_CAP_SET ?
> +				UVC_CTRL_FLAG_SET_CUR : 0)
> +			    |  (data[0] & UVC_CONTROL_CAP_AUTOUPDATE ?
> +				UVC_CTRL_FLAG_AUTO_UPDATE : 0);
>  
>  	kfree(data);
>  	return ret;
> @@ -1689,6 +1687,9 @@ static int uvc_ctrl_fill_xu_info(struct uvc_device *dev,
>  
>  	info->size = le16_to_cpup((__le16 *)data);
>  
> +	info->flags = UVC_CTRL_FLAG_GET_MIN | UVC_CTRL_FLAG_GET_MAX
> +		    | UVC_CTRL_FLAG_GET_RES | UVC_CTRL_FLAG_GET_DEF;
> +
>  	ret = uvc_ctrl_get_flags(dev, ctrl, info);
>  	if (ret < 0) {
>  		uvc_trace(UVC_TRACE_CONTROL,
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-04-11 19:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-21 15:43 [PATCH] media: uvcvideo: Prevent setting unavailable flags Kieran Bingham
2018-03-21 22:04 ` Laurent Pinchart
2018-04-11 19:32 ` Guennadi Liakhovetski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.