【USB笔记】接口关联描述符Interface Association Descriptor

本文深入解析USB接口关联描述符(IAD)的概念与作用,探讨其在设备功能描述中的应用,并提供具体的实例说明。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

USB笔记 接口关联描述符 (Interface Association Descriptor)

接口关联描述符 (Interface Association Descriptor)(IAD),简称IAD,用于描述与同一功能相关联的两个或多个接口。

关联(association)包括两个或多个接口及其所有备用设置接口。设备必须对需要多个接口的每个设备功能使用接口关联描述符 (Interface Association Descriptor)。接口关联描述符(Interface Association Descriptor)总是通过GetDescriptor(Configuration) 请求,作为配置信息的一部分返回。接口关联描述符 (Interface Association Descriptor)不能直接通过 GetDescriptor()或SetDescriptor()请求进行访问。接口关联描述符必须位于与其关联的接口的接口描述符集(包括所有备用设置接口)之前。所有关联接口集的接口号必须是连续的。

接口关联描述符包括功能类(Class)、子类(SubClass)和协议(Protocol)字段。这些字段中的值可以与任何关联接口的接口类(Class)、子类(SubClass)和协议(Protocol)的值相同。对于现有的设备类,首选实现是使用关联接口列表中第一个接口的接口类(Class)、子类(SubClass)和协议(Protocol)字段的值。

通过使用多个接口来管理单个设备功能的设备必须支持接口关联描述符 (Interface Association Descriptor)。早于Interface Association Descriptor(IAD)之前定义的类规范可以没有这个描述符。所有带有多个接口的超高速设备(Enhanced SuperSpeed devices),都必须使用IAD。

使用了IAD的设备,设备描述符中类(Class)、子类(SubClass)和协议(Protocol)的值必须定义成如下数值:

bDeviceClass = 0xEF (miscellaneous device class)
bDeviceSubClass = 0x02 (common class)
bDeviceProtocol = 0x01 (interface association descriptor)

USB2.0规范(The Universal Serial Bus Specification, revision 2.0)没有支持该描述符,不支持将设备的多个接口分组到单个设备功能中。该描述符是由USB-IF发布工程更改通知Engineering Change Notification (ECN),《USB ECN : Interface Association Descriptor》定义了该描述符与功能。

Windows系统从Microsoft Windows XP Service Pack 2 (SP2)版本开始支持IAD。

Interface Association Descriptor(IAD)

OffsetFieldSizeValueDescription
0bLength1Number以字节为单位的描述符大小
1bDescriptorType1Constant接口关联描述符类型
2bFirstInterface1Number与该功能关联的第一个接口的接口号
3bInterfaceCount1Number与该功能关联的连续接口的数量
4bFunctionClass1Class类码
5bFunctionSubClass1SubClass子类码
6bFunctionProtocol1Protocol协议码
7iFunction1Index字符串描述符索引

bLength以字节为单位的描述符大小 (0x08)。

bDescriptorType端点描述符类型,为INTERFACE_ASSOCIATION(0x0B)。

bFirstInterface 与该功能关联的第一个接口的接口号。接口号是接口描述符(Interface Descriptor)中bInterfaceNumber的值。 关联接口的接口号必须是连续的。

bInterfaceCount 与该功能关联的连续接口的数量。

bFunctionClass 类码(Class code),这个类码(Class code)由USB-IF分配。这个字段的值不能为0。如果这个字段的值为FFH,则功能类是厂商专属。其他所有值保留,由USB-IF分配。对于没有规定使用值的类,首选值是第一个关联接口的描述符中的bInterfaceClass的值。

bFunctionSubClass 子类码(SubClass code),这个子类码(SubClass code)由USB-IF分配。如果bFunctionClass值不是FFH,则表示其他所有值保留,由USB-IF分配。对于没有规定使用值的类,首选值是第一个关联接口的描述符中的bInterfaceSubClass的值。

bFunctionProtocol 协议码(Protocol code),这个协议码(Protocol code)由USB-IF分配。这个值受到bFunctionClass和bFunctionSubClass字段的限制。对于没有规定使用值的类,首选值是第一个关联接口的描述符中的bInterfaceProtocol的值。

iFunction 描述该功能的字符串描述符索引。若没有字符串描述符,这个字段的值为0。

获取接口关联描述符

主机通过发送Get Descriptor请求,取得配置描述符,接口关联描述符,接口描述符,端点描述符及其附属描述符。接口关联描述符 (Interface Association Descriptor)总是作为配置描述符的一部分返回。

Get DescriptorValue
bmRequestType0x80
  bmRequestType.Recipient0b00000(Device)
  bmRequestType.Type0b00(Standard)
  bmRequestType.Direction0b1(Device-to-Host)
