Discussion:
What is the command line commands to use UAC2 at USB client side?
Xuebing Wang
2014-08-14 06:35:24 UTC
Permalink
Hi Community,

Based on Freescale platform , I am trying to use USB Audio Class version
2.0. Host can detect this UAC2 device.

At device side (after modprobe g_audio):

***@imx6slevk:~# 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

At device side, in driver/usb/gadget/Kconfig, it says before for
CONFIG_USB_AUDIO
-------------------------
This driver doesn't expect any real Audio codec to be present
on the device - the audio streams are simply sinked to and
sourced from a virtual ALSA sound card created. The user-space
application may choose to do whatever it wants with the data
received from the USB Host and choose to provide whatever it
wants as audio data to the USB Host.
-------------------------

My question is: at device side, how to configure sink/source for UAC2
virtual ALSA sound card (hw:2,0, UAC2_Gadget)?

Thank you very much.

Xuebing Wang
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Jassi Brar
2014-08-14 06:57:22 UTC
Permalink
Post by Xuebing Wang
Hi Community,
Based on Freescale platform , I am trying to use USB Audio Class version
2.0. Host can detect this UAC2 device.
**** 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
At device side, in driver/usb/gadget/Kconfig, it says before for
CONFIG_USB_AUDIO
-------------------------
This driver doesn't expect any real Audio codec to be present
on the device - the audio streams are simply sinked to and
sourced from a virtual ALSA sound card created. The user-space
application may choose to do whatever it wants with the data
received from the USB Host and choose to provide whatever it
wants as audio data to the USB Host.
-------------------------
My question is: at device side, how to configure sink/source for UAC2
virtual ALSA sound card (hw:2,0, UAC2_Gadget)?
At OS level, select the UAC2 card like any other - Control Panel ->
Sound settings. You want to select the same Card on Host as well as
Gadget side.

-Jassi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Xuebing Wang
2014-08-14 07:13:49 UTC
Permalink
Post by Jassi Brar
Post by Xuebing Wang
At device side, in driver/usb/gadget/Kconfig, it says before for
CONFIG_USB_AUDIO
-------------------------
This driver doesn't expect any real Audio codec to be present
on the device - the audio streams are simply sinked to and
sourced from a virtual ALSA sound card created. The user-space
application may choose to do whatever it wants with the data
received from the USB Host and choose to provide whatever it
wants as audio data to the USB Host.
-------------------------
My question is: at device side, how to configure sink/source for UAC2
virtual ALSA sound card (hw:2,0, UAC2_Gadget)?
At OS level, select the UAC2 card like any other - Control Panel ->
Sound settings. You want to select the same Card on Host as well as
Gadget side.
-Jassi
Thanks for your reply. At the device side, should I do something to
redirect the virtual sound card to a real one?
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Peter Chen
2014-08-15 00:55:25 UTC
Permalink
Post by Xuebing Wang
Post by Jassi Brar
Post by Xuebing Wang
At device side, in driver/usb/gadget/Kconfig, it says before for
CONFIG_USB_AUDIO
-------------------------
This driver doesn't expect any real Audio codec to be
present
Post by Jassi Brar
Post by Xuebing Wang
on the device - the audio streams are simply sinked to and
sourced from a virtual ALSA sound card created. The user-
space
Post by Jassi Brar
Post by Xuebing Wang
application may choose to do whatever it wants with the
data
Post by Jassi Brar
Post by Xuebing Wang
received from the USB Host and choose to provide whatever
it
Post by Jassi Brar
Post by Xuebing Wang
wants as audio data to the USB Host.
-------------------------
My question is: at device side, how to configure sink/source for UAC2
virtual ALSA sound card (hw:2,0, UAC2_Gadget)?
At OS level, select the UAC2 card like any other - Control Panel ->
Sound settings. You want to select the same Card on Host as well as
Gadget side.
-Jassi
Thanks for your reply. At the device side, should I do something to
redirect the virtual sound card to a real one?
--
I don't think you need, did you meet any problems?

