Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 137931
b: refs/heads/master
c: 50144ae
h: refs/heads/master
i:
  137929: 49cba2b
  137927: 6fadeae
v: v3
  • Loading branch information
Laurent Pinchart authored and Mauro Carvalho Chehab committed Mar 30, 2009
1 parent 5309aed commit 773b17f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c90e777976f6237a0cdb644c6a9406907939b174
refs/heads/master: 50144aeeb702ea105697ae5249f059ea3990b838
9 changes: 9 additions & 0 deletions trunk/drivers/media/video/uvc/uvc_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1861,6 +1861,15 @@ static struct usb_device_id uvc_ids[] = {
.bInterfaceSubClass = 1,
.bInterfaceProtocol = 0,
.driver_info = UVC_QUIRK_STREAM_NO_FID },
/* ViMicro */
{ .match_flags = USB_DEVICE_ID_MATCH_VENDOR
| USB_DEVICE_ID_MATCH_INT_INFO,
.idVendor = 0x0ac8,
.idProduct = 0x0000,
.bInterfaceClass = USB_CLASS_VIDEO,
.bInterfaceSubClass = 1,
.bInterfaceProtocol = 0,
.driver_info = UVC_QUIRK_FIX_BANDWIDTH },
/* MT6227 */
{ .match_flags = USB_DEVICE_ID_MATCH_DEVICE
| USB_DEVICE_ID_MATCH_INT_INFO,
Expand Down
34 changes: 30 additions & 4 deletions trunk/drivers/media/video/uvc/uvc_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int uvc_query_ctrl(struct uvc_device *dev, __u8 query, __u8 unit,
return 0;
}

static void uvc_fixup_buffer_size(struct uvc_video_device *video,
static void uvc_fixup_video_ctrl(struct uvc_video_device *video,
struct uvc_streaming_control *ctrl)
{
struct uvc_format *format;
Expand All @@ -84,6 +84,31 @@ static void uvc_fixup_buffer_size(struct uvc_video_device *video,
video->dev->uvc_version < 0x0110))
ctrl->dwMaxVideoFrameSize =
frame->dwMaxVideoFrameBufferSize;

if (video->dev->quirks & UVC_QUIRK_FIX_BANDWIDTH &&
video->streaming->intf->num_altsetting > 1) {
u32 interval;
u32 bandwidth;

interval = (ctrl->dwFrameInterval > 100000)
? ctrl->dwFrameInterval
: frame->dwFrameInterval[0];

/* Compute a bandwidth estimation by multiplying the frame
* size by the number of video frames per second, divide the
* result by the number of USB frames (or micro-frames for
* high-speed devices) per second and add the UVC header size
* (assumed to be 12 bytes long).
*/
bandwidth = frame->wWidth * frame->wHeight / 8 * format->bpp;
bandwidth *= 10000000 / interval + 1;
bandwidth /= 1000;
if (video->dev->udev->speed == USB_SPEED_HIGH)
bandwidth /= 8;
bandwidth += 12;

ctrl->dwMaxPayloadTransferSize = bandwidth;
}
}

static int uvc_get_video_ctrl(struct uvc_video_device *video,
Expand Down Expand Up @@ -158,10 +183,11 @@ static int uvc_get_video_ctrl(struct uvc_video_device *video,
ctrl->bMaxVersion = 0;
}

/* Some broken devices return a null or wrong dwMaxVideoFrameSize.
* Try to get the value from the format and frame descriptors.
/* Some broken devices return null or wrong dwMaxVideoFrameSize and
* dwMaxPayloadTransferSize fields. Try to get the value from the
* format and frame descriptors.
*/
uvc_fixup_buffer_size(video, ctrl);
uvc_fixup_video_ctrl(video, ctrl);
ret = 0;

out:
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/media/video/uvc/uvcvideo.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ struct uvc_xu_control {
#define UVC_QUIRK_STREAM_NO_FID 0x00000010
#define UVC_QUIRK_IGNORE_SELECTOR_UNIT 0x00000020
#define UVC_QUIRK_PRUNE_CONTROLS 0x00000040
#define UVC_QUIRK_FIX_BANDWIDTH 0x00000080

/* Format flags */
#define UVC_FMT_FLAG_COMPRESSED 0x00000001
Expand Down

0 comments on commit 773b17f

Please sign in to comment.