X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=sound%2Fsound_core.c;h=2b302bbffe7361c6faccc1eb84099f2e1c5b1baf;hb=f0787f62df516df6975d4325795ed02c495f3728;hp=0b0a016ca6d691563eac593634bc9dbdb3a39a7f;hpb=b9dd6ffc3d6b56417a2c4c917f51dab6470166e6;p=safe%2Fjmp%2Flinux-2.6 diff --git a/sound/sound_core.c b/sound/sound_core.c index 0b0a016..2b302bb 100644 --- a/sound/sound_core.c +++ b/sound/sound_core.c @@ -1,7 +1,64 @@ /* - * Sound core handling. Breaks out sound functions to submodules + * Sound core. This file is composed of two parts. sound_class + * which is common to both OSS and ALSA and OSS sound core which + * is used OSS or emulation of it. + */ + +/* + * First, the common part. + */ +#include +#include +#include +#include + +#ifdef CONFIG_SOUND_OSS_CORE +static int __init init_oss_soundcore(void); +static void cleanup_oss_soundcore(void); +#else +static inline int init_oss_soundcore(void) { return 0; } +static inline void cleanup_oss_soundcore(void) { } +#endif + +struct class *sound_class; +EXPORT_SYMBOL(sound_class); + +MODULE_DESCRIPTION("Core sound module"); +MODULE_AUTHOR("Alan Cox"); +MODULE_LICENSE("GPL"); + +static int __init init_soundcore(void) +{ + int rc; + + rc = init_oss_soundcore(); + if (rc) + return rc; + + sound_class = class_create(THIS_MODULE, "sound"); + if (IS_ERR(sound_class)) { + cleanup_oss_soundcore(); + return PTR_ERR(sound_class); + } + + return 0; +} + +static void __exit cleanup_soundcore(void) +{ + cleanup_oss_soundcore(); + class_destroy(sound_class); +} + +module_init(init_soundcore); +module_exit(cleanup_soundcore); + + +#ifdef CONFIG_SOUND_OSS_CORE +/* + * OSS sound core handling. Breaks out sound functions to submodules * - * Author: Alan Cox + * Author: Alan Cox * * Fixes: * @@ -34,20 +91,17 @@ * locking at some point in 2.3.x. */ -#include #include #include +#include #include #include -#include #include #include #include -#include #define SOUND_STEP 16 - struct sound_unit { int unit_minor; @@ -63,9 +117,6 @@ extern int msnd_classic_init(void); extern int msnd_pinnacle_init(void); #endif -struct class *sound_class; -EXPORT_SYMBOL(sound_class); - /* * Low level list operator. Scan the ordered list, find a hole and * join into it. Called with the lock asserted @@ -170,8 +221,8 @@ static int sound_insert_unit(struct sound_unit **list, const struct file_operati else sprintf(s->name, "sound/%s%d", name, r / SOUND_STEP); - class_device_create(sound_class, NULL, MKDEV(SOUND_MAJOR, s->unit_minor), - dev, s->name+6); + device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor), + NULL, s->name+6); return r; fail: @@ -193,7 +244,7 @@ static void sound_remove_unit(struct sound_unit **list, int unit) p = __sound_remove_unit(list, unit); spin_unlock(&sound_loader_lock); if (p) { - class_device_destroy(sound_class, MKDEV(SOUND_MAJOR, p->unit_minor)); + device_destroy(sound_class, MKDEV(SOUND_MAJOR, p->unit_minor)); kfree(p); } } @@ -366,25 +417,6 @@ int register_sound_dsp(const struct file_operations *fops, int dev) EXPORT_SYMBOL(register_sound_dsp); /** - * register_sound_synth - register a synth device - * @fops: File operations for the driver - * @dev: Unit number to allocate - * - * Allocate a synth device. Unit is the number of the synth device requested. - * Pass -1 to request the next free synth unit. On success the allocated - * number is returned, on failure a negative error code is returned. - */ - - -int register_sound_synth(const struct file_operations *fops, int dev) -{ - return sound_insert_unit(&chains[9], fops, dev, 9, 137, - "synth", S_IRUSR | S_IWUSR, NULL); -} - -EXPORT_SYMBOL(register_sound_synth); - -/** * unregister_sound_special - unregister a special sound device * @unit: unit number to allocate * @@ -426,7 +458,7 @@ EXPORT_SYMBOL(unregister_sound_mixer); void unregister_sound_midi(int unit) { - return sound_remove_unit(&chains[2], unit); + sound_remove_unit(&chains[2], unit); } EXPORT_SYMBOL(unregister_sound_midi); @@ -443,34 +475,19 @@ EXPORT_SYMBOL(unregister_sound_midi); void unregister_sound_dsp(int unit) { - return sound_remove_unit(&chains[3], unit); + sound_remove_unit(&chains[3], unit); } EXPORT_SYMBOL(unregister_sound_dsp); -/** - * unregister_sound_synth - unregister a synth device - * @unit: unit number to allocate - * - * Release a sound device that was allocated with register_sound_synth(). - * The unit passed is the return value from the register function. - */ - -void unregister_sound_synth(int unit) -{ - return sound_remove_unit(&chains[9], unit); -} - -EXPORT_SYMBOL(unregister_sound_synth); - /* * Now our file operations */ static int soundcore_open(struct inode *, struct file *); -static struct file_operations soundcore_fops= +static const struct file_operations soundcore_fops= { /* We must have an owner or the module locking fails */ .owner = THIS_MODULE, @@ -491,13 +508,15 @@ static struct sound_unit *__look_for_unit(int chain, int unit) return NULL; } -int soundcore_open(struct inode *inode, struct file *file) +static int soundcore_open(struct inode *inode, struct file *file) { int chain; int unit = iminor(inode); struct sound_unit *s; const struct file_operations *new_fops = NULL; + lock_kernel (); + chain=unit&0x0F; if(chain==4 || chain==5) /* dsp/audio/dsp16 */ { @@ -545,37 +564,31 @@ int soundcore_open(struct inode *inode, struct file *file) file->f_op = fops_get(old_fops); } fops_put(old_fops); + unlock_kernel(); return err; } spin_unlock(&sound_loader_lock); + unlock_kernel(); return -ENODEV; } -MODULE_DESCRIPTION("Core sound module"); -MODULE_AUTHOR("Alan Cox"); -MODULE_LICENSE("GPL"); MODULE_ALIAS_CHARDEV_MAJOR(SOUND_MAJOR); -static void __exit cleanup_soundcore(void) +static void cleanup_oss_soundcore(void) { /* We have nothing to really do here - we know the lists must be empty */ unregister_chrdev(SOUND_MAJOR, "sound"); - class_destroy(sound_class); } -static int __init init_soundcore(void) +static int __init init_oss_soundcore(void) { if (register_chrdev(SOUND_MAJOR, "sound", &soundcore_fops)==-1) { printk(KERN_ERR "soundcore: sound device already in use.\n"); return -EBUSY; } - sound_class = class_create(THIS_MODULE, "sound"); - if (IS_ERR(sound_class)) - return PTR_ERR(sound_class); return 0; } -module_init(init_soundcore); -module_exit(cleanup_soundcore); +#endif /* CONFIG_SOUND_OSS_CORE */