title: Usb摄像头描述符解析

date: 2019/4/23 20:00:00

toc: true

Usb摄像头描述符解析

总结

参考老师的代码总结如下,序号就是代码的文件夹编号

1. 实现usb插入识别
驱动识别的是接口,摄像头有vc/vs接口,所以probe会进入两次
static struct usb_device_id myuvc_ids[] = {...}
2. 打印设备描述符
// 通过接口获得它的父节点:设备
struct usb_device *dev = interface_to_usbdev(intf);
// 通过 usb_device 设备结构来获得 设备描述符
struct usb_device_descriptor *descriptor = &dev->descriptor; 3. 打印配置描述符
// 设备描述符 指出了多少个配置 descriptor->bNumConfigurations
for (i = 0; i < descriptor->bNumConfigurations; i++)
{
struct usb_host_config *hostconfig;
struct usb_config_descriptor *config; //设备管理结构中包含了配置管理结构
hostconfig = &dev->config[i];
//配置管理结构中包含了配置描述符
config = &hostconfig->desc;
}
4. 打印联合接口描述符
这里的联合接口IAD主要用来扩展USB协议的,这里用来描述video特殊的描述,我们一开始并不知道有多少个 vc,需要解析这个才能知道
这个联合接口是在我们的每个配置下的,可以有多个,这里我们只考虑第一个先
struct usb_interface_assoc_descriptor *assoc_desc;
// 遍历配置
for (i = 0; i < descriptor->bNumConfigurations; i++)
{
assoc_desc = hostconfig->intf_assoc[0]; }
5. 打印接口描述符,也称具体设置
设置描述就在接口下,一个接口下有多个设置
// intf 就是probe 传递的接口
for (j = 0; j < intf->num_altsetting; j++)
{
interface = &intf->altsetting[j].desc;
} 6. 打印具体的联合接口数据
这个联合接口数据在具体的接口设置下的扩展数据
buffer = intf->cur_altsetting->extra; //当前接口的设置
buflen = intf->cur_altsetting->extralen;
7. 解析VC接口的具体数据,上面的配置描述符已经指出了有两个2接口
8. 解析VS接口的具体数据,这里的解析我们需要看uvc多个文档
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);
}
9. 打印端点描述符
接口下有多个设置,设置下有多个端点
for (j = 0; j < intf->num_altsetting; j++)
{
interface = &intf->altsetting[j].desc;
for (m = 0; m < interface->bNumEndpoints; m++)//接口设置描述符下有指示几个端点
{
endpoint = &intf->altsetting[j].endpoint[m].desc;
}
}

参考资料

从零写USB摄像头驱动之分析描述符

插图资料

lsusb的源代码usbutils-006>lsusb.c

打印设备描述符

#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 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; 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); 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");

打印信息如下,这里重复打印了两次,因为能够匹配两次接口

sudo rmmod    uvcvideo
sudo rmmod myuvc
sudo insmod myuvc.ko
dmesg
[  384.615769] Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239
bDeviceSubClass 2
bDeviceProtocol 1
bMaxPacketSize0 64
idVendor 0x05a3
idProduct 0x9310
bcdDevice 0.00
iManufacturer 2
iProduct 1
iSerial 0
bNumConfigurations 1

可以看到程序中的匹配{ USB_INTERFACE_INFO(USB_CLASS_VIDEO, 1, 0) },的USB_CLASS_VIDEO值就是0x0E,这里的描述符类型是1也就是SC_VIDEOCONTROL

打印配置描述符

在设备描述符里, __u8 bNumConfigurations;定义了设备的配置描述符个数,使用for循环将它打印。

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;
int i; 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); } return 0;
}

这里有1个配置描述符,打印如下

 1281.895515]   Configuration Descriptor 0:
bLength 9
bDescriptorType 2
wTotalLength 963
bNumInterfaces 4
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80

打印接口联合体描述符

这里先解释下这个接口联合体描述符,在我们的摄像头框架中,我们并不知道有多少个video control,这里这个接口联合体描述符就会告诉我们这些

接下去的IAD的具体描述指出了具体的信息

struct usb_interface_assoc_descriptor {
__u8 bLength;
__u8 bDescriptorType; __u8 bFirstInterface; //第一个接口
__u8 bInterfaceCount; //总共有多少个接口,在这个联合体里有几个接口
__u8 bFunctionClass;
__u8 bFunctionSubClass;
__u8 bFunctionProtocol;
__u8 iFunction;
} __attribute__ ((packed));

修改代码如下

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;
int i; 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:\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); } return 0;
}

打印信息如下,可以看到这个联合接口描述有两个接口

[20081.506088] myuvc_probe : cnt = 0
[20081.506091] Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239
bDeviceSubClass 2
bDeviceProtocol 1
bMaxPacketSize0 64
idVendor 0x05a3
idProduct 0x9310
bcdDevice 0.00
iManufacturer 2
iProduct 1
iSerial 0
bNumConfigurations 1
[20081.506093] Configuration Descriptor 0:
bLength 9
bDescriptorType 2
wTotalLength 963
bNumInterfaces 4
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
[20081.506094] Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 0 //第一个接口
bInterfaceCount 2 //数量
bFunctionClass 14
bFunctionSubClass 3
bFunctionProtocol 0
iFunction 5

打印接口描述符

USB驱动针对的是接口,而不是每一个设备,也就是idtable匹配到具体的接口描述就会去调用probe

一个接口下面有多个设置,我们可以将这些设置打印出来,在韦老师的代码中,我觉得打印接口描述符不应该

for(多个配置)
for(多个设置)
打印本接口的多个设置

而是应该

for(多个配置)
打印配置描述符
for(多个设置)
打印接口的多个设置

我们的probe传递的接口参数中,altsetting表示了多个设置,cur_altsetting表示了当前的设置

