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