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

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

 



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@xxxxxxxxx>
> Signed-off-by: Jassi Brar <jassisinghbrar@xxxxxxxxx>
> ---
> 
> ===========
> 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
> **** List of CAPTURE Hardware Devices ****
> card 0: uac2 [uac2], device 0: UAC2 PCM [UAC2 PCM]
>   Subdevices: 1/1
>   Subdevice #0: subdevice #0
> 
>   USB_HOST$ aplay -l
> **** List of PLAYBACK Hardware Devices ****
> card 0: PCH [HDA Intel PCH], device 0: ALC665 Analog [ALC665 Analog]
>   Subdevices: 0/1
>   Subdevice #0: subdevice #0
> card 1: Gadget [UAC2 Gadget], device 0: USB Audio [USB Audio]  <<<<<<
>   Subdevices: 1/1
>   Subdevice #0: subdevice #0
> 
>   USB_HOST$ arecord -l
> **** List of CAPTURE Hardware Devices ****
> card 0: PCH [HDA Intel PCH], device 0: ALC665 Analog [ALC665 Analog]
>   Subdevices: 1/1
>   Subdevice #0: subdevice #0
> card 1: Gadget [UAC2 Gadget], device 0: USB Audio [USB Audio] <<<<<<<
>   Subdevices: 1/1
>   Subdevice #0: subdevice #0
> 
>  After this confirmation, you should be able to use it just like another
> sound card in your system. That is, a new sound card should appear in the
> sound preferences which you can select to route your default audio to and
> from.
> 
> ============
> Test Results
> ============
>  The driver has been tested for Half as well as Full Duplex at
> Stereo, S16_LE at 44.1KHz, 48KHz and 64KHz. It should also
> work for other configurations as well, except for different
> sample-size(TODO).
> 
> Obviously, much depends upon the underlying UDC driver.
> 
> While testing with OMAP's implementation of Inventra HDRC, I observed
> some noise for configurations for which the USB-OUT packet size chosen
> by the Host is not a power of 2. USB-IN works just fine.
> For ex, on both Beagle/Panda board, 48KHz USB-OUT has some noise while
> 64KHz is smooth. Also, with full duplex, it occasioanally shows noise.
> 
> Taking benefit of doubt, I assume this driver has unmasked some subtle
> bug in the underlying UDC's ISOCH handling code ;)
> Please feel free to find issue with this driver by testing it over
> some other UDC.
> 
>  drivers/usb/gadget/Kconfig    |   20 +
>  drivers/usb/gadget/Makefile   |    2 +
>  drivers/usb/gadget/audio2.c   |  155 +++++
>  drivers/usb/gadget/f_audio2.c | 1448 +++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 1625 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/usb/gadget/audio2.c
>  create mode 100644 drivers/usb/gadget/f_audio2.c
> 
> diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
> index e35dfef..95c65d8 100644
> --- a/drivers/usb/gadget/Kconfig
> +++ b/drivers/usb/gadget/Kconfig
> @@ -599,6 +599,26 @@ config USB_ZERO_HNPTEST
>  	  the "B-Peripheral" role, that device will use HNP to let this
>  	  one serve as the USB host instead (in the "B-Host" role).
>  
> +config USB_AUDIO_2
> +	tristate "Audio Gadget Class 2.0 (EXPERIMENTAL)"
> +	depends on SND && EXPERIMENTAL
> +	select SND_PCM
> +	help
> +	  This Gadget Audio driver is compatible with USB Audio Class
> +	  specification 2.0. It implements 1 AudioControl interface,
> +	  1 AudioStreaming Interface each for USB-OUT and USB-IN.
> +	  Number of channels, sample rate and sample size can be
> +	  specified as module parameters.
> +	  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.
> +
> +	  Say "y" to link the driver statically, or "m" to build a
> +	  dynamically linked module called "g_audio2".
> +
>  config USB_AUDIO
>  	tristate "Audio Gadget (EXPERIMENTAL)"
>  	depends on SND
> diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
> index 7409338..fa8472e 100644
> --- a/drivers/usb/gadget/Makefile
> +++ b/drivers/usb/gadget/Makefile
> @@ -40,6 +40,7 @@ obj-$(CONFIG_USB_COMPOSITE)	+= usb-composite.o
>  #
>  g_zero-y			:= zero.o
>  g_audio-y			:= audio.o
> +g_audio2-y			:= audio2.o

instead of adding a new gadget driver, can't you just re-use g_audio and
add what's missing ?

-- 
balbi

Attachment: signature.asc
Description: Digital signature


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

  Powered by Linux