Peter
��칻�&�~�&���+-��ݶ��w��˛���m�b��n������ܨ}���Ơz�&j:+v����n�r��6;靫3��\
nnX��f�z��
Xuebing Wang
2014-08-15 02:25:32 UTC
Permalink
Post by Peter Chen
Post by Xuebing Wang
Post by Jassi Brar
Post by Xuebing Wang
At device side, in driver/usb/gadget/Kconfig, it says before for
CONFIG_USB_AUDIO
-------------------------
This driver doesn't expect any real Audio codec to be
present
Post by Jassi Brar
Post by Xuebing Wang
on the device - the audio streams are simply sinked to and
sourced from a virtual ALSA sound card created. The user-
space
Post by Jassi Brar
Post by Xuebing Wang
application may choose to do whatever it wants with the
data
Post by Jassi Brar
Post by Xuebing Wang
received from the USB Host and choose to provide whatever
it
Post by Jassi Brar
Post by Xuebing Wang
wants as audio data to the USB Host.
-------------------------
My question is: at device side, how to configure sink/source for UAC2
virtual ALSA sound card (hw:2,0, UAC2_Gadget)?
At OS level, select the UAC2 card like any other - Control Panel ->
Sound settings. You want to select the same Card on Host as well as
Gadget side.
-Jassi
Thanks for your reply. At the device side, should I do something to
redirect the virtual sound card to a real one?
--
I don't think you need, did you meet any problems?
Peter
Thanks Peter.

My problem is that I can not hear any sound if playing wav from Ubuntu Host.

I can hear sound if I play wav for the real sound card at the device side.

For UAC1 (file u_uac1.c), usb audio stream is hard-coded to be directed
to "/dev/snd/pcmC0D0p". I am wondering for UAC2, should I do the similar?
--
Thanks,
Xuebing Wang

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Jassi Brar
2014-08-15 02:49:02 UTC
Permalink
Post by Xuebing Wang
Post by Peter Chen
Post by Xuebing Wang
Post by Jassi Brar
Post by Xuebing Wang
At device side, in driver/usb/gadget/Kconfig, it says before for
CONFIG_USB_AUDIO
-------------------------
This driver doesn't expect any real Audio codec to be
present
Post by Jassi Brar
Post by Xuebing Wang
on the device - the audio streams are simply sinked to and
sourced from a virtual ALSA sound card created. The user-
space
Post by Jassi Brar
Post by Xuebing Wang
application may choose to do whatever it wants with the
data
Post by Jassi Brar
Post by Xuebing Wang
received from the USB Host and choose to provide whatever
it
Post by Jassi Brar
Post by Xuebing Wang
wants as audio data to the USB Host.
-------------------------
My question is: at device side, how to configure sink/source for UAC2
virtual ALSA sound card (hw:2,0, UAC2_Gadget)?
At OS level, select the UAC2 card like any other - Control Panel ->
Sound settings. You want to select the same Card on Host as well as
Gadget side.
-Jassi
Thanks for your reply. At the device side, should I do something to
redirect the virtual sound card to a real one?
--
I don't think you need, did you meet any problems?
Peter
Thanks Peter.
My problem is that I can not hear any sound if playing wav from Ubuntu Host.
I can hear sound if I play wav for the real sound card at the device side.
For UAC1 (file u_uac1.c), usb audio stream is hard-coded to be directed to
"/dev/snd/pcmC0D0p". I am wondering for UAC2, should I do the similar?
That is actually a bad thing about UAC1. The piping should be done at
user level.
Please google for how to pipe output of 'arecord' into 'aplay'.
(BTW, there is nothing UAC specific about that)

-Jassi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Xuebing Wang
2014-08-15 03:49:45 UTC
Permalink
Post by Jassi Brar
Post by Xuebing Wang
Thanks Peter.
My problem is that I can not hear any sound if playing wav from Ubuntu Host.
I can hear sound if I play wav for the real sound card at the device side.
For UAC1 (file u_uac1.c), usb audio stream is hard-coded to be directed to
"/dev/snd/pcmC0D0p". I am wondering for UAC2, should I do the similar?
That is actually a bad thing about UAC1. The piping should be done at
user level.
Please google for how to pipe output of 'arecord' into 'aplay'.
(BTW, there is nothing UAC specific about that)
-Jassi
Jassi, thanks for your help.

