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