This source file includes following definitions.
- snd_find_driver
- sndtable_init
- sndtable_probe
- sndtable_init_card
- sndtable_get_cardcount
- sound_setup
- sound_chconf
- 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 = sizeof (sound_drivers) / sizeof (struct driver_info);
39
40 for (i = 0; i < (n - 1); 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 = sizeof (snd_installed_cards) / sizeof (struct card_info);
53 int drv;
54
55 printk ("Sound initialization started\n");
56
57 for (i = 0; i < (n - 1); i++)
58 if (snd_installed_cards[i].enabled)
59 if ((drv = snd_find_driver (snd_installed_cards[i].card_type)) == -1)
60 snd_installed_cards[i].enabled = 0;
61
62
63 else if (sound_drivers[drv].probe (&snd_installed_cards[i].config))
64 {
65 #ifndef SHORT_BANNERS
66 printk ("snd%d",
67 snd_installed_cards[i].card_type);
68 #endif
69
70 mem_start = sound_drivers[drv].attach (mem_start, &snd_installed_cards[i].config);
71 #ifndef SHORT_BANNERS
72 printk (" at 0x%x irq %d drq %d\n",
73 snd_installed_cards[i].config.io_base,
74 snd_installed_cards[i].config.irq,
75 snd_installed_cards[i].config.dma);
76 #endif
77 }
78 else
79 snd_installed_cards[i].enabled = 0;
80
81
82 printk ("Sound initialization complete\n");
83 return mem_start;
84 }
85
86 int
87 sndtable_probe (int unit, struct address_info *hw_config)
88 {
89 int i, n = sizeof (snd_installed_cards) / sizeof (struct card_info);
90
91 if (!unit)
92 return TRUE;
93
94 for (i = 0; i < (n - 1); i++)
95 if (snd_installed_cards[i].enabled)
96 if (snd_installed_cards[i].card_type == unit)
97 {
98 int drv;
99
100 snd_installed_cards[i].config.io_base = hw_config->io_base;
101 snd_installed_cards[i].config.irq = hw_config->irq;
102 snd_installed_cards[i].config.dma = hw_config->dma;
103 if ((drv = snd_find_driver (snd_installed_cards[i].card_type)) == -1)
104 snd_installed_cards[i].enabled = 0;
105
106
107
108 else if (sound_drivers[drv].probe (hw_config))
109 return 1;
110 snd_installed_cards[i].enabled = 0;
111
112
113 return 0;
114 }
115
116 return FALSE;
117 }
118
119 int
120 sndtable_init_card (int unit, struct address_info *hw_config)
121 {
122 int i, n = sizeof (snd_installed_cards) / sizeof (struct card_info);
123
124 if (!unit)
125 {
126 if (sndtable_init (0) != 0)
127 panic ("snd: Invalid memory allocation\n");
128 return TRUE;
129 }
130
131 for (i = 0; i < (n - 1); i++)
132 if (snd_installed_cards[i].card_type == unit)
133 {
134 int drv;
135
136 snd_installed_cards[i].config.io_base = hw_config->io_base;
137 snd_installed_cards[i].config.irq = hw_config->irq;
138 snd_installed_cards[i].config.dma = hw_config->dma;
139
140 if ((drv = snd_find_driver (snd_installed_cards[i].card_type)) == -1)
141 snd_installed_cards[i].enabled = 0;
142
143
144 else if (sound_drivers[drv].attach (0, hw_config) != 0)
145 panic ("snd#: Invalid memory allocation\n");
146 return TRUE;
147 }
148
149 return FALSE;
150 }
151
152 int
153 sndtable_get_cardcount (void)
154 {
155 return num_audiodevs + num_mixers + num_synths + num_midis;
156 }
157
158 #ifdef linux
159 void
160 sound_setup (char *str, int *ints)
161 {
162 int i, n = sizeof (snd_installed_cards) / sizeof (struct card_info);
163
164
165
166
167
168 for (i = 0; i < n; i++)
169 snd_installed_cards[i].enabled = 0;
170
171 if (ints[0] == 0 || ints[1] == 0)
172 return;
173
174
175
176
177 for (i = 1; i <= ints[0]; i++)
178 {
179 int card_type, ioaddr, irq, dma, ptr, j;
180 unsigned int val;
181
182 val = (unsigned int) ints[i];
183
184 card_type = (val & 0x0ff00000) >> 20;
185
186 if (card_type > 127)
187 {
188
189
190
191 return;
192 }
193
194 ioaddr = (val & 0x000fff00) >> 8;
195 irq = (val & 0x000000f0) >> 4;
196 dma = (val & 0x0000000f);
197
198 ptr = -1;
199 for (j = 0; j < n && ptr == -1; j++)
200 if (snd_installed_cards[j].card_type == card_type &&
201 !snd_installed_cards[j].enabled)
202
203
204 ptr = j;
205
206 if (ptr == -1)
207 printk ("Sound: Invalid setup parameter 0x%08x\n", val);
208 else
209 {
210 snd_installed_cards[ptr].enabled = 1;
211 snd_installed_cards[ptr].config.io_base = ioaddr;
212 snd_installed_cards[ptr].config.irq = irq;
213 snd_installed_cards[ptr].config.dma = dma;
214 }
215 }
216 }
217
218 #else
219 void
220 sound_chconf (int card_type, int ioaddr, int irq, int dma)
221 {
222 int i, n = sizeof (snd_installed_cards) / sizeof (struct card_info);
223
224 int ptr, j;
225
226 ptr = -1;
227 for (j = 0; j < n && ptr == -1; j++)
228 if (snd_installed_cards[j].card_type == card_type &&
229 !snd_installed_cards[j].enabled)
230
231
232 ptr = j;
233
234 if (ptr != -1)
235 {
236 snd_installed_cards[ptr].enabled = 1;
237 if (ioaddr)
238 snd_installed_cards[ptr].config.io_base = ioaddr;
239 if (irq)
240 snd_installed_cards[ptr].config.irq = irq;
241 if (dma)
242 snd_installed_cards[ptr].config.dma = dma;
243 }
244 }
245
246 #endif
247
248 struct address_info *
249 sound_getconf (int card_type)
250 {
251 int j, ptr;
252 int n = sizeof (snd_installed_cards) / sizeof (struct card_info);
253
254 ptr = -1;
255 for (j = 0; j < n && ptr == -1; j++)
256 if (snd_installed_cards[j].card_type == card_type)
257 ptr = j;
258
259 if (ptr == -1)
260 return (struct address_info *) NULL;
261
262 return &snd_installed_cards[ptr].config;
263 }
264
265 #else
266
267 void
268 sound_setup (char *str, int *ints)
269 {
270 }
271
272 #endif