diff options
Diffstat (limited to 'sound/isa/wavefront/wavefront.c')
-rw-r--r-- | sound/isa/wavefront/wavefront.c | 113 |
1 files changed, 42 insertions, 71 deletions
diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c index e2fdd5fd39d..75673f72385 100644 --- a/sound/isa/wavefront/wavefront.c +++ b/sound/isa/wavefront/wavefront.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include <linux/interrupt.h> | 24 | #include <linux/interrupt.h> |
25 | #include <linux/slab.h> | 25 | #include <linux/slab.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/pnp.h> | 28 | #include <linux/pnp.h> |
29 | #include <linux/moduleparam.h> | 29 | #include <linux/moduleparam.h> |
30 | #include <sound/core.h> | 30 | #include <sound/core.h> |
@@ -40,7 +40,9 @@ MODULE_SUPPORTED_DEVICE("{{Turtle Beach,Maui/Tropez/Tropez+}}"); | |||
40 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ | 40 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ |
41 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ | 41 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ |
42 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ | 42 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ |
43 | #ifdef CONFIG_PNP | ||
43 | static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; | 44 | static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; |
45 | #endif | ||
44 | static long cs4232_pcm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ | 46 | static long cs4232_pcm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ |
45 | static int cs4232_pcm_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,11,12,15 */ | 47 | static int cs4232_pcm_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,11,12,15 */ |
46 | static long cs4232_mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ | 48 | static long cs4232_mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ |
@@ -83,8 +85,6 @@ MODULE_PARM_DESC(fm_port, "FM port #."); | |||
83 | module_param_array(use_cs4232_midi, bool, NULL, 0444); | 85 | module_param_array(use_cs4232_midi, bool, NULL, 0444); |
84 | MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)"); | 86 | MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)"); |
85 | 87 | ||
86 | static struct platform_device *platform_devices[SNDRV_CARDS]; | ||
87 | |||
88 | #ifdef CONFIG_PNP | 88 | #ifdef CONFIG_PNP |
89 | static int pnp_registered; | 89 | static int pnp_registered; |
90 | 90 | ||
@@ -588,56 +588,67 @@ snd_wavefront_probe (struct snd_card *card, int dev) | |||
588 | return snd_card_register(card); | 588 | return snd_card_register(card); |
589 | } | 589 | } |
590 | 590 | ||
591 | static int __devinit snd_wavefront_nonpnp_probe(struct platform_device *pdev) | 591 | static int __devinit snd_wavefront_isa_match(struct device *pdev, |
592 | unsigned int dev) | ||
592 | { | 593 | { |
593 | int dev = pdev->id; | 594 | if (!enable[dev]) |
594 | struct snd_card *card; | 595 | return 0; |
595 | int err; | 596 | #ifdef CONFIG_PNP |
596 | 597 | if (isapnp[dev]) | |
598 | return 0; | ||
599 | #endif | ||
597 | if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) { | 600 | if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) { |
598 | snd_printk("specify CS4232 port\n"); | 601 | snd_printk("specify CS4232 port\n"); |
599 | return -EINVAL; | 602 | return 0; |
600 | } | 603 | } |
601 | if (ics2115_port[dev] == SNDRV_AUTO_PORT) { | 604 | if (ics2115_port[dev] == SNDRV_AUTO_PORT) { |
602 | snd_printk("specify ICS2115 port\n"); | 605 | snd_printk("specify ICS2115 port\n"); |
603 | return -ENODEV; | 606 | return 0; |
604 | } | 607 | } |
608 | return 1; | ||
609 | } | ||
610 | |||
611 | static int __devinit snd_wavefront_isa_probe(struct device *pdev, | ||
612 | unsigned int dev) | ||
613 | { | ||
614 | struct snd_card *card; | ||
615 | int err; | ||
605 | 616 | ||
606 | card = snd_wavefront_card_new(dev); | 617 | card = snd_wavefront_card_new(dev); |
607 | if (! card) | 618 | if (! card) |
608 | return -ENOMEM; | 619 | return -ENOMEM; |
609 | snd_card_set_dev(card, &pdev->dev); | 620 | snd_card_set_dev(card, pdev); |
610 | if ((err = snd_wavefront_probe(card, dev)) < 0) { | 621 | if ((err = snd_wavefront_probe(card, dev)) < 0) { |
611 | snd_card_free(card); | 622 | snd_card_free(card); |
612 | return err; | 623 | return err; |
613 | } | 624 | } |
614 | 625 | ||
615 | platform_set_drvdata(pdev, card); | 626 | dev_set_drvdata(pdev, card); |
616 | return 0; | 627 | return 0; |
617 | } | 628 | } |
618 | 629 | ||
619 | static int __devexit snd_wavefront_nonpnp_remove(struct platform_device *devptr) | 630 | static int __devexit snd_wavefront_isa_remove(struct device *devptr, |
631 | unsigned int dev) | ||
620 | { | 632 | { |
621 | snd_card_free(platform_get_drvdata(devptr)); | 633 | snd_card_free(dev_get_drvdata(devptr)); |
622 | platform_set_drvdata(devptr, NULL); | 634 | dev_set_drvdata(devptr, NULL); |
623 | return 0; | 635 | return 0; |
624 | } | 636 | } |
625 | 637 | ||
626 | #define WAVEFRONT_DRIVER "snd_wavefront" | 638 | #define DEV_NAME "wavefront" |
627 | 639 | ||
628 | static struct platform_driver snd_wavefront_driver = { | 640 | static struct isa_driver snd_wavefront_driver = { |
629 | .probe = snd_wavefront_nonpnp_probe, | 641 | .match = snd_wavefront_isa_match, |
630 | .remove = __devexit_p(snd_wavefront_nonpnp_remove), | 642 | .probe = snd_wavefront_isa_probe, |
643 | .remove = __devexit_p(snd_wavefront_isa_remove), | ||
631 | /* FIXME: suspend, resume */ | 644 | /* FIXME: suspend, resume */ |
632 | .driver = { | 645 | .driver = { |
633 | .name = WAVEFRONT_DRIVER | 646 | .name = DEV_NAME |
634 | }, | 647 | }, |
635 | }; | 648 | }; |
636 | 649 | ||
637 | 650 | ||
638 | #ifdef CONFIG_PNP | 651 | #ifdef CONFIG_PNP |
639 | static unsigned int __devinitdata wavefront_pnp_devices; | ||
640 | |||
641 | static int __devinit snd_wavefront_pnp_detect(struct pnp_card_link *pcard, | 652 | static int __devinit snd_wavefront_pnp_detect(struct pnp_card_link *pcard, |
642 | const struct pnp_card_device_id *pid) | 653 | const struct pnp_card_device_id *pid) |
643 | { | 654 | { |
@@ -670,7 +681,6 @@ static int __devinit snd_wavefront_pnp_detect(struct pnp_card_link *pcard, | |||
670 | 681 | ||
671 | pnp_set_card_drvdata(pcard, card); | 682 | pnp_set_card_drvdata(pcard, card); |
672 | dev++; | 683 | dev++; |
673 | wavefront_pnp_devices++; | ||
674 | return 0; | 684 | return 0; |
675 | } | 685 | } |
676 | 686 | ||
@@ -691,67 +701,28 @@ static struct pnp_card_driver wavefront_pnpc_driver = { | |||
691 | 701 | ||
692 | #endif /* CONFIG_PNP */ | 702 | #endif /* CONFIG_PNP */ |
693 | 703 | ||
694 | static void __init_or_module snd_wavefront_unregister_all(void) | ||
695 | { | ||
696 | int i; | ||
697 | |||
698 | #ifdef CONFIG_PNP | ||
699 | if (pnp_registered) | ||
700 | pnp_unregister_card_driver(&wavefront_pnpc_driver); | ||
701 | #endif | ||
702 | for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) | ||
703 | platform_device_unregister(platform_devices[i]); | ||
704 | platform_driver_unregister(&snd_wavefront_driver); | ||
705 | } | ||
706 | |||
707 | static int __init alsa_card_wavefront_init(void) | 704 | static int __init alsa_card_wavefront_init(void) |
708 | { | 705 | { |
709 | int i, err, cards = 0; | 706 | int err; |
710 | 707 | ||
711 | if ((err = platform_driver_register(&snd_wavefront_driver)) < 0) | 708 | err = isa_register_driver(&snd_wavefront_driver, SNDRV_CARDS); |
709 | if (err < 0) | ||
712 | return err; | 710 | return err; |
713 | |||
714 | for (i = 0; i < SNDRV_CARDS; i++) { | ||
715 | struct platform_device *device; | ||
716 | if (! enable[i]) | ||
717 | continue; | ||
718 | #ifdef CONFIG_PNP | ||
719 | if (isapnp[i]) | ||
720 | continue; | ||
721 | #endif | ||
722 | device = platform_device_register_simple(WAVEFRONT_DRIVER, | ||
723 | i, NULL, 0); | ||
724 | if (IS_ERR(device)) | ||
725 | continue; | ||
726 | if (!platform_get_drvdata(device)) { | ||
727 | platform_device_unregister(device); | ||
728 | continue; | ||
729 | } | ||
730 | platform_devices[i] = device; | ||
731 | cards++; | ||
732 | } | ||
733 | |||
734 | #ifdef CONFIG_PNP | 711 | #ifdef CONFIG_PNP |
735 | err = pnp_register_card_driver(&wavefront_pnpc_driver); | 712 | err = pnp_register_card_driver(&wavefront_pnpc_driver); |
736 | if (!err) { | 713 | if (!err) |
737 | pnp_registered = 1; | 714 | pnp_registered = 1; |
738 | cards += wavefront_pnp_devices; | ||
739 | } | ||
740 | #endif | ||
741 | |||
742 | if (!cards) { | ||
743 | #ifdef MODULE | ||
744 | printk (KERN_ERR "No WaveFront cards found or devices busy\n"); | ||
745 | #endif | 715 | #endif |
746 | snd_wavefront_unregister_all(); | ||
747 | return -ENODEV; | ||
748 | } | ||
749 | return 0; | 716 | return 0; |
750 | } | 717 | } |
751 | 718 | ||
752 | static void __exit alsa_card_wavefront_exit(void) | 719 | static void __exit alsa_card_wavefront_exit(void) |
753 | { | 720 | { |
754 | snd_wavefront_unregister_all(); | 721 | #ifdef CONFIG_PNP |
722 | if (pnp_registered) | ||
723 | pnp_unregister_card_driver(&wavefront_pnpc_driver); | ||
724 | #endif | ||
725 | isa_unregister_driver(&snd_wavefront_driver); | ||
755 | } | 726 | } |
756 | 727 | ||
757 | module_init(alsa_card_wavefront_init) | 728 | module_init(alsa_card_wavefront_init) |