diff options
Diffstat (limited to 'sound/isa/gus')
-rw-r--r-- | sound/isa/gus/gusclassic.c | 292 | ||||
-rw-r--r-- | sound/isa/gus/gusextreme.c | 379 | ||||
-rw-r--r-- | sound/isa/gus/gusmax.c | 71 | ||||
-rw-r--r-- | sound/isa/gus/interwave.c | 101 |
4 files changed, 368 insertions, 475 deletions
diff --git a/sound/isa/gus/gusclassic.c b/sound/isa/gus/gusclassic.c index 0395e2e0dd03..8f23f433d491 100644 --- a/sound/isa/gus/gusclassic.c +++ b/sound/isa/gus/gusclassic.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> |
@@ -33,8 +33,11 @@ | |||
33 | #define SNDRV_LEGACY_FIND_FREE_DMA | 33 | #define SNDRV_LEGACY_FIND_FREE_DMA |
34 | #include <sound/initval.h> | 34 | #include <sound/initval.h> |
35 | 35 | ||
36 | #define CRD_NAME "Gravis UltraSound Classic" | ||
37 | #define DEV_NAME "gusclassic" | ||
38 | |||
39 | MODULE_DESCRIPTION(CRD_NAME); | ||
36 | MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); | 40 | MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); |
37 | MODULE_DESCRIPTION("Gravis UltraSound Classic"); | ||
38 | MODULE_LICENSE("GPL"); | 41 | MODULE_LICENSE("GPL"); |
39 | MODULE_SUPPORTED_DEVICE("{{Gravis,UltraSound Classic}}"); | 42 | MODULE_SUPPORTED_DEVICE("{{Gravis,UltraSound Classic}}"); |
40 | 43 | ||
@@ -51,32 +54,80 @@ static int channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 24}; | |||
51 | static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; | 54 | static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; |
52 | 55 | ||
53 | module_param_array(index, int, NULL, 0444); | 56 | module_param_array(index, int, NULL, 0444); |
54 | MODULE_PARM_DESC(index, "Index value for GUS Classic soundcard."); | 57 | MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard."); |
55 | module_param_array(id, charp, NULL, 0444); | 58 | module_param_array(id, charp, NULL, 0444); |
56 | MODULE_PARM_DESC(id, "ID string for GUS Classic soundcard."); | 59 | MODULE_PARM_DESC(id, "ID string for " CRD_NAME " soundcard."); |
57 | module_param_array(enable, bool, NULL, 0444); | 60 | module_param_array(enable, bool, NULL, 0444); |
58 | MODULE_PARM_DESC(enable, "Enable GUS Classic soundcard."); | 61 | MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard."); |
59 | module_param_array(port, long, NULL, 0444); | 62 | module_param_array(port, long, NULL, 0444); |
60 | MODULE_PARM_DESC(port, "Port # for GUS Classic driver."); | 63 | MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver."); |
61 | module_param_array(irq, int, NULL, 0444); | 64 | module_param_array(irq, int, NULL, 0444); |
62 | MODULE_PARM_DESC(irq, "IRQ # for GUS Classic driver."); | 65 | MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME " driver."); |
63 | module_param_array(dma1, int, NULL, 0444); | 66 | module_param_array(dma1, int, NULL, 0444); |
64 | MODULE_PARM_DESC(dma1, "DMA1 # for GUS Classic driver."); | 67 | MODULE_PARM_DESC(dma1, "DMA1 # for " CRD_NAME " driver."); |
65 | module_param_array(dma2, int, NULL, 0444); | 68 | module_param_array(dma2, int, NULL, 0444); |
66 | MODULE_PARM_DESC(dma2, "DMA2 # for GUS Classic driver."); | 69 | MODULE_PARM_DESC(dma2, "DMA2 # for " CRD_NAME " driver."); |
67 | module_param_array(joystick_dac, int, NULL, 0444); | 70 | module_param_array(joystick_dac, int, NULL, 0444); |
68 | MODULE_PARM_DESC(joystick_dac, "Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for GUS Classic driver."); | 71 | MODULE_PARM_DESC(joystick_dac, "Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for " CRD_NAME " driver."); |
69 | module_param_array(channels, int, NULL, 0444); | 72 | module_param_array(channels, int, NULL, 0444); |
70 | MODULE_PARM_DESC(channels, "GF1 channels for GUS Classic driver."); | 73 | MODULE_PARM_DESC(channels, "GF1 channels for " CRD_NAME " driver."); |
71 | module_param_array(pcm_channels, int, NULL, 0444); | 74 | module_param_array(pcm_channels, int, NULL, 0444); |
72 | MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Classic driver."); | 75 | MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for " CRD_NAME " driver."); |
76 | |||
77 | static int __devinit snd_gusclassic_match(struct device *dev, unsigned int n) | ||
78 | { | ||
79 | return enable[n]; | ||
80 | } | ||
81 | |||
82 | static int __devinit snd_gusclassic_create(struct snd_card *card, | ||
83 | struct device *dev, unsigned int n, struct snd_gus_card **rgus) | ||
84 | { | ||
85 | static long possible_ports[] = {0x220, 0x230, 0x240, 0x250, 0x260}; | ||
86 | static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, 4, -1}; | ||
87 | static int possible_dmas[] = {5, 6, 7, 1, 3, -1}; | ||
88 | |||
89 | int i, error; | ||
90 | |||
91 | if (irq[n] == SNDRV_AUTO_IRQ) { | ||
92 | irq[n] = snd_legacy_find_free_irq(possible_irqs); | ||
93 | if (irq[n] < 0) { | ||
94 | snd_printk(KERN_ERR "%s: unable to find a free IRQ\n", | ||
95 | dev->bus_id); | ||
96 | return -EBUSY; | ||
97 | } | ||
98 | } | ||
99 | if (dma1[n] == SNDRV_AUTO_DMA) { | ||
100 | dma1[n] = snd_legacy_find_free_dma(possible_dmas); | ||
101 | if (dma1[n] < 0) { | ||
102 | snd_printk(KERN_ERR "%s: unable to find a free DMA1\n", | ||
103 | dev->bus_id); | ||
104 | return -EBUSY; | ||
105 | } | ||
106 | } | ||
107 | if (dma2[n] == SNDRV_AUTO_DMA) { | ||
108 | dma2[n] = snd_legacy_find_free_dma(possible_dmas); | ||
109 | if (dma2[n] < 0) { | ||
110 | snd_printk(KERN_ERR "%s: unable to find a free DMA2\n", | ||
111 | dev->bus_id); | ||
112 | return -EBUSY; | ||
113 | } | ||
114 | } | ||
73 | 115 | ||
74 | static struct platform_device *devices[SNDRV_CARDS]; | 116 | if (port[n] != SNDRV_AUTO_PORT) |
117 | return snd_gus_create(card, port[n], irq[n], dma1[n], dma2[n], | ||
118 | 0, channels[n], pcm_channels[n], 0, rgus); | ||
75 | 119 | ||
120 | i = 0; | ||
121 | do { | ||
122 | port[n] = possible_ports[i]; | ||
123 | error = snd_gus_create(card, port[n], irq[n], dma1[n], dma2[n], | ||
124 | 0, channels[n], pcm_channels[n], 0, rgus); | ||
125 | } while (error < 0 && ++i < ARRAY_SIZE(possible_ports)); | ||
76 | 126 | ||
77 | #define PFX "gusclassic: " | 127 | return error; |
128 | } | ||
78 | 129 | ||
79 | static int __devinit snd_gusclassic_detect(struct snd_gus_card * gus) | 130 | static int __devinit snd_gusclassic_detect(struct snd_gus_card *gus) |
80 | { | 131 | { |
81 | unsigned char d; | 132 | unsigned char d; |
82 | 133 | ||
@@ -95,187 +146,104 @@ static int __devinit snd_gusclassic_detect(struct snd_gus_card * gus) | |||
95 | return 0; | 146 | return 0; |
96 | } | 147 | } |
97 | 148 | ||
98 | static void __devinit snd_gusclassic_init(int dev, struct snd_gus_card * gus) | 149 | static int __devinit snd_gusclassic_probe(struct device *dev, unsigned int n) |
99 | { | ||
100 | gus->equal_irq = 0; | ||
101 | gus->codec_flag = 0; | ||
102 | gus->max_flag = 0; | ||
103 | gus->joystick_dac = joystick_dac[dev]; | ||
104 | } | ||
105 | |||
106 | static int __devinit snd_gusclassic_probe(struct platform_device *pdev) | ||
107 | { | 150 | { |
108 | int dev = pdev->id; | ||
109 | static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, 4, -1}; | ||
110 | static int possible_dmas[] = {5, 6, 7, 1, 3, -1}; | ||
111 | int xirq, xdma1, xdma2; | ||
112 | struct snd_card *card; | 151 | struct snd_card *card; |
113 | struct snd_gus_card *gus = NULL; | 152 | struct snd_gus_card *gus; |
114 | int err; | 153 | int error; |
115 | |||
116 | card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); | ||
117 | if (card == NULL) | ||
118 | return -ENOMEM; | ||
119 | if (pcm_channels[dev] < 2) | ||
120 | pcm_channels[dev] = 2; | ||
121 | |||
122 | xirq = irq[dev]; | ||
123 | if (xirq == SNDRV_AUTO_IRQ) { | ||
124 | if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { | ||
125 | snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); | ||
126 | err = -EBUSY; | ||
127 | goto _err; | ||
128 | } | ||
129 | } | ||
130 | xdma1 = dma1[dev]; | ||
131 | if (xdma1 == SNDRV_AUTO_DMA) { | ||
132 | if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { | ||
133 | snd_printk(KERN_ERR PFX "unable to find a free DMA1\n"); | ||
134 | err = -EBUSY; | ||
135 | goto _err; | ||
136 | } | ||
137 | } | ||
138 | xdma2 = dma2[dev]; | ||
139 | if (xdma2 == SNDRV_AUTO_DMA) { | ||
140 | if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) { | ||
141 | snd_printk(KERN_ERR PFX "unable to find a free DMA2\n"); | ||
142 | err = -EBUSY; | ||
143 | goto _err; | ||
144 | } | ||
145 | } | ||
146 | 154 | ||
147 | if (port[dev] != SNDRV_AUTO_PORT) { | 155 | card = snd_card_new(index[n], id[n], THIS_MODULE, 0); |
148 | err = snd_gus_create(card, | 156 | if (!card) |
149 | port[dev], | 157 | return -EINVAL; |
150 | xirq, xdma1, xdma2, | ||
151 | 0, channels[dev], pcm_channels[dev], | ||
152 | 0, &gus); | ||
153 | } else { | ||
154 | /* auto-probe legacy ports */ | ||
155 | static unsigned long possible_ports[] = { | ||
156 | 0x220, 0x230, 0x240, 0x250, 0x260, | ||
157 | }; | ||
158 | int i; | ||
159 | for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { | ||
160 | err = snd_gus_create(card, | ||
161 | possible_ports[i], | ||
162 | xirq, xdma1, xdma2, | ||
163 | 0, channels[dev], pcm_channels[dev], | ||
164 | 0, &gus); | ||
165 | if (err >= 0) { | ||
166 | port[dev] = possible_ports[i]; | ||
167 | break; | ||
168 | } | ||
169 | } | ||
170 | } | ||
171 | if (err < 0) | ||
172 | goto _err; | ||
173 | 158 | ||
174 | if ((err = snd_gusclassic_detect(gus)) < 0) | 159 | if (pcm_channels[n] < 2) |
175 | goto _err; | 160 | pcm_channels[n] = 2; |
176 | 161 | ||
177 | snd_gusclassic_init(dev, gus); | 162 | error = snd_gusclassic_create(card, dev, n, &gus); |
178 | if ((err = snd_gus_initialize(gus)) < 0) | 163 | if (error < 0) |
179 | goto _err; | 164 | goto out; |
180 | 165 | ||
166 | error = snd_gusclassic_detect(gus); | ||
167 | if (error < 0) | ||
168 | goto out; | ||
169 | |||
170 | gus->joystick_dac = joystick_dac[n]; | ||
171 | |||
172 | error = snd_gus_initialize(gus); | ||
173 | if (error < 0) | ||
174 | goto out; | ||
175 | |||
176 | error = -ENODEV; | ||
181 | if (gus->max_flag || gus->ess_flag) { | 177 | if (gus->max_flag || gus->ess_flag) { |
182 | snd_printk(KERN_ERR PFX "GUS Classic or ACE soundcard was not detected at 0x%lx\n", gus->gf1.port); | 178 | snd_printk(KERN_ERR "%s: GUS Classic or ACE soundcard was " |
183 | err = -ENODEV; | 179 | "not detected at 0x%lx\n", dev->bus_id, gus->gf1.port); |
184 | goto _err; | 180 | goto out; |
185 | } | 181 | } |
186 | 182 | ||
187 | if ((err = snd_gf1_new_mixer(gus)) < 0) | 183 | error = snd_gf1_new_mixer(gus); |
188 | goto _err; | 184 | if (error < 0) |
185 | goto out; | ||
189 | 186 | ||
190 | if ((err = snd_gf1_pcm_new(gus, 0, 0, NULL)) < 0) | 187 | error = snd_gf1_pcm_new(gus, 0, 0, NULL); |
191 | goto _err; | 188 | if (error < 0) |
189 | goto out; | ||
192 | 190 | ||
193 | if (!gus->ace_flag) { | 191 | if (!gus->ace_flag) { |
194 | if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) | 192 | error = snd_gf1_rawmidi_new(gus, 0, NULL); |
195 | goto _err; | 193 | if (error < 0) |
194 | goto out; | ||
196 | } | 195 | } |
197 | sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %d, dma %d", gus->gf1.port, xirq, xdma1); | ||
198 | if (xdma2 >= 0) | ||
199 | sprintf(card->longname + strlen(card->longname), "&%d", xdma2); | ||
200 | 196 | ||
201 | snd_card_set_dev(card, &pdev->dev); | 197 | sprintf(card->longname + strlen(card->longname), |
198 | " at 0x%lx, irq %d, dma %d", | ||
199 | gus->gf1.port, gus->gf1.irq, gus->gf1.dma1); | ||
202 | 200 | ||
203 | if ((err = snd_card_register(card)) < 0) | 201 | if (gus->gf1.dma2 >= 0) |
204 | goto _err; | 202 | sprintf(card->longname + strlen(card->longname), |
203 | "&%d", gus->gf1.dma2); | ||
205 | 204 | ||
206 | platform_set_drvdata(pdev, card); | 205 | snd_card_set_dev(card, dev); |
206 | |||
207 | error = snd_card_register(card); | ||
208 | if (error < 0) | ||
209 | goto out; | ||
210 | |||
211 | dev_set_drvdata(dev, card); | ||
207 | return 0; | 212 | return 0; |
208 | 213 | ||
209 | _err: | 214 | out: snd_card_free(card); |
210 | snd_card_free(card); | 215 | return error; |
211 | return err; | ||
212 | } | 216 | } |
213 | 217 | ||
214 | static int __devexit snd_gusclassic_remove(struct platform_device *devptr) | 218 | static int __devexit snd_gusclassic_remove(struct device *dev, unsigned int n) |
215 | { | 219 | { |
216 | snd_card_free(platform_get_drvdata(devptr)); | 220 | snd_card_free(dev_get_drvdata(dev)); |
217 | platform_set_drvdata(devptr, NULL); | 221 | dev_set_drvdata(dev, NULL); |
218 | return 0; | 222 | return 0; |
219 | } | 223 | } |
220 | 224 | ||
221 | #define GUSCLASSIC_DRIVER "snd_gusclassic" | 225 | static struct isa_driver snd_gusclassic_driver = { |
222 | 226 | .match = snd_gusclassic_match, | |
223 | static struct platform_driver snd_gusclassic_driver = { | ||
224 | .probe = snd_gusclassic_probe, | 227 | .probe = snd_gusclassic_probe, |
225 | .remove = __devexit_p(snd_gusclassic_remove), | 228 | .remove = __devexit_p(snd_gusclassic_remove), |
226 | /* FIXME: suspend/resume */ | 229 | #if 0 /* FIXME */ |
230 | .suspend = snd_gusclassic_suspend, | ||
231 | .remove = snd_gusclassic_remove, | ||
232 | #endif | ||
227 | .driver = { | 233 | .driver = { |
228 | .name = GUSCLASSIC_DRIVER | 234 | .name = DEV_NAME |
229 | }, | 235 | } |
230 | }; | 236 | }; |
231 | 237 | ||
232 | static void __init_or_module snd_gusclassic_unregister_all(void) | ||
233 | { | ||
234 | int i; | ||
235 | |||
236 | for (i = 0; i < ARRAY_SIZE(devices); ++i) | ||
237 | platform_device_unregister(devices[i]); | ||
238 | platform_driver_unregister(&snd_gusclassic_driver); | ||
239 | } | ||
240 | |||
241 | static int __init alsa_card_gusclassic_init(void) | 238 | static int __init alsa_card_gusclassic_init(void) |
242 | { | 239 | { |
243 | int i, cards, err; | 240 | return isa_register_driver(&snd_gusclassic_driver, SNDRV_CARDS); |
244 | |||
245 | err = platform_driver_register(&snd_gusclassic_driver); | ||
246 | if (err < 0) | ||
247 | return err; | ||
248 | |||
249 | cards = 0; | ||
250 | for (i = 0; i < SNDRV_CARDS; i++) { | ||
251 | struct platform_device *device; | ||
252 | if (! enable[i]) | ||
253 | continue; | ||
254 | device = platform_device_register_simple(GUSCLASSIC_DRIVER, | ||
255 | i, NULL, 0); | ||
256 | if (IS_ERR(device)) | ||
257 | continue; | ||
258 | if (!platform_get_drvdata(device)) { | ||
259 | platform_device_unregister(device); | ||
260 | continue; | ||
261 | } | ||
262 | devices[i] = device; | ||
263 | cards++; | ||
264 | } | ||
265 | if (!cards) { | ||
266 | #ifdef MODULE | ||
267 | printk(KERN_ERR "GUS Classic soundcard not found or device busy\n"); | ||
268 | #endif | ||
269 | snd_gusclassic_unregister_all(); | ||
270 | return -ENODEV; | ||
271 | } | ||
272 | return 0; | ||
273 | } | 241 | } |
274 | 242 | ||
275 | static void __exit alsa_card_gusclassic_exit(void) | 243 | static void __exit alsa_card_gusclassic_exit(void) |
276 | { | 244 | { |
277 | snd_gusclassic_unregister_all(); | 245 | isa_unregister_driver(&snd_gusclassic_driver); |
278 | } | 246 | } |
279 | 247 | ||
280 | module_init(alsa_card_gusclassic_init) | 248 | module_init(alsa_card_gusclassic_init); |
281 | module_exit(alsa_card_gusclassic_exit) | 249 | module_exit(alsa_card_gusclassic_exit); |
diff --git a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c index 4f55fc3e66c1..0aeaa6cf6cf0 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,172 @@ 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 | gus->codec_flag = 1; |
287 | |||
288 | error = snd_es1688_pcm(es1688, 0, NULL); | ||
289 | if (error < 0) | ||
276 | goto out; | 290 | goto out; |
277 | 291 | ||
278 | if ((err = snd_es1688_mixer(es1688)) < 0) | 292 | error = snd_es1688_mixer(es1688); |
293 | if (error < 0) | ||
279 | goto out; | 294 | goto out; |
280 | 295 | ||
281 | snd_component_add(card, "ES1688"); | 296 | snd_component_add(card, "ES1688"); |
282 | if (pcm_channels[dev] > 0) { | 297 | |
283 | if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) | 298 | if (pcm_channels[n] > 0) { |
299 | error = snd_gf1_pcm_new(gus, 1, 1, NULL); | ||
300 | if (error < 0) | ||
284 | goto out; | 301 | goto out; |
285 | } | 302 | } |
286 | if ((err = snd_gf1_new_mixer(gus)) < 0) | 303 | |
304 | error = snd_gf1_new_mixer(gus); | ||
305 | if (error < 0) | ||
287 | goto out; | 306 | goto out; |
288 | 307 | ||
289 | if ((err = snd_gusextreme_mixer(es1688)) < 0) | 308 | error = snd_gusextreme_mixer(es1688); |
309 | if (error < 0) | ||
290 | goto out; | 310 | goto out; |
291 | 311 | ||
292 | if (snd_opl3_create(card, es1688->port, es1688->port + 2, | 312 | if (snd_opl3_create(card, es1688->port, es1688->port + 2, |
293 | OPL3_HW_OPL3, 0, &opl3) < 0) { | 313 | OPL3_HW_OPL3, 0, &opl3) < 0) |
294 | printk(KERN_ERR PFX "gusextreme: opl3 not detected at 0x%lx\n", es1688->port); | 314 | printk(KERN_ERR "%s: opl3 not detected at 0x%lx\n", |
295 | } else { | 315 | dev->bus_id, es1688->port); |
296 | if ((err = snd_opl3_hwdep_new(opl3, 0, 2, NULL)) < 0) | 316 | else { |
317 | error = snd_opl3_hwdep_new(opl3, 0, 2, NULL); | ||
318 | if (error < 0) | ||
297 | goto out; | 319 | goto out; |
298 | } | 320 | } |
299 | 321 | ||
300 | if (es1688->mpu_port >= 0x300 && | 322 | if (es1688->mpu_port >= 0x300) { |
301 | (err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688, | 323 | error = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688, |
302 | es1688->mpu_port, 0, | 324 | es1688->mpu_port, 0, |
303 | xmpu_irq, | 325 | mpu_irq[n], IRQF_DISABLED, NULL); |
304 | IRQF_DISABLED, | 326 | if (error < 0) |
305 | NULL)) < 0) | 327 | goto out; |
306 | goto out; | 328 | } |
307 | 329 | ||
308 | sprintf(card->longname, "Gravis UltraSound Extreme at 0x%lx, irq %i&%i, dma %i&%i", | 330 | sprintf(card->longname, "Gravis UltraSound Extreme at 0x%lx, " |
309 | es1688->port, xgf1_irq, xess_irq, xgf1_dma, xess_dma); | 331 | "irq %i&%i, dma %i&%i", es1688->port, |
332 | gus->gf1.irq, es1688->irq, gus->gf1.dma1, es1688->dma8); | ||
310 | 333 | ||
311 | snd_card_set_dev(card, &pdev->dev); | 334 | snd_card_set_dev(card, dev); |
312 | 335 | ||
313 | if ((err = snd_card_register(card)) < 0) | 336 | error = snd_card_register(card); |
337 | if (error < 0) | ||
314 | goto out; | 338 | goto out; |
315 | 339 | ||
316 | platform_set_drvdata(pdev, card); | 340 | dev_set_drvdata(dev, card); |
317 | return 0; | 341 | return 0; |
318 | 342 | ||
319 | out: | 343 | out: snd_card_free(card); |
320 | snd_card_free(card); | 344 | return error; |
321 | return err; | ||
322 | } | 345 | } |
323 | 346 | ||
324 | static int __devexit snd_gusextreme_remove(struct platform_device *devptr) | 347 | static int __devexit snd_gusextreme_remove(struct device *dev, unsigned int n) |
325 | { | 348 | { |
326 | snd_card_free(platform_get_drvdata(devptr)); | 349 | snd_card_free(dev_get_drvdata(dev)); |
327 | platform_set_drvdata(devptr, NULL); | 350 | dev_set_drvdata(dev, NULL); |
328 | return 0; | 351 | return 0; |
329 | } | 352 | } |
330 | 353 | ||
331 | #define GUSEXTREME_DRIVER "snd_gusextreme" | 354 | static struct isa_driver snd_gusextreme_driver = { |
332 | 355 | .match = snd_gusextreme_match, | |
333 | static struct platform_driver snd_gusextreme_driver = { | ||
334 | .probe = snd_gusextreme_probe, | 356 | .probe = snd_gusextreme_probe, |
335 | .remove = __devexit_p(snd_gusextreme_remove), | 357 | .remove = snd_gusextreme_remove, |
336 | /* FIXME: suspend/resume */ | 358 | #if 0 /* FIXME */ |
359 | .suspend = snd_gusextreme_suspend, | ||
360 | .resume = snd_gusextreme_resume, | ||
361 | #endif | ||
337 | .driver = { | 362 | .driver = { |
338 | .name = GUSEXTREME_DRIVER | 363 | .name = DEV_NAME |
339 | }, | 364 | } |
340 | }; | 365 | }; |
341 | 366 | ||
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) | 367 | static int __init alsa_card_gusextreme_init(void) |
352 | { | 368 | { |
353 | int i, cards, err; | 369 | 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 | } | 370 | } |
384 | 371 | ||
385 | static void __exit alsa_card_gusextreme_exit(void) | 372 | static void __exit alsa_card_gusextreme_exit(void) |
386 | { | 373 | { |
387 | snd_gusextreme_unregister_all(); | 374 | isa_unregister_driver(&snd_gusextreme_driver); |
388 | } | 375 | } |
389 | 376 | ||
390 | module_init(alsa_card_gusextreme_init) | 377 | module_init(alsa_card_gusextreme_init); |
391 | module_exit(alsa_card_gusextreme_exit) | 378 | module_exit(alsa_card_gusextreme_exit); |
diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c index d1ad90ca035d..708783d4351f 100644 --- a/sound/isa/gus/gusmax.c +++ b/sound/isa/gus/gusmax.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> |
@@ -72,8 +72,6 @@ MODULE_PARM_DESC(channels, "Used GF1 channels for GUS MAX driver."); | |||
72 | module_param_array(pcm_channels, int, NULL, 0444); | 72 | module_param_array(pcm_channels, int, NULL, 0444); |
73 | MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS MAX driver."); | 73 | MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS MAX driver."); |
74 | 74 | ||
75 | static struct platform_device *devices[SNDRV_CARDS]; | ||
76 | |||
77 | struct snd_gusmax { | 75 | struct snd_gusmax { |
78 | int irq; | 76 | int irq; |
79 | struct snd_card *card; | 77 | struct snd_card *card; |
@@ -205,9 +203,13 @@ static void snd_gusmax_free(struct snd_card *card) | |||
205 | free_irq(maxcard->irq, (void *)maxcard); | 203 | free_irq(maxcard->irq, (void *)maxcard); |
206 | } | 204 | } |
207 | 205 | ||
208 | static int __devinit snd_gusmax_probe(struct platform_device *pdev) | 206 | static int __devinit snd_gusmax_match(struct device *pdev, unsigned int dev) |
207 | { | ||
208 | return enable[dev]; | ||
209 | } | ||
210 | |||
211 | static int __devinit snd_gusmax_probe(struct device *pdev, unsigned int dev) | ||
209 | { | 212 | { |
210 | int dev = pdev->id; | ||
211 | static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; | 213 | static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; |
212 | static int possible_dmas[] = {5, 6, 7, 1, 3, -1}; | 214 | static int possible_dmas[] = {5, 6, 7, 1, 3, -1}; |
213 | int xirq, xdma1, xdma2, err; | 215 | int xirq, xdma1, xdma2, err; |
@@ -333,7 +335,7 @@ static int __devinit snd_gusmax_probe(struct platform_device *pdev) | |||
333 | if (xdma2 >= 0) | 335 | if (xdma2 >= 0) |
334 | sprintf(card->longname + strlen(card->longname), "&%i", xdma2); | 336 | sprintf(card->longname + strlen(card->longname), "&%i", xdma2); |
335 | 337 | ||
336 | snd_card_set_dev(card, &pdev->dev); | 338 | snd_card_set_dev(card, pdev); |
337 | 339 | ||
338 | if ((err = snd_card_register(card)) < 0) | 340 | if ((err = snd_card_register(card)) < 0) |
339 | goto _err; | 341 | goto _err; |
@@ -341,7 +343,7 @@ static int __devinit snd_gusmax_probe(struct platform_device *pdev) | |||
341 | maxcard->gus = gus; | 343 | maxcard->gus = gus; |
342 | maxcard->cs4231 = cs4231; | 344 | maxcard->cs4231 = cs4231; |
343 | 345 | ||
344 | platform_set_drvdata(pdev, card); | 346 | dev_set_drvdata(pdev, card); |
345 | return 0; | 347 | return 0; |
346 | 348 | ||
347 | _err: | 349 | _err: |
@@ -349,70 +351,33 @@ static int __devinit snd_gusmax_probe(struct platform_device *pdev) | |||
349 | return err; | 351 | return err; |
350 | } | 352 | } |
351 | 353 | ||
352 | static int __devexit snd_gusmax_remove(struct platform_device *devptr) | 354 | static int __devexit snd_gusmax_remove(struct device *devptr, unsigned int dev) |
353 | { | 355 | { |
354 | snd_card_free(platform_get_drvdata(devptr)); | 356 | snd_card_free(dev_get_drvdata(devptr)); |
355 | platform_set_drvdata(devptr, NULL); | 357 | dev_set_drvdata(devptr, NULL); |
356 | return 0; | 358 | return 0; |
357 | } | 359 | } |
358 | 360 | ||
359 | #define GUSMAX_DRIVER "snd_gusmax" | 361 | #define DEV_NAME "gusmax" |
360 | 362 | ||
361 | static struct platform_driver snd_gusmax_driver = { | 363 | static struct isa_driver snd_gusmax_driver = { |
364 | .match = snd_gusmax_match, | ||
362 | .probe = snd_gusmax_probe, | 365 | .probe = snd_gusmax_probe, |
363 | .remove = __devexit_p(snd_gusmax_remove), | 366 | .remove = __devexit_p(snd_gusmax_remove), |
364 | /* FIXME: suspend/resume */ | 367 | /* FIXME: suspend/resume */ |
365 | .driver = { | 368 | .driver = { |
366 | .name = GUSMAX_DRIVER | 369 | .name = DEV_NAME |
367 | }, | 370 | }, |
368 | }; | 371 | }; |
369 | 372 | ||
370 | static void __init_or_module snd_gusmax_unregister_all(void) | ||
371 | { | ||
372 | int i; | ||
373 | |||
374 | for (i = 0; i < ARRAY_SIZE(devices); ++i) | ||
375 | platform_device_unregister(devices[i]); | ||
376 | platform_driver_unregister(&snd_gusmax_driver); | ||
377 | } | ||
378 | |||
379 | static int __init alsa_card_gusmax_init(void) | 373 | static int __init alsa_card_gusmax_init(void) |
380 | { | 374 | { |
381 | int i, cards, err; | 375 | return isa_register_driver(&snd_gusmax_driver, SNDRV_CARDS); |
382 | |||
383 | err = platform_driver_register(&snd_gusmax_driver); | ||
384 | if (err < 0) | ||
385 | return err; | ||
386 | |||
387 | cards = 0; | ||
388 | for (i = 0; i < SNDRV_CARDS; i++) { | ||
389 | struct platform_device *device; | ||
390 | if (! enable[i]) | ||
391 | continue; | ||
392 | device = platform_device_register_simple(GUSMAX_DRIVER, | ||
393 | i, NULL, 0); | ||
394 | if (IS_ERR(device)) | ||
395 | continue; | ||
396 | if (!platform_get_drvdata(device)) { | ||
397 | platform_device_unregister(device); | ||
398 | continue; | ||
399 | } | ||
400 | devices[i] = device; | ||
401 | cards++; | ||
402 | } | ||
403 | if (!cards) { | ||
404 | #ifdef MODULE | ||
405 | printk(KERN_ERR "GUS MAX soundcard not found or device busy\n"); | ||
406 | #endif | ||
407 | snd_gusmax_unregister_all(); | ||
408 | return -ENODEV; | ||
409 | } | ||
410 | return 0; | ||
411 | } | 376 | } |
412 | 377 | ||
413 | static void __exit alsa_card_gusmax_exit(void) | 378 | static void __exit alsa_card_gusmax_exit(void) |
414 | { | 379 | { |
415 | snd_gusmax_unregister_all(); | 380 | isa_unregister_driver(&snd_gusmax_driver); |
416 | } | 381 | } |
417 | 382 | ||
418 | module_init(alsa_card_gusmax_init) | 383 | module_init(alsa_card_gusmax_init) |
diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c index 4ec2d79431fc..3e4657255536 100644 --- a/sound/isa/gus/interwave.c +++ b/sound/isa/gus/interwave.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <sound/driver.h> | 25 | #include <sound/driver.h> |
26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
27 | #include <linux/err.h> | 27 | #include <linux/err.h> |
28 | #include <linux/platform_device.h> | 28 | #include <linux/isa.h> |
29 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
30 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
31 | #include <linux/pnp.h> | 31 | #include <linux/pnp.h> |
@@ -115,9 +115,6 @@ MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for InterWave driver."); | |||
115 | module_param_array(effect, int, NULL, 0444); | 115 | module_param_array(effect, int, NULL, 0444); |
116 | MODULE_PARM_DESC(effect, "Effects enable for InterWave driver."); | 116 | MODULE_PARM_DESC(effect, "Effects enable for InterWave driver."); |
117 | 117 | ||
118 | static struct platform_device *platform_devices[SNDRV_CARDS]; | ||
119 | static int pnp_registered; | ||
120 | |||
121 | struct snd_interwave { | 118 | struct snd_interwave { |
122 | int irq; | 119 | int irq; |
123 | struct snd_card *card; | 120 | struct snd_card *card; |
@@ -138,6 +135,7 @@ struct snd_interwave { | |||
138 | 135 | ||
139 | 136 | ||
140 | #ifdef CONFIG_PNP | 137 | #ifdef CONFIG_PNP |
138 | static int pnp_registered; | ||
141 | 139 | ||
142 | static struct pnp_card_device_id snd_interwave_pnpids[] = { | 140 | static struct pnp_card_device_id snd_interwave_pnpids[] = { |
143 | #ifndef SNDRV_STB | 141 | #ifndef SNDRV_STB |
@@ -793,7 +791,7 @@ static int __devinit snd_interwave_probe(struct snd_card *card, int dev) | |||
793 | return 0; | 791 | return 0; |
794 | } | 792 | } |
795 | 793 | ||
796 | static int __devinit snd_interwave_nonpnp_probe1(int dev, struct platform_device *devptr) | 794 | static int __devinit snd_interwave_isa_probe1(int dev, struct device *devptr) |
797 | { | 795 | { |
798 | struct snd_card *card; | 796 | struct snd_card *card; |
799 | int err; | 797 | int err; |
@@ -802,18 +800,30 @@ static int __devinit snd_interwave_nonpnp_probe1(int dev, struct platform_device | |||
802 | if (! card) | 800 | if (! card) |
803 | return -ENOMEM; | 801 | return -ENOMEM; |
804 | 802 | ||
805 | snd_card_set_dev(card, &devptr->dev); | 803 | snd_card_set_dev(card, devptr); |
806 | if ((err = snd_interwave_probe(card, dev)) < 0) { | 804 | if ((err = snd_interwave_probe(card, dev)) < 0) { |
807 | snd_card_free(card); | 805 | snd_card_free(card); |
808 | return err; | 806 | return err; |
809 | } | 807 | } |
810 | platform_set_drvdata(devptr, card); | 808 | dev_set_drvdata(devptr, card); |
811 | return 0; | 809 | return 0; |
812 | } | 810 | } |
813 | 811 | ||
814 | static int __devinit snd_interwave_nonpnp_probe(struct platform_device *pdev) | 812 | static int __devinit snd_interwave_isa_match(struct device *pdev, |
813 | unsigned int dev) | ||
814 | { | ||
815 | if (!enable[dev]) | ||
816 | return 0; | ||
817 | #ifdef CONFIG_PNP | ||
818 | if (isapnp[dev]) | ||
819 | return 0; | ||
820 | #endif | ||
821 | return 1; | ||
822 | } | ||
823 | |||
824 | static int __devinit snd_interwave_isa_probe(struct device *pdev, | ||
825 | unsigned int dev) | ||
815 | { | 826 | { |
816 | int dev = pdev->id; | ||
817 | int err; | 827 | int err; |
818 | static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; | 828 | static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; |
819 | static int possible_dmas[] = {0, 1, 3, 5, 6, 7, -1}; | 829 | static int possible_dmas[] = {0, 1, 3, 5, 6, 7, -1}; |
@@ -838,13 +848,13 @@ static int __devinit snd_interwave_nonpnp_probe(struct platform_device *pdev) | |||
838 | } | 848 | } |
839 | 849 | ||
840 | if (port[dev] != SNDRV_AUTO_PORT) | 850 | if (port[dev] != SNDRV_AUTO_PORT) |
841 | return snd_interwave_nonpnp_probe1(dev, pdev); | 851 | return snd_interwave_isa_probe1(dev, pdev); |
842 | else { | 852 | else { |
843 | static long possible_ports[] = {0x210, 0x220, 0x230, 0x240, 0x250, 0x260}; | 853 | static long possible_ports[] = {0x210, 0x220, 0x230, 0x240, 0x250, 0x260}; |
844 | int i; | 854 | int i; |
845 | for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { | 855 | for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { |
846 | port[dev] = possible_ports[i]; | 856 | port[dev] = possible_ports[i]; |
847 | err = snd_interwave_nonpnp_probe1(dev, pdev); | 857 | err = snd_interwave_isa_probe1(dev, pdev); |
848 | if (! err) | 858 | if (! err) |
849 | return 0; | 859 | return 0; |
850 | } | 860 | } |
@@ -852,16 +862,17 @@ static int __devinit snd_interwave_nonpnp_probe(struct platform_device *pdev) | |||
852 | } | 862 | } |
853 | } | 863 | } |
854 | 864 | ||
855 | static int __devexit snd_interwave_nonpnp_remove(struct platform_device *devptr) | 865 | static int __devexit snd_interwave_isa_remove(struct device *devptr, unsigned int dev) |
856 | { | 866 | { |
857 | snd_card_free(platform_get_drvdata(devptr)); | 867 | snd_card_free(dev_get_drvdata(devptr)); |
858 | platform_set_drvdata(devptr, NULL); | 868 | dev_set_drvdata(devptr, NULL); |
859 | return 0; | 869 | return 0; |
860 | } | 870 | } |
861 | 871 | ||
862 | static struct platform_driver snd_interwave_driver = { | 872 | static struct isa_driver snd_interwave_driver = { |
863 | .probe = snd_interwave_nonpnp_probe, | 873 | .match = snd_interwave_isa_match, |
864 | .remove = __devexit_p(snd_interwave_nonpnp_remove), | 874 | .probe = snd_interwave_isa_probe, |
875 | .remove = __devexit_p(snd_interwave_isa_remove), | ||
865 | /* FIXME: suspend,resume */ | 876 | /* FIXME: suspend,resume */ |
866 | .driver = { | 877 | .driver = { |
867 | .name = INTERWAVE_DRIVER | 878 | .name = INTERWAVE_DRIVER |
@@ -869,8 +880,6 @@ static struct platform_driver snd_interwave_driver = { | |||
869 | }; | 880 | }; |
870 | 881 | ||
871 | #ifdef CONFIG_PNP | 882 | #ifdef CONFIG_PNP |
872 | static unsigned int __devinitdata interwave_pnp_devices; | ||
873 | |||
874 | static int __devinit snd_interwave_pnp_detect(struct pnp_card_link *pcard, | 883 | static int __devinit snd_interwave_pnp_detect(struct pnp_card_link *pcard, |
875 | const struct pnp_card_device_id *pid) | 884 | const struct pnp_card_device_id *pid) |
876 | { | 885 | { |
@@ -900,7 +909,6 @@ static int __devinit snd_interwave_pnp_detect(struct pnp_card_link *pcard, | |||
900 | } | 909 | } |
901 | pnp_set_card_drvdata(pcard, card); | 910 | pnp_set_card_drvdata(pcard, card); |
902 | dev++; | 911 | dev++; |
903 | interwave_pnp_devices++; | ||
904 | return 0; | 912 | return 0; |
905 | } | 913 | } |
906 | 914 | ||
@@ -921,64 +929,29 @@ static struct pnp_card_driver interwave_pnpc_driver = { | |||
921 | 929 | ||
922 | #endif /* CONFIG_PNP */ | 930 | #endif /* CONFIG_PNP */ |
923 | 931 | ||
924 | static void __init_or_module snd_interwave_unregister_all(void) | ||
925 | { | ||
926 | int i; | ||
927 | |||
928 | if (pnp_registered) | ||
929 | pnp_unregister_card_driver(&interwave_pnpc_driver); | ||
930 | for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) | ||
931 | platform_device_unregister(platform_devices[i]); | ||
932 | platform_driver_unregister(&snd_interwave_driver); | ||
933 | } | ||
934 | |||
935 | static int __init alsa_card_interwave_init(void) | 932 | static int __init alsa_card_interwave_init(void) |
936 | { | 933 | { |
937 | int i, err, cards = 0; | 934 | int err; |
938 | 935 | ||
939 | if ((err = platform_driver_register(&snd_interwave_driver)) < 0) | 936 | err = isa_register_driver(&snd_interwave_driver, SNDRV_CARDS); |
937 | if (err < 0) | ||
940 | return err; | 938 | return err; |
941 | |||
942 | for (i = 0; i < SNDRV_CARDS; i++) { | ||
943 | struct platform_device *device; | ||
944 | if (! enable[i]) | ||
945 | continue; | ||
946 | #ifdef CONFIG_PNP | 939 | #ifdef CONFIG_PNP |
947 | if (isapnp[i]) | ||
948 | continue; | ||
949 | #endif | ||
950 | device = platform_device_register_simple(INTERWAVE_DRIVER, | ||
951 | i, NULL, 0); | ||
952 | if (IS_ERR(device)) | ||
953 | continue; | ||
954 | if (!platform_get_drvdata(device)) { | ||
955 | platform_device_unregister(device); | ||
956 | continue; | ||
957 | } | ||
958 | platform_devices[i] = device; | ||
959 | cards++; | ||
960 | } | ||
961 | |||
962 | /* ISA PnP cards */ | 940 | /* ISA PnP cards */ |
963 | err = pnp_register_card_driver(&interwave_pnpc_driver); | 941 | err = pnp_register_card_driver(&interwave_pnpc_driver); |
964 | if (!err) { | 942 | if (!err) |
965 | pnp_registered = 1; | 943 | pnp_registered = 1; |
966 | cards += interwave_pnp_devices;; | ||
967 | } | ||
968 | |||
969 | if (!cards) { | ||
970 | #ifdef MODULE | ||
971 | printk(KERN_ERR "InterWave soundcard not found or device busy\n"); | ||
972 | #endif | 944 | #endif |
973 | snd_interwave_unregister_all(); | ||
974 | return -ENODEV; | ||
975 | } | ||
976 | return 0; | 945 | return 0; |
977 | } | 946 | } |
978 | 947 | ||
979 | static void __exit alsa_card_interwave_exit(void) | 948 | static void __exit alsa_card_interwave_exit(void) |
980 | { | 949 | { |
981 | snd_interwave_unregister_all(); | 950 | #ifdef CONFIG_PNP |
951 | if (pnp_registered) | ||
952 | pnp_unregister_card_driver(&interwave_pnpc_driver); | ||
953 | #endif | ||
954 | isa_unregister_driver(&snd_interwave_driver); | ||
982 | } | 955 | } |
983 | 956 | ||
984 | module_init(alsa_card_interwave_init) | 957 | module_init(alsa_card_interwave_init) |