aboutsummaryrefslogtreecommitdiffstats
path: root/sound/isa/opti9xx/opti92x-ad1848.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/isa/opti9xx/opti92x-ad1848.c')
-rw-r--r--sound/isa/opti9xx/opti92x-ad1848.c242
1 files changed, 121 insertions, 121 deletions
diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c
index 5cd555325b9d..c8a8da0d4036 100644
--- a/sound/isa/opti9xx/opti92x-ad1848.c
+++ b/sound/isa/opti9xx/opti92x-ad1848.c
@@ -135,21 +135,15 @@ struct snd_opti9xx {
135 unsigned long mc_base_size; 135 unsigned long mc_base_size;
136#ifdef OPTi93X 136#ifdef OPTi93X
137 unsigned long mc_indir_index; 137 unsigned long mc_indir_index;
138 unsigned long mc_indir_size;
139 struct resource *res_mc_indir;
138 struct snd_wss *codec; 140 struct snd_wss *codec;
139#endif /* OPTi93X */ 141#endif /* OPTi93X */
140 unsigned long pwd_reg; 142 unsigned long pwd_reg;
141 143
142 spinlock_t lock; 144 spinlock_t lock;
143 145
144 long wss_base;
145 int irq; 146 int irq;
146 int dma1;
147 int dma2;
148
149 long fm_port;
150
151 long mpu_port;
152 int mpu_irq;
153 147
154#ifdef CONFIG_PNP 148#ifdef CONFIG_PNP
155 struct pnp_dev *dev; 149 struct pnp_dev *dev;
@@ -185,7 +179,7 @@ MODULE_DEVICE_TABLE(pnp_card, snd_opti9xx_pnpids);
185#endif 179#endif
186 180
187static char * snd_opti9xx_names[] = { 181static char * snd_opti9xx_names[] = {
188 "unkown", 182 "unknown",
189 "82C928", "82C929", 183 "82C928", "82C929",
190 "82C924", "82C925", 184 "82C924", "82C925",
191 "82C930", "82C931", "82C933" 185 "82C930", "82C931", "82C933"
@@ -216,13 +210,7 @@ static int __devinit snd_opti9xx_init(struct snd_opti9xx *chip,
216 210
217 spin_lock_init(&chip->lock); 211 spin_lock_init(&chip->lock);
218 212
219 chip->wss_base = -1;
220 chip->irq = -1; 213 chip->irq = -1;
221 chip->dma1 = -1;
222 chip->dma2 = -1;
223 chip->fm_port = -1;
224 chip->mpu_port = -1;
225 chip->mpu_irq = -1;
226 214
227 switch (hardware) { 215 switch (hardware) {
228#ifndef OPTi93X 216#ifndef OPTi93X
@@ -245,7 +233,10 @@ static int __devinit snd_opti9xx_init(struct snd_opti9xx *chip,
245 case OPTi9XX_HW_82C931: 233 case OPTi9XX_HW_82C931:
246 case OPTi9XX_HW_82C933: 234 case OPTi9XX_HW_82C933:
247 chip->mc_base = (hardware == OPTi9XX_HW_82C930) ? 0xf8f : 0xf8d; 235 chip->mc_base = (hardware == OPTi9XX_HW_82C930) ? 0xf8f : 0xf8d;
248 chip->mc_indir_index = 0xe0e; 236 if (!chip->mc_indir_index) {
237 chip->mc_indir_index = 0xe0e;
238 chip->mc_indir_size = 2;
239 }
249 chip->password = 0xe4; 240 chip->password = 0xe4;
250 chip->pwd_reg = 0; 241 chip->pwd_reg = 0;
251 break; 242 break;
@@ -348,7 +339,10 @@ static void snd_opti9xx_write(struct snd_opti9xx *chip, unsigned char reg,
348 (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask))) 339 (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask)))
349 340
350 341
351static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip) 342static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip,
343 long wss_base,
344 int irq, int dma1, int dma2,
345 long mpu_port, int mpu_irq)
352{ 346{
353 unsigned char wss_base_bits; 347 unsigned char wss_base_bits;
354 unsigned char irq_bits; 348 unsigned char irq_bits;
@@ -416,7 +410,7 @@ static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip)
416 return -EINVAL; 410 return -EINVAL;
417 } 411 }
418 412
419 switch (chip->wss_base) { 413 switch (wss_base) {
420 case 0x530: 414 case 0x530:
421 wss_base_bits = 0x00; 415 wss_base_bits = 0x00;
422 break; 416 break;
@@ -430,14 +424,13 @@ static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip)
430 wss_base_bits = 0x02; 424 wss_base_bits = 0x02;
431 break; 425 break;
432 default: 426 default:
433 snd_printk(KERN_WARNING "WSS port 0x%lx not valid\n", 427 snd_printk(KERN_WARNING "WSS port 0x%lx not valid\n", wss_base);
434 chip->wss_base);
435 goto __skip_base; 428 goto __skip_base;
436 } 429 }
437 snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(1), wss_base_bits << 4, 0x30); 430 snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(1), wss_base_bits << 4, 0x30);
438 431
439__skip_base: 432__skip_base:
440 switch (chip->irq) { 433 switch (irq) {
441//#ifdef OPTi93X 434//#ifdef OPTi93X
442 case 5: 435 case 5:
443 irq_bits = 0x05; 436 irq_bits = 0x05;
@@ -456,11 +449,11 @@ __skip_base:
456 irq_bits = 0x04; 449 irq_bits = 0x04;
457 break; 450 break;
458 default: 451 default:
459 snd_printk(KERN_WARNING "WSS irq # %d not valid\n", chip->irq); 452 snd_printk(KERN_WARNING "WSS irq # %d not valid\n", irq);
460 goto __skip_resources; 453 goto __skip_resources;
461 } 454 }
462 455
463 switch (chip->dma1) { 456 switch (dma1) {
464 case 0: 457 case 0:
465 dma_bits = 0x01; 458 dma_bits = 0x01;
466 break; 459 break;
@@ -471,38 +464,36 @@ __skip_base:
471 dma_bits = 0x03; 464 dma_bits = 0x03;
472 break; 465 break;
473 default: 466 default:
474 snd_printk(KERN_WARNING "WSS dma1 # %d not valid\n", 467 snd_printk(KERN_WARNING "WSS dma1 # %d not valid\n", dma1);
475 chip->dma1);
476 goto __skip_resources; 468 goto __skip_resources;
477 } 469 }
478 470
479#if defined(CS4231) || defined(OPTi93X) 471#if defined(CS4231) || defined(OPTi93X)
480 if (chip->dma1 == chip->dma2) { 472 if (dma1 == dma2) {
481 snd_printk(KERN_ERR "don't want to share dmas\n"); 473 snd_printk(KERN_ERR "don't want to share dmas\n");
482 return -EBUSY; 474 return -EBUSY;
483 } 475 }
484 476
485 switch (chip->dma2) { 477 switch (dma2) {
486 case 0: 478 case 0:
487 case 1: 479 case 1:
488 break; 480 break;
489 default: 481 default:
490 snd_printk(KERN_WARNING "WSS dma2 # %d not valid\n", 482 snd_printk(KERN_WARNING "WSS dma2 # %d not valid\n", dma2);
491 chip->dma2);
492 goto __skip_resources; 483 goto __skip_resources;
493 } 484 }
494 dma_bits |= 0x04; 485 dma_bits |= 0x04;
495#endif /* CS4231 || OPTi93X */ 486#endif /* CS4231 || OPTi93X */
496 487
497#ifndef OPTi93X 488#ifndef OPTi93X
498 outb(irq_bits << 3 | dma_bits, chip->wss_base); 489 outb(irq_bits << 3 | dma_bits, wss_base);
499#else /* OPTi93X */ 490#else /* OPTi93X */
500 snd_opti9xx_write(chip, OPTi9XX_MC_REG(3), (irq_bits << 3 | dma_bits)); 491 snd_opti9xx_write(chip, OPTi9XX_MC_REG(3), (irq_bits << 3 | dma_bits));
501#endif /* OPTi93X */ 492#endif /* OPTi93X */
502 493
503__skip_resources: 494__skip_resources:
504 if (chip->hardware > OPTi9XX_HW_82C928) { 495 if (chip->hardware > OPTi9XX_HW_82C928) {
505 switch (chip->mpu_port) { 496 switch (mpu_port) {
506 case 0: 497 case 0:
507 case -1: 498 case -1:
508 break; 499 break;
@@ -520,12 +511,11 @@ __skip_resources:
520 break; 511 break;
521 default: 512 default:
522 snd_printk(KERN_WARNING 513 snd_printk(KERN_WARNING
523 "MPU-401 port 0x%lx not valid\n", 514 "MPU-401 port 0x%lx not valid\n", mpu_port);
524 chip->mpu_port);
525 goto __skip_mpu; 515 goto __skip_mpu;
526 } 516 }
527 517
528 switch (chip->mpu_irq) { 518 switch (mpu_irq) {
529 case 5: 519 case 5:
530 mpu_irq_bits = 0x02; 520 mpu_irq_bits = 0x02;
531 break; 521 break;
@@ -540,12 +530,12 @@ __skip_resources:
540 break; 530 break;
541 default: 531 default:
542 snd_printk(KERN_WARNING "MPU-401 irq # %d not valid\n", 532 snd_printk(KERN_WARNING "MPU-401 irq # %d not valid\n",
543 chip->mpu_irq); 533 mpu_irq);
544 goto __skip_mpu; 534 goto __skip_mpu;
545 } 535 }
546 536
547 snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(6), 537 snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(6),
548 (chip->mpu_port <= 0) ? 0x00 : 538 (mpu_port <= 0) ? 0x00 :
549 0x80 | mpu_port_bits << 5 | mpu_irq_bits << 3, 539 0x80 | mpu_port_bits << 5 | mpu_irq_bits << 3,
550 0xf8); 540 0xf8);
551 } 541 }
@@ -558,10 +548,13 @@ __skip_mpu:
558 548
559static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id) 549static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id)
560{ 550{
561 struct snd_wss *codec = dev_id; 551 struct snd_opti9xx *chip = dev_id;
562 struct snd_opti9xx *chip = codec->card->private_data; 552 struct snd_wss *codec = chip->codec;
563 unsigned char status; 553 unsigned char status;
564 554
555 if (!codec)
556 return IRQ_HANDLED;
557
565 status = snd_opti9xx_read(chip, OPTi9XX_MC_REG(11)); 558 status = snd_opti9xx_read(chip, OPTi9XX_MC_REG(11));
566 if ((status & OPTi93X_IRQ_PLAYBACK) && codec->playback_substream) 559 if ((status & OPTi93X_IRQ_PLAYBACK) && codec->playback_substream)
567 snd_pcm_period_elapsed(codec->playback_substream); 560 snd_pcm_period_elapsed(codec->playback_substream);
@@ -575,57 +568,69 @@ static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id)
575 568
576#endif /* OPTi93X */ 569#endif /* OPTi93X */
577 570
578static int __devinit snd_card_opti9xx_detect(struct snd_card *card, 571static int __devinit snd_opti9xx_read_check(struct snd_opti9xx *chip)
579 struct snd_opti9xx *chip)
580{ 572{
581 int i, err; 573 unsigned char value;
574#ifdef OPTi93X
575 unsigned long flags;
576#endif
582 577
578 chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size,
579 "OPTi9xx MC");
580 if (chip->res_mc_base == NULL)
581 return -EBUSY;
583#ifndef OPTi93X 582#ifndef OPTi93X
584 for (i = OPTi9XX_HW_82C928; i < OPTi9XX_HW_82C930; i++) { 583 value = snd_opti9xx_read(chip, OPTi9XX_MC_REG(1));
585 unsigned char value; 584 if (value != 0xff && value != inb(chip->mc_base + OPTi9XX_MC_REG(1)))
585 if (value == snd_opti9xx_read(chip, OPTi9XX_MC_REG(1)))
586 return 0;
587#else /* OPTi93X */
588 chip->res_mc_indir = request_region(chip->mc_indir_index,
589 chip->mc_indir_size,
590 "OPTi93x MC");
591 if (chip->res_mc_indir == NULL)
592 return -EBUSY;
586 593
587 if ((err = snd_opti9xx_init(chip, i)) < 0) 594 spin_lock_irqsave(&chip->lock, flags);
588 return err; 595 outb(chip->password, chip->mc_base + chip->pwd_reg);
596 outb(((chip->mc_indir_index & 0x1f0) >> 4), chip->mc_base);
597 spin_unlock_irqrestore(&chip->lock, flags);
589 598
590 if ((chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, "OPTi9xx MC")) == NULL) 599 value = snd_opti9xx_read(chip, OPTi9XX_MC_REG(7));
591 continue; 600 snd_opti9xx_write(chip, OPTi9XX_MC_REG(7), 0xff - value);
601 if (snd_opti9xx_read(chip, OPTi9XX_MC_REG(7)) == 0xff - value)
602 return 0;
592 603
593 value = snd_opti9xx_read(chip, OPTi9XX_MC_REG(1)); 604 release_and_free_resource(chip->res_mc_indir);
594 if ((value != 0xff) && (value != inb(chip->mc_base + 1))) 605 chip->res_mc_indir = NULL;
595 if (value == snd_opti9xx_read(chip, OPTi9XX_MC_REG(1))) 606#endif /* OPTi93X */
596 return 1; 607 release_and_free_resource(chip->res_mc_base);
608 chip->res_mc_base = NULL;
597 609
598 release_and_free_resource(chip->res_mc_base); 610 return -ENODEV;
599 chip->res_mc_base = NULL; 611}
600 612
601 } 613static int __devinit snd_card_opti9xx_detect(struct snd_card *card,
602#else /* OPTi93X */ 614 struct snd_opti9xx *chip)
603 for (i = OPTi9XX_HW_82C931; i >= OPTi9XX_HW_82C930; i--) { 615{
604 unsigned long flags; 616 int i, err;
605 unsigned char value;
606 617
607 if ((err = snd_opti9xx_init(chip, i)) < 0) 618#ifndef OPTi93X
619 for (i = OPTi9XX_HW_82C928; i < OPTi9XX_HW_82C930; i++) {
620#else
621 for (i = OPTi9XX_HW_82C931; i >= OPTi9XX_HW_82C930; i--) {
622#endif
623 err = snd_opti9xx_init(chip, i);
624 if (err < 0)
608 return err; 625 return err;
609 626
610 if ((chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, "OPTi9xx MC")) == NULL) 627 err = snd_opti9xx_read_check(chip);
611 continue; 628 if (err == 0)
612
613 spin_lock_irqsave(&chip->lock, flags);
614 outb(chip->password, chip->mc_base + chip->pwd_reg);
615 outb(((chip->mc_indir_index & (1 << 8)) >> 4) |
616 ((chip->mc_indir_index & 0xf0) >> 4), chip->mc_base);
617 spin_unlock_irqrestore(&chip->lock, flags);
618
619 value = snd_opti9xx_read(chip, OPTi9XX_MC_REG(7));
620 snd_opti9xx_write(chip, OPTi9XX_MC_REG(7), 0xff - value);
621 if (snd_opti9xx_read(chip, OPTi9XX_MC_REG(7)) == 0xff - value)
622 return 1; 629 return 1;
623 630#ifdef OPTi93X
624 release_and_free_resource(chip->res_mc_base); 631 chip->mc_indir_index = 0;
625 chip->res_mc_base = NULL; 632#endif
626 } 633 }
627#endif /* OPTi93X */
628
629 return -ENODEV; 634 return -ENODEV;
630} 635}
631 636
@@ -654,6 +659,8 @@ static int __devinit snd_card_opti9xx_pnp(struct snd_opti9xx *chip,
654#ifdef OPTi93X 659#ifdef OPTi93X
655 port = pnp_port_start(pdev, 0) - 4; 660 port = pnp_port_start(pdev, 0) - 4;
656 fm_port = pnp_port_start(pdev, 1) + 8; 661 fm_port = pnp_port_start(pdev, 1) + 8;
662 chip->mc_indir_index = pnp_port_start(pdev, 3) + 2;
663 chip->mc_indir_size = pnp_port_len(pdev, 3) - 2;
657#else 664#else
658 if (pid->driver_data != 0x0924) 665 if (pid->driver_data != 0x0924)
659 port = pnp_port_start(pdev, 1); 666 port = pnp_port_start(pdev, 1);
@@ -684,14 +691,14 @@ static int __devinit snd_card_opti9xx_pnp(struct snd_opti9xx *chip,
684static void snd_card_opti9xx_free(struct snd_card *card) 691static void snd_card_opti9xx_free(struct snd_card *card)
685{ 692{
686 struct snd_opti9xx *chip = card->private_data; 693 struct snd_opti9xx *chip = card->private_data;
687 694
688 if (chip) { 695 if (chip) {
689#ifdef OPTi93X 696#ifdef OPTi93X
690 struct snd_wss *codec = chip->codec; 697 if (chip->irq > 0) {
691 if (codec && codec->irq > 0) { 698 disable_irq(chip->irq);
692 disable_irq(codec->irq); 699 free_irq(chip->irq, chip);
693 free_irq(codec->irq, codec);
694 } 700 }
701 release_and_free_resource(chip->res_mc_indir);
695#endif 702#endif
696 release_and_free_resource(chip->res_mc_base); 703 release_and_free_resource(chip->res_mc_base);
697 } 704 }
@@ -701,6 +708,7 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card)
701{ 708{
702 static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; 709 static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1};
703 int error; 710 int error;
711 int xdma2;
704 struct snd_opti9xx *chip = card->private_data; 712 struct snd_opti9xx *chip = card->private_data;
705 struct snd_wss *codec; 713 struct snd_wss *codec;
706#ifdef CS4231 714#ifdef CS4231
@@ -710,36 +718,25 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card)
710 struct snd_rawmidi *rmidi; 718 struct snd_rawmidi *rmidi;
711 struct snd_hwdep *synth; 719 struct snd_hwdep *synth;
712 720
713 if (! chip->res_mc_base &&
714 (chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size,
715 "OPTi9xx MC")) == NULL)
716 return -ENOMEM;
717
718 chip->wss_base = port;
719 chip->fm_port = fm_port;
720 chip->mpu_port = mpu_port;
721 chip->irq = irq;
722 chip->mpu_irq = mpu_irq;
723 chip->dma1 = dma1;
724#if defined(CS4231) || defined(OPTi93X) 721#if defined(CS4231) || defined(OPTi93X)
725 chip->dma2 = dma2; 722 xdma2 = dma2;
726#else 723#else
727 chip->dma2 = -1; 724 xdma2 = -1;
728#endif 725#endif
729 726
730 if (chip->wss_base == SNDRV_AUTO_PORT) { 727 if (port == SNDRV_AUTO_PORT) {
731 chip->wss_base = snd_legacy_find_free_ioport(possible_ports, 4); 728 port = snd_legacy_find_free_ioport(possible_ports, 4);
732 if (chip->wss_base < 0) { 729 if (port < 0) {
733 snd_printk(KERN_ERR "unable to find a free WSS port\n"); 730 snd_printk(KERN_ERR "unable to find a free WSS port\n");
734 return -EBUSY; 731 return -EBUSY;
735 } 732 }
736 } 733 }
737 error = snd_opti9xx_configure(chip); 734 error = snd_opti9xx_configure(chip, port, irq, dma1, xdma2,
735 mpu_port, mpu_irq);
738 if (error) 736 if (error)
739 return error; 737 return error;
740 738
741 error = snd_wss_create(card, chip->wss_base + 4, -1, 739 error = snd_wss_create(card, port + 4, -1, irq, dma1, xdma2,
742 chip->irq, chip->dma1, chip->dma2,
743#ifdef OPTi93X 740#ifdef OPTi93X
744 WSS_HW_OPTI93X, WSS_HWSHARE_IRQ, 741 WSS_HW_OPTI93X, WSS_HWSHARE_IRQ,
745#else 742#else
@@ -763,35 +760,35 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card)
763 return error; 760 return error;
764#endif 761#endif
765#ifdef OPTi93X 762#ifdef OPTi93X
766 error = request_irq(chip->irq, snd_opti93x_interrupt, 763 error = request_irq(irq, snd_opti93x_interrupt,
767 IRQF_DISABLED, DEV_NAME" - WSS", codec); 764 IRQF_DISABLED, DEV_NAME" - WSS", chip);
768 if (error < 0) { 765 if (error < 0) {
769 snd_printk(KERN_ERR "opti9xx: can't grab IRQ %d\n", chip->irq); 766 snd_printk(KERN_ERR "opti9xx: can't grab IRQ %d\n", irq);
770 return error; 767 return error;
771 } 768 }
772#endif 769#endif
770 chip->irq = irq;
773 strcpy(card->driver, chip->name); 771 strcpy(card->driver, chip->name);
774 sprintf(card->shortname, "OPTi %s", card->driver); 772 sprintf(card->shortname, "OPTi %s", card->driver);
775#if defined(CS4231) || defined(OPTi93X) 773#if defined(CS4231) || defined(OPTi93X)
776 sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d", 774 sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d",
777 card->shortname, pcm->name, chip->wss_base + 4, 775 card->shortname, pcm->name, port + 4, irq, dma1, xdma2);
778 chip->irq, chip->dma1, chip->dma2);
779#else 776#else
780 sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", 777 sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d",
781 card->shortname, pcm->name, chip->wss_base + 4, 778 card->shortname, pcm->name, port + 4, irq, dma1);
782 chip->irq, chip->dma1);
783#endif /* CS4231 || OPTi93X */ 779#endif /* CS4231 || OPTi93X */
784 780
785 if (chip->mpu_port <= 0 || chip->mpu_port == SNDRV_AUTO_PORT) 781 if (mpu_port <= 0 || mpu_port == SNDRV_AUTO_PORT)
786 rmidi = NULL; 782 rmidi = NULL;
787 else 783 else {
788 if ((error = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, 784 error = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401,
789 chip->mpu_port, 0, chip->mpu_irq, IRQF_DISABLED, 785 mpu_port, 0, mpu_irq, IRQF_DISABLED, &rmidi);
790 &rmidi))) 786 if (error)
791 snd_printk(KERN_WARNING "no MPU-401 device at 0x%lx?\n", 787 snd_printk(KERN_WARNING "no MPU-401 device at 0x%lx?\n",
792 chip->mpu_port); 788 mpu_port);
789 }
793 790
794 if (chip->fm_port > 0 && chip->fm_port != SNDRV_AUTO_PORT) { 791 if (fm_port > 0 && fm_port != SNDRV_AUTO_PORT) {
795 struct snd_opl3 *opl3 = NULL; 792 struct snd_opl3 *opl3 = NULL;
796#ifndef OPTi93X 793#ifndef OPTi93X
797 if (chip->hardware == OPTi9XX_HW_82C928 || 794 if (chip->hardware == OPTi9XX_HW_82C928 ||
@@ -801,9 +798,7 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card)
801 /* assume we have an OPL4 */ 798 /* assume we have an OPL4 */
802 snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), 799 snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2),
803 0x20, 0x20); 800 0x20, 0x20);
804 if (snd_opl4_create(card, 801 if (snd_opl4_create(card, fm_port, fm_port - 8,
805 chip->fm_port,
806 chip->fm_port - 8,
807 2, &opl3, &opl4) < 0) { 802 2, &opl3, &opl4) < 0) {
808 /* no luck, use OPL3 instead */ 803 /* no luck, use OPL3 instead */
809 snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), 804 snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2),
@@ -811,12 +806,10 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card)
811 } 806 }
812 } 807 }
813#endif /* !OPTi93X */ 808#endif /* !OPTi93X */
814 if (!opl3 && snd_opl3_create(card, 809 if (!opl3 && snd_opl3_create(card, fm_port, fm_port + 2,
815 chip->fm_port,
816 chip->fm_port + 2,
817 OPL3_HW_AUTO, 0, &opl3) < 0) { 810 OPL3_HW_AUTO, 0, &opl3) < 0) {
818 snd_printk(KERN_WARNING "no OPL device at 0x%lx-0x%lx\n", 811 snd_printk(KERN_WARNING "no OPL device at 0x%lx-0x%lx\n",
819 chip->fm_port, chip->fm_port + 4 - 1); 812 fm_port, fm_port + 4 - 1);
820 } 813 }
821 if (opl3) { 814 if (opl3) {
822 error = snd_opl3_hwdep_new(opl3, 0, 1, &synth); 815 error = snd_opl3_hwdep_new(opl3, 0, 1, &synth);
@@ -978,6 +971,13 @@ static int __devinit snd_opti9xx_pnp_probe(struct pnp_card_link *pcard,
978 } 971 }
979 if (hw <= OPTi9XX_HW_82C930) 972 if (hw <= OPTi9XX_HW_82C930)
980 chip->mc_base -= 0x80; 973 chip->mc_base -= 0x80;
974
975 error = snd_opti9xx_read_check(chip);
976 if (error) {
977 snd_printk(KERN_ERR "OPTI chip not found\n");
978 snd_card_free(card);
979 return error;
980 }
981 snd_card_set_dev(card, &pcard->card->dev); 981 snd_card_set_dev(card, &pcard->card->dev);
982 if ((error = snd_opti9xx_probe(card)) < 0) { 982 if ((error = snd_opti9xx_probe(card)) < 0) {
983 snd_card_free(card); 983 snd_card_free(card);