Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Contents

Table of Contents

Kernel Setup

Enter kernel configuration

...

  1. Select submenus for USB Gadget configfs : Device Drivers > USB support > USB support > USB Gadget Support. Select <*> for “USB Gadget functions configurable through configfs“, [*] for “Function filesystem (FunctionFS)” and [*] for “Audio Class 1.0“.

...

ConfigFS

Configure UAC gadget through configfs saved as a file named setup_uac.

...

Code Block
#!/bin/sh

CONFIGFS_HOME=/sys/kernel/config
VID=0xabcd
PID=0x1234
serial_number="myserial"
manufacturer="mymfg"
product="myproduct"
name="c"
number="1"
configuration="uac1"
maxpower="500"

CONFIG="configs/$name.$number"
FUNCTION="uac1.0"
UDC_NAME="f8102800.usb"

modprobe libcomposite

mount -t configfs none $CONFIGFS_HOME
mkdir -p $CONFIGFS_HOME/usb_gadget/g1
cd $CONFIGFS_HOME/usb_gadget/g1
echo $VID > idVendor
echo $PID > idProduct

mkdir -p strings/0x409
echo $serial_number > strings/0x409/serialnumber
echo $manufacturer > strings/0x409/manufacturer
echo $product > strings/0x409/product

mkdir -p configs/$name.$number
echo $maxpower > configs/$name.$number/MaxPower

mkdir -p configs/$name.$number/strings/0x409
echo $configuration > configs/$name.$number/strings/0x409/configuration

mkdir -p functions/$FUNCTION
echo 0x3 > functions/$FUNCTION/p_chmask
echo 48000 > functions/$FUNCTION/p_srate
echo 2 > functions/$FUNCTION/p_ssize
echo 0x3 > functions/$FUNCTION/c_chmask
echo 48000 > functions/$FUNCTION/c_srate
echo 2 > functions/$FUNCTION/c_ssize

ln -s functions/$FUNCTION configs/$name.$number
echo $UDC_NAME > UDC

Test Configurations for USB 2.0 Gadget Audio

  1. Use an USB-A to Micro-USB cable to connect the Windows PC and the SP7350 platform.

  2. Plug an USB sound card to the USB 3.0 Type C port of the SP7350 platform and plug a earphone to the sound card.

...

In Device Manager of Windows PC, “Capture Input terminal (AC Interface)“ and “Speakers (AC Interface)“ will show up in Audio inputs and outputs. “AC Interface” will show up in Sound, video and game controllers.

...

Test for USB 2.0 Gadget Audio

The command-line audio player (aplay) and soundfile recorder (arecord) are used for the test.

Record and Play

...

Play music and choose “Speakers (AC Interface)“ in Windows PC. Then use arecord -D hw:1,0 -c 2 -r 48000 -f S16_LE | aplay -D hw:2,0 -c 2 -r 48000 -f S16_LE command to output the sounds to the earphone of the USB sound card in USB 3.0 type C port in the SP7350 platform.

Code Block
sunplus@ubuntu:~$ arecord -D hw:1,0 -c 2 -r 48000 -f S16_LE | aplay -D hw:2,0 -c 2 -r 48000 -f S16_LE
Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
Playing WAVE 'stdin' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo

Record Channel

...

Play music and choose “Speakers (AC Interface)“ in Windows PC. Then use arecord -D hw:1,0 -c 2 -r 48000 -f S16_LE pc_music.wav command to record it as pc_music.wav in the SP7350 platform.

Code Block
sunplus@ubuntu:~$ arecord -D hw:1,0 -c 2 -r 48000 -f S16_LE pc_music.wav
Recording WAVE 'pc_music.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo

Play Channel

...

Use aplay -D hw:1,0 -c 2 -r 48000 -f S16_LE pc_music.wav command to play pc_music.wav in the SP7350 platform. Then choose “Capture Input terminal (AC Interface)“ and record it in the Windows PC.

...