Without knowing what is the best way to implement UAC2 at the device
side, I managed to simply pipe is as below:

Note: When I am playing music from Ubuntu host, I can hear light noise
from the device (via UAC2)


***@imx6slevk:~# modprobe g_audio c_srate=48000
g_audio gadget: Linux USB Audio Gadget, version: Feb 2, 2012
g_audio gadget: g_audio ready
***@imx6slevk:~# g_audio gadget: high-speed config #1: Linux USB Audio
Gadget

***@imx6slevk:~#
***@imx6slevk:~# arecord -f dat -t wav -D hw:2,0 | aplay -D hw:0,0
Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
Playing WAVE 'stdin' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Daniel Mack
2014-08-18 17:11:03 UTC
Permalink
Post by Xuebing Wang
Jassi, thanks for your help.
Without knowing what is the best way to implement UAC2 at the device
Note: When I am playing music from Ubuntu host, I can hear light noise
from the device (via UAC2)
g_audio gadget: Linux USB Audio Gadget, version: Feb 2, 2012
g_audio gadget: g_audio ready
Gadget
Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
Playing WAVE 'stdin' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
Such a setup should work, I recently tried it myself.

The other direction (capturing from host, playback on device), however,
has a major problem as the device interface has no timing mechanism, and
hence 'arecord | aplay' on the gadget side fails. I've prepared patches
and a more comprehensive description for this, but I'm waiting for
Andrzej's patches to be reviewed, as mine are based upon his.


Thanks,
Daniel

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Xuebing Wang
2014-08-19 00:01:50 UTC
Permalink
Post by Daniel Mack
Post by Xuebing Wang
Jassi, thanks for your help.
Without knowing what is the best way to implement UAC2 at the device
Note: When I am playing music from Ubuntu host, I can hear light noise
from the device (via UAC2)
g_audio gadget: Linux USB Audio Gadget, version: Feb 2, 2012
g_audio gadget: g_audio ready
Gadget
Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
Playing WAVE 'stdin' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
Such a setup should work, I recently tried it myself.
The other direction (capturing from host, playback on device), however,
has a major problem as the device interface has no timing mechanism, and
hence 'arecord | aplay' on the gadget side fails. I've prepared patches
and a more comprehensive description for this, but I'm waiting for
Andrzej's patches to be reviewed, as mine are based upon his.
Thanks,
Daniel
Daniel,

Thanks. You were trying UAC2, right? Does it work with Windows 7/8 host?

Did you try UAC1 too?
--
Thanks,
Xuebing Wang

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Daniel Mack
2014-08-19 08:45:51 UTC
Permalink
Post by Xuebing Wang
Post by Daniel Mack
Post by Xuebing Wang
Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
Playing WAVE 'stdin' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
Such a setup should work, I recently tried it myself.
The other direction (capturing from host, playback on device), however,
has a major problem as the device interface has no timing mechanism, and
hence 'arecord | aplay' on the gadget side fails. I've prepared patches
and a more comprehensive description for this, but I'm waiting for
Andrzej's patches to be reviewed, as mine are based upon his.
Thanks. You were trying UAC2, right?
Yes.
Post by Xuebing Wang
Does it work with Windows 7/8 host?
I have no idea, and no Windows box to test on.
Post by Xuebing Wang
Did you try UAC1 too?
Not in this case, no.


