aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRene Herman <rene.herman@gmail.com>2007-02-14 07:23:16 -0500
committerJaroslav Kysela <perex@suse.cz>2007-05-11 10:55:38 -0400
commitab7942b202874f47d38c7ff06ccacdfbced1c4f4 (patch)
treedc64f5e7f1807cdb65523a776c4b8add62b18c49
parente2759e3366eda66b3e000171961ce92b2e01f05f (diff)
[ALSA] isa_bus: adlib
adlib: port to isa_bus infrastructure. Signed-off-by: Rene Herman <rene.herman@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
-rw-r--r--sound/isa/adlib.c122
1 files changed, 44 insertions, 78 deletions
diff --git a/sound/isa/adlib.c b/sound/isa/adlib.c
index 1124344ed948..d68720724c91 100644
--- a/sound/isa/adlib.c
+++ b/sound/isa/adlib.c
@@ -5,13 +5,13 @@
5#include <sound/driver.h> 5#include <sound/driver.h>
6#include <linux/kernel.h> 6#include <linux/kernel.h>
7#include <linux/module.h> 7#include <linux/module.h>
8#include <linux/platform_device.h> 8#include <linux/isa.h>
9#include <sound/core.h> 9#include <sound/core.h>
10#include <sound/initval.h> 10#include <sound/initval.h>
11#include <sound/opl3.h> 11#include <sound/opl3.h>
12 12
13#define CRD_NAME "AdLib FM" 13#define CRD_NAME "AdLib FM"
14#define DRV_NAME "snd_adlib" 14#define DEV_NAME "adlib"
15 15
16MODULE_DESCRIPTION(CRD_NAME); 16MODULE_DESCRIPTION(CRD_NAME);
17MODULE_AUTHOR("Rene Herman"); 17MODULE_AUTHOR("Rene Herman");
@@ -31,133 +31,99 @@ MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard.");
31module_param_array(port, long, NULL, 0444); 31module_param_array(port, long, NULL, 0444);
32MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver."); 32MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver.");
33 33
34static struct platform_device *devices[SNDRV_CARDS]; 34static int __devinit snd_adlib_match(struct device *dev, unsigned int n)
35{
36 if (!enable[n])
37 return 0;
38
39 if (port[n] == SNDRV_AUTO_PORT) {
40 snd_printk(KERN_ERR "%s: please specify port\n", dev->bus_id);
41 return 0;
42 }
43 return 1;
44}
35 45
36static void snd_adlib_free(struct snd_card *card) 46static void snd_adlib_free(struct snd_card *card)
37{ 47{
38 release_and_free_resource(card->private_data); 48 release_and_free_resource(card->private_data);
39} 49}
40 50
41static int __devinit snd_adlib_probe(struct platform_device *device) 51static int __devinit snd_adlib_probe(struct device *dev, unsigned int n)
42{ 52{
43 struct snd_card *card; 53 struct snd_card *card;
44 struct snd_opl3 *opl3; 54 struct snd_opl3 *opl3;
55 int error;
45 56
46 int error, i = device->id; 57 card = snd_card_new(index[n], id[n], THIS_MODULE, 0);
47
48 if (port[i] == SNDRV_AUTO_PORT) {
49 snd_printk(KERN_ERR DRV_NAME ": please specify port\n");
50 error = -EINVAL;
51 goto out0;
52 }
53
54 card = snd_card_new(index[i], id[i], THIS_MODULE, 0);
55 if (!card) { 58 if (!card) {
56 snd_printk(KERN_ERR DRV_NAME ": could not create card\n"); 59 snd_printk(KERN_ERR "%s: could not create card\n", dev->bus_id);
57 error = -EINVAL; 60 return -EINVAL;
58 goto out0;
59 } 61 }
60 62
61 card->private_data = request_region(port[i], 4, CRD_NAME); 63 card->private_data = request_region(port[n], 4, CRD_NAME);
62 if (!card->private_data) { 64 if (!card->private_data) {
63 snd_printk(KERN_ERR DRV_NAME ": could not grab ports\n"); 65 snd_printk(KERN_ERR "%s: could not grab ports\n", dev->bus_id);
64 error = -EBUSY; 66 error = -EBUSY;
65 goto out1; 67 goto out;
66 } 68 }
67 card->private_free = snd_adlib_free; 69 card->private_free = snd_adlib_free;
68 70
69 error = snd_opl3_create(card, port[i], port[i] + 2, OPL3_HW_AUTO, 1, &opl3); 71 strcpy(card->driver, DEV_NAME);
72 strcpy(card->shortname, CRD_NAME);
73 sprintf(card->longname, CRD_NAME " at %#lx", port[n]);
74
75 error = snd_opl3_create(card, port[n], port[n] + 2, OPL3_HW_AUTO, 1, &opl3);
70 if (error < 0) { 76 if (error < 0) {
71 snd_printk(KERN_ERR DRV_NAME ": could not create OPL\n"); 77 snd_printk(KERN_ERR "%s: could not create OPL\n", dev->bus_id);
72 goto out1; 78 goto out;
73 } 79 }
74 80
75 error = snd_opl3_hwdep_new(opl3, 0, 0, NULL); 81 error = snd_opl3_hwdep_new(opl3, 0, 0, NULL);
76 if (error < 0) { 82 if (error < 0) {
77 snd_printk(KERN_ERR DRV_NAME ": could not create FM\n"); 83 snd_printk(KERN_ERR "%s: could not create FM\n", dev->bus_id);
78 goto out1; 84 goto out;
79 } 85 }
80 86
81 strcpy(card->driver, DRV_NAME); 87 snd_card_set_dev(card, dev);
82 strcpy(card->shortname, CRD_NAME);
83 sprintf(card->longname, CRD_NAME " at %#lx", port[i]);
84
85 snd_card_set_dev(card, &device->dev);
86 88
87 error = snd_card_register(card); 89 error = snd_card_register(card);
88 if (error < 0) { 90 if (error < 0) {
89 snd_printk(KERN_ERR DRV_NAME ": could not register card\n"); 91 snd_printk(KERN_ERR "%s: could not register card\n", dev->bus_id);
90 goto out1; 92 goto out;
91 } 93 }
92 94
93 platform_set_drvdata(device, card); 95 dev_set_drvdata(dev, card);
94 return 0; 96 return 0;
95 97
96out1: snd_card_free(card); 98out: snd_card_free(card);
97out0: return error; 99 return error;
98} 100}
99 101
100static int __devexit snd_adlib_remove(struct platform_device *device) 102static int __devexit snd_adlib_remove(struct device *dev, unsigned int n)
101{ 103{
102 snd_card_free(platform_get_drvdata(device)); 104 snd_card_free(dev_get_drvdata(dev));
103 platform_set_drvdata(device, NULL); 105 dev_set_drvdata(dev, NULL);
104 return 0; 106 return 0;
105} 107}
106 108
107static struct platform_driver snd_adlib_driver = { 109static struct isa_driver snd_adlib_driver = {
110 .match = snd_adlib_match,
108 .probe = snd_adlib_probe, 111 .probe = snd_adlib_probe,
109 .remove = __devexit_p(snd_adlib_remove), 112 .remove = __devexit_p(snd_adlib_remove),
110 113
111 .driver = { 114 .driver = {
112 .name = DRV_NAME 115 .name = DEV_NAME
113 } 116 }
114}; 117};
115 118
116static int __init alsa_card_adlib_init(void) 119static int __init alsa_card_adlib_init(void)
117{ 120{
118 int i, cards; 121 return isa_register_driver(&snd_adlib_driver, SNDRV_CARDS);
119
120 if (platform_driver_register(&snd_adlib_driver) < 0) {
121 snd_printk(KERN_ERR DRV_NAME ": could not register driver\n");
122 return -ENODEV;
123 }
124
125 for (cards = 0, i = 0; i < SNDRV_CARDS; i++) {
126 struct platform_device *device;
127
128 if (!enable[i])
129 continue;
130
131 device = platform_device_register_simple(DRV_NAME, i, NULL, 0);
132 if (IS_ERR(device))
133 continue;
134
135 if (!platform_get_drvdata(device)) {
136 platform_device_unregister(device);
137 continue;
138 }
139
140 devices[i] = device;
141 cards++;
142 }
143
144 if (!cards) {
145#ifdef MODULE
146 printk(KERN_ERR CRD_NAME " soundcard not found or device busy\n");
147#endif
148 platform_driver_unregister(&snd_adlib_driver);
149 return -ENODEV;
150 }
151 return 0;
152} 122}
153 123
154static void __exit alsa_card_adlib_exit(void) 124static void __exit alsa_card_adlib_exit(void)
155{ 125{
156 int i; 126 isa_unregister_driver(&snd_adlib_driver);
157
158 for (i = 0; i < SNDRV_CARDS; i++)
159 platform_device_unregister(devices[i]);
160 platform_driver_unregister(&snd_adlib_driver);
161} 127}
162 128
163module_init(alsa_card_adlib_init); 129module_init(alsa_card_adlib_init);