USB系列之-UAC扬声器+麦克风实例分享

原创 嵌入式Lee 2024-04-06 08:01

.前言

UAC的规格书可以从usb.org网站下载,目前有1.0,2.0,3.0三个版本,本文以1.0为例分享一个UAC扬声器的实例, 重点在于描述符拓扑。

规格书《UAC1.0/USB_AV_Specification_Rev_1.0》定义了UAC设备类完整的信息,但是比较复杂,UAC1.0\BasicAudioDevice-10\BasicAudioDevice-10.pdf》定义了其一个最小子集,一般我们实现其子集就够了。所以我们可以参考BasicAudioDevice-10.pdf的最简拓扑结构实现设备,然后具体的描述符,请求等细节可以参考USB_AV_Specification_Rev_1.0

.拓扑

BasicAudioDevice-10.pdf定义了需要支持的3个设备

Headphone:耳机设备,实际上声音播放的都算,所以PC上叫扬声器或者耳机。

Microphone:麦克风设备。

Headset:以上两者的集合,既有麦克风又有扬声器。

我们接下来就分三篇分享下这个三个设备实例,包括描述符拓扑,枚举过程等。

前面已经分享了扬声器和麦克风设备,本文继续分享扬声器+麦克风实例。

我们这里以最简单的单声道为例。

如下是其拓扑结构,本示例拓扑包括特征单元7和混音单元8,可以不要,即可以简化为如下

麦克风: mic采集 -> 输入终端4 -> 特征单元5 -> 输出终端6- > USB IN端点。

扬声器:USB OUT端点 -> 输入终端1->特征单元2->输出终端3 -> 喇叭输出。

即前面介绍的扬声器和麦克风的组合。

其中特征单元用于静音,音量控制等。

.描述符拓扑

相关描述符参考BasicAudioDevice-10.pdf的第七章

我这里分享一个基于IAD的描述符拓扑实例

一共3个接口,接口2是控制接口,接口3是扬声器流,接口4是麦克风流。

接口3alt00带宽接口,设置接口选择该alt时关闭扬声器流,alt1是数据流接口,设置接口选择该alt时启动扬声器流,该接口下有一个OUT端点用于接收数据。

接口4alt00带宽接口,设置接口选择该alt时关闭麦克风流,alt1是数据流接口,设置接口选择该alt时启动麦克风流,该接口下有一个IN端点用于发送数据。

控制接口中包括

扬声器的:输入终端1,特征单元2和输出终端3。流接口3alt 1绑定到输入终端,

而输入终端对应的是OUT端点0x02

麦克风的:输入终端4,特征单元5和输出终端6。流接口4alt 1绑定到输出终端,

而输出终端对应的是IN端点0x82,注意这里在特征单元5和输出终端6之间插入了选择单元9.

四. 描述符实例

设备描述符和配置描述符如下,字符串描述符就略去了,描述符后有详细的注释和注意说明,不再赘述。

