Jassi Brar | 19 Aug 13:22 2011

[PATCH 2/2] USB: Gadget: Add Audio Class 2.0 Driver

This is a flexible USB Audio Class 2.0 compliant gadget driver that
implements a simple topology with a virtual sound card exposed at
the function side.

The driver doesn't expect any real audio codec to be present on the
function - 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.

Capture(USB-Out) and Playback(USB-In) can be run at independent
configurations specified via module parameters while loading the driver.

Signed-off-by: Yadi Brar <yadi.brar01@...>
Signed-off-by: Jassi Brar <jassisinghbrar@...>
---

===========
How To Test
===========
  USB_DEV$ insmod g_audio2.ko c_srate=64000 p_srate=48000 ; say
    gadget: high speed config #1: UAC2

  USB_DEV$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: uac2 [uac2], device 0: UAC2 PCM [UAC2 PCM]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

  USB_DEV$ arecord -l
(Continue reading)

Felipe Balbi | 22 Aug 13:30 2011
Picon

Re: [PATCH 2/2] USB: Gadget: Add Audio Class 2.0 Driver

Hi,

On Fri, Aug 19, 2011 at 04:52:14PM +0530, Jassi Brar wrote:
> This is a flexible USB Audio Class 2.0 compliant gadget driver that
> implements a simple topology with a virtual sound card exposed at
> the function side.
> 
> The driver doesn't expect any real audio codec to be present on the
> function - 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.
> 
> Capture(USB-Out) and Playback(USB-In) can be run at independent
> configurations specified via module parameters while loading the driver.
> 
> Signed-off-by: Yadi Brar <yadi.brar01@...>
> Signed-off-by: Jassi Brar <jassisinghbrar@...>
> ---
> 
> ===========
> How To Test
> ===========
>   USB_DEV$ insmod g_audio2.ko c_srate=64000 p_srate=48000 ; say
>     gadget: high speed config #1: UAC2
> 
>   USB_DEV$ aplay -l
> **** List of PLAYBACK Hardware Devices ****
> card 0: uac2 [uac2], device 0: UAC2 PCM [UAC2 PCM]
>   Subdevices: 1/1
(Continue reading)

Jassi Brar | 22 Aug 14:37 2011

Re: [PATCH 2/2] USB: Gadget: Add Audio Class 2.0 Driver

On 22 August 2011 17:00, Felipe Balbi <balbi@...> wrote:
> Hi,
>
> On Fri, Aug 19, 2011 at 04:52:14PM +0530, Jassi Brar wrote:
>> This is a flexible USB Audio Class 2.0 compliant gadget driver that
>> implements a simple topology with a virtual sound card exposed at
>> the function side.
>>
>> The driver doesn't expect any real audio codec to be present on the
>> function - 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.
>>
>> Capture(USB-Out) and Playback(USB-In) can be run at independent
>> configurations specified via module parameters while loading the driver.
>>
>> Signed-off-by: Yadi Brar <yadi.brar01@...>
>> Signed-off-by: Jassi Brar <jassisinghbrar@...>
>> ---
>>
>> ===========
>> How To Test
>> ===========
>>   USB_DEV$ insmod g_audio2.ko c_srate=64000 p_srate=48000 ; say
>>     gadget: high speed config #1: UAC2
>>
>>   USB_DEV$ aplay -l
>> **** List of PLAYBACK Hardware Devices ****
>> card 0: uac2 [uac2], device 0: UAC2 PCM [UAC2 PCM]
(Continue reading)

Felipe Balbi | 22 Aug 14:44 2011
Picon

Re: [PATCH 2/2] USB: Gadget: Add Audio Class 2.0 Driver

Hi,

On Mon, Aug 22, 2011 at 06:07:46PM +0530, Jassi Brar wrote:

[big snip]

> Hi Felipe,

Hi

> Functionality wise, audio.c hardcodes the data-path to the physical
> audio-codec onboard
> whereas audio2.c provides user-space with a virtual sound-card to fool around
> with audio-data the way the user wants. The functionality that has
> lion's share of code.
> Also, although the functionality of audio.c can be achieved by audio2.c (but not
> vice-versa) we'll break user-space by changing the behavior of audio.c
> to audio2.c
> 
> Besides fundamental differences in functionality, they differ by
> Usb-Audio-Class
> compliance as well.  audio.c is UAC_1 compliant, whereas audio2.c is UAC_2
> complaint.
> One can not replace the other. For ex, MS-Windows doesn't support
> UAC_2 by default
> yet, Linux does reasonably well. And by definition having
> Linux-USB-Gadget support
> UAC_2 also, is only better. So by having both we cover more ground than by
> having just one.

