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