diff options
Diffstat (limited to 'sound/isa/sb/sb16.c')
| -rw-r--r-- | sound/isa/sb/sb16.c | 144 |
1 files changed, 66 insertions, 78 deletions
diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c index 60e2c53c49fc..7888783d68f5 100644 --- a/sound/isa/sb/sb16.c +++ b/sound/isa/sb/sb16.c | |||
| @@ -351,6 +351,12 @@ static void snd_sb16_free(snd_card_t *card) | |||
| 351 | } | 351 | } |
| 352 | } | 352 | } |
| 353 | 353 | ||
| 354 | #ifdef CONFIG_PNP | ||
| 355 | #define is_isapnp_selected(dev) isapnp[dev] | ||
| 356 | #else | ||
| 357 | #define is_isapnp_selected(dev) 0 | ||
| 358 | #endif | ||
| 359 | |||
| 354 | static int __init snd_sb16_probe(int dev, | 360 | static int __init snd_sb16_probe(int dev, |
| 355 | struct pnp_card_link *pcard, | 361 | struct pnp_card_link *pcard, |
| 356 | const struct pnp_card_device_id *pid) | 362 | const struct pnp_card_device_id *pid) |
| @@ -378,10 +384,8 @@ static int __init snd_sb16_probe(int dev, | |||
| 378 | card->private_free = snd_sb16_free; | 384 | card->private_free = snd_sb16_free; |
| 379 | #ifdef CONFIG_PNP | 385 | #ifdef CONFIG_PNP |
| 380 | if (isapnp[dev]) { | 386 | if (isapnp[dev]) { |
| 381 | if ((err = snd_card_sb16_pnp(dev, acard, pcard, pid))) { | 387 | if ((err = snd_card_sb16_pnp(dev, acard, pcard, pid))) |
| 382 | snd_card_free(card); | 388 | goto _err; |
| 383 | return err; | ||
| 384 | } | ||
| 385 | snd_card_set_dev(card, &pcard->card->dev); | 389 | snd_card_set_dev(card, &pcard->card->dev); |
| 386 | } | 390 | } |
| 387 | #endif | 391 | #endif |
| @@ -389,41 +393,37 @@ static int __init snd_sb16_probe(int dev, | |||
| 389 | xirq = irq[dev]; | 393 | xirq = irq[dev]; |
| 390 | xdma8 = dma8[dev]; | 394 | xdma8 = dma8[dev]; |
| 391 | xdma16 = dma16[dev]; | 395 | xdma16 = dma16[dev]; |
| 392 | #ifdef CONFIG_PNP | 396 | if (! is_isapnp_selected(dev)) { |
| 393 | if (!isapnp[dev]) { | 397 | if (xirq == SNDRV_AUTO_IRQ) { |
| 394 | #endif | 398 | if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { |
| 395 | if (xirq == SNDRV_AUTO_IRQ) { | 399 | snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); |
| 396 | if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { | 400 | err = -EBUSY; |
| 397 | snd_card_free(card); | 401 | goto _err; |
| 398 | snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); | 402 | } |
| 399 | return -EBUSY; | ||
| 400 | } | 403 | } |
| 401 | } | 404 | if (xdma8 == SNDRV_AUTO_DMA) { |
| 402 | if (xdma8 == SNDRV_AUTO_DMA) { | 405 | if ((xdma8 = snd_legacy_find_free_dma(possible_dmas8)) < 0) { |
| 403 | if ((xdma8 = snd_legacy_find_free_dma(possible_dmas8)) < 0) { | 406 | snd_printk(KERN_ERR PFX "unable to find a free 8-bit DMA\n"); |
| 404 | snd_card_free(card); | 407 | err = -EBUSY; |
| 405 | snd_printk(KERN_ERR PFX "unable to find a free 8-bit DMA\n"); | 408 | goto _err; |
| 406 | return -EBUSY; | 409 | } |
| 407 | } | 410 | } |
| 408 | } | 411 | if (xdma16 == SNDRV_AUTO_DMA) { |
| 409 | if (xdma16 == SNDRV_AUTO_DMA) { | 412 | if ((xdma16 = snd_legacy_find_free_dma(possible_dmas16)) < 0) { |
| 410 | if ((xdma16 = snd_legacy_find_free_dma(possible_dmas16)) < 0) { | 413 | snd_printk(KERN_ERR PFX "unable to find a free 16-bit DMA\n"); |
| 411 | snd_card_free(card); | 414 | err = -EBUSY; |
| 412 | snd_printk(KERN_ERR PFX "unable to find a free 16-bit DMA\n"); | 415 | goto _err; |
| 413 | return -EBUSY; | 416 | } |
| 414 | } | 417 | } |
| 415 | } | 418 | /* non-PnP FM port address is hardwired with base port address */ |
| 416 | /* non-PnP FM port address is hardwired with base port address */ | 419 | fm_port[dev] = port[dev]; |
| 417 | fm_port[dev] = port[dev]; | 420 | /* block the 0x388 port to avoid PnP conflicts */ |
| 418 | /* block the 0x388 port to avoid PnP conflicts */ | 421 | acard->fm_res = request_region(0x388, 4, "SoundBlaster FM"); |
| 419 | acard->fm_res = request_region(0x388, 4, "SoundBlaster FM"); | ||
| 420 | #ifdef SNDRV_SBAWE_EMU8000 | 422 | #ifdef SNDRV_SBAWE_EMU8000 |
| 421 | /* non-PnP AWE port address is hardwired with base port address */ | 423 | /* non-PnP AWE port address is hardwired with base port address */ |
| 422 | awe_port[dev] = port[dev] + 0x400; | 424 | awe_port[dev] = port[dev] + 0x400; |
| 423 | #endif | 425 | #endif |
| 424 | #ifdef CONFIG_PNP | ||
| 425 | } | 426 | } |
| 426 | #endif | ||
| 427 | 427 | ||
| 428 | if ((err = snd_sbdsp_create(card, | 428 | if ((err = snd_sbdsp_create(card, |
| 429 | port[dev], | 429 | port[dev], |
| @@ -432,28 +432,20 @@ static int __init snd_sb16_probe(int dev, | |||
| 432 | xdma8, | 432 | xdma8, |
| 433 | xdma16, | 433 | xdma16, |
| 434 | SB_HW_AUTO, | 434 | SB_HW_AUTO, |
| 435 | &chip)) < 0) { | 435 | &chip)) < 0) |
| 436 | snd_card_free(card); | 436 | goto _err; |
| 437 | return err; | 437 | |
| 438 | } | ||
| 439 | if (chip->hardware != SB_HW_16) { | 438 | if (chip->hardware != SB_HW_16) { |
| 440 | snd_card_free(card); | 439 | snd_printk(KERN_ERR PFX "SB 16 chip was not detected at 0x%lx\n", port[dev]); |
| 441 | snd_printdd("SB 16 chip was not detected at 0x%lx\n", port[dev]); | 440 | err = -ENODEV; |
| 442 | return -ENODEV; | 441 | goto _err; |
| 443 | } | 442 | } |
| 444 | chip->mpu_port = mpu_port[dev]; | 443 | chip->mpu_port = mpu_port[dev]; |
| 445 | #ifdef CONFIG_PNP | 444 | if (! is_isapnp_selected(dev) && (err = snd_sb16dsp_configure(chip)) < 0) |
| 446 | if (!isapnp[dev] && (err = snd_sb16dsp_configure(chip)) < 0) { | 445 | goto _err; |
| 447 | #else | 446 | |
| 448 | if ((err = snd_sb16dsp_configure(chip)) < 0) { | 447 | if ((err = snd_sb16dsp_pcm(chip, 0, NULL)) < 0) |
| 449 | #endif | 448 | goto _err; |
| 450 | snd_card_free(card); | ||
| 451 | return -ENXIO; | ||
| 452 | } | ||
| 453 | if ((err = snd_sb16dsp_pcm(chip, 0, NULL)) < 0) { | ||
| 454 | snd_card_free(card); | ||
| 455 | return -ENXIO; | ||
| 456 | } | ||
| 457 | 449 | ||
| 458 | strcpy(card->driver, | 450 | strcpy(card->driver, |
| 459 | #ifdef SNDRV_SBAWE_EMU8000 | 451 | #ifdef SNDRV_SBAWE_EMU8000 |
| @@ -474,10 +466,8 @@ static int __init snd_sb16_probe(int dev, | |||
| 474 | if (chip->mpu_port > 0 && chip->mpu_port != SNDRV_AUTO_PORT) { | 466 | if (chip->mpu_port > 0 && chip->mpu_port != SNDRV_AUTO_PORT) { |
| 475 | if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_SB, | 467 | if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_SB, |
| 476 | chip->mpu_port, 0, | 468 | chip->mpu_port, 0, |
| 477 | xirq, 0, &chip->rmidi)) < 0) { | 469 | xirq, 0, &chip->rmidi)) < 0) |
| 478 | snd_card_free(card); | 470 | goto _err; |
| 479 | return -ENXIO; | ||
| 480 | } | ||
| 481 | chip->rmidi_callback = snd_mpu401_uart_interrupt; | 471 | chip->rmidi_callback = snd_mpu401_uart_interrupt; |
| 482 | } | 472 | } |
| 483 | 473 | ||
| @@ -499,17 +489,13 @@ static int __init snd_sb16_probe(int dev, | |||
| 499 | #else | 489 | #else |
| 500 | int seqdev = 1; | 490 | int seqdev = 1; |
| 501 | #endif | 491 | #endif |
| 502 | if ((err = snd_opl3_hwdep_new(opl3, 0, seqdev, &synth)) < 0) { | 492 | if ((err = snd_opl3_hwdep_new(opl3, 0, seqdev, &synth)) < 0) |
| 503 | snd_card_free(card); | 493 | goto _err; |
| 504 | return -ENXIO; | ||
| 505 | } | ||
| 506 | } | 494 | } |
| 507 | } | 495 | } |
| 508 | 496 | ||
| 509 | if ((err = snd_sbmixer_new(chip)) < 0) { | 497 | if ((err = snd_sbmixer_new(chip)) < 0) |
| 510 | snd_card_free(card); | 498 | goto _err; |
| 511 | return -ENXIO; | ||
| 512 | } | ||
| 513 | 499 | ||
| 514 | #ifdef CONFIG_SND_SB16_CSP | 500 | #ifdef CONFIG_SND_SB16_CSP |
| 515 | /* CSP chip on SB16ASP/AWE32 */ | 501 | /* CSP chip on SB16ASP/AWE32 */ |
| @@ -525,11 +511,11 @@ static int __init snd_sb16_probe(int dev, | |||
| 525 | #endif | 511 | #endif |
| 526 | #ifdef SNDRV_SBAWE_EMU8000 | 512 | #ifdef SNDRV_SBAWE_EMU8000 |
| 527 | if (awe_port[dev] > 0) { | 513 | if (awe_port[dev] > 0) { |
| 528 | if (snd_emu8000_new(card, 1, awe_port[dev], | 514 | if ((err = snd_emu8000_new(card, 1, awe_port[dev], |
| 529 | seq_ports[dev], NULL) < 0) { | 515 | seq_ports[dev], NULL)) < 0) { |
| 530 | snd_printk(KERN_ERR PFX "fatal error - EMU-8000 synthesizer not detected at 0x%lx\n", awe_port[dev]); | 516 | snd_printk(KERN_ERR PFX "fatal error - EMU-8000 synthesizer not detected at 0x%lx\n", awe_port[dev]); |
| 531 | snd_card_free(card); | 517 | |
| 532 | return -ENXIO; | 518 | goto _err; |
| 533 | } | 519 | } |
| 534 | } | 520 | } |
| 535 | #endif | 521 | #endif |
| @@ -541,15 +527,21 @@ static int __init snd_sb16_probe(int dev, | |||
| 541 | (mic_agc[dev] ? 0x00 : 0x01)); | 527 | (mic_agc[dev] ? 0x00 : 0x01)); |
| 542 | spin_unlock_irqrestore(&chip->mixer_lock, flags); | 528 | spin_unlock_irqrestore(&chip->mixer_lock, flags); |
| 543 | 529 | ||
| 544 | if ((err = snd_card_register(card)) < 0) { | 530 | if ((err = snd_card_set_generic_dev(card)) < 0) |
| 545 | snd_card_free(card); | 531 | goto _err; |
| 546 | return err; | 532 | |
| 547 | } | 533 | if ((err = snd_card_register(card)) < 0) |
| 534 | goto _err; | ||
| 535 | |||
| 548 | if (pcard) | 536 | if (pcard) |
| 549 | pnp_set_card_drvdata(pcard, card); | 537 | pnp_set_card_drvdata(pcard, card); |
| 550 | else | 538 | else |
| 551 | snd_sb16_legacy[dev] = card; | 539 | snd_sb16_legacy[dev] = card; |
| 552 | return 0; | 540 | return 0; |
| 541 | |||
| 542 | _err: | ||
| 543 | snd_card_free(card); | ||
| 544 | return err; | ||
| 553 | } | 545 | } |
| 554 | 546 | ||
| 555 | static int __init snd_sb16_probe_legacy_port(unsigned long xport) | 547 | static int __init snd_sb16_probe_legacy_port(unsigned long xport) |
| @@ -560,10 +552,8 @@ static int __init snd_sb16_probe_legacy_port(unsigned long xport) | |||
| 560 | for ( ; dev < SNDRV_CARDS; dev++) { | 552 | for ( ; dev < SNDRV_CARDS; dev++) { |
| 561 | if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) | 553 | if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) |
| 562 | continue; | 554 | continue; |
| 563 | #ifdef CONFIG_PNP | 555 | if (is_isapnp_selected(dev)) |
| 564 | if (isapnp[dev]) | ||
| 565 | continue; | 556 | continue; |
| 566 | #endif | ||
| 567 | port[dev] = xport; | 557 | port[dev] = xport; |
| 568 | res = snd_sb16_probe(dev, NULL, NULL); | 558 | res = snd_sb16_probe(dev, NULL, NULL); |
| 569 | if (res < 0) | 559 | if (res < 0) |
| @@ -621,10 +611,8 @@ static int __init alsa_card_sb16_init(void) | |||
| 621 | for (dev = 0; dev < SNDRV_CARDS; dev++) { | 611 | for (dev = 0; dev < SNDRV_CARDS; dev++) { |
| 622 | if (!enable[dev] || port[dev] == SNDRV_AUTO_PORT) | 612 | if (!enable[dev] || port[dev] == SNDRV_AUTO_PORT) |
| 623 | continue; | 613 | continue; |
| 624 | #ifdef CONFIG_PNP | 614 | if (is_isapnp_selected(dev)) |
| 625 | if (isapnp[dev]) | ||
| 626 | continue; | 615 | continue; |
| 627 | #endif | ||
| 628 | if (!snd_sb16_probe(dev, NULL, NULL)) { | 616 | if (!snd_sb16_probe(dev, NULL, NULL)) { |
| 629 | cards++; | 617 | cards++; |
| 630 | continue; | 618 | continue; |
