aboutsummaryrefslogtreecommitdiffstats
path: root/sound/isa/gus/gusmax.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/isa/gus/gusmax.c')
-rw-r--r--sound/isa/gus/gusmax.c145
1 files changed, 62 insertions, 83 deletions
diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c
index 400ff34710fb..0bb44b519340 100644
--- a/sound/isa/gus/gusmax.c
+++ b/sound/isa/gus/gusmax.c
@@ -82,39 +82,25 @@ struct snd_gusmax {
82 82
83static snd_card_t *snd_gusmax_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 83static snd_card_t *snd_gusmax_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
84 84
85#define PFX "gusmax: "
85 86
86static int __init snd_gusmax_detect(snd_gus_card_t * gus) 87static int __init snd_gusmax_detect(snd_gus_card_t * gus)
87{ 88{
88 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */ 89 unsigned char d;
89#ifdef CONFIG_SND_DEBUG_DETECT
90 {
91 unsigned char d;
92 90
93 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) { 91 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */
94 snd_printk("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d); 92 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) {
95 return -ENODEV; 93 snd_printdd("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d);
96 }
97 }
98#else
99 if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 0)
100 return -ENODEV; 94 return -ENODEV;
101#endif 95 }
102 udelay(160); 96 udelay(160);
103 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */ 97 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */
104 udelay(160); 98 udelay(160);
105#ifdef CONFIG_SND_DEBUG_DETECT 99 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) {
106 { 100 snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d);
107 unsigned char d;
108
109 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) {
110 snd_printk("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d);
111 return -ENODEV;
112 }
113 }
114#else
115 if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 1)
116 return -ENODEV; 101 return -ENODEV;
117#endif 102 }
103
118 return 0; 104 return 0;
119} 105}
120 106
@@ -239,25 +225,25 @@ static int __init snd_gusmax_probe(int dev)
239 xirq = irq[dev]; 225 xirq = irq[dev];
240 if (xirq == SNDRV_AUTO_IRQ) { 226 if (xirq == SNDRV_AUTO_IRQ) {
241 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { 227 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
242 snd_card_free(card); 228 snd_printk(KERN_ERR PFX "unable to find a free IRQ\n");
243 snd_printk("unable to find a free IRQ\n"); 229 err = -EBUSY;
244 return -EBUSY; 230 goto _err;
245 } 231 }
246 } 232 }
247 xdma1 = dma1[dev]; 233 xdma1 = dma1[dev];
248 if (xdma1 == SNDRV_AUTO_DMA) { 234 if (xdma1 == SNDRV_AUTO_DMA) {
249 if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { 235 if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
250 snd_card_free(card); 236 snd_printk(KERN_ERR PFX "unable to find a free DMA1\n");
251 snd_printk("unable to find a free DMA1\n"); 237 err = -EBUSY;
252 return -EBUSY; 238 goto _err;
253 } 239 }
254 } 240 }
255 xdma2 = dma2[dev]; 241 xdma2 = dma2[dev];
256 if (xdma2 == SNDRV_AUTO_DMA) { 242 if (xdma2 == SNDRV_AUTO_DMA) {
257 if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) { 243 if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
258 snd_card_free(card); 244 snd_printk(KERN_ERR PFX "unable to find a free DMA2\n");
259 snd_printk("unable to find a free DMA2\n"); 245 err = -EBUSY;
260 return -EBUSY; 246 goto _err;
261 } 247 }
262 } 248 }
263 249
@@ -266,31 +252,28 @@ static int __init snd_gusmax_probe(int dev)
266 -xirq, xdma1, xdma2, 252 -xirq, xdma1, xdma2,
267 0, channels[dev], 253 0, channels[dev],
268 pcm_channels[dev], 254 pcm_channels[dev],
269 0, &gus)) < 0) { 255 0, &gus)) < 0)
270 snd_card_free(card); 256 goto _err;
271 return err; 257
272 } 258 if ((err = snd_gusmax_detect(gus)) < 0)
273 if ((err = snd_gusmax_detect(gus)) < 0) { 259 goto _err;
274 snd_card_free(card); 260
275 return err;
276 }
277 maxcard->gus_status_reg = gus->gf1.reg_irqstat; 261 maxcard->gus_status_reg = gus->gf1.reg_irqstat;
278 maxcard->pcm_status_reg = gus->gf1.port + 0x10c + 2; 262 maxcard->pcm_status_reg = gus->gf1.port + 0x10c + 2;
279 snd_gusmax_init(dev, card, gus); 263 snd_gusmax_init(dev, card, gus);
280 if ((err = snd_gus_initialize(gus)) < 0) { 264 if ((err = snd_gus_initialize(gus)) < 0)
281 snd_card_free(card); 265 goto _err;
282 return err; 266
283 }
284 if (!gus->max_flag) { 267 if (!gus->max_flag) {
285 printk(KERN_ERR "GUS MAX soundcard was not detected at 0x%lx\n", gus->gf1.port); 268 snd_printk(KERN_ERR PFX "GUS MAX soundcard was not detected at 0x%lx\n", gus->gf1.port);
286 snd_card_free(card); 269 err = -ENODEV;
287 return -ENODEV; 270 goto _err;
288 } 271 }
289 272
290 if (request_irq(xirq, snd_gusmax_interrupt, SA_INTERRUPT, "GUS MAX", (void *)maxcard)) { 273 if (request_irq(xirq, snd_gusmax_interrupt, SA_INTERRUPT, "GUS MAX", (void *)maxcard)) {
291 snd_card_free(card); 274 snd_printk(KERN_ERR PFX "unable to grab IRQ %d\n", xirq);
292 printk(KERN_ERR "gusmax: unable to grab IRQ %d\n", xirq); 275 err = -EBUSY;
293 return -EBUSY; 276 goto _err;
294 } 277 }
295 maxcard->irq = xirq; 278 maxcard->irq = xirq;
296 279
@@ -301,50 +284,46 @@ static int __init snd_gusmax_probe(int dev)
301 CS4231_HWSHARE_IRQ | 284 CS4231_HWSHARE_IRQ |
302 CS4231_HWSHARE_DMA1 | 285 CS4231_HWSHARE_DMA1 |
303 CS4231_HWSHARE_DMA2, 286 CS4231_HWSHARE_DMA2,
304 &cs4231)) < 0) { 287 &cs4231)) < 0)
305 snd_card_free(card); 288 goto _err;
306 return err; 289
307 } 290 if ((err = snd_cs4231_pcm(cs4231, 0, NULL)) < 0)
308 if ((err = snd_cs4231_pcm(cs4231, 0, NULL)) < 0) { 291 goto _err;
309 snd_card_free(card); 292
310 return err; 293 if ((err = snd_cs4231_mixer(cs4231)) < 0)
311 } 294 goto _err;
312 if ((err = snd_cs4231_mixer(cs4231)) < 0) { 295
313 snd_card_free(card); 296 if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0)
314 return err; 297 goto _err;
315 } 298
316 if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0) {
317 snd_card_free(card);
318 return err;
319 }
320 if (pcm_channels[dev] > 0) { 299 if (pcm_channels[dev] > 0) {
321 if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) { 300 if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0)
322 snd_card_free(card); 301 goto _err;
323 return err;
324 }
325 }
326 if ((err = snd_gusmax_mixer(cs4231)) < 0) {
327 snd_card_free(card);
328 return err;
329 } 302 }
303 if ((err = snd_gusmax_mixer(cs4231)) < 0)
304 goto _err;
330 305
331 if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) { 306 if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0)
332 snd_card_free(card); 307 goto _err;
333 return err;
334 }
335 308
336 sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %i, dma %i", gus->gf1.port, xirq, xdma1); 309 sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %i, dma %i", gus->gf1.port, xirq, xdma1);
337 if (xdma2 >= 0) 310 if (xdma2 >= 0)
338 sprintf(card->longname + strlen(card->longname), "&%i", xdma2); 311 sprintf(card->longname + strlen(card->longname), "&%i", xdma2);
339 if ((err = snd_card_register(card)) < 0) { 312
340 snd_card_free(card); 313 if ((err = snd_card_set_generic_dev(card)) < 0)
341 return err; 314 goto _err;
342 } 315
316 if ((err = snd_card_register(card)) < 0)
317 goto _err;
343 318
344 maxcard->gus = gus; 319 maxcard->gus = gus;
345 maxcard->cs4231 = cs4231; 320 maxcard->cs4231 = cs4231;
346 snd_gusmax_cards[dev] = card; 321 snd_gusmax_cards[dev] = card;
347 return 0; 322 return 0;
323
324 _err:
325 snd_card_free(card);
326 return err;
348} 327}
349 328
350static int __init snd_gusmax_legacy_auto_probe(unsigned long xport) 329static int __init snd_gusmax_legacy_auto_probe(unsigned long xport)