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/bits.h>
11 #include <linux/gpio/consumer.h>
12 #include <linux/kernel.h>
13 #include <linux/list.h>
14 #include <linux/module.h>
15 #include <linux/slab.h>
16 #include <linux/usb.h>
17 #include <linux/usb/uvc.h>
18 #include <linux/videodev2.h>
19 #include <linux/vmalloc.h>
20 #include <linux/wait.h>
21 #include <asm/unaligned.h>
23 #include <media/v4l2-common.h>
24 #include <media/v4l2-ioctl.h>
28 #define DRIVER_AUTHOR "Laurent Pinchart " \
29 "<laurent.pinchart@ideasonboard.com>"
30 #define DRIVER_DESC "USB Video Class driver"
32 unsigned int uvc_clock_param = CLOCK_MONOTONIC;
33 unsigned int uvc_hw_timestamps_param;
34 unsigned int uvc_no_drop_param;
35 static unsigned int uvc_quirks_param = -1;
36 unsigned int uvc_dbg_param;
37 unsigned int uvc_timeout_param = UVC_CTRL_STREAMING_TIMEOUT;
39 /* ------------------------------------------------------------------------
43 struct usb_host_endpoint *uvc_find_endpoint(struct usb_host_interface *alts,
46 struct usb_host_endpoint *ep;
49 for (i = 0; i < alts->desc.bNumEndpoints; ++i) {
50 ep = &alts->endpoint[i];
51 if (ep->desc.bEndpointAddress == epaddr)
58 static enum v4l2_colorspace uvc_colorspace(const u8 primaries)
60 static const enum v4l2_colorspace colorprimaries[] = {
61 V4L2_COLORSPACE_SRGB, /* Unspecified */
63 V4L2_COLORSPACE_470_SYSTEM_M,
64 V4L2_COLORSPACE_470_SYSTEM_BG,
65 V4L2_COLORSPACE_SMPTE170M,
66 V4L2_COLORSPACE_SMPTE240M,
69 if (primaries < ARRAY_SIZE(colorprimaries))
70 return colorprimaries[primaries];
72 return V4L2_COLORSPACE_SRGB; /* Reserved */
75 static enum v4l2_xfer_func uvc_xfer_func(const u8 transfer_characteristics)
78 * V4L2 does not currently have definitions for all possible values of
79 * UVC transfer characteristics. If v4l2_xfer_func is extended with new
80 * values, the mapping below should be updated.
82 * Substitutions are taken from the mapping given for
83 * V4L2_XFER_FUNC_DEFAULT documented in videodev2.h.
85 static const enum v4l2_xfer_func xfer_funcs[] = {
86 V4L2_XFER_FUNC_DEFAULT, /* Unspecified */
88 V4L2_XFER_FUNC_709, /* Substitution for BT.470-2 M */
89 V4L2_XFER_FUNC_709, /* Substitution for BT.470-2 B, G */
90 V4L2_XFER_FUNC_709, /* Substitution for SMPTE 170M */
91 V4L2_XFER_FUNC_SMPTE240M,
96 if (transfer_characteristics < ARRAY_SIZE(xfer_funcs))
97 return xfer_funcs[transfer_characteristics];
99 return V4L2_XFER_FUNC_DEFAULT; /* Reserved */
102 static enum v4l2_ycbcr_encoding uvc_ycbcr_enc(const u8 matrix_coefficients)
105 * V4L2 does not currently have definitions for all possible values of
106 * UVC matrix coefficients. If v4l2_ycbcr_encoding is extended with new
107 * values, the mapping below should be updated.
109 * Substitutions are taken from the mapping given for
110 * V4L2_YCBCR_ENC_DEFAULT documented in videodev2.h.
112 * FCC is assumed to be close enough to 601.
114 static const enum v4l2_ycbcr_encoding ycbcr_encs[] = {
115 V4L2_YCBCR_ENC_DEFAULT, /* Unspecified */
117 V4L2_YCBCR_ENC_601, /* Substitution for FCC */
118 V4L2_YCBCR_ENC_601, /* Substitution for BT.470-2 B, G */
120 V4L2_YCBCR_ENC_SMPTE240M,
123 if (matrix_coefficients < ARRAY_SIZE(ycbcr_encs))
124 return ycbcr_encs[matrix_coefficients];
126 return V4L2_YCBCR_ENC_DEFAULT; /* Reserved */
129 /* ------------------------------------------------------------------------
130 * Terminal and unit management
133 struct uvc_entity *uvc_entity_by_id(struct uvc_device *dev, int id)
135 struct uvc_entity *entity;
137 list_for_each_entry(entity, &dev->entities, list) {
138 if (entity->id == id)
145 static struct uvc_entity *uvc_entity_by_reference(struct uvc_device *dev,
146 int id, struct uvc_entity *entity)
151 entity = list_entry(&dev->entities, struct uvc_entity, list);
153 list_for_each_entry_continue(entity, &dev->entities, list) {
154 for (i = 0; i < entity->bNrInPins; ++i)
155 if (entity->baSourceID[i] == id)
162 static struct uvc_streaming *uvc_stream_by_id(struct uvc_device *dev, int id)
164 struct uvc_streaming *stream;
166 list_for_each_entry(stream, &dev->streams, list) {
167 if (stream->header.bTerminalLink == id)
174 /* ------------------------------------------------------------------------
175 * Streaming Object Management
178 static void uvc_stream_delete(struct uvc_streaming *stream)
180 if (stream->async_wq)
181 destroy_workqueue(stream->async_wq);
183 mutex_destroy(&stream->mutex);
185 usb_put_intf(stream->intf);
187 kfree(stream->format);
188 kfree(stream->header.bmaControls);
192 static struct uvc_streaming *uvc_stream_new(struct uvc_device *dev,
193 struct usb_interface *intf)
195 struct uvc_streaming *stream;
197 stream = kzalloc(sizeof(*stream), GFP_KERNEL);
201 mutex_init(&stream->mutex);
204 stream->intf = usb_get_intf(intf);
205 stream->intfnum = intf->cur_altsetting->desc.bInterfaceNumber;
207 /* Allocate a stream specific work queue for asynchronous tasks. */
208 stream->async_wq = alloc_workqueue("uvcvideo", WQ_UNBOUND | WQ_HIGHPRI,
210 if (!stream->async_wq) {
211 uvc_stream_delete(stream);
218 /* ------------------------------------------------------------------------
219 * Descriptors parsing
222 static int uvc_parse_format(struct uvc_device *dev,
223 struct uvc_streaming *streaming, struct uvc_format *format,
224 u32 **intervals, unsigned char *buffer, int buflen)
226 struct usb_interface *intf = streaming->intf;
227 struct usb_host_interface *alts = intf->cur_altsetting;
228 const struct uvc_format_desc *fmtdesc;
229 struct uvc_frame *frame;
230 const unsigned char *start = buffer;
231 unsigned int width_multiplier = 1;
232 unsigned int interval;
236 format->type = buffer[2];
237 format->index = buffer[3];
240 case UVC_VS_FORMAT_UNCOMPRESSED:
241 case UVC_VS_FORMAT_FRAME_BASED:
242 n = buffer[2] == UVC_VS_FORMAT_UNCOMPRESSED ? 27 : 28;
245 "device %d videostreaming interface %d FORMAT error\n",
247 alts->desc.bInterfaceNumber);
251 /* Find the format descriptor from its GUID. */
252 fmtdesc = uvc_format_by_guid(&buffer[5]);
256 * Unknown video formats are not fatal errors, the
257 * caller will skip this descriptor.
259 dev_info(&streaming->intf->dev,
260 "Unknown video format %pUl\n", &buffer[5]);
264 format->fcc = fmtdesc->fcc;
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 format->fcc = V4L2_PIX_FMT_GREY;
275 width_multiplier = 2;
279 /* Some devices report bpp that doesn't match the format. */
280 if (dev->quirks & UVC_QUIRK_FORCE_BPP) {
281 const struct v4l2_format_info *info =
282 v4l2_format_info(format->fcc);
285 unsigned int div = info->hdiv * info->vdiv;
287 n = info->bpp[0] * div;
288 for (i = 1; i < info->comp_planes; i++)
291 format->bpp = DIV_ROUND_UP(8 * n, div);
295 if (buffer[2] == UVC_VS_FORMAT_UNCOMPRESSED) {
296 ftype = UVC_VS_FRAME_UNCOMPRESSED;
298 ftype = UVC_VS_FRAME_FRAME_BASED;
300 format->flags = UVC_FMT_FLAG_COMPRESSED;
304 case UVC_VS_FORMAT_MJPEG:
307 "device %d videostreaming interface %d FORMAT error\n",
309 alts->desc.bInterfaceNumber);
313 format->fcc = V4L2_PIX_FMT_MJPEG;
314 format->flags = UVC_FMT_FLAG_COMPRESSED;
316 ftype = UVC_VS_FRAME_MJPEG;
319 case UVC_VS_FORMAT_DV:
322 "device %d videostreaming interface %d FORMAT error\n",
324 alts->desc.bInterfaceNumber);
328 if ((buffer[8] & 0x7f) > 2) {
330 "device %d videostreaming interface %d: unknown DV format %u\n",
332 alts->desc.bInterfaceNumber, buffer[8]);
336 format->fcc = V4L2_PIX_FMT_DV;
337 format->flags = UVC_FMT_FLAG_COMPRESSED | UVC_FMT_FLAG_STREAM;
341 /* Create a dummy frame descriptor. */
342 frame = &format->frame[0];
343 memset(&format->frame[0], 0, sizeof(format->frame[0]));
344 frame->bFrameIntervalType = 1;
345 frame->dwDefaultFrameInterval = 1;
346 frame->dwFrameInterval = *intervals;
351 case UVC_VS_FORMAT_MPEG2TS:
352 case UVC_VS_FORMAT_STREAM_BASED:
353 /* Not supported yet. */
356 "device %d videostreaming interface %d unsupported format %u\n",
357 dev->udev->devnum, alts->desc.bInterfaceNumber,
362 uvc_dbg(dev, DESCR, "Found format %p4cc", &format->fcc);
368 * Parse the frame descriptors. Only uncompressed, MJPEG and frame
369 * based formats have frame descriptors.
371 while (buflen > 2 && buffer[1] == USB_DT_CS_INTERFACE &&
372 buffer[2] == ftype) {
373 frame = &format->frame[format->nframes];
374 if (ftype != UVC_VS_FRAME_FRAME_BASED)
375 n = buflen > 25 ? buffer[25] : 0;
377 n = buflen > 21 ? buffer[21] : 0;
381 if (buflen < 26 + 4*n) {
383 "device %d videostreaming interface %d FRAME error\n",
385 alts->desc.bInterfaceNumber);
389 frame->bFrameIndex = buffer[3];
390 frame->bmCapabilities = buffer[4];
391 frame->wWidth = get_unaligned_le16(&buffer[5])
393 frame->wHeight = get_unaligned_le16(&buffer[7]);
394 frame->dwMinBitRate = get_unaligned_le32(&buffer[9]);
395 frame->dwMaxBitRate = get_unaligned_le32(&buffer[13]);
396 if (ftype != UVC_VS_FRAME_FRAME_BASED) {
397 frame->dwMaxVideoFrameBufferSize =
398 get_unaligned_le32(&buffer[17]);
399 frame->dwDefaultFrameInterval =
400 get_unaligned_le32(&buffer[21]);
401 frame->bFrameIntervalType = buffer[25];
403 frame->dwMaxVideoFrameBufferSize = 0;
404 frame->dwDefaultFrameInterval =
405 get_unaligned_le32(&buffer[17]);
406 frame->bFrameIntervalType = buffer[21];
408 frame->dwFrameInterval = *intervals;
411 * Several UVC chipsets screw up dwMaxVideoFrameBufferSize
412 * completely. Observed behaviours range from setting the
413 * value to 1.1x the actual frame size to hardwiring the
414 * 16 low bits to 0. This results in a higher than necessary
415 * memory usage as well as a wrong image size information. For
416 * uncompressed formats this can be fixed by computing the
417 * value from the frame size.
419 if (!(format->flags & UVC_FMT_FLAG_COMPRESSED))
420 frame->dwMaxVideoFrameBufferSize = format->bpp
421 * frame->wWidth * frame->wHeight / 8;
424 * Some bogus devices report dwMinFrameInterval equal to
425 * dwMaxFrameInterval and have dwFrameIntervalStep set to
426 * zero. Setting all null intervals to 1 fixes the problem and
427 * some other divisions by zero that could happen.
429 for (i = 0; i < n; ++i) {
430 interval = get_unaligned_le32(&buffer[26+4*i]);
431 *(*intervals)++ = interval ? interval : 1;
435 * Make sure that the default frame interval stays between
438 n -= frame->bFrameIntervalType ? 1 : 2;
439 frame->dwDefaultFrameInterval =
440 min(frame->dwFrameInterval[n],
441 max(frame->dwFrameInterval[0],
442 frame->dwDefaultFrameInterval));
444 if (dev->quirks & UVC_QUIRK_RESTRICT_FRAME_RATE) {
445 frame->bFrameIntervalType = 1;
446 frame->dwFrameInterval[0] =
447 frame->dwDefaultFrameInterval;
450 uvc_dbg(dev, DESCR, "- %ux%u (%u.%u fps)\n",
451 frame->wWidth, frame->wHeight,
452 10000000 / frame->dwDefaultFrameInterval,
453 (100000000 / frame->dwDefaultFrameInterval) % 10);
460 if (buflen > 2 && buffer[1] == USB_DT_CS_INTERFACE &&
461 buffer[2] == UVC_VS_STILL_IMAGE_FRAME) {
466 if (buflen > 2 && buffer[1] == USB_DT_CS_INTERFACE &&
467 buffer[2] == UVC_VS_COLORFORMAT) {
470 "device %d videostreaming interface %d COLORFORMAT error\n",
472 alts->desc.bInterfaceNumber);
476 format->colorspace = uvc_colorspace(buffer[3]);
477 format->xfer_func = uvc_xfer_func(buffer[4]);
478 format->ycbcr_enc = uvc_ycbcr_enc(buffer[5]);
483 format->colorspace = V4L2_COLORSPACE_SRGB;
486 return buffer - start;
489 static int uvc_parse_streaming(struct uvc_device *dev,
490 struct usb_interface *intf)
492 struct uvc_streaming *streaming = NULL;
493 struct uvc_format *format;
494 struct uvc_frame *frame;
495 struct usb_host_interface *alts = &intf->altsetting[0];
496 unsigned char *_buffer, *buffer = alts->extra;
497 int _buflen, buflen = alts->extralen;
498 unsigned int nformats = 0, nframes = 0, nintervals = 0;
499 unsigned int size, i, n, p;
504 if (intf->cur_altsetting->desc.bInterfaceSubClass
505 != UVC_SC_VIDEOSTREAMING) {
507 "device %d interface %d isn't a video streaming interface\n",
509 intf->altsetting[0].desc.bInterfaceNumber);
513 if (usb_driver_claim_interface(&uvc_driver.driver, intf, dev)) {
515 "device %d interface %d is already claimed\n",
517 intf->altsetting[0].desc.bInterfaceNumber);
521 streaming = uvc_stream_new(dev, intf);
522 if (streaming == NULL) {
523 usb_driver_release_interface(&uvc_driver.driver, intf);
528 * The Pico iMage webcam has its class-specific interface descriptors
529 * after the endpoint descriptors.
532 for (i = 0; i < alts->desc.bNumEndpoints; ++i) {
533 struct usb_host_endpoint *ep = &alts->endpoint[i];
535 if (ep->extralen == 0)
538 if (ep->extralen > 2 &&
539 ep->extra[1] == USB_DT_CS_INTERFACE) {
541 "trying extra data from endpoint %u\n",
543 buffer = alts->endpoint[i].extra;
544 buflen = alts->endpoint[i].extralen;
550 /* Skip the standard interface descriptors. */
551 while (buflen > 2 && buffer[1] != USB_DT_CS_INTERFACE) {
558 "no class-specific streaming interface descriptors found\n");
562 /* Parse the header descriptor. */
564 case UVC_VS_OUTPUT_HEADER:
565 streaming->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
569 case UVC_VS_INPUT_HEADER:
570 streaming->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
576 "device %d videostreaming interface %d HEADER descriptor not found\n",
577 dev->udev->devnum, alts->desc.bInterfaceNumber);
581 p = buflen >= 4 ? buffer[3] : 0;
582 n = buflen >= size ? buffer[size-1] : 0;
584 if (buflen < size + p*n) {
586 "device %d videostreaming interface %d HEADER descriptor is invalid\n",
587 dev->udev->devnum, alts->desc.bInterfaceNumber);
591 streaming->header.bNumFormats = p;
592 streaming->header.bEndpointAddress = buffer[6];
593 if (buffer[2] == UVC_VS_INPUT_HEADER) {
594 streaming->header.bmInfo = buffer[7];
595 streaming->header.bTerminalLink = buffer[8];
596 streaming->header.bStillCaptureMethod = buffer[9];
597 streaming->header.bTriggerSupport = buffer[10];
598 streaming->header.bTriggerUsage = buffer[11];
600 streaming->header.bTerminalLink = buffer[7];
602 streaming->header.bControlSize = n;
604 streaming->header.bmaControls = kmemdup(&buffer[size], p * n,
606 if (streaming->header.bmaControls == NULL) {
617 /* Count the format and frame descriptors. */
618 while (_buflen > 2 && _buffer[1] == USB_DT_CS_INTERFACE) {
619 switch (_buffer[2]) {
620 case UVC_VS_FORMAT_UNCOMPRESSED:
621 case UVC_VS_FORMAT_MJPEG:
622 case UVC_VS_FORMAT_FRAME_BASED:
626 case UVC_VS_FORMAT_DV:
628 * DV format has no frame descriptor. We will create a
629 * dummy frame descriptor with a dummy frame interval.
636 case UVC_VS_FORMAT_MPEG2TS:
637 case UVC_VS_FORMAT_STREAM_BASED:
639 "device %d videostreaming interface %d FORMAT %u is not supported\n",
641 alts->desc.bInterfaceNumber, _buffer[2]);
644 case UVC_VS_FRAME_UNCOMPRESSED:
645 case UVC_VS_FRAME_MJPEG:
648 nintervals += _buffer[25] ? _buffer[25] : 3;
651 case UVC_VS_FRAME_FRAME_BASED:
654 nintervals += _buffer[21] ? _buffer[21] : 3;
658 _buflen -= _buffer[0];
659 _buffer += _buffer[0];
664 "device %d videostreaming interface %d has no supported formats defined\n",
665 dev->udev->devnum, alts->desc.bInterfaceNumber);
669 size = nformats * sizeof(*format) + nframes * sizeof(*frame)
670 + nintervals * sizeof(*interval);
671 format = kzalloc(size, GFP_KERNEL);
672 if (format == NULL) {
677 frame = (struct uvc_frame *)&format[nformats];
678 interval = (u32 *)&frame[nframes];
680 streaming->format = format;
681 streaming->nformats = 0;
683 /* Parse the format descriptors. */
684 while (buflen > 2 && buffer[1] == USB_DT_CS_INTERFACE) {
686 case UVC_VS_FORMAT_UNCOMPRESSED:
687 case UVC_VS_FORMAT_MJPEG:
688 case UVC_VS_FORMAT_DV:
689 case UVC_VS_FORMAT_FRAME_BASED:
690 format->frame = frame;
691 ret = uvc_parse_format(dev, streaming, format,
692 &interval, buffer, buflen);
698 streaming->nformats++;
699 frame += format->nframes;
716 "device %d videostreaming interface %d has %u bytes of trailing descriptor garbage\n",
717 dev->udev->devnum, alts->desc.bInterfaceNumber, buflen);
719 /* Parse the alternate settings to find the maximum bandwidth. */
720 for (i = 0; i < intf->num_altsetting; ++i) {
721 struct usb_host_endpoint *ep;
723 alts = &intf->altsetting[i];
724 ep = uvc_find_endpoint(alts,
725 streaming->header.bEndpointAddress);
728 psize = uvc_endpoint_max_bpi(dev->udev, ep);
729 if (psize > streaming->maxpsize)
730 streaming->maxpsize = psize;
733 list_add_tail(&streaming->list, &dev->streams);
737 usb_driver_release_interface(&uvc_driver.driver, intf);
738 uvc_stream_delete(streaming);
742 static const u8 uvc_camera_guid[16] = UVC_GUID_UVC_CAMERA;
743 static const u8 uvc_gpio_guid[16] = UVC_GUID_EXT_GPIO_CONTROLLER;
744 static const u8 uvc_media_transport_input_guid[16] =
745 UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT;
746 static const u8 uvc_processing_guid[16] = UVC_GUID_UVC_PROCESSING;
748 static struct uvc_entity *uvc_alloc_entity(u16 type, u16 id,
749 unsigned int num_pads, unsigned int extra_size)
751 struct uvc_entity *entity;
752 unsigned int num_inputs;
756 extra_size = roundup(extra_size, sizeof(*entity->pads));
758 num_inputs = type & UVC_TERM_OUTPUT ? num_pads : num_pads - 1;
761 size = sizeof(*entity) + extra_size + sizeof(*entity->pads) * num_pads
763 entity = kzalloc(size, GFP_KERNEL);
771 * Set the GUID for standard entity types. For extension units, the GUID
772 * is initialized by the caller.
775 case UVC_EXT_GPIO_UNIT:
776 memcpy(entity->guid, uvc_gpio_guid, 16);
779 memcpy(entity->guid, uvc_camera_guid, 16);
781 case UVC_ITT_MEDIA_TRANSPORT_INPUT:
782 memcpy(entity->guid, uvc_media_transport_input_guid, 16);
784 case UVC_VC_PROCESSING_UNIT:
785 memcpy(entity->guid, uvc_processing_guid, 16);
789 entity->num_links = 0;
790 entity->num_pads = num_pads;
791 entity->pads = ((void *)(entity + 1)) + extra_size;
793 for (i = 0; i < num_inputs; ++i)
794 entity->pads[i].flags = MEDIA_PAD_FL_SINK;
795 if (!UVC_ENTITY_IS_OTERM(entity) && num_pads)
796 entity->pads[num_pads-1].flags = MEDIA_PAD_FL_SOURCE;
798 entity->bNrInPins = num_inputs;
799 entity->baSourceID = (u8 *)(&entity->pads[num_pads]);
804 static void uvc_entity_set_name(struct uvc_device *dev, struct uvc_entity *entity,
805 const char *type_name, u8 string_id)
810 * First attempt to read the entity name from the device. If the entity
811 * has no associated string, or if reading the string fails (most
812 * likely due to a buggy firmware), fall back to default names based on
816 ret = usb_string(dev->udev, string_id, entity->name,
817 sizeof(entity->name));
822 sprintf(entity->name, "%s %u", type_name, entity->id);
825 /* Parse vendor-specific extensions. */
826 static int uvc_parse_vendor_control(struct uvc_device *dev,
827 const unsigned char *buffer, int buflen)
829 struct usb_device *udev = dev->udev;
830 struct usb_host_interface *alts = dev->intf->cur_altsetting;
831 struct uvc_entity *unit;
835 switch (le16_to_cpu(dev->udev->descriptor.idVendor)) {
836 case 0x046d: /* Logitech */
837 if (buffer[1] != 0x41 || buffer[2] != 0x01)
841 * Logitech implements several vendor specific functions
842 * through vendor specific extension units (LXU).
844 * The LXU descriptors are similar to XU descriptors
845 * (see "USB Device Video Class for Video Devices", section
846 * 3.7.2.6 "Extension Unit Descriptor") with the following
849 * ----------------------------------------------------------
851 * Size of this descriptor, in bytes: 24+p+n*2
852 * ----------------------------------------------------------
853 * 23+p+n bmControlsType N Bitmap
854 * Individual bits in the set are defined:
858 * This bitset is mapped exactly the same as bmControls.
859 * ----------------------------------------------------------
860 * 23+p+n*2 bReserved 1 Boolean
861 * ----------------------------------------------------------
862 * 24+p+n*2 iExtension 1 Index
863 * Index of a string descriptor that describes this
865 * ----------------------------------------------------------
867 p = buflen >= 22 ? buffer[21] : 0;
868 n = buflen >= 25 + p ? buffer[22+p] : 0;
870 if (buflen < 25 + p + 2*n) {
872 "device %d videocontrol interface %d EXTENSION_UNIT error\n",
873 udev->devnum, alts->desc.bInterfaceNumber);
877 unit = uvc_alloc_entity(UVC_VC_EXTENSION_UNIT, buffer[3],
882 memcpy(unit->guid, &buffer[4], 16);
883 unit->extension.bNumControls = buffer[20];
884 memcpy(unit->baSourceID, &buffer[22], p);
885 unit->extension.bControlSize = buffer[22+p];
886 unit->extension.bmControls = (u8 *)unit + sizeof(*unit);
887 unit->extension.bmControlsType = (u8 *)unit + sizeof(*unit)
889 memcpy(unit->extension.bmControls, &buffer[23+p], 2*n);
891 uvc_entity_set_name(dev, unit, "Extension", buffer[24+p+2*n]);
893 list_add_tail(&unit->list, &dev->entities);
901 static int uvc_parse_standard_control(struct uvc_device *dev,
902 const unsigned char *buffer, int buflen)
904 struct usb_device *udev = dev->udev;
905 struct uvc_entity *unit, *term;
906 struct usb_interface *intf;
907 struct usb_host_interface *alts = dev->intf->cur_altsetting;
908 unsigned int i, n, p, len;
909 const char *type_name;
914 n = buflen >= 12 ? buffer[11] : 0;
916 if (buflen < 12 + n) {
918 "device %d videocontrol interface %d HEADER error\n",
919 udev->devnum, alts->desc.bInterfaceNumber);
923 dev->uvc_version = get_unaligned_le16(&buffer[3]);
924 dev->clock_frequency = get_unaligned_le32(&buffer[7]);
926 /* Parse all USB Video Streaming interfaces. */
927 for (i = 0; i < n; ++i) {
928 intf = usb_ifnum_to_if(udev, buffer[12+i]);
931 "device %d interface %d doesn't exists\n",
936 uvc_parse_streaming(dev, intf);
940 case UVC_VC_INPUT_TERMINAL:
943 "device %d videocontrol interface %d INPUT_TERMINAL error\n",
944 udev->devnum, alts->desc.bInterfaceNumber);
949 * Reject invalid terminal types that would cause issues:
951 * - The high byte must be non-zero, otherwise it would be
952 * confused with a unit.
954 * - Bit 15 must be 0, as we use it internally as a terminal
957 * Other unknown types are accepted.
959 type = get_unaligned_le16(&buffer[4]);
960 if ((type & 0x7f00) == 0 || (type & 0x8000) != 0) {
962 "device %d videocontrol interface %d INPUT_TERMINAL %d has invalid type 0x%04x, skipping\n",
963 udev->devnum, alts->desc.bInterfaceNumber,
972 if (type == UVC_ITT_CAMERA) {
973 n = buflen >= 15 ? buffer[14] : 0;
976 } else if (type == UVC_ITT_MEDIA_TRANSPORT_INPUT) {
977 n = buflen >= 9 ? buffer[8] : 0;
978 p = buflen >= 10 + n ? buffer[9+n] : 0;
982 if (buflen < len + n + p) {
984 "device %d videocontrol interface %d INPUT_TERMINAL error\n",
985 udev->devnum, alts->desc.bInterfaceNumber);
989 term = uvc_alloc_entity(type | UVC_TERM_INPUT, buffer[3],
994 if (UVC_ENTITY_TYPE(term) == UVC_ITT_CAMERA) {
995 term->camera.bControlSize = n;
996 term->camera.bmControls = (u8 *)term + sizeof(*term);
997 term->camera.wObjectiveFocalLengthMin =
998 get_unaligned_le16(&buffer[8]);
999 term->camera.wObjectiveFocalLengthMax =
1000 get_unaligned_le16(&buffer[10]);
1001 term->camera.wOcularFocalLength =
1002 get_unaligned_le16(&buffer[12]);
1003 memcpy(term->camera.bmControls, &buffer[15], n);
1004 } else if (UVC_ENTITY_TYPE(term) ==
1005 UVC_ITT_MEDIA_TRANSPORT_INPUT) {
1006 term->media.bControlSize = n;
1007 term->media.bmControls = (u8 *)term + sizeof(*term);
1008 term->media.bTransportModeSize = p;
1009 term->media.bmTransportModes = (u8 *)term
1010 + sizeof(*term) + n;
1011 memcpy(term->media.bmControls, &buffer[9], n);
1012 memcpy(term->media.bmTransportModes, &buffer[10+n], p);
1015 if (UVC_ENTITY_TYPE(term) == UVC_ITT_CAMERA)
1016 type_name = "Camera";
1017 else if (UVC_ENTITY_TYPE(term) == UVC_ITT_MEDIA_TRANSPORT_INPUT)
1018 type_name = "Media";
1020 type_name = "Input";
1022 uvc_entity_set_name(dev, term, type_name, buffer[7]);
1024 list_add_tail(&term->list, &dev->entities);
1027 case UVC_VC_OUTPUT_TERMINAL:
1030 "device %d videocontrol interface %d OUTPUT_TERMINAL error\n",
1031 udev->devnum, alts->desc.bInterfaceNumber);
1036 * Make sure the terminal type MSB is not null, otherwise it
1037 * could be confused with a unit.
1039 type = get_unaligned_le16(&buffer[4]);
1040 if ((type & 0xff00) == 0) {
1042 "device %d videocontrol interface %d OUTPUT_TERMINAL %d has invalid type 0x%04x, skipping\n",
1043 udev->devnum, alts->desc.bInterfaceNumber,
1048 term = uvc_alloc_entity(type | UVC_TERM_OUTPUT, buffer[3],
1053 memcpy(term->baSourceID, &buffer[7], 1);
1055 uvc_entity_set_name(dev, term, "Output", buffer[8]);
1057 list_add_tail(&term->list, &dev->entities);
1060 case UVC_VC_SELECTOR_UNIT:
1061 p = buflen >= 5 ? buffer[4] : 0;
1063 if (buflen < 5 || buflen < 6 + p) {
1065 "device %d videocontrol interface %d SELECTOR_UNIT error\n",
1066 udev->devnum, alts->desc.bInterfaceNumber);
1070 unit = uvc_alloc_entity(buffer[2], buffer[3], p + 1, 0);
1074 memcpy(unit->baSourceID, &buffer[5], p);
1076 uvc_entity_set_name(dev, unit, "Selector", buffer[5+p]);
1078 list_add_tail(&unit->list, &dev->entities);
1081 case UVC_VC_PROCESSING_UNIT:
1082 n = buflen >= 8 ? buffer[7] : 0;
1083 p = dev->uvc_version >= 0x0110 ? 10 : 9;
1085 if (buflen < p + n) {
1087 "device %d videocontrol interface %d PROCESSING_UNIT error\n",
1088 udev->devnum, alts->desc.bInterfaceNumber);
1092 unit = uvc_alloc_entity(buffer[2], buffer[3], 2, n);
1096 memcpy(unit->baSourceID, &buffer[4], 1);
1097 unit->processing.wMaxMultiplier =
1098 get_unaligned_le16(&buffer[5]);
1099 unit->processing.bControlSize = buffer[7];
1100 unit->processing.bmControls = (u8 *)unit + sizeof(*unit);
1101 memcpy(unit->processing.bmControls, &buffer[8], n);
1102 if (dev->uvc_version >= 0x0110)
1103 unit->processing.bmVideoStandards = buffer[9+n];
1105 uvc_entity_set_name(dev, unit, "Processing", buffer[8+n]);
1107 list_add_tail(&unit->list, &dev->entities);
1110 case UVC_VC_EXTENSION_UNIT:
1111 p = buflen >= 22 ? buffer[21] : 0;
1112 n = buflen >= 24 + p ? buffer[22+p] : 0;
1114 if (buflen < 24 + p + n) {
1116 "device %d videocontrol interface %d EXTENSION_UNIT error\n",
1117 udev->devnum, alts->desc.bInterfaceNumber);
1121 unit = uvc_alloc_entity(buffer[2], buffer[3], p + 1, n);
1125 memcpy(unit->guid, &buffer[4], 16);
1126 unit->extension.bNumControls = buffer[20];
1127 memcpy(unit->baSourceID, &buffer[22], p);
1128 unit->extension.bControlSize = buffer[22+p];
1129 unit->extension.bmControls = (u8 *)unit + sizeof(*unit);
1130 memcpy(unit->extension.bmControls, &buffer[23+p], n);
1132 uvc_entity_set_name(dev, unit, "Extension", buffer[23+p+n]);
1134 list_add_tail(&unit->list, &dev->entities);
1139 "Found an unknown CS_INTERFACE descriptor (%u)\n",
1147 static int uvc_parse_control(struct uvc_device *dev)
1149 struct usb_host_interface *alts = dev->intf->cur_altsetting;
1150 unsigned char *buffer = alts->extra;
1151 int buflen = alts->extralen;
1155 * Parse the default alternate setting only, as the UVC specification
1156 * defines a single alternate setting, the default alternate setting
1160 while (buflen > 2) {
1161 if (uvc_parse_vendor_control(dev, buffer, buflen) ||
1162 buffer[1] != USB_DT_CS_INTERFACE)
1163 goto next_descriptor;
1165 ret = uvc_parse_standard_control(dev, buffer, buflen);
1170 buflen -= buffer[0];
1171 buffer += buffer[0];
1175 * Check if the optional status endpoint is present. Built-in iSight
1176 * webcams have an interrupt endpoint but spit proprietary data that
1177 * don't conform to the UVC status endpoint messages. Don't try to
1178 * handle the interrupt endpoint for those cameras.
1180 if (alts->desc.bNumEndpoints == 1 &&
1181 !(dev->quirks & UVC_QUIRK_BUILTIN_ISIGHT)) {
1182 struct usb_host_endpoint *ep = &alts->endpoint[0];
1183 struct usb_endpoint_descriptor *desc = &ep->desc;
1185 if (usb_endpoint_is_int_in(desc) &&
1186 le16_to_cpu(desc->wMaxPacketSize) >= 8 &&
1187 desc->bInterval != 0) {
1189 "Found a Status endpoint (addr %02x)\n",
1190 desc->bEndpointAddress);
1198 /* -----------------------------------------------------------------------------
1202 static void uvc_gpio_event(struct uvc_device *dev)
1204 struct uvc_entity *unit = dev->gpio_unit;
1205 struct uvc_video_chain *chain;
1211 new_val = gpiod_get_value_cansleep(unit->gpio.gpio_privacy);
1213 /* GPIO entities are always on the first chain. */
1214 chain = list_first_entry(&dev->chains, struct uvc_video_chain, list);
1215 uvc_ctrl_status_event(chain, unit->controls, &new_val);
1218 static int uvc_gpio_get_cur(struct uvc_device *dev, struct uvc_entity *entity,
1219 u8 cs, void *data, u16 size)
1221 if (cs != UVC_CT_PRIVACY_CONTROL || size < 1)
1224 *(u8 *)data = gpiod_get_value_cansleep(entity->gpio.gpio_privacy);
1229 static int uvc_gpio_get_info(struct uvc_device *dev, struct uvc_entity *entity,
1232 if (cs != UVC_CT_PRIVACY_CONTROL)
1235 *caps = UVC_CONTROL_CAP_GET | UVC_CONTROL_CAP_AUTOUPDATE;
1239 static irqreturn_t uvc_gpio_irq(int irq, void *data)
1241 struct uvc_device *dev = data;
1243 uvc_gpio_event(dev);
1247 static int uvc_gpio_parse(struct uvc_device *dev)
1249 struct uvc_entity *unit;
1250 struct gpio_desc *gpio_privacy;
1253 gpio_privacy = devm_gpiod_get_optional(&dev->udev->dev, "privacy",
1255 if (IS_ERR_OR_NULL(gpio_privacy))
1256 return PTR_ERR_OR_ZERO(gpio_privacy);
1258 irq = gpiod_to_irq(gpio_privacy);
1260 return dev_err_probe(&dev->udev->dev, irq,
1261 "No IRQ for privacy GPIO\n");
1263 unit = uvc_alloc_entity(UVC_EXT_GPIO_UNIT, UVC_EXT_GPIO_UNIT_ID, 0, 1);
1267 unit->gpio.gpio_privacy = gpio_privacy;
1268 unit->gpio.irq = irq;
1269 unit->gpio.bControlSize = 1;
1270 unit->gpio.bmControls = (u8 *)unit + sizeof(*unit);
1271 unit->gpio.bmControls[0] = 1;
1272 unit->get_cur = uvc_gpio_get_cur;
1273 unit->get_info = uvc_gpio_get_info;
1274 strscpy(unit->name, "GPIO", sizeof(unit->name));
1276 list_add_tail(&unit->list, &dev->entities);
1278 dev->gpio_unit = unit;
1283 static int uvc_gpio_init_irq(struct uvc_device *dev)
1285 struct uvc_entity *unit = dev->gpio_unit;
1287 if (!unit || unit->gpio.irq < 0)
1290 return devm_request_threaded_irq(&dev->udev->dev, unit->gpio.irq, NULL,
1292 IRQF_ONESHOT | IRQF_TRIGGER_FALLING |
1293 IRQF_TRIGGER_RISING,
1294 "uvc_privacy_gpio", dev);
1297 /* ------------------------------------------------------------------------
1302 * Scan the UVC descriptors to locate a chain starting at an Output Terminal
1303 * and containing the following units:
1305 * - one or more Output Terminals (USB Streaming or Display)
1306 * - zero or one Processing Unit
1307 * - zero, one or more single-input Selector Units
1308 * - zero or one multiple-input Selector Units, provided all inputs are
1309 * connected to input terminals
1310 * - zero, one or mode single-input Extension Units
1311 * - one or more Input Terminals (Camera, External or USB Streaming)
1313 * The terminal and units must match on of the following structures:
1315 * ITT_*(0) -> +---------+ +---------+ +---------+ -> TT_STREAMING(0)
1316 * ... | SU{0,1} | -> | PU{0,1} | -> | XU{0,n} | ...
1317 * ITT_*(n) -> +---------+ +---------+ +---------+ -> TT_STREAMING(n)
1319 * +---------+ +---------+ -> OTT_*(0)
1320 * TT_STREAMING -> | PU{0,1} | -> | XU{0,n} | ...
1321 * +---------+ +---------+ -> OTT_*(n)
1323 * The Processing Unit and Extension Units can be in any order. Additional
1324 * Extension Units connected to the main chain as single-unit branches are
1325 * also supported. Single-input Selector Units are ignored.
1327 static int uvc_scan_chain_entity(struct uvc_video_chain *chain,
1328 struct uvc_entity *entity)
1330 switch (UVC_ENTITY_TYPE(entity)) {
1331 case UVC_VC_EXTENSION_UNIT:
1332 uvc_dbg_cont(PROBE, " <- XU %d", entity->id);
1334 if (entity->bNrInPins != 1) {
1335 uvc_dbg(chain->dev, DESCR,
1336 "Extension unit %d has more than 1 input pin\n",
1343 case UVC_VC_PROCESSING_UNIT:
1344 uvc_dbg_cont(PROBE, " <- PU %d", entity->id);
1346 if (chain->processing != NULL) {
1347 uvc_dbg(chain->dev, DESCR,
1348 "Found multiple Processing Units in chain\n");
1352 chain->processing = entity;
1355 case UVC_VC_SELECTOR_UNIT:
1356 uvc_dbg_cont(PROBE, " <- SU %d", entity->id);
1358 /* Single-input selector units are ignored. */
1359 if (entity->bNrInPins == 1)
1362 if (chain->selector != NULL) {
1363 uvc_dbg(chain->dev, DESCR,
1364 "Found multiple Selector Units in chain\n");
1368 chain->selector = entity;
1371 case UVC_ITT_VENDOR_SPECIFIC:
1372 case UVC_ITT_CAMERA:
1373 case UVC_ITT_MEDIA_TRANSPORT_INPUT:
1374 uvc_dbg_cont(PROBE, " <- IT %d\n", entity->id);
1378 case UVC_OTT_VENDOR_SPECIFIC:
1379 case UVC_OTT_DISPLAY:
1380 case UVC_OTT_MEDIA_TRANSPORT_OUTPUT:
1381 uvc_dbg_cont(PROBE, " OT %d", entity->id);
1385 case UVC_TT_STREAMING:
1386 if (UVC_ENTITY_IS_ITERM(entity))
1387 uvc_dbg_cont(PROBE, " <- IT %d\n", entity->id);
1389 uvc_dbg_cont(PROBE, " OT %d", entity->id);
1394 uvc_dbg(chain->dev, DESCR,
1395 "Unsupported entity type 0x%04x found in chain\n",
1396 UVC_ENTITY_TYPE(entity));
1400 list_add_tail(&entity->chain, &chain->entities);
1404 static int uvc_scan_chain_forward(struct uvc_video_chain *chain,
1405 struct uvc_entity *entity, struct uvc_entity *prev)
1407 struct uvc_entity *forward;
1415 forward = uvc_entity_by_reference(chain->dev, entity->id,
1417 if (forward == NULL)
1419 if (forward == prev)
1421 if (forward->chain.next || forward->chain.prev) {
1422 uvc_dbg(chain->dev, DESCR,
1423 "Found reference to entity %d already in chain\n",
1428 switch (UVC_ENTITY_TYPE(forward)) {
1429 case UVC_VC_EXTENSION_UNIT:
1430 if (forward->bNrInPins != 1) {
1431 uvc_dbg(chain->dev, DESCR,
1432 "Extension unit %d has more than 1 input pin\n",
1438 * Some devices reference an output terminal as the
1439 * source of extension units. This is incorrect, as
1440 * output terminals only have an input pin, and thus
1441 * can't be connected to any entity in the forward
1442 * direction. The resulting topology would cause issues
1443 * when registering the media controller graph. To
1444 * avoid this problem, connect the extension unit to
1445 * the source of the output terminal instead.
1447 if (UVC_ENTITY_IS_OTERM(entity)) {
1448 struct uvc_entity *source;
1450 source = uvc_entity_by_id(chain->dev,
1451 entity->baSourceID[0]);
1453 uvc_dbg(chain->dev, DESCR,
1454 "Can't connect extension unit %u in chain\n",
1459 forward->baSourceID[0] = source->id;
1462 list_add_tail(&forward->chain, &chain->entities);
1464 uvc_dbg_cont(PROBE, " (->");
1466 uvc_dbg_cont(PROBE, " XU %d", forward->id);
1470 case UVC_OTT_VENDOR_SPECIFIC:
1471 case UVC_OTT_DISPLAY:
1472 case UVC_OTT_MEDIA_TRANSPORT_OUTPUT:
1473 case UVC_TT_STREAMING:
1474 if (UVC_ENTITY_IS_ITERM(forward)) {
1475 uvc_dbg(chain->dev, DESCR,
1476 "Unsupported input terminal %u\n",
1481 if (UVC_ENTITY_IS_OTERM(entity)) {
1482 uvc_dbg(chain->dev, DESCR,
1483 "Unsupported connection between output terminals %u and %u\n",
1484 entity->id, forward->id);
1488 list_add_tail(&forward->chain, &chain->entities);
1490 uvc_dbg_cont(PROBE, " (->");
1492 uvc_dbg_cont(PROBE, " OT %d", forward->id);
1498 uvc_dbg_cont(PROBE, ")");
1503 static int uvc_scan_chain_backward(struct uvc_video_chain *chain,
1504 struct uvc_entity **_entity)
1506 struct uvc_entity *entity = *_entity;
1507 struct uvc_entity *term;
1508 int id = -EINVAL, i;
1510 switch (UVC_ENTITY_TYPE(entity)) {
1511 case UVC_VC_EXTENSION_UNIT:
1512 case UVC_VC_PROCESSING_UNIT:
1513 id = entity->baSourceID[0];
1516 case UVC_VC_SELECTOR_UNIT:
1517 /* Single-input selector units are ignored. */
1518 if (entity->bNrInPins == 1) {
1519 id = entity->baSourceID[0];
1523 uvc_dbg_cont(PROBE, " <- IT");
1525 chain->selector = entity;
1526 for (i = 0; i < entity->bNrInPins; ++i) {
1527 id = entity->baSourceID[i];
1528 term = uvc_entity_by_id(chain->dev, id);
1529 if (term == NULL || !UVC_ENTITY_IS_ITERM(term)) {
1530 uvc_dbg(chain->dev, DESCR,
1531 "Selector unit %d input %d isn't connected to an input terminal\n",
1536 if (term->chain.next || term->chain.prev) {
1537 uvc_dbg(chain->dev, DESCR,
1538 "Found reference to entity %d already in chain\n",
1543 uvc_dbg_cont(PROBE, " %d", term->id);
1545 list_add_tail(&term->chain, &chain->entities);
1546 uvc_scan_chain_forward(chain, term, entity);
1549 uvc_dbg_cont(PROBE, "\n");
1554 case UVC_ITT_VENDOR_SPECIFIC:
1555 case UVC_ITT_CAMERA:
1556 case UVC_ITT_MEDIA_TRANSPORT_INPUT:
1557 case UVC_OTT_VENDOR_SPECIFIC:
1558 case UVC_OTT_DISPLAY:
1559 case UVC_OTT_MEDIA_TRANSPORT_OUTPUT:
1560 case UVC_TT_STREAMING:
1561 id = UVC_ENTITY_IS_OTERM(entity) ? entity->baSourceID[0] : 0;
1570 entity = uvc_entity_by_id(chain->dev, id);
1571 if (entity == NULL) {
1572 uvc_dbg(chain->dev, DESCR,
1573 "Found reference to unknown entity %d\n", id);
1581 static int uvc_scan_chain(struct uvc_video_chain *chain,
1582 struct uvc_entity *term)
1584 struct uvc_entity *entity, *prev;
1586 uvc_dbg(chain->dev, PROBE, "Scanning UVC chain:");
1591 while (entity != NULL) {
1592 /* Entity must not be part of an existing chain */
1593 if (entity->chain.next || entity->chain.prev) {
1594 uvc_dbg(chain->dev, DESCR,
1595 "Found reference to entity %d already in chain\n",
1600 /* Process entity */
1601 if (uvc_scan_chain_entity(chain, entity) < 0)
1605 if (uvc_scan_chain_forward(chain, entity, prev) < 0)
1610 if (uvc_scan_chain_backward(chain, &entity) < 0)
1617 static unsigned int uvc_print_terms(struct list_head *terms, u16 dir,
1620 struct uvc_entity *term;
1621 unsigned int nterms = 0;
1624 list_for_each_entry(term, terms, chain) {
1625 if (!UVC_ENTITY_IS_TERM(term) ||
1626 UVC_TERM_DIRECTION(term) != dir)
1630 p += sprintf(p, ",");
1631 if (++nterms >= 4) {
1632 p += sprintf(p, "...");
1635 p += sprintf(p, "%u", term->id);
1641 static const char *uvc_print_chain(struct uvc_video_chain *chain)
1643 static char buffer[43];
1646 p += uvc_print_terms(&chain->entities, UVC_TERM_INPUT, p);
1647 p += sprintf(p, " -> ");
1648 uvc_print_terms(&chain->entities, UVC_TERM_OUTPUT, p);
1653 static struct uvc_video_chain *uvc_alloc_chain(struct uvc_device *dev)
1655 struct uvc_video_chain *chain;
1657 chain = kzalloc(sizeof(*chain), GFP_KERNEL);
1661 INIT_LIST_HEAD(&chain->entities);
1662 mutex_init(&chain->ctrl_mutex);
1664 v4l2_prio_init(&chain->prio);
1670 * Fallback heuristic for devices that don't connect units and terminals in a
1673 * Some devices have invalid baSourceID references, causing uvc_scan_chain()
1674 * to fail, but if we just take the entities we can find and put them together
1675 * in the most sensible chain we can think of, turns out they do work anyway.
1676 * Note: This heuristic assumes there is a single chain.
1678 * At the time of writing, devices known to have such a broken chain are
1679 * - Acer Integrated Camera (5986:055a)
1680 * - Realtek rtl157a7 (0bda:57a7)
1682 static int uvc_scan_fallback(struct uvc_device *dev)
1684 struct uvc_video_chain *chain;
1685 struct uvc_entity *iterm = NULL;
1686 struct uvc_entity *oterm = NULL;
1687 struct uvc_entity *entity;
1688 struct uvc_entity *prev;
1691 * Start by locating the input and output terminals. We only support
1692 * devices with exactly one of each for now.
1694 list_for_each_entry(entity, &dev->entities, list) {
1695 if (UVC_ENTITY_IS_ITERM(entity)) {
1701 if (UVC_ENTITY_IS_OTERM(entity)) {
1708 if (iterm == NULL || oterm == NULL)
1711 /* Allocate the chain and fill it. */
1712 chain = uvc_alloc_chain(dev);
1716 if (uvc_scan_chain_entity(chain, oterm) < 0)
1722 * Add all Processing and Extension Units with two pads. The order
1723 * doesn't matter much, use reverse list traversal to connect units in
1724 * UVC descriptor order as we build the chain from output to input. This
1725 * leads to units appearing in the order meant by the manufacturer for
1726 * the cameras known to require this heuristic.
1728 list_for_each_entry_reverse(entity, &dev->entities, list) {
1729 if (entity->type != UVC_VC_PROCESSING_UNIT &&
1730 entity->type != UVC_VC_EXTENSION_UNIT)
1733 if (entity->num_pads != 2)
1736 if (uvc_scan_chain_entity(chain, entity) < 0)
1739 prev->baSourceID[0] = entity->id;
1743 if (uvc_scan_chain_entity(chain, iterm) < 0)
1746 prev->baSourceID[0] = iterm->id;
1748 list_add_tail(&chain->list, &dev->chains);
1750 uvc_dbg(dev, PROBE, "Found a video chain by fallback heuristic (%s)\n",
1751 uvc_print_chain(chain));
1761 * Scan the device for video chains and register video devices.
1763 * Chains are scanned starting at their output terminals and walked backwards.
1765 static int uvc_scan_device(struct uvc_device *dev)
1767 struct uvc_video_chain *chain;
1768 struct uvc_entity *term;
1770 list_for_each_entry(term, &dev->entities, list) {
1771 if (!UVC_ENTITY_IS_OTERM(term))
1775 * If the terminal is already included in a chain, skip it.
1776 * This can happen for chains that have multiple output
1777 * terminals, where all output terminals beside the first one
1778 * will be inserted in the chain in forward scans.
1780 if (term->chain.next || term->chain.prev)
1783 chain = uvc_alloc_chain(dev);
1787 term->flags |= UVC_ENTITY_FLAG_DEFAULT;
1789 if (uvc_scan_chain(chain, term) < 0) {
1794 uvc_dbg(dev, PROBE, "Found a valid video chain (%s)\n",
1795 uvc_print_chain(chain));
1797 list_add_tail(&chain->list, &dev->chains);
1800 if (list_empty(&dev->chains))
1801 uvc_scan_fallback(dev);
1803 if (list_empty(&dev->chains)) {
1804 dev_info(&dev->udev->dev, "No valid video chain found.\n");
1808 /* Add GPIO entity to the first chain. */
1809 if (dev->gpio_unit) {
1810 chain = list_first_entry(&dev->chains,
1811 struct uvc_video_chain, list);
1812 list_add_tail(&dev->gpio_unit->chain, &chain->entities);
1818 /* ------------------------------------------------------------------------
1819 * Video device registration and unregistration
1823 * Delete the UVC device.
1825 * Called by the kernel when the last reference to the uvc_device structure
1828 * As this function is called after or during disconnect(), all URBs have
1829 * already been cancelled by the USB core. There is no need to kill the
1830 * interrupt URB manually.
1832 static void uvc_delete(struct kref *kref)
1834 struct uvc_device *dev = container_of(kref, struct uvc_device, ref);
1835 struct list_head *p, *n;
1837 uvc_status_cleanup(dev);
1838 uvc_ctrl_cleanup_device(dev);
1840 usb_put_intf(dev->intf);
1841 usb_put_dev(dev->udev);
1843 #ifdef CONFIG_MEDIA_CONTROLLER
1844 media_device_cleanup(&dev->mdev);
1847 list_for_each_safe(p, n, &dev->chains) {
1848 struct uvc_video_chain *chain;
1850 chain = list_entry(p, struct uvc_video_chain, list);
1854 list_for_each_safe(p, n, &dev->entities) {
1855 struct uvc_entity *entity;
1857 entity = list_entry(p, struct uvc_entity, list);
1858 #ifdef CONFIG_MEDIA_CONTROLLER
1859 uvc_mc_cleanup_entity(entity);
1864 list_for_each_safe(p, n, &dev->streams) {
1865 struct uvc_streaming *streaming;
1867 streaming = list_entry(p, struct uvc_streaming, list);
1868 usb_driver_release_interface(&uvc_driver.driver,
1870 uvc_stream_delete(streaming);
1876 static void uvc_release(struct video_device *vdev)
1878 struct uvc_streaming *stream = video_get_drvdata(vdev);
1879 struct uvc_device *dev = stream->dev;
1881 kref_put(&dev->ref, uvc_delete);
1885 * Unregister the video devices.
1887 static void uvc_unregister_video(struct uvc_device *dev)
1889 struct uvc_streaming *stream;
1891 list_for_each_entry(stream, &dev->streams, list) {
1892 if (!video_is_registered(&stream->vdev))
1895 video_unregister_device(&stream->vdev);
1896 video_unregister_device(&stream->meta.vdev);
1898 uvc_debugfs_cleanup_stream(stream);
1901 uvc_status_unregister(dev);
1904 v4l2_device_unregister(&dev->vdev);
1905 #ifdef CONFIG_MEDIA_CONTROLLER
1906 if (media_devnode_is_registered(dev->mdev.devnode))
1907 media_device_unregister(&dev->mdev);
1911 int uvc_register_video_device(struct uvc_device *dev,
1912 struct uvc_streaming *stream,
1913 struct video_device *vdev,
1914 struct uvc_video_queue *queue,
1915 enum v4l2_buf_type type,
1916 const struct v4l2_file_operations *fops,
1917 const struct v4l2_ioctl_ops *ioctl_ops)
1921 /* Initialize the video buffers queue. */
1922 ret = uvc_queue_init(queue, type, !uvc_no_drop_param);
1926 /* Register the device with V4L. */
1929 * We already hold a reference to dev->udev. The video device will be
1930 * unregistered before the reference is released, so we don't need to
1933 vdev->v4l2_dev = &dev->vdev;
1935 vdev->ioctl_ops = ioctl_ops;
1936 vdev->release = uvc_release;
1937 vdev->prio = &stream->chain->prio;
1938 if (type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
1939 vdev->vfl_dir = VFL_DIR_TX;
1941 vdev->vfl_dir = VFL_DIR_RX;
1944 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
1946 vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
1948 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
1949 vdev->device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING;
1951 case V4L2_BUF_TYPE_META_CAPTURE:
1952 vdev->device_caps = V4L2_CAP_META_CAPTURE | V4L2_CAP_STREAMING;
1956 strscpy(vdev->name, dev->name, sizeof(vdev->name));
1959 * Set the driver data before calling video_register_device, otherwise
1960 * the file open() handler might race us.
1962 video_set_drvdata(vdev, stream);
1964 ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1);
1966 dev_err(&stream->intf->dev,
1967 "Failed to register %s device (%d).\n",
1968 v4l2_type_names[type], ret);
1972 kref_get(&dev->ref);
1976 static int uvc_register_video(struct uvc_device *dev,
1977 struct uvc_streaming *stream)
1981 /* Initialize the streaming interface with default parameters. */
1982 ret = uvc_video_init(stream);
1984 dev_err(&stream->intf->dev,
1985 "Failed to initialize the device (%d).\n", ret);
1989 if (stream->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
1990 stream->chain->caps |= V4L2_CAP_VIDEO_CAPTURE
1991 | V4L2_CAP_META_CAPTURE;
1993 stream->chain->caps |= V4L2_CAP_VIDEO_OUTPUT;
1995 uvc_debugfs_init_stream(stream);
1997 /* Register the device with V4L. */
1998 return uvc_register_video_device(dev, stream, &stream->vdev,
1999 &stream->queue, stream->type,
2000 &uvc_fops, &uvc_ioctl_ops);
2004 * Register all video devices in all chains.
2006 static int uvc_register_terms(struct uvc_device *dev,
2007 struct uvc_video_chain *chain)
2009 struct uvc_streaming *stream;
2010 struct uvc_entity *term;
2013 list_for_each_entry(term, &chain->entities, chain) {
2014 if (UVC_ENTITY_TYPE(term) != UVC_TT_STREAMING)
2017 stream = uvc_stream_by_id(dev, term->id);
2018 if (stream == NULL) {
2019 dev_info(&dev->udev->dev,
2020 "No streaming interface found for terminal %u.",
2025 stream->chain = chain;
2026 ret = uvc_register_video(dev, stream);
2031 * Register a metadata node, but ignore a possible failure,
2032 * complete registration of video nodes anyway.
2034 uvc_meta_register(stream);
2036 term->vdev = &stream->vdev;
2042 static int uvc_register_chains(struct uvc_device *dev)
2044 struct uvc_video_chain *chain;
2047 list_for_each_entry(chain, &dev->chains, list) {
2048 ret = uvc_register_terms(dev, chain);
2052 #ifdef CONFIG_MEDIA_CONTROLLER
2053 ret = uvc_mc_register_entities(chain);
2055 dev_info(&dev->udev->dev,
2056 "Failed to register entities (%d).\n", ret);
2063 /* ------------------------------------------------------------------------
2064 * USB probe, disconnect, suspend and resume
2067 static const struct uvc_device_info uvc_quirk_none = { 0 };
2069 static int uvc_probe(struct usb_interface *intf,
2070 const struct usb_device_id *id)
2072 struct usb_device *udev = interface_to_usbdev(intf);
2073 struct uvc_device *dev;
2074 const struct uvc_device_info *info =
2075 (const struct uvc_device_info *)id->driver_info;
2079 /* Allocate memory for the device and initialize it. */
2080 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
2084 INIT_LIST_HEAD(&dev->entities);
2085 INIT_LIST_HEAD(&dev->chains);
2086 INIT_LIST_HEAD(&dev->streams);
2087 kref_init(&dev->ref);
2088 atomic_set(&dev->nmappings, 0);
2089 mutex_init(&dev->lock);
2091 dev->udev = usb_get_dev(udev);
2092 dev->intf = usb_get_intf(intf);
2093 dev->intfnum = intf->cur_altsetting->desc.bInterfaceNumber;
2094 dev->info = info ? info : &uvc_quirk_none;
2095 dev->quirks = uvc_quirks_param == -1
2096 ? dev->info->quirks : uvc_quirks_param;
2098 if (id->idVendor && id->idProduct)
2099 uvc_dbg(dev, PROBE, "Probing known UVC device %s (%04x:%04x)\n",
2100 udev->devpath, id->idVendor, id->idProduct);
2102 uvc_dbg(dev, PROBE, "Probing generic UVC device %s\n",
2105 if (udev->product != NULL)
2106 strscpy(dev->name, udev->product, sizeof(dev->name));
2108 snprintf(dev->name, sizeof(dev->name),
2109 "UVC Camera (%04x:%04x)",
2110 le16_to_cpu(udev->descriptor.idVendor),
2111 le16_to_cpu(udev->descriptor.idProduct));
2114 * Add iFunction or iInterface to names when available as additional
2115 * distinguishers between interfaces. iFunction is prioritized over
2116 * iInterface which matches Windows behavior at the point of writing.
2118 if (intf->intf_assoc && intf->intf_assoc->iFunction != 0)
2119 function = intf->intf_assoc->iFunction;
2121 function = intf->cur_altsetting->desc.iInterface;
2122 if (function != 0) {
2125 strlcat(dev->name, ": ", sizeof(dev->name));
2126 len = strlen(dev->name);
2127 usb_string(udev, function, dev->name + len,
2128 sizeof(dev->name) - len);
2131 /* Initialize the media device. */
2132 #ifdef CONFIG_MEDIA_CONTROLLER
2133 dev->mdev.dev = &intf->dev;
2134 strscpy(dev->mdev.model, dev->name, sizeof(dev->mdev.model));
2136 strscpy(dev->mdev.serial, udev->serial,
2137 sizeof(dev->mdev.serial));
2138 usb_make_path(udev, dev->mdev.bus_info, sizeof(dev->mdev.bus_info));
2139 dev->mdev.hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
2140 media_device_init(&dev->mdev);
2142 dev->vdev.mdev = &dev->mdev;
2145 /* Parse the Video Class control descriptor. */
2146 if (uvc_parse_control(dev) < 0) {
2147 uvc_dbg(dev, PROBE, "Unable to parse UVC descriptors\n");
2151 /* Parse the associated GPIOs. */
2152 if (uvc_gpio_parse(dev) < 0) {
2153 uvc_dbg(dev, PROBE, "Unable to parse UVC GPIOs\n");
2157 dev_info(&dev->udev->dev, "Found UVC %u.%02x device %s (%04x:%04x)\n",
2158 dev->uvc_version >> 8, dev->uvc_version & 0xff,
2159 udev->product ? udev->product : "<unnamed>",
2160 le16_to_cpu(udev->descriptor.idVendor),
2161 le16_to_cpu(udev->descriptor.idProduct));
2163 if (dev->quirks != dev->info->quirks) {
2164 dev_info(&dev->udev->dev,
2165 "Forcing device quirks to 0x%x by module parameter for testing purpose.\n",
2167 dev_info(&dev->udev->dev,
2168 "Please report required quirks to the linux-media mailing list.\n");
2171 if (dev->info->uvc_version) {
2172 dev->uvc_version = dev->info->uvc_version;
2173 dev_info(&dev->udev->dev, "Forcing UVC version to %u.%02x\n",
2174 dev->uvc_version >> 8, dev->uvc_version & 0xff);
2177 /* Register the V4L2 device. */
2178 if (v4l2_device_register(&intf->dev, &dev->vdev) < 0)
2181 /* Scan the device for video chains. */
2182 if (uvc_scan_device(dev) < 0)
2185 /* Initialize controls. */
2186 if (uvc_ctrl_init_device(dev) < 0)
2189 /* Register video device nodes. */
2190 if (uvc_register_chains(dev) < 0)
2193 #ifdef CONFIG_MEDIA_CONTROLLER
2194 /* Register the media device node */
2195 if (media_device_register(&dev->mdev) < 0)
2198 /* Save our data pointer in the interface data. */
2199 usb_set_intfdata(intf, dev);
2201 /* Initialize the interrupt URB. */
2202 ret = uvc_status_init(dev);
2204 dev_info(&dev->udev->dev,
2205 "Unable to initialize the status endpoint (%d), status interrupt will not be supported.\n",
2209 ret = uvc_gpio_init_irq(dev);
2211 dev_err(&dev->udev->dev,
2212 "Unable to request privacy GPIO IRQ (%d)\n", ret);
2216 uvc_dbg(dev, PROBE, "UVC device initialized\n");
2217 usb_enable_autosuspend(udev);
2221 uvc_unregister_video(dev);
2222 kref_put(&dev->ref, uvc_delete);
2226 static void uvc_disconnect(struct usb_interface *intf)
2228 struct uvc_device *dev = usb_get_intfdata(intf);
2231 * Set the USB interface data to NULL. This can be done outside the
2232 * lock, as there's no other reader.
2234 usb_set_intfdata(intf, NULL);
2236 if (intf->cur_altsetting->desc.bInterfaceSubClass ==
2237 UVC_SC_VIDEOSTREAMING)
2240 uvc_unregister_video(dev);
2241 kref_put(&dev->ref, uvc_delete);
2244 static int uvc_suspend(struct usb_interface *intf, pm_message_t message)
2246 struct uvc_device *dev = usb_get_intfdata(intf);
2247 struct uvc_streaming *stream;
2249 uvc_dbg(dev, SUSPEND, "Suspending interface %u\n",
2250 intf->cur_altsetting->desc.bInterfaceNumber);
2252 /* Controls are cached on the fly so they don't need to be saved. */
2253 if (intf->cur_altsetting->desc.bInterfaceSubClass ==
2254 UVC_SC_VIDEOCONTROL) {
2255 mutex_lock(&dev->lock);
2257 uvc_status_stop(dev);
2258 mutex_unlock(&dev->lock);
2262 list_for_each_entry(stream, &dev->streams, list) {
2263 if (stream->intf == intf)
2264 return uvc_video_suspend(stream);
2267 uvc_dbg(dev, SUSPEND,
2268 "Suspend: video streaming USB interface mismatch\n");
2272 static int __uvc_resume(struct usb_interface *intf, int reset)
2274 struct uvc_device *dev = usb_get_intfdata(intf);
2275 struct uvc_streaming *stream;
2278 uvc_dbg(dev, SUSPEND, "Resuming interface %u\n",
2279 intf->cur_altsetting->desc.bInterfaceNumber);
2281 if (intf->cur_altsetting->desc.bInterfaceSubClass ==
2282 UVC_SC_VIDEOCONTROL) {
2284 ret = uvc_ctrl_restore_values(dev);
2289 mutex_lock(&dev->lock);
2291 ret = uvc_status_start(dev, GFP_NOIO);
2292 mutex_unlock(&dev->lock);
2297 list_for_each_entry(stream, &dev->streams, list) {
2298 if (stream->intf == intf) {
2299 ret = uvc_video_resume(stream, reset);
2301 uvc_queue_streamoff(&stream->queue,
2302 stream->queue.queue.type);
2307 uvc_dbg(dev, SUSPEND,
2308 "Resume: video streaming USB interface mismatch\n");
2312 static int uvc_resume(struct usb_interface *intf)
2314 return __uvc_resume(intf, 0);
2317 static int uvc_reset_resume(struct usb_interface *intf)
2319 return __uvc_resume(intf, 1);
2322 /* ------------------------------------------------------------------------
2326 static int uvc_clock_param_get(char *buffer, const struct kernel_param *kp)
2328 if (uvc_clock_param == CLOCK_MONOTONIC)
2329 return sprintf(buffer, "CLOCK_MONOTONIC");
2331 return sprintf(buffer, "CLOCK_REALTIME");
2334 static int uvc_clock_param_set(const char *val, const struct kernel_param *kp)
2336 if (strncasecmp(val, "clock_", strlen("clock_")) == 0)
2337 val += strlen("clock_");
2339 if (strcasecmp(val, "monotonic") == 0)
2340 uvc_clock_param = CLOCK_MONOTONIC;
2341 else if (strcasecmp(val, "realtime") == 0)
2342 uvc_clock_param = CLOCK_REALTIME;
2349 module_param_call(clock, uvc_clock_param_set, uvc_clock_param_get,
2350 &uvc_clock_param, 0644);
2351 MODULE_PARM_DESC(clock, "Video buffers timestamp clock");
2352 module_param_named(hwtimestamps, uvc_hw_timestamps_param, uint, 0644);
2353 MODULE_PARM_DESC(hwtimestamps, "Use hardware timestamps");
2354 module_param_named(nodrop, uvc_no_drop_param, uint, 0644);
2355 MODULE_PARM_DESC(nodrop, "Don't drop incomplete frames");
2356 module_param_named(quirks, uvc_quirks_param, uint, 0644);
2357 MODULE_PARM_DESC(quirks, "Forced device quirks");
2358 module_param_named(trace, uvc_dbg_param, uint, 0644);
2359 MODULE_PARM_DESC(trace, "Trace level bitmask");
2360 module_param_named(timeout, uvc_timeout_param, uint, 0644);
2361 MODULE_PARM_DESC(timeout, "Streaming control requests timeout");
2363 /* ------------------------------------------------------------------------
2364 * Driver initialization and cleanup
2367 static const struct uvc_device_info uvc_ctrl_power_line_limited = {
2368 .mappings = (const struct uvc_control_mapping *[]) {
2369 &uvc_ctrl_power_line_mapping_limited,
2370 NULL, /* Sentinel */
2374 static const struct uvc_device_info uvc_ctrl_power_line_uvc11 = {
2375 .mappings = (const struct uvc_control_mapping *[]) {
2376 &uvc_ctrl_power_line_mapping_uvc11,
2377 NULL, /* Sentinel */
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 /* Quanta USB2.0 HD UVC Webcam */
2412 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2413 | USB_DEVICE_ID_MATCH_INT_INFO,
2415 .idProduct = 0x3090,
2416 .bInterfaceClass = USB_CLASS_VIDEO,
2417 .bInterfaceSubClass = 1,
2418 .bInterfaceProtocol = 0,
2419 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
2420 /* Quanta USB2.0 HD UVC Webcam */
2421 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2422 | USB_DEVICE_ID_MATCH_INT_INFO,
2424 .idProduct = 0x4030,
2425 .bInterfaceClass = USB_CLASS_VIDEO,
2426 .bInterfaceSubClass = 1,
2427 .bInterfaceProtocol = 0,
2428 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
2429 /* Quanta USB2.0 HD UVC Webcam */
2430 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2431 | USB_DEVICE_ID_MATCH_INT_INFO,
2433 .idProduct = 0x4034,
2434 .bInterfaceClass = USB_CLASS_VIDEO,
2435 .bInterfaceSubClass = 1,
2436 .bInterfaceProtocol = UVC_PC_PROTOCOL_15,
2437 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
2438 /* LogiLink Wireless Webcam */
2439 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2440 | USB_DEVICE_ID_MATCH_INT_INFO,
2442 .idProduct = 0xa91a,
2443 .bInterfaceClass = USB_CLASS_VIDEO,
2444 .bInterfaceSubClass = 1,
2445 .bInterfaceProtocol = 0,
2446 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2447 /* Genius eFace 2025 */
2448 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2449 | USB_DEVICE_ID_MATCH_INT_INFO,
2451 .idProduct = 0x706e,
2452 .bInterfaceClass = USB_CLASS_VIDEO,
2453 .bInterfaceSubClass = 1,
2454 .bInterfaceProtocol = 0,
2455 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2456 /* Microsoft Lifecam NX-6000 */
2457 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2458 | USB_DEVICE_ID_MATCH_INT_INFO,
2460 .idProduct = 0x00f8,
2461 .bInterfaceClass = USB_CLASS_VIDEO,
2462 .bInterfaceSubClass = 1,
2463 .bInterfaceProtocol = 0,
2464 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2465 /* Microsoft Lifecam NX-3000 */
2466 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2467 | USB_DEVICE_ID_MATCH_INT_INFO,
2469 .idProduct = 0x0721,
2470 .bInterfaceClass = USB_CLASS_VIDEO,
2471 .bInterfaceSubClass = 1,
2472 .bInterfaceProtocol = 0,
2473 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2474 /* Microsoft Lifecam VX-7000 */
2475 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2476 | USB_DEVICE_ID_MATCH_INT_INFO,
2478 .idProduct = 0x0723,
2479 .bInterfaceClass = USB_CLASS_VIDEO,
2480 .bInterfaceSubClass = 1,
2481 .bInterfaceProtocol = 0,
2482 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2483 /* Logitech, Webcam C910 */
2484 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2485 | USB_DEVICE_ID_MATCH_INT_INFO,
2487 .idProduct = 0x0821,
2488 .bInterfaceClass = USB_CLASS_VIDEO,
2489 .bInterfaceSubClass = 1,
2490 .bInterfaceProtocol = 0,
2491 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_WAKE_AUTOSUSPEND)},
2492 /* Logitech, Webcam B910 */
2493 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2494 | USB_DEVICE_ID_MATCH_INT_INFO,
2496 .idProduct = 0x0823,
2497 .bInterfaceClass = USB_CLASS_VIDEO,
2498 .bInterfaceSubClass = 1,
2499 .bInterfaceProtocol = 0,
2500 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_WAKE_AUTOSUSPEND)},
2501 /* Logitech Quickcam Fusion */
2502 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2503 | USB_DEVICE_ID_MATCH_INT_INFO,
2505 .idProduct = 0x08c1,
2506 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2507 .bInterfaceSubClass = 1,
2508 .bInterfaceProtocol = 0 },
2509 /* Logitech Quickcam Orbit MP */
2510 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2511 | USB_DEVICE_ID_MATCH_INT_INFO,
2513 .idProduct = 0x08c2,
2514 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2515 .bInterfaceSubClass = 1,
2516 .bInterfaceProtocol = 0 },
2517 /* Logitech Quickcam Pro for Notebook */
2518 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2519 | USB_DEVICE_ID_MATCH_INT_INFO,
2521 .idProduct = 0x08c3,
2522 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2523 .bInterfaceSubClass = 1,
2524 .bInterfaceProtocol = 0 },
2525 /* Logitech Quickcam Pro 5000 */
2526 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2527 | USB_DEVICE_ID_MATCH_INT_INFO,
2529 .idProduct = 0x08c5,
2530 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2531 .bInterfaceSubClass = 1,
2532 .bInterfaceProtocol = 0 },
2533 /* Logitech Quickcam OEM Dell Notebook */
2534 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2535 | USB_DEVICE_ID_MATCH_INT_INFO,
2537 .idProduct = 0x08c6,
2538 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2539 .bInterfaceSubClass = 1,
2540 .bInterfaceProtocol = 0 },
2541 /* Logitech Quickcam OEM Cisco VT Camera II */
2542 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2543 | USB_DEVICE_ID_MATCH_INT_INFO,
2545 .idProduct = 0x08c7,
2546 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2547 .bInterfaceSubClass = 1,
2548 .bInterfaceProtocol = 0 },
2549 /* Logitech HD Pro Webcam C920 */
2550 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2551 | USB_DEVICE_ID_MATCH_INT_INFO,
2553 .idProduct = 0x082d,
2554 .bInterfaceClass = USB_CLASS_VIDEO,
2555 .bInterfaceSubClass = 1,
2556 .bInterfaceProtocol = 0,
2557 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_RESTORE_CTRLS_ON_INIT) },
2558 /* Chicony CNF7129 (Asus EEE 100HE) */
2559 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2560 | USB_DEVICE_ID_MATCH_INT_INFO,
2562 .idProduct = 0xb071,
2563 .bInterfaceClass = USB_CLASS_VIDEO,
2564 .bInterfaceSubClass = 1,
2565 .bInterfaceProtocol = 0,
2566 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_RESTRICT_FRAME_RATE) },
2567 /* Chicony EasyCamera */
2568 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2569 | USB_DEVICE_ID_MATCH_INT_INFO,
2571 .idProduct = 0xb5eb,
2572 .bInterfaceClass = USB_CLASS_VIDEO,
2573 .bInterfaceSubClass = 1,
2574 .bInterfaceProtocol = 0,
2575 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
2576 /* Chicony EasyCamera */
2577 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2578 | USB_DEVICE_ID_MATCH_INT_INFO,
2580 .idProduct = 0xb6ba,
2581 .bInterfaceClass = USB_CLASS_VIDEO,
2582 .bInterfaceSubClass = 1,
2583 .bInterfaceProtocol = 0,
2584 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
2585 /* Chicony EasyCamera */
2586 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2587 | USB_DEVICE_ID_MATCH_INT_INFO,
2589 .idProduct = 0xb746,
2590 .bInterfaceClass = USB_CLASS_VIDEO,
2591 .bInterfaceSubClass = 1,
2592 .bInterfaceProtocol = 0,
2593 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
2594 /* Alcor Micro AU3820 (Future Boy PC USB Webcam) */
2595 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2596 | USB_DEVICE_ID_MATCH_INT_INFO,
2598 .idProduct = 0x3820,
2599 .bInterfaceClass = USB_CLASS_VIDEO,
2600 .bInterfaceSubClass = 1,
2601 .bInterfaceProtocol = 0,
2602 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2603 /* Dell XPS m1530 */
2604 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2605 | USB_DEVICE_ID_MATCH_INT_INFO,
2607 .idProduct = 0x2640,
2608 .bInterfaceClass = USB_CLASS_VIDEO,
2609 .bInterfaceSubClass = 1,
2610 .bInterfaceProtocol = 0,
2611 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2612 /* Dell SP2008WFP Monitor */
2613 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2614 | USB_DEVICE_ID_MATCH_INT_INFO,
2616 .idProduct = 0x2641,
2617 .bInterfaceClass = USB_CLASS_VIDEO,
2618 .bInterfaceSubClass = 1,
2619 .bInterfaceProtocol = 0,
2620 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2621 /* Dell Alienware X51 */
2622 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2623 | USB_DEVICE_ID_MATCH_INT_INFO,
2625 .idProduct = 0x2643,
2626 .bInterfaceClass = USB_CLASS_VIDEO,
2627 .bInterfaceSubClass = 1,
2628 .bInterfaceProtocol = 0,
2629 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2630 /* Dell Studio Hybrid 140g (OmniVision webcam) */
2631 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2632 | USB_DEVICE_ID_MATCH_INT_INFO,
2634 .idProduct = 0x264a,
2635 .bInterfaceClass = USB_CLASS_VIDEO,
2636 .bInterfaceSubClass = 1,
2637 .bInterfaceProtocol = 0,
2638 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2639 /* Dell XPS M1330 (OmniVision OV7670 webcam) */
2640 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2641 | USB_DEVICE_ID_MATCH_INT_INFO,
2643 .idProduct = 0x7670,
2644 .bInterfaceClass = USB_CLASS_VIDEO,
2645 .bInterfaceSubClass = 1,
2646 .bInterfaceProtocol = 0,
2647 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2648 /* Apple Built-In iSight */
2649 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2650 | USB_DEVICE_ID_MATCH_INT_INFO,
2652 .idProduct = 0x8501,
2653 .bInterfaceClass = USB_CLASS_VIDEO,
2654 .bInterfaceSubClass = 1,
2655 .bInterfaceProtocol = 0,
2656 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_PROBE_MINMAX
2657 | UVC_QUIRK_BUILTIN_ISIGHT) },
2658 /* Apple FaceTime HD Camera (Built-In) */
2659 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2660 | USB_DEVICE_ID_MATCH_INT_INFO,
2662 .idProduct = 0x8514,
2663 .bInterfaceClass = USB_CLASS_VIDEO,
2664 .bInterfaceSubClass = 1,
2665 .bInterfaceProtocol = 0,
2666 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2667 /* Apple Built-In iSight via iBridge */
2668 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2669 | USB_DEVICE_ID_MATCH_INT_INFO,
2671 .idProduct = 0x8600,
2672 .bInterfaceClass = USB_CLASS_VIDEO,
2673 .bInterfaceSubClass = 1,
2674 .bInterfaceProtocol = 0,
2675 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2676 /* Foxlink ("HP Webcam" on HP Mini 5103) */
2677 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2678 | USB_DEVICE_ID_MATCH_INT_INFO,
2680 .idProduct = 0x0403,
2681 .bInterfaceClass = USB_CLASS_VIDEO,
2682 .bInterfaceSubClass = 1,
2683 .bInterfaceProtocol = 0,
2684 .driver_info = (kernel_ulong_t)&uvc_quirk_fix_bandwidth },
2685 /* Genesys Logic USB 2.0 PC Camera */
2686 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2687 | USB_DEVICE_ID_MATCH_INT_INFO,
2689 .idProduct = 0x0505,
2690 .bInterfaceClass = USB_CLASS_VIDEO,
2691 .bInterfaceSubClass = 1,
2692 .bInterfaceProtocol = 0,
2693 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2694 /* Hercules Classic Silver */
2695 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2696 | USB_DEVICE_ID_MATCH_INT_INFO,
2698 .idProduct = 0x300c,
2699 .bInterfaceClass = USB_CLASS_VIDEO,
2700 .bInterfaceSubClass = 1,
2701 .bInterfaceProtocol = 0,
2702 .driver_info = (kernel_ulong_t)&uvc_quirk_fix_bandwidth },
2704 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2705 | USB_DEVICE_ID_MATCH_INT_INFO,
2707 .idProduct = 0x332d,
2708 .bInterfaceClass = USB_CLASS_VIDEO,
2709 .bInterfaceSubClass = 1,
2710 .bInterfaceProtocol = 0,
2711 .driver_info = (kernel_ulong_t)&uvc_quirk_fix_bandwidth },
2712 /* ViMicro - Minoru3D */
2713 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2714 | USB_DEVICE_ID_MATCH_INT_INFO,
2716 .idProduct = 0x3410,
2717 .bInterfaceClass = USB_CLASS_VIDEO,
2718 .bInterfaceSubClass = 1,
2719 .bInterfaceProtocol = 0,
2720 .driver_info = (kernel_ulong_t)&uvc_quirk_fix_bandwidth },
2721 /* ViMicro Venus - Minoru3D */
2722 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2723 | USB_DEVICE_ID_MATCH_INT_INFO,
2725 .idProduct = 0x3420,
2726 .bInterfaceClass = USB_CLASS_VIDEO,
2727 .bInterfaceSubClass = 1,
2728 .bInterfaceProtocol = 0,
2729 .driver_info = (kernel_ulong_t)&uvc_quirk_fix_bandwidth },
2730 /* Ophir Optronics - SPCAM 620U */
2731 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2732 | USB_DEVICE_ID_MATCH_INT_INFO,
2734 .idProduct = 0x0555,
2735 .bInterfaceClass = USB_CLASS_VIDEO,
2736 .bInterfaceSubClass = 1,
2737 .bInterfaceProtocol = 0,
2738 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2740 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2741 | USB_DEVICE_ID_MATCH_INT_INFO,
2743 .idProduct = 0x0004,
2744 .bInterfaceClass = USB_CLASS_VIDEO,
2745 .bInterfaceSubClass = 1,
2746 .bInterfaceProtocol = 0,
2747 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_PROBE_MINMAX
2748 | UVC_QUIRK_PROBE_DEF) },
2749 /* IMC Networks (Medion Akoya) */
2750 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2751 | USB_DEVICE_ID_MATCH_INT_INFO,
2753 .idProduct = 0x5103,
2754 .bInterfaceClass = USB_CLASS_VIDEO,
2755 .bInterfaceSubClass = 1,
2756 .bInterfaceProtocol = 0,
2757 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2758 /* JMicron USB2.0 XGA WebCam */
2759 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2760 | USB_DEVICE_ID_MATCH_INT_INFO,
2762 .idProduct = 0x0310,
2763 .bInterfaceClass = USB_CLASS_VIDEO,
2764 .bInterfaceSubClass = 1,
2765 .bInterfaceProtocol = 0,
2766 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2767 /* Syntek (HP Spartan) */
2768 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2769 | USB_DEVICE_ID_MATCH_INT_INFO,
2771 .idProduct = 0x5212,
2772 .bInterfaceClass = USB_CLASS_VIDEO,
2773 .bInterfaceSubClass = 1,
2774 .bInterfaceProtocol = 0,
2775 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2776 /* Syntek (Samsung Q310) */
2777 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2778 | USB_DEVICE_ID_MATCH_INT_INFO,
2780 .idProduct = 0x5931,
2781 .bInterfaceClass = USB_CLASS_VIDEO,
2782 .bInterfaceSubClass = 1,
2783 .bInterfaceProtocol = 0,
2784 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2785 /* Syntek (Packard Bell EasyNote MX52 */
2786 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2787 | USB_DEVICE_ID_MATCH_INT_INFO,
2789 .idProduct = 0x8a12,
2790 .bInterfaceClass = USB_CLASS_VIDEO,
2791 .bInterfaceSubClass = 1,
2792 .bInterfaceProtocol = 0,
2793 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2794 /* Syntek (Asus F9SG) */
2795 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2796 | USB_DEVICE_ID_MATCH_INT_INFO,
2798 .idProduct = 0x8a31,
2799 .bInterfaceClass = USB_CLASS_VIDEO,
2800 .bInterfaceSubClass = 1,
2801 .bInterfaceProtocol = 0,
2802 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2803 /* Syntek (Asus U3S) */
2804 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2805 | USB_DEVICE_ID_MATCH_INT_INFO,
2807 .idProduct = 0x8a33,
2808 .bInterfaceClass = USB_CLASS_VIDEO,
2809 .bInterfaceSubClass = 1,
2810 .bInterfaceProtocol = 0,
2811 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2812 /* Syntek (JAOtech Smart Terminal) */
2813 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2814 | USB_DEVICE_ID_MATCH_INT_INFO,
2816 .idProduct = 0x8a34,
2817 .bInterfaceClass = USB_CLASS_VIDEO,
2818 .bInterfaceSubClass = 1,
2819 .bInterfaceProtocol = 0,
2820 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2822 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2823 | USB_DEVICE_ID_MATCH_INT_INFO,
2825 .idProduct = 0x0202,
2826 .bInterfaceClass = USB_CLASS_VIDEO,
2827 .bInterfaceSubClass = 1,
2828 .bInterfaceProtocol = 0,
2829 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2830 /* Lenovo Thinkpad SL400/SL500 */
2831 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2832 | USB_DEVICE_ID_MATCH_INT_INFO,
2834 .idProduct = 0x480b,
2835 .bInterfaceClass = USB_CLASS_VIDEO,
2836 .bInterfaceSubClass = 1,
2837 .bInterfaceProtocol = 0,
2838 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2839 /* Aveo Technology USB 2.0 Camera */
2840 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2841 | USB_DEVICE_ID_MATCH_INT_INFO,
2843 .idProduct = 0x0306,
2844 .bInterfaceClass = USB_CLASS_VIDEO,
2845 .bInterfaceSubClass = 1,
2846 .bInterfaceProtocol = 0,
2847 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_PROBE_MINMAX
2848 | UVC_QUIRK_PROBE_EXTRAFIELDS) },
2849 /* Aveo Technology USB 2.0 Camera (Tasco USB Microscope) */
2850 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2851 | USB_DEVICE_ID_MATCH_INT_INFO,
2853 .idProduct = 0x0516,
2854 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2855 .bInterfaceSubClass = 1,
2856 .bInterfaceProtocol = 0 },
2857 /* Ecamm Pico iMage */
2858 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2859 | USB_DEVICE_ID_MATCH_INT_INFO,
2861 .idProduct = 0xcafe,
2862 .bInterfaceClass = USB_CLASS_VIDEO,
2863 .bInterfaceSubClass = 1,
2864 .bInterfaceProtocol = 0,
2865 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_PROBE_EXTRAFIELDS) },
2866 /* Manta MM-353 Plako */
2867 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2868 | USB_DEVICE_ID_MATCH_INT_INFO,
2870 .idProduct = 0x3188,
2871 .bInterfaceClass = USB_CLASS_VIDEO,
2872 .bInterfaceSubClass = 1,
2873 .bInterfaceProtocol = 0,
2874 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2875 /* FSC WebCam V30S */
2876 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2877 | USB_DEVICE_ID_MATCH_INT_INFO,
2879 .idProduct = 0x3288,
2880 .bInterfaceClass = USB_CLASS_VIDEO,
2881 .bInterfaceSubClass = 1,
2882 .bInterfaceProtocol = 0,
2883 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2884 /* Arkmicro unbranded */
2885 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2886 | USB_DEVICE_ID_MATCH_INT_INFO,
2888 .idProduct = 0x3290,
2889 .bInterfaceClass = USB_CLASS_VIDEO,
2890 .bInterfaceSubClass = 1,
2891 .bInterfaceProtocol = 0,
2892 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2893 /* The Imaging Source USB CCD cameras */
2894 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2895 | USB_DEVICE_ID_MATCH_INT_INFO,
2897 .idProduct = 0x8102,
2898 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2899 .bInterfaceSubClass = 1,
2900 .bInterfaceProtocol = 0 },
2901 /* Bodelin ProScopeHR */
2902 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2903 | USB_DEVICE_ID_MATCH_DEV_HI
2904 | USB_DEVICE_ID_MATCH_INT_INFO,
2906 .idProduct = 0x1000,
2907 .bcdDevice_hi = 0x0126,
2908 .bInterfaceClass = USB_CLASS_VIDEO,
2909 .bInterfaceSubClass = 1,
2910 .bInterfaceProtocol = 0,
2911 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_STATUS_INTERVAL) },
2912 /* MSI StarCam 370i */
2913 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2914 | USB_DEVICE_ID_MATCH_INT_INFO,
2916 .idProduct = 0x2951,
2917 .bInterfaceClass = USB_CLASS_VIDEO,
2918 .bInterfaceSubClass = 1,
2919 .bInterfaceProtocol = 0,
2920 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2921 /* Generalplus Technology Inc. 808 Camera */
2922 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2923 | USB_DEVICE_ID_MATCH_INT_INFO,
2925 .idProduct = 0x2002,
2926 .bInterfaceClass = USB_CLASS_VIDEO,
2927 .bInterfaceSubClass = 1,
2928 .bInterfaceProtocol = 0,
2929 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2930 /* Shenzhen Aoni Electronic Co.,Ltd 2K FHD camera */
2931 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2932 | USB_DEVICE_ID_MATCH_INT_INFO,
2934 .idProduct = 0x0b40,
2935 .bInterfaceClass = USB_CLASS_VIDEO,
2936 .bInterfaceSubClass = 1,
2937 .bInterfaceProtocol = 0,
2938 .driver_info = (kernel_ulong_t)&(const struct uvc_device_info){
2939 .uvc_version = 0x010a,
2941 /* SiGma Micro USB Web Camera */
2942 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2943 | USB_DEVICE_ID_MATCH_INT_INFO,
2945 .idProduct = 0x3000,
2946 .bInterfaceClass = USB_CLASS_VIDEO,
2947 .bInterfaceSubClass = 1,
2948 .bInterfaceProtocol = 0,
2949 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_PROBE_MINMAX
2950 | UVC_QUIRK_IGNORE_SELECTOR_UNIT) },
2951 /* Oculus VR Positional Tracker DK2 */
2952 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2953 | USB_DEVICE_ID_MATCH_INT_INFO,
2955 .idProduct = 0x0201,
2956 .bInterfaceClass = USB_CLASS_VIDEO,
2957 .bInterfaceSubClass = 1,
2958 .bInterfaceProtocol = 0,
2959 .driver_info = (kernel_ulong_t)&uvc_quirk_force_y8 },
2960 /* Oculus VR Rift Sensor */
2961 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2962 | USB_DEVICE_ID_MATCH_INT_INFO,
2964 .idProduct = 0x0211,
2965 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2966 .bInterfaceSubClass = 1,
2967 .bInterfaceProtocol = 0,
2968 .driver_info = (kernel_ulong_t)&uvc_quirk_force_y8 },
2969 /* GEO Semiconductor GC6500 */
2970 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2971 | USB_DEVICE_ID_MATCH_INT_INFO,
2973 .idProduct = 0x4d53,
2974 .bInterfaceClass = USB_CLASS_VIDEO,
2975 .bInterfaceSubClass = 1,
2976 .bInterfaceProtocol = 0,
2977 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_FORCE_BPP) },
2978 /* Lenovo Integrated Camera */
2979 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2980 | USB_DEVICE_ID_MATCH_INT_INFO,
2982 .idProduct = 0x0093,
2983 .bInterfaceClass = USB_CLASS_VIDEO,
2984 .bInterfaceSubClass = 1,
2985 .bInterfaceProtocol = UVC_PC_PROTOCOL_15,
2986 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_uvc11 },
2987 /* Sonix Technology USB 2.0 Camera */
2988 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2989 | USB_DEVICE_ID_MATCH_INT_INFO,
2991 .idProduct = 0x0072,
2992 .bInterfaceClass = USB_CLASS_VIDEO,
2993 .bInterfaceSubClass = 1,
2994 .bInterfaceProtocol = 0,
2995 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
2996 /* Acer EasyCamera */
2997 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2998 | USB_DEVICE_ID_MATCH_INT_INFO,
3000 .idProduct = 0x1172,
3001 .bInterfaceClass = USB_CLASS_VIDEO,
3002 .bInterfaceSubClass = 1,
3003 .bInterfaceProtocol = 0,
3004 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
3005 /* Acer EasyCamera */
3006 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
3007 | USB_DEVICE_ID_MATCH_INT_INFO,
3009 .idProduct = 0x1180,
3010 .bInterfaceClass = USB_CLASS_VIDEO,
3011 .bInterfaceSubClass = 1,
3012 .bInterfaceProtocol = 0,
3013 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
3014 /* Acer EasyCamera */
3015 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
3016 | USB_DEVICE_ID_MATCH_INT_INFO,
3018 .idProduct = 0x1180,
3019 .bInterfaceClass = USB_CLASS_VIDEO,
3020 .bInterfaceSubClass = 1,
3021 .bInterfaceProtocol = 0,
3022 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
3023 /* Intel RealSense D4M */
3024 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
3025 | USB_DEVICE_ID_MATCH_INT_INFO,
3027 .idProduct = 0x0b03,
3028 .bInterfaceClass = USB_CLASS_VIDEO,
3029 .bInterfaceSubClass = 1,
3030 .bInterfaceProtocol = 0,
3031 .driver_info = UVC_INFO_META(V4L2_META_FMT_D4XX) },
3032 /* Generic USB Video Class */
3033 { USB_INTERFACE_INFO(USB_CLASS_VIDEO, 1, UVC_PC_PROTOCOL_UNDEFINED) },
3034 { USB_INTERFACE_INFO(USB_CLASS_VIDEO, 1, UVC_PC_PROTOCOL_15) },
3038 MODULE_DEVICE_TABLE(usb, uvc_ids);
3040 struct uvc_driver uvc_driver = {
3044 .disconnect = uvc_disconnect,
3045 .suspend = uvc_suspend,
3046 .resume = uvc_resume,
3047 .reset_resume = uvc_reset_resume,
3048 .id_table = uvc_ids,
3049 .supports_autosuspend = 1,
3053 static int __init uvc_init(void)
3059 ret = usb_register(&uvc_driver.driver);
3061 uvc_debugfs_cleanup();
3068 static void __exit uvc_cleanup(void)
3070 usb_deregister(&uvc_driver.driver);
3071 uvc_debugfs_cleanup();
3074 module_init(uvc_init);
3075 module_exit(uvc_cleanup);
3077 MODULE_AUTHOR(DRIVER_AUTHOR);
3078 MODULE_DESCRIPTION(DRIVER_DESC);
3079 MODULE_LICENSE("GPL");
3080 MODULE_VERSION(DRIVER_VERSION);