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