Merge tag 'powerpc-5.11-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc...
[linux/fpc-iii.git] / sound / isa / adlib.c
blob5105524b6f3866495f53cbdfef5c6b822f8c2aa9
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * AdLib FM card driver.
4 */
6 #include <linux/kernel.h>
7 #include <linux/module.h>
8 #include <linux/isa.h>
9 #include <sound/core.h>
10 #include <sound/initval.h>
11 #include <sound/opl3.h>
13 #define CRD_NAME "AdLib FM"
14 #define DEV_NAME "adlib"
16 MODULE_DESCRIPTION(CRD_NAME);
17 MODULE_AUTHOR("Rene Herman");
18 MODULE_LICENSE("GPL");
20 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
21 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
22 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;
23 static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
25 module_param_array(index, int, NULL, 0444);
26 MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard.");
27 module_param_array(id, charp, NULL, 0444);
28 MODULE_PARM_DESC(id, "ID string for " CRD_NAME " soundcard.");
29 module_param_array(enable, bool, NULL, 0444);
30 MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard.");
31 module_param_hw_array(port, long, ioport, NULL, 0444);
32 MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver.");
34 static int snd_adlib_match(struct device *dev, unsigned int n)
36 if (!enable[n])
37 return 0;
39 if (port[n] == SNDRV_AUTO_PORT) {
40 dev_err(dev, "please specify port\n");
41 return 0;
43 return 1;
46 static void snd_adlib_free(struct snd_card *card)
48 release_and_free_resource(card->private_data);
51 static int snd_adlib_probe(struct device *dev, unsigned int n)
53 struct snd_card *card;
54 struct snd_opl3 *opl3;
55 int error;
57 error = snd_card_new(dev, index[n], id[n], THIS_MODULE, 0, &card);
58 if (error < 0) {
59 dev_err(dev, "could not create card\n");
60 return error;
63 card->private_data = request_region(port[n], 4, CRD_NAME);
64 if (!card->private_data) {
65 dev_err(dev, "could not grab ports\n");
66 error = -EBUSY;
67 goto out;
69 card->private_free = snd_adlib_free;
71 strcpy(card->driver, DEV_NAME);
72 strcpy(card->shortname, CRD_NAME);
73 sprintf(card->longname, CRD_NAME " at %#lx", port[n]);
75 error = snd_opl3_create(card, port[n], port[n] + 2, OPL3_HW_AUTO, 1, &opl3);
76 if (error < 0) {
77 dev_err(dev, "could not create OPL\n");
78 goto out;
81 error = snd_opl3_hwdep_new(opl3, 0, 0, NULL);
82 if (error < 0) {
83 dev_err(dev, "could not create FM\n");
84 goto out;
87 error = snd_card_register(card);
88 if (error < 0) {
89 dev_err(dev, "could not register card\n");
90 goto out;
93 dev_set_drvdata(dev, card);
94 return 0;
96 out: snd_card_free(card);
97 return error;
100 static int snd_adlib_remove(struct device *dev, unsigned int n)
102 snd_card_free(dev_get_drvdata(dev));
103 return 0;
106 static struct isa_driver snd_adlib_driver = {
107 .match = snd_adlib_match,
108 .probe = snd_adlib_probe,
109 .remove = snd_adlib_remove,
111 .driver = {
112 .name = DEV_NAME
116 module_isa_driver(snd_adlib_driver, SNDRV_CARDS);