storage R&D guy.
全部博文(1000)
分类: 服务器与存储
2015-05-22 10:30:36
This document explains how to enable and use the audio gadget driver, this driver allows to use you board as a audio gadget device for either to work as a audio capture device such as a microphone or to work as an audio receiver device such as speakers.
This driver comes by default into the kernel and is compatible with the USB Audio Class specification 1.0. The current driver allows audio playback mode only and comes wired to the sound system so it automatically uses the default audio decoder to reproduce the audio that is coming from the host machine.
1. Go to you SDK and open the configuration window make config
2. Go to
-> Kernel configuration -> Device Drivers -> USB support (USB_SUPPORT [=y])
and activate the Inventra Highspeed Dual Role Controller (TI, ADI, ...) option to be built in the kernel (press space util it shows a * symbol on it).
Once you have selected it you have to change the Driver Mode option to USB Peripheral (gadget stack).
3. Now activate the USB Gadget Support option (check it as built in the kernel) on
-> Kernel configuration -> Device Drivers -> USB support (USB_SUPPORT [=y])
4. Go to
-> Kernel configuration -> Device Drivers -> USB support (USB_SUPPORT [=y]) -> USB Gadget Support (USB_GADGET [=y])
and change the USB Peripheral Controller option to Inventra HDRC USB Peripheral (TI, ADI, ...).
5. Activate the USB Gadget Drivers option as a module (M) in
-> Kernel configuration -> Device Drivers -> USB support (USB_SUPPORT [=y]) -> USB Gadget Support (USB_GADGET [=y])
6. Activate the Audio Gadget (EXPERIMENTAL) option as a module (M) in
-> Kernel configuration -> Device Drivers -> USB support (USB_SUPPORT [=y]) -> USB Gadget Support (USB_GADGET [=y])
7. Save the changes and exit from the configuration window.
8. Built your SDK (make).
Once you have built the driver it is ready to be used. In this example we are using the LeopardBoard DM368. Before start your board you need to change its jumper configuration to device mode instead of host mode, you can do that by removing the jumper J1 and installing jumper between Pin1 and Pin2 on J4.
After booting up the board you can see the following output
Advanced Linux Sound Architecture Driver Version 1.0.21. No device for DAI tlv320aic3x No device for DAI davinci-i2s asoc: tlv320aic3x <-> davinci-i2s mapping ok ALSA device list: #0: DaVinci DM365 EVM (tlv320aic3x)
Then in the board's terminal you must load the audio gadget module by running the following command
modprobe g_audio
If everything is fine you will see an output like this
/ # modprobe g_audio g_audio gadget: Hardware params: access 3, format 2, channels 2, rate 48000 g_audio gadget: audio_buf_size 48000, req_buf_size 200, req_count 256 g_audio gadget: Linux USB Audio Gadget, version: Dec 18, 2008 g_audio gadget: g_audio ready
This way the module has been loaded and the driver is ready to be used. In order to test it you can connect the board to a PC using a USB cable and send an audio streaming to the board.
Once you have connected the board to the PC you can see if it was recognized correctly by running the following command:
cat /proc/asound/cards
the you will get an output like this
~$ cat /proc/asound/cards 0 [NVidia ]: HDA-Intel - HDA NVidia HDA NVidia at 0xfe024000 irq 22 1 [Gadget ]: USB-Audio - Linux USB Audio Gadget Linux 2.6.32-17-ridgerun with musb_hdrc Linux USB Audio Gadget at usb-0000:00:0
So you can see that the board as been detected as a Linux USB Audio Gadget with ID 1. Now we can playback an audio file using the audio gadget device by running the following command:
aplay -D plug:hw:1 audio_file.wav
Be aware that you must use the same hardware ID we got for the gadget device. After that you will be able to hear the audio content in your board's audio output.