Daniel

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Xuebing Wang
2014-08-19 08:54:46 UTC
Permalink
Post by Xuebing Wang
Thanks. You were trying UAC2, right?
Yes.
Thanks Daniel. Did you hear noise (hear with ear phone, not speaker)
especially when playing music from Ubuntu host? I am hearing slight
noise here.
--
Thanks,
Xuebing Wang

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Daniel Mack
2014-08-19 08:58:13 UTC
Permalink
Post by Xuebing Wang
Post by Xuebing Wang
Thanks. You were trying UAC2, right?
Yes.
Thanks Daniel. Did you hear noise (hear with ear phone, not speaker)
especially when playing music from Ubuntu host? I am hearing slight
noise here.
Not that I noticed. I'd suggest recording audio from the host into a
file, then copy it over to your host for examination. Once you build a
chain of audio components, it's hard to tell where your problem is
otherwise.


Daniel

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Jassi Brar
2014-08-19 09:01:01 UTC
Permalink
Post by Daniel Mack
Post by Xuebing Wang
Post by Daniel Mack
Post by Xuebing Wang
Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
Playing WAVE 'stdin' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
Such a setup should work, I recently tried it myself.
The other direction (capturing from host, playback on device), however,
has a major problem as the device interface has no timing mechanism, and
hence 'arecord | aplay' on the gadget side fails. I've prepared patches
and a more comprehensive description for this, but I'm waiting for
Andrzej's patches to be reviewed, as mine are based upon his.
Hmm... I tested 48KHz USB-IN without noise, 44.1KHz did show noise
though ... iirc
Post by Daniel Mack
Post by Xuebing Wang
Thanks. You were trying UAC2, right?
Yes.
However if used with defaults(i.e, 64KHz USB-OUT and 48KHz USB-IN)
there should be no noise because samples divide up into frame nicely.
Post by Daniel Mack
Post by Xuebing Wang
Does it work with Windows 7/8 host?
I have no idea, and no Windows box to test on.
IIRC Windows doesn't have native support for UAC2.

-jassi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Daniel Mack
2014-08-19 09:09:44 UTC
Permalink
Post by Jassi Brar
Post by Daniel Mack
Post by Xuebing Wang
Post by Daniel Mack
Post by Xuebing Wang
Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
Playing WAVE 'stdin' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
Such a setup should work, I recently tried it myself.
The other direction (capturing from host, playback on device), however,
has a major problem as the device interface has no timing mechanism, and
hence 'arecord | aplay' on the gadget side fails. I've prepared patches
and a more comprehensive description for this, but I'm waiting for
Andrzej's patches to be reviewed, as mine are based upon his.
Hmm... I tested 48KHz USB-IN without noise, 44.1KHz did show noise
though ... iirc
With USB-IN, you're referring to arecord on the host side, and aplay on
the gadget? Playing/ recording wave files on both sides worked fine for
me. The only problem here is that once you link one side to a sink or
source that expects audio to be transported at least roughly with the
announces sample rate, things break because there is nothing that
controls the timing. It's easy to fix, and as I said, I have patches for
this that I'll send out shortly.

However, I thought Xuebing's setup is the other way around, right?
Post by Jassi Brar
Post by Daniel Mack
Post by Xuebing Wang
Does it work with Windows 7/8 host?
I have no idea, and no Windows box to test on.
IIRC Windows doesn't have native support for UAC2.
That's true, you need a third party driver for that. I was referring to
UAC1, but I didn't test this either.


Daniel

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Jassi Brar
2014-08-19 09:52:19 UTC
Permalink
Post by Daniel Mack
Post by Jassi Brar
Post by Daniel Mack
Post by Xuebing Wang
Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
Playing WAVE 'stdin' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
Such a setup should work, I recently tried it myself.
The other direction (capturing from host, playback on device), however,
has a major problem as the device interface has no timing mechanism, and
hence 'arecord | aplay' on the gadget side fails. I've prepared patches
and a more comprehensive description for this, but I'm waiting for
Andrzej's patches to be reviewed, as mine are based upon his.
Hmm... I tested 48KHz USB-IN without noise, 44.1KHz did show noise
though ... iirc
With USB-IN, you're referring to arecord on the host side, and aplay on
the gadget? Playing/ recording wave files on both sides worked fine for
me. The only problem here is that once you link one side to a sink or
source that expects audio to be transported at least roughly with the
announces sample rate, things break because there is nothing that
controls the timing. It's easy to fix, and as I said, I have patches for
this that I'll send out shortly.
Its been quite some time now, but I think we designed the uac2 to rely
on USB's ISO packets' rate control to send and receive audio data at
announced sampling rate. For some rates though the data rate doesn't
become a multiple of packetsize and we see a periodic 'click' noise.
Probably we are talking about the same thing. Please try to CC me on
your patches.
Post by Daniel Mack
However, I thought Xuebing's setup is the other way around, right?
Yes, Xuebing tested USB-OUT.

