aboutsummaryrefslogtreecommitdiffstats
path: root/sound/isa/gus/gusclassic.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/isa/gus/gusclassic.c')
-rw-r--r--sound/isa/gus/gusclassic.c115
1 files changed, 50 insertions, 65 deletions
diff --git a/sound/isa/gus/gusclassic.c b/sound/isa/gus/gusclassic.c
index a99fa5040b46..39cef38835ca 100644
--- a/sound/isa/gus/gusclassic.c
+++ b/sound/isa/gus/gusclassic.c
@@ -72,40 +72,24 @@ MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Classic driver.");
72 72
73static snd_card_t *snd_gusclassic_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 73static snd_card_t *snd_gusclassic_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
74 74
75#define PFX "gusclassic: "
75 76
76static int __init snd_gusclassic_detect(snd_gus_card_t * gus) 77static int __init snd_gusclassic_detect(snd_gus_card_t * gus)
77{ 78{
78 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */ 79 unsigned char d;
79#ifdef CONFIG_SND_DEBUG_DETECT
80 {
81 unsigned char d;
82 80
83 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) { 81 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 0); /* reset GF1 */
84 snd_printk("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d); 82 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 0) {
85 return -ENODEV; 83 snd_printdd("[0x%lx] check 1 failed - 0x%x\n", gus->gf1.port, d);
86 }
87 }
88#else
89 if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 0)
90 return -ENODEV; 84 return -ENODEV;
91#endif 85 }
92 udelay(160); 86 udelay(160);
93 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */ 87 snd_gf1_i_write8(gus, SNDRV_GF1_GB_RESET, 1); /* release reset */
94 udelay(160); 88 udelay(160);
95#ifdef CONFIG_SND_DEBUG_DETECT 89 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) {
96 { 90 snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d);
97 unsigned char d;
98
99 if (((d = snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET)) & 0x07) != 1) {
100 snd_printk("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d);
101 return -ENODEV;
102 }
103 }
104#else
105 if ((snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET) & 0x07) != 1)
106 return -ENODEV; 91 return -ENODEV;
107#endif 92 }
108
109 return 0; 93 return 0;
110} 94}
111 95
@@ -137,25 +121,25 @@ static int __init snd_gusclassic_probe(int dev)
137 xirq = irq[dev]; 121 xirq = irq[dev];
138 if (xirq == SNDRV_AUTO_IRQ) { 122 if (xirq == SNDRV_AUTO_IRQ) {
139 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { 123 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
140 snd_card_free(card); 124 snd_printk(KERN_ERR PFX "unable to find a free IRQ\n");
141 snd_printk("unable to find a free IRQ\n"); 125 err = -EBUSY;
142 return -EBUSY; 126 goto _err;
143 } 127 }
144 } 128 }
145 xdma1 = dma1[dev]; 129 xdma1 = dma1[dev];
146 if (xdma1 == SNDRV_AUTO_DMA) { 130 if (xdma1 == SNDRV_AUTO_DMA) {
147 if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { 131 if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
148 snd_card_free(card); 132 snd_printk(KERN_ERR PFX "unable to find a free DMA1\n");
149 snd_printk("unable to find a free DMA1\n"); 133 err = -EBUSY;
150 return -EBUSY; 134 goto _err;
151 } 135 }
152 } 136 }
153 xdma2 = dma2[dev]; 137 xdma2 = dma2[dev];
154 if (xdma2 == SNDRV_AUTO_DMA) { 138 if (xdma2 == SNDRV_AUTO_DMA) {
155 if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) { 139 if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
156 snd_card_free(card); 140 snd_printk(KERN_ERR PFX "unable to find a free DMA2\n");
157 snd_printk("unable to find a free DMA2\n"); 141 err = -EBUSY;
158 return -EBUSY; 142 goto _err;
159 } 143 }
160 } 144 }
161 145
@@ -164,47 +148,48 @@ static int __init snd_gusclassic_probe(int dev)
164 port[dev], 148 port[dev],
165 xirq, xdma1, xdma2, 149 xirq, xdma1, xdma2,
166 0, channels[dev], pcm_channels[dev], 150 0, channels[dev], pcm_channels[dev],
167 0, &gus)) < 0) { 151 0, &gus)) < 0)
168 snd_card_free(card); 152 goto _err;
169 return err; 153
170 } 154 if ((err = snd_gusclassic_detect(gus)) < 0)
171 if ((err = snd_gusclassic_detect(gus)) < 0) { 155 goto _err;
172 snd_card_free(card); 156
173 return err;
174 }
175 snd_gusclassic_init(dev, gus); 157 snd_gusclassic_init(dev, gus);
176 if ((err = snd_gus_initialize(gus)) < 0) { 158 if ((err = snd_gus_initialize(gus)) < 0)
177 snd_card_free(card); 159 goto _err;
178 return err; 160
179 }
180 if (gus->max_flag || gus->ess_flag) { 161 if (gus->max_flag || gus->ess_flag) {
181 snd_printdd("GUS Classic or ACE soundcard was not detected at 0x%lx\n", gus->gf1.port); 162 snd_printk(KERN_ERR PFX "GUS Classic or ACE soundcard was not detected at 0x%lx\n", gus->gf1.port);
182 snd_card_free(card); 163 err = -ENODEV;
183 return -ENODEV; 164 goto _err;
184 }
185 if ((err = snd_gf1_new_mixer(gus)) < 0) {
186 snd_card_free(card);
187 return err;
188 }
189 if ((err = snd_gf1_pcm_new(gus, 0, 0, NULL)) < 0) {
190 snd_card_free(card);
191 return err;
192 } 165 }
166
167 if ((err = snd_gf1_new_mixer(gus)) < 0)
168 goto _err;
169
170 if ((err = snd_gf1_pcm_new(gus, 0, 0, NULL)) < 0)
171 goto _err;
172
193 if (!gus->ace_flag) { 173 if (!gus->ace_flag) {
194 if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) { 174 if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0)
195 snd_card_free(card); 175 goto _err;
196 return err;
197 }
198 } 176 }
199 sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %d, dma %d", gus->gf1.port, xirq, xdma1); 177 sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %d, dma %d", gus->gf1.port, xirq, xdma1);
200 if (dma2 >= 0) 178 if (dma2 >= 0)
201 sprintf(card->longname + strlen(card->longname), "&%d", xdma2); 179 sprintf(card->longname + strlen(card->longname), "&%d", xdma2);
202 if ((err = snd_card_register(card)) < 0) { 180
203 snd_card_free(card); 181 if ((err = snd_card_set_generic_dev(card)) < 0)
204 return err; 182 goto _err;
205 } 183
184 if ((err = snd_card_register(card)) < 0)
185 goto _err;
186
206 snd_gusclassic_cards[dev] = card; 187 snd_gusclassic_cards[dev] = card;
207 return 0; 188 return 0;
189
190 _err:
191 snd_card_free(card);
192 return err;
208} 193}
209 194
210static int __init snd_gusclassic_legacy_auto_probe(unsigned long xport) 195static int __init snd_gusclassic_legacy_auto_probe(unsigned long xport)