[alsa-devel] [PATCH 2/2] ALSA: hdspm - Provide unique driver id based on card serial

Takashi Iwai tiwai at suse.de
Wed Jan 11 09:09:51 CET 2012

At Tue, 10 Jan 2012 20:53:23 +0100,
Adrian Knoth wrote:
> > Also, if multiple boards have the same serial number (who can trust
> > the hardware? :), it gets -EBUSY at registration.
> Is that true? I don't have two RME cards here, but I've simply
> duplicated a string from my mainboard chip. snd_card_register() was just
> fine:
> $ cat /proc/asound/cards
>   0 [PCH            ]: HDA-Intel - HDA Intel PCH
>                        HDA Intel PCH at 0xf7420000 irq 55
>   1 [NVidia         ]: HDA-Intel - HDA NVidia
>                        HDA NVidia at 0xf7080000 irq 17
>   2 [PCH            ]: HDSPM - RME RayDAT_f1cd85
>                        RME RayDAT S/N 0xf1cd85 at 0xf7300000, irq 18
> Note that snd_card_create() is still called without any serial number
> magic, so card->id will first be set to "Default", "Default_1" and so on
> and only later modified before calling snd_card_register().

These strings are set in snd_card_register().  At the point of
snd_card_create(), the string should be still empty.

> Since I don't see anything in snd_card_register() that could possibly
> fail, it would at least still work. Anyway, I'm now using
> snd_card_set_id(), and this function claims to check for duplicates. ;)

Well, it looks like a bug.  Maybe it got broken when the device id
handling was changed sometime ago for allowing dynamic renaming.

Anyway, the fix should be done individually from this patch.

> > And, MADIface will have no serial number, so it'll look strange.
> The code in question is limited to "if (!MADIface)", so no problem.
> > (Also the string with "%s_%04x" would be better, IMO.)
> I chose %06x, since the serial is masked with 0xFFFFFF.
> > For these, I'd suggest the following changes:
> > - check whether serial is non-zero
> That's actually 0xFFFFFF in case there is no serial. All PCI revisions
> behave like that.
> > - modify sound core registration part to re-generate the id string
> >    with suffix whenever conflicted, only not when the automated id
> >    string generation via card->id = NULL.
> I did not address this. Firstly, because snd_card_register() worked well
> even in case of colliding card->ids, and secondly, because
> snd_card_set_id would take care now to make it unique.

I'll fix snd_card_register() to make the string unique.



More information about the Alsa-devel mailing list