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/gpio/consumer.h>
11 #include <linux/kernel.h>
12 #include <linux/list.h>
13 #include <linux/module.h>
14 #include <linux/slab.h>
15 #include <linux/usb.h>
16 #include <linux/videodev2.h>
17 #include <linux/vmalloc.h>
18 #include <linux/wait.h>
19 #include <asm/unaligned.h>
21 #include <media/v4l2-common.h>
22 #include <media/v4l2-ioctl.h>
23 #include <media/v4l2-uvc.h>
27 #define DRIVER_AUTHOR "Laurent Pinchart " \
28 "<laurent.pinchart@ideasonboard.com>"
29 #define DRIVER_DESC "USB Video Class driver"
31 unsigned int uvc_clock_param = CLOCK_MONOTONIC;
32 unsigned int uvc_hw_timestamps_param;
33 unsigned int uvc_no_drop_param;
34 static unsigned int uvc_quirks_param = -1;
35 unsigned int uvc_dbg_param;
36 unsigned int uvc_timeout_param = UVC_CTRL_STREAMING_TIMEOUT;
38 /* ------------------------------------------------------------------------
42 struct usb_host_endpoint *uvc_find_endpoint(struct usb_host_interface *alts,
45 struct usb_host_endpoint *ep;
48 for (i = 0; i < alts->desc.bNumEndpoints; ++i) {
49 ep = &alts->endpoint[i];
50 if (ep->desc.bEndpointAddress == epaddr)
57 static enum v4l2_colorspace uvc_colorspace(const u8 primaries)
59 static const enum v4l2_colorspace colorprimaries[] = {
60 V4L2_COLORSPACE_SRGB, /* Unspecified */
62 V4L2_COLORSPACE_470_SYSTEM_M,
63 V4L2_COLORSPACE_470_SYSTEM_BG,
64 V4L2_COLORSPACE_SMPTE170M,
65 V4L2_COLORSPACE_SMPTE240M,
68 if (primaries < ARRAY_SIZE(colorprimaries))
69 return colorprimaries[primaries];
71 return V4L2_COLORSPACE_SRGB; /* Reserved */
74 static enum v4l2_xfer_func uvc_xfer_func(const u8 transfer_characteristics)
77 * V4L2 does not currently have definitions for all possible values of
78 * UVC transfer characteristics. If v4l2_xfer_func is extended with new
79 * values, the mapping below should be updated.
81 * Substitutions are taken from the mapping given for
82 * V4L2_XFER_FUNC_DEFAULT documented in videodev2.h.
84 static const enum v4l2_xfer_func xfer_funcs[] = {
85 V4L2_XFER_FUNC_DEFAULT, /* Unspecified */
87 V4L2_XFER_FUNC_709, /* Substitution for BT.470-2 M */
88 V4L2_XFER_FUNC_709, /* Substitution for BT.470-2 B, G */
89 V4L2_XFER_FUNC_709, /* Substitution for SMPTE 170M */
90 V4L2_XFER_FUNC_SMPTE240M,
95 if (transfer_characteristics < ARRAY_SIZE(xfer_funcs))
96 return xfer_funcs[transfer_characteristics];
98 return V4L2_XFER_FUNC_DEFAULT; /* Reserved */
101 static enum v4l2_ycbcr_encoding uvc_ycbcr_enc(const u8 matrix_coefficients)
104 * V4L2 does not currently have definitions for all possible values of
105 * UVC matrix coefficients. If v4l2_ycbcr_encoding is extended with new
106 * values, the mapping below should be updated.
108 * Substitutions are taken from the mapping given for
109 * V4L2_YCBCR_ENC_DEFAULT documented in videodev2.h.
111 * FCC is assumed to be close enough to 601.
113 static const enum v4l2_ycbcr_encoding ycbcr_encs[] = {
114 V4L2_YCBCR_ENC_DEFAULT, /* Unspecified */
116 V4L2_YCBCR_ENC_601, /* Substitution for FCC */
117 V4L2_YCBCR_ENC_601, /* Substitution for BT.470-2 B, G */
119 V4L2_YCBCR_ENC_SMPTE240M,
122 if (matrix_coefficients < ARRAY_SIZE(ycbcr_encs))
123 return ycbcr_encs[matrix_coefficients];
125 return V4L2_YCBCR_ENC_DEFAULT; /* Reserved */
128 /* ------------------------------------------------------------------------
129 * Terminal and unit management
132 struct uvc_entity *uvc_entity_by_id(struct uvc_device *dev, int id)
134 struct uvc_entity *entity;
136 list_for_each_entry(entity, &dev->entities, list) {
137 if (entity->id == id)
144 static struct uvc_entity *uvc_entity_by_reference(struct uvc_device *dev,
145 int id, struct uvc_entity *entity)
150 entity = list_entry(&dev->entities, struct uvc_entity, list);
152 list_for_each_entry_continue(entity, &dev->entities, list) {
153 for (i = 0; i < entity->bNrInPins; ++i)
154 if (entity->baSourceID[i] == id)
161 static struct uvc_streaming *uvc_stream_by_id(struct uvc_device *dev, int id)
163 struct uvc_streaming *stream;
165 list_for_each_entry(stream, &dev->streams, list) {
166 if (stream->header.bTerminalLink == id)
173 /* ------------------------------------------------------------------------
174 * Streaming Object Management
177 static void uvc_stream_delete(struct uvc_streaming *stream)
179 if (stream->async_wq)
180 destroy_workqueue(stream->async_wq);
182 mutex_destroy(&stream->mutex);
184 usb_put_intf(stream->intf);
186 kfree(stream->format);
187 kfree(stream->header.bmaControls);
191 static struct uvc_streaming *uvc_stream_new(struct uvc_device *dev,
192 struct usb_interface *intf)
194 struct uvc_streaming *stream;
196 stream = kzalloc(sizeof(*stream), GFP_KERNEL);
200 mutex_init(&stream->mutex);
203 stream->intf = usb_get_intf(intf);
204 stream->intfnum = intf->cur_altsetting->desc.bInterfaceNumber;
206 /* Allocate a stream specific work queue for asynchronous tasks. */
207 stream->async_wq = alloc_workqueue("uvcvideo", WQ_UNBOUND | WQ_HIGHPRI,
209 if (!stream->async_wq) {
210 uvc_stream_delete(stream);
217 /* ------------------------------------------------------------------------
218 * Descriptors parsing
221 static int uvc_parse_format(struct uvc_device *dev,
222 struct uvc_streaming *streaming, struct uvc_format *format,
223 u32 **intervals, unsigned char *buffer, int buflen)
225 struct usb_interface *intf = streaming->intf;
226 struct usb_host_interface *alts = intf->cur_altsetting;
227 struct uvc_format_desc *fmtdesc;
228 struct uvc_frame *frame;
229 const unsigned char *start = buffer;
230 unsigned int width_multiplier = 1;
231 unsigned int interval;
235 format->type = buffer[2];
236 format->index = buffer[3];
239 case UVC_VS_FORMAT_UNCOMPRESSED:
240 case UVC_VS_FORMAT_FRAME_BASED:
241 n = buffer[2] == UVC_VS_FORMAT_UNCOMPRESSED ? 27 : 28;
244 "device %d videostreaming interface %d FORMAT error\n",
246 alts->desc.bInterfaceNumber);
250 /* Find the format descriptor from its GUID. */
251 fmtdesc = uvc_format_by_guid(&buffer[5]);
253 if (fmtdesc != NULL) {
254 strscpy(format->name, fmtdesc->name,
255 sizeof(format->name));
256 format->fcc = fmtdesc->fcc;
258 dev_info(&streaming->intf->dev,
259 "Unknown video format %pUl\n", &buffer[5]);
260 snprintf(format->name, sizeof(format->name), "%pUl\n",
265 format->bpp = buffer[21];
268 * Some devices report a format that doesn't match what they
271 if (dev->quirks & UVC_QUIRK_FORCE_Y8) {
272 if (format->fcc == V4L2_PIX_FMT_YUYV) {
273 strscpy(format->name, "Greyscale 8-bit (Y8 )",
274 sizeof(format->name));
275 format->fcc = V4L2_PIX_FMT_GREY;
277 width_multiplier = 2;
281 /* Some devices report bpp that doesn't match the format. */
282 if (dev->quirks & UVC_QUIRK_FORCE_BPP) {
283 const struct v4l2_format_info *info =
284 v4l2_format_info(format->fcc);
287 unsigned int div = info->hdiv * info->vdiv;
289 n = info->bpp[0] * div;
290 for (i = 1; i < info->comp_planes; i++)
293 format->bpp = DIV_ROUND_UP(8 * n, div);
297 if (buffer[2] == UVC_VS_FORMAT_UNCOMPRESSED) {
298 ftype = UVC_VS_FRAME_UNCOMPRESSED;
300 ftype = UVC_VS_FRAME_FRAME_BASED;
302 format->flags = UVC_FMT_FLAG_COMPRESSED;
306 case UVC_VS_FORMAT_MJPEG:
309 "device %d videostreaming interface %d FORMAT error\n",
311 alts->desc.bInterfaceNumber);
315 strscpy(format->name, "MJPEG", sizeof(format->name));
316 format->fcc = V4L2_PIX_FMT_MJPEG;
317 format->flags = UVC_FMT_FLAG_COMPRESSED;
319 ftype = UVC_VS_FRAME_MJPEG;
322 case UVC_VS_FORMAT_DV:
325 "device %d videostreaming interface %d FORMAT error\n",
327 alts->desc.bInterfaceNumber);
331 switch (buffer[8] & 0x7f) {
333 strscpy(format->name, "SD-DV", sizeof(format->name));
336 strscpy(format->name, "SDL-DV", sizeof(format->name));
339 strscpy(format->name, "HD-DV", sizeof(format->name));
343 "device %d videostreaming interface %d: unknown DV format %u\n",
345 alts->desc.bInterfaceNumber, buffer[8]);
349 strlcat(format->name, buffer[8] & (1 << 7) ? " 60Hz" : " 50Hz",
350 sizeof(format->name));
352 format->fcc = V4L2_PIX_FMT_DV;
353 format->flags = UVC_FMT_FLAG_COMPRESSED | UVC_FMT_FLAG_STREAM;
357 /* Create a dummy frame descriptor. */
358 frame = &format->frame[0];
359 memset(&format->frame[0], 0, sizeof(format->frame[0]));
360 frame->bFrameIntervalType = 1;
361 frame->dwDefaultFrameInterval = 1;
362 frame->dwFrameInterval = *intervals;
367 case UVC_VS_FORMAT_MPEG2TS:
368 case UVC_VS_FORMAT_STREAM_BASED:
369 /* Not supported yet. */
372 "device %d videostreaming interface %d unsupported format %u\n",
373 dev->udev->devnum, alts->desc.bInterfaceNumber,
378 uvc_dbg(dev, DESCR, "Found format %s\n", format->name);
384 * Parse the frame descriptors. Only uncompressed, MJPEG and frame
385 * based formats have frame descriptors.
387 while (buflen > 2 && buffer[1] == USB_DT_CS_INTERFACE &&
388 buffer[2] == ftype) {
389 frame = &format->frame[format->nframes];
390 if (ftype != UVC_VS_FRAME_FRAME_BASED)
391 n = buflen > 25 ? buffer[25] : 0;
393 n = buflen > 21 ? buffer[21] : 0;
397 if (buflen < 26 + 4*n) {
399 "device %d videostreaming interface %d FRAME error\n",
401 alts->desc.bInterfaceNumber);
405 frame->bFrameIndex = buffer[3];
406 frame->bmCapabilities = buffer[4];
407 frame->wWidth = get_unaligned_le16(&buffer[5])
409 frame->wHeight = get_unaligned_le16(&buffer[7]);
410 frame->dwMinBitRate = get_unaligned_le32(&buffer[9]);
411 frame->dwMaxBitRate = get_unaligned_le32(&buffer[13]);
412 if (ftype != UVC_VS_FRAME_FRAME_BASED) {
413 frame->dwMaxVideoFrameBufferSize =
414 get_unaligned_le32(&buffer[17]);
415 frame->dwDefaultFrameInterval =
416 get_unaligned_le32(&buffer[21]);
417 frame->bFrameIntervalType = buffer[25];
419 frame->dwMaxVideoFrameBufferSize = 0;
420 frame->dwDefaultFrameInterval =
421 get_unaligned_le32(&buffer[17]);
422 frame->bFrameIntervalType = buffer[21];
424 frame->dwFrameInterval = *intervals;
427 * Several UVC chipsets screw up dwMaxVideoFrameBufferSize
428 * completely. Observed behaviours range from setting the
429 * value to 1.1x the actual frame size to hardwiring the
430 * 16 low bits to 0. This results in a higher than necessary
431 * memory usage as well as a wrong image size information. For
432 * uncompressed formats this can be fixed by computing the
433 * value from the frame size.
435 if (!(format->flags & UVC_FMT_FLAG_COMPRESSED))
436 frame->dwMaxVideoFrameBufferSize = format->bpp
437 * frame->wWidth * frame->wHeight / 8;
440 * Some bogus devices report dwMinFrameInterval equal to
441 * dwMaxFrameInterval and have dwFrameIntervalStep set to
442 * zero. Setting all null intervals to 1 fixes the problem and
443 * some other divisions by zero that could happen.
445 for (i = 0; i < n; ++i) {
446 interval = get_unaligned_le32(&buffer[26+4*i]);
447 *(*intervals)++ = interval ? interval : 1;
451 * Make sure that the default frame interval stays between
454 n -= frame->bFrameIntervalType ? 1 : 2;
455 frame->dwDefaultFrameInterval =
456 min(frame->dwFrameInterval[n],
457 max(frame->dwFrameInterval[0],
458 frame->dwDefaultFrameInterval));
460 if (dev->quirks & UVC_QUIRK_RESTRICT_FRAME_RATE) {
461 frame->bFrameIntervalType = 1;
462 frame->dwFrameInterval[0] =
463 frame->dwDefaultFrameInterval;
466 uvc_dbg(dev, DESCR, "- %ux%u (%u.%u fps)\n",
467 frame->wWidth, frame->wHeight,
468 10000000 / frame->dwDefaultFrameInterval,
469 (100000000 / frame->dwDefaultFrameInterval) % 10);
476 if (buflen > 2 && buffer[1] == USB_DT_CS_INTERFACE &&
477 buffer[2] == UVC_VS_STILL_IMAGE_FRAME) {
482 if (buflen > 2 && buffer[1] == USB_DT_CS_INTERFACE &&
483 buffer[2] == UVC_VS_COLORFORMAT) {
486 "device %d videostreaming interface %d COLORFORMAT error\n",
488 alts->desc.bInterfaceNumber);
492 format->colorspace = uvc_colorspace(buffer[3]);
493 format->xfer_func = uvc_xfer_func(buffer[4]);
494 format->ycbcr_enc = uvc_ycbcr_enc(buffer[5]);
499 format->colorspace = V4L2_COLORSPACE_SRGB;
502 return buffer - start;
505 static int uvc_parse_streaming(struct uvc_device *dev,
506 struct usb_interface *intf)
508 struct uvc_streaming *streaming = NULL;
509 struct uvc_format *format;
510 struct uvc_frame *frame;
511 struct usb_host_interface *alts = &intf->altsetting[0];
512 unsigned char *_buffer, *buffer = alts->extra;
513 int _buflen, buflen = alts->extralen;
514 unsigned int nformats = 0, nframes = 0, nintervals = 0;
515 unsigned int size, i, n, p;
520 if (intf->cur_altsetting->desc.bInterfaceSubClass
521 != UVC_SC_VIDEOSTREAMING) {
523 "device %d interface %d isn't a video streaming interface\n",
525 intf->altsetting[0].desc.bInterfaceNumber);
529 if (usb_driver_claim_interface(&uvc_driver.driver, intf, dev)) {
531 "device %d interface %d is already claimed\n",
533 intf->altsetting[0].desc.bInterfaceNumber);
537 streaming = uvc_stream_new(dev, intf);
538 if (streaming == NULL) {
539 usb_driver_release_interface(&uvc_driver.driver, intf);
544 * The Pico iMage webcam has its class-specific interface descriptors
545 * after the endpoint descriptors.
548 for (i = 0; i < alts->desc.bNumEndpoints; ++i) {
549 struct usb_host_endpoint *ep = &alts->endpoint[i];
551 if (ep->extralen == 0)
554 if (ep->extralen > 2 &&
555 ep->extra[1] == USB_DT_CS_INTERFACE) {
557 "trying extra data from endpoint %u\n",
559 buffer = alts->endpoint[i].extra;
560 buflen = alts->endpoint[i].extralen;
566 /* Skip the standard interface descriptors. */
567 while (buflen > 2 && buffer[1] != USB_DT_CS_INTERFACE) {
574 "no class-specific streaming interface descriptors found\n");
578 /* Parse the header descriptor. */
580 case UVC_VS_OUTPUT_HEADER:
581 streaming->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
585 case UVC_VS_INPUT_HEADER:
586 streaming->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
592 "device %d videostreaming interface %d HEADER descriptor not found\n",
593 dev->udev->devnum, alts->desc.bInterfaceNumber);
597 p = buflen >= 4 ? buffer[3] : 0;
598 n = buflen >= size ? buffer[size-1] : 0;
600 if (buflen < size + p*n) {
602 "device %d videostreaming interface %d HEADER descriptor is invalid\n",
603 dev->udev->devnum, alts->desc.bInterfaceNumber);
607 streaming->header.bNumFormats = p;
608 streaming->header.bEndpointAddress = buffer[6];
609 if (buffer[2] == UVC_VS_INPUT_HEADER) {
610 streaming->header.bmInfo = buffer[7];
611 streaming->header.bTerminalLink = buffer[8];
612 streaming->header.bStillCaptureMethod = buffer[9];
613 streaming->header.bTriggerSupport = buffer[10];
614 streaming->header.bTriggerUsage = buffer[11];
616 streaming->header.bTerminalLink = buffer[7];
618 streaming->header.bControlSize = n;
620 streaming->header.bmaControls = kmemdup(&buffer[size], p * n,
622 if (streaming->header.bmaControls == NULL) {
633 /* Count the format and frame descriptors. */
634 while (_buflen > 2 && _buffer[1] == USB_DT_CS_INTERFACE) {
635 switch (_buffer[2]) {
636 case UVC_VS_FORMAT_UNCOMPRESSED:
637 case UVC_VS_FORMAT_MJPEG:
638 case UVC_VS_FORMAT_FRAME_BASED:
642 case UVC_VS_FORMAT_DV:
644 * DV format has no frame descriptor. We will create a
645 * dummy frame descriptor with a dummy frame interval.
652 case UVC_VS_FORMAT_MPEG2TS:
653 case UVC_VS_FORMAT_STREAM_BASED:
655 "device %d videostreaming interface %d FORMAT %u is not supported\n",
657 alts->desc.bInterfaceNumber, _buffer[2]);
660 case UVC_VS_FRAME_UNCOMPRESSED:
661 case UVC_VS_FRAME_MJPEG:
664 nintervals += _buffer[25] ? _buffer[25] : 3;
667 case UVC_VS_FRAME_FRAME_BASED:
670 nintervals += _buffer[21] ? _buffer[21] : 3;
674 _buflen -= _buffer[0];
675 _buffer += _buffer[0];
680 "device %d videostreaming interface %d has no supported formats defined\n",
681 dev->udev->devnum, alts->desc.bInterfaceNumber);
685 size = nformats * sizeof(*format) + nframes * sizeof(*frame)
686 + nintervals * sizeof(*interval);
687 format = kzalloc(size, GFP_KERNEL);
688 if (format == NULL) {
693 frame = (struct uvc_frame *)&format[nformats];
694 interval = (u32 *)&frame[nframes];
696 streaming->format = format;
697 streaming->nformats = nformats;
699 /* Parse the format descriptors. */
700 while (buflen > 2 && buffer[1] == USB_DT_CS_INTERFACE) {
702 case UVC_VS_FORMAT_UNCOMPRESSED:
703 case UVC_VS_FORMAT_MJPEG:
704 case UVC_VS_FORMAT_DV:
705 case UVC_VS_FORMAT_FRAME_BASED:
706 format->frame = frame;
707 ret = uvc_parse_format(dev, streaming, format,
708 &interval, buffer, buflen);
712 frame += format->nframes;
729 "device %d videostreaming interface %d has %u bytes of trailing descriptor garbage\n",
730 dev->udev->devnum, alts->desc.bInterfaceNumber, buflen);
732 /* Parse the alternate settings to find the maximum bandwidth. */
733 for (i = 0; i < intf->num_altsetting; ++i) {
734 struct usb_host_endpoint *ep;
735 alts = &intf->altsetting[i];
736 ep = uvc_find_endpoint(alts,
737 streaming->header.bEndpointAddress);
740 psize = uvc_endpoint_max_bpi(dev->udev, ep);
741 if (psize > streaming->maxpsize)
742 streaming->maxpsize = psize;
745 list_add_tail(&streaming->list, &dev->streams);
749 usb_driver_release_interface(&uvc_driver.driver, intf);
750 uvc_stream_delete(streaming);
754 static const u8 uvc_camera_guid[16] = UVC_GUID_UVC_CAMERA;
755 static const u8 uvc_gpio_guid[16] = UVC_GUID_EXT_GPIO_CONTROLLER;
756 static const u8 uvc_media_transport_input_guid[16] =
757 UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT;
758 static const u8 uvc_processing_guid[16] = UVC_GUID_UVC_PROCESSING;
760 static struct uvc_entity *uvc_alloc_entity(u16 type, u16 id,
761 unsigned int num_pads, unsigned int extra_size)
763 struct uvc_entity *entity;
764 unsigned int num_inputs;
768 extra_size = roundup(extra_size, sizeof(*entity->pads));
770 num_inputs = type & UVC_TERM_OUTPUT ? num_pads : num_pads - 1;
773 size = sizeof(*entity) + extra_size + sizeof(*entity->pads) * num_pads
775 entity = kzalloc(size, GFP_KERNEL);
783 * Set the GUID for standard entity types. For extension units, the GUID
784 * is initialized by the caller.
787 case UVC_EXT_GPIO_UNIT:
788 memcpy(entity->guid, uvc_gpio_guid, 16);
791 memcpy(entity->guid, uvc_camera_guid, 16);
793 case UVC_ITT_MEDIA_TRANSPORT_INPUT:
794 memcpy(entity->guid, uvc_media_transport_input_guid, 16);
796 case UVC_VC_PROCESSING_UNIT:
797 memcpy(entity->guid, uvc_processing_guid, 16);
801 entity->num_links = 0;
802 entity->num_pads = num_pads;
803 entity->pads = ((void *)(entity + 1)) + extra_size;
805 for (i = 0; i < num_inputs; ++i)
806 entity->pads[i].flags = MEDIA_PAD_FL_SINK;
807 if (!UVC_ENTITY_IS_OTERM(entity) && num_pads)
808 entity->pads[num_pads-1].flags = MEDIA_PAD_FL_SOURCE;
810 entity->bNrInPins = num_inputs;
811 entity->baSourceID = (u8 *)(&entity->pads[num_pads]);
816 /* Parse vendor-specific extensions. */
817 static int uvc_parse_vendor_control(struct uvc_device *dev,
818 const unsigned char *buffer, int buflen)
820 struct usb_device *udev = dev->udev;
821 struct usb_host_interface *alts = dev->intf->cur_altsetting;
822 struct uvc_entity *unit;
826 switch (le16_to_cpu(dev->udev->descriptor.idVendor)) {
827 case 0x046d: /* Logitech */
828 if (buffer[1] != 0x41 || buffer[2] != 0x01)
832 * Logitech implements several vendor specific functions
833 * through vendor specific extension units (LXU).
835 * The LXU descriptors are similar to XU descriptors
836 * (see "USB Device Video Class for Video Devices", section
837 * 3.7.2.6 "Extension Unit Descriptor") with the following
840 * ----------------------------------------------------------
842 * Size of this descriptor, in bytes: 24+p+n*2
843 * ----------------------------------------------------------
844 * 23+p+n bmControlsType N Bitmap
845 * Individual bits in the set are defined:
849 * This bitset is mapped exactly the same as bmControls.
850 * ----------------------------------------------------------
851 * 23+p+n*2 bReserved 1 Boolean
852 * ----------------------------------------------------------
853 * 24+p+n*2 iExtension 1 Index
854 * Index of a string descriptor that describes this
856 * ----------------------------------------------------------
858 p = buflen >= 22 ? buffer[21] : 0;
859 n = buflen >= 25 + p ? buffer[22+p] : 0;
861 if (buflen < 25 + p + 2*n) {
863 "device %d videocontrol interface %d EXTENSION_UNIT error\n",
864 udev->devnum, alts->desc.bInterfaceNumber);
868 unit = uvc_alloc_entity(UVC_VC_EXTENSION_UNIT, buffer[3],
873 memcpy(unit->guid, &buffer[4], 16);
874 unit->extension.bNumControls = buffer[20];
875 memcpy(unit->baSourceID, &buffer[22], p);
876 unit->extension.bControlSize = buffer[22+p];
877 unit->extension.bmControls = (u8 *)unit + sizeof(*unit);
878 unit->extension.bmControlsType = (u8 *)unit + sizeof(*unit)
880 memcpy(unit->extension.bmControls, &buffer[23+p], 2*n);
882 if (buffer[24+p+2*n] != 0)
883 usb_string(udev, buffer[24+p+2*n], unit->name,
886 sprintf(unit->name, "Extension %u", buffer[3]);
888 list_add_tail(&unit->list, &dev->entities);
896 static int uvc_parse_standard_control(struct uvc_device *dev,
897 const unsigned char *buffer, int buflen)
899 struct usb_device *udev = dev->udev;
900 struct uvc_entity *unit, *term;
901 struct usb_interface *intf;
902 struct usb_host_interface *alts = dev->intf->cur_altsetting;
903 unsigned int i, n, p, len;
908 n = buflen >= 12 ? buffer[11] : 0;
910 if (buflen < 12 + n) {
912 "device %d videocontrol interface %d HEADER error\n",
913 udev->devnum, alts->desc.bInterfaceNumber);
917 dev->uvc_version = get_unaligned_le16(&buffer[3]);
918 dev->clock_frequency = get_unaligned_le32(&buffer[7]);
920 /* Parse all USB Video Streaming interfaces. */
921 for (i = 0; i < n; ++i) {
922 intf = usb_ifnum_to_if(udev, buffer[12+i]);
925 "device %d interface %d doesn't exists\n",
930 uvc_parse_streaming(dev, intf);
934 case UVC_VC_INPUT_TERMINAL:
937 "device %d videocontrol interface %d INPUT_TERMINAL error\n",
938 udev->devnum, alts->desc.bInterfaceNumber);
943 * Reject invalid terminal types that would cause issues:
945 * - The high byte must be non-zero, otherwise it would be
946 * confused with a unit.
948 * - Bit 15 must be 0, as we use it internally as a terminal
951 * Other unknown types are accepted.
953 type = get_unaligned_le16(&buffer[4]);
954 if ((type & 0x7f00) == 0 || (type & 0x8000) != 0) {
956 "device %d videocontrol interface %d INPUT_TERMINAL %d has invalid type 0x%04x, skipping\n",
957 udev->devnum, alts->desc.bInterfaceNumber,
966 if (type == UVC_ITT_CAMERA) {
967 n = buflen >= 15 ? buffer[14] : 0;
970 } else if (type == UVC_ITT_MEDIA_TRANSPORT_INPUT) {
971 n = buflen >= 9 ? buffer[8] : 0;
972 p = buflen >= 10 + n ? buffer[9+n] : 0;
976 if (buflen < len + n + p) {
978 "device %d videocontrol interface %d INPUT_TERMINAL error\n",
979 udev->devnum, alts->desc.bInterfaceNumber);
983 term = uvc_alloc_entity(type | UVC_TERM_INPUT, buffer[3],
988 if (UVC_ENTITY_TYPE(term) == UVC_ITT_CAMERA) {
989 term->camera.bControlSize = n;
990 term->camera.bmControls = (u8 *)term + sizeof(*term);
991 term->camera.wObjectiveFocalLengthMin =
992 get_unaligned_le16(&buffer[8]);
993 term->camera.wObjectiveFocalLengthMax =
994 get_unaligned_le16(&buffer[10]);
995 term->camera.wOcularFocalLength =
996 get_unaligned_le16(&buffer[12]);
997 memcpy(term->camera.bmControls, &buffer[15], n);
998 } else if (UVC_ENTITY_TYPE(term) ==
999 UVC_ITT_MEDIA_TRANSPORT_INPUT) {
1000 term->media.bControlSize = n;
1001 term->media.bmControls = (u8 *)term + sizeof(*term);
1002 term->media.bTransportModeSize = p;
1003 term->media.bmTransportModes = (u8 *)term
1004 + sizeof(*term) + n;
1005 memcpy(term->media.bmControls, &buffer[9], n);
1006 memcpy(term->media.bmTransportModes, &buffer[10+n], p);
1010 usb_string(udev, buffer[7], term->name,
1011 sizeof(term->name));
1012 else if (UVC_ENTITY_TYPE(term) == UVC_ITT_CAMERA)
1013 sprintf(term->name, "Camera %u", buffer[3]);
1014 else if (UVC_ENTITY_TYPE(term) == UVC_ITT_MEDIA_TRANSPORT_INPUT)
1015 sprintf(term->name, "Media %u", buffer[3]);
1017 sprintf(term->name, "Input %u", buffer[3]);
1019 list_add_tail(&term->list, &dev->entities);
1022 case UVC_VC_OUTPUT_TERMINAL:
1025 "device %d videocontrol interface %d OUTPUT_TERMINAL error\n",
1026 udev->devnum, alts->desc.bInterfaceNumber);
1031 * Make sure the terminal type MSB is not null, otherwise it
1032 * could be confused with a unit.
1034 type = get_unaligned_le16(&buffer[4]);
1035 if ((type & 0xff00) == 0) {
1037 "device %d videocontrol interface %d OUTPUT_TERMINAL %d has invalid type 0x%04x, skipping\n",
1038 udev->devnum, alts->desc.bInterfaceNumber,
1043 term = uvc_alloc_entity(type | UVC_TERM_OUTPUT, buffer[3],
1048 memcpy(term->baSourceID, &buffer[7], 1);
1051 usb_string(udev, buffer[8], term->name,
1052 sizeof(term->name));
1054 sprintf(term->name, "Output %u", buffer[3]);
1056 list_add_tail(&term->list, &dev->entities);
1059 case UVC_VC_SELECTOR_UNIT:
1060 p = buflen >= 5 ? buffer[4] : 0;
1062 if (buflen < 5 || buflen < 6 + p) {
1064 "device %d videocontrol interface %d SELECTOR_UNIT error\n",
1065 udev->devnum, alts->desc.bInterfaceNumber);
1069 unit = uvc_alloc_entity(buffer[2], buffer[3], p + 1, 0);
1073 memcpy(unit->baSourceID, &buffer[5], p);
1075 if (buffer[5+p] != 0)
1076 usb_string(udev, buffer[5+p], unit->name,
1077 sizeof(unit->name));
1079 sprintf(unit->name, "Selector %u", buffer[3]);
1081 list_add_tail(&unit->list, &dev->entities);
1084 case UVC_VC_PROCESSING_UNIT:
1085 n = buflen >= 8 ? buffer[7] : 0;
1086 p = dev->uvc_version >= 0x0110 ? 10 : 9;
1088 if (buflen < p + n) {
1090 "device %d videocontrol interface %d PROCESSING_UNIT error\n",
1091 udev->devnum, alts->desc.bInterfaceNumber);
1095 unit = uvc_alloc_entity(buffer[2], buffer[3], 2, n);
1099 memcpy(unit->baSourceID, &buffer[4], 1);
1100 unit->processing.wMaxMultiplier =
1101 get_unaligned_le16(&buffer[5]);
1102 unit->processing.bControlSize = buffer[7];
1103 unit->processing.bmControls = (u8 *)unit + sizeof(*unit);
1104 memcpy(unit->processing.bmControls, &buffer[8], n);
1105 if (dev->uvc_version >= 0x0110)
1106 unit->processing.bmVideoStandards = buffer[9+n];
1108 if (buffer[8+n] != 0)
1109 usb_string(udev, buffer[8+n], unit->name,
1110 sizeof(unit->name));
1112 sprintf(unit->name, "Processing %u", buffer[3]);
1114 list_add_tail(&unit->list, &dev->entities);
1117 case UVC_VC_EXTENSION_UNIT:
1118 p = buflen >= 22 ? buffer[21] : 0;
1119 n = buflen >= 24 + p ? buffer[22+p] : 0;
1121 if (buflen < 24 + p + n) {
1123 "device %d videocontrol interface %d EXTENSION_UNIT error\n",
1124 udev->devnum, alts->desc.bInterfaceNumber);
1128 unit = uvc_alloc_entity(buffer[2], buffer[3], p + 1, n);
1132 memcpy(unit->guid, &buffer[4], 16);
1133 unit->extension.bNumControls = buffer[20];
1134 memcpy(unit->baSourceID, &buffer[22], p);
1135 unit->extension.bControlSize = buffer[22+p];
1136 unit->extension.bmControls = (u8 *)unit + sizeof(*unit);
1137 memcpy(unit->extension.bmControls, &buffer[23+p], n);
1139 if (buffer[23+p+n] != 0)
1140 usb_string(udev, buffer[23+p+n], unit->name,
1141 sizeof(unit->name));
1143 sprintf(unit->name, "Extension %u", buffer[3]);
1145 list_add_tail(&unit->list, &dev->entities);
1150 "Found an unknown CS_INTERFACE descriptor (%u)\n",
1158 static int uvc_parse_control(struct uvc_device *dev)
1160 struct usb_host_interface *alts = dev->intf->cur_altsetting;
1161 unsigned char *buffer = alts->extra;
1162 int buflen = alts->extralen;
1166 * Parse the default alternate setting only, as the UVC specification
1167 * defines a single alternate setting, the default alternate setting
1171 while (buflen > 2) {
1172 if (uvc_parse_vendor_control(dev, buffer, buflen) ||
1173 buffer[1] != USB_DT_CS_INTERFACE)
1174 goto next_descriptor;
1176 if ((ret = uvc_parse_standard_control(dev, buffer, buflen)) < 0)
1180 buflen -= buffer[0];
1181 buffer += buffer[0];
1185 * Check if the optional status endpoint is present. Built-in iSight
1186 * webcams have an interrupt endpoint but spit proprietary data that
1187 * don't conform to the UVC status endpoint messages. Don't try to
1188 * handle the interrupt endpoint for those cameras.
1190 if (alts->desc.bNumEndpoints == 1 &&
1191 !(dev->quirks & UVC_QUIRK_BUILTIN_ISIGHT)) {
1192 struct usb_host_endpoint *ep = &alts->endpoint[0];
1193 struct usb_endpoint_descriptor *desc = &ep->desc;
1195 if (usb_endpoint_is_int_in(desc) &&
1196 le16_to_cpu(desc->wMaxPacketSize) >= 8 &&
1197 desc->bInterval != 0) {
1199 "Found a Status endpoint (addr %02x)\n",
1200 desc->bEndpointAddress);
1208 /* -----------------------------------------------------------------------------
1212 static void uvc_gpio_event(struct uvc_device *dev)
1214 struct uvc_entity *unit = dev->gpio_unit;
1215 struct uvc_video_chain *chain;
1221 new_val = gpiod_get_value_cansleep(unit->gpio.gpio_privacy);
1223 /* GPIO entities are always on the first chain. */
1224 chain = list_first_entry(&dev->chains, struct uvc_video_chain, list);
1225 uvc_ctrl_status_event(chain, unit->controls, &new_val);
1228 static int uvc_gpio_get_cur(struct uvc_device *dev, struct uvc_entity *entity,
1229 u8 cs, void *data, u16 size)
1231 if (cs != UVC_CT_PRIVACY_CONTROL || size < 1)
1234 *(u8 *)data = gpiod_get_value_cansleep(entity->gpio.gpio_privacy);
1239 static int uvc_gpio_get_info(struct uvc_device *dev, struct uvc_entity *entity,
1242 if (cs != UVC_CT_PRIVACY_CONTROL)
1245 *caps = UVC_CONTROL_CAP_GET | UVC_CONTROL_CAP_AUTOUPDATE;
1249 static irqreturn_t uvc_gpio_irq(int irq, void *data)
1251 struct uvc_device *dev = data;
1253 uvc_gpio_event(dev);
1257 static int uvc_gpio_parse(struct uvc_device *dev)
1259 struct uvc_entity *unit;
1260 struct gpio_desc *gpio_privacy;
1263 gpio_privacy = devm_gpiod_get_optional(&dev->udev->dev, "privacy",
1265 if (IS_ERR_OR_NULL(gpio_privacy))
1266 return PTR_ERR_OR_ZERO(gpio_privacy);
1268 irq = gpiod_to_irq(gpio_privacy);
1270 if (irq != EPROBE_DEFER)
1271 dev_err(&dev->udev->dev,
1272 "No IRQ for privacy GPIO (%d)\n", irq);
1276 unit = uvc_alloc_entity(UVC_EXT_GPIO_UNIT, UVC_EXT_GPIO_UNIT_ID, 0, 1);
1280 unit->gpio.gpio_privacy = gpio_privacy;
1281 unit->gpio.irq = irq;
1282 unit->gpio.bControlSize = 1;
1283 unit->gpio.bmControls = (u8 *)unit + sizeof(*unit);
1284 unit->gpio.bmControls[0] = 1;
1285 unit->get_cur = uvc_gpio_get_cur;
1286 unit->get_info = uvc_gpio_get_info;
1287 strscpy(unit->name, "GPIO", sizeof(unit->name));
1289 list_add_tail(&unit->list, &dev->entities);
1291 dev->gpio_unit = unit;
1296 static int uvc_gpio_init_irq(struct uvc_device *dev)
1298 struct uvc_entity *unit = dev->gpio_unit;
1300 if (!unit || unit->gpio.irq < 0)
1303 return devm_request_threaded_irq(&dev->udev->dev, unit->gpio.irq, NULL,
1305 IRQF_ONESHOT | IRQF_TRIGGER_FALLING |
1306 IRQF_TRIGGER_RISING,
1307 "uvc_privacy_gpio", dev);
1310 /* ------------------------------------------------------------------------
1315 * Scan the UVC descriptors to locate a chain starting at an Output Terminal
1316 * and containing the following units:
1318 * - one or more Output Terminals (USB Streaming or Display)
1319 * - zero or one Processing Unit
1320 * - zero, one or more single-input Selector Units
1321 * - zero or one multiple-input Selector Units, provided all inputs are
1322 * connected to input terminals
1323 * - zero, one or mode single-input Extension Units
1324 * - one or more Input Terminals (Camera, External or USB Streaming)
1326 * The terminal and units must match on of the following structures:
1328 * ITT_*(0) -> +---------+ +---------+ +---------+ -> TT_STREAMING(0)
1329 * ... | SU{0,1} | -> | PU{0,1} | -> | XU{0,n} | ...
1330 * ITT_*(n) -> +---------+ +---------+ +---------+ -> TT_STREAMING(n)
1332 * +---------+ +---------+ -> OTT_*(0)
1333 * TT_STREAMING -> | PU{0,1} | -> | XU{0,n} | ...
1334 * +---------+ +---------+ -> OTT_*(n)
1336 * The Processing Unit and Extension Units can be in any order. Additional
1337 * Extension Units connected to the main chain as single-unit branches are
1338 * also supported. Single-input Selector Units are ignored.
1340 static int uvc_scan_chain_entity(struct uvc_video_chain *chain,
1341 struct uvc_entity *entity)
1343 switch (UVC_ENTITY_TYPE(entity)) {
1344 case UVC_VC_EXTENSION_UNIT:
1345 uvc_dbg_cont(PROBE, " <- XU %d", entity->id);
1347 if (entity->bNrInPins != 1) {
1348 uvc_dbg(chain->dev, DESCR,
1349 "Extension unit %d has more than 1 input pin\n",
1356 case UVC_VC_PROCESSING_UNIT:
1357 uvc_dbg_cont(PROBE, " <- PU %d", entity->id);
1359 if (chain->processing != NULL) {
1360 uvc_dbg(chain->dev, DESCR,
1361 "Found multiple Processing Units in chain\n");
1365 chain->processing = entity;
1368 case UVC_VC_SELECTOR_UNIT:
1369 uvc_dbg_cont(PROBE, " <- SU %d", entity->id);
1371 /* Single-input selector units are ignored. */
1372 if (entity->bNrInPins == 1)
1375 if (chain->selector != NULL) {
1376 uvc_dbg(chain->dev, DESCR,
1377 "Found multiple Selector Units in chain\n");
1381 chain->selector = entity;
1384 case UVC_ITT_VENDOR_SPECIFIC:
1385 case UVC_ITT_CAMERA:
1386 case UVC_ITT_MEDIA_TRANSPORT_INPUT:
1387 uvc_dbg_cont(PROBE, " <- IT %d\n", entity->id);
1391 case UVC_OTT_VENDOR_SPECIFIC:
1392 case UVC_OTT_DISPLAY:
1393 case UVC_OTT_MEDIA_TRANSPORT_OUTPUT:
1394 uvc_dbg_cont(PROBE, " OT %d", entity->id);
1398 case UVC_TT_STREAMING:
1399 if (UVC_ENTITY_IS_ITERM(entity))
1400 uvc_dbg_cont(PROBE, " <- IT %d\n", entity->id);
1402 uvc_dbg_cont(PROBE, " OT %d", entity->id);
1407 uvc_dbg(chain->dev, DESCR,
1408 "Unsupported entity type 0x%04x found in chain\n",
1409 UVC_ENTITY_TYPE(entity));
1413 list_add_tail(&entity->chain, &chain->entities);
1417 static int uvc_scan_chain_forward(struct uvc_video_chain *chain,
1418 struct uvc_entity *entity, struct uvc_entity *prev)
1420 struct uvc_entity *forward;
1428 forward = uvc_entity_by_reference(chain->dev, entity->id,
1430 if (forward == NULL)
1432 if (forward == prev)
1434 if (forward->chain.next || forward->chain.prev) {
1435 uvc_dbg(chain->dev, DESCR,
1436 "Found reference to entity %d already in chain\n",
1441 switch (UVC_ENTITY_TYPE(forward)) {
1442 case UVC_VC_EXTENSION_UNIT:
1443 if (forward->bNrInPins != 1) {
1444 uvc_dbg(chain->dev, DESCR,
1445 "Extension unit %d has more than 1 input pin\n",
1451 * Some devices reference an output terminal as the
1452 * source of extension units. This is incorrect, as
1453 * output terminals only have an input pin, and thus
1454 * can't be connected to any entity in the forward
1455 * direction. The resulting topology would cause issues
1456 * when registering the media controller graph. To
1457 * avoid this problem, connect the extension unit to
1458 * the source of the output terminal instead.
1460 if (UVC_ENTITY_IS_OTERM(entity)) {
1461 struct uvc_entity *source;
1463 source = uvc_entity_by_id(chain->dev,
1464 entity->baSourceID[0]);
1466 uvc_dbg(chain->dev, DESCR,
1467 "Can't connect extension unit %u in chain\n",
1472 forward->baSourceID[0] = source->id;
1475 list_add_tail(&forward->chain, &chain->entities);
1477 uvc_dbg_cont(PROBE, " (->");
1479 uvc_dbg_cont(PROBE, " XU %d", forward->id);
1483 case UVC_OTT_VENDOR_SPECIFIC:
1484 case UVC_OTT_DISPLAY:
1485 case UVC_OTT_MEDIA_TRANSPORT_OUTPUT:
1486 case UVC_TT_STREAMING:
1487 if (UVC_ENTITY_IS_ITERM(forward)) {
1488 uvc_dbg(chain->dev, DESCR,
1489 "Unsupported input terminal %u\n",
1494 if (UVC_ENTITY_IS_OTERM(entity)) {
1495 uvc_dbg(chain->dev, DESCR,
1496 "Unsupported connection between output terminals %u and %u\n",
1497 entity->id, forward->id);
1501 list_add_tail(&forward->chain, &chain->entities);
1503 uvc_dbg_cont(PROBE, " (->");
1505 uvc_dbg_cont(PROBE, " OT %d", forward->id);
1511 uvc_dbg_cont(PROBE, ")");
1516 static int uvc_scan_chain_backward(struct uvc_video_chain *chain,
1517 struct uvc_entity **_entity)
1519 struct uvc_entity *entity = *_entity;
1520 struct uvc_entity *term;
1521 int id = -EINVAL, i;
1523 switch (UVC_ENTITY_TYPE(entity)) {
1524 case UVC_VC_EXTENSION_UNIT:
1525 case UVC_VC_PROCESSING_UNIT:
1526 id = entity->baSourceID[0];
1529 case UVC_VC_SELECTOR_UNIT:
1530 /* Single-input selector units are ignored. */
1531 if (entity->bNrInPins == 1) {
1532 id = entity->baSourceID[0];
1536 uvc_dbg_cont(PROBE, " <- IT");
1538 chain->selector = entity;
1539 for (i = 0; i < entity->bNrInPins; ++i) {
1540 id = entity->baSourceID[i];
1541 term = uvc_entity_by_id(chain->dev, id);
1542 if (term == NULL || !UVC_ENTITY_IS_ITERM(term)) {
1543 uvc_dbg(chain->dev, DESCR,
1544 "Selector unit %d input %d isn't connected to an input terminal\n",
1549 if (term->chain.next || term->chain.prev) {
1550 uvc_dbg(chain->dev, DESCR,
1551 "Found reference to entity %d already in chain\n",
1556 uvc_dbg_cont(PROBE, " %d", term->id);
1558 list_add_tail(&term->chain, &chain->entities);
1559 uvc_scan_chain_forward(chain, term, entity);
1562 uvc_dbg_cont(PROBE, "\n");
1567 case UVC_ITT_VENDOR_SPECIFIC:
1568 case UVC_ITT_CAMERA:
1569 case UVC_ITT_MEDIA_TRANSPORT_INPUT:
1570 case UVC_OTT_VENDOR_SPECIFIC:
1571 case UVC_OTT_DISPLAY:
1572 case UVC_OTT_MEDIA_TRANSPORT_OUTPUT:
1573 case UVC_TT_STREAMING:
1574 id = UVC_ENTITY_IS_OTERM(entity) ? entity->baSourceID[0] : 0;
1583 entity = uvc_entity_by_id(chain->dev, id);
1584 if (entity == NULL) {
1585 uvc_dbg(chain->dev, DESCR,
1586 "Found reference to unknown entity %d\n", id);
1594 static int uvc_scan_chain(struct uvc_video_chain *chain,
1595 struct uvc_entity *term)
1597 struct uvc_entity *entity, *prev;
1599 uvc_dbg(chain->dev, PROBE, "Scanning UVC chain:");
1604 while (entity != NULL) {
1605 /* Entity must not be part of an existing chain */
1606 if (entity->chain.next || entity->chain.prev) {
1607 uvc_dbg(chain->dev, DESCR,
1608 "Found reference to entity %d already in chain\n",
1613 /* Process entity */
1614 if (uvc_scan_chain_entity(chain, entity) < 0)
1618 if (uvc_scan_chain_forward(chain, entity, prev) < 0)
1623 if (uvc_scan_chain_backward(chain, &entity) < 0)
1630 static unsigned int uvc_print_terms(struct list_head *terms, u16 dir,
1633 struct uvc_entity *term;
1634 unsigned int nterms = 0;
1637 list_for_each_entry(term, terms, chain) {
1638 if (!UVC_ENTITY_IS_TERM(term) ||
1639 UVC_TERM_DIRECTION(term) != dir)
1643 p += sprintf(p, ",");
1644 if (++nterms >= 4) {
1645 p += sprintf(p, "...");
1648 p += sprintf(p, "%u", term->id);
1654 static const char *uvc_print_chain(struct uvc_video_chain *chain)
1656 static char buffer[43];
1659 p += uvc_print_terms(&chain->entities, UVC_TERM_INPUT, p);
1660 p += sprintf(p, " -> ");
1661 uvc_print_terms(&chain->entities, UVC_TERM_OUTPUT, p);
1666 static struct uvc_video_chain *uvc_alloc_chain(struct uvc_device *dev)
1668 struct uvc_video_chain *chain;
1670 chain = kzalloc(sizeof(*chain), GFP_KERNEL);
1674 INIT_LIST_HEAD(&chain->entities);
1675 mutex_init(&chain->ctrl_mutex);
1677 v4l2_prio_init(&chain->prio);
1683 * Fallback heuristic for devices that don't connect units and terminals in a
1686 * Some devices have invalid baSourceID references, causing uvc_scan_chain()
1687 * to fail, but if we just take the entities we can find and put them together
1688 * in the most sensible chain we can think of, turns out they do work anyway.
1689 * Note: This heuristic assumes there is a single chain.
1691 * At the time of writing, devices known to have such a broken chain are
1692 * - Acer Integrated Camera (5986:055a)
1693 * - Realtek rtl157a7 (0bda:57a7)
1695 static int uvc_scan_fallback(struct uvc_device *dev)
1697 struct uvc_video_chain *chain;
1698 struct uvc_entity *iterm = NULL;
1699 struct uvc_entity *oterm = NULL;
1700 struct uvc_entity *entity;
1701 struct uvc_entity *prev;
1704 * Start by locating the input and output terminals. We only support
1705 * devices with exactly one of each for now.
1707 list_for_each_entry(entity, &dev->entities, list) {
1708 if (UVC_ENTITY_IS_ITERM(entity)) {
1714 if (UVC_ENTITY_IS_OTERM(entity)) {
1721 if (iterm == NULL || oterm == NULL)
1724 /* Allocate the chain and fill it. */
1725 chain = uvc_alloc_chain(dev);
1729 if (uvc_scan_chain_entity(chain, oterm) < 0)
1735 * Add all Processing and Extension Units with two pads. The order
1736 * doesn't matter much, use reverse list traversal to connect units in
1737 * UVC descriptor order as we build the chain from output to input. This
1738 * leads to units appearing in the order meant by the manufacturer for
1739 * the cameras known to require this heuristic.
1741 list_for_each_entry_reverse(entity, &dev->entities, list) {
1742 if (entity->type != UVC_VC_PROCESSING_UNIT &&
1743 entity->type != UVC_VC_EXTENSION_UNIT)
1746 if (entity->num_pads != 2)
1749 if (uvc_scan_chain_entity(chain, entity) < 0)
1752 prev->baSourceID[0] = entity->id;
1756 if (uvc_scan_chain_entity(chain, iterm) < 0)
1759 prev->baSourceID[0] = iterm->id;
1761 list_add_tail(&chain->list, &dev->chains);
1763 uvc_dbg(dev, PROBE, "Found a video chain by fallback heuristic (%s)\n",
1764 uvc_print_chain(chain));
1774 * Scan the device for video chains and register video devices.
1776 * Chains are scanned starting at their output terminals and walked backwards.
1778 static int uvc_scan_device(struct uvc_device *dev)
1780 struct uvc_video_chain *chain;
1781 struct uvc_entity *term;
1783 list_for_each_entry(term, &dev->entities, list) {
1784 if (!UVC_ENTITY_IS_OTERM(term))
1788 * If the terminal is already included in a chain, skip it.
1789 * This can happen for chains that have multiple output
1790 * terminals, where all output terminals beside the first one
1791 * will be inserted in the chain in forward scans.
1793 if (term->chain.next || term->chain.prev)
1796 chain = uvc_alloc_chain(dev);
1800 term->flags |= UVC_ENTITY_FLAG_DEFAULT;
1802 if (uvc_scan_chain(chain, term) < 0) {
1807 uvc_dbg(dev, PROBE, "Found a valid video chain (%s)\n",
1808 uvc_print_chain(chain));
1810 list_add_tail(&chain->list, &dev->chains);
1813 if (list_empty(&dev->chains))
1814 uvc_scan_fallback(dev);
1816 if (list_empty(&dev->chains)) {
1817 dev_info(&dev->udev->dev, "No valid video chain found.\n");
1821 /* Add GPIO entity to the first chain. */
1822 if (dev->gpio_unit) {
1823 chain = list_first_entry(&dev->chains,
1824 struct uvc_video_chain, list);
1825 list_add_tail(&dev->gpio_unit->chain, &chain->entities);
1831 /* ------------------------------------------------------------------------
1832 * Video device registration and unregistration
1836 * Delete the UVC device.
1838 * Called by the kernel when the last reference to the uvc_device structure
1841 * As this function is called after or during disconnect(), all URBs have
1842 * already been cancelled by the USB core. There is no need to kill the
1843 * interrupt URB manually.
1845 static void uvc_delete(struct kref *kref)
1847 struct uvc_device *dev = container_of(kref, struct uvc_device, ref);
1848 struct list_head *p, *n;
1850 uvc_status_cleanup(dev);
1851 uvc_ctrl_cleanup_device(dev);
1853 usb_put_intf(dev->intf);
1854 usb_put_dev(dev->udev);
1856 #ifdef CONFIG_MEDIA_CONTROLLER
1857 media_device_cleanup(&dev->mdev);
1860 list_for_each_safe(p, n, &dev->chains) {
1861 struct uvc_video_chain *chain;
1862 chain = list_entry(p, struct uvc_video_chain, list);
1866 list_for_each_safe(p, n, &dev->entities) {
1867 struct uvc_entity *entity;
1868 entity = list_entry(p, struct uvc_entity, list);
1869 #ifdef CONFIG_MEDIA_CONTROLLER
1870 uvc_mc_cleanup_entity(entity);
1875 list_for_each_safe(p, n, &dev->streams) {
1876 struct uvc_streaming *streaming;
1877 streaming = list_entry(p, struct uvc_streaming, list);
1878 usb_driver_release_interface(&uvc_driver.driver,
1880 uvc_stream_delete(streaming);
1886 static void uvc_release(struct video_device *vdev)
1888 struct uvc_streaming *stream = video_get_drvdata(vdev);
1889 struct uvc_device *dev = stream->dev;
1891 kref_put(&dev->ref, uvc_delete);
1895 * Unregister the video devices.
1897 static void uvc_unregister_video(struct uvc_device *dev)
1899 struct uvc_streaming *stream;
1901 list_for_each_entry(stream, &dev->streams, list) {
1902 if (!video_is_registered(&stream->vdev))
1905 video_unregister_device(&stream->vdev);
1906 video_unregister_device(&stream->meta.vdev);
1908 uvc_debugfs_cleanup_stream(stream);
1911 uvc_status_unregister(dev);
1914 v4l2_device_unregister(&dev->vdev);
1915 #ifdef CONFIG_MEDIA_CONTROLLER
1916 if (media_devnode_is_registered(dev->mdev.devnode))
1917 media_device_unregister(&dev->mdev);
1921 int uvc_register_video_device(struct uvc_device *dev,
1922 struct uvc_streaming *stream,
1923 struct video_device *vdev,
1924 struct uvc_video_queue *queue,
1925 enum v4l2_buf_type type,
1926 const struct v4l2_file_operations *fops,
1927 const struct v4l2_ioctl_ops *ioctl_ops)
1931 /* Initialize the video buffers queue. */
1932 ret = uvc_queue_init(queue, type, !uvc_no_drop_param);
1936 /* Register the device with V4L. */
1939 * We already hold a reference to dev->udev. The video device will be
1940 * unregistered before the reference is released, so we don't need to
1943 vdev->v4l2_dev = &dev->vdev;
1945 vdev->ioctl_ops = ioctl_ops;
1946 vdev->release = uvc_release;
1947 vdev->prio = &stream->chain->prio;
1948 if (type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
1949 vdev->vfl_dir = VFL_DIR_TX;
1951 vdev->vfl_dir = VFL_DIR_RX;
1954 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
1956 vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
1958 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
1959 vdev->device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING;
1961 case V4L2_BUF_TYPE_META_CAPTURE:
1962 vdev->device_caps = V4L2_CAP_META_CAPTURE | V4L2_CAP_STREAMING;
1966 strscpy(vdev->name, dev->name, sizeof(vdev->name));
1969 * Set the driver data before calling video_register_device, otherwise
1970 * the file open() handler might race us.
1972 video_set_drvdata(vdev, stream);
1974 ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1);
1976 dev_err(&stream->intf->dev,
1977 "Failed to register %s device (%d).\n",
1978 v4l2_type_names[type], ret);
1982 kref_get(&dev->ref);
1986 static int uvc_register_video(struct uvc_device *dev,
1987 struct uvc_streaming *stream)
1991 /* Initialize the streaming interface with default parameters. */
1992 ret = uvc_video_init(stream);
1994 dev_err(&stream->intf->dev,
1995 "Failed to initialize the device (%d).\n", ret);
1999 if (stream->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
2000 stream->chain->caps |= V4L2_CAP_VIDEO_CAPTURE
2001 | V4L2_CAP_META_CAPTURE;
2003 stream->chain->caps |= V4L2_CAP_VIDEO_OUTPUT;
2005 uvc_debugfs_init_stream(stream);
2007 /* Register the device with V4L. */
2008 return uvc_register_video_device(dev, stream, &stream->vdev,
2009 &stream->queue, stream->type,
2010 &uvc_fops, &uvc_ioctl_ops);
2014 * Register all video devices in all chains.
2016 static int uvc_register_terms(struct uvc_device *dev,
2017 struct uvc_video_chain *chain)
2019 struct uvc_streaming *stream;
2020 struct uvc_entity *term;
2023 list_for_each_entry(term, &chain->entities, chain) {
2024 if (UVC_ENTITY_TYPE(term) != UVC_TT_STREAMING)
2027 stream = uvc_stream_by_id(dev, term->id);
2028 if (stream == NULL) {
2029 dev_info(&dev->udev->dev,
2030 "No streaming interface found for terminal %u.",
2035 stream->chain = chain;
2036 ret = uvc_register_video(dev, stream);
2041 * Register a metadata node, but ignore a possible failure,
2042 * complete registration of video nodes anyway.
2044 uvc_meta_register(stream);
2046 term->vdev = &stream->vdev;
2052 static int uvc_register_chains(struct uvc_device *dev)
2054 struct uvc_video_chain *chain;
2057 list_for_each_entry(chain, &dev->chains, list) {
2058 ret = uvc_register_terms(dev, chain);
2062 #ifdef CONFIG_MEDIA_CONTROLLER
2063 ret = uvc_mc_register_entities(chain);
2065 dev_info(&dev->udev->dev,
2066 "Failed to register entities (%d).\n", ret);
2073 /* ------------------------------------------------------------------------
2074 * USB probe, disconnect, suspend and resume
2077 static const struct uvc_device_info uvc_quirk_none = { 0 };
2079 static int uvc_probe(struct usb_interface *intf,
2080 const struct usb_device_id *id)
2082 struct usb_device *udev = interface_to_usbdev(intf);
2083 struct uvc_device *dev;
2084 const struct uvc_device_info *info =
2085 (const struct uvc_device_info *)id->driver_info;
2089 /* Allocate memory for the device and initialize it. */
2090 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
2094 INIT_LIST_HEAD(&dev->entities);
2095 INIT_LIST_HEAD(&dev->chains);
2096 INIT_LIST_HEAD(&dev->streams);
2097 kref_init(&dev->ref);
2098 atomic_set(&dev->nmappings, 0);
2099 mutex_init(&dev->lock);
2101 dev->udev = usb_get_dev(udev);
2102 dev->intf = usb_get_intf(intf);
2103 dev->intfnum = intf->cur_altsetting->desc.bInterfaceNumber;
2104 dev->info = info ? info : &uvc_quirk_none;
2105 dev->quirks = uvc_quirks_param == -1
2106 ? dev->info->quirks : uvc_quirks_param;
2108 if (id->idVendor && id->idProduct)
2109 uvc_dbg(dev, PROBE, "Probing known UVC device %s (%04x:%04x)\n",
2110 udev->devpath, id->idVendor, id->idProduct);
2112 uvc_dbg(dev, PROBE, "Probing generic UVC device %s\n",
2115 if (udev->product != NULL)
2116 strscpy(dev->name, udev->product, sizeof(dev->name));
2118 snprintf(dev->name, sizeof(dev->name),
2119 "UVC Camera (%04x:%04x)",
2120 le16_to_cpu(udev->descriptor.idVendor),
2121 le16_to_cpu(udev->descriptor.idProduct));
2124 * Add iFunction or iInterface to names when available as additional
2125 * distinguishers between interfaces. iFunction is prioritized over
2126 * iInterface which matches Windows behavior at the point of writing.
2128 if (intf->intf_assoc && intf->intf_assoc->iFunction != 0)
2129 function = intf->intf_assoc->iFunction;
2131 function = intf->cur_altsetting->desc.iInterface;
2132 if (function != 0) {
2135 strlcat(dev->name, ": ", sizeof(dev->name));
2136 len = strlen(dev->name);
2137 usb_string(udev, function, dev->name + len,
2138 sizeof(dev->name) - len);
2141 /* Initialize the media device. */
2142 #ifdef CONFIG_MEDIA_CONTROLLER
2143 dev->mdev.dev = &intf->dev;
2144 strscpy(dev->mdev.model, dev->name, sizeof(dev->mdev.model));
2146 strscpy(dev->mdev.serial, udev->serial,
2147 sizeof(dev->mdev.serial));
2148 usb_make_path(udev, dev->mdev.bus_info, sizeof(dev->mdev.bus_info));
2149 dev->mdev.hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
2150 media_device_init(&dev->mdev);
2152 dev->vdev.mdev = &dev->mdev;
2155 /* Parse the Video Class control descriptor. */
2156 if (uvc_parse_control(dev) < 0) {
2157 uvc_dbg(dev, PROBE, "Unable to parse UVC descriptors\n");
2161 /* Parse the associated GPIOs. */
2162 if (uvc_gpio_parse(dev) < 0) {
2163 uvc_dbg(dev, PROBE, "Unable to parse UVC GPIOs\n");
2167 dev_info(&dev->udev->dev, "Found UVC %u.%02x device %s (%04x:%04x)\n",
2168 dev->uvc_version >> 8, dev->uvc_version & 0xff,
2169 udev->product ? udev->product : "<unnamed>",
2170 le16_to_cpu(udev->descriptor.idVendor),
2171 le16_to_cpu(udev->descriptor.idProduct));
2173 if (dev->quirks != dev->info->quirks) {
2174 dev_info(&dev->udev->dev,
2175 "Forcing device quirks to 0x%x by module parameter for testing purpose.\n",
2177 dev_info(&dev->udev->dev,
2178 "Please report required quirks to the linux-media mailing list.\n");
2181 if (dev->info->uvc_version) {
2182 dev->uvc_version = dev->info->uvc_version;
2183 dev_info(&dev->udev->dev, "Forcing UVC version to %u.%02x\n",
2184 dev->uvc_version >> 8, dev->uvc_version & 0xff);
2187 /* Register the V4L2 device. */
2188 if (v4l2_device_register(&intf->dev, &dev->vdev) < 0)
2191 /* Scan the device for video chains. */
2192 if (uvc_scan_device(dev) < 0)
2195 /* Initialize controls. */
2196 if (uvc_ctrl_init_device(dev) < 0)
2199 /* Register video device nodes. */
2200 if (uvc_register_chains(dev) < 0)
2203 #ifdef CONFIG_MEDIA_CONTROLLER
2204 /* Register the media device node */
2205 if (media_device_register(&dev->mdev) < 0)
2208 /* Save our data pointer in the interface data. */
2209 usb_set_intfdata(intf, dev);
2211 /* Initialize the interrupt URB. */
2212 if ((ret = uvc_status_init(dev)) < 0) {
2213 dev_info(&dev->udev->dev,
2214 "Unable to initialize the status endpoint (%d), status interrupt will not be supported.\n",
2218 ret = uvc_gpio_init_irq(dev);
2220 dev_err(&dev->udev->dev,
2221 "Unable to request privacy GPIO IRQ (%d)\n", ret);
2225 uvc_dbg(dev, PROBE, "UVC device initialized\n");
2226 usb_enable_autosuspend(udev);
2230 uvc_unregister_video(dev);
2231 kref_put(&dev->ref, uvc_delete);
2235 static void uvc_disconnect(struct usb_interface *intf)
2237 struct uvc_device *dev = usb_get_intfdata(intf);
2240 * Set the USB interface data to NULL. This can be done outside the
2241 * lock, as there's no other reader.
2243 usb_set_intfdata(intf, NULL);
2245 if (intf->cur_altsetting->desc.bInterfaceSubClass ==
2246 UVC_SC_VIDEOSTREAMING)
2249 uvc_unregister_video(dev);
2250 kref_put(&dev->ref, uvc_delete);
2253 static int uvc_suspend(struct usb_interface *intf, pm_message_t message)
2255 struct uvc_device *dev = usb_get_intfdata(intf);
2256 struct uvc_streaming *stream;
2258 uvc_dbg(dev, SUSPEND, "Suspending interface %u\n",
2259 intf->cur_altsetting->desc.bInterfaceNumber);
2261 /* Controls are cached on the fly so they don't need to be saved. */
2262 if (intf->cur_altsetting->desc.bInterfaceSubClass ==
2263 UVC_SC_VIDEOCONTROL) {
2264 mutex_lock(&dev->lock);
2266 uvc_status_stop(dev);
2267 mutex_unlock(&dev->lock);
2271 list_for_each_entry(stream, &dev->streams, list) {
2272 if (stream->intf == intf)
2273 return uvc_video_suspend(stream);
2276 uvc_dbg(dev, SUSPEND,
2277 "Suspend: video streaming USB interface mismatch\n");
2281 static int __uvc_resume(struct usb_interface *intf, int reset)
2283 struct uvc_device *dev = usb_get_intfdata(intf);
2284 struct uvc_streaming *stream;
2287 uvc_dbg(dev, SUSPEND, "Resuming interface %u\n",
2288 intf->cur_altsetting->desc.bInterfaceNumber);
2290 if (intf->cur_altsetting->desc.bInterfaceSubClass ==
2291 UVC_SC_VIDEOCONTROL) {
2293 ret = uvc_ctrl_restore_values(dev);
2298 mutex_lock(&dev->lock);
2300 ret = uvc_status_start(dev, GFP_NOIO);
2301 mutex_unlock(&dev->lock);
2306 list_for_each_entry(stream, &dev->streams, list) {
2307 if (stream->intf == intf) {
2308 ret = uvc_video_resume(stream, reset);
2310 uvc_queue_streamoff(&stream->queue,
2311 stream->queue.queue.type);
2316 uvc_dbg(dev, SUSPEND,
2317 "Resume: video streaming USB interface mismatch\n");
2321 static int uvc_resume(struct usb_interface *intf)
2323 return __uvc_resume(intf, 0);
2326 static int uvc_reset_resume(struct usb_interface *intf)
2328 return __uvc_resume(intf, 1);
2331 /* ------------------------------------------------------------------------
2335 static int uvc_clock_param_get(char *buffer, const struct kernel_param *kp)
2337 if (uvc_clock_param == CLOCK_MONOTONIC)
2338 return sprintf(buffer, "CLOCK_MONOTONIC");
2340 return sprintf(buffer, "CLOCK_REALTIME");
2343 static int uvc_clock_param_set(const char *val, const struct kernel_param *kp)
2345 if (strncasecmp(val, "clock_", strlen("clock_")) == 0)
2346 val += strlen("clock_");
2348 if (strcasecmp(val, "monotonic") == 0)
2349 uvc_clock_param = CLOCK_MONOTONIC;
2350 else if (strcasecmp(val, "realtime") == 0)
2351 uvc_clock_param = CLOCK_REALTIME;
2358 module_param_call(clock, uvc_clock_param_set, uvc_clock_param_get,
2359 &uvc_clock_param, S_IRUGO|S_IWUSR);
2360 MODULE_PARM_DESC(clock, "Video buffers timestamp clock");
2361 module_param_named(hwtimestamps, uvc_hw_timestamps_param, uint, S_IRUGO|S_IWUSR);
2362 MODULE_PARM_DESC(hwtimestamps, "Use hardware timestamps");
2363 module_param_named(nodrop, uvc_no_drop_param, uint, S_IRUGO|S_IWUSR);
2364 MODULE_PARM_DESC(nodrop, "Don't drop incomplete frames");
2365 module_param_named(quirks, uvc_quirks_param, uint, S_IRUGO|S_IWUSR);
2366 MODULE_PARM_DESC(quirks, "Forced device quirks");
2367 module_param_named(trace, uvc_dbg_param, uint, S_IRUGO|S_IWUSR);
2368 MODULE_PARM_DESC(trace, "Trace level bitmask");
2369 module_param_named(timeout, uvc_timeout_param, uint, S_IRUGO|S_IWUSR);
2370 MODULE_PARM_DESC(timeout, "Streaming control requests timeout");
2372 /* ------------------------------------------------------------------------
2373 * Driver initialization and cleanup
2376 static const struct uvc_menu_info power_line_frequency_controls_limited[] = {
2381 static const struct uvc_control_mapping uvc_ctrl_power_line_mapping_limited = {
2382 .id = V4L2_CID_POWER_LINE_FREQUENCY,
2383 .entity = UVC_GUID_UVC_PROCESSING,
2384 .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL,
2387 .v4l2_type = V4L2_CTRL_TYPE_MENU,
2388 .data_type = UVC_CTRL_DATA_TYPE_ENUM,
2389 .menu_info = power_line_frequency_controls_limited,
2390 .menu_count = ARRAY_SIZE(power_line_frequency_controls_limited),
2393 static const struct uvc_device_info uvc_ctrl_power_line_limited = {
2394 .mappings = (const struct uvc_control_mapping *[]) {
2395 &uvc_ctrl_power_line_mapping_limited,
2396 NULL, /* Sentinel */
2400 static const struct uvc_device_info uvc_quirk_probe_minmax = {
2401 .quirks = UVC_QUIRK_PROBE_MINMAX,
2404 static const struct uvc_device_info uvc_quirk_fix_bandwidth = {
2405 .quirks = UVC_QUIRK_FIX_BANDWIDTH,
2408 static const struct uvc_device_info uvc_quirk_probe_def = {
2409 .quirks = UVC_QUIRK_PROBE_DEF,
2412 static const struct uvc_device_info uvc_quirk_stream_no_fid = {
2413 .quirks = UVC_QUIRK_STREAM_NO_FID,
2416 static const struct uvc_device_info uvc_quirk_force_y8 = {
2417 .quirks = UVC_QUIRK_FORCE_Y8,
2420 #define UVC_INFO_QUIRK(q) (kernel_ulong_t)&(struct uvc_device_info){.quirks = q}
2421 #define UVC_INFO_META(m) (kernel_ulong_t)&(struct uvc_device_info) \
2425 * The Logitech cameras listed below have their interface class set to
2426 * VENDOR_SPEC because they don't announce themselves as UVC devices, even
2427 * though they are compliant.
2429 static const struct usb_device_id uvc_ids[] = {
2430 /* Quanta USB2.0 HD UVC Webcam */
2431 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2432 | USB_DEVICE_ID_MATCH_INT_INFO,
2434 .idProduct = 0x3090,
2435 .bInterfaceClass = USB_CLASS_VIDEO,
2436 .bInterfaceSubClass = 1,
2437 .bInterfaceProtocol = 0,
2438 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
2439 /* Quanta USB2.0 HD UVC Webcam */
2440 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2441 | USB_DEVICE_ID_MATCH_INT_INFO,
2443 .idProduct = 0x4030,
2444 .bInterfaceClass = USB_CLASS_VIDEO,
2445 .bInterfaceSubClass = 1,
2446 .bInterfaceProtocol = 0,
2447 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
2448 /* Quanta USB2.0 HD UVC Webcam */
2449 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2450 | USB_DEVICE_ID_MATCH_INT_INFO,
2452 .idProduct = 0x4034,
2453 .bInterfaceClass = USB_CLASS_VIDEO,
2454 .bInterfaceSubClass = 1,
2455 .bInterfaceProtocol = UVC_PC_PROTOCOL_15,
2456 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
2457 /* LogiLink Wireless Webcam */
2458 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2459 | USB_DEVICE_ID_MATCH_INT_INFO,
2461 .idProduct = 0xa91a,
2462 .bInterfaceClass = USB_CLASS_VIDEO,
2463 .bInterfaceSubClass = 1,
2464 .bInterfaceProtocol = 0,
2465 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2466 /* Genius eFace 2025 */
2467 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2468 | USB_DEVICE_ID_MATCH_INT_INFO,
2470 .idProduct = 0x706e,
2471 .bInterfaceClass = USB_CLASS_VIDEO,
2472 .bInterfaceSubClass = 1,
2473 .bInterfaceProtocol = 0,
2474 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2475 /* Microsoft Lifecam NX-6000 */
2476 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2477 | USB_DEVICE_ID_MATCH_INT_INFO,
2479 .idProduct = 0x00f8,
2480 .bInterfaceClass = USB_CLASS_VIDEO,
2481 .bInterfaceSubClass = 1,
2482 .bInterfaceProtocol = 0,
2483 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2484 /* Microsoft Lifecam NX-3000 */
2485 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2486 | USB_DEVICE_ID_MATCH_INT_INFO,
2488 .idProduct = 0x0721,
2489 .bInterfaceClass = USB_CLASS_VIDEO,
2490 .bInterfaceSubClass = 1,
2491 .bInterfaceProtocol = 0,
2492 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2493 /* Microsoft Lifecam VX-7000 */
2494 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2495 | USB_DEVICE_ID_MATCH_INT_INFO,
2497 .idProduct = 0x0723,
2498 .bInterfaceClass = USB_CLASS_VIDEO,
2499 .bInterfaceSubClass = 1,
2500 .bInterfaceProtocol = 0,
2501 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2502 /* Logitech Quickcam Fusion */
2503 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2504 | USB_DEVICE_ID_MATCH_INT_INFO,
2506 .idProduct = 0x08c1,
2507 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2508 .bInterfaceSubClass = 1,
2509 .bInterfaceProtocol = 0 },
2510 /* Logitech Quickcam Orbit MP */
2511 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2512 | USB_DEVICE_ID_MATCH_INT_INFO,
2514 .idProduct = 0x08c2,
2515 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2516 .bInterfaceSubClass = 1,
2517 .bInterfaceProtocol = 0 },
2518 /* Logitech Quickcam Pro for Notebook */
2519 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2520 | USB_DEVICE_ID_MATCH_INT_INFO,
2522 .idProduct = 0x08c3,
2523 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2524 .bInterfaceSubClass = 1,
2525 .bInterfaceProtocol = 0 },
2526 /* Logitech Quickcam Pro 5000 */
2527 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2528 | USB_DEVICE_ID_MATCH_INT_INFO,
2530 .idProduct = 0x08c5,
2531 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2532 .bInterfaceSubClass = 1,
2533 .bInterfaceProtocol = 0 },
2534 /* Logitech Quickcam OEM Dell Notebook */
2535 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2536 | USB_DEVICE_ID_MATCH_INT_INFO,
2538 .idProduct = 0x08c6,
2539 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2540 .bInterfaceSubClass = 1,
2541 .bInterfaceProtocol = 0 },
2542 /* Logitech Quickcam OEM Cisco VT Camera II */
2543 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2544 | USB_DEVICE_ID_MATCH_INT_INFO,
2546 .idProduct = 0x08c7,
2547 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2548 .bInterfaceSubClass = 1,
2549 .bInterfaceProtocol = 0 },
2550 /* Logitech HD Pro Webcam C920 */
2551 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2552 | USB_DEVICE_ID_MATCH_INT_INFO,
2554 .idProduct = 0x082d,
2555 .bInterfaceClass = USB_CLASS_VIDEO,
2556 .bInterfaceSubClass = 1,
2557 .bInterfaceProtocol = 0,
2558 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_RESTORE_CTRLS_ON_INIT) },
2559 /* Chicony CNF7129 (Asus EEE 100HE) */
2560 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2561 | USB_DEVICE_ID_MATCH_INT_INFO,
2563 .idProduct = 0xb071,
2564 .bInterfaceClass = USB_CLASS_VIDEO,
2565 .bInterfaceSubClass = 1,
2566 .bInterfaceProtocol = 0,
2567 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_RESTRICT_FRAME_RATE) },
2568 /* Chicony EasyCamera */
2569 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2570 | USB_DEVICE_ID_MATCH_INT_INFO,
2572 .idProduct = 0xb5eb,
2573 .bInterfaceClass = USB_CLASS_VIDEO,
2574 .bInterfaceSubClass = 1,
2575 .bInterfaceProtocol = 0,
2576 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
2577 /* Chicony EasyCamera */
2578 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2579 | USB_DEVICE_ID_MATCH_INT_INFO,
2581 .idProduct = 0xb6ba,
2582 .bInterfaceClass = USB_CLASS_VIDEO,
2583 .bInterfaceSubClass = 1,
2584 .bInterfaceProtocol = 0,
2585 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
2586 /* Chicony EasyCamera */
2587 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2588 | USB_DEVICE_ID_MATCH_INT_INFO,
2590 .idProduct = 0xb746,
2591 .bInterfaceClass = USB_CLASS_VIDEO,
2592 .bInterfaceSubClass = 1,
2593 .bInterfaceProtocol = 0,
2594 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
2595 /* Alcor Micro AU3820 (Future Boy PC USB Webcam) */
2596 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2597 | USB_DEVICE_ID_MATCH_INT_INFO,
2599 .idProduct = 0x3820,
2600 .bInterfaceClass = USB_CLASS_VIDEO,
2601 .bInterfaceSubClass = 1,
2602 .bInterfaceProtocol = 0,
2603 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2604 /* Dell XPS m1530 */
2605 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2606 | USB_DEVICE_ID_MATCH_INT_INFO,
2608 .idProduct = 0x2640,
2609 .bInterfaceClass = USB_CLASS_VIDEO,
2610 .bInterfaceSubClass = 1,
2611 .bInterfaceProtocol = 0,
2612 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2613 /* Dell SP2008WFP Monitor */
2614 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2615 | USB_DEVICE_ID_MATCH_INT_INFO,
2617 .idProduct = 0x2641,
2618 .bInterfaceClass = USB_CLASS_VIDEO,
2619 .bInterfaceSubClass = 1,
2620 .bInterfaceProtocol = 0,
2621 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2622 /* Dell Alienware X51 */
2623 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2624 | USB_DEVICE_ID_MATCH_INT_INFO,
2626 .idProduct = 0x2643,
2627 .bInterfaceClass = USB_CLASS_VIDEO,
2628 .bInterfaceSubClass = 1,
2629 .bInterfaceProtocol = 0,
2630 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2631 /* Dell Studio Hybrid 140g (OmniVision webcam) */
2632 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2633 | USB_DEVICE_ID_MATCH_INT_INFO,
2635 .idProduct = 0x264a,
2636 .bInterfaceClass = USB_CLASS_VIDEO,
2637 .bInterfaceSubClass = 1,
2638 .bInterfaceProtocol = 0,
2639 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2640 /* Dell XPS M1330 (OmniVision OV7670 webcam) */
2641 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2642 | USB_DEVICE_ID_MATCH_INT_INFO,
2644 .idProduct = 0x7670,
2645 .bInterfaceClass = USB_CLASS_VIDEO,
2646 .bInterfaceSubClass = 1,
2647 .bInterfaceProtocol = 0,
2648 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2649 /* Apple Built-In iSight */
2650 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2651 | USB_DEVICE_ID_MATCH_INT_INFO,
2653 .idProduct = 0x8501,
2654 .bInterfaceClass = USB_CLASS_VIDEO,
2655 .bInterfaceSubClass = 1,
2656 .bInterfaceProtocol = 0,
2657 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_PROBE_MINMAX
2658 | UVC_QUIRK_BUILTIN_ISIGHT) },
2659 /* Apple FaceTime HD Camera (Built-In) */
2660 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2661 | USB_DEVICE_ID_MATCH_INT_INFO,
2663 .idProduct = 0x8514,
2664 .bInterfaceClass = USB_CLASS_VIDEO,
2665 .bInterfaceSubClass = 1,
2666 .bInterfaceProtocol = 0,
2667 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2668 /* Apple Built-In iSight via iBridge */
2669 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2670 | USB_DEVICE_ID_MATCH_INT_INFO,
2672 .idProduct = 0x8600,
2673 .bInterfaceClass = USB_CLASS_VIDEO,
2674 .bInterfaceSubClass = 1,
2675 .bInterfaceProtocol = 0,
2676 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2677 /* Foxlink ("HP Webcam" on HP Mini 5103) */
2678 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2679 | USB_DEVICE_ID_MATCH_INT_INFO,
2681 .idProduct = 0x0403,
2682 .bInterfaceClass = USB_CLASS_VIDEO,
2683 .bInterfaceSubClass = 1,
2684 .bInterfaceProtocol = 0,
2685 .driver_info = (kernel_ulong_t)&uvc_quirk_fix_bandwidth },
2686 /* Genesys Logic USB 2.0 PC Camera */
2687 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2688 | USB_DEVICE_ID_MATCH_INT_INFO,
2690 .idProduct = 0x0505,
2691 .bInterfaceClass = USB_CLASS_VIDEO,
2692 .bInterfaceSubClass = 1,
2693 .bInterfaceProtocol = 0,
2694 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2695 /* Hercules Classic Silver */
2696 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2697 | USB_DEVICE_ID_MATCH_INT_INFO,
2699 .idProduct = 0x300c,
2700 .bInterfaceClass = USB_CLASS_VIDEO,
2701 .bInterfaceSubClass = 1,
2702 .bInterfaceProtocol = 0,
2703 .driver_info = (kernel_ulong_t)&uvc_quirk_fix_bandwidth },
2705 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2706 | USB_DEVICE_ID_MATCH_INT_INFO,
2708 .idProduct = 0x332d,
2709 .bInterfaceClass = USB_CLASS_VIDEO,
2710 .bInterfaceSubClass = 1,
2711 .bInterfaceProtocol = 0,
2712 .driver_info = (kernel_ulong_t)&uvc_quirk_fix_bandwidth },
2713 /* ViMicro - Minoru3D */
2714 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2715 | USB_DEVICE_ID_MATCH_INT_INFO,
2717 .idProduct = 0x3410,
2718 .bInterfaceClass = USB_CLASS_VIDEO,
2719 .bInterfaceSubClass = 1,
2720 .bInterfaceProtocol = 0,
2721 .driver_info = (kernel_ulong_t)&uvc_quirk_fix_bandwidth },
2722 /* ViMicro Venus - Minoru3D */
2723 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2724 | USB_DEVICE_ID_MATCH_INT_INFO,
2726 .idProduct = 0x3420,
2727 .bInterfaceClass = USB_CLASS_VIDEO,
2728 .bInterfaceSubClass = 1,
2729 .bInterfaceProtocol = 0,
2730 .driver_info = (kernel_ulong_t)&uvc_quirk_fix_bandwidth },
2731 /* Ophir Optronics - SPCAM 620U */
2732 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2733 | USB_DEVICE_ID_MATCH_INT_INFO,
2735 .idProduct = 0x0555,
2736 .bInterfaceClass = USB_CLASS_VIDEO,
2737 .bInterfaceSubClass = 1,
2738 .bInterfaceProtocol = 0,
2739 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2741 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2742 | USB_DEVICE_ID_MATCH_INT_INFO,
2744 .idProduct = 0x0004,
2745 .bInterfaceClass = USB_CLASS_VIDEO,
2746 .bInterfaceSubClass = 1,
2747 .bInterfaceProtocol = 0,
2748 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_PROBE_MINMAX
2749 | UVC_QUIRK_PROBE_DEF) },
2750 /* IMC Networks (Medion Akoya) */
2751 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2752 | USB_DEVICE_ID_MATCH_INT_INFO,
2754 .idProduct = 0x5103,
2755 .bInterfaceClass = USB_CLASS_VIDEO,
2756 .bInterfaceSubClass = 1,
2757 .bInterfaceProtocol = 0,
2758 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2759 /* JMicron USB2.0 XGA WebCam */
2760 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2761 | USB_DEVICE_ID_MATCH_INT_INFO,
2763 .idProduct = 0x0310,
2764 .bInterfaceClass = USB_CLASS_VIDEO,
2765 .bInterfaceSubClass = 1,
2766 .bInterfaceProtocol = 0,
2767 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2768 /* Syntek (HP Spartan) */
2769 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2770 | USB_DEVICE_ID_MATCH_INT_INFO,
2772 .idProduct = 0x5212,
2773 .bInterfaceClass = USB_CLASS_VIDEO,
2774 .bInterfaceSubClass = 1,
2775 .bInterfaceProtocol = 0,
2776 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2777 /* Syntek (Samsung Q310) */
2778 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2779 | USB_DEVICE_ID_MATCH_INT_INFO,
2781 .idProduct = 0x5931,
2782 .bInterfaceClass = USB_CLASS_VIDEO,
2783 .bInterfaceSubClass = 1,
2784 .bInterfaceProtocol = 0,
2785 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2786 /* Syntek (Packard Bell EasyNote MX52 */
2787 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2788 | USB_DEVICE_ID_MATCH_INT_INFO,
2790 .idProduct = 0x8a12,
2791 .bInterfaceClass = USB_CLASS_VIDEO,
2792 .bInterfaceSubClass = 1,
2793 .bInterfaceProtocol = 0,
2794 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2795 /* Syntek (Asus F9SG) */
2796 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2797 | USB_DEVICE_ID_MATCH_INT_INFO,
2799 .idProduct = 0x8a31,
2800 .bInterfaceClass = USB_CLASS_VIDEO,
2801 .bInterfaceSubClass = 1,
2802 .bInterfaceProtocol = 0,
2803 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2804 /* Syntek (Asus U3S) */
2805 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2806 | USB_DEVICE_ID_MATCH_INT_INFO,
2808 .idProduct = 0x8a33,
2809 .bInterfaceClass = USB_CLASS_VIDEO,
2810 .bInterfaceSubClass = 1,
2811 .bInterfaceProtocol = 0,
2812 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2813 /* Syntek (JAOtech Smart Terminal) */
2814 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2815 | USB_DEVICE_ID_MATCH_INT_INFO,
2817 .idProduct = 0x8a34,
2818 .bInterfaceClass = USB_CLASS_VIDEO,
2819 .bInterfaceSubClass = 1,
2820 .bInterfaceProtocol = 0,
2821 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2823 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2824 | USB_DEVICE_ID_MATCH_INT_INFO,
2826 .idProduct = 0x0202,
2827 .bInterfaceClass = USB_CLASS_VIDEO,
2828 .bInterfaceSubClass = 1,
2829 .bInterfaceProtocol = 0,
2830 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2831 /* Lenovo Thinkpad SL400/SL500 */
2832 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2833 | USB_DEVICE_ID_MATCH_INT_INFO,
2835 .idProduct = 0x480b,
2836 .bInterfaceClass = USB_CLASS_VIDEO,
2837 .bInterfaceSubClass = 1,
2838 .bInterfaceProtocol = 0,
2839 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2840 /* Aveo Technology USB 2.0 Camera */
2841 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2842 | USB_DEVICE_ID_MATCH_INT_INFO,
2844 .idProduct = 0x0306,
2845 .bInterfaceClass = USB_CLASS_VIDEO,
2846 .bInterfaceSubClass = 1,
2847 .bInterfaceProtocol = 0,
2848 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_PROBE_MINMAX
2849 | UVC_QUIRK_PROBE_EXTRAFIELDS) },
2850 /* Aveo Technology USB 2.0 Camera (Tasco USB Microscope) */
2851 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2852 | USB_DEVICE_ID_MATCH_INT_INFO,
2854 .idProduct = 0x0516,
2855 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2856 .bInterfaceSubClass = 1,
2857 .bInterfaceProtocol = 0 },
2858 /* Ecamm Pico iMage */
2859 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2860 | USB_DEVICE_ID_MATCH_INT_INFO,
2862 .idProduct = 0xcafe,
2863 .bInterfaceClass = USB_CLASS_VIDEO,
2864 .bInterfaceSubClass = 1,
2865 .bInterfaceProtocol = 0,
2866 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_PROBE_EXTRAFIELDS) },
2867 /* Manta MM-353 Plako */
2868 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2869 | USB_DEVICE_ID_MATCH_INT_INFO,
2871 .idProduct = 0x3188,
2872 .bInterfaceClass = USB_CLASS_VIDEO,
2873 .bInterfaceSubClass = 1,
2874 .bInterfaceProtocol = 0,
2875 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2876 /* FSC WebCam V30S */
2877 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2878 | USB_DEVICE_ID_MATCH_INT_INFO,
2880 .idProduct = 0x3288,
2881 .bInterfaceClass = USB_CLASS_VIDEO,
2882 .bInterfaceSubClass = 1,
2883 .bInterfaceProtocol = 0,
2884 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2885 /* Arkmicro unbranded */
2886 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2887 | USB_DEVICE_ID_MATCH_INT_INFO,
2889 .idProduct = 0x3290,
2890 .bInterfaceClass = USB_CLASS_VIDEO,
2891 .bInterfaceSubClass = 1,
2892 .bInterfaceProtocol = 0,
2893 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2894 /* The Imaging Source USB CCD cameras */
2895 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2896 | USB_DEVICE_ID_MATCH_INT_INFO,
2898 .idProduct = 0x8102,
2899 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2900 .bInterfaceSubClass = 1,
2901 .bInterfaceProtocol = 0 },
2902 /* Bodelin ProScopeHR */
2903 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2904 | USB_DEVICE_ID_MATCH_DEV_HI
2905 | USB_DEVICE_ID_MATCH_INT_INFO,
2907 .idProduct = 0x1000,
2908 .bcdDevice_hi = 0x0126,
2909 .bInterfaceClass = USB_CLASS_VIDEO,
2910 .bInterfaceSubClass = 1,
2911 .bInterfaceProtocol = 0,
2912 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_STATUS_INTERVAL) },
2913 /* MSI StarCam 370i */
2914 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2915 | USB_DEVICE_ID_MATCH_INT_INFO,
2917 .idProduct = 0x2951,
2918 .bInterfaceClass = USB_CLASS_VIDEO,
2919 .bInterfaceSubClass = 1,
2920 .bInterfaceProtocol = 0,
2921 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2922 /* Generalplus Technology Inc. 808 Camera */
2923 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2924 | USB_DEVICE_ID_MATCH_INT_INFO,
2926 .idProduct = 0x2002,
2927 .bInterfaceClass = USB_CLASS_VIDEO,
2928 .bInterfaceSubClass = 1,
2929 .bInterfaceProtocol = 0,
2930 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2931 /* Shenzhen Aoni Electronic Co.,Ltd 2K FHD camera */
2932 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2933 | USB_DEVICE_ID_MATCH_INT_INFO,
2935 .idProduct = 0x0b40,
2936 .bInterfaceClass = USB_CLASS_VIDEO,
2937 .bInterfaceSubClass = 1,
2938 .bInterfaceProtocol = 0,
2939 .driver_info = (kernel_ulong_t)&(const struct uvc_device_info){
2940 .uvc_version = 0x010a,
2942 /* SiGma Micro USB Web Camera */
2943 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2944 | USB_DEVICE_ID_MATCH_INT_INFO,
2946 .idProduct = 0x3000,
2947 .bInterfaceClass = USB_CLASS_VIDEO,
2948 .bInterfaceSubClass = 1,
2949 .bInterfaceProtocol = 0,
2950 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_PROBE_MINMAX
2951 | UVC_QUIRK_IGNORE_SELECTOR_UNIT) },
2952 /* Oculus VR Positional Tracker DK2 */
2953 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2954 | USB_DEVICE_ID_MATCH_INT_INFO,
2956 .idProduct = 0x0201,
2957 .bInterfaceClass = USB_CLASS_VIDEO,
2958 .bInterfaceSubClass = 1,
2959 .bInterfaceProtocol = 0,
2960 .driver_info = (kernel_ulong_t)&uvc_quirk_force_y8 },
2961 /* Oculus VR Rift Sensor */
2962 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2963 | USB_DEVICE_ID_MATCH_INT_INFO,
2965 .idProduct = 0x0211,
2966 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2967 .bInterfaceSubClass = 1,
2968 .bInterfaceProtocol = 0,
2969 .driver_info = (kernel_ulong_t)&uvc_quirk_force_y8 },
2970 /* GEO Semiconductor GC6500 */
2971 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2972 | USB_DEVICE_ID_MATCH_INT_INFO,
2974 .idProduct = 0x4d53,
2975 .bInterfaceClass = USB_CLASS_VIDEO,
2976 .bInterfaceSubClass = 1,
2977 .bInterfaceProtocol = 0,
2978 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_FORCE_BPP) },
2979 /* Sonix Technology USB 2.0 Camera */
2980 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2981 | USB_DEVICE_ID_MATCH_INT_INFO,
2983 .idProduct = 0x0072,
2984 .bInterfaceClass = USB_CLASS_VIDEO,
2985 .bInterfaceSubClass = 1,
2986 .bInterfaceProtocol = 0,
2987 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
2988 /* Acer EasyCamera */
2989 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2990 | USB_DEVICE_ID_MATCH_INT_INFO,
2992 .idProduct = 0x1172,
2993 .bInterfaceClass = USB_CLASS_VIDEO,
2994 .bInterfaceSubClass = 1,
2995 .bInterfaceProtocol = 0,
2996 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
2997 /* Intel RealSense D4M */
2998 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2999 | USB_DEVICE_ID_MATCH_INT_INFO,
3001 .idProduct = 0x0b03,
3002 .bInterfaceClass = USB_CLASS_VIDEO,
3003 .bInterfaceSubClass = 1,
3004 .bInterfaceProtocol = 0,
3005 .driver_info = UVC_INFO_META(V4L2_META_FMT_D4XX) },
3006 /* Generic USB Video Class */
3007 { USB_INTERFACE_INFO(USB_CLASS_VIDEO, 1, UVC_PC_PROTOCOL_UNDEFINED) },
3008 { USB_INTERFACE_INFO(USB_CLASS_VIDEO, 1, UVC_PC_PROTOCOL_15) },
3012 MODULE_DEVICE_TABLE(usb, uvc_ids);
3014 struct uvc_driver uvc_driver = {
3018 .disconnect = uvc_disconnect,
3019 .suspend = uvc_suspend,
3020 .resume = uvc_resume,
3021 .reset_resume = uvc_reset_resume,
3022 .id_table = uvc_ids,
3023 .supports_autosuspend = 1,
3027 static int __init uvc_init(void)
3033 ret = usb_register(&uvc_driver.driver);
3035 uvc_debugfs_cleanup();
3042 static void __exit uvc_cleanup(void)
3044 usb_deregister(&uvc_driver.driver);
3045 uvc_debugfs_cleanup();
3048 module_init(uvc_init);
3049 module_exit(uvc_cleanup);
3051 MODULE_AUTHOR(DRIVER_AUTHOR);
3052 MODULE_DESCRIPTION(DRIVER_DESC);
3053 MODULE_LICENSE("GPL");
3054 MODULE_VERSION(DRIVER_VERSION);