static const uint8_t dev_desc[] = {    0x12,        /* bLength 本描述符长度,固定为0x12 */    0x01,        /* bDescriptorType 描述符类型DEVICE=1, 见Table 9-5. Descriptor Types */    0x00,0x02,   /* bcdUSB USB规格书发布编号,BCD,小端 */    /* bDeviceClass-bDeviceSubClass-DeviceProtocol决定具体设备类型 见https://www.usb.org/defined-class-codes     * 这里EF-02-01表示IAD设备     */    0xEF,        /* bDeviceClass 设备类类型  */    0x02,        /* bDeviceSubClass 设备子类 */    0x01,        /* bDeviceProtocol 设备协议 */    0x40,        /* bMaxPacketSize0 控制端点最大包大小 */    0x4A,0x4C,   /* idVendor 厂商ID VID,小端*/    0x55,0x4C,   /* idProduct 产品ID PID,小端*/    0x00,0x01,   /* bcdDevice 设备发布号,BCD,小端*/    0x01,        /* iManufacturer 制造商字符串描述符索引 */      0x02,        /* iProduct 产品字符串描述符索引 */    0x03,        /* iSerialNumber 设备序列号字符串描述符索引 0则不使用 */    0x01,        /* bNumConfigurations 配置个数 */};
static const uint8_t cfg_desc[] = {    /* 配置描述符见Table 9-10. Standard Configuration Descriptor */    0x09,  /* bLength 本描述符长度,固定为9 */    0x02,  /* bDescriptorType 描述符类型CONFIGURATION =0x02, 见Table 9-5. Descriptor Types P251 */    0xCF,  /* wTotalLength 本配置符所有内容长度,小端 */    0x00,    0x03,  /* bNumInterfaces 本配置的接口数 一个控制一个流 */    0x01,  /* bConfigurationValue 设置配置请求,选择该配置的对应的设置值 */    0x00,  /* iConfiguration 本配置对应的字符串描述符,配置为0则没有     */    0x80,  /* bmAttributes 配置特征 D7固定为1 D6:Self-powered D5:Remote Wakeup*/    0xC8,  /* bMaxPower 最大消耗电流,单位2mA */
    /********************************************************     *           以下是MIC+SPK部分     *******************************************************/    /**     * IAD描述符  参考InterfaceAssociationDescriptor_ecn P4    */    0x08,         /* bLength 本描述符长度,固定为8 */    0x0B,         /* bDescriptorType 描述符类型 INTERFACE_ASSOCIATION=0x0B 参考InterfaceAssociationDescriptor_ecn P3 */    SPK_AC_ITF,   /* bFirstInterface 本IAD下第一个接口 */    0x03,         /* bInterfaceCount 本IAD下接口数,默认一个控制接口一个SPK流接口一个MIC流接口 */    0x01,         /* bFunctionClass UAC是接口中说明类功能 这里应该是接口类 见https://www.usb.org/defined-class-codes (Audio=1) 见audio10.pdf P99 Table A-1: Audio Interface Class Code AUDIO=1 */    0x02,         /* bFunctionSubClass  UAC是接口中说明类功能 这里应该是接口类子类 见audio10.pdf P99 Table A-2: Audio Interface Subclass Codes AUDIOSTREAMING=0x02 */    0x00,         /* bFunctionProtocol UAC是接口中说明类功能 这里应该是接口协议号 见audio10.pdf P99 Table A-3: Audio Interface Protocol Codes PR_PROTOCOL_UNDEFINED=0x00  */    0x07,         /* iFunction 对应字符串索引                                */
        /********************************************************         *           控制接口部分         *******************************************************/        /* 接口描述符 UAC是接口描述符说明功能          * 见usb_20 P268 Table 9-12. Standard Interface Descriptor         */        0x09,         /* bLength                */        0x04,         /* bDescriptorType   见usb_20 P251 Table 9-5. Descriptor Types  INTERFACE=4   */        SPK_AC_ITF,   /* bInterfaceNumber       */        0x00,         /* bAlternateSetting      */        0x00,         /* bNumEndpoints 本接口下无端点*/        0x01,         /* bInterfaceClass    (Audio)  见audio10.pdf P99 Table A-1: Audio Interface Class Code AUDIO=1  */        0x01,         /* bInterfaceSubClass (Audio Control) 见audio10.pdf P99 Table A-2: Audio Interface Subclass Codes AUDIOCONTROL=0x01 */        0x00,         /* bInterfaceProtocol   见audio10.pdf P99 Table A-3: Audio Interface Protocol Codes PR_PROTOCOL_UNDEFINED=0x00  */        0x07,         /* iInterface 对应字符串索引           */
        /* BasicAudioDevice-10.pdf P57 Table 7-4: Headset Class-Specific AC Interface Header Descriptor */        0x0A,         /* bLength */        0x24,         /* bDescriptorType 见audio10.pdf P99 Table A-4: Audio Class-specific Descriptor Types CS_INTERFACE=0x24  */        0x01,         /* bDescriptorSubtype 见audio10.pdf P100 Table A-5: Audio Class-Specific AC Interface Descriptor Subtypes HEADER=0x01 */        0x00,0x01,    /* bcdADC Audio 1.0 */        0x4D,0x00,   /* wTotalLength 本接口下后续所有描述符的长度 包括本描述符 */        0x02,         /* bInCollection 2个流接口 */        SPK_AS_ITF,   /* baInterfaceNr(1) SPK流接口号 */        MIC_AS_ITF,   /* baInterfaceNr(2) MIC流接口号 */
        /* BasicAudioDevice-10.pdf P22 Table 5-3: Mono Input Terminal Descriptor          * BasicAudioDevice-10.pdf P21 5.3.3.1.3 Headphone Input Terminal ID1 Descriptor         * BasicAudioDevice-10.pdf P58 7.3.3.1.3 Headset Input Terminal ID1 Descriptor        */        0x0C,         /* bLength */        0x24,         /* bDescriptorType 见audio10.pdf P99 Table A-4: Audio Class-specific Descriptor Types CS_INTERFACE=0x24 */        0x02,         /* bDescriptorSubtype 见audio10.pdf P100 Table A-5: Audio Class-Specific AC Interface Descriptor Subtypes INPUT_TERMINAL=0x02 */        SPK_INPUT_TID,/* bTerminalID TID=1*/        0x01,0x01,    /* wTerminalType TT Headphone Input Terminal */        0x00,         /* bAssocTerminal */        0x01,         /* bNrChannels 1个通道 */        0x04,0x00,    /* wChannelConfig Center Front channel. */        0x00,         /* iChannelNames 固定为0 */        0x00,         /* iTerminal 对应字符串描述符索引 */
        /* BasicAudioDevice-10.pdf P24 Table 5-5: Mono Feature Unit Descriptor          * BasicAudioDevice-10.pdf P59 7.3.3.1.7 Headset Feature Unit ID2 Descriptor         */        0x09,         /* bLength */        0x24,         /* bDescriptorType 见audio10.pdf P99 Table A-4: Audio Class-specific Descriptor Types CS_INTERFACE=0x24  */        0x06,         /* bDescriptorSubtype 见audio10.pdf P100 Table A-5: Audio Class-Specific AC Interface Descriptor Subtypes FEATURE_UNIT=0x06 */        SPK_FEATURE_TID,         /* bUnitID   */        SPK_INPUT_TID,           /* bSourceID */        0x01,                 /* bControlSize */        /**            A bit set to 1 indicates that the mentioned            Control is supported for master channel            0:            D0: Mute            D1: Volume            D2: Bass            D3: Mid            D4: Treble            D5: Graphic Equalizer            D6: Automatic Gain            D7: Delay            D8: Bass Boost            D9: Loudness            D10..(n*8-1): Reserved        */        0x01,                 /* bmaControls(0) Mute Control on Master Channel.*/        /*A bit set to 1 indicates that the mentioned          Control is supported for logical channel 1 */        0x02,                 /* bmaControls(1) Volume Control on Center Front channel */        0x00,         /* iFeature 对应字符串描述符索引 */
        /* BasicAudioDevice-10.pdf P25 Table 5-7: Headphone Output Terminal ID3 Descriptor          * BasicAudioDevice-10.pdf P67 7.3.3.1.16 Headset Output Terminal ID3 Descriptor        */        0x09,       /* bLength */        0x24,       /* bDescriptorType 见audio10.pdf P99 Table A-4: Audio Class-specific Descriptor Types CS_INTERFACE=0x24  */        0x03,       /* bDescriptorSubtype 见audio10.pdf P100 Table A-5: Audio Class-Specific AC Interface Descriptor Subtypes OUTPUT_TERMINAL=0x03 */        SPK_OUTPUT_TID,       /* bTerminalID */        0x02, 0x03,           /* 0x0301扬声器 0x0302耳机 Headphones Terminal Type (0x0302) */        0x00,                 /* bAssocTerminal */        SPK_FEATURE_TID,      /* bSourceID */        0x00,                 /* iTerminal */                    /* BasicAudioDevice-10.pdf P59 7.3.3.1.6 Headset Microphone Input Terminal ID4 Descriptor         * BasicAudioDevice-10.pdf P40 6.3.3.1.3 Microphone Input Terminal ID4 Descriptor         * BasicAudioDevice-10.pdf P22 Table 5-3: Mono Input Terminal Descriptor        */        0x0C,       /* bLength */        0x24,       /* bDescriptorType 见audio10.pdf P99 Table A-4: Audio Class-specific Descriptor Types CS_INTERFACE=0x24 */        0x02,       /* bDescriptorSubtype 见audio10.pdf P100 Table A-5: Audio Class-Specific AC Interface Descriptor Subtypes INPUT_TERMINAL=0x02 */        MIC_INPUT_TID,/* bTerminalID TID=4*/        0x01,0x02,    /* wTerminalType TT Terminal is Microphone. */        0x00,         /* bAssocTerminal */        0x01,         /* bNrChannels 1个通道 */        0x04,0x00,    /* wChannelConfig Center Front channel. @todo 0x0000改为0004*/        0x00,         /* iChannelNames 固定为0 */        0x00,         /* iTerminal 对应字符串描述符索引 */
        /*         * BasicAudioDevice-10.pdf P60 7.3.3.1.10 Headset Feature Unit ID5 Descriptor        */        0x09,      /* bLength */        0x24,      /* bDescriptorType 见audio10.pdf P99 Table A-4: Audio Class-specific Descriptor Types CS_INTERFACE=0x24 */        0x06,      /* bDescriptorSubtype 见audio10.pdf P100 Table A-5: Audio Class-Specific AC Interface Descriptor Subtypes FEATURE_UNIT=0x06 */        MIC_FEATURE_TID,      /* bUnitID   */        MIC_INPUT_TID,        /* bSourceID */        0x01,                 /* bControlSize */        /**            A bit set to 1 indicates that the mentioned            Control is supported for master channel            0:            D0: Mute            D1: Volume            D2: Bass            D3: Mid            D4: Treble            D5: Graphic Equalizer            D6: Automatic Gain            D7: Delay            D8: Bass Boost            D9: Loudness            D10..(n*8-1): Reserved        */        0x43,                 /* bmaControls(0) Mute Control on Master Channel.*/        /*A bit set to 1 indicates that the mentioned          Control is supported for logical channel 1 */        0x00,                 /* bmaControls(1) Volume Control on Center Front channel */        0x00,                 /* iFeature 对应字符串描述符索引 */
        /* BasicAudioDevice-10.pdf P66 Table 7-12: Headset Selector Unit ID9 Descriptor for HS2 */        0x07,                 /* bLength */        0x24,                 /* bDescriptorType 见audio10.pdf P99 Table A-4: Audio Class-specific Descriptor Types CS_INTERFACE=0x24 */        0x05,                 /* bDescriptorSubtype 见audio10.pdf P100 Table A-5: Audio Class-Specific AC Interface Descriptor Subtypes SELECTOR_UNIT=0x05 */        MIC_SEL_TID,          /* bUnitID */        0x01,                 /* bNrInPins */        MIC_FEATURE_TID,      /* baSourceID(1) */        0x00,                 /* iSelector */
        /*         * BasicAudioDevice-10.pdf P67 7.3.3.1.17 Headset Output Terminal ID6 Descriptor        */        0x09,    /* bLength */        0x24,    /* bDescriptorType 见audio10.pdf P99 Table A-4: Audio Class-specific Descriptor Types CS_INTERFACE=0x24 */        0x03,    /* bDescriptorSubtype 见audio10.pdf P100 Table A-5: Audio Class-Specific AC Interface Descriptor Subtypes OUTPUT_TERMINAL=0x03 */        MIC_OUTPUT_TID,       /* bTerminalID */        0x01,0x01,            /* wTerminalType USB Streaming Terminal Type*/        0x02,                 /* bAssocTerminal */        MIC_SEL_TID,          /* bSourceID */        0x00,                 /* iTerminal */
        /********************************************************         *           SPK流部分         *******************************************************/
        /* 接口描述符        * usb_20.pdf P268 Table 9-12. Standard Interface Descriptor         * BasicAudioDevice-10.pdf P30  Table 5-13: Headphone Standard AS Interface Descriptor (Alt. Set. 0)        */        0x09,    /* bLength */        0x04,    /* bDescriptorType INTERFACE */        SPK_AS_ITF,    /* bInterfaceNumber */        0x00,    /* bAlternateSetting */        0x00,    /* bNumEndpoints */        0x01,    /* bInterfaceClass 见audio10.pdf P99 Table A-1: Audio Interface Class Code AUDIO=1  */        0x02,    /* bInterfaceSubClass 见audio10.pdf P99 Table A-2: Audio Interface Subclass Codes AUDIOSTREAMING=0x02 */        0x00,    /* bInterfaceProtocol 见audio10.pdf P99 Table A-3: Audio Interface Protocol Codes PR_PROTOCOL_UNDEFINED = 0x00 */        0x00,    /* iInterface         */
        /* 接口描述符        * usb_20.pdf P268 Table 9-12. Standard Interface Descriptor         BasicAudioDevice-10.pdf P31  Table 5-14: Headphone Standard AS Interface Descriptor (Alt. Set .1)        */        0x09,   /* bLength */        0x04,   /* bDescriptorType INTERFACE */        SPK_AS_ITF,   /* bInterfaceNumber */        0x01,   /* bAlternateSetting */        0x01,   /* bNumEndpoints 一个端点 */        0x01,   /* bInterfaceClass 见audio10.pdf P99 Table A-1: Audio Interface Class Code AUDIO=1 */        0x02,   /* bInterfaceSubClass 见audio10.pdf P99 Table A-2: Audio Interface Subclass Codes AUDIOSTREAMING=0x02 */        0x00,   /* bInterfaceProtocol 见audio10.pdf P99 Table A-3: Audio Interface Protocol Codes PR_PROTOCOL_UNDEFINED = 0x00 */        0x00,   /* iInterface         */
        /*         * BasicAudioDevice-10.pdf P31  Table 5-15: Headphone Class-specific AS General Interface Descriptor        */        0x07,   /* bLength */        0x24,   /* bDescriptorType 见audio10.pdf P99 Table A-4: Audio Class-specific Descriptor Types CS_INTERFACE=0x24  */        0x01,   /* bDescriptorSubtype 见audio10.pdf P100 Table A-6: Audio Class-Specific AS Interface Descriptor Subtypes AS_GENERAL=0x01 */        SPK_INPUT_TID,   /* bTerminalLink */        0x01,            /* bDelay Total interface delay, expressed in frames. Not used and shall be set to 0x00 */        0x01,0x00,       /* wFormatTag PCM Format */
        /*         * BasicAudioDevice-10.pdf P32 Table 5-16: Mono Headphone Type I Format Type Descriptor         */        0x0B,  /* bLength */        0x24,  /* bDescriptorType 见audio10.pdf P99 Table A-4: Audio Class-specific Descriptor Types CS_INTERFACE=0x24  */        0x02,  /* bDescriptorSubtype 见audio10.pdf P100 Table A-6: Audio Class-Specific AS Interface Descriptor Subtypes FORMAT_TYPE=0x02 */        0x01,  /* bFormatType 见frmts10.pdf P20 Table A-4: Format Type Codes FORMAT_TYPE_I=0x01 */        0x01,  /* bNrChannels One channel. */        0x02,  /* bSubFrameSize Two bytes per audio subframe. */        0x10,  /* bBitResolution 16 bits per sample */        0x01,  /* bSamFreqType One frequency supported. */        0x80,0x3E,0x00, /* tSamFreq 0x003E80=16000 */
        /* 端点描述符         * usb_20.pdf P269 Table 9-13. Standard Endpoint Descriptor        * BasicAudioDevice-10.pdf P33 Table 5-18: Mono Headphone Standard AS Audio Data Endpoint Descriptor        */        0x09,  /* bLength */        0x05,  /* bDescriptorType 见usb_20.pdf P251 Table 9-5. Descriptor Types ENDPOINT=5 */        SPK_OUT_EP, /* bEndpointAddress */        0x0D,  /* bmAttributes b[1:0] 01 = Isochronous, b[3:2] 11 = Synchronous */        0x20,  0x00,  /* wMaxPacketSize */        0x01,  /* bInterval 1ms一包 */        0x00,  /* bRefresh  */        0x00,  /* bSynchAddress */
        /*         * BasicAudioDevice-10.pdf P33 Table 5-20: Headphone Class-specific Isoc. Audio Data Endpoint Descriptor        */        0x07,  /* bLength                                */        0x25,  /* bDescriptorType 见audio10.pdf P99 Table A-4: Audio Class-specific Descriptor Types CS_ENDPOINT=0x25 */        0x01,  /* bDescriptorSubtype 见audio10.pdf P101 Table A-8: Audio Class-Specific Endpoint Descriptor Subtypes EP_GENERAL=0x01. */        0x00,  /* bmAttributes No sampling frequency control, no pitch control, no packet padding.*/        0x00,  /* bLockDelayUnits */        0x00,  0x00, /* wLockDelay */
        /********************************************************         *           MIC流部分         *******************************************************/        /* 接口描述符        * usb_20.pdf P268 Table 9-12. Standard Interface Descriptor         * BasicAudioDevice-10.pdf P30  Table 5-13: Headphone Standard AS Interface Descriptor (Alt. Set. 0)        */        0x09,    /* bLength */        0x04,    /* bDescriptorType INTERFACE */        MIC_AS_ITF,    /* bInterfaceNumber */        0x00,    /* bAlternateSetting */        0x00,    /* bNumEndpoints */        0x01,    /* bInterfaceClass 见audio10.pdf P99 Table A-1: Audio Interface Class Code AUDIO=1  */        0x02,    /* bInterfaceSubClass 见audio10.pdf P99 Table A-2: Audio Interface Subclass Codes AUDIOSTREAMING=0x02 */        0x00,    /* bInterfaceProtocol 见audio10.pdf P99 Table A-3: Audio Interface Protocol Codes PR_PROTOCOL_UNDEFINED = 0x00 */        0x00,    /* iInterface         */
        /* 接口描述符        * usb_20.pdf P268 Table 9-12. Standard Interface Descriptor         BasicAudioDevice-10.pdf P31  Table 5-14: Headphone Standard AS Interface Descriptor (Alt. Set .1)        */        0x09,   /* bLength */        0x04,   /* bDescriptorType INTERFACE */        MIC_AS_ITF,   /* bInterfaceNumber */        0x01,   /* bAlternateSetting */        0x01,   /* bNumEndpoints 一个端点 */        0x01,   /* bInterfaceClass 见audio10.pdf P99 Table A-1: Audio Interface Class Code AUDIO=1 */        0x02,   /* bInterfaceSubClass 见audio10.pdf P99 Table A-2: Audio Interface Subclass Codes AUDIOSTREAMING=0x02 */        0x00,   /* bInterfaceProtocol 见audio10.pdf P99 Table A-3: Audio Interface Protocol Codes PR_PROTOCOL_UNDEFINED = 0x00 */        0x00,   /* iInterface         */
        /*         * BasicAudioDevice-10.pdf P31  Table 5-15: Headphone Class-specific AS General Interface Descriptor        */        0x07,   /* bLength */        0x24,   /* bDescriptorType 见audio10.pdf P99 Table A-4: Audio Class-specific Descriptor Types CS_INTERFACE=0x24  */        0x01,   /* bDescriptorSubtype 见audio10.pdf P100 Table A-6: Audio Class-Specific AS Interface Descriptor Subtypes AS_GENERAL=0x01 */        MIC_OUTPUT_TID,   /* bTerminalLink */        0x01,            /* bDelay Total interface delay, expressed in frames. Not used and shall be set to 0x00 */        0x01,0x00,       /* wFormatTag PCM Format */
        /*         * BasicAudioDevice-10.pdf P32 Table 5-16: Mono Headphone Type I Format Type Descriptor         */        0x0B,  /* bLength */        0x24,  /* bDescriptorType 见audio10.pdf P99 Table A-4: Audio Class-specific Descriptor Types CS_INTERFACE=0x24  */        0x02,  /* bDescriptorSubtype 见audio10.pdf P100 Table A-6: Audio Class-Specific AS Interface Descriptor Subtypes FORMAT_TYPE=0x02 */        0x01,  /* bFormatType 见frmts10.pdf P20 Table A-4: Format Type Codes FORMAT_TYPE_I=0x01 */        0x01,  /* bNrChannels One channel. */        0x02,  /* bSubFrameSize Two bytes per audio subframe. */        0x10,  /* bBitResolution 16 bits per sample */        0x01,  /* bSamFreqType One frequency supported. */        0x80,0x3E,0x00, /* tSamFreq 0x003E80=16000 */
        /* 端点描述符         * usb_20.pdf P269 Table 9-13. Standard Endpoint Descriptor        * BasicAudioDevice-10.pdf P33 Table 5-18: Mono Headphone Standard AS Audio Data Endpoint Descriptor        */        0x09,  /* bLength */        0x05,  /* bDescriptorType 见usb_20.pdf P251 Table 9-5. Descriptor Types ENDPOINT=5 */        MIC_IN_EP, /* bEndpointAddress */        0x0D,  /* bmAttributes b[1:0] 01 = Isochronous, b[3:2] 11 = Synchronous */        0x20,  0x00,  /* wMaxPacketSize */        0x01,  /* bInterval 1ms一包 */        0x00,  /* bRefresh  */        0x00,  /* bSynchAddress */
        /*         * BasicAudioDevice-10.pdf P33 Table 5-20: Headphone Class-specific Isoc. Audio Data Endpoint Descriptor        */        0x07,  /* bLength                                */        0x25,  /* bDescriptorType 见audio10.pdf P99 Table A-4: Audio Class-specific Descriptor Types CS_ENDPOINT=0x25 */        0x01,  /* bDescriptorSubtype 见audio10.pdf P101 Table A-8: Audio Class-Specific Endpoint Descriptor Subtypes EP_GENERAL=0x01. */        0x00,  /* bmAttributes No sampling frequency control, no pitch control, no packet padding.*/        0x00,  /* bLockDelayUnits */        0x00,  0x00, /* wLockDelay */};

