2 * Driver for SoundBlaster 16/AWE32/AWE64 soundcards
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
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.
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.
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
22 #include <sound/driver.h>
24 #include <linux/init.h>
25 #include <linux/slab.h>
26 #include <linux/pnp.h>
27 #include <sound/core.h>
29 #include <sound/sb16_csp.h>
30 #include <sound/mpu401.h>
31 #include <sound/opl3.h>
32 #include <sound/emu8000.h>
33 #include <sound/seq_device.h>
34 #define SNDRV_LEGACY_AUTO_PROBE
35 #define SNDRV_LEGACY_FIND_FREE_IRQ
36 #define SNDRV_LEGACY_FIND_FREE_DMA
38 #include <sound/initval.h>
48 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
49 MODULE_LICENSE("GPL");
50 MODULE_CLASSES("{sound}");
52 MODULE_DESCRIPTION("Sound Blaster 16");
53 MODULE_DEVICES("{{Creative Labs,SB 16},"
54 "{Creative Labs,SB Vibra16S},"
55 "{Creative Labs,SB Vibra16C},"
56 "{Creative Labs,SB Vibra16CL},"
57 "{Creative Labs,SB Vibra16X}}");
59 MODULE_DESCRIPTION("Sound Blaster AWE");
60 MODULE_DEVICES("{{Creative Labs,SB AWE 32},"
61 "{Creative Labs,SB AWE 64},"
62 "{Creative Labs,SB AWE 64 Gold}}");
66 #define SNDRV_DEBUG_IRQ
69 #if defined(SNDRV_SBAWE) && (defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE)))
70 #define SNDRV_SBAWE_EMU8000
73 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
74 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
75 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
77 static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
79 static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260,0x280 */
80 static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x330,0x300 */
81 static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
82 #ifdef SNDRV_SBAWE_EMU8000
83 static long awe_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
85 static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,10 */
86 static int dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3 */
87 static int dma16[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 5,6,7 */
88 static int mic_agc[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
89 #ifdef CONFIG_SND_SB16_CSP
90 static int csp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
92 #ifdef SNDRV_SBAWE_EMU8000
93 static int seq_ports[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 4};
96 MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
97 MODULE_PARM_DESC(index, "Index value for SoundBlaster 16 soundcard.");
98 MODULE_PARM_SYNTAX(index, SNDRV_INDEX_DESC);
99 MODULE_PARM(id, "1-" __MODULE_STRING(SNDRV_CARDS) "s");
100 MODULE_PARM_DESC(id, "ID string for SoundBlaster 16 soundcard.");
101 MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC);
102 MODULE_PARM(enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
103 MODULE_PARM_DESC(enable, "Enable SoundBlaster 16 soundcard.");
104 MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC);
106 MODULE_PARM(isapnp, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
107 MODULE_PARM_DESC(isapnp, "PnP detection for specified soundcard.");
108 MODULE_PARM_SYNTAX(isapnp, SNDRV_ISAPNP_DESC);
110 MODULE_PARM(port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
111 MODULE_PARM_DESC(port, "Port # for SB16 driver.");
112 MODULE_PARM_SYNTAX(port, SNDRV_ENABLED ",allows:{{0x220},{0x240},{0x260},{0x280}},dialog:list");
113 MODULE_PARM(mpu_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
114 MODULE_PARM_DESC(mpu_port, "MPU-401 port # for SB16 driver.");
115 MODULE_PARM_SYNTAX(mpu_port, SNDRV_ENABLED ",allows:{{0x330},{0x300}},dialog:list");
116 MODULE_PARM(fm_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
117 MODULE_PARM_DESC(fm_port, "FM port # for SB16 PnP driver.");
118 MODULE_PARM_SYNTAX(fm_port, SNDRV_ENABLED ",allows:{{0x388},{0x38c},{0x390},{0x394}},dialog:list");
119 #ifdef SNDRV_SBAWE_EMU8000
120 MODULE_PARM(awe_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
121 MODULE_PARM_DESC(awe_port, "AWE port # for SB16 PnP driver.");
122 MODULE_PARM_SYNTAX(awe_port, SNDRV_ENABLED ",allows:{{0x620},{0x640},{0x660},{0x680}},dialog:list");
124 MODULE_PARM(irq, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
125 MODULE_PARM_DESC(irq, "IRQ # for SB16 driver.");
126 MODULE_PARM_SYNTAX(irq, SNDRV_IRQ_DESC);
127 MODULE_PARM(dma8, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
128 MODULE_PARM_DESC(dma8, "8-bit DMA # for SB16 driver.");
129 MODULE_PARM_SYNTAX(dma8, SNDRV_DMA8_DESC);
130 MODULE_PARM(dma16, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
131 MODULE_PARM_DESC(dma16, "16-bit DMA # for SB16 driver.");
132 MODULE_PARM_SYNTAX(dma16, SNDRV_DMA16_DESC);
133 MODULE_PARM(mic_agc, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
134 MODULE_PARM_DESC(mic_agc, "Mic Auto-Gain-Control switch.");
135 MODULE_PARM_SYNTAX(mic_agc, SNDRV_ENABLED "," SNDRV_BOOLEAN_TRUE_DESC);
136 #ifdef CONFIG_SND_SB16_CSP
137 MODULE_PARM(csp, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
138 MODULE_PARM_DESC(csp, "ASP/CSP chip support.");
139 MODULE_PARM_SYNTAX(csp, SNDRV_ENABLED "," SNDRV_ENABLE_DESC);
141 #ifdef SNDRV_SBAWE_EMU8000
142 MODULE_PARM(seq_ports, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
143 MODULE_PARM_DESC(seq_ports, "Number of sequencer ports for WaveTable synth.");
144 MODULE_PARM_SYNTAX(seq_ports, SNDRV_ENABLED ",allows:{{0,8}},skill:advanced");
147 struct snd_card_sb16 {
148 struct resource *fm_res; /* used to block FM i/o region for legacy cards */
152 #ifdef SNDRV_SBAWE_EMU8000
153 struct pnp_dev *devwt;
158 static snd_card_t *snd_sb16_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
162 static struct pnp_card_device_id snd_sb16_pnpids[] = {
164 /* Sound Blaster 16 PnP */
165 { .id = "CTL0024", .devs = { { "CTL0031" } } },
166 /* Sound Blaster 16 PnP */
167 { .id = "CTL0025", .devs = { { "CTL0031" } } },
168 /* Sound Blaster 16 PnP */
169 { .id = "CTL0026", .devs = { { "CTL0031" } } },
170 /* Sound Blaster 16 PnP */
171 { .id = "CTL0027", .devs = { { "CTL0031" } } },
172 /* Sound Blaster 16 PnP */
173 { .id = "CTL0028", .devs = { { "CTL0031" } } },
174 /* Sound Blaster 16 PnP */
175 { .id = "CTL0029", .devs = { { "CTL0031" } } },
176 /* Sound Blaster 16 PnP */
177 { .id = "CTL002a", .devs = { { "CTL0031" } } },
178 /* Sound Blaster 16 PnP */
179 /* Note: This card has also a CTL0051:StereoEnhance device!!! */
180 { .id = "CTL002b", .devs = { { "CTL0031" } } },
181 /* Sound Blaster 16 PnP */
182 { .id = "CTL002c", .devs = { { "CTL0031" } } },
183 /* Sound Blaster Vibra16S */
184 { .id = "CTL0051", .devs = { { "CTL0001" } } },
185 /* Sound Blaster Vibra16C */
186 { .id = "CTL0070", .devs = { { "CTL0001" } } },
187 /* Sound Blaster Vibra16CL - added by ctm@ardi.com */
188 { .id = "CTL0080", .devs = { { "CTL0041" } } },
189 /* Sound Blaster 16 'value' PnP. It says model ct4130 on the pcb, */
190 /* but ct4131 on a sticker on the board.. */
191 { .id = "CTL0086", .devs = { { "CTL0041" } } },
192 /* Sound Blaster Vibra16X */
193 { .id = "CTL00f0", .devs = { { "CTL0043" } } },
194 #else /* SNDRV_SBAWE defined */
195 /* Sound Blaster AWE 32 PnP */
196 { .id = "CTL0035", .devs = { { "CTL0031" }, { "CTL0021" } } },
197 /* Sound Blaster AWE 32 PnP */
198 { .id = "CTL0039", .devs = { { "CTL0031" }, { "CTL0021" } } },
199 /* Sound Blaster AWE 32 PnP */
200 { .id = "CTL0042", .devs = { { "CTL0031" }, { "CTL0021" } } },
201 /* Sound Blaster AWE 32 PnP */
202 { .id = "CTL0043", .devs = { { "CTL0031" }, { "CTL0021" } } },
203 /* Sound Blaster AWE 32 PnP */
204 /* Note: This card has also a CTL0051:StereoEnhance device!!! */
205 { .id = "CTL0044", .devs = { { "CTL0031" }, { "CTL0021" } } },
206 /* Sound Blaster AWE 32 PnP */
207 /* Note: This card has also a CTL0051:StereoEnhance device!!! */
208 { .id = "CTL0045", .devs = { { "CTL0031" }, { "CTL0021" } } },
209 /* Sound Blaster AWE 32 PnP */
210 { .id = "CTL0046", .devs = { { "CTL0031" }, { "CTL0021" } } },
211 /* Sound Blaster AWE 32 PnP */
212 { .id = "CTL0047", .devs = { { "CTL0031" }, { "CTL0021" } } },
213 /* Sound Blaster AWE 32 PnP */
214 { .id = "CTL0048", .devs = { { "CTL0031" }, { "CTL0021" } } },
215 /* Sound Blaster AWE 32 PnP */
216 { .id = "CTL0054", .devs = { { "CTL0031" }, { "CTL0021" } } },
217 /* Sound Blaster AWE 32 PnP */
218 { .id = "CTL009a", .devs = { { "CTL0041" }, { "CTL0021" } } },
219 /* Sound Blaster AWE 32 PnP */
220 { .id = "CTL009c", .devs = { { "CTL0041" }, { "CTL0021" } } },
221 /* Sound Blaster 32 PnP */
222 { .id = "CTL009f", .devs = { { "CTL0041" }, { "CTL0021" } } },
223 /* Sound Blaster AWE 64 PnP */
224 { .id = "CTL009d", .devs = { { "CTL0042" }, { "CTL0022" } } },
225 /* Sound Blaster AWE 64 PnP Gold */
226 { .id = "CTL009e", .devs = { { "CTL0044" }, { "CTL0023" } } },
227 /* Sound Blaster AWE 64 PnP Gold */
228 { .id = "CTL00b2", .devs = { { "CTL0044" }, { "CTL0023" } } },
229 /* Sound Blaster AWE 64 PnP */
230 { .id = "CTL00c1", .devs = { { "CTL0042" }, { "CTL0022" } } },
231 /* Sound Blaster AWE 64 PnP */
232 { .id = "CTL00c3", .devs = { { "CTL0045" }, { "CTL0022" } } },
233 /* Sound Blaster AWE 64 PnP */
234 { .id = "CTL00c5", .devs = { { "CTL0045" }, { "CTL0022" } } },
235 /* Sound Blaster AWE 64 PnP */
236 { .id = "CTL00c7", .devs = { { "CTL0045" }, { "CTL0022" } } },
237 /* Sound Blaster AWE 64 PnP */
238 { .id = "CTL00e4", .devs = { { "CTL0045" }, { "CTL0022" } } },
239 /* Sound Blaster AWE 64 PnP */
240 { .id = "CTL00e9", .devs = { { "CTL0045" }, { "CTL0022" } } },
241 /* Sound Blaster 16 PnP (AWE) */
242 { .id = "CTL00ed", .devs = { { "CTL0041" }, { "CTL0070" } } },
243 /* Generic entries */
244 { .id = "CTLXXXX" , .devs = { { "CTL0031" }, { "CTL0021" } } },
245 { .id = "CTLXXXX" , .devs = { { "CTL0041" }, { "CTL0021" } } },
246 { .id = "CTLXXXX" , .devs = { { "CTL0042" }, { "CTL0022" } } },
247 { .id = "CTLXXXX" , .devs = { { "CTL0044" }, { "CTL0023" } } },
248 { .id = "CTLXXXX" , .devs = { { "CTL0045" }, { "CTL0022" } } },
249 #endif /* SNDRV_SBAWE */
253 MODULE_DEVICE_TABLE(pnp_card, snd_sb16_pnpids);
255 #endif /* CONFIG_PNP */
257 #ifdef SNDRV_SBAWE_EMU8000
258 #define DRIVER_NAME "snd-card-sbawe"
260 #define DRIVER_NAME "snd-card-sb16"
265 static int __devinit snd_card_sb16_pnp(int dev, struct snd_card_sb16 *acard,
266 struct pnp_card_link *card,
267 const struct pnp_card_device_id *id)
269 struct pnp_dev *pdev;
270 struct pnp_resource_table * cfg = kmalloc(sizeof(struct pnp_resource_table), GFP_KERNEL);
275 acard->dev = pnp_request_card_device(card, id->devs[0].id, NULL);
276 if (acard->dev == NULL) {
280 #ifdef SNDRV_SBAWE_EMU8000
281 acard->devwt = pnp_request_card_device(card, id->devs[1].id, acard->dev);
283 /* Audio initialization */
286 pnp_init_resource_table(cfg);
288 /* override resources */
290 if (port[dev] != SNDRV_AUTO_PORT)
291 pnp_resource_change(&cfg->port_resource[0], port[dev], 16);
292 if (mpu_port[dev] != SNDRV_AUTO_PORT)
293 pnp_resource_change(&cfg->port_resource[1], mpu_port[dev], 2);
294 if (fm_port[dev] != SNDRV_AUTO_PORT)
295 pnp_resource_change(&cfg->port_resource[2], fm_port[dev], 4);
296 if (dma8[dev] != SNDRV_AUTO_DMA)
297 pnp_resource_change(&cfg->dma_resource[0], dma8[dev], 1);
298 if (dma16[dev] != SNDRV_AUTO_DMA)
299 pnp_resource_change(&cfg->dma_resource[1], dma16[dev], 1);
300 if (irq[dev] != SNDRV_AUTO_IRQ)
301 pnp_resource_change(&cfg->irq_resource[0], irq[dev], 1);
302 if (pnp_manual_config_dev(pdev, cfg, 0) < 0)
303 snd_printk(KERN_ERR PFX "AUDIO the requested resources are invalid, using auto config\n");
304 err = pnp_activate_dev(pdev);
306 snd_printk(KERN_ERR PFX "AUDIO pnp configure failure\n");
310 port[dev] = pnp_port_start(pdev, 0);
311 mpu_port[dev] = pnp_port_start(pdev, 1);
312 fm_port[dev] = pnp_port_start(pdev, 2);
313 dma8[dev] = pnp_dma(pdev, 0);
314 dma16[dev] = pnp_dma(pdev, 1);
315 irq[dev] = pnp_irq(pdev, 0);
316 snd_printdd("pnp SB16: port=0x%lx, mpu port=0x%lx, fm port=0x%lx\n",
317 port[dev], mpu_port[dev], fm_port[dev]);
318 snd_printdd("pnp SB16: dma1=%i, dma2=%i, irq=%i\n",
319 dma8[dev], dma16[dev], irq[dev]);
320 #ifdef SNDRV_SBAWE_EMU8000
321 /* WaveTable initialization */
324 pnp_init_resource_table(cfg);
326 /* override resources */
328 if (awe_port[dev] != SNDRV_AUTO_PORT) {
329 pnp_resource_change(&cfg->port_resource[0], awe_port[dev], 4);
330 pnp_resource_change(&cfg->port_resource[1], awe_port[dev] + 0x400, 4);
331 pnp_resource_change(&cfg->port_resource[2], awe_port[dev] + 0x800, 4);
333 if ((pnp_manual_config_dev(pdev, cfg, 0)) < 0)
334 snd_printk(KERN_ERR PFX "WaveTable the requested resources are invalid, using auto config\n");
335 err = pnp_activate_dev(pdev);
339 awe_port[dev] = pnp_port_start(pdev, 0);
340 snd_printdd("pnp SB16: wavetable port=0x%lx\n", pnp_port_start(pdev, 0));
344 pnp_release_card_device(pdev);
345 snd_printk(KERN_ERR PFX "WaveTable pnp configure failure\n");
355 #endif /* CONFIG_PNP */
357 static void snd_sb16_free(snd_card_t *card)
359 struct snd_card_sb16 *acard = (struct snd_card_sb16 *)card->private_data;
364 release_resource(acard->fm_res);
365 kfree_nocheck(acard->fm_res);
369 static int __init snd_sb16_probe(int dev,
370 struct pnp_card_link *pcard,
371 const struct pnp_card_device_id *pid)
373 static int possible_irqs[] = {5, 9, 10, 7, -1};
374 static int possible_dmas8[] = {1, 3, 0, -1};
375 static int possible_dmas16[] = {5, 6, 7, -1};
376 int xirq, xdma8, xdma16;
379 struct snd_card_sb16 *acard;
381 snd_hwdep_t *synth = NULL;
382 #ifdef CONFIG_SND_SB16_CSP
383 snd_hwdep_t *xcsp = NULL;
388 card = snd_card_new(index[dev], id[dev], THIS_MODULE,
389 sizeof(struct snd_card_sb16));
392 acard = (struct snd_card_sb16 *) card->private_data;
393 card->private_free = snd_sb16_free;
396 if ((err = snd_card_sb16_pnp(dev, acard, pcard, pid))) {
400 snd_card_set_dev(card, &pcard->card->dev);
410 if (xirq == SNDRV_AUTO_IRQ) {
411 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
413 snd_printk(KERN_ERR PFX "unable to find a free IRQ\n");
417 if (xdma8 == SNDRV_AUTO_DMA) {
418 if ((xdma8 = snd_legacy_find_free_dma(possible_dmas8)) < 0) {
420 snd_printk(KERN_ERR PFX "unable to find a free 8-bit DMA\n");
424 if (xdma16 == SNDRV_AUTO_DMA) {
425 if ((xdma16 = snd_legacy_find_free_dma(possible_dmas16)) < 0) {
427 snd_printk(KERN_ERR PFX "unable to find a free 16-bit DMA\n");
431 /* non-PnP FM port address is hardwired with base port address */
432 fm_port[dev] = port[dev];
433 /* block the 0x388 port to avoid PnP conflicts */
434 acard->fm_res = request_region(0x388, 4, "SoundBlaster FM");
435 #ifdef SNDRV_SBAWE_EMU8000
436 /* non-PnP AWE port address is hardwired with base port address */
437 awe_port[dev] = port[dev] + 0x400;
443 if ((err = snd_sbdsp_create(card,
446 snd_sb16dsp_interrupt,
454 if (chip->hardware != SB_HW_16) {
456 snd_printdd("SB 16 chip was not detected at 0x%lx\n", port[dev]);
459 chip->mpu_port = mpu_port[dev];
461 if (!isapnp[dev] && (err = snd_sb16dsp_configure(chip)) < 0) {
463 if ((err = snd_sb16dsp_configure(chip)) < 0) {
468 if ((err = snd_sb16dsp_pcm(chip, 0, NULL)) < 0) {
474 #ifdef SNDRV_SBAWE_EMU8000
475 awe_port[dev] > 0 ? "SB AWE" :
478 strcpy(card->shortname, chip->name);
479 sprintf(card->longname, "%s at 0x%lx, irq %i, dma ",
484 sprintf(card->longname + strlen(card->longname), "%d", xdma8);
486 sprintf(card->longname + strlen(card->longname), "%s%d",
487 xdma8 >= 0 ? "&" : "", xdma16);
489 if (chip->mpu_port > 0 && chip->mpu_port != SNDRV_AUTO_PORT) {
490 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_SB,
492 xirq, 0, &chip->rmidi)) < 0) {
496 chip->rmidi_callback = snd_mpu401_uart_interrupt;
499 #ifdef SNDRV_SBAWE_EMU8000
500 if (awe_port[dev] == SNDRV_AUTO_PORT)
501 awe_port[dev] = 0; /* disable */
504 if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) {
505 if (snd_opl3_create(card, fm_port[dev], fm_port[dev] + 2,
507 acard->fm_res != NULL || fm_port[dev] == port[dev],
509 snd_printk(KERN_ERR PFX "no OPL device at 0x%lx-0x%lx\n",
510 fm_port[dev], fm_port[dev] + 2);
512 #ifdef SNDRV_SBAWE_EMU8000
513 int seqdev = awe_port[dev] > 0 ? 2 : 1;
517 if ((err = snd_opl3_hwdep_new(opl3, 0, seqdev, &synth)) < 0) {
524 if ((err = snd_sbmixer_new(chip)) < 0) {
529 #ifdef CONFIG_SND_SB16_CSP
530 /* CSP chip on SB16ASP/AWE32 */
531 if ((chip->hardware == SB_HW_16) && csp[dev]) {
532 snd_sb_csp_new(chip, synth != NULL ? 1 : 0, &xcsp);
534 chip->csp = xcsp->private_data;
535 chip->hardware = SB_HW_16CSP;
537 snd_printk(KERN_INFO PFX "warning - CSP chip not detected on soundcard #%i\n", dev + 1);
541 #ifdef SNDRV_SBAWE_EMU8000
542 if (awe_port[dev] > 0) {
543 if (snd_emu8000_new(card, 1, awe_port[dev],
544 seq_ports[dev], NULL) < 0) {
545 snd_printk(KERN_ERR PFX "fatal error - EMU-8000 synthesizer not detected at 0x%lx\n", awe_port[dev]);
553 spin_lock_irqsave(&chip->mixer_lock, flags);
554 snd_sbmixer_write(chip, SB_DSP4_MIC_AGC,
555 (snd_sbmixer_read(chip, SB_DSP4_MIC_AGC) & 0x01) |
556 (mic_agc[dev] ? 0x00 : 0x01));
557 spin_unlock_irqrestore(&chip->mixer_lock, flags);
559 if ((err = snd_card_register(card)) < 0) {
564 pnp_set_card_drvdata(pcard, card);
566 snd_sb16_legacy[dev] = card;
570 static int __init snd_sb16_probe_legacy_port(unsigned long xport)
575 for ( ; dev < SNDRV_CARDS; dev++) {
576 if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT)
583 res = snd_sb16_probe(dev, NULL, NULL);
585 port[dev] = SNDRV_AUTO_PORT;
593 static int __devinit snd_sb16_pnp_detect(struct pnp_card_link *card,
594 const struct pnp_card_device_id *id)
599 for ( ; dev < SNDRV_CARDS; dev++) {
600 if (!enable[dev] || !isapnp[dev])
602 res = snd_sb16_probe(dev, card, id);
612 static void __devexit snd_sb16_pnp_remove(struct pnp_card_link * pcard)
614 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard);
616 snd_card_disconnect(card);
617 snd_card_free_in_thread(card);
620 static struct pnp_card_driver sb16_pnpc_driver = {
621 .flags = PNP_DRIVER_RES_DISABLE,
623 .id_table = snd_sb16_pnpids,
624 .probe = snd_sb16_pnp_detect,
625 .remove = __devexit_p(snd_sb16_pnp_remove),
628 #endif /* CONFIG_PNP */
630 static int __init alsa_card_sb16_init(void)
632 int dev, cards = 0, i;
633 static unsigned long possible_ports[] = {0x220, 0x240, 0x260, 0x280, -1};
635 /* legacy non-auto cards at first */
636 for (dev = 0; dev < SNDRV_CARDS; dev++) {
637 if (!enable[dev] || port[dev] == SNDRV_AUTO_PORT)
643 if (!snd_sb16_probe(dev, NULL, NULL)) {
648 snd_printk(KERN_ERR "Sound Blaster 16+ soundcard #%i not found at 0x%lx or device busy\n", dev, port[dev]);
651 /* legacy auto configured cards */
652 i = snd_legacy_auto_probe(possible_ports, snd_sb16_probe_legacy_port);
657 /* PnP cards at last */
658 i = pnp_register_card_driver(&sb16_pnpc_driver);
665 pnp_unregister_card_driver(&sb16_pnpc_driver);
668 snd_printk(KERN_ERR "Sound Blaster 16 soundcard not found or device busy\n");
669 #ifdef SNDRV_SBAWE_EMU8000
670 snd_printk(KERN_ERR "In case, if you have non-AWE card, try snd-sb16 module\n");
672 snd_printk(KERN_ERR "In case, if you have AWE card, try snd-sbawe module\n");
680 static void __exit alsa_card_sb16_exit(void)
685 /* PnP cards first */
686 pnp_unregister_card_driver(&sb16_pnpc_driver);
688 for (dev = 0; dev < SNDRV_CARDS; dev++)
689 snd_card_free(snd_sb16_legacy[dev]);
692 module_init(alsa_card_sb16_init)
693 module_exit(alsa_card_sb16_exit)
697 /* format is: snd-sb16=enable,index,id,isapnp,
698 port,mpu_port,fm_port,
701 [awe_port,seq_ports] */
703 static int __init alsa_card_sb16_setup(char *str)
705 static unsigned __initdata nr_dev = 0;
706 int __attribute__ ((__unused__)) pnp = INT_MAX;
707 int __attribute__ ((__unused__)) xcsp = INT_MAX;
709 if (nr_dev >= SNDRV_CARDS)
711 (void)(get_option(&str,&enable[nr_dev]) == 2 &&
712 get_option(&str,&index[nr_dev]) == 2 &&
713 get_id(&str,&id[nr_dev]) == 2 &&
714 get_option(&str,&pnp) == 2 &&
715 get_option_long(&str,&port[nr_dev]) == 2 &&
716 get_option_long(&str,&mpu_port[nr_dev]) == 2 &&
717 get_option_long(&str,&fm_port[nr_dev]) == 2 &&
718 get_option(&str,&irq[nr_dev]) == 2 &&
719 get_option(&str,&dma8[nr_dev]) == 2 &&
720 get_option(&str,&dma16[nr_dev]) == 2 &&
721 get_option(&str,&mic_agc[nr_dev]) == 2
722 #ifdef CONFIG_SND_SB16_CSP
724 get_option(&str,&xcsp) == 2
726 #ifdef SNDRV_SBAWE_EMU8000
728 get_option_long(&str,&awe_port[nr_dev]) == 2 &&
729 get_option(&str,&seq_ports[nr_dev]) == 2
734 isapnp[nr_dev] = pnp;
736 #ifdef CONFIG_SND_SB16_CSP
744 #ifndef SNDRV_SBAWE_EMU8000
745 __setup("snd-sb16=", alsa_card_sb16_setup);
747 __setup("snd-sbawe=", alsa_card_sb16_setup);
750 #endif /* ifndef MODULE */