1 | /*
|
---|
2 | * Driver for SoundBlaster 16/AWE32/AWE64 soundcards
|
---|
3 | * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
|
---|
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
19 | *
|
---|
20 | */
|
---|
21 |
|
---|
22 | #define SNDRV_MAIN_OBJECT_FILE
|
---|
23 | #include <sound/driver.h>
|
---|
24 | #include <sound/sb.h>
|
---|
25 | #include <sound/sb16_csp.h>
|
---|
26 | #include <sound/mpu401.h>
|
---|
27 | #include <sound/opl3.h>
|
---|
28 | #include <sound/emu8000.h>
|
---|
29 | #include <sound/seq_device.h>
|
---|
30 | #define SNDRV_LEGACY_AUTO_PROBE
|
---|
31 | #define SNDRV_LEGACY_FIND_FREE_IRQ
|
---|
32 | #define SNDRV_LEGACY_FIND_FREE_DMA
|
---|
33 | #define SNDRV_GET_ID
|
---|
34 | #include <sound/initval.h>
|
---|
35 |
|
---|
36 | EXPORT_NO_SYMBOLS;
|
---|
37 | #ifndef SNDRV_SBAWE
|
---|
38 | MODULE_DESCRIPTION("Sound Blaster 16");
|
---|
39 | MODULE_CLASSES("{sound}");
|
---|
40 | MODULE_DEVICES("{{Creative Labs,SB 16},"
|
---|
41 | "{Creative Labs,SB Vibra16S},"
|
---|
42 | "{Creative Labs,SB Vibra16C},"
|
---|
43 | "{Creative Labs,SB Vibra16CL},"
|
---|
44 | "{Creative Labs,SB Vibra16X}}");
|
---|
45 | #else
|
---|
46 | MODULE_DESCRIPTION("Sound Blaster AWE");
|
---|
47 | MODULE_CLASSES("{sound}");
|
---|
48 | MODULE_DEVICES("{{Creative Labs,SB AWE 32},"
|
---|
49 | "{Creative Labs,SB AWE 64},"
|
---|
50 | "{Creative Labs,SB AWE 64 Gold}}");
|
---|
51 | #endif
|
---|
52 |
|
---|
53 | #if 0
|
---|
54 | #define SNDRV_DEBUG_IRQ
|
---|
55 | #endif
|
---|
56 |
|
---|
57 | #if defined(SNDRV_SBAWE) && defined(CONFIG_SND_SEQUENCER) && defined(CONFIG_SND_SYNTH_EMU8000)
|
---|
58 | #define SNDRV_SBAWE_EMU8000
|
---|
59 | #endif
|
---|
60 |
|
---|
61 | static int snd_index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
|
---|
62 | static char *snd_id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
|
---|
63 | static int snd_enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
|
---|
64 | #ifdef __ISAPNP__
|
---|
65 | #ifdef TARGET_OS2
|
---|
66 | static int snd_isapnp[SNDRV_CARDS] = {1,1,1,1,1,1,1,1};
|
---|
67 | #else
|
---|
68 | static int snd_isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
|
---|
69 | #endif
|
---|
70 | #endif
|
---|
71 | static long snd_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260,0x280 */
|
---|
72 | #ifdef TARGET_OS2
|
---|
73 | static long snd_mpu_port[SNDRV_CARDS] = {0x330, 0x300, -1,-1,-1,-1,-1,-1};
|
---|
74 | #else
|
---|
75 | static long snd_mpu_port[SNDRV_CARDS] = {0x330, 0x300,[2 ... (SNDRV_CARDS - 1)] = -1};
|
---|
76 | #endif
|
---|
77 | static long snd_fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
|
---|
78 | #ifdef SNDRV_SBAWE_EMU8000
|
---|
79 | static long snd_awe_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
|
---|
80 | #endif
|
---|
81 | static int snd_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,10 */
|
---|
82 | static int snd_dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3 */
|
---|
83 | static int snd_dma16[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 5,6,7 */
|
---|
84 | #ifdef TARGET_OS2
|
---|
85 | static int snd_mic_agc[SNDRV_CARDS] = {1,1,1,1,1,1,1,1};
|
---|
86 | #ifdef CONFIG_SND_SB16_CSP
|
---|
87 | static int snd_csp[SNDRV_CARDS] = {0,0,0,0,0,0,0,0};
|
---|
88 | #endif
|
---|
89 | #ifdef SNDRV_SBAWE_EMU8000
|
---|
90 | static int snd_seq_ports[SNDRV_CARDS] = {4,4,4,4,4,4,4,4};
|
---|
91 | #endif
|
---|
92 | #else
|
---|
93 | static int snd_mic_agc[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
|
---|
94 | #ifdef CONFIG_SND_SB16_CSP
|
---|
95 | static int snd_csp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
|
---|
96 | #endif
|
---|
97 | #ifdef SNDRV_SBAWE_EMU8000
|
---|
98 | static int snd_seq_ports[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 4};
|
---|
99 | #endif
|
---|
100 | #endif
|
---|
101 |
|
---|
102 | MODULE_PARM(snd_index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
103 | MODULE_PARM_DESC(snd_index, "Index value for SoundBlaster 16 soundcard.");
|
---|
104 | MODULE_PARM_SYNTAX(snd_index, SNDRV_INDEX_DESC);
|
---|
105 | MODULE_PARM(snd_id, "1-" __MODULE_STRING(SNDRV_CARDS) "s");
|
---|
106 | MODULE_PARM_DESC(snd_id, "ID string for SoundBlaster 16 soundcard.");
|
---|
107 | MODULE_PARM_SYNTAX(snd_id, SNDRV_ID_DESC);
|
---|
108 | MODULE_PARM(snd_enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
109 | MODULE_PARM_DESC(snd_enable, "Enable SoundBlaster 16 soundcard.");
|
---|
110 | MODULE_PARM_SYNTAX(snd_enable, SNDRV_ENABLE_DESC);
|
---|
111 | #ifdef __ISAPNP__
|
---|
112 | MODULE_PARM(snd_isapnp, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
113 | MODULE_PARM_DESC(snd_isapnp, "ISA PnP detection for specified soundcard.");
|
---|
114 | MODULE_PARM_SYNTAX(snd_isapnp, SNDRV_ISAPNP_DESC);
|
---|
115 | #endif
|
---|
116 | MODULE_PARM(snd_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
|
---|
117 | MODULE_PARM_DESC(snd_port, "Port # for SB16 driver.");
|
---|
118 | MODULE_PARM_SYNTAX(snd_port, SNDRV_ENABLED ",allows:{{0x220},{0x240},{0x260},{0x280}},dialog:list");
|
---|
119 | MODULE_PARM(snd_mpu_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
|
---|
120 | MODULE_PARM_DESC(snd_mpu_port, "MPU-401 port # for SB16 driver.");
|
---|
121 | MODULE_PARM_SYNTAX(snd_mpu_port, SNDRV_ENABLED ",allows:{{0x330},{0x300}},dialog:list");
|
---|
122 | MODULE_PARM(snd_fm_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
|
---|
123 | MODULE_PARM_DESC(snd_fm_port, "FM port # for SB16 PnP driver.");
|
---|
124 | MODULE_PARM_SYNTAX(snd_fm_port, SNDRV_ENABLED ",allows:{{0x388},{0x38c},{0x390},{0x394}},dialog:list");
|
---|
125 | #ifdef SNDRV_SBAWE_EMU8000
|
---|
126 | MODULE_PARM(snd_awe_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
|
---|
127 | MODULE_PARM_DESC(snd_awe_port, "AWE port # for SB16 PnP driver.");
|
---|
128 | MODULE_PARM_SYNTAX(snd_awe_port, SNDRV_ENABLED ",allows:{{0x620},{0x640},{0x660},{0x680}},dialog:list");
|
---|
129 | #endif
|
---|
130 | MODULE_PARM(snd_irq, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
131 | MODULE_PARM_DESC(snd_irq, "IRQ # for SB16 driver.");
|
---|
132 | MODULE_PARM_SYNTAX(snd_irq, SNDRV_IRQ_DESC);
|
---|
133 | MODULE_PARM(snd_dma8, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
134 | MODULE_PARM_DESC(snd_dma8, "8-bit DMA # for SB16 driver.");
|
---|
135 | MODULE_PARM_SYNTAX(snd_dma8, SNDRV_DMA8_DESC);
|
---|
136 | MODULE_PARM(snd_dma16, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
137 | MODULE_PARM_DESC(snd_dma16, "16-bit DMA # for SB16 driver.");
|
---|
138 | MODULE_PARM_SYNTAX(snd_dma16, SNDRV_DMA16_DESC);
|
---|
139 | MODULE_PARM(snd_mic_agc, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
140 | MODULE_PARM_DESC(snd_mic_agc, "Mic Auto-Gain-Control switch.");
|
---|
141 | MODULE_PARM_SYNTAX(snd_mic_agcm, SNDRV_ENABLED "," SNDRV_BOOLEAN_TRUE_DESC);
|
---|
142 | #ifdef CONFIG_SND_SB16_CSP
|
---|
143 | MODULE_PARM(snd_csp, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
144 | MODULE_PARM_DESC(snd_csp, "ASP/CSP chip support.");
|
---|
145 | MODULE_PARM_SYNTAX(snd_csp, SNDRV_ENABLED "," SNDRV_ENABLE_DESC);
|
---|
146 | #endif
|
---|
147 | #ifdef SNDRV_SBAWE_EMU8000
|
---|
148 | MODULE_PARM(snd_seq_ports, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
149 | MODULE_PARM_DESC(snd_seq_ports, "Number of sequencer ports for WaveTable synth.");
|
---|
150 | MODULE_PARM_SYNTAX(snd_seq_ports, SNDRV_ENABLED ",allows:{{0,8}},skill:advanced");
|
---|
151 | #endif
|
---|
152 |
|
---|
153 | struct snd_sb16 {
|
---|
154 | struct resource *fm_res; /* used to block FM i/o region for legacy cards */
|
---|
155 | #ifdef __ISAPNP__
|
---|
156 | struct isapnp_dev *dev;
|
---|
157 | #ifdef SNDRV_SBAWE_EMU8000
|
---|
158 | struct isapnp_dev *devwt;
|
---|
159 | #endif
|
---|
160 | #endif
|
---|
161 | };
|
---|
162 |
|
---|
163 | static snd_card_t *snd_sb16_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
|
---|
164 |
|
---|
165 | #ifdef __ISAPNP__
|
---|
166 |
|
---|
167 | static struct isapnp_card *snd_sb16_isapnp_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
|
---|
168 | static const struct isapnp_card_id *snd_sb16_isapnp_id[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
|
---|
169 |
|
---|
170 | #ifdef TARGET_OS2
|
---|
171 | #define ISAPNP_SB16(_va, _vb, _vc, _device, _audio) \
|
---|
172 | { \
|
---|
173 | 0, ISAPNP_CARD_ID(_va, _vb, _vc, _device), \
|
---|
174 | { ISAPNP_DEVICE_ID(_va, _vb, _vc, _audio), } \
|
---|
175 | }
|
---|
176 | #define ISAPNP_SBAWE(_va, _vb, _vc, _device, _audio, _awe) \
|
---|
177 | { \
|
---|
178 | 0, ISAPNP_CARD_ID(_va, _vb, _vc, _device), \
|
---|
179 | { ISAPNP_DEVICE_ID(_va, _vb, _vc, _audio), \
|
---|
180 | ISAPNP_DEVICE_ID(_va, _vb, _vc, _awe), } \
|
---|
181 | }
|
---|
182 | #else
|
---|
183 | #define ISAPNP_SB16(_va, _vb, _vc, _device, _audio) \
|
---|
184 | { \
|
---|
185 | ISAPNP_CARD_ID(_va, _vb, _vc, _device), \
|
---|
186 | devs : { ISAPNP_DEVICE_ID(_va, _vb, _vc, _audio), } \
|
---|
187 | }
|
---|
188 | #define ISAPNP_SBAWE(_va, _vb, _vc, _device, _audio, _awe) \
|
---|
189 | { \
|
---|
190 | ISAPNP_CARD_ID(_va, _vb, _vc, _device), \
|
---|
191 | devs : { ISAPNP_DEVICE_ID(_va, _vb, _vc, _audio), \
|
---|
192 | ISAPNP_DEVICE_ID(_va, _vb, _vc, _awe), } \
|
---|
193 | }
|
---|
194 | #endif
|
---|
195 |
|
---|
196 | static struct isapnp_card_id snd_sb16_pnpids[] __devinitdata = {
|
---|
197 | #ifndef SNDRV_SBAWE
|
---|
198 | /* Sound Blaster 16 PnP */
|
---|
199 | ISAPNP_SB16('C','T','L',0x0024,0x0031),
|
---|
200 | /* Sound Blaster 16 PnP */
|
---|
201 | ISAPNP_SB16('C','T','L',0x0026,0x0031),
|
---|
202 | /* Sound Blaster 16 PnP */
|
---|
203 | ISAPNP_SB16('C','T','L',0x0027,0x0031),
|
---|
204 | /* Sound Blaster 16 PnP */
|
---|
205 | ISAPNP_SB16('C','T','L',0x0028,0x0031),
|
---|
206 | /* Sound Blaster 16 PnP */
|
---|
207 | ISAPNP_SB16('C','T','L',0x0029,0x0031),
|
---|
208 | /* Sound Blaster 16 PnP */
|
---|
209 | ISAPNP_SB16('C','T','L',0x002a,0x0031),
|
---|
210 | /* Sound Blaster 16 PnP */
|
---|
211 | /* Note: This card has also a CTL0051:StereoEnhance device!!! */
|
---|
212 | ISAPNP_SB16('C','T','L',0x002b,0x0031),
|
---|
213 | /* Sound Blaster 16 PnP */
|
---|
214 | ISAPNP_SB16('C','T','L',0x002c,0x0031),
|
---|
215 | /* Sound Blaster Vibra16S */
|
---|
216 | ISAPNP_SB16('C','T','L',0x0051,0x0001),
|
---|
217 | /* Sound Blaster Vibra16C */
|
---|
218 | ISAPNP_SB16('C','T','L',0x0070,0x0001),
|
---|
219 | /* Sound Blaster Vibra16CL - added by ctm@ardi.com */
|
---|
220 | ISAPNP_SB16('C','T','L',0x0080,0x0041),
|
---|
221 | /* Sound Blaster Vibra16X */
|
---|
222 | ISAPNP_SB16('C','T','L',0x00f0,0x0043),
|
---|
223 | #else /* SNDRV_SBAWE defined */
|
---|
224 | /* Sound Blaster AWE 32 PnP */
|
---|
225 | ISAPNP_SBAWE('C','T','L',0x0035,0x0031,0x0021),
|
---|
226 | /* Sound Blaster AWE 32 PnP */
|
---|
227 | ISAPNP_SBAWE('C','T','L',0x0039,0x0031,0x0021),
|
---|
228 | /* Sound Blaster AWE 32 PnP */
|
---|
229 | ISAPNP_SBAWE('C','T','L',0x0042,0x0031,0x0021),
|
---|
230 | /* Sound Blaster AWE 32 PnP */
|
---|
231 | ISAPNP_SBAWE('C','T','L',0x0043,0x0031,0x0021),
|
---|
232 | /* Sound Blaster AWE 32 PnP */
|
---|
233 | /* Note: This card has also a CTL0051:StereoEnhance device!!! */
|
---|
234 | ISAPNP_SBAWE('C','T','L',0x0044,0x0031,0x0021),
|
---|
235 | /* Sound Blaster AWE 32 PnP */
|
---|
236 | /* Note: This card has also a CTL0051:StereoEnhance device!!! */
|
---|
237 | ISAPNP_SBAWE('C','T','L',0x0045,0x0031,0x0021),
|
---|
238 | /* Sound Blaster AWE 32 PnP */
|
---|
239 | ISAPNP_SBAWE('C','T','L',0x0047,0x0031,0x0021),
|
---|
240 | /* Sound Blaster AWE 32 PnP */
|
---|
241 | ISAPNP_SBAWE('C','T','L',0x0048,0x0031,0x0021),
|
---|
242 | /* Sound Blaster AWE 32 PnP */
|
---|
243 | ISAPNP_SBAWE('C','T','L',0x0054,0x0031,0x0021),
|
---|
244 | /* Sound Blaster AWE 32 PnP */
|
---|
245 | ISAPNP_SBAWE('C','T','L',0x009a,0x0041,0x0021),
|
---|
246 | /* Sound Blaster AWE 32 PnP */
|
---|
247 | ISAPNP_SBAWE('C','T','L',0x009c,0x0041,0x0021),
|
---|
248 | /* Sound Blaster 32 PnP */
|
---|
249 | ISAPNP_SBAWE('C','T','L',0x009f,0x0041,0x0021),
|
---|
250 | /* Sound Blaster AWE 64 PnP */
|
---|
251 | ISAPNP_SBAWE('C','T','L',0x009d,0x0042,0x0022),
|
---|
252 | /* Sound Blaster AWE 64 PnP Gold */
|
---|
253 | ISAPNP_SBAWE('C','T','L',0x009e,0x0044,0x0023),
|
---|
254 | /* Sound Blaster AWE 64 PnP Gold */
|
---|
255 | ISAPNP_SBAWE('C','T','L',0x00b2,0x0044,0x0023),
|
---|
256 | /* Sound Blaster AWE 64 PnP */
|
---|
257 | ISAPNP_SBAWE('C','T','L',0x00c1,0x0042,0x0022),
|
---|
258 | /* Sound Blaster AWE 64 PnP */
|
---|
259 | ISAPNP_SBAWE('C','T','L',0x00c3,0x0045,0x0022),
|
---|
260 | /* Sound Blaster AWE 64 PnP */
|
---|
261 | ISAPNP_SBAWE('C','T','L',0x00c5,0x0045,0x0022),
|
---|
262 | /* Sound Blaster AWE 64 PnP */
|
---|
263 | ISAPNP_SBAWE('C','T','L',0x00c7,0x0045,0x0022),
|
---|
264 | /* Sound Blaster AWE 64 PnP */
|
---|
265 | ISAPNP_SBAWE('C','T','L',0x00e4,0x0045,0x0022),
|
---|
266 | /* Sound Blaster 16 PnP (AWE) */
|
---|
267 | ISAPNP_SBAWE('C','T','L',0x00ed,0x0041,0x0070),
|
---|
268 | /* Generic entries */
|
---|
269 | ISAPNP_SBAWE('C','T','L',ISAPNP_ANY_ID,0x0031,0x0021),
|
---|
270 | ISAPNP_SBAWE('C','T','L',ISAPNP_ANY_ID,0x0041,0x0021),
|
---|
271 | ISAPNP_SBAWE('C','T','L',ISAPNP_ANY_ID,0x0042,0x0022),
|
---|
272 | ISAPNP_SBAWE('C','T','L',ISAPNP_ANY_ID,0x0044,0x0023),
|
---|
273 | ISAPNP_SBAWE('C','T','L',ISAPNP_ANY_ID,0x0045,0x0022),
|
---|
274 | #endif /* SNDRV_SBAWE */
|
---|
275 | { ISAPNP_CARD_END, }
|
---|
276 | };
|
---|
277 |
|
---|
278 | ISAPNP_CARD_TABLE(snd_sb16_pnpids);
|
---|
279 |
|
---|
280 | static int __init snd_sb16_isapnp(int dev, struct snd_sb16 *acard)
|
---|
281 | {
|
---|
282 | const struct isapnp_card_id *id = snd_sb16_isapnp_id[dev];
|
---|
283 | struct isapnp_card *card = snd_sb16_isapnp_cards[dev];
|
---|
284 | struct isapnp_dev *pdev;
|
---|
285 |
|
---|
286 | acard->dev = isapnp_find_dev(card, id->devs[0].vendor, id->devs[0].function, NULL);
|
---|
287 | if (acard->dev->active) {
|
---|
288 | acard->dev = NULL;
|
---|
289 | return -EBUSY;
|
---|
290 | }
|
---|
291 | #ifdef SNDRV_SBAWE_EMU8000
|
---|
292 | acard->devwt = isapnp_find_dev(card, id->devs[1].vendor, id->devs[1].function, NULL);
|
---|
293 | if (acard->devwt->active) {
|
---|
294 | acard->dev = acard->devwt = NULL;
|
---|
295 | return -EBUSY;
|
---|
296 | }
|
---|
297 | #endif
|
---|
298 | /* Audio initialization */
|
---|
299 | pdev = acard->dev;
|
---|
300 | if (pdev->prepare(pdev) < 0)
|
---|
301 | return -EAGAIN;
|
---|
302 | if (snd_port[dev] != SNDRV_AUTO_PORT)
|
---|
303 | isapnp_resource_change(&pdev->resource[0], snd_port[dev], 16);
|
---|
304 | if (snd_mpu_port[dev] != SNDRV_AUTO_PORT)
|
---|
305 | isapnp_resource_change(&pdev->resource[1], snd_mpu_port[dev], 2);
|
---|
306 | if (snd_fm_port[dev] != SNDRV_AUTO_PORT)
|
---|
307 | isapnp_resource_change(&pdev->resource[2], snd_fm_port[dev], 4);
|
---|
308 | if (snd_dma8[dev] != SNDRV_AUTO_DMA)
|
---|
309 | isapnp_resource_change(&pdev->dma_resource[0], snd_dma8[dev], 1);
|
---|
310 | if (snd_dma16[dev] != SNDRV_AUTO_DMA)
|
---|
311 | isapnp_resource_change(&pdev->dma_resource[1], snd_dma16[dev], 1);
|
---|
312 | if (snd_irq[dev] != SNDRV_AUTO_IRQ)
|
---|
313 | isapnp_resource_change(&pdev->irq_resource[0], snd_irq[dev], 1);
|
---|
314 | if (pdev->activate(pdev) < 0) {
|
---|
315 | snd_printk("isapnp configure failure (out of resources?)\n");
|
---|
316 | return -EBUSY;
|
---|
317 | }
|
---|
318 | snd_port[dev] = pdev->resource[0].start;
|
---|
319 | snd_mpu_port[dev] = pdev->resource[1].start;
|
---|
320 | snd_fm_port[dev] = pdev->resource[2].start;
|
---|
321 | snd_dma8[dev] = pdev->dma_resource[0].start;
|
---|
322 | snd_dma16[dev] = pdev->dma_resource[1].start;
|
---|
323 | snd_irq[dev] = pdev->irq_resource[0].start;
|
---|
324 | snd_printdd("isapnp SB16: port=0x%lx, mpu port=0x%lx, fm port=0x%lx\n",
|
---|
325 | snd_port[dev], snd_mpu_port[dev], snd_fm_port[dev]);
|
---|
326 | snd_printdd("isapnp SB16: dma1=%i, dma2=%i, irq=%i\n",
|
---|
327 | snd_dma8[dev], snd_dma16[dev], snd_irq[dev]);
|
---|
328 | #ifdef SNDRV_SBAWE_EMU8000
|
---|
329 | /* WaveTable initialization */
|
---|
330 | pdev = acard->devwt;
|
---|
331 | if (pdev->prepare(pdev)<0) {
|
---|
332 | acard->dev->deactivate(acard->dev);
|
---|
333 | return -EAGAIN;
|
---|
334 | }
|
---|
335 | if (snd_awe_port[dev] != SNDRV_AUTO_PORT)
|
---|
336 | isapnp_resource_change(&pdev->resource[0], snd_awe_port[dev], 4);
|
---|
337 | if (pdev->activate(pdev)<0) {
|
---|
338 | snd_printk("WaveTable isapnp configure failure (out of resources?)\n");
|
---|
339 | acard->dev->deactivate(acard->dev);
|
---|
340 | return -EBUSY;
|
---|
341 | }
|
---|
342 | snd_awe_port[dev] = pdev->resource[0].start;
|
---|
343 | snd_printdd("isapnp SB16: wavetable port=0x%lx\n", pdev->resource[0].start);
|
---|
344 | #endif
|
---|
345 | return 0;
|
---|
346 | }
|
---|
347 |
|
---|
348 | static void snd_sb16_deactivate(struct snd_sb16 *acard)
|
---|
349 | {
|
---|
350 | if (acard->dev) {
|
---|
351 | acard->dev->deactivate(acard->dev);
|
---|
352 | acard->dev = NULL;
|
---|
353 | }
|
---|
354 | #ifdef SNDRV_SBAWE_EMU8000
|
---|
355 | if (acard->devwt) {
|
---|
356 | acard->devwt->deactivate(acard->devwt);
|
---|
357 | acard->devwt = NULL;
|
---|
358 | }
|
---|
359 | #endif
|
---|
360 | }
|
---|
361 |
|
---|
362 | #endif /* __ISAPNP__ */
|
---|
363 |
|
---|
364 | static void snd_sb16_free(snd_card_t *card)
|
---|
365 | {
|
---|
366 | struct snd_sb16 *acard = (struct snd_sb16 *)card->private_data;
|
---|
367 |
|
---|
368 | if (acard == NULL)
|
---|
369 | return;
|
---|
370 | if (acard->fm_res)
|
---|
371 | release_resource(acard->fm_res);
|
---|
372 | #ifdef __ISAPNP__
|
---|
373 | snd_sb16_deactivate(acard);
|
---|
374 | #endif
|
---|
375 | }
|
---|
376 |
|
---|
377 | static int __init snd_sb16_probe(int dev)
|
---|
378 | {
|
---|
379 | static int possible_irqs[] = {5, 9, 10, 7, -1};
|
---|
380 | static int possible_dmas8[] = {1, 3, 0, -1};
|
---|
381 | static int possible_dmas16[] = {5, 6, 7, -1};
|
---|
382 | int irq, dma8, dma16;
|
---|
383 | sb_t *chip;
|
---|
384 | snd_card_t *card;
|
---|
385 | struct snd_sb16 *acard;
|
---|
386 | opl3_t *opl3;
|
---|
387 | snd_hwdep_t *synth = NULL;
|
---|
388 | snd_hwdep_t *csp = NULL;
|
---|
389 | unsigned long flags;
|
---|
390 | int err;
|
---|
391 |
|
---|
392 | card = snd_card_new(snd_index[dev], snd_id[dev], THIS_MODULE,
|
---|
393 | sizeof(struct snd_sb16));
|
---|
394 | if (card == NULL)
|
---|
395 | return -ENOMEM;
|
---|
396 | acard = (struct snd_sb16 *) card->private_data;
|
---|
397 | card->private_free = snd_sb16_free;
|
---|
398 | #ifdef __ISAPNP__
|
---|
399 | if (snd_isapnp[dev] && snd_sb16_isapnp(dev, acard) < 0) {
|
---|
400 | snd_card_free(card);
|
---|
401 | return -EBUSY;
|
---|
402 | }
|
---|
403 | #endif
|
---|
404 |
|
---|
405 | irq = snd_irq[dev];
|
---|
406 | dma8 = snd_dma8[dev];
|
---|
407 | dma16 = snd_dma16[dev];
|
---|
408 | #ifdef __ISAPNP__
|
---|
409 | if (!snd_isapnp[dev]) {
|
---|
410 | #endif
|
---|
411 | if (irq == SNDRV_AUTO_IRQ) {
|
---|
412 | if ((irq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
|
---|
413 | snd_card_free(card);
|
---|
414 | snd_printk("unable to find a free IRQ\n");
|
---|
415 | return -EBUSY;
|
---|
416 | }
|
---|
417 | }
|
---|
418 | if (dma8 == SNDRV_AUTO_DMA) {
|
---|
419 | if ((dma8 = snd_legacy_find_free_dma(possible_dmas8)) < 0) {
|
---|
420 | snd_card_free(card);
|
---|
421 | snd_printk("unable to find a free 8-bit DMA\n");
|
---|
422 | return -EBUSY;
|
---|
423 | }
|
---|
424 | }
|
---|
425 | if (dma16 == SNDRV_AUTO_DMA) {
|
---|
426 | if ((dma16 = snd_legacy_find_free_dma(possible_dmas16)) < 0) {
|
---|
427 | snd_card_free(card);
|
---|
428 | snd_printk("unable to find a free 16-bit DMA\n");
|
---|
429 | return -EBUSY;
|
---|
430 | }
|
---|
431 | }
|
---|
432 | /* non-PnP FM port address is hardwired with base port address */
|
---|
433 | snd_fm_port[dev] = snd_port[dev];
|
---|
434 | /* block the 0x388 port to avoid PnP conflicts */
|
---|
435 | acard->fm_res = request_region(0x388, 4, "SoundBlaster FM");
|
---|
436 | #ifdef SNDRV_SBAWE_EMU8000
|
---|
437 | /* non-PnP AWE port address is hardwired with base port address */
|
---|
438 | snd_awe_port[dev] = snd_port[dev] + 0x400;
|
---|
439 | #endif
|
---|
440 | #ifdef __ISAPNP__
|
---|
441 | }
|
---|
442 | #endif
|
---|
443 |
|
---|
444 | if ((err = snd_sbdsp_create(card,
|
---|
445 | snd_port[dev],
|
---|
446 | irq,
|
---|
447 | snd_sb16dsp_interrupt,
|
---|
448 | dma8,
|
---|
449 | dma16,
|
---|
450 | SB_HW_AUTO,
|
---|
451 | &chip)) < 0) {
|
---|
452 | snd_card_free(card);
|
---|
453 | return err;
|
---|
454 | }
|
---|
455 | if (chip->hardware != SB_HW_16) {
|
---|
456 | snd_card_free(card);
|
---|
457 | snd_printdd("SB 16 chip was not detected at 0x%lx\n", snd_port[dev]);
|
---|
458 | return -ENODEV;
|
---|
459 | }
|
---|
460 | chip->mpu_port = snd_mpu_port[dev];
|
---|
461 | #ifdef __ISAPNP__
|
---|
462 | if (!snd_isapnp[dev] && (err = snd_sb16dsp_configure(chip)) < 0) {
|
---|
463 | #else
|
---|
464 | if ((err = snd_sb16dsp_configure(chip)) < 0) {
|
---|
465 | #endif
|
---|
466 | snd_card_free(card);
|
---|
467 | return -ENXIO;
|
---|
468 | }
|
---|
469 | if ((err = snd_sb16dsp_pcm(chip, 0, NULL)) < 0) {
|
---|
470 | snd_card_free(card);
|
---|
471 | return -ENXIO;
|
---|
472 | }
|
---|
473 |
|
---|
474 | if (chip->mpu_port) {
|
---|
475 | if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_SB,
|
---|
476 | chip->mpu_port, 0,
|
---|
477 | irq, 0, &chip->rmidi)) < 0) {
|
---|
478 | snd_card_free(card);
|
---|
479 | return -ENXIO;
|
---|
480 | }
|
---|
481 | }
|
---|
482 |
|
---|
483 | if (snd_fm_port[dev] > 0) {
|
---|
484 | if (snd_opl3_create(card, snd_fm_port[dev], snd_fm_port[dev] + 2,
|
---|
485 | OPL3_HW_OPL3, snd_fm_port[dev] == snd_port[dev],
|
---|
486 | &opl3) < 0) {
|
---|
487 | snd_printk("no OPL device at 0x%lx-0x%lx\n",
|
---|
488 | snd_fm_port[dev], snd_fm_port[dev] + 2);
|
---|
489 | } else {
|
---|
490 | #ifdef SNDRV_SBAWE_EMU8000
|
---|
491 | int seqdev = snd_awe_port[dev] > 0 ? 2 : 1;
|
---|
492 | #else
|
---|
493 | int seqdev = 1;
|
---|
494 | #endif
|
---|
495 | if ((err = snd_opl3_hwdep_new(opl3, 0, seqdev, &synth)) < 0) {
|
---|
496 | snd_card_free(card);
|
---|
497 | return -ENXIO;
|
---|
498 | }
|
---|
499 | }
|
---|
500 | }
|
---|
501 |
|
---|
502 | if ((err = snd_sbmixer_new(chip)) < 0) {
|
---|
503 | snd_card_free(card);
|
---|
504 | return -ENXIO;
|
---|
505 | }
|
---|
506 |
|
---|
507 | #ifdef CONFIG_SND_SB16_CSP
|
---|
508 | /* CSP chip on SB16ASP/AWE32 */
|
---|
509 | if ((chip->hardware == SB_HW_16) && snd_csp[dev]) {
|
---|
510 | snd_sb_csp_new(chip, synth != NULL ? 1 : 0, &csp);
|
---|
511 | if (csp) {
|
---|
512 | chip->csp = csp->private_data;
|
---|
513 | chip->hardware = SB_HW_16CSP;
|
---|
514 | } else {
|
---|
515 | snd_printk("warning - CSP chip not detected on soundcard #%i\n", dev + 1);
|
---|
516 | }
|
---|
517 | }
|
---|
518 | #endif
|
---|
519 | #ifdef SNDRV_SBAWE_EMU8000
|
---|
520 | if (snd_awe_port[dev] > 0) {
|
---|
521 | if (snd_emu8000_new(card, 1, snd_awe_port[dev],
|
---|
522 | snd_seq_ports[dev], NULL) < 0) {
|
---|
523 | snd_printk("fatal error - EMU-8000 synthesizer not detected at 0x%lx\n", snd_awe_port[dev]);
|
---|
524 | snd_card_free(card);
|
---|
525 | return -ENXIO;
|
---|
526 | }
|
---|
527 | }
|
---|
528 | #endif
|
---|
529 |
|
---|
530 | /* setup Mic AGC */
|
---|
531 | spin_lock_irqsave(&chip->mixer_lock, flags);
|
---|
532 | snd_sbmixer_write(chip, SB_DSP4_MIC_AGC,
|
---|
533 | (snd_sbmixer_read(chip, SB_DSP4_MIC_AGC) & 0x01) |
|
---|
534 | (snd_mic_agc[dev] ? 0x00 : 0x01));
|
---|
535 | spin_unlock_irqrestore(&chip->mixer_lock, flags);
|
---|
536 |
|
---|
537 | strcpy(card->driver,
|
---|
538 | #ifdef SNDRV_SBAWE_EMU8000
|
---|
539 | snd_awe_port[dev] > 0 ? "SB AWE" :
|
---|
540 | #endif
|
---|
541 | "SB16");
|
---|
542 | strcpy(card->shortname, chip->name);
|
---|
543 | sprintf(card->longname, "%s at 0x%lx, irq %i, dma ",
|
---|
544 | chip->name,
|
---|
545 | chip->port,
|
---|
546 | irq);
|
---|
547 | if (dma8 >= 0)
|
---|
548 | sprintf(card->longname + strlen(card->longname), "%d", dma8);
|
---|
549 | if (dma16 >= 0)
|
---|
550 | sprintf(card->longname + strlen(card->longname), "%s%d",
|
---|
551 | dma8 >= 0 ? "&" : "", dma16);
|
---|
552 | if ((err = snd_card_register(card)) < 0) {
|
---|
553 | snd_card_free(card);
|
---|
554 | return err;
|
---|
555 | }
|
---|
556 | snd_sb16_cards[dev] = card;
|
---|
557 | return 0;
|
---|
558 | }
|
---|
559 |
|
---|
560 | static int __init snd_sb16_probe_legacy_port(unsigned long port)
|
---|
561 | {
|
---|
562 | static int dev = 0;
|
---|
563 | int res;
|
---|
564 |
|
---|
565 | for ( ; dev < SNDRV_CARDS; dev++) {
|
---|
566 | if (!snd_enable[dev] || snd_port[dev] != SNDRV_AUTO_PORT)
|
---|
567 | continue;
|
---|
568 | #ifdef __ISAPNP__
|
---|
569 | if (snd_isapnp[dev])
|
---|
570 | continue;
|
---|
571 | #endif
|
---|
572 | snd_port[dev] = port;
|
---|
573 | res = snd_sb16_probe(dev);
|
---|
574 | if (res < 0)
|
---|
575 | snd_port[dev] = SNDRV_AUTO_PORT;
|
---|
576 | return res;
|
---|
577 | }
|
---|
578 | return -ENODEV;
|
---|
579 | }
|
---|
580 |
|
---|
581 | #ifdef __ISAPNP__
|
---|
582 |
|
---|
583 | static int __init snd_sb16_isapnp_detect(struct isapnp_card *card,
|
---|
584 | const struct isapnp_card_id *id)
|
---|
585 | {
|
---|
586 | static int dev = 0;
|
---|
587 | int res;
|
---|
588 |
|
---|
589 | for ( ; dev < SNDRV_CARDS; dev++) {
|
---|
590 | if (!snd_enable[dev] || !snd_isapnp[dev])
|
---|
591 | continue;
|
---|
592 | snd_sb16_isapnp_cards[dev] = card;
|
---|
593 | snd_sb16_isapnp_id[dev] = id;
|
---|
594 | res = snd_sb16_probe(dev);
|
---|
595 | if (res < 0)
|
---|
596 | return res;
|
---|
597 | dev++;
|
---|
598 | return 0;
|
---|
599 | }
|
---|
600 |
|
---|
601 | return -ENODEV;
|
---|
602 | }
|
---|
603 |
|
---|
604 | #endif /* __ISAPNP__ */
|
---|
605 |
|
---|
606 | static int __init alsa_card_sb16_init(void)
|
---|
607 | {
|
---|
608 | int dev, cards = 0;
|
---|
609 | static unsigned long possible_ports[] = {0x220, 0x240, 0x260, 0x280, -1};
|
---|
610 |
|
---|
611 | /* legacy non-auto cards at first */
|
---|
612 | for (dev = 0; dev < SNDRV_CARDS; dev++) {
|
---|
613 | if (!snd_enable[dev] || snd_port[dev] == SNDRV_AUTO_PORT)
|
---|
614 | continue;
|
---|
615 | #ifdef __ISAPNP__
|
---|
616 | if (snd_isapnp[dev])
|
---|
617 | continue;
|
---|
618 | #endif
|
---|
619 | if (!snd_sb16_probe(dev)) {
|
---|
620 | cards++;
|
---|
621 | continue;
|
---|
622 | }
|
---|
623 | #ifdef MODULE
|
---|
624 | snd_printk("Sound Blaster 16+ soundcard #%i not found at 0x%lx or device busy\n", dev, snd_port[dev]);
|
---|
625 | #endif
|
---|
626 | }
|
---|
627 | /* legacy auto configured cards */
|
---|
628 | cards += snd_legacy_auto_probe(possible_ports, snd_sb16_probe_legacy_port);
|
---|
629 | #ifdef __ISAPNP__
|
---|
630 | /* ISA PnP cards at last */
|
---|
631 | cards += isapnp_probe_cards(snd_sb16_pnpids, snd_sb16_isapnp_detect);
|
---|
632 | #endif
|
---|
633 |
|
---|
634 | if (!cards) {
|
---|
635 | #ifdef MODULE
|
---|
636 | snd_printk("Sound Blaster 16 soundcard not found or device busy\n");
|
---|
637 | #ifdef SNDRV_SBAWE_EMU8000
|
---|
638 | snd_printk("In case, if you have non-AWE card, try snd-card-sb16 module\n");
|
---|
639 | #else
|
---|
640 | snd_printk("In case, if you have AWE card, try snd-card-sbawe module\n");
|
---|
641 | #endif
|
---|
642 | #endif
|
---|
643 | return -ENODEV;
|
---|
644 | }
|
---|
645 | return 0;
|
---|
646 | }
|
---|
647 |
|
---|
648 | static void __exit alsa_card_sb16_exit(void)
|
---|
649 | {
|
---|
650 | int dev;
|
---|
651 |
|
---|
652 | for (dev = 0; dev < SNDRV_CARDS; dev++)
|
---|
653 | snd_card_free(snd_sb16_cards[dev]);
|
---|
654 | }
|
---|
655 |
|
---|
656 | module_init(alsa_card_sb16_init)
|
---|
657 | module_exit(alsa_card_sb16_exit)
|
---|
658 |
|
---|
659 | #ifndef MODULE
|
---|
660 |
|
---|
661 | /* format is: snd-card-sb16=snd_enable,snd_index,snd_id,snd_isapnp,
|
---|
662 | snd_port,snd_mpu_port,snd_fm_port,
|
---|
663 | snd_irq,snd_dma8,snd_dma16,
|
---|
664 | snd_mic_agc,snd_csp,
|
---|
665 | [snd_awe_port,snd_seq_ports] */
|
---|
666 |
|
---|
667 | static int __init alsa_card_sb16_setup(char *str)
|
---|
668 | {
|
---|
669 | static unsigned __initdata nr_dev = 0;
|
---|
670 | int __attribute__ ((__unused__)) pnp = INT_MAX;
|
---|
671 | int __attribute__ ((__unused__)) csp = INT_MAX;
|
---|
672 |
|
---|
673 | if (nr_dev >= SNDRV_CARDS)
|
---|
674 | return 0;
|
---|
675 | (void)(get_option(&str,&snd_enable[nr_dev]) == 2 &&
|
---|
676 | get_option(&str,&snd_index[nr_dev]) == 2 &&
|
---|
677 | get_id(&str,&snd_id[nr_dev]) == 2 &&
|
---|
678 | get_option(&str,&pnp) == 2 &&
|
---|
679 | get_option(&str,(int *)&snd_port[nr_dev]) == 2 &&
|
---|
680 | get_option(&str,(int *)&snd_mpu_port[nr_dev]) == 2 &&
|
---|
681 | get_option(&str,(int *)&snd_fm_port[nr_dev]) == 2 &&
|
---|
682 | get_option(&str,&snd_irq[nr_dev]) == 2 &&
|
---|
683 | get_option(&str,&snd_dma8[nr_dev]) == 2 &&
|
---|
684 | get_option(&str,&snd_dma16[nr_dev]) == 2 &&
|
---|
685 | get_option(&str,&snd_mic_agc[nr_dev]) == 2 &&
|
---|
686 | get_option(&str,&snd_csp[nr_dev]) == 2
|
---|
687 | #ifdef SNDRV_SBAWE_EMU8000
|
---|
688 | &&
|
---|
689 | get_option(&str,(int *)&snd_awe_port[nr_dev]) == 2 &&
|
---|
690 | get_option(&str,&snd_seq_ports[nr_dev]) == 2
|
---|
691 | #endif
|
---|
692 | );
|
---|
693 | #ifdef __ISAPNP__
|
---|
694 | if (pnp != INT_MAX)
|
---|
695 | snd_isapnp[nr_dev] = pnp;
|
---|
696 | #endif
|
---|
697 | #ifdef CONFIG_SND_SB16_CSP
|
---|
698 | if (csp != INT_MAX)
|
---|
699 | snd_csp[nr_dev] = csp;
|
---|
700 | #endif
|
---|
701 | nr_dev++;
|
---|
702 | return 1;
|
---|
703 | }
|
---|
704 |
|
---|
705 | #ifndef SNDRV_SBAWE_EMU8000
|
---|
706 | __setup("snd-card-sb16=", alsa_card_sb16_setup);
|
---|
707 | #else
|
---|
708 | __setup("snd-card-sbawe=", alsa_card_sb16_setup);
|
---|
709 | #endif
|
---|
710 |
|
---|
711 | #endif /* ifndef MODULE */
|
---|