UVC 摄像头驱动(二)描述符分析
当一个 usb 设备接入时,usb 主机控制器会与设备交互,读取出设备的所有的描述符,并且调用相应 usb_driver 的 probe 函数,同时传入一个接口的指针,因为一个接口代表一个逻辑上的 usb 设备。如果 usb 设备含有多个接口,同时都被这个 usb_driver 支持的话,probe 函数就会被调用多次。
对于一个 usb 设备来说,首先它有一个设备描述符,一个设备可能会拥有多个配置,每一个配置都拥有一个配置描述符,配置可以理解成多个接口的组合。那么一个配置会拥有多个接口,每一个接口会拥有一个接口描述符,同时一个接口又会有多个设置,设置可以理解成多个端点的组合,每一个端点拥有一个端点描述符。关于详细的设备、配置、接口、设置、端点之间的关系请参考我之前的文章《USB驱动——设备、配置、接口、设置、端点之前的关系以及它们的获取过程分析》那么对于 usb video class 它在标准的 usb 协议上进行了扩展,扩展的部分称为 class specific ,完整的关系如下图所示:
在 UVC 1.5 Class specification 的第三章,有专门对 UVC 的描述符进行解释,在第 3.1 节,给出了一个完整uvc设备描述符的布局如下图所示:
其中,Device 等白色的描述符为标准描述符,灰色是 class specific 描述符。
IAD Interface Association Descriptor
一个设备需要用一个联合接口描述符(IAD)来描述一个视频接口集合,对于每一个设备功能需要一个视频控制接口(VideoControl Interface)和一个或者多个视频流接口(VideoStreaming Interface)。标准的视频接口联合描述符和标准接口联合描述符定义相同。在代码中,它体现在“配置”中。
struct usb_host_config { struct usb_config_descriptor desc; // 配置描述符 char *string; struct usb_interface_assoc_descriptor *intf_assoc[USB_MAXIADS];//IADstruct usb_interface *interface[USB_MAXINTERFACES]; // 接口 struct usb_interface_cache *intf_cache[USB_MAXINTERFACES]; unsigned char *extra; int extralen;
};
那么这个联合接口描述符(IAD)有什么含义呢?
举例:
Interface Association:bLength 8bDescriptorType 11bFirstInterface 0bInterfaceCount 2bFunctionClass 14 VideobFunctionSubClass 3 Video Interface CollectionbFunctionProtocol 0 iFunction
该接口联合描述符中表明了,它是两个接口的集合,起始接口为 0 ,其实没啥意义。大致可以知道是一个控制接口和一个流接口。
VideoControl Interface Descriptors
它包含两部分,一个是白色标准视频控制接口描述符,其余的灰色是UVC类特殊的视频控制接口描述符。
Standard VC Interface Descriptor
标准 VC 接口描述符和标准接口描述符的定义是一样的,定义在 section 9.6.5 “Interface” of USB Specification Revision 2.0 。代码中,它包含在接口的设置里。
struct usb_host_interface { struct usb_interface_descriptor desc; // 接口描述符 struct usb_host_endpoint *endpoint; char *string; /* iInterface string, if present */ unsigned char *extra; /* Class-Specific VC Interface Descriptor */ int extralen;
};
举例:
Interface Descriptor:bLength 9bDescriptorType 4bInterfaceNumber 0bAlternateSetting 0bNumEndpoints 1bInterfaceClass 14 VideobInterfaceSubClass 1 Video ControlbInterfaceProtocol 0 iInterface 2
主要信息:这是第0号接口,是一个 video_control 接口。
Class-Specific VC Interface Descriptor
UVC 类特殊接口描述符是一连串的描述符,它包含了所有用来描述设备功能的描述符,比如 unit 和 terminal 描述符。它和标准接口描述符为与同一个结构体里。
struct usb_host_interface { struct usb_interface_descriptor desc; // 接口描述符 struct usb_host_endpoint *endpoint; char *string; /* iInterface string, if present */ unsigned char *extra; /* Class-Specific VC Interface Descriptor */ int extralen; /* lenth of Class-Specific VC Interface Descriptor */
};
举例:
VideoControl Interface Descriptor:bLength 13bDescriptorType 36bDescriptorSubtype 1 (HEADER)bcdUVC 1.00wTotalLength 109dwClockFrequency 48.000000MHzbInCollection 1baInterfaceNr( 0) 1VideoControl Interface Descriptor:bLength 18bDescriptorType 36bDescriptorSubtype 2 (INPUT_TERMINAL)bTerminalID 1wTerminalType 0x0201 Camera SensorbAssocTerminal 0iTerminal 0 wObjectiveFocalLengthMin 0wObjectiveFocalLengthMax 0wOcularFocalLength 0bControlSize 3bmControls 0x00000006Auto-Exposure ModeAuto-Exposure PriorityVideoControl Interface Descriptor:bLength 11bDescriptorType 36bDescriptorSubtype 5 (PROCESSING_UNIT)Warning: Descriptor too shortbUnitID 2bSourceID 1wMaxMultiplier 16384bControlSize 2bmControls 0x0000153fBrightnessContrastHueSaturationSharpnessGammaBacklight CompensationPower Line FrequencyWhite Balance Temperature, AutoiProcessing 0 bmVideoStandards 0x1dNonePAL - 625/50SECAM - 625/50NTSC - 625/50VideoControl Interface Descriptor:bLength 29bDescriptorType 36bDescriptorSubtype 6 (EXTENSION_UNIT)bUnitID 3guidExtensionCode {82066163-7050-ab49-b8cc-b3855e8d221d}bNumControl 0bNrPins 1baSourceID( 0) 2bControlSize 4bmControls( 0) 0xffbmControls( 1) 0xffbmControls( 2) 0x1dbmControls( 3) 0x00iExtension 0 VideoControl Interface Descriptor:bLength 29bDescriptorType 36bDescriptorSubtype 6 (EXTENSION_UNIT)bUnitID 4guidExtensionCode {64e7c624-515f-7e43-9089-28ffa487bdca}bNumControl 0bNrPins 1baSourceID( 0) 3bControlSize 4bmControls( 0) 0x0fbmControls( 1) 0x00bmControls( 2) 0x00bmControls( 3) 0x00iExtension 0 VideoControl Interface Descriptor:bLength 9bDescriptorType 36bDescriptorSubtype 3 (OUTPUT_TERMINAL)bTerminalID 5wTerminalType 0x0101 USB StreamingbAssocTerminal 0bSourceID 4iTerminal 0 Endpoint Descriptor:bLength 7bDescriptorType 5bEndpointAddress 0x87 EP 7 INbmAttributes 3Transfer Type InterruptSynch Type NoneUsage Type DatawMaxPacketSize 0x0010 1x 16 bytesbInterval 8
根据上面的信息,控制接口描述符有很多子类,前面在摄像头硬件描述中,我们说在控制接口中抽象出了两个概念,一个是 unit 另一个 terminal ,unit 和 terminal 的信息就包含在这些描述符信息中了。它们直连的链接关系可以通过描述符中的 bSourceID 或者 baSourceID 来分析,比如这款摄像头,它的硬件模型就是:
IT -> PU ->EU -> EU ->OT 具体的描述符含义,参考 UVC 1.5 Class specification Table 3-3 到 3-10 .这里只分析一下 header 描述符。
在 header 描述符的第11位,bInCollection 指出了该设备拥有的VS接口的数量,从第12位起,是每一个 VS 接口的接口号。
VC Interrupt Endpoint Descriptors
中断端点描述符也分为标准中断端点描述符和UVC类特殊的中断端点描述符
- Standard VC Interrupt Endpoint Descriptor
- Class-specific VC Interrupt Endpoint Descriptor
它们在代码中位于 “端点”中:
struct usb_host_endpoint { struct usb_endpoint_descriptor desc; // 端点描述符 struct list_head urb_list; // 该端点的 urb 队列 void *hcpriv; struct ep_device *ep_dev; /* For sysfs info */ struct usb_host_ss_ep_comp *ss_ep_comp; /* For SS devices */ unsigned char *extra;/* Class-specific VC Interrupt Endpoint Descriptor */ int extralen;/* lenth of Class-specific VC Interrupt Endpoint Descriptor */ int enabled;
};
具体的定义与说明参考:
UVC 1.5 Class specification Table 3-11
UVC 1.5 Class specification Table 3-12
VideoStreaming Interface Descriptors
视频流接口描述符包含了所有用来描述视频流接口特性的相关信息。
Standard VS Interface Descriptor
标准视频流接口描述符和标准接口描述符的定义相同,在section 9.6.5 “Interface” of USB Specification Revision 2.0 or USB Specification Revision 3.0 中定义.
举例:
Interface Descriptor:bLength 9bDescriptorType 4bInterfaceNumber 1bAlternateSetting 0bNumEndpoints 0bInterfaceClass 14 VideobInterfaceSubClass 2 Video StreamingbInterfaceProtocol 0 iInterface 0
主要信息,它是第1号接口,接口类型是 video_streaming
Class-Specific VS Interface Descriptors
UVC 类特殊视频流接口由 input header 、oupt header 、format 和 frame 描述符组成,每一个视频流接口都有一个单独的 input 或者 output header 描述符,对于它支持的每一个 format 都有一个单独的 format 描述符,对于每一个 format 描述符如果需要的话会包含多个 frame 描述符。format 和 frame 描述符仅仅会定义在接口的第0号设置中。
定义参考:
Table 3-14 Class-specific VS Interface Input Header Descriptor
USB_Video_Payload_Uncompressed_1.5
USB_Video_Payload_MJPEG_1.5
USB_Video_Payload_Frame_Based_1.5
举例:
VideoStreaming Interface Descriptor:bLength 15bDescriptorType 36bDescriptorSubtype 1 (INPUT_HEADER)bNumFormats 2wTotalLength 525bEndPointAddress 129bmInfo 0bTerminalLink 5bStillCaptureMethod 1bTriggerSupport 1bTriggerUsage 0bControlSize 1bmaControls( 0) 27bmaControls( 1) 27VideoStreaming Interface Descriptor:bLength 27bDescriptorType 36bDescriptorSubtype 4 (FORMAT_UNCOMPRESSED)bFormatIndex 1bNumFrameDescriptors 7guidFormat {59555932-0000-1000-8000-00aa00389b71}bBitsPerPixel 16bDefaultFrameIndex 1bAspectRatioX 0bAspectRatioY 0bmInterlaceFlags 0x00Interlaced stream or variable: NoFields per frame: 2 fieldsField 1 first: NoField pattern: Field 1 onlybCopyProtect 0VideoStreaming Interface Descriptor:bLength 34bDescriptorType 36bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)bFrameIndex 1bmCapabilities 0x01Still image supportedwWidth 640wHeight 480dwMinBitRate 73728000dwMaxBitRate 147456000dwMaxVideoFrameBufferSize 614400dwDefaultFrameInterval 333333bFrameIntervalType 2dwFrameInterval( 0) 333333dwFrameInterval( 1) 666666VideoStreaming Interface Descriptor:bLength 34bDescriptorType 36bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)bFrameIndex 2bmCapabilities 0x01Still image supportedwWidth 160wHeight 120dwMinBitRate 4608000dwMaxBitRate 9216000dwMaxVideoFrameBufferSize 38400dwDefaultFrameInterval 333333bFrameIntervalType 2dwFrameInterval( 0) 333333dwFrameInterval( 1) 666666VideoStreaming Interface Descriptor:bLength 34bDescriptorType 36bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)bFrameIndex 3bmCapabilities 0x01Still image supportedwWidth 176wHeight 144dwMinBitRate 6082560dwMaxBitRate 12165120dwMaxVideoFrameBufferSize 50688dwDefaultFrameInterval 333333bFrameIntervalType 2dwFrameInterval( 0) 333333dwFrameInterval( 1) 666666VideoStreaming Interface Descriptor:bLength 34bDescriptorType 36bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)bFrameIndex 4bmCapabilities 0x01Still image supportedwWidth 320wHeight 240dwMinBitRate 18432000dwMaxBitRate 36864000dwMaxVideoFrameBufferSize 153600dwDefaultFrameInterval 333333bFrameIntervalType 2dwFrameInterval( 0) 333333dwFrameInterval( 1) 666666VideoStreaming Interface Descriptor:bLength 34bDescriptorType 36bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)bFrameIndex 5bmCapabilities 0x01Still image supportedwWidth 352wHeight 288dwMinBitRate 24330240dwMaxBitRate 48660480dwMaxVideoFrameBufferSize 202752dwDefaultFrameInterval 333333bFrameIntervalType 2dwFrameInterval( 0) 333333dwFrameInterval( 1) 666666VideoStreaming Interface Descriptor:bLength 30bDescriptorType 36bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)bFrameIndex 6bmCapabilities 0x01Still image supportedwWidth 1280wHeight 720dwMinBitRate 147456000dwMaxBitRate 147456000dwMaxVideoFrameBufferSize 1843200dwDefaultFrameInterval 1000000bFrameIntervalType 1dwFrameInterval( 0) 1000000VideoStreaming Interface Descriptor:bLength 30bDescriptorType 36bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)bFrameIndex 7bmCapabilities 0x01Still image supportedwWidth 1280wHeight 800dwMinBitRate 163840000dwMaxBitRate 163840000dwMaxVideoFrameBufferSize 2048000dwDefaultFrameInterval 1000000bFrameIntervalType 1dwFrameInterval( 0) 1000000VideoStreaming Interface Descriptor:bLength 6bDescriptorType 36bDescriptorSubtype 13 (COLORFORMAT)bColorPrimaries 1 (BT.709,sRGB)bTransferCharacteristics 1 (BT.709)bMatrixCoefficients 4 (SMPTE 170M (BT.601))VideoStreaming Interface Descriptor:bLength 11bDescriptorType 36bDescriptorSubtype 6 (FORMAT_MJPEG)bFormatIndex 2bNumFrameDescriptors 7bFlags 1Fixed-size samples: YesbDefaultFrameIndex 1bAspectRatioX 0bAspectRatioY 0bmInterlaceFlags 0x00Interlaced stream or variable: NoFields per frame: 1 fieldsField 1 first: NoField pattern: Field 1 onlybCopyProtect 0VideoStreaming Interface Descriptor:bLength 34bDescriptorType 36bDescriptorSubtype 7 (FRAME_MJPEG)bFrameIndex 1bmCapabilities 0x01Still image supportedwWidth 640wHeight 480dwMinBitRate 73728000dwMaxBitRate 147456000dwMaxVideoFrameBufferSize 614400dwDefaultFrameInterval 333333bFrameIntervalType 2dwFrameInterval( 0) 333333dwFrameInterval( 1) 666666VideoStreaming Interface Descriptor:bLength 34bDescriptorType 36bDescriptorSubtype 7 (FRAME_MJPEG)bFrameIndex 2bmCapabilities 0x01Still image supportedwWidth 160wHeight 120dwMinBitRate 4608000dwMaxBitRate 9216000dwMaxVideoFrameBufferSize 38400dwDefaultFrameInterval 333333bFrameIntervalType 2dwFrameInterval( 0) 333333dwFrameInterval( 1) 666666VideoStreaming Interface Descriptor:bLength 34bDescriptorType 36bDescriptorSubtype 7 (FRAME_MJPEG)bFrameIndex 3bmCapabilities 0x01Still image supportedwWidth 176wHeight 144dwMinBitRate 6082560dwMaxBitRate 12165120dwMaxVideoFrameBufferSize 50688dwDefaultFrameInterval 333333bFrameIntervalType 2dwFrameInterval( 0) 333333dwFrameInterval( 1) 666666VideoStreaming Interface Descriptor:bLength 34bDescriptorType 36bDescriptorSubtype 7 (FRAME_MJPEG)bFrameIndex 4bmCapabilities 0x01Still image supportedwWidth 320wHeight 240dwMinBitRate 18432000dwMaxBitRate 36864000dwMaxVideoFrameBufferSize 153600dwDefaultFrameInterval 333333bFrameIntervalType 2dwFrameInterval( 0) 333333dwFrameInterval( 1) 666666VideoStreaming Interface Descriptor:bLength 34bDescriptorType 36bDescriptorSubtype 7 (FRAME_MJPEG)bFrameIndex 5bmCapabilities 0x01Still image supportedwWidth 352wHeight 288dwMinBitRate 24330240dwMaxBitRate 48660480dwMaxVideoFrameBufferSize 202752dwDefaultFrameInterval 333333bFrameIntervalType 2dwFrameInterval( 0) 333333dwFrameInterval( 1) 666666VideoStreaming Interface Descriptor:bLength 30bDescriptorType 36bDescriptorSubtype 7 (FRAME_MJPEG)bFrameIndex 6bmCapabilities 0x01Still image supportedwWidth 1280wHeight 720dwMinBitRate 442368000dwMaxBitRate 442368000dwMaxVideoFrameBufferSize 1843200dwDefaultFrameInterval 333333bFrameIntervalType 1dwFrameInterval( 0) 333333VideoStreaming Interface Descriptor:bLength 30bDescriptorType 36bDescriptorSubtype 7 (FRAME_MJPEG)bFrameIndex 7bmCapabilities 0x01Still image supportedwWidth 1280wHeight 800dwMinBitRate 491520000dwMaxBitRate 491520000dwMaxVideoFrameBufferSize 2048000dwDefaultFrameInterval 333333bFrameIntervalType 1dwFrameInterval( 0) 333333VideoStreaming Interface Descriptor:bLength 6bDescriptorType 36bDescriptorSubtype 13 (COLORFORMAT)bColorPrimaries 1 (BT.709,sRGB)bTransferCharacteristics 1 (BT.709)bMatrixCoefficients 4 (SMPTE 170M (BT.601))
可以看到,这款摄像头支持两种 format 一种是未压缩的,另一种是压缩的 MJPEG ,对于每一个 format 下面又有多个 frame ,frame 的区别比如像素大小。
VideoStreaming Endpoint Descriptors
The following sections describe all possible endpoint-related descriptors for the VideoStreaming
interface.
VS Video Data Endpoint Descriptors
Standard VS Isochronous Video Data Endpoint Descriptor
Table 3-20 Standard VS Isochronous Video Data Endpoint Descriptor
Standard VS Bulk Video Data Endpoint Descriptor
Table 3-21 Standard VS Bulk Video Data Endpoint Descriptor
VS Bulk Still Image Data Endpoint Descriptors
Standard VS Bulk Still Image Data Endpoint Descriptor
Table 3-22 Standard VS Bulk Still Image Data Endpoint Descriptor
打印描述符
根据上述的分析过程,我们可以把所有的描述符信息打印出来,前面举例是lsusb 打印出来的信息,那么,为了方便,我们可以参考 lsusb 的源码来写打印程序。
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/usb.h>
#include <linux/videodev2.h>
#include <linux/vmalloc.h>
#include <linux/wait.h>
#include <asm/atomic.h>
#include <asm/unaligned.h>#include <media/v4l2-common.h>static const char *get_guid(const unsigned char *buf)
{static char guid[39];/* NOTE: see RFC 4122 for more information about GUID/UUID* structure. The first fields fields are historically big* endian numbers, dating from Apollo mc68000 workstations.*/sprintf(guid, "{%02x%02x%02x%02x""-%02x%02x""-%02x%02x""-%02x%02x""-%02x%02x%02x%02x%02x%02x}",buf[0], buf[1], buf[2], buf[3],buf[4], buf[5],buf[6], buf[7],buf[8], buf[9],buf[10], buf[11], buf[12], buf[13], buf[14], buf[15]);return guid;
}static void parse_videocontrol_interface(struct usb_interface *intf, unsigned char *buf, int buflen)
{static const char * const ctrlnames[] = {"Brightness", "Contrast", "Hue", "Saturation", "Sharpness", "Gamma","White Balance Temperature", "White Balance Component", "Backlight Compensation","Gain", "Power Line Frequency", "Hue, Auto", "White Balance Temperature, Auto","White Balance Component, Auto", "Digital Multiplier", "Digital Multiplier Limit","Analog Video Standard", "Analog Video Lock Status"};static const char * const camctrlnames[] = {"Scanning Mode", "Auto-Exposure Mode", "Auto-Exposure Priority","Exposure Time (Absolute)", "Exposure Time (Relative)", "Focus (Absolute)","Focus (Relative)", "Iris (Absolute)", "Iris (Relative)", "Zoom (Absolute)","Zoom (Relative)", "PanTilt (Absolute)", "PanTilt (Relative)","Roll (Absolute)", "Roll (Relative)", "Reserved", "Reserved", "Focus, Auto","Privacy"};static const char * const stdnames[] = {"None", "NTSC - 525/60", "PAL - 625/50", "SECAM - 625/50","NTSC - 625/50", "PAL - 525/60" };unsigned int i, ctrls, stds, n, p, termt, freq;while (buflen > 0){if (buf[1] != USB_DT_CS_INTERFACE)printk(" Warning: Invalid descriptor\n");else if (buf[0] < 3)printk(" Warning: Descriptor too short\n");printk(" VideoControl Interface Descriptor:\n"" bLength %5u\n"" bDescriptorType %5u\n"" bDescriptorSubtype %5u ",buf[0], buf[1], buf[2]);switch (buf[2]) {case 0x01: /* HEADER */printk("(HEADER)\n");n = buf[11];if (buf[0] < 12+n)printk(" Warning: Descriptor too short\n");freq = buf[7] | (buf[8] << 8) | (buf[9] << 16) | (buf[10] << 24);printk(" bcdUVC %2x.%02x\n"" wTotalLength %5u\n"" dwClockFrequency %5u.%06uMHz\n"" bInCollection %5u\n",buf[4], buf[3], buf[5] | (buf[6] << 8), freq / 1000000,freq % 1000000, n);for (i = 0; i < n; i++)printk(" baInterfaceNr(%2u) %5u\n", i, buf[12+i]);break;case 0x02: /* INPUT_TERMINAL */printk("(INPUT_TERMINAL)\n");termt = buf[4] | (buf[5] << 8);n = termt == 0x0201 ? 7 : 0;if (buf[0] < 8 + n)printk(" Warning: Descriptor too short\n");printk(" bTerminalID %5u\n"" wTerminalType 0x%04x\n"" bAssocTerminal %5u\n",buf[3], termt, buf[6]);printk(" iTerminal %5u\n",buf[7]);if (termt == 0x0201) {n += buf[14];printk(" wObjectiveFocalLengthMin %5u\n"" wObjectiveFocalLengthMax %5u\n"" wOcularFocalLength %5u\n"" bControlSize %5u\n",buf[8] | (buf[9] << 8), buf[10] | (buf[11] << 8),buf[12] | (buf[13] << 8), buf[14]);ctrls = 0;for (i = 0; i < 3 && i < buf[14]; i++)ctrls = (ctrls << 8) | buf[8+n-i-1];printk(" bmControls 0x%08x\n", ctrls);for (i = 0; i < 19; i++)if ((ctrls >> i) & 1)printk(" %s\n", camctrlnames[i]);}break;case 0x03: /* OUTPUT_TERMINAL */printk("(OUTPUT_TERMINAL)\n");termt = buf[4] | (buf[5] << 8);if (buf[0] < 9)printk(" Warning: Descriptor too short\n");printk(" bTerminalID %5u\n"" wTerminalType 0x%04x\n"" bAssocTerminal %5u\n"" bSourceID %5u\n"" iTerminal %5u\n",buf[3], termt, buf[6], buf[7], buf[8]);break;case 0x04: /* SELECTOR_UNIT */printk("(SELECTOR_UNIT)\n");p = buf[4];if (buf[0] < 6+p)printk(" Warning: Descriptor too short\n");printk(" bUnitID %5u\n"" bNrInPins %5u\n",buf[3], p);for (i = 0; i < p; i++)printk(" baSource(%2u) %5u\n", i, buf[5+i]);printk(" iSelector %5u\n",buf[5+p]);break;case 0x05: /* PROCESSING_UNIT */printk("(PROCESSING_UNIT)\n");n = buf[7];if (buf[0] < 10+n)printk(" Warning: Descriptor too short\n");printk(" bUnitID %5u\n"" bSourceID %5u\n"" wMaxMultiplier %5u\n"" bControlSize %5u\n",buf[3], buf[4], buf[5] | (buf[6] << 8), n);ctrls = 0;for (i = 0; i < 3 && i < n; i++)ctrls = (ctrls << 8) | buf[8+n-i-1];printk(" bmControls 0x%08x\n", ctrls);for (i = 0; i < 18; i++)if ((ctrls >> i) & 1)printk(" %s\n", ctrlnames[i]);stds = buf[9+n];printk(" iProcessing %5u\n"" bmVideoStandards 0x%2x\n", buf[8+n], stds);for (i = 0; i < 6; i++)if ((stds >> i) & 1)printk(" %s\n", stdnames[i]);break;case 0x06: /* EXTENSION_UNIT */printk("(EXTENSION_UNIT)\n");p = buf[21];n = buf[22+p];if (buf[0] < 24+p+n)printk(" Warning: Descriptor too short\n");printk(" bUnitID %5u\n"" guidExtensionCode %s\n"" bNumControl %5u\n"" bNrPins %5u\n",buf[3], get_guid(&buf[4]), buf[20], buf[21]);for (i = 0; i < p; i++)printk(" baSourceID(%2u) %5u\n", i, buf[22+i]);printk(" bControlSize %5u\n", buf[22+p]);for (i = 0; i < n; i++)printk(" bmControls(%2u) 0x%02x\n", i, buf[23+p+i]);printk(" iExtension %5u\n",buf[23+p+n]);break;default:printk("(unknown)\n"" Invalid desc subtype:");break;}buflen -= buf[0];buf += buf[0];}
}static void parse_videostreaming_interface(struct usb_interface *intf, unsigned char *buf, int buflen)
{static const char * const colorPrims[] = { "Unspecified", "BT.709,sRGB","BT.470-2 (M)", "BT.470-2 (B,G)", "SMPTE 170M", "SMPTE 240M" };static const char * const transferChars[] = { "Unspecified", "BT.709","BT.470-2 (M)", "BT.470-2 (B,G)", "SMPTE 170M", "SMPTE 240M","Linear", "sRGB"};static const char * const matrixCoeffs[] = { "Unspecified", "BT.709","FCC", "BT.470-2 (B,G)", "SMPTE 170M (BT.601)", "SMPTE 240M" };unsigned int i, m, n, p, flags, len;while (buflen > 0){if (buf[1] != USB_DT_CS_INTERFACE)printk(" Warning: Invalid descriptor\n");else if (buf[0] < 3)printk(" Warning: Descriptor too short\n");printk(" VideoStreaming Interface Descriptor:\n"" bLength %5u\n"" bDescriptorType %5u\n"" bDescriptorSubtype %5u ",buf[0], buf[1], buf[2]);switch (buf[2]) {case 0x01: /* INPUT_HEADER */printk("(INPUT_HEADER)\n");p = buf[3];n = buf[12];if (buf[0] < 13+p*n)printk(" Warning: Descriptor too short\n");printk(" bNumFormats %5u\n"" wTotalLength %5u\n"" bEndPointAddress %5u\n"" bmInfo %5u\n"" bTerminalLink %5u\n"" bStillCaptureMethod %5u\n"" bTriggerSupport %5u\n"" bTriggerUsage %5u\n"" bControlSize %5u\n",p, buf[4] | (buf[5] << 8), buf[6], buf[7], buf[8],buf[9], buf[10], buf[11], n);for (i = 0; i < p; i++)printk(" bmaControls(%2u) %5u\n",i, buf[13+p*n]);break;case 0x02: /* OUTPUT_HEADER */printk("(OUTPUT_HEADER)\n");p = buf[3];n = buf[8];if (buf[0] < 9+p*n)printk(" Warning: Descriptor too short\n");printk(" bNumFormats %5u\n"" wTotalLength %5u\n"" bEndpointAddress %5u\n"" bTerminalLink %5u\n"" bControlSize %5u\n",p, buf[4] | (buf[5] << 8), buf[6], buf[7], n);for (i = 0; i < p; i++)printk(" bmaControls(%2u) %5u\n",i, buf[9+p*n]);break;case 0x03: /* STILL_IMAGE_FRAME */printk("(STILL_IMAGE_FRAME)\n");n = buf[4];m = buf[5+4*n];if (buf[0] < 6+4*n+m)printk(" Warning: Descriptor too short\n");printk(" bEndpointAddress %5u\n"" bNumImageSizePatterns %3u\n",buf[3], n);for (i = 0; i < n; i++)printk(" wWidth(%2u) %5u\n"" wHeight(%2u) %5u\n",i, buf[5+4*i] | (buf[6+4*i] << 8),i, buf[7+4*i] | (buf[8+4*i] << 8));printk(" bNumCompressionPatterns %3u\n", n);for (i = 0; i < m; i++)printk(" bCompression(%2u) %5u\n",i, buf[6+4*n+i]);break;case 0x04: /* FORMAT_UNCOMPRESSED */case 0x10: /* FORMAT_FRAME_BASED */if (buf[2] == 0x04) {printk("(FORMAT_UNCOMPRESSED)\n");len = 27;} else {printk("(FORMAT_FRAME_BASED)\n");len = 28;}if (buf[0] < len)printk(" Warning: Descriptor too short\n");flags = buf[25];printk(" bFormatIndex %5u\n"" bNumFrameDescriptors %5u\n"" guidFormat %s\n"" bBitsPerPixel %5u\n"" bDefaultFrameIndex %5u\n"" bAspectRatioX %5u\n"" bAspectRatioY %5u\n"" bmInterlaceFlags 0x%02x\n",buf[3], buf[4], get_guid(&buf[5]), buf[21], buf[22],buf[23], buf[24], flags);printk(" Interlaced stream or variable: %s\n",(flags & (1 << 0)) ? "Yes" : "No");printk(" Fields per frame: %u fields\n",(flags & (1 << 1)) ? 1 : 2);printk(" Field 1 first: %s\n",(flags & (1 << 2)) ? "Yes" : "No");printk(" Field pattern: ");switch ((flags >> 4) & 0x03) {case 0:printk("Field 1 only\n");break;case 1:printk("Field 2 only\n");break;case 2:printk("Regular pattern of fields 1 and 2\n");break;case 3:printk("Random pattern of fields 1 and 2\n");break;}printk(" bCopyProtect %5u\n", buf[26]);if (buf[2] == 0x10)printk(" bVariableSize %5u\n", buf[27]);break;case 0x05: /* FRAME UNCOMPRESSED */case 0x07: /* FRAME_MJPEG */case 0x11: /* FRAME_FRAME_BASED */if (buf[2] == 0x05) {printk("(FRAME_UNCOMPRESSED)\n");n = 25;} else if (buf[2] == 0x07) {printk("(FRAME_MJPEG)\n");n = 25;} else {printk("(FRAME_FRAME_BASED)\n");n = 21;}len = (buf[n] != 0) ? (26+buf[n]*4) : 38;if (buf[0] < len)printk(" Warning: Descriptor too short\n");flags = buf[4];printk(" bFrameIndex %5u\n"" bmCapabilities 0x%02x\n",buf[3], flags);printk(" Still image %ssupported\n",(flags & (1 << 0)) ? "" : "un");if (flags & (1 << 1))printk(" Fixed frame-rate\n");printk(" wWidth %5u\n"" wHeight %5u\n"" dwMinBitRate %9u\n"" dwMaxBitRate %9u\n",buf[5] | (buf[6] << 8), buf[7] | (buf[8] << 8),buf[9] | (buf[10] << 8) | (buf[11] << 16) | (buf[12] << 24),buf[13] | (buf[14] << 8) | (buf[15] << 16) | (buf[16] << 24));if (buf[2] == 0x11)printk(" dwDefaultFrameInterval %9u\n"" bFrameIntervalType %5u\n"" dwBytesPerLine %9u\n",buf[17] | (buf[18] << 8) | (buf[19] << 16) | (buf[20] << 24),buf[21],buf[22] | (buf[23] << 8) | (buf[24] << 16) | (buf[25] << 24));elseprintk(" dwMaxVideoFrameBufferSize %9u\n"" dwDefaultFrameInterval %9u\n"" bFrameIntervalType %5u\n",buf[17] | (buf[18] << 8) | (buf[19] << 16) | (buf[20] << 24),buf[21] | (buf[22] << 8) | (buf[23] << 16) | (buf[24] << 24),buf[25]);if (buf[n] == 0)printk(" dwMinFrameInterval %9u\n"" dwMaxFrameInterval %9u\n"" dwFrameIntervalStep %9u\n",buf[26] | (buf[27] << 8) | (buf[28] << 16) | (buf[29] << 24),buf[30] | (buf[31] << 8) | (buf[32] << 16) | (buf[33] << 24),buf[34] | (buf[35] << 8) | (buf[36] << 16) | (buf[37] << 24));elsefor (i = 0; i < buf[n]; i++)printk(" dwFrameInterval(%2u) %9u\n",i, buf[26+4*i] | (buf[27+4*i] << 8) |(buf[28+4*i] << 16) | (buf[29+4*i] << 24));break;case 0x06: /* FORMAT_MJPEG */printk("(FORMAT_MJPEG)\n");if (buf[0] < 11)printk(" Warning: Descriptor too short\n");flags = buf[5];printk(" bFormatIndex %5u\n"" bNumFrameDescriptors %5u\n"" bFlags %5u\n",buf[3], buf[4], flags);printk(" Fixed-size samples: %s\n",(flags & (1 << 0)) ? "Yes" : "No");flags = buf[9];printk(" bDefaultFrameIndex %5u\n"" bAspectRatioX %5u\n"" bAspectRatioY %5u\n"" bmInterlaceFlags 0x%02x\n",buf[6], buf[7], buf[8], flags);printk(" Interlaced stream or variable: %s\n",(flags & (1 << 0)) ? "Yes" : "No");printk(" Fields per frame: %u fields\n",(flags & (1 << 1)) ? 2 : 1);printk(" Field 1 first: %s\n",(flags & (1 << 2)) ? "Yes" : "No");printk(" Field pattern: ");switch ((flags >> 4) & 0x03) {case 0:printk("Field 1 only\n");break;case 1:printk("Field 2 only\n");break;case 2:printk("Regular pattern of fields 1 and 2\n");break;case 3:printk("Random pattern of fields 1 and 2\n");break;}printk(" bCopyProtect %5u\n", buf[10]);break;case 0x0a: /* FORMAT_MPEG2TS */printk("(FORMAT_MPEG2TS)\n");len = buf[0] < 23 ? 7 : 23;if (buf[0] < len)printk(" Warning: Descriptor too short\n");printk(" bFormatIndex %5u\n"" bDataOffset %5u\n"" bPacketLength %5u\n"" bStrideLength %5u\n",buf[3], buf[4], buf[5], buf[6]);if (len > 7)printk(" guidStrideFormat %s\n",get_guid(&buf[7]));break;case 0x0d: /* COLORFORMAT */printk("(COLORFORMAT)\n");if (buf[0] < 6)printk(" Warning: Descriptor too short\n");printk(" bColorPrimaries %5u (%s)\n",buf[3], (buf[3] <= 5) ? colorPrims[buf[3]] : "Unknown");printk(" bTransferCharacteristics %5u (%s)\n",buf[4], (buf[4] <= 7) ? transferChars[buf[4]] : "Unknown");printk(" bMatrixCoefficients %5u (%s)\n",buf[5], (buf[5] <= 5) ? matrixCoeffs[buf[5]] : "Unknown");break;default:printk(" Invalid desc subtype:");break;}buflen -= buf[0];buf += buf[0];}
}static void dump_endpoint(const struct usb_endpoint_descriptor *endpoint)
{static const char * const typeattr[] = {"Control","Isochronous","Bulk","Interrupt"};static const char * const syncattr[] = {"None","Asynchronous","Adaptive","Synchronous"};static const char * const usage[] = {"Data","Feedback","Implicit feedback Data","(reserved)"};static const char * const hb[] = { "1x", "2x", "3x", "(?\?)" };unsigned wmax = le16_to_cpu(endpoint->wMaxPacketSize);printk(" Standard Endpoint Descriptor:\n"" bLength %5u\n"" bDescriptorType %5u\n"" bEndpointAddress 0x%02x EP %u %s\n"" bmAttributes %5u\n"" Transfer Type %s\n"" Synch Type %s\n"" Usage Type %s\n"" wMaxPacketSize 0x%04x %s %d bytes\n"" bInterval %5u\n",endpoint->bLength,endpoint->bDescriptorType,endpoint->bEndpointAddress,endpoint->bEndpointAddress & 0x0f,(endpoint->bEndpointAddress & 0x80) ? "IN" : "OUT",endpoint->bmAttributes,typeattr[endpoint->bmAttributes & 3],syncattr[(endpoint->bmAttributes >> 2) & 3],usage[(endpoint->bmAttributes >> 4) & 3],wmax, hb[(wmax >> 11) & 3], wmax & 0x7ff,endpoint->bInterval);/* only for audio endpoints */if (endpoint->bLength == 9)printk(" bRefresh %5u\n"" bSynchAddress %5u\n",endpoint->bRefresh, endpoint->bSynchAddress);}static int myuvc_probe(struct usb_interface *intf,const struct usb_device_id *id)
{static int cnt = 0;struct usb_device *dev = interface_to_usbdev(intf);struct usb_device_descriptor *descriptor = &dev->descriptor;struct usb_host_config *hostconfig;struct usb_config_descriptor *config;struct usb_interface_assoc_descriptor *assoc_desc;struct usb_interface_descriptor *interface;struct usb_endpoint_descriptor *endpoint;int i, j, k, l, m;unsigned char *buffer;int buflen;int desc_len;int desc_cnt;printk("myuvc_probe : cnt = %d\n", cnt++);/* 打印设备描述符 */printk("Device Descriptor:\n"" bLength %5u\n"" bDescriptorType %5u\n"" bcdUSB %2x.%02x\n"" bDeviceClass %5u \n"" bDeviceSubClass %5u \n"" bDeviceProtocol %5u \n"" bMaxPacketSize0 %5u\n"" idVendor 0x%04x \n"" idProduct 0x%04x \n"" bcdDevice %2x.%02x\n"" iManufacturer %5u\n"" iProduct %5u\n"" iSerial %5u\n"" bNumConfigurations %5u\n",descriptor->bLength, descriptor->bDescriptorType,descriptor->bcdUSB >> 8, descriptor->bcdUSB & 0xff,descriptor->bDeviceClass, descriptor->bDeviceSubClass,descriptor->bDeviceProtocol, descriptor->bMaxPacketSize0,descriptor->idVendor, descriptor->idProduct,descriptor->bcdDevice >> 8, descriptor->bcdDevice & 0xff,descriptor->iManufacturer, descriptor->iProduct, descriptor->iSerialNumber, descriptor->bNumConfigurations);for (i = 0; i < descriptor->bNumConfigurations; i++){hostconfig = &dev->config[i];config = &hostconfig->desc;// 配置描述符printk(" Configuration Descriptor %d:\n"" bLength %5u\n"" bDescriptorType %5u\n"" wTotalLength %5u\n"" bNumInterfaces %5u\n"" bConfigurationValue %5u\n"" iConfiguration %5u\n"" bmAttributes 0x%02x\n",i, config->bLength, config->bDescriptorType,le16_to_cpu(config->wTotalLength),config->bNumInterfaces, config->bConfigurationValue,config->iConfiguration,config->bmAttributes);// 接口联合描述符assoc_desc = hostconfig->intf_assoc[0];printk(" Interface Association Descriptor:\n"" bLength %5u\n"" bDescriptorType %5u\n"" bFirstInterface %5u\n"" bInterfaceCount %5u\n"" bFunctionClass %5u\n"" bFunctionSubClass %5u\n"" bFunctionProtocol %5u\n"" iFunction %5u\n",assoc_desc->bLength,assoc_desc->bDescriptorType,assoc_desc->bFirstInterface,assoc_desc->bInterfaceCount,assoc_desc->bFunctionClass,assoc_desc->bFunctionSubClass,assoc_desc->bFunctionProtocol,assoc_desc->iFunction); // 打印当前 probe 传进来接口的每一个设置的接口描述符for (j = 0; j < intf->num_altsetting; j++){interface = &intf->altsetting[j].desc;// Standard Interface Descriptorprintk(" Standard Interface Descriptor -> altsetting %d:\n"" bLength %5u\n"" bDescriptorType %5u\n"" bInterfaceNumber %5u\n"" bAlternateSetting %5u\n"" bNumEndpoints %5u\n"" bInterfaceClass %5u\n"" bInterfaceSubClass %5u\n"" bInterfaceProtocol %5u\n"" iInterface %5u\n",j, interface->bLength, interface->bDescriptorType, interface->bInterfaceNumber,interface->bAlternateSetting, interface->bNumEndpoints, interface->bInterfaceClass,interface->bInterfaceSubClass, interface->bInterfaceProtocol,interface->iInterface);/* 打印端点描述符 */for (m = 0; m < interface->bNumEndpoints; m++){endpoint = &intf->altsetting[j].endpoint[m].desc;dump_endpoint(endpoint);/* class specific endpoint Descriptor */buffer = &intf->altsetting[j].endpoint[m].extra;buflen = intf->altsetting[j].endpoint[m].enabled;printk(" Class-specific Endpoint Descriptor:\n");k = 0;desc_cnt = 0;while (k < buflen){desc_len = buffer[k];printk("extra desc %d: ", desc_cnt);for (l = 0; l < desc_len; l++, k++){printk("%02x ", buffer[k]);}desc_cnt++;printk("\n");}}} // 只打印当前设置的 class specific Descriptorbuffer = intf->cur_altsetting->extra;// Class-specific Interface Descriptorprintk(" Class-specific Interface Descriptor\n");buflen = intf->cur_altsetting->extralen;printk("extra buffer of interface %d:\n", cnt-1);k = 0;desc_cnt = 0;while (k < buflen){desc_len = buffer[k];printk("extra desc %d: ", desc_cnt);for (l = 0; l < desc_len; l++, k++){printk("%02x ", buffer[k]);}desc_cnt++;printk("\n");}// 解析 Class-specific Interface Descriptor interface = &intf->cur_altsetting->desc;if ((buffer[1] == USB_DT_CS_INTERFACE) && (interface->bInterfaceSubClass == 1)){parse_videocontrol_interface(intf, buffer, buflen);}if ((buffer[1] == USB_DT_CS_INTERFACE) && (interface->bInterfaceSubClass == 2)){parse_videostreaming_interface(intf, buffer, buflen);} } return 0;
}static void myuvc_disconnect(struct usb_interface *intf)
{static int cnt = 0;printk("myuvc_disconnect : cnt = %d\n", cnt++);
}static struct usb_device_id myuvc_ids[] = {/* Generic USB Video Class */{ USB_INTERFACE_INFO(USB_CLASS_VIDEO, 1, 0) }, /* VideoControl Interface */{ USB_INTERFACE_INFO(USB_CLASS_VIDEO, 2, 0) }, /* VideoStreaming Interface */{}
};/* 1. 分配usb_driver */
/* 2. 设置 */
static struct usb_driver myuvc_driver = {.name = "myuvc",.probe = myuvc_probe,.disconnect = myuvc_disconnect,.id_table = myuvc_ids,
};static int myuvc_init(void)
{/* 3. 注册 */usb_register(&myuvc_driver);return 0;
}static void myuvc_exit(void)
{usb_deregister(&myuvc_driver);
}module_init(myuvc_init);
module_exit(myuvc_exit);
MODULE_LICENSE("GPL");
描述符打印信息
myuvc_probe : cnt = 0Device Descriptor:bLength 18bDescriptorType 1bcdUSB 2.00bDeviceClass 239 bDeviceSubClass 2 bDeviceProtocol 1 bMaxPacketSize0 64idVendor 0x04f2 idProduct 0xb26a bcdDevice 52.68iManufacturer 1iProduct 2iSerial 0bNumConfigurations 1Configuration Descriptor 0:bLength 9bDescriptorType 2wTotalLength 857bNumInterfaces 2bConfigurationValue 1iConfiguration 0bmAttributes 0x80Interface Association Descriptor:bLength 8bDescriptorType 11bFirstInterface 0bInterfaceCount 2bFunctionClass 14bFunctionSubClass 3bFunctionProtocol 0iFunction 2Standard Interface Descriptor -> altsetting 0:bLength 9bDescriptorType 4bInterfaceNumber 0bAlternateSetting 0bNumEndpoints 1bInterfaceClass 14bInterfaceSubClass 1bInterfaceProtocol 0iInterface 2Standard Endpoint Descriptor:bLength 7bDescriptorType 5bEndpointAddress 0x87 EP 7 INbmAttributes 3Transfer Type InterruptSynch Type NoneUsage Type DatawMaxPacketSize 0x0010 1x 16 bytesbInterval 8Class-specific Endpoint Descriptor:extra desc 0: 05 25 03 10 00 Class-specific Interface Descriptorextra buffer of interface 0:extra desc 0: 0d 24 01 00 01 6d 00 00 6c dc 02 01 01 extra desc 1: 12 24 02 01 01 02 00 00 00 00 00 00 00 00 03 06 00 00 extra desc 2: 0b 24 05 02 01 00 40 02 3f 15 00 extra desc 3: 1d 24 06 03 82 06 61 63 70 50 ab 49 b8 cc b3 85 5e 8d 22 1d 00 01 02 04 ff ff 1d 00 00 extra desc 4: 1d 24 06 04 64 e7 c6 24 51 5f 7e 43 90 89 28 ff a4 87 bd ca 00 01 03 04 0f 00 00 00 00 extra desc 5: 09 24 03 05 01 01 00 04 00 VideoControl Interface Descriptor:bLength 13bDescriptorType 36bDescriptorSubtype 1 (HEADER)bcdUVC 1.00wTotalLength 109dwClockFrequency 48.000000MHzbInCollection 1baInterfaceNr( 0) 1VideoControl Interface Descriptor:bLength 18bDescriptorType 36bDescriptorSubtype 2 (INPUT_TERMINAL)bTerminalID 1wTerminalType 0x0201bAssocTerminal 0iTerminal 0wObjectiveFocalLengthMin 0wObjectiveFocalLengthMax 0wOcularFocalLength 0bControlSize 3bmControls 0x00000006Auto-Exposure ModeAuto-Exposure PriorityVideoControl Interface Descriptor:bLength 11bDescriptorType 36bDescriptorSubtype 5 (PROCESSING_UNIT)Warning: Descriptor too shortbUnitID 2bSourceID 1wMaxMultiplier 16384bControlSize 2bmControls 0x0000153fBrightnessContrastHueSaturationSharpnessGammaBacklight CompensationPower Line FrequencyWhite Balance Temperature, AutoiProcessing 0bmVideoStandards 0x1dNonePAL - 625/50SECAM - 625/50NTSC - 625/50VideoControl Interface Descriptor:bLength 29bDescriptorType 36bDescriptorSubtype 6 (EXTENSION_UNIT)bUnitID 3guidExtensionCode {82066163-7050-ab49-b8cc-b3855e8d221d}bNumControl 0bNrPins 1baSourceID( 0) 2bControlSize 4bmControls( 0) 0xffbmControls( 1) 0xffbmControls( 2) 0x1dbmControls( 3) 0x00iExtension 0VideoControl Interface Descriptor:bLength 29bDescriptorType 36bDescriptorSubtype 6 (EXTENSION_UNIT)bUnitID 4guidExtensionCode {64e7c624-515f-7e43-9089-28ffa487bdca}bNumControl 0bNrPins 1baSourceID( 0) 3bControlSize 4bmControls( 0) 0x0fbmControls( 1) 0x00bmControls( 2) 0x00bmControls( 3) 0x00iExtension 0VideoControl Interface Descriptor:bLength 9bDescriptorType 36bDescriptorSubtype 3 (OUTPUT_TERMINAL)bTerminalID 5wTerminalType 0x0101bAssocTerminal 0bSourceID 4iTerminal 0myuvc_probe : cnt = 1Device Descriptor:bLength 18bDescriptorType 1bcdUSB 2.00bDeviceClass 239 bDeviceSubClass 2 bDeviceProtocol 1 bMaxPacketSize0 64idVendor 0x04f2 idProduct 0xb26a bcdDevice 52.68iManufacturer 1iProduct 2iSerial 0bNumConfigurations 1Configuration Descriptor 0:bLength 9bDescriptorType 2wTotalLength 857bNumInterfaces 2bConfigurationValue 1iConfiguration 0bmAttributes 0x80Interface Association Descriptor:bLength 8bDescriptorType 11bFirstInterface 0bInterfaceCount 2bFunctionClass 14bFunctionSubClass 3bFunctionProtocol 0iFunction 2Standard Interface Descriptor -> altsetting 0:bLength 9bDescriptorType 4bInterfaceNumber 1bAlternateSetting 0bNumEndpoints 0bInterfaceClass 14bInterfaceSubClass 2bInterfaceProtocol 0iInterface 0Standard Interface Descriptor -> altsetting 1:bLength 9bDescriptorType 4bInterfaceNumber 1bAlternateSetting 1bNumEndpoints 1bInterfaceClass 14bInterfaceSubClass 2bInterfaceProtocol 0iInterface 0Standard Endpoint Descriptor:bLength 7bDescriptorType 5bEndpointAddress 0x81 EP 1 INbmAttributes 5Transfer Type IsochronousSynch Type AsynchronousUsage Type DatawMaxPacketSize 0x00c0 1x 192 bytesbInterval 1Class-specific Endpoint Descriptor:Standard Interface Descriptor -> altsetting 2:bLength 9bDescriptorType 4bInterfaceNumber 1bAlternateSetting 2bNumEndpoints 1bInterfaceClass 14bInterfaceSubClass 2bInterfaceProtocol 0iInterface 0Standard Endpoint Descriptor:bLength 7bDescriptorType 5bEndpointAddress 0x81 EP 1 INbmAttributes 5Transfer Type IsochronousSynch Type AsynchronousUsage Type DatawMaxPacketSize 0x0180 1x 384 bytesbInterval 1Class-specific Endpoint Descriptor:Standard Interface Descriptor -> altsetting 3:bLength 9bDescriptorType 4bInterfaceNumber 1bAlternateSetting 3bNumEndpoints 1bInterfaceClass 14bInterfaceSubClass 2bInterfaceProtocol 0iInterface 0Standard Endpoint Descriptor:bLength 7bDescriptorType 5bEndpointAddress 0x81 EP 1 INbmAttributes 5Transfer Type IsochronousSynch Type AsynchronousUsage Type DatawMaxPacketSize 0x0200 1x 512 bytesbInterval 1Class-specific Endpoint Descriptor:Standard Interface Descriptor -> altsetting 4:bLength 9bDescriptorType 4bInterfaceNumber 1bAlternateSetting 4bNumEndpoints 1bInterfaceClass 14bInterfaceSubClass 2bInterfaceProtocol 0iInterface 0Standard Endpoint Descriptor:bLength 7bDescriptorType 5bEndpointAddress 0x81 EP 1 INbmAttributes 5Transfer Type IsochronousSynch Type AsynchronousUsage Type DatawMaxPacketSize 0x0280 1x 640 bytesbInterval 1Class-specific Endpoint Descriptor:Standard Interface Descriptor -> altsetting 5:bLength 9bDescriptorType 4bInterfaceNumber 1bAlternateSetting 5bNumEndpoints 1bInterfaceClass 14bInterfaceSubClass 2bInterfaceProtocol 0iInterface 0Standard Endpoint Descriptor:bLength 7bDescriptorType 5bEndpointAddress 0x81 EP 1 INbmAttributes 5Transfer Type IsochronousSynch Type AsynchronousUsage Type DatawMaxPacketSize 0x0320 1x 800 bytesbInterval 1Class-specific Endpoint Descriptor:Standard Interface Descriptor -> altsetting 6:bLength 9bDescriptorType 4bInterfaceNumber 1bAlternateSetting 6bNumEndpoints 1bInterfaceClass 14bInterfaceSubClass 2bInterfaceProtocol 0iInterface 0Standard Endpoint Descriptor:bLength 7bDescriptorType 5bEndpointAddress 0x81 EP 1 INbmAttributes 5Transfer Type IsochronousSynch Type AsynchronousUsage Type DatawMaxPacketSize 0x03b0 1x 944 bytesbInterval 1Class-specific Endpoint Descriptor:Standard Interface Descriptor -> altsetting 7:bLength 9bDescriptorType 4bInterfaceNumber 1bAlternateSetting 7bNumEndpoints 1bInterfaceClass 14bInterfaceSubClass 2bInterfaceProtocol 0iInterface 0Standard Endpoint Descriptor:bLength 7bDescriptorType 5bEndpointAddress 0x81 EP 1 INbmAttributes 5Transfer Type IsochronousSynch Type AsynchronousUsage Type DatawMaxPacketSize 0x0a80 2x 640 bytesbInterval 1Class-specific Endpoint Descriptor:Standard Interface Descriptor -> altsetting 8:bLength 9bDescriptorType 4bInterfaceNumber 1bAlternateSetting 8bNumEndpoints 1bInterfaceClass 14bInterfaceSubClass 2bInterfaceProtocol 0iInterface 0Standard Endpoint Descriptor:bLength 7bDescriptorType 5bEndpointAddress 0x81 EP 1 INbmAttributes 5Transfer Type IsochronousSynch Type AsynchronousUsage Type DatawMaxPacketSize 0x0b20 2x 800 bytesbInterval 1Class-specific Endpoint Descriptor:Standard Interface Descriptor -> altsetting 9:bLength 9bDescriptorType 4bInterfaceNumber 1bAlternateSetting 9bNumEndpoints 1bInterfaceClass 14bInterfaceSubClass 2bInterfaceProtocol 0iInterface 0Standard Endpoint Descriptor:bLength 7bDescriptorType 5bEndpointAddress 0x81 EP 1 INbmAttributes 5Transfer Type IsochronousSynch Type AsynchronousUsage Type DatawMaxPacketSize 0x0be0 2x 992 bytesbInterval 1Class-specific Endpoint Descriptor:Standard Interface Descriptor -> altsetting 10:bLength 9bDescriptorType 4bInterfaceNumber 1bAlternateSetting 10bNumEndpoints 1bInterfaceClass 14bInterfaceSubClass 2bInterfaceProtocol 0iInterface 0Standard Endpoint Descriptor:bLength 7bDescriptorType 5bEndpointAddress 0x81 EP 1 INbmAttributes 5Transfer Type IsochronousSynch Type AsynchronousUsage Type DatawMaxPacketSize 0x1380 3x 896 bytesbInterval 1Class-specific Endpoint Descriptor:Standard Interface Descriptor -> altsetting 11:bLength 9bDescriptorType 4bInterfaceNumber 1bAlternateSetting 11bNumEndpoints 1bInterfaceClass 14bInterfaceSubClass 2bInterfaceProtocol 0iInterface 0Standard Endpoint Descriptor:bLength 7bDescriptorType 5bEndpointAddress 0x81 EP 1 INbmAttributes 5Transfer Type IsochronousSynch Type AsynchronousUsage Type DatawMaxPacketSize 0x13fc 3x 1020 bytesbInterval 1Class-specific Endpoint Descriptor:Class-specific Interface Descriptorextra buffer of interface 1:extra desc 0: 0f 24 01 02 0d 02 81 00 05 01 01 00 01 00 04 extra desc 1: 1b 24 04 01 07 59 55 59 32 00 00 10 00 80 00 00 aa 00 38 9b 71 10 01 00 00 00 00 extra desc 2: 22 24 05 01 01 80 02 e0 01 00 00 65 04 00 00 ca 08 00 60 09 00 15 16 05 00 02 15 16 05 00 2a 2c 0a 00 extra desc 3: 22 24 05 02 01 a0 00 78 00 00 50 46 00 00 a0 8c 00 00 96 00 00 15 16 05 00 02 15 16 05 00 2a 2c 0a 00 extra desc 4: 22 24 05 03 01 b0 00 90 00 00 d0 5c 00 00 a0 b9 00 00 c6 00 00 15 16 05 00 02 15 16 05 00 2a 2c 0a 00 extra desc 5: 22 24 05 04 01 40 01 f0 00 00 40 19 01 00 80 32 02 00 58 02 00 15 16 05 00 02 15 16 05 00 2a 2c 0a 00 extra desc 6: 22 24 05 05 01 60 01 20 01 00 40 73 01 00 80 e6 02 00 18 03 00 15 16 05 00 02 15 16 05 00 2a 2c 0a 00 extra desc 7: 1e 24 05 06 01 00 05 d0 02 00 00 ca 08 00 00 ca 08 00 20 1c 00 40 42 0f 00 01 40 42 0f 00 extra desc 8: 1e 24 05 07 01 00 05 20 03 00 00 c4 09 00 00 c4 09 00 40 1f 00 40 42 0f 00 01 40 42 0f 00 extra desc 9: 06 24 0d 01 01 04 extra desc 10: 0b 24 06 02 07 01 01 00 00 00 00 extra desc 11: 22 24 07 01 01 80 02 e0 01 00 00 65 04 00 00 ca 08 00 60 09 00 15 16 05 00 02 15 16 05 00 2a 2c 0a 00 extra desc 12: 22 24 07 02 01 a0 00 78 00 00 50 46 00 00 a0 8c 00 00 96 00 00 15 16 05 00 02 15 16 05 00 2a 2c 0a 00 extra desc 13: 22 24 07 03 01 b0 00 90 00 00 d0 5c 00 00 a0 b9 00 00 c6 00 00 15 16 05 00 02 15 16 05 00 2a 2c 0a 00 extra desc 14: 22 24 07 04 01 40 01 f0 00 00 40 19 01 00 80 32 02 00 58 02 00 15 16 05 00 02 15 16 05 00 2a 2c 0a 00 extra desc 15: 22 24 07 05 01 60 01 20 01 00 40 73 01 00 80 e6 02 00 18 03 00 15 16 05 00 02 15 16 05 00 2a 2c 0a 00 extra desc 16: 1e 24 07 06 01 00 05 d0 02 00 00 5e 1a 00 00 5e 1a 00 20 1c 00 15 16 05 00 01 15 16 05 00 extra desc 17: 1e 24 07 07 01 00 05 20 03 00 00 4c 1d 00 00 4c 1d 00 40 1f 00 15 16 05 00 01 15 16 05 00 extra desc 18: 06 24 0d 01 01 04 VideoStreaming Interface Descriptor:bLength 15bDescriptorType 36bDescriptorSubtype 1 (INPUT_HEADER)bNumFormats 2wTotalLength 525bEndPointAddress 129bmInfo 0bTerminalLink 5bStillCaptureMethod 1bTriggerSupport 1bTriggerUsage 0bControlSize 1bmaControls( 0) 27bmaControls( 1) 27VideoStreaming Interface Descriptor:bLength 27bDescriptorType 36bDescriptorSubtype 4 (FORMAT_UNCOMPRESSED)bFormatIndex 1bNumFrameDescriptors 7guidFormat {59555932-0000-1000-8000-00aa00389b71}bBitsPerPixel 16bDefaultFrameIndex 1bAspectRatioX 0bAspectRatioY 0bmInterlaceFlags 0x00Interlaced stream or variable: NoFields per frame: 2 fieldsField 1 first: NoField pattern: Field 1 onlybCopyProtect 0VideoStreaming Interface Descriptor:bLength 34bDescriptorType 36bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)bFrameIndex 1bmCapabilities 0x01Still image supportedwWidth 640wHeight 480dwMinBitRate 73728000dwMaxBitRate 147456000dwMaxVideoFrameBufferSize 614400dwDefaultFrameInterval 333333bFrameIntervalType 2dwFrameInterval( 0) 333333dwFrameInterval( 1) 666666VideoStreaming Interface Descriptor:bLength 34bDescriptorType 36bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)bFrameIndex 2bmCapabilities 0x01Still image supportedwWidth 160wHeight 120dwMinBitRate 4608000dwMaxBitRate 9216000dwMaxVideoFrameBufferSize 38400dwDefaultFrameInterval 333333bFrameIntervalType 2dwFrameInterval( 0) 333333dwFrameInterval( 1) 666666VideoStreaming Interface Descriptor:bLength 34bDescriptorType 36bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)bFrameIndex 3bmCapabilities 0x01Still image supportedwWidth 176wHeight 144dwMinBitRate 6082560dwMaxBitRate 12165120dwMaxVideoFrameBufferSize 50688dwDefaultFrameInterval 333333bFrameIntervalType 2dwFrameInterval( 0) 333333dwFrameInterval( 1) 666666VideoStreaming Interface Descriptor:bLength 34bDescriptorType 36bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)bFrameIndex 4bmCapabilities 0x01Still image supportedwWidth 320wHeight 240dwMinBitRate 18432000dwMaxBitRate 36864000dwMaxVideoFrameBufferSize 153600dwDefaultFrameInterval 333333bFrameIntervalType 2dwFrameInterval( 0) 333333dwFrameInterval( 1) 666666VideoStreaming Interface Descriptor:bLength 34bDescriptorType 36bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)bFrameIndex 5bmCapabilities 0x01Still image supportedwWidth 352wHeight 288dwMinBitRate 24330240dwMaxBitRate 48660480dwMaxVideoFrameBufferSize 202752dwDefaultFrameInterval 333333bFrameIntervalType 2dwFrameInterval( 0) 333333dwFrameInterval( 1) 666666VideoStreaming Interface Descriptor:bLength 30bDescriptorType 36bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)bFrameIndex 6bmCapabilities 0x01Still image supportedwWidth 1280wHeight 720dwMinBitRate 147456000dwMaxBitRate 147456000dwMaxVideoFrameBufferSize 1843200dwDefaultFrameInterval 1000000bFrameIntervalType 1dwFrameInterval( 0) 1000000VideoStreaming Interface Descriptor:bLength 30bDescriptorType 36bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)bFrameIndex 7bmCapabilities 0x01Still image supportedwWidth 1280wHeight 800dwMinBitRate 163840000dwMaxBitRate 163840000dwMaxVideoFrameBufferSize 2048000dwDefaultFrameInterval 1000000bFrameIntervalType 1dwFrameInterval( 0) 1000000VideoStreaming Interface Descriptor:bLength 6bDescriptorType 36bDescriptorSubtype 13 (COLORFORMAT)bColorPrimaries 1 (BT.709,sRGB)bTransferCharacteristics 1 (BT.709)bMatrixCoefficients 4 (SMPTE 170M (BT.601))VideoStreaming Interface Descriptor:bLength 11bDescriptorType 36bDescriptorSubtype 6 (FORMAT_MJPEG)bFormatIndex 2bNumFrameDescriptors 7bFlags 1Fixed-size samples: YesbDefaultFrameIndex 1bAspectRatioX 0bAspectRatioY 0bmInterlaceFlags 0x00Interlaced stream or variable: NoFields per frame: 1 fieldsField 1 first: NoField pattern: Field 1 onlybCopyProtect 0VideoStreaming Interface Descriptor:bLength 34bDescriptorType 36bDescriptorSubtype 7 (FRAME_MJPEG)bFrameIndex 1bmCapabilities 0x01Still image supportedwWidth 640wHeight 480dwMinBitRate 73728000dwMaxBitRate 147456000dwMaxVideoFrameBufferSize 614400dwDefaultFrameInterval 333333bFrameIntervalType 2dwFrameInterval( 0) 333333dwFrameInterval( 1) 666666VideoStreaming Interface Descriptor:bLength 34bDescriptorType 36bDescriptorSubtype 7 (FRAME_MJPEG)bFrameIndex 2bmCapabilities 0x01Still image supportedwWidth 160wHeight 120dwMinBitRate 4608000dwMaxBitRate 9216000dwMaxVideoFrameBufferSize 38400dwDefaultFrameInterval 333333bFrameIntervalType 2dwFrameInterval( 0) 333333dwFrameInterval( 1) 666666VideoStreaming Interface Descriptor:bLength 34bDescriptorType 36bDescriptorSubtype 7 (FRAME_MJPEG)bFrameIndex 3bmCapabilities 0x01Still image supportedwWidth 176wHeight 144dwMinBitRate 6082560dwMaxBitRate 12165120dwMaxVideoFrameBufferSize 50688dwDefaultFrameInterval 333333bFrameIntervalType 2dwFrameInterval( 0) 333333dwFrameInterval( 1) 666666VideoStreaming Interface Descriptor:bLength 34bDescriptorType 36bDescriptorSubtype 7 (FRAME_MJPEG)bFrameIndex 4bmCapabilities 0x01Still image supportedwWidth 320wHeight 240dwMinBitRate 18432000dwMaxBitRate 36864000dwMaxVideoFrameBufferSize 153600dwDefaultFrameInterval 333333bFrameIntervalType 2dwFrameInterval( 0) 333333dwFrameInterval( 1) 666666VideoStreaming Interface Descriptor:bLength 34bDescriptorType 36bDescriptorSubtype 7 (FRAME_MJPEG)bFrameIndex 5bmCapabilities 0x01Still image supportedwWidth 352wHeight 288dwMinBitRate 24330240dwMaxBitRate 48660480dwMaxVideoFrameBufferSize 202752dwDefaultFrameInterval 333333bFrameIntervalType 2dwFrameInterval( 0) 333333dwFrameInterval( 1) 666666VideoStreaming Interface Descriptor:bLength 30bDescriptorType 36bDescriptorSubtype 7 (FRAME_MJPEG)bFrameIndex 6bmCapabilities 0x01Still image supportedwWidth 1280wHeight 720dwMinBitRate 442368000dwMaxBitRate 442368000dwMaxVideoFrameBufferSize 1843200dwDefaultFrameInterval 333333bFrameIntervalType 1dwFrameInterval( 0) 333333VideoStreaming Interface Descriptor:bLength 30bDescriptorType 36bDescriptorSubtype 7 (FRAME_MJPEG)bFrameIndex 7bmCapabilities 0x01Still image supportedwWidth 1280wHeight 800dwMinBitRate 491520000dwMaxBitRate 491520000dwMaxVideoFrameBufferSize 2048000dwDefaultFrameInterval 333333bFrameIntervalType 1dwFrameInterval( 0) 333333VideoStreaming Interface Descriptor:bLength 6bDescriptorType 36bDescriptorSubtype 13 (COLORFORMAT)bColorPrimaries 1 (BT.709,sRGB)bTransferCharacteristics 1 (BT.709)bMatrixCoefficients 4 (SMPTE 170M (BT.601))
UVC 摄像头驱动(二)描述符分析相关推荐
- UVC 摄像头驱动(一)硬件描述
虚拟摄像头驱动vivi 内核中使用 video_device 结构来描述一个 video 设备,以虚拟摄像头驱动 vivi 为例,整体框架无非是: 分配一个 video_device 设置 video ...
- UVC 摄像头驱动(三)配置摄像头,实时数据采集
前面分析了 UVC 摄像头的硬件模型和描述符,对于一个 usb 摄像头来说,内部大概分为一个 VC 接口和一个 VS 接口,VC 接口内部有许多 unit 和 terminal 用来"控制& ...
- linux usb摄像头 源码,Linux USB摄像头驱动实现源码分析
Spac5xx的实现是按照标准的USB VIDEO设备的驱动框架编写(其具体的驱动框架可参照/usr/src/linux/drivers/usb/usbvideo.c文件),整个源程序由四个主体部分组 ...
- dpdk报文收发流程--理解dma控制器、UIO驱动、描述符空间、mbuf空间、KNI
1. dpdk报文收发流程 1.1 报文接收流程 传统方式接收报文时,当网卡接收到报文后会产生硬件中断,进而报文会通过协议栈,最后到达应用层,这个过程需要内核协议栈的处理. 和传统报文接收不同,当应用 ...
- linux UVC摄像头驱动 简介
1. 如何判断Camera是否为UVC Camera Linux UVC driver(uvc) 该驱动适用于符合USB视频类(USB Video Class)规范的摄像头设备,它包括V4L2内核设备 ...
- LBD算法 - Line Band Discriptor 描述符分析
LBD概述 LBD算法源自2013年文章<An efficient and robust line segment matching approach based on LBD descript ...
- ros uvc摄像头驱动安装
USB插入win10系统设备管理器/照相机/属性/详细信息/属性/硬件ID :VID_1BCF ;PID:2CBD linux下输入,安装驱动: sudo apt-get install ros-ki ...
- linux uvc摄像头操作,Linux uvc摄像头驱动初探
本文基于AM6C平台Linux3.0.8内核. 1.drivers/media/video/uvc/Makefile uvcvideo-objs := uvc_driver.o uvc_queue.o ...
- linux uvc 拍照程序,Linux uvc摄像头驱动初探
本文基于AM6C平台Linux3.0.8内核. 1.drivers/media/video/uvc/Makefile uvcvideo-objs := uvc_driver.o uvc_queue.o ...
- uvc摄像头代码解析之描述符
1.uvc驱动模块入口 module_init(uvc_init); //1.模块入口 2.初始化函数 static int __init uvc_init(void) // 2.初始化函数 {int ...
最新文章
- Java项目:学生选课系统(java+javaweb+jdbc)
- document.all使用
- 如何实现容器透明,内容不透明?
- 如何修改pdf文件的背景色
- 【音视频安卓开发 (六)】Android GLSurfaceView播放视频
- layui根据name获取对象_layui表格行合并;解决侧边固定栏合并
- linux下find命令-atime,-ctime,-mtime真正含义
- Daily Scrum 12.13
- AIDA64 Business Edition 4.00.2700绿色单文件破解版下载
- 小鹏G3/G3i/P7/P5维修手册电路图用户手册维修诊断拆装技术资料
- GitLab 创建项目组及将代码导入项目
- JAVA输入五中水果英文名称_水果英文名称大全
- 收钱吧好还是网付好?
- 《直面苦难》--周国平
- 讲述近十几年的房地产
- OneTab: 一键合并所有 Chrome 浏览器标签页
- 插画版Kubernetes指南(小孩子也能看懂的kubernetes教程)
- C Primer Plus (第6版) 读书笔记_Chapter 2
- 致敬!阿里云的数据库侠客!
- php7安装flarum,如何在Ubuntu 18.04上安装Flarum社区软件