如下是UsbTreeView抓到的描述符



---------------------- Device Descriptor ----------------------bLength : 0x12 (18 bytes)bDescriptorType : 0x01 (Device Descriptor)bcdUSB : 0x200 (USB Version 2.0)bDeviceClass : 0xEF (Miscellaneous)bDeviceSubClass : 0x02bDeviceProtocol : 0x01 (IAD - Interface Association Descriptor)bMaxPacketSize0 : 0x40 (64 bytes)idVendor : 0x4C4A (Unknown Vendor)idProduct : 0x4C55bcdDevice : 0x0100iManufacturer : 0x01 (String Descriptor 1) Language 0x0409 : "xxxxx.Technology"iProduct : 0x02 (String Descriptor 2) Language 0x0409 : "USB.Audio"iSerialNumber : 0x03 (String Descriptor 3) Language 0x0409 : "0.1"bNumConfigurations : 0x01 (1 Configuration)Data (HexDump) : 12 01 00 02 EF 02 01 40 4A 4C 55 4C 00 01 01 02 .......@JLUL.... 03 01 ..
------------------ Configuration Descriptor -------------------bLength : 0x09 (9 bytes)bDescriptorType : 0x02 (Configuration Descriptor)wTotalLength : 0x00CF (207 bytes)bNumInterfaces : 0x03 (3 Interfaces)bConfigurationValue : 0x01 (Configuration 1)iConfiguration : 0x00 (No String Descriptor)bmAttributes : 0x80 D7: Reserved, set 1 : 0x01 D6: Self Powered : 0x00 (no) D5: Remote Wakeup : 0x00 (no) D4..0: Reserved, set 0 : 0x00MaxPower : 0xC8 (400 mA)Data (HexDump) : 09 02 CF 00 03 01 00 80 C8 08 0B 02 03 01 02 00 ................ 07 09 04 02 00 00 01 01 00 07 0A 24 01 00 01 4D ...........$...F 00 02 03 04 0C 24 02 01 01 01 00 01 04 00 00 00 .....$.......... 09 24 06 02 01 01 01 02 00 09 24 03 03 02 03 00 .$........$..... 02 00 0C 24 02 04 01 02 00 01 04 00 00 00 09 24 ...$...........$ 06 05 04 01 43 00 00 07 24 05 09 01 05 00 09 24 ....C...$......$ 03 06 01 01 02 09 00 09 04 03 00 00 01 02 00 00 ................ 09 04 03 01 01 01 02 00 00 07 24 01 01 01 01 00 ..........$..... 0B 24 02 01 01 02 10 01 80 3E 00 09 05 02 0D 20 .$.......>..... 00 01 00 00 07 25 01 00 00 00 00 09 04 04 00 00 .....%.......... 01 02 00 00 09 04 04 01 01 01 02 00 00 07 24 01 ..............$. 06 01 01 00 0B 24 02 01 01 02 10 01 80 3E 00 09 .....$.......>.. 05 82 0D 20 00 04 00 00 07 25 01 00 00 00 00 ... .....%.....
------------------- IAD Descriptor --------------------bLength : 0x08 (8 bytes)bDescriptorType : 0x0B (Interface Association Descriptor)bFirstInterface : 0x02 (Interface 2)bInterfaceCount : 0x03 (3 Interfaces)*!*ERROR The total number of interfaces (3) must be greater than or equal to the highest linked interface number (base 2 + count 3 = 5)bFunctionClass : 0x01 (Audio)bFunctionSubClass : 0x02 (Audio Streaming)bFunctionProtocol : 0x00iFunction : 0x07 (String Descriptor 7) Language 0x0409 : "USB.Audio"Data (HexDump) : 08 0B 02 03 01 02 00 07 ........
---------------- Interface Descriptor -----------------bLength : 0x09 (9 bytes)bDescriptorType : 0x04 (Interface Descriptor)bInterfaceNumber : 0x02 (Interface 2)bAlternateSetting : 0x00bNumEndpoints : 0x00 (Default Control Pipe only)bInterfaceClass : 0x01 (Audio)bInterfaceSubClass : 0x01 (Audio Control)bInterfaceProtocol : 0x00iInterface : 0x07 (String Descriptor 7) Language 0x0409 : "USB.Audio"Data (HexDump) : 09 04 02 00 00 01 01 00 07 .........
------ Audio Control Interface Header Descriptor ------bLength : 0x0A (10 bytes)bDescriptorType : 0x24 (Audio Interface Descriptor)bDescriptorSubtype : 0x01 (Header)bcdADC : 0x0100wTotalLength : 0x004D (77 bytes)bInCollection : 0x02baInterfaceNr[1] : 0x03baInterfaceNr[2] : 0x04Data (HexDump) : 0A 24 01 00 01 4D 00 02 03 04 .$...F....
------- Audio Control Input Terminal Descriptor -------bLength : 0x0C (12 bytes)bDescriptorType : 0x24 (Audio Interface Descriptor)bDescriptorSubtype : 0x02 (Input Terminal)bTerminalID : 0x01wTerminalType : 0x0101 (USB Streaming)bAssocTerminal : 0x00bNrChannels : 0x01 (1 channel)wChannelConfig : 0x0004 (C)iChannelNames : 0x00 (No String Descriptor)iTerminal : 0x00 (No String Descriptor)Data (HexDump) : 0C 24 02 01 01 01 00 01 04 00 00 00 .$..........
-------- Audio Control Feature Unit Descriptor --------bLength : 0x09 (9 bytes)bDescriptorType : 0x24 (Audio Interface Descriptor)bDescriptorSubtype : 0x06 (Feature Unit)bUnitID : 0x02 (2)bSourceID : 0x01 (1)bControlSize : 0x01 (1 byte per control)bmaControls[0] : 0x01 D0: Mute : 1 D1: Volume : 0 D2: Bass : 0 D3: Mid : 0 D4: Treble : 0 D5: Graphic Equalizer : 0 D6: Automatic Gain : 0 D7: Delay : 0bmaControls[1] : 0x02 D0: Mute : 0 D1: Volume : 1 D2: Bass : 0 D3: Mid : 0 D4: Treble : 0 D5: Graphic Equalizer : 0 D6: Automatic Gain : 0 D7: Delay : 0iFeature : 0x00 (No String Descriptor)Data (HexDump) : 09 24 06 02 01 01 01 02 00 .$.......
------- Audio Control Output Terminal Descriptor ------bLength : 0x09 (9 bytes)bDescriptorType : 0x24 (Audio Interface Descriptor)bDescriptorSubtype : 0x03 (Output Terminal)bTerminalID : 0x03wTerminalType : 0x0302 (Headphones)bAssocTerminal : 0x00 (0)bSourceID : 0x02 (2)iTerminal : 0x00 (No String Descriptor)Data (HexDump) : 09 24 03 03 02 03 00 02 00 .$.......
------- Audio Control Input Terminal Descriptor -------bLength : 0x0C (12 bytes)bDescriptorType : 0x24 (Audio Interface Descriptor)bDescriptorSubtype : 0x02 (Input Terminal)bTerminalID : 0x04wTerminalType : 0x0201 (Microphone)bAssocTerminal : 0x00bNrChannels : 0x01 (1 channel)wChannelConfig : 0x0004 (C)iChannelNames : 0x00 (No String Descriptor)iTerminal : 0x00 (No String Descriptor)Data (HexDump) : 0C 24 02 04 01 02 00 01 04 00 00 00 .$..........
-------- Audio Control Feature Unit Descriptor --------bLength : 0x09 (9 bytes)bDescriptorType : 0x24 (Audio Interface Descriptor)bDescriptorSubtype : 0x06 (Feature Unit)bUnitID : 0x05 (5)bSourceID : 0x04 (4)bControlSize : 0x01 (1 byte per control)bmaControls[0] : 0x43 D0: Mute : 1 D1: Volume : 1 D2: Bass : 0 D3: Mid : 0 D4: Treble : 0 D5: Graphic Equalizer : 0 D6: Automatic Gain : 1 D7: Delay : 0bmaControls[1] : 0x00 D0: Mute : 0 D1: Volume : 0 D2: Bass : 0 D3: Mid : 0 D4: Treble : 0 D5: Graphic Equalizer : 0 D6: Automatic Gain : 0 D7: Delay : 0iFeature : 0x00 (No String Descriptor)Data (HexDump) : 09 24 06 05 04 01 43 00 00 .$....C..
------- Audio Control Selector Unit Descriptor --------bLength : 0x07 (7 bytes)bDescriptorType : 0x24 (Audio Interface Descriptor)bDescriptorSubtype : 0x05 (Selector Unit)bUnitID : 0x09bNrInPins : 0x01 (1 Input Pin)baSourceID[1] : 0x05 (5)iSelector : 0x00 (No String Descriptor)Data (HexDump) : 07 24 05 09 01 05 00 .$.....
------- Audio Control Output Terminal Descriptor ------bLength : 0x09 (9 bytes)bDescriptorType : 0x24 (Audio Interface Descriptor)bDescriptorSubtype : 0x03 (Output Terminal)bTerminalID : 0x06wTerminalType : 0x0101 (USB Streaming)bAssocTerminal : 0x02 (2)bSourceID : 0x09 (9)iTerminal : 0x00 (No String Descriptor)Data (HexDump) : 09 24 03 06 01 01 02 09 00 .$.......
---------------- Interface Descriptor -----------------bLength : 0x09 (9 bytes)bDescriptorType : 0x04 (Interface Descriptor)bInterfaceNumber : 0x03 (Interface 3)bAlternateSetting : 0x00bNumEndpoints : 0x00 (Default Control Pipe only)bInterfaceClass : 0x01 (Audio)bInterfaceSubClass : 0x02 (Audio Streaming)bInterfaceProtocol : 0x00iInterface : 0x00 (No String Descriptor)Data (HexDump) : 09 04 03 00 00 01 02 00 00 .........
---------------- Interface Descriptor -----------------bLength : 0x09 (9 bytes)bDescriptorType : 0x04 (Interface Descriptor)bInterfaceNumber : 0x03 (Interface 3)bAlternateSetting : 0x01bNumEndpoints : 0x01 (1 Endpoint)bInterfaceClass : 0x01 (Audio)bInterfaceSubClass : 0x02 (Audio Streaming)bInterfaceProtocol : 0x00iInterface : 0x00 (No String Descriptor)Data (HexDump) : 09 04 03 01 01 01 02 00 00 .........
-------- Audio Streaming Interface Descriptor ---------bLength : 0x07 (7 bytes)bDescriptorType : 0x24 (Audio Interface Descriptor)bDescriptorSubtype : 0x01 (AS_GENERAL)bTerminalLink : 0x01 (Terminal ID 1)bDelay : 0x01 (1 frame)wFormatTag : 0x0001 (PCM)Data (HexDump) : 07 24 01 01 01 01 00 .$.....
------- Audio Streaming Format Type Descriptor --------bLength : 0x0B (11 bytes)bDescriptorType : 0x24 (Audio Interface Descriptor)bDescriptorSubtype : 0x02 (Format Type)bFormatType : 0x01 (FORMAT_TYPE_I)bNrChannels : 0x01 (1 channel)bSubframeSize : 0x02 (2 bytes per subframe)bBitResolution : 0x10 (16 bits per sample)bSamFreqType : 0x01 (supports 1 sample frequence)tSamFreq[1] : 0x03E80 (16000 Hz)Data (HexDump) : 0B 24 02 01 01 02 10 01 80 3E 00 .$.......>.
----------------- Endpoint Descriptor -----------------bLength : 0x09 (9 bytes)bDescriptorType : 0x05 (Endpoint Descriptor)bEndpointAddress : 0x02 (Direction=OUT EndpointID=2)bmAttributes : 0x0D (TransferType=Isochronous SyncType=Synchronous EndpointType=Data)wMaxPacketSize : 0x0020 Bits 15..13 : 0x00 (reserved, must be zero) Bits 12..11 : 0x00 (0 additional transactions per microframe -> allows 1..1024 bytes per packet) Bits 10..0 : 0x20 (32 bytes per packet)bInterval : 0x01 (1 ms)bRefresh : 0x00bSynchAddress : 0x00Data (HexDump) : 09 05 02 0D 20 00 01 00 00 .... ....
----------- Audio Data Endpoint Descriptor ------------bLength : 0x07 (7 bytes)bDescriptorType : 0x25 (Audio Endpoint Descriptor)bDescriptorSubtype : 0x01 (General)bmAttributes : 0x00 D0 : Sampling Freq : 0x00 (not supported) D1 : Pitch : 0x00 (not supported) D6..2: Reserved : 0x00 D7 : MaxPacketsOnly : 0x00 (no)bLockDelayUnits : 0x00 (Undefined)wLockDelay : 0x0000Data (HexDump) : 07 25 01 00 00 00 00 .%.....
---------------- Interface Descriptor -----------------bLength : 0x09 (9 bytes)bDescriptorType : 0x04 (Interface Descriptor)bInterfaceNumber : 0x04 (Interface 4)bAlternateSetting : 0x00bNumEndpoints : 0x00 (Default Control Pipe only)bInterfaceClass : 0x01 (Audio)bInterfaceSubClass : 0x02 (Audio Streaming)bInterfaceProtocol : 0x00iInterface : 0x00 (No String Descriptor)Data (HexDump) : 09 04 04 00 00 01 02 00 00 .........
---------------- Interface Descriptor -----------------bLength : 0x09 (9 bytes)bDescriptorType : 0x04 (Interface Descriptor)bInterfaceNumber : 0x04 (Interface 4)bAlternateSetting : 0x01bNumEndpoints : 0x01 (1 Endpoint)bInterfaceClass : 0x01 (Audio)bInterfaceSubClass : 0x02 (Audio Streaming)bInterfaceProtocol : 0x00iInterface : 0x00 (No String Descriptor)Data (HexDump) : 09 04 04 01 01 01 02 00 00 .........
-------- Audio Streaming Interface Descriptor ---------bLength : 0x07 (7 bytes)bDescriptorType : 0x24 (Audio Interface Descriptor)bDescriptorSubtype : 0x01 (AS_GENERAL)bTerminalLink : 0x06 (Terminal ID 6)bDelay : 0x01 (1 frame)wFormatTag : 0x0001 (PCM)Data (HexDump) : 07 24 01 06 01 01 00 .$.....
------- Audio Streaming Format Type Descriptor --------bLength : 0x0B (11 bytes)bDescriptorType : 0x24 (Audio Interface Descriptor)bDescriptorSubtype : 0x02 (Format Type)bFormatType : 0x01 (FORMAT_TYPE_I)bNrChannels : 0x01 (1 channel)bSubframeSize : 0x02 (2 bytes per subframe)bBitResolution : 0x10 (16 bits per sample)bSamFreqType : 0x01 (supports 1 sample frequence)tSamFreq[1] : 0x03E80 (16000 Hz)Data (HexDump) : 0B 24 02 01 01 02 10 01 80 3E 00 .$.......>.
----------------- Endpoint Descriptor -----------------bLength : 0x09 (9 bytes)bDescriptorType : 0x05 (Endpoint Descriptor)bEndpointAddress : 0x82 (Direction=IN EndpointID=2)bmAttributes : 0x0D (TransferType=Isochronous SyncType=Synchronous EndpointType=Data)wMaxPacketSize : 0x0020 Bits 15..13 : 0x00 (reserved, must be zero) Bits 12..11 : 0x00 (0 additional transactions per microframe -> allows 1..1024 bytes per packet) Bits 10..0 : 0x20 (32 bytes per packet)bInterval : 0x01 (1 ms)bRefresh : 0x00bSynchAddress : 0x00Data (HexDump) : 09 05 82 0D 20 00 01 00 00 .... ....
----------- Audio Data Endpoint Descriptor ------------bLength : 0x07 (7 bytes)bDescriptorType : 0x25 (Audio Endpoint Descriptor)bDescriptorSubtype : 0x01 (General)bmAttributes : 0x00 D0 : Sampling Freq : 0x00 (not supported) D1 : Pitch : 0x00 (not supported) D6..2: Reserved : 0x00 D7 : MaxPacketsOnly : 0x00 (no)bLockDelayUnits : 0x00 (Undefined)wLockDelay : 0x0000Data (HexDump) : 07 25 01 00 00 00 00 .%.....
--------- Device Qualifier Descriptor (for Full-Speed) --------bLength : 0x0A (10 bytes)bDescriptorType : 0x06 (Device_qualifier Descriptor)bcdUSB : 0x200 (USB Version 2.00)bDeviceClass : 0xEF (Miscellaneous)bDeviceSubClass : 0x02bDeviceProtocol : 0x01 (IAD - Interface Association Descriptor)bMaxPacketSize0 : 0x40 (64 Bytes)bNumConfigurations : 0x01 (1 other-speed configuration)bReserved : 0x00Data (HexDump) : 0A 06 00 02 EF 02 01 40 01 00 .......@..
------------------ Configuration Descriptor -------------------bLength : 0x09 (9 bytes)bDescriptorType : 0x02 (Configuration Descriptor)wTotalLength : 0x00CF (207 bytes)bNumInterfaces : 0x03 (3 Interfaces)bConfigurationValue : 0x01 (Configuration 1)iConfiguration : 0x00 (No String Descriptor)bmAttributes : 0x80 D7: Reserved, set 1 : 0x01 D6: Self Powered : 0x00 (no) D5: Remote Wakeup : 0x00 (no) D4..0: Reserved, set 0 : 0x00MaxPower : 0xC8 (400 mA)Data (HexDump) : 09 02 CF 00 03 01 00 80 C8 08 0B 02 03 01 02 00 ................ 07 09 04 02 00 00 01 01 00 07 0A 24 01 00 01 4D ...........$...F 00 02 03 04 0C 24 02 01 01 01 00 01 04 00 00 00 .....$.......... 09 24 06 02 01 01 01 02 00 09 24 03 03 02 03 00 .$........$..... 02 00 0C 24 02 04 01 02 00 01 04 00 00 00 09 24 ...$...........$ 06 05 04 01 43 00 00 07 24 05 09 01 05 00 09 24 ....C...$......$ 03 06 01 01 02 09 00 09 04 03 00 00 01 02 00 00 ................ 09 04 03 01 01 01 02 00 00 07 24 01 01 01 01 00 ..........$..... 0B 24 02 01 01 02 10 01 80 3E 00 09 05 02 0D 20 .$.......>..... 00 01 00 00 07 25 01 00 00 00 00 09 04 04 00 00 .....%.......... 01 02 00 00 09 04 04 01 01 01 02 00 00 07 24 01 ..............$. 06 01 01 00 0B 24 02 01 01 02 10 01 80 3E 00 09 .....$.......>.. 05 82 0D 20 00 04 00 00 07 25 01 00 00 00 00 ... .....%.....
------------------- IAD Descriptor --------------------bLength : 0x08 (8 bytes)bDescriptorType : 0x0B (Interface Association Descriptor)bFirstInterface : 0x02 (Interface 2)bInterfaceCount : 0x03 (3 Interfaces)*!*ERROR The total number of interfaces (3) must be greater than or equal to the highest linked interface number (base 2 + count 3 = 5)bFunctionClass : 0x01 (Audio)bFunctionSubClass : 0x02 (Audio Streaming)bFunctionProtocol : 0x00iFunction : 0x07 (String Descriptor 7) Language 0x0409 : "USB.Audio"Data (HexDump) : 08 0B 02 03 01 02 00 07 ........
---------------- Interface Descriptor -----------------bLength : 0x09 (9 bytes)bDescriptorType : 0x04 (Interface Descriptor)bInterfaceNumber : 0x02 (Interface 2)bAlternateSetting : 0x00bNumEndpoints : 0x00 (Default Control Pipe only)bInterfaceClass : 0x01 (Audio)bInterfaceSubClass : 0x01 (Audio Control)bInterfaceProtocol : 0x00iInterface : 0x07 (String Descriptor 7) Language 0x0409 : "USB.Audio"Data (HexDump) : 09 04 02 00 00 01 01 00 07 .........
------ Audio Control Interface Header Descriptor ------bLength : 0x0A (10 bytes)bDescriptorType : 0x24 (Audio Interface Descriptor)bDescriptorSubtype : 0x01 (Header)bcdADC : 0x0100wTotalLength : 0x004D (77 bytes)bInCollection : 0x02baInterfaceNr[1] : 0x03baInterfaceNr[2] : 0x04Data (HexDump) : 0A 24 01 00 01 4D 00 02 03 04 .$...F....
------- Audio Control Input Terminal Descriptor -------bLength : 0x0C (12 bytes)bDescriptorType : 0x24 (Audio Interface Descriptor)bDescriptorSubtype : 0x02 (Input Terminal)bTerminalID : 0x01wTerminalType : 0x0101 (USB Streaming)bAssocTerminal : 0x00bNrChannels : 0x01 (1 channel)wChannelConfig : 0x0004 (C)iChannelNames : 0x00 (No String Descriptor)iTerminal : 0x00 (No String Descriptor)Data (HexDump) : 0C 24 02 01 01 01 00 01 04 00 00 00 .$..........
-------- Audio Control Feature Unit Descriptor --------bLength : 0x09 (9 bytes)bDescriptorType : 0x24 (Audio Interface Descriptor)bDescriptorSubtype : 0x06 (Feature Unit)bUnitID : 0x02 (2)bSourceID : 0x01 (1)bControlSize : 0x01 (1 byte per control)bmaControls[0] : 0x01 D0: Mute : 1 D1: Volume : 0 D2: Bass : 0 D3: Mid : 0 D4: Treble : 0 D5: Graphic Equalizer : 0 D6: Automatic Gain : 0 D7: Delay : 0bmaControls[1] : 0x02 D0: Mute : 0 D1: Volume : 1 D2: Bass : 0 D3: Mid : 0 D4: Treble : 0 D5: Graphic Equalizer : 0 D6: Automatic Gain : 0 D7: Delay : 0iFeature : 0x00 (No String Descriptor)Data (HexDump) : 09 24 06 02 01 01 01 02 00 .$.......
------- Audio Control Output Terminal Descriptor ------bLength : 0x09 (9 bytes)bDescriptorType : 0x24 (Audio Interface Descriptor)bDescriptorSubtype : 0x03 (Output Terminal)bTerminalID : 0x03wTerminalType : 0x0302 (Headphones)bAssocTerminal : 0x00 (0)bSourceID : 0x02 (2)iTerminal : 0x00 (No String Descriptor)Data (HexDump) : 09 24 03 03 02 03 00 02 00 .$.......
------- Audio Control Input Terminal Descriptor -------bLength : 0x0C (12 bytes)bDescriptorType : 0x24 (Audio Interface Descriptor)bDescriptorSubtype : 0x02 (Input Terminal)bTerminalID : 0x04wTerminalType : 0x0201 (Microphone)bAssocTerminal : 0x00bNrChannels : 0x01 (1 channel)wChannelConfig : 0x0004 (C)iChannelNames : 0x00 (No String Descriptor)iTerminal : 0x00 (No String Descriptor)Data (HexDump) : 0C 24 02 04 01 02 00 01 04 00 00 00 .$..........
-------- Audio Control Feature Unit Descriptor --------bLength : 0x09 (9 bytes)bDescriptorType : 0x24 (Audio Interface Descriptor)bDescriptorSubtype : 0x06 (Feature Unit)bUnitID : 0x05 (5)bSourceID : 0x04 (4)bControlSize : 0x01 (1 byte per control)bmaControls[0] : 0x43 D0: Mute : 1 D1: Volume : 1 D2: Bass : 0 D3: Mid : 0 D4: Treble : 0 D5: Graphic Equalizer : 0 D6: Automatic Gain : 1 D7: Delay : 0bmaControls[1] : 0x00 D0: Mute : 0 D1: Volume : 0 D2: Bass : 0 D3: Mid : 0 D4: Treble : 0 D5: Graphic Equalizer : 0 D6: Automatic Gain : 0 D7: Delay : 0iFeature : 0x00 (No String Descriptor)Data (HexDump) : 09 24 06 05 04 01 43 00 00 .$....C..
------- Audio Control Selector Unit Descriptor --------bLength : 0x07 (7 bytes)bDescriptorType : 0x24 (Audio Interface Descriptor)bDescriptorSubtype : 0x05 (Selector Unit)bUnitID : 0x09bNrInPins : 0x01 (1 Input Pin)baSourceID[1] : 0x05 (5)iSelector : 0x00 (No String Descriptor)Data (HexDump) : 07 24 05 09 01 05 00 .$.....
------- Audio Control Output Terminal Descriptor ------bLength : 0x09 (9 bytes)bDescriptorType : 0x24 (Audio Interface Descriptor)bDescriptorSubtype : 0x03 (Output Terminal)bTerminalID : 0x06wTerminalType : 0x0101 (USB Streaming)bAssocTerminal : 0x02 (2)bSourceID : 0x09 (9)iTerminal : 0x00 (No String Descriptor)Data (HexDump) : 09 24 03 06 01 01 02 09 00 .$.......
---------------- Interface Descriptor -----------------bLength : 0x09 (9 bytes)bDescriptorType : 0x04 (Interface Descriptor)bInterfaceNumber : 0x03 (Interface 3)bAlternateSetting : 0x00bNumEndpoints : 0x00 (Default Control Pipe only)bInterfaceClass : 0x01 (Audio)bInterfaceSubClass : 0x02 (Audio Streaming)bInterfaceProtocol : 0x00iInterface : 0x00 (No String Descriptor)Data (HexDump) : 09 04 03 00 00 01 02 00 00 .........
---------------- Interface Descriptor -----------------bLength : 0x09 (9 bytes)bDescriptorType : 0x04 (Interface Descriptor)bInterfaceNumber : 0x03 (Interface 3)bAlternateSetting : 0x01bNumEndpoints : 0x01 (1 Endpoint)bInterfaceClass : 0x01 (Audio)bInterfaceSubClass : 0x02 (Audio Streaming)bInterfaceProtocol : 0x00iInterface : 0x00 (No String Descriptor)Data (HexDump) : 09 04 03 01 01 01 02 00 00 .........
-------- Audio Streaming Interface Descriptor ---------bLength : 0x07 (7 bytes)bDescriptorType : 0x24 (Audio Interface Descriptor)bDescriptorSubtype : 0x01 (AS_GENERAL)bTerminalLink : 0x01 (Terminal ID 1)bDelay : 0x01 (1 frame)wFormatTag : 0x0001 (PCM)Data (HexDump) : 07 24 01 01 01 01 00 .$.....
------- Audio Streaming Format Type Descriptor --------bLength : 0x0B (11 bytes)bDescriptorType : 0x24 (Audio Interface Descriptor)bDescriptorSubtype : 0x02 (Format Type)bFormatType : 0x01 (FORMAT_TYPE_I)bNrChannels : 0x01 (1 channel)bSubframeSize : 0x02 (2 bytes per subframe)bBitResolution : 0x10 (16 bits per sample)bSamFreqType : 0x01 (supports 1 sample frequence)tSamFreq[1] : 0x03E80 (16000 Hz)Data (HexDump) : 0B 24 02 01 01 02 10 01 80 3E 00 .$.......>.
----------------- Endpoint Descriptor -----------------bLength : 0x09 (9 bytes)bDescriptorType : 0x05 (Endpoint Descriptor)bEndpointAddress : 0x02 (Direction=OUT EndpointID=2)bmAttributes : 0x0D (TransferType=Isochronous SyncType=Synchronous EndpointType=Data)wMaxPacketSize : 0x0020 (32 bytes)bInterval : 0x01 (1 ms)bRefresh : 0x00bSynchAddress : 0x00Data (HexDump) : 09 05 02 0D 20 00 01 00 00 .... ....
----------- Audio Data Endpoint Descriptor ------------bLength : 0x07 (7 bytes)bDescriptorType : 0x25 (Audio Endpoint Descriptor)bDescriptorSubtype : 0x01 (General)bmAttributes : 0x00 D0 : Sampling Freq : 0x00 (not supported) D1 : Pitch : 0x00 (not supported) D6..2: Reserved : 0x00 D7 : MaxPacketsOnly : 0x00 (no)bLockDelayUnits : 0x00 (Undefined)wLockDelay : 0x0000Data (HexDump) : 07 25 01 00 00 00 00 .%.....
---------------- Interface Descriptor -----------------bLength : 0x09 (9 bytes)bDescriptorType : 0x04 (Interface Descriptor)bInterfaceNumber : 0x04 (Interface 4)bAlternateSetting : 0x00bNumEndpoints : 0x00 (Default Control Pipe only)bInterfaceClass : 0x01 (Audio)bInterfaceSubClass : 0x02 (Audio Streaming)bInterfaceProtocol : 0x00iInterface : 0x00 (No String Descriptor)Data (HexDump) : 09 04 04 00 00 01 02 00 00 .........
---------------- Interface Descriptor -----------------bLength : 0x09 (9 bytes)bDescriptorType : 0x04 (Interface Descriptor)bInterfaceNumber : 0x04 (Interface 4)bAlternateSetting : 0x01bNumEndpoints : 0x01 (1 Endpoint)bInterfaceClass : 0x01 (Audio)bInterfaceSubClass : 0x02 (Audio Streaming)bInterfaceProtocol : 0x00iInterface : 0x00 (No String Descriptor)Data (HexDump) : 09 04 04 01 01 01 02 00 00 .........
-------- Audio Streaming Interface Descriptor ---------bLength : 0x07 (7 bytes)bDescriptorType : 0x24 (Audio Interface Descriptor)bDescriptorSubtype : 0x01 (AS_GENERAL)bTerminalLink : 0x06 (Terminal ID 6)bDelay : 0x01 (1 frame)wFormatTag : 0x0001 (PCM)Data (HexDump) : 07 24 01 06 01 01 00 .$.....
------- Audio Streaming Format Type Descriptor --------bLength : 0x0B (11 bytes)bDescriptorType : 0x24 (Audio Interface Descriptor)bDescriptorSubtype : 0x02 (Format Type)bFormatType : 0x01 (FORMAT_TYPE_I)bNrChannels : 0x01 (1 channel)bSubframeSize : 0x02 (2 bytes per subframe)bBitResolution : 0x10 (16 bits per sample)bSamFreqType : 0x01 (supports 1 sample frequence)tSamFreq[1] : 0x03E80 (16000 Hz)Data (HexDump) : 0B 24 02 01 01 02 10 01 80 3E 00 .$.......>.
----------------- Endpoint Descriptor -----------------bLength : 0x09 (9 bytes)bDescriptorType : 0x05 (Endpoint Descriptor)bEndpointAddress : 0x82 (Direction=IN EndpointID=2)bmAttributes : 0x0D (TransferType=Isochronous SyncType=Synchronous EndpointType=Data)wMaxPacketSize : 0x0020 (32 bytes)bInterval : 0x01 (1 ms)bRefresh : 0x00bSynchAddress : 0x00Data (HexDump) : 09 05 82 0D 20 00 01 00 00 .... ....
----------- Audio Data Endpoint Descriptor ------------bLength : 0x07 (7 bytes)bDescriptorType : 0x25 (Audio Endpoint Descriptor)bDescriptorSubtype : 0x01 (General)bmAttributes : 0x00 D0 : Sampling Freq : 0x00 (not supported) D1 : Pitch : 0x00 (not supported) D6..2: Reserved : 0x00 D7 : MaxPacketsOnly : 0x00 (no)bLockDelayUnits : 0x00 (Undefined)wLockDelay : 0x0000Data (HexDump) : 07 25 01 00 00 00 00 .%.....
-------------------- String Descriptors ------------------- ------ String Descriptor 0 ------bLength : 0x04 (4 bytes)bDescriptorType : 0x03 (String Descriptor)Language ID[0] : 0x0409 (English - United States)Data (HexDump) : 04 03 09 04 .... ------ String Descriptor 1 ------bLength : 0x22 (34 bytes)bDescriptorType : 0x03 (String Descriptor)Language 0x0409 : "xxxxx.Technology"Data (HexDump) : 22 03 78 00 78 00 78 00 78 00 78 00 2E 00 54 00 ".x.x.x.x.x...T. 65 00 63 00 68 00 6E 00 6F 00 6C 00 6F 00 67 00 e.c.h.n.o.l.o.g. 79 00 y. ------ String Descriptor 2 ------bLength : 0x14 (20 bytes)bDescriptorType : 0x03 (String Descriptor)Language 0x0409 : "USB.Audio"Data (HexDump) : 14 03 55 00 53 00 42 00 2E 00 41 00 75 00 64 00 ..U.S.B...A.u.d. 69 00 6F 00 i.o. ------ String Descriptor 3 ------bLength : 0x08 (8 bytes)bDescriptorType : 0x03 (String Descriptor)Language 0x0409 : "0.1"Data (HexDump) : 08 03 30 00 2E 00 31 00 ..0...1. ------ String Descriptor 4 ------bLength : 0x1C (28 bytes)bDescriptorType : 0x03 (String Descriptor)Language 0x0409 : "Configuration"Data (HexDump) : 1C 03 43 00 6F 00 6E 00 66 00 69 00 67 00 75 00 ..C.o.n.f.i.g.u. 72 00 61 00 74 00 69 00 6F 00 6E 00 r.a.t.i.o.n. ------ String Descriptor 5 ------bLength : 0x14 (20 bytes)bDescriptorType : 0x03 (String Descriptor)Language 0x0409 : "USB.Video"Data (HexDump) : 14 03 55 00 53 00 42 00 2E 00 56 00 69 00 64 00 ..U.S.B...V.i.d. 65 00 6F 00 e.o. ------ String Descriptor 6 ------bLength : 0x14 (20 bytes)bDescriptorType : 0x03 (String Descriptor)Language 0x0409 : "USB.Audio"Data (HexDump) : 14 03 55 00 53 00 42 00 2E 00 41 00 75 00 64 00 ..U.S.B...A.u.d. 69 00 6F 00 i.o. ------ String Descriptor 7 ------bLength : 0x14 (20 bytes)bDescriptorType : 0x03 (String Descriptor)Language 0x0409 : "USB.Audio"Data (HexDump) : 14 03 55 00 53 00 42 00 2E 00 41 00 75 00 64 00 ..U.S.B...A.u.d. 69 00 6F 00 i.o. ------ String Descriptor 8 ------bLength : 0x08 (8 bytes)bDescriptorType : 0x03 (String Descriptor)Language 0x0409 : "XXX"Data (HexDump) : 08 03 58 00 58 00 58 00 ..X.X.X. ------ String Descriptor 9 ------bLength : 0x08 (8 bytes)bDescriptorType : 0x03 (String Descriptor)Language 0x0409 : "XXX"Data (HexDump) : 08 03 58 00 58 00 58 00 ..X.X.X.

