usb描述符, 存在于usb设备端, 用于描述该设备, 配置, 接口, 端点, 名称等信息。如
- Device Decriptor
- Configuration Descriptor
- Interface Association Descritor (IAD)
- Interface Descriptor
- Endpoint Descriptor
- String Descriptor
等等。
本文主要描述IAD即Interface Association Descriptor描述符相关。
字面含义, 接口关联描述符。
参看USB3_1协议, ch9.6.4章节。
以及CYPRESS的AN57294等文档。对IAD描述如下:
This descriptor describes two or more interfaces that are associated with a single device function. The interface
association descriptor (IAD) informs the host that the interfaces are linked together. For example, a USB UART has
two interfaces associated with it: a control interface and a data interface. The IAD tells the host that these two
interfaces are part of the same function, which is a USBUART, and falls under the communication device class
(CDC). This descriptor is not required in all cases. Figure 43 shows how a single interface relates to a single device
function. The interface descriptor defines the characteristics for that function. Figure 43 shows how two separate
interfaces are linked to a particular device function. This is where the IAD is required. Table 7 shows the structure for
an interface association descriptor.
图贴出来就清楚了, 后面再补充。
即对于多功能(接口)的usb设备, 会有两种情况,
1. 多接口 分别 对应不同主机端驱动, 如内核自带的g_multi 多功能复合设备, 包含虚拟串口g_serial, 虚拟网口RNDIS/ECM, 大容量存储g_mass_storage三种驱动, 主机枚举后需要分别加载三种驱动以使用这三种功能。
2. 多接口 对应一个主机端驱动。 即多接口关联在同一个Function Driver中。
常见如UVC, 即usb webcam, 通常设计有Video Control Interface和Video Stream Interface。
其中Control Interface控制格式, 分辨率, 帧率, 亮度, 白平衡, 3A等各种效果。
而Video Stream Interface负责数据传输通道。
描述符:
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2 ?
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
idVendor 0x046d Logitech, Inc.
idProduct 0x0825 Webcam C270
bcdDevice 0.12
iManufacturer 0
iProduct 0
iSerial 2
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 2466
bNumInterfaces 4
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 500mA
Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 0
bInterfaceCount 2
bFunctionClass 14 Video
bFunctionSubClass 3 Video Interface Collection
bFunctionProtocol 0
iFunction 0
......
主机端:
|__ Port 2: Dev 3, If 2, Class=Audio, Driver=snd-usb-audio, 480M
|__ Port 2: Dev 3, If 0, Class=Video, Driver=uvcvideo, 480M
|__ Port 2: Dev 3, If 3, Class=Audio, Driver=snd-usb-audio, 480M
|__ Port 2: Dev 3, If 1, Class=Video, Driver=uvcvideo, 480M
如上, 可看到Control Interface 和 Stream Interface是包含在同一个Function Driver中, 主机端加载同样的uvcvideo驱动。
另外也摘录uvc 1.5 specification中的描述。
2.4.1 Video Interface Collection
A device must use an Interface Association Descriptor to describe a Video Interface Collection
for each device function that requires a VideoControl Interface and one or more VideoStreaming
interfaces. The Interface Association Descriptor must always be returned as part of the device’s
complete configuration descriptor in response to a GetDescriptor (Configuration) request. The
Interface Association Descriptor must be located before the VideoControl Interface and its
associated VideoStreaming Interfaces (including all alternate settings). All of the interface
numbers in the set of associated interfaces must be contiguous.
ok, 大致如此。
另外其他可参考分析:
https://www.cnblogs.com/shangdawei/p/4712305.html