1 | /*
|
---|
2 | * Driver for Yamaha OPL3-SA[2,3] soundcards
|
---|
3 | * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
|
---|
4 | *
|
---|
5 | *
|
---|
6 | * This program is free software; you can redistribute it and/or modify
|
---|
7 | * it under the terms of the GNU General Public License as published by
|
---|
8 | * the Free Software Foundation; either version 2 of the License, or
|
---|
9 | * (at your option) any later version.
|
---|
10 | *
|
---|
11 | * This program is distributed in the hope that it will be useful,
|
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | * GNU General Public License for more details.
|
---|
15 | *
|
---|
16 | * You should have received a copy of the GNU General Public License
|
---|
17 | * along with this program; if not, write to the Free Software
|
---|
18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
19 | *
|
---|
20 | */
|
---|
21 |
|
---|
22 | #define SNDRV_MAIN_OBJECT_FILE
|
---|
23 | #include <sound/driver.h>
|
---|
24 | #include <sound/cs4231.h>
|
---|
25 | #include <sound/mpu401.h>
|
---|
26 | #include <sound/opl3.h>
|
---|
27 | #define SNDRV_GET_ID
|
---|
28 | #include <sound/initval.h>
|
---|
29 |
|
---|
30 | EXPORT_NO_SYMBOLS;
|
---|
31 | MODULE_DESCRIPTION("Yamaha OPL3SA2+");
|
---|
32 | MODULE_CLASSES("{sound}");
|
---|
33 | MODULE_DEVICES("{{Yamaha,YMF719E-S},"
|
---|
34 | "{Genius,Sound Maker 3DX},"
|
---|
35 | "{Yamaha,OPL3SA3},"
|
---|
36 | "{Intel,AL440LX sound},"
|
---|
37 | "{NeoMagic,MagicWave 3DX}}");
|
---|
38 |
|
---|
39 | static int snd_index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
|
---|
40 | static char *snd_id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
|
---|
41 | static int snd_enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
|
---|
42 | #ifdef __ISAPNP__
|
---|
43 | #ifdef TARGET_OS2
|
---|
44 | static int snd_isapnp[SNDRV_CARDS] = {1,1,1,1,1,1,1,1};
|
---|
45 | #else
|
---|
46 | static int snd_isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
|
---|
47 | #endif
|
---|
48 | #endif
|
---|
49 | static long snd_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0xf86,0x370,0x100 */
|
---|
50 | static long snd_sb_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260 */
|
---|
51 | static long snd_wss_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;/* 0x530,0xe80,0xf40,0x604 */
|
---|
52 | static long snd_fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x388 */
|
---|
53 | static long snd_midi_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;/* 0x330,0x300 */
|
---|
54 | static int snd_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 0,1,3,5,9,11,12,15 */
|
---|
55 | static int snd_dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 1,3,5,6,7 */
|
---|
56 | static int snd_dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 1,3,5,6,7 */
|
---|
57 | #ifdef TARGET_OS2
|
---|
58 | static int snd_opl3sa3_ymode[SNDRV_CARDS] = { 0,0,0,0,0,0,0,0 }; /* 0,1,2,3 */ /*SL Added*/
|
---|
59 | #else
|
---|
60 | static int snd_opl3sa3_ymode[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = 0 }; /* 0,1,2,3 */ /*SL Added*/
|
---|
61 | #endif
|
---|
62 |
|
---|
63 | MODULE_PARM(snd_index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
64 | MODULE_PARM_DESC(snd_index, "Index value for OPL3-SA soundcard.");
|
---|
65 | MODULE_PARM_SYNTAX(snd_index, SNDRV_INDEX_DESC);
|
---|
66 | MODULE_PARM(snd_id, "1-" __MODULE_STRING(SNDRV_CARDS) "s");
|
---|
67 | MODULE_PARM_DESC(snd_id, "ID string for OPL3-SA soundcard.");
|
---|
68 | MODULE_PARM_SYNTAX(snd_id, SNDRV_ID_DESC);
|
---|
69 | MODULE_PARM(snd_enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
70 | MODULE_PARM_DESC(snd_enable, "Enable OPL3-SA soundcard.");
|
---|
71 | MODULE_PARM_SYNTAX(snd_enable, SNDRV_ENABLE_DESC);
|
---|
72 | MODULE_PARM(snd_isapnp, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
73 | MODULE_PARM_DESC(snd_isapnp, "ISA PnP detection for specified soundcard.");
|
---|
74 | MODULE_PARM_SYNTAX(snd_isapnp, SNDRV_ISAPNP_DESC);
|
---|
75 | MODULE_PARM(snd_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
|
---|
76 | MODULE_PARM_DESC(snd_port, "Port # for OPL3-SA driver.");
|
---|
77 | MODULE_PARM_SYNTAX(snd_port, SNDRV_ENABLED ",allows:{{0xf86},{0x370},{0x100}},dialog:list");
|
---|
78 | MODULE_PARM(snd_sb_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
|
---|
79 | MODULE_PARM_DESC(snd_sb_port, "SB port # for OPL3-SA driver.");
|
---|
80 | MODULE_PARM_SYNTAX(snd_sb_port, SNDRV_ENABLED ",allows:{{0x220},{0x240},{0x260}},dialog:list");
|
---|
81 | MODULE_PARM(snd_wss_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
|
---|
82 | MODULE_PARM_DESC(snd_wss_port, "WSS port # for OPL3-SA driver.");
|
---|
83 | MODULE_PARM_SYNTAX(snd_wss_port, SNDRV_ENABLED ",allows:{{0x530},{0xe80},{0xf40},{0x604}},dialog:list");
|
---|
84 | MODULE_PARM(snd_fm_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
|
---|
85 | MODULE_PARM_DESC(snd_fm_port, "FM port # for OPL3-SA driver.");
|
---|
86 | MODULE_PARM_SYNTAX(snd_fm_port, SNDRV_ENABLED ",allows:{{0x388}},dialog:list");
|
---|
87 | MODULE_PARM(snd_midi_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
|
---|
88 | MODULE_PARM_DESC(snd_midi_port, "MIDI port # for OPL3-SA driver.");
|
---|
89 | MODULE_PARM_SYNTAX(snd_midi_port, SNDRV_ENABLED ",allows:{{0x330},{0x300}},dialog:list");
|
---|
90 | MODULE_PARM(snd_irq, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
91 | MODULE_PARM_DESC(snd_irq, "IRQ # for OPL3-SA driver.");
|
---|
92 | MODULE_PARM_SYNTAX(snd_irq, SNDRV_ENABLED ",allows:{{0},{1},{3},{5},{9},{11},{12},{15}},dialog:list");
|
---|
93 | MODULE_PARM(snd_dma1, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
94 | MODULE_PARM_DESC(snd_dma1, "DMA1 # for OPL3-SA driver.");
|
---|
95 | MODULE_PARM_SYNTAX(snd_dma1, SNDRV_ENABLED ",allows:{{1},{3},{5},{6},{7}},dialog:list");
|
---|
96 | MODULE_PARM(snd_dma2, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
|
---|
97 | MODULE_PARM_DESC(snd_dma2, "DMA2 # for OPL3-SA driver.");
|
---|
98 | MODULE_PARM_SYNTAX(snd_dma2, SNDRV_ENABLED ",allows:{{1},{3},{5},{6},{7}},dialog:list");
|
---|
99 | MODULE_PARM(snd_opl3sa3_ymode, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); /* SL Added */
|
---|
100 | MODULE_PARM_DESC(snd_opl3sa3_ymode, "Speaker size selection for 3D Enhancement mode: Desktop/Large Notebook/Small Notebook/HiFi.");
|
---|
101 | MODULE_PARM_SYNTAX(snd_opl3sa3_ymode, SNDRV_ENABLED ",allows:{{0,3}},dialog:list"); /* SL Added */
|
---|
102 |
|
---|
103 | struct snd_opl3sa {
|
---|
104 | snd_card_t *card;
|
---|
105 | int version; /* 2 or 3 */
|
---|
106 | unsigned long port; /* control port */
|
---|
107 | struct resource *res_port; /* control port resource */
|
---|
108 | int irq;
|
---|
109 | int single_dma;
|
---|
110 | spinlock_t reg_lock;
|
---|
111 | snd_hwdep_t *synth;
|
---|
112 | snd_rawmidi_t *rmidi;
|
---|
113 | cs4231_t *cs4231;
|
---|
114 | #ifdef __ISAPNP__
|
---|
115 | struct isapnp_dev *dev;
|
---|
116 | #endif
|
---|
117 | unsigned char ctlregs[0x20];
|
---|
118 | int ymode; /* SL added */
|
---|
119 | snd_kcontrol_t *master_switch;
|
---|
120 | snd_kcontrol_t *master_volume;
|
---|
121 | };
|
---|
122 |
|
---|
123 | static snd_card_t *snd_opl3sa_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
|
---|
124 |
|
---|
125 | #ifdef __ISAPNP__
|
---|
126 |
|
---|
127 | static struct isapnp_card *snd_opl3sa2_isapnp_cards[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PTR;
|
---|
128 | static const struct isapnp_card_id *snd_opl3sa2_isapnp_id[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PTR;
|
---|
129 |
|
---|
130 | #ifdef TARGET_OS2
|
---|
131 | #define ISAPNP_OPL3SA2(_va, _vb, _vc, _device, _function) \
|
---|
132 | { \
|
---|
133 | 0, ISAPNP_CARD_ID(_va, _vb, _vc, _device), \
|
---|
134 | { ISAPNP_DEVICE_ID(_va, _vb, _vc, _function), } \
|
---|
135 | }
|
---|
136 | #else
|
---|
137 | #define ISAPNP_OPL3SA2(_va, _vb, _vc, _device, _function) \
|
---|
138 | { \
|
---|
139 | ISAPNP_CARD_ID(_va, _vb, _vc, _device), \
|
---|
140 | devs : { ISAPNP_DEVICE_ID(_va, _vb, _vc, _function), } \
|
---|
141 | }
|
---|
142 | #endif
|
---|
143 |
|
---|
144 | static struct isapnp_card_id snd_opl3sa2_pnpids[] __devinitdata = {
|
---|
145 | /* Yamaha YMF719E-S (Genius Sound Maker 3DX) */
|
---|
146 | ISAPNP_OPL3SA2('Y','M','H',0x0020,0x0021),
|
---|
147 | /* Yamaha OPL3-SA3 (integrated on Intel's Pentium II AL440LX motherboard) */
|
---|
148 | ISAPNP_OPL3SA2('Y','M','H',0x0030,0x0021),
|
---|
149 | /* ??? */
|
---|
150 | ISAPNP_OPL3SA2('Y','M','H',0x0800,0x0021),
|
---|
151 | /* NeoMagic MagicWave 3DX */
|
---|
152 | ISAPNP_OPL3SA2('N','M','X',0x2200,0x2210),
|
---|
153 | /* --- */
|
---|
154 | { ISAPNP_CARD_END, } /* end */
|
---|
155 | };
|
---|
156 |
|
---|
157 | ISAPNP_CARD_TABLE(snd_opl3sa2_pnpids);
|
---|
158 |
|
---|
159 | #endif /* __ISAPNP__ */
|
---|
160 |
|
---|
161 | static unsigned char snd_opl3sa_read(unsigned long port, unsigned char reg)
|
---|
162 | {
|
---|
163 | unsigned long flags;
|
---|
164 | unsigned char result;
|
---|
165 |
|
---|
166 | save_flags(flags);
|
---|
167 | cli();
|
---|
168 | #if 0
|
---|
169 | outb(0x1d, port); /* password */
|
---|
170 | printk("read [0x%lx] = 0x%x\n", port, inb(port));
|
---|
171 | #endif
|
---|
172 | outb(reg, port); /* register */
|
---|
173 | result = inb(port + 1);
|
---|
174 | restore_flags(flags);
|
---|
175 | #if 0
|
---|
176 | printk("read [0x%lx] = 0x%x [0x%x]\n", port, result, inb(port));
|
---|
177 | #endif
|
---|
178 | return result;
|
---|
179 | }
|
---|
180 |
|
---|
181 | static void snd_opl3sa_write(unsigned long port,
|
---|
182 | unsigned char reg, unsigned char value)
|
---|
183 | {
|
---|
184 | unsigned long flags;
|
---|
185 |
|
---|
186 | save_flags(flags);
|
---|
187 | cli();
|
---|
188 | #if 0
|
---|
189 | outb(0x1d, port); /* password */
|
---|
190 | #endif
|
---|
191 | outb(reg, port); /* register */
|
---|
192 | outb(value, port + 1);
|
---|
193 | restore_flags(flags);
|
---|
194 | }
|
---|
195 |
|
---|
196 | static int __init snd_opl3sa_detect(struct snd_opl3sa *oplcard)
|
---|
197 | {
|
---|
198 | snd_card_t *card;
|
---|
199 | unsigned long port;
|
---|
200 | unsigned char tmp, tmp1;
|
---|
201 | char str[2];
|
---|
202 |
|
---|
203 | card = oplcard->card;
|
---|
204 | port = oplcard->port;
|
---|
205 | if ((oplcard->res_port = request_region(port, 2, "OPL3-SA control")) == NULL)
|
---|
206 | return -EBUSY;
|
---|
207 | // snd_printk("REG 0A = 0x%x\n", snd_opl3sa_read(port, 0x0a));
|
---|
208 | oplcard->version = 0;
|
---|
209 | tmp = snd_opl3sa_read(port, 0x0a);
|
---|
210 | if (tmp == 0xff) {
|
---|
211 | snd_printd("OPL3-SA [0x%lx] detect = 0x%x\n", port, tmp);
|
---|
212 | return -ENODEV;
|
---|
213 | }
|
---|
214 | switch (tmp & 0x07) {
|
---|
215 | case 0x01:
|
---|
216 | oplcard->version = 2;
|
---|
217 | break;
|
---|
218 | default:
|
---|
219 | oplcard->version = 3;
|
---|
220 | /* 0x02 - standard */
|
---|
221 | /* 0x03 - YM715B */
|
---|
222 | /* 0x04 - YM719 - OPL-SA4? */
|
---|
223 | /* 0x05 - OPL3-SA3 - Libretto 100 */
|
---|
224 | break;
|
---|
225 | }
|
---|
226 | str[0] = oplcard->version + '0';
|
---|
227 | str[1] = 0;
|
---|
228 | strcat(card->shortname, str);
|
---|
229 | snd_opl3sa_write(port, 0x0a, tmp ^ 7);
|
---|
230 | if ((tmp1 = snd_opl3sa_read(port, 0x0a)) != tmp) {
|
---|
231 | snd_printd("OPL3-SA [0x%lx] detect (1) = 0x%x (0x%x)\n", port, tmp, tmp1);
|
---|
232 | return -ENODEV;
|
---|
233 | }
|
---|
234 | /* try if the MIC register is accesible */
|
---|
235 | tmp = snd_opl3sa_read(port, 0x09);
|
---|
236 | snd_opl3sa_write(port, 0x09, 0x8a);
|
---|
237 | if (((tmp1 = snd_opl3sa_read(port, 0x09)) & 0x9f) != 0x8a) {
|
---|
238 | snd_printd("OPL3-SA [0x%lx] detect (2) = 0x%x (0x%x)\n", port, tmp, tmp1);
|
---|
239 | return -ENODEV;
|
---|
240 | }
|
---|
241 | snd_opl3sa_write(port, 0x09, 0x9f);
|
---|
242 | /* initialization */
|
---|
243 | snd_opl3sa_write(port, 0x01, 0x00); /* Power Management - default */
|
---|
244 | if (oplcard->version > 2) { /* SL Added */
|
---|
245 | snd_opl3sa_write(port, 0x02, (oplcard->ymode << 4)); /* SL Modified - System Control - ymode is bits 4&5 (of 0 to 7) on all but opl3sa2 versions */
|
---|
246 | } else { /* SL Added */
|
---|
247 | snd_opl3sa_write(port, 0x02, 0x00); /* SL Modified - System Control - default for opl3sa2 versions */
|
---|
248 | } /* SL Added */
|
---|
249 | snd_opl3sa_write(port, 0x03, 0x0d); /* Interrupt Channel Configuration - IRQ A = OPL3 + MPU + WSS */
|
---|
250 | if (oplcard->single_dma) {
|
---|
251 | snd_opl3sa_write(port, 0x06, 0x03); /* DMA Configuration - DMA A = WSS-R + WSS-P */
|
---|
252 | } else {
|
---|
253 | snd_opl3sa_write(port, 0x06, 0x21); /* DMA Configuration - DMA B = WSS-R, DMA A = WSS-P */
|
---|
254 | }
|
---|
255 | snd_opl3sa_write(port, 0x0a, 0x80 | (tmp & 7)); /* Miscellaneous - default */
|
---|
256 | if (oplcard->version > 2) {
|
---|
257 | snd_opl3sa_write(port, 0x12, 0x00); /* Digital Block Partial Power Down - default */
|
---|
258 | snd_opl3sa_write(port, 0x13, 0x00); /* Analog Block Partial Power Down - default */
|
---|
259 | }
|
---|
260 | return 0;
|
---|
261 | }
|
---|
262 |
|
---|
263 | static void snd_opl3sa_interrupt(int irq, void *dev_id, struct pt_regs *regs)
|
---|
264 | {
|
---|
265 | unsigned short status;
|
---|
266 | struct snd_opl3sa *oplcard = (struct snd_opl3sa *) dev_id;
|
---|
267 |
|
---|
268 | if (oplcard == NULL || oplcard->card == NULL)
|
---|
269 | return;
|
---|
270 |
|
---|
271 | spin_lock(&oplcard->reg_lock);
|
---|
272 | outb(0x04, oplcard->port); /* register - Interrupt IRQ-A status */
|
---|
273 | status = inb(oplcard->port + 1);
|
---|
274 | spin_unlock(&oplcard->reg_lock);
|
---|
275 |
|
---|
276 | if (status & 0x20)
|
---|
277 | snd_opl3_interrupt(oplcard->synth);
|
---|
278 |
|
---|
279 | if ((status & 0x10) && oplcard->rmidi != NULL)
|
---|
280 | snd_mpu401_uart_interrupt(irq, oplcard->rmidi->private_data, regs);
|
---|
281 |
|
---|
282 | if (status & 0x07) /* TI,CI,PI */
|
---|
283 | snd_cs4231_interrupt(irq, oplcard->cs4231, regs);
|
---|
284 |
|
---|
285 | if (status & 0x40) {
|
---|
286 | /* reading from Master Lch register at 0x07 clears this bit */
|
---|
287 | snd_opl3sa_read(oplcard->port, 0x08);
|
---|
288 | snd_opl3sa_read(oplcard->port, 0x07);
|
---|
289 | snd_ctl_notify(oplcard->card, SNDRV_CTL_EVENT_MASK_VALUE, &oplcard->master_switch->id);
|
---|
290 | snd_ctl_notify(oplcard->card, SNDRV_CTL_EVENT_MASK_VALUE, &oplcard->master_volume->id);
|
---|
291 | }
|
---|
292 | }
|
---|
293 |
|
---|
294 | #ifdef TARGET_OS2
|
---|
295 | #define OPL3SA_SINGLE(xname, xindex, reg, shift, mask, invert) \
|
---|
296 | { SNDRV_CTL_ELEM_IFACE_MIXER, 0, 0, xname, xindex, \
|
---|
297 | 0, 0, snd_opl3sa_info_single, \
|
---|
298 | snd_opl3sa_get_single, snd_opl3sa_put_single, \
|
---|
299 | reg | (shift << 8) | (mask << 16) | (invert << 24) }
|
---|
300 |
|
---|
301 | #else
|
---|
302 | #define OPL3SA_SINGLE(xname, xindex, reg, shift, mask, invert) \
|
---|
303 | { iface: SNDRV_CTL_ELEM_IFACE_MIXER, name: xname, index: xindex, \
|
---|
304 | info: snd_opl3sa_info_single, \
|
---|
305 | get: snd_opl3sa_get_single, put: snd_opl3sa_put_single, \
|
---|
306 | private_value: reg | (shift << 8) | (mask << 16) | (invert << 24) }
|
---|
307 | #endif
|
---|
308 |
|
---|
309 | static int snd_opl3sa_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
|
---|
310 | {
|
---|
311 | int mask = (kcontrol->private_value >> 16) & 0xff;
|
---|
312 |
|
---|
313 | uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
|
---|
314 | uinfo->count = 1;
|
---|
315 | uinfo->value.integer.min = 0;
|
---|
316 | uinfo->value.integer.max = mask;
|
---|
317 | return 0;
|
---|
318 | }
|
---|
319 |
|
---|
320 | int snd_opl3sa_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
|
---|
321 | {
|
---|
322 | struct snd_opl3sa *oplcard = (struct snd_opl3sa *)_snd_kcontrol_chip(kcontrol);
|
---|
323 | unsigned long flags;
|
---|
324 | int reg = kcontrol->private_value & 0xff;
|
---|
325 | int shift = (kcontrol->private_value >> 8) & 0xff;
|
---|
326 | int mask = (kcontrol->private_value >> 16) & 0xff;
|
---|
327 | int invert = (kcontrol->private_value >> 24) & 0xff;
|
---|
328 |
|
---|
329 | spin_lock_irqsave(&oplcard->reg_lock, flags);
|
---|
330 | ucontrol->value.integer.value[0] = (oplcard->ctlregs[reg] >> shift) & mask;
|
---|
331 | spin_unlock_irqrestore(&oplcard->reg_lock, flags);
|
---|
332 | if (invert)
|
---|
333 | ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0];
|
---|
334 | return 0;
|
---|
335 | }
|
---|
336 |
|
---|
337 | int snd_opl3sa_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
|
---|
338 | {
|
---|
339 | struct snd_opl3sa *oplcard = (struct snd_opl3sa *)_snd_kcontrol_chip(kcontrol);
|
---|
340 | unsigned long flags;
|
---|
341 | int reg = kcontrol->private_value & 0xff;
|
---|
342 | int shift = (kcontrol->private_value >> 8) & 0xff;
|
---|
343 | int mask = (kcontrol->private_value >> 16) & 0xff;
|
---|
344 | int invert = (kcontrol->private_value >> 24) & 0xff;
|
---|
345 | int change;
|
---|
346 | unsigned short val, oval;
|
---|
347 |
|
---|
348 | val = (ucontrol->value.integer.value[0] & mask);
|
---|
349 | if (invert)
|
---|
350 | val = mask - val;
|
---|
351 | val <<= shift;
|
---|
352 | spin_lock_irqsave(&oplcard->reg_lock, flags);
|
---|
353 | oval = oplcard->ctlregs[reg];
|
---|
354 | val = (oval & ~(mask << shift)) | val;
|
---|
355 | change = val != oval;
|
---|
356 | snd_opl3sa_write(oplcard->port, reg, oplcard->ctlregs[reg] = val);
|
---|
357 | spin_unlock_irqrestore(&oplcard->reg_lock, flags);
|
---|
358 | return change;
|
---|
359 | }
|
---|
360 |
|
---|
361 | #ifdef TARGET_OS2
|
---|
362 | #define OPL3SA_DOUBLE(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert) \
|
---|
363 | { SNDRV_CTL_ELEM_IFACE_MIXER, 0, 0, xname, xindex, \
|
---|
364 | 0, 0, snd_opl3sa_info_double, \
|
---|
365 | snd_opl3sa_get_double, snd_opl3sa_put_double, \
|
---|
366 | left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) }
|
---|
367 |
|
---|
368 | #else
|
---|
369 | #define OPL3SA_DOUBLE(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert) \
|
---|
370 | { iface: SNDRV_CTL_ELEM_IFACE_MIXER, name: xname, index: xindex, \
|
---|
371 | info: snd_opl3sa_info_double, \
|
---|
372 | get: snd_opl3sa_get_double, put: snd_opl3sa_put_double, \
|
---|
373 | private_value: left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) }
|
---|
374 | #endif
|
---|
375 |
|
---|
376 | int snd_opl3sa_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
|
---|
377 | {
|
---|
378 | int mask = (kcontrol->private_value >> 24) & 0xff;
|
---|
379 |
|
---|
380 | uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
|
---|
381 | uinfo->count = 2;
|
---|
382 | uinfo->value.integer.min = 0;
|
---|
383 | uinfo->value.integer.max = mask;
|
---|
384 | return 0;
|
---|
385 | }
|
---|
386 |
|
---|
387 | int snd_opl3sa_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
|
---|
388 | {
|
---|
389 | struct snd_opl3sa *oplcard = (struct snd_opl3sa *)_snd_kcontrol_chip(kcontrol);
|
---|
390 | unsigned long flags;
|
---|
391 | int left_reg = kcontrol->private_value & 0xff;
|
---|
392 | int right_reg = (kcontrol->private_value >> 8) & 0xff;
|
---|
393 | int shift_left = (kcontrol->private_value >> 16) & 0x07;
|
---|
394 | int shift_right = (kcontrol->private_value >> 19) & 0x07;
|
---|
395 | int mask = (kcontrol->private_value >> 24) & 0xff;
|
---|
396 | int invert = (kcontrol->private_value >> 22) & 1;
|
---|
397 |
|
---|
398 | spin_lock_irqsave(&oplcard->reg_lock, flags);
|
---|
399 | ucontrol->value.integer.value[0] = (oplcard->ctlregs[left_reg] >> shift_left) & mask;
|
---|
400 | ucontrol->value.integer.value[1] = (oplcard->ctlregs[right_reg] >> shift_right) & mask;
|
---|
401 | spin_unlock_irqrestore(&oplcard->reg_lock, flags);
|
---|
402 | if (invert) {
|
---|
403 | ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0];
|
---|
404 | ucontrol->value.integer.value[1] = mask - ucontrol->value.integer.value[1];
|
---|
405 | }
|
---|
406 | return 0;
|
---|
407 | }
|
---|
408 |
|
---|
409 | int snd_opl3sa_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
|
---|
410 | {
|
---|
411 | struct snd_opl3sa *oplcard = (struct snd_opl3sa *)_snd_kcontrol_chip(kcontrol);
|
---|
412 | unsigned long flags;
|
---|
413 | int left_reg = kcontrol->private_value & 0xff;
|
---|
414 | int right_reg = (kcontrol->private_value >> 8) & 0xff;
|
---|
415 | int shift_left = (kcontrol->private_value >> 16) & 0x07;
|
---|
416 | int shift_right = (kcontrol->private_value >> 19) & 0x07;
|
---|
417 | int mask = (kcontrol->private_value >> 24) & 0xff;
|
---|
418 | int invert = (kcontrol->private_value >> 22) & 1;
|
---|
419 | int change;
|
---|
420 | unsigned short val1, val2, oval1, oval2;
|
---|
421 |
|
---|
422 | val1 = ucontrol->value.integer.value[0] & mask;
|
---|
423 | val2 = ucontrol->value.integer.value[1] & mask;
|
---|
424 | if (invert) {
|
---|
425 | val1 = mask - val1;
|
---|
426 | val2 = mask - val2;
|
---|
427 | }
|
---|
428 | val1 <<= shift_left;
|
---|
429 | val2 <<= shift_right;
|
---|
430 | spin_lock_irqsave(&oplcard->reg_lock, flags);
|
---|
431 | if (left_reg != right_reg) {
|
---|
432 | oval1 = oplcard->ctlregs[left_reg];
|
---|
433 | oval2 = oplcard->ctlregs[right_reg];
|
---|
434 | val1 = (oval1 & ~(mask << shift_left)) | val1;
|
---|
435 | val2 = (oval2 & ~(mask << shift_right)) | val2;
|
---|
436 | change = val1 != oval1 || val2 != oval2;
|
---|
437 | snd_opl3sa_write(oplcard->port, left_reg, oplcard->ctlregs[left_reg] = val1);
|
---|
438 | snd_opl3sa_write(oplcard->port, right_reg, oplcard->ctlregs[right_reg] = val2);
|
---|
439 | } else {
|
---|
440 | oval1 = oplcard->ctlregs[left_reg];
|
---|
441 | val1 = (oval1 & ~((mask << shift_left) | (mask << shift_right))) | val1 | val2;
|
---|
442 | change = val1 != oval1;
|
---|
443 | snd_opl3sa_write(oplcard->port, left_reg, oplcard->ctlregs[left_reg] = val1);
|
---|
444 | }
|
---|
445 | spin_unlock_irqrestore(&oplcard->reg_lock, flags);
|
---|
446 | return change;
|
---|
447 | }
|
---|
448 |
|
---|
449 | #define OPL3SA_CONTROLS (sizeof(snd_opl3sa_controls)/sizeof(snd_kcontrol_new_t))
|
---|
450 |
|
---|
451 | static snd_kcontrol_new_t snd_opl3sa_controls[] = {
|
---|
452 | OPL3SA_DOUBLE("Master Playback Switch", 0, 0x07, 0x08, 7, 7, 1, 1),
|
---|
453 | OPL3SA_DOUBLE("Master Playback Volume", 0, 0x07, 0x08, 0, 0, 15, 1),
|
---|
454 | OPL3SA_SINGLE("Mic Playback Switch", 0, 0x09, 7, 1, 1),
|
---|
455 | OPL3SA_SINGLE("Mic Playback Volume", 0, 0x09, 0, 31, 1)
|
---|
456 | };
|
---|
457 |
|
---|
458 | #define OPL3SA_TONE_CONTROLS (sizeof(snd_opl3sa_tone_controls)/sizeof(snd_kcontrol_new_t))
|
---|
459 |
|
---|
460 | static snd_kcontrol_new_t snd_opl3sa_tone_controls[] = {
|
---|
461 | OPL3SA_DOUBLE("3D Control - Wide", 0, 0x14, 0x14, 4, 0, 7, 0),
|
---|
462 | OPL3SA_DOUBLE("Tone Control - Bass", 0, 0x15, 0x15, 4, 0, 7, 0),
|
---|
463 | OPL3SA_DOUBLE("Tone Control - Treble", 0, 0x16, 0x16, 4, 0, 7, 0)
|
---|
464 | };
|
---|
465 |
|
---|
466 | static void snd_opl3sa_master_free(snd_kcontrol_t *kcontrol)
|
---|
467 | {
|
---|
468 | struct snd_opl3sa *oplcard = (struct snd_opl3sa *)_snd_kcontrol_chip(kcontrol);
|
---|
469 |
|
---|
470 | oplcard->master_switch = NULL;
|
---|
471 | oplcard->master_volume = NULL;
|
---|
472 | }
|
---|
473 |
|
---|
474 | static int __init snd_opl3sa_mixer(struct snd_opl3sa *oplcard)
|
---|
475 | {
|
---|
476 | snd_card_t *card = oplcard->card;
|
---|
477 | snd_ctl_elem_id_t id1, id2;
|
---|
478 | snd_kcontrol_t *kctl;
|
---|
479 | int idx, err;
|
---|
480 |
|
---|
481 | memset(&id1, 0, sizeof(id1));
|
---|
482 | memset(&id2, 0, sizeof(id2));
|
---|
483 | id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
|
---|
484 | /* reassign AUX0 to CD */
|
---|
485 | strcpy(id1.name, "Aux Playback Switch");
|
---|
486 | strcpy(id2.name, "CD Playback Switch");
|
---|
487 | if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0)
|
---|
488 | return err;
|
---|
489 | strcpy(id1.name, "Aux Playback Volume");
|
---|
490 | strcpy(id2.name, "CD Playback Volume");
|
---|
491 | if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0)
|
---|
492 | return err;
|
---|
493 | /* reassign AUX1 to FM */
|
---|
494 | strcpy(id1.name, "Aux Playback Switch"); id1.index = 1;
|
---|
495 | strcpy(id2.name, "FM Playback Switch");
|
---|
496 | if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0)
|
---|
497 | return err;
|
---|
498 | strcpy(id1.name, "Aux Playback Volume");
|
---|
499 | strcpy(id2.name, "FM Playback Volume");
|
---|
500 | if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0)
|
---|
501 | return err;
|
---|
502 | /* add OPL3SA2 controls */
|
---|
503 | for (idx = 0; idx < OPL3SA_CONTROLS; idx++) {
|
---|
504 | if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_opl3sa_controls[idx], oplcard))) < 0)
|
---|
505 | return err;
|
---|
506 | switch (idx) {
|
---|
507 | case 0: oplcard->master_switch = kctl; kctl->private_free = snd_opl3sa_master_free; break;
|
---|
508 | case 1: oplcard->master_volume = kctl; kctl->private_free = snd_opl3sa_master_free; break;
|
---|
509 | }
|
---|
510 | }
|
---|
511 | if (oplcard->version > 2) {
|
---|
512 | for (idx = 0; idx < OPL3SA_TONE_CONTROLS; idx++)
|
---|
513 | if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_opl3sa_tone_controls[idx], oplcard))) < 0)
|
---|
514 | return err;
|
---|
515 | }
|
---|
516 | return 0;
|
---|
517 | }
|
---|
518 |
|
---|
519 | #ifdef __ISAPNP__
|
---|
520 | static int __init snd_opl3sa_isapnp(int dev, struct snd_opl3sa *oplcard)
|
---|
521 | {
|
---|
522 | const struct isapnp_card_id *id = snd_opl3sa2_isapnp_id[dev];
|
---|
523 | struct isapnp_card *card = snd_opl3sa2_isapnp_cards[dev];
|
---|
524 | struct isapnp_dev *pdev;
|
---|
525 |
|
---|
526 | oplcard->dev = isapnp_find_dev(card, id->devs[0].vendor, id->devs[0].function, NULL);
|
---|
527 | if (oplcard->dev->active) {
|
---|
528 | oplcard->dev = NULL;
|
---|
529 | return -EBUSY;
|
---|
530 | }
|
---|
531 | /* PnP initialization */
|
---|
532 | pdev = oplcard->dev;
|
---|
533 | if (pdev->prepare(pdev)<0)
|
---|
534 | return -EAGAIN;
|
---|
535 | if (snd_sb_port[dev] != SNDRV_AUTO_PORT)
|
---|
536 | isapnp_resource_change(&pdev->resource[0], snd_sb_port[dev], 16);
|
---|
537 | if (snd_wss_port[dev] != SNDRV_AUTO_PORT)
|
---|
538 | isapnp_resource_change(&pdev->resource[1], snd_wss_port[dev], 8);
|
---|
539 | if (snd_fm_port[dev] != SNDRV_AUTO_PORT)
|
---|
540 | isapnp_resource_change(&pdev->resource[2], snd_fm_port[dev], 4);
|
---|
541 | if (snd_midi_port[dev] != SNDRV_AUTO_PORT)
|
---|
542 | isapnp_resource_change(&pdev->resource[3], snd_midi_port[dev], 2);
|
---|
543 | if (snd_port[dev] != SNDRV_AUTO_PORT)
|
---|
544 | isapnp_resource_change(&pdev->resource[4], snd_port[dev], 2);
|
---|
545 | if (snd_dma1[dev] != SNDRV_AUTO_DMA)
|
---|
546 | isapnp_resource_change(&pdev->dma_resource[0], snd_dma1[dev], 1);
|
---|
547 | if (snd_dma2[dev] != SNDRV_AUTO_DMA)
|
---|
548 | isapnp_resource_change(&pdev->dma_resource[1], snd_dma2[dev], 1);
|
---|
549 | if (snd_irq[dev] != SNDRV_AUTO_IRQ)
|
---|
550 | isapnp_resource_change(&pdev->irq_resource[0], snd_irq[dev], 1);
|
---|
551 | if (pdev->activate(pdev)<0) {
|
---|
552 | snd_printk("isapnp configure failure (out of resources?)\n");
|
---|
553 | return -EBUSY;
|
---|
554 | }
|
---|
555 | snd_sb_port[dev] = pdev->resource[0].start;
|
---|
556 | snd_wss_port[dev] = pdev->resource[1].start;
|
---|
557 | snd_fm_port[dev] = pdev->resource[2].start;
|
---|
558 | snd_midi_port[dev] = pdev->resource[3].start;
|
---|
559 | snd_port[dev] = pdev->resource[4].start;
|
---|
560 | snd_dma1[dev] = pdev->dma_resource[0].start;
|
---|
561 | snd_dma2[dev] = pdev->dma_resource[1].start;
|
---|
562 | snd_irq[dev] = pdev->irq_resource[0].start;
|
---|
563 | snd_printdd("isapnp OPL3-SA: sb port=0x%lx, wss port=0x%lx, fm port=0x%lx, midi port=0x%lx\n",
|
---|
564 | snd_sb_port[dev], snd_wss_port[dev], snd_fm_port[dev], snd_midi_port[dev]);
|
---|
565 | snd_printdd("isapnp OPL3-SA: control port=0x%lx, dma1=%i, dma2=%i, irq=%i\n",
|
---|
566 | snd_port[dev], snd_dma1[dev], snd_dma2[dev], snd_irq[dev]);
|
---|
567 | return 0;
|
---|
568 | }
|
---|
569 |
|
---|
570 | static void snd_opl3sa_deactivate(struct snd_opl3sa *oplcard)
|
---|
571 | {
|
---|
572 | if (oplcard->dev) {
|
---|
573 | oplcard->dev->deactivate(oplcard->dev);
|
---|
574 | oplcard->dev = NULL;
|
---|
575 | }
|
---|
576 | }
|
---|
577 | #endif /* __ISAPNP__ */
|
---|
578 |
|
---|
579 | static void snd_card_opl3sa2_free(snd_card_t *card)
|
---|
580 | {
|
---|
581 | struct snd_opl3sa *acard = (struct snd_opl3sa *)card->private_data;
|
---|
582 |
|
---|
583 | if (acard) {
|
---|
584 | #ifdef __ISAPNP__
|
---|
585 | snd_opl3sa_deactivate(acard);
|
---|
586 | #endif
|
---|
587 | if (acard->irq >= 0)
|
---|
588 | free_irq(acard->irq, (void *)acard);
|
---|
589 | if (acard->res_port)
|
---|
590 | release_resource(acard->res_port);
|
---|
591 | }
|
---|
592 | }
|
---|
593 |
|
---|
594 | static int __init snd_opl3sa_probe(int dev)
|
---|
595 | {
|
---|
596 | int irq, dma1, dma2;
|
---|
597 | snd_card_t *card;
|
---|
598 | struct snd_opl3sa *oplcard;
|
---|
599 | cs4231_t *cs4231;
|
---|
600 | opl3_t *opl3;
|
---|
601 | int err;
|
---|
602 |
|
---|
603 | #ifdef __ISAPNP__
|
---|
604 | if (!snd_isapnp[dev]) {
|
---|
605 | #endif
|
---|
606 | if (snd_port[dev] == SNDRV_AUTO_PORT) {
|
---|
607 | snd_printk("specify snd_port\n");
|
---|
608 | return -EINVAL;
|
---|
609 | }
|
---|
610 | if (snd_wss_port[dev] == SNDRV_AUTO_PORT) {
|
---|
611 | snd_printk("specify snd_wss_port\n");
|
---|
612 | return -EINVAL;
|
---|
613 | }
|
---|
614 | if (snd_fm_port[dev] == SNDRV_AUTO_PORT) {
|
---|
615 | snd_printk("specify snd_fm_port\n");
|
---|
616 | return -EINVAL;
|
---|
617 | }
|
---|
618 | if (snd_midi_port[dev] == SNDRV_AUTO_PORT) {
|
---|
619 | snd_printk("specify snd_midi_port\n");
|
---|
620 | return -EINVAL;
|
---|
621 | }
|
---|
622 | #ifdef __ISAPNP__
|
---|
623 | }
|
---|
624 | #endif
|
---|
625 | card = snd_card_new(snd_index[dev], snd_id[dev], THIS_MODULE,
|
---|
626 | sizeof(struct snd_opl3sa));
|
---|
627 | if (card == NULL)
|
---|
628 | return -ENOMEM;
|
---|
629 | oplcard = (struct snd_opl3sa *)card->private_data;
|
---|
630 | oplcard->irq = -1;
|
---|
631 | card->private_free = snd_card_opl3sa2_free;
|
---|
632 | strcpy(card->driver, "OPL3SA2");
|
---|
633 | strcpy(card->shortname, "Yamaha OPL3-SA2");
|
---|
634 | #ifdef __ISAPNP__
|
---|
635 | if (snd_isapnp[dev] && snd_opl3sa_isapnp(dev, oplcard) < 0) {
|
---|
636 | snd_card_free(card);
|
---|
637 | return -EBUSY;
|
---|
638 | }
|
---|
639 | #endif
|
---|
640 | oplcard->ymode = snd_opl3sa3_ymode[dev] & 0x03 ; /* SL Added - initialise this card from supplied (or default) parameter*/
|
---|
641 | oplcard->card = card;
|
---|
642 | oplcard->port = snd_port[dev];
|
---|
643 | irq = snd_irq[dev];
|
---|
644 | dma1 = snd_dma1[dev];
|
---|
645 | dma2 = snd_dma2[dev];
|
---|
646 | if (dma2 < 0)
|
---|
647 | oplcard->single_dma = 1;
|
---|
648 | if ((snd_opl3sa_detect(oplcard)) < 0) {
|
---|
649 | snd_card_free(card);
|
---|
650 | return -ENODEV;
|
---|
651 | }
|
---|
652 | if (request_irq(irq, snd_opl3sa_interrupt, SA_INTERRUPT, "OPL3-SA2/3", (void *)oplcard)) {
|
---|
653 | snd_card_free(card);
|
---|
654 | return -ENODEV;
|
---|
655 | }
|
---|
656 | oplcard->irq = irq;
|
---|
657 | if ((err = snd_cs4231_create(card,
|
---|
658 | snd_wss_port[dev] + 4, -1,
|
---|
659 | irq, dma1, dma2,
|
---|
660 | CS4231_HW_OPL3SA2,
|
---|
661 | CS4231_HWSHARE_IRQ,
|
---|
662 | &cs4231)) < 0) {
|
---|
663 | snd_printd("Oops, WSS not detected at 0x%lx\n", snd_wss_port[dev] + 4);
|
---|
664 | snd_card_free(card);
|
---|
665 | return err;
|
---|
666 | }
|
---|
667 | oplcard->cs4231 = cs4231;
|
---|
668 | if ((err = snd_cs4231_pcm(cs4231, 0, NULL)) < 0) {
|
---|
669 | snd_card_free(card);
|
---|
670 | return err;
|
---|
671 | }
|
---|
672 | if ((err = snd_cs4231_mixer(cs4231)) < 0) {
|
---|
673 | snd_card_free(card);
|
---|
674 | return err;
|
---|
675 | }
|
---|
676 | if ((err = snd_opl3sa_mixer(oplcard)) < 0) {
|
---|
677 | snd_card_free(card);
|
---|
678 | return err;
|
---|
679 | }
|
---|
680 | if ((err = snd_cs4231_timer(cs4231, 0, NULL)) < 0) {
|
---|
681 | snd_card_free(card);
|
---|
682 | return err;
|
---|
683 | }
|
---|
684 | if (snd_fm_port[dev] >= 0x340 && snd_fm_port[dev] < 0x400) {
|
---|
685 | if ((err = snd_opl3_create(card, snd_fm_port[dev],
|
---|
686 | snd_fm_port[dev] + 2,
|
---|
687 | OPL3_HW_OPL3, 0, &opl3)) < 0) {
|
---|
688 | snd_card_free(card);
|
---|
689 | return err;
|
---|
690 | }
|
---|
691 | if ((err = snd_opl3_timer_new(opl3, 1, 2)) < 0) {
|
---|
692 | snd_card_free(card);
|
---|
693 | return err;
|
---|
694 | }
|
---|
695 | if ((err = snd_opl3_hwdep_new(opl3, 0, 1, &oplcard->synth)) < 0) {
|
---|
696 | snd_card_free(card);
|
---|
697 | return err;
|
---|
698 | }
|
---|
699 | }
|
---|
700 | if (snd_midi_port[dev] >= 0x300 && snd_midi_port[dev] < 0x340) {
|
---|
701 | if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_OPL3SA2,
|
---|
702 | snd_midi_port[dev], 0,
|
---|
703 | irq, 0, &oplcard->rmidi)) < 0) {
|
---|
704 | snd_card_free(card);
|
---|
705 | return err;
|
---|
706 | }
|
---|
707 | }
|
---|
708 | sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d",
|
---|
709 | card->shortname, oplcard->port, irq, dma1);
|
---|
710 | if (dma2 >= 0)
|
---|
711 | sprintf(card->longname + strlen(card->longname), "&%d", dma2);
|
---|
712 |
|
---|
713 | if ((err = snd_card_register(card)) < 0) {
|
---|
714 | snd_card_free(card);
|
---|
715 | return err;
|
---|
716 | }
|
---|
717 | snd_opl3sa_cards[dev] = card;
|
---|
718 | return 0;
|
---|
719 | }
|
---|
720 |
|
---|
721 | #ifdef __ISAPNP__
|
---|
722 | static int __init snd_opl3sa2_isapnp_detect(struct isapnp_card *card,
|
---|
723 | const struct isapnp_card_id *id)
|
---|
724 | {
|
---|
725 | static int dev = 0;
|
---|
726 | int res;
|
---|
727 |
|
---|
728 | for ( ; dev < SNDRV_CARDS; dev++) {
|
---|
729 | if (!snd_enable[dev])
|
---|
730 | continue;
|
---|
731 | snd_opl3sa2_isapnp_cards[dev] = card;
|
---|
732 | snd_opl3sa2_isapnp_id[dev] = id;
|
---|
733 | res = snd_opl3sa_probe(dev);
|
---|
734 | if (res < 0)
|
---|
735 | return res;
|
---|
736 | dev++;
|
---|
737 | return 0;
|
---|
738 | }
|
---|
739 | return -ENODEV;
|
---|
740 | }
|
---|
741 | #endif /* __ISAPNP__ */
|
---|
742 |
|
---|
743 | static int __init alsa_card_opl3sa2_init(void)
|
---|
744 | {
|
---|
745 | int dev, cards = 0;
|
---|
746 |
|
---|
747 | for (dev = 0; dev < SNDRV_CARDS; dev++) {
|
---|
748 | if (!snd_enable[dev])
|
---|
749 | continue;
|
---|
750 | #ifdef __ISAPNP__
|
---|
751 | if (snd_isapnp[dev])
|
---|
752 | continue;
|
---|
753 | #endif
|
---|
754 | if (snd_opl3sa_probe(dev) >= 0)
|
---|
755 | cards++;
|
---|
756 | }
|
---|
757 | #ifdef __ISAPNP__
|
---|
758 | cards += isapnp_probe_cards(snd_opl3sa2_pnpids, snd_opl3sa2_isapnp_detect);
|
---|
759 | #endif
|
---|
760 | if (!cards) {
|
---|
761 | #ifdef MODULE
|
---|
762 | snd_printk("Yamaha OPL3-SA soundcard not found or device busy\n");
|
---|
763 | #endif
|
---|
764 | return -ENODEV;
|
---|
765 | }
|
---|
766 | return 0;
|
---|
767 | }
|
---|
768 |
|
---|
769 | static void __exit alsa_card_opl3sa2_exit(void)
|
---|
770 | {
|
---|
771 | int idx;
|
---|
772 |
|
---|
773 | for (idx = 0; idx < SNDRV_CARDS; idx++)
|
---|
774 | snd_card_free(snd_opl3sa_cards[idx]);
|
---|
775 | }
|
---|
776 |
|
---|
777 | module_init(alsa_card_opl3sa2_init)
|
---|
778 | module_exit(alsa_card_opl3sa2_exit)
|
---|
779 |
|
---|
780 | #ifndef MODULE
|
---|
781 |
|
---|
782 | /* format is: snd-card-opl3sa2=snd_enable,snd_index,snd_id,snd_isapnp,
|
---|
783 | snd_port,snd_sb_port,snd_wss_port,snd_fm_port,
|
---|
784 | snd_midi_port,snd_irq,snd_dma1,snd_dma2,
|
---|
785 | snd_opl3sa3_ymode */
|
---|
786 |
|
---|
787 | static int __init alsa_card_opl3sa2_setup(char *str)
|
---|
788 | {
|
---|
789 | static unsigned __initdata nr_dev = 0;
|
---|
790 | int __attribute__ ((__unused__)) pnp = INT_MAX;
|
---|
791 |
|
---|
792 | if (nr_dev >= SNDRV_CARDS)
|
---|
793 | return 0;
|
---|
794 | (void)(get_option(&str,&snd_enable[nr_dev]) == 2 &&
|
---|
795 | get_option(&str,&snd_index[nr_dev]) == 2 &&
|
---|
796 | get_id(&str,&snd_id[nr_dev]) == 2 &&
|
---|
797 | get_option(&str,&pnp) == 2 &&
|
---|
798 | get_option(&str,(int *)&snd_port[nr_dev]) == 2 &&
|
---|
799 | get_option(&str,(int *)&snd_sb_port[nr_dev]) == 2 &&
|
---|
800 | get_option(&str,(int *)&snd_wss_port[nr_dev]) == 2 &&
|
---|
801 | get_option(&str,(int *)&snd_fm_port[nr_dev]) == 2 &&
|
---|
802 | get_option(&str,(int *)&snd_midi_port[nr_dev]) == 2 &&
|
---|
803 | get_option(&str,&snd_irq[nr_dev]) == 2 &&
|
---|
804 | get_option(&str,&snd_dma1[nr_dev]) == 2 &&
|
---|
805 | get_option(&str,&snd_dma2[nr_dev]) == 2 &&
|
---|
806 | get_option(&str,&snd_opl3sa3_ymode[nr_dev]) == 2);
|
---|
807 | #ifdef __ISAPNP__
|
---|
808 | if (pnp != INT_MAX)
|
---|
809 | snd_isapnp[nr_dev] = pnp;
|
---|
810 | #endif
|
---|
811 | nr_dev++;
|
---|
812 | return 1;
|
---|
813 | }
|
---|
814 |
|
---|
815 | __setup("snd-card-opl3sa2=", alsa_card_opl3sa2_setup);
|
---|
816 |
|
---|
817 | #endif /* ifndef MODULE */
|
---|