UAC1.0麦克风端点描述符wMaxPacketSize的问题分析
2022-06-07
710
0
同事搞了一个UAC麦克风,将输入端点设置如下:
----------------- Endpoint Descriptor -----------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x05 (Endpoint Descriptor)
bEndpointAddress : 0x83 (Direction=IN EndpointID=3)
bmAttributes : 0x0D (TransferType=Isochronous SyncType=Synchronous EndpointType=Data)
wMaxPacketSize : 0x0B00
bInterval : 0x04(1ms)
bRefresh : 0x00
bSynchAddress : 0x00
Data (HexDump) : 09 05 83 0D C0 00 01 00 00
这里使用的是USB2.0高速传输,所以这里通过USB规范可以分析出,最点的最大长度为768字节,可以进行一次额外传输,所以总共可以传输768x2=1536字节。
其实这里的麦克风参数为48K采样率,16通道,每通道2字节的PCM数据,所以48x16x2=1536字节。
可是实际在通过BUSHOUND抓包的时候,出现如下错误:
33.1 USTS c0000b00 isoc req failed
33.1 URB ISOC TRANSFER
10 01 0a 00 00 0b 00 c0 18 c4 df 8b 70 7f 00 00 00 00 00 00 00 00 00 00 40 56 b5 6e 8f 80 ff ff
05 00 00 00 00 00 00 00 10 1f 86 79 8f 80 ff ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
71 89 93 06 0a 00 00 00 0a 00 00 00 00 00 00 00 00 00 00 00 12 00 00 c0 00 0b 00 00 00 00 00 00
12 00 00 c0 00 16 00 00 00 00 00 00 12 00 00 c0 00 21 00 00 00 00 00 00 12 00 00 c0 00 2c 00 00
00 00 00 00 12 00 00 c0 00 37 00 00 00 00 00 00 12 00 00 c0 00 42 00 00 00 00 00 00 12 00 00 c0
00 4d 00 00 00 00 00 00 12 00 00 c0 00 58 00 00 00 00 00 00 12 00 00 c0 00 63 00 00 00 00 00 00
12 00 00 c0 00 00 00 00 00 00 00 00 00 00 00 00
通过在 http://www.usbzh.com/article/detail-645.html 查询为 c0000b00的错误信息
USBD_STATUS_BABBLE_DETECTED:the device returned a babble detected error (defined for backward compatibility with the USB 1.0).
通过可以看到,这是一个不清楚的错误信息。
但是在实际将端点描述符配置成wMaxPacketSize=1536的时候,这时usbtreeviewer虽然会显示错误的值,但实际工作上是可以正常工作的。
从上面对比来看,这里不科学啊。遵循规范的不能正常工作,不遵循的又可以正常工作。
经过深入的分析,其实这里有一段孽缘在这里。
- UAC1.0规范发布于1998年。
- USB2.0规范发布于2000年
所以可以看到,UAC1.0这里可能就不遵循USB2.0相关的规范,因为UAC1.0更早,所以应该是:
- UAC1.0高速设备,端点的大小可配置大于1024字节长度,但在实际传输时可能会使用1024字节进行传输
- UAC1.0端点的大小的值与实际传输的长度关系不大,不过影响了URB每个ISO包的大小,因为我们分析URB时可以看到
_URB_ISOCH_TRANSFER
_URB_HEADER Hdr
USHORT Length 10 01
USHORT Function 0A 00
USBD_STATUS Status 00 0B 00 C0
PVOID UsbdDeviceHandle 18 C4 DF 8B 70 7F 00 00
ULONG UsbdFlags 00 00 00 00
ULONG reversed 00 00 00 00
PVOID PipeHandle 40 56 B5 6E 8F 80 FF FF
ULONG TransferFlags 05 00 00 00
ULONG TransferBufferLength 00 00 00 00
PVOID TransferBuffer 10 1F 86 79 8F 80 FF FF
PVOID TransferBufferMDL 00 00 00 00 00 00 00 00
PVOID UrbLink* 00 00 00 00 00 00 00 00
_URB_HCD_AREA hca
PVOID Reserved[8]
02 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
ULONG StartFrame 71 89 93 06
ULONG NumberOfPackets 0A 00 00 00
ULONG ErrorCount 0A 00 00 00
_USBD_ISO_PACKET_DESCRIPTOR IsoPacket[10]
ULONG Offset 00 00 00 00
ULONG Length 00 00 00 00
USBD_STATUS Status 12 00 00 C0
ULONG Offset 00 0B 00 00
ULONG Length 00 00 00 00
USBD_STATUS Status 12 00 00 C0
ULONG Offset 00 16 00 00
ULONG Length 00 00 00 00
USBD_STATUS Status 12 00 00 C0
ULONG Offset 00 21 00 00
ULONG Length 00 00 00 00
USBD_STATUS Status 12 00 00 C0
ULONG Offset 00 2C 00 00
ULONG Length 00 00 00 00
USBD_STATUS Status 12 00 00 C0
ULONG Offset 00 37 00 00
ULONG Length 00 00 00 00
USBD_STATUS Status 12 00 00 C0
ULONG Offset 00 42 00 00
ULONG Length 00 00 00 00
USBD_STATUS Status 12 00 00 C0
ULONG Offset 00 4D 00 00
ULONG Length 00 00 00 00
USBD_STATUS Status 12 00 00 C0
ULONG Offset 00 58 00 00
ULONG Length 00 00 00 00
USBD_STATUS Status 12 00 00 C0
ULONG Offset 00 63 00 00
ULONG Length 00 00 00 00
USBD_STATUS Status 12 00 00 C0
HID人机交互QQ群:564808376
UAC音频QQ群:218581009
UVC相机QQ群:331552032
BOT&UASP大容量存储QQ群:258159197
STC-USB单片机QQ群:315457461
USB技术交流QQ群2:580684376
USB技术交流QQ群:952873936