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@xxxxxxxxx> > --- > .../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 -- To unsubscribe from this list: send the line "unsubscribe linux-doc" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html