四. 枚举过程

见九.抓包文件分享,不再赘述

五. 开关控制

参见前面扬声器和麦克风的实例

.静音与音量控制

参见前面扬声器和麦克风的实例

.数据传输

参见前面扬声器和麦克风的实例

.抓包文件分享

UAC_SPK_MIC.upv

可以使用USB Packet Viewer这个软件回放,方便查看枚举和数据传输过程。

链接:https://pan.baidu.com/s/1ANSHlXRQC_mTyram9qbHAg?pwd=btcj

提取码:btcj

十. 总结

以上分享了一个完整的UAC的扬声器+麦克风的实例,描述符可以直接使用,其他参考单独的扬声器和麦克风的实现即可。USB描述符的正确是能顺利枚举的首要条件,枚举完成了,基本就成功了一半了。有时候描述符一丁点不对就会导致枚举失败,所以有时候这些问题会困扰很久,有一个正确的描述符作为参考显得很有价值。故特分享此案例。


评论
  • 嘿,咱来聊聊RISC-V MCU技术哈。 这RISC-V MCU技术呢,简单来说就是基于一个叫RISC-V的指令集架构做出的微控制器技术。RISC-V这个啊,2010年的时候,是加州大学伯克利分校的研究团队弄出来的,目的就是想搞个新的、开放的指令集架构,能跟上现代计算的需要。到了2015年,专门成立了个RISC-V基金会,让这个架构更标准,也更好地推广开了。这几年啊,这个RISC-V的生态系统发展得可快了,好多公司和机构都加入了RISC-V International,还推出了不少RISC-V
    丙丁先生 2025-01-21 12:10 111浏览
  • 本文介绍瑞芯微开发板/主板Android配置APK默认开启性能模式方法,开启性能模式后,APK的CPU使用优先级会有所提高。触觉智能RK3562开发板演示,搭载4核A53处理器,主频高达2.0GHz;内置独立1Tops算力NPU,可应用于物联网网关、平板电脑、智能家居、教育电子、工业显示与控制等行业。源码修改修改源码根目录下文件device/rockchip/rk3562/package_performance.xml并添加以下内容,注意"+"号为添加内容,"com.tencent.mm"为AP
    Industio_触觉智能 2025-01-17 14:09 161浏览
  • 高速先生成员--黄刚这不马上就要过年了嘛,高速先生就不打算给大家上难度了,整一篇简单但很实用的文章给大伙瞧瞧好了。相信这个标题一出来,尤其对于PCB设计工程师来说,心就立马凉了半截。他们辛辛苦苦进行PCB的过孔设计,高速先生居然说设计多大的过孔他们不关心!另外估计这时候就跳出很多“挑刺”的粉丝了哈,因为翻看很多以往的文章,高速先生都表达了过孔孔径对高速性能的影响是很大的哦!咋滴,今天居然说孔径不关心了?别,别急哈,听高速先生在这篇文章中娓娓道来。首先还是要对各位设计工程师的设计表示肯定,毕竟像我
    一博科技 2025-01-21 16:17 95浏览
  • 现在为止,我们已经完成了Purple Pi OH主板的串口调试和部分配件的连接,接下来,让我们趁热打铁,完成剩余配件的连接!注:配件连接前请断开主板所有供电,避免敏感电路损坏!1.1 耳机接口主板有一路OTMP 标准四节耳机座J6,具备进行音频输出及录音功能,接入耳机后声音将优先从耳机输出,如下图所示:1.21.2 相机接口MIPI CSI 接口如上图所示,支持OV5648 和OV8858 摄像头模组。接入摄像头模组后,使用系统相机软件打开相机拍照和录像,如下图所示:1.3 以太网接口主板有一路
    Industio_触觉智能 2025-01-20 11:04 150浏览
  • Ubuntu20.04默认情况下为root账号自动登录,本文介绍如何取消root账号自动登录,改为通过输入账号密码登录,使用触觉智能EVB3568鸿蒙开发板演示,搭载瑞芯微RK3568,四核A55处理器,主频2.0Ghz,1T算力NPU;支持OpenHarmony5.0及Linux、Android等操作系统,接口丰富,开发评估快人一步!添加新账号1、使用adduser命令来添加新用户,用户名以industio为例,系统会提示设置密码以及其他信息,您可以根据需要填写或跳过,命令如下:root@id
    Industio_触觉智能 2025-01-17 14:14 121浏览
  •     IPC-2581是基于ODB++标准、结合PCB行业特点而指定的PCB加工文件规范。    IPC-2581旨在替代CAM350格式,成为PCB加工行业的新的工业规范。    有一些免费软件,可以查看(不可修改)IPC-2581数据文件。这些软件典型用途是工艺校核。    1. Vu2581        出品:Downstream     
    电子知识打边炉 2025-01-22 11:12 49浏览
  • 临近春节,各方社交及应酬也变得多起来了,甚至一月份就排满了各式约见。有的是关系好的专业朋友的周末“恳谈会”,基本是关于2025年经济预判的话题,以及如何稳定工作等话题;但更多的预约是来自几个客户老板及副总裁们的见面,他们为今年的经济预判与企业发展焦虑而来。在聊天过程中,我发现今年的聊天有个很有意思的“点”,挺多人尤其关心我到底是怎么成长成现在的多领域风格的,还能掌握一些经济趋势的分析能力,到底学过哪些专业、在企业管过哪些具体事情?单单就这个一个月内,我就重复了数次“为什么”,再辅以我上次写的:《
    牛言喵语 2025-01-22 17:10 30浏览
  • 2024年是很平淡的一年,能保住饭碗就是万幸了,公司业绩不好,跳槽又不敢跳,还有一个原因就是老板对我们这些员工还是很好的,碍于人情也不能在公司困难时去雪上加霜。在工作其间遇到的大问题没有,小问题还是有不少,这里就举一两个来说一下。第一个就是,先看下下面的这个封装,你能猜出它的引脚间距是多少吗?这种排线座比较常规的是0.6mm间距(即排线是0.3mm间距)的,而这个规格也是我们用得最多的,所以我们按惯性思维来看的话,就会认为这个座子就是0.6mm间距的,这样往往就不会去细看规格书了,所以这次的运气
    wuliangu 2025-01-21 00:15 181浏览
  •  万万没想到!科幻电影中的人形机器人,正在一步步走进我们人类的日常生活中来了。1月17日,乐聚将第100台全尺寸人形机器人交付北汽越野车,再次吹响了人形机器人疯狂进厂打工的号角。无独有尔,银河通用机器人作为一家成立不到两年时间的创业公司,在短短一年多时间内推出革命性的第一代产品Galbot G1,这是一款轮式、双臂、身体可折叠的人形机器人,得到了美团战投、经纬创投、IDG资本等众多投资方的认可。作为一家成立仅仅只有两年多时间的企业,智元机器人也把机器人从梦想带进了现实。2024年8月1
    刘旷 2025-01-21 11:15 360浏览
  • 数字隔离芯片是一种实现电气隔离功能的集成电路,在工业自动化、汽车电子、光伏储能与电力通信等领域的电气系统中发挥着至关重要的作用。其不仅可令高、低压系统之间相互独立,提高低压系统的抗干扰能力,同时还可确保高、低压系统之间的安全交互,使系统稳定工作,并避免操作者遭受来自高压系统的电击伤害。典型数字隔离芯片的简化原理图值得一提的是,数字隔离芯片历经多年发展,其应用范围已十分广泛,凡涉及到在高、低压系统之间进行信号传输的场景中基本都需要应用到此种芯片。那么,电气工程师在进行电路设计时到底该如何评估选择一
    华普微HOPERF 2025-01-20 16:50 73浏览
我要评论
0
点击右上角,分享到朋友圈 我知道啦
请使用浏览器分享功能 我知道啦