All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: usbtv: fix brightness and contrast controls
@ 2017-10-24 20:14 Adam Sampson
  2017-10-25  6:50 ` Lubomir Rintel
  0 siblings, 1 reply; 2+ messages in thread
From: Adam Sampson @ 2017-10-24 20:14 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Lubomir Rintel, linux-media, Adam Sampson

Because the brightness and contrast controls share a register,
usbtv_s_ctrl needs to read the existing values for both controls before
inserting the new value. However, the code accidentally wrote to the
registers (from an uninitialised stack array), rather than reading them.

The user-visible effect of this was that adjusting the brightness would
also set the contrast to a random value, and vice versa -- so it wasn't
possible to correctly adjust the brightness of usbtv's video output.

Tested with an "EasyDAY" UTV007 device.

Fixes: c53a846c48f2 ("usbtv: add video controls")
Signed-off-by: Adam Sampson <ats@offog.org>
---
 drivers/media/usb/usbtv/usbtv-video.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/usb/usbtv/usbtv-video.c b/drivers/media/usb/usbtv/usbtv-video.c
index 95b5f43..3668a04 100644
--- a/drivers/media/usb/usbtv/usbtv-video.c
+++ b/drivers/media/usb/usbtv/usbtv-video.c
@@ -718,8 +718,8 @@ static int usbtv_s_ctrl(struct v4l2_ctrl *ctrl)
 	 */
 	if (ctrl->id == V4L2_CID_BRIGHTNESS || ctrl->id == V4L2_CID_CONTRAST) {
 		ret = usb_control_msg(usbtv->udev,
-			usb_sndctrlpipe(usbtv->udev, 0), USBTV_CONTROL_REG,
-			USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+			usb_rcvctrlpipe(usbtv->udev, 0), USBTV_CONTROL_REG,
+			USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
 			0, USBTV_BASE + 0x0244, (void *)data, 3, 0);
 		if (ret < 0)
 			goto error;
-- 
2.1.4

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

* Re: [PATCH] media: usbtv: fix brightness and contrast controls
  2017-10-24 20:14 [PATCH] media: usbtv: fix brightness and contrast controls Adam Sampson
@ 2017-10-25  6:50 ` Lubomir Rintel
  0 siblings, 0 replies; 2+ messages in thread
From: Lubomir Rintel @ 2017-10-25  6:50 UTC (permalink / raw)
  To: Adam Sampson, Mauro Carvalho Chehab; +Cc: linux-media

On Tue, 2017-10-24 at 21:14 +0100, Adam Sampson wrote:
> Because the brightness and contrast controls share a register,
> usbtv_s_ctrl needs to read the existing values for both controls
> before
> inserting the new value. However, the code accidentally wrote to the
> registers (from an uninitialised stack array), rather than reading
> them.
> 
> The user-visible effect of this was that adjusting the brightness
> would
> also set the contrast to a random value, and vice versa -- so it
> wasn't
> possible to correctly adjust the brightness of usbtv's video output.
> 
> Tested with an "EasyDAY" UTV007 device.
> 
> Fixes: c53a846c48f2 ("usbtv: add video controls")
> Signed-off-by: Adam Sampson <ats@offog.org>

Thank you!

Reviewed-By: Lubomir Rintel <lkundrak@v3.sk>

> ---
>  drivers/media/usb/usbtv/usbtv-video.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/usb/usbtv/usbtv-video.c
> b/drivers/media/usb/usbtv/usbtv-video.c
> index 95b5f43..3668a04 100644
> --- a/drivers/media/usb/usbtv/usbtv-video.c
> +++ b/drivers/media/usb/usbtv/usbtv-video.c
> @@ -718,8 +718,8 @@ static int usbtv_s_ctrl(struct v4l2_ctrl *ctrl)
>  	 */
>  	if (ctrl->id == V4L2_CID_BRIGHTNESS || ctrl->id ==
> V4L2_CID_CONTRAST) {
>  		ret = usb_control_msg(usbtv->udev,
> -			usb_sndctrlpipe(usbtv->udev, 0),
> USBTV_CONTROL_REG,
> -			USB_DIR_OUT | USB_TYPE_VENDOR |
> USB_RECIP_DEVICE,
> +			usb_rcvctrlpipe(usbtv->udev, 0),
> USBTV_CONTROL_REG,
> +			USB_DIR_IN | USB_TYPE_VENDOR |
> USB_RECIP_DEVICE,
>  			0, USBTV_BASE + 0x0244, (void *)data, 3, 0);
>  		if (ret < 0)
>  			goto error;

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

end of thread, other threads:[~2017-10-25  6:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-24 20:14 [PATCH] media: usbtv: fix brightness and contrast controls Adam Sampson
2017-10-25  6:50 ` Lubomir Rintel

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.