Rockchip Developer Guide Linux4.4 USB Gadget UAC CN

User Manual:

Open the PDF directly: View PDF PDF.
Page Count: 35

DownloadRockchip-Developer-Guide-Linux4.4-USB-Gadget-UAC-CN
Open PDF In BrowserView PDF
Linux4.4 USB Gadget UAC
发布版本:1.0
作者邮箱:wulf@rock-chips.com
⽇期:2019-03-13
⽂档密级:公开资料
概述
本⽂档提供 Rockchip 平台基于 Linux4.4 内核的 USB Gadget UAC(USB Audio Class)驱动的使⽤⽅法。Rockchip
平台可以⽀持 UAC1(兼容USB Audio Class specification 1.0)和 UAC2(兼容USB Audio Class specification
2.0)驱动,并且,这两个驱动都可以⽀持基础的录⾳和放⾳功能。此外,Rockchip 平台还提供了 UAC1 Legacy
(需要实际的声卡⽀持,只⽀持放⾳功能)和 Audio Source(只⽀持录⾳功能,但可以⽀持多达15种不同的采样
率)。开发⼈员可以根据产品的实际需求来选择合适的UAC驱动。
如果要⽀持⾳量调节/静⾳功能,需要添加HID的控制,⽬前发布的SDK还没有⽀持。开发⼈员可以参考如下的⽂档,
进⾏HID功能的开发。
Kernel/Documentation/usb/gadget-testing.txt (参考 6. HID function)
Kernel/Documentation/ABI/testing/configfs-usb-gadget-hid
Universal Serial Bus Audio Device Class Specification for Basic Audio Devices

)

Audio Devices

产品版本

