ALSA: usb-audio: Inform the delayed registration more properly
PATCH 1/2 ALSA: usb-audio: Inform the delayed registration more properly
The info message that was added in the commit a4aad5636c72 ("ALSA:
usb-audio: Inform devices that need delayed registration") is actually useful to know the need for the delayed registration. However, it turned out that this doesn't catch the all cases; namely, this warned only when a PCM stream is attached onto the existing PCM instance, but it doesn't count for a newly created PCM instance. This made confusion as if there were no further delayed registration.
This patch moves the check to the code path for either adding a stream or creating a PCM instance. Also, make it simpler by checking the card->registered flag instead of querying each snd_device state.
--- sound/usb/stream.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
sound/usb/stream.c +4 -3
@@ -495,6 +495,10 @@ static int __snd_usb_add_audio_stream(struct snd_usb_audio *chip,return 0 ; } } + +if (chip->card->registered) + chip->need_delayed_register = true; +/* look for an empty stream */ list_for_each_entry (as, &chip->pcm_list, list) {if (as->fmt_type != fp->fmt_type)
@@ -502,9 +506,6 @@ static int __snd_usb_add_audio_stream(struct snd_usb_audio *chip, subs = &as->substream[stream];if (subs->ep_num)continue ; -if (snd_device_get_state (chip->card, as->pcm) != -SNDRV_DEV_BUILD ) - chip->need_delayed_register = true; err =snd_pcm_new_stream (as->pcm, stream,1 );if (err <0 )return err;
Signature · 1 line
2.35.3
PATCH 2/2 ALSA: usb-audio: Register card again for iface over delayed_register option
When the delayed registration is specified via either delayed_register option or the quirk, we delay the invocation of snd_card_register() until the given interface. But if a wrong value has been set there and there are more interfaces over the given interface number, snd_card_register() call would be missing for those interfaces.
This patch catches up those missing calls by fixing the comparison of the interface number. Now the call is skipped only if the processed interface is less than the given interface, instead of the exact match.
--- sound/usb/card.c | 2 +- sound/usb/quirks.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
sound/usb/card.c +1 -1
@@ -699,7 +699,7 @@ static bool check_delayed_register_option(struct snd_usb_audio *chip, int iface)if (delayed_register[i] &&sscanf (delayed_register[i],"%x:%x" , &id, &inum) ==2 && id == chip->usb_id) -return inum != iface; +return iface < inum; }return false;
sound/usb/quirks.c +1 -1
@@ -1764,7 +1764,7 @@ bool snd_usb_registration_quirk(struct snd_usb_audio *chip, int iface)for (q = registration_quirks; q->usb_id; q++)if (chip->usb_id == q->usb_id) -return iface != q->interface; +return iface < q->interface;/* Register as normal */ return false;
Signature · 1 line
2.35.3