struct usb_interface {
/* array of alternate settings for this interface,
* stored in no particular order */
struct usb_host_interface *altsetting; struct usb_host_interface *cur_altsetting; /* the currently
* active alternate setting */
unsigned num_altsetting; /* number of alternate settings */ /* If there is an interface association descriptor then it will list
* the associated interfaces */
struct usb_interface_assoc_descriptor *intf_assoc; int minor; /* minor number this interface is
* bound to */
enum usb_interface_condition condition; /* state of binding */
unsigned sysfs_files_created:1; /* the sysfs attributes exist */
unsigned ep_devs_created:1; /* endpoint "devices" exist */
unsigned unregistering:1; /* unregistration is in progress */
unsigned needs_remote_wakeup:1; /* driver requires remote wakeup */
unsigned needs_altsetting0:1; /* switch to altsetting 0 is pending */
unsigned needs_binding:1; /* needs delayed unbind/rebind */
unsigned resetting_device:1; /* true: bandwidth alloc after reset */
unsigned authorized:1; /* used for interface authorization */ struct device dev; /* interface specific device info */
struct device *usb_dev;
atomic_t pm_usage_cnt; /* usage counter for autosuspend */
struct work_struct reset_ws; /* for resets in atomic context */
};

测试代码如下

struct usb_interface_descriptor	*interface;
for (j = 0; j < intf->num_altsetting; j++)
{
interface = &intf->altsetting[j].desc;
printk(" 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);
}

打印如下

-------------------------设备描述符--------------------------------------
[22200.195958] myuvc_probe : cnt = 0
[22200.195961] Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239
bDeviceSubClass 2
bDeviceProtocol 1
bMaxPacketSize0 64
idVendor 0x05a3
idProduct 0x9310
bcdDevice 0.00
iManufacturer 2
iProduct 1
iSerial 0
bNumConfigurations 1
-------------------------配置描述符-------------------------------------- [22200.195963] Configuration Descriptor 0:
bLength 9
bDescriptorType 2
wTotalLength 963
bNumInterfaces 4
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
-------------------------接口联合体描述符--------------------------------------
[22200.195981] Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 0
bInterfaceCount 2
bFunctionClass 14
bFunctionSubClass 3
bFunctionProtocol 0
iFunction 5
=====================接口1点描述符,描述了当前支持的设置 =========================
[22200.195983] Interface Descriptor altsetting 0:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 14
bInterfaceSubClass 1
bInterfaceProtocol 0
iInterface 5
[22200.195998] myuvc_probe : cnt = 1
[22200.196000] Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239
bDeviceSubClass 2
bDeviceProtocol 1
bMaxPacketSize0 64
idVendor 0x05a3
idProduct 0x9310
bcdDevice 0.00
iManufacturer 2
iProduct 1
iSerial 0
bNumConfigurations 1
[22200.196001] Configuration Descriptor 0:
bLength 9
bDescriptorType 2
wTotalLength 963
bNumInterfaces 4
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
[22200.196002] Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 0
bInterfaceCount 2
bFunctionClass 14
bFunctionSubClass 3
bFunctionProtocol 0
iFunction 5
=====================接口2点描述符,描述了当前支持的设置 =========================
[22200.196003] Interface Descriptor altsetting 0:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 14
bInterfaceSubClass 2
bInterfaceProtocol 0
iInterface 5
[22200.196004] Interface Descriptor altsetting 1:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 1
bNumEndpoints 1
bInterfaceClass 14
bInterfaceSubClass 2
bInterfaceProtocol 0
iInterface 0
[22200.196006] Interface Descriptor altsetting 2:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 2
bNumEndpoints 1
bInterfaceClass 14
bInterfaceSubClass 2
bInterfaceProtocol 0
iInterface 0
[22200.196007] Interface Descriptor altsetting 3:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 3
bNumEndpoints 1
bInterfaceClass 14
bInterfaceSubClass 2
bInterfaceProtocol 0
iInterface 0
[22200.196008] Interface Descriptor altsetting 4:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 4
bNumEndpoints 1
bInterfaceClass 14
bInterfaceSubClass 2
bInterfaceProtocol 0
iInterface 0
[22200.196009] Interface Descriptor altsetting 5:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 5
bNumEndpoints 1
bInterfaceClass 14
bInterfaceSubClass 2
bInterfaceProtocol 0
iInterface 0
[22200.196010] Interface Descriptor altsetting 6:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 6
bNumEndpoints 1
bInterfaceClass 14
bInterfaceSubClass 2
bInterfaceProtocol 0
iInterface 0

打印当前设置的额外描述符

这里的额外描述符,也就是我们上面提到的接口联合体扩展中所提到的扩展了2个接口,数据存在当前设置的extra中

struct usb_host_interface {
struct usb_interface_descriptor desc; int extralen;
unsigned char *extra; /* Extra descriptors */ /* array of desc.bNumEndpoints endpoints associated with this
* interface setting. these will be in no particular order.
*/
struct usb_host_endpoint *endpoint; char *string; /* iInterface string, if present */
};

测试代码如下,这里首先获取buf的总长度,其次每个描述符的第一个字节都是长度,所以依次取出这个长度然后打印

buffer = intf->cur_altsetting->extra;
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");
}

结果如下,我们可以从 A.4. Video Class-Specific Descriptor Types P171入手,依次读取 其中

CS_INTERFACE 0x24

第三个字节就是子类,搜索具体子类的名字再去分析

仔细分析打印的数据,总结出数据走向

