aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/seq
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2005-11-20 08:09:05 -0500
committerJaroslav Kysela <perex@suse.cz>2006-01-03 06:29:21 -0500
commitd001544ded23ddb1116f945ccc2d89a7f98ab7e8 (patch)
tree721fbc6355acfb886817e2b120f198383c5e6ae6 /sound/core/seq
parent204bdb1b50013c7aa3922d8b66df943123087bd8 (diff)
[ALSA] dynamic minors (6/6): increase maximum number of sound cards
Modules: ALSA Core,Memalloc module,ALSA sequencer With dynamic minor numbers, we can increase the number of sound cards. This requires that the sequencer client numbers of some kernel drivers are allocated dynamically, too. Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Diffstat (limited to 'sound/core/seq')
-rw-r--r--sound/core/seq/seq_clientmgr.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
index 95bd5ae92b92..2a9c6b316b14 100644
--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -47,6 +47,10 @@
47 * 47 *
48 */ 48 */
49 49
50/* range for dynamically allocated client numbers of kernel drivers */
51#define SNDRV_SEQ_DYNAMIC_CLIENT_BEGIN 16
52#define SNDRV_SEQ_DYNAMIC_CLIENT_END 48
53
50#define SNDRV_SEQ_LFLG_INPUT 0x0001 54#define SNDRV_SEQ_LFLG_INPUT 0x0001
51#define SNDRV_SEQ_LFLG_OUTPUT 0x0002 55#define SNDRV_SEQ_LFLG_OUTPUT 0x0002
52#define SNDRV_SEQ_LFLG_OPEN (SNDRV_SEQ_LFLG_INPUT|SNDRV_SEQ_LFLG_OUTPUT) 56#define SNDRV_SEQ_LFLG_OPEN (SNDRV_SEQ_LFLG_INPUT|SNDRV_SEQ_LFLG_OUTPUT)
@@ -203,7 +207,8 @@ int __init client_init_data(void)
203} 207}
204 208
205 209
206static struct snd_seq_client *seq_create_client1(int client_index, int poolsize) 210static struct snd_seq_client *seq_create_client1(int client_index, int poolsize,
211 int kernel_client)
207{ 212{
208 unsigned long flags; 213 unsigned long flags;
209 int c; 214 int c;
@@ -227,7 +232,15 @@ static struct snd_seq_client *seq_create_client1(int client_index, int poolsize)
227 /* find free slot in the client table */ 232 /* find free slot in the client table */
228 spin_lock_irqsave(&clients_lock, flags); 233 spin_lock_irqsave(&clients_lock, flags);
229 if (client_index < 0) { 234 if (client_index < 0) {
230 for (c = 128; c < SNDRV_SEQ_MAX_CLIENTS; c++) { 235 int cmin, cmax;
236 if (kernel_client) {
237 cmin = SNDRV_SEQ_DYNAMIC_CLIENT_BEGIN;
238 cmax = SNDRV_SEQ_DYNAMIC_CLIENT_END;
239 } else {
240 cmin = 128;
241 cmax = SNDRV_SEQ_MAX_CLIENTS;
242 }
243 for (c = cmin; c < cmax; c++) {
231 if (clienttab[c] || clienttablock[c]) 244 if (clienttab[c] || clienttablock[c])
232 continue; 245 continue;
233 clienttab[client->number = c] = client; 246 clienttab[client->number = c] = client;
@@ -306,7 +319,7 @@ static int snd_seq_open(struct inode *inode, struct file *file)
306 319
307 if (down_interruptible(&register_mutex)) 320 if (down_interruptible(&register_mutex))
308 return -ERESTARTSYS; 321 return -ERESTARTSYS;
309 client = seq_create_client1(-1, SNDRV_SEQ_DEFAULT_EVENTS); 322 client = seq_create_client1(-1, SNDRV_SEQ_DEFAULT_EVENTS, 0);
310 if (client == NULL) { 323 if (client == NULL) {
311 up(&register_mutex); 324 up(&register_mutex);
312 return -ENOMEM; /* failure code */ 325 return -ENOMEM; /* failure code */
@@ -2212,13 +2225,19 @@ int snd_seq_create_kernel_client(struct snd_card *card, int client_index,
2212 return -EINVAL; 2225 return -EINVAL;
2213 if (card == NULL && client_index > 63) 2226 if (card == NULL && client_index > 63)
2214 return -EINVAL; 2227 return -EINVAL;
2215 if (card)
2216 client_index += 64 + (card->number << 2);
2217 2228
2218 if (down_interruptible(&register_mutex)) 2229 if (down_interruptible(&register_mutex))
2219 return -ERESTARTSYS; 2230 return -ERESTARTSYS;
2231
2232 if (card) {
2233 if (card->number < 16)
2234 client_index += 64 + (card->number << 2);
2235 else
2236 client_index = -1;
2237 }
2238
2220 /* empty write queue as default */ 2239 /* empty write queue as default */
2221 client = seq_create_client1(client_index, 0); 2240 client = seq_create_client1(client_index, 0, 1);
2222 if (client == NULL) { 2241 if (client == NULL) {
2223 up(&register_mutex); 2242 up(&register_mutex);
2224 return -EBUSY; /* failure code */ 2243 return -EBUSY; /* failure code */