summaryrefslogtreecommitdiff
path: root/sound/usb
diff options
context:
space:
mode:
authorWesley Cheng <quic_wcheng@quicinc.com>2025-04-09 12:47:46 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-04-11 13:02:31 +0200
commit722f79117ee886c4c1ef08f443a1fdfd5433747f (patch)
tree863cf76d2ae17bcf42cd923b1bc99db3c2a9c788 /sound/usb
parent74914dc1ea268a58be7112f14d8b3568866e40e8 (diff)
ALSA: usb-audio: Allow for rediscovery of connected USB SND devices
In case of notifying SND platform drivers of connection events, some of these use cases, such as offloading, require an ASoC USB backend device to be initialized before the events can be handled. If the USB backend device has not yet been probed, this leads to missing initial USB audio device connection events. Expose an API that traverses the usb_chip array for connected devices, and to call the respective connection callback registered to the SND platform driver. Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com> Acked-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20250409194804.3773260-14-quic_wcheng@quicinc.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'sound/usb')
-rw-r--r--sound/usb/card.c21
-rw-r--r--sound/usb/card.h2
2 files changed, 23 insertions, 0 deletions
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 4ac7f2b8309a..9fb8726a6c93 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -156,6 +156,27 @@ int snd_usb_unregister_platform_ops(void)
EXPORT_SYMBOL_GPL(snd_usb_unregister_platform_ops);
/*
+ * in case the platform driver was not ready at the time of USB SND
+ * device connect, expose an API to discover all connected USB devices
+ * so it can populate any dependent resources/structures.
+ */
+void snd_usb_rediscover_devices(void)
+{
+ int i;
+
+ guard(mutex)(&register_mutex);
+
+ if (!platform_ops || !platform_ops->connect_cb)
+ return;
+
+ for (i = 0; i < SNDRV_CARDS; i++) {
+ if (usb_chip[i])
+ platform_ops->connect_cb(usb_chip[i]);
+ }
+}
+EXPORT_SYMBOL_GPL(snd_usb_rediscover_devices);
+
+/*
* 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.
diff --git a/sound/usb/card.h b/sound/usb/card.h
index d8b8522e1613..94404c24d240 100644
--- a/sound/usb/card.h
+++ b/sound/usb/card.h
@@ -222,4 +222,6 @@ snd_usb_find_suppported_substream(int card_idx, struct snd_pcm_hw_params *params
int snd_usb_register_platform_ops(struct snd_usb_platform_ops *ops);
int snd_usb_unregister_platform_ops(void);
+
+void snd_usb_rediscover_devices(void);
#endif /* __USBAUDIO_CARD_H */