Skip to content

Commit a4aad56

Browse files
committed
ALSA: usb-audio: Inform devices that need delayed registration
The USB-audio driver may call snd_card_register() multiple times as its probe function is per USB interface while some USB-audio devices may provide multiple interfaces to assign different streams although they belong to the same device. This works in most cases but the registration is racy, hence it may miss the device recognition, e.g. PA doesn't see certain devices when hotplugged. The recent addition of the delayed registration quirk allows to sync the registration at the last known interface, and the previous commit added a new module option to allow the dynamic setup for that purpose. Now, this patch tries to find out and notifies for such devices that require the delayed registration. It shows a message like: Found post-registration device assignment: 1234abcd:02 If you hit this message, you can pass delayed_register module option like: snd_usb_audio.delayed_register=1234abcd:02 by just copying the last shown entry. If this works, it can be added statically in the quirk list, registration_quirks[] found at the end of sound/usb/quirks.c. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent b70038e commit a4aad56

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

sound/usb/card.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,13 @@ static int usb_audio_probe(struct usb_interface *intf,
680680
goto __error;
681681
}
682682

683+
if (chip->need_delayed_register) {
684+
dev_info(&dev->dev,
685+
"Found post-registration device assignment: %08x:%02x\n",
686+
chip->usb_id, ifnum);
687+
chip->need_delayed_register = false; /* clear again */
688+
}
689+
683690
/* we are allowed to call snd_card_register() many times, but first
684691
* check to see if a device needs to skip it or do anything special
685692
*/

sound/usb/stream.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,9 @@ static int __snd_usb_add_audio_stream(struct snd_usb_audio *chip,
502502
subs = &as->substream[stream];
503503
if (subs->ep_num)
504504
continue;
505+
if (snd_device_get_state(chip->card, as->pcm) !=
506+
SNDRV_DEV_BUILD)
507+
chip->need_delayed_register = true;
505508
err = snd_pcm_new_stream(as->pcm, stream, 1);
506509
if (err < 0)
507510
return err;

sound/usb/usbaudio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ struct snd_usb_audio {
3434
unsigned int txfr_quirk:1; /* Subframe boundaries on transfers */
3535
unsigned int tx_length_quirk:1; /* Put length specifier in transfers */
3636
unsigned int setup_fmt_after_resume_quirk:1; /* setup the format to interface after resume */
37+
unsigned int need_delayed_register:1; /* warn for delayed registration */
3738
int num_interfaces;
3839
int num_suspended_intf;
3940
int sample_rate_read_error;

0 commit comments

Comments
 (0)