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