IT>PU>EU(扩展单元,厂家自定义)>OT
[26644.221914] extra buffer of interface 0:
[26644.221914] extra desc 0:
[26644.221915] 0d
[26644.221916] 24 //CS_INTERFACE
[26644.221916] 01 // 子类subtype VC_HEADER
[26644.221917] 00 // bcdUVC
[26644.221917] 01 // bcdUVC
[26644.221918] 4d //wTotalLength
[26644.221918] 00 //wTotalLength
[26644.221919] c0 //dwClockFrequency
[26644.221919] e1 //dwClockFrequency
[26644.221920] e4 //dwClockFrequency
[26644.221920] 00 //dwClockFrequency
[26644.221921] 01 //bInCollection
[26644.221921] 01 //bInCollection //总结起来就是 IT>PU>EU(扩展单元,厂家自定义)>OT // VC_OUTPUT_TERMINAL 的源是04 也就是下面的 VC_EXTENSION_UNIT EU>OT
[26644.221923] extra desc 1:
[26644.221923] 09
[26644.221924] 24
[26644.221924] 03 VC_OUTPUT_TERMINAL
[26644.221925] 02 bTerminalID
[26644.221925] 01 wTerminalType
[26644.221926] 01 wTerminalType
[26644.221926] 00 bAssocTerminal
[26644.221927] 04 bSourceID ---源
[26644.221927] 00 iTerminal //VC_EXTENSION_UNIT 的源是03,也就是VC_PROCESSING_UNIT PU>EU
[26644.221928] extra desc 2:
[26644.221929] 1a
[26644.221929] 24
[26644.221930] 06 VC_EXTENSION_UNIT
[26644.221930] 04 bUnitID //id
[26644.221931] 70 GUID(16)
[26644.221931] 33
[26644.221932] f0
[26644.221932] 28
[26644.221933] 11
[26644.221933] 63
[26644.221934] 2e
[26644.221934] 4a
[26644.221935] ba
[26644.221935] 2c
[26644.221936] 68
[26644.221936] 90
[26644.221937] eb
[26644.221937] 33
[26644.221938] 40
[26644.221938] 16
[26644.221939] 08 bNumControls
[26644.221939] 01 bNrInPins
[26644.221940] 03 baSourceID ----源头
[26644.221940] 01
[26644.221941] 0f
[26644.221941] 00
//VC_INPUT_TERMINAL 没有源
[26644.221942] extra desc 3:
[26644.221943] 12
[26644.221943] 24
[26644.221944] 02 VC_INPUT_TERMINAL
[26644.221944] 01 bTerminalID //id
[26644.221945] 01 wTerminalType //可以搜索到162页
[26644.221945] 02 wTerminalType
[26644.221946] 00 bAssocTerminal
[26644.221946] 00 iTerminal
[26644.221947] 00 wObjectiveFocalLengthMin
[26644.221947] 00 wObjectiveFocalLengthMin
[26644.221948] 00 wObjectiveFocalLengthMax
[26644.221948] 00 wObjectiveFocalLengthMax
[26644.221949] 00 wOcularFocalLength
[26644.221949] 00 wOcularFocalLength
[26644.221950] 03 bControlSize
[26644.221950] 1e bmControls
[26644.221951] 00 bmControls
[26644.221951] 00 bmControls
//VC_PROCESSING_UNIT 的源是01 VC_INPUT_TERMINAL IT>PU
[26644.221952] extra desc 4:
[26644.221953] 0b
[26644.221953] 24
[26644.221954] 05 VC_PROCESSING_UNIT
[26644.221954] 03 bUnitID
[26644.221955] 01 bSourceID --源头是01
[26644.221955] 00 wMaxMultiplier
[26644.221985] 00 wMaxMultiplier
[26644.221986] 02 bControlSize
[26644.221987] 7f bmControls
[26644.221987] 37 bmControls
[26644.221988] 00 bmControls

接着我们可以搜索下VS流的子类也就是157页,其中具体的格式format后和fram后需要到其他的pdf找,比如USB_Video_Payload_MJPEG_1.5和USB_Video_Payload_Uncompressed_1.5

下面的支持两种格式mjpeg和未压缩的 uncompressed,每种视频格式又有多种fram(分辨率)

具体的分析如下

