source: GPL/alsa-kernel/isa/wavefront/wavefront.c@ 1

Last change on this file since 1 was 1, checked in by vladest, 20 years ago

initial import

File size: 25.3 KB
Line 
1/*
2 * ALSA card-level driver for Turtle Beach Wavefront cards
3 * (Maui,Tropez,Tropez+)
4 *
5 * Copyright (c) 1997-1999 by Paul Barton-Davis <pbd@op.net>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#define SNDRV_MAIN_OBJECT_FILE
23#include <sound/driver.h>
24#define SNDRV_GET_ID
25#include <sound/initval.h>
26#include <sound/opl3.h>
27#include <sound/snd_wavefront.h>
28
29#define chip_t cs4231_t
30
31EXPORT_NO_SYMBOLS;
32MODULE_DESCRIPTION("Turtle Beach Wavefront");
33MODULE_CLASSES("{sound}");
34MODULE_DEVICES("{{Turtle Beach,Maui/Tropez/Tropez+}}");
35
36static int snd_index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
37static char *snd_id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
38static int snd_enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
39static int snd_isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
40static long snd_cs4232_pcm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
41static int snd_cs4232_pcm_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,11,12,15 */
42static long snd_cs4232_mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
43static int snd_cs4232_mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 9,11,12,15 */
44static long snd_ics2115_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
45static int snd_ics2115_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 2,9,11,12,15 */
46static long snd_fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
47static long snd_control_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
48static long snd_wss_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
49static int snd_dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */
50static int snd_dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */
51
52MODULE_AUTHOR("Paul Barton-Davis <pbd@op.net>");
53MODULE_PARM(snd_index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
54MODULE_PARM_SYNTAX(snd_index, "Index value for WaveFront soundcard.");
55MODULE_PARM(snd_id, "1-" __MODULE_STRING(SNDRV_CARDS) "s");
56MODULE_PARM_DESC(snd_id, "ID string for WaveFront soundcard.");
57MODULE_PARM_SYNTAX(snd_id, SNDRV_ID_DESC);
58MODULE_PARM(snd_enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
59MODULE_PARM_DESC(snd_enable, "Enable WaveFront soundcard.");
60MODULE_PARM_SYNTAX(snd_enable, SNDRV_ENABLE_DESC);
61#ifdef __ISAPNP__
62MODULE_PARM(snd_isapnp, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
63MODULE_PARM_DESC(snd_isapnp, "ISA PnP detection for WaveFront soundcards.");
64MODULE_PARM_SYNTAX(snd_isapnp, SNDRV_ISAPNP_DESC);
65#endif
66MODULE_PARM(snd_cs4232_pcm_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
67MODULE_PARM_DESC(snd_4232_port, "Port # for CS4232 PCM interface.");
68MODULE_PARM_SYNTAX(snd_cs4232_port, SNDRV_PORT12_DESC);
69MODULE_PARM(snd_cs4232_pcm_irq, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
70MODULE_PARM_DESC(snd_cs4232_pcm_irq, "IRQ # for CS4232 PCM interface.");
71MODULE_PARM_SYNTAX(snd_cs4232_pcm_irq, SNDRV_ENABLED ",allows:{{5},{7},{9},{11},{12},{15}},dialog:list");
72MODULE_PARM(snd_dma1, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
73MODULE_PARM_DESC(snd_dma1, "DMA1 # for CS4232 PCM interface.");
74MODULE_PARM_SYNTAX(snd_dma1, SNDRV_DMA_DESC);
75MODULE_PARM(snd_dma2, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
76MODULE_PARM_DESC(snd_dma2, "DMA2 # for CS4232 PCM interface.");
77MODULE_PARM_SYNTAX(snd_dma2, SNDRV_DMA_DESC);
78MODULE_PARM(snd_cs4232_mpu_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
79MODULE_PARM_DESC(snd_cs4232_mpu_port, "port # for CS4232 MPU-401 interface.");
80MODULE_PARM_SYNTAX(snd_cs4232_mpu_port, SNDRV_PORT12_DESC);
81MODULE_PARM(snd_cs4232_mpu_irq, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
82MODULE_PARM_DESC(snd_cs4232_mpu_irq, "IRQ # for CS4232 MPU-401 interface.");
83MODULE_PARM_SYNTAX(snd_cs4232_mpu_irq, SNDRV_ENABLED ",allows:{{9},{11},{12},{15}},dialog:list");
84MODULE_PARM(snd_ics2115_irq, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
85MODULE_PARM_DESC(snd_ics2115_irq, "IRQ # for ICS2115.");
86MODULE_PARM_SYNTAX(snd_ics2115_irq, SNDRV_ENABLED ",allows:{{9},{11},{12},{15}},dialog:list");
87MODULE_PARM(snd_ics2115_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
88MODULE_PARM_DESC(snd_ics2115_port, "Port # for ICS2115.");
89MODULE_PARM_SYNTAX(snd_ics2115_port, SNDRV_PORT12_DESC);
90MODULE_PARM(snd_fm_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
91MODULE_PARM_DESC(snd_fm_port, "FM port #.");
92MODULE_PARM_SYNTAX(snd_fm_port, SNDRV_PORT12_DESC);
93MODULE_PARM(snd_wss_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
94MODULE_PARM_DESC(snd_wss_port, "Windows Sound System port #.");
95MODULE_PARM_SYNTAX(snd_wss_port, SNDRV_PORT12_DESC);
96
97static snd_card_t *snd_wavefront_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
98
99#ifdef __ISAPNP__
100
101static struct isapnp_card *snd_wavefront_isapnp_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
102static const struct isapnp_card_id *snd_wavefront_isapnp_id[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
103
104static struct isapnp_card_id snd_wavefront_pnpids[] __devinitdata = {
105 {
106 ISAPNP_CARD_ID('C','S','C',0x7532), /* Tropez */
107 devs: { ISAPNP_DEVICE_ID('C','S','C',0x0000), /* WSS */
108 ISAPNP_DEVICE_ID('C','S','C',0x0010), /* CTRL */
109 ISAPNP_DEVICE_ID('P','n','P',0xb006), /* MPU */
110 ISAPNP_DEVICE_ID('C','S','C',000004), }, /* SYNTH */
111 },
112 {
113 ISAPNP_CARD_ID('C','S','C',0x7632), /* Tropez+ */
114 devs: { ISAPNP_DEVICE_ID('C','S','C',0x0000), /* WSS */
115 ISAPNP_DEVICE_ID('C','S','C',0x0010), /* CTRL */
116 ISAPNP_DEVICE_ID('P','n','P',0xb006), /* MPU */
117 ISAPNP_DEVICE_ID('C','S','C',000004), }, /* SYNTH */
118 },
119 { ISAPNP_CARD_END, }
120};
121
122ISAPNP_CARD_TABLE(snd_wavefront_pnpids);
123
124static int __init
125snd_wavefront_isapnp (int dev, snd_wavefront_card_t *acard)
126{
127 const struct isapnp_card_id *id = snd_wavefront_isapnp_id[dev];
128 struct isapnp_card *card = snd_wavefront_isapnp_cards[dev];
129 struct isapnp_dev *pdev;
130 int tmp;
131
132 /* Check for each logical device. */
133
134 /* "windows sound system" has id 0 */
135
136 acard->wss = isapnp_find_dev(card, id->devs[0].vendor, id->devs[0].function, NULL);
137 if (acard->wss->active) {
138 acard->wss = NULL;
139 return -EBUSY;
140 }
141
142 /* control interface has id 1 */
143
144 acard->ctrl = isapnp_find_dev(card, id->devs[1].vendor, id->devs[1].function, NULL);
145 if (acard->ctrl->active) {
146 acard->wss = acard->ctrl = NULL;
147 return -EBUSY;
148 }
149
150 /* synth has id 3 */
151
152 acard->synth = isapnp_find_dev(card, id->devs[3].vendor, id->devs[3].function, NULL);
153 if (acard->synth->active) {
154 acard->wss = acard->ctrl = acard->synth = NULL;
155 return -EBUSY;
156 }
157
158 /* Only configure the CS4232 MIDI interface is its been
159 requested. It has id 2.
160 */
161
162 if (snd_cs4232_mpu_port[dev] != SNDRV_AUTO_PORT) {
163 acard->mpu = isapnp_find_dev(card, id->devs[2].vendor, id->devs[2].function, NULL);
164 if (acard->mpu->active) {
165 acard->wss = acard->ctrl = acard->synth = acard->mpu = NULL;
166 return -EBUSY;
167 }
168 }
169
170 /* PCM/FM initialization */
171
172 pdev = acard->wss;
173
174 if ((tmp = pdev->prepare (pdev)) < 0) {
175 if (tmp == -EBUSY) {
176 snd_printk ("ISA PnP configuration appears to have been "
177 "done. Restart the isa-pnp module.\n");
178 return 0;
179 }
180
181 snd_printk ("isapnp WSS preparation failed\n");
182 return -EAGAIN;
183 }
184
185 if (snd_cs4232_pcm_port[dev] != SNDRV_AUTO_PORT)
186 isapnp_resource_change(&pdev->resource[0], snd_cs4232_pcm_port[dev], 4);
187 if (snd_fm_port[dev] != SNDRV_AUTO_PORT)
188 isapnp_resource_change(&pdev->resource[1], snd_fm_port[dev], 4);
189 if (snd_wss_port[dev] != SNDRV_AUTO_PORT)
190 isapnp_resource_change(&pdev->resource[2], snd_wss_port[dev], 4);
191
192 if (snd_ics2115_port[dev] != SNDRV_AUTO_PORT)
193 isapnp_resource_change(&pdev->resource[3], snd_ics2115_port[dev], 8);
194 if (snd_ics2115_irq[dev] != SNDRV_AUTO_IRQ)
195 isapnp_resource_change(&pdev->irq_resource[3], snd_ics2115_irq[dev], 1);
196
197 if (snd_dma1[dev] != SNDRV_AUTO_DMA)
198 isapnp_resource_change(&pdev->dma_resource[0], snd_dma1[dev], 1);
199 if (snd_dma2[dev] != SNDRV_AUTO_DMA)
200 isapnp_resource_change(&pdev->dma_resource[1], snd_dma2[dev], 1);
201
202 if (snd_cs4232_pcm_irq[dev] != SNDRV_AUTO_IRQ)
203 isapnp_resource_change(&pdev->irq_resource[0], snd_cs4232_pcm_irq[dev], 1);
204
205 if (pdev->activate(pdev)<0) {
206 snd_printk ("isapnp WSS activation failed\n");
207 return -EBUSY;
208 }
209
210 snd_cs4232_pcm_port[dev] = pdev->resource[0].start;
211 snd_fm_port[dev] = pdev->resource[1].start;
212 snd_wss_port[dev] = pdev->resource[2].start;
213
214 snd_ics2115_port[dev] = pdev->resource[3].start;
215 snd_ics2115_irq[dev] = pdev->irq_resource[3].start;
216
217 snd_dma1[dev] = pdev->dma_resource[0].start;
218 snd_dma2[dev] = pdev->dma_resource[1].start == 4 ? -1 : pdev->dma_resource[1].start;
219
220 snd_cs4232_pcm_irq[dev] = pdev->irq_resource[0].start;
221
222 snd_printk ("CS4232: port=0x%lx, fm port=0x%lx, wss port=0x%lx\n"
223 "CS4232: dma1=%i, dma2=%i, irq=%i\n"
224 "ICS2115: port=0x%lx, irq=%i\n",
225 snd_cs4232_pcm_port[dev], snd_fm_port[dev], snd_wss_port[dev],
226 snd_dma1[dev], snd_dma2[dev], snd_cs4232_pcm_irq[dev],
227 snd_ics2115_port[dev],
228 snd_ics2115_irq[dev]);
229
230 /* CTRL initialization */
231
232 if (snd_control_port[dev] != SNDRV_AUTO_PORT) {
233
234 pdev = acard->ctrl;
235
236 if (pdev->prepare(pdev)<0) {
237 acard->wss->deactivate(acard->wss);
238 snd_printk ("isapnp CTRL preparation failed\n");
239 return -EAGAIN;
240 }
241
242 if (snd_control_port[dev] != SNDRV_AUTO_PORT)
243 isapnp_resource_change(&pdev->resource[0], snd_control_port[dev], 8);
244
245 if (pdev->activate(pdev)<0) {
246 snd_printk("isapnp CTRL activation failed\n");
247 acard->wss->deactivate(acard->wss);
248 return -EBUSY;
249 }
250
251 snd_control_port[dev] = pdev->resource[0].start;
252 snd_printk ("isapnp CTRL: control port=0x%lx\n",
253 snd_control_port[dev]);
254 }
255
256 /* Synth initialization */
257
258 if (snd_ics2115_port[dev] != SNDRV_AUTO_PORT) {
259
260 pdev = acard->synth;
261
262 if (pdev->prepare(pdev)<0) {
263 acard->wss->deactivate(acard->wss);
264 if (acard->ctrl)
265 acard->ctrl->deactivate(acard->ctrl);
266 snd_printk ("ICS2115 synth preparation failed\n");
267 return -EAGAIN;
268 }
269
270 isapnp_resource_change(&pdev->resource[0], snd_ics2115_port[dev], 8);
271 if (snd_ics2115_irq[dev] != SNDRV_AUTO_IRQ)
272 isapnp_resource_change(&pdev->irq_resource[0], snd_ics2115_irq[dev], 1);
273
274 if (pdev->activate(pdev)<0) {
275 snd_printk("synth configuration failed\n");
276 acard->wss->deactivate(acard->wss);
277 if (acard->ctrl)
278 acard->ctrl->deactivate(acard->ctrl);
279 return -EBUSY;
280 }
281
282 snd_ics2115_port[dev] = pdev->resource[0].start;
283 snd_ics2115_irq[dev] = pdev->irq_resource[0].start;
284 }
285
286 /* CS4232 MPU initialization. Configure this only if
287 explicitly requested, since its physically inaccessible and
288 consumes another IRQ.
289 */
290
291 if (snd_cs4232_mpu_port[dev] != SNDRV_AUTO_PORT) {
292
293 pdev = acard->mpu;
294
295 if (pdev->prepare(pdev)<0) {
296 acard->wss->deactivate(acard->wss);
297 if (acard->ctrl)
298 acard->ctrl->deactivate(acard->ctrl);
299 if (acard->synth)
300 acard->synth->deactivate(acard->synth);
301 snd_printk ("CS4232 MPU preparation failed\n");
302 return -EAGAIN;
303 }
304
305 if (snd_cs4232_mpu_port[dev] != SNDRV_AUTO_PORT)
306 isapnp_resource_change(&pdev->resource[0], snd_cs4232_mpu_port[dev], 2);
307 if (snd_cs4232_mpu_irq[dev] != SNDRV_AUTO_IRQ)
308 isapnp_resource_change(&pdev->resource[0], snd_cs4232_mpu_irq[dev], 1);
309
310 if (pdev->activate(pdev)<0) {
311 snd_printk("isapnp CS4232 MPU activation failed\n");
312 snd_cs4232_mpu_port[dev] = SNDRV_AUTO_PORT;
313 } else {
314 snd_cs4232_mpu_port[dev] = pdev->resource[0].start;
315 snd_cs4232_mpu_irq[dev] = pdev->irq_resource[0].start;
316 }
317
318 snd_printk ("CS4232 MPU: port=0x%lx, irq=%i\n",
319 snd_cs4232_mpu_port[dev],
320 snd_cs4232_mpu_irq[dev]);
321 }
322
323 return 0;
324}
325
326static void
327snd_wavefront_deactivate (snd_wavefront_card_t *acard)
328{
329 snd_printk ("deactivating PnP devices\n");
330 if (acard->wss) {
331 acard->wss->deactivate(acard->wss);
332 acard->wss = NULL;
333 }
334 if (acard->ctrl) {
335 acard->ctrl->deactivate(acard->ctrl);
336 acard->ctrl = NULL;
337 }
338 if (acard->mpu) {
339 acard->mpu->deactivate(acard->mpu);
340 acard->mpu = NULL;
341 }
342 if (acard->synth) {
343 acard->synth->deactivate(acard->synth);
344 acard->synth = NULL;
345 }
346}
347
348#endif /* __ISAPNP__ */
349
350static void snd_wavefront_ics2115_interrupt(int irq,
351 void *dev_id,
352 struct pt_regs *regs)
353{
354 snd_wavefront_card_t *acard;
355
356 acard = (snd_wavefront_card_t *) dev_id;
357
358 if (acard == NULL)
359 return;
360
361 if (acard->wavefront.interrupts_are_midi) {
362 snd_wavefront_midi_interrupt (acard);
363 } else {
364 snd_wavefront_internal_interrupt (acard);
365 }
366}
367
368snd_hwdep_t * __init
369snd_wavefront_new_synth (snd_card_t *card,
370 int hw_dev,
371 snd_wavefront_card_t *acard)
372{
373 snd_hwdep_t *wavefront_synth;
374
375 if (snd_wavefront_detect (acard) < 0) {
376 return NULL;
377 }
378
379 if (snd_wavefront_start (&acard->wavefront) < 0) {
380 return NULL;
381 }
382
383 if (snd_hwdep_new(card, "WaveFront", hw_dev, &wavefront_synth) < 0)
384 return NULL;
385 strcpy (wavefront_synth->name,
386 "WaveFront (ICS2115) wavetable synthesizer");
387 wavefront_synth->ops.open = snd_wavefront_synth_open;
388 wavefront_synth->ops.release = snd_wavefront_synth_release;
389 wavefront_synth->ops.ioctl = snd_wavefront_synth_ioctl;
390
391 return wavefront_synth;
392}
393
394snd_hwdep_t * __init
395snd_wavefront_new_fx (snd_card_t *card,
396 int hw_dev,
397 snd_wavefront_card_t *acard,
398 unsigned long port)
399
400{
401 snd_hwdep_t *fx_processor;
402
403 if (snd_wavefront_fx_start (&acard->wavefront)) {
404 snd_printk ("cannot initialize YSS225 FX processor");
405 return NULL;
406 }
407
408 if (snd_hwdep_new (card, "YSS225", hw_dev, &fx_processor) < 0)
409 return NULL;
410 sprintf (fx_processor->name, "YSS225 FX Processor at 0x%lx", port);
411 fx_processor->ops.open = snd_wavefront_fx_open;
412 fx_processor->ops.release = snd_wavefront_fx_release;
413 fx_processor->ops.ioctl = snd_wavefront_fx_ioctl;
414
415 return fx_processor;
416}
417
418static snd_wavefront_mpu_id internal_id = internal_mpu;
419static snd_wavefront_mpu_id external_id = external_mpu;
420
421snd_rawmidi_t * __init
422snd_wavefront_new_midi (snd_card_t *card,
423 int midi_dev,
424 snd_wavefront_card_t *acard,
425 unsigned long port,
426 snd_wavefront_mpu_id mpu)
427
428{
429 snd_rawmidi_t *rmidi;
430 static int first = 1;
431
432 if (first) {
433 first = 0;
434 acard->wavefront.midi.base = port;
435 if (snd_wavefront_midi_start (acard)) {
436 snd_printk ("cannot initialize MIDI interface\n");
437 return NULL;
438 }
439 }
440
441 if (snd_rawmidi_new (card, "WaveFront MIDI", midi_dev, 1, 1, &rmidi) < 0)
442 return NULL;
443
444 if (mpu == internal_mpu) {
445 strcpy(rmidi->name, "WaveFront MIDI (Internal)");
446 rmidi->private_data = &internal_id;
447 } else {
448 strcpy(rmidi->name, "WaveFront MIDI (External)");
449 rmidi->private_data = &external_id;
450 }
451
452 snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_wavefront_midi_output);
453 snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, &snd_wavefront_midi_input);
454
455 rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT |
456 SNDRV_RAWMIDI_INFO_INPUT |
457 SNDRV_RAWMIDI_INFO_DUPLEX;
458
459 return rmidi;
460}
461
462static void
463snd_wavefront_free(snd_card_t *card)
464{
465 snd_wavefront_card_t *acard = (snd_wavefront_card_t *)card->private_data;
466
467 if (acard) {
468#ifdef __ISAPNP__
469 snd_wavefront_deactivate(acard);
470#endif
471 if (acard->wavefront.res_base != NULL)
472 release_resource(acard->wavefront.res_base);
473 if (acard->wavefront.irq > 0)
474 free_irq(acard->wavefront.irq, (void *)acard);
475 }
476}
477
478static int __init
479snd_wavefront_probe (int dev)
480{
481 snd_card_t *card;
482 snd_wavefront_card_t *acard;
483 cs4231_t *chip;
484 snd_hwdep_t *wavefront_synth;
485 snd_rawmidi_t *ics2115_internal_rmidi = NULL;
486 snd_rawmidi_t *ics2115_external_rmidi = NULL;
487 snd_hwdep_t *fx_processor;
488 int hw_dev = 0, midi_dev = 0, err;
489
490 if (snd_cs4232_mpu_port[dev] < 0)
491 snd_cs4232_mpu_port[dev] = SNDRV_AUTO_PORT;
492 if (snd_fm_port[dev] < 0)
493 snd_fm_port[dev] = SNDRV_AUTO_PORT;
494 if (snd_ics2115_port[dev] < 0)
495 snd_ics2115_port[dev] = SNDRV_AUTO_PORT;
496
497#ifdef __ISAPNP__
498 if (!snd_isapnp[dev]) {
499#endif
500 if (snd_cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) {
501 snd_printk("specify CS4232 port\n");
502 return -EINVAL;
503 }
504 if (snd_ics2115_port[dev] == SNDRV_AUTO_PORT) {
505 snd_printk("specify ICS2115 port\n");
506 return -ENODEV;
507 }
508#ifdef __ISAPNP__
509 }
510#endif
511 card = snd_card_new (snd_index[dev],
512 snd_id[dev],
513 THIS_MODULE,
514 sizeof(snd_wavefront_card_t));
515
516 if (card == NULL) {
517 return -ENOMEM;
518 }
519 acard = (snd_wavefront_card_t *)card->private_data;
520 acard->wavefront.irq = -1;
521 init_waitqueue_head(&acard->wavefront.interrupt_sleeper);
522 spin_lock_init(&acard->wavefront.midi.open);
523 spin_lock_init(&acard->wavefront.midi.virtual);
524 card->private_free = snd_wavefront_free;
525
526#ifdef __ISAPNP__
527 if (snd_isapnp[dev] && snd_wavefront_isapnp (dev, acard) < 0) {
528 if (snd_cs4232_pcm_port[dev] == SNDRV_AUTO_PORT ||
529 snd_control_port[dev] == SNDRV_AUTO_PORT) {
530 snd_printk ("isapnp detection failed\n");
531 snd_card_free (card);
532 return -ENODEV;
533 }
534 }
535#endif /* __ISAPNP__ */
536
537 /* --------- PCM --------------- */
538
539 if ((err = snd_cs4231_create (card,
540 snd_cs4232_pcm_port[dev],
541 snd_control_port[dev],
542 snd_cs4232_pcm_irq[dev],
543 snd_dma1[dev],
544 snd_dma2[dev],
545 CS4231_HW_DETECT, 0, &chip)) < 0) {
546 snd_card_free(card);
547 snd_printk ("can't allocate CS4231 device\n");
548 return err;
549 }
550
551 if ((err = snd_cs4231_pcm (chip, 0, NULL)) < 0) {
552 snd_card_free(card);
553 return err;
554 }
555 if ((err = snd_cs4231_timer (chip, 0, NULL)) < 0) {
556 snd_card_free(card);
557 return err;
558 }
559
560 /* ---------- OPL3 synth --------- */
561
562 if (snd_fm_port[dev] != SNDRV_AUTO_PORT) {
563 opl3_t *opl3;
564
565 if ((err = snd_opl3_create(card,
566 snd_fm_port[dev],
567 snd_fm_port[dev] + 2,
568 OPL3_HW_OPL3_CS,
569 0, &opl3)) < 0) {
570 snd_printk ("can't allocate or detect OPL3 synth\n");
571 snd_card_free(card);
572 return err;
573 }
574
575 if ((err = snd_opl3_hwdep_new(opl3, hw_dev, 1, NULL)) < 0) {
576 snd_card_free(card);
577 return err;
578 }
579 hw_dev++;
580 }
581
582 /* ------- ICS2115 Wavetable synth ------- */
583
584 if ((acard->wavefront.res_base = request_region(snd_ics2115_port[dev], 16, "ICS2115")) == NULL) {
585 snd_printk("unable to grab ICS2115 i/o region 0x%lx-0x%lx\n", snd_ics2115_port[dev], snd_ics2115_port[dev] + 16 - 1);
586 snd_card_free(card);
587 return -EBUSY;
588 }
589 if (request_irq(snd_ics2115_irq[dev], snd_wavefront_ics2115_interrupt, SA_INTERRUPT, "ICS2115", (void *)acard)) {
590 snd_printk("unable to use ICS2115 IRQ %d\n", snd_ics2115_irq[dev]);
591 snd_card_free(card);
592 return -EBUSY;
593 }
594
595 acard->wavefront.irq = snd_ics2115_irq[dev];
596 acard->wavefront.base = snd_ics2115_port[dev];
597
598 if ((wavefront_synth = snd_wavefront_new_synth (card, hw_dev, acard)) == NULL) {
599 snd_printk ("can't create WaveFront synth device\n");
600 snd_card_free(card);
601 return -ENOMEM;
602 }
603
604 strcpy (wavefront_synth->name, "ICS2115 Wavetable MIDI Synthesizer");
605 wavefront_synth->iface = SNDRV_HWDEP_IFACE_ICS2115;
606 hw_dev++;
607
608 /* --------- Mixer ------------ */
609
610 if ((err = snd_cs4231_mixer(chip)) < 0) {
611 snd_printk ("can't allocate mixer device\n");
612 snd_card_free(card);
613 return err;
614 }
615
616 /* -------- CS4232 MPU-401 interface -------- */
617
618 if (snd_cs4232_mpu_port[dev] > 0 && snd_cs4232_mpu_port[dev] != SNDRV_AUTO_PORT) {
619 if ((err = snd_mpu401_uart_new(card, midi_dev, MPU401_HW_CS4232,
620 snd_cs4232_mpu_port[dev], 0,
621 snd_cs4232_mpu_irq[dev],
622 SA_INTERRUPT,
623 NULL)) < 0) {
624 snd_printk ("can't allocate CS4232 MPU-401 device\n");
625 snd_card_free(card);
626 return err;
627 }
628 midi_dev++;
629 }
630
631 /* ------ ICS2115 internal MIDI ------------ */
632
633 if (snd_ics2115_port[dev] >= 0 && snd_ics2115_port[dev] != SNDRV_AUTO_PORT) {
634 ics2115_internal_rmidi =
635 snd_wavefront_new_midi (card,
636 midi_dev,
637 acard,
638 snd_ics2115_port[dev],
639 internal_mpu);
640 if (ics2115_internal_rmidi == NULL) {
641 snd_printk ("can't setup ICS2115 internal MIDI device\n");
642 snd_card_free(card);
643 return -ENOMEM;
644 }
645 midi_dev++;
646 }
647
648 /* ------ ICS2115 external MIDI ------------ */
649
650 if (snd_ics2115_port[dev] >= 0 && snd_ics2115_port[dev] != SNDRV_AUTO_PORT) {
651 ics2115_external_rmidi =
652 snd_wavefront_new_midi (card,
653 midi_dev,
654 acard,
655 snd_ics2115_port[dev],
656 external_mpu);
657 if (ics2115_external_rmidi == NULL) {
658 snd_printk ("can't setup ICS2115 external MIDI device\n");
659 snd_card_free(card);
660 return -ENOMEM;
661 }
662 midi_dev++;
663 }
664
665 /* FX processor for Tropez+ */
666
667 if (acard->wavefront.has_fx) {
668 fx_processor = snd_wavefront_new_fx (card,
669 hw_dev,
670 acard,
671 snd_ics2115_port[dev]);
672 if (fx_processor == NULL) {
673 snd_printk ("can't setup FX device\n");
674 snd_card_free(card);
675 return -ENOMEM;
676 }
677
678 hw_dev++;
679
680 strcpy(card->driver, "Tropez+");
681 strcpy(card->shortname, "Turtle Beach Tropez+");
682 } else {
683 /* Need a way to distinguish between Maui and Tropez */
684 strcpy(card->driver, "WaveFront");
685 strcpy(card->shortname, "Turtle Beach WaveFront");
686 }
687
688 /* ----- Register the card --------- */
689
690 /* Not safe to include "Turtle Beach" in longname, due to
691 length restrictions
692 */
693
694 sprintf(card->longname, "%s PCM 0x%lx irq %d dma %d",
695 card->driver,
696 chip->port,
697 snd_cs4232_pcm_irq[dev],
698 snd_dma1[dev]);
699
700 if (snd_dma2[dev] >= 0 && snd_dma2[dev] < 8)
701 sprintf(card->longname + strlen(card->longname), "&%d", snd_dma2[dev]);
702
703 if (snd_cs4232_mpu_port[dev] != SNDRV_AUTO_PORT) {
704 sprintf (card->longname + strlen (card->longname),
705 " MPU-401 0x%lx irq %d",
706 snd_cs4232_mpu_port[dev],
707 snd_cs4232_mpu_irq[dev]);
708 }
709
710 sprintf (card->longname + strlen (card->longname),
711 " SYNTH 0x%lx irq %d",
712 snd_ics2115_port[dev],
713 snd_ics2115_irq[dev]);
714
715 if ((err = snd_card_register(card)) < 0) {
716 snd_card_free(card);
717 return err;
718 }
719 snd_wavefront_cards[dev] = card;
720 return 0;
721}
722
723#ifdef __ISAPNP__
724
725static int __init snd_wavefront_isapnp_detect(struct isapnp_card *card,
726 const struct isapnp_card_id *id)
727{
728 static int dev = 0;
729 int res;
730
731 for ( ; dev < SNDRV_CARDS; dev++) {
732 if (!snd_enable[dev] || !snd_isapnp[dev])
733 continue;
734 snd_wavefront_isapnp_cards[dev] = card;
735 snd_wavefront_isapnp_id[dev] = id;
736 res = snd_wavefront_probe(dev);
737 if (res < 0)
738 return res;
739 dev++;
740 return 0;
741 }
742
743 return -ENODEV;
744}
745
746#endif /* __ISAPNP__ */
747
748static int __init alsa_card_wavefront_init(void)
749{
750 int cards = 0;
751 int dev;
752 for (dev = 0; dev < SNDRV_CARDS; dev++) {
753 if (!snd_enable[dev])
754 continue;
755#ifdef __ISAPNP__
756 if (snd_isapnp[dev])
757 continue;
758#endif
759 if (snd_wavefront_probe(dev) >= 0)
760 cards++;
761 }
762#ifdef __ISAPNP__
763 cards += isapnp_probe_cards(snd_wavefront_pnpids, snd_wavefront_isapnp_detect);
764#endif
765 if (!cards) {
766#ifdef MODULE
767 snd_printk ("No cards found or devices busy\n");
768#endif
769 return -ENODEV;
770 }
771 return 0;
772}
773
774static void __exit alsa_card_wavefront_exit(void)
775{
776 int idx;
777
778 for (idx = 0; idx < SNDRV_CARDS; idx++)
779 snd_card_free(snd_wavefront_cards[idx]);
780}
781
782module_init(alsa_card_wavefront_init)
783module_exit(alsa_card_wavefront_exit)
784
785#ifndef MODULE
786
787/* format is: snd-card-wavefront=snd_enable,snd_index,snd_id,snd_isapnp,
788 snd_cs4232_pcm_port,snd_cs4232_pcm_irq,
789 snd_cs4232_mpu_port,snd_cs4232_mpu_irq,
790 snd_ics2115_port,snd_ics2115_irq,
791 snd_fm_port,snd_control_port,snd_wss_port,
792 snd_dma1,snd_dma2 */
793
794static int __init alsa_card_wavefront_setup(char *str)
795{
796 static unsigned __initdata nr_dev = 0;
797
798 if (nr_dev >= SNDRV_CARDS)
799 return 0;
800 (void)(get_option(&str,&snd_enable[nr_dev]) == 2 &&
801 get_option(&str,&snd_index[nr_dev]) == 2 &&
802 get_id(&str,&snd_id[nr_dev]) == 2 &&
803 get_option(&str,&snd_isapnp[nr_dev]) == 2 &&
804 get_option(&str,(int *)&snd_cs4232_pcm_port[nr_dev]) == 2 &&
805 get_option(&str,&snd_cs4232_pcm_irq[nr_dev]) == 2 &&
806 get_option(&str,(int *)&snd_cs4232_mpu_port[nr_dev]) == 2 &&
807 get_option(&str,&snd_cs4232_mpu_irq[nr_dev]) == 2 &&
808 get_option(&str,(int *)&snd_ics2115_port[nr_dev]) == 2 &&
809 get_option(&str,&snd_ics2115_irq[nr_dev]) == 2 &&
810 get_option(&str,(int *)&snd_fm_port[nr_dev]) == 2 &&
811 get_option(&str,(int *)&snd_control_port[nr_dev]) == 2 &&
812 get_option(&str,(int *)&snd_wss_port[nr_dev]) == 2 &&
813 get_option(&str,&snd_dma1[nr_dev]) == 2 &&
814 get_option(&str,&snd_dma2[nr_dev]) == 2);
815 nr_dev++;
816 return 1;
817}
818
819__setup("snd-card-wavefront=", alsa_card_wavefront_setup);
820
821#endif /* ifndef MODULE */
Note: See TracBrowser for help on using the repository browser.