Gadget Audio implements the USB Audio class, appearing to the host as a soundcard.It receives the PCM stream from host,i.e, a PC, over usb and sends it to the audio codec on board to playback it.Also,it can perform the inverse job for record.
Source file drivers/usb/gadget/audio.c
Before enabling this feature,make sure that audio codec works well on your board.
[Linux Kernel Configuration] -→ [Device Drivers] -→ [USB support] -→ [USB Gadget Support] <M> Support for USB Gadgets <M> Audio Gadget (EXPERIMENTAL)
Here the CPU is BF527C, with a built-in audio codec named SSM2602. After system booting up, SSM2602 can be seen as follows:
Advanced Linux Sound Architecture Driver Version 1.0.20. No device for DAI SSM2602 dma rx:3 tx:4, err irq:15, regs:ffc00800 ssm2602 Audio Codec 0.1 asoc: SSM2602 <-> bf5xx-i2s mapping ok ALSA device list: #0: bf5xx_ssm2602 (SSM2602)
On target side,You must load the gadget audio driver.
root:/> modprobe g_audio
If every thing is OK,then messages like follows will show up.
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 root:/> g_audio gadget: high speed config #1: Linux USB Audio Gadget
On the PC side:
cliff@debiancliff:~$ cat /proc/asound/cards
0 [Intel ]: HDA-Intel - HDA Intel
HDA Intel at 0xdfdfc000 irq 16
1 [Gadget ]: USB-Audio - Linux USB Audio Gadget
Linux 2.6.31.6-ADI-2010R1-pre-svn7883 with musb_h Linux USB Audio Gadget at usb
here,audio gadget device is shown up as sound card 1.
playback music with audio gadget device(soundcard 1 as above)
cliff@debiancliff:~$ aplay -D plug:hw:1 a.wav Playing WAVE 'a.wav' : Signed 16 bit Little Endian, Rate 22050 Hz, Stereo