toccata.c revision 1.14.4.1 1 /* $NetBSD: toccata.c,v 1.14.4.1 2011/11/20 12:41:59 mrg Exp $ */
2
3 /*-
4 * Copyright (c) 1998, 1999, 2001, 2002 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Paul Kranenburg and Ignatios Souvatzis.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: toccata.c,v 1.14.4.1 2011/11/20 12:41:59 mrg Exp $");
34
35 #include <sys/types.h>
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/kernel.h>
39 #include <sys/device.h>
40 #include <sys/fcntl.h> /* FREAD */
41 #include <sys/bus.h>
42
43 #include <sys/audioio.h>
44 #include <dev/audio_if.h>
45
46 #include <dev/ic/ad1848reg.h>
47 #include <dev/ic/ad1848var.h>
48
49 #include <amiga/dev/zbusvar.h>
50 #include <amiga/amiga/isr.h>
51
52
53 /* Register offsets. XXX All of this is guesswork. */
54
55 /*
56 * The Toccata board consists of: GALs for ZBus AutoConfig(tm) glue, GALs
57 * that interface the FIFO chips and the audio codec chip to the ZBus,
58 * an AD1848 (or AD1845), and 2 Integrated Device Technology 7202LA
59 * (1024x9bit FIFO) chips.
60 */
61
62 #define TOCC_FIFO_STAT 0x1ffe
63 #define TOCC_FIFO_DATA 0x2000
64
65 /*
66 * I don't know whether the AD1848 PIO data registers are connected... and
67 * at 2 or 3 accesses to read or write a data byte in the best case, I better
68 * don't even think about it. The AD1848 address/status and data port are
69 * here:
70 */
71 #define TOCC_CODEC_ADDR 0x67FF
72 #define TOCC_CODEC_STAT TOCC_CODEC_ADDR
73 #define TOCC_CODEC_REG 0x6801
74
75 /* fifo status bits, read */
76
77 #define TOCC_FIFO_INT 0x80 /* active low; together with one of those: */
78
79 #define TOCC_FIFO_PBHE 0x08 /* playback fifo is half empty (active high) */
80 #define TOCC_FIFO_CPHF 0x04 /* capture fifo is half full (active high) */
81
82 /* fifo status bits, write */
83
84 /*
85 * seems to work like this:
86 * init: write 2; delay; write 1
87 *
88 * capture: write 1; write 1+4+8+0x40 (0x4D)
89 * capt. int: read 512 bytes out of fifo.
90 * capt. int off by writing 1+4+8 (0x0D)
91 *
92 * playback: write 1; write 1 + 0x10; (0x11)
93 * 3/4 fill fifo with silence; init codec;
94 * write 1+4+0x10+0x80 (0x95)
95 * pb int: write 512 bytes to fifo
96 * pb int off by writing 1+4+0x10 (0x15)
97 */
98
99 #define TOCC_RST 0x02
100 #define TOCC_ACT 0x01
101 #define TOCC_MAGIC 0x04
102
103 #define TOCC_PB_INTENA 0x80
104 #define TOCC_PB_FILL 0x10
105
106 #define TOCC_PB_PREP (TOCC_ACT + TOCC_PB_FILL)
107 #define TOCC_PB_TAIL (TOCC_PB_PREP + TOCC_MAGIC)
108 #define TOCC_PB_MAIN (TOCC_PB_TAIL + TOCC_PB_INTENA)
109
110 #define TOCC_CP_INTENA 0x40
111 #define TOCC_CP_RUN 0x08
112
113 #define TOCC_CP_TAIL (TOCC_ACT + TOCC_CP_RUN)
114 #define TOCC_CP_MAIN (TOCC_CP_TAIL + TOCC_CP_INTENA + TOCC_MAGIC)
115
116 /*
117 * For the port stuff. Similar to the cs4231 table, but MONO is not wired
118 * on the Toccata, which was designed for the AD1848. Also we know how
119 * to handle input.
120 */
121
122 #define TOCCATA_INPUT_CLASS 0
123 #define TOCCATA_OUTPUT_CLASS 1
124 #define TOCCATA_MONITOR_CLASS 2
125 #define TOCCATA_RECORD_CLASS 3
126
127 #define TOCCATA_RECORD_SOURCE 4
128 #define TOCCATA_REC_LVL 5
129
130 #define TOCCATA_MIC_IN_LVL 6
131
132 #define TOCCATA_AUX1_LVL 7
133 #define TOCCATA_AUX1_MUTE 8
134
135 #define TOCCATA_AUX2_LVL 9
136 #define TOCCATA_AUX2_MUTE 10
137
138 #define TOCCATA_MONITOR_LVL 11
139 #define TOCCATA_MONITOR_MUTE 12
140 #define TOCCATA_OUTPUT_LVL 13
141
142 /* only on AD1845 in mode 2 */
143
144 #define TOCCATA_LINE_IN_LVL 14
145 #define TOCCATA_LINE_IN_MUTE 15
146
147 /* special, need support */
148 #define TOCCATA_MIC_LVL 16
149 #define TOCCATA_MIC_MUTE 17
150
151
152
153 /* prototypes */
154
155 int toccata_intr(void *);
156 int toccata_readreg(struct ad1848_softc *, int);
157 void toccata_writereg(struct ad1848_softc *, int, int);
158
159 int toccata_round_blocksize(void *, int, int, const audio_params_t *);
160 size_t toccata_round_buffersize(void *, int, size_t);
161
162 int toccata_open(void *, int);
163 void toccata_close(void *);
164 int toccata_getdev(void *, struct audio_device *);
165 int toccata_get_props(void *);
166
167 int toccata_halt_input(void *);
168 int toccata_halt_output(void *);
169 int toccata_start_input(void *, void *, int, void (*)(void *), void *);
170 int toccata_start_output(void *, void *, int, void (*)(void *), void *);
171
172 /* I suspect those should be in a shared file */
173 int toccata_set_port(void *, mixer_ctrl_t *);
174 int toccata_get_port(void *, mixer_ctrl_t *);
175 int toccata_query_devinfo(void *, mixer_devinfo_t *);
176
177 void toccata_get_locks(void *, kmutex_t **, kmutex_t **);
178
179 const struct audio_hw_if audiocs_hw_if = {
180 toccata_open,
181 toccata_close,
182 0, /*
183 * XXX toccata_drain could be written:
184 * sleep for play interrupt. This loses less then 512 bytes of
185 * sample data, otherwise up to 1024.
186 */
187 ad1848_query_encoding,
188 ad1848_set_params,
189 toccata_round_blocksize,
190 ad1848_commit_settings,
191 0, /* init_output */ /* XXX need this to prefill? */
192 0, /* init_input */
193 toccata_start_output,
194 toccata_start_input,
195 toccata_halt_output,
196 toccata_halt_input,
197 0, /* speaker */
198 toccata_getdev,
199 0, /* setfd */
200 toccata_set_port,
201 toccata_get_port,
202 toccata_query_devinfo,
203 0, /* alloc/free */
204 0,
205 toccata_round_buffersize, /* round_buffer */
206 0, /* mappage */
207 toccata_get_props,
208 0, /* trigger_output */
209 0,
210 0,
211 0,
212 toccata_get_locks,
213 };
214
215 struct toccata_softc {
216 struct ad1848_softc sc_ad;
217 struct isr sc_isr;
218 volatile uint8_t *sc_boardp; /* only need a few addresses! */
219
220 void (*sc_captmore)(void *);
221 void *sc_captarg;
222 void *sc_captbuf;
223 int sc_captbufsz;
224
225 void (*sc_playmore)(void *);
226 void *sc_playarg;
227
228 kmutex_t sc_lock;
229 kmutex_t sc_intr_lock;
230 };
231
232 int toccata_match(device_t, cfdata_t, void *);
233 void toccata_attach(device_t, device_t, void *);
234
235 CFATTACH_DECL_NEW(toccata, sizeof(struct toccata_softc),
236 toccata_match, toccata_attach, NULL, NULL);
237
238 int
239 toccata_match(device_t parent, cfdata_t cfp, void *aux)
240 {
241 struct zbus_args *zap;
242
243 zap = aux;
244
245 if (zap->manid != 18260)
246 return (0);
247
248 if (zap->prodid != 12)
249 return (0);
250
251 return (1);
252 }
253
254 void
255 toccata_attach(device_t parent, device_t self, void *aux)
256 {
257 struct toccata_softc *sc;
258 struct ad1848_softc *asc;
259 struct zbus_args *zap;
260 volatile uint8_t *boardp;
261
262 sc = device_private(self);
263 asc = &sc->sc_ad;
264 asc->sc_dev = self;
265 zap = aux;
266
267 boardp = (volatile uint8_t *)zap->va;
268 sc->sc_boardp = boardp;
269
270 *boardp = TOCC_RST;
271 delay(500000); /* look up value */
272 *boardp = TOCC_ACT;
273
274 asc->parent = sc;
275 asc->sc_readreg = toccata_readreg;
276 asc->sc_writereg = toccata_writereg;
277
278 asc->chip_name = "ad1848";
279 asc->mode = 1;
280 ad1848_attach(asc);
281 printf("\n");
282
283 sc->sc_captbuf = 0;
284 sc->sc_playmore = 0;
285
286 mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
287 mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_SCHED);
288
289 sc->sc_isr.isr_ipl = 6;
290 sc->sc_isr.isr_arg = sc;
291 sc->sc_isr.isr_intr = toccata_intr;
292 add_isr(&sc->sc_isr);
293
294 audio_attach_mi(&audiocs_hw_if, sc, self);
295
296 }
297
298 /* interrupt handler */
299 int
300 toccata_intr(void *tag) {
301 struct toccata_softc *sc;
302 uint8_t *buf;
303 volatile uint8_t *fifo;
304 uint8_t status;
305 int i;
306
307 sc = tag;
308
309 mutex_spin_enter(&sc->sc_intr_lock);
310
311 status = *(sc->sc_boardp);
312
313 if (status & TOCC_FIFO_INT) { /* active low */
314 mutex_spin_exit(&sc->sc_intr_lock);
315 return 0;
316 }
317
318 if (status & TOCC_FIFO_PBHE) {
319 if (sc->sc_playmore) {
320 (*sc->sc_playmore)(sc->sc_playarg);
321 mutex_spin_exit(&sc->sc_intr_lock);
322 return 1;
323 }
324 } else if (status & TOCC_FIFO_CPHF) {
325 if (sc->sc_captbuf) {
326 buf = sc->sc_captbuf;
327 fifo = sc->sc_boardp + TOCC_FIFO_DATA;
328
329 for (i = sc->sc_captbufsz/4 - 1; i>=0; --i) {
330 *buf++ = *fifo;
331 *buf++ = *fifo;
332 *buf++ = *fifo;
333 *buf++ = *fifo;
334 }
335
336 /* XXX if (sc->sc_captmore) { */
337 (*sc->sc_captmore)(sc->sc_captarg);
338 mutex_spin_exit(&sc->sc_intr_lock);
339 return 1;
340 }
341 }
342
343 /*
344 * Something is wrong; switch interrupts off to avoid wedging the
345 * machine, and notify the alpha tester.
346 * Normally, the halt_* functions should have switched off the
347 * FIFO interrupt.
348 */
349 #ifdef DEBUG
350 printf("%s: got unexpected interrupt %x\n",
351 device_xname(sc->sc_ad.sc_dev), status);
352 #endif
353 *sc->sc_boardp = TOCC_ACT;
354 mutex_spin_exit(&sc->sc_intr_lock);
355 return 1;
356 }
357
358 /* support for ad1848 functions */
359
360 int
361 toccata_readreg(struct ad1848_softc *asc, int offset)
362 {
363 struct toccata_softc *sc;
364
365 sc = (struct toccata_softc *)asc;
366 return *(sc->sc_boardp + TOCC_CODEC_ADDR +
367 offset * (TOCC_CODEC_REG - TOCC_CODEC_ADDR));
368 }
369
370 void
371 toccata_writereg(struct ad1848_softc *asc, int offset, int value)
372 {
373 struct toccata_softc *sc;
374
375 sc = (struct toccata_softc *)asc;
376 *(sc->sc_boardp + TOCC_CODEC_ADDR +
377 offset * (TOCC_CODEC_REG - TOCC_CODEC_ADDR)) = value;
378 }
379
380 /* our own copy of open/close; we don't ever enable the ad1848 interrupts */
381 int
382 toccata_open(void *addr, int flags)
383 {
384 struct toccata_softc *sc;
385 struct ad1848_softc *asc;
386
387 sc = addr;
388 asc = &sc->sc_ad;
389
390 asc->open_mode = flags;
391 /* If recording && monitoring, the playback part is also used. */
392 if (flags & FREAD && asc->mute[AD1848_MONITOR_CHANNEL] == 0)
393 ad1848_mute_wave_output(asc, WAVE_UNMUTE1, 1);
394
395 #ifdef AUDIO_DEBUG
396 if (ad1848debug)
397 ad1848_dump_regs(asc);
398 #endif
399
400 return 0;
401 }
402
403 void
404 toccata_close(void *addr)
405 {
406 struct toccata_softc *sc;
407 struct ad1848_softc *asc;
408 unsigned reg;
409
410 sc = addr;
411 asc = &sc->sc_ad;
412 asc->open_mode = 0;
413
414 ad1848_mute_wave_output(asc, WAVE_UNMUTE1, 0);
415
416 reg = ad_read(&sc->sc_ad, SP_INTERFACE_CONFIG);
417 ad_write(&sc->sc_ad, SP_INTERFACE_CONFIG,
418 (reg & ~(CAPTURE_ENABLE|PLAYBACK_ENABLE)));
419
420 /* Disable interrupts */
421 *sc->sc_boardp = TOCC_ACT;
422 #ifdef AUDIO_DEBUG
423 if (ad1848debug)
424 ad1848_dump_regs(asc);
425 #endif
426 }
427
428 int
429 toccata_round_blocksize(void *addr, int blk,
430 int mode, const audio_params_t *param)
431 {
432 int ret;
433
434 ret = blk > 512 ? 512 : (blk & -4);
435
436 return ret;
437 }
438
439 size_t
440 toccata_round_buffersize(void *addr, int direction, size_t suggested)
441 {
442
443 return suggested & -4;
444 }
445
446 struct audio_device toccata_device = {
447 "toccata", "x", "audio"
448 };
449
450 int
451 toccata_getdev(void *addr, struct audio_device *retp)
452 {
453
454 *retp = toccata_device;
455 return 0;
456 }
457
458 int
459 toccata_get_props(void *addr)
460 {
461 return 0;
462 }
463
464 void
465 toccata_get_locks(void *opaque, kmutex_t **intr, kmutex_t **thread)
466 {
467 struct toccata_softc *sc = opaque;
468
469 *intr = &sc->sc_intr_lock;
470 *thread = &sc->sc_lock;
471 }
472
473 int
474 toccata_halt_input(void *addr)
475 {
476 struct toccata_softc *sc;
477 struct ad1848_softc *asc;
478 unsigned reg;
479
480 sc = addr;
481 asc = &sc->sc_ad;
482
483 /* we're half_duplex; be brutal */
484 *sc->sc_boardp = TOCC_CP_TAIL;
485 sc->sc_captmore = 0;
486 sc->sc_captbuf = 0;
487
488 reg = ad_read(&sc->sc_ad, SP_INTERFACE_CONFIG);
489 ad_write(&sc->sc_ad, SP_INTERFACE_CONFIG, (reg & ~CAPTURE_ENABLE));
490
491 return 0;
492 }
493
494 int
495 toccata_start_input(void *addr, void *block, int blksize,
496 void (*intr)(void *), void *intrarg)
497 {
498 struct toccata_softc *sc;
499 unsigned int reg;
500 volatile uint8_t *cmd;
501
502 sc = addr;
503 cmd = sc->sc_boardp;
504
505 if (sc->sc_captmore == 0) {
506
507 /* we're half-duplex, be brutal */
508 *cmd = TOCC_ACT;
509 *cmd = TOCC_CP_MAIN;
510
511 reg = ad_read(&sc->sc_ad, SP_INTERFACE_CONFIG);
512 ad_write(&sc->sc_ad, SP_INTERFACE_CONFIG,
513 (reg | CAPTURE_ENABLE));
514
515 }
516
517 sc->sc_captarg = intrarg;
518 sc->sc_captmore = intr;
519 sc->sc_captbuf = (uint8_t *)block;
520 sc->sc_captbufsz = blksize;
521
522 return 0;
523 }
524
525 int
526 toccata_halt_output(void *addr)
527 {
528 struct toccata_softc *sc;
529 struct ad1848_softc *asc;
530 unsigned int reg;
531
532 sc = addr;
533 asc = &sc->sc_ad;
534
535 /* we're half_duplex; be brutal */
536 *sc->sc_boardp = TOCC_PB_TAIL;
537 sc->sc_playmore = 0;
538
539 reg = ad_read(&sc->sc_ad, SP_INTERFACE_CONFIG);
540 ad_write(&sc->sc_ad, SP_INTERFACE_CONFIG, (reg & ~PLAYBACK_ENABLE));
541
542 return 0;
543 }
544
545 int
546 toccata_start_output(void *addr, void *block, int blksize,
547 void (*intr)(void*), void *intrarg)
548 {
549 struct toccata_softc *sc;
550 unsigned reg;
551 int i;
552 volatile uint8_t *cmd, *fifo;
553 uint8_t *buf;
554
555 sc = addr;
556 buf = block;
557
558 cmd = sc->sc_boardp;
559 fifo = sc->sc_boardp + TOCC_FIFO_DATA;
560
561 if (sc->sc_playmore == 0) {
562 *cmd = TOCC_ACT;
563 *cmd = TOCC_PB_PREP;
564 }
565
566 /*
567 * We rounded the blocksize to a multiple of 4 bytes. Modest
568 * unrolling saves 2% of cputime playing 48000 16bit stereo
569 * on 68040/25MHz.
570 */
571
572 for (i = blksize/4 - 1; i>=0; --i) {
573 *fifo = *buf++;
574 *fifo = *buf++;
575 *fifo = *buf++;
576 *fifo = *buf++;
577 }
578
579 if (sc->sc_playmore == 0) {
580 reg = ad_read(&sc->sc_ad, SP_INTERFACE_CONFIG);
581 ad_write(&sc->sc_ad, SP_INTERFACE_CONFIG,
582 (reg | PLAYBACK_ENABLE));
583
584 /* we're half-duplex, be brutal */
585 *sc->sc_boardp = TOCC_PB_MAIN;
586 }
587
588 sc->sc_playarg = intrarg;
589 sc->sc_playmore = intr;
590
591 return 0;
592 }
593
594 static ad1848_devmap_t csmapping[] = {
595 { TOCCATA_MIC_IN_LVL, AD1848_KIND_MICGAIN, -1 },
596 { TOCCATA_AUX1_LVL, AD1848_KIND_LVL, AD1848_AUX1_CHANNEL },
597 { TOCCATA_AUX1_MUTE, AD1848_KIND_MUTE, AD1848_AUX1_CHANNEL },
598 { TOCCATA_AUX2_LVL, AD1848_KIND_LVL, AD1848_AUX2_CHANNEL },
599 { TOCCATA_AUX2_MUTE, AD1848_KIND_MUTE, AD1848_AUX2_CHANNEL },
600 { TOCCATA_OUTPUT_LVL, AD1848_KIND_LVL, AD1848_DAC_CHANNEL },
601 { TOCCATA_MONITOR_LVL, AD1848_KIND_LVL, AD1848_MONITOR_CHANNEL },
602 { TOCCATA_MONITOR_MUTE, AD1848_KIND_MUTE, AD1848_MONITOR_CHANNEL },
603 { TOCCATA_REC_LVL, AD1848_KIND_RECORDGAIN, -1 },
604 { TOCCATA_RECORD_SOURCE, AD1848_KIND_RECORDSOURCE, -1 },
605 /* only in mode 2: */
606 { TOCCATA_LINE_IN_LVL, AD1848_KIND_LVL, AD1848_LINE_CHANNEL },
607 { TOCCATA_LINE_IN_MUTE, AD1848_KIND_MUTE, AD1848_LINE_CHANNEL },
608 };
609
610 #define nummap (sizeof(csmapping) / sizeof(csmapping[0]))
611
612 int
613 toccata_set_port(void *addr, mixer_ctrl_t *cp)
614 {
615 struct ad1848_softc *ac;
616
617 /* printf("set_port(%d)\n", cp->dev); */
618 ac = addr;
619 return ad1848_mixer_set_port(ac, csmapping,
620 ac->mode == 2 ? nummap : nummap - 2, cp);
621 }
622
623 int
624 toccata_get_port(void *addr, mixer_ctrl_t *cp)
625 {
626 struct ad1848_softc *ac;
627
628 /* printf("get_port(%d)\n", cp->dev); */
629 ac = addr;
630 return ad1848_mixer_get_port(ac, csmapping,
631 ac->mode == 2 ? nummap : nummap - 2, cp);
632 }
633
634 int
635 toccata_query_devinfo(void *addr, mixer_devinfo_t *dip)
636 {
637
638 switch(dip->index) {
639 case TOCCATA_MIC_IN_LVL: /* Microphone */
640 dip->type = AUDIO_MIXER_VALUE;
641 dip->mixer_class = TOCCATA_INPUT_CLASS;
642 dip->prev = dip->next = AUDIO_MIXER_LAST;
643 strcpy(dip->label.name, AudioNmicrophone);
644 dip->un.v.num_channels = 1;
645 strcpy(dip->un.v.units.name, AudioNvolume);
646 break;
647 #if 0
648
649 case TOCCATA_MONO_LVL: /* mono/microphone mixer */
650 dip->type = AUDIO_MIXER_VALUE;
651 dip->mixer_class = TOCCATA_INPUT_CLASS;
652 dip->prev = AUDIO_MIXER_LAST;
653 dip->next = TOCCATA_MONO_MUTE;
654 strcpy(dip->label.name, AudioNmicrophone);
655 dip->un.v.num_channels = 1;
656 strcpy(dip->un.v.units.name, AudioNvolume);
657 break;
658 #endif
659
660 case TOCCATA_AUX1_LVL: /* dacout */
661 dip->type = AUDIO_MIXER_VALUE;
662 dip->mixer_class = TOCCATA_INPUT_CLASS;
663 dip->prev = AUDIO_MIXER_LAST;
664 dip->next = TOCCATA_AUX1_MUTE;
665 strcpy(dip->label.name, "aux1");
666 dip->un.v.num_channels = 2;
667 strcpy(dip->un.v.units.name, AudioNvolume);
668 break;
669
670 case TOCCATA_AUX1_MUTE:
671 dip->mixer_class = TOCCATA_INPUT_CLASS;
672 dip->type = AUDIO_MIXER_ENUM;
673 dip->prev = TOCCATA_AUX1_LVL;
674 dip->next = AUDIO_MIXER_LAST;
675 goto mute;
676
677
678
679 case TOCCATA_AUX2_LVL:
680 dip->type = AUDIO_MIXER_VALUE;
681 dip->mixer_class = TOCCATA_INPUT_CLASS;
682 dip->prev = AUDIO_MIXER_LAST;
683 dip->next = TOCCATA_AUX2_MUTE;
684 strcpy(dip->label.name, "aux2");
685 dip->un.v.num_channels = 2;
686 strcpy(dip->un.v.units.name, AudioNvolume);
687 break;
688
689 case TOCCATA_AUX2_MUTE:
690 dip->mixer_class = TOCCATA_INPUT_CLASS;
691 dip->type = AUDIO_MIXER_ENUM;
692 dip->prev = TOCCATA_AUX2_LVL;
693 dip->next = AUDIO_MIXER_LAST;
694 goto mute;
695
696
697 case TOCCATA_MONITOR_LVL: /* monitor level */
698 dip->type = AUDIO_MIXER_VALUE;
699 dip->mixer_class = TOCCATA_MONITOR_CLASS;
700 dip->next = TOCCATA_MONITOR_MUTE;
701 dip->prev = AUDIO_MIXER_LAST;
702 strcpy(dip->label.name, AudioNmonitor);
703 dip->un.v.num_channels = 1;
704 strcpy(dip->un.v.units.name, AudioNvolume);
705 break;
706
707 case TOCCATA_OUTPUT_LVL: /* output volume */
708 dip->type = AUDIO_MIXER_VALUE;
709 dip->mixer_class = TOCCATA_OUTPUT_CLASS;
710 dip->prev = dip->next = AUDIO_MIXER_LAST;
711 strcpy(dip->label.name, AudioNmaster);
712 dip->un.v.num_channels = 2;
713 strcpy(dip->un.v.units.name, AudioNvolume);
714 break;
715 #if 0
716 case TOCCATA_LINE_IN_LVL: /* line */
717 dip->type = AUDIO_MIXER_VALUE;
718 dip->mixer_class = TOCCATA_INPUT_CLASS;
719 dip->prev = AUDIO_MIXER_LAST;
720 dip->next = TOCCATA_LINE_IN_MUTE;
721 strcpy(dip->label.name, AudioNline);
722 dip->un.v.num_channels = 2;
723 strcpy(dip->un.v.units.name, AudioNvolume);
724 break;
725
726 case TOCCATA_LINE_IN_MUTE:
727 dip->mixer_class = TOCCATA_INPUT_CLASS;
728 dip->type = AUDIO_MIXER_ENUM;
729 dip->prev = TOCCATA_LINE_IN_LVL;
730 dip->next = AUDIO_MIXER_LAST;
731 goto mute;
732 #endif
733 case TOCCATA_MONITOR_MUTE:
734 dip->mixer_class = TOCCATA_MONITOR_CLASS;
735 dip->type = AUDIO_MIXER_ENUM;
736 dip->prev = TOCCATA_MONITOR_LVL;
737 dip->next = AUDIO_MIXER_LAST;
738 mute:
739 strcpy(dip->label.name, AudioNmute);
740 dip->un.e.num_mem = 2;
741 strcpy(dip->un.e.member[0].label.name, AudioNoff);
742 dip->un.e.member[0].ord = 0;
743 strcpy(dip->un.e.member[1].label.name, AudioNon);
744 dip->un.e.member[1].ord = 1;
745 break;
746
747 case TOCCATA_REC_LVL: /* record level */
748 dip->type = AUDIO_MIXER_VALUE;
749 dip->mixer_class = TOCCATA_INPUT_CLASS;
750 dip->prev = AUDIO_MIXER_LAST;
751 dip->next = TOCCATA_RECORD_SOURCE;
752 strcpy(dip->label.name, AudioNrecord);
753 dip->un.v.num_channels = 2;
754 strcpy(dip->un.v.units.name, AudioNvolume);
755 break;
756
757 case TOCCATA_RECORD_SOURCE:
758 dip->mixer_class = TOCCATA_RECORD_CLASS;
759 dip->type = AUDIO_MIXER_ENUM;
760 dip->prev = TOCCATA_REC_LVL;
761 dip->next = AUDIO_MIXER_LAST;
762 strcpy(dip->label.name, AudioNsource);
763 dip->un.e.num_mem = 4;
764 strcpy(dip->un.e.member[0].label.name, AudioNmicrophone);
765 dip->un.e.member[1].ord = MIC_IN_PORT;
766 strcpy(dip->un.e.member[1].label.name, AudioNline);
767 dip->un.e.member[3].ord = LINE_IN_PORT;
768 strcpy(dip->un.e.member[2].label.name, "aux1");
769 dip->un.e.member[2].ord = AUX1_IN_PORT;
770 strcpy(dip->un.e.member[3].label.name, AudioNoutput);
771 dip->un.e.member[0].ord = DAC_IN_PORT;
772 break;
773
774 case TOCCATA_INPUT_CLASS: /* input class descriptor */
775 dip->type = AUDIO_MIXER_CLASS;
776 dip->mixer_class = TOCCATA_INPUT_CLASS;
777 dip->next = dip->prev = AUDIO_MIXER_LAST;
778 strcpy(dip->label.name, AudioCinputs);
779 break;
780
781 case TOCCATA_OUTPUT_CLASS: /* output class descriptor */
782 dip->type = AUDIO_MIXER_CLASS;
783 dip->mixer_class = TOCCATA_OUTPUT_CLASS;
784 dip->next = dip->prev = AUDIO_MIXER_LAST;
785 strcpy(dip->label.name, AudioCoutputs);
786 break;
787
788 case TOCCATA_MONITOR_CLASS: /* monitor class descriptor */
789 dip->type = AUDIO_MIXER_CLASS;
790 dip->mixer_class = TOCCATA_MONITOR_CLASS;
791 dip->next = dip->prev = AUDIO_MIXER_LAST;
792 strcpy(dip->label.name, AudioCmonitor);
793 break;
794
795 case TOCCATA_RECORD_CLASS: /* record source class */
796 dip->type = AUDIO_MIXER_CLASS;
797 dip->mixer_class = TOCCATA_RECORD_CLASS;
798 dip->next = dip->prev = AUDIO_MIXER_LAST;
799 strcpy(dip->label.name, AudioCrecord);
800 break;
801
802 default:
803 return ENXIO;
804 /*NOTREACHED*/
805 }
806
807 return 0;
808 }
809