aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/seq/seq.c4
-rw-r--r--sound/core/seq/seq_clientmgr.c57
2 files changed, 33 insertions, 28 deletions
diff --git a/sound/core/seq/seq.c b/sound/core/seq/seq.c
index 24644150f24b..20f954bc7aa0 100644
--- a/sound/core/seq/seq.c
+++ b/sound/core/seq/seq.c
@@ -36,9 +36,9 @@
36#include <sound/seq_device.h> 36#include <sound/seq_device.h>
37 37
38#if defined(CONFIG_SND_SEQ_DUMMY_MODULE) 38#if defined(CONFIG_SND_SEQ_DUMMY_MODULE)
39int seq_client_load[64] = {[0] = SNDRV_SEQ_CLIENT_DUMMY, [1 ... 63] = -1}; 39int seq_client_load[15] = {[0] = SNDRV_SEQ_CLIENT_DUMMY, [1 ... 14] = -1};
40#else 40#else
41int seq_client_load[64] = {[0 ... 63] = -1}; 41int seq_client_load[15] = {[0 ... 14] = -1};
42#endif 42#endif
43int seq_default_timer_class = SNDRV_TIMER_CLASS_GLOBAL; 43int seq_default_timer_class = SNDRV_TIMER_CLASS_GLOBAL;
44int seq_default_timer_sclass = SNDRV_TIMER_SCLASS_NONE; 44int seq_default_timer_sclass = SNDRV_TIMER_SCLASS_NONE;
diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
index 606d076f72f4..fd2032eae214 100644
--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -47,9 +47,20 @@
47 * 47 *
48 */ 48 */
49 49
50/* range for dynamically allocated client numbers of kernel drivers */ 50/*
51#define SNDRV_SEQ_DYNAMIC_CLIENT_BEGIN 16 51 * There are four ranges of client numbers (last two shared):
52#define SNDRV_SEQ_DYNAMIC_CLIENT_END 48 52 * 0..15: global clients
53 * 16..127: statically allocated client numbers for cards 0..27
54 * 128..191: dynamically allocated client numbers for cards 28..31
55 * 128..191: dynamically allocated client numbers for applications
56 */
57
58/* number of kernel non-card clients */
59#define SNDRV_SEQ_GLOBAL_CLIENTS 16
60/* clients per cards, for static clients */
61#define SNDRV_SEQ_CLIENTS_PER_CARD 4
62/* dynamically allocated client numbers (both kernel drivers and user space) */
63#define SNDRV_SEQ_DYNAMIC_CLIENTS_BEGIN 128
53 64
54#define SNDRV_SEQ_LFLG_INPUT 0x0001 65#define SNDRV_SEQ_LFLG_INPUT 0x0001
55#define SNDRV_SEQ_LFLG_OUTPUT 0x0002 66#define SNDRV_SEQ_LFLG_OUTPUT 0x0002
@@ -143,14 +154,14 @@ struct snd_seq_client *snd_seq_client_use_ptr(int clientid)
143 spin_unlock_irqrestore(&clients_lock, flags); 154 spin_unlock_irqrestore(&clients_lock, flags);
144#ifdef CONFIG_KMOD 155#ifdef CONFIG_KMOD
145 if (!in_interrupt() && current->fs->root) { 156 if (!in_interrupt() && current->fs->root) {
146 static char client_requested[64]; 157 static char client_requested[SNDRV_SEQ_GLOBAL_CLIENTS];
147 static char card_requested[SNDRV_CARDS]; 158 static char card_requested[SNDRV_CARDS];
148 if (clientid < 64) { 159 if (clientid < SNDRV_SEQ_GLOBAL_CLIENTS) {
149 int idx; 160 int idx;
150 161
151 if (! client_requested[clientid] && current->fs->root) { 162 if (! client_requested[clientid] && current->fs->root) {
152 client_requested[clientid] = 1; 163 client_requested[clientid] = 1;
153 for (idx = 0; idx < 64; idx++) { 164 for (idx = 0; idx < 15; idx++) {
154 if (seq_client_load[idx] < 0) 165 if (seq_client_load[idx] < 0)
155 break; 166 break;
156 if (seq_client_load[idx] == clientid) { 167 if (seq_client_load[idx] == clientid) {
@@ -160,8 +171,9 @@ struct snd_seq_client *snd_seq_client_use_ptr(int clientid)
160 } 171 }
161 } 172 }
162 } 173 }
163 } else if (clientid >= 64 && clientid < 128) { 174 } else if (clientid < SNDRV_SEQ_DYNAMIC_CLIENTS_BEGIN) {
164 int card = (clientid - 64) / 4; 175 int card = (clientid - SNDRV_SEQ_GLOBAL_CLIENTS) /
176 SNDRV_SEQ_CLIENTS_PER_CARD;
165 if (card < snd_ecards_limit) { 177 if (card < snd_ecards_limit) {
166 if (! card_requested[card]) { 178 if (! card_requested[card]) {
167 card_requested[card] = 1; 179 card_requested[card] = 1;
@@ -207,8 +219,7 @@ int __init client_init_data(void)
207} 219}
208 220
209 221
210static struct snd_seq_client *seq_create_client1(int client_index, int poolsize, 222static struct snd_seq_client *seq_create_client1(int client_index, int poolsize)
211 int kernel_client)
212{ 223{
213 unsigned long flags; 224 unsigned long flags;
214 int c; 225 int c;
@@ -232,15 +243,9 @@ static struct snd_seq_client *seq_create_client1(int client_index, int poolsize,
232 /* find free slot in the client table */ 243 /* find free slot in the client table */
233 spin_lock_irqsave(&clients_lock, flags); 244 spin_lock_irqsave(&clients_lock, flags);
234 if (client_index < 0) { 245 if (client_index < 0) {
235 int cmin, cmax; 246 for (c = SNDRV_SEQ_DYNAMIC_CLIENTS_BEGIN;
236 if (kernel_client) { 247 c < SNDRV_SEQ_MAX_CLIENTS;
237 cmin = SNDRV_SEQ_DYNAMIC_CLIENT_BEGIN; 248 c++) {
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++) {
244 if (clienttab[c] || clienttablock[c]) 249 if (clienttab[c] || clienttablock[c])
245 continue; 250 continue;
246 clienttab[client->number = c] = client; 251 clienttab[client->number = c] = client;
@@ -319,7 +324,7 @@ static int snd_seq_open(struct inode *inode, struct file *file)
319 324
320 if (down_interruptible(&register_mutex)) 325 if (down_interruptible(&register_mutex))
321 return -ERESTARTSYS; 326 return -ERESTARTSYS;
322 client = seq_create_client1(-1, SNDRV_SEQ_DEFAULT_EVENTS, 0); 327 client = seq_create_client1(-1, SNDRV_SEQ_DEFAULT_EVENTS);
323 if (client == NULL) { 328 if (client == NULL) {
324 up(&register_mutex); 329 up(&register_mutex);
325 return -ENOMEM; /* failure code */ 330 return -ENOMEM; /* failure code */
@@ -2220,23 +2225,23 @@ int snd_seq_create_kernel_client(struct snd_card *card, int client_index,
2220 2225
2221 snd_assert(! in_interrupt(), return -EBUSY); 2226 snd_assert(! in_interrupt(), return -EBUSY);
2222 2227
2223 if (card && client_index > 3) 2228 if (card && client_index >= SNDRV_SEQ_CLIENTS_PER_CARD)
2224 return -EINVAL; 2229 return -EINVAL;
2225 if (card == NULL && client_index > 63) 2230 if (card == NULL && client_index >= SNDRV_SEQ_GLOBAL_CLIENTS)
2226 return -EINVAL; 2231 return -EINVAL;
2227 2232
2228 if (down_interruptible(&register_mutex)) 2233 if (down_interruptible(&register_mutex))
2229 return -ERESTARTSYS; 2234 return -ERESTARTSYS;
2230 2235
2231 if (card) { 2236 if (card) {
2232 if (card->number < 16) 2237 client_index += SNDRV_SEQ_GLOBAL_CLIENTS
2233 client_index += 64 + (card->number << 2); 2238 + card->number * SNDRV_SEQ_CLIENTS_PER_CARD;
2234 else 2239 if (client_index >= SNDRV_SEQ_DYNAMIC_CLIENTS_BEGIN)
2235 client_index = -1; 2240 client_index = -1;
2236 } 2241 }
2237 2242
2238 /* empty write queue as default */ 2243 /* empty write queue as default */
2239 client = seq_create_client1(client_index, 0, 1); 2244 client = seq_create_client1(client_index, 0);
2240 if (client == NULL) { 2245 if (client == NULL) {
2241 up(&register_mutex); 2246 up(&register_mutex);
2242 return -EBUSY; /* failure code */ 2247 return -EBUSY; /* failure code */