diff options
| author | Wesley Cheng <[email protected]> | 2025-04-09 19:47:42 +0000 |
|---|---|---|
| committer | Greg Kroah-Hartman <[email protected]> | 2025-04-11 11:02:30 +0000 |
| commit | 2bde439265e24ee2086ba6573458c6bdc43d6364 (patch) | |
| tree | cd44189bbc838abfe1b4ef24c901a8fe4a579de9 | |
| parent | ALSA: usb-audio: Export USB SND APIs for modules (diff) | |
| download | kernel-2bde439265e24ee2086ba6573458c6bdc43d6364.tar.gz kernel-2bde439265e24ee2086ba6573458c6bdc43d6364.zip | |
ALSA: usb-audio: Check for support for requested audio format
Allow for checks on a specific USB audio device to see if a requested PCM
format is supported. This is needed for support when playback is
initiated by the ASoC USB backend path.
Reviewed-by: Pierre-Louis Bossart <[email protected]>
Signed-off-by: Wesley Cheng <[email protected]>
Acked-by: Mark Brown <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
| -rw-r--r-- | sound/usb/card.c | 32 | ||||
| -rw-r--r-- | sound/usb/card.h | 3 |
2 files changed, 35 insertions, 0 deletions
diff --git a/sound/usb/card.c b/sound/usb/card.c index a0087bde684c..6c5b0e02e57b 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -120,6 +120,38 @@ static struct snd_usb_audio *usb_chip[SNDRV_CARDS]; static struct usb_driver usb_audio_driver; /* + * Checks to see if requested audio profile, i.e sample rate, # of + * channels, etc... is supported by the substream associated to the + * USB audio device. + */ +struct snd_usb_stream * +snd_usb_find_suppported_substream(int card_idx, struct snd_pcm_hw_params *params, + int direction) +{ + struct snd_usb_audio *chip; + struct snd_usb_substream *subs; + struct snd_usb_stream *as; + + /* + * Register mutex is held when populating and clearing usb_chip + * array. + */ + guard(mutex)(®ister_mutex); + chip = usb_chip[card_idx]; + + if (chip && enable[card_idx]) { + list_for_each_entry(as, &chip->pcm_list, list) { + subs = &as->substream[direction]; + if (snd_usb_find_substream_format(subs, params)) + return as; + } + } + + return NULL; +} +EXPORT_SYMBOL_GPL(snd_usb_find_suppported_substream); + +/* * disconnect streams * called from usb_audio_disconnect() */ diff --git a/sound/usb/card.h b/sound/usb/card.h index 6ec95b2edf86..4f4f3f39b7fa 100644 --- a/sound/usb/card.h +++ b/sound/usb/card.h @@ -207,4 +207,7 @@ struct snd_usb_stream { struct list_head list; }; +struct snd_usb_stream * +snd_usb_find_suppported_substream(int card_idx, struct snd_pcm_hw_params *params, + int direction); #endif /* __USBAUDIO_CARD_H */ |