[26644.221914] extra buffer of interface 0:
[26644.221914] extra desc 0:
[26644.221915] 0d
[26644.221916] 24 //CS_INTERFACE
[26644.221916] 01 // 子类subtype VC_HEADER
[26644.221917] 00 // bcdUVC
[26644.221917] 01 // bcdUVC
[26644.221918] 4d //wTotalLength
[26644.221918] 00 //wTotalLength
[26644.221919] c0 //dwClockFrequency
[26644.221919] e1 //dwClockFrequency
[26644.221920] e4 //dwClockFrequency
[26644.221920] 00 //dwClockFrequency
[26644.221921] 01 //bInCollection
[26644.221921] 01 //bInCollection //总结起来就是 IT>PU>EU(扩展单元,厂家自定义)>OT // VC_OUTPUT_TERMINAL 的源是04 也就是下面的 VC_EXTENSION_UNIT EU>OT
[26644.221923] extra desc 1:
[26644.221923] 09
[26644.221924] 24
[26644.221924] 03 VC_OUTPUT_TERMINAL
[26644.221925] 02 bTerminalID
[26644.221925] 01 wTerminalType
[26644.221926] 01 wTerminalType
[26644.221926] 00 bAssocTerminal
[26644.221927] 04 bSourceID ---源
[26644.221927] 00 iTerminal //VC_EXTENSION_UNIT 的源是03,也就是VC_PROCESSING_UNIT PU>EU
[26644.221928] extra desc 2:
[26644.221929] 1a
[26644.221929] 24
[26644.221930] 06 VC_EXTENSION_UNIT
[26644.221930] 04 bUnitID //id
[26644.221931] 70 GUID(16)
[26644.221931] 33
[26644.221932] f0
[26644.221932] 28
[26644.221933] 11
[26644.221933] 63
[26644.221934] 2e
[26644.221934] 4a
[26644.221935] ba
[26644.221935] 2c
[26644.221936] 68
[26644.221936] 90
[26644.221937] eb
[26644.221937] 33
[26644.221938] 40
[26644.221938] 16
[26644.221939] 08 bNumControls
[26644.221939] 01 bNrInPins
[26644.221940] 03 baSourceID ----源头
[26644.221940] 01
[26644.221941] 0f
[26644.221941] 00
//VC_INPUT_TERMINAL 没有源
[26644.221942] extra desc 3:
[26644.221943] 12
[26644.221943] 24
[26644.221944] 02 VC_INPUT_TERMINAL
[26644.221944] 01 bTerminalID //id
[26644.221945] 01 wTerminalType //可以搜索到162页
[26644.221945] 02 wTerminalType
[26644.221946] 00 bAssocTerminal
[26644.221946] 00 iTerminal
[26644.221947] 00 wObjectiveFocalLengthMin
[26644.221947] 00 wObjectiveFocalLengthMin
[26644.221948] 00 wObjectiveFocalLengthMax
[26644.221948] 00 wObjectiveFocalLengthMax
[26644.221949] 00 wOcularFocalLength
[26644.221949] 00 wOcularFocalLength
[26644.221950] 03 bControlSize
[26644.221950] 1e bmControls
[26644.221951] 00 bmControls
[26644.221951] 00 bmControls
//VC_PROCESSING_UNIT 的源是01 VC_INPUT_TERMINAL IT>PU
[26644.221952] extra desc 4:
[26644.221953] 0b
[26644.221953] 24
[26644.221954] 05 VC_PROCESSING_UNIT
[26644.221954] 03 bUnitID
[26644.221955] 01 bSourceID --源头是01
[26644.221955] 00 wMaxMultiplier
[26644.221985] 00 wMaxMultiplier
[26644.221986] 02 bControlSize
[26644.221987] 7f bmControls
[26644.221987] 37 bmControls
[26644.221988] 00 bmControls [26644.222013] myuvc_probe : cnt = 1
[26644.222017] Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239
bDeviceSubClass 2
bDeviceProtocol 1
bMaxPacketSize0 64
idVendor 0x05a3
idProduct 0x9310
bcdDevice 0.00
iManufacturer 2
iProduct 1
iSerial 0
bNumConfigurations 1
[26644.222019] Configuration Descriptor 0:
bLength 9
bDescriptorType 2
wTotalLength 963
bNumInterfaces 4
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
[26644.222021] Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 0
bInterfaceCount 2
bFunctionClass 14
bFunctionSubClass 3
bFunctionProtocol 0
iFunction 5
[26644.222023] Interface Descriptor altsetting 0:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 14
bInterfaceSubClass 2
bInterfaceProtocol 0
iInterface 5
[26644.222025] Interface Descriptor altsetting 1:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 1
bNumEndpoints 1
bInterfaceClass 14
bInterfaceSubClass 2
bInterfaceProtocol 0
iInterface 0
[26644.222027] Interface Descriptor altsetting 2:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 2
bNumEndpoints 1
bInterfaceClass 14
bInterfaceSubClass 2
bInterfaceProtocol 0
iInterface 0
[26644.222029] Interface Descriptor altsetting 3:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 3
bNumEndpoints 1
bInterfaceClass 14
bInterfaceSubClass 2
bInterfaceProtocol 0
iInterface 0
[26644.222031] Interface Descriptor altsetting 4:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 4
bNumEndpoints 1
bInterfaceClass 14
bInterfaceSubClass 2
bInterfaceProtocol 0
iInterface 0
[26644.222033] Interface Descriptor altsetting 5:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 5
bNumEndpoints 1
bInterfaceClass 14
bInterfaceSubClass 2
bInterfaceProtocol 0
iInterface 0
[26644.222035] Interface Descriptor altsetting 6:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 6
bNumEndpoints 1
bInterfaceClass 14
bInterfaceSubClass 2
bInterfaceProtocol 0
iInterface 0
[26644.222036] extra buffer of interface 1:
[26644.222036] extra desc 0:
[26644.222037] 0f
[26644.222037] 24
[26644.222038] 01 VS_INPUT_HEADER
[26644.222038] 02 bNumFormats //支持两种格式,具体去
[26644.222039] 67 wTotalLength
[26644.222039] 02
[26644.222040] 81 bEndpointAddress
[26644.222040] 00 bmInfo
[26644.222041] 02 bTerminalLink
[26644.222041] 02 bStillCaptureMethod
[26644.222042] 00 bTriggerSupport
[26644.222042] 00 bTriggerUsage
[26644.222043] 01 bControlSize
[26644.222043] 00 bmaControls
[26644.222044] 00 bmaControls [26644.222045] extra desc 1:
[26644.222045] 0b
[26644.222046] 24
[26644.222046] 06 VS_FORMAT_MJPEG //支持这个格式
[26644.222047] 01 bFormatIndex //第一种格式
[26644.222047] 08 bNumFrameDescriptors //有8种frame,下面就有8个格式
[26644.222048] 00 bmFlags
[26644.222069] 01 bDefaultFrameIndex // 默认的frame
[26644.222071] 00 bAspectRatioX
[26644.222071] 00 bAspectRatioY
[26644.222072] 00 bmInterlaceFlags
[26644.222072] 00 bCopyProtect [26644.222073] extra desc 2:
[26644.222074] 1e
[26644.222074] 24
[26644.222075] 07 VS_FRAME_MJPEG //具体的frame
[26644.222075] 01 bFrameIndex //frame 编号
[26644.222076] 00 bmCapabilities
[26644.222076] 00 wWidth 0x0500=1280
[26644.222077] 05
[26644.222077] d0 wHeight 720
[26644.222078] 02
[26644.222078] 30 dwMaxBitRate
[26644.222079] 28
[26644.222079] 60
[26644.222080] 1a
[26644.222080] 30 dwMaxVideoFrameBufferSize
[26644.222081] 28
[26644.222081] 60
[26644.222082] 1a dwDefaultFrameInterval
[26644.222082] 4d
[26644.222083] 22
[26644.222083] 1c
[26644.222084] 00 dwDefaultFrameInterval
[26644.222084] 15
[26644.222085] 16
[26644.222085] 05
[26644.222086] 00 bFrameIntervalType
[26644.222087] 01
[26644.222087] 15
[26644.222088] 16
[26644.222088] 05
[26644.222089] 00 [26644.222090] extra desc 3:
[26644.222090] 1e
[26644.222091] 24
[26644.222091] 07 VS_FRAME_MJPEG //具体的frame
[26644.222092] 02 bFrameIndex //frame 编号
[26644.222092] 00 bmCapabilities
[26644.222093] 80 wWidth 0x0280=640
[26644.222093] 02
[26644.222094] e0 wHeight 480
[26644.222094] 01
[26644.222095] 30 dwMaxBitRate
[26644.222095] 28
[26644.222096] cc
[26644.222096] 08
[26644.222097] 30
[26644.222097] 28
[26644.222098] cc
[26644.222098] 08
[26644.222099] 4d
[26644.222099] 62
[26644.222100] 09
[26644.222100] 00
[26644.222101] 15
[26644.222101] 16
[26644.222102] 05
[26644.222102] 00
[26644.222103] 01
[26644.222103] 15
[26644.222104] 16
[26644.222104] 05
[26644.222105] 00 [26644.222106] extra desc 4:
[26644.222106] 1e
[26644.222107] 24
[26644.222107] 07 VS_FRAME_MJPEG //具体的frame
[26644.222108] 03 bFrameIndex //frame 编号
[26644.222108] 00 bmCapabilities
[26644.222109] 60 wWidth 352
[26644.222109] 01
[26644.222110] 20 wHeight 288
[26644.222110] 01
[26644.222111] 30 dwMaxBitRate
[26644.222111] a8
[26644.222112] e8
[26644.222112] 02
[26644.222113] 30
[26644.222113] a8
[26644.222114] e8
[26644.222114] 02
[26644.222115] 4d
[26644.222115] 1a
[26644.222116] 03
[26644.222116] 00
[26644.222117] 15
[26644.222117] 16
[26644.222118] 05
[26644.222118] 00
[26644.222119] 01
[26644.222119] 15
[26644.222120] 16
[26644.222120] 05
[26644.222121] 00 [26644.222122] extra desc 5:
[26644.222122] 1e
[26644.222123] 24
[26644.222123] 07 VS_FRAME_MJPEG //具体的frame
[26644.222124] 04 bFrameIndex //frame 编号
[26644.222124] 00 bmCapabilities
[26644.222125] 40 wWidth
[26644.222125] 01
[26644.222126] f0 wHeight
[26644.222126] 00
[26644.222127] 30 dwMaxBitRate
[26644.222127] a8
[26644.222128] 34
[26644.222128] 02
[26644.222129] 30
[26644.222129] a8
[26644.222130] 34
[26644.222130] 02
[26644.222131] 4d
[26644.222131] 5a
[26644.222132] 02
[26644.222132] 00
[26644.222133] 15
[26644.222133] 16
[26644.222134] 05
[26644.222134] 00
[26644.222135] 01
[26644.222135] 15
[26644.222136] 16
[26644.222136] 05
[26644.222137] 00 [26644.222138] extra desc 6:
[26644.222138] 1e
[26644.222139] 24
[26644.222139] 07 VS_FRAME_MJPEG //具体的frame
[26644.222140] 05 bFrameIndex //frame 编号
[26644.222140] 00 bmCapabilities
[26644.222141] b0 wWidth
[26644.222141] 00
[26644.222142] 90 wHeight
[26644.222142] 00
[26644.222143] 30 dwMaxBitRate
[26644.222143] c8
[26644.222144] bb
[26644.222144] 00
[26644.222145] 30
[26644.222145] c8
[26644.222146] bb
[26644.222146] 00
[26644.222147] 4d
[26644.222147] c8
[26644.222148] 00
[26644.222148] 00
[26644.222149] 15
[26644.222149] 16
[26644.222150] 05
[26644.222150] 00
[26644.222151] 01
[26644.222151] 15
[26644.222152] 16
[26644.222152] 05
[26644.222153] 00 [26644.222154] extra desc 7:
[26644.222154] 1e
[26644.222155] 24
[26644.222155] 07 VS_FRAME_MJPEG //具体的frame
[26644.222156] 06 bFrameIndex //frame 编号
[26644.222156] 00 bmCapabilities
[26644.222157] a0 wWidth
[26644.222157] 00
[26644.222158] 78 wHeight
[26644.222158] 00
[26644.222159] 30 dwMaxBitRate
[26644.222159] c8
[26644.222160] 8e
[26644.222160] 00
[26644.222161] 30
[26644.222161] c8
[26644.222162] 8e
[26644.222162] 00
[26644.222163] 4d
[26644.222163] 98
[26644.222164] 00
[26644.222164] 00
[26644.222165] 15
[26644.222165] 16
[26644.222166] 05
[26644.222166] 00
[26644.222167] 01
[26644.222167] 15
[26644.222168] 16
[26644.222168] 05
[26644.222169] 00 [26644.222170] extra desc 8:
[26644.222170] 1e
[26644.222171] 24
[26644.222171] 07 VS_FRAME_MJPEG //具体的frame
[26644.222189] 07 bFrameIndex //frame 编号
[26644.222191] 00 bmCapabilities
[26644.222191] 20 wWidth
[26644.222192] 03
[26644.222192] 58 wHeight
[26644.222193] 02
[26644.222193] 30 dwMaxBitRate
[26644.222194] c8
[26644.222194] bd
[26644.222195] 0d
[26644.222195] 30
[26644.222196] c8
[26644.222196] bd
[26644.222197] 0d
[26644.222197] 4d
[26644.222198] a8
[26644.222198] 0e
[26644.222199] 00
[26644.222199] 15
[26644.222200] 16
[26644.222200] 05
[26644.222201] 00
[26644.222201] 01
[26644.222202] 15
[26644.222202] 16
[26644.222203] 05
[26644.222203] 00 [26644.222204] extra desc 9:
[26644.222205] 1e
[26644.222205] 24
[26644.222206] 07 VS_FRAME_MJPEG //具体的frame
[26644.222206] 08 bFrameIndex //frame 编号
[26644.222207] 00 bmCapabilities
[26644.222207] c0 wWidth
[26644.222208] 03
[26644.222208] d0 wHeight
[26644.222209] 02
[26644.222209] 30 dwMaxBitRate
[26644.222210] a8
[26644.222210] c8
[26644.222211] 13
[26644.222211] 30
[26644.222212] a8
[26644.222212] c8
[26644.222213] 13
[26644.222213] 4d
[26644.222214] 1a
[26644.222214] 15
[26644.222215] 00
[26644.222215] 15
[26644.222216] 16
[26644.222216] 05
[26644.222217] 00
[26644.222217] 01
[26644.222218] 15
[26644.222218] 16
[26644.222219] 05
[26644.222219] 00 [26644.222220] extra desc 10:
[26644.222221] 26
[26644.222221] 24
[26644.222222] 03 VS_STILL_IMAGE_FRAME
[26644.222222] 00 bEndpointAddress
[26644.222223] 08 bNumImageSizePatterns 8个类型的大小
[26644.222223] 00 wWidth ---接下去是重复的1
[26644.222224] 05
[26644.222224] d0 wHeight
[26644.222225] 02
[26644.222225] c0 wWidth ---接下去是重复的2
[26644.222226] 03
[26644.222226] d0 wHeight
[26644.222227] 02
[26644.222227] 20 wWidth ---接下去是重复的3
[26644.222228] 03
[26644.222228] 58 wHeight
[26644.222229] 02
[26644.222229] 80 wWidth ---接下去是重复的4
[26644.222230] 02
[26644.222230] e0 wHeight
[26644.222231] 01
[26644.222231] 60 wWidth ---接下去是重复的5
[26644.222232] 01
[26644.222232] 20 wHeight
[26644.222233] 01
[26644.222234] 40 wWidth ---接下去是重复的6
[26644.222234] 01
[26644.222235] f0 wHeight
[26644.222235] 00
[26644.222236] b0 wWidth ---接下去是重复的7
[26644.222236] 00
[26644.222237] 90 wHeight
[26644.222237] 00
[26644.222238] a0 wWidth ---接下去是重复的8
[26644.222238] 00
[26644.222239] 78 wHeight
[26644.222239] 00 bNumCompressionPattern 0
[26644.222240] 00 bCompression 0 [26644.222240] extra desc 11:
[26644.222241] 1b
[26644.222241] 24
[26644.222242] 04 VS_FORMAT_UNCOMPRESSED //未压缩的视频,这里需要去搜索另外的文档 Uncompressed Payload
[26644.222242] 02 bFormatIndex //第二种格式
[26644.222243] 08 bNumFrameDescriptors//有8种fram
[26644.222243] 59 guidFormat(16)
[26644.222244] 55
[26644.222244] 59
[26644.222245] 32
[26644.222246] 00
[26644.222246] 00
[26644.222247] 10
[26644.222247] 00
[26644.222248] 80
[26644.222248] 00
[26644.222249] 00
[26644.222249] aa
[26644.222250] 00
[26644.222250] 38
[26644.222251] 9b
[26644.222251] 71
[26644.222252] 10 bBitsPerPixel
[26644.222252] 01 bDefaultFrameIndex
[26644.222253] 00 bAspectRatioX
[26644.222253] 00 bAspectRatioY
[26644.222254] 00 bmInterlaceFlags
[26644.222254] 00 bCopyProtect [26644.222255] extra desc 12:
[26644.222255] 1e
[26644.222256] 24
[26644.222256] 05 VS_FRAME_UNCOMPRESSED //具体的fram格式
[26644.222257] 01 bFrameIndex //id
[26644.222257] 00 bmCapabilities
[26644.222258] 00 wWidth
[26644.222258] 05
[26644.222259] d0 wHeight
[26644.222259] 02
[26644.222260] 00 dwMinBitRate
[26644.222260] 00
[26644.222261] ca
[26644.222261] 08
[26644.222262] 00 dwMaxBitRate
[26644.222262] 00
[26644.222263] ca
[26644.222263] 08
[26644.222264] 00 dwMaxVideoFrameBufferSize
[26644.222264] 20
[26644.222265] 1c
[26644.222265] 00
[26644.222266] 40 dwDefaultFrameInterval
[26644.222267] 42 bFrameIntervalType
[26644.222267] 0f
[26644.222267] 00
[26644.222268] 01
[26644.222268] 40
[26644.222269] 42
[26644.222269] 0f
[26644.222270] 00 [26644.222271] extra desc 13:
[26644.222271] 1e
[26644.222272] 24
[26644.222272] 05 VS_FRAME_UNCOMPRESSED //具体的fram格式
[26644.222273] 02 bFrameIndex //id
[26644.222273] 00
[26644.222274] 80
[26644.222274] 02
[26644.222275] e0
[26644.222275] 01
[26644.222276] 00
[26644.222276] 00
[26644.222277] ca
[26644.222277] 08
[26644.222278] 00
[26644.222278] 00
[26644.222279] ca
[26644.222279] 08
[26644.222280] 00
[26644.222280] 60
[26644.222281] 09
[26644.222281] 00
[26644.222282] 15
[26644.222282] 16
[26644.222283] 05
[26644.222283] 00
[26644.222284] 01
[26644.222284] 15
[26644.222285] 16
[26644.222285] 05
[26644.222286] 00 [26644.222287] extra desc 14:
[26644.222287] 1e
[26644.222288] 24
[26644.222288] 05 VS_FRAME_UNCOMPRESSED //具体的fram格式
[26644.222289] 03 bFrameIndex //id
[26644.222289] 00
[26644.222290] 60
[26644.222290] 01
[26644.222291] 20
[26644.222291] 01
[26644.222309] 00
[26644.222310] 80
[26644.222311] e6
[26644.222311] 02
[26644.222312] 00
[26644.222312] 80
[26644.222313] e6
[26644.222313] 02
[26644.222314] 00
[26644.222314] 18
[26644.222315] 03
[26644.222315] 00
[26644.222316] 15
[26644.222316] 16
[26644.222317] 05
[26644.222317] 00
[26644.222318] 01
[26644.222319] 15
[26644.222319] 16
[26644.222320] 05
[26644.222320] 00 [26644.222321] extra desc 15:
[26644.222322] 1e
[26644.222322] 24
[26644.222323] 05 VS_FRAME_UNCOMPRESSED //具体的fram格式
[26644.222323] 04 bFrameIndex //id
[26644.222324] 00
[26644.222324] 40
[26644.222325] 01
[26644.222325] f0
[26644.222326] 00
[26644.222326] 00
[26644.222327] 80
[26644.222327] 32
[26644.222328] 02
[26644.222328] 00
[26644.222329] 80
[26644.222329] 32
[26644.222330] 02
[26644.222330] 00
[26644.222331] 58
[26644.222331] 02
[26644.222332] 00
[26644.222332] 15
[26644.222333] 16
[26644.222333] 05
[26644.222334] 00
[26644.222334] 01
[26644.222335] 15
[26644.222335] 16
[26644.222336] 05
[26644.222336] 00 [26644.222337] extra desc 16:
[26644.222338] 1e
[26644.222338] 24
[26644.222339] 05 VS_FRAME_UNCOMPRESSED //具体的fram格式
[26644.222339] 05 bFrameIndex //id
[26644.222340] 00
[26644.222340] b0
[26644.222341] 00
[26644.222341] 90
[26644.222342] 00
[26644.222342] 00
[26644.222343] a0
[26644.222343] b9
[26644.222344] 00
[26644.222344] 00
[26644.222345] a0
[26644.222345] b9
[26644.222346] 00
[26644.222346] 00
[26644.222347] c6
[26644.222347] 00
[26644.222348] 00
[26644.222348] 15
[26644.222349] 16
[26644.222349] 05
[26644.222350] 00
[26644.222350] 01
[26644.222351] 15
[26644.222351] 16
[26644.222352] 05
[26644.222352] 00 [26644.222353] extra desc 17:
[26644.222354] 1e
[26644.222354] 24
[26644.222355] 05 VS_FRAME_UNCOMPRESSED //具体的fram格式
[26644.222355] 06 bFrameIndex //id
[26644.222356] 00
[26644.222356] a0
[26644.222357] 00
[26644.222357] 78
[26644.222358] 00
[26644.222358] 00
[26644.222359] a0
[26644.222359] 8c
[26644.222360] 00
[26644.222360] 00
[26644.222361] a0
[26644.222361] 8c
[26644.222362] 00
[26644.222362] 00
[26644.222363] 96
[26644.222363] 00
[26644.222364] 00
[26644.222364] 15
[26644.222365] 16
[26644.222365] 05
[26644.222366] 00
[26644.222366] 01
[26644.222367] 15
[26644.222367] 16
[26644.222368] 05
[26644.222368] 00 [26644.222369] extra desc 18:
[26644.222370] 1e
[26644.222370] 24
[26644.222371] 05 VS_FRAME_UNCOMPRESSED //具体的fram格式
[26644.222371] 07 bFrameIndex //id
[26644.222372] 00
[26644.222372] 20
[26644.222373] 03
[26644.222373] 58
[26644.222374] 02
[26644.222374] 00
[26644.222375] c0
[26644.222375] 27
[26644.222376] 09
[26644.222376] 00
[26644.222377] c0
[26644.222377] 27
[26644.222378] 09
[26644.222378] 00
[26644.222379] a6
[26644.222379] 0e
[26644.222380] 00
[26644.222380] 20
[26644.222381] a1
[26644.222381] 07
[26644.222382] 00
[26644.222382] 01
[26644.222383] 20
[26644.222383] a1
[26644.222384] 07
[26644.222384] 00 [26644.222385] extra desc 19:
[26644.222386] 1e
[26644.222386] 24
[26644.222387] 05 VS_FRAME_UNCOMPRESSED //具体的fram格式
[26644.222387] 08 bFrameIndex //id
[26644.222388] 00
[26644.222388] c0
[26644.222389] 03
[26644.222389] d0
[26644.222390] 02
[26644.222390] 00
[26644.222391] 40
[26644.222391] e3
[26644.222392] 09
[26644.222392] 00
[26644.222393] 40
[26644.222393] e3
[26644.222394] 09
[26644.222394] 00
[26644.222395] 18
[26644.222395] 15
[26644.222396] 00
[26644.222396] 2a
[26644.222397] 2c
[26644.222397] 0a
[26644.222398] 00
[26644.222398] 01
[26644.222399] 2a
[26644.222399] 2c
[26644.222400] 0a
[26644.222400] 00 [26644.222401] extra desc 20:
[26644.222402] 26
[26644.222402] 24
[26644.222403] 03 VS_STILL_IMAGE_FRAME
[26644.222403] 00
[26644.222404] 08 //8种类型的尺寸
[26644.222404] 00
[26644.222405] 05
[26644.222405] d0
[26644.222406] 02
[26644.222406] c0
[26644.222407] 03
[26644.222407] d0
[26644.222408] 02
[26644.222408] 20
[26644.222409] 03
[26644.222409] 58
[26644.222410] 02
[26644.222410] 80
[26644.222411] 02
[26644.222411] e0
[26644.222412] 01
[26644.222412] 60
[26644.222413] 01
[26644.222413] 20
[26644.222414] 01
[26644.222414] 40
[26644.222415] 01
[26644.222415] f0
[26644.222416] 00
[26644.222416] b0
[26644.222417] 00
[26644.222417] 90
[26644.222418] 00
[26644.222418] a0
[26644.222419] 00
[26644.222419] 78
[26644.222420] 00
[26644.222420] 00 [26644.222421] extra desc 21:
[26644.222422] 06
[26644.222422] 24
[26644.222423] 0d VS_COLORFORMAT
[26644.222423] 01 bColorPrimaries
[26644.222424] 01 bTransferCharacteristics
[26644.222424] 04 bMatrixCoefficients

