diff options
Diffstat (limited to 'sound/isa/sgalaxy.c')
-rw-r--r-- | sound/isa/sgalaxy.c | 103 |
1 files changed, 36 insertions, 67 deletions
diff --git a/sound/isa/sgalaxy.c b/sound/isa/sgalaxy.c index 4fcd0f4e868c..19e0b0edb8c4 100644 --- a/sound/isa/sgalaxy.c +++ b/sound/isa/sgalaxy.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include <sound/driver.h> | 24 | #include <sound/driver.h> |
25 | #include <linux/init.h> | 25 | #include <linux/init.h> |
26 | #include <linux/err.h> | 26 | #include <linux/err.h> |
27 | #include <linux/platform_device.h> | 27 | #include <linux/isa.h> |
28 | #include <linux/delay.h> | 28 | #include <linux/delay.h> |
29 | #include <linux/time.h> | 29 | #include <linux/time.h> |
30 | #include <linux/interrupt.h> | 30 | #include <linux/interrupt.h> |
@@ -64,8 +64,6 @@ MODULE_PARM_DESC(irq, "IRQ # for Sound Galaxy driver."); | |||
64 | module_param_array(dma1, int, NULL, 0444); | 64 | module_param_array(dma1, int, NULL, 0444); |
65 | MODULE_PARM_DESC(dma1, "DMA1 # for Sound Galaxy driver."); | 65 | MODULE_PARM_DESC(dma1, "DMA1 # for Sound Galaxy driver."); |
66 | 66 | ||
67 | static struct platform_device *devices[SNDRV_CARDS]; | ||
68 | |||
69 | #define SGALAXY_AUXC_LEFT 18 | 67 | #define SGALAXY_AUXC_LEFT 18 |
70 | #define SGALAXY_AUXC_RIGHT 19 | 68 | #define SGALAXY_AUXC_RIGHT 19 |
71 | 69 | ||
@@ -96,7 +94,8 @@ static int snd_sgalaxy_sbdsp_reset(unsigned long port) | |||
96 | return 0; | 94 | return 0; |
97 | } | 95 | } |
98 | 96 | ||
99 | static int __init snd_sgalaxy_sbdsp_command(unsigned long port, unsigned char val) | 97 | static int __devinit snd_sgalaxy_sbdsp_command(unsigned long port, |
98 | unsigned char val) | ||
100 | { | 99 | { |
101 | int i; | 100 | int i; |
102 | 101 | ||
@@ -114,7 +113,7 @@ static irqreturn_t snd_sgalaxy_dummy_interrupt(int irq, void *dev_id) | |||
114 | return IRQ_NONE; | 113 | return IRQ_NONE; |
115 | } | 114 | } |
116 | 115 | ||
117 | static int __init snd_sgalaxy_setup_wss(unsigned long port, int irq, int dma) | 116 | static int __devinit snd_sgalaxy_setup_wss(unsigned long port, int irq, int dma) |
118 | { | 117 | { |
119 | static int interrupt_bits[] = {-1, -1, -1, -1, -1, -1, -1, 0x08, -1, | 118 | static int interrupt_bits[] = {-1, -1, -1, -1, -1, -1, -1, 0x08, -1, |
120 | 0x10, 0x18, 0x20, -1, -1, -1, -1}; | 119 | 0x10, 0x18, 0x20, -1, -1, -1, -1}; |
@@ -161,7 +160,7 @@ static int __init snd_sgalaxy_setup_wss(unsigned long port, int irq, int dma) | |||
161 | return 0; | 160 | return 0; |
162 | } | 161 | } |
163 | 162 | ||
164 | static int __init snd_sgalaxy_detect(int dev, int irq, int dma) | 163 | static int __devinit snd_sgalaxy_detect(int dev, int irq, int dma) |
165 | { | 164 | { |
166 | #if 0 | 165 | #if 0 |
167 | snd_printdd(PFX "switching to WSS mode\n"); | 166 | snd_printdd(PFX "switching to WSS mode\n"); |
@@ -182,7 +181,7 @@ AD1848_DOUBLE("Aux Playback Switch", 0, SGALAXY_AUXC_LEFT, SGALAXY_AUXC_RIGHT, 7 | |||
182 | AD1848_DOUBLE("Aux Playback Volume", 0, SGALAXY_AUXC_LEFT, SGALAXY_AUXC_RIGHT, 0, 0, 31, 0) | 181 | AD1848_DOUBLE("Aux Playback Volume", 0, SGALAXY_AUXC_LEFT, SGALAXY_AUXC_RIGHT, 0, 0, 31, 0) |
183 | }; | 182 | }; |
184 | 183 | ||
185 | static int __init snd_sgalaxy_mixer(struct snd_ad1848 *chip) | 184 | static int __devinit snd_sgalaxy_mixer(struct snd_ad1848 *chip) |
186 | { | 185 | { |
187 | struct snd_card *card = chip->card; | 186 | struct snd_card *card = chip->card; |
188 | struct snd_ctl_elem_id id1, id2; | 187 | struct snd_ctl_elem_id id1, id2; |
@@ -218,23 +217,29 @@ static int __init snd_sgalaxy_mixer(struct snd_ad1848 *chip) | |||
218 | return 0; | 217 | return 0; |
219 | } | 218 | } |
220 | 219 | ||
221 | static int __init snd_sgalaxy_probe(struct platform_device *devptr) | 220 | static int __devinit snd_sgalaxy_match(struct device *devptr, unsigned int dev) |
222 | { | 221 | { |
223 | int dev = devptr->id; | 222 | if (!enable[dev]) |
224 | static int possible_irqs[] = {7, 9, 10, 11, -1}; | 223 | return 0; |
225 | static int possible_dmas[] = {1, 3, 0, -1}; | ||
226 | int err, xirq, xdma1; | ||
227 | struct snd_card *card; | ||
228 | struct snd_ad1848 *chip; | ||
229 | |||
230 | if (sbport[dev] == SNDRV_AUTO_PORT) { | 224 | if (sbport[dev] == SNDRV_AUTO_PORT) { |
231 | snd_printk(KERN_ERR PFX "specify SB port\n"); | 225 | snd_printk(KERN_ERR PFX "specify SB port\n"); |
232 | return -EINVAL; | 226 | return 0; |
233 | } | 227 | } |
234 | if (wssport[dev] == SNDRV_AUTO_PORT) { | 228 | if (wssport[dev] == SNDRV_AUTO_PORT) { |
235 | snd_printk(KERN_ERR PFX "specify WSS port\n"); | 229 | snd_printk(KERN_ERR PFX "specify WSS port\n"); |
236 | return -EINVAL; | 230 | return 0; |
237 | } | 231 | } |
232 | return 1; | ||
233 | } | ||
234 | |||
235 | static int __devinit snd_sgalaxy_probe(struct device *devptr, unsigned int dev) | ||
236 | { | ||
237 | static int possible_irqs[] = {7, 9, 10, 11, -1}; | ||
238 | static int possible_dmas[] = {1, 3, 0, -1}; | ||
239 | int err, xirq, xdma1; | ||
240 | struct snd_card *card; | ||
241 | struct snd_ad1848 *chip; | ||
242 | |||
238 | card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); | 243 | card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); |
239 | if (card == NULL) | 244 | if (card == NULL) |
240 | return -ENOMEM; | 245 | return -ENOMEM; |
@@ -283,12 +288,12 @@ static int __init snd_sgalaxy_probe(struct platform_device *devptr) | |||
283 | sprintf(card->longname, "Sound Galaxy at 0x%lx, irq %d, dma %d", | 288 | sprintf(card->longname, "Sound Galaxy at 0x%lx, irq %d, dma %d", |
284 | wssport[dev], xirq, xdma1); | 289 | wssport[dev], xirq, xdma1); |
285 | 290 | ||
286 | snd_card_set_dev(card, &devptr->dev); | 291 | snd_card_set_dev(card, devptr); |
287 | 292 | ||
288 | if ((err = snd_card_register(card)) < 0) | 293 | if ((err = snd_card_register(card)) < 0) |
289 | goto _err; | 294 | goto _err; |
290 | 295 | ||
291 | platform_set_drvdata(devptr, card); | 296 | dev_set_drvdata(devptr, card); |
292 | return 0; | 297 | return 0; |
293 | 298 | ||
294 | _err: | 299 | _err: |
@@ -296,17 +301,18 @@ static int __init snd_sgalaxy_probe(struct platform_device *devptr) | |||
296 | return err; | 301 | return err; |
297 | } | 302 | } |
298 | 303 | ||
299 | static int __devexit snd_sgalaxy_remove(struct platform_device *devptr) | 304 | static int __devexit snd_sgalaxy_remove(struct device *devptr, unsigned int dev) |
300 | { | 305 | { |
301 | snd_card_free(platform_get_drvdata(devptr)); | 306 | snd_card_free(dev_get_drvdata(devptr)); |
302 | platform_set_drvdata(devptr, NULL); | 307 | dev_set_drvdata(devptr, NULL); |
303 | return 0; | 308 | return 0; |
304 | } | 309 | } |
305 | 310 | ||
306 | #ifdef CONFIG_PM | 311 | #ifdef CONFIG_PM |
307 | static int snd_sgalaxy_suspend(struct platform_device *pdev, pm_message_t state) | 312 | static int snd_sgalaxy_suspend(struct device *pdev, unsigned int n, |
313 | pm_message_t state) | ||
308 | { | 314 | { |
309 | struct snd_card *card = platform_get_drvdata(pdev); | 315 | struct snd_card *card = dev_get_drvdata(pdev); |
310 | struct snd_ad1848 *chip = card->private_data; | 316 | struct snd_ad1848 *chip = card->private_data; |
311 | 317 | ||
312 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); | 318 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); |
@@ -314,9 +320,9 @@ static int snd_sgalaxy_suspend(struct platform_device *pdev, pm_message_t state) | |||
314 | return 0; | 320 | return 0; |
315 | } | 321 | } |
316 | 322 | ||
317 | static int snd_sgalaxy_resume(struct platform_device *pdev) | 323 | static int snd_sgalaxy_resume(struct device *pdev, unsigned int n) |
318 | { | 324 | { |
319 | struct snd_card *card = platform_get_drvdata(pdev); | 325 | struct snd_card *card = dev_get_drvdata(pdev); |
320 | struct snd_ad1848 *chip = card->private_data; | 326 | struct snd_ad1848 *chip = card->private_data; |
321 | 327 | ||
322 | chip->resume(chip); | 328 | chip->resume(chip); |
@@ -330,7 +336,8 @@ static int snd_sgalaxy_resume(struct platform_device *pdev) | |||
330 | 336 | ||
331 | #define SND_SGALAXY_DRIVER "snd_sgalaxy" | 337 | #define SND_SGALAXY_DRIVER "snd_sgalaxy" |
332 | 338 | ||
333 | static struct platform_driver snd_sgalaxy_driver = { | 339 | static struct isa_driver snd_sgalaxy_driver = { |
340 | .match = snd_sgalaxy_match, | ||
334 | .probe = snd_sgalaxy_probe, | 341 | .probe = snd_sgalaxy_probe, |
335 | .remove = __devexit_p(snd_sgalaxy_remove), | 342 | .remove = __devexit_p(snd_sgalaxy_remove), |
336 | #ifdef CONFIG_PM | 343 | #ifdef CONFIG_PM |
@@ -342,52 +349,14 @@ static struct platform_driver snd_sgalaxy_driver = { | |||
342 | }, | 349 | }, |
343 | }; | 350 | }; |
344 | 351 | ||
345 | static void __init_or_module snd_sgalaxy_unregister_all(void) | ||
346 | { | ||
347 | int i; | ||
348 | |||
349 | for (i = 0; i < ARRAY_SIZE(devices); ++i) | ||
350 | platform_device_unregister(devices[i]); | ||
351 | platform_driver_unregister(&snd_sgalaxy_driver); | ||
352 | } | ||
353 | |||
354 | static int __init alsa_card_sgalaxy_init(void) | 352 | static int __init alsa_card_sgalaxy_init(void) |
355 | { | 353 | { |
356 | int i, cards, err; | 354 | return isa_register_driver(&snd_sgalaxy_driver, SNDRV_CARDS); |
357 | |||
358 | err = platform_driver_register(&snd_sgalaxy_driver); | ||
359 | if (err < 0) | ||
360 | return err; | ||
361 | |||
362 | cards = 0; | ||
363 | for (i = 0; i < SNDRV_CARDS; i++) { | ||
364 | struct platform_device *device; | ||
365 | if (! enable[i]) | ||
366 | continue; | ||
367 | device = platform_device_register_simple(SND_SGALAXY_DRIVER, | ||
368 | i, NULL, 0); | ||
369 | if (IS_ERR(device)) | ||
370 | continue; | ||
371 | if (!platform_get_drvdata(device)) { | ||
372 | platform_device_unregister(device); | ||
373 | continue; | ||
374 | } | ||
375 | devices[i] = device; | ||
376 | cards++; | ||
377 | } | ||
378 | if (!cards) { | ||
379 | #ifdef MODULE | ||
380 | snd_printk(KERN_ERR "Sound Galaxy soundcard not found or device busy\n"); | ||
381 | #endif | ||
382 | snd_sgalaxy_unregister_all(); | ||
383 | return -ENODEV; | ||
384 | } | ||
385 | return 0; | ||
386 | } | 355 | } |
387 | 356 | ||
388 | static void __exit alsa_card_sgalaxy_exit(void) | 357 | static void __exit alsa_card_sgalaxy_exit(void) |
389 | { | 358 | { |
390 | snd_sgalaxy_unregister_all(); | 359 | isa_unregister_driver(&snd_sgalaxy_driver); |
391 | } | 360 | } |
392 | 361 | ||
393 | module_init(alsa_card_sgalaxy_init) | 362 | module_init(alsa_card_sgalaxy_init) |