Skip to contentSkip to conversation

USB Audio Device Class 3.0 support

PATCH Superseded Ruslan Bilovol 3 participants 4 messages Mar 21, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 USB Audio Device Class 3.0 support

Hi Takashi,

This patch adds initial USB Audio Device Class 3.0 [1] support to the ALSA that we discussed at ELCE.

The patch was tested with UAC3 gadget [2] that I posted to USB mailing list before. It is good for working with BADD device which implements such topologies like BAIF (Basic Audio Input Functions), BAOF (Basic Audio Output Functions) or compbination of both.

UAC3 spec has changed descriptors laout and many other codes comparing to UAC2 spec, thus making reuse of existing sources impossible or quite complex.

There are still many areas of improvement, as this patch doesn't have UAC3 Mixer Unit support nor some new features like Power Management

I tested this with BeagleBone Black as UAC3 gadget device.

[1] http://www.usb.org/developers/docs/devclass_docs/USB_Audio_v3.0.zip
[2] http://www.spinics.net/lists/linux-usb/msg162482.html

v3 changes:
- dropped audioformat quirks patch (already accepted)
- addressed coding style requested changes

v2 changes:
- moved audioformat quirks to quirks.c
- addressed many comments from Pierre-Louis Bossart
- reorganized audio-v3.h
- added more UAC3 channel relationship definitions

Ruslan Bilovol (1):
ALSA: usb: initial USB Audio Device Class 3.0 support

 include/linux/usb/audio-v2.h   |   4 +-
 include/linux/usb/audio-v3.h   | 395 +++++++++++++++++++++++++++++++++++++++++
 include/uapi/linux/usb/audio.h |   1 +
 sound/usb/card.c               |   7 +-
 sound/usb/card.h               |   2 +-
 sound/usb/clock.c              | 228 +++++++++++++++++++++---
 sound/usb/clock.h              |   4 +-
 sound/usb/format.c             |  91 ++++++++--
 sound/usb/format.h             |   6 +-
 sound/usb/mixer.c              | 337 +++++++++++++++++++++++------------
 sound/usb/stream.c             | 365 +++++++++++++++++++++++++++++++++----
 11 files changed, 1246 insertions(+), 194 deletions(-)
 create mode 100644 include/linux/usb/audio-v3.h
Signature · 1 line
1.9.1
#1 lore raw

PATCH v3 1/1 ALSA: usb: initial USB Audio Device Class 3.0 support

Recently released USB Audio Class 3.0 specification introduces many significant changes comparing to previous versions, like
- new Power Domains, support for LPM/L1
- new Cluster descriptor
- changed layout of all class-specific descriptors
- new High Capability descriptors
- New class-specific String descriptors
- new and removed units
- additional sources for interrupts
- removed Type II Audio Data Formats
- ... and many other things (check spec)

It also provides backward compatibility through
multiple configurations, as well as requires
mandatory support for BADD (Basic Audio Device
Definition) on each ADC3.0 compliant device

This patch adds initial support of UAC3 specification that is enough for Generic I/O Profile (BAOF, BAIF) device support from BADD document.

---
 include/linux/usb/audio-v2.h   |   4 +-
 include/linux/usb/audio-v3.h   | 395 +++++++++++++++++++++++++++++++++++++++++
 include/uapi/linux/usb/audio.h |   1 +
 sound/usb/card.c               |   7 +-
 sound/usb/card.h               |   2 +-
 sound/usb/clock.c              | 228 +++++++++++++++++++++---
 sound/usb/clock.h              |   4 +-
 sound/usb/format.c             |  91 ++++++++--
 sound/usb/format.h             |   6 +-
 sound/usb/mixer.c              | 337 +++++++++++++++++++++++------------
 sound/usb/stream.c             | 365 +++++++++++++++++++++++++++++++++----
 11 files changed, 1246 insertions(+), 194 deletions(-)
 create mode 100644 include/linux/usb/audio-v3.h
include/linux/usb/audio-v2.h +2 -2
index 3119d0a..2db83a1 100644
@@ -34,12 +34,12 @@
  *
  */
 
-static inline bool uac2_control_is_readable(u32 bmControls, u8 control)
+static inline bool uac_v2v3_control_is_readable(u32 bmControls, u8 control)
 {
 	return (bmControls >> (control * 2)) & 0x1;
 }
 
-static inline bool uac2_control_is_writeable(u32 bmControls, u8 control)
+static inline bool uac_v2v3_control_is_writeable(u32 bmControls, u8 control)
 {
 	return (bmControls >> (control * 2)) & 0x2;
 }
include/linux/usb/audio-v3.h new file +395 -0

395 lines not on this page · raw message

include/uapi/linux/usb/audio.h +1 -0
index da3315e..3a78e71 100644
@@ -27,6 +27,7 @@
 /* bInterfaceProtocol values to denote the version of the standard used */
 #define UAC_VERSION_1			0x00
 #define UAC_VERSION_2			0x20
+#define UAC_VERSION_3			0x30
 
 /* A.2 Audio Interface Subclass Codes */
 #define USB_SUBCLASS_AUDIOCONTROL	0x01
sound/usb/card.c +5 -2
index 8018d56..4a1c6bb 100644
@@ -7,6 +7,7 @@
  *	    Alan Cox ([email protected])
  *	    Thomas Sailer ([email protected])
  *
+ *   Audio Class 3.0 support by Ruslan Bilovol <[email protected]>
  *
  *   This program is free software; you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
@@ -44,6 +45,7 @@
 #include <linux/mutex.h>
 #include <linux/usb/audio.h>
 #include <linux/usb/audio-v2.h>
+#include <linux/usb/audio-v3.h>
 #include <linux/module.h>
 
 #include <sound/control.h>
@@ -281,7 +283,8 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
 		break;
 	}
 
-	case UAC_VERSION_2: {
+	case UAC_VERSION_2:
+	case UAC_VERSION_3: {
 		struct usb_interface_assoc_descriptor *assoc =
 			usb_ifnum_to_if(dev, ctrlif)->intf_assoc;
 
@@ -301,7 +304,7 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
 		}
 
 		if (!assoc) {
-			dev_err(&dev->dev, "Audio class v2 interfaces need an interface association\n");
+			dev_err(&dev->dev, "Audio class v2/v3 interfaces need an interface association\n");
 			return -EINVAL;
 		}
 
sound/usb/card.h +1 -1
index ed87cc8..1406292 100644
@@ -22,7 +22,7 @@ struct audioformat {
 	unsigned char endpoint;		/* endpoint */
 	unsigned char ep_attr;		/* endpoint attributes */
 	unsigned char datainterval;	/* log_2 of data packet interval */
-	unsigned char protocol;		/* UAC_VERSION_1/2 */
+	unsigned char protocol;		/* UAC_VERSION_1/2/3 */
 	unsigned int maxpacksize;	/* max. packet size */
 	unsigned int rates;		/* rate bitmasks */
 	unsigned int rate_min, rate_max;	/* min/max rates */
sound/usb/clock.c +203 -25

338 lines not on this page · raw message

sound/usb/clock.h +2 -2
index 87557ca..076e31b 100644
@@ -6,7 +6,7 @@ int snd_usb_init_sample_rate(struct snd_usb_audio *chip, int iface,
 			     struct usb_host_interface *alts,
 			     struct audioformat *fmt, int rate);
 
-int snd_usb_clock_find_source(struct snd_usb_audio *chip, int entity_id,
-			     bool validate);
+int snd_usb_clock_find_source(struct snd_usb_audio *chip, int protocol,
+			     int entity_id, bool validate);
 
 #endif /* __USBAUDIO_CLOCK_H */
sound/usb/format.c +75 -16

186 lines not on this page · raw message

sound/usb/format.h +5 -1
index 8c3ff9c..e701718 100644
@@ -3,8 +3,12 @@
 #define __USBAUDIO_FORMAT_H
 
 int snd_usb_parse_audio_format(struct snd_usb_audio *chip,
-			       struct audioformat *fp, unsigned int format,
+			       struct audioformat *fp, u64 format,
 			       struct uac_format_type_i_continuous_descriptor *fmt,
 			       int stream);
 
+int snd_usb_parse_audio_format_v3(struct snd_usb_audio *chip,
+			       struct audioformat *fp,
+			       struct uac3_as_header_descriptor *as,
+			       int stream);
 #endif /*  __USBAUDIO_FORMAT_H */
sound/usb/mixer.c +228 -109

456 lines not on this page · raw message

sound/usb/stream.c +329 -36

416 lines not on this page · raw message

Signature · 1 line
1.9.1
maintainer Reviewed-by on v3 1/1
#2 lore raw

Re: [PATCH v3] ALSA: usb: initial USB Audio Device Class 3.0 support

Quoted 18 lines · Ruslan Bilovol

Recently released USB Audio Class 3.0 specification introduces many significant changes comparing to previous versions, like
- new Power Domains, support for LPM/L1
- new Cluster descriptor
- changed layout of all class-specific descriptors
- new High Capability descriptors
- New class-specific String descriptors
- new and removed units
- additional sources for interrupts
- removed Type II Audio Data Formats
- ... and many other things (check spec)

It also provides backward compatibility through multiple configurations, as well as requires mandatory support for BADD (Basic Audio Device Definition) on each ADC3.0 compliant device

Quoted 5 lines

This patch adds initial support of UAC3 specification that is enough for Generic I/O Profile (BAOF, BAIF) device support from BADD document.

Nice work!

#3 lore raw

Re: [PATCH v3] ALSA: usb: initial USB Audio Device Class 3.0 support

In reply to Ruslan Bilovol
Quoted 19 lines · Ruslan Bilovol

Recently released USB Audio Class 3.0 specification introduces many significant changes comparing to previous versions, like
- new Power Domains, support for LPM/L1
- new Cluster descriptor
- changed layout of all class-specific descriptors
- new High Capability descriptors
- New class-specific String descriptors
- new and removed units
- additional sources for interrupts
- removed Type II Audio Data Formats
- ... and many other things (check spec)

It also provides backward compatibility through multiple configurations, as well as requires mandatory support for BADD (Basic Audio Device Definition) on each ADC3.0 compliant device

Quoted 5 lines

This patch adds initial support of UAC3 specification that is enough for Generic I/O Profile (BAOF, BAIF) device support from BADD document.

Applied now to for-next branch with Greg's reviewed-by tag.

Thanks!

Takashi