]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
[media] uvcvideo: Fix incorrect bandwidth with Chicony device 04f2:b50b
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Tue, 12 May 2015 21:57:53 +0000 (18:57 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Sat, 30 May 2015 15:12:15 +0000 (12:12 -0300)
The "TOSHIBA Web Camera - 5M" Chicony device (04f2:b50b) seems to
compute the bandwidth on 16 bits and erroneously sign-extend it to
32 bits, resulting in a huge bandwidth value. Detect and fix that
condition by setting the 16 MSBs to 0 when they're all equal to 1.

Reported-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/usb/uvc/uvc_video.c

index 20ccc9d315dcf40c8f36803e3bd4d4806e0977d9..f839654ea4369fa7645f579f7ab5b94189055611 100644 (file)
@@ -119,6 +119,14 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
                ctrl->dwMaxVideoFrameSize =
                        frame->dwMaxVideoFrameBufferSize;
 
+       /* The "TOSHIBA Web Camera - 5M" Chicony device (04f2:b50b) seems to
+        * compute the bandwidth on 16 bits and erroneously sign-extend it to
+        * 32 bits, resulting in a huge bandwidth value. Detect and fix that
+        * condition by setting the 16 MSBs to 0 when they're all equal to 1.
+        */
+       if ((ctrl->dwMaxPayloadTransferSize & 0xffff0000) == 0xffff0000)
+               ctrl->dwMaxPayloadTransferSize &= ~0xffff0000;
+
        if (!(format->flags & UVC_FMT_FLAG_COMPRESSED) &&
            stream->dev->quirks & UVC_QUIRK_FIX_BANDWIDTH &&
            stream->intf->num_altsetting > 1) {