Home | History | Annotate | Line # | Download | only in dev
toccata.c revision 1.14
      1 /* $NetBSD: toccata.c,v 1.14 2011/07/19 15:55:27 dyoung 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 2011/07/19 15:55:27 dyoung 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 const struct audio_hw_if audiocs_hw_if = {
    178 	toccata_open,
    179 	toccata_close,
    180 	0,	/*
    181 		 * XXX toccata_drain could be written:
    182 		 * sleep for play interrupt. This loses less then 512 bytes of
    183 		 * sample data, otherwise up to 1024.
    184 		 */
    185 	ad1848_query_encoding,
    186 	ad1848_set_params,
    187 	toccata_round_blocksize,
    188 	ad1848_commit_settings,
    189 	0,	/* init_output */	/* XXX need this to prefill? */
    190 	0,	/* init_input */
    191 	toccata_start_output,
    192 	toccata_start_input,
    193 	toccata_halt_output,
    194 	toccata_halt_input,
    195 	0,	/* speaker */
    196 	toccata_getdev,
    197 	0,	/* setfd */
    198 	toccata_set_port,
    199 	toccata_get_port,
    200 	toccata_query_devinfo,
    201 	0,	/* alloc/free */
    202 	0,
    203 	toccata_round_buffersize, /* round_buffer */
    204 	0,	/* mappage */
    205 	toccata_get_props,
    206 	0,	/* trigger_output */
    207 	0,
    208 };
    209 
    210 struct toccata_softc {
    211 	struct ad1848_softc	sc_ad;
    212 	struct isr		sc_isr;
    213 	volatile uint8_t	*sc_boardp; /* only need a few addresses! */
    214 
    215 	void			(*sc_captmore)(void *);
    216 	void			 *sc_captarg;
    217 	void			 *sc_captbuf;
    218 	int			sc_captbufsz;
    219 
    220 	void			(*sc_playmore)(void *);
    221 	void			 *sc_playarg;
    222 };
    223 
    224 int toccata_match(device_t, cfdata_t, void *);
    225 void toccata_attach(device_t, device_t, void *);
    226 
    227 CFATTACH_DECL_NEW(toccata, sizeof(struct toccata_softc),
    228     toccata_match, toccata_attach, NULL, NULL);
    229 
    230 int
    231 toccata_match(device_t parent, cfdata_t cfp, void *aux)
    232 {
    233 	struct zbus_args *zap;
    234 
    235 	zap = aux;
    236 
    237 	if (zap->manid != 18260)
    238 		return (0);
    239 
    240 	if (zap->prodid != 12)
    241 		return (0);
    242 
    243 	return (1);
    244 }
    245 
    246 void
    247 toccata_attach(device_t parent, device_t self, void *aux)
    248 {
    249 	struct toccata_softc *sc;
    250 	struct ad1848_softc *asc;
    251 	struct zbus_args *zap;
    252 	volatile uint8_t *boardp;
    253 
    254 	sc = device_private(self);
    255 	asc = &sc->sc_ad;
    256 	asc->sc_dev = self;
    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, self);
    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",
    333 	    device_xname(sc->sc_ad.sc_dev), 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