Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Wesley Cheng and committed by
Greg Kroah-Hartman
722f7911 74914dc1

+23
+21
sound/usb/card.c
··· 156 156 EXPORT_SYMBOL_GPL(snd_usb_unregister_platform_ops); 157 157 158 158 /* 159 + * in case the platform driver was not ready at the time of USB SND 160 + * device connect, expose an API to discover all connected USB devices 161 + * so it can populate any dependent resources/structures. 162 + */ 163 + void snd_usb_rediscover_devices(void) 164 + { 165 + int i; 166 + 167 + guard(mutex)(&register_mutex); 168 + 169 + if (!platform_ops || !platform_ops->connect_cb) 170 + return; 171 + 172 + for (i = 0; i < SNDRV_CARDS; i++) { 173 + if (usb_chip[i]) 174 + platform_ops->connect_cb(usb_chip[i]); 175 + } 176 + } 177 + EXPORT_SYMBOL_GPL(snd_usb_rediscover_devices); 178 + 179 + /* 159 180 * Checks to see if requested audio profile, i.e sample rate, # of 160 181 * channels, etc... is supported by the substream associated to the 161 182 * USB audio device.
+2
sound/usb/card.h
··· 222 222 223 223 int snd_usb_register_platform_ops(struct snd_usb_platform_ops *ops); 224 224 int snd_usb_unregister_platform_ops(void); 225 + 226 + void snd_usb_rediscover_devices(void); 225 227 #endif /* __USBAUDIO_CARD_H */