diff options
Diffstat (limited to 'sound/isa/opl3sa2.c')
-rw-r--r-- | sound/isa/opl3sa2.c | 123 |
1 files changed, 48 insertions, 75 deletions
diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c index f3db686b1c0c..50a812f1c804 100644 --- a/sound/isa/opl3sa2.c +++ b/sound/isa/opl3sa2.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/interrupt.h> | 26 | #include <linux/interrupt.h> |
27 | #include <linux/pm.h> | 27 | #include <linux/pm.h> |
28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
@@ -91,12 +91,10 @@ MODULE_PARM_DESC(dma2, "DMA2 # for OPL3-SA driver."); | |||
91 | module_param_array(opl3sa3_ymode, int, NULL, 0444); | 91 | module_param_array(opl3sa3_ymode, int, NULL, 0444); |
92 | MODULE_PARM_DESC(opl3sa3_ymode, "Speaker size selection for 3D Enhancement mode: Desktop/Large Notebook/Small Notebook/HiFi."); | 92 | MODULE_PARM_DESC(opl3sa3_ymode, "Speaker size selection for 3D Enhancement mode: Desktop/Large Notebook/Small Notebook/HiFi."); |
93 | 93 | ||
94 | static struct platform_device *platform_devices[SNDRV_CARDS]; | ||
95 | #ifdef CONFIG_PNP | 94 | #ifdef CONFIG_PNP |
96 | static int pnp_registered; | 95 | static int pnp_registered; |
97 | static int pnpc_registered; | 96 | static int pnpc_registered; |
98 | #endif | 97 | #endif |
99 | static unsigned int snd_opl3sa2_devices; | ||
100 | 98 | ||
101 | /* control ports */ | 99 | /* control ports */ |
102 | #define OPL3SA2_PM_CTRL 0x01 | 100 | #define OPL3SA2_PM_CTRL 0x01 |
@@ -783,7 +781,6 @@ static int __devinit snd_opl3sa2_pnp_detect(struct pnp_dev *pdev, | |||
783 | } | 781 | } |
784 | pnp_set_drvdata(pdev, card); | 782 | pnp_set_drvdata(pdev, card); |
785 | dev++; | 783 | dev++; |
786 | snd_opl3sa2_devices++; | ||
787 | return 0; | 784 | return 0; |
788 | } | 785 | } |
789 | 786 | ||
@@ -850,7 +847,6 @@ static int __devinit snd_opl3sa2_pnp_cdetect(struct pnp_card_link *pcard, | |||
850 | } | 847 | } |
851 | pnp_set_card_drvdata(pcard, card); | 848 | pnp_set_card_drvdata(pcard, card); |
852 | dev++; | 849 | dev++; |
853 | snd_opl3sa2_devices++; | ||
854 | return 0; | 850 | return 0; |
855 | } | 851 | } |
856 | 852 | ||
@@ -884,116 +880,95 @@ static struct pnp_card_driver opl3sa2_pnpc_driver = { | |||
884 | }; | 880 | }; |
885 | #endif /* CONFIG_PNP */ | 881 | #endif /* CONFIG_PNP */ |
886 | 882 | ||
887 | static int __devinit snd_opl3sa2_nonpnp_probe(struct platform_device *pdev) | 883 | static int __devinit snd_opl3sa2_isa_match(struct device *pdev, |
884 | unsigned int dev) | ||
888 | { | 885 | { |
889 | struct snd_card *card; | 886 | if (!enable[dev]) |
890 | int err; | 887 | return 0; |
891 | int dev = pdev->id; | 888 | #ifdef CONFIG_PNP |
892 | 889 | if (isapnp[dev]) | |
890 | return 0; | ||
891 | #endif | ||
893 | if (port[dev] == SNDRV_AUTO_PORT) { | 892 | if (port[dev] == SNDRV_AUTO_PORT) { |
894 | snd_printk(KERN_ERR PFX "specify port\n"); | 893 | snd_printk(KERN_ERR PFX "specify port\n"); |
895 | return -EINVAL; | 894 | return 0; |
896 | } | 895 | } |
897 | if (wss_port[dev] == SNDRV_AUTO_PORT) { | 896 | if (wss_port[dev] == SNDRV_AUTO_PORT) { |
898 | snd_printk(KERN_ERR PFX "specify wss_port\n"); | 897 | snd_printk(KERN_ERR PFX "specify wss_port\n"); |
899 | return -EINVAL; | 898 | return 0; |
900 | } | 899 | } |
901 | if (fm_port[dev] == SNDRV_AUTO_PORT) { | 900 | if (fm_port[dev] == SNDRV_AUTO_PORT) { |
902 | snd_printk(KERN_ERR PFX "specify fm_port\n"); | 901 | snd_printk(KERN_ERR PFX "specify fm_port\n"); |
903 | return -EINVAL; | 902 | return 0; |
904 | } | 903 | } |
905 | if (midi_port[dev] == SNDRV_AUTO_PORT) { | 904 | if (midi_port[dev] == SNDRV_AUTO_PORT) { |
906 | snd_printk(KERN_ERR PFX "specify midi_port\n"); | 905 | snd_printk(KERN_ERR PFX "specify midi_port\n"); |
907 | return -EINVAL; | 906 | return 0; |
908 | } | 907 | } |
908 | return 1; | ||
909 | } | ||
910 | |||
911 | static int __devinit snd_opl3sa2_isa_probe(struct device *pdev, | ||
912 | unsigned int dev) | ||
913 | { | ||
914 | struct snd_card *card; | ||
915 | int err; | ||
909 | 916 | ||
910 | card = snd_opl3sa2_card_new(dev); | 917 | card = snd_opl3sa2_card_new(dev); |
911 | if (! card) | 918 | if (! card) |
912 | return -ENOMEM; | 919 | return -ENOMEM; |
913 | snd_card_set_dev(card, &pdev->dev); | 920 | snd_card_set_dev(card, pdev); |
914 | if ((err = snd_opl3sa2_probe(card, dev)) < 0) { | 921 | if ((err = snd_opl3sa2_probe(card, dev)) < 0) { |
915 | snd_card_free(card); | 922 | snd_card_free(card); |
916 | return err; | 923 | return err; |
917 | } | 924 | } |
918 | platform_set_drvdata(pdev, card); | 925 | dev_set_drvdata(pdev, card); |
919 | return 0; | 926 | return 0; |
920 | } | 927 | } |
921 | 928 | ||
922 | static int __devexit snd_opl3sa2_nonpnp_remove(struct platform_device *devptr) | 929 | static int __devexit snd_opl3sa2_isa_remove(struct device *devptr, |
930 | unsigned int dev) | ||
923 | { | 931 | { |
924 | snd_card_free(platform_get_drvdata(devptr)); | 932 | snd_card_free(dev_get_drvdata(devptr)); |
925 | platform_set_drvdata(devptr, NULL); | 933 | dev_set_drvdata(devptr, NULL); |
926 | return 0; | 934 | return 0; |
927 | } | 935 | } |
928 | 936 | ||
929 | #ifdef CONFIG_PM | 937 | #ifdef CONFIG_PM |
930 | static int snd_opl3sa2_nonpnp_suspend(struct platform_device *dev, pm_message_t state) | 938 | static int snd_opl3sa2_isa_suspend(struct device *dev, unsigned int n, |
939 | pm_message_t state) | ||
931 | { | 940 | { |
932 | return snd_opl3sa2_suspend(platform_get_drvdata(dev), state); | 941 | return snd_opl3sa2_suspend(dev_get_drvdata(dev), state); |
933 | } | 942 | } |
934 | 943 | ||
935 | static int snd_opl3sa2_nonpnp_resume(struct platform_device *dev) | 944 | static int snd_opl3sa2_isa_resume(struct device *dev, unsigned int n) |
936 | { | 945 | { |
937 | return snd_opl3sa2_resume(platform_get_drvdata(dev)); | 946 | return snd_opl3sa2_resume(dev_get_drvdata(dev)); |
938 | } | 947 | } |
939 | #endif | 948 | #endif |
940 | 949 | ||
941 | #define OPL3SA2_DRIVER "snd_opl3sa2" | 950 | #define OPL3SA2_DRIVER "snd_opl3sa2" |
942 | 951 | ||
943 | static struct platform_driver snd_opl3sa2_nonpnp_driver = { | 952 | static struct isa_driver snd_opl3sa2_isa_driver = { |
944 | .probe = snd_opl3sa2_nonpnp_probe, | 953 | .match = snd_opl3sa2_isa_match, |
945 | .remove = __devexit( snd_opl3sa2_nonpnp_remove), | 954 | .probe = snd_opl3sa2_isa_probe, |
955 | .remove = __devexit( snd_opl3sa2_isa_remove), | ||
946 | #ifdef CONFIG_PM | 956 | #ifdef CONFIG_PM |
947 | .suspend = snd_opl3sa2_nonpnp_suspend, | 957 | .suspend = snd_opl3sa2_isa_suspend, |
948 | .resume = snd_opl3sa2_nonpnp_resume, | 958 | .resume = snd_opl3sa2_isa_resume, |
949 | #endif | 959 | #endif |
950 | .driver = { | 960 | .driver = { |
951 | .name = OPL3SA2_DRIVER | 961 | .name = OPL3SA2_DRIVER |
952 | }, | 962 | }, |
953 | }; | 963 | }; |
954 | 964 | ||
955 | static void __init_or_module snd_opl3sa2_unregister_all(void) | ||
956 | { | ||
957 | int i; | ||
958 | |||
959 | #ifdef CONFIG_PNP | ||
960 | if (pnpc_registered) | ||
961 | pnp_unregister_card_driver(&opl3sa2_pnpc_driver); | ||
962 | if (pnp_registered) | ||
963 | pnp_unregister_driver(&opl3sa2_pnp_driver); | ||
964 | #endif | ||
965 | for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) | ||
966 | platform_device_unregister(platform_devices[i]); | ||
967 | platform_driver_unregister(&snd_opl3sa2_nonpnp_driver); | ||
968 | } | ||
969 | |||
970 | static int __init alsa_card_opl3sa2_init(void) | 965 | static int __init alsa_card_opl3sa2_init(void) |
971 | { | 966 | { |
972 | int i, err; | 967 | int err; |
973 | 968 | ||
974 | if ((err = platform_driver_register(&snd_opl3sa2_nonpnp_driver)) < 0) | 969 | err = isa_register_driver(&snd_opl3sa2_isa_driver, SNDRV_CARDS); |
970 | if (err < 0) | ||
975 | return err; | 971 | return err; |
976 | |||
977 | for (i = 0; i < SNDRV_CARDS; i++) { | ||
978 | struct platform_device *device; | ||
979 | if (! enable[i]) | ||
980 | continue; | ||
981 | #ifdef CONFIG_PNP | ||
982 | if (isapnp[i]) | ||
983 | continue; | ||
984 | #endif | ||
985 | device = platform_device_register_simple(OPL3SA2_DRIVER, | ||
986 | i, NULL, 0); | ||
987 | if (IS_ERR(device)) | ||
988 | continue; | ||
989 | if (!platform_get_drvdata(device)) { | ||
990 | platform_device_unregister(device); | ||
991 | continue; | ||
992 | } | ||
993 | platform_devices[i] = device; | ||
994 | snd_opl3sa2_devices++; | ||
995 | } | ||
996 | |||
997 | #ifdef CONFIG_PNP | 972 | #ifdef CONFIG_PNP |
998 | err = pnp_register_driver(&opl3sa2_pnp_driver); | 973 | err = pnp_register_driver(&opl3sa2_pnp_driver); |
999 | if (!err) | 974 | if (!err) |
@@ -1002,20 +977,18 @@ static int __init alsa_card_opl3sa2_init(void) | |||
1002 | if (!err) | 977 | if (!err) |
1003 | pnpc_registered = 1; | 978 | pnpc_registered = 1; |
1004 | #endif | 979 | #endif |
1005 | |||
1006 | if (!snd_opl3sa2_devices) { | ||
1007 | #ifdef MODULE | ||
1008 | snd_printk(KERN_ERR "Yamaha OPL3-SA soundcard not found or device busy\n"); | ||
1009 | #endif | ||
1010 | snd_opl3sa2_unregister_all(); | ||
1011 | return -ENODEV; | ||
1012 | } | ||
1013 | return 0; | 980 | return 0; |
1014 | } | 981 | } |
1015 | 982 | ||
1016 | static void __exit alsa_card_opl3sa2_exit(void) | 983 | static void __exit alsa_card_opl3sa2_exit(void) |
1017 | { | 984 | { |
1018 | snd_opl3sa2_unregister_all(); | 985 | #ifdef CONFIG_PNP |
986 | if (pnpc_registered) | ||
987 | pnp_unregister_card_driver(&opl3sa2_pnpc_driver); | ||
988 | if (pnp_registered) | ||
989 | pnp_unregister_driver(&opl3sa2_pnp_driver); | ||
990 | #endif | ||
991 | isa_unregister_driver(&snd_opl3sa2_isa_driver); | ||
1019 | } | 992 | } |
1020 | 993 | ||
1021 | module_init(alsa_card_opl3sa2_init) | 994 | module_init(alsa_card_opl3sa2_init) |