(Continue reading)

Jassi Brar | 22 Aug 15:00 2011
Picon

Re: [PATCH 2/2] USB: Gadget: Add Audio Class 2.0 Driver

On Mon, Aug 22, 2011 at 6:14 PM, Felipe Balbi <balbi <at> ti.com> wrote:
>> Functionality wise, audio.c hardcodes the data-path to the physical
>> audio-codec onboard
>> whereas audio2.c provides user-space with a virtual sound-card to fool around
>> with audio-data the way the user wants. The functionality that has
>> lion's share of code.
>> Also, although the functionality of audio.c can be achieved by audio2.c (but not
>> vice-versa) we'll break user-space by changing the behavior of audio.c
>> to audio2.c
>>
>> Besides fundamental differences in functionality, they differ by
>> Usb-Audio-Class
>> compliance as well.  audio.c is UAC_1 compliant, whereas audio2.c is UAC_2
>> complaint.
>> One can not replace the other. For ex, MS-Windows doesn't support
>> UAC_2 by default
>> yet, Linux does reasonably well. And by definition having
>> Linux-USB-Gadget support
>> UAC_2 also, is only better. So by having both we cover more ground than by
>> having just one.
>
> I understand your point, but then we will have two gadget drivers (and
> two function drivers) for the same thing (USB Audio), it's the same
> thing with the storage gadgets and we have decided on dropping one of
> them recently, so I'm not keen on accepting another gadget driver which
> will essentially do the same thing.
No dear, not the same thing.
As I said, they differ by features as well as USB-Spec... only the
'audio' thing is common.

(Continue reading)

Felipe Balbi | 22 Aug 15:46 2011
Picon

Re: [PATCH 2/2] USB: Gadget: Add Audio Class 2.0 Driver

Hi,

On Mon, Aug 22, 2011 at 06:30:36PM +0530, Jassi Brar wrote:
> > I understand your point, but then we will have two gadget drivers (and
> > two function drivers) for the same thing (USB Audio), it's the same
> > thing with the storage gadgets and we have decided on dropping one of
> > them recently, so I'm not keen on accepting another gadget driver which
> > will essentially do the same thing.
> No dear, not the same thing.
> As I said, they differ by features as well as USB-Spec... only the
> 'audio' thing is common.

and that's what I meant by same thing. How different is UAC_1 from
UAC_2.

> > If audio2.c can achieve audio.c's functionality, then you can start by
> > re-factoring audio.c so that it come closer to what audio2.c is today.
> audio.c and audio2.c have almost nothing in common. Please have a look
> at the code.
> Making audio.c closer to audio2.c would mean :-
>   * Changing all of the descriptors of audio.c {uac_1 -> uac_2}
>   * Removing all alsa related code and adding virtual alsa sound card.
>  At the end, audio.c would have been changed completely and Linux-usb-gadget
> lost the UAC_1 compliance.

it shouldn't loose compliance. If it does it was probably not done
right.

> > WRT UAC_1/UAC_2 compliance, you can use a Kconfig entry, or two separate
> > USB configurations (one with UAC_1 and another UAC_2). So there are ways
(Continue reading)

Jassi Brar | 22 Aug 16:00 2011
Picon

Re: [PATCH 2/2] USB: Gadget: Add Audio Class 2.0 Driver

On Mon, Aug 22, 2011 at 7:16 PM, Felipe Balbi <balbi@...> wrote:
>
>> But that would mean having two drivers in one file, because they are
>> so different.
>
> then make only a differnt function driver, f_uac2.c, which gets added as
> another interface (or configuration) to audio.c.
Yup, by audio.c I meant {audio.c + f_audio.c} and audio2.c {audio2.c +
f_audio2.c}

>> Otherwise, please have a look at audio.c and audio2.c and suggest what
>> exactly you mean.
>
> audio.c doesn't do anything audio related. It's just adding the
> configuration to composite layer. The real specification is implemented
> in f_audio.c (should probably be called f_uac1.c, though).
Agreed. Reusing audio.c is quite reasonable.
So, I'll :-
* Merge audio2.c into audio.c
* Rename f_audio.c -> f_uac1.c
* Add new f_audio2.c as f_uac2.c
* Add Kconfig switch to compile UAC_1 (audio.c + f_uac1.c)  or  UAC_2
(audio.c + f_uac2.c)

