aboutsummaryrefslogtreecommitdiffstats
path: root/sound/sound_core.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2008-08-28 10:42:51 -0400
committerJaroslav Kysela <perex@perex.cz>2008-08-29 04:06:21 -0400
commitd886e87cb82b0f6636476c1104bb84d7c8dc87d9 (patch)
treef44fe9eeb7fea8687f8d4fc34a2aad813293462c /sound/sound_core.c
parent9f99a6386eb1ad1197a401495669315de2f19039 (diff)
sound: make OSS sound core optional
sound/sound_core.c implements soundcore.ko and contains two parts - sound_class which is shared by both ALSA and OSS and device redirection support for OSS. It's always compiled when any sound support is enabled although it's necessary only when OSS (the actual one or emulation) is enabled. This is slightly wasteful and as device redirection always registers character device region for major 14, it prevents alternative implementation. This patch introduces a new config SOUND_OSS_CORE which is selected iff OSS support is actually necessary and build the OSS core part conditionally. If OSS is disabled, soundcore merely contains sound_class but leaving it that way seems to be the simplest approach as otherwise sound_class should be in ALSA core file if OSS is disabled but should be in soundcore if OSS is enabled. Also, there's also the user confusion factor. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/sound_core.c')
-rw-r--r--sound/sound_core.c79
1 files changed, 60 insertions, 19 deletions
diff --git a/sound/sound_core.c b/sound/sound_core.c
index 1b04259a4328..68614c3ed541 100644
--- a/sound/sound_core.c
+++ b/sound/sound_core.c
@@ -1,5 +1,61 @@
1/* 1/*
2 * Sound core handling. Breaks out sound functions to submodules 2 * Sound core. This file is composed of two parts. sound_class
3 * which is common to both OSS and ALSA and OSS sound core which
4 * is used OSS or emulation of it.
5 */
6
7/*
8 * First, the common part.
9 */
10#include <linux/module.h>
11#include <linux/device.h>
12#include <linux/err.h>
13
14#ifdef CONFIG_SOUND_OSS_CORE
15static int __init init_oss_soundcore(void);
16static void __exit cleanup_oss_soundcore(void);
17#else
18static inline int init_oss_soundcore(void) { return 0; }
19static inline void cleanup_oss_soundcore(void) { }
20#endif
21
22struct class *sound_class;
23EXPORT_SYMBOL(sound_class);
24
25MODULE_DESCRIPTION("Core sound module");
26MODULE_AUTHOR("Alan Cox");
27MODULE_LICENSE("GPL");
28
29static int __init init_soundcore(void)
30{
31 int rc;
32
33 rc = init_oss_soundcore();
34 if (rc)
35 return rc;
36
37 sound_class = class_create(THIS_MODULE, "sound");
38 if (IS_ERR(sound_class)) {
39 cleanup_oss_soundcore();
40 return PTR_ERR(sound_class);
41 }
42
43 return 0;
44}
45
46static void __exit cleanup_soundcore(void)
47{
48 cleanup_oss_soundcore();
49 class_destroy(sound_class);
50}
51
52module_init(init_soundcore);
53module_exit(cleanup_soundcore);
54
55
56#ifdef CONFIG_SOUND_OSS_CORE
57/*
58 * OSS sound core handling. Breaks out sound functions to submodules
3 * 59 *
4 * Author: Alan Cox <alan.cox@linux.org> 60 * Author: Alan Cox <alan.cox@linux.org>
5 * 61 *
@@ -34,21 +90,17 @@
34 * locking at some point in 2.3.x. 90 * locking at some point in 2.3.x.
35 */ 91 */
36 92
37#include <linux/module.h>
38#include <linux/init.h> 93#include <linux/init.h>
39#include <linux/slab.h> 94#include <linux/slab.h>
40#include <linux/smp_lock.h> 95#include <linux/smp_lock.h>
41#include <linux/types.h> 96#include <linux/types.h>
42#include <linux/kernel.h> 97#include <linux/kernel.h>
43#include <linux/fs.h>
44#include <linux/sound.h> 98#include <linux/sound.h>
45#include <linux/major.h> 99#include <linux/major.h>
46#include <linux/kmod.h> 100#include <linux/kmod.h>
47#include <linux/device.h>
48 101
49#define SOUND_STEP 16 102#define SOUND_STEP 16
50 103
51
52struct sound_unit 104struct sound_unit
53{ 105{
54 int unit_minor; 106 int unit_minor;
@@ -64,9 +116,6 @@ extern int msnd_classic_init(void);
64extern int msnd_pinnacle_init(void); 116extern int msnd_pinnacle_init(void);
65#endif 117#endif
66 118
67struct class *sound_class;
68EXPORT_SYMBOL(sound_class);
69
70/* 119/*
71 * Low level list operator. Scan the ordered list, find a hole and 120 * Low level list operator. Scan the ordered list, find a hole and
72 * join into it. Called with the lock asserted 121 * join into it. Called with the lock asserted
@@ -523,31 +572,23 @@ int soundcore_open(struct inode *inode, struct file *file)
523 return -ENODEV; 572 return -ENODEV;
524} 573}
525 574
526MODULE_DESCRIPTION("Core sound module");
527MODULE_AUTHOR("Alan Cox");
528MODULE_LICENSE("GPL");
529MODULE_ALIAS_CHARDEV_MAJOR(SOUND_MAJOR); 575MODULE_ALIAS_CHARDEV_MAJOR(SOUND_MAJOR);
530 576
531static void __exit cleanup_soundcore(void) 577static void __exit cleanup_oss_soundcore(void)
532{ 578{
533 /* We have nothing to really do here - we know the lists must be 579 /* We have nothing to really do here - we know the lists must be
534 empty */ 580 empty */
535 unregister_chrdev(SOUND_MAJOR, "sound"); 581 unregister_chrdev(SOUND_MAJOR, "sound");
536 class_destroy(sound_class);
537} 582}
538 583
539static int __init init_soundcore(void) 584static int __init init_oss_soundcore(void)
540{ 585{
541 if (register_chrdev(SOUND_MAJOR, "sound", &soundcore_fops)==-1) { 586 if (register_chrdev(SOUND_MAJOR, "sound", &soundcore_fops)==-1) {
542 printk(KERN_ERR "soundcore: sound device already in use.\n"); 587 printk(KERN_ERR "soundcore: sound device already in use.\n");
543 return -EBUSY; 588 return -EBUSY;
544 } 589 }
545 sound_class = class_create(THIS_MODULE, "sound");
546 if (IS_ERR(sound_class))
547 return PTR_ERR(sound_class);
548 590
549 return 0; 591 return 0;
550} 592}
551 593
552module_init(init_soundcore); 594#endif /* CONFIG_SOUND_OSS_CORE */
553module_exit(cleanup_soundcore);