Need more than 32 USB sound cards on my system [closed] Need more than 32 USB sound cards on my system [closed] linux linux

Need more than 32 USB sound cards on my system [closed]


The question you pose is basically: Can there be more then 32 sound cards in the system controlled by ALSA? It obviously seems that while your USB controllers know all sound cards you attached, the ALSA system does not.

Let's get into the kernel sources to check what's going on here. In /sound/core/sound.c you will find more information about the issue of maximum sound cards:

  39 static int cards_limit = 1;  40   41 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");  42 MODULE_DESCRIPTION("Advanced Linux Sound Architecture driver for soundcards.");  43 MODULE_LICENSE("GPL");  44 module_param(major, int, 0444);  45 MODULE_PARM_DESC(major, "Major # for sound driver.");  46 module_param(cards_limit, int, 0444);  47 MODULE_PARM_DESC(cards_limit, "Count of auto-loadable soundcards.");  48 MODULE_ALIAS_CHARDEV_MAJOR(CONFIG_SND_MAJOR);  49   50 /* this one holds the actual max. card number currently available.  51  * as default, it's identical with cards_limit option.  when more  52  * modules are loaded manually, this limit number increases, too.  53  */  54 int snd_ecards_limit;  55 EXPORT_SYMBOL(snd_ecards_limit);

From the code and its comments I read two things:

  1. The variable cards_limit is a module parameter. I assume that on your installation this parameter is set to 32. If ALSA support is built into the kernel you can build a custom kernel where you changed this option. If ALSA support is not built-in, but loaded as a module, you can set this parameter during module load. For this you either change your system config (man modprobe.d) or unload the module, then reload it with the option (man modprobe).

  2. The limit is described to only limit the number of automatically loaded soundcards. To overcome this limit, it may suffice to manually load the module responsible for your soundcards. There is no limit set in the kernel for manually added soundcards.

Source: Kernel 2.8 Git


The sound card limit is defined as the symbol SNDRV_CARDS in include/sound/core.h.

When I increased this seven years ago, I did not go beyond 32 because the card index is used as a bit index for the variable snd_cards_lock in sound/core/init.c, and I did not want to change more than necessary.

If you make snd_cards_lock a 64-bit variable, change all accesses to use a 64-bit type, and adjust any other side effect that I might have forgotten about, you should be able to get the kernel to have more ALSA cards.

This limit also exists in the alsa-lib package; you will have to change at least the check in snd_ctl_hw_open in src/control/control_hw.c.