diff options
Diffstat (limited to 'sound/isa/gus/gusextreme.c')
-rw-r--r-- | sound/isa/gus/gusextreme.c | 378 |
1 files changed, 182 insertions, 196 deletions
diff --git a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c index 4f55fc3e66c1..74e34e6e16f2 100644 --- a/sound/isa/gus/gusextreme.c +++ b/sound/isa/gus/gusextreme.c | |||
@@ -22,7 +22,7 @@ | |||
22 | #include <sound/driver.h> | 22 | #include <sound/driver.h> |
23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
24 | #include <linux/err.h> | 24 | #include <linux/err.h> |
25 | #include <linux/platform_device.h> | 25 | #include <linux/isa.h> |
26 | #include <linux/delay.h> | 26 | #include <linux/delay.h> |
27 | #include <linux/time.h> | 27 | #include <linux/time.h> |
28 | #include <linux/moduleparam.h> | 28 | #include <linux/moduleparam.h> |
@@ -37,8 +37,11 @@ | |||
37 | #define SNDRV_LEGACY_FIND_FREE_DMA | 37 | #define SNDRV_LEGACY_FIND_FREE_DMA |
38 | #include <sound/initval.h> | 38 | #include <sound/initval.h> |
39 | 39 | ||
40 | #define CRD_NAME "Gravis UltraSound Extreme" | ||
41 | #define DEV_NAME "gusextreme" | ||
42 | |||
43 | MODULE_DESCRIPTION(CRD_NAME); | ||
40 | MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); | 44 | MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); |
41 | MODULE_DESCRIPTION("Gravis UltraSound Extreme"); | ||
42 | MODULE_LICENSE("GPL"); | 45 | MODULE_LICENSE("GPL"); |
43 | MODULE_SUPPORTED_DEVICE("{{Gravis,UltraSound Extreme}}"); | 46 | MODULE_SUPPORTED_DEVICE("{{Gravis,UltraSound Extreme}}"); |
44 | 47 | ||
@@ -59,43 +62,107 @@ static int channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 24}; | |||
59 | static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; | 62 | static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; |
60 | 63 | ||
61 | module_param_array(index, int, NULL, 0444); | 64 | module_param_array(index, int, NULL, 0444); |
62 | MODULE_PARM_DESC(index, "Index value for GUS Extreme soundcard."); | 65 | MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard."); |
63 | module_param_array(id, charp, NULL, 0444); | 66 | module_param_array(id, charp, NULL, 0444); |
64 | MODULE_PARM_DESC(id, "ID string for GUS Extreme soundcard."); | 67 | MODULE_PARM_DESC(id, "ID string for " CRD_NAME " soundcard."); |
65 | module_param_array(enable, bool, NULL, 0444); | 68 | module_param_array(enable, bool, NULL, 0444); |
66 | MODULE_PARM_DESC(enable, "Enable GUS Extreme soundcard."); | 69 | MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard."); |
67 | module_param_array(port, long, NULL, 0444); | 70 | module_param_array(port, long, NULL, 0444); |
68 | MODULE_PARM_DESC(port, "Port # for GUS Extreme driver."); | 71 | MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver."); |
69 | module_param_array(gf1_port, long, NULL, 0444); | 72 | module_param_array(gf1_port, long, NULL, 0444); |
70 | MODULE_PARM_DESC(gf1_port, "GF1 port # for GUS Extreme driver (optional)."); | 73 | MODULE_PARM_DESC(gf1_port, "GF1 port # for " CRD_NAME " driver (optional)."); |
71 | module_param_array(mpu_port, long, NULL, 0444); | 74 | module_param_array(mpu_port, long, NULL, 0444); |
72 | MODULE_PARM_DESC(mpu_port, "MPU-401 port # for GUS Extreme driver."); | 75 | MODULE_PARM_DESC(mpu_port, "MPU-401 port # for " CRD_NAME " driver."); |
73 | module_param_array(irq, int, NULL, 0444); | 76 | module_param_array(irq, int, NULL, 0444); |
74 | MODULE_PARM_DESC(irq, "IRQ # for GUS Extreme driver."); | 77 | MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME " driver."); |
75 | module_param_array(mpu_irq, int, NULL, 0444); | 78 | module_param_array(mpu_irq, int, NULL, 0444); |
76 | MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for GUS Extreme driver."); | 79 | MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for " CRD_NAME " driver."); |
77 | module_param_array(gf1_irq, int, NULL, 0444); | 80 | module_param_array(gf1_irq, int, NULL, 0444); |
78 | MODULE_PARM_DESC(gf1_irq, "GF1 IRQ # for GUS Extreme driver."); | 81 | MODULE_PARM_DESC(gf1_irq, "GF1 IRQ # for " CRD_NAME " driver."); |
79 | module_param_array(dma8, int, NULL, 0444); | 82 | module_param_array(dma8, int, NULL, 0444); |
80 | MODULE_PARM_DESC(dma8, "8-bit DMA # for GUS Extreme driver."); | 83 | MODULE_PARM_DESC(dma8, "8-bit DMA # for " CRD_NAME " driver."); |
81 | module_param_array(dma1, int, NULL, 0444); | 84 | module_param_array(dma1, int, NULL, 0444); |
82 | MODULE_PARM_DESC(dma1, "GF1 DMA # for GUS Extreme driver."); | 85 | MODULE_PARM_DESC(dma1, "GF1 DMA # for " CRD_NAME " driver."); |
83 | module_param_array(joystick_dac, int, NULL, 0444); | 86 | module_param_array(joystick_dac, int, NULL, 0444); |
84 | MODULE_PARM_DESC(joystick_dac, "Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for GUS Extreme driver."); | 87 | MODULE_PARM_DESC(joystick_dac, "Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for " CRD_NAME " driver."); |
85 | module_param_array(channels, int, NULL, 0444); | 88 | module_param_array(channels, int, NULL, 0444); |
86 | MODULE_PARM_DESC(channels, "GF1 channels for GUS Extreme driver."); | 89 | MODULE_PARM_DESC(channels, "GF1 channels for " CRD_NAME " driver."); |
87 | module_param_array(pcm_channels, int, NULL, 0444); | 90 | module_param_array(pcm_channels, int, NULL, 0444); |
88 | MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Extreme driver."); | 91 | MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for " CRD_NAME " driver."); |
92 | |||
93 | static int __devinit snd_gusextreme_match(struct device *dev, unsigned int n) | ||
94 | { | ||
95 | return enable[n]; | ||
96 | } | ||
97 | |||
98 | static int __devinit snd_gusextreme_es1688_create(struct snd_card *card, | ||
99 | struct device *dev, unsigned int n, struct snd_es1688 **rchip) | ||
100 | { | ||
101 | static long possible_ports[] = {0x220, 0x240, 0x260}; | ||
102 | static int possible_irqs[] = {5, 9, 10, 7, -1}; | ||
103 | static int possible_dmas[] = {1, 3, 0, -1}; | ||
104 | |||
105 | int i, error; | ||
106 | |||
107 | if (irq[n] == SNDRV_AUTO_IRQ) { | ||
108 | irq[n] = snd_legacy_find_free_irq(possible_irqs); | ||
109 | if (irq[n] < 0) { | ||
110 | snd_printk(KERN_ERR "%s: unable to find a free IRQ " | ||
111 | "for ES1688\n", dev->bus_id); | ||
112 | return -EBUSY; | ||
113 | } | ||
114 | } | ||
115 | if (dma8[n] == SNDRV_AUTO_DMA) { | ||
116 | dma8[n] = snd_legacy_find_free_dma(possible_dmas); | ||
117 | if (dma8[n] < 0) { | ||
118 | snd_printk(KERN_ERR "%s: unable to find a free DMA " | ||
119 | "for ES1688\n", dev->bus_id); | ||
120 | return -EBUSY; | ||
121 | } | ||
122 | } | ||
89 | 123 | ||
90 | static struct platform_device *devices[SNDRV_CARDS]; | 124 | if (port[n] != SNDRV_AUTO_PORT) |
125 | return snd_es1688_create(card, port[n], mpu_port[n], irq[n], | ||
126 | mpu_irq[n], dma8[n], ES1688_HW_1688, rchip); | ||
91 | 127 | ||
128 | i = 0; | ||
129 | do { | ||
130 | port[n] = possible_ports[i]; | ||
131 | error = snd_es1688_create(card, port[n], mpu_port[n], irq[n], | ||
132 | mpu_irq[n], dma8[n], ES1688_HW_1688, rchip); | ||
133 | } while (error < 0 && ++i < ARRAY_SIZE(possible_ports)); | ||
92 | 134 | ||
93 | #define PFX "gusextreme: " | 135 | return error; |
136 | } | ||
94 | 137 | ||
95 | static int __devinit snd_gusextreme_detect(int dev, | 138 | static int __devinit snd_gusextreme_gus_card_create(struct snd_card *card, |
96 | struct snd_card *card, | 139 | struct device *dev, unsigned int n, struct snd_gus_card **rgus) |
97 | struct snd_gus_card * gus, | 140 | { |
98 | struct snd_es1688 *es1688) | 141 | static int possible_irqs[] = {11, 12, 15, 9, 5, 7, 3, -1}; |
142 | static int possible_dmas[] = {5, 6, 7, 3, 1, -1}; | ||
143 | |||
144 | if (gf1_irq[n] == SNDRV_AUTO_IRQ) { | ||
145 | gf1_irq[n] = snd_legacy_find_free_irq(possible_irqs); | ||
146 | if (gf1_irq[n] < 0) { | ||
147 | snd_printk(KERN_ERR "%s: unable to find a free IRQ " | ||
148 | "for GF1\n", dev->bus_id); | ||
149 | return -EBUSY; | ||
150 | } | ||
151 | } | ||
152 | if (dma1[n] == SNDRV_AUTO_DMA) { | ||
153 | dma1[n] = snd_legacy_find_free_dma(possible_dmas); | ||
154 | if (dma1[n] < 0) { | ||
155 | snd_printk(KERN_ERR "%s: unable to find a free DMA " | ||
156 | "for GF1\n", dev->bus_id); | ||
157 | return -EBUSY; | ||
158 | } | ||
159 | } | ||
160 | return snd_gus_create(card, gf1_port[n], gf1_irq[n], dma1[n], -1, | ||
161 | 0, channels[n], pcm_channels[n], 0, rgus); | ||
162 | } | ||
163 | |||
164 | static int __devinit snd_gusextreme_detect(struct snd_gus_card *gus, | ||
165 | struct snd_es1688 *es1688) | ||
99 | { | 166 | { |
100 | unsigned long flags; | 167 | unsigned long flags; |
101 | unsigned char d; | 168 | unsigned char d; |
@@ -117,12 +184,13 @@ static int __devinit snd_gusextreme_detect(int dev, | |||
117 | spin_lock_irqsave(&es1688->mixer_lock, flags); | 184 | spin_lock_irqsave(&es1688->mixer_lock, flags); |
118 | snd_es1688_mixer_write(es1688, 0x40, 0x0b); /* don't change!!! */ | 185 | snd_es1688_mixer_write(es1688, 0x40, 0x0b); /* don't change!!! */ |
119 | spin_unlock_irqrestore(&es1688->mixer_lock, flags); | 186 | spin_unlock_irqrestore(&es1688->mixer_lock, flags); |
187 | |||
120 | spin_lock_irqsave(&es1688->reg_lock, flags); | 188 | spin_lock_irqsave(&es1688->reg_lock, flags); |
121 | outb(gf1_port[dev] & 0x040 ? 2 : 0, ES1688P(es1688, INIT1)); | 189 | outb(gus->gf1.port & 0x040 ? 2 : 0, ES1688P(es1688, INIT1)); |
122 | outb(0, 0x201); | 190 | outb(0, 0x201); |
123 | outb(gf1_port[dev] & 0x020 ? 2 : 0, ES1688P(es1688, INIT1)); | 191 | outb(gus->gf1.port & 0x020 ? 2 : 0, ES1688P(es1688, INIT1)); |
124 | outb(0, 0x201); | 192 | outb(0, 0x201); |
125 | outb(gf1_port[dev] & 0x010 ? 3 : 1, ES1688P(es1688, INIT1)); | 193 | outb(gus->gf1.port & 0x010 ? 3 : 1, ES1688P(es1688, INIT1)); |
126 | spin_unlock_irqrestore(&es1688->reg_lock, flags); | 194 | spin_unlock_irqrestore(&es1688->reg_lock, flags); |
127 | 195 | ||
128 | udelay(100); | 196 | udelay(100); |
@@ -139,253 +207,171 @@ static int __devinit snd_gusextreme_detect(int dev, | |||
139 | snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d); | 207 | snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d); |
140 | return -EIO; | 208 | return -EIO; |
141 | } | 209 | } |
142 | return 0; | ||
143 | } | ||
144 | 210 | ||
145 | static void __devinit snd_gusextreme_init(int dev, struct snd_gus_card * gus) | 211 | return 0; |
146 | { | ||
147 | gus->joystick_dac = joystick_dac[dev]; | ||
148 | } | 212 | } |
149 | 213 | ||
150 | static int __devinit snd_gusextreme_mixer(struct snd_es1688 *chip) | 214 | static int __devinit snd_gusextreme_mixer(struct snd_es1688 *chip) |
151 | { | 215 | { |
152 | struct snd_card *card = chip->card; | 216 | struct snd_card *card = chip->card; |
153 | struct snd_ctl_elem_id id1, id2; | 217 | struct snd_ctl_elem_id id1, id2; |
154 | int err; | 218 | int error; |
155 | 219 | ||
156 | memset(&id1, 0, sizeof(id1)); | 220 | memset(&id1, 0, sizeof(id1)); |
157 | memset(&id2, 0, sizeof(id2)); | 221 | memset(&id2, 0, sizeof(id2)); |
158 | id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER; | 222 | id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER; |
223 | |||
159 | /* reassign AUX to SYNTHESIZER */ | 224 | /* reassign AUX to SYNTHESIZER */ |
160 | strcpy(id1.name, "Aux Playback Volume"); | 225 | strcpy(id1.name, "Aux Playback Volume"); |
161 | strcpy(id2.name, "Synth Playback Volume"); | 226 | strcpy(id2.name, "Synth Playback Volume"); |
162 | if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) | 227 | error = snd_ctl_rename_id(card, &id1, &id2); |
163 | return err; | 228 | if (error < 0) |
229 | return error; | ||
230 | |||
164 | /* reassign Master Playback Switch to Synth Playback Switch */ | 231 | /* reassign Master Playback Switch to Synth Playback Switch */ |
165 | strcpy(id1.name, "Master Playback Switch"); | 232 | strcpy(id1.name, "Master Playback Switch"); |
166 | strcpy(id2.name, "Synth Playback Switch"); | 233 | strcpy(id2.name, "Synth Playback Switch"); |
167 | if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) | 234 | error = snd_ctl_rename_id(card, &id1, &id2); |
168 | return err; | 235 | if (error < 0) |
236 | return error; | ||
237 | |||
169 | return 0; | 238 | return 0; |
170 | } | 239 | } |
171 | 240 | ||
172 | static int __devinit snd_gusextreme_probe(struct platform_device *pdev) | 241 | static int __devinit snd_gusextreme_probe(struct device *dev, unsigned int n) |
173 | { | 242 | { |
174 | int dev = pdev->id; | ||
175 | static int possible_ess_irqs[] = {5, 9, 10, 7, -1}; | ||
176 | static int possible_ess_dmas[] = {1, 3, 0, -1}; | ||
177 | static int possible_gf1_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; | ||
178 | static int possible_gf1_dmas[] = {5, 6, 7, 1, 3, -1}; | ||
179 | int xgf1_irq, xgf1_dma, xess_irq, xmpu_irq, xess_dma; | ||
180 | struct snd_card *card; | 243 | struct snd_card *card; |
181 | struct snd_gus_card *gus; | 244 | struct snd_gus_card *gus; |
182 | struct snd_es1688 *es1688; | 245 | struct snd_es1688 *es1688; |
183 | struct snd_opl3 *opl3; | 246 | struct snd_opl3 *opl3; |
184 | int err; | 247 | int error; |
185 | 248 | ||
186 | card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); | 249 | card = snd_card_new(index[n], id[n], THIS_MODULE, 0); |
187 | if (card == NULL) | 250 | if (!card) |
188 | return -ENOMEM; | 251 | return -EINVAL; |
189 | 252 | ||
190 | xgf1_irq = gf1_irq[dev]; | 253 | if (mpu_port[n] == SNDRV_AUTO_PORT) |
191 | if (xgf1_irq == SNDRV_AUTO_IRQ) { | 254 | mpu_port[n] = 0; |
192 | if ((xgf1_irq = snd_legacy_find_free_irq(possible_gf1_irqs)) < 0) { | ||
193 | snd_printk(KERN_ERR PFX "unable to find a free IRQ for GF1\n"); | ||
194 | err = -EBUSY; | ||
195 | goto out; | ||
196 | } | ||
197 | } | ||
198 | xess_irq = irq[dev]; | ||
199 | if (xess_irq == SNDRV_AUTO_IRQ) { | ||
200 | if ((xess_irq = snd_legacy_find_free_irq(possible_ess_irqs)) < 0) { | ||
201 | snd_printk(KERN_ERR PFX "unable to find a free IRQ for ES1688\n"); | ||
202 | err = -EBUSY; | ||
203 | goto out; | ||
204 | } | ||
205 | } | ||
206 | if (mpu_port[dev] == SNDRV_AUTO_PORT) | ||
207 | mpu_port[dev] = 0; | ||
208 | xmpu_irq = mpu_irq[dev]; | ||
209 | if (xmpu_irq > 15) | ||
210 | xmpu_irq = -1; | ||
211 | xgf1_dma = dma1[dev]; | ||
212 | if (xgf1_dma == SNDRV_AUTO_DMA) { | ||
213 | if ((xgf1_dma = snd_legacy_find_free_dma(possible_gf1_dmas)) < 0) { | ||
214 | snd_printk(KERN_ERR PFX "unable to find a free DMA for GF1\n"); | ||
215 | err = -EBUSY; | ||
216 | goto out; | ||
217 | } | ||
218 | } | ||
219 | xess_dma = dma8[dev]; | ||
220 | if (xess_dma == SNDRV_AUTO_DMA) { | ||
221 | if ((xess_dma = snd_legacy_find_free_dma(possible_ess_dmas)) < 0) { | ||
222 | snd_printk(KERN_ERR PFX "unable to find a free DMA for ES1688\n"); | ||
223 | err = -EBUSY; | ||
224 | goto out; | ||
225 | } | ||
226 | } | ||
227 | 255 | ||
228 | if (port[dev] != SNDRV_AUTO_PORT) { | 256 | if (mpu_irq[n] > 15) |
229 | err = snd_es1688_create(card, port[dev], mpu_port[dev], | 257 | mpu_irq[n] = -1; |
230 | xess_irq, xmpu_irq, xess_dma, | 258 | |
231 | ES1688_HW_1688, &es1688); | 259 | error = snd_gusextreme_es1688_create(card, dev, n, &es1688); |
232 | } else { | 260 | if (error < 0) |
233 | /* auto-probe legacy ports */ | ||
234 | static unsigned long possible_ports[] = {0x220, 0x240, 0x260}; | ||
235 | int i; | ||
236 | for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { | ||
237 | err = snd_es1688_create(card, | ||
238 | possible_ports[i], | ||
239 | mpu_port[dev], | ||
240 | xess_irq, xmpu_irq, xess_dma, | ||
241 | ES1688_HW_1688, &es1688); | ||
242 | if (err >= 0) { | ||
243 | port[dev] = possible_ports[i]; | ||
244 | break; | ||
245 | } | ||
246 | } | ||
247 | } | ||
248 | if (err < 0) | ||
249 | goto out; | 261 | goto out; |
250 | 262 | ||
251 | if (gf1_port[dev] < 0) | 263 | if (gf1_port[n] < 0) |
252 | gf1_port[dev] = port[dev] + 0x20; | 264 | gf1_port[n] = es1688->port + 0x20; |
253 | if ((err = snd_gus_create(card, | 265 | |
254 | gf1_port[dev], | 266 | error = snd_gusextreme_gus_card_create(card, dev, n, &gus); |
255 | xgf1_irq, | 267 | if (error < 0) |
256 | xgf1_dma, | ||
257 | -1, | ||
258 | 0, channels[dev], | ||
259 | pcm_channels[dev], 0, | ||
260 | &gus)) < 0) | ||
261 | goto out; | 268 | goto out; |
262 | 269 | ||
263 | if ((err = snd_gusextreme_detect(dev, card, gus, es1688)) < 0) | 270 | error = snd_gusextreme_detect(gus, es1688); |
271 | if (error < 0) | ||
264 | goto out; | 272 | goto out; |
265 | 273 | ||
266 | snd_gusextreme_init(dev, gus); | 274 | gus->joystick_dac = joystick_dac[n]; |
267 | if ((err = snd_gus_initialize(gus)) < 0) | 275 | |
276 | error = snd_gus_initialize(gus); | ||
277 | if (error < 0) | ||
268 | goto out; | 278 | goto out; |
269 | 279 | ||
280 | error = -ENODEV; | ||
270 | if (!gus->ess_flag) { | 281 | if (!gus->ess_flag) { |
271 | snd_printk(KERN_ERR PFX "GUS Extreme soundcard was not detected at 0x%lx\n", gus->gf1.port); | 282 | snd_printk(KERN_ERR "%s: GUS Extreme soundcard was not " |
272 | err = -ENODEV; | 283 | "detected at 0x%lx\n", dev->bus_id, gus->gf1.port); |
273 | goto out; | 284 | goto out; |
274 | } | 285 | } |
275 | if ((err = snd_es1688_pcm(es1688, 0, NULL)) < 0) | 286 | |
287 | error = snd_es1688_pcm(es1688, 0, NULL); | ||
288 | if (error < 0) | ||
276 | goto out; | 289 | goto out; |
277 | 290 | ||
278 | if ((err = snd_es1688_mixer(es1688)) < 0) | 291 | error = snd_es1688_mixer(es1688); |
292 | if (error < 0) | ||
279 | goto out; | 293 | goto out; |
280 | 294 | ||
281 | snd_component_add(card, "ES1688"); | 295 | snd_component_add(card, "ES1688"); |
282 | if (pcm_channels[dev] > 0) { | 296 | |
283 | if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) | 297 | if (pcm_channels[n] > 0) { |
298 | error = snd_gf1_pcm_new(gus, 1, 1, NULL); | ||
299 | if (error < 0) | ||
284 | goto out; | 300 | goto out; |
285 | } | 301 | } |
286 | if ((err = snd_gf1_new_mixer(gus)) < 0) | 302 | |
303 | error = snd_gf1_new_mixer(gus); | ||
304 | if (error < 0) | ||
287 | goto out; | 305 | goto out; |
288 | 306 | ||
289 | if ((err = snd_gusextreme_mixer(es1688)) < 0) | 307 | error = snd_gusextreme_mixer(es1688); |
308 | if (error < 0) | ||
290 | goto out; | 309 | goto out; |
291 | 310 | ||
292 | if (snd_opl3_create(card, es1688->port, es1688->port + 2, | 311 | if (snd_opl3_create(card, es1688->port, es1688->port + 2, |
293 | OPL3_HW_OPL3, 0, &opl3) < 0) { | 312 | OPL3_HW_OPL3, 0, &opl3) < 0) |
294 | printk(KERN_ERR PFX "gusextreme: opl3 not detected at 0x%lx\n", es1688->port); | 313 | printk(KERN_ERR "%s: opl3 not detected at 0x%lx\n", |
295 | } else { | 314 | dev->bus_id, es1688->port); |
296 | if ((err = snd_opl3_hwdep_new(opl3, 0, 2, NULL)) < 0) | 315 | else { |
316 | error = snd_opl3_hwdep_new(opl3, 0, 2, NULL); | ||
317 | if (error < 0) | ||
297 | goto out; | 318 | goto out; |
298 | } | 319 | } |
299 | 320 | ||
300 | if (es1688->mpu_port >= 0x300 && | 321 | if (es1688->mpu_port >= 0x300) { |
301 | (err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688, | 322 | error = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688, |
302 | es1688->mpu_port, 0, | 323 | es1688->mpu_port, 0, |
303 | xmpu_irq, | 324 | mpu_irq[n], IRQF_DISABLED, NULL); |
304 | IRQF_DISABLED, | 325 | if (error < 0) |
305 | NULL)) < 0) | 326 | goto out; |
306 | goto out; | 327 | } |
307 | 328 | ||
308 | sprintf(card->longname, "Gravis UltraSound Extreme at 0x%lx, irq %i&%i, dma %i&%i", | 329 | sprintf(card->longname, "Gravis UltraSound Extreme at 0x%lx, " |
309 | es1688->port, xgf1_irq, xess_irq, xgf1_dma, xess_dma); | 330 | "irq %i&%i, dma %i&%i", es1688->port, |
331 | gus->gf1.irq, es1688->irq, gus->gf1.dma1, es1688->dma8); | ||
310 | 332 | ||
311 | snd_card_set_dev(card, &pdev->dev); | 333 | snd_card_set_dev(card, dev); |
312 | 334 | ||
313 | if ((err = snd_card_register(card)) < 0) | 335 | error = snd_card_register(card); |
336 | if (error < 0) | ||
314 | goto out; | 337 | goto out; |
315 | 338 | ||
316 | platform_set_drvdata(pdev, card); | 339 | dev_set_drvdata(dev, card); |
317 | return 0; | 340 | return 0; |
318 | 341 | ||
319 | out: | 342 | out: snd_card_free(card); |
320 | snd_card_free(card); | 343 | return error; |
321 | return err; | ||
322 | } | 344 | } |
323 | 345 | ||
324 | static int __devexit snd_gusextreme_remove(struct platform_device *devptr) | 346 | static int __devexit snd_gusextreme_remove(struct device *dev, unsigned int n) |
325 | { | 347 | { |
326 | snd_card_free(platform_get_drvdata(devptr)); | 348 | snd_card_free(dev_get_drvdata(dev)); |
327 | platform_set_drvdata(devptr, NULL); | 349 | dev_set_drvdata(dev, NULL); |
328 | return 0; | 350 | return 0; |
329 | } | 351 | } |
330 | 352 | ||
331 | #define GUSEXTREME_DRIVER "snd_gusextreme" | 353 | static struct isa_driver snd_gusextreme_driver = { |
332 | 354 | .match = snd_gusextreme_match, | |
333 | static struct platform_driver snd_gusextreme_driver = { | ||
334 | .probe = snd_gusextreme_probe, | 355 | .probe = snd_gusextreme_probe, |
335 | .remove = __devexit_p(snd_gusextreme_remove), | 356 | .remove = snd_gusextreme_remove, |
336 | /* FIXME: suspend/resume */ | 357 | #if 0 /* FIXME */ |
358 | .suspend = snd_gusextreme_suspend, | ||
359 | .resume = snd_gusextreme_resume, | ||
360 | #endif | ||
337 | .driver = { | 361 | .driver = { |
338 | .name = GUSEXTREME_DRIVER | 362 | .name = DEV_NAME |
339 | }, | 363 | } |
340 | }; | 364 | }; |
341 | 365 | ||
342 | static void __init_or_module snd_gusextreme_unregister_all(void) | ||
343 | { | ||
344 | int i; | ||
345 | |||
346 | for (i = 0; i < ARRAY_SIZE(devices); ++i) | ||
347 | platform_device_unregister(devices[i]); | ||
348 | platform_driver_unregister(&snd_gusextreme_driver); | ||
349 | } | ||
350 | |||
351 | static int __init alsa_card_gusextreme_init(void) | 366 | static int __init alsa_card_gusextreme_init(void) |
352 | { | 367 | { |
353 | int i, cards, err; | 368 | return isa_register_driver(&snd_gusextreme_driver, SNDRV_CARDS); |
354 | |||
355 | err = platform_driver_register(&snd_gusextreme_driver); | ||
356 | if (err < 0) | ||
357 | return err; | ||
358 | |||
359 | cards = 0; | ||
360 | for (i = 0; i < SNDRV_CARDS; i++) { | ||
361 | struct platform_device *device; | ||
362 | if (! enable[i]) | ||
363 | continue; | ||
364 | device = platform_device_register_simple(GUSEXTREME_DRIVER, | ||
365 | i, NULL, 0); | ||
366 | if (IS_ERR(device)) | ||
367 | continue; | ||
368 | if (!platform_get_drvdata(device)) { | ||
369 | platform_device_unregister(device); | ||
370 | continue; | ||
371 | } | ||
372 | devices[i] = device; | ||
373 | cards++; | ||
374 | } | ||
375 | if (!cards) { | ||
376 | #ifdef MODULE | ||
377 | printk(KERN_ERR "GUS Extreme soundcard not found or device busy\n"); | ||
378 | #endif | ||
379 | snd_gusextreme_unregister_all(); | ||
380 | return -ENODEV; | ||
381 | } | ||
382 | return 0; | ||
383 | } | 369 | } |
384 | 370 | ||
385 | static void __exit alsa_card_gusextreme_exit(void) | 371 | static void __exit alsa_card_gusextreme_exit(void) |
386 | { | 372 | { |
387 | snd_gusextreme_unregister_all(); | 373 | isa_unregister_driver(&snd_gusextreme_driver); |
388 | } | 374 | } |
389 | 375 | ||
390 | module_init(alsa_card_gusextreme_init) | 376 | module_init(alsa_card_gusextreme_init); |
391 | module_exit(alsa_card_gusextreme_exit) | 377 | module_exit(alsa_card_gusextreme_exit); |