(参考 8 HID Support in Basic

芯⽚名称
RK3399、RK3368、RK3366、RK3328、RK3288、RK312X、RK3188、RK30XX、RK3308、
RK3326、PX30
读者对象 本⽂档(本指南)主要适⽤于以下⼯程师:
软件⼯程师
技术⽀持⼯程师
修订记录
⽇期

版本

2019-03-13

V1.0

Linux4.4 USB Gadget UAC
1 Kernel UAC CONFIG

作者
吴良峰

修改说明
初始版本

内核版本
Linux4.4

1.1 Related Kernel Commits
1.2 Related CONFIGs
1.3 Related Documents
2 UAC1 Usage and Test
2.1 UAC1 Usage
2.2 UAC1 Test
2.2.1 UAC1 Test on Windows
2.2.2 UAC1 Test on Ubuntu
3 UAC2 Usage and Test
3.1 UAC2 Usage
3.2 UAC2 Test
3.2.1 UAC2 Test on Windows
3.2.2 UAC2 Test on Ubuntu
4 UAC1 Legacy Usage and Test
4.1 UAC1 Legacy Usage
4.2 UAC1 Legacy Test
5 Audio Source Usage and Test
5.1 Audio Source Usage
5.2 Audio Source Test
6 UAC1 Legacy and Audio Source Composite Usage and Test
6.1 UAC1 Legacy and Audio Source Composite Usage
6.2 UAC1 Legacy and Audio Source Composite Test
7 Composite with ADB
8 Reference Documentation
9 Appendix A UAC1 Device Descriptor
10 Appendix B UAC2 Device Descriptor

1 Kernel UAC CONFIG
1.1 Related Kernel Commits

如果要正常使⽤ Kernel-4.4 的 UAC1/UAC2 的功能,需要先确认所使⽤的内核已经包含如下的系列补丁,如果未找
到补丁,请提交问题到 Rockchip Redmine 平台,或者发邮件给本⽂档的作者。
请参考补丁简报:
[1] Kernel 4.4 ⽀持USB Gadget UAC1/UAC2 录⾳和放⾳功能
问题描述: Kernel-4.4 的 USB Gadget UAC1/UAC2 驱动存在如下的问题:
UAC1只⽀持放⾳功能,并且需要实际声卡配合使⽤
UAC2⽆法兼容Windows,虽然可以⽀持录⾳和放⾳,但是功能不完善
补丁列表:
5e962a0 usb: gadget: f_uac2: fix some issues for Windows recognized
14e0a40 UPSTREAM: usb: gadget: f_uac2: disable IN/OUT ep if unused
a90af74 UPSTREAM: usb: gadget: u_audio: protect stream runtime fields with stream spinlock
7335245 UPSTREAM: usb: gadget: u_audio: remove cached period bytes value
deb045e UPSTREAM: usb: gadget: u_audio: remove caching of stream buffer parameters
6ec0a4d UPSTREAM: usb: gadget: u_audio: update hw_ptr in iso_complete after data copied

f81ce6a UPSTREAM: usb: gadget: u_audio: fix pcm/card naming in g_audio_setup()
bbd7715 UPSTREAM: usb: gadget: f_uac2: fix error handling in afunc_bind (again)
1adbd21 UPSTREAM: usb: gadget: make snd_pcm_hardware const
de6e281 UPSTREAM: usb: gadget: f_uac2: constify snd_pcm_ops structures
0106bd0 UPSTREAM: usb: gadget: f_uac2: endianness fixes.
98492ac UPSTREAM: usb: gadget: f_uac1: endianness fixes.
45e29d4 UPSTREAM: usb: gadget: add f_uac1 variant based on a new u_audio api
55f51fc UPSTREAM: usb: gadget: function: make current f_uac1 implementation legacy
ef10d9e UPSTREAM: usb: gadget: f_uac2: split out audio core
dc16803 UPSTREAM: usb: gadget: f_uac2: remove platform driver/device creation
7d1ddce UPSTREAM: usb: gadget: f_uac2: calculate wMaxPacketSize before endpoint match
4f76843 UPSTREAM: usb: gadget: uac2: add req_number as parameter
2b9c1a8 UPSTREAM: usb: gadget: f_uac2: improve error handling
70f4537 UPSTREAM: usb: gadget: uac2: Drop unused device qualifier descriptor

解决Kernel USB Gadget UAC1拔插⽆法识别的问题
问题描述:
USB Gadget UAC1 连接到 PC,实现 USB 声卡播放⾳乐的功能。在放⾳开始的任意过程中,拔出 USB 线,再重新插
⼊,会⼤概率出现 PC ⽆法重新识别 USB UAC1 设备的问题。
补丁列表:
[2]

cafb671 UPSTREAM: usb: dwc2: gadget: Disable enabled HW endpoint in dwc2_hsotg_ep_disable
9b54359 UPSTREAM: usb: dwc2: gadget: Correct dwc2_hsotg_ep_stop_xfr() function

1.2 Related CONFIGs
CONFIG_USB_CONFIGFS_F_UAC1 (enable UAC1 Function )
CONFIG_USB_CONFIGFS_F_UAC2 (enable UAC2 Function )
CONFIG_USB_CONFIGFS_F_UAC1_LEGACY (enable UAC1 Legacy Function )
CONFIG_USB_CONFIGFS_F_ACC

(Audio Source depends on it)

CONFIG_USB_CONFIGFS_F_AUDIO_SRC (enable Audio Source Function)

1.3 Related Documents
Documentation/usb/gadget_configfs.txt
Documentation/usb/gadget-testing.txt
Documentation/ABI/testing/configfs-usb-gadget-uac1
Documentation/ABI/testing/configfs-usb-gadget-uac1_legacy
Documentation/ABI/testing/configfs-usb-gadget-uac2

2 UAC1 Usage and Test
2.1 UAC1 Usage
USB Audio Class 1 standard (1998)

This standard allows for 24 bits/96 kHz max.
The standard itself doesn't impose any limitation on sample rate.
Class 1 is tied to USB 1 Full Speed = 12 MHz
Every millisecond a package is send. Maximum package size is 1024 bytes. 2 channel x 24 bit x 96000 Hz
sample rate= 4608000 bits/s or 576 Byte/ms This fits in the 1024 byte limit. Any higher popular sample
rate e.g. 176 kHz needs 1056 bytes so in excess of the maximum package size.
All operating systems (Win, OSX, and Linux) support USB Audio Class 1 natively. This means you don’t
need to install drivers, it is plug&play. All support 2 channel audio with 24 bit words and 96 kHz sample
rate

参考 The Well-Tempered Computer (An introduction to computer audio) - USB
Note:
USB Audio 1.0 Specification在 USB 2.0 core Specification之前完成,因此 USB Audio 1.0 Specification没有⾼速模式
(High Speed)这⼀概念。可以通过⼀些经验规则使得 Audio 1.0兼容设备在特定的操作系统上实现⾼速模式。⽐如修改
isochronous endpoint descriptor 的 bInterval=4。⽬前尚没有详尽的经验规则保证在所有的操作系统上都能正常⼯
作在⾼速模式下。
Rockchip 平台 UAC1 驱动⽀持 USB Audio Class specification 1.0,⽀持录⾳和放⾳,并且不需要实际的声卡。
UAC1 驱动设置 bInterval=4。
默认⽀持:
速率:High Speed
采样率:playback 和 capture 都为 48 KHz,可以通过内核提供的接⼝配置为其他采样率
声道数:playback 和 capture 都为 2 Channels,最多⽀持双声道,可以通过内核提供的接⼝配置为单声道
位深度:playback 和 capture 都为 16 bits
UAC1 使⽤⽅法如下:
添加 CONFIG_USB_CONFIGFS_F_UAC1=y 到内核的defconfig
以 3308 EVB 为例
配置 UAC1 的脚本参考如下:
mount -t configfs none /sys/kernel/config
mkdir /sys/kernel/config/usb_gadget/rockchip

-m 0770

echo 0x2207 > /sys/kernel/config/usb_gadget/rockchip/idVendor
echo 0x0019 > /sys/kernel/config/usb_gadget/rockchip/idProduct
echo 0x0100 > /sys/kernel/config/usb_gadget/rockchip/bcdDevice
mkdir /sys/kernel/config/usb_gadget/rockchip/strings/0x409

-m 0770

echo "0123456789ABCDEF" > /sys/kernel/config/usb_gadget/rockchip/strings/0x409/serialnumber
echo "rockchip"

> /sys/kernel/config/usb_gadget/rockchip/strings/0x409/manufacturer

echo "USB Audio Device"

> /sys/kernel/config/usb_gadget/rockchip/strings/0x409/product

mkdir /sys/kernel/config/usb_gadget/rockchip/configs/b.1

-m 0770

mkdir /sys/kernel/config/usb_gadget/rockchip/configs/b.1/strings/0x409

-m 0770

echo 500 > /sys/kernel/config/usb_gadget/rockchip/configs/b.1/MaxPower
echo "uac1" >
/sys/kernel/config/usb_gadget/rockchip/configs/b.1/strings/0x409/configuration

mkdir /sys/kernel/config/usb_gadget/rockchip/functions/uac1.gs0
ln -s /sys/kernel/config/usb_gadget/rockchip/functions/uac1.gs0
/sys/kernel/config/usb_gadget/rockchip/configs/b.1/uac1.gs0
echo ff400000.usb > /sys/kernel/config/usb_gadget/rockchip/UDC

假如 3308 开机后,默认运⾏了 ADB 配置脚本,会导致上述的配置⽅法出错,在调试阶段,可以⼿动执⾏如下命令
来配置 UAC1 功能。最终产品的 USB 配置脚本,需要根据实际的需求来整合 ADB 和 UAC1 的配置脚本。
rm -rf /sys/kernel/config/usb_gadget/rockchip/configs/b.1/ffs.adb
mkdir /sys/kernel/config/usb_gadget/rockchip/functions/uac1.gs0
echo 0x0019 > /sys/kernel/config/usb_gadget/rockchip/idProduct
echo 0x0100 > /sys/kernel/config/usb_gadget/rockchip/bcdDevice
echo "USB Audio Device" > /sys/kernel/config/usb_gadget/rockchip/strings/0x409/product
echo "uac1" >
/sys/kernel/config/usb_gadget/rockchip/configs/b.1/strings/0x409/configuration
cd /sys/kernel/config/usb_gadget/rockchip/configs/b.1
ln -s ../../functions/uac1.gs0
echo ff400000.usb > ../../UDC

:

Note

可以根据产品⾃⾏定义,但不能与产品的其他 USB Function idProduct 冲突
“UDC” 为 USB 控制器名称,对应 /sys/class/udc/控制器名称
Windows 会对设备驱动记忆,更改配置后最好卸载驱动,让 Windows 重新识别设备
配置脚本执⾏成功后,连接USB到PC,PC端可以识别到USB Audio设备,如下图2-1 Windows-USB-Audio-Class1,
图2-2 Ubuntu-USB-Audio-Class1-Output和图2-3 Ubuntu-USB-Audio-Class1-Input。
“idProduct ”

图2-1 Windows-USB-Audio-Class1

图2-2 Ubuntu-USB-Audio-Class1-Output

图2-3 Ubuntu-USB-Audio-Class1-Input
3308 端的串⼝打印如下USB UAC1正常枚举的⽇志:

dwc2 ff400000.usb: new device is high-speed
dwc2 ff400000.usb: new address 19
android_work: sent uevent USB_STATE=CONNECTED
configfs-gadget gadget: high-speed config #1: b
android_work: sent uevent USB_STATE=CONFIGURED

驱动提供如下的配置接⼝:
如下配置⽆法动态⽣效,也即必须添加在UAC的配置脚本中执⾏。
UAC1

# ls -lh /sys/kernel/config/usb_gadget/rockchip/functions/uac1.gs0
-rw-r--r--

1 root

root

4.0K Dec 31 19:11 c_chmask

-rw-r--r--

1 root

root

4.0K Dec 31 19:11 c_srate

-rw-r--r--

1 root

root

4.0K Dec 31 19:11 c_ssize

-rw-r--r--

1 root

root

4.0K Dec 31 19:11 p_chmask

-rw-r--r--

1 root

root

4.0K Dec 31 19:11 p_srate

-rw-r--r--

1 root

root

4.0K Dec 31 19:11 p_ssize

-rw-r--r--

1 root

root

4.0K Dec 31 19:11 req_number

默认设置为 3
默认设置为 48000
c_ssize - capture sample size (bytes) 默认设置为 2
p_chmask - playback channel mask 默认设置为 3
p_srate - playback sampling rate 默认设置为 48000
p_ssize - playback sample size (bytes) 默认设置为 2
c_chmask - capture channel mask
c_srate - capture sampling rate

req_number - the number of pre-allocated request for both capture and playback

默认设置为 2

查看 UAC1 声卡信息的⽅法:
如下显⽰的结果,UAC1 对应 card2 (UAC1Gadget),具有⼀个playback设备节点 - pcmC2D0p 和⼀个capture设
备节点 - pcmC2D0c。
# cat /proc/asound/cards
0 [rockchiprk3308v]: rockchip_rk3308 - rockchip,rk3308-vad
rockchip,rk3308-vad
1 [rockchiprk3308p]: rockchip_rk3308 - rockchip,rk3308-pcm
rockchip,rk3308-pcm
2 [UAC1Gadget

]: UAC1_Gadget - UAC1_Gadget

7 [Loopback

]: Loopback - Loopback

UAC1_Gadget 0
Loopback 1
# ls -lh /proc/asound/card2
-r--r--r--

1 root

root

0 Dec 31 19:14 id

dr-xr-xr-x

3 root

root

0 Dec 31 19:14 pcm0c

dr-xr-xr-x

3 root

root

0 Dec 31 19:14 pcm0p

# ls /dev/snd/
controlC0

controlC7

pcmC1D0c

pcmC2D0p

pcmC7D1c

controlC1

pcmC0D0c

pcmC1D0p

pcmC7D0c

pcmC7D1p

controlC2

pcmC0D0p

pcmC2D0c

pcmC7D0p

timer

2.2 UAC1 Test
2.2.1 UAC1 Test on Windows

打开Windows声⾳设置,如下图2-4 Windows-Audio-Setting,分别选择USB-Audio 作为声⾳输出设备和声⾳输⼊设
备(⻨克⻛)。

图2-4 Windows-Audio-Setting
测试 Windows UAC1 放⾳功能:
在 3308 端的串⼝执⾏如下的 UAC1 放⾳命令:

arecord -f dat -t wav -r 48000 -c 2 -D hw:2,0 | aplay -f dat -r 48000 -c 2 -D hw:0,0

上述命令表⽰从Card2(USB Audio)录⾳,然后从本地声卡Card0播放声⾳
执⾏完命令后,Windows PC端播放⾳乐,3308 本地声卡可以实时放⾳。
测试 Windows UAC1 录⾳功能:
测试录⾳功能,需要使⽤可以播放的⾳频⽂件。通过 ADB push 或者 arecord 的⽅法,保存测试使⽤的⾳频⽂件
(要求 48KHz,2 channels,16 bits)
⽐如,3308 端的串⼝执⾏ arecord 命令,保存测试使⽤的⾳频⽂件test.wav
arecord -f dat -t wav -r 48000 -c 2 -D hw:2,0 /tmp/test.wav

保存⾳频⽂件test.wav成功后,再执⾏如下的 UAC1 录⾳命令:
aplay /tmp/test.wav -c 2 -r 48000 -D hw:2,0

执⾏完上述命令后,PC端可以使⽤Windows⾃带的 “Voice Recorder”软件保存录⾳⽂件,如下图2-5 WindowsVoice-Recorder。

图2-5 Windows-Voice-Recorder
除了上述的录⾳测试⽅法,也可以使⽤Windows的录⾳侦听功能,实时播放录⾳的⾳频,⽅法如下:
打开“声⾳设置” --> “声⾳控制⾯板” --> "录制" --> “属性” --> "侦听" ,勾选“侦听此设备”,并选择播放的扬声器。
如下图2-6 Windows-Capture-Listen-1 和图2-7 Windows-Capture-Listen-2。

图2-6 Windows-Capture-Listen-1

图2-6 Windows-Capture-Listen-2
2.2.2 UAC1 Test on Ubuntu

打开Ubuntu声⾳设置,如下图2-7 Ubuntu-Audio-Setting-Output 和图2-8 Ubuntu-Audio-Setting-Input,分别选择
USB-Audio 作为声⾳输出设备和声⾳输⼊设备(⻨克⻛)。

图2-7 Ubuntu-Audio-Setting-Output

图2-8 Ubuntu-Audio-Setting-Input
测试 Ubuntu UAC1 放⾳功能:
在 3308 端的串⼝执⾏如下的 UAC1 放⾳命令:
arecord -f dat -t wav -r 48000 -c 2 -D hw:2,0 | aplay -f dat -r 48000 -c 2 -D hw:0,0

上述命令表⽰从Card2(USB Audio)录⾳,然后从本地声卡Card0播放声⾳
执⾏完命令后,Ubuntu PC端播放⾳乐,3308 本地声卡可以实时放⾳。
测试 Ubuntu UAC1 录⾳功能:
测试录⾳功能,需要使⽤可以播放的⾳频⽂件。通过 ADB push 或者 arecord 的⽅法,保存测试使⽤的⾳频⽂件
(要求 48KHz,2 channels,16 bits)
⽐如,3308 端的串⼝执⾏ arecord 命令,保存测试使⽤的⾳频⽂件test.wav
arecord -f dat -t wav -r 48000 -c 2 -D hw:2,0 /tmp/test.wav

保存⾳频⽂件test.wav成功后,再执⾏如下的 UAC1 录⾳命令:
aplay /tmp/test.wav -c 2 -r 48000 -D hw:2,0

执⾏完上述命令后,在Ubuntu端打开录⾳软件,如“audacity”,进⾏录⾳功能测试。
audacity 安装命令:
sudo apt install audacity

audacity

录⾳界⾯如下图2-9所⽰。

图2-9 Ubuntu-audacity
3 UAC2 Usage and Test
3.1 UAC2 Usage
USB Audio Class 2 standard (2009)

USB Audio Class 2 additionally supports 32 bit and all common sample rates > 96 kHz Class 2 uses High
Speed (480 MHz). This requires USB 2 or 3. As the data rate of High Speed is 40 X Full speed, recording a
60 channel using 24 bits at 96 kHz (132 Mbit/s) is not a problem.
Using High Speed USB for playback there are no limits in resolution.
It is downwards compatible with class 1.
From mid-2010 on USB audio class 2 drivers are available in OSX 10.6.4 and Linux. Both support sample
rates up to 384 kHz.
Microsoft simply didn’t support UAC2.
In April 2017, an update of Win10 finally brought native mode drivers.
If you use older versions of Win, you still need a third party driver.

:

Note

从Windows 10(1703版)开始,Windows才默认⽀持UAC 2.0驱动程序。
Windows 和 Linux 对⾳频事件的响应流程稍有不同,要做兼容性处理,Linux 和 Android ⼀样。
Windows 会对设备驱动记忆,更改配置后最好卸载驱动,让 Windows 重新识别设备
Rockchip 平台 UAC2 驱动⽀持 USB Audio Class specification 2.0,⽀持录⾳和放⾳,并且不需要实际的声卡。
默认⽀持:
速率:High Speed
采样率:playback 为 48K Hz, capture 为 64 KHz,可以通过内核提供的接⼝配置为其他采样率
声道数:playback 和 capture 都为 2 Channels,最多⽀持双声道,可以通过内核提供的接⼝配置为单声道
位深度:playback 和 capture 都为 16 bits
UAC2 使⽤⽅法如下:
添加 CONFIG_USB_CONFIGFS_F_UAC2=y 到内核的defconfig
以 3308 EVB 为例
配置 UAC2 的脚本参考如下:
mount -t configfs none /sys/kernel/config
mkdir /sys/kernel/config/usb_gadget/rockchip

-m 0770

echo 0x2207 > /sys/kernel/config/usb_gadget/rockchip/idVendor
echo 0x0019 > /sys/kernel/config/usb_gadget/rockchip/idProduct
echo 0x0200 > /sys/kernel/config/usb_gadget/rockchip/bcdDevice
mkdir /sys/kernel/config/usb_gadget/rockchip/strings/0x409

-m 0770

echo "0123456789ABCDEF" > /sys/kernel/config/usb_gadget/rockchip/strings/0x409/serialnumber
echo "rockchip"

> /sys/kernel/config/usb_gadget/rockchip/strings/0x409/manufacturer

echo "USB Audio Device"

> /sys/kernel/config/usb_gadget/rockchip/strings/0x409/product

mkdir /sys/kernel/config/usb_gadget/rockchip/configs/b.1

-m 0770

mkdir /sys/kernel/config/usb_gadget/rockchip/configs/b.1/strings/0x409

-m 0770

echo 500 > /sys/kernel/config/usb_gadget/rockchip/configs/b.1/MaxPower
echo "uac2" > /sys/kernel/config/usb_gadget/rockchip/configs/b.1/strings/0x409/configuration
mkdir /sys/kernel/config/usb_gadget/rockchip/functions/uac2.gs0
ln -s /sys/kernel/config/usb_gadget/rockchip/functions/uac2.gs0

/sys/kernel/config/usb_gadget/rockchip/configs/b.1/uac2.gs0
echo ff400000.usb > /sys/kernel/config/usb_gadget/rockchip/UDC

假如 3308 开机后,默认运⾏了 ADB 配置脚本,会导致上述的配置⽅法出错,在调试阶段,可以⼿动执⾏如下命令
来配置 UAC2 功能。最终产品的 USB 配置脚本,需要根据实际的需求来整合 ADB 和 UAC2 的配置脚本。
rm -rf /sys/kernel/config/usb_gadget/rockchip/configs/b.1/ffs.adb
mkdir /sys/kernel/config/usb_gadget/rockchip/functions/uac2.gs0
echo 0x0019 > /sys/kernel/config/usb_gadget/rockchip/idProduct
echo 0x0200 > /sys/kernel/config/usb_gadget/rockchip/bcdDevice
echo "USB Audio Device" > /sys/kernel/config/usb_gadget/rockchip/strings/0x409/product
echo "uac2" > /sys/kernel/config/usb_gadget/rockchip/configs/b.1/strings/0x409/configuration
cd /sys/kernel/config/usb_gadget/rockchip/configs/b.1
ln -s ../../functions/uac2.gs0
echo ff400000.usb > ../../UDC

:

Note

可以根据产品⾃⾏定义,但不能与产品的其他 USB Function idProduct 冲突
“UDC” 为 USB 控制器名称,对应 /sys/class/udc/控制器名称
Windows 会对设备驱动记忆,更改配置后最好卸载驱动,让 Windows 重新识别设备
配置脚本执⾏成功后,连接USB到PC,PC端可以识别到USB Audio设备,如下图3-1 Windows-USB-Audio-Class2,
图3-2 Ubuntu-USB-Audio-Class2-Output和图3-3 Ubuntu-USB-Audio-Class2-Input。
“idProduct ”

图3-1 Windows-USB-Audio-Class2

图3-2 Ubuntu-USB-Audio-Class2-Output

图3-3 Ubuntu-USB-Audio-Class2-Input
3308 端的串⼝打印如下USB UAC2正常枚举的⽇志:

dwc2 ff400000.usb: new device is high-speed
dwc2 ff400000.usb: new address 21
android_work: sent uevent USB_STATE=CONNECTED
configfs-gadget gadget: high-speed config #1: b
android_work: sent uevent USB_STATE=CONFIGURED

驱动提供如下的配置接⼝:
如下配置⽆法动态⽣效,也即必须添加在UAC的配置脚本中执⾏。
⽐如,配置 c_srate 为 48KHz的命令为:
UAC2

echo 48000 > /sys/kernel/config/usb_gadget/rockchip/functions/uac2.gs0/c_srate
# ls -lh /sys/kernel/config/usb_gadget/rockchip/functions/uac2.gs0
-rw-r--r--

1 root

root

4.0K Dec 31 19:01 c_chmask

-rw-r--r--

1 root

root

4.0K Dec 31 19:01 c_srate

-rw-r--r--

1 root

root

4.0K Dec 31 19:01 c_ssize

-rw-r--r--

1 root

root

4.0K Dec 31 19:01 p_chmask

-rw-r--r--

1 root

root

4.0K Dec 31 19:01 p_srate

-rw-r--r--

1 root

root

4.0K Dec 31 19:01 p_ssize

-rw-r--r--

1 root

root

4.0K Dec 31 19:01 req_number

默认设置为 3
c_srate - capture sampling rate 默认设置为 64000
c_ssize - capture sample size (bytes) 默认设置为 2
p_chmask - playback channel mask 默认设置为 3
p_srate - playback sampling rate 默认设置为 48000
p_ssize - playback sample size (bytes) 默认设置为 2
c_chmask - capture channel mask

req_number - the number of pre-allocated request for both capture and playback

默认设置为 2

查看 UAC2 声卡信息的⽅法:
如下显⽰的结果,UAC2 对应 card2 (UAC2Gadget),具有⼀个playback设备节点 - pcmC2D0p 和⼀个capture设
备节点 - pcmC2D0c。
# cat /proc/asound/cards
0 [rockchiprk3308v]: rockchip_rk3308 - rockchip,rk3308-vad
rockchip,rk3308-vad
1 [rockchiprk3308p]: rockchip_rk3308 - rockchip,rk3308-pcm
rockchip,rk3308-pcm
2 [UAC2Gadget

]: UAC2_Gadget - UAC2_Gadget
UAC2_Gadget 0

7 [Loopback

]: Loopback - Loopback
Loopback 1

# ls -lh /proc/asound/card2
-r--r--r--

1 root

root

0 Dec 31 19:04 id

dr-xr-xr-x

3 root

root

0 Dec 31 19:04 pcm0c

dr-xr-xr-x

3 root

root

0 Dec 31 19:04 pcm0p

# ls /dev/snd/

controlC0

controlC7

pcmC1D0c

pcmC2D0p

pcmC7D1c

controlC1

pcmC0D0c

pcmC1D0p

pcmC7D0c

pcmC7D1p

controlC2

pcmC0D0p

pcmC2D0c

pcmC7D0p

timer

3.2 UAC2 Test
3.2.1 UAC2 Test on Windows

端的设置请参考2.2.1 UAC1 Test on Windows
测试 Windows UAC2 放⾳功能:
在 3308 端的串⼝执⾏如下的 UAC2 放⾳命令:
Windows PC

arecord -f dat -t wav -r 64000 -c 2 -D hw:2,0 | aplay -f dat -r 64000 -c 2 -D hw:0,0

上述命令表⽰从Card2(USB Audio)录⾳,然后从本地声卡Card0播放声⾳,采样率为64KHz(默认)。
如果通过UAC1驱动提供的内核接⼝,配置采样率为48KHz,则放⾳命令为:
arecord -f dat -t wav -r 48000 -c 2 -D hw:2,0 | aplay -f dat -r 48000 -c 2 -D hw:0,0

执⾏完命令后,Windows PC端播放⾳乐,3308 本地声卡可以实时放⾳。
测试 Windows UAC2 录⾳功能:
测试录⾳功能,需要使⽤可以播放的⾳频⽂件。通过 ADB push 或者 arecord 的⽅法,保存测试使⽤的⾳频⽂件
(要求 48KHz,2 channels,16 bits)
⽐如,3308 端的串⼝执⾏ arecord 命令,保存测试使⽤的⾳频⽂件test.wav
(以录⾳和放⾳的采样率都为48KHz的配置为例)
arecord -f dat -t wav -r 48000 -c 2 -D hw:2,0 /tmp/test.wav

保存⾳频⽂件test.wav成功后,再执⾏如下的 UAC1 录⾳命令:
aplay /tmp/test.wav -c 2 -r 48000 -D hw:2,0

执⾏完上述命令后,PC端可以使⽤Windows⾃带的 “Voice Recorder”软件保存录⾳⽂件,使⽤⽅法参考2.2.1 UAC1
Test on Windows

3.2.2 UAC2 Test on Ubuntu

端的设置请参考2.2.2 UAC1 Test on Ubuntu
Ubuntu PC环境下, 3308 端的 UAC2 录⾳和放⾳测试命令,请直接参考3.2.1 UAC2 Test on Windows
Ubuntu PC

4 UAC1 Legacy Usage and Test
4.1 UAC1 Legacy Usage

平台 UAC1 Legacy 驱动兼容 USB Audio Class specification 1.0,但只⽀持放⾳功能,并且需要实际的声
卡⽀持(默认使⽤ /dev/snd/pcmC0D0p)。
默认⽀持:
速率:High Speed
采样率:playback 48 KHz,不可配置
声道数:playback 2 Channels,不可配置
位深度:playback 16 bits
UAC1 Legacy 使⽤⽅法如下:
添加 CONFIG_USB_CONFIGFS_F_UAC1_LEGACY=y 到内核的defconfig
以 3308 EVB 为例
配置 UAC1 Legacy 的脚本参考如下:
Rockchip

mount -t configfs none /sys/kernel/config
mkdir /sys/kernel/config/usb_gadget/rockchip

-m 0770

echo 0x2207 > /sys/kernel/config/usb_gadget/rockchip/idVendor
echo 0x0019 > /sys/kernel/config/usb_gadget/rockchip/idProduct
echo 0x0100 > /sys/kernel/config/usb_gadget/rockchip/bcdDevice
mkdir /sys/kernel/config/usb_gadget/rockchip/strings/0x409

-m 0770

echo "0123456789ABCDEF" > /sys/kernel/config/usb_gadget/rockchip/strings/0x409/serialnumber
echo "rockchip"

> /sys/kernel/config/usb_gadget/rockchip/strings/0x409/manufacturer

echo "USB Audio Device"

> /sys/kernel/config/usb_gadget/rockchip/strings/0x409/product

mkdir /sys/kernel/config/usb_gadget/rockchip/configs/b.1

-m 0770

mkdir /sys/kernel/config/usb_gadget/rockchip/configs/b.1/strings/0x409

-m 0770

echo 500 > /sys/kernel/config/usb_gadget/rockchip/configs/b.1/MaxPower
echo "uac1" > /sys/kernel/config/usb_gadget/rockchip/configs/b.1/strings/0x409/configuration
mkdir /sys/kernel/config/usb_gadget/rockchip/functions/uac1_legacy.gs0
ln -s /sys/kernel/config/usb_gadget/rockchip/functions/uac1_legacy.gs0
/sys/kernel/config/usb_gadget/rockchip/configs/b.1/uac1_legacy.gs0
echo ff400000.usb > /sys/kernel/config/usb_gadget/rockchip/UDC

假如 3308 开机后,默认运⾏了 ADB 配置脚本,会导致上述的配置⽅法出错,在调试阶段,可以⼿动执⾏如下命令
来配置 UAC1 Legacy 功能。最终产品的 USB 配置脚本,需要根据实际的需求来整合 ADB 和 UAC1 Legacy 的配置脚
本。
rm -rf /sys/kernel/config/usb_gadget/rockchip/configs/b.1/ffs.adb
mkdir /sys/kernel/config/usb_gadget/rockchip/functions/uac1_legacy.gs0
echo 0x0019 > /sys/kernel/config/usb_gadget/rockchip/idProduct
echo 0x0100 > /sys/kernel/config/usb_gadget/rockchip/bcdDevice
echo "USB Audio Device" > /sys/kernel/config/usb_gadget/rockchip/strings/0x409/product
echo "uac1" > /sys/kernel/config/usb_gadget/rockchip/configs/b.1/strings/0x409/configuration
cd /sys/kernel/config/usb_gadget/rockchip/configs/b.1
ln -s ../../functions/uac1_legacy.gs0
echo ff400000.usb > ../../UDC

:

Note

可以根据产品⾃⾏定义,但不能与产品的其他 USB Function idProduct 冲突
“UDC” 为 USB 控制器名称,对应 /sys/class/udc/控制器名称
Windows 会对设备驱动记忆,更改配置后最好卸载驱动,让 Windows 重新识别设备
配置脚本执⾏成功后,连接USB到PC,PC端可以识别到USB Audio设备,如图4-1
“idProduct ”

图4-1 Windows-USB-Audio-Class1-Legacy
3308 端的串⼝打印如下 USB UAC1 Legacy 正常枚举的⽇志:
configfs-gadget gadget: Hardware params: access 3, format 2, channels 2, rate 48000
dwc2 ff400000.usb: bound driver configfs-gadget
dwc2 ff400000.usb: new device is high-speed
dwc2 ff400000.usb: new address 25
android_work: sent uevent USB_STATE=CONNECTED
configfs-gadget gadget: high-speed config #1: b
android_work: sent uevent USB_STATE=CONFIGURED

驱动提供如下的配置接⼝:
如下配置⽆法动态⽣效,也即必须添加在UAC的配置脚本中执⾏。
UAC1 Legacy

# ls -lh /sys/kernel/config/usb_gadget/g1/functions/uac1_legacy.gs0/
-rw-r--r--

1 root

root

4.0K Dec 31 19:08 audio_buf_size

-rw-r--r--

1 root

root

4.0K Dec 31 19:08 fn_cap

-rw-r--r--

1 root

root

4.0K Dec 31 19:08 fn_cntl

-rw-r--r--

1 root

root

4.0K Dec 31 19:08 fn_play

-rw-r--r--

1 root

root

4.0K Dec 31 19:08 req_buf_size

-rw-r--r--

1 root

root

4.0K Dec 31 19:08 req_count

默认设置为 48000
fn_cap - capture pcm device file name 默认设置为 /dev/snd/pcmC0D0c
fn_cntl - control device file name 默认设置为 /dev/snd/controlC0
fn_play - playback pcm device file name 默认设置为 /dev/snd/pcmC0D0p
req_buf_size - ISO OUT endpoint request buffer size 默认设置为 200
req_count - ISO OUT endpoint request count 默认设置为 256
audio_buf_size - audio buffer size

UAC1 Legacy

不会在3308端创建对应的声卡设备节点。

4.2 UAC1 Legacy Test

端的放⾳设置请参考 2.2.1 UAC1 Test on Windows
Ubuntu PC 端的放⾳设置请参考 2.2.2 UAC1 Test on Ubuntu
3308 端不需要执⾏任何命令,连接 USB 到 PC 后,UAC1 Legacy 驱动默认会打开 3308 本地 Card0 声卡播放声⾳。
Windows PC

5 Audio Source Usage and Test
5.1 Audio Source Usage

平台 Audio Source 驱动兼容 USB Audio Class specification 1.0,但只⽀持录⾳功能。
默认⽀持:
速率:High Speed
采样率:playback 默认使⽤44.1KHz,总共⽀持如下15种不同的采样率,PC端可以动态配置
Rockchip

8000, 11025, 16000, 22050, 24000,
32000, 40000, 44100, 48000, 56000,
64000, 72000, 80000, 88200, 96000,

声道数:playback 2 Channels,不可配置
位深度:playback 16 bits
Audio Source 使⽤⽅法如下:
添加 CONFIG_USB_CONFIGFS_F_ACC=y(Audio Source depends on it)到内核的defconfig
添加 CONFIG_USB_CONFIGFS_F_AUDIO_SRC=y 到内核的defconfig
以 3308 EVB 为例
配置 Audio Source 的脚本参考如下:
mount -t configfs none /sys/kernel/config
mkdir /sys/kernel/config/usb_gadget/rockchip

-m 0770

echo 0x2207 > /sys/kernel/config/usb_gadget/rockchip/idVendor
echo 0x0019 > /sys/kernel/config/usb_gadget/rockchip/idProduct
mkdir /sys/kernel/config/usb_gadget/rockchip/strings/0x409

-m 0770

echo "0123456789ABCDEF" > /sys/kernel/config/usb_gadget/rockchip/strings/0x409/serialnumber
echo "rockchip"

> /sys/kernel/config/usb_gadget/rockchip/strings/0x409/manufacturer

echo "USB Audio Device"

> /sys/kernel/config/usb_gadget/rockchip/strings/0x409/product

mkdir /sys/kernel/config/usb_gadget/rockchip/configs/b.1

-m 0770

mkdir /sys/kernel/config/usb_gadget/rockchip/configs/b.1/strings/0x409

-m 0770

echo 500 > /sys/kernel/config/usb_gadget/rockchip/configs/b.1/MaxPower
echo "audio" > /sys/kernel/config/usb_gadget/rockchip/configs/b.1/strings/0x409/configuration
mkdir /sys/kernel/config/usb_gadget/rockchip/functions/audio_source.gs0
ln -s /sys/kernel/config/usb_gadget/rockchip/functions/audio_source.gs0

/sys/kernel/config/usb_gadget/rockchip/configs/b.1/audio_source.gs0
echo ff400000.usb > /sys/kernel/config/usb_gadget/rockchip/UDC

假如 3308 开机后,默认运⾏了 ADB 配置脚本,会导致上述的配置⽅法出错,在调试阶段,可以⼿动执⾏如下命令
来配置 Audio Source 功能。最终产品的 USB 配置脚本,需要根据实际的需求来整合 ADB 和 Audio Source 的配置
脚本。
rm -rf /sys/kernel/config/usb_gadget/rockchip/configs/b.1/ffs.adb
mkdir /sys/kernel/config/usb_gadget/rockchip/functions/audio_source.gs0
echo 0x0019 > /sys/kernel/config/usb_gadget/rockchip/idProduct
echo 0x0100 > /sys/kernel/config/usb_gadget/rockchip/bcdDevice
echo "USB Audio Device" > /sys/kernel/config/usb_gadget/rockchip/strings/0x409/product
echo "audio" > /sys/kernel/config/usb_gadget/rockchip/configs/b.1/strings/0x409/configuration
cd /sys/kernel/config/usb_gadget/rockchip/configs/b.1
ln -s ../../functions/audio_source.gs0
echo ff400000.usb > ../../UDC

:

Note

可以根据产品⾃⾏定义,但不能与产品的其他 USB Function idProduct 冲突
“UDC” 为 USB 控制器名称,对应 /sys/class/udc/控制器名称
Windows 会对设备驱动记忆,更改配置后最好卸载驱动,让 Windows 重新识别设备
配置脚本执⾏成功后,连接USB到PC,PC端可以识别到USB Audio设备,如下图5-1 Windows-USB-Audio-Source
和图5-2 Ubuntu-USB-Audio-Source
“idProduct ”

图5-1 Windows-USB-Audio-Source

图5-2 Ubuntu-USB-Audio-Source
3308 端的串⼝打印如下USB Audio Source正常枚举的⽇志:
dwc2 ff400000.usb: new device is high-speed
dwc2 ff400000.usb: new address 23
android_work: sent uevent USB_STATE=CONNECTED
configfs-gadget gadget: high-speed config #1: b
android_work: sent uevent USB_STATE=CONFIGURED

驱动没有提供可配置的内核接⼝。
查看 Audio Source 信息的⽅法:
如下显⽰的结果,Audio Source 对应 card2 (audiosource),只有⼀个playback设备节点 - pcmC2D0p。
Audio Source

# cat /proc/asound/cards
0 [rockchiprk3308v]: rockchip_rk3308 - rockchip,rk3308-vad
rockchip,rk3308-vad
1 [rockchiprk3308p]: rockchip_rk3308 - rockchip,rk3308-pcm
rockchip,rk3308-pcm
2 [audiosource

]: audio_source - audio_source

7 [Loopback

]: Loopback - Loopback

USB accessory audio source
Loopback 1
# ls -lh /proc/asound/card2
-r--r--r--

1 root

root

0 Dec 31 19:06 id

dr-xr-xr-x

3 root

root

0 Dec 31 19:06 pcm0p

# ls /dev/snd/

controlC0

controlC2

pcmC0D0c

pcmC1D0c

pcmC2D0p

pcmC7D0p

pcmC7D1p

controlC1

controlC7

pcmC0D0p

pcmC1D0p

pcmC7D0c

pcmC7D1c

timer

5.2 Audio Source Test

测试 Audio Source 录⾳功能:
Windows PC端的录⾳设置请参考 2.2.1 UAC1 Test on Windows
Ubuntu PC端的录⾳设置请参考 2.2.2 UAC1 Test on Ubuntu
3308 端的测试命令(假设采样率使⽤默认的44.1KHz):
aplay /tmp/test.wav -r 44100 -c 2 -D hw:2,0

:
测试使⽤的⾳频⽂件 test.wav 的采样率,应与录⾳的采样率⼀致,否则,测试时可能出现杂⾳或者⽆声⾳
此外,因为Audio Source⽀持15种不同的采样率,所以PC端可以动态配置采样率,⽅法如下:
打开“声⾳设置” --> “声⾳控制⾯板” --> "录制" --> “属性” --> “⾼级”,选择对应的采样率。
如下图5-3 所⽰。
Note

图5-3 Windows-USB-Audio-Source-Setting

6 UAC1 Legacy and Audio Source Composite Usage and
Test
6.1 UAC1 Legacy and Audio Source Composite Usage

使⽤⽅法如下:
UAC1 Legacy 和 Audio Source 可以组合为⼀个USB 复合设备,⽀持录⾳和放⾳功能。
添加 CONFIG_USB_CONFIGFS_F_UAC1_LEGACY=y 到内核的defconfig
添加 CONFIG_USB_CONFIGFS_F_ACC=y(Audio Source depends on it)到内核的defconfig
添加 CONFIG_USB_CONFIGFS_F_AUDIO_SRC=y 到内核的defconfig
此外,需要单独更新补丁“support_uac1_legacy_and_audio_source.patch”。
以 3308 EVB 为例
配置 UAC1 Legacy + Audio Source 的脚本参考如下:
UAC1 Legacy + Audio Source

mount -t configfs none /sys/kernel/config
mkdir /sys/kernel/config/usb_gadget/rockchip

-m 0770

echo 0x2207 > /sys/kernel/config/usb_gadget/rockchip/idVendor
echo 0x0019 > /sys/kernel/config/usb_gadget/rockchip/idProduct
echo 0x0100 > /sys/kernel/config/usb_gadget/rockchip/bcdDevice
mkdir /sys/kernel/config/usb_gadget/rockchip/strings/0x409

-m 0770

echo "0123456789ABCDEF" > /sys/kernel/config/usb_gadget/rockchip/strings/0x409/serialnumber
echo "rockchip"

> /sys/kernel/config/usb_gadget/rockchip/strings/0x409/manufacturer

echo "USB Audio Device"

> /sys/kernel/config/usb_gadget/rockchip/strings/0x409/product

mkdir /sys/kernel/config/usb_gadget/rockchip/configs/b.1

-m 0770

mkdir /sys/kernel/config/usb_gadget/rockchip/configs/b.1/strings/0x409

-m 0770

echo 500 > /sys/kernel/config/usb_gadget/rockchip/configs/b.1/MaxPower
echo "uac1" > /sys/kernel/config/usb_gadget/rockchip/configs/b.1/strings/0x409/configuration
mkdir /sys/kernel/config/usb_gadget/rockchip/functions/uac1_legacy.gs0
ln -s /sys/kernel/config/usb_gadget/rockchip/functions/uac1_legacy.gs0
/sys/kernel/config/usb_gadget/rockchip/configs/b.1/uac1_legacy.gs0
mkdir /sys/kernel/config/usb_gadget/rockchip/functions/audio_source.gs0
ln -s /sys/kernel/config/usb_gadget/rockchip/functions/audio_source.gs0
/sys/kernel/config/usb_gadget/rockchip/configs/b.1/audio_source.gs0
echo ff400000.usb > /sys/kernel/config/usb_gadget/rockchip/UDC

其他配置和调试⽅法,请参考 4.1 UAC1 Legacy Usage 和 5.1 Audio Source Usage
6.2 UAC1 Legacy and Audio Source Composite Test

请参考 4.2 UAC1 Legacy Test 和 5.2 Audio Source Test
7 Composite with ADB

当 UAC1 和 ADB ⼀起使⽤时,UAC1 必须放在前⾯。否则,可能会导致在Windows系统上,UAC设备驱动⽆法识别
的问题。

⽐如:UAC1,ADB同时使⽤时,脚本的link顺序应该为:UAC1,ADB
ln -s /sys/kernel/config/usb_gadget/rockchip/functions/uac1.gs0
/sys/kernel/config/usb_gadget/rockchip/configs/b.1/uac1.gs0
ln -s /sys/kernel/config/usb_gadget/rockchip/functions/ffs.adb
/sys/kernel/config/usb_gadget/rockchip/configs/b.1/ffs.adb

8 Reference Documentation
USB Protocol (from USB Implementers Forum)
Universal Serial Bus Specification, Revision 2.0
Universal Serial Bus Audio Device Class Specification for Basic Audio Devices
Universal Serial Bus Device Class Definition for Audio Devices, Release 1.0
Universal Serial Bus Device Class Definition for Audio Devices, Release 2.0
Universal Serial Bus Device Class Definition for Audio Data Formats(referred to in this document as USB
Audio Data Formats)
Universal Serial Bus Device Class Definition for Terminal Types(referred to in this document as USB Audio
Terminal Types)
Others
The Well-Tempered Computer (An introduction to computer audio) - USB
Windows USB Audio 2.0 Drivers

9 Appendix A UAC1 Device Descriptor
Device Descriptor:
bLength

18

bDescriptorType
bcdUSB

1
2.00

bDeviceClass

0 (Defined at Interface level)

bDeviceSubClass

0

bDeviceProtocol

0

bMaxPacketSize0

64

idVendor

0x2207

idProduct

0x0019

bcdDevice

1.00

iManufacturer

1 rockchip

iProduct

2 USB Audio Device

iSerial

3 0123456789ABCDEF

bNumConfigurations

1

Configuration Descriptor:
bLength
bDescriptorType
wTotalLength

9
2
174

bNumInterfaces

3

bConfigurationValue

1

iConfiguration
bmAttributes

4 audio
0x80

(Bus Powered)
MaxPower

500mA

Interface Descriptor:
bLength

9

bDescriptorType

4

bInterfaceNumber

0

bAlternateSetting

0

bNumEndpoints

0

bInterfaceClass

1 Audio

bInterfaceSubClass

1 Control Device

bInterfaceProtocol

0

iInterface

5 AC Interface

AudioControl Interface Descriptor:
bLength

10

bDescriptorType

36

bDescriptorSubtype
bcdADC

1 (HEADER)
1.00

wTotalLength

52

bInCollection

2

baInterfaceNr( 0)

1

baInterfaceNr( 1)

2

AudioControl Interface Descriptor:
bLength

12

bDescriptorType

36

bDescriptorSubtype
bTerminalID
wTerminalType
bAssocTerminal
bNrChannels
wChannelConfig

2 (INPUT_TERMINAL)
1
0x0101 USB Streaming
0
2
0x0003

Left Front (L)
Right Front (R)
iChannelNames

7 Playback Channels

iTerminal

6 Playback Input terminal

AudioControl Interface Descriptor:
bLength
bDescriptorType
bDescriptorSubtype
bTerminalID
wTerminalType

9
36
3 (OUTPUT_TERMINAL)
2
0x0301 Speaker

bAssocTerminal

0

bSourceID

1

iTerminal

8 Playback Output terminal

AudioControl Interface Descriptor:
bLength

12

bDescriptorType

36

bDescriptorSubtype

2 (INPUT_TERMINAL)

bTerminalID

3

wTerminalType

0x0201 Microphone

bAssocTerminal

0

bNrChannels

2

wChannelConfig

0x0003

Left Front (L)
Right Front (R)
iChannelNames

10 Capture Channels

iTerminal

9 Capture Input terminal

AudioControl Interface Descriptor:
bLength
bDescriptorType

9
36

bDescriptorSubtype

3 (OUTPUT_TERMINAL)

bTerminalID

4

wTerminalType

0x0101 USB Streaming

bAssocTerminal

0

bSourceID

3

iTerminal

11 Capture Output terminal

Interface Descriptor:
bLength

9

bDescriptorType

4

bInterfaceNumber

1

bAlternateSetting

0

bNumEndpoints

0

bInterfaceClass

1 Audio

bInterfaceSubClass

2 Streaming

bInterfaceProtocol
iInterface

0
12 Playback Inactive

Interface Descriptor:
bLength

9

bDescriptorType

4

bInterfaceNumber

1

bAlternateSetting

1

bNumEndpoints

1

bInterfaceClass

1 Audio

bInterfaceSubClass

2 Streaming

bInterfaceProtocol
iInterface

0
13 Playback Active

AudioStreaming Interface Descriptor:
bLength
bDescriptorType

7
36

bDescriptorSubtype

1 (AS_GENERAL)

bTerminalLink

1

bDelay

1 frames

wFormatTag

1 PCM

AudioStreaming Interface Descriptor:
bLength

11

bDescriptorType

36

bDescriptorSubtype

2 (FORMAT_TYPE)

bFormatType

1 (FORMAT_TYPE_I)

bNrChannels

2

bSubframeSize

2

bBitResolution

16

bSamFreqType
tSamFreq[ 0]

1 Discrete
48000

Endpoint Descriptor:
bLength

9

bDescriptorType

5

bEndpointAddress

0x02

bmAttributes

EP 2 OUT

9

Transfer Type

Isochronous

Synch Type

Adaptive

Usage Type
wMaxPacketSize

Data
0x00c8

bInterval

4

bRefresh

0

bSynchAddress

0

1x 200 bytes

AudioControl Endpoint Descriptor:
bLength

7

bDescriptorType

37

bDescriptorSubtype

1 (EP_GENERAL)

bmAttributes

0x01

Sampling Frequency
bLockDelayUnits

1 Milliseconds

wLockDelay

1 Milliseconds

Interface Descriptor:
bLength

9

bDescriptorType

4

bInterfaceNumber

2

bAlternateSetting

0

bNumEndpoints

0

bInterfaceClass

1 Audio

bInterfaceSubClass

2 Streaming

bInterfaceProtocol
iInterface

0
14 Capture Inactive

Interface Descriptor:
bLength

9

bDescriptorType

4

bInterfaceNumber

2

bAlternateSetting

1

bNumEndpoints

1

bInterfaceClass

1 Audio

bInterfaceSubClass

2 Streaming

bInterfaceProtocol

0

iInterface

15 Capture Active

AudioStreaming Interface Descriptor:
bLength
bDescriptorType

7
36

bDescriptorSubtype

1 (AS_GENERAL)

bTerminalLink

4

bDelay

1 frames

wFormatTag

1 PCM

AudioStreaming Interface Descriptor:
bLength

11

bDescriptorType

36

bDescriptorSubtype

2 (FORMAT_TYPE)

bFormatType

1 (FORMAT_TYPE_I)

bNrChannels

2

bSubframeSize

2

bBitResolution

16

bSamFreqType

1 Discrete

tSamFreq[ 0]

48000

Endpoint Descriptor:
bLength

9

bDescriptorType

5

bEndpointAddress

0x81

bmAttributes

EP 1 IN

5

Transfer Type

Isochronous

Synch Type

Asynchronous

Usage Type

Data

wMaxPacketSize

0x00c8

bInterval

4

bRefresh

0

bSynchAddress

0

1x 200 bytes

AudioControl Endpoint Descriptor:
bLength

7

bDescriptorType

37

bDescriptorSubtype
bmAttributes

1 (EP_GENERAL)
0x01

Sampling Frequency
bLockDelayUnits

0 Undefined

wLockDelay

0 Undefined

Device Qualifier (for other device speed):
bLength

10

bDescriptorType

6

bcdUSB

2.00

bDeviceClass

0 (Defined at Interface level)

bDeviceSubClass

0

bDeviceProtocol

0

bMaxPacketSize0

64

bNumConfigurations
Device Status:

1

0x0000

(Bus Powered)

10 Appendix B UAC2 Device Descriptor
Device Descriptor:
bLength
bDescriptorType
bcdUSB

18
1
2.00

bDeviceClass

0 (Defined at Interface level)

bDeviceSubClass

0

bDeviceProtocol

0

bMaxPacketSize0

64

idVendor

0x2207

idProduct

0x0019

bcdDevice

2.00

iManufacturer

1 rockchip

iProduct

2 USB Audio Device

iSerial

3 0123456789ABCDEF

bNumConfigurations

1

Configuration Descriptor:

bLength

9

bDescriptorType

2

wTotalLength

219

bNumInterfaces

3

bConfigurationValue

1

iConfiguration
bmAttributes

4 audio
0x80

(Bus Powered)
MaxPower

500mA

Interface Association:
bLength

8

bDescriptorType

11

bFirstInterface

0

bInterfaceCount

3

bFunctionClass

1 Audio

bFunctionSubClass

0

bFunctionProtocol

32

iFunction

5 Source/Sink

Interface Descriptor:
bLength

9

bDescriptorType

4

bInterfaceNumber

0

bAlternateSetting

0

bNumEndpoints

0

bInterfaceClass

1 Audio

bInterfaceSubClass

1 Control Device

bInterfaceProtocol
iInterface

32
6 Topology Control

AudioControl Interface Descriptor:
bLength
bDescriptorType
bDescriptorSubtype
bcdADC
bCategory
wTotalLength
bmControl

9
36
1 (HEADER)
2.00
8
83
0x00

AudioControl Interface Descriptor:
bLength

8

bDescriptorType

36

bDescriptorSubtype

10 (CLOCK_SOURCE)

bClockID

6

bmAttributes

0x01 Internal fixed Clock

bmControls

0x01

Clock Frequency Control (read-only)
bAssocTerminal

0

iClockSource

7 48000Hz

AudioControl Interface Descriptor:
bLength

8

bDescriptorType

36

bDescriptorSubtype

10 (CLOCK_SOURCE)

bClockID

5

bmAttributes

0x01 Internal fixed Clock

bmControls

0x01

Clock Frequency Control (read-only)
bAssocTerminal

0

iClockSource

8 64000Hz

AudioControl Interface Descriptor:
bLength

17

bDescriptorType

36

bDescriptorSubtype

2 (INPUT_TERMINAL)

bTerminalID

1

wTerminalType

0x0101 USB Streaming

bAssocTerminal

0

bCSourceID

5

bNrChannels

2

bmChannelConfig

0x00000003

Front Left (FL)
Front Right (FR)
bmControls

0x0003

Copy Protect Control (read/write)
iChannelNames

0

iTerminal

9 USBH Out

AudioControl Interface Descriptor:
bLength

17

bDescriptorType

36

bDescriptorSubtype

2 (INPUT_TERMINAL)

bTerminalID

2

wTerminalType

0x0201 Microphone

bAssocTerminal

0

bCSourceID

6

bNrChannels

2

bmChannelConfig

0x00000003

Front Left (FL)
Front Right (FR)
bmControls

0x0003

Copy Protect Control (read/write)
iChannelNames
iTerminal

0
10 USBD Out

AudioControl Interface Descriptor:
bLength

12

bDescriptorType

36

bDescriptorSubtype

3 (OUTPUT_TERMINAL)

bTerminalID

4

wTerminalType

0x0101 USB Streaming

bAssocTerminal

0

bSourceID

2

bCSourceID

6

bmControls

0x0003

Copy Protect Control (read/write)
iTerminal

11 USBH In

AudioControl Interface Descriptor:
bLength

12

bDescriptorType

36

bDescriptorSubtype
bTerminalID
wTerminalType

3 (OUTPUT_TERMINAL)
3
0x0301 Speaker

bAssocTerminal

0

bSourceID

1

bCSourceID

5

bmControls

0x0003

Copy Protect Control (read/write)
iTerminal

12 USBD In

Interface Descriptor:
bLength

9

bDescriptorType

4

bInterfaceNumber

1

bAlternateSetting

0

bNumEndpoints

0

bInterfaceClass

1 Audio

bInterfaceSubClass

2 Streaming

bInterfaceProtocol

32

iInterface

13 Playback Inactive

Interface Descriptor:
bLength

9

bDescriptorType

4

bInterfaceNumber

1

bAlternateSetting

1

bNumEndpoints

1

bInterfaceClass

1 Audio

bInterfaceSubClass

2 Streaming

bInterfaceProtocol

32

iInterface

14 Playback Active

AudioStreaming Interface Descriptor:
bLength

16

bDescriptorType

36

bDescriptorSubtype
bTerminalLink

1

bmControls

0x00

bFormatType
bmFormats

1 (AS_GENERAL)

1
0x00000001

PCM
bNrChannels
bmChannelConfig

2
0x00000003

Front Left (FL)
Front Right (FR)
iChannelNames

0

AudioStreaming Interface Descriptor:
bLength
bDescriptorType

6
36

bDescriptorSubtype

2 (FORMAT_TYPE)

bFormatType

1 (FORMAT_TYPE_I)

bSubslotSize
bBitResolution

2
16

Endpoint Descriptor:
bLength

7

bDescriptorType

5

bEndpointAddress
bmAttributes
Transfer Type

0x02

EP 2 OUT

9
Isochronous

Synch Type

Adaptive

Usage Type

Data

wMaxPacketSize

0x0100

bInterval

1x 256 bytes

4

AudioControl Endpoint Descriptor:
bLength

8

bDescriptorType

37

bDescriptorSubtype

1 (EP_GENERAL)

bmAttributes

0x00

bmControls

0x00

bLockDelayUnits

0 Undefined

wLockDelay

0

Interface Descriptor:
bLength

9

bDescriptorType

4

bInterfaceNumber

2

bAlternateSetting

0

bNumEndpoints

0

bInterfaceClass

1 Audio

bInterfaceSubClass

2 Streaming

bInterfaceProtocol

32

iInterface

15 Capture Inactive

Interface Descriptor:
bLength

9

bDescriptorType

4

bInterfaceNumber

2

bAlternateSetting

1

bNumEndpoints

1

bInterfaceClass

1 Audio

bInterfaceSubClass

2 Streaming

bInterfaceProtocol

32

iInterface

16 Capture Active

AudioStreaming Interface Descriptor:
bLength

16

bDescriptorType

36

bDescriptorSubtype

1 (AS_GENERAL)

bTerminalLink

4

bmControls

0x00

bFormatType
bmFormats

1
0x00000001

PCM
bNrChannels
bmChannelConfig

2
0x00000003

Front Left (FL)
Front Right (FR)
iChannelNames

0

AudioStreaming Interface Descriptor:
bLength
bDescriptorType

6
36

bDescriptorSubtype

2 (FORMAT_TYPE)

bFormatType

1 (FORMAT_TYPE_I)

bSubslotSize
bBitResolution

2
16

Endpoint Descriptor:
bLength

7

bDescriptorType

5

bEndpointAddress

0x81

bmAttributes

EP 1 IN

13

Transfer Type

Isochronous

Synch Type

Synchronous

Usage Type

Data

wMaxPacketSize

0x00c0

bInterval

1x 192 bytes

4

AudioControl Endpoint Descriptor:
bLength

8

bDescriptorType

37

bDescriptorSubtype

1 (EP_GENERAL)

bmAttributes

0x00

bmControls

0x00

bLockDelayUnits

0 Undefined

wLockDelay

0

Device Qualifier (for other device speed):
bLength

10

bDescriptorType

6

bcdUSB

2.00

bDeviceClass

0 (Defined at Interface level)

bDeviceSubClass

0

bDeviceProtocol

0

bMaxPacketSize0

64

bNumConfigurations
Device Status:
(Bus Powered)

0x0000

1



Source Exif Data:
File Type                       : PDF
File Type Extension             : pdf
MIME Type                       : application/pdf
PDF Version                     : 1.4
Linearized                      : No
Creator                         : Typora
Producer                        : Typora
Create Date                     : 2019:03:14 10:56:03
Modify Date                     : 2019:03:14 10:56:03
Page Count                      : 35
Page Mode                       : UseOutlines
Warning                         : [Minor] Ignored duplicate Info dictionary
EXIF Metadata provided by EXIF.tools

Navigation menu