====== USB声卡描述符样例 ====== ===== - 一个USB Audio的配置描述符 USB数据包 ===== '' /* Frame (281 bytes) */ \\ static const unsigned char pkt2[281] = { \\ 0x1c, 0x00, 0xb0, 0x98, 0xed, 0x62, 0x80, 0xfa, \\ 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, \\ 0x01, 0x01, 0x00, 0x04, 0x00, 0x80, 0x02, 0xfd, \\ 0x00, 0x00, 0x00, 0x01, 0x09, 0x02, 0xfd, 0x00, \\ 0x04, 0x01, 0x00, 0x80, 0x32, 0x09, 0x04, 0x00, \\ 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x0a, 0x24, \\ 0x01, 0x00, 0x01, 0x64, 0x00, 0x02, 0x01, 0x02, \\ 0x0c, 0x24, 0x02, 0x01, 0x01, 0x01, 0x00, 0x02, \\ 0x03, 0x00, 0x00, 0x00, 0x0c, 0x24, 0x02, 0x04, \\ 0x01, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, \\ 0x09, 0x24, 0x03, 0x03, 0x01, 0x03, 0x00, 0x06, \\ 0x00, 0x09, 0x24, 0x03, 0x02, 0x01, 0x01, 0x00, \\ 0x09, 0x00, 0x07, 0x24, 0x05, 0x09, 0x01, 0x05, \\ 0x00, 0x0a, 0x24, 0x06, 0x06, 0x08, 0x01, 0x01, \\ 0x02, 0x02, 0x00, 0x09, 0x24, 0x06, 0x05, 0x04, \\ 0x01, 0x43, 0x00, 0x00, 0x09, 0x24, 0x06, 0x07, \\ 0x04, 0x01, 0x03, 0x00, 0x00, 0x0d, 0x24, 0x04, \\ 0x08, 0x02, 0x01, 0x07, 0x02, 0x03, 0x00, 0x00, \\ 0x00, 0x00, 0x09, 0x04, 0x01, 0x00, 0x00, 0x01, \\ 0x02, 0x00, 0x00, 0x09, 0x04, 0x01, 0x01, 0x01, \\ 0x01, 0x02, 0x00, 0x00, 0x07, 0x24, 0x01, 0x01, \\ 0x01, 0x01, 0x00, 0x0e, 0x24, 0x02, 0x01, 0x02, \\ 0x02, 0x10, 0x02, 0x44, 0xac, 0x00, 0x80, 0xbb, \\ 0x00, 0x09, 0x05, 0x05, 0x01, 0xc0, 0x00, 0x01, \\ 0x00, 0x00, 0x07, 0x25, 0x01, 0x01, 0x00, 0x00, \\ 0x00, 0x09, 0x04, 0x02, 0x00, 0x00, 0x01, 0x02, \\ 0x00, 0x00, 0x09, 0x04, 0x02, 0x01, 0x01, 0x01, \\ 0x02, 0x00, 0x00, 0x07, 0x24, 0x01, 0x02, 0x01, \\ 0x01, 0x00, 0x0e, 0x24, 0x02, 0x01, 0x01, 0x02, \\ 0x10, 0x02, 0x44, 0xac, 0x00, 0x80, 0xbb, 0x00, \\ 0x09, 0x05, 0x86, 0x01, 0x64, 0x00, 0x01, 0x00, \\ 0x00, 0x07, 0x25, 0x01, 0x01, 0x00, 0x00, 0x00, \\ 0x09, 0x04, 0x03, 0x00, 0x01, 0x03, 0x00, 0x00, \\ 0x00, 0x09, 0x21, 0x01, 0x02, 0x00, 0x01, 0x22, \\ 0x29, 0x00, 0x07, 0x05, 0x83, 0x03, 0x08, 0x00, \\ 0x20 \\ }; \\ '' ===== - 配置描述符包分析 ===== Frame 8: 281 bytes on wire (2248 bits), 281 bytes captured (2248 bits) on interface 0 USB URB CONFIGURATION DESCRIPTOR INTERFACE DESCRIPTOR (0.0): class Audio Class-specific Audio Control Interface Descriptor: Header Descriptor Class-specific Audio Control Interface Descriptor: Input terminal descriptor Class-specific Audio Control Interface Descriptor: Input terminal descriptor Class-specific Audio Control Interface Descriptor: Output terminal descriptor Class-specific Audio Control Interface Descriptor: Output terminal descriptor Class-specific Audio Control Interface Descriptor: Selector unit descriptor Class-specific Audio Control Interface Descriptor: Feature unit descriptor Class-specific Audio Control Interface Descriptor: Feature unit descriptor Class-specific Audio Control Interface Descriptor: Feature unit descriptor Class-specific Audio Control Interface Descriptor: Mixer unit descriptor INTERFACE DESCRIPTOR (1.0): class Audio INTERFACE DESCRIPTOR (1.1): class Audio Class-specific Audio Streaming Interface Descriptor: General AS Descriptor Class-specific Audio Streaming Interface Descriptor: Format type descriptor ENDPOINT DESCRIPTOR Class-specific Audio Streaming Endpoint Descriptor INTERFACE DESCRIPTOR (2.0): class Audio INTERFACE DESCRIPTOR (2.1): class Audio Class-specific Audio Streaming Interface Descriptor: General AS Descriptor Class-specific Audio Streaming Interface Descriptor: Format type descriptor ENDPOINT DESCRIPTOR Class-specific Audio Streaming Endpoint Descriptor INTERFACE DESCRIPTOR (3.0): class HID HID DESCRIPTOR ENDPOINT DESCRIPTOR Frame 2: 281 bytes on wire (2248 bits), 281 bytes captured (2248 bits) on interface 0 Interface id: 0 (\\.\pipe\wireshark_extcap_\\.\USBPcap1_20210206011049) Interface name: \\.\pipe\wireshark_extcap_\\.\USBPcap1_20210206011049 Encapsulation type: USB packets with USBPcap header (152) Arrival Time: Feb 6, 2021 01:11:12.962023000 中国标准时间 [Time shift for this packet: 0.000000000 seconds] Epoch Time: 1612545072.962023000 seconds [Time delta from previous captured frame: 0.000000000 seconds] [Time delta from previous displayed frame: 0.000000000 seconds] [Time since reference or first frame: 0.000000000 seconds] Frame Number: 2 Frame Length: 281 bytes (2248 bits) Capture Length: 281 bytes (2248 bits) [Frame is marked: True] [Frame is ignored: False] [Protocols in frame: usb:usbaudio:usbaudio:usbaudio:usbaudio:usbaudio:usbaudio:usbaudio:usbaudio:usbaudio:usbaudio:usbaudio:usbaudio:usbaudio:usbaudio:usbaudio:usbaudio:usbhid] USB URB [Source: 1.4.0] [Destination: host] USBPcap pseudoheader length: 28 IRP ID: 0xfffffa8062ed98b0 IRP USBD_STATUS: USBD_STATUS_SUCCESS (0x00000000) URB Function: URB_FUNCTION_CONTROL_TRANSFER (0x0008) IRP information: 0x01, Direction: PDO -> FDO 0000 000. = Reserved: 0x00 .... ...1 = Direction: PDO -> FDO (0x1) URB bus id: 1 Device address: 4 Endpoint: 0x80, Direction: IN 1... .... = Direction: IN (1) .... 0000 = Endpoint number: 0 URB transfer type: URB_CONTROL (0x02) Packet Data Length: 253 [Request in: 1] [Time from request: 0.000000000 seconds] Control transfer stage: Data (1) CONFIGURATION DESCRIPTOR bLength: 9 bDescriptorType: 0x02 (CONFIGURATION) wTotalLength: 253 bNumInterfaces: 4 bConfigurationValue: 1 iConfiguration: 0 Configuration bmAttributes: 0x80 NOT SELF-POWERED NO REMOTE-WAKEUP 1... .... = Must be 1: Must be 1 for USB 1.1 and higher .0.. .... = Self-Powered: This device is powered from the USB bus ..0. .... = Remote Wakeup: This device does NOT support remote wakeup bMaxPower: 50 (100mA) INTERFACE DESCRIPTOR (0.0): class Audio bLength: 9 bDescriptorType: 0x04 (INTERFACE) bInterfaceNumber: 0 bAlternateSetting: 0 bNumEndpoints: 0 bInterfaceClass: Audio (0x01) bInterfaceSubClass: 0x01 bInterfaceProtocol: 0x00 iInterface: 0 Class-specific Audio Control Interface Descriptor: Header Descriptor bLength: 10 bDescriptorType: 0x24 (audio class interface) Subtype: Header Descriptor (0x01) Version: 1.00 Total length: 100 Total number of interfaces: 2 Interface number: 1 Interface number: 2 Class-specific Audio Control Interface Descriptor: Input terminal descriptor bLength: 12 bDescriptorType: 0x24 (audio class interface) Subtype: Input terminal descriptor (0x02) Terminal ID: 1 Terminal Type: USB Streaming (0x0101) Assoc Terminal: 0 Number Channels: 2 Channel Config: 0x0003, Left Front, Right Front .... .... .... ...1 = Left Front: True .... .... .... ..1. = Right Front: True .... .... .... .0.. = Center Front: False .... .... .... 0... = Low Frequency Enhancement: False .... .... ...0 .... = Left Surround: False .... .... ..0. .... = Right Surround: False .... .... .0.. .... = Left of Center: False .... .... 0... .... = Right of Center: False .... ...0 .... .... = Surround: False .... ..0. .... .... = Side Left: False .... .0.. .... .... = Side Right: False .... 0... .... .... = Top: False 0000 .... .... .... = Reserved: 0x0 Channel Names: 0 Terminal: 0 Class-specific Audio Control Interface Descriptor: Input terminal descriptor bLength: 12 bDescriptorType: 0x24 (audio class interface) Subtype: Input terminal descriptor (0x02) Terminal ID: 4 Terminal Type: Microphone (0x0201) Assoc Terminal: 0 Number Channels: 1 Channel Config: 0x0001, Left Front .... .... .... ...1 = Left Front: True .... .... .... ..0. = Right Front: False .... .... .... .0.. = Center Front: False .... .... .... 0... = Low Frequency Enhancement: False .... .... ...0 .... = Left Surround: False .... .... ..0. .... = Right Surround: False .... .... .0.. .... = Left of Center: False .... .... 0... .... = Right of Center: False .... ...0 .... .... = Surround: False .... ..0. .... .... = Side Left: False .... .0.. .... .... = Side Right: False .... 0... .... .... = Top: False 0000 .... .... .... = Reserved: 0x0 Channel Names: 0 Terminal: 0 Class-specific Audio Control Interface Descriptor: Output terminal descriptor bLength: 9 bDescriptorType: 0x24 (audio class interface) Subtype: Output terminal descriptor (0x03) Terminal ID: 3 Terminal Type: Speaker (0x0301) Assoc Terminal: 0 Source ID: 6 Terminal: 0 Class-specific Audio Control Interface Descriptor: Output terminal descriptor bLength: 9 bDescriptorType: 0x24 (audio class interface) Subtype: Output terminal descriptor (0x03) Terminal ID: 2 Terminal Type: USB Streaming (0x0101) Assoc Terminal: 0 Source ID: 9 Terminal: 0 Class-specific Audio Control Interface Descriptor: Selector unit descriptor bLength: 7 bDescriptorType: 0x24 (audio class interface) Subtype: Selector unit descriptor (0x05) Unit ID: 9 Number In Pins: 1 Source ID: 5 Selector : 0 Class-specific Audio Control Interface Descriptor: Feature unit descriptor bLength: 10 bDescriptorType: 0x24 (audio class interface) Subtype: Feature unit descriptor (0x06) Unit ID: 6 Source ID: 8 Control Size: 1 Controls: 0102 Control: 0x01, Mute .... ...1 = Mute: True .... ..0. = Volume: False .... .0.. = Bass: False .... 0... = Mid: False ...0 .... = Treble: False ..0. .... = Graphic Equalizer: False .0.. .... = Automatic Gain: False 0... .... = Delay: False Control: 0x02, Loudness .... ...0 = Bass Boost: False .... ..1. = Loudness: True 0000 00.. = Reserved: 0x00 Feature: 2 Class-specific Audio Control Interface Descriptor: Feature unit descriptor bLength: 9 bDescriptorType: 0x24 (audio class interface) Subtype: Feature unit descriptor (0x06) Unit ID: 5 Source ID: 4 Control Size: 1 Controls: 4300 Control: 0x43, Mute, Volume, Automatic Gain .... ...1 = Mute: True .... ..1. = Volume: True .... .0.. = Bass: False .... 0... = Mid: False ...0 .... = Treble: False ..0. .... = Graphic Equalizer: False .1.. .... = Automatic Gain: True 0... .... = Delay: False Control: 0x00 .... ...0 = Bass Boost: False .... ..0. = Loudness: False 0000 00.. = Reserved: 0x00 Feature: 0 Class-specific Audio Control Interface Descriptor: Feature unit descriptor bLength: 9 bDescriptorType: 0x24 (audio class interface) Subtype: Feature unit descriptor (0x06) Unit ID: 7 Source ID: 4 Control Size: 1 Controls: 0300 Control: 0x03, Mute, Volume .... ...1 = Mute: True .... ..1. = Volume: True .... .0.. = Bass: False .... 0... = Mid: False ...0 .... = Treble: False ..0. .... = Graphic Equalizer: False .0.. .... = Automatic Gain: False 0... .... = Delay: False Control: 0x00 .... ...0 = Bass Boost: False .... ..0. = Loudness: False 0000 00.. = Reserved: 0x00 Feature: 0 Class-specific Audio Control Interface Descriptor: Mixer unit descriptor bLength: 13 bDescriptorType: 0x24 (audio class interface) Subtype: Mixer unit descriptor (0x04) Unit ID: 8 Number In Pins: 2 Source ID: 1 Source ID: 7 Number Channels: 2 Channel Config: 0x0003, Left Front, Right Front .... .... .... ...1 = Left Front: True .... .... .... ..1. = Right Front: True .... .... .... .0.. = Center Front: False .... .... .... 0... = Low Frequency Enhancement: False .... .... ...0 .... = Left Surround: False .... .... ..0. .... = Right Surround: False .... .... .0.. .... = Left of Center: False .... .... 0... .... = Right of Center: False .... ...0 .... .... = Surround: False .... ..0. .... .... = Side Left: False .... .0.. .... .... = Side Right: False .... 0... .... .... = Top: False 0000 .... .... .... = Reserved: 0x0 Channel Names: 0 Controls: 0x00 Mixer: 0 INTERFACE DESCRIPTOR (1.0): class Audio bLength: 9 bDescriptorType: 0x04 (INTERFACE) bInterfaceNumber: 1 bAlternateSetting: 0 bNumEndpoints: 0 bInterfaceClass: Audio (0x01) bInterfaceSubClass: 0x02 bInterfaceProtocol: 0x00 iInterface: 0 INTERFACE DESCRIPTOR (1.1): class Audio bLength: 9 bDescriptorType: 0x04 (INTERFACE) bInterfaceNumber: 1 bAlternateSetting: 1 bNumEndpoints: 1 bInterfaceClass: Audio (0x01) bInterfaceSubClass: 0x02 bInterfaceProtocol: 0x00 iInterface: 0 Class-specific Audio Streaming Interface Descriptor: General AS Descriptor bLength: 7 bDescriptorType: 0x24 (audio class interface) Subtype: General AS Descriptor (0x01) Terminal ID: 1 Interface delay in frames: 1 Format: 0x0001 Class-specific Audio Streaming Interface Descriptor: Format type descriptor bLength: 14 bDescriptorType: 0x24 (audio class interface) Subtype: Format type descriptor (0x02) FormatType: 1 Number Channels: 2 Subframe Size: 2 Bit Resolution: 16 Samples Frequence Type: 2 Samples Frequence: 44100 Samples Frequence: 48000 ENDPOINT DESCRIPTOR bLength: 9 bDescriptorType: 0x05 (ENDPOINT) bEndpointAddress: 0x05 OUT Endpoint:5 0... .... = Direction: OUT Endpoint .... 0101 = Endpoint Number: 0x5 bmAttributes: 0x01 .... ..01 = Transfertype: Isochronous-Transfer (0x1) .... 00.. = Synchronisationtype: No Sync (0x0) ..00 .... = Behaviourtype: Data-Endpoint (0x0) wMaxPacketSize: 192 ...0 0... .... .... = Transactions per microframe: 1 (0) .... ..00 1100 0000 = Maximum Packet Size: 192 bInterval: 1 Class-specific Audio Streaming Endpoint Descriptor bLength: 7 bDescriptorType: 0x25 (audio class endpoint) Subtype: 0x01 INTERFACE DESCRIPTOR (2.0): class Audio bLength: 9 bDescriptorType: 0x04 (INTERFACE) bInterfaceNumber: 2 bAlternateSetting: 0 bNumEndpoints: 0 bInterfaceClass: Audio (0x01) bInterfaceSubClass: 0x02 bInterfaceProtocol: 0x00 iInterface: 0 INTERFACE DESCRIPTOR (2.1): class Audio bLength: 9 bDescriptorType: 0x04 (INTERFACE) bInterfaceNumber: 2 bAlternateSetting: 1 bNumEndpoints: 1 bInterfaceClass: Audio (0x01) bInterfaceSubClass: 0x02 bInterfaceProtocol: 0x00 iInterface: 0 Class-specific Audio Streaming Interface Descriptor: General AS Descriptor bLength: 7 bDescriptorType: 0x24 (audio class interface) Subtype: General AS Descriptor (0x01) Terminal ID: 2 Interface delay in frames: 1 Format: 0x0001 Class-specific Audio Streaming Interface Descriptor: Format type descriptor bLength: 14 bDescriptorType: 0x24 (audio class interface) Subtype: Format type descriptor (0x02) FormatType: 1 Number Channels: 1 Subframe Size: 2 Bit Resolution: 16 Samples Frequence Type: 2 Samples Frequence: 44100 Samples Frequence: 48000 ENDPOINT DESCRIPTOR bLength: 9 bDescriptorType: 0x05 (ENDPOINT) bEndpointAddress: 0x86 IN Endpoint:6 1... .... = Direction: IN Endpoint .... 0110 = Endpoint Number: 0x6 bmAttributes: 0x01 .... ..01 = Transfertype: Isochronous-Transfer (0x1) .... 00.. = Synchronisationtype: No Sync (0x0) ..00 .... = Behaviourtype: Data-Endpoint (0x0) wMaxPacketSize: 100 ...0 0... .... .... = Transactions per microframe: 1 (0) .... ..00 0110 0100 = Maximum Packet Size: 100 bInterval: 1 Class-specific Audio Streaming Endpoint Descriptor bLength: 7 bDescriptorType: 0x25 (audio class endpoint) Subtype: 0x01 INTERFACE DESCRIPTOR (3.0): class HID bLength: 9 bDescriptorType: 0x04 (INTERFACE) bInterfaceNumber: 3 bAlternateSetting: 0 bNumEndpoints: 1 bInterfaceClass: HID (0x03) bInterfaceSubClass: No Subclass (0x00) bInterfaceProtocol: 0x00 iInterface: 0 HID DESCRIPTOR bLength: 9 bDescriptorType: 0x21 (HID) bcdHID: 0x0201 bCountryCode: Not Supported (0x00) bNumDescriptors: 1 bDescriptorType: HID Report (0x22) wDescriptorLength: 41 ENDPOINT DESCRIPTOR bLength: 7 bDescriptorType: 0x05 (ENDPOINT) bEndpointAddress: 0x83 IN Endpoint:3 1... .... = Direction: IN Endpoint .... 0011 = Endpoint Number: 0x3 bmAttributes: 0x03 .... ..11 = Transfertype: Interrupt-Transfer (0x3) wMaxPacketSize: 8 ...0 0... .... .... = Transactions per microframe: 1 (0) .... ..00 0000 1000 = Maximum Packet Size: 8 bInterval: 32 ===== - 解读 ===== * 配置包含4个Interface(CONFIGURATION DESCRIPTOR bNumInterfaces: 4) * Interface 0~2 是音频类接口, 4是HID接口 ==== - Interface 0 ==== 共11个描述符,其中: \\ Interface Descriptor 1 \\ Class-specific Audio Control Interface Descriptor : 10 \\ 除去1个头部描述符,余下9个控制描述符如下表 ^序号^ 接口子类 ^ ID ^ 输入源ID ^ 备注 ^ ^1| Input terminal descriptor(0x02) | 1 | | USB Streaming (0x0101) | ^2| Input terminal descriptor(0x02) | 4 | | Microphone (0x0201) | ^3| Output terminal descriptor(0x03) | 3 | 6 | Speaker (0x0301) | ^4| Output terminal descriptor(0x03) | 2 | 9 | USB Streaming (0x0101) | ^5| Selector unit descriptor(0x05) | 9 | 5 | Selector, | ^6| Feature unit descriptor(0x06) | 6 | 8 | Feature Unit,Controls:Mute(0x01) Volume(0x02) | ^7| Feature unit descriptor(0x06) | 5 | 4 | Feature Unit,Controls:Mute, Volume, Automatic Gain(0x43) 0x00 | ^8| Feature unit descriptor(0x06) | 7 | 4 | Feature Unit, Controls:Mute, Volume(0x03) 0x00 | ^9| Mixer unit descriptor(0x04) | 8 | 1/7 | Mixer, Number Channels: 2, Channel Config: Left Front, Right Front(0x0003) | IT(4)(MIC) ---> FU(5)(Mute,Volume) ---> FU(9)(Selector) -----------------------> OT(2)(AS) \-> FU(7)(Mute,Volume) ---> FU(8)(Mixer) ---> FU(6)(Mute,Volume) ---> OT(3)(Speaker) IT(1)(AS) --------------------------/ ==== - Interface 1 ==== ==== - Interface 2 ==== ==== - Interface 3 ====