USB Audio Gadget Driver

Gadget  Audio

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

Kernel config of Audio Gadget
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)

Use BF527-EZKIT as a soundcard for linux Host
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
# 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 with musb_h Linux USB Audio Gadget at usb
here,audio gadget device is shown up as sound card 1.

Related :   USB Ethernet Testing - Measuring network throughput using iperf

Test Audio Gadget

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


Android Android Commands Android Java Applications Application Libraries Application Stack / User Interface Bash / Shell Scripts Commands and Packages Compilation Content Management System - CMS Core Kernel C Programs Development & Build Development Environment Setup Errors & Failures Flutter git Go Language Programs Hardware Platforms HTML JAVA Programs Kernel & Device Drivers Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Monetization / Google AdSense Multimedia - Audio, Video, Images NDK / Middleware / HAL OS Concepts PHP Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized User Interface Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply / Ask Question