This source file includes following definitions.
- snd_find_driver
- sndtable_init
- sound_unload_drivers
- sndtable_probe
- sndtable_init_card
- sndtable_get_cardcount
- sndtable_identify_card
- sound_setup
- sound_getconf
- sound_setup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 #define _DEV_TABLE_C_
31 #include "sound_config.h"
32
33 #ifdef CONFIGURE_SOUNDCARD
34
35 int
36 snd_find_driver (int type)
37 {
38 int i, n = num_sound_drivers;
39
40 for (i = 0; i < n; i++)
41 if (sound_drivers[i].card_type == type)
42 return i;
43
44 return -1;
45
46
47 }
48
49 long
50 sndtable_init (long mem_start)
51 {
52 int i, n = num_sound_cards;
53 int drv;
54
55 printk ("Sound initialization started\n");
56
57
58
59
60
61 for (i = 0; i < n && snd_installed_cards[i].card_type; i++)
62 num_sound_cards = i + 1;
63
64 for (i = 0; i < n && snd_installed_cards[i].card_type; i++)
65 if (snd_installed_cards[i].enabled)
66 {
67 snd_installed_cards[i].for_driver_use = NULL;
68
69 if ((drv = snd_find_driver (snd_installed_cards[i].card_type)) == -1)
70 snd_installed_cards[i].enabled = 0;
71
72
73 else if (sound_drivers[drv].probe (&snd_installed_cards[i].config))
74 {
75 #ifndef SHORT_BANNERS
76 printk ("snd%d",
77 snd_installed_cards[i].card_type);
78 #endif
79
80 mem_start = sound_drivers[drv].attach (mem_start, &snd_installed_cards[i].config);
81 #ifndef SHORT_BANNERS
82 printk (" at 0x%x irq %d drq %d",
83 snd_installed_cards[i].config.io_base,
84 snd_installed_cards[i].config.irq,
85 snd_installed_cards[i].config.dma);
86 if (snd_installed_cards[i].config.dma2 != -1)
87 printk (",%d\n",
88 snd_installed_cards[i].config.dma2);
89 else
90 printk ("\n");
91 #endif
92 }
93 else
94 snd_installed_cards[i].enabled = 0;
95
96
97 }
98
99 printk ("Sound initialization complete\n");
100 return mem_start;
101 }
102
103 void
104 sound_unload_drivers (void)
105 {
106 int i, n = num_sound_cards;
107 int drv;
108
109 printk ("Sound unload started\n");
110
111 for (i = 0; i < n && snd_installed_cards[i].card_type; i++)
112 if (snd_installed_cards[i].enabled)
113 if ((drv = snd_find_driver (snd_installed_cards[i].card_type)) != -1)
114 if (sound_drivers[drv].unload)
115 sound_drivers[drv].unload (&snd_installed_cards[i].config);
116
117 printk ("Sound unload complete\n");
118 }
119
120 int
121 sndtable_probe (int unit, struct address_info *hw_config)
122 {
123 int i, sel = -1, n = num_sound_cards;
124
125 if (!unit)
126 return TRUE;
127
128 for (i = 0; i < n && sel == -1 && snd_installed_cards[i].card_type; i++)
129 if (snd_installed_cards[i].enabled)
130 if (snd_installed_cards[i].card_type == unit)
131 sel = i;
132
133 if (sel == -1 && num_sound_cards < max_sound_cards)
134 {
135 int i;
136
137 i = sel = (num_sound_cards++);
138
139 snd_installed_cards[sel].card_type = unit;
140 snd_installed_cards[sel].enabled = 1;
141 }
142
143 if (sel != -1)
144 {
145 int drv;
146
147 snd_installed_cards[sel].for_driver_use = NULL;
148 snd_installed_cards[sel].config.io_base = hw_config->io_base;
149 snd_installed_cards[sel].config.irq = hw_config->irq;
150 snd_installed_cards[sel].config.dma = hw_config->dma;
151 snd_installed_cards[sel].config.dma2 = hw_config->dma2;
152 if ((drv = snd_find_driver (snd_installed_cards[sel].card_type)) == -1)
153 {
154 snd_installed_cards[sel].enabled = 0;
155 }
156 else if (sound_drivers[drv].probe (hw_config))
157 return TRUE;
158
159 snd_installed_cards[sel].enabled = 0;
160
161
162 return FALSE;
163 }
164
165 return FALSE;
166 }
167
168 int
169 sndtable_init_card (int unit, struct address_info *hw_config)
170 {
171 int i, n = num_sound_cards;
172
173 DDB (printk ("sndtable_init_card(%d) entered\n", unit));
174
175 if (!unit)
176 {
177 if (sndtable_init (0) != 0)
178 panic ("sound: Invalid memory allocation\n");
179 return TRUE;
180 }
181
182 for (i = 0; i < n && snd_installed_cards[i].card_type; i++)
183 if (snd_installed_cards[i].card_type == unit)
184 {
185 int drv;
186
187 snd_installed_cards[i].config.io_base = hw_config->io_base;
188 snd_installed_cards[i].config.irq = hw_config->irq;
189 snd_installed_cards[i].config.dma = hw_config->dma;
190 snd_installed_cards[i].config.dma2 = hw_config->dma2;
191
192 if ((drv = snd_find_driver (snd_installed_cards[i].card_type)) == -1)
193 snd_installed_cards[i].enabled = 0;
194
195
196 else
197 {
198
199 DDB (printk ("Located card - calling attach routine\n"));
200 printk ("snd%d", unit);
201 if (sound_drivers[drv].attach (0, hw_config) != 0)
202 panic ("sound: Invalid memory allocation\n");
203
204 DDB (printk ("attach routine finished\n"));
205 printk (" at 0x%x irq %d drq %d",
206 snd_installed_cards[i].config.io_base,
207 snd_installed_cards[i].config.irq,
208 snd_installed_cards[i].config.dma);
209 if (snd_installed_cards[i].config.dma2 != -1)
210 printk (",%d\n",
211 snd_installed_cards[i].config.dma2);
212 else
213 printk ("\n");
214 }
215 return TRUE;
216 }
217
218 printk ("sndtable_init_card: No card defined with type=%d, num cards: %d\n",
219 unit, num_sound_cards);
220 return FALSE;
221 }
222
223 int
224 sndtable_get_cardcount (void)
225 {
226 return num_audiodevs + num_mixers + num_synths + num_midis;
227 }
228
229 int
230 sndtable_identify_card (char *name)
231 {
232 int i, n = num_sound_drivers;
233
234 if (name == NULL)
235 return 0;
236
237 for (i = 0; i < n; i++)
238 if (sound_drivers[i].driver_id != NULL)
239 {
240 char *id = sound_drivers[i].driver_id;
241 int j;
242
243 for (j = 0; j < 80 && name[j] == id[j]; j++)
244 if (id[j] == 0 && name[j] == 0)
245 return sound_drivers[i].card_type;
246 }
247
248 return 0;
249 }
250
251 void
252 sound_setup (char *str, int *ints)
253 {
254 int i, n = num_sound_cards;
255
256
257
258
259
260 for (i = 0; i < n && snd_installed_cards[i].card_type; i++)
261 snd_installed_cards[i].enabled = 0;
262
263 if (ints[0] == 0 || ints[1] == 0)
264 return;
265
266
267
268
269 for (i = 1; i <= ints[0]; i++)
270 {
271 int card_type, ioaddr, irq, dma, ptr, j;
272 unsigned int val;
273
274 val = (unsigned int) ints[i];
275
276 card_type = (val & 0x0ff00000) >> 20;
277
278 if (card_type > 127)
279 {
280
281
282
283 return;
284 }
285
286 ioaddr = (val & 0x000fff00) >> 8;
287 irq = (val & 0x000000f0) >> 4;
288 dma = (val & 0x0000000f);
289
290 ptr = -1;
291 for (j = 0; j < n && ptr == -1; j++)
292 if (snd_installed_cards[j].card_type == card_type &&
293 !snd_installed_cards[j].enabled)
294
295
296 ptr = j;
297
298 if (ptr == -1)
299 printk ("Sound: Invalid setup parameter 0x%08x\n", val);
300 else
301 {
302 snd_installed_cards[ptr].enabled = 1;
303 snd_installed_cards[ptr].config.io_base = ioaddr;
304 snd_installed_cards[ptr].config.irq = irq;
305 snd_installed_cards[ptr].config.dma = dma;
306 snd_installed_cards[ptr].config.dma2 = -1;
307 }
308 }
309 }
310
311
312 struct address_info *
313 sound_getconf (int card_type)
314 {
315 int j, ptr;
316 int n = num_sound_cards;
317
318 ptr = -1;
319 for (j = 0; j < n && ptr == -1 && snd_installed_cards[j].card_type; j++)
320 if (snd_installed_cards[j].card_type == card_type)
321 ptr = j;
322
323 if (ptr == -1)
324 return (struct address_info *) NULL;
325
326 return &snd_installed_cards[ptr].config;
327 }
328
329 #else
330
331 void
332 sound_setup (char *str, int *ints)
333 {
334 }
335
336 #endif