diff options
author | Takashi Iwai <tiwai@suse.de> | 2007-10-26 09:10:15 -0400 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2008-01-31 11:29:11 -0500 |
commit | 304cd07f92027af7e92d742d9554c3be9fa4d4cf (patch) | |
tree | 79129c34ac5a4ae063b6d0bd8cd62bd0fbb45ac0 /sound/core | |
parent | e97a516701cfc3c4b27444212208884214d10c20 (diff) |
[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/core')
-rw-r--r-- | sound/core/init.c | 36 |
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); | |||
43 | 43 | ||
44 | static DEFINE_MUTEX(snd_card_mutex); | 44 | static DEFINE_MUTEX(snd_card_mutex); |
45 | 45 | ||
46 | static char *slots[SNDRV_CARDS]; | ||
47 | module_param_array(slots, charp, NULL, 0444); | ||
48 | MODULE_PARM_DESC(slots, "Module names assigned to the slots."); | ||
49 | |||
50 | /* return non-zero if the given index is already reserved for another | ||
51 | * module via slots option | ||
52 | */ | ||
53 | static int module_slot_mismatch(struct module *module, int idx) | ||
54 | { | ||
55 | #ifdef MODULE | ||
56 | char *s1, *s2; | ||
57 | if (!module || !module->name || !slots[idx]) | ||
58 | return 0; | ||
59 | s1 = slots[idx]; | ||
60 | s2 = module->name; | ||
61 | /* compare module name strings | ||
62 | * hyphens are handled as equivalent with underscore | ||
63 | */ | ||
64 | for (;;) { | ||
65 | char c1 = *s1++; | ||
66 | char c2 = *s2++; | ||
67 | if (c1 == '-') | ||
68 | c1 = '_'; | ||
69 | if (c2 == '-') | ||
70 | c2 = '_'; | ||
71 | if (c1 != c2) | ||
72 | return 1; | ||
73 | if (!c1) | ||
74 | break; | ||
75 | } | ||
76 | #endif | ||
77 | return 0; | ||
78 | } | ||
79 | |||
46 | #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) | 80 | #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) |
47 | int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int free_flag); | 81 | int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int free_flag); |
48 | EXPORT_SYMBOL(snd_mixer_oss_notify_callback); | 82 | EXPORT_SYMBOL(snd_mixer_oss_notify_callback); |
@@ -115,6 +149,8 @@ struct snd_card *snd_card_new(int idx, const char *xid, | |||
115 | for (idx2 = 0; idx2 < SNDRV_CARDS; idx2++) | 149 | for (idx2 = 0; idx2 < SNDRV_CARDS; idx2++) |
116 | /* idx == -1 == 0xffff means: take any free slot */ | 150 | /* idx == -1 == 0xffff means: take any free slot */ |
117 | if (~snd_cards_lock & idx & 1<<idx2) { | 151 | if (~snd_cards_lock & idx & 1<<idx2) { |
152 | if (module_slot_mismatch(module, idx2)) | ||
153 | continue; | ||
118 | idx = idx2; | 154 | idx = idx2; |
119 | if (idx >= snd_ecards_limit) | 155 | if (idx >= snd_ecards_limit) |
120 | snd_ecards_limit = idx + 1; | 156 | snd_ecards_limit = idx + 1; |