1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * uvc_driver.c -- USB Video Class driver
5 * Copyright (C) 2005-2010
6 * Laurent Pinchart (laurent.pinchart@ideasonboard.com)
9 #include <linux/atomic.h>
10 #include <linux/kernel.h>
11 #include <linux/list.h>
12 #include <linux/module.h>
13 #include <linux/slab.h>
14 #include <linux/usb.h>
15 #include <linux/videodev2.h>
16 #include <linux/vmalloc.h>
17 #include <linux/wait.h>
18 #include <linux/version.h>
19 #include <asm/unaligned.h>
21 #include <media/v4l2-common.h>
22 #include <media/v4l2-ioctl.h>
26 #define DRIVER_AUTHOR "Laurent Pinchart " \
27 "<laurent.pinchart@ideasonboard.com>"
28 #define DRIVER_DESC "USB Video Class driver"
30 unsigned int uvc_clock_param = CLOCK_MONOTONIC;
31 unsigned int uvc_hw_timestamps_param;
32 unsigned int uvc_no_drop_param;
33 static unsigned int uvc_quirks_param = -1;
34 unsigned int uvc_trace_param;
35 unsigned int uvc_timeout_param = UVC_CTRL_STREAMING_TIMEOUT;
37 /* ------------------------------------------------------------------------
41 static struct uvc_format_desc uvc_fmts[] = {
43 .name = "YUV 4:2:2 (YUYV)",
44 .guid = UVC_GUID_FORMAT_YUY2,
45 .fcc = V4L2_PIX_FMT_YUYV,
48 .name = "YUV 4:2:2 (YUYV)",
49 .guid = UVC_GUID_FORMAT_YUY2_ISIGHT,
50 .fcc = V4L2_PIX_FMT_YUYV,
53 .name = "YUV 4:2:0 (NV12)",
54 .guid = UVC_GUID_FORMAT_NV12,
55 .fcc = V4L2_PIX_FMT_NV12,
59 .guid = UVC_GUID_FORMAT_MJPEG,
60 .fcc = V4L2_PIX_FMT_MJPEG,
63 .name = "YVU 4:2:0 (YV12)",
64 .guid = UVC_GUID_FORMAT_YV12,
65 .fcc = V4L2_PIX_FMT_YVU420,
68 .name = "YUV 4:2:0 (I420)",
69 .guid = UVC_GUID_FORMAT_I420,
70 .fcc = V4L2_PIX_FMT_YUV420,
73 .name = "YUV 4:2:0 (M420)",
74 .guid = UVC_GUID_FORMAT_M420,
75 .fcc = V4L2_PIX_FMT_M420,
78 .name = "YUV 4:2:2 (UYVY)",
79 .guid = UVC_GUID_FORMAT_UYVY,
80 .fcc = V4L2_PIX_FMT_UYVY,
83 .name = "Greyscale 8-bit (Y800)",
84 .guid = UVC_GUID_FORMAT_Y800,
85 .fcc = V4L2_PIX_FMT_GREY,
88 .name = "Greyscale 8-bit (Y8 )",
89 .guid = UVC_GUID_FORMAT_Y8,
90 .fcc = V4L2_PIX_FMT_GREY,
93 .name = "Greyscale 8-bit (D3DFMT_L8)",
94 .guid = UVC_GUID_FORMAT_D3DFMT_L8,
95 .fcc = V4L2_PIX_FMT_GREY,
98 .name = "IR 8-bit (L8_IR)",
99 .guid = UVC_GUID_FORMAT_KSMEDIA_L8_IR,
100 .fcc = V4L2_PIX_FMT_GREY,
103 .name = "Greyscale 10-bit (Y10 )",
104 .guid = UVC_GUID_FORMAT_Y10,
105 .fcc = V4L2_PIX_FMT_Y10,
108 .name = "Greyscale 12-bit (Y12 )",
109 .guid = UVC_GUID_FORMAT_Y12,
110 .fcc = V4L2_PIX_FMT_Y12,
113 .name = "Greyscale 16-bit (Y16 )",
114 .guid = UVC_GUID_FORMAT_Y16,
115 .fcc = V4L2_PIX_FMT_Y16,
118 .name = "BGGR Bayer (BY8 )",
119 .guid = UVC_GUID_FORMAT_BY8,
120 .fcc = V4L2_PIX_FMT_SBGGR8,
123 .name = "BGGR Bayer (BA81)",
124 .guid = UVC_GUID_FORMAT_BA81,
125 .fcc = V4L2_PIX_FMT_SBGGR8,
128 .name = "GBRG Bayer (GBRG)",
129 .guid = UVC_GUID_FORMAT_GBRG,
130 .fcc = V4L2_PIX_FMT_SGBRG8,
133 .name = "GRBG Bayer (GRBG)",
134 .guid = UVC_GUID_FORMAT_GRBG,
135 .fcc = V4L2_PIX_FMT_SGRBG8,
138 .name = "RGGB Bayer (RGGB)",
139 .guid = UVC_GUID_FORMAT_RGGB,
140 .fcc = V4L2_PIX_FMT_SRGGB8,
144 .guid = UVC_GUID_FORMAT_RGBP,
145 .fcc = V4L2_PIX_FMT_RGB565,
148 .name = "BGR 8:8:8 (BGR3)",
149 .guid = UVC_GUID_FORMAT_BGR3,
150 .fcc = V4L2_PIX_FMT_BGR24,
154 .guid = UVC_GUID_FORMAT_H264,
155 .fcc = V4L2_PIX_FMT_H264,
158 .name = "Greyscale 8 L/R (Y8I)",
159 .guid = UVC_GUID_FORMAT_Y8I,
160 .fcc = V4L2_PIX_FMT_Y8I,
163 .name = "Greyscale 12 L/R (Y12I)",
164 .guid = UVC_GUID_FORMAT_Y12I,
165 .fcc = V4L2_PIX_FMT_Y12I,
168 .name = "Depth data 16-bit (Z16)",
169 .guid = UVC_GUID_FORMAT_Z16,
170 .fcc = V4L2_PIX_FMT_Z16,
173 .name = "Bayer 10-bit (SRGGB10P)",
174 .guid = UVC_GUID_FORMAT_RW10,
175 .fcc = V4L2_PIX_FMT_SRGGB10P,
178 .name = "Bayer 16-bit (SBGGR16)",
179 .guid = UVC_GUID_FORMAT_BG16,
180 .fcc = V4L2_PIX_FMT_SBGGR16,
183 .name = "Bayer 16-bit (SGBRG16)",
184 .guid = UVC_GUID_FORMAT_GB16,
185 .fcc = V4L2_PIX_FMT_SGBRG16,
188 .name = "Bayer 16-bit (SRGGB16)",
189 .guid = UVC_GUID_FORMAT_RG16,
190 .fcc = V4L2_PIX_FMT_SRGGB16,
193 .name = "Bayer 16-bit (SGRBG16)",
194 .guid = UVC_GUID_FORMAT_GR16,
195 .fcc = V4L2_PIX_FMT_SGRBG16,
198 .name = "Depth data 16-bit (Z16)",
199 .guid = UVC_GUID_FORMAT_INVZ,
200 .fcc = V4L2_PIX_FMT_Z16,
203 .name = "Greyscale 10-bit (Y10 )",
204 .guid = UVC_GUID_FORMAT_INVI,
205 .fcc = V4L2_PIX_FMT_Y10,
208 .name = "IR:Depth 26-bit (INZI)",
209 .guid = UVC_GUID_FORMAT_INZI,
210 .fcc = V4L2_PIX_FMT_INZI,
213 .name = "4-bit Depth Confidence (Packed)",
214 .guid = UVC_GUID_FORMAT_CNF4,
215 .fcc = V4L2_PIX_FMT_CNF4,
219 /* ------------------------------------------------------------------------
223 struct usb_host_endpoint *uvc_find_endpoint(struct usb_host_interface *alts,
226 struct usb_host_endpoint *ep;
229 for (i = 0; i < alts->desc.bNumEndpoints; ++i) {
230 ep = &alts->endpoint[i];
231 if (ep->desc.bEndpointAddress == epaddr)
238 static struct uvc_format_desc *uvc_format_by_guid(const u8 guid[16])
240 unsigned int len = ARRAY_SIZE(uvc_fmts);
243 for (i = 0; i < len; ++i) {
244 if (memcmp(guid, uvc_fmts[i].guid, 16) == 0)
251 static u32 uvc_colorspace(const u8 primaries)
253 static const u8 colorprimaries[] = {
255 V4L2_COLORSPACE_SRGB,
256 V4L2_COLORSPACE_470_SYSTEM_M,
257 V4L2_COLORSPACE_470_SYSTEM_BG,
258 V4L2_COLORSPACE_SMPTE170M,
259 V4L2_COLORSPACE_SMPTE240M,
262 if (primaries < ARRAY_SIZE(colorprimaries))
263 return colorprimaries[primaries];
268 /* Simplify a fraction using a simple continued fraction decomposition. The
269 * idea here is to convert fractions such as 333333/10000000 to 1/30 using
270 * 32 bit arithmetic only. The algorithm is not perfect and relies upon two
271 * arbitrary parameters to remove non-significative terms from the simple
272 * continued fraction decomposition. Using 8 and 333 for n_terms and threshold
273 * respectively seems to give nice results.
275 void uvc_simplify_fraction(u32 *numerator, u32 *denominator,
276 unsigned int n_terms, unsigned int threshold)
282 an = kmalloc_array(n_terms, sizeof(*an), GFP_KERNEL);
286 /* Convert the fraction to a simple continued fraction. See
287 * http://mathforum.org/dr.math/faq/faq.fractions.html
288 * Stop if the current term is bigger than or equal to the given
294 for (n = 0; n < n_terms && y != 0; ++n) {
296 if (an[n] >= threshold) {
307 /* Expand the simple continued fraction back to an integer fraction. */
311 for (i = n; i > 0; --i) {
322 /* Convert a fraction to a frame interval in 100ns multiples. The idea here is
323 * to compute numerator / denominator * 10000000 using 32 bit fixed point
326 u32 uvc_fraction_to_interval(u32 numerator, u32 denominator)
330 /* Saturate the result if the operation would overflow. */
331 if (denominator == 0 ||
332 numerator/denominator >= ((u32)-1)/10000000)
335 /* Divide both the denominator and the multiplier by two until
336 * numerator * multiplier doesn't overflow. If anyone knows a better
337 * algorithm please let me know.
339 multiplier = 10000000;
340 while (numerator > ((u32)-1)/multiplier) {
345 return denominator ? numerator * multiplier / denominator : 0;
348 /* ------------------------------------------------------------------------
349 * Terminal and unit management
352 struct uvc_entity *uvc_entity_by_id(struct uvc_device *dev, int id)
354 struct uvc_entity *entity;
356 list_for_each_entry(entity, &dev->entities, list) {
357 if (entity->id == id)
364 static struct uvc_entity *uvc_entity_by_reference(struct uvc_device *dev,
365 int id, struct uvc_entity *entity)
370 entity = list_entry(&dev->entities, struct uvc_entity, list);
372 list_for_each_entry_continue(entity, &dev->entities, list) {
373 for (i = 0; i < entity->bNrInPins; ++i)
374 if (entity->baSourceID[i] == id)
381 static struct uvc_streaming *uvc_stream_by_id(struct uvc_device *dev, int id)
383 struct uvc_streaming *stream;
385 list_for_each_entry(stream, &dev->streams, list) {
386 if (stream->header.bTerminalLink == id)
393 /* ------------------------------------------------------------------------
394 * Streaming Object Management
397 static void uvc_stream_delete(struct uvc_streaming *stream)
399 if (stream->async_wq)
400 destroy_workqueue(stream->async_wq);
402 mutex_destroy(&stream->mutex);
404 usb_put_intf(stream->intf);
406 kfree(stream->format);
407 kfree(stream->header.bmaControls);
411 static struct uvc_streaming *uvc_stream_new(struct uvc_device *dev,
412 struct usb_interface *intf)
414 struct uvc_streaming *stream;
416 stream = kzalloc(sizeof(*stream), GFP_KERNEL);
420 mutex_init(&stream->mutex);
423 stream->intf = usb_get_intf(intf);
424 stream->intfnum = intf->cur_altsetting->desc.bInterfaceNumber;
426 /* Allocate a stream specific work queue for asynchronous tasks. */
427 stream->async_wq = alloc_workqueue("uvcvideo", WQ_UNBOUND | WQ_HIGHPRI,
429 if (!stream->async_wq) {
430 uvc_stream_delete(stream);
437 /* ------------------------------------------------------------------------
438 * Descriptors parsing
441 static int uvc_parse_format(struct uvc_device *dev,
442 struct uvc_streaming *streaming, struct uvc_format *format,
443 u32 **intervals, unsigned char *buffer, int buflen)
445 struct usb_interface *intf = streaming->intf;
446 struct usb_host_interface *alts = intf->cur_altsetting;
447 struct uvc_format_desc *fmtdesc;
448 struct uvc_frame *frame;
449 const unsigned char *start = buffer;
450 unsigned int width_multiplier = 1;
451 unsigned int interval;
455 format->type = buffer[2];
456 format->index = buffer[3];
459 case UVC_VS_FORMAT_UNCOMPRESSED:
460 case UVC_VS_FORMAT_FRAME_BASED:
461 n = buffer[2] == UVC_VS_FORMAT_UNCOMPRESSED ? 27 : 28;
463 uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming "
464 "interface %d FORMAT error\n",
466 alts->desc.bInterfaceNumber);
470 /* Find the format descriptor from its GUID. */
471 fmtdesc = uvc_format_by_guid(&buffer[5]);
473 if (fmtdesc != NULL) {
474 strscpy(format->name, fmtdesc->name,
475 sizeof(format->name));
476 format->fcc = fmtdesc->fcc;
478 uvc_printk(KERN_INFO, "Unknown video format %pUl\n",
480 snprintf(format->name, sizeof(format->name), "%pUl\n",
485 format->bpp = buffer[21];
487 /* Some devices report a format that doesn't match what they
490 if (dev->quirks & UVC_QUIRK_FORCE_Y8) {
491 if (format->fcc == V4L2_PIX_FMT_YUYV) {
492 strscpy(format->name, "Greyscale 8-bit (Y8 )",
493 sizeof(format->name));
494 format->fcc = V4L2_PIX_FMT_GREY;
496 width_multiplier = 2;
500 if (buffer[2] == UVC_VS_FORMAT_UNCOMPRESSED) {
501 ftype = UVC_VS_FRAME_UNCOMPRESSED;
503 ftype = UVC_VS_FRAME_FRAME_BASED;
505 format->flags = UVC_FMT_FLAG_COMPRESSED;
509 case UVC_VS_FORMAT_MJPEG:
511 uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming "
512 "interface %d FORMAT error\n",
514 alts->desc.bInterfaceNumber);
518 strscpy(format->name, "MJPEG", sizeof(format->name));
519 format->fcc = V4L2_PIX_FMT_MJPEG;
520 format->flags = UVC_FMT_FLAG_COMPRESSED;
522 ftype = UVC_VS_FRAME_MJPEG;
525 case UVC_VS_FORMAT_DV:
527 uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming "
528 "interface %d FORMAT error\n",
530 alts->desc.bInterfaceNumber);
534 switch (buffer[8] & 0x7f) {
536 strscpy(format->name, "SD-DV", sizeof(format->name));
539 strscpy(format->name, "SDL-DV", sizeof(format->name));
542 strscpy(format->name, "HD-DV", sizeof(format->name));
545 uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming "
546 "interface %d: unknown DV format %u\n",
548 alts->desc.bInterfaceNumber, buffer[8]);
552 strlcat(format->name, buffer[8] & (1 << 7) ? " 60Hz" : " 50Hz",
553 sizeof(format->name));
555 format->fcc = V4L2_PIX_FMT_DV;
556 format->flags = UVC_FMT_FLAG_COMPRESSED | UVC_FMT_FLAG_STREAM;
560 /* Create a dummy frame descriptor. */
561 frame = &format->frame[0];
562 memset(&format->frame[0], 0, sizeof(format->frame[0]));
563 frame->bFrameIntervalType = 1;
564 frame->dwDefaultFrameInterval = 1;
565 frame->dwFrameInterval = *intervals;
570 case UVC_VS_FORMAT_MPEG2TS:
571 case UVC_VS_FORMAT_STREAM_BASED:
572 /* Not supported yet. */
574 uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming "
575 "interface %d unsupported format %u\n",
576 dev->udev->devnum, alts->desc.bInterfaceNumber,
581 uvc_trace(UVC_TRACE_DESCR, "Found format %s.\n", format->name);
586 /* Parse the frame descriptors. Only uncompressed, MJPEG and frame
587 * based formats have frame descriptors.
589 while (buflen > 2 && buffer[1] == USB_DT_CS_INTERFACE &&
590 buffer[2] == ftype) {
591 frame = &format->frame[format->nframes];
592 if (ftype != UVC_VS_FRAME_FRAME_BASED)
593 n = buflen > 25 ? buffer[25] : 0;
595 n = buflen > 21 ? buffer[21] : 0;
599 if (buflen < 26 + 4*n) {
600 uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming "
601 "interface %d FRAME error\n", dev->udev->devnum,
602 alts->desc.bInterfaceNumber);
606 frame->bFrameIndex = buffer[3];
607 frame->bmCapabilities = buffer[4];
608 frame->wWidth = get_unaligned_le16(&buffer[5])
610 frame->wHeight = get_unaligned_le16(&buffer[7]);
611 frame->dwMinBitRate = get_unaligned_le32(&buffer[9]);
612 frame->dwMaxBitRate = get_unaligned_le32(&buffer[13]);
613 if (ftype != UVC_VS_FRAME_FRAME_BASED) {
614 frame->dwMaxVideoFrameBufferSize =
615 get_unaligned_le32(&buffer[17]);
616 frame->dwDefaultFrameInterval =
617 get_unaligned_le32(&buffer[21]);
618 frame->bFrameIntervalType = buffer[25];
620 frame->dwMaxVideoFrameBufferSize = 0;
621 frame->dwDefaultFrameInterval =
622 get_unaligned_le32(&buffer[17]);
623 frame->bFrameIntervalType = buffer[21];
625 frame->dwFrameInterval = *intervals;
627 /* Several UVC chipsets screw up dwMaxVideoFrameBufferSize
628 * completely. Observed behaviours range from setting the
629 * value to 1.1x the actual frame size to hardwiring the
630 * 16 low bits to 0. This results in a higher than necessary
631 * memory usage as well as a wrong image size information. For
632 * uncompressed formats this can be fixed by computing the
633 * value from the frame size.
635 if (!(format->flags & UVC_FMT_FLAG_COMPRESSED))
636 frame->dwMaxVideoFrameBufferSize = format->bpp
637 * frame->wWidth * frame->wHeight / 8;
639 /* Some bogus devices report dwMinFrameInterval equal to
640 * dwMaxFrameInterval and have dwFrameIntervalStep set to
641 * zero. Setting all null intervals to 1 fixes the problem and
642 * some other divisions by zero that could happen.
644 for (i = 0; i < n; ++i) {
645 interval = get_unaligned_le32(&buffer[26+4*i]);
646 *(*intervals)++ = interval ? interval : 1;
649 /* Make sure that the default frame interval stays between
652 n -= frame->bFrameIntervalType ? 1 : 2;
653 frame->dwDefaultFrameInterval =
654 min(frame->dwFrameInterval[n],
655 max(frame->dwFrameInterval[0],
656 frame->dwDefaultFrameInterval));
658 if (dev->quirks & UVC_QUIRK_RESTRICT_FRAME_RATE) {
659 frame->bFrameIntervalType = 1;
660 frame->dwFrameInterval[0] =
661 frame->dwDefaultFrameInterval;
664 uvc_trace(UVC_TRACE_DESCR, "- %ux%u (%u.%u fps)\n",
665 frame->wWidth, frame->wHeight,
666 10000000/frame->dwDefaultFrameInterval,
667 (100000000/frame->dwDefaultFrameInterval)%10);
674 if (buflen > 2 && buffer[1] == USB_DT_CS_INTERFACE &&
675 buffer[2] == UVC_VS_STILL_IMAGE_FRAME) {
680 if (buflen > 2 && buffer[1] == USB_DT_CS_INTERFACE &&
681 buffer[2] == UVC_VS_COLORFORMAT) {
683 uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming "
684 "interface %d COLORFORMAT error\n",
686 alts->desc.bInterfaceNumber);
690 format->colorspace = uvc_colorspace(buffer[3]);
696 return buffer - start;
699 static int uvc_parse_streaming(struct uvc_device *dev,
700 struct usb_interface *intf)
702 struct uvc_streaming *streaming = NULL;
703 struct uvc_format *format;
704 struct uvc_frame *frame;
705 struct usb_host_interface *alts = &intf->altsetting[0];
706 unsigned char *_buffer, *buffer = alts->extra;
707 int _buflen, buflen = alts->extralen;
708 unsigned int nformats = 0, nframes = 0, nintervals = 0;
709 unsigned int size, i, n, p;
714 if (intf->cur_altsetting->desc.bInterfaceSubClass
715 != UVC_SC_VIDEOSTREAMING) {
716 uvc_trace(UVC_TRACE_DESCR, "device %d interface %d isn't a "
717 "video streaming interface\n", dev->udev->devnum,
718 intf->altsetting[0].desc.bInterfaceNumber);
722 if (usb_driver_claim_interface(&uvc_driver.driver, intf, dev)) {
723 uvc_trace(UVC_TRACE_DESCR, "device %d interface %d is already "
724 "claimed\n", dev->udev->devnum,
725 intf->altsetting[0].desc.bInterfaceNumber);
729 streaming = uvc_stream_new(dev, intf);
730 if (streaming == NULL) {
731 usb_driver_release_interface(&uvc_driver.driver, intf);
735 /* The Pico iMage webcam has its class-specific interface descriptors
736 * after the endpoint descriptors.
739 for (i = 0; i < alts->desc.bNumEndpoints; ++i) {
740 struct usb_host_endpoint *ep = &alts->endpoint[i];
742 if (ep->extralen == 0)
745 if (ep->extralen > 2 &&
746 ep->extra[1] == USB_DT_CS_INTERFACE) {
747 uvc_trace(UVC_TRACE_DESCR, "trying extra data "
748 "from endpoint %u.\n", i);
749 buffer = alts->endpoint[i].extra;
750 buflen = alts->endpoint[i].extralen;
756 /* Skip the standard interface descriptors. */
757 while (buflen > 2 && buffer[1] != USB_DT_CS_INTERFACE) {
763 uvc_trace(UVC_TRACE_DESCR, "no class-specific streaming "
764 "interface descriptors found.\n");
768 /* Parse the header descriptor. */
770 case UVC_VS_OUTPUT_HEADER:
771 streaming->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
775 case UVC_VS_INPUT_HEADER:
776 streaming->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
781 uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming interface "
782 "%d HEADER descriptor not found.\n", dev->udev->devnum,
783 alts->desc.bInterfaceNumber);
787 p = buflen >= 4 ? buffer[3] : 0;
788 n = buflen >= size ? buffer[size-1] : 0;
790 if (buflen < size + p*n) {
791 uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming "
792 "interface %d HEADER descriptor is invalid.\n",
793 dev->udev->devnum, alts->desc.bInterfaceNumber);
797 streaming->header.bNumFormats = p;
798 streaming->header.bEndpointAddress = buffer[6];
799 if (buffer[2] == UVC_VS_INPUT_HEADER) {
800 streaming->header.bmInfo = buffer[7];
801 streaming->header.bTerminalLink = buffer[8];
802 streaming->header.bStillCaptureMethod = buffer[9];
803 streaming->header.bTriggerSupport = buffer[10];
804 streaming->header.bTriggerUsage = buffer[11];
806 streaming->header.bTerminalLink = buffer[7];
808 streaming->header.bControlSize = n;
810 streaming->header.bmaControls = kmemdup(&buffer[size], p * n,
812 if (streaming->header.bmaControls == NULL) {
823 /* Count the format and frame descriptors. */
824 while (_buflen > 2 && _buffer[1] == USB_DT_CS_INTERFACE) {
825 switch (_buffer[2]) {
826 case UVC_VS_FORMAT_UNCOMPRESSED:
827 case UVC_VS_FORMAT_MJPEG:
828 case UVC_VS_FORMAT_FRAME_BASED:
832 case UVC_VS_FORMAT_DV:
833 /* DV format has no frame descriptor. We will create a
834 * dummy frame descriptor with a dummy frame interval.
841 case UVC_VS_FORMAT_MPEG2TS:
842 case UVC_VS_FORMAT_STREAM_BASED:
843 uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming "
844 "interface %d FORMAT %u is not supported.\n",
846 alts->desc.bInterfaceNumber, _buffer[2]);
849 case UVC_VS_FRAME_UNCOMPRESSED:
850 case UVC_VS_FRAME_MJPEG:
853 nintervals += _buffer[25] ? _buffer[25] : 3;
856 case UVC_VS_FRAME_FRAME_BASED:
859 nintervals += _buffer[21] ? _buffer[21] : 3;
863 _buflen -= _buffer[0];
864 _buffer += _buffer[0];
868 uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming interface "
869 "%d has no supported formats defined.\n",
870 dev->udev->devnum, alts->desc.bInterfaceNumber);
874 size = nformats * sizeof(*format) + nframes * sizeof(*frame)
875 + nintervals * sizeof(*interval);
876 format = kzalloc(size, GFP_KERNEL);
877 if (format == NULL) {
882 frame = (struct uvc_frame *)&format[nformats];
883 interval = (u32 *)&frame[nframes];
885 streaming->format = format;
886 streaming->nformats = nformats;
888 /* Parse the format descriptors. */
889 while (buflen > 2 && buffer[1] == USB_DT_CS_INTERFACE) {
891 case UVC_VS_FORMAT_UNCOMPRESSED:
892 case UVC_VS_FORMAT_MJPEG:
893 case UVC_VS_FORMAT_DV:
894 case UVC_VS_FORMAT_FRAME_BASED:
895 format->frame = frame;
896 ret = uvc_parse_format(dev, streaming, format,
897 &interval, buffer, buflen);
901 frame += format->nframes;
917 uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming interface "
918 "%d has %u bytes of trailing descriptor garbage.\n",
919 dev->udev->devnum, alts->desc.bInterfaceNumber, buflen);
921 /* Parse the alternate settings to find the maximum bandwidth. */
922 for (i = 0; i < intf->num_altsetting; ++i) {
923 struct usb_host_endpoint *ep;
924 alts = &intf->altsetting[i];
925 ep = uvc_find_endpoint(alts,
926 streaming->header.bEndpointAddress);
930 psize = le16_to_cpu(ep->desc.wMaxPacketSize);
931 psize = (psize & 0x07ff) * (1 + ((psize >> 11) & 3));
932 if (psize > streaming->maxpsize)
933 streaming->maxpsize = psize;
936 list_add_tail(&streaming->list, &dev->streams);
940 usb_driver_release_interface(&uvc_driver.driver, intf);
941 uvc_stream_delete(streaming);
945 static struct uvc_entity *uvc_alloc_entity(u16 type, u8 id,
946 unsigned int num_pads, unsigned int extra_size)
948 struct uvc_entity *entity;
949 unsigned int num_inputs;
953 extra_size = roundup(extra_size, sizeof(*entity->pads));
954 num_inputs = (type & UVC_TERM_OUTPUT) ? num_pads : num_pads - 1;
955 size = sizeof(*entity) + extra_size + sizeof(*entity->pads) * num_pads
957 entity = kzalloc(size, GFP_KERNEL);
964 entity->num_links = 0;
965 entity->num_pads = num_pads;
966 entity->pads = ((void *)(entity + 1)) + extra_size;
968 for (i = 0; i < num_inputs; ++i)
969 entity->pads[i].flags = MEDIA_PAD_FL_SINK;
970 if (!UVC_ENTITY_IS_OTERM(entity))
971 entity->pads[num_pads-1].flags = MEDIA_PAD_FL_SOURCE;
973 entity->bNrInPins = num_inputs;
974 entity->baSourceID = (u8 *)(&entity->pads[num_pads]);
979 /* Parse vendor-specific extensions. */
980 static int uvc_parse_vendor_control(struct uvc_device *dev,
981 const unsigned char *buffer, int buflen)
983 struct usb_device *udev = dev->udev;
984 struct usb_host_interface *alts = dev->intf->cur_altsetting;
985 struct uvc_entity *unit;
989 switch (le16_to_cpu(dev->udev->descriptor.idVendor)) {
990 case 0x046d: /* Logitech */
991 if (buffer[1] != 0x41 || buffer[2] != 0x01)
994 /* Logitech implements several vendor specific functions
995 * through vendor specific extension units (LXU).
997 * The LXU descriptors are similar to XU descriptors
998 * (see "USB Device Video Class for Video Devices", section
999 * 3.7.2.6 "Extension Unit Descriptor") with the following
1002 * ----------------------------------------------------------
1003 * 0 bLength 1 Number
1004 * Size of this descriptor, in bytes: 24+p+n*2
1005 * ----------------------------------------------------------
1006 * 23+p+n bmControlsType N Bitmap
1007 * Individual bits in the set are defined:
1011 * This bitset is mapped exactly the same as bmControls.
1012 * ----------------------------------------------------------
1013 * 23+p+n*2 bReserved 1 Boolean
1014 * ----------------------------------------------------------
1015 * 24+p+n*2 iExtension 1 Index
1016 * Index of a string descriptor that describes this
1018 * ----------------------------------------------------------
1020 p = buflen >= 22 ? buffer[21] : 0;
1021 n = buflen >= 25 + p ? buffer[22+p] : 0;
1023 if (buflen < 25 + p + 2*n) {
1024 uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol "
1025 "interface %d EXTENSION_UNIT error\n",
1026 udev->devnum, alts->desc.bInterfaceNumber);
1030 unit = uvc_alloc_entity(UVC_VC_EXTENSION_UNIT, buffer[3],
1035 memcpy(unit->extension.guidExtensionCode, &buffer[4], 16);
1036 unit->extension.bNumControls = buffer[20];
1037 memcpy(unit->baSourceID, &buffer[22], p);
1038 unit->extension.bControlSize = buffer[22+p];
1039 unit->extension.bmControls = (u8 *)unit + sizeof(*unit);
1040 unit->extension.bmControlsType = (u8 *)unit + sizeof(*unit)
1042 memcpy(unit->extension.bmControls, &buffer[23+p], 2*n);
1044 if (buffer[24+p+2*n] != 0)
1045 usb_string(udev, buffer[24+p+2*n], unit->name,
1046 sizeof(unit->name));
1048 sprintf(unit->name, "Extension %u", buffer[3]);
1050 list_add_tail(&unit->list, &dev->entities);
1058 static int uvc_parse_standard_control(struct uvc_device *dev,
1059 const unsigned char *buffer, int buflen)
1061 struct usb_device *udev = dev->udev;
1062 struct uvc_entity *unit, *term;
1063 struct usb_interface *intf;
1064 struct usb_host_interface *alts = dev->intf->cur_altsetting;
1065 unsigned int i, n, p, len;
1068 switch (buffer[2]) {
1070 n = buflen >= 12 ? buffer[11] : 0;
1072 if (buflen < 12 + n) {
1073 uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol "
1074 "interface %d HEADER error\n", udev->devnum,
1075 alts->desc.bInterfaceNumber);
1079 dev->uvc_version = get_unaligned_le16(&buffer[3]);
1080 dev->clock_frequency = get_unaligned_le32(&buffer[7]);
1082 /* Parse all USB Video Streaming interfaces. */
1083 for (i = 0; i < n; ++i) {
1084 intf = usb_ifnum_to_if(udev, buffer[12+i]);
1086 uvc_trace(UVC_TRACE_DESCR, "device %d "
1087 "interface %d doesn't exists\n",
1092 uvc_parse_streaming(dev, intf);
1096 case UVC_VC_INPUT_TERMINAL:
1098 uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol "
1099 "interface %d INPUT_TERMINAL error\n",
1100 udev->devnum, alts->desc.bInterfaceNumber);
1105 * Reject invalid terminal types that would cause issues:
1107 * - The high byte must be non-zero, otherwise it would be
1108 * confused with a unit.
1110 * - Bit 15 must be 0, as we use it internally as a terminal
1113 * Other unknown types are accepted.
1115 type = get_unaligned_le16(&buffer[4]);
1116 if ((type & 0x7f00) == 0 || (type & 0x8000) != 0) {
1117 uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol "
1118 "interface %d INPUT_TERMINAL %d has invalid "
1119 "type 0x%04x, skipping\n", udev->devnum,
1120 alts->desc.bInterfaceNumber,
1129 if (type == UVC_ITT_CAMERA) {
1130 n = buflen >= 15 ? buffer[14] : 0;
1133 } else if (type == UVC_ITT_MEDIA_TRANSPORT_INPUT) {
1134 n = buflen >= 9 ? buffer[8] : 0;
1135 p = buflen >= 10 + n ? buffer[9+n] : 0;
1139 if (buflen < len + n + p) {
1140 uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol "
1141 "interface %d INPUT_TERMINAL error\n",
1142 udev->devnum, alts->desc.bInterfaceNumber);
1146 term = uvc_alloc_entity(type | UVC_TERM_INPUT, buffer[3],
1151 if (UVC_ENTITY_TYPE(term) == UVC_ITT_CAMERA) {
1152 term->camera.bControlSize = n;
1153 term->camera.bmControls = (u8 *)term + sizeof(*term);
1154 term->camera.wObjectiveFocalLengthMin =
1155 get_unaligned_le16(&buffer[8]);
1156 term->camera.wObjectiveFocalLengthMax =
1157 get_unaligned_le16(&buffer[10]);
1158 term->camera.wOcularFocalLength =
1159 get_unaligned_le16(&buffer[12]);
1160 memcpy(term->camera.bmControls, &buffer[15], n);
1161 } else if (UVC_ENTITY_TYPE(term) ==
1162 UVC_ITT_MEDIA_TRANSPORT_INPUT) {
1163 term->media.bControlSize = n;
1164 term->media.bmControls = (u8 *)term + sizeof(*term);
1165 term->media.bTransportModeSize = p;
1166 term->media.bmTransportModes = (u8 *)term
1167 + sizeof(*term) + n;
1168 memcpy(term->media.bmControls, &buffer[9], n);
1169 memcpy(term->media.bmTransportModes, &buffer[10+n], p);
1173 usb_string(udev, buffer[7], term->name,
1174 sizeof(term->name));
1175 else if (UVC_ENTITY_TYPE(term) == UVC_ITT_CAMERA)
1176 sprintf(term->name, "Camera %u", buffer[3]);
1177 else if (UVC_ENTITY_TYPE(term) == UVC_ITT_MEDIA_TRANSPORT_INPUT)
1178 sprintf(term->name, "Media %u", buffer[3]);
1180 sprintf(term->name, "Input %u", buffer[3]);
1182 list_add_tail(&term->list, &dev->entities);
1185 case UVC_VC_OUTPUT_TERMINAL:
1187 uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol "
1188 "interface %d OUTPUT_TERMINAL error\n",
1189 udev->devnum, alts->desc.bInterfaceNumber);
1193 /* Make sure the terminal type MSB is not null, otherwise it
1194 * could be confused with a unit.
1196 type = get_unaligned_le16(&buffer[4]);
1197 if ((type & 0xff00) == 0) {
1198 uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol "
1199 "interface %d OUTPUT_TERMINAL %d has invalid "
1200 "type 0x%04x, skipping\n", udev->devnum,
1201 alts->desc.bInterfaceNumber, buffer[3], type);
1205 term = uvc_alloc_entity(type | UVC_TERM_OUTPUT, buffer[3],
1210 memcpy(term->baSourceID, &buffer[7], 1);
1213 usb_string(udev, buffer[8], term->name,
1214 sizeof(term->name));
1216 sprintf(term->name, "Output %u", buffer[3]);
1218 list_add_tail(&term->list, &dev->entities);
1221 case UVC_VC_SELECTOR_UNIT:
1222 p = buflen >= 5 ? buffer[4] : 0;
1224 if (buflen < 5 || buflen < 6 + p) {
1225 uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol "
1226 "interface %d SELECTOR_UNIT error\n",
1227 udev->devnum, alts->desc.bInterfaceNumber);
1231 unit = uvc_alloc_entity(buffer[2], buffer[3], p + 1, 0);
1235 memcpy(unit->baSourceID, &buffer[5], p);
1237 if (buffer[5+p] != 0)
1238 usb_string(udev, buffer[5+p], unit->name,
1239 sizeof(unit->name));
1241 sprintf(unit->name, "Selector %u", buffer[3]);
1243 list_add_tail(&unit->list, &dev->entities);
1246 case UVC_VC_PROCESSING_UNIT:
1247 n = buflen >= 8 ? buffer[7] : 0;
1248 p = dev->uvc_version >= 0x0110 ? 10 : 9;
1250 if (buflen < p + n) {
1251 uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol "
1252 "interface %d PROCESSING_UNIT error\n",
1253 udev->devnum, alts->desc.bInterfaceNumber);
1257 unit = uvc_alloc_entity(buffer[2], buffer[3], 2, n);
1261 memcpy(unit->baSourceID, &buffer[4], 1);
1262 unit->processing.wMaxMultiplier =
1263 get_unaligned_le16(&buffer[5]);
1264 unit->processing.bControlSize = buffer[7];
1265 unit->processing.bmControls = (u8 *)unit + sizeof(*unit);
1266 memcpy(unit->processing.bmControls, &buffer[8], n);
1267 if (dev->uvc_version >= 0x0110)
1268 unit->processing.bmVideoStandards = buffer[9+n];
1270 if (buffer[8+n] != 0)
1271 usb_string(udev, buffer[8+n], unit->name,
1272 sizeof(unit->name));
1274 sprintf(unit->name, "Processing %u", buffer[3]);
1276 list_add_tail(&unit->list, &dev->entities);
1279 case UVC_VC_EXTENSION_UNIT:
1280 p = buflen >= 22 ? buffer[21] : 0;
1281 n = buflen >= 24 + p ? buffer[22+p] : 0;
1283 if (buflen < 24 + p + n) {
1284 uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol "
1285 "interface %d EXTENSION_UNIT error\n",
1286 udev->devnum, alts->desc.bInterfaceNumber);
1290 unit = uvc_alloc_entity(buffer[2], buffer[3], p + 1, n);
1294 memcpy(unit->extension.guidExtensionCode, &buffer[4], 16);
1295 unit->extension.bNumControls = buffer[20];
1296 memcpy(unit->baSourceID, &buffer[22], p);
1297 unit->extension.bControlSize = buffer[22+p];
1298 unit->extension.bmControls = (u8 *)unit + sizeof(*unit);
1299 memcpy(unit->extension.bmControls, &buffer[23+p], n);
1301 if (buffer[23+p+n] != 0)
1302 usb_string(udev, buffer[23+p+n], unit->name,
1303 sizeof(unit->name));
1305 sprintf(unit->name, "Extension %u", buffer[3]);
1307 list_add_tail(&unit->list, &dev->entities);
1311 uvc_trace(UVC_TRACE_DESCR, "Found an unknown CS_INTERFACE "
1312 "descriptor (%u)\n", buffer[2]);
1319 static int uvc_parse_control(struct uvc_device *dev)
1321 struct usb_host_interface *alts = dev->intf->cur_altsetting;
1322 unsigned char *buffer = alts->extra;
1323 int buflen = alts->extralen;
1326 /* Parse the default alternate setting only, as the UVC specification
1327 * defines a single alternate setting, the default alternate setting
1331 while (buflen > 2) {
1332 if (uvc_parse_vendor_control(dev, buffer, buflen) ||
1333 buffer[1] != USB_DT_CS_INTERFACE)
1334 goto next_descriptor;
1336 if ((ret = uvc_parse_standard_control(dev, buffer, buflen)) < 0)
1340 buflen -= buffer[0];
1341 buffer += buffer[0];
1344 /* Check if the optional status endpoint is present. Built-in iSight
1345 * webcams have an interrupt endpoint but spit proprietary data that
1346 * don't conform to the UVC status endpoint messages. Don't try to
1347 * handle the interrupt endpoint for those cameras.
1349 if (alts->desc.bNumEndpoints == 1 &&
1350 !(dev->quirks & UVC_QUIRK_BUILTIN_ISIGHT)) {
1351 struct usb_host_endpoint *ep = &alts->endpoint[0];
1352 struct usb_endpoint_descriptor *desc = &ep->desc;
1354 if (usb_endpoint_is_int_in(desc) &&
1355 le16_to_cpu(desc->wMaxPacketSize) >= 8 &&
1356 desc->bInterval != 0) {
1357 uvc_trace(UVC_TRACE_DESCR, "Found a Status endpoint "
1358 "(addr %02x).\n", desc->bEndpointAddress);
1366 /* ------------------------------------------------------------------------
1371 * Scan the UVC descriptors to locate a chain starting at an Output Terminal
1372 * and containing the following units:
1374 * - one or more Output Terminals (USB Streaming or Display)
1375 * - zero or one Processing Unit
1376 * - zero, one or more single-input Selector Units
1377 * - zero or one multiple-input Selector Units, provided all inputs are
1378 * connected to input terminals
1379 * - zero, one or mode single-input Extension Units
1380 * - one or more Input Terminals (Camera, External or USB Streaming)
1382 * The terminal and units must match on of the following structures:
1384 * ITT_*(0) -> +---------+ +---------+ +---------+ -> TT_STREAMING(0)
1385 * ... | SU{0,1} | -> | PU{0,1} | -> | XU{0,n} | ...
1386 * ITT_*(n) -> +---------+ +---------+ +---------+ -> TT_STREAMING(n)
1388 * +---------+ +---------+ -> OTT_*(0)
1389 * TT_STREAMING -> | PU{0,1} | -> | XU{0,n} | ...
1390 * +---------+ +---------+ -> OTT_*(n)
1392 * The Processing Unit and Extension Units can be in any order. Additional
1393 * Extension Units connected to the main chain as single-unit branches are
1394 * also supported. Single-input Selector Units are ignored.
1396 static int uvc_scan_chain_entity(struct uvc_video_chain *chain,
1397 struct uvc_entity *entity)
1399 switch (UVC_ENTITY_TYPE(entity)) {
1400 case UVC_VC_EXTENSION_UNIT:
1401 if (uvc_trace_param & UVC_TRACE_PROBE)
1402 printk(KERN_CONT " <- XU %d", entity->id);
1404 if (entity->bNrInPins != 1) {
1405 uvc_trace(UVC_TRACE_DESCR, "Extension unit %d has more "
1406 "than 1 input pin.\n", entity->id);
1412 case UVC_VC_PROCESSING_UNIT:
1413 if (uvc_trace_param & UVC_TRACE_PROBE)
1414 printk(KERN_CONT " <- PU %d", entity->id);
1416 if (chain->processing != NULL) {
1417 uvc_trace(UVC_TRACE_DESCR, "Found multiple "
1418 "Processing Units in chain.\n");
1422 chain->processing = entity;
1425 case UVC_VC_SELECTOR_UNIT:
1426 if (uvc_trace_param & UVC_TRACE_PROBE)
1427 printk(KERN_CONT " <- SU %d", entity->id);
1429 /* Single-input selector units are ignored. */
1430 if (entity->bNrInPins == 1)
1433 if (chain->selector != NULL) {
1434 uvc_trace(UVC_TRACE_DESCR, "Found multiple Selector "
1435 "Units in chain.\n");
1439 chain->selector = entity;
1442 case UVC_ITT_VENDOR_SPECIFIC:
1443 case UVC_ITT_CAMERA:
1444 case UVC_ITT_MEDIA_TRANSPORT_INPUT:
1445 if (uvc_trace_param & UVC_TRACE_PROBE)
1446 printk(KERN_CONT " <- IT %d\n", entity->id);
1450 case UVC_OTT_VENDOR_SPECIFIC:
1451 case UVC_OTT_DISPLAY:
1452 case UVC_OTT_MEDIA_TRANSPORT_OUTPUT:
1453 if (uvc_trace_param & UVC_TRACE_PROBE)
1454 printk(KERN_CONT " OT %d", entity->id);
1458 case UVC_TT_STREAMING:
1459 if (UVC_ENTITY_IS_ITERM(entity)) {
1460 if (uvc_trace_param & UVC_TRACE_PROBE)
1461 printk(KERN_CONT " <- IT %d\n", entity->id);
1463 if (uvc_trace_param & UVC_TRACE_PROBE)
1464 printk(KERN_CONT " OT %d", entity->id);
1470 uvc_trace(UVC_TRACE_DESCR, "Unsupported entity type "
1471 "0x%04x found in chain.\n", UVC_ENTITY_TYPE(entity));
1475 list_add_tail(&entity->chain, &chain->entities);
1479 static int uvc_scan_chain_forward(struct uvc_video_chain *chain,
1480 struct uvc_entity *entity, struct uvc_entity *prev)
1482 struct uvc_entity *forward;
1490 forward = uvc_entity_by_reference(chain->dev, entity->id,
1492 if (forward == NULL)
1494 if (forward == prev)
1496 if (forward->chain.next || forward->chain.prev) {
1497 uvc_trace(UVC_TRACE_DESCR, "Found reference to "
1498 "entity %d already in chain.\n", forward->id);
1502 switch (UVC_ENTITY_TYPE(forward)) {
1503 case UVC_VC_EXTENSION_UNIT:
1504 if (forward->bNrInPins != 1) {
1505 uvc_trace(UVC_TRACE_DESCR, "Extension unit %d "
1506 "has more than 1 input pin.\n",
1511 list_add_tail(&forward->chain, &chain->entities);
1512 if (uvc_trace_param & UVC_TRACE_PROBE) {
1514 printk(KERN_CONT " (->");
1516 printk(KERN_CONT " XU %d", forward->id);
1521 case UVC_OTT_VENDOR_SPECIFIC:
1522 case UVC_OTT_DISPLAY:
1523 case UVC_OTT_MEDIA_TRANSPORT_OUTPUT:
1524 case UVC_TT_STREAMING:
1525 if (UVC_ENTITY_IS_ITERM(forward)) {
1526 uvc_trace(UVC_TRACE_DESCR, "Unsupported input "
1527 "terminal %u.\n", forward->id);
1531 list_add_tail(&forward->chain, &chain->entities);
1532 if (uvc_trace_param & UVC_TRACE_PROBE) {
1534 printk(KERN_CONT " (->");
1536 printk(KERN_CONT " OT %d", forward->id);
1543 printk(KERN_CONT ")");
1548 static int uvc_scan_chain_backward(struct uvc_video_chain *chain,
1549 struct uvc_entity **_entity)
1551 struct uvc_entity *entity = *_entity;
1552 struct uvc_entity *term;
1553 int id = -EINVAL, i;
1555 switch (UVC_ENTITY_TYPE(entity)) {
1556 case UVC_VC_EXTENSION_UNIT:
1557 case UVC_VC_PROCESSING_UNIT:
1558 id = entity->baSourceID[0];
1561 case UVC_VC_SELECTOR_UNIT:
1562 /* Single-input selector units are ignored. */
1563 if (entity->bNrInPins == 1) {
1564 id = entity->baSourceID[0];
1568 if (uvc_trace_param & UVC_TRACE_PROBE)
1569 printk(KERN_CONT " <- IT");
1571 chain->selector = entity;
1572 for (i = 0; i < entity->bNrInPins; ++i) {
1573 id = entity->baSourceID[i];
1574 term = uvc_entity_by_id(chain->dev, id);
1575 if (term == NULL || !UVC_ENTITY_IS_ITERM(term)) {
1576 uvc_trace(UVC_TRACE_DESCR, "Selector unit %d "
1577 "input %d isn't connected to an "
1578 "input terminal\n", entity->id, i);
1582 if (term->chain.next || term->chain.prev) {
1583 uvc_trace(UVC_TRACE_DESCR, "Found reference to "
1584 "entity %d already in chain.\n",
1589 if (uvc_trace_param & UVC_TRACE_PROBE)
1590 printk(KERN_CONT " %d", term->id);
1592 list_add_tail(&term->chain, &chain->entities);
1593 uvc_scan_chain_forward(chain, term, entity);
1596 if (uvc_trace_param & UVC_TRACE_PROBE)
1597 printk(KERN_CONT "\n");
1602 case UVC_ITT_VENDOR_SPECIFIC:
1603 case UVC_ITT_CAMERA:
1604 case UVC_ITT_MEDIA_TRANSPORT_INPUT:
1605 case UVC_OTT_VENDOR_SPECIFIC:
1606 case UVC_OTT_DISPLAY:
1607 case UVC_OTT_MEDIA_TRANSPORT_OUTPUT:
1608 case UVC_TT_STREAMING:
1609 id = UVC_ENTITY_IS_OTERM(entity) ? entity->baSourceID[0] : 0;
1618 entity = uvc_entity_by_id(chain->dev, id);
1619 if (entity == NULL) {
1620 uvc_trace(UVC_TRACE_DESCR, "Found reference to "
1621 "unknown entity %d.\n", id);
1629 static int uvc_scan_chain(struct uvc_video_chain *chain,
1630 struct uvc_entity *term)
1632 struct uvc_entity *entity, *prev;
1634 uvc_trace(UVC_TRACE_PROBE, "Scanning UVC chain:");
1639 while (entity != NULL) {
1640 /* Entity must not be part of an existing chain */
1641 if (entity->chain.next || entity->chain.prev) {
1642 uvc_trace(UVC_TRACE_DESCR, "Found reference to "
1643 "entity %d already in chain.\n", entity->id);
1647 /* Process entity */
1648 if (uvc_scan_chain_entity(chain, entity) < 0)
1652 if (uvc_scan_chain_forward(chain, entity, prev) < 0)
1657 if (uvc_scan_chain_backward(chain, &entity) < 0)
1664 static unsigned int uvc_print_terms(struct list_head *terms, u16 dir,
1667 struct uvc_entity *term;
1668 unsigned int nterms = 0;
1671 list_for_each_entry(term, terms, chain) {
1672 if (!UVC_ENTITY_IS_TERM(term) ||
1673 UVC_TERM_DIRECTION(term) != dir)
1677 p += sprintf(p, ",");
1678 if (++nterms >= 4) {
1679 p += sprintf(p, "...");
1682 p += sprintf(p, "%u", term->id);
1688 static const char *uvc_print_chain(struct uvc_video_chain *chain)
1690 static char buffer[43];
1693 p += uvc_print_terms(&chain->entities, UVC_TERM_INPUT, p);
1694 p += sprintf(p, " -> ");
1695 uvc_print_terms(&chain->entities, UVC_TERM_OUTPUT, p);
1700 static struct uvc_video_chain *uvc_alloc_chain(struct uvc_device *dev)
1702 struct uvc_video_chain *chain;
1704 chain = kzalloc(sizeof(*chain), GFP_KERNEL);
1708 INIT_LIST_HEAD(&chain->entities);
1709 mutex_init(&chain->ctrl_mutex);
1711 v4l2_prio_init(&chain->prio);
1717 * Fallback heuristic for devices that don't connect units and terminals in a
1720 * Some devices have invalid baSourceID references, causing uvc_scan_chain()
1721 * to fail, but if we just take the entities we can find and put them together
1722 * in the most sensible chain we can think of, turns out they do work anyway.
1723 * Note: This heuristic assumes there is a single chain.
1725 * At the time of writing, devices known to have such a broken chain are
1726 * - Acer Integrated Camera (5986:055a)
1727 * - Realtek rtl157a7 (0bda:57a7)
1729 static int uvc_scan_fallback(struct uvc_device *dev)
1731 struct uvc_video_chain *chain;
1732 struct uvc_entity *iterm = NULL;
1733 struct uvc_entity *oterm = NULL;
1734 struct uvc_entity *entity;
1735 struct uvc_entity *prev;
1738 * Start by locating the input and output terminals. We only support
1739 * devices with exactly one of each for now.
1741 list_for_each_entry(entity, &dev->entities, list) {
1742 if (UVC_ENTITY_IS_ITERM(entity)) {
1748 if (UVC_ENTITY_IS_OTERM(entity)) {
1755 if (iterm == NULL || oterm == NULL)
1758 /* Allocate the chain and fill it. */
1759 chain = uvc_alloc_chain(dev);
1763 if (uvc_scan_chain_entity(chain, oterm) < 0)
1769 * Add all Processing and Extension Units with two pads. The order
1770 * doesn't matter much, use reverse list traversal to connect units in
1771 * UVC descriptor order as we build the chain from output to input. This
1772 * leads to units appearing in the order meant by the manufacturer for
1773 * the cameras known to require this heuristic.
1775 list_for_each_entry_reverse(entity, &dev->entities, list) {
1776 if (entity->type != UVC_VC_PROCESSING_UNIT &&
1777 entity->type != UVC_VC_EXTENSION_UNIT)
1780 if (entity->num_pads != 2)
1783 if (uvc_scan_chain_entity(chain, entity) < 0)
1786 prev->baSourceID[0] = entity->id;
1790 if (uvc_scan_chain_entity(chain, iterm) < 0)
1793 prev->baSourceID[0] = iterm->id;
1795 list_add_tail(&chain->list, &dev->chains);
1797 uvc_trace(UVC_TRACE_PROBE,
1798 "Found a video chain by fallback heuristic (%s).\n",
1799 uvc_print_chain(chain));
1809 * Scan the device for video chains and register video devices.
1811 * Chains are scanned starting at their output terminals and walked backwards.
1813 static int uvc_scan_device(struct uvc_device *dev)
1815 struct uvc_video_chain *chain;
1816 struct uvc_entity *term;
1818 list_for_each_entry(term, &dev->entities, list) {
1819 if (!UVC_ENTITY_IS_OTERM(term))
1822 /* If the terminal is already included in a chain, skip it.
1823 * This can happen for chains that have multiple output
1824 * terminals, where all output terminals beside the first one
1825 * will be inserted in the chain in forward scans.
1827 if (term->chain.next || term->chain.prev)
1830 chain = uvc_alloc_chain(dev);
1834 term->flags |= UVC_ENTITY_FLAG_DEFAULT;
1836 if (uvc_scan_chain(chain, term) < 0) {
1841 uvc_trace(UVC_TRACE_PROBE, "Found a valid video chain (%s).\n",
1842 uvc_print_chain(chain));
1844 list_add_tail(&chain->list, &dev->chains);
1847 if (list_empty(&dev->chains))
1848 uvc_scan_fallback(dev);
1850 if (list_empty(&dev->chains)) {
1851 uvc_printk(KERN_INFO, "No valid video chain found.\n");
1858 /* ------------------------------------------------------------------------
1859 * Video device registration and unregistration
1863 * Delete the UVC device.
1865 * Called by the kernel when the last reference to the uvc_device structure
1868 * As this function is called after or during disconnect(), all URBs have
1869 * already been cancelled by the USB core. There is no need to kill the
1870 * interrupt URB manually.
1872 static void uvc_delete(struct kref *kref)
1874 struct uvc_device *dev = container_of(kref, struct uvc_device, ref);
1875 struct list_head *p, *n;
1877 uvc_status_cleanup(dev);
1878 uvc_ctrl_cleanup_device(dev);
1880 usb_put_intf(dev->intf);
1881 usb_put_dev(dev->udev);
1883 #ifdef CONFIG_MEDIA_CONTROLLER
1884 media_device_cleanup(&dev->mdev);
1887 list_for_each_safe(p, n, &dev->chains) {
1888 struct uvc_video_chain *chain;
1889 chain = list_entry(p, struct uvc_video_chain, list);
1893 list_for_each_safe(p, n, &dev->entities) {
1894 struct uvc_entity *entity;
1895 entity = list_entry(p, struct uvc_entity, list);
1896 #ifdef CONFIG_MEDIA_CONTROLLER
1897 uvc_mc_cleanup_entity(entity);
1902 list_for_each_safe(p, n, &dev->streams) {
1903 struct uvc_streaming *streaming;
1904 streaming = list_entry(p, struct uvc_streaming, list);
1905 usb_driver_release_interface(&uvc_driver.driver,
1907 uvc_stream_delete(streaming);
1913 static void uvc_release(struct video_device *vdev)
1915 struct uvc_streaming *stream = video_get_drvdata(vdev);
1916 struct uvc_device *dev = stream->dev;
1918 kref_put(&dev->ref, uvc_delete);
1922 * Unregister the video devices.
1924 static void uvc_unregister_video(struct uvc_device *dev)
1926 struct uvc_streaming *stream;
1928 list_for_each_entry(stream, &dev->streams, list) {
1929 if (!video_is_registered(&stream->vdev))
1932 video_unregister_device(&stream->vdev);
1933 video_unregister_device(&stream->meta.vdev);
1935 uvc_debugfs_cleanup_stream(stream);
1938 uvc_status_unregister(dev);
1941 v4l2_device_unregister(&dev->vdev);
1942 #ifdef CONFIG_MEDIA_CONTROLLER
1943 if (media_devnode_is_registered(dev->mdev.devnode))
1944 media_device_unregister(&dev->mdev);
1948 int uvc_register_video_device(struct uvc_device *dev,
1949 struct uvc_streaming *stream,
1950 struct video_device *vdev,
1951 struct uvc_video_queue *queue,
1952 enum v4l2_buf_type type,
1953 const struct v4l2_file_operations *fops,
1954 const struct v4l2_ioctl_ops *ioctl_ops)
1958 /* Initialize the video buffers queue. */
1959 ret = uvc_queue_init(queue, type, !uvc_no_drop_param);
1963 /* Register the device with V4L. */
1966 * We already hold a reference to dev->udev. The video device will be
1967 * unregistered before the reference is released, so we don't need to
1970 vdev->v4l2_dev = &dev->vdev;
1972 vdev->ioctl_ops = ioctl_ops;
1973 vdev->release = uvc_release;
1974 vdev->prio = &stream->chain->prio;
1975 if (type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
1976 vdev->vfl_dir = VFL_DIR_TX;
1978 vdev->vfl_dir = VFL_DIR_RX;
1981 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
1983 vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
1985 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
1986 vdev->device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING;
1988 case V4L2_BUF_TYPE_META_CAPTURE:
1989 vdev->device_caps = V4L2_CAP_META_CAPTURE | V4L2_CAP_STREAMING;
1993 strscpy(vdev->name, dev->name, sizeof(vdev->name));
1996 * Set the driver data before calling video_register_device, otherwise
1997 * the file open() handler might race us.
1999 video_set_drvdata(vdev, stream);
2001 ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1);
2003 uvc_printk(KERN_ERR, "Failed to register %s device (%d).\n",
2004 v4l2_type_names[type], ret);
2008 kref_get(&dev->ref);
2012 static int uvc_register_video(struct uvc_device *dev,
2013 struct uvc_streaming *stream)
2017 /* Initialize the streaming interface with default parameters. */
2018 ret = uvc_video_init(stream);
2020 uvc_printk(KERN_ERR, "Failed to initialize the device (%d).\n",
2025 if (stream->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
2026 stream->chain->caps |= V4L2_CAP_VIDEO_CAPTURE
2027 | V4L2_CAP_META_CAPTURE;
2029 stream->chain->caps |= V4L2_CAP_VIDEO_OUTPUT;
2031 uvc_debugfs_init_stream(stream);
2033 /* Register the device with V4L. */
2034 return uvc_register_video_device(dev, stream, &stream->vdev,
2035 &stream->queue, stream->type,
2036 &uvc_fops, &uvc_ioctl_ops);
2040 * Register all video devices in all chains.
2042 static int uvc_register_terms(struct uvc_device *dev,
2043 struct uvc_video_chain *chain)
2045 struct uvc_streaming *stream;
2046 struct uvc_entity *term;
2049 list_for_each_entry(term, &chain->entities, chain) {
2050 if (UVC_ENTITY_TYPE(term) != UVC_TT_STREAMING)
2053 stream = uvc_stream_by_id(dev, term->id);
2054 if (stream == NULL) {
2055 uvc_printk(KERN_INFO, "No streaming interface found "
2056 "for terminal %u.", term->id);
2060 stream->chain = chain;
2061 ret = uvc_register_video(dev, stream);
2065 /* Register a metadata node, but ignore a possible failure,
2066 * complete registration of video nodes anyway.
2068 uvc_meta_register(stream);
2070 term->vdev = &stream->vdev;
2076 static int uvc_register_chains(struct uvc_device *dev)
2078 struct uvc_video_chain *chain;
2081 list_for_each_entry(chain, &dev->chains, list) {
2082 ret = uvc_register_terms(dev, chain);
2086 #ifdef CONFIG_MEDIA_CONTROLLER
2087 ret = uvc_mc_register_entities(chain);
2089 uvc_printk(KERN_INFO,
2090 "Failed to register entities (%d).\n", ret);
2097 /* ------------------------------------------------------------------------
2098 * USB probe, disconnect, suspend and resume
2101 static const struct uvc_device_info uvc_quirk_none = { 0 };
2103 static int uvc_probe(struct usb_interface *intf,
2104 const struct usb_device_id *id)
2106 struct usb_device *udev = interface_to_usbdev(intf);
2107 struct uvc_device *dev;
2108 const struct uvc_device_info *info =
2109 (const struct uvc_device_info *)id->driver_info;
2113 if (id->idVendor && id->idProduct)
2114 uvc_trace(UVC_TRACE_PROBE, "Probing known UVC device %s "
2115 "(%04x:%04x)\n", udev->devpath, id->idVendor,
2118 uvc_trace(UVC_TRACE_PROBE, "Probing generic UVC device %s\n",
2121 /* Allocate memory for the device and initialize it. */
2122 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
2126 INIT_LIST_HEAD(&dev->entities);
2127 INIT_LIST_HEAD(&dev->chains);
2128 INIT_LIST_HEAD(&dev->streams);
2129 kref_init(&dev->ref);
2130 atomic_set(&dev->nmappings, 0);
2131 mutex_init(&dev->lock);
2133 dev->udev = usb_get_dev(udev);
2134 dev->intf = usb_get_intf(intf);
2135 dev->intfnum = intf->cur_altsetting->desc.bInterfaceNumber;
2136 dev->info = info ? info : &uvc_quirk_none;
2137 dev->quirks = uvc_quirks_param == -1
2138 ? dev->info->quirks : uvc_quirks_param;
2140 if (udev->product != NULL)
2141 strscpy(dev->name, udev->product, sizeof(dev->name));
2143 snprintf(dev->name, sizeof(dev->name),
2144 "UVC Camera (%04x:%04x)",
2145 le16_to_cpu(udev->descriptor.idVendor),
2146 le16_to_cpu(udev->descriptor.idProduct));
2149 * Add iFunction or iInterface to names when available as additional
2150 * distinguishers between interfaces. iFunction is prioritized over
2151 * iInterface which matches Windows behavior at the point of writing.
2153 if (intf->intf_assoc && intf->intf_assoc->iFunction != 0)
2154 function = intf->intf_assoc->iFunction;
2156 function = intf->cur_altsetting->desc.iInterface;
2157 if (function != 0) {
2160 strlcat(dev->name, ": ", sizeof(dev->name));
2161 len = strlen(dev->name);
2162 usb_string(udev, function, dev->name + len,
2163 sizeof(dev->name) - len);
2166 /* Initialize the media device. */
2167 #ifdef CONFIG_MEDIA_CONTROLLER
2168 dev->mdev.dev = &intf->dev;
2169 strscpy(dev->mdev.model, dev->name, sizeof(dev->mdev.model));
2171 strscpy(dev->mdev.serial, udev->serial,
2172 sizeof(dev->mdev.serial));
2173 usb_make_path(udev, dev->mdev.bus_info, sizeof(dev->mdev.bus_info));
2174 dev->mdev.hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
2175 media_device_init(&dev->mdev);
2177 dev->vdev.mdev = &dev->mdev;
2180 /* Parse the Video Class control descriptor. */
2181 if (uvc_parse_control(dev) < 0) {
2182 uvc_trace(UVC_TRACE_PROBE, "Unable to parse UVC "
2187 uvc_printk(KERN_INFO, "Found UVC %u.%02x device %s (%04x:%04x)\n",
2188 dev->uvc_version >> 8, dev->uvc_version & 0xff,
2189 udev->product ? udev->product : "<unnamed>",
2190 le16_to_cpu(udev->descriptor.idVendor),
2191 le16_to_cpu(udev->descriptor.idProduct));
2193 if (dev->quirks != dev->info->quirks) {
2194 uvc_printk(KERN_INFO, "Forcing device quirks to 0x%x by module "
2195 "parameter for testing purpose.\n", dev->quirks);
2196 uvc_printk(KERN_INFO, "Please report required quirks to the "
2197 "linux-uvc-devel mailing list.\n");
2200 /* Register the V4L2 device. */
2201 if (v4l2_device_register(&intf->dev, &dev->vdev) < 0)
2204 /* Initialize controls. */
2205 if (uvc_ctrl_init_device(dev) < 0)
2208 /* Scan the device for video chains. */
2209 if (uvc_scan_device(dev) < 0)
2212 /* Register video device nodes. */
2213 if (uvc_register_chains(dev) < 0)
2216 #ifdef CONFIG_MEDIA_CONTROLLER
2217 /* Register the media device node */
2218 if (media_device_register(&dev->mdev) < 0)
2221 /* Save our data pointer in the interface data. */
2222 usb_set_intfdata(intf, dev);
2224 /* Initialize the interrupt URB. */
2225 if ((ret = uvc_status_init(dev)) < 0) {
2226 uvc_printk(KERN_INFO, "Unable to initialize the status "
2227 "endpoint (%d), status interrupt will not be "
2228 "supported.\n", ret);
2231 uvc_trace(UVC_TRACE_PROBE, "UVC device initialized.\n");
2232 usb_enable_autosuspend(udev);
2236 uvc_unregister_video(dev);
2237 kref_put(&dev->ref, uvc_delete);
2241 static void uvc_disconnect(struct usb_interface *intf)
2243 struct uvc_device *dev = usb_get_intfdata(intf);
2245 /* Set the USB interface data to NULL. This can be done outside the
2246 * lock, as there's no other reader.
2248 usb_set_intfdata(intf, NULL);
2250 if (intf->cur_altsetting->desc.bInterfaceSubClass ==
2251 UVC_SC_VIDEOSTREAMING)
2254 uvc_unregister_video(dev);
2255 kref_put(&dev->ref, uvc_delete);
2258 static int uvc_suspend(struct usb_interface *intf, pm_message_t message)
2260 struct uvc_device *dev = usb_get_intfdata(intf);
2261 struct uvc_streaming *stream;
2263 uvc_trace(UVC_TRACE_SUSPEND, "Suspending interface %u\n",
2264 intf->cur_altsetting->desc.bInterfaceNumber);
2266 /* Controls are cached on the fly so they don't need to be saved. */
2267 if (intf->cur_altsetting->desc.bInterfaceSubClass ==
2268 UVC_SC_VIDEOCONTROL) {
2269 mutex_lock(&dev->lock);
2271 uvc_status_stop(dev);
2272 mutex_unlock(&dev->lock);
2276 list_for_each_entry(stream, &dev->streams, list) {
2277 if (stream->intf == intf)
2278 return uvc_video_suspend(stream);
2281 uvc_trace(UVC_TRACE_SUSPEND, "Suspend: video streaming USB interface "
2286 static int __uvc_resume(struct usb_interface *intf, int reset)
2288 struct uvc_device *dev = usb_get_intfdata(intf);
2289 struct uvc_streaming *stream;
2292 uvc_trace(UVC_TRACE_SUSPEND, "Resuming interface %u\n",
2293 intf->cur_altsetting->desc.bInterfaceNumber);
2295 if (intf->cur_altsetting->desc.bInterfaceSubClass ==
2296 UVC_SC_VIDEOCONTROL) {
2298 ret = uvc_ctrl_restore_values(dev);
2303 mutex_lock(&dev->lock);
2305 ret = uvc_status_start(dev, GFP_NOIO);
2306 mutex_unlock(&dev->lock);
2311 list_for_each_entry(stream, &dev->streams, list) {
2312 if (stream->intf == intf) {
2313 ret = uvc_video_resume(stream, reset);
2315 uvc_queue_streamoff(&stream->queue,
2316 stream->queue.queue.type);
2321 uvc_trace(UVC_TRACE_SUSPEND, "Resume: video streaming USB interface "
2326 static int uvc_resume(struct usb_interface *intf)
2328 return __uvc_resume(intf, 0);
2331 static int uvc_reset_resume(struct usb_interface *intf)
2333 return __uvc_resume(intf, 1);
2336 /* ------------------------------------------------------------------------
2340 static int uvc_clock_param_get(char *buffer, const struct kernel_param *kp)
2342 if (uvc_clock_param == CLOCK_MONOTONIC)
2343 return sprintf(buffer, "CLOCK_MONOTONIC");
2345 return sprintf(buffer, "CLOCK_REALTIME");
2348 static int uvc_clock_param_set(const char *val, const struct kernel_param *kp)
2350 if (strncasecmp(val, "clock_", strlen("clock_")) == 0)
2351 val += strlen("clock_");
2353 if (strcasecmp(val, "monotonic") == 0)
2354 uvc_clock_param = CLOCK_MONOTONIC;
2355 else if (strcasecmp(val, "realtime") == 0)
2356 uvc_clock_param = CLOCK_REALTIME;
2363 module_param_call(clock, uvc_clock_param_set, uvc_clock_param_get,
2364 &uvc_clock_param, S_IRUGO|S_IWUSR);
2365 MODULE_PARM_DESC(clock, "Video buffers timestamp clock");
2366 module_param_named(hwtimestamps, uvc_hw_timestamps_param, uint, S_IRUGO|S_IWUSR);
2367 MODULE_PARM_DESC(hwtimestamps, "Use hardware timestamps");
2368 module_param_named(nodrop, uvc_no_drop_param, uint, S_IRUGO|S_IWUSR);
2369 MODULE_PARM_DESC(nodrop, "Don't drop incomplete frames");
2370 module_param_named(quirks, uvc_quirks_param, uint, S_IRUGO|S_IWUSR);
2371 MODULE_PARM_DESC(quirks, "Forced device quirks");
2372 module_param_named(trace, uvc_trace_param, uint, S_IRUGO|S_IWUSR);
2373 MODULE_PARM_DESC(trace, "Trace level bitmask");
2374 module_param_named(timeout, uvc_timeout_param, uint, S_IRUGO|S_IWUSR);
2375 MODULE_PARM_DESC(timeout, "Streaming control requests timeout");
2377 /* ------------------------------------------------------------------------
2378 * Driver initialization and cleanup
2381 static const struct uvc_device_info uvc_quirk_probe_minmax = {
2382 .quirks = UVC_QUIRK_PROBE_MINMAX,
2385 static const struct uvc_device_info uvc_quirk_fix_bandwidth = {
2386 .quirks = UVC_QUIRK_FIX_BANDWIDTH,
2389 static const struct uvc_device_info uvc_quirk_probe_def = {
2390 .quirks = UVC_QUIRK_PROBE_DEF,
2393 static const struct uvc_device_info uvc_quirk_stream_no_fid = {
2394 .quirks = UVC_QUIRK_STREAM_NO_FID,
2397 static const struct uvc_device_info uvc_quirk_force_y8 = {
2398 .quirks = UVC_QUIRK_FORCE_Y8,
2401 #define UVC_INFO_QUIRK(q) (kernel_ulong_t)&(struct uvc_device_info){.quirks = q}
2402 #define UVC_INFO_META(m) (kernel_ulong_t)&(struct uvc_device_info) \
2406 * The Logitech cameras listed below have their interface class set to
2407 * VENDOR_SPEC because they don't announce themselves as UVC devices, even
2408 * though they are compliant.
2410 static const struct usb_device_id uvc_ids[] = {
2411 /* LogiLink Wireless Webcam */
2412 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2413 | USB_DEVICE_ID_MATCH_INT_INFO,
2415 .idProduct = 0xa91a,
2416 .bInterfaceClass = USB_CLASS_VIDEO,
2417 .bInterfaceSubClass = 1,
2418 .bInterfaceProtocol = 0,
2419 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2420 /* Genius eFace 2025 */
2421 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2422 | USB_DEVICE_ID_MATCH_INT_INFO,
2424 .idProduct = 0x706e,
2425 .bInterfaceClass = USB_CLASS_VIDEO,
2426 .bInterfaceSubClass = 1,
2427 .bInterfaceProtocol = 0,
2428 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2429 /* Microsoft Lifecam NX-6000 */
2430 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2431 | USB_DEVICE_ID_MATCH_INT_INFO,
2433 .idProduct = 0x00f8,
2434 .bInterfaceClass = USB_CLASS_VIDEO,
2435 .bInterfaceSubClass = 1,
2436 .bInterfaceProtocol = 0,
2437 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2438 /* Microsoft Lifecam NX-3000 */
2439 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2440 | USB_DEVICE_ID_MATCH_INT_INFO,
2442 .idProduct = 0x0721,
2443 .bInterfaceClass = USB_CLASS_VIDEO,
2444 .bInterfaceSubClass = 1,
2445 .bInterfaceProtocol = 0,
2446 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2447 /* Microsoft Lifecam VX-7000 */
2448 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2449 | USB_DEVICE_ID_MATCH_INT_INFO,
2451 .idProduct = 0x0723,
2452 .bInterfaceClass = USB_CLASS_VIDEO,
2453 .bInterfaceSubClass = 1,
2454 .bInterfaceProtocol = 0,
2455 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2456 /* Logitech Quickcam Fusion */
2457 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2458 | USB_DEVICE_ID_MATCH_INT_INFO,
2460 .idProduct = 0x08c1,
2461 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2462 .bInterfaceSubClass = 1,
2463 .bInterfaceProtocol = 0 },
2464 /* Logitech Quickcam Orbit MP */
2465 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2466 | USB_DEVICE_ID_MATCH_INT_INFO,
2468 .idProduct = 0x08c2,
2469 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2470 .bInterfaceSubClass = 1,
2471 .bInterfaceProtocol = 0 },
2472 /* Logitech Quickcam Pro for Notebook */
2473 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2474 | USB_DEVICE_ID_MATCH_INT_INFO,
2476 .idProduct = 0x08c3,
2477 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2478 .bInterfaceSubClass = 1,
2479 .bInterfaceProtocol = 0 },
2480 /* Logitech Quickcam Pro 5000 */
2481 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2482 | USB_DEVICE_ID_MATCH_INT_INFO,
2484 .idProduct = 0x08c5,
2485 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2486 .bInterfaceSubClass = 1,
2487 .bInterfaceProtocol = 0 },
2488 /* Logitech Quickcam OEM Dell Notebook */
2489 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2490 | USB_DEVICE_ID_MATCH_INT_INFO,
2492 .idProduct = 0x08c6,
2493 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2494 .bInterfaceSubClass = 1,
2495 .bInterfaceProtocol = 0 },
2496 /* Logitech Quickcam OEM Cisco VT Camera II */
2497 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2498 | USB_DEVICE_ID_MATCH_INT_INFO,
2500 .idProduct = 0x08c7,
2501 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2502 .bInterfaceSubClass = 1,
2503 .bInterfaceProtocol = 0 },
2504 /* Logitech HD Pro Webcam C920 */
2505 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2506 | USB_DEVICE_ID_MATCH_INT_INFO,
2508 .idProduct = 0x082d,
2509 .bInterfaceClass = USB_CLASS_VIDEO,
2510 .bInterfaceSubClass = 1,
2511 .bInterfaceProtocol = 0,
2512 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_RESTORE_CTRLS_ON_INIT) },
2513 /* Chicony CNF7129 (Asus EEE 100HE) */
2514 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2515 | USB_DEVICE_ID_MATCH_INT_INFO,
2517 .idProduct = 0xb071,
2518 .bInterfaceClass = USB_CLASS_VIDEO,
2519 .bInterfaceSubClass = 1,
2520 .bInterfaceProtocol = 0,
2521 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_RESTRICT_FRAME_RATE) },
2522 /* Alcor Micro AU3820 (Future Boy PC USB Webcam) */
2523 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2524 | USB_DEVICE_ID_MATCH_INT_INFO,
2526 .idProduct = 0x3820,
2527 .bInterfaceClass = USB_CLASS_VIDEO,
2528 .bInterfaceSubClass = 1,
2529 .bInterfaceProtocol = 0,
2530 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2531 /* Dell XPS m1530 */
2532 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2533 | USB_DEVICE_ID_MATCH_INT_INFO,
2535 .idProduct = 0x2640,
2536 .bInterfaceClass = USB_CLASS_VIDEO,
2537 .bInterfaceSubClass = 1,
2538 .bInterfaceProtocol = 0,
2539 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2540 /* Dell SP2008WFP Monitor */
2541 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2542 | USB_DEVICE_ID_MATCH_INT_INFO,
2544 .idProduct = 0x2641,
2545 .bInterfaceClass = USB_CLASS_VIDEO,
2546 .bInterfaceSubClass = 1,
2547 .bInterfaceProtocol = 0,
2548 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2549 /* Dell Alienware X51 */
2550 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2551 | USB_DEVICE_ID_MATCH_INT_INFO,
2553 .idProduct = 0x2643,
2554 .bInterfaceClass = USB_CLASS_VIDEO,
2555 .bInterfaceSubClass = 1,
2556 .bInterfaceProtocol = 0,
2557 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2558 /* Dell Studio Hybrid 140g (OmniVision webcam) */
2559 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2560 | USB_DEVICE_ID_MATCH_INT_INFO,
2562 .idProduct = 0x264a,
2563 .bInterfaceClass = USB_CLASS_VIDEO,
2564 .bInterfaceSubClass = 1,
2565 .bInterfaceProtocol = 0,
2566 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2567 /* Dell XPS M1330 (OmniVision OV7670 webcam) */
2568 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2569 | USB_DEVICE_ID_MATCH_INT_INFO,
2571 .idProduct = 0x7670,
2572 .bInterfaceClass = USB_CLASS_VIDEO,
2573 .bInterfaceSubClass = 1,
2574 .bInterfaceProtocol = 0,
2575 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2576 /* Apple Built-In iSight */
2577 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2578 | USB_DEVICE_ID_MATCH_INT_INFO,
2580 .idProduct = 0x8501,
2581 .bInterfaceClass = USB_CLASS_VIDEO,
2582 .bInterfaceSubClass = 1,
2583 .bInterfaceProtocol = 0,
2584 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_PROBE_MINMAX
2585 | UVC_QUIRK_BUILTIN_ISIGHT) },
2586 /* Apple Built-In iSight via iBridge */
2587 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2588 | USB_DEVICE_ID_MATCH_INT_INFO,
2590 .idProduct = 0x8600,
2591 .bInterfaceClass = USB_CLASS_VIDEO,
2592 .bInterfaceSubClass = 1,
2593 .bInterfaceProtocol = 0,
2594 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2595 /* Foxlink ("HP Webcam" on HP Mini 5103) */
2596 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2597 | USB_DEVICE_ID_MATCH_INT_INFO,
2599 .idProduct = 0x0403,
2600 .bInterfaceClass = USB_CLASS_VIDEO,
2601 .bInterfaceSubClass = 1,
2602 .bInterfaceProtocol = 0,
2603 .driver_info = (kernel_ulong_t)&uvc_quirk_fix_bandwidth },
2604 /* Genesys Logic USB 2.0 PC Camera */
2605 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2606 | USB_DEVICE_ID_MATCH_INT_INFO,
2608 .idProduct = 0x0505,
2609 .bInterfaceClass = USB_CLASS_VIDEO,
2610 .bInterfaceSubClass = 1,
2611 .bInterfaceProtocol = 0,
2612 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2613 /* Hercules Classic Silver */
2614 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2615 | USB_DEVICE_ID_MATCH_INT_INFO,
2617 .idProduct = 0x300c,
2618 .bInterfaceClass = USB_CLASS_VIDEO,
2619 .bInterfaceSubClass = 1,
2620 .bInterfaceProtocol = 0,
2621 .driver_info = (kernel_ulong_t)&uvc_quirk_fix_bandwidth },
2623 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2624 | USB_DEVICE_ID_MATCH_INT_INFO,
2626 .idProduct = 0x332d,
2627 .bInterfaceClass = USB_CLASS_VIDEO,
2628 .bInterfaceSubClass = 1,
2629 .bInterfaceProtocol = 0,
2630 .driver_info = (kernel_ulong_t)&uvc_quirk_fix_bandwidth },
2631 /* ViMicro - Minoru3D */
2632 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2633 | USB_DEVICE_ID_MATCH_INT_INFO,
2635 .idProduct = 0x3410,
2636 .bInterfaceClass = USB_CLASS_VIDEO,
2637 .bInterfaceSubClass = 1,
2638 .bInterfaceProtocol = 0,
2639 .driver_info = (kernel_ulong_t)&uvc_quirk_fix_bandwidth },
2640 /* ViMicro Venus - Minoru3D */
2641 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2642 | USB_DEVICE_ID_MATCH_INT_INFO,
2644 .idProduct = 0x3420,
2645 .bInterfaceClass = USB_CLASS_VIDEO,
2646 .bInterfaceSubClass = 1,
2647 .bInterfaceProtocol = 0,
2648 .driver_info = (kernel_ulong_t)&uvc_quirk_fix_bandwidth },
2649 /* Ophir Optronics - SPCAM 620U */
2650 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2651 | USB_DEVICE_ID_MATCH_INT_INFO,
2653 .idProduct = 0x0555,
2654 .bInterfaceClass = USB_CLASS_VIDEO,
2655 .bInterfaceSubClass = 1,
2656 .bInterfaceProtocol = 0,
2657 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2659 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2660 | USB_DEVICE_ID_MATCH_INT_INFO,
2662 .idProduct = 0x0004,
2663 .bInterfaceClass = USB_CLASS_VIDEO,
2664 .bInterfaceSubClass = 1,
2665 .bInterfaceProtocol = 0,
2666 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_PROBE_MINMAX
2667 | UVC_QUIRK_PROBE_DEF) },
2668 /* IMC Networks (Medion Akoya) */
2669 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2670 | USB_DEVICE_ID_MATCH_INT_INFO,
2672 .idProduct = 0x5103,
2673 .bInterfaceClass = USB_CLASS_VIDEO,
2674 .bInterfaceSubClass = 1,
2675 .bInterfaceProtocol = 0,
2676 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2677 /* JMicron USB2.0 XGA WebCam */
2678 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2679 | USB_DEVICE_ID_MATCH_INT_INFO,
2681 .idProduct = 0x0310,
2682 .bInterfaceClass = USB_CLASS_VIDEO,
2683 .bInterfaceSubClass = 1,
2684 .bInterfaceProtocol = 0,
2685 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2686 /* Syntek (HP Spartan) */
2687 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2688 | USB_DEVICE_ID_MATCH_INT_INFO,
2690 .idProduct = 0x5212,
2691 .bInterfaceClass = USB_CLASS_VIDEO,
2692 .bInterfaceSubClass = 1,
2693 .bInterfaceProtocol = 0,
2694 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2695 /* Syntek (Samsung Q310) */
2696 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2697 | USB_DEVICE_ID_MATCH_INT_INFO,
2699 .idProduct = 0x5931,
2700 .bInterfaceClass = USB_CLASS_VIDEO,
2701 .bInterfaceSubClass = 1,
2702 .bInterfaceProtocol = 0,
2703 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2704 /* Syntek (Packard Bell EasyNote MX52 */
2705 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2706 | USB_DEVICE_ID_MATCH_INT_INFO,
2708 .idProduct = 0x8a12,
2709 .bInterfaceClass = USB_CLASS_VIDEO,
2710 .bInterfaceSubClass = 1,
2711 .bInterfaceProtocol = 0,
2712 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2713 /* Syntek (Asus F9SG) */
2714 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2715 | USB_DEVICE_ID_MATCH_INT_INFO,
2717 .idProduct = 0x8a31,
2718 .bInterfaceClass = USB_CLASS_VIDEO,
2719 .bInterfaceSubClass = 1,
2720 .bInterfaceProtocol = 0,
2721 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2722 /* Syntek (Asus U3S) */
2723 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2724 | USB_DEVICE_ID_MATCH_INT_INFO,
2726 .idProduct = 0x8a33,
2727 .bInterfaceClass = USB_CLASS_VIDEO,
2728 .bInterfaceSubClass = 1,
2729 .bInterfaceProtocol = 0,
2730 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2731 /* Syntek (JAOtech Smart Terminal) */
2732 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2733 | USB_DEVICE_ID_MATCH_INT_INFO,
2735 .idProduct = 0x8a34,
2736 .bInterfaceClass = USB_CLASS_VIDEO,
2737 .bInterfaceSubClass = 1,
2738 .bInterfaceProtocol = 0,
2739 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2741 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2742 | USB_DEVICE_ID_MATCH_INT_INFO,
2744 .idProduct = 0x0202,
2745 .bInterfaceClass = USB_CLASS_VIDEO,
2746 .bInterfaceSubClass = 1,
2747 .bInterfaceProtocol = 0,
2748 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2749 /* Lenovo Thinkpad SL400/SL500 */
2750 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2751 | USB_DEVICE_ID_MATCH_INT_INFO,
2753 .idProduct = 0x480b,
2754 .bInterfaceClass = USB_CLASS_VIDEO,
2755 .bInterfaceSubClass = 1,
2756 .bInterfaceProtocol = 0,
2757 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2758 /* Aveo Technology USB 2.0 Camera */
2759 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2760 | USB_DEVICE_ID_MATCH_INT_INFO,
2762 .idProduct = 0x0306,
2763 .bInterfaceClass = USB_CLASS_VIDEO,
2764 .bInterfaceSubClass = 1,
2765 .bInterfaceProtocol = 0,
2766 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_PROBE_MINMAX
2767 | UVC_QUIRK_PROBE_EXTRAFIELDS) },
2768 /* Aveo Technology USB 2.0 Camera (Tasco USB Microscope) */
2769 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2770 | USB_DEVICE_ID_MATCH_INT_INFO,
2772 .idProduct = 0x0516,
2773 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2774 .bInterfaceSubClass = 1,
2775 .bInterfaceProtocol = 0 },
2776 /* Ecamm Pico iMage */
2777 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2778 | USB_DEVICE_ID_MATCH_INT_INFO,
2780 .idProduct = 0xcafe,
2781 .bInterfaceClass = USB_CLASS_VIDEO,
2782 .bInterfaceSubClass = 1,
2783 .bInterfaceProtocol = 0,
2784 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_PROBE_EXTRAFIELDS) },
2785 /* Manta MM-353 Plako */
2786 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2787 | USB_DEVICE_ID_MATCH_INT_INFO,
2789 .idProduct = 0x3188,
2790 .bInterfaceClass = USB_CLASS_VIDEO,
2791 .bInterfaceSubClass = 1,
2792 .bInterfaceProtocol = 0,
2793 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2794 /* FSC WebCam V30S */
2795 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2796 | USB_DEVICE_ID_MATCH_INT_INFO,
2798 .idProduct = 0x3288,
2799 .bInterfaceClass = USB_CLASS_VIDEO,
2800 .bInterfaceSubClass = 1,
2801 .bInterfaceProtocol = 0,
2802 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2803 /* Arkmicro unbranded */
2804 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2805 | USB_DEVICE_ID_MATCH_INT_INFO,
2807 .idProduct = 0x3290,
2808 .bInterfaceClass = USB_CLASS_VIDEO,
2809 .bInterfaceSubClass = 1,
2810 .bInterfaceProtocol = 0,
2811 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2812 /* The Imaging Source USB CCD cameras */
2813 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2814 | USB_DEVICE_ID_MATCH_INT_INFO,
2816 .idProduct = 0x8102,
2817 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2818 .bInterfaceSubClass = 1,
2819 .bInterfaceProtocol = 0 },
2820 /* Bodelin ProScopeHR */
2821 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2822 | USB_DEVICE_ID_MATCH_DEV_HI
2823 | USB_DEVICE_ID_MATCH_INT_INFO,
2825 .idProduct = 0x1000,
2826 .bcdDevice_hi = 0x0126,
2827 .bInterfaceClass = USB_CLASS_VIDEO,
2828 .bInterfaceSubClass = 1,
2829 .bInterfaceProtocol = 0,
2830 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_STATUS_INTERVAL) },
2831 /* MSI StarCam 370i */
2832 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2833 | USB_DEVICE_ID_MATCH_INT_INFO,
2835 .idProduct = 0x2951,
2836 .bInterfaceClass = USB_CLASS_VIDEO,
2837 .bInterfaceSubClass = 1,
2838 .bInterfaceProtocol = 0,
2839 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2840 /* Generalplus Technology Inc. 808 Camera */
2841 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2842 | USB_DEVICE_ID_MATCH_INT_INFO,
2844 .idProduct = 0x2002,
2845 .bInterfaceClass = USB_CLASS_VIDEO,
2846 .bInterfaceSubClass = 1,
2847 .bInterfaceProtocol = 0,
2848 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2849 /* SiGma Micro USB Web Camera */
2850 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2851 | USB_DEVICE_ID_MATCH_INT_INFO,
2853 .idProduct = 0x3000,
2854 .bInterfaceClass = USB_CLASS_VIDEO,
2855 .bInterfaceSubClass = 1,
2856 .bInterfaceProtocol = 0,
2857 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_PROBE_MINMAX
2858 | UVC_QUIRK_IGNORE_SELECTOR_UNIT) },
2859 /* Oculus VR Positional Tracker DK2 */
2860 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2861 | USB_DEVICE_ID_MATCH_INT_INFO,
2863 .idProduct = 0x0201,
2864 .bInterfaceClass = USB_CLASS_VIDEO,
2865 .bInterfaceSubClass = 1,
2866 .bInterfaceProtocol = 0,
2867 .driver_info = (kernel_ulong_t)&uvc_quirk_force_y8 },
2868 /* Oculus VR Rift Sensor */
2869 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2870 | USB_DEVICE_ID_MATCH_INT_INFO,
2872 .idProduct = 0x0211,
2873 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2874 .bInterfaceSubClass = 1,
2875 .bInterfaceProtocol = 0,
2876 .driver_info = (kernel_ulong_t)&uvc_quirk_force_y8 },
2877 /* Intel RealSense D4M */
2878 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2879 | USB_DEVICE_ID_MATCH_INT_INFO,
2881 .idProduct = 0x0b03,
2882 .bInterfaceClass = USB_CLASS_VIDEO,
2883 .bInterfaceSubClass = 1,
2884 .bInterfaceProtocol = 0,
2885 .driver_info = UVC_INFO_META(V4L2_META_FMT_D4XX) },
2886 /* Generic USB Video Class */
2887 { USB_INTERFACE_INFO(USB_CLASS_VIDEO, 1, UVC_PC_PROTOCOL_UNDEFINED) },
2888 { USB_INTERFACE_INFO(USB_CLASS_VIDEO, 1, UVC_PC_PROTOCOL_15) },
2892 MODULE_DEVICE_TABLE(usb, uvc_ids);
2894 struct uvc_driver uvc_driver = {
2898 .disconnect = uvc_disconnect,
2899 .suspend = uvc_suspend,
2900 .resume = uvc_resume,
2901 .reset_resume = uvc_reset_resume,
2902 .id_table = uvc_ids,
2903 .supports_autosuspend = 1,
2907 static int __init uvc_init(void)
2913 ret = usb_register(&uvc_driver.driver);
2915 uvc_debugfs_cleanup();
2919 printk(KERN_INFO DRIVER_DESC " (" DRIVER_VERSION ")\n");
2923 static void __exit uvc_cleanup(void)
2925 usb_deregister(&uvc_driver.driver);
2926 uvc_debugfs_cleanup();
2929 module_init(uvc_init);
2930 module_exit(uvc_cleanup);
2932 MODULE_AUTHOR(DRIVER_AUTHOR);
2933 MODULE_DESCRIPTION(DRIVER_DESC);
2934 MODULE_LICENSE("GPL");
2935 MODULE_VERSION(DRIVER_VERSION);