Re: uac2: diagnosing uac2 audio gadget problems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 14, 2016 at 02:00:23PM +0800, Peter Chen wrote:
> On Mon, Jun 13, 2016 at 04:49:50PM -0700, Caleb Crome wrote:
> > On Mon, Jun 13, 2016 at 4:04 PM, Caleb Crome <caleb@xxxxxxxxx> wrote:
> > > On Mon, Jun 13, 2016 at 2:53 AM, Peter Chen <hzpeterchen@xxxxxxxxx> wrote:
> > >> On Wed, Jun 08, 2016 at 04:11:11PM -0700, Caleb Crome wrote:
> > >>>
> > >>> Here is the script I use for starting the gadget interface:
> > >>>
> > >>> cd /sys/kernel/config/usb_gadget
> > >>> mkdir g1
> > >>> cd g1
> > >>> echo "0x1d6b" > idVendor
> > >>> echo "0x0104" > idProduct
> > >>> mkdir strings/0x409
> > >>> echo "0123456789" > strings/0x409/serialnumber
> > >>> echo "Foo Inc." > strings/0x409/manufacturer
> > >>> echo "Bar Gadget" > strings/0x409/product
> > >>> mkdir functions/uac2.aud0
> > >>> mkdir functions/ecm.usb0
> > >>> #echo 64000 > functions/uac2.aud0/c_srate
> > >>> #echo 64000 > functions/uac2.aud0/p_srate
> > >>> mkdir configs/c.1
> > >>> mkdir configs/c.1/strings/0x409
> > >>> echo "CDC ECM + audio" > configs/c.1/strings/0x409/configuration
> > >>> ln -s functions/uac2.aud0 configs/c.1
> > >>> ln -s functions/ecm.usb0 configs/c.1
> > >>> echo `ls /sys/class/udc/` > /sys/kernel/config/usb_gadget/g1/UDC
> > >>>
> > >>
> > >> Try to use below command to see if it works, it works at my i.mx6 board.
> > >>
> > >> 1. **** List of PLAYBACK Hardware Devices ****
> > >> root@imx6sxsabresd:~# aplay -l
> > >> **** List of PLAYBACK Hardware Devices ****
> > >> card 0: wm8962audio [wm8962-audio], device 0: HiFi wm8962-0 []
> > >>   Subdevices: 1/1
> > >>   Subdevice #0: subdevice #0
> > >> card 1: imxspdif [imx-spdif], device 0: S/PDIF PCM Playback dit-hifi-0 []
> > >>   Subdevices: 1/1
> > >>   Subdevice #0: subdevice #0
> > >> card 2: UAC2Gadget [UAC2_Gadget], device 0: UAC2 PCM [UAC2 PCM]
> > >>   Subdevices: 1/1
> > >>   Subdevice #0: subdevice #0
> > >> 2. **** List of CAPTURE Hardware Devices ****
> > >> root@imx6sxsabresd:~# arecord -l
> > >> **** List of CAPTURE Hardware Devices ****
> > >> card 0: wm8962audio [wm8962-audio], device 0: HiFi wm8962-0 []
> > >>   Subdevices: 1/1
> > >>   Subdevice #0: subdevice #0
> > >> card 2: UAC2Gadget [UAC2_Gadget], device 0: UAC2 PCM [UAC2 PCM]
> > >>   Subdevices: 1/1
> > >>   Subdevice #0: subdevice #0
> > >> 3. Using below command to play (it is playback, the audio file is from
> > >> PC)
> > >> root@imx6sxsabresd:~# arecord -f dat -t wav -D hw:2,0 | aplay -D hw:0,0 &
> > >>
> > >> NOTE: arecord uses uac2_gadget to record, aplay uses real codec to play
> > >>
> > >
> > > Great to hear that it works on your board, that gives me hope :-)
> > >
> > > 2 questions:
> > > 1) What kernel version do you use?
> > > 2) What are the commands you send to configfs to get it working?  Does
> > > it look like mine?
> > >
> 
> I tried your commands, it can't work indeed. It seems the two interfaces
> can't be work together, the host side can't find the USB audio device.
> My test branch:
> https://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git
> branch: testing/next
> 
> Works command:
> modprobe libcomposite
> mount none /sys/kernel/config/ -t configfs
> cd /sys/kernel/config/usb_gadget
> mkdir g1
> cd g1
> echo "0x1d6b" > idVendor
> echo "0x0104" > idProduct
> mkdir strings/0x409
> echo "0123456789" > strings/0x409/serialnumber
> echo "Foo Inc." > strings/0x409/manufacturer
> echo "Bar Gadget" > strings/0x409/product
> mkdir functions/uac2.aud0
> # mkdir functions/ecm.usb0
> 
> mkdir configs/c.1
> mkdir configs/c.1/strings/0x409
> # echo "CDC ECM + audio" > configs/c.1/strings/0x409/configuration
> 
> 
> echo 2 > functions/uac2.aud0/p_ssize
> echo 48000 > functions/uac2.aud0/p_srate
> echo 3 > functions/uac2.aud0/p_chmask
> 
> echo 2 > functions/uac2.aud0/c_ssize
> echo 48000 > functions/uac2.aud0/c_srate
> echo 3 > functions/uac2.aud0/c_chmask
> 
> ln -s functions/uac2.aud0 configs/c.1
> # ln -s functions/ecm.usb0 configs/c.1
> 
> echo `ls /sys/class/udc/` > /sys/kernel/config/usb_gadget/g1/UDC
> 
> At host side:
> aplay -Dhw:1 sine48k16s-5min.wav
> card 1: Gadget [Bar Gadget], device 0: USB Audio [USB Audio]
>   Subdevices: 1/1
>     Subdevice #0: subdevice #0
> 
> At device side:
> arecord -f dat -t wav -D hw:2,0 | aplay -D hw:0,0 &
> 
> I can hear the wav from my codec
> 

When I try to fix that issue, I find this issue is gone. Both
ncm and usb audio works properly. Below is my commands:

modprobe libcomposite
# echo "file drivers/usb/* +p" > /sys/kernel/debug/dynamic_debug/control

mount none /sys/kernel/config/ -t configfs
cd /sys/kernel/config/usb_gadget
mkdir g1
cd g1
echo "0x1d6b" > idVendor
echo "0x0104" > idProduct
mkdir strings/0x409
echo "0123456789" > strings/0x409/serialnumber
echo "Foo Inc." > strings/0x409/manufacturer
echo "Bar Gadget" > strings/0x409/product
mkdir functions/uac2.aud0
mkdir functions/ecm.usb0

mkdir configs/c.1
mkdir configs/c.1/strings/0x409
echo "CDC ECM + audio" > configs/c.1/strings/0x409/configuration


echo 2 > functions/uac2.aud0/p_ssize
echo 48000 > functions/uac2.aud0/p_srate
echo 3 > functions/uac2.aud0/p_chmask

echo 2 > functions/uac2.aud0/c_ssize
echo 48000 > functions/uac2.aud0/c_srate
echo 3 > functions/uac2.aud0/c_chmask

ln -s functions/uac2.aud0 configs/c.1
ln -s functions/ecm.usb0 configs/c.1

echo `ls /sys/class/udc/` > /sys/kernel/config/usb_gadget/g1/UDC

-- 

Best Regards,
Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux