ALSA/ASoC: USB Audio Offload
Subsystems (8)
Cezary Rojewski
maintainercover ALSA/ASoC: USB Audio Offload
Note: this series is based on Mark's broonie/for-next. The xHCI dependency is missing so it won't compile. Goal of this RFC is discussing the direction of sound/usb changes.
Note #2: Why exclude xHCI? Current form of xhci-sideband.c [1] does not fare well with Intel's hardware design for USB Audio Offload feature. The production shape for usb/xHCI subjects is being discussed with Mathias. Once we're ready, I'll share the rest.
Note #3: this series does _NOT_ aim to block QCOM's equivalent series [2]. The team does acknowledge that we came the "table" late. At the same time, we're prepared to help QCOM switch to the presented sound/usb approach if that would benefit the framework and its users as a whole. Make it part of this very series if need be.
Apart from changes to sound/usb, the patchset contains exemplary ASoC-based, offload-aware USB driver and a small sound card on the avs-driver side to show how card/dai_link initialization looks like.
In short, USB Audio Offload functionality lowers CPU usage when streaming PCM over a USB Audio-Class device. It has been first introduced in xHCI 1.2 release and is described in section 7.9 [3]. Once hardware is prepared with hw_params(), all the USB endpoints operations e.g.: start, stop, submitting URBs, are performed internally, by the hardware and AudioDSP firmware. Software driver shall not intervene.
Startup flow from:
usb_pcm_open() usb_pcm_hw_params() snd_usb_endpoint_open() usb_pcm_prepare() usb_set_interface() snd_usb_endpoint_start() usb_pcm_trigger(cmd: START/STOP etc.)
reduced to:
usb_pcm_open() usb_pcm_hw_params() snd_usb_endpoint_open() usb_pcm_prepare() usb_set_interface()
Handlers such as ack(), sync_stop(), pointer(), delay() are not used here too. The AudioDSP driver will handle pointer(), rest is firmware/hardware responsibility.
There's a hefty number of limitations, most importantly:
1) typically 2 USB devices tops, rest go the classic (non-offload) path
2) AUDIOSTREAMING interfaces only, MIDI not. While not an interface type, Media (sound/usb/media) unsupported either
3) simple PCM, UAC_FORMAT_TYPE_I_PCM only
Current patchset shows this in form of 'udev->audsb_capable' field. True if xHCI sideband reasource has been assigned to the device. The filtering is code is not part of the patchset.
Important to highlight, 1) means both, offload-aware and offload-unaware drivers could be utilized simultaneously on the system in runtime. Opportunistically few devices would be controlled by the offload-aware driver, whereas everything else by the offload-unaware one. This differs from existing HDAudio Controller driver situation where either classic, snd_hda_intel driver takes complete control -or- the offload-aware snd_soc_avs driver.
In short, once all Audio Sideband resources are depleted, classic sound/usb/card.c driver manages whatever comes next:
snd_usb_audio (offload un-aware, sound/usb/card.c) snd_soc_usb_codec (offload aware, sound/soc/codecs/usb.c)
The design goals:
- make ASoC first class citizen of sound/usb
- re-use code found in sound/usb, mimic HDAudio integration in ASoC:
small sound/soc/codecs/hda.c driver leveraging power of entire sound/pci/hda/
- no shared control over a USB device, either snd_usb_audio or its ASoC equivalent takes control of the device
To do that, major tasks are identified:
a) On ASoC side 'struct snd_card' is part of 'struct snd_soc_card' and is managed by the framework. Similar situation with 'struct snd_pcm' and rtd->pcm. To keep the teardown path sane, drop card->private_free() and pcm->private_free() usage.
b) To initialize ASoC components/DAI properly, PCM capabilities should be known up-front. To do that, existing USB card probe() has to be split. From one-stage to two-stage process:
- look ahead and parse usb_interface descriptors for PCM endpoints but do not create any PCMs (sound devices) yet
- create all PCMs based on obtained ->pcm_list and follow with MIDI/mixers/media
Such approach allows to feed DAIs proper data even when a valid sound-card pointer is not yet present - the initialization occurs before snd_soc_bind_card() is called.
Point a) is scaled for all three "domains" of sound/usb: chip, stream and quirks. That's why there total of 6 commits doing that job. First implement, then switch. Everything that follows is, in my opinion, self-explanatory. No need to repeat commit messages.
[1]: https://lore.kernel.org/all/[email protected]/
[2]: https://lore.kernel.org/all/[email protected]/
[3]: https://www.intel.com/content/dam/www/public/us/en/documents/technical-specifications/extensible-host-controler-interface-usb-xhci.pdf
Cezary Rojewski (15):
ALSA: usb: Move media-filters to the media code
ALSA: usb: Drop private_free() usage for card and pcms
ALSA: usb: Relocate the usbaudio header file
ALSA: usb: Implement two-stage quirk applying mechanism
ALSA: usb: Implement two-stage stream creation mechanism
ALSA: usb: Implement two-stage chip probing mechanism
ALSA: usb: Switch to the two-stage chip probing
ALSA: usb: Switch to the two-stage stream creation
ALSA: usb: Switch to the two-stage quirk applying
ALSA: usb: Export PCM operations
ALSA: usb: Export usb_interface driver operations
ALSA: usb: Export card-naming procedure
ALSA: usb: Add getters to obtain endpoint information
ASoC: codecs: Add USB-Audio driver
ASoC: Intel: avs: Add USB machine board
include/linux/usb.h | 15 + include/linux/usb/ch9.h | 11 + sound/usb/usbaudio.h => include/sound/usb.h | 53 +- include/sound/usb_offload.h | 46 + sound/soc/codecs/Kconfig | 6 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/usb.c | 441 +++++++++ sound/soc/intel/avs/boards/Kconfig | 8 + sound/soc/intel/avs/boards/Makefile | 2 + sound/soc/intel/avs/boards/usb.c | 115 +++ sound/usb/caiaq/device.h | 2 +- sound/usb/card.c | 946 +++++++++++++------- sound/usb/card.h | 4 +- sound/usb/clock.c | 2 +- sound/usb/endpoint.c | 2 +- sound/usb/format.c | 2 +- sound/usb/helper.c | 2 +- sound/usb/implicit.c | 2 +- sound/usb/media.c | 8 +- sound/usb/midi.c | 2 +- sound/usb/midi.h | 2 + sound/usb/midi2.c | 2 +- sound/usb/midi2.h | 1 + sound/usb/misc/ua101.c | 2 +- sound/usb/mixer.c | 2 +- sound/usb/mixer_quirks.c | 2 +- sound/usb/mixer_s1810c.c | 2 +- sound/usb/mixer_scarlett.c | 2 +- sound/usb/mixer_scarlett2.c | 2 +- sound/usb/mixer_us16x08.c | 2 +- sound/usb/pcm.c | 161 +++- sound/usb/power.c | 2 +- sound/usb/proc.c | 2 +- sound/usb/quirks.c | 203 +++-- sound/usb/quirks.h | 6 + sound/usb/stream.c | 217 +++-- sound/usb/stream.h | 2 + sound/usb/usx2y/us122l.c | 2 +- sound/usb/usx2y/usX2Yhwdep.c | 1 + sound/usb/usx2y/usbusx2y.h | 2 +- sound/usb/validate.c | 2 +- 41 files changed, 1749 insertions(+), 541 deletions(-) rename sound/usb/usbaudio.h => include/sound/usb.h (82%) create mode 100644 include/sound/usb_offload.h create mode 100644 sound/soc/codecs/usb.c create mode 100644 sound/soc/intel/avs/boards/usb.c
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerRFC 1/15 ALSA: usb: Move media-filters to the media code
Creating and deleting process of media devices in the common code can be simplified if quirk_flags are checked in callee.
--- sound/usb/card.c | 13 +++---------- sound/usb/media.c | 6 ++++++ 2 files changed, 9 insertions(+), 10 deletions(-)
sound/usb/card.c +3 -10
@@ -909,10 +909,8 @@ static int usb_audio_probe(struct usb_interface *intf,if (err <0 ) goto __error_no_register; -if (chip->quirk_flags &QUIRK_FLAG_SHARE_MEDIA_DEVICE ) { -/* don't want to fail when snd_media_device_create() fails */ -snd_media_device_create (chip, intf); - } +/* don't want to fail when snd_media_device_create() fails */ +snd_media_device_create (chip, intf);if (quirk) chip->quirk_type = quirk->type;
@@ -983,12 +981,7 @@ static void usb_audio_disconnect(struct usb_interface *intf)snd_usbmidi_disconnect (p); }snd_usb_midi_v2_disconnect_all (chip); -/* -* Nice to check quirk && quirk->shares_media_device and -* then call the snd_media_device_delete(). Don't have -* access to the quirk here. snd_media_device_delete() -* accesses mixer_list -*/ +/* snd_media_device_delete() accesses mixer_list */ snd_media_device_delete (chip);/* release mixer resources */
sound/usb/media.c +6 -0
@@ -258,6 +258,9 @@ int snd_media_device_create(struct snd_usb_audio *chip,struct usb_device *usbdev =interface_to_usbdev (iface);int ret =0 ; +if (!(chip->quirk_flags &QUIRK_FLAG_SHARE_MEDIA_DEVICE )) +return 0 ; +/* usb-audio driver is probed for each usb interface, and * there are multiple interfaces per device. Avoid calling * media_device_usb_allocate() each time usb_audio_probe()
@@ -312,6 +315,9 @@ void snd_media_device_delete(struct snd_usb_audio *chip)struct media_device *mdev = chip->media_dev;struct snd_usb_stream *stream; +if (!(chip->quirk_flags &QUIRK_FLAG_SHARE_MEDIA_DEVICE )) +return ; +/* release resources */ list_for_each_entry (stream, &chip->pcm_list, list) {snd_media_stream_delete (&stream->substream[0 ]);
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerRFC 2/15 ALSA: usb: Drop private_free() usage for card and pcms
In reply to Cezary RojewskiOn ASoC side, drivers operate on instance of struct snd_soc_card instead of struct snd_card. The latter is owned by the ASoC framework. To make the existing sound/usb code ASoC-friendly and avoid freeing-order problems when soc_cleanup_card_resources() is called, resign from cardd->private_free() and extra-size when allocating new card with snd_card_new(). Similar pattern applies to PCMs.
--- sound/usb/card.c | 50 ++++++++++++++++++++++------------------------ sound/usb/stream.c | 14 ++++++------- sound/usb/stream.h | 1 + 3 files changed, 31 insertions(+), 34 deletions(-)
sound/usb/card.c +24 -26
@@ -485,25 +485,6 @@ lookup_device_name(u32 id)return NULL ; } -/* -* free the chip instance -* -* here we have to do not much, since pcm and controls are already freed -* -*/ - -static void snd_usb_audio_free (struct snd_card *card) -{ -struct snd_usb_audio *chip = card->private_data; - -snd_usb_endpoint_free_all (chip); -snd_usb_midi_v2_free_all (chip); - -mutex_destroy (&chip->mutex); -if (!atomic_read (&chip->shutdown)) -dev_set_drvdata (&chip->dev->dev,NULL ); -} -static void usb_audio_make_shortname (struct usb_device *dev,struct snd_usb_audio *chip,const struct snd_usb_audio_quirk *quirk)
@@ -630,14 +611,17 @@ static int snd_usb_audio_create(struct usb_interface *intf,return -ENXIO ; } - err =snd_card_new (&intf->dev, index[idx], id[idx],THIS_MODULE , -sizeof (*chip), &card); + chip =kzalloc (sizeof (*chip),GFP_KERNEL ); +if (!chip) +return -ENOMEM ; + + err =snd_card_new (&intf->dev, index[idx], id[idx],THIS_MODULE ,0 , &card);if (err <0 ) {dev_err (&dev->dev,"cannot create card instance %d\n" , idx); +kfree (chip);return err; } - chip = card->private_data;mutex_init (&chip->mutex);init_waitqueue_head (&chip->shutdown_wait); chip->index = idx;
@@ -665,8 +649,6 @@ static int snd_usb_audio_create(struct usb_interface *intf,else snd_usb_init_quirk_flags (chip); - card->private_free = snd_usb_audio_free; -strcpy (card->driver,"USB-Audio" );sprintf (component,"USB%04x:%04x" ,USB_ID_VENDOR (chip->usb_id),USB_ID_PRODUCT (chip->usb_id));
@@ -755,6 +737,19 @@ get_alias_quirk(struct usb_device *dev, unsigned int id)return NULL ; } +static void snd_usb_chip_free (struct snd_usb_audio *chip) +{ +snd_usb_free_pcms (chip); +snd_usb_endpoint_free_all (chip); +snd_usb_midi_v2_free_all (chip); +/* mixers and midi1.0 freed with snd_card_free(). */ + +mutex_destroy (&chip->mutex); +if (!atomic_read (&chip->shutdown)) +dev_set_drvdata (&chip->dev->dev,NULL ); +kfree (chip); +} +/* register card if we reach to the last interface or to the specified * one given via option */
@@ -934,8 +929,10 @@ static int usb_audio_probe(struct usb_interface *intf,* decrement before memory is possibly returned. */ atomic_dec (&chip->active); -if (!chip->num_interfaces) +if (!chip->num_interfaces) {snd_card_free (chip->card); +snd_usb_chip_free (chip); + } }mutex_unlock (®ister_mutex);return err;
@@ -997,7 +994,8 @@ static void usb_audio_disconnect(struct usb_interface *intf)if (chip->num_interfaces <=0 ) { usb_chip[chip->index] =NULL ;mutex_unlock (®ister_mutex); -snd_card_free_when_closed (card); +snd_card_free (card); +snd_usb_chip_free (chip); }else {mutex_unlock (®ister_mutex); }
sound/usb/stream.c +6 -8
@@ -55,7 +55,7 @@ static void free_substream(struct snd_usb_substream *subs)/* * free a usb stream instance */ -static void snd_usb_audio_stream_free (struct snd_usb_stream *stream) +static void snd_usb_pcm_free (struct snd_usb_stream *stream) {free_substream (&stream->substream[0 ]);free_substream (&stream->substream[1 ]);
@@ -63,13 +63,12 @@ static void snd_usb_audio_stream_free(struct snd_usb_stream *stream)kfree (stream); } -static void snd_usb_audio_pcm_free (struct snd_pcm *pcm) +void snd_usb_free_pcms (struct snd_usb_audio *chip) { -struct snd_usb_stream *stream = pcm->private_data; -if (stream) { - stream->pcm =NULL ; -snd_usb_audio_stream_free (stream); - } +struct snd_usb_stream *as, *save; + +list_for_each_entry_safe (as, save, &chip->pcm_list, list) +snd_usb_pcm_free (as); }/*
@@ -533,7 +532,6 @@ static int __snd_usb_add_audio_stream(struct snd_usb_audio *chip, } as->pcm = pcm; pcm->private_data = as; - pcm->private_free = snd_usb_audio_pcm_free; pcm->info_flags =0 ;if (chip->pcm_devs >0 )sprintf (pcm->name,"USB Audio #%d" , chip->pcm_devs);
sound/usb/stream.h +1 -0
@@ -8,6 +8,7 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip,int snd_usb_add_audio_stream (struct snd_usb_audio *chip,int stream,struct audioformat *fp); +void snd_usb_free_pcms (struct snd_usb_audio *chip);#endif /* __USBAUDIO_STREAM_H */
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerRFC 3/15 ALSA: usb: Relocate the usbaudio header file
In reply to Cezary RojewskiFor ALSA and ASoC to share the symbols, common header shall be defined. Existing usbaudio.h holds most of important stuff, with few adjustments it can be simply relocated to include/ to satisfy needs of both frameworks. The adjstments are:
- rename quirk_type enumeration to snd_usb_quirk_type to avoid naming conflits
- add quirk pointer so that quirks applied for a USB device can later be referred to
--- sound/usb/usbaudio.h => include/sound/usb.h | 24 +++++++++++---------- sound/usb/caiaq/device.h | 2 +- sound/usb/card.c | 2 +- sound/usb/clock.c | 2 +- sound/usb/endpoint.c | 2 +- sound/usb/format.c | 2 +- sound/usb/helper.c | 2 +- sound/usb/implicit.c | 2 +- sound/usb/media.c | 2 +- sound/usb/midi.c | 2 +- sound/usb/midi.h | 2 ++ sound/usb/midi2.c | 2 +- sound/usb/midi2.h | 1 + sound/usb/misc/ua101.c | 2 +- sound/usb/mixer.c | 2 +- sound/usb/mixer_quirks.c | 2 +- sound/usb/mixer_s1810c.c | 2 +- sound/usb/mixer_scarlett.c | 2 +- sound/usb/mixer_scarlett2.c | 2 +- sound/usb/mixer_us16x08.c | 2 +- sound/usb/pcm.c | 2 +- sound/usb/power.c | 2 +- sound/usb/proc.c | 2 +- sound/usb/quirks.c | 2 +- sound/usb/quirks.h | 2 ++ sound/usb/stream.c | 2 +- sound/usb/usx2y/us122l.c | 2 +- sound/usb/usx2y/usX2Yhwdep.c | 1 + sound/usb/usx2y/usbusx2y.h | 2 +- sound/usb/validate.c | 2 +- 30 files changed, 44 insertions(+), 36 deletions(-) rename sound/usb/usbaudio.h => include/sound/usb.h (98%)
include/sound/usb.h renamed from sound/usb/usbaudio.h +13 -11
@@ -1,6 +1,7 @@/* SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef __USBAUDIO_H -#define __USBAUDIO_H +#ifndef __SOUND_USB_H +#define __SOUND_USB_H +/* * (Tentative) USB Audio Driver for ALSA *
@@ -21,6 +22,14 @@ struct media_intf_devnode;#define MAX_CARD_INTERFACES 16 +struct snd_usb_audio_quirk { +const char *vendor_name; +const char *product_name; +int16_t ifnum; +uint16_t type; +const void *data; +}; +/* * Structure holding assosiation between Audio Control Interface * and given Streaming or Midi Interface.
@@ -37,6 +46,7 @@ struct snd_usb_audio {struct usb_interface *intf[MAX_CARD_INTERFACES ];u32 usb_id;uint16_t quirk_type; +const struct snd_usb_audio_quirk *quirk;struct mutex mutex;unsigned int system_suspend;atomic_t active;
@@ -99,7 +109,7 @@ struct snd_usb_audio {#define QUIRK_NO_INTERFACE -2#define QUIRK_ANY_INTERFACE -1 -enum quirk_type { +enum snd_usb_quirk_type {QUIRK_IGNORE_INTERFACE ,QUIRK_COMPOSITE ,QUIRK_AUTODETECT ,
@@ -124,14 +134,6 @@ enum quirk_type { QUIRK_TYPE_COUNT }; -struct snd_usb_audio_quirk { -const char *vendor_name; -const char *product_name; -int16_t ifnum; -uint16_t type; -const void *data; -}; -#define combine_word (s) ((*(s)) | ((unsigned int)(s)[1] << 8))#define combine_triple (s) (combine_word(s) | ((unsigned int)(s)[2] << 16))#define combine_quad (s) (combine_triple(s) | ((unsigned int)(s)[3] << 24))
sound/usb/caiaq/device.h +1 -1
@@ -2,7 +2,7 @@#ifndef CAIAQ_DEVICE_H #define CAIAQ_DEVICE_H -#include "../usbaudio.h" +#include <sound/usb.h> #define USB_VID_NATIVEINSTRUMENTS 0x17cc
sound/usb/card.c +1 -1
@@ -40,8 +40,8 @@#include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/initval.h> +#include <sound/usb.h> -#include "usbaudio.h" #include "card.h" #include "midi.h" #include "midi2.h"
sound/usb/clock.c +1 -1
@@ -14,8 +14,8 @@#include <sound/core.h> #include <sound/info.h> #include <sound/pcm.h> +#include <sound/usb.h> -#include "usbaudio.h" #include "card.h" #include "helper.h" #include "clock.h"
sound/usb/endpoint.c +1 -1
@@ -12,8 +12,8 @@#include <sound/core.h> #include <sound/pcm.h> #include <sound/pcm_params.h> +#include <sound/usb.h> -#include "usbaudio.h" #include "helper.h" #include "card.h" #include "endpoint.h"
sound/usb/format.c +1 -1
@@ -11,8 +11,8 @@#include <sound/core.h> #include <sound/pcm.h> +#include <sound/usb.h> -#include "usbaudio.h" #include "card.h" #include "quirks.h" #include "helper.h"
sound/usb/helper.c +1 -1
@@ -5,8 +5,8 @@#include <linux/init.h> #include <linux/slab.h> #include <linux/usb.h> +#include <sound/usb.h> -#include "usbaudio.h" #include "helper.h" #include "quirks.h"
sound/usb/implicit.c +1 -1
@@ -11,8 +11,8 @@#include <sound/core.h> #include <sound/pcm.h> #include <sound/pcm_params.h> +#include <sound/usb.h> -#include "usbaudio.h" #include "card.h" #include "helper.h" #include "pcm.h"
sound/usb/media.c +1 -1
@@ -24,8 +24,8 @@#include <sound/pcm.h> #include <sound/core.h> +#include <sound/usb.h> -#include "usbaudio.h" #include "card.h" #include "mixer.h" #include "media.h"
sound/usb/midi.c +1 -1
@@ -54,7 +54,7 @@#include <sound/control.h> #include <sound/rawmidi.h> #include <sound/asequencer.h> -#include "usbaudio.h" +#include <sound/usb.h> #include "midi.h" #include "power.h" #include "helper.h"
sound/usb/midi.h +2 -0
@@ -2,6 +2,8 @@#ifndef __USBMIDI_H#define __USBMIDI_H +#include <sound/usb.h> +/* maximum number of endpoints per interface */ #define MIDI_MAX_ENDPOINTS 2
sound/usb/midi2.c +1 -1
@@ -18,7 +18,7 @@#include <sound/core.h> #include <sound/control.h> #include <sound/ump.h> -#include "usbaudio.h" +#include <sound/usb.h> #include "midi.h" #include "midi2.h" #include "helper.h"
sound/usb/midi2.h +1 -0
@@ -2,6 +2,7 @@#ifndef __USB_AUDIO_MIDI2_H#define __USB_AUDIO_MIDI2_H +#include <sound/usb.h> #include "midi.h" #if IS_ENABLED (CONFIG_SND_USB_AUDIO_MIDI_V2 )
sound/usb/misc/ua101.c +1 -1
@@ -13,7 +13,7 @@#include <sound/initval.h> #include <sound/pcm.h> #include <sound/pcm_params.h> -#include "../usbaudio.h" +#include <sound/usb.h> #include "../midi.h" MODULE_DESCRIPTION ("Edirol UA-101/1000 driver" );
sound/usb/mixer.c +1 -1
@@ -43,8 +43,8 @@#include <sound/hwdep.h> #include <sound/info.h> #include <sound/tlv.h> +#include <sound/usb.h> -#include "usbaudio.h" #include "mixer.h" #include "helper.h" #include "mixer_quirks.h"
sound/usb/mixer_quirks.c +1 -1
@@ -29,8 +29,8 @@#include <sound/hwdep.h> #include <sound/info.h> #include <sound/tlv.h> +#include <sound/usb.h> -#include "usbaudio.h" #include "mixer.h" #include "mixer_quirks.h" #include "mixer_scarlett.h"
sound/usb/mixer_s1810c.c +1 -1
@@ -18,8 +18,8 @@#include <linux/slab.h> #include <sound/core.h> #include <sound/control.h> +#include <sound/usb.h> -#include "usbaudio.h" #include "mixer.h" #include "mixer_quirks.h" #include "helper.h"
sound/usb/mixer_scarlett.c +1 -1
@@ -124,8 +124,8 @@#include <sound/core.h> #include <sound/control.h> #include <sound/tlv.h> +#include <sound/usb.h> -#include "usbaudio.h" #include "mixer.h" #include "helper.h" #include "power.h"
sound/usb/mixer_scarlett2.c +1 -1
@@ -158,10 +158,10 @@#include <sound/control.h> #include <sound/tlv.h> #include <sound/hwdep.h> +#include <sound/usb.h> #include <uapi/sound/scarlett2.h> -#include "usbaudio.h" #include "mixer.h" #include "helper.h"
sound/usb/mixer_us16x08.c +1 -1
@@ -11,8 +11,8 @@#include <sound/core.h> #include <sound/control.h> +#include <sound/usb.h> -#include "usbaudio.h" #include "mixer.h" #include "helper.h"
sound/usb/pcm.c +1 -1
@@ -13,8 +13,8 @@#include <sound/core.h> #include <sound/pcm.h> #include <sound/pcm_params.h> +#include <sound/usb.h> -#include "usbaudio.h" #include "card.h" #include "quirks.h" #include "endpoint.h"
sound/usb/power.c +1 -1
@@ -8,8 +8,8 @@#include <linux/usb/audio.h> #include <linux/usb/audio-v2.h> #include <linux/usb/audio-v3.h> +#include <sound/usb.h> -#include "usbaudio.h" #include "helper.h" #include "power.h"
sound/usb/proc.c +1 -1
@@ -8,8 +8,8 @@#include <sound/core.h> #include <sound/info.h> #include <sound/pcm.h> +#include <sound/usb.h> -#include "usbaudio.h" #include "helper.h" #include "card.h" #include "endpoint.h"
sound/usb/quirks.c +1 -1
@@ -13,8 +13,8 @@#include <sound/core.h> #include <sound/info.h> #include <sound/pcm.h> +#include <sound/usb.h> -#include "usbaudio.h" #include "card.h" #include "mixer.h" #include "mixer_quirks.h"
sound/usb/quirks.h +2 -0
@@ -2,6 +2,8 @@#ifndef __USBAUDIO_QUIRKS_H#define __USBAUDIO_QUIRKS_H +#include <sound/usb.h> +struct audioformat ;struct snd_usb_endpoint ;struct snd_usb_substream ;
sound/usb/stream.c +1 -1
@@ -14,8 +14,8 @@#include <sound/pcm.h> #include <sound/control.h> #include <sound/tlv.h> +#include <sound/usb.h> -#include "usbaudio.h" #include "card.h" #include "proc.h" #include "quirks.h"
sound/usb/usx2y/us122l.c +1 -1
@@ -11,9 +11,9 @@#include <sound/hwdep.h> #include <sound/pcm.h> #include <sound/initval.h> +#include <sound/usb.h> #define MODNAME "US122L"#include "usb_stream.c" -#include "../usbaudio.h" #include "../midi.h" #include "us122l.h"
sound/usb/usx2y/usX2Yhwdep.c +1 -0
@@ -14,6 +14,7 @@#include <sound/memalloc.h> #include <sound/pcm.h> #include <sound/hwdep.h> +#include <sound/usb.h> #include "usx2y.h" #include "usbusx2y.h" #include "usX2Yhwdep.h"
sound/usb/usx2y/usbusx2y.h +1 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ #ifndef USBUSX2Y_H #define USBUSX2Y_H -#include "../usbaudio.h" +#include <sound/usb.h> #include "../midi.h" #include "usbus428ctldefs.h"
sound/usb/validate.c +1 -1
@@ -9,7 +9,7 @@#include <linux/usb/audio-v2.h> #include <linux/usb/audio-v3.h> #include <linux/usb/midi.h> -#include "usbaudio.h" +#include <sound/usb.h> #include "helper.h" struct usb_desc_validator {
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerRFC 4/15 ALSA: usb: Implement two-stage quirk applying mechanism
In reply to Cezary RojewskiThe USB Audio-Class (AC) device driver on ASoC side needs to know the number of available PCM streams when creating list of DAI and DAI Links before these objects are actually probed. To achieve that split existing USB stream enumeration procedure from one-stage to two-stage process:
1) parse the descriptors and obtain information about PCMs but do not create them yet
2) create all PCMs based on the previously obtained information and follow that up with MIDIs, mixers and Media resources
On quirks side this translates to splitting all handlers that do combine pcm/midi/mixer together into 'pcm-only' and 'others'. A top level handler snd_usb_parse_pcms_quirk() is provided to invoke all the necessary parse-pcm quirks depending on the quirk type. It mimics behavior of snd_usb_create_quirk() but limits itself to just parsing the PCMs.
--- sound/usb/quirks.c | 217 ++++++++++++++++++++++++++++++++++++--------- sound/usb/quirks.h | 4 + 2 files changed, 179 insertions(+), 42 deletions(-)
sound/usb/quirks.c +175 -42
@@ -28,7 +28,36 @@#include "stream.h" /* -* handle the quirks for the contained interfaces +* First run of composite quirk. Parses all PCM interfaces. +* These can be later created with snd_usb_add_pcms(). +*/ +static int create_composite_pcm_quirk (struct snd_usb_audio *chip, +struct usb_interface *iface, +struct usb_driver *driver, +const struct snd_usb_audio_quirk *quirk_comp) +{ +int probed_ifnum =get_iface_desc (iface->altsetting)->bInterfaceNumber; +const struct snd_usb_audio_quirk *quirk; +int err; + +for (quirk = quirk_comp->data; quirk->ifnum >=0 ; ++quirk) { + iface =usb_ifnum_to_if (chip->dev, quirk->ifnum); +if (!iface) +continue ; +if (quirk->ifnum != probed_ifnum && +usb_interface_claimed (iface)) +continue ; + err =snd_usb_parse_pcms_quirk (chip, iface, driver, quirk); +if (err <0 ) +return err; + } + +return 0 ; +} + +/* +* Second run of composite quirk. Creates all non-PCM interfaces and +* claims the usb_interface @iface. */ static int create_composite_quirk(struct snd_usb_audio *chip, struct usb_interface *iface,
@@ -375,6 +404,25 @@ static int create_auto_midi_quirk(struct snd_usb_audio *chip,return create_std_midi_quirk (chip, iface, driver, alts); } +static int create_autodetect_pcm_quirk (struct snd_usb_audio *chip, +struct usb_interface *iface, +struct usb_driver *driver, +const struct snd_usb_audio_quirk *quirk) +{ +return create_auto_pcm_quirk (chip, iface, driver); +} + +__maybe_unused +static int create_autodetect_midi_quirk (struct snd_usb_audio *chip, +struct usb_interface *iface, +struct usb_driver *driver, +const struct snd_usb_audio_quirk *quirk) +{ +if (list_empty (&chip->pcm_list)) +return create_auto_midi_quirk (chip, iface, driver); +return 1 ; +} + static int create_autodetect_quirk(struct snd_usb_audio *chip, struct usb_interface *iface, struct usb_driver *driver,
@@ -388,14 +436,10 @@ static int create_autodetect_quirk(struct snd_usb_audio *chip,return err; } -/* -* Create a stream for an Edirol UA-700/UA-25/UA-4FX interface. -* The only way to detect the sample rate is by looking at wMaxPacketSize. -*/ -static int create_uaxx_quirk (struct snd_usb_audio *chip, -struct usb_interface *iface, -struct usb_driver *driver, -const struct snd_usb_audio_quirk *quirk) +static int create_uaxx_pcm_quirk (struct snd_usb_audio *chip, +struct usb_interface *iface, +struct usb_driver *driver, +const struct snd_usb_audio_quirk *quirk) {static const struct audioformat ua_format = { .formats =SNDRV_PCM_FMTBIT_S24_3LE ,
@@ -405,8 +449,8 @@ static int create_uaxx_quirk(struct snd_usb_audio *chip, .altset_idx = 1, .rates = SNDRV_PCM_RATE_CONTINUOUS, }; -struct usb_host_interface *alts;struct usb_interface_descriptor *altsd; +struct usb_host_interface *alts;struct audioformat *fp;int err;
@@ -416,35 +460,15 @@ static int create_uaxx_quirk(struct snd_usb_audio *chip, alts = &iface->altsetting[1 ]; altsd =get_iface_desc (alts); -if (altsd->bNumEndpoints ==2 ) { -static const struct snd_usb_midi_endpoint_info ua700_ep = { - .out_cables =0x0003 , - .in_cables =0x0003 - }; -static const struct snd_usb_audio_quirk ua700_quirk = { - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = &ua700_ep - }; -static const struct snd_usb_midi_endpoint_info uaxx_ep = { - .out_cables =0x0001 , - .in_cables =0x0001 - }; -static const struct snd_usb_audio_quirk uaxx_quirk = { - .type =QUIRK_MIDI_FIXED_ENDPOINT , - .data = &uaxx_ep - }; -const struct snd_usb_audio_quirk *quirk = - chip->usb_id ==USB_ID (0x0582 ,0x002b ) - ? &ua700_quirk : &uaxx_quirk; -return __snd_usbmidi_create (chip->card, iface, - &chip->midi_list, quirk, - chip->usb_id, - &chip->num_rawmidis); +switch (altsd->bNumEndpoints) { +case 2 : +return 2 ;/* Leave this to midi. */ +case 1 : +break ; +default : +return -ENXIO ; } -if (altsd->bNumEndpoints !=1 ) -return -ENXIO ; - fp =kmemdup (&ua_format,sizeof (*fp),GFP_KERNEL );if (!fp)return -ENOMEM ;
@@ -484,6 +508,78 @@ static int create_uaxx_quirk(struct snd_usb_audio *chip,return 0 ; } +/* +* Create a stream for an Edirol UA-700/UA-25/UA-4FX interface. +* The only way to detect the sample rate is by looking at wMaxPacketSize. +*/ +static int create_uaxx_midi_quirk (struct snd_usb_audio *chip, +struct usb_interface *iface, +struct usb_driver *driver, +const struct snd_usb_audio_quirk *quirk) +{ +static const struct snd_usb_midi_endpoint_info ua700_ep = { + .out_cables =0x0003 , + .in_cables =0x0003 + }; +static const struct snd_usb_audio_quirk ua700_quirk = { + .type =QUIRK_MIDI_FIXED_ENDPOINT , + .data = &ua700_ep + }; +static const struct snd_usb_midi_endpoint_info uaxx_ep = { + .out_cables =0x0001 , + .in_cables =0x0001 + }; +static const struct snd_usb_audio_quirk uaxx_quirk = { + .type =QUIRK_MIDI_FIXED_ENDPOINT , + .data = &uaxx_ep + }; +const struct snd_usb_audio_quirk *spec; +struct usb_host_interface *alt; + + spec = chip->usb_id ==USB_ID (0x0582 ,0x002b ) ? &ua700_quirk : &uaxx_quirk; + +/* both PCM and MIDI interfaces have 2 or more altsettings */ +if (iface->num_altsetting <2 ) +return -ENXIO ; + alt = &iface->altsetting[1 ]; + +switch (alt->desc.bNumEndpoints) { +case 2 : +break ; +case 1 : +return 1 ;/* Leave this to pcm. */ +default : +return -ENXIO ; + } + +return __snd_usbmidi_create (chip->card, iface, &chip->midi_list, spec, chip->usb_id, + &chip->num_rawmidis); +} + +static int create_uaxx_quirk (struct snd_usb_audio *chip, +struct usb_interface *iface, +struct usb_driver *driver, +const struct snd_usb_audio_quirk *quirk) +{ +struct usb_interface_descriptor *altsd; +struct usb_host_interface *alts; + +/* both PCM and MIDI interfaces have 2 or more altsettings */ +if (iface->num_altsetting <2 ) +return -ENXIO ; + alts = &iface->altsetting[1 ]; + altsd =get_iface_desc (alts); + +switch (altsd->bNumEndpoints) { +case 2 : +return create_uaxx_midi_quirk (chip, iface, driver, quirk); +case 1 : +return create_uaxx_pcm_quirk (chip, iface, driver, quirk); +default : +return -ENXIO ; + } +} +/* * Create a standard mixer for the specified interface. */
@@ -498,6 +594,44 @@ static int create_standard_mixer_quirk(struct snd_usb_audio *chip,return snd_usb_create_mixer (chip, quirk->ifnum); } +int snd_usb_parse_pcms_quirk (struct snd_usb_audio *chip, +struct usb_interface *iface, +struct usb_driver *driver, +const struct snd_usb_audio_quirk *quirk) +{ +typedef int (*quirk_func_t )(struct snd_usb_audio *, +struct usb_interface *, +struct usb_driver *, +const struct snd_usb_audio_quirk *); +static const quirk_func_t quirk_funcs[] = { + [QUIRK_IGNORE_INTERFACE ] = ignore_interface_quirk, + [QUIRK_COMPOSITE ] = create_composite_pcm_quirk, + [QUIRK_AUTODETECT ] = create_autodetect_pcm_quirk, + [QUIRK_MIDI_STANDARD_INTERFACE ] = ignore_interface_quirk, + [QUIRK_MIDI_FIXED_ENDPOINT ] = ignore_interface_quirk, + [QUIRK_MIDI_YAMAHA ] = ignore_interface_quirk, + [QUIRK_MIDI_ROLAND ] = ignore_interface_quirk, + [QUIRK_MIDI_MIDIMAN ] = ignore_interface_quirk, + [QUIRK_MIDI_NOVATION ] = ignore_interface_quirk, + [QUIRK_MIDI_RAW_BYTES ] = ignore_interface_quirk, + [QUIRK_MIDI_EMAGIC ] = ignore_interface_quirk, + [QUIRK_MIDI_CME ] = ignore_interface_quirk, + [QUIRK_MIDI_AKAI ] = ignore_interface_quirk, + [QUIRK_MIDI_FTDI ] = ignore_interface_quirk, + [QUIRK_MIDI_CH345 ] = ignore_interface_quirk, + [QUIRK_AUDIO_STANDARD_INTERFACE ] = create_standard_audio_quirk, + [QUIRK_AUDIO_FIXED_ENDPOINT ] = create_fixed_stream_quirk, + [QUIRK_AUDIO_EDIROL_UAXX ] = create_uaxx_pcm_quirk, + [QUIRK_AUDIO_STANDARD_MIXER ] = ignore_interface_quirk, + }; + +if (quirk->type <QUIRK_TYPE_COUNT ) +return quirk_funcs[quirk->type](chip, iface, driver, quirk); + +usb_audio_err (chip,"invalid quirk type %d\n" , quirk->type); +return -ENXIO ; +} +/* * audio-interface quirks *
@@ -537,12 +671,11 @@ int snd_usb_create_quirk(struct snd_usb_audio *chip, [QUIRK_AUDIO_STANDARD_MIXER] = create_standard_mixer_quirk, }; -if (quirk->type <QUIRK_TYPE_COUNT ) { +if (quirk->type <QUIRK_TYPE_COUNT )return quirk_funcs[quirk->type](chip, iface, driver, quirk); - }else { -usb_audio_err (chip,"invalid quirk type %d\n" , quirk->type); -return -ENXIO ; - } + +usb_audio_err (chip,"invalid quirk type %d\n" , quirk->type); +return -ENXIO ; }/*
sound/usb/quirks.h +4 -0
@@ -8,6 +8,10 @@ struct audioformat;struct snd_usb_endpoint ;struct snd_usb_substream ; +int snd_usb_parse_pcms_quirk (struct snd_usb_audio *chip, +struct usb_interface *iface, +struct usb_driver *driver, +const struct snd_usb_audio_quirk *quirk); int snd_usb_create_quirk(struct snd_usb_audio *chip, struct usb_interface *iface, struct usb_driver *driver,
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerRFC 5/15 ALSA: usb: Implement two-stage stream creation mechanism
In reply to Cezary RojewskiThe USB Audio-Class (AC) device driver on ASoC side needs to know the number of available PCM streams when creating list of DAI and DAI Links before these objects are actually probed. To achieve that split existing USB stream enumeration procedure from one-stage to two-stage process:
1) parse the descriptors and obtain information about PCMs but do not create them yet
2) create all PCMs based on the previously obtained information and follow that up with MIDIs, mixers and Media resources
On the streaming side, this translates to replacing existing functions that do:
create_all()
with new ones that:
parse_pcms()
create_nonpcms()
As number of changes is large, the process is not part of a single patch. The switch is done in follow ups.
The implementation does try to align with existing equivalent as closely as possible - no quirks and magic if-statements are skipped. Any kind of cleanup in that area is outside of the scope of this change.
Existing snd_usb_create_stream() is represented by:
snd_usb_streaming_iface() snd_usb_create_claim_pcm() snd_usb_create_claim_midi()
Part of existing usb_audio_probe(), responsible for stream creation is represented by:
snd_usb_parse_pcms()
snd_usb_create_nonpcms()
Existing __snd_usb_add_audio_stream() is represented by:
snd_usb_parse_pcms() snd_usb_pcm_add() snd_usb_add_pcms()
As ASoC is responsible for calling snd_pcm_new(), the component driver has to bind the PCMs to USB streams manually. Helper snd_usb_bind_pcm() addresses that need.
--- include/sound/usb.h | 5 ++ sound/usb/card.c | 168 ++++++++++++++++++++++++++++++++++++++++++++ sound/usb/stream.c | 145 ++++++++++++++++++++++++++++++++++++++ sound/usb/stream.h | 1 + 4 files changed, 319 insertions(+)
include/sound/usb.h +5 -0
@@ -8,6 +8,9 @@* Copyright (c) 2002 by Takashi Iwai <[email protected]> */ +#include <linux/list.h> +#include <sound/pcm.h> +/* handling of USB vendor/product ID pairs as 32-bit numbers */ #define USB_ID (vendor, product) (((unsigned int)(vendor) << 16) | (product))#define USB_ID_VENDOR (id) ((id) >> 16)
@@ -87,6 +90,8 @@ struct snd_usb_audio {struct snd_intf_to_ctrl intf_to_ctrl[MAX_CARD_INTERFACES ]; }; +int snd_usb_bind_pcm (struct list_head *stream_entry,struct snd_pcm *pcm); +#define USB_AUDIO_IFACE_UNUSED ((void *)-1L) #define usb_audio_err(chip, fmt, args...) \
sound/usb/card.c +168 -0
180 lines not on this page · raw message
sound/usb/stream.c +145 -0
151 lines not on this page · raw message
sound/usb/stream.h +1 -0
@@ -9,6 +9,7 @@ int snd_usb_add_audio_stream(struct snd_usb_audio *chip,int stream, struct audioformat *fp);void snd_usb_free_pcms (struct snd_usb_audio *chip); +int snd_usb_add_pcms (struct snd_usb_audio *chip);#endif /* __USBAUDIO_STREAM_H */
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerRFC 6/15 ALSA: usb: Implement two-stage chip probing mechanism
In reply to Cezary RojewskiThe USB Audio-Class (AC) device driver on ASoC side needs to know the number of available PCM streams when creating list of DAI and DAI Links before these objects are actually probed. To achieve that split existing USB stream enumeration procedure from one-stage to two-stage process:
1) parse the descriptors and obtain information about PCMs but do not create them yet
2) create all PCMs based on the previously obtained information and follow that up with MIDIs, mixers and Media resources
As number of changes is large, the process is not part of a single patch. The switch is done in follow ups.
Existing usb_audio_probe() is a non-atomic function that performs a large number of operations. These can be represented with:
snd_usb_request_chip() snd_usb_find_chip() snd_usb_alloc_slot() snd_usb_new_chip() snd_usb_chip_init() snd_usb_chip_release() snd_usb_sanity_check() snd_usb_create_card()
All the steps done before stream creation are performed in first-stage probing function - snd_usb_probe_unlocked(). As ASoC is responsible for calling snd_card_new(), the component driver has to bind the card to USB device manually. Helper snd_usb_bind_card() addresses that need.
--- include/linux/usb.h | 15 +++ include/linux/usb/ch9.h | 11 ++ include/sound/usb.h | 2 + sound/usb/card.c | 289 +++++++++++++++++++++++++++++++++++++++- 4 files changed, 316 insertions(+), 1 deletion(-)
include/linux/usb.h +15 -0
@@ -749,6 +749,21 @@ static inline const struct usb_device *__intf_to_usbdev_const(const struct usb_i const struct usb_interface *: __intf_to_usbdev_const, \ struct usb_interface *: __intf_to_usbdev)(intf) +static inline u16 usb_device_vid(struct usb_device *udev) +{ + return le16_to_cpu(udev->descriptor.idVendor); +} + +static inline u16 usb_device_pid (struct usb_device *udev) +{ +return le16_to_cpu (udev->descriptor.idProduct); +} + +static inline u32 usb_device_vpid (struct usb_device *udev) +{ +return ((u32 )usb_device_vid (udev) <<16 ) |usb_device_pid (udev); +} +extern struct usb_device *usb_get_dev (struct usb_device *dev);extern void usb_put_dev (struct usb_device *dev); extern struct usb_device *usb_hub_find_child(struct usb_device *hdev,
include/linux/usb/ch9.h +11 -0
@@ -57,4 +57,15 @@ extern const char *usb_decode_ctrl(char *str, size_t size, __u8 bRequestType, __u16 wLength);#endif +/** +* usb_epaddr_num - extract endpoint's number from its address +* @epaddr: bEndpointAddress of the USB endpoint +* +* Returns endpoint number: 0 to 15. +*/ +static inline int usb_epaddr_num (unsigned char epaddr) +{ +return epaddr &USB_ENDPOINT_NUMBER_MASK ; +} +#endif /* __LINUX_USB_CH9_H */
include/sound/usb.h +2 -0
@@ -90,6 +90,8 @@ struct snd_usb_audio {struct snd_intf_to_ctrl intf_to_ctrl[MAX_CARD_INTERFACES ]; }; +int snd_usb_bind_card (struct snd_usb_audio *chip,struct snd_card *card, +struct usb_driver *driver);int snd_usb_bind_pcm (struct list_head *stream_entry,struct snd_pcm *pcm);#define USB_AUDIO_IFACE_UNUSED ((void *)-1L)
sound/usb/card.c +288 -1
301 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerRFC 7/15 ALSA: usb: Switch to the two-stage chip probing
In reply to Cezary RojewskiUtilize newly added functions and update existing probing procedure of USB Audio-Class (AC) device from one-stage into two-stage process. In consequence, drop snd_usb_audio_create() and rewrite usb_audio_probe() to first do snd_usb_probe_unlocked() which is intended to be shared by both ALSA and ASoC driver before continuing with creating all the streams.
While at it, do not forget about snd_audio_disconnect(). Use snd_usb_chip_release() to keep both probe() and disconnect() synchronized.
--- sound/usb/card.c | 281 ++++++++--------------------------------------- 1 file changed, 45 insertions(+), 236 deletions(-)
sound/usb/card.c +45 -236
@@ -21,6 +21,7 @@#include <linux/bitops.h> +#include <linux/cleanup.h> #include <linux/init.h> #include <linux/list.h> #include <linux/slab.h>
@@ -687,86 +688,6 @@ static void usb_audio_make_longname(struct usb_device *dev, } } -/* -* create a chip instance and set its names. -*/ -static int snd_usb_audio_create (struct usb_interface *intf, -struct usb_device *dev,int idx, -const struct snd_usb_audio_quirk *quirk, -unsigned int usb_id, -struct snd_usb_audio **rchip) -{ -struct snd_card *card; -struct snd_usb_audio *chip; -int err; -char component[14 ]; - - *rchip =NULL ; - -switch (snd_usb_get_speed (dev)) { -case USB_SPEED_LOW : -case USB_SPEED_FULL : -case USB_SPEED_HIGH : -case USB_SPEED_SUPER : -case USB_SPEED_SUPER_PLUS : -break ; -default : -dev_err (&dev->dev,"unknown device speed %d\n" ,snd_usb_get_speed (dev)); -return -ENXIO ; - } - - chip =kzalloc (sizeof (*chip),GFP_KERNEL ); -if (!chip) -return -ENOMEM ; - - err =snd_card_new (&intf->dev, index[idx], id[idx],THIS_MODULE ,0 , &card); -if (err <0 ) { -dev_err (&dev->dev,"cannot create card instance %d\n" , idx); -kfree (chip); -return err; - } - -mutex_init (&chip->mutex); -init_waitqueue_head (&chip->shutdown_wait); - chip->index = idx; - chip->dev = dev; - chip->card = card; - chip->setup = device_setup[idx]; - chip->generic_implicit_fb = implicit_fb[idx]; - chip->autoclock = autoclock; - chip->lowlatency = lowlatency; -atomic_set (&chip->active,1 );/* avoid autopm during probing */ -atomic_set (&chip->usage_count,0 ); -atomic_set (&chip->shutdown,0 ); - - chip->usb_id = usb_id; -INIT_LIST_HEAD (&chip->pcm_list); -INIT_LIST_HEAD (&chip->ep_list); -INIT_LIST_HEAD (&chip->iface_ref_list); -INIT_LIST_HEAD (&chip->clock_ref_list); -INIT_LIST_HEAD (&chip->midi_list); -INIT_LIST_HEAD (&chip->midi_v2_list); -INIT_LIST_HEAD (&chip->mixer_list); - -if (quirk_flags[idx]) - chip->quirk_flags = quirk_flags[idx]; -else -snd_usb_init_quirk_flags (chip); - -strcpy (card->driver,"USB-Audio" ); -sprintf (component,"USB%04x:%04x" , -USB_ID_VENDOR (chip->usb_id),USB_ID_PRODUCT (chip->usb_id)); -snd_component_add (card, component); - -usb_audio_make_shortname (dev, chip, quirk); -usb_audio_make_longname (dev, chip, quirk); - -snd_usb_audio_create_proc (chip); - - *rchip = chip; -return 0 ; -} -/* look for a matching quirk alias id */ static bool get_alias_id (struct usb_device *dev,unsigned int *id) {
@@ -870,7 +791,6 @@ static int snd_usb_parse_pcms(struct snd_usb_audio *chip, struct usb_interface *return 0 ; } -__maybe_unused static int snd_usb_create_nonpcms (struct snd_usb_audio *chip,struct usb_interface *iface,struct usb_driver *driver) {
@@ -1118,7 +1038,6 @@ static int snd_usb_sanity_check(struct usb_interface *iface,return 0 ; } -__maybe_unused static int snd_usb_probe_unlocked (struct usb_interface *iface,const struct usb_device_id *usb_id,struct usb_driver *driver) {
@@ -1179,7 +1098,6 @@ int snd_usb_bind_card(struct snd_usb_audio *chip, struct snd_card *card, }EXPORT_SYMBOL_GPL (snd_usb_bind_card); -__maybe_unused static int snd_usb_create_card (struct snd_usb_audio *chip,struct usb_interface *iface) {struct usb_device *udev = chip->dev;
@@ -1227,170 +1145,68 @@ static int try_to_register_card(struct snd_usb_audio *chip, int ifnum)* only at the first time. the successive calls of this function will * append the pcm interface to the corresponding card. */ -static int usb_audio_probe (struct usb_interface *intf, -const struct usb_device_id *usb_id) +static int usb_audio_probe (struct usb_interface *iface,const struct usb_device_id *usb_id) { -struct usb_device *dev =interface_to_usbdev (intf); -const struct snd_usb_audio_quirk *quirk = - (const struct snd_usb_audio_quirk *)usb_id->driver_info; -struct snd_usb_audio *chip; -int i, err;struct usb_host_interface *alts; -int ifnum; -u32 id; +struct snd_usb_audio *chip; +struct usb_device *udev; +int ifnum, ret; - alts = &intf->altsetting[0 ]; - ifnum =get_iface_desc (alts)->bInterfaceNumber; - id =USB_ID (le16_to_cpu (dev->descriptor.idVendor), -le16_to_cpu (dev->descriptor.idProduct)); -if (get_alias_id (dev, &id)) - quirk =get_alias_quirk (dev, id); -if (quirk && quirk->ifnum >=0 && ifnum != quirk->ifnum) -return -ENXIO ; -if (quirk && quirk->ifnum ==QUIRK_NODEV_INTERFACE ) + alts = &iface->altsetting[0 ]; + ifnum = alts->desc.bInterfaceNumber; + udev =interface_to_usbdev (iface); + + udev =interface_to_usbdev (iface); +if (udev->audsb_capable)return -ENODEV ; - err =snd_usb_apply_boot_quirk (dev, intf, quirk, id); -if (err <0 ) -return err; - -/* -* found a config. now register to ALSA -*/ - -/* check whether it's already registered */ - chip =NULL ; -mutex_lock (®ister_mutex); -for (i =0 ; i <SNDRV_CARDS ; i++) { -if (usb_chip[i] && usb_chip[i]->dev == dev) { -if (atomic_read (&usb_chip[i]->shutdown)) { -dev_err (&dev->dev,"USB device is in the shutdown state, cannot create a card instance\n" ); - err = -EIO ; - goto __error; - } - chip = usb_chip[i]; -atomic_inc (&chip->active);/* avoid autopm */ -break ; - } - } -if (! chip) { - err =snd_usb_apply_boot_quirk_once (dev, intf, quirk, id); -if (err <0 ) - goto __error; - -/* it's a fresh one. -* now look for an empty slot and create a new card instance -*/ -for (i =0 ; i <SNDRV_CARDS ; i++) -if (!usb_chip[i] && - (vid[i] ==-1 || vid[i] ==USB_ID_VENDOR (id)) && - (pid[i] ==-1 || pid[i] ==USB_ID_PRODUCT (id))) { -if (enable[i]) { - err =snd_usb_audio_create (intf, dev, i, quirk, - id, &chip); -if (err <0 ) - goto __error; -break ; - }else if (vid[i] !=-1 || pid[i] !=-1 ) { -dev_info (&dev->dev, -"device (%04x:%04x) is disabled\n" , -USB_ID_VENDOR (id), -USB_ID_PRODUCT (id)); - err = -ENOENT ; - goto __error; - } - } -if (!chip) { -dev_err (&dev->dev,"no available usb audio device\n" ); - err = -ENODEV ; - goto __error; - } -find_last_interface (chip); - } - -if (chip->num_interfaces >=MAX_CARD_INTERFACES ) { -dev_info (&dev->dev,"Too many interfaces assigned to the single USB-audio card\n" ); - err = -EINVAL ; - goto __error; +guard (mutex)(®ister_mutex); + + ret =snd_usb_probe_unlocked (iface, usb_id, &usb_audio_driver); + chip =dev_get_drvdata (&udev->dev); +/* If chip isn't there, probe failed at the first interface. */ +if (!chip) +return ret; +if (ret) + goto err_try_register; +if (!chip->card) { + ret =snd_usb_create_card (chip, iface); +if (ret) + goto err_no_register; } -dev_set_drvdata (&dev->dev, chip); + ret =snd_usb_add_pcms (chip); +if (ret) + goto err_try_register; -if (ignore_ctl_error) - chip->quirk_flags |=QUIRK_FLAG_IGNORE_CTL_ERROR ; - -if (chip->quirk_flags &QUIRK_FLAG_DISABLE_AUTOSUSPEND ) -usb_disable_autosuspend (interface_to_usbdev (intf)); - -/* -* For devices with more than one control interface, we assume the -* first contains the audio controls. We might need a more specific -* check here in the future. -*/ -if (!chip->ctrl_intf) - chip->ctrl_intf = alts; - - err =1 ;/* continue */ -if (quirk && quirk->ifnum !=QUIRK_NO_INTERFACE ) { -/* need some special handlings */ - err =snd_usb_create_quirk (chip, intf, &usb_audio_driver, quirk); -if (err <0 ) - goto __error; - } - -if (err >0 ) { -/* create normal USB audio interfaces */ - err =snd_usb_create_streams (chip, ifnum); -if (err <0 ) - goto __error; - err =snd_usb_create_mixer (chip, ifnum); -if (err <0 ) - goto __error; - } + ret =snd_usb_create_nonpcms (chip, iface, &usb_audio_driver); +if (ret) + goto err_try_register;if (chip->need_delayed_register) { -dev_info (&dev->dev, -"Found post-registration device assignment: %08x:%02x\n" , +dev_info (&udev->dev,"Found post-registration device assignment: %08x:%02x\n" , chip->usb_id, ifnum); chip->need_delayed_register = false;/* clear again */ } - err =try_to_register_card (chip, ifnum); -if (err <0 ) - goto __error_no_register; + ret =try_to_register_card (chip, ifnum); +if (ret <0 ) + goto err_no_register; -/* don't want to fail when snd_media_device_create() fails */ -snd_media_device_create (chip, intf); +/* Media device is optional, ignore error checks. */ +snd_media_device_create (chip, iface); -if (quirk) - chip->quirk_type = quirk->type; - - usb_chip[chip->index] = chip; - chip->intf[chip->num_interfaces] = intf; - chip->num_interfaces++; -usb_set_intfdata (intf, chip);atomic_dec (&chip->active); -mutex_unlock (®ister_mutex);return 0 ; - __error: -/* in the case of error in secondary interface, still try to register */ -if (chip) -try_to_register_card (chip, ifnum); +err_try_register: +/* In the case of error in secondary interface, still try to register. */ +try_to_register_card (chip, ifnum); - __error_no_register: -if (chip) { -/* chip->active is inside the chip->card object, -* decrement before memory is possibly returned. -*/ -atomic_dec (&chip->active); -if (!chip->num_interfaces) { -snd_card_free (chip->card); -snd_usb_chip_free (chip); - } - } -mutex_unlock (®ister_mutex); -return err; +err_no_register: +atomic_dec (&chip->active); +snd_usb_chip_release (chip, iface); +return ret; }/*
@@ -1445,15 +1261,8 @@ static void usb_audio_disconnect(struct usb_interface *intf)if (chip->quirk_flags &QUIRK_FLAG_DISABLE_AUTOSUSPEND )usb_enable_autosuspend (interface_to_usbdev (intf)); - chip->num_interfaces--; -if (chip->num_interfaces <=0 ) { - usb_chip[chip->index] =NULL ; -mutex_unlock (®ister_mutex); -snd_card_free (card); -snd_usb_chip_free (chip); - }else { -mutex_unlock (®ister_mutex); - } +snd_usb_chip_release (chip, intf); +mutex_unlock (®ister_mutex); }/* lock the shutdown (disconnect) task and autoresume */
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerRFC 8/15 ALSA: usb: Switch to the two-stage stream creation
In reply to Cezary RojewskiUtilize newly added functions and update existing stream craetion procedure for USB Audio-Class (AC) device from one-stage into two-stage process. In consequence, snd_usb_create_stream() and __snd_usb_add_audio_stream().
To complete the process, update snd_usb_create_streams() so that it performs correct operation: parse pcms -or- create non-pcms based on the SubClass value of the USB interface.
--- sound/usb/card.c | 119 ++++++++++----------------------------------- sound/usb/stream.c | 97 +----------------------------------- 2 files changed, 29 insertions(+), 187 deletions(-)
sound/usb/card.c +27 -92
@@ -138,87 +138,6 @@ static void snd_usb_stream_disconnect(struct snd_usb_stream *as) } } -static int snd_usb_create_stream (struct snd_usb_audio *chip,int ctrlif,int interface) -{ -struct usb_device *dev = chip->dev; -struct usb_host_interface *alts; -struct usb_interface_descriptor *altsd; -struct usb_interface *iface =usb_ifnum_to_if (dev, interface); - -if (!iface) { -dev_err (&dev->dev,"%u:%d : does not exist\n" , - ctrlif, interface); -return -EINVAL ; - } - - alts = &iface->altsetting[0 ]; - altsd =get_iface_desc (alts); - -/* -* Android with both accessory and audio interfaces enabled gets the -* interface numbers wrong. -*/ -if ((chip->usb_id ==USB_ID (0x18d1 ,0x2d04 ) || - chip->usb_id ==USB_ID (0x18d1 ,0x2d05 )) && - interface ==0 && - altsd->bInterfaceClass ==USB_CLASS_VENDOR_SPEC && - altsd->bInterfaceSubClass ==USB_SUBCLASS_VENDOR_SPEC ) { - interface =2 ; - iface =usb_ifnum_to_if (dev, interface); -if (!iface) -return -EINVAL ; - alts = &iface->altsetting[0 ]; - altsd =get_iface_desc (alts); - } - -if (usb_interface_claimed (iface)) { -dev_dbg (&dev->dev,"%d:%d: skipping, already claimed\n" , - ctrlif, interface); -return -EINVAL ; - } - -if ((altsd->bInterfaceClass ==USB_CLASS_AUDIO || - altsd->bInterfaceClass ==USB_CLASS_VENDOR_SPEC ) && - altsd->bInterfaceSubClass ==USB_SUBCLASS_MIDISTREAMING ) { -int err =snd_usb_midi_v2_create (chip, iface,NULL , - chip->usb_id); -if (err <0 ) { -dev_err (&dev->dev, -"%u:%d: cannot create sequencer device\n" , - ctrlif, interface); -return -EINVAL ; - } -return usb_driver_claim_interface (&usb_audio_driver, iface, -USB_AUDIO_IFACE_UNUSED ); - } - -if ((altsd->bInterfaceClass !=USB_CLASS_AUDIO && - altsd->bInterfaceClass !=USB_CLASS_VENDOR_SPEC ) || - altsd->bInterfaceSubClass !=USB_SUBCLASS_AUDIOSTREAMING ) { -dev_dbg (&dev->dev, -"%u:%d: skipping non-supported interface %d\n" , - ctrlif, interface, altsd->bInterfaceClass); -/* skip non-supported classes */ -return -EINVAL ; - } - -if (snd_usb_get_speed (dev) ==USB_SPEED_LOW ) { -dev_err (&dev->dev,"low speed audio streaming not supported\n" ); -return -EINVAL ; - } - -snd_usb_add_ctrl_interface_link (chip, interface, ctrlif); - -if (!snd_usb_parse_audio_interface (chip, interface)) { -usb_set_interface (dev, interface,0 );/* reset the current interface */ -return usb_driver_claim_interface (&usb_audio_driver, iface, -USB_AUDIO_IFACE_UNUSED ); - } - -return 0 ; -} - -__maybe_unused static struct usb_interface *snd_usb_streaming_iface (struct snd_usb_audio *chip,int ctrlif,int interface,u8 subclass) {
@@ -274,7 +193,6 @@ static struct usb_interface *snd_usb_streaming_iface(struct snd_usb_audio *chip,return NULL ; } -__maybe_unused static int snd_usb_parse_claim_pcm (struct snd_usb_audio *chip,int ctrlif,struct usb_interface *iface,struct usb_driver *iface_driver)
@@ -301,7 +219,6 @@ static int snd_usb_parse_claim_pcm(struct snd_usb_audio *chip, int ctrlif,return 0 ; } -__maybe_unused static int snd_usb_create_claim_midi (struct snd_usb_audio *chip,int ctrlif,struct usb_interface *iface,struct usb_driver *iface_driver)
@@ -325,18 +242,30 @@ static int snd_usb_create_claim_midi(struct snd_usb_audio *chip, int ctrlif,/* * parse audio control descriptor and create pcm/midi streams */ -static int snd_usb_create_streams (struct snd_usb_audio *chip,int ctrlif) +static int snd_usb_create_streams (struct snd_usb_audio *chip,int ctrlif, +struct usb_driver *iface_driver,u8 subclass) { +int (*create_stream)(struct snd_usb_audio *,int , +struct usb_interface *,struct usb_driver *);struct usb_device *dev = chip->dev;struct usb_host_interface *host_iface;struct usb_interface_descriptor *altsd; +struct usb_interface *iface;int i, protocol; +int ifnum;/* find audiocontrol interface */ host_iface = &usb_ifnum_to_if (dev, ctrlif)->altsetting[0 ]; altsd =get_iface_desc (host_iface); protocol = altsd->bInterfaceProtocol; +if (subclass ==USB_SUBCLASS_AUDIOSTREAMING ) + create_stream = snd_usb_parse_claim_pcm; +else if (subclass ==USB_SUBCLASS_MIDISTREAMING ) + create_stream = snd_usb_create_claim_midi; +else +return -EINVAL ; +switch (protocol) {default : dev_warn(&dev->dev,
@@ -385,8 +314,12 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)return -EINVAL ; } -for (i =0 ; i < h1->bInCollection; i++) -snd_usb_create_stream (chip, ctrlif, h1->baInterfaceNr[i]); +for (i =0 ; i < h1->bInCollection; i++) { + ifnum = h1->baInterfaceNr[i]; + iface =snd_usb_streaming_iface (chip, ctrlif, ifnum, subclass); +if (!IS_ERR_OR_NULL (iface)) +create_stream (chip, ctrlif, iface, iface_driver); + }break ; }
@@ -431,10 +364,12 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif) }for (i =0 ; i < assoc->bInterfaceCount; i++) { -int intf = assoc->bFirstInterface + i; - -if (intf != ctrlif) -snd_usb_create_stream (chip, ctrlif, intf); + ifnum = assoc->bFirstInterface + i; +if (ifnum == ctrlif) +continue ; + iface =snd_usb_streaming_iface (chip, ctrlif, ifnum, subclass); +if (!IS_ERR_OR_NULL (iface)) +create_stream (chip, ctrlif, iface, iface_driver); }break ;
@@ -784,7 +719,7 @@ static int snd_usb_parse_pcms(struct snd_usb_audio *chip, struct usb_interface * }/* Parse pcm interfaces in generic fashion. */ - ret =snd_usb_create_streams (chip, ifnum); + ret =snd_usb_create_streams (chip, ifnum, driver,USB_SUBCLASS_AUDIOSTREAMING );if (ret <0 )return ret;
@@ -813,7 +748,7 @@ static int snd_usb_create_nonpcms(struct snd_usb_audio *chip, struct usb_interfa }/* Create midi/mixer interfaces in generic fashion. */ - ret =snd_usb_create_streams (chip, ifnum); + ret =snd_usb_create_streams (chip, ifnum, driver,USB_SUBCLASS_MIDISTREAMING );if (ret <0 )return ret;
sound/usb/stream.c +2 -95
128 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerRFC 9/15 ALSA: usb: Switch to the two-stage quirk applying
In reply to Cezary RojewskiUtilize newly added functions and update existing apply-quirks procedure for USB Audio-Class (AC) device from one-stage into two-stage process. In consequence, drop create_uaxx_quirk() and create_autodetect_quirk() and update existing snd_usb_create_quirk() so that it only creates new streams, leaving the PCM parsing process to snd_usb_parse_pcms_quirk().
--- sound/usb/quirks.c | 42 ++---------------------------------------- 1 file changed, 2 insertions(+), 40 deletions(-)
sound/usb/quirks.c +2 -40
@@ -412,7 +412,6 @@ static int create_autodetect_pcm_quirk(struct snd_usb_audio *chip,return create_auto_pcm_quirk (chip, iface, driver); } -__maybe_unused static int create_autodetect_midi_quirk(struct snd_usb_audio *chip, struct usb_interface *iface, struct usb_driver *driver,
@@ -423,19 +422,6 @@ static int create_autodetect_midi_quirk(struct snd_usb_audio *chip,return 1 ; } -static int create_autodetect_quirk (struct snd_usb_audio *chip, -struct usb_interface *iface, -struct usb_driver *driver, -const struct snd_usb_audio_quirk *quirk) -{ -int err; - - err =create_auto_pcm_quirk (chip, iface, driver); -if (err == -ENODEV ) - err =create_auto_midi_quirk (chip, iface, driver); -return err; -} - static int create_uaxx_pcm_quirk(struct snd_usb_audio *chip, struct usb_interface *iface, struct usb_driver *driver,
@@ -556,30 +542,6 @@ static int create_uaxx_midi_quirk(struct snd_usb_audio *chip, &chip->num_rawmidis); } -static int create_uaxx_quirk (struct snd_usb_audio *chip, -struct usb_interface *iface, -struct usb_driver *driver, -const struct snd_usb_audio_quirk *quirk) -{ -struct usb_interface_descriptor *altsd; -struct usb_host_interface *alts; - -/* both PCM and MIDI interfaces have 2 or more altsettings */ -if (iface->num_altsetting <2 ) -return -ENXIO ; - alts = &iface->altsetting[1 ]; - altsd =get_iface_desc (alts); - -switch (altsd->bNumEndpoints) { -case 2 : -return create_uaxx_midi_quirk (chip, iface, driver, quirk); -case 1 : -return create_uaxx_pcm_quirk (chip, iface, driver, quirk); -default : -return -ENXIO ; - } -} -/* * Create a standard mixer for the specified interface. */
@@ -652,7 +614,7 @@ int snd_usb_create_quirk(struct snd_usb_audio *chip,static const quirk_func_t quirk_funcs[] = { [QUIRK_IGNORE_INTERFACE ] = ignore_interface_quirk, [QUIRK_COMPOSITE ] = create_composite_quirk, - [QUIRK_AUTODETECT ] = create_autodetect_quirk, + [QUIRK_AUTODETECT ] = create_autodetect_midi_quirk, [QUIRK_MIDI_STANDARD_INTERFACE ] = create_any_midi_quirk, [QUIRK_MIDI_FIXED_ENDPOINT ] = create_any_midi_quirk, [QUIRK_MIDI_YAMAHA ] = create_any_midi_quirk,
@@ -667,7 +629,7 @@ int snd_usb_create_quirk(struct snd_usb_audio *chip, [QUIRK_MIDI_CH345] = create_any_midi_quirk, [QUIRK_AUDIO_STANDARD_INTERFACE] = create_standard_audio_quirk, [QUIRK_AUDIO_FIXED_ENDPOINT] = create_fixed_stream_quirk, - [QUIRK_AUDIO_EDIROL_UAXX] = create_uaxx_quirk, + [QUIRK_AUDIO_EDIROL_UAXX] = create_uaxx_midi_quirk, [QUIRK_AUDIO_STANDARD_MIXER] = create_standard_mixer_quirk, };
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerRFC 10/15 ALSA: usb: Export PCM operations
In reply to Cezary RojewskiExisting PCM operations can be reused by DAIs on the ASoC side. Not all of them are exported as endpoints of the offloaded USB device are entirely controlled by the Audio Sideband and AudioDSP hardware. As ASoC occupies substream->private_data, update existing open() and close() to utilize runtime->private_data for obtaining USB stream instead.
Provide a wrapper for ASoC driver i.e.: snd_usb_pcm_open() as they are unaware of details of USB streams and do not access USB substreams directly.
--- include/sound/usb.h | 9 +++ sound/usb/pcm.c | 159 +++++++++++++++++++++++++++++++------------- 2 files changed, 120 insertions(+), 48 deletions(-)
include/sound/usb.h +9 -0
@@ -93,6 +93,15 @@ struct snd_usb_audio {int snd_usb_bind_card (struct snd_usb_audio *chip,struct snd_card *card,struct usb_driver *driver);int snd_usb_bind_pcm (struct list_head *stream_entry,struct snd_pcm *pcm); +void snd_usb_pcm_hw_init (struct list_head *stream_entry,int dir,struct snd_pcm_hardware *hw); + +/* PCM operations, see struct snd_pcm_ops. */ +int snd_usb_pcm_open (struct snd_pcm_substream *substream); +int snd_usb_pcm_close (struct snd_pcm_substream *substream); +int snd_usb_pcm_hw_params (struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *hw_params); +int snd_usb_pcm_hw_free (struct snd_pcm_substream *substream); +int snd_usb_pcm_prepare (struct snd_pcm_substream *substream);#define USB_AUDIO_IFACE_UNUSED ((void *)-1L)
sound/usb/pcm.c +111 -48
262 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerRFC 11/15 ALSA: usb: Export usb_interface driver operations
In reply to Cezary RojewskiExisting usb_driver operations can be reused by component-drivers on the ASoC side.
ASoC embraces modular approach and it is entirely acceptable for component to be unbound while the USB device is still plugged in. In such case, PCM list built when scanning USB interfaces can be kept intact to avoid scanning the device a second time when the component is probed again. Add snd_usb_release_resources() to cover that scenario.
--- include/sound/usb.h | 8 +++++ sound/usb/card.c | 88 +++++++++++++++++++++++++++++++++++++++------ 2 files changed, 85 insertions(+), 11 deletions(-)
include/sound/usb.h +8 -0
@@ -90,11 +90,19 @@ struct snd_usb_audio {struct snd_intf_to_ctrl intf_to_ctrl[MAX_CARD_INTERFACES ]; }; +void snd_usb_release_resources (struct snd_usb_audio *chip);int snd_usb_bind_card (struct snd_usb_audio *chip,struct snd_card *card,struct usb_driver *driver);int snd_usb_bind_pcm (struct list_head *stream_entry,struct snd_pcm *pcm);void snd_usb_pcm_hw_init (struct list_head *stream_entry,int dir,struct snd_pcm_hardware *hw); +/* USB interface operations, see struct usb_driver. */ +int snd_usb_probe (struct usb_interface *iface,const struct usb_device_id *usb_id, +struct usb_driver *driver); +void snd_usb_disconnect (struct usb_interface *iface); +int snd_usb_suspend (struct usb_interface *intf,pm_message_t message); +int snd_usb_resume (struct usb_interface *intf); +/* PCM operations, see struct snd_pcm_ops. */ int snd_usb_pcm_open (struct snd_pcm_substream *substream);int snd_usb_pcm_close (struct snd_pcm_substream *substream);
sound/usb/card.c +77 -11
156 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerRFC 12/15 ALSA: usb: Export card-naming procedure
In reply to Cezary RojewskiUSB sound card features customized naming procedure. For ALSA and ASoC drivers to share UseCaseManagement (UCM) configuration files, it is best if the naming is aligned between the two.
--- include/sound/usb.h | 1 + sound/usb/card.c | 78 ++++++++++++++++++++++----------------------- 2 files changed, 39 insertions(+), 40 deletions(-)
include/sound/usb.h +1 -0
@@ -91,6 +91,7 @@ struct snd_usb_audio { };void snd_usb_release_resources (struct snd_usb_audio *chip); +void snd_usb_make_card_names (struct snd_usb_audio *chip,char *shortname,char *longname);int snd_usb_bind_card (struct snd_usb_audio *chip,struct snd_card *card,struct usb_driver *driver);int snd_usb_bind_pcm (struct list_head *stream_entry,struct snd_pcm *pcm);
sound/usb/card.c +38 -40
149 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerRFC 13/15 ALSA: usb: Add getters to obtain endpoint information
In reply to Cezary RojewskiIntel's Audio Link Hub (ALH) requires information about the data and feedback endpoints to manage the offloaded PCM stream properly.
--- include/sound/usb.h | 4 ++++ sound/usb/card.h | 4 ++-- sound/usb/stream.c | 51 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-)
include/sound/usb.h +4 -0
@@ -96,6 +96,10 @@ int snd_usb_bind_card(struct snd_usb_audio *chip, struct snd_card *card, struct usb_driver *driver);int snd_usb_bind_pcm (struct list_head *stream_entry,struct snd_pcm *pcm);void snd_usb_pcm_hw_init (struct list_head *stream_entry,int dir,struct snd_pcm_hardware *hw); +void snd_usb_pcm_get_epaddr (struct list_head *stream_entry,int dir,u8 *data_epaddr, +u8 *fb_epaddr); +void snd_usb_pcm_get_epinfo (struct list_head *stream_entry,int dir,u16 *data_maxp,u16 *fb_maxp, +u8 *fb_syncinterval);/* USB interface operations, see struct usb_driver. */ int snd_usb_probe(struct usb_interface *iface, const struct usb_device_id *usb_id,
sound/usb/card.h +2 -2
@@ -21,10 +21,10 @@ struct audioformat {unsigned char ep_idx;/* endpoint array index */ unsigned char altset_idx;/* array index of alternate setting */ unsigned char attributes;/* corresponding attributes of cs endpoint */ -unsigned char endpoint;/* endpoint */ +unsigned char endpoint;/* bEndpointAddress of data endpoint */ unsigned char ep_attr;/* endpoint attributes */ bool implicit_fb;/* implicit feedback endpoint */ -unsigned char sync_ep;/* sync endpoint number */ +unsigned char sync_ep;/* bEndpointAddress of feedback endpoint */ unsigned char sync_iface;/* sync EP interface */ unsigned char sync_altsetting;/* sync EP alternate setting */ unsigned char sync_ep_idx;/* sync EP array index */
sound/usb/stream.c +51 -0
57 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerRFC 14/15 ASoC: codecs: Add USB-Audio driver
In reply to Cezary RojewskiSound card on the ASoC side is typically a marriage of two major
components: codec and platform. Platform usually covers DSP subject so the USB Audio-Class (AC) driver fits the codec role better.
The driver takes heavily from the 'classic' driver defined in sound/usb/card.c. The difference worth noting is lack of tolerance for quirks - given the limited number of Audio Link Hub (ALH) streams, only candidates (USB devices) we can be sure of have green light for offloading.
There are two important responsibilities of the driver on top of PCM/component operations:
- register platform device for machine-board driver to hook onto
- allocation and free of Audio Sideband resources and storing up-to-date information about USB endpoints engaged in the streaming.
The platform component can leverage the latter to configure their hardware accordingly to what is present on xHCI side.
--- include/sound/usb_offload.h | 46 ++++ sound/soc/codecs/Kconfig | 6 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/usb.c | 441 ++++++++++++++++++++++++++++++++++++ 4 files changed, 495 insertions(+) create mode 100644 include/sound/usb_offload.h create mode 100644 sound/soc/codecs/usb.c
include/sound/usb_offload.h new file +46 -0
@@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* USB Audio Offload(ed) stream information +* +* Copyright(c) 2025 Intel Corporation +*/ +#ifndef __SOUND_USB_OFFLOAD_H +#define __SOUND_USB_OFFLOAD_H + +#include <uapi/linux/usb/ch9.h> /* enum usb_device_speed */ + +/** +* struct uao_stream_info - USB Audio Offload stream information +* +* @bus_devid: Device ID of the owning xHCI controller, see pci_dev_id(). +* @slot_id: slot_id of the USB device. +* @tt: true if behind USB2.0 Transaction Translator (TT) +* @speed: USB_SPEED_XXX of the USB device. +* +* @data_epaddr: bEndpointAddress of the data endpoint. +* @data_audsb_res: Audio Sideband resource assigned by xHCI. +* @data_maxp: wMaxPacketSize of the data endpoint. +* @fb_epaddr: bEndpointAddress of the feedback endpoint. +* @fb_audsb_res: Audio Sideband resource assigned by xHCI. +* @fb_maxp: wMaxPacketSize of the feedback endpoint. +* @fb_interval: Synchornization interval of the feedback endpoint. +* +* If the owning xHCI controller is not a PCI device, @bus_devid is 0. +* If no feedback endpoint exists for a given stream, all fb_xxx are 0. +*/ +struct uao_stream_info { +u16 bus_devid; +u8 slot_id; +u8 tt; +enum usb_device_speed speed; + +u8 data_epaddr; +u8 data_audsb_res; +u16 data_maxp; +u8 fb_epaddr; +u8 fb_audsb_res; +u16 fb_maxp; +u8 fb_syncinterval; +}; + +#endif
sound/soc/codecs/Kconfig +6 -0
@@ -2177,6 +2177,12 @@ config SND_SOC_UDA1380 tristate depends on I2C +config SND_SOC_USB_CODEC + tristate "USB \"codec\" representative in ASoC" + depends on SND_USB_AUDIO + help + TODO + config SND_SOC_WCD_CLASSH tristate
sound/soc/codecs/Makefile +2 -0
@@ -331,6 +331,7 @@ snd-soc-twl6040-y := twl6040.o snd-soc-uda1334-y := uda1334.o snd-soc-uda1342-y := uda1342.o snd-soc-uda1380-y := uda1380.o +snd-soc-usb-codec-y := usb.o snd-soc-wcd-classh-y := wcd-clsh-v2.o snd-soc-wcd-mbhc-y := wcd-mbhc-v2.o snd-soc-wcd9335-y := wcd9335.o
@@ -746,6 +747,7 @@ obj-$(CONFIG_SND_SOC_TWL6040) += snd-soc-twl6040.o obj-$(CONFIG_SND_SOC_UDA1334) += snd-soc-uda1334.o obj-$(CONFIG_SND_SOC_UDA1342) += snd-soc-uda1342.o obj-$(CONFIG_SND_SOC_UDA1380) += snd-soc-uda1380.o +obj-$(CONFIG_SND_SOC_USB_CODEC) += snd-soc-usb-codec.o obj-$(CONFIG_SND_SOC_WCD_CLASSH) += snd-soc-wcd-classh.o obj-$(CONFIG_SND_SOC_WCD_MBHC) += snd-soc-wcd-mbhc.o obj-$(CONFIG_SND_SOC_WCD9335) += snd-soc-wcd9335.o
sound/soc/codecs/usb.c new file +441 -0
441 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerRFC 15/15 ASoC: Intel: avs: Add USB machine board
In reply to Cezary RojewskiProvide machine board driver that represents USB Audio sound card. The card connects ASoC USB codec driver with Intel AudioDSP avs-driver driver so that user can enjoy streaming over USB device without engaging their CPU - transfer is offloaded onto DSP instead.
--- sound/soc/intel/avs/boards/Kconfig | 8 ++ sound/soc/intel/avs/boards/Makefile | 2 + sound/soc/intel/avs/boards/usb.c | 115 ++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 sound/soc/intel/avs/boards/usb.c
sound/soc/intel/avs/boards/Kconfig +8 -0
@@ -244,4 +244,12 @@ config SND_SOC_INTEL_AVS_MACH_TDF8532 Say Y or m if you have such a device. This is a recommended option. If unsure select "N". +config SND_SOC_INTEL_AVS_MACH_USB + tristate "USB-Audio board" + depends on USB_XHCI_PCI || COMPILE_TEST + select SND_SOC_USB_CODEC + help + This allows Intel AVS driver to pair with xHCI Audio Sideband. + If unsure select "N". + endmenu
sound/soc/intel/avs/boards/Makefile +2 -0
@@ -24,6 +24,7 @@ snd-soc-avs-rt5663-y := rt5663.o snd-soc-avs-rt5682-y := rt5682.o snd-soc-avs-ssm4567-y := ssm4567.o snd-soc-avs-tdf8532-y := tdf8532.o +snd-soc-avs-usb-y := usb.o obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_DA7219) += snd-soc-avs-da7219.o obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_DMIC) += snd-soc-avs-dmic.o
@@ -49,3 +50,4 @@ obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_RT5663) += snd-soc-avs-rt5663.o obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_RT5682) += snd-soc-avs-rt5682.o obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_SSM4567) += snd-soc-avs-ssm4567.o obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_TDF8532) += snd-soc-avs-tdf8532.o +obj-$(CONFIG_SND_SOC_INTEL_AVS_MACH_USB) += snd-soc-avs-usb.o
sound/soc/intel/avs/boards/usb.c new file +115 -0
115 lines not on this page · raw message
Signature · 1 line
2.25.1
Greg KH
maintainerQuoted 8 lines · Cezary Rojewski
Note: this series is based on Mark's broonie/for-next. The xHCI dependency is missing so it won't compile. Goal of this RFC is discussing the direction of
sound/usbchanges.Note #2: Why exclude xHCI? Current form of
xhci-sideband.c[1] does not fare well with Intel's hardware design for USB Audio Offload feature. The production shape for usb/xHCI subjects is being discussed with Mathias. Once we're ready, I'll share the rest.
How is that going to work with the patches that add xhci offload that have already been reviewed on the list?
Quoted 5 lines
Note #3: this series does _NOT_ aim to block QCOM's equivalent series [2]. The team does acknowledge that we came the "table" late. At the same time, we're prepared to help QCOM switch to the presented
sound/usbapproach if that would benefit the framework and its users as a whole. Make it part of this very series if need be.
I don't understand, I'm just about to take the QCOM patches now. They have been on the list and reviewed for years now, why hasn't this work happened before now? Please work to make your changes on top of that patch series.
So what do you expect me to do here?
confused,
greg k-h
Cezary Rojewski
maintainerQuoted 19 lines · Greg KH
Quoted 8 lines · Cezary Rojewski
Note: this series is based on Mark's broonie/for-next. The xHCI dependency is missing so it won't compile. Goal of this RFC is discussing the direction of
sound/usbchanges.Note #2: Why exclude xHCI? Current form of
xhci-sideband.c[1] does not fare well with Intel's hardware design for USB Audio Offload feature. The production shape for usb/xHCI subjects is being discussed with Mathias. Once we're ready, I'll share the rest.How is that going to work with the patches that add xhci offload that have already been reviewed on the list?
Quoted 5 lines
Note #3: this series does _NOT_ aim to block QCOM's equivalent series [2]. The team does acknowledge that we came the "table" late. At the same time, we're prepared to help QCOM switch to the presented
sound/usbapproach if that would benefit the framework and its users as a whole. Make it part of this very series if need be.
Quoted 8 lines
I don't understand, I'm just about to take the QCOM patches now. They have been on the list and reviewed for years now, why hasn't this work happened before now? Please work to make your changes on top of that patch series.
So what do you expect me to do here?
confused,
Hi Greg,
I wanted the effort to be transparent, that's it. Given the size of the task, I've decided to get the feedback earlier. I believe asking sound-maintainers now for their take on sound/usb is better than coming here much later and shooting everything at once. If the proposed approach to sound/usb is not welcomed by the sound maintainers, obviously xhci-sideband additions that will arrive here later will be impacted two. In regard to the sound changes alone, there is no intention to blow up the parallel solution.
TLDR:
Work present here will be placed on top of the QCOM patches, no question about it. xhci-sideband.c will receive a number of changes to cope with Intel's design but nothing the list haven't seen before.
Kind regards,
Czarek
Quoted 41 lines · Cezary Rojewski
Quoted 19 lines · Greg KH
Quoted 8 lines · Cezary Rojewski
Note: this series is based on Mark's broonie/for-next. The xHCI dependency is missing so it won't compile. Goal of this RFC is discussing the direction of
sound/usbchanges.Note #2: Why exclude xHCI? Current form of
xhci-sideband.c[1] does not fare well with Intel's hardware design for USB Audio Offload feature. The production shape for usb/xHCI subjects is being discussed with Mathias. Once we're ready, I'll share the rest.How is that going to work with the patches that add xhci offload that have already been reviewed on the list?
Quoted 5 lines
Note #3: this series does _NOT_ aim to block QCOM's equivalent series [2]. The team does acknowledge that we came the "table" late. At the same time, we're prepared to help QCOM switch to the presented
sound/usbapproach if that would benefit the framework and its users as a whole. Make it part of this very series if need be.Quoted 8 lines
I don't understand, I'm just about to take the QCOM patches now. They have been on the list and reviewed for years now, why hasn't this work happened before now? Please work to make your changes on top of that patch series.
So what do you expect me to do here?
confused,
Hi Greg,
I wanted the effort to be transparent, that's it. Given the size of the task, I've decided to get the feedback earlier. I believe asking sound-maintainers now for their take on
sound/usbis better than coming here much later and shooting everything at once. If the proposed approach tosound/usbis not welcomed by the sound maintainers, obviously xhci-sideband additions that will arrive here later will be impacted two. In regard to the sound changes alone, there is no intention to blow up the parallel solution.
Quoted 4 lines
TLDR:
Work present here will be placed on top of the QCOM patches, no question about it.xhci-sideband.cwill receive a number of changes to cope with Intel's design but nothing the list haven't seen before.
Thanks for the patches, but they appeared obviously too late to the game. Qcom patches are close to the merge, and I'd love to make things proceeded finally after many years struggle at first.
The basic question, though again, is how the offloading is managed -- to which card or device is applied. The same question was applied to qcom implementation and their solution was to manage via the control API. The rest are rather opaque to users, and it allows us to even switch the complete implementation later to a different way like what you suggested, too. But it's only when the user-space will keep working as is.
Takashi
Quoted 40 lines · Cezary Rojewski
Note: this series is based on Mark's broonie/for-next. The xHCI dependency is missing so it won't compile. Goal of this RFC is discussing the direction of
sound/usbchanges.Note #2: Why exclude xHCI? Current form of
xhci-sideband.c[1] does not fare well with Intel's hardware design for USB Audio Offload feature. The production shape for usb/xHCI subjects is being discussed with Mathias. Once we're ready, I'll share the rest.Note #3: this series does _NOT_ aim to block QCOM's equivalent series [2]. The team does acknowledge that we came the "table" late. At the same time, we're prepared to help QCOM switch to the presented
sound/usbapproach if that would benefit the framework and its users as a whole. Make it part of this very series if need be.Apart from changes to
sound/usb, the patchset contains exemplary ASoC-based, offload-aware USB driver and a small sound card on the avs-driver side to show how card/dai_link initialization looks like.In short, USB Audio Offload functionality lowers CPU usage when streaming PCM over a USB Audio-Class device. It has been first introduced in xHCI 1.2 release and is described in section 7.9 [3]. Once hardware is prepared with
hw_params(), all the USB endpoints operations e.g.: start, stop, submitting URBs, are performed internally, by the hardware and AudioDSP firmware. Software driver shall not intervene.Startup flow from:
usb_pcm_open() usb_pcm_hw_params() snd_usb_endpoint_open() usb_pcm_prepare() usb_set_interface() snd_usb_endpoint_start() usb_pcm_trigger(cmd: START/STOP etc.)
Quoted 7 lines
reduced to:
usb_pcm_open() usb_pcm_hw_params() snd_usb_endpoint_open() usb_pcm_prepare() usb_set_interface()
Hmm, how can it be? The start of EP at prepare stage is done only conditionally for non-lowlatency or implicit-feedback mode, for example.
Quoted 38 lines
Handlers such as
ack(),sync_stop(),pointer(),delay()are not used here too. The AudioDSP driver will handlepointer(), rest isfirmware/hardwareresponsibility.There's a hefty number of limitations, most importantly:
1) typically 2 USB devices tops, rest go the classic (non-offload) path
2) AUDIOSTREAMING interfaces only, MIDI not. While not an interface type, Media (sound/usb/media) unsupported either
3) simple PCM,UAC_FORMAT_TYPE_I_PCMonlyCurrent patchset shows this in form of '
udev->audsb_capable' field. True if xHCI sideband reasource has been assigned to the device. The filtering is code is not part of the patchset.Important to highlight, 1) means both, offload-aware and offload-unaware drivers could be utilized simultaneously on the system in runtime. Opportunistically few devices would be controlled by the offload-aware driver, whereas everything else by the offload-unaware one. This differs from existing HDAudio Controller driver situation where either classic,
snd_hda_inteldriver takes complete control -or- the offload-awaresnd_soc_avsdriver.
In short, once all Audio Sideband resources are depleted, classicsound/usb/card.cdriver manages whatever comes next:
snd_usb_audio(offload un-aware,sound/usb/card.c)snd_soc_usb_codec(offload aware,sound/soc/codecs/usb.c)The design goals:
- make ASoC first class citizen ofsound/usb
- re-use code found insound/usb, mimic HDAudio integration in ASoC:
smallsound/soc/codecs/hda.cdriver leveraging power of entiresound/pci/hda/
- no shared control over a USB device, eithersnd_usb_audioor its ASoC equivalent takes control of the device
Quoted 6 lines
To do that, major tasks are identified:
a) On ASoC side 'struct
snd_card' is part of 'structsnd_soc_card' and is managed by the framework. Similar situation with 'structsnd_pcm' andrtd->pcm. To keep the teardown path sane, dropcard->private_free()andpcm->private_free()usage.
Well, this is a generic problem of ASoC framework.
I believe this should be better handled in ASoC core side at first. e.g. the card object could be created at the very first step of the snd_soc_card creation, too (but without the actual slot assignment or device creation).
Quoted 4 lines
b) To initialize ASoC components/DAI properly, PCM capabilities should be known up-front. To do that, existing USB card
probe()has to be split. From one-stage to two-stage process:
Quoted 8 lines
- look ahead and parse
usb_interfacedescriptors for PCM endpoints but do not create any PCMs (sound devices) yet
- create all PCMs based on obtained ->pcm_list and follow with MIDI/mixers/mediaSuch approach allows to feed DAIs proper data even when a valid sound-card pointer is not yet present - the initialization occurs before
snd_soc_bind_card()is called.
This one is another thing that is needed to adjust for ASoC framework. But when snd_card object is available, this can be resolved automatically, too? e.g. snd_pcm object or such can be created at that point. The actual device registration is done anyway later via snd_device_register() call.
thanks,
Takashi
Quoted 78 lines
Point a) is scaled for all three "domains" of
sound/usb: chip, stream and quirks. That's why there total of 6 commits doing that job. First implement, then switch. Everything that follows is, in my opinion, self-explanatory. No need to repeat commit messages.[1]: https://lore.kernel.org/all/[email protected]/
[2]: https://lore.kernel.org/all/[email protected]/
[3]: https://www.intel.com/content/dam/www/public/us/en/documents/technical-specifications/extensible-host-controler-interface-usb-xhci.pdfCezary Rojewski (15):
ALSA: usb: Move media-filters to the media code
ALSA: usb: Dropprivate_free()usage for card and pcms
ALSA: usb: Relocate the usbaudio header file
ALSA: usb: Implement two-stage quirk applying mechanism
ALSA: usb: Implement two-stage stream creation mechanism
ALSA: usb: Implement two-stage chip probing mechanism
ALSA: usb: Switch to the two-stage chip probing
ALSA: usb: Switch to the two-stage stream creation
ALSA: usb: Switch to the two-stage quirk applying
ALSA: usb: Export PCM operations
ALSA: usb: Exportusb_interfacedriver operations
ALSA: usb: Export card-naming procedure
ALSA: usb: Add getters to obtain endpoint information
ASoC: codecs: Add USB-Audio driver
ASoC: Intel: avs: Add USB machine boardinclude/linux/usb.h | 15 + include/linux/usb/ch9.h | 11 + sound/usb/usbaudio.h => include/sound/usb.h | 53 +- include/sound/usb_offload.h | 46 + sound/soc/codecs/Kconfig | 6 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/usb.c | 441 +++++++++ sound/soc/intel/avs/boards/Kconfig | 8 + sound/soc/intel/avs/boards/Makefile | 2 + sound/soc/intel/avs/boards/usb.c | 115 +++ sound/usb/caiaq/device.h | 2 +- sound/usb/card.c | 946 +++++++++++++------- sound/usb/card.h | 4 +- sound/usb/clock.c | 2 +- sound/usb/endpoint.c | 2 +- sound/usb/format.c | 2 +- sound/usb/helper.c | 2 +- sound/usb/implicit.c | 2 +- sound/usb/media.c | 8 +- sound/usb/midi.c | 2 +- sound/usb/midi.h | 2 + sound/usb/midi2.c | 2 +- sound/usb/midi2.h | 1 + sound/usb/misc/ua101.c | 2 +- sound/usb/mixer.c | 2 +- sound/usb/mixer_quirks.c | 2 +- sound/usb/mixer_s1810c.c | 2 +- sound/usb/mixer_scarlett.c | 2 +- sound/usb/mixer_scarlett2.c | 2 +- sound/usb/mixer_us16x08.c | 2 +- sound/usb/pcm.c | 161 +++- sound/usb/power.c | 2 +- sound/usb/proc.c | 2 +- sound/usb/quirks.c | 203 +++-- sound/usb/quirks.h | 6 + sound/usb/stream.c | 217 +++-- sound/usb/stream.h | 2 + sound/usb/usx2y/us122l.c | 2 +- sound/usb/usx2y/usX2Yhwdep.c | 1 + sound/usb/usx2y/usbusx2y.h | 2 +- sound/usb/validate.c | 2 +- 41 files changed, 1749 insertions(+), 541 deletions(-) rename sound/usb/usbaudio.h => include/sound/usb.h (82%) create mode 100644 include/sound/usb_offload.h create mode 100644 sound/soc/codecs/usb.c create mode 100644 sound/soc/intel/avs/boards/usb.cSignature · 1 line
2.25.1
Cezary Rojewski
maintainerQuoted 50 lines · Takashi Iwai
Quoted 40 lines · Cezary Rojewski
Note: this series is based on Mark's broonie/for-next. The xHCI dependency is missing so it won't compile. Goal of this RFC is discussing the direction of
sound/usbchanges.Note #2: Why exclude xHCI? Current form of
xhci-sideband.c[1] does not fare well with Intel's hardware design for USB Audio Offload feature. The production shape for usb/xHCI subjects is being discussed with Mathias. Once we're ready, I'll share the rest.Note #3: this series does _NOT_ aim to block QCOM's equivalent series [2]. The team does acknowledge that we came the "table" late. At the same time, we're prepared to help QCOM switch to the presented
sound/usbapproach if that would benefit the framework and its users as a whole. Make it part of this very series if need be.Apart from changes to
sound/usb, the patchset contains exemplary ASoC-based, offload-aware USB driver and a small sound card on the avs-driver side to show how card/dai_link initialization looks like.In short, USB Audio Offload functionality lowers CPU usage when streaming PCM over a USB Audio-Class device. It has been first introduced in xHCI 1.2 release and is described in section 7.9 [3]. Once hardware is prepared with
hw_params(), all the USB endpoints operations e.g.: start, stop, submitting URBs, are performed internally, by the hardware and AudioDSP firmware. Software driver shall not intervene.Startup flow from:
usb_pcm_open() usb_pcm_hw_params() snd_usb_endpoint_open() usb_pcm_prepare() usb_set_interface() snd_usb_endpoint_start() usb_pcm_trigger(cmd: START/STOP etc.)Quoted 7 lines
reduced to:
usb_pcm_open() usb_pcm_hw_params() snd_usb_endpoint_open() usb_pcm_prepare() usb_set_interface()
Quoted 3 lines
Hmm, how can it be? The start of EP at prepare stage is done only conditionally for non-lowlatency or implicit-feedback mode, for example.
On Intel architecture the AudioDSP utilizes internal channel to communicate with xHCI and perform all the transfer operations. In essence, once SET_INTERFACE TRB is done, the usb-driver is not supposed to do anything. The avs-driver (sound driver) would be the trigger here - sends the start/stop/etc. requests to the AudioDSP firmware, DSP does the rest.
By trigger I mean SET_PIPELINE_STATE IPC and avs_path_xxx() which are utilized for any transfer-type (sound/soc/intel/avs/pcm.c).
Quoted 45 lines
Quoted 38 lines
Handlers such as
ack(),sync_stop(),pointer(),delay()are not used here too. The AudioDSP driver will handlepointer(), rest isfirmware/hardwareresponsibility.There's a hefty number of limitations, most importantly:
1) typically 2 USB devices tops, rest go the classic (non-offload) path
2) AUDIOSTREAMING interfaces only, MIDI not. While not an interface type, Media (sound/usb/media) unsupported either
3) simple PCM,UAC_FORMAT_TYPE_I_PCMonlyCurrent patchset shows this in form of '
udev->audsb_capable' field. True if xHCI sideband reasource has been assigned to the device. The filtering is code is not part of the patchset.Important to highlight, 1) means both, offload-aware and offload-unaware drivers could be utilized simultaneously on the system in runtime. Opportunistically few devices would be controlled by the offload-aware driver, whereas everything else by the offload-unaware one. This differs from existing HDAudio Controller driver situation where either classic,
snd_hda_inteldriver takes complete control -or- the offload-awaresnd_soc_avsdriver.
In short, once all Audio Sideband resources are depleted, classicsound/usb/card.cdriver manages whatever comes next:
snd_usb_audio(offload un-aware,sound/usb/card.c)snd_soc_usb_codec(offload aware,sound/soc/codecs/usb.c)The design goals:
- make ASoC first class citizen ofsound/usb
- re-use code found insound/usb, mimic HDAudio integration in ASoC:
smallsound/soc/codecs/hda.cdriver leveraging power of entiresound/pci/hda/
- no shared control over a USB device, eithersnd_usb_audioor its ASoC equivalent takes control of the deviceQuoted 6 lines
To do that, major tasks are identified:
a) On ASoC side 'struct
snd_card' is part of 'structsnd_soc_card' and is managed by the framework. Similar situation with 'structsnd_pcm' andrtd->pcm. To keep the teardown path sane, dropcard->private_free()andpcm->private_free()usage.
Quoted 5 lines
Well, this is a generic problem of ASoC framework.
I believe this should be better handled in ASoC core side at first. e.g. the card object could be created at the very first step of thesnd_soc_cardcreation, too (but without the actual slot assignment or device creation).
Well, in my opinion the card's tailing private context (extra size), private_free() and all that comes with them in sound/core brings unnecessary complexity to the ALSA framework. devm_xxx() is enough. Polluting snd_card and sound/core/init.c with driver-specifics causes the teardown procedures on the ALSA framework side harder to read/maintain.
Quoted 13 lines
Quoted 4 lines
b) To initialize ASoC components/DAI properly, PCM capabilities should be known up-front. To do that, existing USB card
probe()has to be split. From one-stage to two-stage process:Quoted 8 lines
- look ahead and parse
usb_interfacedescriptors for PCM endpoints but do not create any PCMs (sound devices) yet
- create all PCMs based on obtained ->pcm_list and follow with MIDI/mixers/mediaSuch approach allows to feed DAIs proper data even when a valid sound-card pointer is not yet present - the initialization occurs before
snd_soc_bind_card()is called.
Quoted 5 lines
This one is another thing that is needed to adjust for ASoC framework. But when
snd_cardobject is available, this can be resolved automatically, too? e.g.snd_pcmobject or such can be created at that point. The actual device registration is done anyway later viasnd_device_register()call.
While I'm up for upgrading either framework in any area necessary to have proper UAO support in ASoC, not sure whether it's a good idea to make it a requirement for the feature. This will enlarge the series - well, guess it will be separate series (dependency) entirely.
Quoted 9 lines
Quoted 9 lines
Point a) is scaled for all three "domains" of
sound/usb: chip, stream and quirks. That's why there total of 6 commits doing that job. First implement, then switch. Everything that follows is, in my opinion, self-explanatory. No need to repeat commit messages.[1]: https://lore.kernel.org/all/[email protected]/
[2]: https://lore.kernel.org/all/[email protected]/
[3]: https://www.intel.com/content/dam/www/public/us/en/documents/technical-specifications/extensible-host-controler-interface-usb-xhci.pdf
Quoted 64 lines · Cezary Rojewski
Quoted 50 lines · Takashi Iwai
Quoted 40 lines · Cezary Rojewski
Note: this series is based on Mark's broonie/for-next. The xHCI dependency is missing so it won't compile. Goal of this RFC is discussing the direction of
sound/usbchanges.Note #2: Why exclude xHCI? Current form of
xhci-sideband.c[1] does not fare well with Intel's hardware design for USB Audio Offload feature. The production shape for usb/xHCI subjects is being discussed with Mathias. Once we're ready, I'll share the rest.Note #3: this series does _NOT_ aim to block QCOM's equivalent series [2]. The team does acknowledge that we came the "table" late. At the same time, we're prepared to help QCOM switch to the presented
sound/usbapproach if that would benefit the framework and its users as a whole. Make it part of this very series if need be.Apart from changes to
sound/usb, the patchset contains exemplary ASoC-based, offload-aware USB driver and a small sound card on the avs-driver side to show how card/dai_link initialization looks like.In short, USB Audio Offload functionality lowers CPU usage when streaming PCM over a USB Audio-Class device. It has been first introduced in xHCI 1.2 release and is described in section 7.9 [3]. Once hardware is prepared with
hw_params(), all the USB endpoints operations e.g.: start, stop, submitting URBs, are performed internally, by the hardware and AudioDSP firmware. Software driver shall not intervene.Startup flow from:
usb_pcm_open() usb_pcm_hw_params() snd_usb_endpoint_open() usb_pcm_prepare() usb_set_interface() snd_usb_endpoint_start() usb_pcm_trigger(cmd: START/STOP etc.)Quoted 7 lines
reduced to:
usb_pcm_open() usb_pcm_hw_params() snd_usb_endpoint_open() usb_pcm_prepare() usb_set_interface()Quoted 3 lines
Hmm, how can it be? The start of EP at prepare stage is done only conditionally for non-lowlatency or implicit-feedback mode, for example.
On Intel architecture the AudioDSP utilizes internal channel to communicate with xHCI and perform all the transfer operations. In essence, once
SET_INTERFACETRB is done, the usb-driver is not supposed to do anything. The avs-driver (sound driver) would be the trigger here - sends the start/stop/etc. requests to the AudioDSP firmware, DSP does the rest.
Quoted 2 lines
By trigger I mean
SET_PIPELINE_STATEIPC andavs_path_xxx()which are utilized for any transfer-type (sound/soc/intel/avs/pcm.c).
But does the DSP handles the different ways for the implicit feedback mode, the low-latency playback and else? A specific mode like the implicit feedback mode is mandatory for many devices. Similarly, the low-latency mode is essential for some application setups (e.g. pipewire or JACK prefers), while it's not always applicable depending on the PCM parameters (such as the free-wheeling mode).
AFAIK, the qcom offloading doesn't support those fully, hence the configuration must be dynamic for them.
Quoted 52 lines
Quoted 45 lines
Quoted 38 lines
Handlers such as
ack(),sync_stop(),pointer(),delay()are not used here too. The AudioDSP driver will handlepointer(), rest isfirmware/hardwareresponsibility.There's a hefty number of limitations, most importantly:
1) typically 2 USB devices tops, rest go the classic (non-offload) path
2) AUDIOSTREAMING interfaces only, MIDI not. While not an interface type, Media (sound/usb/media) unsupported either
3) simple PCM,UAC_FORMAT_TYPE_I_PCMonlyCurrent patchset shows this in form of '
udev->audsb_capable' field. True if xHCI sideband reasource has been assigned to the device. The filtering is code is not part of the patchset.Important to highlight, 1) means both, offload-aware and offload-unaware drivers could be utilized simultaneously on the system in runtime. Opportunistically few devices would be controlled by the offload-aware driver, whereas everything else by the offload-unaware one. This differs from existing HDAudio Controller driver situation where either classic,
snd_hda_inteldriver takes complete control -or- the offload-awaresnd_soc_avsdriver.
In short, once all Audio Sideband resources are depleted, classicsound/usb/card.cdriver manages whatever comes next:
snd_usb_audio(offload un-aware,sound/usb/card.c)snd_soc_usb_codec(offload aware,sound/soc/codecs/usb.c)The design goals:
- make ASoC first class citizen ofsound/usb
- re-use code found insound/usb, mimic HDAudio integration in ASoC:
smallsound/soc/codecs/hda.cdriver leveraging power of entiresound/pci/hda/
- no shared control over a USB device, eithersnd_usb_audioor its ASoC equivalent takes control of the deviceQuoted 6 lines
To do that, major tasks are identified:
a) On ASoC side 'struct
snd_card' is part of 'structsnd_soc_card' and is managed by the framework. Similar situation with 'structsnd_pcm' andrtd->pcm. To keep the teardown path sane, dropcard->private_free()andpcm->private_free()usage.Quoted 5 lines
Well, this is a generic problem of ASoC framework.
I believe this should be better handled in ASoC core side at first. e.g. the card object could be created at the very first step of thesnd_soc_cardcreation, too (but without the actual slot assignment or device creation).
Quoted 6 lines
Well, in my opinion the card's tailing private context (extra size),
private_free()and all that comes with them insound/corebrings unnecessary complexity to the ALSA framework.devm_xxx()is enough. Pollutingsnd_cardandsound/core/init.cwith driver-specifics causes the teardown procedures on the ALSA framework side harder to read/maintain.
Well, I'd say it depends, and pretty much a matter of taste. The resources managed by the card free should be the last thing that is tied with the card object itself. So, yes, it can be devm, but this wouldn't make things easier; the devm is merely a serialized release, after all.
Quoted 19 lines
Quoted 9 lines
Quoted 9 lines
b) To initialize ASoC components/DAI properly, PCM capabilities should be known up-front. To do that, existing USB card
probe()has to be split. From one-stage to two-stage process:- look ahead and parse
usb_interfacedescriptors for PCM endpoints but do not create any PCMs (sound devices) yet
- create all PCMs based on obtained ->pcm_list and follow with MIDI/mixers/mediaQuoted 8 lines
Quoted 3 lines
Such approach allows to feed DAIs proper data even when a valid sound-card pointer is not yet present - the initialization occurs before
snd_soc_bind_card()is called.This one is another thing that is needed to adjust for ASoC
framework. But whensnd_cardobject is available, this can be resolved automatically, too? e.g.snd_pcmobject or such can be created at that point. The actual device registration is done anyway later viasnd_device_register()call.
Quoted 4 lines
While I'm up for upgrading either framework in any area necessary to have proper UAO support in ASoC, not sure whether it's a good idea to make it a requirement for the feature. This will enlarge the series - well, guess it will be separate series (dependency) entirely.
The series contains lots of hackish API exposure, and I really would like to avoid that if possible. In the case of HD-audio, the whole stuff was moved to its own bus at first for adapting to ASoC hd-audio ext implementation, but for USB-audio, I don't see the need for that yet. And, if the concern is about the snd_card object lifecycle and ASoC binding, it can be improved in the lower level at first.
thanks,
Takashi
Cezary Rojewski
maintainerQuoted 6 lines · Takashi Iwai
Quoted 4 lines · Cezary Rojewski
Quoted 2 lines · Takashi Iwai
On Wed, 09 Apr 2025 13:07:15 +0200,
Cezary Rojewski wrote:
...
Quoted 52 lines
Quoted 42 lines
Quoted 30 lines
Quoted 22 lines
Apart from changes to
sound/usb, the patchset contains exemplary ASoC-based, offload-aware USB driver and a small sound card on the avs-driver side to show how card/dai_link initialization looks like.In short, USB Audio Offload functionality lowers CPU usage when streaming PCM over a USB Audio-Class device. It has been first introduced in xHCI 1.2 release and is described in section 7.9 [3]. Once hardware is prepared with
hw_params(), all the USB endpoints operations e.g.: start, stop, submitting URBs, are performed internally, by the hardware and AudioDSP firmware. Software driver shall not intervene.Startup flow from:
usb_pcm_open() usb_pcm_hw_params() snd_usb_endpoint_open() usb_pcm_prepare() usb_set_interface() snd_usb_endpoint_start() usb_pcm_trigger(cmd: START/STOP etc.)Quoted 7 lines
reduced to:
usb_pcm_open() usb_pcm_hw_params() snd_usb_endpoint_open() usb_pcm_prepare() usb_set_interface()Quoted 3 lines
Hmm, how can it be? The start of EP at prepare stage is done only conditionally for non-lowlatency or implicit-feedback mode, for example.
On Intel architecture the AudioDSP utilizes internal channel to communicate with xHCI and perform all the transfer operations. In essence, once
SET_INTERFACETRB is done, the usb-driver is not supposed to do anything. The avs-driver (sound driver) would be the trigger here - sends the start/stop/etc. requests to the AudioDSP firmware, DSP does the rest.Quoted 2 lines
By trigger I mean
SET_PIPELINE_STATEIPC andavs_path_xxx()which are utilized for any transfer-type (sound/soc/intel/avs/pcm.c).But does the DSP handles the different ways for the implicit feedback mode, the low-latency playback and else? A specific mode like the implicit feedback mode is mandatory for many devices. Similarly, the low-latency mode is essential for some application setups (e.g. pipewire or JACK prefers), while it's not always applicable depending on the PCM parameters (such as the free-wheeling mode).
Quoted 2 lines
AFAIK, the qcom offloading doesn't support those fully, hence the configuration must be dynamic for them.
The hw design is unfortunately not simple:
xHCI <> SIO <> ALH
^ USB side ^Audio DSP side
It's an internal channel between so-called Audio Sideband located on xHCI controller side, goes through Scalable-IO and links with Audio Link Hub that's acts as 'front-end' for DSP. Every block has their own requirements and restrictions.
And thus the number of available 'streams' in such configuration is very limited - typically to just 6. These are not even bi-direction streams but an internal map: IDs {1, 2} for outputs, IDs {3, 4, 5, 6} for inputs. Due to such small number of available streams, there is pressure to filter USB devices. In regard to endpoint types, only DATA and FEEDBACK are supported, IMPLICIT_FEEDBACK is not. Such device should fail offload-candidate filtering and be serviced by snd_usb_audio driver instead.
The official xHCI spec and its section regarding Audio Sideband is tailored for "claim entire device for offload or ignore" approach:
- scan the USB device descriptors
- verify if it's an offload-candidate
- count number of DATA + FEEDBACK endpoints
- ask xHCI to _reserve_ Audio Sideband resources up-front. This means the resources are reserved long before sound-devices are visible from userspace, yet alone opened for streaming
- pcm->open/close() just ask xHCI to perform SET_ASSIGNMENT(reserved_resources_here) TRBs to prepare/close the internal channel for runtime operations, that's it
There is no intention to allow for switching the ownership between offload-aware and offload-unaware. Either entire USB device and all its endpoints have Audio Sideband resources pre-allocated or no offload is present for the device at all.
...
Quoted 59 lines
Quoted 22 lines
Quoted 15 lines
Quoted 8 lines
The design goals:
- make ASoC first class citizen ofsound/usb
- re-use code found insound/usb, mimic HDAudio integration in ASoC:
smallsound/soc/codecs/hda.cdriver leveraging power of entiresound/pci/hda/
- no shared control over a USB device, eithersnd_usb_audioor its ASoC equivalent takes control of the deviceQuoted 6 lines
To do that, major tasks are identified:
a) On ASoC side 'struct
snd_card' is part of 'structsnd_soc_card' and is managed by the framework. Similar situation with 'structsnd_pcm' andrtd->pcm. To keep the teardown path sane, dropcard->private_free()andpcm->private_free()usage.Quoted 5 lines
Well, this is a generic problem of ASoC framework.
I believe this should be better handled in ASoC core side at first. e.g. the card object could be created at the very first step of thesnd_soc_cardcreation, too (but without the actual slot assignment or device creation).Quoted 6 lines
Well, in my opinion the card's tailing private context (extra size),
private_free()and all that comes with them insound/corebrings unnecessary complexity to the ALSA framework.devm_xxx()is enough. Pollutingsnd_cardandsound/core/init.cwith driver-specifics causes the teardown procedures on the ALSA framework side harder to read/maintain.Well, I'd say it depends, and pretty much a matter of taste. The resources managed by the card free should be the last thing that is tied with the card object itself. So, yes, it can be devm, but this wouldn't make things easier; the devm is merely a serialized release, after all.
Quoted 19 lines
Quoted 9 lines
Quoted 9 lines
b) To initialize ASoC components/DAI properly, PCM capabilities should be known up-front. To do that, existing USB card
probe()has to be split. From one-stage to two-stage process:- look ahead and parse
usb_interfacedescriptors for PCM endpoints but do not create any PCMs (sound devices) yet
- create all PCMs based on obtained ->pcm_list and follow with MIDI/mixers/mediaQuoted 8 lines
Quoted 3 lines
Such approach allows to feed DAIs proper data even when a valid sound-card pointer is not yet present - the initialization occurs before
snd_soc_bind_card()is called.This one is another thing that is needed to adjust for ASoC
framework. But whensnd_cardobject is available, this can be resolved automatically, too? e.g.snd_pcmobject or such can be created at that point. The actual device registration is done anyway later viasnd_device_register()call.Quoted 4 lines
While I'm up for upgrading either framework in any area necessary to have proper UAO support in ASoC, not sure whether it's a good idea to make it a requirement for the feature. This will enlarge the series - well, guess it will be separate series (dependency) entirely.
Quoted 6 lines
The series contains lots of hackish API exposure, and I really would like to avoid that if possible. In the case of HD-audio, the whole stuff was moved to its own bus at first for adapting to ASoC hd-audio ext implementation, but for USB-audio, I don't see the need for that yet. And, if the concern is about the
snd_cardobject lifecycle and ASoC binding, it can be improved in the lower level at first.
I tried hard to avoid hackish stuff, perhaps not hard enough :) Would it be possible to list the areas which you believe need to be look at? This is frankly the feedback which I'm most interested in. Mathias gave me a number of these, e.g.: do not access udev->slot_id in sound/, avoid manipulating hcd/controller in sound/ and such.
In regard to the HDAudio point, I see clear benefits by having HDAudio and USB aligned in the approach on ASoC side. It's a path that's known, works and is well tested.
In regard to the snd_soc_card vs snd_card, in my opinion the refactor of card initialization is a large task. In the past I did similar change for the snd_soc_component [1] but the card is an entirely different beast. That's why I'm suggesting incremental approach - update ASoC initialization as a next step.
[1]: https://lore.kernel.org/all/[email protected]/
Kind regards,
Czarek
Pierre-Louis Bossart
reviewerQuoted 2 lines
In regard to the HDAudio point, I see clear benefits by having HDAudio and USB aligned in the approach on ASoC side. It's a path that's known, works and is well tested.
The current direction for HDaudio is to have the DSP handle ALL streams with DSP-enabled drivers (or none with snd-hda-intel).
But for USB we absolutely need the ability to bypass the DSP when the resources are exceeded (too many endpoints, too many channels, etc), or when low-latency is required (lowering CPU utilization comes at the expense of latency).
In other words, the USB solution MUST expose two PCM paths, a legacy one and a DSP-one, and a sideband communication between DSP and legacy drivers to manage resources.
HDAudio has none of those concepts, which makes it hard to see what the suggested alignment is?
Cezary Rojewski
maintainerQuoted 10 lines · Pierre-Louis Bossart
Quoted 2 lines
In regard to the HDAudio point, I see clear benefits by having HDAudio and USB aligned in the approach on ASoC side. It's a path that's known, works and is well tested.
The current direction for HDaudio is to have the DSP handle ALL streams with DSP-enabled drivers (or none with snd-hda-intel).
But for USB we absolutely need the ability to bypass the DSP when the resources are exceeded (too many endpoints, too many channels, etc), or when low-latency is required (lowering CPU utilization comes at the expense of latency).
In other words, the USB solution MUST expose two PCM paths, a legacy one and a DSP-one, and a sideband communication between DSP and legacy drivers to manage resources.
HDAudio has none of those concepts, which makes it hard to see what the suggested alignment is?
Hi Pierre,
I see your point but the spec describes the exact opposite. The intention is to follow the Intel's software architecture specification for USB Audio Offload Link (UAOL). The high-level steps provided in previous replies align with the recommendations of the spec. The reservation of Audio Sideband resources and negotiation of audio format are part of that. There is no intention to offload every single USB device and the device is to be claimed for offload entirely or fallback to the classic, offload-unaware driver.
That design (UAOL) is known, well tested and proven on the market. It shares a number of logical flows with the HDAudio case and thus having similar programming on the software side both makes the code easier to understand and aligns with the spec's recommendations.
Kind regards,
Czarek
Pierre-Louis Bossart
reviewerQuoted 9 lines
Quoted 9 lines
Quoted 2 lines
In regard to the HDAudio point, I see clear benefits by having HDAudio and USB aligned in the approach on ASoC side. It's a path that's known, works and is well tested.
The current direction for HDaudio is to have the DSP handle ALL streams with DSP-enabled drivers (or none with snd-hda-intel).
But for USB we absolutely need the ability to bypass the DSP when the resources are exceeded (too many endpoints, too many channels, etc), or when low-latency is required (lowering CPU utilization comes at the expense of latency).
In other words, the USB solution MUST expose two PCM paths, a legacy one and a DSP-one, and a sideband communication between DSP and legacy drivers to manage resources.
Quoted 8 lines
Quoted 1 line
HDAudio has none of those concepts, which makes it hard to see what the suggested alignment is?
Hi Pierre,
I see your point but the spec describes the exact opposite. The intention is to follow the Intel's software architecture specification for USB Audio Offload Link (UAOL). The high-level steps provided in previous replies align with the recommendations of the spec. The reservation of Audio Sideband resources and negotiation of audio format are part of that. There is no intention to offload every single USB device and the device is to be claimed for offload entirely or fallback to the classic, offload-unaware driver.
That design (UAOL) is known, well tested and proven on the market. It shares a number of logical flows with the HDAudio case and thus having similar programming on the software side both makes the code easier to understand and aligns with the spec's recommendations.
I don't know what specification you are referring to... We've consistently agreed with others that the use of the offload capability was a run-time decision left as an exercise for the application. The low-level details of the UAOL flows and IPC should not define how USB is used, they are a 'detail' that should be well compartmentalized in Intel-specific host configurations.
The main argument I would have to keep the legacy non-offload solution always available is that USB is the only solution for users if for some reason their DSP-based solution is not supported (missing or incomplete machine driver, missing firmware, etc). Forcing users to rely on offload is not a good direction, it has to opt-in for Linux distributions.
I should also point out that one key requirement is that the DSP-based solution does not degrade the quality with any asynchronous sample-rate converter, which requires firmware to be able to avoid working with the 1ms tick but instead adjust the amount of data processed per tick, specifically in the case of endpoints with feedback. If the firmware does resample with a TBD filter, then the performance of that TBD filter should be clearly documented. We had similar discussions in the past with MP3 offload, the expectation is that offload only improves power consumption but does not result in any quality shortcuts taken.
Greg KH
maintainerQuoted 3 lines · Cezary Rojewski
Note: this series is based on Mark's broonie/for-next. The xHCI dependency is missing so it won't compile. Goal of this RFC is discussing the direction of
sound/usbchanges.
Any specific reason you aren't cc: [email protected] on USB stuff like this?
thanks,
greg k-h
Cezary Rojewski
maintainerQuoted 7 lines · Greg KH
Quoted 3 lines · Cezary Rojewski
Note: this series is based on Mark's broonie/for-next. The xHCI dependency is missing so it won't compile. Goal of this RFC is discussing the direction of
sound/usbchanges.Any specific reason you aren't cc: [email protected] on USB stuff like this?
Actually I was expecting the exact opposite feedback had I included linux-usb, given lack of drivers/usb changes. Lesson learned.
However, given the current feedback, for the next revision I plan to rebase onto your tree and include the xHCI changes. While I'm familiar with sound/ practices, I clearly was not with drivers/usb/ ones. The initial offload-aware vs offload-unaware USB audio-device filtering stuff was done by xHCI. Thanks to Mathias now I'm aware there is no place for such specific class code in drivers/usb/host.
I'll try to get the usb changes adjusted as quickly as possible so that the list can see the entire thing.
Kind regards,
Czarek