xref: /openbmc/linux/sound/core/seq/seq.c (revision 22246614)
1 /*
2  *  ALSA sequencer main module
3  *  Copyright (c) 1998-1999 by Frank van de Pol <fvdpol@coil.demon.nl>
4  *
5  *
6  *   This program is free software; you can redistribute it and/or modify
7  *   it under the terms of the GNU General Public License as published by
8  *   the Free Software Foundation; either version 2 of the License, or
9  *   (at your option) any later version.
10  *
11  *   This program is distributed in the hope that it will be useful,
12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *   GNU General Public License for more details.
15  *
16  *   You should have received a copy of the GNU General Public License
17  *   along with this program; if not, write to the Free Software
18  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19  *
20  */
21 
22 #include <linux/init.h>
23 #include <linux/moduleparam.h>
24 #include <sound/core.h>
25 #include <sound/initval.h>
26 
27 #include <sound/seq_kernel.h>
28 #include "seq_clientmgr.h"
29 #include "seq_memory.h"
30 #include "seq_queue.h"
31 #include "seq_lock.h"
32 #include "seq_timer.h"
33 #include "seq_system.h"
34 #include "seq_info.h"
35 #include <sound/seq_device.h>
36 
37 #if defined(CONFIG_SND_SEQ_DUMMY_MODULE)
38 int seq_client_load[15] = {[0] = SNDRV_SEQ_CLIENT_DUMMY, [1 ... 14] = -1};
39 #else
40 int seq_client_load[15] = {[0 ... 14] = -1};
41 #endif
42 int seq_default_timer_class = SNDRV_TIMER_CLASS_GLOBAL;
43 int seq_default_timer_sclass = SNDRV_TIMER_SCLASS_NONE;
44 int seq_default_timer_card = -1;
45 int seq_default_timer_device =
46 #ifdef CONFIG_SND_SEQ_RTCTIMER_DEFAULT
47 	SNDRV_TIMER_GLOBAL_RTC
48 #else
49 	SNDRV_TIMER_GLOBAL_SYSTEM
50 #endif
51 	;
52 int seq_default_timer_subdevice = 0;
53 int seq_default_timer_resolution = 0;	/* Hz */
54 
55 MODULE_AUTHOR("Frank van de Pol <fvdpol@coil.demon.nl>, Jaroslav Kysela <perex@perex.cz>");
56 MODULE_DESCRIPTION("Advanced Linux Sound Architecture sequencer.");
57 MODULE_LICENSE("GPL");
58 
59 module_param_array(seq_client_load, int, NULL, 0444);
60 MODULE_PARM_DESC(seq_client_load, "The numbers of global (system) clients to load through kmod.");
61 module_param(seq_default_timer_class, int, 0644);
62 MODULE_PARM_DESC(seq_default_timer_class, "The default timer class.");
63 module_param(seq_default_timer_sclass, int, 0644);
64 MODULE_PARM_DESC(seq_default_timer_sclass, "The default timer slave class.");
65 module_param(seq_default_timer_card, int, 0644);
66 MODULE_PARM_DESC(seq_default_timer_card, "The default timer card number.");
67 module_param(seq_default_timer_device, int, 0644);
68 MODULE_PARM_DESC(seq_default_timer_device, "The default timer device number.");
69 module_param(seq_default_timer_subdevice, int, 0644);
70 MODULE_PARM_DESC(seq_default_timer_subdevice, "The default timer subdevice number.");
71 module_param(seq_default_timer_resolution, int, 0644);
72 MODULE_PARM_DESC(seq_default_timer_resolution, "The default timer resolution in Hz.");
73 
74 /*
75  *  INIT PART
76  */
77 
78 static int __init alsa_seq_init(void)
79 {
80 	int err;
81 
82 	snd_seq_autoload_lock();
83 	if ((err = client_init_data()) < 0)
84 		goto error;
85 
86 	/* init memory, room for selected events */
87 	if ((err = snd_sequencer_memory_init()) < 0)
88 		goto error;
89 
90 	/* init event queues */
91 	if ((err = snd_seq_queues_init()) < 0)
92 		goto error;
93 
94 	/* register sequencer device */
95 	if ((err = snd_sequencer_device_init()) < 0)
96 		goto error;
97 
98 	/* register proc interface */
99 	if ((err = snd_seq_info_init()) < 0)
100 		goto error;
101 
102 	/* register our internal client */
103 	if ((err = snd_seq_system_client_init()) < 0)
104 		goto error;
105 
106  error:
107 	snd_seq_autoload_unlock();
108 	return err;
109 }
110 
111 static void __exit alsa_seq_exit(void)
112 {
113 	/* unregister our internal client */
114 	snd_seq_system_client_done();
115 
116 	/* unregister proc interface */
117 	snd_seq_info_done();
118 
119 	/* delete timing queues */
120 	snd_seq_queues_delete();
121 
122 	/* unregister sequencer device */
123 	snd_sequencer_device_done();
124 
125 	/* release event memory */
126 	snd_sequencer_memory_done();
127 }
128 
129 module_init(alsa_seq_init)
130 module_exit(alsa_seq_exit)
131