I'll wait for other comments and revise the patch after a few days.

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@...
(Continue reading)

Felipe Balbi | 22 Aug 16:28 2011
Picon

Re: [PATCH 2/2] USB: Gadget: Add Audio Class 2.0 Driver

Hi,

On Mon, Aug 22, 2011 at 07:30:35PM +0530, Jassi Brar wrote:
> On Mon, Aug 22, 2011 at 7:16 PM, Felipe Balbi <balbi@...> wrote:
> >
> >> But that would mean having two drivers in one file, because they are
> >> so different.
> >
> > then make only a differnt function driver, f_uac2.c, which gets added as
> > another interface (or configuration) to audio.c.
> Yup, by audio.c I meant {audio.c + f_audio.c} and audio2.c {audio2.c +
> f_audio2.c}
> 
> 
> >> Otherwise, please have a look at audio.c and audio2.c and suggest what
> >> exactly you mean.
> >
> > audio.c doesn't do anything audio related. It's just adding the
> > configuration to composite layer. The real specification is implemented
> > in f_audio.c (should probably be called f_uac1.c, though).
> Agreed. Reusing audio.c is quite reasonable.
> So, I'll :-
> * Merge audio2.c into audio.c
> * Rename f_audio.c -> f_uac1.c
> * Add new f_audio2.c as f_uac2.c
> * Add Kconfig switch to compile UAC_1 (audio.c + f_uac1.c)  or  UAC_2
> (audio.c + f_uac2.c)
> 
> I'll wait for other comments and revise the patch after a few days.

(Continue reading)

Felipe Balbi | 22 Aug 16:29 2011
Picon

Re: [PATCH 2/2] USB: Gadget: Add Audio Class 2.0 Driver

Hi,

On Mon, Aug 22, 2011 at 05:28:05PM +0300, Felipe Balbi wrote:
> > >> Otherwise, please have a look at audio.c and audio2.c and suggest what
> > >> exactly you mean.
> > >
> > > audio.c doesn't do anything audio related. It's just adding the
> > > configuration to composite layer. The real specification is implemented
> > > in f_audio.c (should probably be called f_uac1.c, though).
> > Agreed. Reusing audio.c is quite reasonable.
> > So, I'll :-
> > * Merge audio2.c into audio.c
> > * Rename f_audio.c -> f_uac1.c

just another tip/request:

when generating your patches add -M -C switches to git format-patch.
This will let git detect the renaming.

--

-- 
balbi
Jassi Brar | 2 Feb 17:19 2012
Picon

Re: [PATCH 2/2] USB: Gadget: Add Audio Class 2.0 Driver

On Mon, Aug 22, 2011 at 7:58 PM, Felipe Balbi <balbi@...> wrote:
>
>> > audio.c doesn't do anything audio related. It's just adding the
>> > configuration to composite layer. The real specification is implemented
>> > in f_audio.c (should probably be called f_uac1.c, though).
>> Agreed. Reusing audio.c is quite reasonable.
>> So, I'll :-
>> * Merge audio2.c into audio.c
>> * Rename f_audio.c -> f_uac1.c
>> * Add new f_audio2.c as f_uac2.c
>> * Add Kconfig switch to compile UAC_1 (audio.c + f_uac1.c)  or  UAC_2
>> (audio.c + f_uac2.c)
>>
>> I'll wait for other comments and revise the patch after a few days.
>
> ok, sounds reasonable.
>
OK, after a 'few days' on some distant giant planet, here is the revised
patchset accordingly.

Cheers
-jassi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@...
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Jassi Brar | 2 Feb 17:29 2012

[PATCH 1/4] USB: Gadget: Rename audio function to uac1

The extant USB-Audio function driver complies to UAC_1 spec.
So name the files accordingly, paving way for inclusion of
a new UAC_2 specified driver.

Signed-off-by: Yadi Brar <yadi.brar01@...>
Signed-off-by: Jassi Brar <jaswinder.singh@...>
---
 drivers/usb/gadget/audio.c                 |    6 +++---
 drivers/usb/gadget/{f_audio.c => f_uac1.c} |    2 +-
 drivers/usb/gadget/{u_audio.c => u_uac1.c} |    4 ++--
 drivers/usb/gadget/{u_audio.h => u_uac1.h} |    2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)
 rename drivers/usb/gadget/{f_audio.c => f_uac1.c} (99%)
 rename drivers/usb/gadget/{u_audio.c => u_uac1.c} (99%)
 rename drivers/usb/gadget/{u_audio.h => u_uac1.h} (94%)

diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c
index 9d89ae47..056a2d9 100644
--- a/drivers/usb/gadget/audio.c
+++ b/drivers/usb/gadget/audio.c
 <at>  <at>  -14,7 +14,7  <at>  <at> 
 #include <linux/kernel.h>
 #include <linux/utsname.h>

-#include "u_audio.h"
+#include "u_uac1.h"

 #define DRIVER_DESC		"Linux USB Audio Gadget"
 #define DRIVER_VERSION		"Dec 18, 2008"
 <at>  <at>  -33,8 +33,8  <at>  <at> 
(Continue reading)

Felipe Balbi | 15 Feb 09:12 2012
Picon

Re: [PATCH 1/4] USB: Gadget: Rename audio function to uac1

On Thu, Feb 02, 2012 at 09:59:53PM +0530, Jassi Brar wrote:
> The extant USB-Audio function driver complies to UAC_1 spec.
> So name the files accordingly, paving way for inclusion of
> a new UAC_2 specified driver.
> 
> Signed-off-by: Yadi Brar <yadi.brar01 <at> gmail.com>
> Signed-off-by: Jassi Brar <jaswinder.singh <at> linaro.org>

nobody complains in 2 weeks so I'm applying this entire series, thanks

-- 
balbi
On Thu, Feb 02, 2012 at 09:59:53PM +0530, Jassi Brar wrote:
> The extant USB-Audio function driver complies to UAC_1 spec.
> So name the files accordingly, paving way for inclusion of
> a new UAC_2 specified driver.
> 
> Signed-off-by: Yadi Brar <yadi.brar01 <at> gmail.com>
> Signed-off-by: Jassi Brar <jaswinder.singh <at> linaro.org>

nobody complains in 2 weeks so I'm applying this entire series, thanks

--

-- 
balbi
Jassi Brar | 2 Feb 17:30 2012

[PATCH 2/4] USB: UAC2: Add ACHeader and FormatType descriptor

Add missing but needed ACHeader and FormatType descriptor definitions.

Signed-off-by: Yadi Brar <yadi.brar01@...>
Signed-off-by: Jassi Brar <jaswinder.singh@...>
---
 include/linux/usb/audio-v2.h |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/include/linux/usb/audio-v2.h b/include/linux/usb/audio-v2.h
index 964cb60..ed13053 100644
--- a/include/linux/usb/audio-v2.h
+++ b/include/linux/usb/audio-v2.h
 <at>  <at>  -43,6 +43,27  <at>  <at>  static inline bool uac2_control_is_writeable(u32 bmControls, u8 control)
 	return (bmControls >> (control * 2)) & 0x2;
 }

