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

Takashi Iwai tiwai at suse.de
Sun Jan 8 16:15:28 CET 2012


At Wed,  4 Jan 2012 14:31:17 +0100,
Adrian Knoth wrote:
> 
> Before, /proc/asound looked like this:
> 
>  2 [Default        ]: HDSPM - RME RayDAT_f1cd85
>                       RME RayDAT S/N 0xf1cd85 at 0xf7300000, irq 18
> 
> In case of a second HDSPM card, its name would be Default_1. This is
> cumbersome, because the order of the cards isn't stable across reboots.
> 
> To help userspace tools referring to the correct card, this commit
> provides a unique id for each card:
> 
>  2 [HDSPM_f1cd85   ]: HDSPM - RME RayDAT_f1cd85
>                       RME RayDAT S/N 0xf1cd85 at 0xf7300000, irq 18
> 
> In this example, userspace (configuration files) would then use
> hw:HDSPM_f1cd85 to choose the right card.
> 
> The serial is masked to 24bits, so this string is always shorter than
> sixteen chars.
> 
> Signed-off-by: Adrian Knoth <adi at drcomp.erfurt.thur.de>

This can't be applied as is, unfortunately.
This would break when user passes the card id string via option.
Also, if multiple boards have the same serial number (who can trust
the hardware? :), it gets -EBUSY at registration.
And, MADIface will have no serial number, so it'll look strange.
(Also the string with "%s_%04x" would be better, IMO.)

For these, I'd suggest the following changes:
- check whether serial is non-zero
- check whether card->id is empty; fill the new string only if empty
- 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.


thanks,

Takashi

> diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
> index 1609253..a3121c9 100644
> --- a/sound/pci/rme9652/hdspm.c
> +++ b/sound/pci/rme9652/hdspm.c
> @@ -6872,6 +6872,7 @@ static int __devinit snd_hdspm_probe(struct pci_dev *pci,
>  		sprintf(card->shortname, "%s_%x",
>  			hdspm->card_name,
>  			hdspm->serial);
> +		sprintf(card->id, "HDSPM_%x", hdspm->serial);
>  		sprintf(card->longname, "%s S/N 0x%x at 0x%lx, irq %d",
>  			hdspm->card_name,
>  			hdspm->serial,
> -- 
> 1.7.7.3
> 


More information about the Alsa-devel mailing list