From: Peter Chen <hzpeterchen@gmail.com>
To: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Cc: Felipe Balbi <balbi@kernel.org>, Daniel Mack <zonque@gmail.com>,
Jassi Brar <jassisinghbrar@gmail.com>,
Clemens Ladisch <clemens@ladisch.de>,
Jonathan Corbet <corbet@lwn.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/3] usb: gadget: add f_uac1 variant based on new u_audio api
Date: Tue, 16 Aug 2016 10:52:57 +0800 [thread overview]
Message-ID: <20160816025257.GF16965@shlinux2> (raw)
In-Reply-To: <1471126884-20117-4-git-send-email-ruslan.bilovol@gmail.com>
On Sun, Aug 14, 2016 at 01:21:24AM +0300, Ruslan Bilovol wrote:
> This patch adds new function f_uac1_newapi that
> uses recently created u_audio api. This makes
> f_uac1_newapi implementation much simpler by
> reusing existing u_audio core utilities.
>
> This also drops previous f_uac1 approach (write
> audio samples directly to existing ALSA sound
> card) and moves to more generic/flexible
> one - create an f_uac1 ALSA sound card that
> represents USB Audio function and allows to
> be used by userspace tools.
>
> f_uac1_newapi also has capture support (gadget->host).
> By default, capture interface has 48000kHz/2ch
> configuration, same as playback channel has.
>
> f_uac1_newapi descriptors naming conventios
> uses f_uac2 driver naming convention that
> makes it more common and meaningful.
>
> Comparing to f_uac1, the f_uac1_newapi doesn't
> have volume/mute functionality. This is because
> the volume/mute feature unit was dummy
> implementation since that driver creation (2009)
> and never had real volume control or mute
> functionality.
>
> g_audio can be built using one of existing
> uac functions (f_uac1, f_uac1_newapi or f_uac2)
>
> Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
> ---
> .../ABI/testing/configfs-usb-gadget-uac1_newapi | 12 +
> Documentation/usb/gadget-testing.txt | 41 ++
> drivers/usb/gadget/Kconfig | 21 +
> drivers/usb/gadget/function/Makefile | 2 +
> drivers/usb/gadget/function/f_uac1_newapi.c | 795 +++++++++++++++++++++
> drivers/usb/gadget/function/u_uac1_newapi.h | 39 +
> drivers/usb/gadget/legacy/Kconfig | 15 +-
> drivers/usb/gadget/legacy/audio.c | 52 ++
> 8 files changed, 975 insertions(+), 2 deletions(-)
> create mode 100644 Documentation/ABI/testing/configfs-usb-gadget-uac1_newapi
> create mode 100644 drivers/usb/gadget/function/f_uac1_newapi.c
> create mode 100644 drivers/usb/gadget/function/u_uac1_newapi.h
>
> diff --git a/Documentation/ABI/testing/configfs-usb-gadget-uac1_newapi b/Documentation/ABI/testing/configfs-usb-gadget-uac1_newapi
> new file mode 100644
> index 0000000..d355275
> --- /dev/null
> +++ b/Documentation/ABI/testing/configfs-usb-gadget-uac1_newapi
> @@ -0,0 +1,12 @@
> +What: /config/usb-gadget/gadget/functions/uac1_newapi.name
> +Date: Aug 2016
> +KernelVersion: 4.9
> +Description:
> + The attributes:
> +
> + c_chmask - capture channel mask
> + c_srate - capture sampling rate
> + c_ssize - capture sample size (bytes)
> + p_chmask - playback channel mask
> + p_srate - playback sampling rate
> + p_ssize - playback sample size (bytes)
> diff --git a/Documentation/usb/gadget-testing.txt b/Documentation/usb/gadget-testing.txt
> index 5819605..4598d7f 100644
> --- a/Documentation/usb/gadget-testing.txt
> +++ b/Documentation/usb/gadget-testing.txt
> @@ -20,6 +20,7 @@ provided by gadgets.
> 17. UAC2 function
> 18. UVC function
> 19. PRINTER function
> +20. UAC1 function (new API)
>
>
> 1. ACM function
> @@ -770,3 +771,43 @@ host:
>
> More advanced testing can be done with the prn_example
> described in Documentation/usb/gadget-printer.txt.
> +
> +
> +20. UAC1 function (new API, using u_audio)
> +=================
> +
> +The function is provided by usb_f_uac1_newapi.ko module.
> +
> +Function-specific configfs interface
> +------------------------------------
> +
> +The function name to use when creating the function directory
> +is "uac1_newapi". The uac1_newapi function provides these attributes
> +in its function directory:
> +
> + c_chmask - capture channel mask
> + c_srate - capture sampling rate
> + c_ssize - capture sample size (bytes)
> + p_chmask - playback channel mask
> + p_srate - playback sampling rate
> + p_ssize - playback sample size (bytes)
> +
> +The attributes have sane default values.
> +
> +Testing the UAC1 function
> +-------------------------
> +
> +device: run the gadget
> +host: aplay -l # should list our USB Audio Gadget
> +
> +This function does not require real hardware support, it just
> +sends a stream of audio data to/from the host. In order to
> +actually hear something at the device side, a command similar
> +to this must be used at the device side:
> +
> +$ arecord -f dat -t wav -D hw:2,0 | aplay -D hw:0,0 &
> +
> +e.g.:
> +
> +$ arecord -f dat -t wav -D hw:CARD=UAC1Gadget,DEV=0 | \
> +aplay -D default:CARD=OdroidU3
> diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
> index a25afd8..abcb539 100644
> --- a/drivers/usb/gadget/Kconfig
> +++ b/drivers/usb/gadget/Kconfig
> @@ -194,6 +194,9 @@ config USB_F_FS
> config USB_F_UAC1
> tristate
>
> +config USB_F_UAC1_NEWAPI
> + tristate
> +
> config USB_F_UAC2
> tristate
>
> @@ -397,6 +400,24 @@ config USB_CONFIGFS_F_UAC1
> This driver requires a real Audio codec to be present
> on the device.
>
> +config USB_CONFIGFS_F_UAC1_NEWAPI
> + bool "Audio Class 1.0 (new API)"
> + depends on USB_CONFIGFS
> + depends on SND
> + select USB_LIBCOMPOSITE
> + select SND_PCM
> + select USB_U_AUDIO
> + select USB_F_UAC1_NEWAPI
> + help
> + This Audio function implements 1 AudioControl interface,
> + 1 AudioStreaming Interface each for USB-OUT and USB-IN.
%s/1/one
--
Best Regards,
Peter Chen
next prev parent reply other threads:[~2016-08-16 3:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-13 22:21 [PATCH v2 0/3] USB Audio Gadget refactoring Ruslan Bilovol
2016-08-13 22:21 ` [PATCH v2 1/3] usb: gadget: f_uac2: remove platform driver/device creation Ruslan Bilovol
2016-08-13 22:21 ` [PATCH v2 2/3] usb: gadget: f_uac2: split out audio core Ruslan Bilovol
2016-08-16 18:20 ` kbuild test robot
2016-08-16 20:46 ` Ruslan Bilovol
2016-08-13 22:21 ` [PATCH v2 3/3] usb: gadget: add f_uac1 variant based on new u_audio api Ruslan Bilovol
2016-08-16 2:52 ` Peter Chen [this message]
2016-08-16 20:24 ` Ruslan Bilovol
2016-08-16 9:16 ` [PATCH v2 0/3] USB Audio Gadget refactoring Peter Chen
2016-08-16 9:32 ` Clemens Ladisch
2016-08-16 9:49 ` Peter Chen
2016-08-16 10:13 ` Clemens Ladisch
2016-08-16 20:40 ` Ruslan Bilovol
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160816025257.GF16965@shlinux2 \
--to=hzpeterchen@gmail.com \
--cc=balbi@kernel.org \
--cc=clemens@ladisch.de \
--cc=corbet@lwn.net \
--cc=gregkh@linuxfoundation.org \
--cc=jassisinghbrar@gmail.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=ruslan.bilovol@gmail.com \
--cc=zonque@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox