summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2007-10-26 17:10:15 +0400
committerJaroslav Kysela <perex@perex.cz>2008-01-31 19:29:11 +0300
commit304cd07f92027af7e92d742d9554c3be9fa4d4cf (patch)
tree79129c34ac5a4ae063b6d0bd8cd62bd0fbb45ac0 /sound
parente97a516701cfc3c4b27444212208884214d10c20 (diff)
downloadlinux-304cd07f92027af7e92d742d9554c3be9fa4d4cf.tar.xz
[ALSA] Introduce slots option to snd module
Introduced the global 'slots' option to snd module. This option provides an alternative way to handle the order of multiple sound card instances. It's an easier approach to avoid conflict with hotplug devices, and can be used together with the existing 'order' option of each card driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound')
-rw-r--r--sound/core/init.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/sound/core/init.c b/sound/core/init.c
index 2cb7099eb1e1..48d38a79cbbb 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -43,6 +43,40 @@ EXPORT_SYMBOL(snd_cards);
static DEFINE_MUTEX(snd_card_mutex);
+static char *slots[SNDRV_CARDS];
+module_param_array(slots, charp, NULL, 0444);
+MODULE_PARM_DESC(slots, "Module names assigned to the slots.");
+
+/* return non-zero if the given index is already reserved for another
+ * module via slots option
+ */
+static int module_slot_mismatch(struct module *module, int idx)
+{
+#ifdef MODULE
+ char *s1, *s2;
+ if (!module || !module->name || !slots[idx])
+ return 0;
+ s1 = slots[idx];
+ s2 = module->name;
+ /* compare module name strings
+ * hyphens are handled as equivalent with underscore
+ */
+ for (;;) {
+ char c1 = *s1++;
+ char c2 = *s2++;
+ if (c1 == '-')
+ c1 = '_';
+ if (c2 == '-')
+ c2 = '_';
+ if (c1 != c2)
+ return 1;
+ if (!c1)
+ break;
+ }
+#endif
+ return 0;
+}
+
#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int free_flag);
EXPORT_SYMBOL(snd_mixer_oss_notify_callback);
@@ -115,6 +149,8 @@ struct snd_card *snd_card_new(int idx, const char *xid,
for (idx2 = 0; idx2 < SNDRV_CARDS; idx2++)
/* idx == -1 == 0xffff means: take any free slot */
if (~snd_cards_lock & idx & 1<<idx2) {
+ if (module_slot_mismatch(module, idx2))
+ continue;
idx = idx2;
if (idx >= snd_ecards_limit)
snd_ecards_limit = idx + 1;