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