Skip to content

Commit b70038e

Browse files
committed
ALSA: usb-audio: Add delayed_register option
Add a new option for specifying the quirk for delayed registration of the certain device. A list of devices can be passed in a form ID:IFACE,ID:IFACE,ID:IFACE,.... where ID is the 32bit hex number combo of vendor and device IDs and IFACE is the interface number to trigger the register. When a matching device is probed, the card registration is delayed until the given interface is probed. It's needed for syncing the registration until the last interface when multiple interfaces are provided for the same card. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent d8695bc commit b70038e

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

sound/usb/card.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ static int device_setup[SNDRV_CARDS]; /* device parameter for this card */
7272
static bool ignore_ctl_error;
7373
static bool autoclock = true;
7474
static char *quirk_alias[SNDRV_CARDS];
75+
static char *delayed_register[SNDRV_CARDS];
7576

7677
bool snd_usb_use_vmalloc = true;
7778
bool snd_usb_skip_validation;
@@ -95,6 +96,8 @@ module_param(autoclock, bool, 0444);
9596
MODULE_PARM_DESC(autoclock, "Enable auto-clock selection for UAC2 devices (default: yes).");
9697
module_param_array(quirk_alias, charp, NULL, 0444);
9798
MODULE_PARM_DESC(quirk_alias, "Quirk aliases, e.g. 0123abcd:5678beef.");
99+
module_param_array(delayed_register, charp, NULL, 0444);
100+
MODULE_PARM_DESC(delayed_register, "Quirk for delayed registration, given by id:iface, e.g. 0123abcd:4.");
98101
module_param_named(use_vmalloc, snd_usb_use_vmalloc, bool, 0444);
99102
MODULE_PARM_DESC(use_vmalloc, "Use vmalloc for PCM intermediate buffers (default: yes).");
100103
module_param_named(skip_validation, snd_usb_skip_validation, bool, 0444);
@@ -525,6 +528,21 @@ static bool get_alias_id(struct usb_device *dev, unsigned int *id)
525528
return false;
526529
}
527530

531+
static bool check_delayed_register_option(struct snd_usb_audio *chip, int iface)
532+
{
533+
int i;
534+
unsigned int id, inum;
535+
536+
for (i = 0; i < ARRAY_SIZE(delayed_register); i++) {
537+
if (delayed_register[i] &&
538+
sscanf(delayed_register[i], "%x:%x", &id, &inum) == 2 &&
539+
id == chip->usb_id)
540+
return inum != iface;
541+
}
542+
543+
return false;
544+
}
545+
528546
static const struct usb_device_id usb_audio_ids[]; /* defined below */
529547

530548
/* look for the corresponding quirk */
@@ -665,7 +683,8 @@ static int usb_audio_probe(struct usb_interface *intf,
665683
/* we are allowed to call snd_card_register() many times, but first
666684
* check to see if a device needs to skip it or do anything special
667685
*/
668-
if (!snd_usb_registration_quirk(chip, ifnum)) {
686+
if (!snd_usb_registration_quirk(chip, ifnum) &&
687+
!check_delayed_register_option(chip, ifnum)) {
669688
err = snd_card_register(chip->card);
670689
if (err < 0)
671690
goto __error;

0 commit comments

Comments
 (0)