Cheers,
-Jassi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Daniel Mack
2014-08-24 13:56:41 UTC
Permalink
Hi Jassi,
Post by Jassi Brar
Its been quite some time now, but I think we designed the uac2 to rely
on USB's ISO packets' rate control to send and receive audio data at
announced sampling rate.
I'm still thinking how that setup should have ever been possible with
snd-usb-audio on the host side.

snd-usb-audio prepares its capture USB ISO frames with a pre-calculated
value of how many bytes per packet to expect on the capture endpoint.
That value is derived from the currently configured sample rate, and if
the sound card fills each of its buffers with that number of bytes or
less, everything's fine. Also, each urb is resubmitted immediately after
reception, and there is no delay or timing or anything.

f_uac2, however, currently always completes its buffers with 512 bytes
packets, which causes two problems: a) it leads to -EOVERFLOW errors on
the host side, as the host doesn't expect such big packets, and b) audio
is transported as fast as possible, and nothing ties the actual rate to
any clock on either side. In my tests, audio was transported roughly at
3x the actual sample rate. While this works fine if only files are in
the game on both sides, but once any part of the system expects the
actual rate to be at least approximately in the configured range, things
go wrong of course.

Also, the maximum number of bytes that the host expects to receive for a
packet is not part of the request communication on the USB wire. Even if
we wanted, we wouldn't be able to adopt to it in order to prevent
overflows on the host side.


My current fix is comprised of two parts:

a) set UAC_EP_CS_ATTR_FILL_MAX in the capture UAC2 endpoint, which
allows the gadget to actually send packet with wMaxPacketSize bytes, and

b) implement a simple timing mechanism to tie the gadget's capture
stream to the configured sample rate, and send 0 bytes packets if the
timing doesn't allow a full-sized packet to be sent again.

These two changes fixed the functionality on a BBB/musb gadget setup,
but I'd still like to understand how this could have ever worked the way
it's implemented at the moment.

Which OS did you test with on the host side, and what type of gadget
hardware was in use? I'll send out the patches once I have confidence
that I'm not missing anything essential :)



Thanks,
Daniel


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Jassi Brar
2014-08-24 16:26:02 UTC
Permalink
Post by Daniel Mack
Hi Jassi,
Post by Jassi Brar
Its been quite some time now, but I think we designed the uac2 to rely
on USB's ISO packets' rate control to send and receive audio data at
announced sampling rate.
I'm still thinking how that setup should have ever been possible with
snd-usb-audio on the host side.
snd-usb-audio prepares its capture USB ISO frames with a pre-calculated
value of how many bytes per packet to expect on the capture endpoint.
That value is derived from the currently configured sample rate, and if
the sound card fills each of its buffers with that number of bytes or
less, everything's fine. Also, each urb is resubmitted immediately after
reception, and there is no delay or timing or anything.
Doesn't .bInterval, set to get one ISO packet per millisec, play any role?
Post by Daniel Mack
f_uac2, however, currently always completes its buffers with 512 bytes
packets,
Current uac2 uses the max packset size (which may not be 512 for every
udc) for the EP. Probably it (wMaxPacketSize) should be set to
bytes/ms for the sampling rate.
Post by Daniel Mack
which causes two problems: a) it leads to -EOVERFLOW errors on
the host side, as the host doesn't expect such big packets, and b) audio
is transported as fast as possible, and nothing ties the actual rate to
any clock on either side. In my tests, audio was transported roughly at
3x the actual sample rate. While this works fine if only files are in
the game on both sides
f_uac2 is a virtual sound card that can not play/record sound to/from
a physical codec ... it's basically just a way to capture audio data
in digital form ;) so 'files' was assumed to be the primary way of
using it.
Now for USB-IN data flow control, maybe we should play with
bInterval, wMaxPacketSize and an hrtimer for some sampling rates.
Post by Daniel Mack
Which OS did you test with on the host side, and what type of gadget
hardware was in use? I'll send out the patches once I have confidence
that I'm not missing anything essential :)
The host was Ubuntu latest at that time. Testing method and 'quirks'
are documented in archives
http://www.spinics.net/lists/linux-usb/msg50855.html
We didn't have access to a Mac and Windows wouldn't support UAC2.

