FROMGIT: 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 <pierre-louis.bossart@linux.intel.com> Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com> Acked-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20250409194804.3773260-10-quic_wcheng@quicinc.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Bug: 392112015 (cherry picked from commit 2bde439265e24ee2086ba6573458c6bdc43d6364 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next) Change-Id: Iada94d1a7bbc316bc69bd19c9fa6f5c123f7ccd1 Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
This commit is contained in:
committed by
Carlos Llamas
parent
5886d35219
commit
40fea4faf2
@@ -119,6 +119,38 @@ static DEFINE_MUTEX(register_mutex);
|
||||
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()
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user