bRequest0x06(Get Descriptor)
wValue0x0200(Configuration #0)
wIndex0x0000
wLength0x???(wTotalLength)

下面举例说明一个获取接口关联描述符 (Interface Association Descriptor)的过程。使用USB分析仪抓包,软件Total Phase Data Center。
示例接口关联描述符 (Interface Association Descriptor)如下:
0

使用USB分析仪抓包可以看到,获取配置描述符Configuration Descriptor,而接口关联描述符 (Interface Association Descriptor)就包含在其中:
1

接口关联描述符 (Interface Association Descriptor)的获取过程如下:
2

再展开看到详细的过程:
3
完成整个接口关联描述符 (Interface Association Descriptor)的获取。


描述符示例

这里举例一个带有该描述符的示例设备。

Device Descriptor

OffsetFieldSizeValueDescription
0bLength10x12
1bDescriptorType10x01DEVICE
2bcdUSB20x02102.10
4bDeviceClass10xefMiscellaneous
5bDeviceSubClass10x02Common
6bDeviceProtocol10x01Interface Association Descriptor
7bMaxPacketSize010x40
8idVendor20x046d
10idProduct20xc31c
12bcdDevice20x00010.01
14iManufacturer10x01
15iProduct10x02
16iSerialNumber10x00
17bNumConfigurations10x01

Configuration Descriptor

OffsetFieldSizeValueDescription
0bLength10x09
1bDescriptorType10x02CONFIGURATION
2wTotalLength20x017d
4bNumInterfaces10x05
5bConfigurationValue10x01
6iConfiguration10x00
7bmAttributes10x80
8bMaxPower10xfa

Interface Association Descriptor(IAD)

OffsetFieldSizeValueDescription
0bLength10x08
1bDescriptorType10x0b
2bFirstInterface10x00
3bInterfaceCount10x02
4bFunctionClass10x0eVideo
5bFunctionSubClass10x03Video Interface Collection
6bFunctionProtocol10x00
7iFunction10x00

Interface Descriptor

OffsetFieldSizeValueDescription
0bLength10x09
1bDescriptorType10x04INTERFACE
2bInterfaceNumber10x00
3bAlternateSetting10x00
4bNumEndpoints10x01
5bInterfaceClass10x0eVideo
6bInterfaceSubClass10x01Video Control
7bInterfaceProtocol10x00
8iInterface10x00

Video Interface Header Descriptor

OffsetFieldSizeValueDescription
0bLength10x0d

省略中间的Video类描述符。

Interface Descriptor

OffsetFieldSizeValueDescription
0bLength10x09
1bDescriptorType10x04INTERFACE
2bInterfaceNumber10x01
3bAlternateSetting10x00
4bNumEndpoints10x00
5bInterfaceClass10x0eVideo
6bInterfaceSubClass10x02Video Streaming
7bInterfaceProtocol10x00
8iInterface10x00

Video Input Header Descriptor

OffsetFieldSizeValueDescription
0bLength10x0e

后续描述符省略。


附录

USB2.0/USB3.x Interface Association Descriptor

OffsetFieldSizeValueDescription
0bLength1NumberSize of this descriptor in bytes.
1bDescriptorType1ConstantINTERFACE ASSOCIATION Descriptor.
2bFirstInterface1NumberInterface number of the first interface that is associated with this function.
3bInterfaceCount1NumberNumber of contiguous interfaces that are associated with this function.
4bFunctionClass1ClassClass code (assigned by USB-IF).
A value of zero is not allowed in this descriptor.
If this field is FFH, the function class is vendor-specific.
All other values are reserved for assignment by the USB-IF.
5bFunctionSubClass1SubClassSubclass code (assigned by USB-IF).
If the bFunctionClass field is not set to FFH all values are reserved for assignment by the USB-IF.
6bFunctionProtocol1ProtocolProtocol code (assigned by USB-IF). These codes are qualified by the values of the bFunctionClass and bFunctionSubClass fields.
7iFunction1IndexIndex of string descriptor describing this function.

Example Device Descriptor Using Class Codes for IAD

OffsetFieldSizeValueDescription
0bLength1NumberSize of this descriptor in bytes
1bDescriptorType1ConstantSee Table 9-8, USB Specification, Revision 2.0
2bcdUSB2BCDSee Table 9-8, USB Specification, Revision 2.0
4bDeviceClass1EFHMiscellaneous Device Class
5bDeviceSubClass102HCommon Class
6bDeviceProtocol101HInterface Association Descriptor
7bMaxPacketSize01NumberSee Table 9-8, USB Specification, Revision 2.0
8idVendor2IDSee Table 9-8, USB Specification, Revision 2.0
10idProduct2IDSee Table 9-8, USB Specification, Revision 2.0
12bcdDevice2BCDSee Table 9-8, USB Specification, Revision 2.0
14iManufacturer1IndexSee Table 9-8, USB Specification, Revision 2.0
15iProduct1IndexSee Table 9-8, USB Specification, Revision 2.0
16iSerialNumber1IndexSee Table 9-8, USB Specification, Revision 2.0
17bNumConfigurations1NumberSee Table 9-8, USB Specification, Revision 2.0

Example Device Framework Using Interface Association Descriptors

0


[参考资料]

Universal Serial Bus Specification Revision 2.0

Universal Serial Bus 3.0 Specification

Universal Serial Bus 3.1 Specification

Universal Serial Bus 3.2 Specification

USB ECN : Interface Association Descriptor

USB Interface Association Descriptor Device Class Code and Use Model

USB Complete, 5th Edition

USB开发大全

USB2.0与OTG规范及开发指南

Microsoft USB Interface Association Descriptor


本文链接:https://blog.csdn.net/u012028275/article/details/109790166

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值