]> bbs.cooldavid.org Git - net-next-2.6.git/blame - sound/isa/adlib.c
net: more Kconfig whitespace cleanup
[net-next-2.6.git] / sound / isa / adlib.c
CommitLineData
cf40a310
RH
1/*
2 * AdLib FM card driver.
3 */
4
cf40a310
RH
5#include <linux/kernel.h>
6#include <linux/module.h>
ab7942b2 7#include <linux/isa.h>
cf40a310
RH
8#include <sound/core.h>
9#include <sound/initval.h>
10#include <sound/opl3.h>
11
12#define CRD_NAME "AdLib FM"
ab7942b2 13#define DEV_NAME "adlib"
cf40a310
RH
14
15MODULE_DESCRIPTION(CRD_NAME);
16MODULE_AUTHOR("Rene Herman");
17MODULE_LICENSE("GPL");
18
19static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
20static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
21static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;
22static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
23
24module_param_array(index, int, NULL, 0444);
25MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard.");
26module_param_array(id, charp, NULL, 0444);
27MODULE_PARM_DESC(id, "ID string for " CRD_NAME " soundcard.");
28module_param_array(enable, bool, NULL, 0444);
29MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard.");
30module_param_array(port, long, NULL, 0444);
31MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver.");
32
ab7942b2
RH
33static int __devinit snd_adlib_match(struct device *dev, unsigned int n)
34{
35 if (!enable[n])
36 return 0;
37
38 if (port[n] == SNDRV_AUTO_PORT) {
0418ff0c 39 dev_err(dev, "please specify port\n");
ab7942b2
RH
40 return 0;
41 }
42 return 1;
43}
cf40a310
RH
44
45static void snd_adlib_free(struct snd_card *card)
46{
47 release_and_free_resource(card->private_data);
48}
49
ab7942b2 50static int __devinit snd_adlib_probe(struct device *dev, unsigned int n)
cf40a310
RH
51{
52 struct snd_card *card;
53 struct snd_opl3 *opl3;
ab7942b2 54 int error;
cf40a310 55
c95eadd2
TI
56 error = snd_card_create(index[n], id[n], THIS_MODULE, 0, &card);
57 if (error < 0) {
0418ff0c 58 dev_err(dev, "could not create card\n");
c95eadd2 59 return error;
cf40a310
RH
60 }
61
ab7942b2 62 card->private_data = request_region(port[n], 4, CRD_NAME);
cf40a310 63 if (!card->private_data) {
0418ff0c 64 dev_err(dev, "could not grab ports\n");
cf40a310 65 error = -EBUSY;
ab7942b2 66 goto out;
cf40a310
RH
67 }
68 card->private_free = snd_adlib_free;
69
ab7942b2
RH
70 strcpy(card->driver, DEV_NAME);
71 strcpy(card->shortname, CRD_NAME);
72 sprintf(card->longname, CRD_NAME " at %#lx", port[n]);
73
74 error = snd_opl3_create(card, port[n], port[n] + 2, OPL3_HW_AUTO, 1, &opl3);
cf40a310 75 if (error < 0) {
0418ff0c 76 dev_err(dev, "could not create OPL\n");
ab7942b2 77 goto out;
cf40a310
RH
78 }
79
80 error = snd_opl3_hwdep_new(opl3, 0, 0, NULL);
81 if (error < 0) {
0418ff0c 82 dev_err(dev, "could not create FM\n");
ab7942b2 83 goto out;
cf40a310
RH
84 }
85
ab7942b2 86 snd_card_set_dev(card, dev);
cf40a310
RH
87
88 error = snd_card_register(card);
89 if (error < 0) {
0418ff0c 90 dev_err(dev, "could not register card\n");
ab7942b2 91 goto out;
cf40a310
RH
92 }
93
ab7942b2 94 dev_set_drvdata(dev, card);
cf40a310
RH
95 return 0;
96
ab7942b2
RH
97out: snd_card_free(card);
98 return error;
cf40a310
RH
99}
100
ab7942b2 101static int __devexit snd_adlib_remove(struct device *dev, unsigned int n)
cf40a310 102{
ab7942b2
RH
103 snd_card_free(dev_get_drvdata(dev));
104 dev_set_drvdata(dev, NULL);
cf40a310
RH
105 return 0;
106}
107
ab7942b2
RH
108static struct isa_driver snd_adlib_driver = {
109 .match = snd_adlib_match,
cf40a310
RH
110 .probe = snd_adlib_probe,
111 .remove = __devexit_p(snd_adlib_remove),
112
113 .driver = {
ab7942b2 114 .name = DEV_NAME
cf40a310
RH
115 }
116};
117
118static int __init alsa_card_adlib_init(void)
119{
ab7942b2 120 return isa_register_driver(&snd_adlib_driver, SNDRV_CARDS);
cf40a310
RH
121}
122
123static void __exit alsa_card_adlib_exit(void)
124{
ab7942b2 125 isa_unregister_driver(&snd_adlib_driver);
cf40a310
RH
126}
127
128module_init(alsa_card_adlib_init);
129module_exit(alsa_card_adlib_exit);