aboutsummaryrefslogtreecommitdiffstats
path: root/sound/isa/gus/interwave.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/isa/gus/interwave.c')
-rw-r--r--sound/isa/gus/interwave.c101
1 files changed, 37 insertions, 64 deletions
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.");
115module_param_array(effect, int, NULL, 0444); 115module_param_array(effect, int, NULL, 0444);
116MODULE_PARM_DESC(effect, "Effects enable for InterWave driver."); 116MODULE_PARM_DESC(effect, "Effects enable for InterWave driver.");
117 117
118static struct platform_device *platform_devices[SNDRV_CARDS];
119static int pnp_registered;
120
121struct snd_interwave { 118struct 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
138static int pnp_registered;
141 139
142static struct pnp_card_device_id snd_interwave_pnpids[] = { 140static 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
796static int __devinit snd_interwave_nonpnp_probe1(int dev, struct platform_device *devptr) 794static 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
814static int __devinit snd_interwave_nonpnp_probe(struct platform_device *pdev) 812static 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
824static 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
855static int __devexit snd_interwave_nonpnp_remove(struct platform_device *devptr) 865static 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
862static struct platform_driver snd_interwave_driver = { 872static 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
872static unsigned int __devinitdata interwave_pnp_devices;
873
874static int __devinit snd_interwave_pnp_detect(struct pnp_card_link *pcard, 883static 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
924static 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
935static int __init alsa_card_interwave_init(void) 932static 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
979static void __exit alsa_card_interwave_exit(void) 948static 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
984module_init(alsa_card_interwave_init) 957module_init(alsa_card_interwave_init)