Skip to contentSkip to conversation

media: usbtv: fix brightness and contrast controls

PATCH In review Adam Sampson 2 participants 2 messages Oct 24, 2017 – Oct 25, 2017 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: usbtv: fix brightness and contrast controls

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")
---
 drivers/media/usb/usbtv/usbtv-video.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/usb/usbtv/usbtv-video.c +2 -2
index 95b5f43..3668a04 100644
@@ -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;
Signature · 1 line
2.1.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · 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.

Quoted 4 lines

Tested with an "EasyDAY" UTV007 device.

Fixes c53a846c48f2 ("usbtv: add video controls")

Thank you!

Quoted 25 lines
---
 drivers/media/usb/usbtv/usbtv-video.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/usb/usbtv/usbtv-video.c +1 -2
index 95b5f43..3668a04 100644
@@ -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,

drivers/media/usb/usbtv/usbtv-video.c +1 -0
+			USB_DIR_IN | USB_TYPE_VENDOR |

USB_RECIP_DEVICE,

drivers/media/usb/usbtv/usbtv-video.c +0 -0
 			0, USBTV_BASE + 0x0244, (void *)data, 3, 0);
 		if (ret < 0)
 			goto error;