Re: uac2: diagnosing uac2 audio gadget problems

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

 



> On Mon, Jun 13, 2016 at 11:56 PM, Peter Chen <hzpeterchen@xxxxxxxxx> wrote:
>>
>> 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



Thanks so much for your help Peter!

It does sort of work!  My previous problem was that I wasn't playing
anything on the host when I was attempting to record.  I thought it
would just be sending zeros all the time, but no, it times out.

Unfortunately, it's not reliable for me.  I try this:

on MX6:
# arecord -f dat -t wav -D hw:1,0  | aplay -f dat -t wav -D hw:1,0

Notice that I'm just looping the data back to card 1.  I'm not
attempting to play out the sound card on the MX6 and on host I bring
up audacity and and simultaneously play and record.

It does kind of work, but it's full of glitches and gaps.  And for
some reason the volume is changed!  Strange.

I also try:

jackd -d alsa -d hw:1,0 -D -i2 -o2 -S -r48000&

but that really doesn't work when I try to connect.

So... it's definitely not usable at this point for me.  Maybe with
some some parameter tweaking it would work.

 Cheers,
   -Caleb
>
--
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