aboutsummaryrefslogtreecommitdiffstats
path: root/sound/isa/gus/interwave.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/isa/gus/interwave.c')
-rw-r--r--sound/isa/gus/interwave.c167
1 files changed, 70 insertions, 97 deletions
diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c
index 46e867daba6a..358cba9d738f 100644
--- a/sound/isa/gus/interwave.c
+++ b/sound/isa/gus/interwave.c
@@ -73,6 +73,12 @@ static int midi[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
73static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; 73static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
74static int effect[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0}; 74static int effect[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
75 75
76#ifdef SNDRV_STB
77#define PFX "interwave-stb: "
78#else
79#define PFX "interwave: "
80#endif
81
76module_param_array(index, int, NULL, 0444); 82module_param_array(index, int, NULL, 0444);
77MODULE_PARM_DESC(index, "Index value for InterWave soundcard."); 83MODULE_PARM_DESC(index, "Index value for InterWave soundcard.");
78module_param_array(id, charp, NULL, 0444); 84module_param_array(id, charp, NULL, 0444);
@@ -249,38 +255,20 @@ static int __devinit snd_interwave_detect(struct snd_interwave *iwcard,
249{ 255{
250 unsigned long flags; 256 unsigned long flags;
251 unsigned char rev1, rev2; 257 unsigned char rev1, rev2;
258 int d;
252 259
253 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */ 260 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */
254#ifdef CONFIG_SND_DEBUG_DETECT 261 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) {
255 { 262 snd_printdd("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d);
256 int d;
257
258 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) {
259 snd_printk("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d);
260 return -ENODEV;
261 }
262 }
263#else
264 if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 0)
265 return -ENODEV; 263 return -ENODEV;
266#endif 264 }
267 udelay(160); 265 udelay(160);
268 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */ 266 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */
269 udelay(160); 267 udelay(160);
270#ifdef CONFIG_SND_DEBUG_DETECT 268 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) {
271 { 269 snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d);
272 int d;
273
274 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) {
275 snd_printk("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d);
276 return -ENODEV;
277 }
278 }
279#else
280 if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 1)
281 return -ENODEV; 270 return -ENODEV;
282#endif 271 }
283
284 spin_lock_irqsave(&gus->reg_lock, flags); 272 spin_lock_irqsave(&gus->reg_lock, flags);
285 rev1 = snd_gf1_look8(gus, SNDRV_GF1_GB_VERSION_NUMBER); 273 rev1 = snd_gf1_look8(gus, SNDRV_GF1_GB_VERSION_NUMBER);
286 snd_gf1_write8(gus, SNDRV_GF1_GB_VERSION_NUMBER, ~rev1); 274 snd_gf1_write8(gus, SNDRV_GF1_GB_VERSION_NUMBER, ~rev1);
@@ -686,35 +674,33 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard,
686 card->private_free = snd_interwave_free; 674 card->private_free = snd_interwave_free;
687#ifdef CONFIG_PNP 675#ifdef CONFIG_PNP
688 if (isapnp[dev]) { 676 if (isapnp[dev]) {
689 if (snd_interwave_pnp(dev, iwcard, pcard, pid)) { 677 if ((err = snd_interwave_pnp(dev, iwcard, pcard, pid)) < 0)
690 snd_card_free(card); 678 goto _err;
691 return -ENODEV;
692 }
693 snd_card_set_dev(card, &pcard->card->dev); 679 snd_card_set_dev(card, &pcard->card->dev);
694 } 680 }
695#endif 681#endif
696 xirq = irq[dev]; 682 xirq = irq[dev];
697 if (xirq == SNDRV_AUTO_IRQ) { 683 if (xirq == SNDRV_AUTO_IRQ) {
698 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { 684 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
699 snd_card_free(card); 685 snd_printk(KERN_ERR PFX "unable to find a free IRQ\n");
700 snd_printk("unable to find a free IRQ\n"); 686 err = -EBUSY;
701 return -EBUSY; 687 goto _err;
702 } 688 }
703 } 689 }
704 xdma1 = dma1[dev]; 690 xdma1 = dma1[dev];
705 if (xdma1 == SNDRV_AUTO_DMA) { 691 if (xdma1 == SNDRV_AUTO_DMA) {
706 if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { 692 if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
707 snd_card_free(card); 693 snd_printk(KERN_ERR PFX "unable to find a free DMA1\n");
708 snd_printk("unable to find a free DMA1\n"); 694 err = -EBUSY;
709 return -EBUSY; 695 goto _err;
710 } 696 }
711 } 697 }
712 xdma2 = dma2[dev]; 698 xdma2 = dma2[dev];
713 if (xdma2 == SNDRV_AUTO_DMA) { 699 if (xdma2 == SNDRV_AUTO_DMA) {
714 if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) { 700 if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
715 snd_card_free(card); 701 snd_printk(KERN_ERR PFX "unable to find a free DMA2\n");
716 snd_printk("unable to find a free DMA2\n"); 702 err = -EBUSY;
717 return -EBUSY; 703 goto _err;
718 } 704 }
719 } 705 }
720 706
@@ -722,32 +708,28 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard,
722 port[dev], 708 port[dev],
723 -xirq, xdma1, xdma2, 709 -xirq, xdma1, xdma2,
724 0, 32, 710 0, 32,
725 pcm_channels[dev], effect[dev], &gus)) < 0) { 711 pcm_channels[dev], effect[dev], &gus)) < 0)
726 snd_card_free(card); 712 goto _err;
727 return err; 713
728 }
729 if ((err = snd_interwave_detect(iwcard, gus, dev 714 if ((err = snd_interwave_detect(iwcard, gus, dev
730#ifdef SNDRV_STB 715#ifdef SNDRV_STB
731 , &i2c_bus 716 , &i2c_bus
732#endif 717#endif
733 )) < 0) { 718 )) < 0)
734 snd_card_free(card); 719 goto _err;
735 return err; 720
736 }
737 iwcard->gus_status_reg = gus->gf1.reg_irqstat; 721 iwcard->gus_status_reg = gus->gf1.reg_irqstat;
738 iwcard->pcm_status_reg = gus->gf1.port + 0x10c + 2; 722 iwcard->pcm_status_reg = gus->gf1.port + 0x10c + 2;
739 723
740 snd_interwave_init(dev, gus); 724 snd_interwave_init(dev, gus);
741 snd_interwave_detect_memory(gus); 725 snd_interwave_detect_memory(gus);
742 if ((err = snd_gus_initialize(gus)) < 0) { 726 if ((err = snd_gus_initialize(gus)) < 0)
743 snd_card_free(card); 727 goto _err;
744 return err;
745 }
746 728
747 if (request_irq(xirq, snd_interwave_interrupt, SA_INTERRUPT, "InterWave", (void *)iwcard)) { 729 if (request_irq(xirq, snd_interwave_interrupt, SA_INTERRUPT, "InterWave", (void *)iwcard)) {
748 snd_card_free(card); 730 snd_printk(KERN_ERR PFX "unable to grab IRQ %d\n", xirq);
749 snd_printk("unable to grab IRQ %d\n", xirq); 731 err = -EBUSY;
750 return -EBUSY; 732 goto _err;
751 } 733 }
752 iwcard->irq = xirq; 734 iwcard->irq = xirq;
753 735
@@ -758,34 +740,28 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard,
758 CS4231_HWSHARE_IRQ | 740 CS4231_HWSHARE_IRQ |
759 CS4231_HWSHARE_DMA1 | 741 CS4231_HWSHARE_DMA1 |
760 CS4231_HWSHARE_DMA2, 742 CS4231_HWSHARE_DMA2,
761 &cs4231)) < 0) { 743 &cs4231)) < 0)
762 snd_card_free(card); 744 goto _err;
763 return err; 745
764 } 746 if ((err = snd_cs4231_pcm(cs4231, 0, &pcm)) < 0)
765 if ((err = snd_cs4231_pcm(cs4231, 0, &pcm)) < 0) { 747 goto _err;
766 snd_card_free(card); 748
767 return err;
768 }
769 sprintf(pcm->name + strlen(pcm->name), " rev %c", gus->revision + 'A'); 749 sprintf(pcm->name + strlen(pcm->name), " rev %c", gus->revision + 'A');
770 strcat(pcm->name, " (codec)"); 750 strcat(pcm->name, " (codec)");
771 if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0) { 751
772 snd_card_free(card); 752 if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0)
773 return err; 753 goto _err;
774 } 754
775 if ((err = snd_cs4231_mixer(cs4231)) < 0) { 755 if ((err = snd_cs4231_mixer(cs4231)) < 0)
776 snd_card_free(card); 756 goto _err;
777 return err; 757
778 }
779 if (pcm_channels[dev] > 0) { 758 if (pcm_channels[dev] > 0) {
780 if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) { 759 if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0)
781 snd_card_free(card); 760 goto _err;
782 return err;
783 }
784 }
785 if ((err = snd_interwave_mixer(cs4231)) < 0) {
786 snd_card_free(card);
787 return err;
788 } 761 }
762 if ((err = snd_interwave_mixer(cs4231)) < 0)
763 goto _err;
764
789#ifdef SNDRV_STB 765#ifdef SNDRV_STB
790 { 766 {
791 snd_ctl_elem_id_t id1, id2; 767 snd_ctl_elem_id_t id1, id2;
@@ -795,28 +771,20 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard,
795 strcpy(id1.name, "Master Playback Switch"); 771 strcpy(id1.name, "Master Playback Switch");
796 strcpy(id2.name, id1.name); 772 strcpy(id2.name, id1.name);
797 id2.index = 1; 773 id2.index = 1;
798 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) { 774 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0)
799 snd_card_free(card); 775 goto _err;
800 return err;
801 }
802 strcpy(id1.name, "Master Playback Volume"); 776 strcpy(id1.name, "Master Playback Volume");
803 strcpy(id2.name, id1.name); 777 strcpy(id2.name, id1.name);
804 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) { 778 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0)
805 snd_card_free(card); 779 goto _err;
806 return err; 780 if ((err = snd_tea6330t_update_mixer(card, i2c_bus, 0, 1)) < 0)
807 } 781 goto _err;
808 if ((err = snd_tea6330t_update_mixer(card, i2c_bus, 0, 1)) < 0) {
809 snd_card_free(card);
810 return err;
811 }
812 } 782 }
813#endif 783#endif
814 784
815 gus->uart_enable = midi[dev]; 785 gus->uart_enable = midi[dev];
816 if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) { 786 if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0)
817 snd_card_free(card); 787 goto _err;
818 return err;
819 }
820 788
821#ifndef SNDRV_STB 789#ifndef SNDRV_STB
822 str = "AMD InterWave"; 790 str = "AMD InterWave";
@@ -835,10 +803,11 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard,
835 if (xdma2 >= 0) 803 if (xdma2 >= 0)
836 sprintf(card->longname + strlen(card->longname), "&%d", xdma2); 804 sprintf(card->longname + strlen(card->longname), "&%d", xdma2);
837 805
838 if ((err = snd_card_register(card)) < 0) { 806 if ((err = snd_card_set_generic_dev(card)) < 0)
839 snd_card_free(card); 807 goto _err;
840 return err; 808
841 } 809 if ((err = snd_card_register(card)) < 0)
810 goto _err;
842 811
843 iwcard->cs4231 = cs4231; 812 iwcard->cs4231 = cs4231;
844 iwcard->gus = gus; 813 iwcard->gus = gus;
@@ -847,6 +816,10 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard,
847 else 816 else
848 snd_interwave_legacy[dev++] = card; 817 snd_interwave_legacy[dev++] = card;
849 return 0; 818 return 0;
819
820 _err:
821 snd_card_free(card);
822 return err;
850} 823}
851 824
852static int __devinit snd_interwave_probe_legacy_port(unsigned long xport) 825static int __devinit snd_interwave_probe_legacy_port(unsigned long xport)