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