+/* 4.7.2 Class-Specific AC Interface Descriptor */
+struct uac2_ac_header_descriptor {
+	__u8  bLength;			/* 9 */
+	__u8  bDescriptorType;		/* USB_DT_CS_INTERFACE */
+	__u8  bDescriptorSubtype;	/* UAC_MS_HEADER */
+	__le16 bcdADC;			/* 0x0200 */
+	__u8  bCategory;
+	__le16 wTotalLength;		/* includes Unit and Terminal desc. */
+	__u8  bmControls;
+} __packed;
+
+/* 2.3.1.6 Type I Format Type Descriptor (Frmts20 final.pdf)*/
+struct uac2_format_type_i_descriptor {
+	__u8  bLength;			/* in bytes: 6 */
(Continue reading)

Jassi Brar | 2 Feb 17:31 2012

[PATCH 3/4] USB: Gadget: Audio: Move string IDs to audio.c

Move manufacturer and product string ids into audio.c so
as to be reusable by the new uac2 version of gadget driver.

Signed-off-by: Yadi Brar <yadi.brar01@...>
Signed-off-by: Jassi Brar <jaswinder.singh@...>
---
 drivers/usb/gadget/audio.c  |   23 +++++++++++++++++++++++
 drivers/usb/gadget/f_uac1.c |   23 -----------------------
 2 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c
index 056a2d9..33e9327 100644
--- a/drivers/usb/gadget/audio.c
+++ b/drivers/usb/gadget/audio.c
 <at>  <at>  -33,6 +33,29  <at>  <at> 
 #include "config.c"
 #include "epautoconf.c"

+/* string IDs are assigned dynamically */
+
+#define STRING_MANUFACTURER_IDX		0
+#define STRING_PRODUCT_IDX		1
+
+static char manufacturer[50];
+
+static struct usb_string strings_dev[] = {
+	[STRING_MANUFACTURER_IDX].s = manufacturer,
+	[STRING_PRODUCT_IDX].s = DRIVER_DESC,
+	{  } /* end of list */
+};
(Continue reading)

Jassi Brar | 2 Feb 17:31 2012

[PATCH 4/4] USB: Gadget: Add Audio Class 2.0 Driver

This is a flexible USB Audio Class 2.0 compliant gadget driver that
implements a simple topology with a virtual sound card exposed at
the function side.

The driver doesn't expect any real audio codec to be present on the
function - 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.

Capture(USB-Out) and Playback(USB-In) can be run at independent
configurations specified via module parameters while loading the driver.

Make this new version as the default selection by a new Kconfig choice.

Signed-off-by: Yadi Brar <yadi.brar01@...>
Signed-off-by: Jassi Brar <jaswinder.singh@...>
---
 drivers/usb/gadget/Kconfig  |   25 +-
 drivers/usb/gadget/audio.c  |   20 +-
 drivers/usb/gadget/f_uac2.c | 1449 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1485 insertions(+), 9 deletions(-)
 create mode 100644 drivers/usb/gadget/f_uac2.c

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 7ecb68a..1623b52 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
 <at>  <at>  -599,16 +599,29  <at>  <at>  config USB_AUDIO
 	depends on SND
(Continue reading)

Chen Peter-B29397 | 24 Aug 04:00 2011

RE: [PATCH 2/2] USB: Gadget: Add Audio Class 2.0 Driver


> -----Original Message-----
> From: linux-usb-owner-u79uwXL29TY76Z2rM5mHXA <at> public.gmane.org [mailto:linux-usb-
> owner-u79uwXL29TY76Z2rM5mHXA <at> public.gmane.org] On Behalf Of Jassi Brar
> Sent: Friday, August 19, 2011 7:22 PM
> To: linux-usb-u79uwXL29TY76Z2rM5mHXA <at> public.gmane.org; balbi-l0cyMroinI0 <at> public.gmane.org; gregkh-l3A5Bk7waGM <at> public.gmane.org
> Cc: alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw <at> public.gmane.org; zonque-Re5JQEeQqe8AvxtiuMwx3w <at> public.gmane.org; yadi.brar01-Re5JQEeQqe8AvxtiuMwx3w <at> public.gmane.org;
> Jassi Brar
> Subject: [PATCH 2/2] USB: Gadget: Add Audio Class 2.0 Driver
> 
> This is a flexible USB Audio Class 2.0 compliant gadget driver that
> implements a simple topology with a virtual sound card exposed at
> the function side.
> 
> The driver doesn't expect any real audio codec to be present on the
> function - 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.
> 
> Capture(USB-Out) and Playback(USB-In) can be run at independent
> configurations specified via module parameters while loading the driver.
> 

Have you a chance to test at Macbook (10.6.5+) which has USB Audio 2.0 support well?
 
> Signed-off-by: Yadi Brar <yadi.brar01-Re5JQEeQqe8AvxtiuMwx3w <at> public.gmane.org>
> Signed-off-by: Jassi Brar <jassisinghbrar-Re5JQEeQqe8AvxtiuMwx3w <at> public.gmane.org>
> ---
> 
(Continue reading)

Jassi Brar | 24 Aug 06:22 2011
Picon

Re: [PATCH 2/2] USB: Gadget: Add Audio Class 2.0 Driver

On Wed, Aug 24, 2011 at 7:30 AM, Chen Peter-B29397 <B29397@...m> wrote:
>>
>> This is a flexible USB Audio Class 2.0 compliant gadget driver that
>> implements a simple topology with a virtual sound card exposed at
>> the function side.
>>
>> The driver doesn't expect any real audio codec to be present on the
>> function - 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.
>>
>> Capture(USB-Out) and Playback(USB-In) can be run at independent
>> configurations specified via module parameters while loading the driver.
>>
>
> Have you a chance to test at Macbook (10.6.5+) which has USB Audio 2.0 support well?
>
Nopes, haven't had my hands on one yet.
It would help if someone could verify.

.....

>> +/* STD AS ISO OUT Endpoint */
>> +struct usb_endpoint_descriptor fs_epout_desc = {
>> +     .bLength = USB_DT_ENDPOINT_SIZE,
>> +     .bDescriptorType = USB_DT_ENDPOINT,
>> +
>> +     .bEndpointAddress = USB_DIR_OUT,
>> +     .bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC,
(Continue reading)


Gmane