代码解析额外的描述符

参考lsusb的开源代码

lsusb.C
dump_altsetting
switch (buf[1]
case USB_DT_CS_INTERFACE:
case USB_CLASS_VIDEO:
switch (interface->bInterfaceSubClass) {
case 1:
dump_videocontrol_interface(dev, buf);//vc解析
break;
case 2:
dump_videostreaming_interface(buf);//vs解析
break;
default:
goto dump;
}
break;

打印端点描述符

参考
lsusb.c
dump_altsetting
for (i = 0 ; i < interface->bNumEndpoints ; i++)
dump_endpoint(dev, interface, &interface->endpoint[i]);

源码如下

//接口下的设置
for (j = 0; j < intf->num_altsetting; j++)
{
/* 打印端点描述符 */
for (m = 0; m < interface->bNumEndpoints; m++)
{
// 某个接口下的某个设置下的第m个端点
endpoint = &intf->altsetting[j].endpoint[m].desc;
dump_endpoint(endpoint);
}
}

分析

这里的dmesg信息过多,显示不下了,使用dmesg >dmesg.txt来保存查看,搜索下Endpoint可以看到好几个

[38736.519001]       Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0010 1x 16 bytes
bInterval 6 .....

(八) Usb摄像头描述符解析的更多相关文章

  1. 2.7 usb摄像头之usb摄像头描述符打印

    学习目标:参考lsusb源码,打印USB摄像头的设备描述符.配置描述符.接口联合描述符.端点描述符: 一.lsusb命令和源码 使用命令lsusb可以看看设备的id,并执行 # lsusb -v -d ...

  2. USB协议-USB的描述符及其之间的关系

    USB只是一个总线,只提供一个数据通路而已.USB总线驱动程序并不知道一个设备具体如何操作,有哪些行为.具体的一个设备实现什么功能,要由设备自己来决定.那么,USB主机是如何知道一个设备的功能以及行为 ...

  3. USB HID描述符【转】

    本文转载自: USB是个通用的总线,端口都是统一的.但是USB设备却各种各样,例如USB鼠标,USB键盘,U盘等等,那么USB主机是如何识别出不同的设备的呢?这就要依赖于描述符了.USB的描述符主要有 ...

  4. (转)USB的描述符及各种描述符之间的依赖关系

    全文链接:http://justmei.blog.163.com/blog/static/11609985320102421659260/?latestBlog 1 推荐 [原创] USB入门系列之七 ...

  5. USB描述符解析-->枚举.

    枚举可以理解为主机按不定的顺序向USB设备讨要设备信息,好给它分配资源,若枚举不成功,就放弃分配资源,免得浪费资源.一般都是使用中断传输方式通信. 常用的描述符有以下几种:01H.设备描述符  02H ...

  6. 12.1、USB驱动——描述符、URB、管道

    大家常说,一个设备通常有多个配置,配置通常有多个接口,接口通常有多个端点.接口代表逻辑上的设备,比如声卡分为 录音和播放.访问设备时,访问的是某个接口(逻辑设备).除了端点0之外,每个端点只支持一个传 ...

  7. 2.5 USB摄像头驱动程序框架

    学习目标:根据vivi驱动架构和linux-2.6.31/linux-2.6.31.14/drivers/media/video/uvc/Uvc_driver.c驱动源码,分析usb摄像头驱动程序框架 ...

  8. 2.6 USB摄像头驱动之USB描述符

    学习目标:分析USB摄像头驱动的描述符: 一.USB设备描述符 在usb设备驱动分析那一节,也用到了usb描述符. usb描述符可分为: USB设备描述符(usb_device_descriptor) ...

  9. USB HID Report Descriptor 报告描述符详解

    Report descriptors are composed of pieces of information. Each piece of information is called an Ite ...

随机推荐

  1. fullpage 全屏插件

     fullpage 全屏插件 全屏滚动效果,原生js也很好实现,主要是用 mousewheel 鼠标滚轮滚动事件, 来判断上滚动还是下滚动,之后设置每次滚动的高度为屏幕的高度即可.但是,虽然效果简单, ...

  2. Android,View转换bitmap,bitmap转换drawable

    Android View转换Bitmap,Bitmap转换Drawable //测试设置bitmap View view1 = ViewGroup.inflate(context, R.layout. ...

  3. ORA-02266错误的批量生成脚本解决方案

    ORA-02266: unique/primary keys in table referenced by enabled foreign keys这篇博客是很早之前总结的一篇文章,最近导数时使用TR ...

  4. JavaScript 节流函数 Throttle 详解

    在浏览器 DOM 事件里面,有一些事件会随着用户的操作不间断触发.比如:重新调整浏览器窗口大小(resize),浏览器页面滚动(scroll),鼠标移动(mousemove).也就是说用户在触发这些浏 ...

  5. Mysql事务与锁详解

    脏读: 不可重复读: 幻读: 锁: 表级别的意向锁为了提高效率, 我们能给一张表成功加上一个表锁的前提是:没有任何一个事务对这张表的某些行加了锁. 如果没有意向表锁: 如果现在要给一个表加上表锁. 如 ...

  6. 创建一个Windows服务程序与实现定时器效果

    1.创建一个Windows服务程序 一.   新建Window服务项目 二.   添加安装程序 三.   配置服务属性 四.   编写定时器代码 publicpartialclassService1 ...

  7. thinkphp封装方法添加跨域请求

    function wang_json($data){ //返回JSON数据格式到客户端,包含状态信息 header(' Content-Type:application/json; charset=u ...

  8. 接口list

    List接口介绍 java.util.List 接口继承自 Collection 接口,是单列集合的一个重要分支,习惯性地会将实现了 List 接口的对象称为List集合. List接口特点: 它是一 ...

  9. 记录一次无厘头的粗心失误——java后台报错:Unknown column 'xxx' in 'field list'

    原因: sql文件马虎,直接用错了仓库.用的不是程序调用的仓库.而自己pojo和mapper还是采用Mybatis的逆向工程生成的.当时搞得很无厘头. 解决方案: sql用到程序指定的仓库就行啦. 总 ...

  10. Docker镜像仓库清理的探索之路

    用友云开发者中心是基于Docker容器进行微服务架构应用的落地与管理.相信各位同学在使用的过程中,会发现随着Docker镜像的增多,占用磁盘空间也约来越多.这时我们需要清理私有镜像仓库中不需要的镜像. ...