xref: /netbsd-src/sys/arch/amiga/dev/toccata.c (revision 1b9578b8c2c1f848eeb16dabbfd7d1f0d9fdefbd)
1 /* $NetBSD: toccata.c,v 1.13 2011/06/02 14:12:24 tsutsui 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.13 2011/06/02 14:12:24 tsutsui 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(device_t, cfdata_t, void *);
226 void toccata_attach(device_t, device_t, void *);
227 
228 CFATTACH_DECL_NEW(toccata, sizeof(struct toccata_softc),
229     toccata_match, toccata_attach, NULL, NULL);
230 
231 int
232 toccata_match(device_t parent, cfdata_t 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(device_t parent, device_t 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 = device_private(self);
256 	asc = &sc->sc_ad;
257 	asc->sc_dev = self;
258 	zap = aux;
259 
260 	boardp = (volatile uint8_t *)zap->va;
261 	sc->sc_boardp = boardp;
262 
263 	*boardp = TOCC_RST;
264 	delay(500000);		/* look up value */
265 	*boardp = TOCC_ACT;
266 
267 	asc->parent = sc;
268 	asc->sc_readreg = toccata_readreg;
269 	asc->sc_writereg = toccata_writereg;
270 
271 	asc->chip_name = "ad1848";
272 	asc->mode = 1;
273 	ad1848_attach(asc);
274 	printf("\n");
275 
276 	sc->sc_captbuf = 0;
277 	sc->sc_playmore = 0;
278 
279 	sc->sc_isr.isr_ipl = 6;
280 	sc->sc_isr.isr_arg = sc;
281 	sc->sc_isr.isr_intr = toccata_intr;
282 	add_isr(&sc->sc_isr);
283 
284 	audio_attach_mi(&audiocs_hw_if, sc, self);
285 
286 }
287 
288 /* interrupt handler */
289 int
290 toccata_intr(void *tag) {
291 	struct toccata_softc *sc;
292 	uint8_t *buf;
293 	volatile uint8_t *fifo;
294 	uint8_t status;
295 	int i;
296 
297 	sc = tag;
298 	status = *(sc->sc_boardp);
299 
300 	if (status & TOCC_FIFO_INT)	/* active low */
301 		return 0;
302 
303 	if (status & TOCC_FIFO_PBHE) {
304 		if (sc->sc_playmore) {
305 			(*sc->sc_playmore)(sc->sc_playarg);
306 			return 1;
307 		}
308 	} else if (status & TOCC_FIFO_CPHF) {
309 		if (sc->sc_captbuf) {
310 			buf = sc->sc_captbuf;
311 			fifo = sc->sc_boardp + TOCC_FIFO_DATA;
312 
313 			for (i = sc->sc_captbufsz/4 - 1; i>=0; --i) {
314 				*buf++ = *fifo;
315 				*buf++ = *fifo;
316 				*buf++ = *fifo;
317 				*buf++ = *fifo;
318 			}
319 
320 			/* XXX if (sc->sc_captmore) { */
321 			(*sc->sc_captmore)(sc->sc_captarg);
322 			return 1;
323 		}
324 	}
325 
326 	/*
327 	 * Something is wrong; switch interrupts off to avoid wedging the
328 	 * machine, and notify the alpha tester.
329 	 * Normally, the halt_* functions should have switched off the
330 	 * FIFO interrupt.
331 	 */
332 #ifdef DEBUG
333 	printf("%s: got unexpected interrupt %x\n",
334 	    device_xname(sc->sc_ad.sc_dev), status);
335 #endif
336 	*sc->sc_boardp = TOCC_ACT;
337 	return 1;
338 }
339 
340 /* support for ad1848 functions */
341 
342 int
343 toccata_readreg(struct ad1848_softc *asc, int offset)
344 {
345 	struct toccata_softc *sc;
346 
347 	sc = (struct toccata_softc *)asc;
348 	return *(sc->sc_boardp + TOCC_CODEC_ADDR +
349 		offset * (TOCC_CODEC_REG - TOCC_CODEC_ADDR));
350 }
351 
352 void
353 toccata_writereg(struct ad1848_softc *asc, int offset, int value)
354 {
355 	struct toccata_softc *sc;
356 
357 	sc = (struct toccata_softc *)asc;
358 	*(sc->sc_boardp + TOCC_CODEC_ADDR +
359 		offset * (TOCC_CODEC_REG - TOCC_CODEC_ADDR)) = value;
360 }
361 
362 /* our own copy of open/close; we don't ever enable the ad1848 interrupts */
363 int
364 toccata_open(void *addr, int flags)
365 {
366 	struct toccata_softc *sc;
367 	struct ad1848_softc *asc;
368 
369 	sc = addr;
370 	asc = &sc->sc_ad;
371 
372 	asc->open_mode = flags;
373 	/* If recording && monitoring, the playback part is also used. */
374 	if (flags & FREAD && asc->mute[AD1848_MONITOR_CHANNEL] == 0)
375 		ad1848_mute_wave_output(asc, WAVE_UNMUTE1, 1);
376 
377 #ifdef AUDIO_DEBUG
378 	if (ad1848debug)
379 		ad1848_dump_regs(asc);
380 #endif
381 
382 	return 0;
383 }
384 
385 void
386 toccata_close(void *addr)
387 {
388 	struct toccata_softc *sc;
389 	struct ad1848_softc *asc;
390 	unsigned reg;
391 
392 	sc = addr;
393 	asc = &sc->sc_ad;
394 	asc->open_mode = 0;
395 
396 	ad1848_mute_wave_output(asc, WAVE_UNMUTE1, 0);
397 
398 	reg = ad_read(&sc->sc_ad, SP_INTERFACE_CONFIG);
399 	ad_write(&sc->sc_ad, SP_INTERFACE_CONFIG,
400 		(reg & ~(CAPTURE_ENABLE|PLAYBACK_ENABLE)));
401 
402 	/* Disable interrupts */
403 	*sc->sc_boardp = TOCC_ACT;
404 #ifdef AUDIO_DEBUG
405 	if (ad1848debug)
406 		ad1848_dump_regs(asc);
407 #endif
408 }
409 
410 int
411 toccata_round_blocksize(void *addr, int blk,
412 			int mode, const audio_params_t *param)
413 {
414 	int ret;
415 
416 	ret = blk > 512 ? 512 : (blk & -4);
417 
418 	return ret;
419 }
420 
421 size_t
422 toccata_round_buffersize(void *addr, int direction, size_t suggested)
423 {
424 
425 	return suggested & -4;
426 }
427 
428 struct audio_device toccata_device = {
429 	"toccata", "x", "audio"
430 };
431 
432 int
433 toccata_getdev(void *addr, struct audio_device *retp)
434 {
435 
436 	*retp = toccata_device;
437 	return 0;
438 }
439 
440 int
441 toccata_get_props(void *addr)
442 {
443 	return 0;
444 }
445 
446 int
447 toccata_halt_input(void *addr)
448 {
449 	struct toccata_softc *sc;
450 	struct ad1848_softc *asc;
451 	unsigned reg;
452 
453 	sc = addr;
454 	asc = &sc->sc_ad;
455 
456 	/* we're half_duplex; be brutal */
457 	*sc->sc_boardp = TOCC_CP_TAIL;
458 	sc->sc_captmore = 0;
459 	sc->sc_captbuf = 0;
460 
461 	reg = ad_read(&sc->sc_ad, SP_INTERFACE_CONFIG);
462 	ad_write(&sc->sc_ad, SP_INTERFACE_CONFIG, (reg & ~CAPTURE_ENABLE));
463 
464 	return 0;
465 }
466 
467 int
468 toccata_start_input(void *addr, void *block, int blksize,
469 	void (*intr)(void *), void *intrarg)
470 {
471 	struct toccata_softc *sc;
472 	unsigned int reg;
473 	volatile uint8_t *cmd;
474 
475 	sc = addr;
476 	cmd = sc->sc_boardp;
477 
478 	if (sc->sc_captmore == 0) {
479 
480 		/* we're half-duplex, be brutal */
481 		*cmd = TOCC_ACT;
482 		*cmd = TOCC_CP_MAIN;
483 
484 		reg = ad_read(&sc->sc_ad, SP_INTERFACE_CONFIG);
485 		ad_write(&sc->sc_ad, SP_INTERFACE_CONFIG,
486 		    (reg | CAPTURE_ENABLE));
487 
488 	}
489 
490 	sc->sc_captarg = intrarg;
491 	sc->sc_captmore = intr;
492 	sc->sc_captbuf = (uint8_t *)block;
493 	sc->sc_captbufsz = blksize;
494 
495 	return 0;
496 }
497 
498 int
499 toccata_halt_output(void *addr)
500 {
501 	struct toccata_softc *sc;
502 	struct ad1848_softc *asc;
503 	unsigned int reg;
504 
505 	sc = addr;
506 	asc = &sc->sc_ad;
507 
508 	/* we're half_duplex; be brutal */
509 	*sc->sc_boardp = TOCC_PB_TAIL;
510 	sc->sc_playmore = 0;
511 
512 	reg = ad_read(&sc->sc_ad, SP_INTERFACE_CONFIG);
513 	ad_write(&sc->sc_ad, SP_INTERFACE_CONFIG, (reg & ~PLAYBACK_ENABLE));
514 
515 	return 0;
516 }
517 
518 int
519 toccata_start_output(void *addr, void *block, int blksize,
520 	void (*intr)(void*), void *intrarg)
521 {
522 	struct toccata_softc *sc;
523 	unsigned reg;
524 	int i;
525 	volatile uint8_t *cmd, *fifo;
526 	uint8_t *buf;
527 
528 	sc = addr;
529 	buf = block;
530 
531 	cmd = sc->sc_boardp;
532 	fifo = sc->sc_boardp + TOCC_FIFO_DATA;
533 
534 	if (sc->sc_playmore == 0) {
535 		*cmd = TOCC_ACT;
536 		*cmd = TOCC_PB_PREP;
537 	}
538 
539 	/*
540 	 * We rounded the blocksize to a multiple of 4 bytes. Modest
541 	 * unrolling saves 2% of cputime playing 48000 16bit stereo
542 	 * on 68040/25MHz.
543 	 */
544 
545 	for (i = blksize/4 - 1; i>=0; --i) {
546 		*fifo = *buf++;
547 		*fifo = *buf++;
548 		*fifo = *buf++;
549 		*fifo = *buf++;
550 	}
551 
552 	if (sc->sc_playmore == 0) {
553 		reg = ad_read(&sc->sc_ad, SP_INTERFACE_CONFIG);
554 		ad_write(&sc->sc_ad, SP_INTERFACE_CONFIG,
555 		    (reg | PLAYBACK_ENABLE));
556 
557 		/* we're half-duplex, be brutal */
558 		*sc->sc_boardp = TOCC_PB_MAIN;
559 	}
560 
561 	sc->sc_playarg = intrarg;
562 	sc->sc_playmore = intr;
563 
564 	return 0;
565 }
566 
567 static ad1848_devmap_t csmapping[] = {
568 	{ TOCCATA_MIC_IN_LVL, AD1848_KIND_MICGAIN, -1 },
569 	{ TOCCATA_AUX1_LVL, AD1848_KIND_LVL, AD1848_AUX1_CHANNEL },
570 	{ TOCCATA_AUX1_MUTE, AD1848_KIND_MUTE, AD1848_AUX1_CHANNEL },
571 	{ TOCCATA_AUX2_LVL, AD1848_KIND_LVL, AD1848_AUX2_CHANNEL },
572 	{ TOCCATA_AUX2_MUTE, AD1848_KIND_MUTE, AD1848_AUX2_CHANNEL },
573 	{ TOCCATA_OUTPUT_LVL, AD1848_KIND_LVL, AD1848_DAC_CHANNEL },
574 	{ TOCCATA_MONITOR_LVL, AD1848_KIND_LVL, AD1848_MONITOR_CHANNEL },
575 	{ TOCCATA_MONITOR_MUTE, AD1848_KIND_MUTE, AD1848_MONITOR_CHANNEL },
576 	{ TOCCATA_REC_LVL, AD1848_KIND_RECORDGAIN, -1 },
577 	{ TOCCATA_RECORD_SOURCE, AD1848_KIND_RECORDSOURCE, -1 },
578 /* only in mode 2: */
579 	{ TOCCATA_LINE_IN_LVL, AD1848_KIND_LVL, AD1848_LINE_CHANNEL },
580 	{ TOCCATA_LINE_IN_MUTE, AD1848_KIND_MUTE, AD1848_LINE_CHANNEL },
581 };
582 
583 #define nummap (sizeof(csmapping) / sizeof(csmapping[0]))
584 
585 int
586 toccata_set_port(void *addr, mixer_ctrl_t *cp)
587 {
588 	struct ad1848_softc *ac;
589 
590 	/* printf("set_port(%d)\n", cp->dev); */
591 	ac = addr;
592 	return ad1848_mixer_set_port(ac, csmapping,
593 		ac->mode == 2 ? nummap : nummap - 2, cp);
594 }
595 
596 int
597 toccata_get_port(void *addr, mixer_ctrl_t *cp)
598 {
599 	struct ad1848_softc *ac;
600 
601 	/* printf("get_port(%d)\n", cp->dev); */
602 	ac = addr;
603 	return ad1848_mixer_get_port(ac, csmapping,
604 		ac->mode == 2 ? nummap : nummap - 2, cp);
605 }
606 
607 int
608 toccata_query_devinfo(void *addr, mixer_devinfo_t *dip)
609 {
610 
611 	switch(dip->index) {
612 	case TOCCATA_MIC_IN_LVL:	/* Microphone */
613 		dip->type = AUDIO_MIXER_VALUE;
614 		dip->mixer_class = TOCCATA_INPUT_CLASS;
615 		dip->prev = dip->next = AUDIO_MIXER_LAST;
616 		strcpy(dip->label.name, AudioNmicrophone);
617 		dip->un.v.num_channels = 1;
618 		strcpy(dip->un.v.units.name, AudioNvolume);
619 		break;
620 #if 0
621 
622 	case TOCCATA_MONO_LVL:	/* mono/microphone mixer */
623 		dip->type = AUDIO_MIXER_VALUE;
624 		dip->mixer_class = TOCCATA_INPUT_CLASS;
625 		dip->prev = AUDIO_MIXER_LAST;
626 		dip->next = TOCCATA_MONO_MUTE;
627 		strcpy(dip->label.name, AudioNmicrophone);
628 		dip->un.v.num_channels = 1;
629 		strcpy(dip->un.v.units.name, AudioNvolume);
630 		break;
631 #endif
632 
633 	case TOCCATA_AUX1_LVL:		/*  dacout */
634 		dip->type = AUDIO_MIXER_VALUE;
635 		dip->mixer_class = TOCCATA_INPUT_CLASS;
636 		dip->prev = AUDIO_MIXER_LAST;
637 		dip->next = TOCCATA_AUX1_MUTE;
638 		strcpy(dip->label.name, "aux1");
639 		dip->un.v.num_channels = 2;
640 		strcpy(dip->un.v.units.name, AudioNvolume);
641 		break;
642 
643 	case TOCCATA_AUX1_MUTE:
644 		dip->mixer_class = TOCCATA_INPUT_CLASS;
645 		dip->type = AUDIO_MIXER_ENUM;
646 		dip->prev = TOCCATA_AUX1_LVL;
647 		dip->next = AUDIO_MIXER_LAST;
648 		goto mute;
649 
650 
651 
652 	case TOCCATA_AUX2_LVL:
653 		dip->type = AUDIO_MIXER_VALUE;
654 		dip->mixer_class = TOCCATA_INPUT_CLASS;
655 		dip->prev = AUDIO_MIXER_LAST;
656 		dip->next = TOCCATA_AUX2_MUTE;
657 		strcpy(dip->label.name, "aux2");
658 		dip->un.v.num_channels = 2;
659 		strcpy(dip->un.v.units.name, AudioNvolume);
660 		break;
661 
662 	case TOCCATA_AUX2_MUTE:
663 		dip->mixer_class = TOCCATA_INPUT_CLASS;
664 		dip->type = AUDIO_MIXER_ENUM;
665 		dip->prev = TOCCATA_AUX2_LVL;
666 		dip->next = AUDIO_MIXER_LAST;
667 		goto mute;
668 
669 
670 	case TOCCATA_MONITOR_LVL:	/* monitor level */
671 		dip->type = AUDIO_MIXER_VALUE;
672 		dip->mixer_class = TOCCATA_MONITOR_CLASS;
673 		dip->next = TOCCATA_MONITOR_MUTE;
674 		dip->prev = AUDIO_MIXER_LAST;
675 		strcpy(dip->label.name, AudioNmonitor);
676 		dip->un.v.num_channels = 1;
677 		strcpy(dip->un.v.units.name, AudioNvolume);
678 		break;
679 
680 	case TOCCATA_OUTPUT_LVL:	/* output volume */
681 		dip->type = AUDIO_MIXER_VALUE;
682 		dip->mixer_class = TOCCATA_OUTPUT_CLASS;
683 		dip->prev = dip->next = AUDIO_MIXER_LAST;
684 		strcpy(dip->label.name, AudioNmaster);
685 		dip->un.v.num_channels = 2;
686 		strcpy(dip->un.v.units.name, AudioNvolume);
687 		break;
688 #if 0
689 	case TOCCATA_LINE_IN_LVL:	/* line */
690 		dip->type = AUDIO_MIXER_VALUE;
691 		dip->mixer_class = TOCCATA_INPUT_CLASS;
692 		dip->prev = AUDIO_MIXER_LAST;
693 		dip->next = TOCCATA_LINE_IN_MUTE;
694 		strcpy(dip->label.name, AudioNline);
695 		dip->un.v.num_channels = 2;
696 		strcpy(dip->un.v.units.name, AudioNvolume);
697 		break;
698 
699 	case TOCCATA_LINE_IN_MUTE:
700 		dip->mixer_class = TOCCATA_INPUT_CLASS;
701 		dip->type = AUDIO_MIXER_ENUM;
702 		dip->prev = TOCCATA_LINE_IN_LVL;
703 		dip->next = AUDIO_MIXER_LAST;
704 		goto mute;
705 #endif
706 	case TOCCATA_MONITOR_MUTE:
707 		dip->mixer_class = TOCCATA_MONITOR_CLASS;
708 		dip->type = AUDIO_MIXER_ENUM;
709 		dip->prev = TOCCATA_MONITOR_LVL;
710 		dip->next = AUDIO_MIXER_LAST;
711 	mute:
712 		strcpy(dip->label.name, AudioNmute);
713 		dip->un.e.num_mem = 2;
714 		strcpy(dip->un.e.member[0].label.name, AudioNoff);
715 		dip->un.e.member[0].ord = 0;
716 		strcpy(dip->un.e.member[1].label.name, AudioNon);
717 		dip->un.e.member[1].ord = 1;
718 		break;
719 
720 	case TOCCATA_REC_LVL:	/* record level */
721 		dip->type = AUDIO_MIXER_VALUE;
722 		dip->mixer_class = TOCCATA_INPUT_CLASS;
723 		dip->prev = AUDIO_MIXER_LAST;
724 		dip->next = TOCCATA_RECORD_SOURCE;
725 		strcpy(dip->label.name, AudioNrecord);
726 		dip->un.v.num_channels = 2;
727 		strcpy(dip->un.v.units.name, AudioNvolume);
728 		break;
729 
730 	case TOCCATA_RECORD_SOURCE:
731 		dip->mixer_class = TOCCATA_RECORD_CLASS;
732 		dip->type = AUDIO_MIXER_ENUM;
733 		dip->prev = TOCCATA_REC_LVL;
734 		dip->next = AUDIO_MIXER_LAST;
735 		strcpy(dip->label.name, AudioNsource);
736 		dip->un.e.num_mem = 4;
737 		strcpy(dip->un.e.member[0].label.name, AudioNmicrophone);
738 		dip->un.e.member[1].ord = MIC_IN_PORT;
739 		strcpy(dip->un.e.member[1].label.name, AudioNline);
740 		dip->un.e.member[3].ord = LINE_IN_PORT;
741 		strcpy(dip->un.e.member[2].label.name, "aux1");
742 		dip->un.e.member[2].ord = AUX1_IN_PORT;
743 		strcpy(dip->un.e.member[3].label.name, AudioNoutput);
744 		dip->un.e.member[0].ord = DAC_IN_PORT;
745 		break;
746 
747 	case TOCCATA_INPUT_CLASS:		/* input class descriptor */
748 		dip->type = AUDIO_MIXER_CLASS;
749 		dip->mixer_class = TOCCATA_INPUT_CLASS;
750 		dip->next = dip->prev = AUDIO_MIXER_LAST;
751 		strcpy(dip->label.name, AudioCinputs);
752 		break;
753 
754 	case TOCCATA_OUTPUT_CLASS:		/* output class descriptor */
755 		dip->type = AUDIO_MIXER_CLASS;
756 		dip->mixer_class = TOCCATA_OUTPUT_CLASS;
757 		dip->next = dip->prev = AUDIO_MIXER_LAST;
758 		strcpy(dip->label.name, AudioCoutputs);
759 		break;
760 
761 	case TOCCATA_MONITOR_CLASS:		/* monitor class descriptor */
762 		dip->type = AUDIO_MIXER_CLASS;
763 		dip->mixer_class = TOCCATA_MONITOR_CLASS;
764 		dip->next = dip->prev = AUDIO_MIXER_LAST;
765 		strcpy(dip->label.name, AudioCmonitor);
766 		break;
767 
768 	case TOCCATA_RECORD_CLASS:		/* record source class */
769 		dip->type = AUDIO_MIXER_CLASS;
770 		dip->mixer_class = TOCCATA_RECORD_CLASS;
771 		dip->next = dip->prev = AUDIO_MIXER_LAST;
772 		strcpy(dip->label.name, AudioCrecord);
773 		break;
774 
775 	default:
776 		return ENXIO;
777 		/*NOTREACHED*/
778 	}
779 
780 	return 0;
781 }
782