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]);
254 if (fmtdesc != NULL) {
255 format->fcc = fmtdesc->fcc;
257 dev_info(&streaming->intf->dev,
258 "Unknown video format %pUl\n", &buffer[5]);
262 format->bpp = buffer[21];
265 * Some devices report a format that doesn't match what they
268 if (dev->quirks & UVC_QUIRK_FORCE_Y8) {
269 if (format->fcc == V4L2_PIX_FMT_YUYV) {
270 format->fcc = V4L2_PIX_FMT_GREY;
272 width_multiplier = 2;
276 /* Some devices report bpp that doesn't match the format. */
277 if (dev->quirks & UVC_QUIRK_FORCE_BPP) {
278 const struct v4l2_format_info *info =
279 v4l2_format_info(format->fcc);
282 unsigned int div = info->hdiv * info->vdiv;
284 n = info->bpp[0] * div;
285 for (i = 1; i < info->comp_planes; i++)
288 format->bpp = DIV_ROUND_UP(8 * n, div);
292 if (buffer[2] == UVC_VS_FORMAT_UNCOMPRESSED) {
293 ftype = UVC_VS_FRAME_UNCOMPRESSED;
295 ftype = UVC_VS_FRAME_FRAME_BASED;
297 format->flags = UVC_FMT_FLAG_COMPRESSED;
301 case UVC_VS_FORMAT_MJPEG:
304 "device %d videostreaming interface %d FORMAT error\n",
306 alts->desc.bInterfaceNumber);
310 format->fcc = V4L2_PIX_FMT_MJPEG;
311 format->flags = UVC_FMT_FLAG_COMPRESSED;
313 ftype = UVC_VS_FRAME_MJPEG;
316 case UVC_VS_FORMAT_DV:
319 "device %d videostreaming interface %d FORMAT error\n",
321 alts->desc.bInterfaceNumber);
325 if ((buffer[8] & 0x7f) > 2) {
327 "device %d videostreaming interface %d: unknown DV format %u\n",
329 alts->desc.bInterfaceNumber, buffer[8]);
333 format->fcc = V4L2_PIX_FMT_DV;
334 format->flags = UVC_FMT_FLAG_COMPRESSED | UVC_FMT_FLAG_STREAM;
338 /* Create a dummy frame descriptor. */
339 frame = &format->frame[0];
340 memset(&format->frame[0], 0, sizeof(format->frame[0]));
341 frame->bFrameIntervalType = 1;
342 frame->dwDefaultFrameInterval = 1;
343 frame->dwFrameInterval = *intervals;
348 case UVC_VS_FORMAT_MPEG2TS:
349 case UVC_VS_FORMAT_STREAM_BASED:
350 /* Not supported yet. */
353 "device %d videostreaming interface %d unsupported format %u\n",
354 dev->udev->devnum, alts->desc.bInterfaceNumber,
359 uvc_dbg(dev, DESCR, "Found format %p4cc", &format->fcc);
365 * Parse the frame descriptors. Only uncompressed, MJPEG and frame
366 * based formats have frame descriptors.
368 while (buflen > 2 && buffer[1] == USB_DT_CS_INTERFACE &&
369 buffer[2] == ftype) {
370 frame = &format->frame[format->nframes];
371 if (ftype != UVC_VS_FRAME_FRAME_BASED)
372 n = buflen > 25 ? buffer[25] : 0;
374 n = buflen > 21 ? buffer[21] : 0;
378 if (buflen < 26 + 4*n) {
380 "device %d videostreaming interface %d FRAME error\n",
382 alts->desc.bInterfaceNumber);
386 frame->bFrameIndex = buffer[3];
387 frame->bmCapabilities = buffer[4];
388 frame->wWidth = get_unaligned_le16(&buffer[5])
390 frame->wHeight = get_unaligned_le16(&buffer[7]);
391 frame->dwMinBitRate = get_unaligned_le32(&buffer[9]);
392 frame->dwMaxBitRate = get_unaligned_le32(&buffer[13]);
393 if (ftype != UVC_VS_FRAME_FRAME_BASED) {
394 frame->dwMaxVideoFrameBufferSize =
395 get_unaligned_le32(&buffer[17]);
396 frame->dwDefaultFrameInterval =
397 get_unaligned_le32(&buffer[21]);
398 frame->bFrameIntervalType = buffer[25];
400 frame->dwMaxVideoFrameBufferSize = 0;
401 frame->dwDefaultFrameInterval =
402 get_unaligned_le32(&buffer[17]);
403 frame->bFrameIntervalType = buffer[21];
405 frame->dwFrameInterval = *intervals;
408 * Several UVC chipsets screw up dwMaxVideoFrameBufferSize
409 * completely. Observed behaviours range from setting the
410 * value to 1.1x the actual frame size to hardwiring the
411 * 16 low bits to 0. This results in a higher than necessary
412 * memory usage as well as a wrong image size information. For
413 * uncompressed formats this can be fixed by computing the
414 * value from the frame size.
416 if (!(format->flags & UVC_FMT_FLAG_COMPRESSED))
417 frame->dwMaxVideoFrameBufferSize = format->bpp
418 * frame->wWidth * frame->wHeight / 8;
421 * Some bogus devices report dwMinFrameInterval equal to
422 * dwMaxFrameInterval and have dwFrameIntervalStep set to
423 * zero. Setting all null intervals to 1 fixes the problem and
424 * some other divisions by zero that could happen.
426 for (i = 0; i < n; ++i) {
427 interval = get_unaligned_le32(&buffer[26+4*i]);
428 *(*intervals)++ = interval ? interval : 1;
432 * Make sure that the default frame interval stays between
435 n -= frame->bFrameIntervalType ? 1 : 2;
436 frame->dwDefaultFrameInterval =
437 min(frame->dwFrameInterval[n],
438 max(frame->dwFrameInterval[0],
439 frame->dwDefaultFrameInterval));
441 if (dev->quirks & UVC_QUIRK_RESTRICT_FRAME_RATE) {
442 frame->bFrameIntervalType = 1;
443 frame->dwFrameInterval[0] =
444 frame->dwDefaultFrameInterval;
447 uvc_dbg(dev, DESCR, "- %ux%u (%u.%u fps)\n",
448 frame->wWidth, frame->wHeight,
449 10000000 / frame->dwDefaultFrameInterval,
450 (100000000 / frame->dwDefaultFrameInterval) % 10);
457 if (buflen > 2 && buffer[1] == USB_DT_CS_INTERFACE &&
458 buffer[2] == UVC_VS_STILL_IMAGE_FRAME) {
463 if (buflen > 2 && buffer[1] == USB_DT_CS_INTERFACE &&
464 buffer[2] == UVC_VS_COLORFORMAT) {
467 "device %d videostreaming interface %d COLORFORMAT error\n",
469 alts->desc.bInterfaceNumber);
473 format->colorspace = uvc_colorspace(buffer[3]);
474 format->xfer_func = uvc_xfer_func(buffer[4]);
475 format->ycbcr_enc = uvc_ycbcr_enc(buffer[5]);
480 format->colorspace = V4L2_COLORSPACE_SRGB;
483 return buffer - start;
486 static int uvc_parse_streaming(struct uvc_device *dev,
487 struct usb_interface *intf)
489 struct uvc_streaming *streaming = NULL;
490 struct uvc_format *format;
491 struct uvc_frame *frame;
492 struct usb_host_interface *alts = &intf->altsetting[0];
493 unsigned char *_buffer, *buffer = alts->extra;
494 int _buflen, buflen = alts->extralen;
495 unsigned int nformats = 0, nframes = 0, nintervals = 0;
496 unsigned int size, i, n, p;
501 if (intf->cur_altsetting->desc.bInterfaceSubClass
502 != UVC_SC_VIDEOSTREAMING) {
504 "device %d interface %d isn't a video streaming interface\n",
506 intf->altsetting[0].desc.bInterfaceNumber);
510 if (usb_driver_claim_interface(&uvc_driver.driver, intf, dev)) {
512 "device %d interface %d is already claimed\n",
514 intf->altsetting[0].desc.bInterfaceNumber);
518 streaming = uvc_stream_new(dev, intf);
519 if (streaming == NULL) {
520 usb_driver_release_interface(&uvc_driver.driver, intf);
525 * The Pico iMage webcam has its class-specific interface descriptors
526 * after the endpoint descriptors.
529 for (i = 0; i < alts->desc.bNumEndpoints; ++i) {
530 struct usb_host_endpoint *ep = &alts->endpoint[i];
532 if (ep->extralen == 0)
535 if (ep->extralen > 2 &&
536 ep->extra[1] == USB_DT_CS_INTERFACE) {
538 "trying extra data from endpoint %u\n",
540 buffer = alts->endpoint[i].extra;
541 buflen = alts->endpoint[i].extralen;
547 /* Skip the standard interface descriptors. */
548 while (buflen > 2 && buffer[1] != USB_DT_CS_INTERFACE) {
555 "no class-specific streaming interface descriptors found\n");
559 /* Parse the header descriptor. */
561 case UVC_VS_OUTPUT_HEADER:
562 streaming->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
566 case UVC_VS_INPUT_HEADER:
567 streaming->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
573 "device %d videostreaming interface %d HEADER descriptor not found\n",
574 dev->udev->devnum, alts->desc.bInterfaceNumber);
578 p = buflen >= 4 ? buffer[3] : 0;
579 n = buflen >= size ? buffer[size-1] : 0;
581 if (buflen < size + p*n) {
583 "device %d videostreaming interface %d HEADER descriptor is invalid\n",
584 dev->udev->devnum, alts->desc.bInterfaceNumber);
588 streaming->header.bNumFormats = p;
589 streaming->header.bEndpointAddress = buffer[6];
590 if (buffer[2] == UVC_VS_INPUT_HEADER) {
591 streaming->header.bmInfo = buffer[7];
592 streaming->header.bTerminalLink = buffer[8];
593 streaming->header.bStillCaptureMethod = buffer[9];
594 streaming->header.bTriggerSupport = buffer[10];
595 streaming->header.bTriggerUsage = buffer[11];
597 streaming->header.bTerminalLink = buffer[7];
599 streaming->header.bControlSize = n;
601 streaming->header.bmaControls = kmemdup(&buffer[size], p * n,
603 if (streaming->header.bmaControls == NULL) {
614 /* Count the format and frame descriptors. */
615 while (_buflen > 2 && _buffer[1] == USB_DT_CS_INTERFACE) {
616 switch (_buffer[2]) {
617 case UVC_VS_FORMAT_UNCOMPRESSED:
618 case UVC_VS_FORMAT_MJPEG:
619 case UVC_VS_FORMAT_FRAME_BASED:
623 case UVC_VS_FORMAT_DV:
625 * DV format has no frame descriptor. We will create a
626 * dummy frame descriptor with a dummy frame interval.
633 case UVC_VS_FORMAT_MPEG2TS:
634 case UVC_VS_FORMAT_STREAM_BASED:
636 "device %d videostreaming interface %d FORMAT %u is not supported\n",
638 alts->desc.bInterfaceNumber, _buffer[2]);
641 case UVC_VS_FRAME_UNCOMPRESSED:
642 case UVC_VS_FRAME_MJPEG:
645 nintervals += _buffer[25] ? _buffer[25] : 3;
648 case UVC_VS_FRAME_FRAME_BASED:
651 nintervals += _buffer[21] ? _buffer[21] : 3;
655 _buflen -= _buffer[0];
656 _buffer += _buffer[0];
661 "device %d videostreaming interface %d has no supported formats defined\n",
662 dev->udev->devnum, alts->desc.bInterfaceNumber);
666 size = nformats * sizeof(*format) + nframes * sizeof(*frame)
667 + nintervals * sizeof(*interval);
668 format = kzalloc(size, GFP_KERNEL);
669 if (format == NULL) {
674 frame = (struct uvc_frame *)&format[nformats];
675 interval = (u32 *)&frame[nframes];
677 streaming->format = format;
678 streaming->nformats = nformats;
680 /* Parse the format descriptors. */
681 while (buflen > 2 && buffer[1] == USB_DT_CS_INTERFACE) {
683 case UVC_VS_FORMAT_UNCOMPRESSED:
684 case UVC_VS_FORMAT_MJPEG:
685 case UVC_VS_FORMAT_DV:
686 case UVC_VS_FORMAT_FRAME_BASED:
687 format->frame = frame;
688 ret = uvc_parse_format(dev, streaming, format,
689 &interval, buffer, buflen);
693 frame += format->nframes;
710 "device %d videostreaming interface %d has %u bytes of trailing descriptor garbage\n",
711 dev->udev->devnum, alts->desc.bInterfaceNumber, buflen);
713 /* Parse the alternate settings to find the maximum bandwidth. */
714 for (i = 0; i < intf->num_altsetting; ++i) {
715 struct usb_host_endpoint *ep;
717 alts = &intf->altsetting[i];
718 ep = uvc_find_endpoint(alts,
719 streaming->header.bEndpointAddress);
722 psize = uvc_endpoint_max_bpi(dev->udev, ep);
723 if (psize > streaming->maxpsize)
724 streaming->maxpsize = psize;
727 list_add_tail(&streaming->list, &dev->streams);
731 usb_driver_release_interface(&uvc_driver.driver, intf);
732 uvc_stream_delete(streaming);
736 static const u8 uvc_camera_guid[16] = UVC_GUID_UVC_CAMERA;
737 static const u8 uvc_gpio_guid[16] = UVC_GUID_EXT_GPIO_CONTROLLER;
738 static const u8 uvc_media_transport_input_guid[16] =
739 UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT;
740 static const u8 uvc_processing_guid[16] = UVC_GUID_UVC_PROCESSING;
742 static struct uvc_entity *uvc_alloc_entity(u16 type, u16 id,
743 unsigned int num_pads, unsigned int extra_size)
745 struct uvc_entity *entity;
746 unsigned int num_inputs;
750 extra_size = roundup(extra_size, sizeof(*entity->pads));
752 num_inputs = type & UVC_TERM_OUTPUT ? num_pads : num_pads - 1;
755 size = sizeof(*entity) + extra_size + sizeof(*entity->pads) * num_pads
757 entity = kzalloc(size, GFP_KERNEL);
765 * Set the GUID for standard entity types. For extension units, the GUID
766 * is initialized by the caller.
769 case UVC_EXT_GPIO_UNIT:
770 memcpy(entity->guid, uvc_gpio_guid, 16);
773 memcpy(entity->guid, uvc_camera_guid, 16);
775 case UVC_ITT_MEDIA_TRANSPORT_INPUT:
776 memcpy(entity->guid, uvc_media_transport_input_guid, 16);
778 case UVC_VC_PROCESSING_UNIT:
779 memcpy(entity->guid, uvc_processing_guid, 16);
783 entity->num_links = 0;
784 entity->num_pads = num_pads;
785 entity->pads = ((void *)(entity + 1)) + extra_size;
787 for (i = 0; i < num_inputs; ++i)
788 entity->pads[i].flags = MEDIA_PAD_FL_SINK;
789 if (!UVC_ENTITY_IS_OTERM(entity) && num_pads)
790 entity->pads[num_pads-1].flags = MEDIA_PAD_FL_SOURCE;
792 entity->bNrInPins = num_inputs;
793 entity->baSourceID = (u8 *)(&entity->pads[num_pads]);
798 static void uvc_entity_set_name(struct uvc_device *dev, struct uvc_entity *entity,
799 const char *type_name, u8 string_id)
804 * First attempt to read the entity name from the device. If the entity
805 * has no associated string, or if reading the string fails (most
806 * likely due to a buggy firmware), fall back to default names based on
810 ret = usb_string(dev->udev, string_id, entity->name,
811 sizeof(entity->name));
816 sprintf(entity->name, "%s %u", type_name, entity->id);
819 /* Parse vendor-specific extensions. */
820 static int uvc_parse_vendor_control(struct uvc_device *dev,
821 const unsigned char *buffer, int buflen)
823 struct usb_device *udev = dev->udev;
824 struct usb_host_interface *alts = dev->intf->cur_altsetting;
825 struct uvc_entity *unit;
829 switch (le16_to_cpu(dev->udev->descriptor.idVendor)) {
830 case 0x046d: /* Logitech */
831 if (buffer[1] != 0x41 || buffer[2] != 0x01)
835 * Logitech implements several vendor specific functions
836 * through vendor specific extension units (LXU).
838 * The LXU descriptors are similar to XU descriptors
839 * (see "USB Device Video Class for Video Devices", section
840 * 3.7.2.6 "Extension Unit Descriptor") with the following
843 * ----------------------------------------------------------
845 * Size of this descriptor, in bytes: 24+p+n*2
846 * ----------------------------------------------------------
847 * 23+p+n bmControlsType N Bitmap
848 * Individual bits in the set are defined:
852 * This bitset is mapped exactly the same as bmControls.
853 * ----------------------------------------------------------
854 * 23+p+n*2 bReserved 1 Boolean
855 * ----------------------------------------------------------
856 * 24+p+n*2 iExtension 1 Index
857 * Index of a string descriptor that describes this
859 * ----------------------------------------------------------
861 p = buflen >= 22 ? buffer[21] : 0;
862 n = buflen >= 25 + p ? buffer[22+p] : 0;
864 if (buflen < 25 + p + 2*n) {
866 "device %d videocontrol interface %d EXTENSION_UNIT error\n",
867 udev->devnum, alts->desc.bInterfaceNumber);
871 unit = uvc_alloc_entity(UVC_VC_EXTENSION_UNIT, buffer[3],
876 memcpy(unit->guid, &buffer[4], 16);
877 unit->extension.bNumControls = buffer[20];
878 memcpy(unit->baSourceID, &buffer[22], p);
879 unit->extension.bControlSize = buffer[22+p];
880 unit->extension.bmControls = (u8 *)unit + sizeof(*unit);
881 unit->extension.bmControlsType = (u8 *)unit + sizeof(*unit)
883 memcpy(unit->extension.bmControls, &buffer[23+p], 2*n);
885 uvc_entity_set_name(dev, unit, "Extension", buffer[24+p+2*n]);
887 list_add_tail(&unit->list, &dev->entities);
895 static int uvc_parse_standard_control(struct uvc_device *dev,
896 const unsigned char *buffer, int buflen)
898 struct usb_device *udev = dev->udev;
899 struct uvc_entity *unit, *term;
900 struct usb_interface *intf;
901 struct usb_host_interface *alts = dev->intf->cur_altsetting;
902 unsigned int i, n, p, len;
903 const char *type_name;
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);
1009 if (UVC_ENTITY_TYPE(term) == UVC_ITT_CAMERA)
1010 type_name = "Camera";
1011 else if (UVC_ENTITY_TYPE(term) == UVC_ITT_MEDIA_TRANSPORT_INPUT)
1012 type_name = "Media";
1014 type_name = "Input";
1016 uvc_entity_set_name(dev, term, type_name, buffer[7]);
1018 list_add_tail(&term->list, &dev->entities);
1021 case UVC_VC_OUTPUT_TERMINAL:
1024 "device %d videocontrol interface %d OUTPUT_TERMINAL error\n",
1025 udev->devnum, alts->desc.bInterfaceNumber);
1030 * Make sure the terminal type MSB is not null, otherwise it
1031 * could be confused with a unit.
1033 type = get_unaligned_le16(&buffer[4]);
1034 if ((type & 0xff00) == 0) {
1036 "device %d videocontrol interface %d OUTPUT_TERMINAL %d has invalid type 0x%04x, skipping\n",
1037 udev->devnum, alts->desc.bInterfaceNumber,
1042 term = uvc_alloc_entity(type | UVC_TERM_OUTPUT, buffer[3],
1047 memcpy(term->baSourceID, &buffer[7], 1);
1049 uvc_entity_set_name(dev, term, "Output", buffer[8]);
1051 list_add_tail(&term->list, &dev->entities);
1054 case UVC_VC_SELECTOR_UNIT:
1055 p = buflen >= 5 ? buffer[4] : 0;
1057 if (buflen < 5 || buflen < 6 + p) {
1059 "device %d videocontrol interface %d SELECTOR_UNIT error\n",
1060 udev->devnum, alts->desc.bInterfaceNumber);
1064 unit = uvc_alloc_entity(buffer[2], buffer[3], p + 1, 0);
1068 memcpy(unit->baSourceID, &buffer[5], p);
1070 uvc_entity_set_name(dev, unit, "Selector", buffer[5+p]);
1072 list_add_tail(&unit->list, &dev->entities);
1075 case UVC_VC_PROCESSING_UNIT:
1076 n = buflen >= 8 ? buffer[7] : 0;
1077 p = dev->uvc_version >= 0x0110 ? 10 : 9;
1079 if (buflen < p + n) {
1081 "device %d videocontrol interface %d PROCESSING_UNIT error\n",
1082 udev->devnum, alts->desc.bInterfaceNumber);
1086 unit = uvc_alloc_entity(buffer[2], buffer[3], 2, n);
1090 memcpy(unit->baSourceID, &buffer[4], 1);
1091 unit->processing.wMaxMultiplier =
1092 get_unaligned_le16(&buffer[5]);
1093 unit->processing.bControlSize = buffer[7];
1094 unit->processing.bmControls = (u8 *)unit + sizeof(*unit);
1095 memcpy(unit->processing.bmControls, &buffer[8], n);
1096 if (dev->uvc_version >= 0x0110)
1097 unit->processing.bmVideoStandards = buffer[9+n];
1099 uvc_entity_set_name(dev, unit, "Processing", buffer[8+n]);
1101 list_add_tail(&unit->list, &dev->entities);
1104 case UVC_VC_EXTENSION_UNIT:
1105 p = buflen >= 22 ? buffer[21] : 0;
1106 n = buflen >= 24 + p ? buffer[22+p] : 0;
1108 if (buflen < 24 + p + n) {
1110 "device %d videocontrol interface %d EXTENSION_UNIT error\n",
1111 udev->devnum, alts->desc.bInterfaceNumber);
1115 unit = uvc_alloc_entity(buffer[2], buffer[3], p + 1, n);
1119 memcpy(unit->guid, &buffer[4], 16);
1120 unit->extension.bNumControls = buffer[20];
1121 memcpy(unit->baSourceID, &buffer[22], p);
1122 unit->extension.bControlSize = buffer[22+p];
1123 unit->extension.bmControls = (u8 *)unit + sizeof(*unit);
1124 memcpy(unit->extension.bmControls, &buffer[23+p], n);
1126 uvc_entity_set_name(dev, unit, "Extension", buffer[23+p+n]);
1128 list_add_tail(&unit->list, &dev->entities);
1133 "Found an unknown CS_INTERFACE descriptor (%u)\n",
1141 static int uvc_parse_control(struct uvc_device *dev)
1143 struct usb_host_interface *alts = dev->intf->cur_altsetting;
1144 unsigned char *buffer = alts->extra;
1145 int buflen = alts->extralen;
1149 * Parse the default alternate setting only, as the UVC specification
1150 * defines a single alternate setting, the default alternate setting
1154 while (buflen > 2) {
1155 if (uvc_parse_vendor_control(dev, buffer, buflen) ||
1156 buffer[1] != USB_DT_CS_INTERFACE)
1157 goto next_descriptor;
1159 ret = uvc_parse_standard_control(dev, buffer, buflen);
1164 buflen -= buffer[0];
1165 buffer += buffer[0];
1169 * Check if the optional status endpoint is present. Built-in iSight
1170 * webcams have an interrupt endpoint but spit proprietary data that
1171 * don't conform to the UVC status endpoint messages. Don't try to
1172 * handle the interrupt endpoint for those cameras.
1174 if (alts->desc.bNumEndpoints == 1 &&
1175 !(dev->quirks & UVC_QUIRK_BUILTIN_ISIGHT)) {
1176 struct usb_host_endpoint *ep = &alts->endpoint[0];
1177 struct usb_endpoint_descriptor *desc = &ep->desc;
1179 if (usb_endpoint_is_int_in(desc) &&
1180 le16_to_cpu(desc->wMaxPacketSize) >= 8 &&
1181 desc->bInterval != 0) {
1183 "Found a Status endpoint (addr %02x)\n",
1184 desc->bEndpointAddress);
1192 /* -----------------------------------------------------------------------------
1196 static void uvc_gpio_event(struct uvc_device *dev)
1198 struct uvc_entity *unit = dev->gpio_unit;
1199 struct uvc_video_chain *chain;
1205 new_val = gpiod_get_value_cansleep(unit->gpio.gpio_privacy);
1207 /* GPIO entities are always on the first chain. */
1208 chain = list_first_entry(&dev->chains, struct uvc_video_chain, list);
1209 uvc_ctrl_status_event(chain, unit->controls, &new_val);
1212 static int uvc_gpio_get_cur(struct uvc_device *dev, struct uvc_entity *entity,
1213 u8 cs, void *data, u16 size)
1215 if (cs != UVC_CT_PRIVACY_CONTROL || size < 1)
1218 *(u8 *)data = gpiod_get_value_cansleep(entity->gpio.gpio_privacy);
1223 static int uvc_gpio_get_info(struct uvc_device *dev, struct uvc_entity *entity,
1226 if (cs != UVC_CT_PRIVACY_CONTROL)
1229 *caps = UVC_CONTROL_CAP_GET | UVC_CONTROL_CAP_AUTOUPDATE;
1233 static irqreturn_t uvc_gpio_irq(int irq, void *data)
1235 struct uvc_device *dev = data;
1237 uvc_gpio_event(dev);
1241 static int uvc_gpio_parse(struct uvc_device *dev)
1243 struct uvc_entity *unit;
1244 struct gpio_desc *gpio_privacy;
1247 gpio_privacy = devm_gpiod_get_optional(&dev->udev->dev, "privacy",
1249 if (IS_ERR_OR_NULL(gpio_privacy))
1250 return PTR_ERR_OR_ZERO(gpio_privacy);
1252 irq = gpiod_to_irq(gpio_privacy);
1254 return dev_err_probe(&dev->udev->dev, irq,
1255 "No IRQ for privacy GPIO\n");
1257 unit = uvc_alloc_entity(UVC_EXT_GPIO_UNIT, UVC_EXT_GPIO_UNIT_ID, 0, 1);
1261 unit->gpio.gpio_privacy = gpio_privacy;
1262 unit->gpio.irq = irq;
1263 unit->gpio.bControlSize = 1;
1264 unit->gpio.bmControls = (u8 *)unit + sizeof(*unit);
1265 unit->gpio.bmControls[0] = 1;
1266 unit->get_cur = uvc_gpio_get_cur;
1267 unit->get_info = uvc_gpio_get_info;
1268 strscpy(unit->name, "GPIO", sizeof(unit->name));
1270 list_add_tail(&unit->list, &dev->entities);
1272 dev->gpio_unit = unit;
1277 static int uvc_gpio_init_irq(struct uvc_device *dev)
1279 struct uvc_entity *unit = dev->gpio_unit;
1281 if (!unit || unit->gpio.irq < 0)
1284 return devm_request_threaded_irq(&dev->udev->dev, unit->gpio.irq, NULL,
1286 IRQF_ONESHOT | IRQF_TRIGGER_FALLING |
1287 IRQF_TRIGGER_RISING,
1288 "uvc_privacy_gpio", dev);
1291 /* ------------------------------------------------------------------------
1296 * Scan the UVC descriptors to locate a chain starting at an Output Terminal
1297 * and containing the following units:
1299 * - one or more Output Terminals (USB Streaming or Display)
1300 * - zero or one Processing Unit
1301 * - zero, one or more single-input Selector Units
1302 * - zero or one multiple-input Selector Units, provided all inputs are
1303 * connected to input terminals
1304 * - zero, one or mode single-input Extension Units
1305 * - one or more Input Terminals (Camera, External or USB Streaming)
1307 * The terminal and units must match on of the following structures:
1309 * ITT_*(0) -> +---------+ +---------+ +---------+ -> TT_STREAMING(0)
1310 * ... | SU{0,1} | -> | PU{0,1} | -> | XU{0,n} | ...
1311 * ITT_*(n) -> +---------+ +---------+ +---------+ -> TT_STREAMING(n)
1313 * +---------+ +---------+ -> OTT_*(0)
1314 * TT_STREAMING -> | PU{0,1} | -> | XU{0,n} | ...
1315 * +---------+ +---------+ -> OTT_*(n)
1317 * The Processing Unit and Extension Units can be in any order. Additional
1318 * Extension Units connected to the main chain as single-unit branches are
1319 * also supported. Single-input Selector Units are ignored.
1321 static int uvc_scan_chain_entity(struct uvc_video_chain *chain,
1322 struct uvc_entity *entity)
1324 switch (UVC_ENTITY_TYPE(entity)) {
1325 case UVC_VC_EXTENSION_UNIT:
1326 uvc_dbg_cont(PROBE, " <- XU %d", entity->id);
1328 if (entity->bNrInPins != 1) {
1329 uvc_dbg(chain->dev, DESCR,
1330 "Extension unit %d has more than 1 input pin\n",
1337 case UVC_VC_PROCESSING_UNIT:
1338 uvc_dbg_cont(PROBE, " <- PU %d", entity->id);
1340 if (chain->processing != NULL) {
1341 uvc_dbg(chain->dev, DESCR,
1342 "Found multiple Processing Units in chain\n");
1346 chain->processing = entity;
1349 case UVC_VC_SELECTOR_UNIT:
1350 uvc_dbg_cont(PROBE, " <- SU %d", entity->id);
1352 /* Single-input selector units are ignored. */
1353 if (entity->bNrInPins == 1)
1356 if (chain->selector != NULL) {
1357 uvc_dbg(chain->dev, DESCR,
1358 "Found multiple Selector Units in chain\n");
1362 chain->selector = entity;
1365 case UVC_ITT_VENDOR_SPECIFIC:
1366 case UVC_ITT_CAMERA:
1367 case UVC_ITT_MEDIA_TRANSPORT_INPUT:
1368 uvc_dbg_cont(PROBE, " <- IT %d\n", entity->id);
1372 case UVC_OTT_VENDOR_SPECIFIC:
1373 case UVC_OTT_DISPLAY:
1374 case UVC_OTT_MEDIA_TRANSPORT_OUTPUT:
1375 uvc_dbg_cont(PROBE, " OT %d", entity->id);
1379 case UVC_TT_STREAMING:
1380 if (UVC_ENTITY_IS_ITERM(entity))
1381 uvc_dbg_cont(PROBE, " <- IT %d\n", entity->id);
1383 uvc_dbg_cont(PROBE, " OT %d", entity->id);
1388 uvc_dbg(chain->dev, DESCR,
1389 "Unsupported entity type 0x%04x found in chain\n",
1390 UVC_ENTITY_TYPE(entity));
1394 list_add_tail(&entity->chain, &chain->entities);
1398 static int uvc_scan_chain_forward(struct uvc_video_chain *chain,
1399 struct uvc_entity *entity, struct uvc_entity *prev)
1401 struct uvc_entity *forward;
1409 forward = uvc_entity_by_reference(chain->dev, entity->id,
1411 if (forward == NULL)
1413 if (forward == prev)
1415 if (forward->chain.next || forward->chain.prev) {
1416 uvc_dbg(chain->dev, DESCR,
1417 "Found reference to entity %d already in chain\n",
1422 switch (UVC_ENTITY_TYPE(forward)) {
1423 case UVC_VC_EXTENSION_UNIT:
1424 if (forward->bNrInPins != 1) {
1425 uvc_dbg(chain->dev, DESCR,
1426 "Extension unit %d has more than 1 input pin\n",
1432 * Some devices reference an output terminal as the
1433 * source of extension units. This is incorrect, as
1434 * output terminals only have an input pin, and thus
1435 * can't be connected to any entity in the forward
1436 * direction. The resulting topology would cause issues
1437 * when registering the media controller graph. To
1438 * avoid this problem, connect the extension unit to
1439 * the source of the output terminal instead.
1441 if (UVC_ENTITY_IS_OTERM(entity)) {
1442 struct uvc_entity *source;
1444 source = uvc_entity_by_id(chain->dev,
1445 entity->baSourceID[0]);
1447 uvc_dbg(chain->dev, DESCR,
1448 "Can't connect extension unit %u in chain\n",
1453 forward->baSourceID[0] = source->id;
1456 list_add_tail(&forward->chain, &chain->entities);
1458 uvc_dbg_cont(PROBE, " (->");
1460 uvc_dbg_cont(PROBE, " XU %d", forward->id);
1464 case UVC_OTT_VENDOR_SPECIFIC:
1465 case UVC_OTT_DISPLAY:
1466 case UVC_OTT_MEDIA_TRANSPORT_OUTPUT:
1467 case UVC_TT_STREAMING:
1468 if (UVC_ENTITY_IS_ITERM(forward)) {
1469 uvc_dbg(chain->dev, DESCR,
1470 "Unsupported input terminal %u\n",
1475 if (UVC_ENTITY_IS_OTERM(entity)) {
1476 uvc_dbg(chain->dev, DESCR,
1477 "Unsupported connection between output terminals %u and %u\n",
1478 entity->id, forward->id);
1482 list_add_tail(&forward->chain, &chain->entities);
1484 uvc_dbg_cont(PROBE, " (->");
1486 uvc_dbg_cont(PROBE, " OT %d", forward->id);
1492 uvc_dbg_cont(PROBE, ")");
1497 static int uvc_scan_chain_backward(struct uvc_video_chain *chain,
1498 struct uvc_entity **_entity)
1500 struct uvc_entity *entity = *_entity;
1501 struct uvc_entity *term;
1502 int id = -EINVAL, i;
1504 switch (UVC_ENTITY_TYPE(entity)) {
1505 case UVC_VC_EXTENSION_UNIT:
1506 case UVC_VC_PROCESSING_UNIT:
1507 id = entity->baSourceID[0];
1510 case UVC_VC_SELECTOR_UNIT:
1511 /* Single-input selector units are ignored. */
1512 if (entity->bNrInPins == 1) {
1513 id = entity->baSourceID[0];
1517 uvc_dbg_cont(PROBE, " <- IT");
1519 chain->selector = entity;
1520 for (i = 0; i < entity->bNrInPins; ++i) {
1521 id = entity->baSourceID[i];
1522 term = uvc_entity_by_id(chain->dev, id);
1523 if (term == NULL || !UVC_ENTITY_IS_ITERM(term)) {
1524 uvc_dbg(chain->dev, DESCR,
1525 "Selector unit %d input %d isn't connected to an input terminal\n",
1530 if (term->chain.next || term->chain.prev) {
1531 uvc_dbg(chain->dev, DESCR,
1532 "Found reference to entity %d already in chain\n",
1537 uvc_dbg_cont(PROBE, " %d", term->id);
1539 list_add_tail(&term->chain, &chain->entities);
1540 uvc_scan_chain_forward(chain, term, entity);
1543 uvc_dbg_cont(PROBE, "\n");
1548 case UVC_ITT_VENDOR_SPECIFIC:
1549 case UVC_ITT_CAMERA:
1550 case UVC_ITT_MEDIA_TRANSPORT_INPUT:
1551 case UVC_OTT_VENDOR_SPECIFIC:
1552 case UVC_OTT_DISPLAY:
1553 case UVC_OTT_MEDIA_TRANSPORT_OUTPUT:
1554 case UVC_TT_STREAMING:
1555 id = UVC_ENTITY_IS_OTERM(entity) ? entity->baSourceID[0] : 0;
1564 entity = uvc_entity_by_id(chain->dev, id);
1565 if (entity == NULL) {
1566 uvc_dbg(chain->dev, DESCR,
1567 "Found reference to unknown entity %d\n", id);
1575 static int uvc_scan_chain(struct uvc_video_chain *chain,
1576 struct uvc_entity *term)
1578 struct uvc_entity *entity, *prev;
1580 uvc_dbg(chain->dev, PROBE, "Scanning UVC chain:");
1585 while (entity != NULL) {
1586 /* Entity must not be part of an existing chain */
1587 if (entity->chain.next || entity->chain.prev) {
1588 uvc_dbg(chain->dev, DESCR,
1589 "Found reference to entity %d already in chain\n",
1594 /* Process entity */
1595 if (uvc_scan_chain_entity(chain, entity) < 0)
1599 if (uvc_scan_chain_forward(chain, entity, prev) < 0)
1604 if (uvc_scan_chain_backward(chain, &entity) < 0)
1611 static unsigned int uvc_print_terms(struct list_head *terms, u16 dir,
1614 struct uvc_entity *term;
1615 unsigned int nterms = 0;
1618 list_for_each_entry(term, terms, chain) {
1619 if (!UVC_ENTITY_IS_TERM(term) ||
1620 UVC_TERM_DIRECTION(term) != dir)
1624 p += sprintf(p, ",");
1625 if (++nterms >= 4) {
1626 p += sprintf(p, "...");
1629 p += sprintf(p, "%u", term->id);
1635 static const char *uvc_print_chain(struct uvc_video_chain *chain)
1637 static char buffer[43];
1640 p += uvc_print_terms(&chain->entities, UVC_TERM_INPUT, p);
1641 p += sprintf(p, " -> ");
1642 uvc_print_terms(&chain->entities, UVC_TERM_OUTPUT, p);
1647 static struct uvc_video_chain *uvc_alloc_chain(struct uvc_device *dev)
1649 struct uvc_video_chain *chain;
1651 chain = kzalloc(sizeof(*chain), GFP_KERNEL);
1655 INIT_LIST_HEAD(&chain->entities);
1656 mutex_init(&chain->ctrl_mutex);
1658 v4l2_prio_init(&chain->prio);
1664 * Fallback heuristic for devices that don't connect units and terminals in a
1667 * Some devices have invalid baSourceID references, causing uvc_scan_chain()
1668 * to fail, but if we just take the entities we can find and put them together
1669 * in the most sensible chain we can think of, turns out they do work anyway.
1670 * Note: This heuristic assumes there is a single chain.
1672 * At the time of writing, devices known to have such a broken chain are
1673 * - Acer Integrated Camera (5986:055a)
1674 * - Realtek rtl157a7 (0bda:57a7)
1676 static int uvc_scan_fallback(struct uvc_device *dev)
1678 struct uvc_video_chain *chain;
1679 struct uvc_entity *iterm = NULL;
1680 struct uvc_entity *oterm = NULL;
1681 struct uvc_entity *entity;
1682 struct uvc_entity *prev;
1685 * Start by locating the input and output terminals. We only support
1686 * devices with exactly one of each for now.
1688 list_for_each_entry(entity, &dev->entities, list) {
1689 if (UVC_ENTITY_IS_ITERM(entity)) {
1695 if (UVC_ENTITY_IS_OTERM(entity)) {
1702 if (iterm == NULL || oterm == NULL)
1705 /* Allocate the chain and fill it. */
1706 chain = uvc_alloc_chain(dev);
1710 if (uvc_scan_chain_entity(chain, oterm) < 0)
1716 * Add all Processing and Extension Units with two pads. The order
1717 * doesn't matter much, use reverse list traversal to connect units in
1718 * UVC descriptor order as we build the chain from output to input. This
1719 * leads to units appearing in the order meant by the manufacturer for
1720 * the cameras known to require this heuristic.
1722 list_for_each_entry_reverse(entity, &dev->entities, list) {
1723 if (entity->type != UVC_VC_PROCESSING_UNIT &&
1724 entity->type != UVC_VC_EXTENSION_UNIT)
1727 if (entity->num_pads != 2)
1730 if (uvc_scan_chain_entity(chain, entity) < 0)
1733 prev->baSourceID[0] = entity->id;
1737 if (uvc_scan_chain_entity(chain, iterm) < 0)
1740 prev->baSourceID[0] = iterm->id;
1742 list_add_tail(&chain->list, &dev->chains);
1744 uvc_dbg(dev, PROBE, "Found a video chain by fallback heuristic (%s)\n",
1745 uvc_print_chain(chain));
1755 * Scan the device for video chains and register video devices.
1757 * Chains are scanned starting at their output terminals and walked backwards.
1759 static int uvc_scan_device(struct uvc_device *dev)
1761 struct uvc_video_chain *chain;
1762 struct uvc_entity *term;
1764 list_for_each_entry(term, &dev->entities, list) {
1765 if (!UVC_ENTITY_IS_OTERM(term))
1769 * If the terminal is already included in a chain, skip it.
1770 * This can happen for chains that have multiple output
1771 * terminals, where all output terminals beside the first one
1772 * will be inserted in the chain in forward scans.
1774 if (term->chain.next || term->chain.prev)
1777 chain = uvc_alloc_chain(dev);
1781 term->flags |= UVC_ENTITY_FLAG_DEFAULT;
1783 if (uvc_scan_chain(chain, term) < 0) {
1788 uvc_dbg(dev, PROBE, "Found a valid video chain (%s)\n",
1789 uvc_print_chain(chain));
1791 list_add_tail(&chain->list, &dev->chains);
1794 if (list_empty(&dev->chains))
1795 uvc_scan_fallback(dev);
1797 if (list_empty(&dev->chains)) {
1798 dev_info(&dev->udev->dev, "No valid video chain found.\n");
1802 /* Add GPIO entity to the first chain. */
1803 if (dev->gpio_unit) {
1804 chain = list_first_entry(&dev->chains,
1805 struct uvc_video_chain, list);
1806 list_add_tail(&dev->gpio_unit->chain, &chain->entities);
1812 /* ------------------------------------------------------------------------
1813 * Video device registration and unregistration
1817 * Delete the UVC device.
1819 * Called by the kernel when the last reference to the uvc_device structure
1822 * As this function is called after or during disconnect(), all URBs have
1823 * already been cancelled by the USB core. There is no need to kill the
1824 * interrupt URB manually.
1826 static void uvc_delete(struct kref *kref)
1828 struct uvc_device *dev = container_of(kref, struct uvc_device, ref);
1829 struct list_head *p, *n;
1831 uvc_status_cleanup(dev);
1832 uvc_ctrl_cleanup_device(dev);
1834 usb_put_intf(dev->intf);
1835 usb_put_dev(dev->udev);
1837 #ifdef CONFIG_MEDIA_CONTROLLER
1838 media_device_cleanup(&dev->mdev);
1841 list_for_each_safe(p, n, &dev->chains) {
1842 struct uvc_video_chain *chain;
1844 chain = list_entry(p, struct uvc_video_chain, list);
1848 list_for_each_safe(p, n, &dev->entities) {
1849 struct uvc_entity *entity;
1851 entity = list_entry(p, struct uvc_entity, list);
1852 #ifdef CONFIG_MEDIA_CONTROLLER
1853 uvc_mc_cleanup_entity(entity);
1858 list_for_each_safe(p, n, &dev->streams) {
1859 struct uvc_streaming *streaming;
1861 streaming = list_entry(p, struct uvc_streaming, list);
1862 usb_driver_release_interface(&uvc_driver.driver,
1864 uvc_stream_delete(streaming);
1870 static void uvc_release(struct video_device *vdev)
1872 struct uvc_streaming *stream = video_get_drvdata(vdev);
1873 struct uvc_device *dev = stream->dev;
1875 kref_put(&dev->ref, uvc_delete);
1879 * Unregister the video devices.
1881 static void uvc_unregister_video(struct uvc_device *dev)
1883 struct uvc_streaming *stream;
1885 list_for_each_entry(stream, &dev->streams, list) {
1886 if (!video_is_registered(&stream->vdev))
1889 video_unregister_device(&stream->vdev);
1890 video_unregister_device(&stream->meta.vdev);
1892 uvc_debugfs_cleanup_stream(stream);
1895 uvc_status_unregister(dev);
1898 v4l2_device_unregister(&dev->vdev);
1899 #ifdef CONFIG_MEDIA_CONTROLLER
1900 if (media_devnode_is_registered(dev->mdev.devnode))
1901 media_device_unregister(&dev->mdev);
1905 int uvc_register_video_device(struct uvc_device *dev,
1906 struct uvc_streaming *stream,
1907 struct video_device *vdev,
1908 struct uvc_video_queue *queue,
1909 enum v4l2_buf_type type,
1910 const struct v4l2_file_operations *fops,
1911 const struct v4l2_ioctl_ops *ioctl_ops)
1915 /* Initialize the video buffers queue. */
1916 ret = uvc_queue_init(queue, type, !uvc_no_drop_param);
1920 /* Register the device with V4L. */
1923 * We already hold a reference to dev->udev. The video device will be
1924 * unregistered before the reference is released, so we don't need to
1927 vdev->v4l2_dev = &dev->vdev;
1929 vdev->ioctl_ops = ioctl_ops;
1930 vdev->release = uvc_release;
1931 vdev->prio = &stream->chain->prio;
1932 if (type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
1933 vdev->vfl_dir = VFL_DIR_TX;
1935 vdev->vfl_dir = VFL_DIR_RX;
1938 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
1940 vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
1942 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
1943 vdev->device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING;
1945 case V4L2_BUF_TYPE_META_CAPTURE:
1946 vdev->device_caps = V4L2_CAP_META_CAPTURE | V4L2_CAP_STREAMING;
1950 strscpy(vdev->name, dev->name, sizeof(vdev->name));
1953 * Set the driver data before calling video_register_device, otherwise
1954 * the file open() handler might race us.
1956 video_set_drvdata(vdev, stream);
1958 ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1);
1960 dev_err(&stream->intf->dev,
1961 "Failed to register %s device (%d).\n",
1962 v4l2_type_names[type], ret);
1966 kref_get(&dev->ref);
1970 static int uvc_register_video(struct uvc_device *dev,
1971 struct uvc_streaming *stream)
1975 /* Initialize the streaming interface with default parameters. */
1976 ret = uvc_video_init(stream);
1978 dev_err(&stream->intf->dev,
1979 "Failed to initialize the device (%d).\n", ret);
1983 if (stream->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
1984 stream->chain->caps |= V4L2_CAP_VIDEO_CAPTURE
1985 | V4L2_CAP_META_CAPTURE;
1987 stream->chain->caps |= V4L2_CAP_VIDEO_OUTPUT;
1989 uvc_debugfs_init_stream(stream);
1991 /* Register the device with V4L. */
1992 return uvc_register_video_device(dev, stream, &stream->vdev,
1993 &stream->queue, stream->type,
1994 &uvc_fops, &uvc_ioctl_ops);
1998 * Register all video devices in all chains.
2000 static int uvc_register_terms(struct uvc_device *dev,
2001 struct uvc_video_chain *chain)
2003 struct uvc_streaming *stream;
2004 struct uvc_entity *term;
2007 list_for_each_entry(term, &chain->entities, chain) {
2008 if (UVC_ENTITY_TYPE(term) != UVC_TT_STREAMING)
2011 stream = uvc_stream_by_id(dev, term->id);
2012 if (stream == NULL) {
2013 dev_info(&dev->udev->dev,
2014 "No streaming interface found for terminal %u.",
2019 stream->chain = chain;
2020 ret = uvc_register_video(dev, stream);
2025 * Register a metadata node, but ignore a possible failure,
2026 * complete registration of video nodes anyway.
2028 uvc_meta_register(stream);
2030 term->vdev = &stream->vdev;
2036 static int uvc_register_chains(struct uvc_device *dev)
2038 struct uvc_video_chain *chain;
2041 list_for_each_entry(chain, &dev->chains, list) {
2042 ret = uvc_register_terms(dev, chain);
2046 #ifdef CONFIG_MEDIA_CONTROLLER
2047 ret = uvc_mc_register_entities(chain);
2049 dev_info(&dev->udev->dev,
2050 "Failed to register entities (%d).\n", ret);
2057 /* ------------------------------------------------------------------------
2058 * USB probe, disconnect, suspend and resume
2061 static const struct uvc_device_info uvc_quirk_none = { 0 };
2063 static int uvc_probe(struct usb_interface *intf,
2064 const struct usb_device_id *id)
2066 struct usb_device *udev = interface_to_usbdev(intf);
2067 struct uvc_device *dev;
2068 const struct uvc_device_info *info =
2069 (const struct uvc_device_info *)id->driver_info;
2073 /* Allocate memory for the device and initialize it. */
2074 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
2078 INIT_LIST_HEAD(&dev->entities);
2079 INIT_LIST_HEAD(&dev->chains);
2080 INIT_LIST_HEAD(&dev->streams);
2081 kref_init(&dev->ref);
2082 atomic_set(&dev->nmappings, 0);
2083 mutex_init(&dev->lock);
2085 dev->udev = usb_get_dev(udev);
2086 dev->intf = usb_get_intf(intf);
2087 dev->intfnum = intf->cur_altsetting->desc.bInterfaceNumber;
2088 dev->info = info ? info : &uvc_quirk_none;
2089 dev->quirks = uvc_quirks_param == -1
2090 ? dev->info->quirks : uvc_quirks_param;
2092 if (id->idVendor && id->idProduct)
2093 uvc_dbg(dev, PROBE, "Probing known UVC device %s (%04x:%04x)\n",
2094 udev->devpath, id->idVendor, id->idProduct);
2096 uvc_dbg(dev, PROBE, "Probing generic UVC device %s\n",
2099 if (udev->product != NULL)
2100 strscpy(dev->name, udev->product, sizeof(dev->name));
2102 snprintf(dev->name, sizeof(dev->name),
2103 "UVC Camera (%04x:%04x)",
2104 le16_to_cpu(udev->descriptor.idVendor),
2105 le16_to_cpu(udev->descriptor.idProduct));
2108 * Add iFunction or iInterface to names when available as additional
2109 * distinguishers between interfaces. iFunction is prioritized over
2110 * iInterface which matches Windows behavior at the point of writing.
2112 if (intf->intf_assoc && intf->intf_assoc->iFunction != 0)
2113 function = intf->intf_assoc->iFunction;
2115 function = intf->cur_altsetting->desc.iInterface;
2116 if (function != 0) {
2119 strlcat(dev->name, ": ", sizeof(dev->name));
2120 len = strlen(dev->name);
2121 usb_string(udev, function, dev->name + len,
2122 sizeof(dev->name) - len);
2125 /* Initialize the media device. */
2126 #ifdef CONFIG_MEDIA_CONTROLLER
2127 dev->mdev.dev = &intf->dev;
2128 strscpy(dev->mdev.model, dev->name, sizeof(dev->mdev.model));
2130 strscpy(dev->mdev.serial, udev->serial,
2131 sizeof(dev->mdev.serial));
2132 usb_make_path(udev, dev->mdev.bus_info, sizeof(dev->mdev.bus_info));
2133 dev->mdev.hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
2134 media_device_init(&dev->mdev);
2136 dev->vdev.mdev = &dev->mdev;
2139 /* Parse the Video Class control descriptor. */
2140 if (uvc_parse_control(dev) < 0) {
2141 uvc_dbg(dev, PROBE, "Unable to parse UVC descriptors\n");
2145 /* Parse the associated GPIOs. */
2146 if (uvc_gpio_parse(dev) < 0) {
2147 uvc_dbg(dev, PROBE, "Unable to parse UVC GPIOs\n");
2151 dev_info(&dev->udev->dev, "Found UVC %u.%02x device %s (%04x:%04x)\n",
2152 dev->uvc_version >> 8, dev->uvc_version & 0xff,
2153 udev->product ? udev->product : "<unnamed>",
2154 le16_to_cpu(udev->descriptor.idVendor),
2155 le16_to_cpu(udev->descriptor.idProduct));
2157 if (dev->quirks != dev->info->quirks) {
2158 dev_info(&dev->udev->dev,
2159 "Forcing device quirks to 0x%x by module parameter for testing purpose.\n",
2161 dev_info(&dev->udev->dev,
2162 "Please report required quirks to the linux-media mailing list.\n");
2165 if (dev->info->uvc_version) {
2166 dev->uvc_version = dev->info->uvc_version;
2167 dev_info(&dev->udev->dev, "Forcing UVC version to %u.%02x\n",
2168 dev->uvc_version >> 8, dev->uvc_version & 0xff);
2171 /* Register the V4L2 device. */
2172 if (v4l2_device_register(&intf->dev, &dev->vdev) < 0)
2175 /* Scan the device for video chains. */
2176 if (uvc_scan_device(dev) < 0)
2179 /* Initialize controls. */
2180 if (uvc_ctrl_init_device(dev) < 0)
2183 /* Register video device nodes. */
2184 if (uvc_register_chains(dev) < 0)
2187 #ifdef CONFIG_MEDIA_CONTROLLER
2188 /* Register the media device node */
2189 if (media_device_register(&dev->mdev) < 0)
2192 /* Save our data pointer in the interface data. */
2193 usb_set_intfdata(intf, dev);
2195 /* Initialize the interrupt URB. */
2196 ret = uvc_status_init(dev);
2198 dev_info(&dev->udev->dev,
2199 "Unable to initialize the status endpoint (%d), status interrupt will not be supported.\n",
2203 ret = uvc_gpio_init_irq(dev);
2205 dev_err(&dev->udev->dev,
2206 "Unable to request privacy GPIO IRQ (%d)\n", ret);
2210 uvc_dbg(dev, PROBE, "UVC device initialized\n");
2211 usb_enable_autosuspend(udev);
2215 uvc_unregister_video(dev);
2216 kref_put(&dev->ref, uvc_delete);
2220 static void uvc_disconnect(struct usb_interface *intf)
2222 struct uvc_device *dev = usb_get_intfdata(intf);
2225 * Set the USB interface data to NULL. This can be done outside the
2226 * lock, as there's no other reader.
2228 usb_set_intfdata(intf, NULL);
2230 if (intf->cur_altsetting->desc.bInterfaceSubClass ==
2231 UVC_SC_VIDEOSTREAMING)
2234 uvc_unregister_video(dev);
2235 kref_put(&dev->ref, uvc_delete);
2238 static int uvc_suspend(struct usb_interface *intf, pm_message_t message)
2240 struct uvc_device *dev = usb_get_intfdata(intf);
2241 struct uvc_streaming *stream;
2243 uvc_dbg(dev, SUSPEND, "Suspending interface %u\n",
2244 intf->cur_altsetting->desc.bInterfaceNumber);
2246 /* Controls are cached on the fly so they don't need to be saved. */
2247 if (intf->cur_altsetting->desc.bInterfaceSubClass ==
2248 UVC_SC_VIDEOCONTROL) {
2249 mutex_lock(&dev->lock);
2251 uvc_status_stop(dev);
2252 mutex_unlock(&dev->lock);
2256 list_for_each_entry(stream, &dev->streams, list) {
2257 if (stream->intf == intf)
2258 return uvc_video_suspend(stream);
2261 uvc_dbg(dev, SUSPEND,
2262 "Suspend: video streaming USB interface mismatch\n");
2266 static int __uvc_resume(struct usb_interface *intf, int reset)
2268 struct uvc_device *dev = usb_get_intfdata(intf);
2269 struct uvc_streaming *stream;
2272 uvc_dbg(dev, SUSPEND, "Resuming interface %u\n",
2273 intf->cur_altsetting->desc.bInterfaceNumber);
2275 if (intf->cur_altsetting->desc.bInterfaceSubClass ==
2276 UVC_SC_VIDEOCONTROL) {
2278 ret = uvc_ctrl_restore_values(dev);
2283 mutex_lock(&dev->lock);
2285 ret = uvc_status_start(dev, GFP_NOIO);
2286 mutex_unlock(&dev->lock);
2291 list_for_each_entry(stream, &dev->streams, list) {
2292 if (stream->intf == intf) {
2293 ret = uvc_video_resume(stream, reset);
2295 uvc_queue_streamoff(&stream->queue,
2296 stream->queue.queue.type);
2301 uvc_dbg(dev, SUSPEND,
2302 "Resume: video streaming USB interface mismatch\n");
2306 static int uvc_resume(struct usb_interface *intf)
2308 return __uvc_resume(intf, 0);
2311 static int uvc_reset_resume(struct usb_interface *intf)
2313 return __uvc_resume(intf, 1);
2316 /* ------------------------------------------------------------------------
2320 static int uvc_clock_param_get(char *buffer, const struct kernel_param *kp)
2322 if (uvc_clock_param == CLOCK_MONOTONIC)
2323 return sprintf(buffer, "CLOCK_MONOTONIC");
2325 return sprintf(buffer, "CLOCK_REALTIME");
2328 static int uvc_clock_param_set(const char *val, const struct kernel_param *kp)
2330 if (strncasecmp(val, "clock_", strlen("clock_")) == 0)
2331 val += strlen("clock_");
2333 if (strcasecmp(val, "monotonic") == 0)
2334 uvc_clock_param = CLOCK_MONOTONIC;
2335 else if (strcasecmp(val, "realtime") == 0)
2336 uvc_clock_param = CLOCK_REALTIME;
2343 module_param_call(clock, uvc_clock_param_set, uvc_clock_param_get,
2344 &uvc_clock_param, 0644);
2345 MODULE_PARM_DESC(clock, "Video buffers timestamp clock");
2346 module_param_named(hwtimestamps, uvc_hw_timestamps_param, uint, 0644);
2347 MODULE_PARM_DESC(hwtimestamps, "Use hardware timestamps");
2348 module_param_named(nodrop, uvc_no_drop_param, uint, 0644);
2349 MODULE_PARM_DESC(nodrop, "Don't drop incomplete frames");
2350 module_param_named(quirks, uvc_quirks_param, uint, 0644);
2351 MODULE_PARM_DESC(quirks, "Forced device quirks");
2352 module_param_named(trace, uvc_dbg_param, uint, 0644);
2353 MODULE_PARM_DESC(trace, "Trace level bitmask");
2354 module_param_named(timeout, uvc_timeout_param, uint, 0644);
2355 MODULE_PARM_DESC(timeout, "Streaming control requests timeout");
2357 /* ------------------------------------------------------------------------
2358 * Driver initialization and cleanup
2361 static const struct uvc_device_info uvc_ctrl_power_line_limited = {
2362 .mappings = (const struct uvc_control_mapping *[]) {
2363 &uvc_ctrl_power_line_mapping_limited,
2364 NULL, /* Sentinel */
2368 static const struct uvc_device_info uvc_ctrl_power_line_uvc11 = {
2369 .mappings = (const struct uvc_control_mapping *[]) {
2370 &uvc_ctrl_power_line_mapping_uvc11,
2371 NULL, /* Sentinel */
2375 static const struct uvc_device_info uvc_quirk_probe_minmax = {
2376 .quirks = UVC_QUIRK_PROBE_MINMAX,
2379 static const struct uvc_device_info uvc_quirk_fix_bandwidth = {
2380 .quirks = UVC_QUIRK_FIX_BANDWIDTH,
2383 static const struct uvc_device_info uvc_quirk_probe_def = {
2384 .quirks = UVC_QUIRK_PROBE_DEF,
2387 static const struct uvc_device_info uvc_quirk_stream_no_fid = {
2388 .quirks = UVC_QUIRK_STREAM_NO_FID,
2391 static const struct uvc_device_info uvc_quirk_force_y8 = {
2392 .quirks = UVC_QUIRK_FORCE_Y8,
2395 #define UVC_INFO_QUIRK(q) (kernel_ulong_t)&(struct uvc_device_info){.quirks = q}
2396 #define UVC_INFO_META(m) (kernel_ulong_t)&(struct uvc_device_info) \
2400 * The Logitech cameras listed below have their interface class set to
2401 * VENDOR_SPEC because they don't announce themselves as UVC devices, even
2402 * though they are compliant.
2404 static const struct usb_device_id uvc_ids[] = {
2405 /* Quanta USB2.0 HD UVC Webcam */
2406 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2407 | USB_DEVICE_ID_MATCH_INT_INFO,
2409 .idProduct = 0x3090,
2410 .bInterfaceClass = USB_CLASS_VIDEO,
2411 .bInterfaceSubClass = 1,
2412 .bInterfaceProtocol = 0,
2413 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
2414 /* Quanta USB2.0 HD UVC Webcam */
2415 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2416 | USB_DEVICE_ID_MATCH_INT_INFO,
2418 .idProduct = 0x4030,
2419 .bInterfaceClass = USB_CLASS_VIDEO,
2420 .bInterfaceSubClass = 1,
2421 .bInterfaceProtocol = 0,
2422 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
2423 /* Quanta USB2.0 HD UVC Webcam */
2424 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2425 | USB_DEVICE_ID_MATCH_INT_INFO,
2427 .idProduct = 0x4034,
2428 .bInterfaceClass = USB_CLASS_VIDEO,
2429 .bInterfaceSubClass = 1,
2430 .bInterfaceProtocol = UVC_PC_PROTOCOL_15,
2431 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
2432 /* LogiLink Wireless Webcam */
2433 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2434 | USB_DEVICE_ID_MATCH_INT_INFO,
2436 .idProduct = 0xa91a,
2437 .bInterfaceClass = USB_CLASS_VIDEO,
2438 .bInterfaceSubClass = 1,
2439 .bInterfaceProtocol = 0,
2440 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2441 /* Genius eFace 2025 */
2442 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2443 | USB_DEVICE_ID_MATCH_INT_INFO,
2445 .idProduct = 0x706e,
2446 .bInterfaceClass = USB_CLASS_VIDEO,
2447 .bInterfaceSubClass = 1,
2448 .bInterfaceProtocol = 0,
2449 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2450 /* Microsoft Lifecam NX-6000 */
2451 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2452 | USB_DEVICE_ID_MATCH_INT_INFO,
2454 .idProduct = 0x00f8,
2455 .bInterfaceClass = USB_CLASS_VIDEO,
2456 .bInterfaceSubClass = 1,
2457 .bInterfaceProtocol = 0,
2458 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2459 /* Microsoft Lifecam NX-3000 */
2460 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2461 | USB_DEVICE_ID_MATCH_INT_INFO,
2463 .idProduct = 0x0721,
2464 .bInterfaceClass = USB_CLASS_VIDEO,
2465 .bInterfaceSubClass = 1,
2466 .bInterfaceProtocol = 0,
2467 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2468 /* Microsoft Lifecam VX-7000 */
2469 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2470 | USB_DEVICE_ID_MATCH_INT_INFO,
2472 .idProduct = 0x0723,
2473 .bInterfaceClass = USB_CLASS_VIDEO,
2474 .bInterfaceSubClass = 1,
2475 .bInterfaceProtocol = 0,
2476 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2477 /* Logitech, Webcam C910 */
2478 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2479 | USB_DEVICE_ID_MATCH_INT_INFO,
2481 .idProduct = 0x0821,
2482 .bInterfaceClass = USB_CLASS_VIDEO,
2483 .bInterfaceSubClass = 1,
2484 .bInterfaceProtocol = 0,
2485 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_WAKE_AUTOSUSPEND)},
2486 /* Logitech, Webcam B910 */
2487 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2488 | USB_DEVICE_ID_MATCH_INT_INFO,
2490 .idProduct = 0x0823,
2491 .bInterfaceClass = USB_CLASS_VIDEO,
2492 .bInterfaceSubClass = 1,
2493 .bInterfaceProtocol = 0,
2494 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_WAKE_AUTOSUSPEND)},
2495 /* Logitech Quickcam Fusion */
2496 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2497 | USB_DEVICE_ID_MATCH_INT_INFO,
2499 .idProduct = 0x08c1,
2500 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2501 .bInterfaceSubClass = 1,
2502 .bInterfaceProtocol = 0 },
2503 /* Logitech Quickcam Orbit MP */
2504 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2505 | USB_DEVICE_ID_MATCH_INT_INFO,
2507 .idProduct = 0x08c2,
2508 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2509 .bInterfaceSubClass = 1,
2510 .bInterfaceProtocol = 0 },
2511 /* Logitech Quickcam Pro for Notebook */
2512 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2513 | USB_DEVICE_ID_MATCH_INT_INFO,
2515 .idProduct = 0x08c3,
2516 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2517 .bInterfaceSubClass = 1,
2518 .bInterfaceProtocol = 0 },
2519 /* Logitech Quickcam Pro 5000 */
2520 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2521 | USB_DEVICE_ID_MATCH_INT_INFO,
2523 .idProduct = 0x08c5,
2524 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2525 .bInterfaceSubClass = 1,
2526 .bInterfaceProtocol = 0 },
2527 /* Logitech Quickcam OEM Dell Notebook */
2528 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2529 | USB_DEVICE_ID_MATCH_INT_INFO,
2531 .idProduct = 0x08c6,
2532 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2533 .bInterfaceSubClass = 1,
2534 .bInterfaceProtocol = 0 },
2535 /* Logitech Quickcam OEM Cisco VT Camera II */
2536 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2537 | USB_DEVICE_ID_MATCH_INT_INFO,
2539 .idProduct = 0x08c7,
2540 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2541 .bInterfaceSubClass = 1,
2542 .bInterfaceProtocol = 0 },
2543 /* Logitech HD Pro Webcam C920 */
2544 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2545 | USB_DEVICE_ID_MATCH_INT_INFO,
2547 .idProduct = 0x082d,
2548 .bInterfaceClass = USB_CLASS_VIDEO,
2549 .bInterfaceSubClass = 1,
2550 .bInterfaceProtocol = 0,
2551 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_RESTORE_CTRLS_ON_INIT) },
2552 /* Chicony CNF7129 (Asus EEE 100HE) */
2553 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2554 | USB_DEVICE_ID_MATCH_INT_INFO,
2556 .idProduct = 0xb071,
2557 .bInterfaceClass = USB_CLASS_VIDEO,
2558 .bInterfaceSubClass = 1,
2559 .bInterfaceProtocol = 0,
2560 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_RESTRICT_FRAME_RATE) },
2561 /* Chicony EasyCamera */
2562 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2563 | USB_DEVICE_ID_MATCH_INT_INFO,
2565 .idProduct = 0xb5eb,
2566 .bInterfaceClass = USB_CLASS_VIDEO,
2567 .bInterfaceSubClass = 1,
2568 .bInterfaceProtocol = 0,
2569 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
2570 /* Chicony EasyCamera */
2571 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2572 | USB_DEVICE_ID_MATCH_INT_INFO,
2574 .idProduct = 0xb6ba,
2575 .bInterfaceClass = USB_CLASS_VIDEO,
2576 .bInterfaceSubClass = 1,
2577 .bInterfaceProtocol = 0,
2578 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
2579 /* Chicony EasyCamera */
2580 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2581 | USB_DEVICE_ID_MATCH_INT_INFO,
2583 .idProduct = 0xb746,
2584 .bInterfaceClass = USB_CLASS_VIDEO,
2585 .bInterfaceSubClass = 1,
2586 .bInterfaceProtocol = 0,
2587 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
2588 /* Alcor Micro AU3820 (Future Boy PC USB Webcam) */
2589 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2590 | USB_DEVICE_ID_MATCH_INT_INFO,
2592 .idProduct = 0x3820,
2593 .bInterfaceClass = USB_CLASS_VIDEO,
2594 .bInterfaceSubClass = 1,
2595 .bInterfaceProtocol = 0,
2596 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2597 /* Dell XPS m1530 */
2598 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2599 | USB_DEVICE_ID_MATCH_INT_INFO,
2601 .idProduct = 0x2640,
2602 .bInterfaceClass = USB_CLASS_VIDEO,
2603 .bInterfaceSubClass = 1,
2604 .bInterfaceProtocol = 0,
2605 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2606 /* Dell SP2008WFP Monitor */
2607 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2608 | USB_DEVICE_ID_MATCH_INT_INFO,
2610 .idProduct = 0x2641,
2611 .bInterfaceClass = USB_CLASS_VIDEO,
2612 .bInterfaceSubClass = 1,
2613 .bInterfaceProtocol = 0,
2614 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2615 /* Dell Alienware X51 */
2616 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2617 | USB_DEVICE_ID_MATCH_INT_INFO,
2619 .idProduct = 0x2643,
2620 .bInterfaceClass = USB_CLASS_VIDEO,
2621 .bInterfaceSubClass = 1,
2622 .bInterfaceProtocol = 0,
2623 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2624 /* Dell Studio Hybrid 140g (OmniVision webcam) */
2625 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2626 | USB_DEVICE_ID_MATCH_INT_INFO,
2628 .idProduct = 0x264a,
2629 .bInterfaceClass = USB_CLASS_VIDEO,
2630 .bInterfaceSubClass = 1,
2631 .bInterfaceProtocol = 0,
2632 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2633 /* Dell XPS M1330 (OmniVision OV7670 webcam) */
2634 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2635 | USB_DEVICE_ID_MATCH_INT_INFO,
2637 .idProduct = 0x7670,
2638 .bInterfaceClass = USB_CLASS_VIDEO,
2639 .bInterfaceSubClass = 1,
2640 .bInterfaceProtocol = 0,
2641 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2642 /* Apple Built-In iSight */
2643 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2644 | USB_DEVICE_ID_MATCH_INT_INFO,
2646 .idProduct = 0x8501,
2647 .bInterfaceClass = USB_CLASS_VIDEO,
2648 .bInterfaceSubClass = 1,
2649 .bInterfaceProtocol = 0,
2650 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_PROBE_MINMAX
2651 | UVC_QUIRK_BUILTIN_ISIGHT) },
2652 /* Apple FaceTime HD Camera (Built-In) */
2653 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2654 | USB_DEVICE_ID_MATCH_INT_INFO,
2656 .idProduct = 0x8514,
2657 .bInterfaceClass = USB_CLASS_VIDEO,
2658 .bInterfaceSubClass = 1,
2659 .bInterfaceProtocol = 0,
2660 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2661 /* Apple Built-In iSight via iBridge */
2662 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2663 | USB_DEVICE_ID_MATCH_INT_INFO,
2665 .idProduct = 0x8600,
2666 .bInterfaceClass = USB_CLASS_VIDEO,
2667 .bInterfaceSubClass = 1,
2668 .bInterfaceProtocol = 0,
2669 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2670 /* Foxlink ("HP Webcam" on HP Mini 5103) */
2671 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2672 | USB_DEVICE_ID_MATCH_INT_INFO,
2674 .idProduct = 0x0403,
2675 .bInterfaceClass = USB_CLASS_VIDEO,
2676 .bInterfaceSubClass = 1,
2677 .bInterfaceProtocol = 0,
2678 .driver_info = (kernel_ulong_t)&uvc_quirk_fix_bandwidth },
2679 /* Genesys Logic USB 2.0 PC Camera */
2680 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2681 | USB_DEVICE_ID_MATCH_INT_INFO,
2683 .idProduct = 0x0505,
2684 .bInterfaceClass = USB_CLASS_VIDEO,
2685 .bInterfaceSubClass = 1,
2686 .bInterfaceProtocol = 0,
2687 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2688 /* Hercules Classic Silver */
2689 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2690 | USB_DEVICE_ID_MATCH_INT_INFO,
2692 .idProduct = 0x300c,
2693 .bInterfaceClass = USB_CLASS_VIDEO,
2694 .bInterfaceSubClass = 1,
2695 .bInterfaceProtocol = 0,
2696 .driver_info = (kernel_ulong_t)&uvc_quirk_fix_bandwidth },
2698 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2699 | USB_DEVICE_ID_MATCH_INT_INFO,
2701 .idProduct = 0x332d,
2702 .bInterfaceClass = USB_CLASS_VIDEO,
2703 .bInterfaceSubClass = 1,
2704 .bInterfaceProtocol = 0,
2705 .driver_info = (kernel_ulong_t)&uvc_quirk_fix_bandwidth },
2706 /* ViMicro - Minoru3D */
2707 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2708 | USB_DEVICE_ID_MATCH_INT_INFO,
2710 .idProduct = 0x3410,
2711 .bInterfaceClass = USB_CLASS_VIDEO,
2712 .bInterfaceSubClass = 1,
2713 .bInterfaceProtocol = 0,
2714 .driver_info = (kernel_ulong_t)&uvc_quirk_fix_bandwidth },
2715 /* ViMicro Venus - Minoru3D */
2716 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2717 | USB_DEVICE_ID_MATCH_INT_INFO,
2719 .idProduct = 0x3420,
2720 .bInterfaceClass = USB_CLASS_VIDEO,
2721 .bInterfaceSubClass = 1,
2722 .bInterfaceProtocol = 0,
2723 .driver_info = (kernel_ulong_t)&uvc_quirk_fix_bandwidth },
2724 /* Ophir Optronics - SPCAM 620U */
2725 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2726 | USB_DEVICE_ID_MATCH_INT_INFO,
2728 .idProduct = 0x0555,
2729 .bInterfaceClass = USB_CLASS_VIDEO,
2730 .bInterfaceSubClass = 1,
2731 .bInterfaceProtocol = 0,
2732 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2734 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2735 | USB_DEVICE_ID_MATCH_INT_INFO,
2737 .idProduct = 0x0004,
2738 .bInterfaceClass = USB_CLASS_VIDEO,
2739 .bInterfaceSubClass = 1,
2740 .bInterfaceProtocol = 0,
2741 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_PROBE_MINMAX
2742 | UVC_QUIRK_PROBE_DEF) },
2743 /* IMC Networks (Medion Akoya) */
2744 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2745 | USB_DEVICE_ID_MATCH_INT_INFO,
2747 .idProduct = 0x5103,
2748 .bInterfaceClass = USB_CLASS_VIDEO,
2749 .bInterfaceSubClass = 1,
2750 .bInterfaceProtocol = 0,
2751 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2752 /* JMicron USB2.0 XGA WebCam */
2753 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2754 | USB_DEVICE_ID_MATCH_INT_INFO,
2756 .idProduct = 0x0310,
2757 .bInterfaceClass = USB_CLASS_VIDEO,
2758 .bInterfaceSubClass = 1,
2759 .bInterfaceProtocol = 0,
2760 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2761 /* Syntek (HP Spartan) */
2762 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2763 | USB_DEVICE_ID_MATCH_INT_INFO,
2765 .idProduct = 0x5212,
2766 .bInterfaceClass = USB_CLASS_VIDEO,
2767 .bInterfaceSubClass = 1,
2768 .bInterfaceProtocol = 0,
2769 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2770 /* Syntek (Samsung Q310) */
2771 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2772 | USB_DEVICE_ID_MATCH_INT_INFO,
2774 .idProduct = 0x5931,
2775 .bInterfaceClass = USB_CLASS_VIDEO,
2776 .bInterfaceSubClass = 1,
2777 .bInterfaceProtocol = 0,
2778 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2779 /* Syntek (Packard Bell EasyNote MX52 */
2780 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2781 | USB_DEVICE_ID_MATCH_INT_INFO,
2783 .idProduct = 0x8a12,
2784 .bInterfaceClass = USB_CLASS_VIDEO,
2785 .bInterfaceSubClass = 1,
2786 .bInterfaceProtocol = 0,
2787 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2788 /* Syntek (Asus F9SG) */
2789 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2790 | USB_DEVICE_ID_MATCH_INT_INFO,
2792 .idProduct = 0x8a31,
2793 .bInterfaceClass = USB_CLASS_VIDEO,
2794 .bInterfaceSubClass = 1,
2795 .bInterfaceProtocol = 0,
2796 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2797 /* Syntek (Asus U3S) */
2798 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2799 | USB_DEVICE_ID_MATCH_INT_INFO,
2801 .idProduct = 0x8a33,
2802 .bInterfaceClass = USB_CLASS_VIDEO,
2803 .bInterfaceSubClass = 1,
2804 .bInterfaceProtocol = 0,
2805 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2806 /* Syntek (JAOtech Smart Terminal) */
2807 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2808 | USB_DEVICE_ID_MATCH_INT_INFO,
2810 .idProduct = 0x8a34,
2811 .bInterfaceClass = USB_CLASS_VIDEO,
2812 .bInterfaceSubClass = 1,
2813 .bInterfaceProtocol = 0,
2814 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2816 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2817 | USB_DEVICE_ID_MATCH_INT_INFO,
2819 .idProduct = 0x0202,
2820 .bInterfaceClass = USB_CLASS_VIDEO,
2821 .bInterfaceSubClass = 1,
2822 .bInterfaceProtocol = 0,
2823 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2824 /* Lenovo Thinkpad SL400/SL500 */
2825 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2826 | USB_DEVICE_ID_MATCH_INT_INFO,
2828 .idProduct = 0x480b,
2829 .bInterfaceClass = USB_CLASS_VIDEO,
2830 .bInterfaceSubClass = 1,
2831 .bInterfaceProtocol = 0,
2832 .driver_info = (kernel_ulong_t)&uvc_quirk_stream_no_fid },
2833 /* Aveo Technology USB 2.0 Camera */
2834 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2835 | USB_DEVICE_ID_MATCH_INT_INFO,
2837 .idProduct = 0x0306,
2838 .bInterfaceClass = USB_CLASS_VIDEO,
2839 .bInterfaceSubClass = 1,
2840 .bInterfaceProtocol = 0,
2841 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_PROBE_MINMAX
2842 | UVC_QUIRK_PROBE_EXTRAFIELDS) },
2843 /* Aveo Technology USB 2.0 Camera (Tasco USB Microscope) */
2844 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2845 | USB_DEVICE_ID_MATCH_INT_INFO,
2847 .idProduct = 0x0516,
2848 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2849 .bInterfaceSubClass = 1,
2850 .bInterfaceProtocol = 0 },
2851 /* Ecamm Pico iMage */
2852 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2853 | USB_DEVICE_ID_MATCH_INT_INFO,
2855 .idProduct = 0xcafe,
2856 .bInterfaceClass = USB_CLASS_VIDEO,
2857 .bInterfaceSubClass = 1,
2858 .bInterfaceProtocol = 0,
2859 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_PROBE_EXTRAFIELDS) },
2860 /* Manta MM-353 Plako */
2861 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2862 | USB_DEVICE_ID_MATCH_INT_INFO,
2864 .idProduct = 0x3188,
2865 .bInterfaceClass = USB_CLASS_VIDEO,
2866 .bInterfaceSubClass = 1,
2867 .bInterfaceProtocol = 0,
2868 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2869 /* FSC WebCam V30S */
2870 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2871 | USB_DEVICE_ID_MATCH_INT_INFO,
2873 .idProduct = 0x3288,
2874 .bInterfaceClass = USB_CLASS_VIDEO,
2875 .bInterfaceSubClass = 1,
2876 .bInterfaceProtocol = 0,
2877 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2878 /* Arkmicro unbranded */
2879 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2880 | USB_DEVICE_ID_MATCH_INT_INFO,
2882 .idProduct = 0x3290,
2883 .bInterfaceClass = USB_CLASS_VIDEO,
2884 .bInterfaceSubClass = 1,
2885 .bInterfaceProtocol = 0,
2886 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_def },
2887 /* The Imaging Source USB CCD cameras */
2888 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2889 | USB_DEVICE_ID_MATCH_INT_INFO,
2891 .idProduct = 0x8102,
2892 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2893 .bInterfaceSubClass = 1,
2894 .bInterfaceProtocol = 0 },
2895 /* Bodelin ProScopeHR */
2896 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2897 | USB_DEVICE_ID_MATCH_DEV_HI
2898 | USB_DEVICE_ID_MATCH_INT_INFO,
2900 .idProduct = 0x1000,
2901 .bcdDevice_hi = 0x0126,
2902 .bInterfaceClass = USB_CLASS_VIDEO,
2903 .bInterfaceSubClass = 1,
2904 .bInterfaceProtocol = 0,
2905 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_STATUS_INTERVAL) },
2906 /* MSI StarCam 370i */
2907 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2908 | USB_DEVICE_ID_MATCH_INT_INFO,
2910 .idProduct = 0x2951,
2911 .bInterfaceClass = USB_CLASS_VIDEO,
2912 .bInterfaceSubClass = 1,
2913 .bInterfaceProtocol = 0,
2914 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2915 /* Generalplus Technology Inc. 808 Camera */
2916 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2917 | USB_DEVICE_ID_MATCH_INT_INFO,
2919 .idProduct = 0x2002,
2920 .bInterfaceClass = USB_CLASS_VIDEO,
2921 .bInterfaceSubClass = 1,
2922 .bInterfaceProtocol = 0,
2923 .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },
2924 /* Shenzhen Aoni Electronic Co.,Ltd 2K FHD camera */
2925 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2926 | USB_DEVICE_ID_MATCH_INT_INFO,
2928 .idProduct = 0x0b40,
2929 .bInterfaceClass = USB_CLASS_VIDEO,
2930 .bInterfaceSubClass = 1,
2931 .bInterfaceProtocol = 0,
2932 .driver_info = (kernel_ulong_t)&(const struct uvc_device_info){
2933 .uvc_version = 0x010a,
2935 /* SiGma Micro USB Web Camera */
2936 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2937 | USB_DEVICE_ID_MATCH_INT_INFO,
2939 .idProduct = 0x3000,
2940 .bInterfaceClass = USB_CLASS_VIDEO,
2941 .bInterfaceSubClass = 1,
2942 .bInterfaceProtocol = 0,
2943 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_PROBE_MINMAX
2944 | UVC_QUIRK_IGNORE_SELECTOR_UNIT) },
2945 /* Oculus VR Positional Tracker DK2 */
2946 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2947 | USB_DEVICE_ID_MATCH_INT_INFO,
2949 .idProduct = 0x0201,
2950 .bInterfaceClass = USB_CLASS_VIDEO,
2951 .bInterfaceSubClass = 1,
2952 .bInterfaceProtocol = 0,
2953 .driver_info = (kernel_ulong_t)&uvc_quirk_force_y8 },
2954 /* Oculus VR Rift Sensor */
2955 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2956 | USB_DEVICE_ID_MATCH_INT_INFO,
2958 .idProduct = 0x0211,
2959 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
2960 .bInterfaceSubClass = 1,
2961 .bInterfaceProtocol = 0,
2962 .driver_info = (kernel_ulong_t)&uvc_quirk_force_y8 },
2963 /* GEO Semiconductor GC6500 */
2964 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2965 | USB_DEVICE_ID_MATCH_INT_INFO,
2967 .idProduct = 0x4d53,
2968 .bInterfaceClass = USB_CLASS_VIDEO,
2969 .bInterfaceSubClass = 1,
2970 .bInterfaceProtocol = 0,
2971 .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_FORCE_BPP) },
2972 /* Lenovo Integrated Camera */
2973 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2974 | USB_DEVICE_ID_MATCH_INT_INFO,
2976 .idProduct = 0x0093,
2977 .bInterfaceClass = USB_CLASS_VIDEO,
2978 .bInterfaceSubClass = 1,
2979 .bInterfaceProtocol = UVC_PC_PROTOCOL_15,
2980 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_uvc11 },
2981 /* Sonix Technology USB 2.0 Camera */
2982 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2983 | USB_DEVICE_ID_MATCH_INT_INFO,
2985 .idProduct = 0x0072,
2986 .bInterfaceClass = USB_CLASS_VIDEO,
2987 .bInterfaceSubClass = 1,
2988 .bInterfaceProtocol = 0,
2989 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
2990 /* Acer EasyCamera */
2991 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2992 | USB_DEVICE_ID_MATCH_INT_INFO,
2994 .idProduct = 0x1172,
2995 .bInterfaceClass = USB_CLASS_VIDEO,
2996 .bInterfaceSubClass = 1,
2997 .bInterfaceProtocol = 0,
2998 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
2999 /* Acer EasyCamera */
3000 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
3001 | USB_DEVICE_ID_MATCH_INT_INFO,
3003 .idProduct = 0x1180,
3004 .bInterfaceClass = USB_CLASS_VIDEO,
3005 .bInterfaceSubClass = 1,
3006 .bInterfaceProtocol = 0,
3007 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
3008 /* Acer EasyCamera */
3009 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
3010 | USB_DEVICE_ID_MATCH_INT_INFO,
3012 .idProduct = 0x1180,
3013 .bInterfaceClass = USB_CLASS_VIDEO,
3014 .bInterfaceSubClass = 1,
3015 .bInterfaceProtocol = 0,
3016 .driver_info = (kernel_ulong_t)&uvc_ctrl_power_line_limited },
3017 /* Intel RealSense D4M */
3018 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
3019 | USB_DEVICE_ID_MATCH_INT_INFO,
3021 .idProduct = 0x0b03,
3022 .bInterfaceClass = USB_CLASS_VIDEO,
3023 .bInterfaceSubClass = 1,
3024 .bInterfaceProtocol = 0,
3025 .driver_info = UVC_INFO_META(V4L2_META_FMT_D4XX) },
3026 /* Generic USB Video Class */
3027 { USB_INTERFACE_INFO(USB_CLASS_VIDEO, 1, UVC_PC_PROTOCOL_UNDEFINED) },
3028 { USB_INTERFACE_INFO(USB_CLASS_VIDEO, 1, UVC_PC_PROTOCOL_15) },
3032 MODULE_DEVICE_TABLE(usb, uvc_ids);
3034 struct uvc_driver uvc_driver = {
3038 .disconnect = uvc_disconnect,
3039 .suspend = uvc_suspend,
3040 .resume = uvc_resume,
3041 .reset_resume = uvc_reset_resume,
3042 .id_table = uvc_ids,
3043 .supports_autosuspend = 1,
3047 static int __init uvc_init(void)
3053 ret = usb_register(&uvc_driver.driver);
3055 uvc_debugfs_cleanup();
3062 static void __exit uvc_cleanup(void)
3064 usb_deregister(&uvc_driver.driver);
3065 uvc_debugfs_cleanup();
3068 module_init(uvc_init);
3069 module_exit(uvc_cleanup);
3071 MODULE_AUTHOR(DRIVER_AUTHOR);
3072 MODULE_DESCRIPTION(DRIVER_DESC);
3073 MODULE_LICENSE("GPL");
3074 MODULE_VERSION(DRIVER_VERSION);