-jassi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Daniel Mack
2014-08-24 16:49:26 UTC
Permalink
Post by Jassi Brar
Post by Daniel Mack
f_uac2, however, currently always completes its buffers with 512 bytes
packets,
Current uac2 uses the max packset size (which may not be 512 for every
udc) for the EP. Probably it (wMaxPacketSize) should be set to
bytes/ms for the sampling rate.
It's actually really common to set wMaxPacketSize to something much
higher than the actual payload will be. After all, the device is free to
return short packets, and it's even supposed to do.
Post by Jassi Brar
Post by Daniel Mack
which causes two problems: a) it leads to -EOVERFLOW errors on
the host side, as the host doesn't expect such big packets, and b) audio
is transported as fast as possible, and nothing ties the actual rate to
any clock on either side. In my tests, audio was transported roughly at
3x the actual sample rate. While this works fine if only files are in
the game on both sides
f_uac2 is a virtual sound card that can not play/record sound to/from
a physical codec ... it's basically just a way to capture audio data
in digital form ;) so 'files' was assumed to be the primary way of
using it.
Sure, but audio still required to be 'real-time' :)
Post by Jassi Brar
The host was Ubuntu latest at that time. Testing method and 'quirks'
are documented in archives
http://www.spinics.net/lists/linux-usb/msg50855.html
We didn't have access to a Mac and Windows wouldn't support UAC2.
Ok. With files on both sides, it does in fact work. The use case for the
current setup, however, is a real-time streaming device, and hence we
have to rely on reasonable timing.

Anyway - thanks for the explanations. I'll polish my patches and post
them for discussion.


Thanks!
Daniel

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Peter Chen
2014-08-19 14:31:03 UTC
Permalink
Post by Daniel Mack
Post by Jassi Brar
Post by Daniel Mack
Post by Xuebing Wang
Post by Daniel Mack
Post by Xuebing Wang
Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
Playing WAVE 'stdin' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
Such a setup should work, I recently tried it myself.
The other direction (capturing from host, playback on device), however,
has a major problem as the device interface has no timing mechanism, and
hence 'arecord | aplay' on the gadget side fails. I've prepared patches
and a more comprehensive description for this, but I'm waiting for
Andrzej's patches to be reviewed, as mine are based upon his.
Hmm... I tested 48KHz USB-IN without noise, 44.1KHz did show noise
though ... iirc
With USB-IN, you're referring to arecord on the host side, and aplay on
the gadget? Playing/ recording wave files on both sides worked fine for
me. The only problem here is that once you link one side to a sink or
source that expects audio to be transported at least roughly with the
announces sample rate, things break because there is nothing that
controls the timing. It's easy to fix, and as I said, I have patches for
this that I'll send out shortly.
Will you add feedback endpoint for that?
Post by Daniel Mack
However, I thought Xuebing's setup is the other way around, right?
Post by Jassi Brar
Post by Daniel Mack
Post by Xuebing Wang
Does it work with Windows 7/8 host?
I have no idea, and no Windows box to test on.
IIRC Windows doesn't have native support for UAC2.
That's true, you need a third party driver for that. I was referring to
UAC1, but I didn't test this either.
Daniel
--
Best Regards,
Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Loading...