10 #include <linux/module.h>
11 #include <linux/device.h>
13 #include <linux/kdev_t.h>
17 #ifdef CONFIG_SOUND_OSS_CORE
18 static int __init init_oss_soundcore(
void);
19 static void cleanup_oss_soundcore(
void);
21 static inline int init_oss_soundcore(
void) {
return 0; }
22 static inline void cleanup_oss_soundcore(
void) { }
39 static int __init init_soundcore(
void)
43 rc = init_oss_soundcore();
48 if (IS_ERR(sound_class)) {
49 cleanup_oss_soundcore();
50 return PTR_ERR(sound_class);
53 sound_class->
devnode = sound_devnode;
58 static void __exit cleanup_soundcore(
void)
60 cleanup_oss_soundcore();
68 #ifdef CONFIG_SOUND_OSS_CORE
106 #include <linux/slab.h>
107 #include <linux/types.h>
108 #include <linux/kernel.h>
109 #include <linux/sound.h>
112 #define SOUND_STEP 16
118 struct sound_unit *
next;
122 #ifdef CONFIG_SOUND_MSNDCLAS
123 extern int msnd_classic_init(
void);
125 #ifdef CONFIG_SOUND_MSNDPIN
126 extern int msnd_pinnacle_init(
void);
152 #ifdef CONFIG_SOUND_OSS_CORE_PRECLAIM
153 static int preclaim_oss = 1;
155 static int preclaim_oss = 0;
160 static int soundcore_open(
struct inode *,
struct file *);
166 .open = soundcore_open,
181 while (*list && (*list)->unit_minor<n)
182 list=&((*list)->next);
187 if(*list==
NULL || (*list)->unit_minor>n)
189 list=&((*list)->next);
198 if ((*list)->unit_minor==n)
200 if ((*list)->unit_minor>n)
202 list=&((*list)->next);
228 static struct sound_unit *__sound_remove_unit(
struct sound_unit **list,
int unit)
232 struct sound_unit *
p=*
list;
233 if(p->unit_minor==unit)
255 static int sound_insert_unit(
struct sound_unit **list,
const struct file_operations *fops,
int index,
int low,
int top,
const char *
name,
umode_t mode,
struct device *dev)
263 spin_lock(&sound_loader_lock);
265 r = __sound_insert_unit(s, list, fops, index, low, top);
266 spin_unlock(&sound_loader_lock);
270 else if (r < SOUND_STEP)
271 sprintf(s->name,
"sound/%s", name);
273 sprintf(s->name,
"sound/%s%d", name, r / SOUND_STEP);
284 spin_lock(&sound_loader_lock);
285 __sound_remove_unit(list, s->unit_minor);
287 low = s->unit_minor + SOUND_STEP;
290 spin_unlock(&sound_loader_lock);
297 return s->unit_minor;
310 static void sound_remove_unit(
struct sound_unit **list,
int unit)
312 struct sound_unit *
p;
314 spin_lock(&sound_loader_lock);
315 p = __sound_remove_unit(list, unit);
316 spin_unlock(&sound_loader_lock);
347 static struct sound_unit *chains[SOUND_STEP];
363 const int chain = unit % SOUND_STEP;
374 if (unit >= SOUND_STEP)
392 if (unit >= SOUND_STEP)
414 sprintf(_name,
"unknown%d", chain);
415 if (unit >= SOUND_STEP)
421 return sound_insert_unit(&chains[chain], fops, -1, unit, max_unit,
446 return sound_insert_unit(&chains[0], fops, dev, 0, 128,
464 return sound_insert_unit(&chains[2], fops, dev, 2, 130,
490 return sound_insert_unit(&chains[3], fops, dev, 3, 131,
508 sound_remove_unit(&chains[unit % SOUND_STEP], unit);
523 sound_remove_unit(&chains[0], unit);
538 sound_remove_unit(&chains[2], unit);
555 sound_remove_unit(&chains[3], unit);
561 static struct sound_unit *__look_for_unit(
int chain,
int unit)
563 struct sound_unit *
s;
566 while(s && s->unit_minor <= unit)
568 if(s->unit_minor==unit)
578 int unit = iminor(inode);
579 struct sound_unit *
s;
583 if(chain==4 || chain==5)
590 spin_lock(&sound_loader_lock);
591 s = __look_for_unit(chain, unit);
594 if (preclaim_oss && !new_fops) {
595 spin_unlock(&sound_loader_lock);
604 request_module(
"sound-slot-%i", unit>>4);
605 request_module(
"sound-service-%i-%i", unit>>4, chain);
614 if (request_module(
"char-major-%d-%d",
SOUND_MAJOR, unit) > 0)
617 spin_lock(&sound_loader_lock);
618 s = __look_for_unit(chain, unit);
632 file->
f_op = new_fops;
633 spin_unlock(&sound_loader_lock);
635 if (file->
f_op->open)
636 err = file->
f_op->open(inode,file);
646 spin_unlock(&sound_loader_lock);
652 static void cleanup_oss_soundcore(
void)
659 static int __init init_oss_soundcore(
void)
662 register_chrdev(
SOUND_MAJOR,
"sound", &soundcore_fops) == -1) {