aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/video/uvc/uvc_ctrl.c6
-rw-r--r--drivers/media/video/uvc/uvc_driver.c52
-rw-r--r--drivers/media/video/uvc/uvc_isight.c2
-rw-r--r--drivers/media/video/uvc/uvc_queue.c30
-rw-r--r--drivers/media/video/uvc/uvc_status.c2
-rw-r--r--drivers/media/video/uvc/uvc_v4l2.c10
-rw-r--r--drivers/media/video/uvc/uvc_video.c28
-rw-r--r--drivers/media/video/uvc/uvcvideo.h232
8 files changed, 184 insertions, 178 deletions
diff --git a/drivers/media/video/uvc/uvc_ctrl.c b/drivers/media/video/uvc/uvc_ctrl.c
index c506068bec6..d2576f6391c 100644
--- a/drivers/media/video/uvc/uvc_ctrl.c
+++ b/drivers/media/video/uvc/uvc_ctrl.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * uvc_ctrl.c -- USB Video Class driver - Controls 2 * uvc_ctrl.c -- USB Video Class driver - Controls
3 * 3 *
4 * Copyright (C) 2005-2008 4 * Copyright (C) 2005-2009
5 * Laurent Pinchart (laurent.pinchart@skynet.be) 5 * Laurent Pinchart (laurent.pinchart@skynet.be)
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -28,7 +28,7 @@
28#define UVC_CTRL_DATA_BACKUP 1 28#define UVC_CTRL_DATA_BACKUP 1
29 29
30/* ------------------------------------------------------------------------ 30/* ------------------------------------------------------------------------
31 * Control, formats, ... 31 * Controls
32 */ 32 */
33 33
34static struct uvc_control_info uvc_ctrls[] = { 34static struct uvc_control_info uvc_ctrls[] = {
@@ -634,7 +634,7 @@ static __s32 uvc_get_le_value(struct uvc_control_mapping *mapping,
634 mask = (1 << bits) - 1; 634 mask = (1 << bits) - 1;
635 } 635 }
636 636
637 /* Sign-extend the value if needed */ 637 /* Sign-extend the value if needed. */
638 if (mapping->data_type == UVC_CTRL_DATA_TYPE_SIGNED) 638 if (mapping->data_type == UVC_CTRL_DATA_TYPE_SIGNED)
639 value |= -(value & (1 << (mapping->size - 1))); 639 value |= -(value & (1 << (mapping->size - 1)));
640 640
diff --git a/drivers/media/video/uvc/uvc_driver.c b/drivers/media/video/uvc/uvc_driver.c
index a0537464987..20c16c4a62d 100644
--- a/drivers/media/video/uvc/uvc_driver.c
+++ b/drivers/media/video/uvc/uvc_driver.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * uvc_driver.c -- USB Video Class driver 2 * uvc_driver.c -- USB Video Class driver
3 * 3 *
4 * Copyright (C) 2005-2008 4 * Copyright (C) 2005-2009
5 * Laurent Pinchart (laurent.pinchart@skynet.be) 5 * Laurent Pinchart (laurent.pinchart@skynet.be)
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -48,7 +48,7 @@ static unsigned int uvc_quirks_param;
48unsigned int uvc_trace_param; 48unsigned int uvc_trace_param;
49 49
50/* ------------------------------------------------------------------------ 50/* ------------------------------------------------------------------------
51 * Control, formats, ... 51 * Video formats
52 */ 52 */
53 53
54static struct uvc_format_desc uvc_fmts[] = { 54static struct uvc_format_desc uvc_fmts[] = {
@@ -473,7 +473,7 @@ static int uvc_parse_format(struct uvc_device *dev,
473 473
474 /* Several UVC chipsets screw up dwMaxVideoFrameBufferSize 474 /* Several UVC chipsets screw up dwMaxVideoFrameBufferSize
475 * completely. Observed behaviours range from setting the 475 * completely. Observed behaviours range from setting the
476 * value to 1.1x the actual frame size of hardwiring the 476 * value to 1.1x the actual frame size to hardwiring the
477 * 16 low bits to 0. This results in a higher than necessary 477 * 16 low bits to 0. This results in a higher than necessary
478 * memory usage as well as a wrong image size information. For 478 * memory usage as well as a wrong image size information. For
479 * uncompressed formats this can be fixed by computing the 479 * uncompressed formats this can be fixed by computing the
@@ -486,7 +486,7 @@ static int uvc_parse_format(struct uvc_device *dev,
486 /* Some bogus devices report dwMinFrameInterval equal to 486 /* Some bogus devices report dwMinFrameInterval equal to
487 * dwMaxFrameInterval and have dwFrameIntervalStep set to 487 * dwMaxFrameInterval and have dwFrameIntervalStep set to
488 * zero. Setting all null intervals to 1 fixes the problem and 488 * zero. Setting all null intervals to 1 fixes the problem and
489 * some other divisions by zero which could happen. 489 * some other divisions by zero that could happen.
490 */ 490 */
491 for (i = 0; i < n; ++i) { 491 for (i = 0; i < n; ++i) {
492 interval = get_unaligned_le32(&buffer[26+4*i]); 492 interval = get_unaligned_le32(&buffer[26+4*i]);
@@ -1199,13 +1199,13 @@ static void uvc_unregister_video(struct uvc_device *dev)
1199 * Scan the UVC descriptors to locate a chain starting at an Output Terminal 1199 * Scan the UVC descriptors to locate a chain starting at an Output Terminal
1200 * and containing the following units: 1200 * and containing the following units:
1201 * 1201 *
1202 * - a USB Streaming Output Terminal 1202 * - one Output Terminal (USB Streaming or Display)
1203 * - zero or one Processing Unit 1203 * - zero or one Processing Unit
1204 * - zero, one or mode single-input Selector Units 1204 * - zero, one or mode single-input Selector Units
1205 * - zero or one multiple-input Selector Units, provided all inputs are 1205 * - zero or one multiple-input Selector Units, provided all inputs are
1206 * connected to input terminals 1206 * connected to input terminals
1207 * - zero, one or mode single-input Extension Units 1207 * - zero, one or mode single-input Extension Units
1208 * - one Camera Input Terminal, or one or more External terminals. 1208 * - one or more Input Terminals (Camera, External or USB Streaming)
1209 * 1209 *
1210 * A side forward scan is made on each detected entity to check for additional 1210 * A side forward scan is made on each detected entity to check for additional
1211 * extension units. 1211 * extension units.
@@ -1530,10 +1530,6 @@ static int uvc_register_video(struct uvc_device *dev)
1530 1530
1531 /* Set the driver data before calling video_register_device, otherwise 1531 /* Set the driver data before calling video_register_device, otherwise
1532 * uvc_v4l2_open might race us. 1532 * uvc_v4l2_open might race us.
1533 *
1534 * FIXME: usb_set_intfdata hasn't been called so far. Is that a
1535 * problem ? Does any function which could be called here get
1536 * a pointer to the usb_interface ?
1537 */ 1533 */
1538 dev->video.vdev = vdev; 1534 dev->video.vdev = vdev;
1539 video_set_drvdata(vdev, &dev->video); 1535 video_set_drvdata(vdev, &dev->video);
@@ -1568,7 +1564,7 @@ void uvc_delete(struct kref *kref)
1568 struct uvc_device *dev = container_of(kref, struct uvc_device, kref); 1564 struct uvc_device *dev = container_of(kref, struct uvc_device, kref);
1569 struct list_head *p, *n; 1565 struct list_head *p, *n;
1570 1566
1571 /* Unregister the video device */ 1567 /* Unregister the video device. */
1572 uvc_unregister_video(dev); 1568 uvc_unregister_video(dev);
1573 usb_put_intf(dev->intf); 1569 usb_put_intf(dev->intf);
1574 usb_put_dev(dev->udev); 1570 usb_put_dev(dev->udev);
@@ -1611,7 +1607,7 @@ static int uvc_probe(struct usb_interface *intf,
1611 uvc_trace(UVC_TRACE_PROBE, "Probing generic UVC device %s\n", 1607 uvc_trace(UVC_TRACE_PROBE, "Probing generic UVC device %s\n",
1612 udev->devpath); 1608 udev->devpath);
1613 1609
1614 /* Allocate memory for the device and initialize it */ 1610 /* Allocate memory for the device and initialize it. */
1615 if ((dev = kzalloc(sizeof *dev, GFP_KERNEL)) == NULL) 1611 if ((dev = kzalloc(sizeof *dev, GFP_KERNEL)) == NULL)
1616 return -ENOMEM; 1612 return -ENOMEM;
1617 1613
@@ -1632,7 +1628,7 @@ static int uvc_probe(struct usb_interface *intf,
1632 le16_to_cpu(udev->descriptor.idVendor), 1628 le16_to_cpu(udev->descriptor.idVendor),
1633 le16_to_cpu(udev->descriptor.idProduct)); 1629 le16_to_cpu(udev->descriptor.idProduct));
1634 1630
1635 /* Parse the Video Class control descriptor */ 1631 /* Parse the Video Class control descriptor. */
1636 if (uvc_parse_control(dev) < 0) { 1632 if (uvc_parse_control(dev) < 0) {
1637 uvc_trace(UVC_TRACE_PROBE, "Unable to parse UVC " 1633 uvc_trace(UVC_TRACE_PROBE, "Unable to parse UVC "
1638 "descriptors.\n"); 1634 "descriptors.\n");
@@ -1652,18 +1648,18 @@ static int uvc_probe(struct usb_interface *intf,
1652 "linux-uvc-devel mailing list.\n"); 1648 "linux-uvc-devel mailing list.\n");
1653 } 1649 }
1654 1650
1655 /* Initialize controls */ 1651 /* Initialize controls. */
1656 if (uvc_ctrl_init_device(dev) < 0) 1652 if (uvc_ctrl_init_device(dev) < 0)
1657 goto error; 1653 goto error;
1658 1654
1659 /* Register the video devices */ 1655 /* Register the video devices. */
1660 if (uvc_register_video(dev) < 0) 1656 if (uvc_register_video(dev) < 0)
1661 goto error; 1657 goto error;
1662 1658
1663 /* Save our data pointer in the interface data */ 1659 /* Save our data pointer in the interface data. */
1664 usb_set_intfdata(intf, dev); 1660 usb_set_intfdata(intf, dev);
1665 1661
1666 /* Initialize the interrupt URB */ 1662 /* Initialize the interrupt URB. */
1667 if ((ret = uvc_status_init(dev)) < 0) { 1663 if ((ret = uvc_status_init(dev)) < 0) {
1668 uvc_printk(KERN_INFO, "Unable to initialize the status " 1664 uvc_printk(KERN_INFO, "Unable to initialize the status "
1669 "endpoint (%d), status interrupt will not be " 1665 "endpoint (%d), status interrupt will not be "
@@ -1838,24 +1834,24 @@ static struct usb_device_id uvc_ids[] = {
1838 .bInterfaceSubClass = 1, 1834 .bInterfaceSubClass = 1,
1839 .bInterfaceProtocol = 0 }, 1835 .bInterfaceProtocol = 0 },
1840 /* Apple Built-In iSight */ 1836 /* Apple Built-In iSight */
1841 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE 1837 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
1842 | USB_DEVICE_ID_MATCH_INT_INFO, 1838 | USB_DEVICE_ID_MATCH_INT_INFO,
1843 .idVendor = 0x05ac, 1839 .idVendor = 0x05ac,
1844 .idProduct = 0x8501, 1840 .idProduct = 0x8501,
1845 .bInterfaceClass = USB_CLASS_VIDEO, 1841 .bInterfaceClass = USB_CLASS_VIDEO,
1846 .bInterfaceSubClass = 1, 1842 .bInterfaceSubClass = 1,
1847 .bInterfaceProtocol = 0, 1843 .bInterfaceProtocol = 0,
1848 .driver_info = UVC_QUIRK_PROBE_MINMAX 1844 .driver_info = UVC_QUIRK_PROBE_MINMAX
1849 | UVC_QUIRK_BUILTIN_ISIGHT }, 1845 | UVC_QUIRK_BUILTIN_ISIGHT },
1850 /* Genesys Logic USB 2.0 PC Camera */ 1846 /* Genesys Logic USB 2.0 PC Camera */
1851 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE 1847 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
1852 | USB_DEVICE_ID_MATCH_INT_INFO, 1848 | USB_DEVICE_ID_MATCH_INT_INFO,
1853 .idVendor = 0x05e3, 1849 .idVendor = 0x05e3,
1854 .idProduct = 0x0505, 1850 .idProduct = 0x0505,
1855 .bInterfaceClass = USB_CLASS_VIDEO, 1851 .bInterfaceClass = USB_CLASS_VIDEO,
1856 .bInterfaceSubClass = 1, 1852 .bInterfaceSubClass = 1,
1857 .bInterfaceProtocol = 0, 1853 .bInterfaceProtocol = 0,
1858 .driver_info = UVC_QUIRK_STREAM_NO_FID }, 1854 .driver_info = UVC_QUIRK_STREAM_NO_FID },
1859 /* MT6227 */ 1855 /* MT6227 */
1860 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE 1856 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
1861 | USB_DEVICE_ID_MATCH_INT_INFO, 1857 | USB_DEVICE_ID_MATCH_INT_INFO,
diff --git a/drivers/media/video/uvc/uvc_isight.c b/drivers/media/video/uvc/uvc_isight.c
index 37bdefdbead..436f462685a 100644
--- a/drivers/media/video/uvc/uvc_isight.c
+++ b/drivers/media/video/uvc/uvc_isight.c
@@ -3,6 +3,8 @@
3 * 3 *
4 * Copyright (C) 2006-2007 4 * Copyright (C) 2006-2007
5 * Ivan N. Zlatev <contact@i-nz.net> 5 * Ivan N. Zlatev <contact@i-nz.net>
6 * Copyright (C) 2008-2009
7 * Laurent Pinchart <laurent.pinchart@skynet.be>
6 * 8 *
7 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
diff --git a/drivers/media/video/uvc/uvc_queue.c b/drivers/media/video/uvc/uvc_queue.c
index 8f676f9d9e3..0155752e4a5 100644
--- a/drivers/media/video/uvc/uvc_queue.c
+++ b/drivers/media/video/uvc/uvc_queue.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * uvc_queue.c -- USB Video Class driver - Buffers management 2 * uvc_queue.c -- USB Video Class driver - Buffers management
3 * 3 *
4 * Copyright (C) 2005-2008 4 * Copyright (C) 2005-2009
5 * Laurent Pinchart (laurent.pinchart@skynet.be) 5 * Laurent Pinchart (laurent.pinchart@skynet.be)
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -36,22 +36,22 @@
36 * to user space will return -EBUSY. 36 * to user space will return -EBUSY.
37 * 37 *
38 * Video buffers are managed using two queues. However, unlike most USB video 38 * Video buffers are managed using two queues. However, unlike most USB video
39 * drivers which use an in queue and an out queue, we use a main queue which 39 * drivers that use an in queue and an out queue, we use a main queue to hold
40 * holds all queued buffers (both 'empty' and 'done' buffers), and an irq 40 * all queued buffers (both 'empty' and 'done' buffers), and an irq queue to
41 * queue which holds empty buffers. This design (copied from video-buf) 41 * hold empty buffers. This design (copied from video-buf) minimizes locking
42 * minimizes locking in interrupt, as only one queue is shared between 42 * in interrupt, as only one queue is shared between interrupt and user
43 * interrupt and user contexts. 43 * contexts.
44 * 44 *
45 * Use cases 45 * Use cases
46 * --------- 46 * ---------
47 * 47 *
48 * Unless stated otherwise, all operations which modify the irq buffers queue 48 * Unless stated otherwise, all operations that modify the irq buffers queue
49 * are protected by the irq spinlock. 49 * are protected by the irq spinlock.
50 * 50 *
51 * 1. The user queues the buffers, starts streaming and dequeues a buffer. 51 * 1. The user queues the buffers, starts streaming and dequeues a buffer.
52 * 52 *
53 * The buffers are added to the main and irq queues. Both operations are 53 * The buffers are added to the main and irq queues. Both operations are
54 * protected by the queue lock, and the latert is protected by the irq 54 * protected by the queue lock, and the later is protected by the irq
55 * spinlock as well. 55 * spinlock as well.
56 * 56 *
57 * The completion handler fetches a buffer from the irq queue and fills it 57 * The completion handler fetches a buffer from the irq queue and fills it
@@ -59,7 +59,7 @@
59 * returns immediately. 59 * returns immediately.
60 * 60 *
61 * When the buffer is full, the completion handler removes it from the irq 61 * When the buffer is full, the completion handler removes it from the irq
62 * queue, marks it as ready (UVC_BUF_STATE_DONE) and wake its wait queue. 62 * queue, marks it as ready (UVC_BUF_STATE_DONE) and wakes its wait queue.
63 * At that point, any process waiting on the buffer will be woken up. If a 63 * At that point, any process waiting on the buffer will be woken up. If a
64 * process tries to dequeue a buffer after it has been marked ready, the 64 * process tries to dequeue a buffer after it has been marked ready, the
65 * dequeing will succeed immediately. 65 * dequeing will succeed immediately.
@@ -90,8 +90,8 @@ void uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type)
90/* 90/*
91 * Allocate the video buffers. 91 * Allocate the video buffers.
92 * 92 *
93 * Pages are reserved to make sure they will not be swaped, as they will be 93 * Pages are reserved to make sure they will not be swapped, as they will be
94 * filled in URB completion handler. 94 * filled in the URB completion handler.
95 * 95 *
96 * Buffers will be individually mapped, so they must all be page aligned. 96 * Buffers will be individually mapped, so they must all be page aligned.
97 */ 97 */
@@ -209,8 +209,8 @@ int uvc_query_buffer(struct uvc_video_queue *queue,
209 __uvc_query_buffer(&queue->buffer[v4l2_buf->index], v4l2_buf); 209 __uvc_query_buffer(&queue->buffer[v4l2_buf->index], v4l2_buf);
210 210
211done: 211done:
212 mutex_unlock(&queue->mutex); 212 mutex_unlock(&queue->mutex);
213 return ret; 213 return ret;
214} 214}
215 215
216/* 216/*
@@ -235,7 +235,7 @@ int uvc_queue_buffer(struct uvc_video_queue *queue,
235 } 235 }
236 236
237 mutex_lock(&queue->mutex); 237 mutex_lock(&queue->mutex);
238 if (v4l2_buf->index >= queue->count) { 238 if (v4l2_buf->index >= queue->count) {
239 uvc_trace(UVC_TRACE_CAPTURE, "[E] Out of range index.\n"); 239 uvc_trace(UVC_TRACE_CAPTURE, "[E] Out of range index.\n");
240 ret = -EINVAL; 240 ret = -EINVAL;
241 goto done; 241 goto done;
@@ -428,7 +428,7 @@ done:
428 * Cancel the video buffers queue. 428 * Cancel the video buffers queue.
429 * 429 *
430 * Cancelling the queue marks all buffers on the irq queue as erroneous, 430 * Cancelling the queue marks all buffers on the irq queue as erroneous,
431 * wakes them up and remove them from the queue. 431 * wakes them up and removes them from the queue.
432 * 432 *
433 * If the disconnect parameter is set, further calls to uvc_queue_buffer will 433 * If the disconnect parameter is set, further calls to uvc_queue_buffer will
434 * fail with -ENODEV. 434 * fail with -ENODEV.
diff --git a/drivers/media/video/uvc/uvc_status.c b/drivers/media/video/uvc/uvc_status.c
index b482f4fc7b3..c1e4ae27c61 100644
--- a/drivers/media/video/uvc/uvc_status.c
+++ b/drivers/media/video/uvc/uvc_status.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * uvc_status.c -- USB Video Class driver - Status endpoint 2 * uvc_status.c -- USB Video Class driver - Status endpoint
3 * 3 *
4 * Copyright (C) 2007-2008 4 * Copyright (C) 2007-2009
5 * Laurent Pinchart (laurent.pinchart@skynet.be) 5 * Laurent Pinchart (laurent.pinchart@skynet.be)
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
diff --git a/drivers/media/video/uvc/uvc_v4l2.c b/drivers/media/video/uvc/uvc_v4l2.c
index fa150fff2c1..d681519d0c8 100644
--- a/drivers/media/video/uvc/uvc_v4l2.c
+++ b/drivers/media/video/uvc/uvc_v4l2.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * uvc_v4l2.c -- USB Video Class driver - V4L2 API 2 * uvc_v4l2.c -- USB Video Class driver - V4L2 API
3 * 3 *
4 * Copyright (C) 2005-2008 4 * Copyright (C) 2005-2009
5 * Laurent Pinchart (laurent.pinchart@skynet.be) 5 * Laurent Pinchart (laurent.pinchart@skynet.be)
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -37,7 +37,7 @@
37 * must be grouped (for instance the Red Balance, Blue Balance and Do White 37 * must be grouped (for instance the Red Balance, Blue Balance and Do White
38 * Balance V4L2 controls use the White Balance Component UVC control) or 38 * Balance V4L2 controls use the White Balance Component UVC control) or
39 * otherwise translated. The approach we take here is to use a translation 39 * otherwise translated. The approach we take here is to use a translation
40 * table for the controls which can be mapped directly, and handle the others 40 * table for the controls that can be mapped directly, and handle the others
41 * manually. 41 * manually.
42 */ 42 */
43static int uvc_v4l2_query_menu(struct uvc_video_device *video, 43static int uvc_v4l2_query_menu(struct uvc_video_device *video,
@@ -189,7 +189,7 @@ static int uvc_v4l2_try_format(struct uvc_video_device *video,
189 probe->dwMaxVideoFrameSize = 189 probe->dwMaxVideoFrameSize =
190 video->streaming->ctrl.dwMaxVideoFrameSize; 190 video->streaming->ctrl.dwMaxVideoFrameSize;
191 191
192 /* Probe the device */ 192 /* Probe the device. */
193 if ((ret = uvc_probe_video(video, probe)) < 0) 193 if ((ret = uvc_probe_video(video, probe)) < 0)
194 goto done; 194 goto done;
195 195
@@ -354,11 +354,11 @@ static int uvc_v4l2_set_streamparm(struct uvc_video_device *video,
354 * 354 *
355 * Each open instance of a UVC device can either be in a privileged or 355 * Each open instance of a UVC device can either be in a privileged or
356 * unprivileged state. Only a single instance can be in a privileged state at 356 * unprivileged state. Only a single instance can be in a privileged state at
357 * a given time. Trying to perform an operation which requires privileges will 357 * a given time. Trying to perform an operation that requires privileges will
358 * automatically acquire the required privileges if possible, or return -EBUSY 358 * automatically acquire the required privileges if possible, or return -EBUSY
359 * otherwise. Privileges are dismissed when closing the instance. 359 * otherwise. Privileges are dismissed when closing the instance.
360 * 360 *
361 * Operations which require privileges are: 361 * Operations that require privileges are:
362 * 362 *
363 * - VIDIOC_S_INPUT 363 * - VIDIOC_S_INPUT
364 * - VIDIOC_S_PARM 364 * - VIDIOC_S_PARM
diff --git a/drivers/media/video/uvc/uvc_video.c b/drivers/media/video/uvc/uvc_video.c
index 6e9e30f174a..f9eb0e97405 100644
--- a/drivers/media/video/uvc/uvc_video.c
+++ b/drivers/media/video/uvc/uvc_video.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * uvc_video.c -- USB Video Class driver - Video handling 2 * uvc_video.c -- USB Video Class driver - Video handling
3 * 3 *
4 * Copyright (C) 2005-2008 4 * Copyright (C) 2005-2009
5 * Laurent Pinchart (laurent.pinchart@skynet.be) 5 * Laurent Pinchart (laurent.pinchart@skynet.be)
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -159,7 +159,7 @@ static int uvc_get_video_ctrl(struct uvc_video_device *video,
159 } 159 }
160 160
161 /* Some broken devices return a null or wrong dwMaxVideoFrameSize. 161 /* Some broken devices return a null or wrong dwMaxVideoFrameSize.
162 * Try to get the value from the format and frame descriptor. 162 * Try to get the value from the format and frame descriptors.
163 */ 163 */
164 uvc_fixup_buffer_size(video, ctrl); 164 uvc_fixup_buffer_size(video, ctrl);
165 ret = 0; 165 ret = 0;
@@ -190,9 +190,6 @@ static int uvc_set_video_ctrl(struct uvc_video_device *video,
190 *(__le16 *)&data[12] = cpu_to_le16(ctrl->wCompQuality); 190 *(__le16 *)&data[12] = cpu_to_le16(ctrl->wCompQuality);
191 *(__le16 *)&data[14] = cpu_to_le16(ctrl->wCompWindowSize); 191 *(__le16 *)&data[14] = cpu_to_le16(ctrl->wCompWindowSize);
192 *(__le16 *)&data[16] = cpu_to_le16(ctrl->wDelay); 192 *(__le16 *)&data[16] = cpu_to_le16(ctrl->wDelay);
193 /* Note: Some of the fields below are not required for IN devices (see
194 * UVC spec, 4.3.1.1), but we still copy them in case support for OUT
195 * devices is added in the future. */
196 put_unaligned_le32(ctrl->dwMaxVideoFrameSize, &data[18]); 193 put_unaligned_le32(ctrl->dwMaxVideoFrameSize, &data[18]);
197 put_unaligned_le32(ctrl->dwMaxPayloadTransferSize, &data[22]); 194 put_unaligned_le32(ctrl->dwMaxPayloadTransferSize, &data[22]);
198 195
@@ -399,7 +396,7 @@ static int uvc_video_decode_start(struct uvc_video_device *video,
399 * 396 *
400 * Empty buffers (bytesused == 0) don't trigger end of frame detection 397 * Empty buffers (bytesused == 0) don't trigger end of frame detection
401 * as it doesn't make sense to return an empty buffer. This also 398 * as it doesn't make sense to return an empty buffer. This also
402 * avoids detecting and of frame conditions at FID toggling if the 399 * avoids detecting end of frame conditions at FID toggling if the
403 * previous payload had the EOF bit set. 400 * previous payload had the EOF bit set.
404 */ 401 */
405 if (fid != video->last_fid && buf->buf.bytesused != 0) { 402 if (fid != video->last_fid && buf->buf.bytesused != 0) {
@@ -452,6 +449,17 @@ static void uvc_video_decode_end(struct uvc_video_device *video,
452 } 449 }
453} 450}
454 451
452/* Video payload encoding is handled by uvc_video_encode_header() and
453 * uvc_video_encode_data(). Only bulk transfers are currently supported.
454 *
455 * uvc_video_encode_header is called at the start of a payload. It adds header
456 * data to the transfer buffer and returns the header size. As the only known
457 * UVC output device transfers a whole frame in a single payload, the EOF bit
458 * is always set in the header.
459 *
460 * uvc_video_encode_data is called for every URB and copies the data from the
461 * video buffer to the transfer buffer.
462 */
455static int uvc_video_encode_header(struct uvc_video_device *video, 463static int uvc_video_encode_header(struct uvc_video_device *video,
456 struct uvc_buffer *buf, __u8 *data, int len) 464 struct uvc_buffer *buf, __u8 *data, int len)
457{ 465{
@@ -952,7 +960,7 @@ int uvc_video_suspend(struct uvc_video_device *video)
952} 960}
953 961
954/* 962/*
955 * Reconfigure the video interface and restart streaming if it was enable 963 * Reconfigure the video interface and restart streaming if it was enabled
956 * before suspend. 964 * before suspend.
957 * 965 *
958 * If an error occurs, disable the video queue. This will wake all pending 966 * If an error occurs, disable the video queue. This will wake all pending
@@ -984,8 +992,8 @@ int uvc_video_resume(struct uvc_video_device *video)
984 */ 992 */
985 993
986/* 994/*
987 * Initialize the UVC video device by retrieving the default format and 995 * Initialize the UVC video device by switching to alternate setting 0 and
988 * committing it. 996 * retrieve the default format.
989 * 997 *
990 * Some cameras (namely the Fuji Finepix) set the format and frame 998 * Some cameras (namely the Fuji Finepix) set the format and frame
991 * indexes to zero. The UVC standard doesn't clearly make this a spec 999 * indexes to zero. The UVC standard doesn't clearly make this a spec
@@ -1013,7 +1021,7 @@ int uvc_video_init(struct uvc_video_device *video)
1013 */ 1021 */
1014 usb_set_interface(video->dev->udev, video->streaming->intfnum, 0); 1022 usb_set_interface(video->dev->udev, video->streaming->intfnum, 0);
1015 1023
1016 /* Some webcams don't suport GET_DEF request on the probe control. We 1024 /* Some webcams don't suport GET_DEF requests on the probe control. We
1017 * fall back to GET_CUR if GET_DEF fails. 1025 * fall back to GET_CUR if GET_DEF fails.
1018 */ 1026 */
1019 if ((ret = uvc_get_video_ctrl(video, probe, 1, GET_DEF)) < 0 && 1027 if ((ret = uvc_get_video_ctrl(video, probe, 1, GET_DEF)) < 0 &&
diff --git a/drivers/media/video/uvc/uvcvideo.h b/drivers/media/video/uvc/uvcvideo.h
index bcf4361dc1b..027947ea9b6 100644
--- a/drivers/media/video/uvc/uvcvideo.h
+++ b/drivers/media/video/uvc/uvcvideo.h
@@ -72,149 +72,149 @@ struct uvc_xu_control {
72 * UVC constants 72 * UVC constants
73 */ 73 */
74 74
75#define SC_UNDEFINED 0x00 75#define SC_UNDEFINED 0x00
76#define SC_VIDEOCONTROL 0x01 76#define SC_VIDEOCONTROL 0x01
77#define SC_VIDEOSTREAMING 0x02 77#define SC_VIDEOSTREAMING 0x02
78#define SC_VIDEO_INTERFACE_COLLECTION 0x03 78#define SC_VIDEO_INTERFACE_COLLECTION 0x03
79 79
80#define PC_PROTOCOL_UNDEFINED 0x00 80#define PC_PROTOCOL_UNDEFINED 0x00
81 81
82#define CS_UNDEFINED 0x20 82#define CS_UNDEFINED 0x20
83#define CS_DEVICE 0x21 83#define CS_DEVICE 0x21
84#define CS_CONFIGURATION 0x22 84#define CS_CONFIGURATION 0x22
85#define CS_STRING 0x23 85#define CS_STRING 0x23
86#define CS_INTERFACE 0x24 86#define CS_INTERFACE 0x24
87#define CS_ENDPOINT 0x25 87#define CS_ENDPOINT 0x25
88 88
89/* VideoControl class specific interface descriptor */ 89/* VideoControl class specific interface descriptor */
90#define VC_DESCRIPTOR_UNDEFINED 0x00 90#define VC_DESCRIPTOR_UNDEFINED 0x00
91#define VC_HEADER 0x01 91#define VC_HEADER 0x01
92#define VC_INPUT_TERMINAL 0x02 92#define VC_INPUT_TERMINAL 0x02
93#define VC_OUTPUT_TERMINAL 0x03 93#define VC_OUTPUT_TERMINAL 0x03
94#define VC_SELECTOR_UNIT 0x04 94#define VC_SELECTOR_UNIT 0x04
95#define VC_PROCESSING_UNIT 0x05 95#define VC_PROCESSING_UNIT 0x05
96#define VC_EXTENSION_UNIT 0x06 96#define VC_EXTENSION_UNIT 0x06
97 97
98/* VideoStreaming class specific interface descriptor */ 98/* VideoStreaming class specific interface descriptor */
99#define VS_UNDEFINED 0x00 99#define VS_UNDEFINED 0x00
100#define VS_INPUT_HEADER 0x01 100#define VS_INPUT_HEADER 0x01
101#define VS_OUTPUT_HEADER 0x02 101#define VS_OUTPUT_HEADER 0x02
102#define VS_STILL_IMAGE_FRAME 0x03 102#define VS_STILL_IMAGE_FRAME 0x03
103#define VS_FORMAT_UNCOMPRESSED 0x04 103#define VS_FORMAT_UNCOMPRESSED 0x04
104#define VS_FRAME_UNCOMPRESSED 0x05 104#define VS_FRAME_UNCOMPRESSED 0x05
105#define VS_FORMAT_MJPEG 0x06 105#define VS_FORMAT_MJPEG 0x06
106#define VS_FRAME_MJPEG 0x07 106#define VS_FRAME_MJPEG 0x07
107#define VS_FORMAT_MPEG2TS 0x0a 107#define VS_FORMAT_MPEG2TS 0x0a
108#define VS_FORMAT_DV 0x0c 108#define VS_FORMAT_DV 0x0c
109#define VS_COLORFORMAT 0x0d 109#define VS_COLORFORMAT 0x0d
110#define VS_FORMAT_FRAME_BASED 0x10 110#define VS_FORMAT_FRAME_BASED 0x10
111#define VS_FRAME_FRAME_BASED 0x11 111#define VS_FRAME_FRAME_BASED 0x11
112#define VS_FORMAT_STREAM_BASED 0x12 112#define VS_FORMAT_STREAM_BASED 0x12
113 113
114/* Endpoint type */ 114/* Endpoint type */
115#define EP_UNDEFINED 0x00 115#define EP_UNDEFINED 0x00
116#define EP_GENERAL 0x01 116#define EP_GENERAL 0x01
117#define EP_ENDPOINT 0x02 117#define EP_ENDPOINT 0x02
118#define EP_INTERRUPT 0x03 118#define EP_INTERRUPT 0x03
119 119
120/* Request codes */ 120/* Request codes */
121#define RC_UNDEFINED 0x00 121#define RC_UNDEFINED 0x00
122#define SET_CUR 0x01 122#define SET_CUR 0x01
123#define GET_CUR 0x81 123#define GET_CUR 0x81
124#define GET_MIN 0x82 124#define GET_MIN 0x82
125#define GET_MAX 0x83 125#define GET_MAX 0x83
126#define GET_RES 0x84 126#define GET_RES 0x84
127#define GET_LEN 0x85 127#define GET_LEN 0x85
128#define GET_INFO 0x86 128#define GET_INFO 0x86
129#define GET_DEF 0x87 129#define GET_DEF 0x87
130 130
131/* VideoControl interface controls */ 131/* VideoControl interface controls */
132#define VC_CONTROL_UNDEFINED 0x00 132#define VC_CONTROL_UNDEFINED 0x00
133#define VC_VIDEO_POWER_MODE_CONTROL 0x01 133#define VC_VIDEO_POWER_MODE_CONTROL 0x01
134#define VC_REQUEST_ERROR_CODE_CONTROL 0x02 134#define VC_REQUEST_ERROR_CODE_CONTROL 0x02
135 135
136/* Terminal controls */ 136/* Terminal controls */
137#define TE_CONTROL_UNDEFINED 0x00 137#define TE_CONTROL_UNDEFINED 0x00
138 138
139/* Selector Unit controls */ 139/* Selector Unit controls */
140#define SU_CONTROL_UNDEFINED 0x00 140#define SU_CONTROL_UNDEFINED 0x00
141#define SU_INPUT_SELECT_CONTROL 0x01 141#define SU_INPUT_SELECT_CONTROL 0x01
142 142
143/* Camera Terminal controls */ 143/* Camera Terminal controls */
144#define CT_CONTROL_UNDEFINED 0x00 144#define CT_CONTROL_UNDEFINED 0x00
145#define CT_SCANNING_MODE_CONTROL 0x01 145#define CT_SCANNING_MODE_CONTROL 0x01
146#define CT_AE_MODE_CONTROL 0x02 146#define CT_AE_MODE_CONTROL 0x02
147#define CT_AE_PRIORITY_CONTROL 0x03 147#define CT_AE_PRIORITY_CONTROL 0x03
148#define CT_EXPOSURE_TIME_ABSOLUTE_CONTROL 0x04 148#define CT_EXPOSURE_TIME_ABSOLUTE_CONTROL 0x04
149#define CT_EXPOSURE_TIME_RELATIVE_CONTROL 0x05 149#define CT_EXPOSURE_TIME_RELATIVE_CONTROL 0x05
150#define CT_FOCUS_ABSOLUTE_CONTROL 0x06 150#define CT_FOCUS_ABSOLUTE_CONTROL 0x06
151#define CT_FOCUS_RELATIVE_CONTROL 0x07 151#define CT_FOCUS_RELATIVE_CONTROL 0x07
152#define CT_FOCUS_AUTO_CONTROL 0x08 152#define CT_FOCUS_AUTO_CONTROL 0x08
153#define CT_IRIS_ABSOLUTE_CONTROL 0x09 153#define CT_IRIS_ABSOLUTE_CONTROL 0x09
154#define CT_IRIS_RELATIVE_CONTROL 0x0a 154#define CT_IRIS_RELATIVE_CONTROL 0x0a
155#define CT_ZOOM_ABSOLUTE_CONTROL 0x0b 155#define CT_ZOOM_ABSOLUTE_CONTROL 0x0b
156#define CT_ZOOM_RELATIVE_CONTROL 0x0c 156#define CT_ZOOM_RELATIVE_CONTROL 0x0c
157#define CT_PANTILT_ABSOLUTE_CONTROL 0x0d 157#define CT_PANTILT_ABSOLUTE_CONTROL 0x0d
158#define CT_PANTILT_RELATIVE_CONTROL 0x0e 158#define CT_PANTILT_RELATIVE_CONTROL 0x0e
159#define CT_ROLL_ABSOLUTE_CONTROL 0x0f 159#define CT_ROLL_ABSOLUTE_CONTROL 0x0f
160#define CT_ROLL_RELATIVE_CONTROL 0x10 160#define CT_ROLL_RELATIVE_CONTROL 0x10
161#define CT_PRIVACY_CONTROL 0x11 161#define CT_PRIVACY_CONTROL 0x11
162 162
163/* Processing Unit controls */ 163/* Processing Unit controls */
164#define PU_CONTROL_UNDEFINED 0x00 164#define PU_CONTROL_UNDEFINED 0x00
165#define PU_BACKLIGHT_COMPENSATION_CONTROL 0x01 165#define PU_BACKLIGHT_COMPENSATION_CONTROL 0x01
166#define PU_BRIGHTNESS_CONTROL 0x02 166#define PU_BRIGHTNESS_CONTROL 0x02
167#define PU_CONTRAST_CONTROL 0x03 167#define PU_CONTRAST_CONTROL 0x03
168#define PU_GAIN_CONTROL 0x04 168#define PU_GAIN_CONTROL 0x04
169#define PU_POWER_LINE_FREQUENCY_CONTROL 0x05 169#define PU_POWER_LINE_FREQUENCY_CONTROL 0x05
170#define PU_HUE_CONTROL 0x06 170#define PU_HUE_CONTROL 0x06
171#define PU_SATURATION_CONTROL 0x07 171#define PU_SATURATION_CONTROL 0x07
172#define PU_SHARPNESS_CONTROL 0x08 172#define PU_SHARPNESS_CONTROL 0x08
173#define PU_GAMMA_CONTROL 0x09 173#define PU_GAMMA_CONTROL 0x09
174#define PU_WHITE_BALANCE_TEMPERATURE_CONTROL 0x0a 174#define PU_WHITE_BALANCE_TEMPERATURE_CONTROL 0x0a
175#define PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL 0x0b 175#define PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL 0x0b
176#define PU_WHITE_BALANCE_COMPONENT_CONTROL 0x0c 176#define PU_WHITE_BALANCE_COMPONENT_CONTROL 0x0c
177#define PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL 0x0d 177#define PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL 0x0d
178#define PU_DIGITAL_MULTIPLIER_CONTROL 0x0e 178#define PU_DIGITAL_MULTIPLIER_CONTROL 0x0e
179#define PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL 0x0f 179#define PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL 0x0f
180#define PU_HUE_AUTO_CONTROL 0x10 180#define PU_HUE_AUTO_CONTROL 0x10
181#define PU_ANALOG_VIDEO_STANDARD_CONTROL 0x11 181#define PU_ANALOG_VIDEO_STANDARD_CONTROL 0x11
182#define PU_ANALOG_LOCK_STATUS_CONTROL 0x12 182#define PU_ANALOG_LOCK_STATUS_CONTROL 0x12
183 183
184#define LXU_MOTOR_PANTILT_RELATIVE_CONTROL 0x01 184#define LXU_MOTOR_PANTILT_RELATIVE_CONTROL 0x01
185#define LXU_MOTOR_PANTILT_RESET_CONTROL 0x02 185#define LXU_MOTOR_PANTILT_RESET_CONTROL 0x02
186#define LXU_MOTOR_FOCUS_MOTOR_CONTROL 0x03 186#define LXU_MOTOR_FOCUS_MOTOR_CONTROL 0x03
187 187
188/* VideoStreaming interface controls */ 188/* VideoStreaming interface controls */
189#define VS_CONTROL_UNDEFINED 0x00 189#define VS_CONTROL_UNDEFINED 0x00
190#define VS_PROBE_CONTROL 0x01 190#define VS_PROBE_CONTROL 0x01
191#define VS_COMMIT_CONTROL 0x02 191#define VS_COMMIT_CONTROL 0x02
192#define VS_STILL_PROBE_CONTROL 0x03 192#define VS_STILL_PROBE_CONTROL 0x03
193#define VS_STILL_COMMIT_CONTROL 0x04 193#define VS_STILL_COMMIT_CONTROL 0x04
194#define VS_STILL_IMAGE_TRIGGER_CONTROL 0x05 194#define VS_STILL_IMAGE_TRIGGER_CONTROL 0x05
195#define VS_STREAM_ERROR_CODE_CONTROL 0x06 195#define VS_STREAM_ERROR_CODE_CONTROL 0x06
196#define VS_GENERATE_KEY_FRAME_CONTROL 0x07 196#define VS_GENERATE_KEY_FRAME_CONTROL 0x07
197#define VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08 197#define VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08
198#define VS_SYNC_DELAY_CONTROL 0x09 198#define VS_SYNC_DELAY_CONTROL 0x09
199 199
200#define TT_VENDOR_SPECIFIC 0x0100 200#define TT_VENDOR_SPECIFIC 0x0100
201#define TT_STREAMING 0x0101 201#define TT_STREAMING 0x0101
202 202
203/* Input Terminal types */ 203/* Input Terminal types */
204#define ITT_VENDOR_SPECIFIC 0x0200 204#define ITT_VENDOR_SPECIFIC 0x0200
205#define ITT_CAMERA 0x0201 205#define ITT_CAMERA 0x0201
206#define ITT_MEDIA_TRANSPORT_INPUT 0x0202 206#define ITT_MEDIA_TRANSPORT_INPUT 0x0202
207 207
208/* Output Terminal types */ 208/* Output Terminal types */
209#define OTT_VENDOR_SPECIFIC 0x0300 209#define OTT_VENDOR_SPECIFIC 0x0300
210#define OTT_DISPLAY 0x0301 210#define OTT_DISPLAY 0x0301
211#define OTT_MEDIA_TRANSPORT_OUTPUT 0x0302 211#define OTT_MEDIA_TRANSPORT_OUTPUT 0x0302
212 212
213/* External Terminal types */ 213/* External Terminal types */
214#define EXTERNAL_VENDOR_SPECIFIC 0x0400 214#define EXTERNAL_VENDOR_SPECIFIC 0x0400
215#define COMPOSITE_CONNECTOR 0x0401 215#define COMPOSITE_CONNECTOR 0x0401
216#define SVIDEO_CONNECTOR 0x0402 216#define SVIDEO_CONNECTOR 0x0402
217#define COMPONENT_CONNECTOR 0x0403 217#define COMPONENT_CONNECTOR 0x0403
218 218
219#define UVC_TERM_INPUT 0x0000 219#define UVC_TERM_INPUT 0x0000
220#define UVC_TERM_OUTPUT 0x8000 220#define UVC_TERM_OUTPUT 0x8000
@@ -541,11 +541,11 @@ struct uvc_streaming {
541}; 541};
542 542
543enum uvc_buffer_state { 543enum uvc_buffer_state {
544 UVC_BUF_STATE_IDLE = 0, 544 UVC_BUF_STATE_IDLE = 0,
545 UVC_BUF_STATE_QUEUED = 1, 545 UVC_BUF_STATE_QUEUED = 1,
546 UVC_BUF_STATE_ACTIVE = 2, 546 UVC_BUF_STATE_ACTIVE = 2,
547 UVC_BUF_STATE_DONE = 3, 547 UVC_BUF_STATE_DONE = 3,
548 UVC_BUF_STATE_ERROR = 4, 548 UVC_BUF_STATE_ERROR = 4,
549}; 549};
550 550
551struct uvc_buffer { 551struct uvc_buffer {