Home | History | Annotate | Line # | Download | only in isa
aria.c revision 1.27.28.1
      1  1.27.28.1    bouyer /*	$NetBSD: aria.c,v 1.27.28.1 2007/10/25 22:38:07 bouyer Exp $	*/
      2        1.5   mycroft 
      3        1.1  augustss /*-
      4        1.1  augustss  * Copyright (c) 1995, 1996, 1998 Roland C. Dowdeswell.  All rights reserved.
      5        1.1  augustss  *
      6        1.1  augustss  * Redistribution and use in source and binary forms, with or without
      7        1.1  augustss  * modification, are permitted provided that the following conditions
      8        1.1  augustss  * are met:
      9        1.1  augustss  * 1. Redistributions of source code must retain the above copyright
     10        1.1  augustss  *    notice, this list of conditions and the following disclaimer.
     11        1.1  augustss  * 2. Redistributions in binary form must reproduce the above copyright
     12        1.1  augustss  *    notice, this list of conditions and the following disclaimer in the
     13        1.1  augustss  *    documentation and/or other materials provided with the distribution.
     14        1.1  augustss  * 3. All advertising materials mentioning features or use of this software
     15        1.1  augustss  *    must display the following acknowledgement:
     16        1.1  augustss  *      This product includes software developed by Roland C. Dowdeswell.
     17        1.1  augustss  * 4. The name of the authors may not be used to endorse or promote products
     18        1.1  augustss  *      derived from this software without specific prior written permission.
     19        1.1  augustss  *
     20        1.1  augustss  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
     21        1.1  augustss  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22        1.1  augustss  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23        1.1  augustss  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
     24        1.1  augustss  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25        1.1  augustss  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26        1.1  augustss  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27        1.1  augustss  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28        1.1  augustss  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29        1.1  augustss  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30        1.1  augustss  */
     31        1.1  augustss 
     32        1.1  augustss /*-
     33        1.1  augustss  * TODO:
     34        1.1  augustss  *  o   Test the driver on cards other than a single
     35        1.1  augustss  *      Prometheus Aria 16.
     36        1.1  augustss  *  o   Look into where aria_prometheus_kludge() belongs.
     37       1.18       wiz  *  o   Add some DMA code.  It accomplishes its goal by
     38        1.1  augustss  *      direct IO at the moment.
     39        1.1  augustss  *  o   Different programs should be able to open the device
     40        1.1  augustss  *      with O_RDONLY and O_WRONLY at the same time.  But I
     41        1.1  augustss  *      do not see support for this in /sys/dev/audio.c, so
     42        1.1  augustss  *	I cannot effectively code it.
     43       1.17       wiz  *  o   We should nicely deal with the cards that can do mu-law
     44       1.17       wiz  *      and A-law output.
     45        1.1  augustss  *  o   Rework the mixer interface.
     46        1.1  augustss  *       o   Deal with the lvls better.  We need to do better mapping
     47        1.1  augustss  *           between logarithmic scales and the one byte that
     48        1.1  augustss  *           we are passed.
     49        1.1  augustss  *       o   Deal better with cards that have no mixer.
     50        1.1  augustss  */
     51       1.11     lukem 
     52       1.11     lukem #include <sys/cdefs.h>
     53  1.27.28.1    bouyer __KERNEL_RCSID(0, "$NetBSD: aria.c,v 1.27.28.1 2007/10/25 22:38:07 bouyer Exp $");
     54        1.1  augustss 
     55        1.1  augustss #include <sys/param.h>
     56        1.1  augustss #include <sys/systm.h>
     57        1.1  augustss #include <sys/errno.h>
     58        1.1  augustss #include <sys/ioctl.h>
     59        1.1  augustss #include <sys/syslog.h>
     60        1.1  augustss #include <sys/device.h>
     61        1.1  augustss #include <sys/proc.h>
     62        1.1  augustss #include <sys/buf.h>
     63       1.20   mycroft #include <sys/fcntl.h>
     64        1.1  augustss 
     65  1.27.28.1    bouyer #include <sys/cpu.h>
     66  1.27.28.1    bouyer #include <sys/bus.h>
     67        1.1  augustss 
     68        1.1  augustss #include <sys/audioio.h>
     69        1.1  augustss #include <dev/audio_if.h>
     70        1.1  augustss #include <dev/auconv.h>
     71        1.1  augustss 
     72        1.1  augustss #include <dev/mulaw.h>
     73        1.1  augustss #include <dev/isa/isavar.h>
     74        1.1  augustss 
     75        1.1  augustss #include <dev/isa/ariareg.h>
     76        1.1  augustss 
     77        1.1  augustss #ifdef AUDIO_DEBUG
     78        1.1  augustss #define DPRINTF(x)	printf x
     79        1.1  augustss int	ariadebug = 0;
     80        1.1  augustss #else
     81        1.1  augustss #define DPRINTF(x)
     82        1.1  augustss #endif
     83        1.1  augustss 
     84        1.1  augustss struct aria_mixdev_info {
     85        1.1  augustss 	u_char	num_channels;
     86        1.1  augustss 	u_char	level[2];
     87        1.1  augustss 	u_char	mute;
     88        1.1  augustss };
     89        1.1  augustss 
     90        1.1  augustss struct aria_mixmaster {
     91        1.1  augustss 	u_char num_channels;
     92        1.1  augustss 	u_char level[2];
     93        1.1  augustss 	u_char treble[2];
     94        1.1  augustss 	u_char bass[2];
     95        1.1  augustss };
     96        1.1  augustss 
     97        1.1  augustss struct aria_softc {
     98        1.1  augustss 	struct	device sc_dev;		/* base device */
     99        1.1  augustss 	void	*sc_ih;			/* interrupt vectoring */
    100        1.1  augustss 	bus_space_tag_t sc_iot;		/* Tag on 'da bus. */
    101        1.1  augustss 	bus_space_handle_t sc_ioh;	/* Handle of iospace */
    102        1.2   thorpej 	isa_chipset_tag_t sc_ic;	/* ISA chipset info */
    103        1.1  augustss 
    104        1.1  augustss 	u_short	sc_open;		/* reference count of open calls */
    105        1.1  augustss 	u_short sc_play;		/* non-paused play chans 2**chan */
    106        1.1  augustss 	u_short sc_record;		/* non-paused record chans 2**chan */
    107        1.1  augustss /* XXX -- keep this? */
    108        1.1  augustss 	u_short sc_gain[2];		/* left/right gain (play) */
    109        1.1  augustss 
    110        1.1  augustss 	u_long	sc_rate;		/* Sample rate for input and output */
    111       1.17       wiz 	u_int	sc_encoding;		/* audio encoding -- mu-law/linear */
    112        1.1  augustss 	int	sc_chans;		/* # of channels */
    113        1.1  augustss 	int	sc_precision;		/* # bits per sample */
    114        1.1  augustss 
    115        1.1  augustss 	u_long	sc_interrupts;		/* number of interrupts taken */
    116        1.1  augustss 	void	(*sc_rintr)(void*);	/* record transfer completion intr handler */
    117        1.1  augustss 	void	(*sc_pintr)(void*);	/* play transfer completion intr handler */
    118        1.1  augustss 	void	*sc_rarg;		/* arg for sc_rintr() */
    119        1.1  augustss 	void	*sc_parg;		/* arg for sc_pintr() */
    120        1.1  augustss 
    121        1.1  augustss 	int	sc_blocksize;		/* literal dio block size */
    122        1.1  augustss 	void	*sc_rdiobuffer;		/* record: where the next samples should be */
    123        1.1  augustss 	void	*sc_pdiobuffer;		/* play:   where the next samples are */
    124        1.1  augustss 
    125        1.1  augustss 	u_short sc_hardware;		/* bit field of hardware present */
    126        1.1  augustss #define ARIA_TELEPHONE	0x0001		/* has telephone input */
    127        1.1  augustss #define ARIA_MIXER	0x0002		/* has SC18075 digital mixer */
    128        1.1  augustss #define ARIA_MODEL	0x0004		/* is SC18025 (=0) or SC18026 (=1) */
    129        1.1  augustss 
    130        1.1  augustss 	struct aria_mixdev_info aria_mix[6];
    131        1.1  augustss 	struct aria_mixmaster ariamix_master;
    132        1.1  augustss 	u_char	aria_mix_source;
    133        1.1  augustss 
    134        1.1  augustss 	int	sc_sendcmd_err;
    135        1.1  augustss };
    136        1.1  augustss 
    137       1.23      kent int	ariaprobe(struct device *, struct cfdata *, void *);
    138       1.23      kent void	ariaattach(struct device *, struct device *, void *);
    139       1.23      kent void	ariaclose(void *);
    140       1.23      kent int	ariaopen(void *, int);
    141       1.23      kent int	ariareset(bus_space_tag_t, bus_space_handle_t);
    142       1.23      kent int	aria_reset(struct aria_softc *);
    143       1.23      kent int	aria_getdev(void *, struct audio_device *);
    144       1.23      kent 
    145       1.23      kent void	aria_do_kludge(bus_space_tag_t, bus_space_handle_t,
    146       1.23      kent 		       bus_space_handle_t,
    147       1.23      kent 		       u_short, u_short, u_short, u_short);
    148       1.23      kent void	aria_prometheus_kludge(struct isa_attach_args *, bus_space_handle_t);
    149       1.23      kent 
    150       1.23      kent int	aria_query_encoding(void *, struct audio_encoding *);
    151       1.23      kent int	aria_round_blocksize(void *, int, int, const audio_params_t *);
    152       1.23      kent int	aria_speaker_ctl(void *, int);
    153       1.23      kent int	aria_commit_settings(void *);
    154       1.23      kent int	aria_set_params(void *, int, int, audio_params_t *, audio_params_t *,
    155       1.23      kent 			stream_filter_list_t *, stream_filter_list_t *);
    156       1.23      kent int	aria_get_props(void *);
    157       1.23      kent 
    158       1.23      kent int	aria_start_output(void *, void *, int, void (*)(void *), void*);
    159       1.23      kent int	aria_start_input(void *, void *, int, void (*)(void *), void*);
    160       1.23      kent 
    161       1.23      kent int	aria_halt_input(void *);
    162       1.23      kent int	aria_halt_output(void *);
    163       1.23      kent 
    164       1.23      kent int	aria_sendcmd(struct aria_softc *, u_short, int, int, int);
    165       1.23      kent 
    166       1.23      kent u_short	aria_getdspmem(struct aria_softc *, u_short);
    167       1.23      kent void	aria_putdspmem(struct aria_softc *, u_short, u_short);
    168       1.23      kent 
    169       1.23      kent int	aria_intr(void *);
    170       1.23      kent short	ariaversion(struct aria_softc *);
    171       1.23      kent 
    172       1.23      kent void	aria_set_mixer(struct aria_softc *, int);
    173       1.23      kent 
    174       1.23      kent void	aria_mix_write(struct aria_softc *, int, int);
    175       1.23      kent int	aria_mix_read(struct aria_softc *, int);
    176       1.23      kent 
    177       1.23      kent int	aria_mixer_set_port(void *, mixer_ctrl_t *);
    178       1.23      kent int	aria_mixer_get_port(void *, mixer_ctrl_t *);
    179       1.23      kent int	aria_mixer_query_devinfo(void *, mixer_devinfo_t *);
    180        1.1  augustss 
    181       1.14   thorpej CFATTACH_DECL(aria, sizeof(struct aria_softc),
    182       1.15   thorpej     ariaprobe, ariaattach, NULL, NULL);
    183        1.1  augustss 
    184        1.1  augustss /* XXX temporary test for 1.3 */
    185        1.1  augustss #ifndef AudioNaux
    186        1.1  augustss /* 1.3 */
    187        1.1  augustss struct cfdriver aria_cd = {
    188        1.1  augustss 	NULL, "aria", DV_DULL
    189        1.1  augustss };
    190        1.1  augustss #endif
    191        1.1  augustss 
    192        1.1  augustss struct audio_device aria_device = {
    193        1.1  augustss 	"Aria 16(se)",
    194        1.1  augustss 	"x",
    195        1.1  augustss 	"aria"
    196        1.1  augustss };
    197        1.1  augustss 
    198        1.1  augustss /*
    199        1.1  augustss  * Define our interface to the higher level audio driver.
    200        1.1  augustss  */
    201        1.1  augustss 
    202       1.21      yamt const struct audio_hw_if aria_hw_if = {
    203        1.1  augustss 	ariaopen,
    204        1.1  augustss 	ariaclose,
    205        1.1  augustss 	NULL,
    206        1.1  augustss 	aria_query_encoding,
    207        1.1  augustss 	aria_set_params,
    208        1.1  augustss 	aria_round_blocksize,
    209        1.1  augustss 	aria_commit_settings,
    210        1.1  augustss 	NULL,
    211        1.1  augustss 	NULL,
    212        1.1  augustss 	aria_start_output,
    213        1.1  augustss 	aria_start_input,
    214        1.1  augustss 	aria_halt_input,
    215        1.1  augustss 	aria_halt_output,
    216        1.1  augustss 	NULL,
    217        1.1  augustss 	aria_getdev,
    218        1.1  augustss 	NULL,
    219        1.1  augustss 	aria_mixer_set_port,
    220        1.1  augustss 	aria_mixer_get_port,
    221        1.1  augustss 	aria_mixer_query_devinfo,
    222        1.1  augustss 	NULL,
    223        1.1  augustss 	NULL,
    224        1.1  augustss 	NULL,
    225        1.1  augustss 	NULL,
    226        1.1  augustss 	aria_get_props,
    227       1.10  augustss 	NULL,
    228       1.10  augustss 	NULL,
    229       1.10  augustss 	NULL,
    230       1.25  christos 	NULL,
    231        1.1  augustss };
    232        1.1  augustss 
    233        1.1  augustss /*
    234        1.1  augustss  * Probe / attach routines.
    235        1.1  augustss  */
    236        1.1  augustss 
    237        1.1  augustss /*
    238        1.1  augustss  * Probe for the aria hardware.
    239        1.1  augustss  */
    240        1.1  augustss int
    241       1.27  christos ariaprobe(struct device *parent, struct cfdata *cf, void *aux)
    242        1.1  augustss {
    243        1.1  augustss 	bus_space_handle_t ioh;
    244       1.23      kent 	struct isa_attach_args *ia;
    245        1.1  augustss 
    246       1.23      kent 	ia = aux;
    247       1.12   thorpej 	if (ia->ia_nio < 1)
    248       1.23      kent 		return 0;
    249       1.12   thorpej 	if (ia->ia_nirq < 1)
    250       1.23      kent 		return 0;
    251       1.12   thorpej 
    252       1.12   thorpej 	if (ISA_DIRECT_CONFIG(ia))
    253       1.23      kent 		return 0;
    254       1.12   thorpej 
    255       1.12   thorpej 	if (!ARIA_BASE_VALID(ia->ia_io[0].ir_addr)) {
    256       1.12   thorpej 		printf("aria: configured iobase %d invalid\n",
    257       1.12   thorpej 		    ia->ia_io[0].ir_addr);
    258        1.1  augustss 		return 0;
    259        1.1  augustss 	}
    260       1.23      kent 
    261       1.12   thorpej 	if (!ARIA_IRQ_VALID(ia->ia_irq[0].ir_irq)) {
    262       1.12   thorpej 		printf("aria: configured irq %d invalid\n",
    263       1.12   thorpej 		    ia->ia_irq[0].ir_irq);
    264        1.1  augustss 		return 0;
    265        1.1  augustss 	}
    266        1.1  augustss 
    267       1.12   thorpej 	if (bus_space_map(ia->ia_iot, ia->ia_io[0].ir_addr, ARIADSP_NPORT,
    268       1.12   thorpej 	    0, &ioh)) {
    269        1.1  augustss 		DPRINTF(("aria: aria probe failed\n"));
    270        1.1  augustss 		return 0;
    271        1.1  augustss 	}
    272        1.1  augustss 
    273        1.1  augustss 	if (cf->cf_flags & 1)
    274        1.1  augustss 		aria_prometheus_kludge(ia, ioh);
    275        1.1  augustss 
    276        1.1  augustss 	if (ariareset(ia->ia_iot, ioh) != 0) {
    277        1.1  augustss 		DPRINTF(("aria: aria probe failed\n"));
    278        1.1  augustss 		bus_space_unmap(ia->ia_iot, ioh,  ARIADSP_NPORT);
    279        1.1  augustss 		return 0;
    280        1.1  augustss 	}
    281        1.1  augustss 
    282       1.12   thorpej 	bus_space_unmap(ia->ia_iot, ioh, ARIADSP_NPORT);
    283       1.12   thorpej 
    284       1.12   thorpej 	ia->ia_nio = 1;
    285       1.12   thorpej 	ia->ia_io[0].ir_size = ARIADSP_NPORT;
    286       1.12   thorpej 
    287       1.12   thorpej 	ia->ia_nirq = 1;
    288       1.12   thorpej 
    289       1.12   thorpej 	ia->ia_niomem = 0;
    290       1.12   thorpej 	ia->ia_ndrq = 0;
    291        1.1  augustss 
    292        1.1  augustss 	DPRINTF(("aria: aria probe succeeded\n"));
    293        1.1  augustss 	return 1;
    294        1.1  augustss }
    295        1.1  augustss 
    296        1.1  augustss /*
    297        1.1  augustss  * I didn't call this a kludge for
    298        1.1  augustss  * nothing.  This is cribbed from
    299        1.1  augustss  * ariainit, the author of that
    300        1.1  augustss  * disassembled some code to discover
    301        1.1  augustss  * how to set up the initial values of
    302        1.1  augustss  * the card.  Without this, the card
    303        1.1  augustss  * is dead. (It will not respond to _any_
    304        1.1  augustss  * input at all.)
    305        1.1  augustss  *
    306        1.1  augustss  * ariainit can be found (ftp) at:
    307        1.1  augustss  * ftp://ftp.wi.leidenuniv.nl/pub/audio/aria/programming/contrib/ariainit.zip
    308        1.1  augustss  * currently.
    309        1.1  augustss  */
    310        1.1  augustss 
    311        1.1  augustss void
    312       1.23      kent aria_prometheus_kludge(struct isa_attach_args *ia, bus_space_handle_t ioh1)
    313        1.1  augustss {
    314        1.1  augustss 	bus_space_tag_t iot;
    315        1.1  augustss 	bus_space_handle_t ioh;
    316        1.1  augustss 	u_short	end;
    317        1.1  augustss 
    318        1.1  augustss 	DPRINTF(("aria: begin aria_prometheus_kludge\n"));
    319        1.1  augustss 
    320       1.23      kent 	/* Begin Config Sequence */
    321        1.1  augustss 
    322        1.1  augustss 	iot = ia->ia_iot;
    323        1.1  augustss 	bus_space_map(iot, 0x200, 8, 0, &ioh);
    324        1.1  augustss 
    325       1.23      kent 	bus_space_write_1(iot, ioh, 4, 0x4c);
    326       1.23      kent 	bus_space_write_1(iot, ioh, 5, 0x42);
    327       1.23      kent 	bus_space_write_1(iot, ioh, 6, 0x00);
    328       1.23      kent 	bus_space_write_2(iot, ioh, 0, 0x0f);
    329       1.23      kent 	bus_space_write_1(iot, ioh, 1, 0x00);
    330       1.23      kent 	bus_space_write_2(iot, ioh, 0, 0x02);
    331       1.23      kent 	bus_space_write_1(iot, ioh, 1, ia->ia_io[0].ir_addr>>2);
    332       1.23      kent 
    333       1.23      kent 	/*
    334       1.23      kent 	 * These next three lines set up the iobase
    335       1.23      kent 	 * and the irq; and disable the drq.
    336       1.23      kent 	 */
    337       1.12   thorpej 	aria_do_kludge(iot, ioh, ioh1, 0x111,
    338       1.12   thorpej 	    ((ia->ia_io[0].ir_addr-0x280)>>2)+0xA0, 0xbf, 0xa0);
    339       1.12   thorpej 	aria_do_kludge(iot, ioh, ioh1, 0x011,
    340       1.12   thorpej 	    ia->ia_irq[0].ir_irq-6, 0xf8, 0x00);
    341        1.1  augustss 	aria_do_kludge(iot, ioh, ioh1, 0x011, 0x00, 0xef, 0x00);
    342        1.1  augustss 
    343       1.23      kent 	/* The rest of these lines just disable everything else */
    344        1.1  augustss 	aria_do_kludge(iot, ioh, ioh1, 0x113, 0x00, 0x88, 0x00);
    345        1.1  augustss 	aria_do_kludge(iot, ioh, ioh1, 0x013, 0x00, 0xf8, 0x00);
    346        1.1  augustss 	aria_do_kludge(iot, ioh, ioh1, 0x013, 0x00, 0xef, 0x00);
    347        1.1  augustss 	aria_do_kludge(iot, ioh, ioh1, 0x117, 0x00, 0x88, 0x00);
    348        1.1  augustss 	aria_do_kludge(iot, ioh, ioh1, 0x017, 0x00, 0xff, 0x00);
    349        1.1  augustss 
    350       1.23      kent 	/* End Sequence */
    351        1.1  augustss 	bus_space_write_1(iot, ioh, 0, 0x0f);
    352        1.1  augustss 	end = bus_space_read_1(iot, ioh1, 0);
    353        1.1  augustss 	bus_space_write_2(iot, ioh, 0, 0x0f);
    354        1.1  augustss 	bus_space_write_1(iot, ioh, 1, end|0x80);
    355        1.1  augustss 	bus_space_read_1(iot, ioh, 0);
    356        1.1  augustss 
    357        1.1  augustss 	bus_space_unmap(iot, ioh, 8);
    358       1.23      kent 	/*
    359       1.23      kent 	 * This delay is necessary for some reason,
    360       1.23      kent 	 * at least it would crash, and sometimes not
    361       1.23      kent 	 * probe properly if it did not exist.
    362       1.23      kent 	 */
    363        1.1  augustss 	delay(1000000);
    364        1.1  augustss }
    365        1.1  augustss 
    366        1.1  augustss void
    367       1.23      kent aria_do_kludge(
    368       1.23      kent 	bus_space_tag_t iot,
    369       1.23      kent 	bus_space_handle_t ioh,
    370       1.23      kent 	bus_space_handle_t ioh1,
    371       1.23      kent 	u_short func,
    372       1.23      kent 	u_short bits,
    373       1.23      kent 	u_short and,
    374       1.23      kent 	u_short or)
    375        1.1  augustss {
    376        1.1  augustss 	u_int i;
    377       1.23      kent 
    378        1.1  augustss 	if (func & 0x100) {
    379        1.1  augustss 		func &= ~0x100;
    380        1.1  augustss 		if (bits) {
    381        1.1  augustss 			bus_space_write_2(iot, ioh, 0, func-1);
    382        1.1  augustss 			bus_space_write_1(iot, ioh, 1, bits);
    383        1.1  augustss 		}
    384        1.1  augustss 	} else
    385        1.1  augustss 		or |= bits;
    386        1.1  augustss 
    387        1.1  augustss 	bus_space_write_1(iot, ioh, 0, func);
    388        1.1  augustss 	i = bus_space_read_1(iot, ioh1, 0);
    389        1.1  augustss 	bus_space_write_2(iot, ioh, 0, func);
    390        1.1  augustss 	bus_space_write_1(iot, ioh, 1, (i&and) | or);
    391        1.1  augustss }
    392        1.1  augustss 
    393        1.1  augustss /*
    394        1.1  augustss  * Attach hardware to driver, attach hardware driver to audio
    395        1.1  augustss  * pseudo-device driver.
    396        1.1  augustss  */
    397        1.1  augustss void
    398       1.27  christos ariaattach(struct device *parent, struct device *self, void *aux)
    399        1.1  augustss {
    400        1.1  augustss 	bus_space_handle_t ioh;
    401       1.23      kent 	struct aria_softc *sc;
    402       1.23      kent 	struct isa_attach_args *ia;
    403        1.1  augustss 	u_short i;
    404        1.1  augustss 
    405       1.23      kent 	sc = (void *)self;
    406       1.23      kent 	ia = aux;
    407       1.12   thorpej 	if (bus_space_map(ia->ia_iot, ia->ia_io[0].ir_addr, ARIADSP_NPORT,
    408       1.12   thorpej 	    0, &ioh))
    409        1.1  augustss 		panic("%s: can map io port range", self->dv_xname);
    410        1.1  augustss 
    411        1.1  augustss 	sc->sc_iot = ia->ia_iot;
    412        1.1  augustss 	sc->sc_ioh = ioh;
    413        1.2   thorpej 	sc->sc_ic = ia->ia_ic;
    414        1.1  augustss 
    415       1.12   thorpej 	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
    416       1.12   thorpej 	    IST_EDGE, IPL_AUDIO, aria_intr, sc);
    417        1.1  augustss 
    418        1.1  augustss 	DPRINTF(("isa_intr_establish() returns (%x)\n", (unsigned) sc->sc_ih));
    419        1.1  augustss 
    420        1.1  augustss 	i = aria_getdspmem(sc, ARIAA_HARDWARE_A);
    421        1.1  augustss 
    422        1.1  augustss 	sc->sc_hardware  = 0;
    423        1.1  augustss 	sc->sc_hardware |= ((i>>13)&0x01)==1 ? ARIA_TELEPHONE:0;
    424        1.1  augustss 	sc->sc_hardware |= (((i>>5)&0x07))==0x04 ? ARIA_MIXER:0;
    425        1.1  augustss 	sc->sc_hardware |= (aria_getdspmem(sc, ARIAA_MODEL_A)>=1)?ARIA_MODEL:0;
    426        1.1  augustss 
    427        1.1  augustss 	sc->sc_open       = 0;
    428        1.1  augustss 	sc->sc_play       = 0;
    429        1.1  augustss 	sc->sc_record     = 0;
    430        1.1  augustss 	sc->sc_rate       = 7875;
    431        1.1  augustss 	sc->sc_chans      = 1;
    432        1.1  augustss 	sc->sc_blocksize  = 1024;
    433        1.1  augustss 	sc->sc_precision  = 8;
    434       1.23      kent 	sc->sc_rintr      = 0;
    435       1.23      kent 	sc->sc_rarg       = 0;
    436       1.23      kent 	sc->sc_pintr      = 0;
    437       1.23      kent 	sc->sc_parg       = 0;
    438        1.1  augustss 	sc->sc_gain[0]       = 127;
    439        1.1  augustss 	sc->sc_gain[1]       = 127;
    440        1.1  augustss 
    441        1.1  augustss 	for (i=0; i<6; i++) {
    442        1.1  augustss 		if (i == ARIAMIX_TEL_LVL)
    443        1.1  augustss 			sc->aria_mix[i].num_channels = 1;
    444        1.1  augustss 		else
    445        1.1  augustss 			sc->aria_mix[i].num_channels = 2;
    446        1.1  augustss 		sc->aria_mix[i].level[0] = 127;
    447        1.1  augustss 		sc->aria_mix[i].level[1] = 127;
    448        1.1  augustss 	}
    449        1.1  augustss 
    450        1.1  augustss 	sc->ariamix_master.num_channels = 2;
    451        1.1  augustss 	sc->ariamix_master.level[0] = 222;
    452        1.1  augustss 	sc->ariamix_master.level[1] = 222;
    453        1.1  augustss 	sc->ariamix_master.bass[0] = 127;
    454        1.1  augustss 	sc->ariamix_master.bass[1] = 127;
    455        1.1  augustss 	sc->ariamix_master.treble[0] = 127;
    456        1.1  augustss 	sc->ariamix_master.treble[1] = 127;
    457        1.1  augustss 	sc->aria_mix_source = 0;
    458        1.1  augustss 
    459        1.1  augustss 	aria_commit_settings(sc);
    460        1.1  augustss 
    461        1.1  augustss 	printf(": dsp %s", (ARIA_MODEL&sc->sc_hardware)?"SC18026":"SC18025");
    462        1.1  augustss 	if (ARIA_TELEPHONE&sc->sc_hardware)
    463        1.1  augustss 		printf(", tel");
    464        1.1  augustss 	if (ARIA_MIXER&sc->sc_hardware)
    465        1.1  augustss 		printf(", SC18075 mixer");
    466        1.1  augustss 	printf("\n");
    467        1.1  augustss 
    468       1.23      kent 	snprintf(aria_device.version, sizeof(aria_device.version), "%s",
    469        1.1  augustss 		ARIA_MODEL & sc->sc_hardware ? "SC18026" : "SC18025");
    470        1.1  augustss 
    471        1.6  augustss 	audio_attach_mi(&aria_hw_if, (void *)sc, &sc->sc_dev);
    472        1.1  augustss }
    473        1.1  augustss 
    474        1.1  augustss /*
    475        1.1  augustss  * Various routines to interface to higher level audio driver
    476        1.1  augustss  */
    477        1.1  augustss 
    478        1.1  augustss int
    479       1.23      kent ariaopen(void *addr, int flags)
    480        1.1  augustss {
    481       1.23      kent 	struct aria_softc *sc;
    482        1.1  augustss 
    483       1.23      kent 	sc = addr;
    484        1.1  augustss 	DPRINTF(("ariaopen() called\n"));
    485       1.23      kent 
    486        1.1  augustss 	if (!sc)
    487        1.1  augustss 		return ENXIO;
    488       1.23      kent 
    489        1.1  augustss 	if (flags&FREAD)
    490        1.1  augustss 		sc->sc_open |= ARIAR_OPEN_RECORD;
    491        1.1  augustss 	if (flags&FWRITE)
    492        1.1  augustss 		sc->sc_open |= ARIAR_OPEN_PLAY;
    493        1.1  augustss 
    494        1.1  augustss 	return 0;
    495        1.1  augustss }
    496        1.1  augustss 
    497        1.1  augustss int
    498       1.27  christos aria_getdev(void *addr, struct audio_device *retp)
    499        1.1  augustss {
    500       1.23      kent 
    501        1.1  augustss 	*retp = aria_device;
    502        1.1  augustss 	return 0;
    503        1.1  augustss }
    504        1.1  augustss 
    505        1.1  augustss /*
    506        1.1  augustss  * Various routines to interface to higher level audio driver
    507        1.1  augustss  */
    508        1.1  augustss 
    509        1.1  augustss int
    510       1.23      kent aria_query_encoding(void *addr, struct audio_encoding *fp)
    511        1.1  augustss {
    512       1.23      kent 	struct aria_softc *sc;
    513        1.1  augustss 
    514       1.23      kent 	sc = addr;
    515        1.1  augustss 	switch (fp->index) {
    516        1.1  augustss 		case 0:
    517        1.1  augustss 			strcpy(fp->name, AudioEmulaw);
    518        1.1  augustss 			fp->encoding = AUDIO_ENCODING_ULAW;
    519        1.1  augustss 			fp->precision = 8;
    520        1.1  augustss 			if ((ARIA_MODEL&sc->sc_hardware) == 0)
    521        1.1  augustss 				fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
    522        1.1  augustss 			break;
    523        1.1  augustss 		case 1:
    524        1.1  augustss 			strcpy(fp->name, AudioEalaw);
    525        1.1  augustss 			fp->encoding = AUDIO_ENCODING_ALAW;
    526        1.1  augustss 			fp->precision = 8;
    527        1.1  augustss 			if ((ARIA_MODEL&sc->sc_hardware) == 0)
    528        1.1  augustss 				fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
    529        1.1  augustss 			break;
    530        1.1  augustss 		case 2:
    531        1.1  augustss 			strcpy(fp->name, AudioEslinear);
    532        1.1  augustss 			fp->encoding = AUDIO_ENCODING_SLINEAR;
    533        1.1  augustss 			fp->precision = 8;
    534        1.1  augustss 			fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
    535        1.1  augustss 			break;
    536        1.1  augustss 		case 3:
    537        1.1  augustss 			strcpy(fp->name, AudioEslinear_le);
    538        1.1  augustss 			fp->encoding = AUDIO_ENCODING_SLINEAR_LE;
    539        1.1  augustss 			fp->precision = 16;
    540        1.1  augustss 			fp->flags = 0;
    541        1.1  augustss 			break;
    542        1.1  augustss 		case 4:
    543        1.1  augustss 			strcpy(fp->name, AudioEslinear_be);
    544        1.1  augustss 			fp->encoding = AUDIO_ENCODING_SLINEAR_BE;
    545        1.1  augustss 			fp->precision = 16;
    546        1.1  augustss 			fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
    547        1.1  augustss 			break;
    548        1.1  augustss 		case 5:
    549        1.1  augustss 			strcpy(fp->name, AudioEulinear);
    550        1.1  augustss 			fp->encoding = AUDIO_ENCODING_ULINEAR;
    551        1.1  augustss 			fp->precision = 8;
    552        1.1  augustss 			fp->flags = 0;
    553        1.1  augustss 			break;
    554        1.1  augustss 		case 6:
    555        1.1  augustss 			strcpy(fp->name, AudioEulinear_le);
    556        1.1  augustss 			fp->encoding = AUDIO_ENCODING_ULINEAR_LE;
    557        1.1  augustss 			fp->precision = 16;
    558        1.1  augustss 			fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
    559        1.1  augustss 			break;
    560        1.1  augustss 		case 7:
    561        1.1  augustss 			strcpy(fp->name, AudioEulinear_be);
    562        1.1  augustss 			fp->encoding = AUDIO_ENCODING_ULINEAR_BE;
    563        1.1  augustss 			fp->precision = 16;
    564        1.1  augustss 			fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
    565        1.1  augustss 			break;
    566        1.1  augustss 		default:
    567       1.23      kent 			return EINVAL;
    568        1.1  augustss 		/*NOTREACHED*/
    569        1.1  augustss 	}
    570        1.1  augustss 
    571       1.23      kent 	return 0;
    572        1.1  augustss }
    573        1.1  augustss 
    574        1.1  augustss /*
    575        1.1  augustss  * Store blocksize in bytes.
    576        1.1  augustss  */
    577        1.1  augustss 
    578        1.1  augustss int
    579       1.27  christos aria_round_blocksize(void *addr, int blk, int mode,
    580       1.27  christos     const audio_params_t *param)
    581        1.1  augustss {
    582        1.1  augustss 	int i;
    583       1.23      kent 
    584        1.1  augustss #if 0 /* XXX -- this is being a tad bit of a problem... */
    585       1.23      kent 	for (i = 64; i < 1024; i *= 2)
    586        1.1  augustss 		if (blk <= i)
    587        1.1  augustss 			break;
    588        1.1  augustss #else
    589        1.1  augustss 	i = 1024;
    590        1.1  augustss #endif
    591       1.23      kent 	return i;
    592        1.1  augustss }
    593        1.1  augustss 
    594        1.1  augustss int
    595       1.27  christos aria_get_props(void *addr)
    596        1.1  augustss {
    597       1.23      kent 
    598        1.1  augustss 	return AUDIO_PROP_FULLDUPLEX;
    599        1.1  augustss }
    600        1.1  augustss 
    601        1.1  augustss int
    602       1.23      kent aria_set_params(
    603       1.26  christos     void *addr,
    604       1.27  christos     int setmode,
    605       1.27  christos     int usemode,
    606       1.26  christos     audio_params_t *p,
    607       1.27  christos     audio_params_t *r,
    608       1.26  christos     stream_filter_list_t *pfil,
    609       1.26  christos     stream_filter_list_t *rfil
    610       1.26  christos )
    611        1.1  augustss {
    612       1.22      kent 	audio_params_t hw;
    613       1.23      kent 	struct aria_softc *sc;
    614        1.1  augustss 
    615       1.23      kent 	sc = addr;
    616        1.1  augustss 	switch(p->encoding) {
    617        1.1  augustss 	case AUDIO_ENCODING_ULAW:
    618        1.1  augustss 	case AUDIO_ENCODING_ALAW:
    619        1.1  augustss 	case AUDIO_ENCODING_SLINEAR:
    620        1.1  augustss 	case AUDIO_ENCODING_SLINEAR_LE:
    621        1.1  augustss 	case AUDIO_ENCODING_SLINEAR_BE:
    622        1.1  augustss 	case AUDIO_ENCODING_ULINEAR:
    623        1.1  augustss 	case AUDIO_ENCODING_ULINEAR_LE:
    624        1.1  augustss 	case AUDIO_ENCODING_ULINEAR_BE:
    625        1.1  augustss 		break;
    626        1.1  augustss 	default:
    627       1.23      kent 		return EINVAL;
    628        1.1  augustss 	}
    629        1.1  augustss 
    630        1.1  augustss 	if (p->sample_rate <= 9450)
    631        1.1  augustss 		p->sample_rate = 7875;
    632        1.1  augustss 	else if (p->sample_rate <= 13387)
    633        1.1  augustss 		p->sample_rate = 11025;
    634        1.1  augustss 	else if (p->sample_rate <= 18900)
    635        1.1  augustss 		p->sample_rate = 15750;
    636        1.1  augustss 	else if (p->sample_rate <= 26775)
    637        1.1  augustss 		p->sample_rate = 22050;
    638        1.1  augustss 	else if (p->sample_rate <= 37800)
    639        1.1  augustss 		p->sample_rate = 31500;
    640        1.1  augustss 	else
    641        1.1  augustss 		p->sample_rate = 44100;
    642        1.1  augustss 
    643       1.22      kent 	hw = *p;
    644        1.1  augustss 	sc->sc_encoding = p->encoding;
    645        1.1  augustss 	sc->sc_precision = p->precision;
    646        1.1  augustss 	sc->sc_chans = p->channels;
    647        1.1  augustss 	sc->sc_rate = p->sample_rate;
    648        1.1  augustss 
    649        1.1  augustss 	switch(p->encoding) {
    650        1.1  augustss 	case AUDIO_ENCODING_ULAW:
    651        1.1  augustss 		if ((ARIA_MODEL&sc->sc_hardware) == 0) {
    652       1.22      kent 			hw.encoding = AUDIO_ENCODING_ULINEAR_LE;
    653       1.23      kent 			pfil->append(pfil, mulaw_to_linear8, &hw);
    654       1.23      kent 			rfil->append(rfil, linear8_to_mulaw, &hw);
    655        1.1  augustss 		}
    656        1.1  augustss 		break;
    657        1.1  augustss 	case AUDIO_ENCODING_ALAW:
    658        1.1  augustss 		if ((ARIA_MODEL&sc->sc_hardware) == 0) {
    659       1.22      kent 			hw.encoding = AUDIO_ENCODING_ULINEAR_LE;
    660       1.23      kent 			pfil->append(pfil, alaw_to_linear8, &hw);
    661       1.23      kent 			rfil->append(rfil, linear8_to_alaw, &hw);
    662        1.1  augustss 		}
    663        1.1  augustss 		break;
    664        1.1  augustss 	case AUDIO_ENCODING_SLINEAR:
    665       1.22      kent 		hw.encoding = AUDIO_ENCODING_ULINEAR_LE;
    666       1.23      kent 		pfil->append(pfil, change_sign8, &hw);
    667       1.23      kent 		rfil->append(rfil, change_sign8, &hw);
    668        1.1  augustss 		break;
    669        1.1  augustss 	case AUDIO_ENCODING_ULINEAR_LE:
    670       1.22      kent 		hw.encoding = AUDIO_ENCODING_SLINEAR_LE;
    671       1.23      kent 		pfil->append(pfil, change_sign16, &hw);
    672       1.23      kent 		rfil->append(rfil, change_sign16, &hw);
    673        1.1  augustss 		break;
    674        1.1  augustss 	case AUDIO_ENCODING_SLINEAR_BE:
    675       1.22      kent 		hw.encoding = AUDIO_ENCODING_SLINEAR_LE;
    676       1.23      kent 		pfil->append(pfil, swap_bytes, &hw);
    677       1.23      kent 		rfil->append(rfil, swap_bytes, &hw);
    678        1.1  augustss 		break;
    679        1.1  augustss 	case AUDIO_ENCODING_ULINEAR_BE:
    680       1.22      kent 		hw.encoding = AUDIO_ENCODING_SLINEAR_LE;
    681       1.23      kent 		pfil->append(pfil, swap_bytes_change_sign16, &hw);
    682       1.23      kent 		rfil->append(rfil, swap_bytes_change_sign16, &hw);
    683        1.1  augustss 		break;
    684        1.1  augustss 	}
    685        1.1  augustss 
    686        1.1  augustss 	return 0;
    687        1.1  augustss }
    688        1.1  augustss 
    689        1.1  augustss /*
    690        1.1  augustss  * This is where all of the twiddling goes on.
    691        1.1  augustss  */
    692        1.1  augustss 
    693        1.1  augustss int
    694       1.23      kent aria_commit_settings(void *addr)
    695        1.1  augustss {
    696       1.23      kent 	static u_char tones[16] =
    697        1.1  augustss 	    { 7, 6, 5, 4, 3, 2, 1, 0, 8, 9, 10, 11, 12, 13, 14, 15 };
    698       1.23      kent 	struct aria_softc *sc;
    699       1.23      kent 	bus_space_tag_t iot;
    700       1.23      kent 	bus_space_handle_t ioh;
    701        1.1  augustss 	u_short format;
    702        1.1  augustss 	u_short left, right;
    703        1.1  augustss 	u_short samp;
    704        1.1  augustss 	u_char i;
    705        1.1  augustss 
    706        1.1  augustss 	DPRINTF(("aria_commit_settings\n"));
    707        1.1  augustss 
    708       1.23      kent 	sc = addr;
    709       1.23      kent 	iot = sc->sc_iot;
    710       1.23      kent 	ioh = sc->sc_ioh;
    711        1.1  augustss 	switch (sc->sc_rate) {
    712        1.1  augustss 	case  7875: format = 0x00; samp = 0x60; break;
    713        1.1  augustss 	case 11025: format = 0x00; samp = 0x40; break;
    714        1.1  augustss 	case 15750: format = 0x10; samp = 0x60; break;
    715        1.1  augustss 	case 22050: format = 0x10; samp = 0x40; break;
    716        1.1  augustss 	case 31500: format = 0x10; samp = 0x20; break;
    717        1.1  augustss 	case 44100: format = 0x20; samp = 0x00; break;
    718        1.1  augustss 	default:    format = 0x00; samp = 0x40; break;/* XXX can we get here? */
    719        1.1  augustss 	}
    720        1.1  augustss 
    721        1.1  augustss 	if ((ARIA_MODEL&sc->sc_hardware) != 0) {
    722       1.23      kent 		format |= sc->sc_encoding == AUDIO_ENCODING_ULAW ? 0x06 : 0x00;
    723       1.23      kent 		format |= sc->sc_encoding == AUDIO_ENCODING_ALAW ? 0x08 : 0x00;
    724        1.1  augustss 	}
    725       1.23      kent 
    726       1.23      kent 	format |= (sc->sc_precision == 16) ? 0x02 : 0x00;
    727       1.23      kent 	format |= (sc->sc_chans == 2) ? 1 : 0;
    728        1.1  augustss 	samp |= bus_space_read_2(iot, ioh, ARIADSP_STATUS) & ~0x60;
    729        1.1  augustss 
    730        1.1  augustss 	aria_sendcmd(sc, ARIADSPC_FORMAT, format, -1, -1);
    731        1.1  augustss 	bus_space_write_2(iot, ioh, ARIADSP_CONTROL, samp);
    732        1.1  augustss 
    733        1.1  augustss 	if (sc->sc_hardware&ARIA_MIXER) {
    734        1.1  augustss 		for (i = 0; i < 6; i++)
    735        1.1  augustss 			aria_set_mixer(sc, i);
    736       1.23      kent 
    737        1.1  augustss 		if (sc->sc_chans==2) {
    738       1.23      kent 			aria_sendcmd(sc, ARIADSPC_CHAN_VOL, ARIAR_PLAY_CHAN,
    739        1.1  augustss 				     ((sc->sc_gain[0]+sc->sc_gain[1])/2)<<7,
    740        1.1  augustss 				     -1);
    741       1.23      kent 			aria_sendcmd(sc, ARIADSPC_CHAN_PAN, ARIAR_PLAY_CHAN,
    742        1.1  augustss 				     (sc->sc_gain[0]-sc->sc_gain[1])/4+0x40,
    743        1.1  augustss 				     -1);
    744        1.1  augustss 		} else {
    745       1.23      kent 			aria_sendcmd(sc, ARIADSPC_CHAN_VOL, ARIAR_PLAY_CHAN,
    746        1.1  augustss 				     sc->sc_gain[0]<<7, -1);
    747       1.23      kent 			aria_sendcmd(sc, ARIADSPC_CHAN_PAN, ARIAR_PLAY_CHAN,
    748        1.1  augustss 				     0x40, -1);
    749        1.1  augustss 		}
    750        1.1  augustss 
    751       1.23      kent 		aria_sendcmd(sc, ARIADSPC_MASMONMODE,
    752        1.1  augustss 			     sc->ariamix_master.num_channels != 2, -1, -1);
    753        1.1  augustss 
    754       1.23      kent 		aria_sendcmd(sc, ARIADSPC_MIXERVOL, 0x0004,
    755       1.23      kent 			     sc->ariamix_master.level[0] << 7,
    756        1.1  augustss 			     sc->ariamix_master.level[1] << 7);
    757        1.1  augustss 
    758        1.1  augustss 		/* Convert treble/bass from byte to soundcard style */
    759        1.1  augustss 
    760       1.23      kent 		left  = (tones[(sc->ariamix_master.treble[0]>>4)&0x0f]<<8) |
    761        1.1  augustss 			 tones[(sc->ariamix_master.bass[0]>>4)&0x0f];
    762       1.23      kent 		right = (tones[(sc->ariamix_master.treble[1]>>4)&0x0f]<<8) |
    763        1.1  augustss 			 tones[(sc->ariamix_master.bass[1]>>4)&0x0f];
    764        1.1  augustss 
    765        1.1  augustss 		aria_sendcmd(sc, ARIADSPC_TONE, left, right, -1);
    766        1.1  augustss 	}
    767        1.1  augustss 
    768        1.1  augustss 	aria_sendcmd(sc, ARIADSPC_BLOCKSIZE, sc->sc_blocksize/2, -1, -1);
    769        1.1  augustss 
    770        1.1  augustss /*
    771        1.1  augustss  * If we think that the card is recording or playing, start it up again here.
    772        1.1  augustss  * Some of the previous commands turn the channels off.
    773        1.1  augustss  */
    774        1.1  augustss 
    775        1.1  augustss 	if (sc->sc_record&(1<<ARIAR_RECORD_CHAN))
    776        1.1  augustss 		aria_sendcmd(sc, ARIADSPC_START_REC, ARIAR_RECORD_CHAN, -1,-1);
    777        1.1  augustss 
    778        1.1  augustss 	if (sc->sc_play&(1<<ARIAR_PLAY_CHAN))
    779        1.1  augustss 		aria_sendcmd(sc, ARIADSPC_START_PLAY, ARIAR_PLAY_CHAN, -1, -1);
    780        1.1  augustss 
    781       1.23      kent 	return 0;
    782        1.1  augustss }
    783        1.1  augustss 
    784        1.1  augustss void
    785       1.23      kent aria_set_mixer(struct aria_softc *sc, int i)
    786        1.1  augustss {
    787        1.1  augustss 	u_char source;
    788       1.23      kent 
    789        1.1  augustss 	switch(i) {
    790        1.1  augustss 	case ARIAMIX_MIC_LVL:     source = 0x0001; break;
    791        1.1  augustss 	case ARIAMIX_CD_LVL:      source = 0x0002; break;
    792        1.1  augustss 	case ARIAMIX_LINE_IN_LVL: source = 0x0008; break;
    793        1.1  augustss 	case ARIAMIX_TEL_LVL:     source = 0x0020; break;
    794        1.1  augustss 	case ARIAMIX_AUX_LVL:     source = 0x0010; break;
    795        1.1  augustss 	case ARIAMIX_DAC_LVL:     source = 0x0004; break;
    796       1.23      kent 	default:		  source = 0x0000; break;
    797        1.1  augustss 	}
    798       1.23      kent 
    799        1.1  augustss 	if (source != 0x0000 && source != 0x0004) {
    800        1.1  augustss 		if (sc->aria_mix[i].mute == 1)
    801        1.1  augustss 			aria_sendcmd(sc, ARIADSPC_INPMONMODE, source, 3, -1);
    802        1.1  augustss 		else
    803       1.23      kent 			aria_sendcmd(sc, ARIADSPC_INPMONMODE, source,
    804       1.23      kent 				     sc->aria_mix[i].num_channels != 2, -1);
    805       1.23      kent 
    806       1.23      kent 		aria_sendcmd(sc, ARIADSPC_INPMONMODE, 0x8000|source,
    807        1.1  augustss 			     sc->aria_mix[i].num_channels != 2, -1);
    808       1.23      kent 		aria_sendcmd(sc, ARIADSPC_MIXERVOL, source,
    809       1.23      kent 			     sc->aria_mix[i].level[0] << 7,
    810        1.1  augustss 			     sc->aria_mix[i].level[1] << 7);
    811        1.1  augustss 	}
    812       1.23      kent 
    813        1.1  augustss 	if (sc->aria_mix_source == i) {
    814        1.1  augustss 		aria_sendcmd(sc, ARIADSPC_ADCSOURCE, source, -1, -1);
    815       1.23      kent 
    816        1.1  augustss 		if (sc->sc_open & ARIAR_OPEN_RECORD)
    817        1.1  augustss 			aria_sendcmd(sc, ARIADSPC_ADCCONTROL, 1, -1, -1);
    818       1.23      kent 		else
    819        1.1  augustss 			aria_sendcmd(sc, ARIADSPC_ADCCONTROL, 0, -1, -1);
    820        1.1  augustss 	}
    821        1.1  augustss }
    822        1.1  augustss 
    823        1.1  augustss void
    824       1.23      kent ariaclose(void *addr)
    825        1.1  augustss {
    826       1.23      kent 	struct aria_softc *sc;
    827        1.1  augustss 
    828       1.23      kent 	sc = addr;
    829       1.23      kent 	DPRINTF(("aria_close sc=%p\n", sc));
    830        1.1  augustss 
    831        1.1  augustss 	sc->sc_open = 0;
    832        1.1  augustss 
    833        1.1  augustss 	if (aria_reset(sc) != 0) {
    834        1.1  augustss 		delay(500);
    835        1.1  augustss 		aria_reset(sc);
    836        1.1  augustss 	}
    837        1.1  augustss }
    838        1.1  augustss 
    839        1.1  augustss /*
    840        1.1  augustss  * Reset the hardware.
    841        1.1  augustss  */
    842        1.1  augustss 
    843       1.23      kent int ariareset(bus_space_tag_t iot, bus_space_handle_t ioh)
    844        1.1  augustss {
    845       1.23      kent 	struct aria_softc tmp, *sc;
    846        1.1  augustss 
    847       1.23      kent 	sc = &tmp;
    848        1.1  augustss 	sc->sc_iot = iot;
    849        1.1  augustss 	sc->sc_ioh = ioh;
    850        1.1  augustss 	return aria_reset(sc);
    851        1.1  augustss }
    852        1.1  augustss 
    853        1.1  augustss int
    854       1.23      kent aria_reset(struct aria_softc *sc)
    855        1.1  augustss {
    856       1.23      kent 	bus_space_tag_t iot;
    857       1.23      kent 	bus_space_handle_t ioh;
    858       1.23      kent 	int fail;
    859        1.1  augustss 	int i;
    860        1.1  augustss 
    861       1.23      kent 	iot = sc->sc_iot;
    862       1.23      kent 	ioh = sc->sc_ioh;
    863       1.23      kent 	fail = 0;
    864       1.23      kent 	bus_space_write_2(iot, ioh, ARIADSP_CONTROL,
    865        1.1  augustss 			  ARIAR_ARIA_SYNTH | ARIAR_SR22K|ARIAR_DSPINTWR);
    866        1.1  augustss 	aria_putdspmem(sc, 0x6102, 0);
    867        1.1  augustss 
    868        1.1  augustss 	fail |= aria_sendcmd(sc, ARIADSPC_SYSINIT, 0x0000, 0x0000, 0x0000);
    869        1.1  augustss 
    870        1.1  augustss 	for (i=0; i < ARIAR_NPOLL; i++)
    871        1.1  augustss 		if (aria_getdspmem(sc, ARIAA_TASK_A) == 1)
    872        1.1  augustss 			break;
    873        1.1  augustss 
    874       1.23      kent 	bus_space_write_2(iot, ioh, ARIADSP_CONTROL,
    875        1.1  augustss 			  ARIAR_ARIA_SYNTH|ARIAR_SR22K | ARIAR_DSPINTWR |
    876        1.1  augustss 			  ARIAR_PCINTWR);
    877        1.1  augustss 	fail |= aria_sendcmd(sc, ARIADSPC_MODE, ARIAV_MODE_NO_SYNTH,-1,-1);
    878        1.1  augustss 
    879       1.23      kent 	return fail;
    880        1.1  augustss }
    881        1.1  augustss 
    882        1.1  augustss /*
    883        1.1  augustss  * Lower-level routines
    884        1.1  augustss  */
    885        1.1  augustss 
    886        1.1  augustss void
    887       1.23      kent aria_putdspmem(struct aria_softc *sc, u_short loc, u_short val)
    888        1.1  augustss {
    889       1.23      kent 	bus_space_tag_t iot;
    890       1.23      kent 	bus_space_handle_t ioh;
    891       1.23      kent 
    892       1.23      kent 	iot = sc->sc_iot;
    893       1.23      kent 	ioh = sc->sc_ioh;
    894        1.1  augustss 	bus_space_write_2(iot, ioh, ARIADSP_DMAADDRESS, loc);
    895        1.1  augustss 	bus_space_write_2(iot, ioh, ARIADSP_DMADATA, val);
    896        1.1  augustss }
    897        1.1  augustss 
    898        1.1  augustss u_short
    899       1.23      kent aria_getdspmem(struct aria_softc *sc, u_short loc)
    900        1.1  augustss {
    901       1.23      kent 	bus_space_tag_t iot;
    902       1.23      kent 	bus_space_handle_t ioh;
    903       1.23      kent 
    904       1.23      kent 	iot = sc->sc_iot;
    905       1.23      kent 	ioh = sc->sc_ioh;
    906        1.1  augustss 	bus_space_write_2(iot, ioh, ARIADSP_DMAADDRESS, loc);
    907        1.1  augustss 	return bus_space_read_2(iot, ioh, ARIADSP_DMADATA);
    908        1.1  augustss }
    909        1.1  augustss 
    910        1.1  augustss /*
    911        1.1  augustss  * aria_sendcmd()
    912        1.1  augustss  *  each full DSP command is unified into this
    913        1.1  augustss  *  function.
    914        1.1  augustss  */
    915        1.1  augustss 
    916        1.1  augustss #define ARIASEND(data, flag) \
    917        1.1  augustss 	for (i = ARIAR_NPOLL; \
    918        1.1  augustss 	     (bus_space_read_2(iot, ioh, ARIADSP_STATUS) & ARIAR_BUSY) && i>0; \
    919        1.1  augustss 	     i--) \
    920        1.1  augustss 		; \
    921        1.1  augustss 	if (bus_space_read_2(iot, ioh, ARIADSP_STATUS) & ARIAR_BUSY) \
    922        1.1  augustss 		fail |= flag; \
    923        1.1  augustss 	bus_space_write_2(iot, ioh, ARIADSP_WRITE, (u_short)data)
    924        1.1  augustss 
    925        1.1  augustss int
    926       1.23      kent aria_sendcmd(struct aria_softc *sc, u_short command,
    927       1.23      kent 	     int arg1, int arg2, int arg3)
    928       1.23      kent {
    929       1.23      kent 	bus_space_tag_t iot;
    930       1.23      kent 	bus_space_handle_t ioh;
    931       1.23      kent 	int i, fail;
    932        1.1  augustss 
    933       1.23      kent 	iot = sc->sc_iot;
    934       1.23      kent 	ioh = sc->sc_ioh;
    935       1.23      kent 	fail = 0;
    936        1.1  augustss 	ARIASEND(command, 1);
    937        1.1  augustss 	if (arg1 != -1) {
    938        1.1  augustss 		ARIASEND(arg1, 2);
    939        1.1  augustss 	}
    940        1.1  augustss 	if (arg2 != -1) {
    941        1.1  augustss 		ARIASEND(arg2, 4);
    942        1.1  augustss 	}
    943        1.1  augustss 	if (arg3 != -1) {
    944        1.1  augustss 		ARIASEND(arg3, 8);
    945        1.1  augustss 	}
    946        1.1  augustss 	ARIASEND(ARIADSPC_TERM, 16);
    947       1.23      kent 
    948        1.1  augustss 	if (fail) {
    949        1.1  augustss 		sc->sc_sendcmd_err++;
    950        1.1  augustss #ifdef AUDIO_DEBUG
    951        1.1  augustss 		DPRINTF(("aria_sendcmd: failure=(%d) cmd=(0x%x) fail=(0x%x)\n",
    952        1.1  augustss 			 sc->sc_sendcmd_err, command, fail));
    953        1.1  augustss #endif
    954        1.1  augustss 		return -1;
    955        1.1  augustss 	}
    956        1.1  augustss 
    957        1.1  augustss 	return 0;
    958        1.1  augustss }
    959        1.1  augustss #undef ARIASEND
    960        1.1  augustss 
    961        1.1  augustss int
    962       1.23      kent aria_halt_input(void *addr)
    963        1.1  augustss {
    964       1.23      kent 	struct aria_softc *sc;
    965        1.1  augustss 
    966       1.23      kent 	sc = addr;
    967        1.1  augustss 	DPRINTF(("aria_halt_input\n"));
    968        1.1  augustss 
    969        1.1  augustss 	if (sc->sc_record & (1<<0)) {
    970        1.1  augustss 		aria_sendcmd(sc, ARIADSPC_STOP_REC, 0, -1, -1);
    971        1.1  augustss 		sc->sc_record &= ~(1<<0);
    972       1.20   mycroft 		sc->sc_rdiobuffer = 0;
    973        1.1  augustss 	}
    974        1.1  augustss 
    975       1.23      kent 	return 0;
    976        1.1  augustss }
    977        1.1  augustss 
    978        1.1  augustss int
    979       1.23      kent aria_halt_output(void *addr)
    980        1.1  augustss {
    981       1.23      kent 	struct aria_softc *sc;
    982        1.1  augustss 
    983       1.23      kent 	sc = addr;
    984        1.1  augustss 	DPRINTF(("aria_halt_output\n"));
    985        1.1  augustss 
    986        1.1  augustss 	if (sc->sc_play & (1<<1)) {
    987        1.1  augustss 		aria_sendcmd(sc, ARIADSPC_STOP_PLAY, 1, -1, -1);
    988        1.1  augustss 		sc->sc_play &= ~(1<<1);
    989       1.20   mycroft 		sc->sc_pdiobuffer = 0;
    990        1.1  augustss 	}
    991        1.1  augustss 
    992       1.23      kent 	return 0;
    993        1.1  augustss }
    994        1.1  augustss 
    995        1.1  augustss /*
    996        1.1  augustss  * Here we just set up the buffers.  If we receive
    997        1.1  augustss  * an interrupt without these set, it is ignored.
    998        1.1  augustss  */
    999        1.1  augustss 
   1000        1.1  augustss int
   1001       1.23      kent aria_start_input(void *addr, void *p, int cc, void (*intr)(void *), void *arg)
   1002        1.1  augustss {
   1003       1.23      kent 	struct aria_softc *sc;
   1004        1.1  augustss 
   1005       1.23      kent 	sc = addr;
   1006       1.23      kent 	DPRINTF(("aria_start_input %d @ %p\n", cc, p));
   1007        1.1  augustss 
   1008        1.1  augustss 	if (cc != sc->sc_blocksize) {
   1009        1.1  augustss 		DPRINTF(("aria_start_input reqsize %d not sc_blocksize %d\n",
   1010        1.1  augustss 			cc, sc->sc_blocksize));
   1011        1.1  augustss 		return EINVAL;
   1012        1.1  augustss 	}
   1013        1.1  augustss 
   1014        1.1  augustss 	sc->sc_rarg = arg;
   1015        1.1  augustss 	sc->sc_rintr = intr;
   1016        1.1  augustss 	sc->sc_rdiobuffer = p;
   1017        1.1  augustss 
   1018        1.1  augustss 	if (!(sc->sc_record&(1<<ARIAR_RECORD_CHAN))) {
   1019        1.1  augustss 		aria_sendcmd(sc, ARIADSPC_START_REC, ARIAR_RECORD_CHAN, -1,-1);
   1020        1.1  augustss 		sc->sc_record |= (1<<ARIAR_RECORD_CHAN);
   1021        1.1  augustss 	}
   1022        1.1  augustss 
   1023        1.1  augustss 	return 0;
   1024        1.1  augustss }
   1025        1.1  augustss 
   1026        1.1  augustss int
   1027       1.23      kent aria_start_output(void *addr, void *p, int cc, void (*intr)(void *), void *arg)
   1028        1.1  augustss {
   1029       1.23      kent 	struct aria_softc *sc;
   1030        1.1  augustss 
   1031       1.23      kent 	sc = addr;
   1032       1.23      kent 	DPRINTF(("aria_start_output %d @ %p\n", cc, p));
   1033        1.1  augustss 
   1034        1.1  augustss 	if (cc != sc->sc_blocksize) {
   1035        1.1  augustss 		DPRINTF(("aria_start_output reqsize %d not sc_blocksize %d\n",
   1036        1.1  augustss 			cc, sc->sc_blocksize));
   1037        1.1  augustss 		return EINVAL;
   1038        1.1  augustss 	}
   1039        1.1  augustss 
   1040        1.1  augustss 	sc->sc_parg = arg;
   1041        1.1  augustss 	sc->sc_pintr = intr;
   1042        1.1  augustss 	sc->sc_pdiobuffer = p;
   1043        1.1  augustss 
   1044        1.1  augustss 	if (!(sc->sc_play&(1<<ARIAR_PLAY_CHAN))) {
   1045        1.1  augustss 		aria_sendcmd(sc, ARIADSPC_START_PLAY, ARIAR_PLAY_CHAN, -1, -1);
   1046        1.1  augustss 		sc->sc_play |= (1<<ARIAR_PLAY_CHAN);
   1047        1.1  augustss 	}
   1048        1.1  augustss 
   1049        1.1  augustss 	return 0;
   1050        1.1  augustss }
   1051        1.1  augustss 
   1052        1.1  augustss /*
   1053        1.1  augustss  * Process an interrupt.  This should be a
   1054        1.1  augustss  * request (from the card) to write or read
   1055        1.1  augustss  * samples.
   1056        1.1  augustss  */
   1057        1.1  augustss int
   1058       1.23      kent aria_intr(void *arg)
   1059        1.1  augustss {
   1060       1.23      kent 	struct aria_softc *sc;
   1061       1.23      kent 	bus_space_tag_t iot;
   1062       1.23      kent 	bus_space_handle_t ioh;
   1063       1.23      kent 	u_short *pdata;
   1064       1.23      kent 	u_short *rdata;
   1065        1.1  augustss 	u_short address;
   1066        1.1  augustss 
   1067       1.23      kent 	sc = arg;
   1068       1.23      kent 	iot = sc->sc_iot;
   1069       1.23      kent 	ioh = sc->sc_ioh;
   1070       1.23      kent 	pdata = sc->sc_pdiobuffer;
   1071       1.23      kent 	rdata = sc->sc_rdiobuffer;
   1072        1.1  augustss #if 0 /*  XXX --  BAD BAD BAD (That this is #define'd out */
   1073        1.1  augustss 	DPRINTF(("Checking to see if this is our intr\n"));
   1074        1.1  augustss 
   1075       1.23      kent 	if ((inw(iobase) & 1) != 0x1)
   1076        1.1  augustss 		return 0;  /* not for us */
   1077        1.1  augustss #endif
   1078        1.1  augustss 
   1079        1.1  augustss 	sc->sc_interrupts++;
   1080        1.1  augustss 
   1081        1.1  augustss 	DPRINTF(("aria_intr\n"));
   1082        1.1  augustss 
   1083        1.1  augustss 	if ((sc->sc_open & ARIAR_OPEN_PLAY) && (pdata!=NULL)) {
   1084        1.1  augustss 		DPRINTF(("aria_intr play=(%x)\n", (unsigned) pdata));
   1085        1.1  augustss 		address = 0x8000 - 2*(sc->sc_blocksize);
   1086        1.1  augustss 		address+= aria_getdspmem(sc, ARIAA_PLAY_FIFO_A);
   1087        1.1  augustss 		bus_space_write_2(iot, ioh, ARIADSP_DMAADDRESS, address);
   1088       1.23      kent 		bus_space_write_multi_2(iot, ioh, ARIADSP_DMADATA, pdata,
   1089        1.1  augustss 					sc->sc_blocksize / 2);
   1090        1.1  augustss 		if (sc->sc_pintr != NULL)
   1091        1.1  augustss 			(*sc->sc_pintr)(sc->sc_parg);
   1092        1.1  augustss 	}
   1093        1.1  augustss 
   1094        1.1  augustss 	if ((sc->sc_open & ARIAR_OPEN_RECORD) && (rdata!=NULL)) {
   1095        1.1  augustss 		DPRINTF(("aria_intr record=(%x)\n", (unsigned) rdata));
   1096        1.1  augustss 		address = 0x8000 - (sc->sc_blocksize);
   1097        1.1  augustss 		address+= aria_getdspmem(sc, ARIAA_REC_FIFO_A);
   1098        1.1  augustss 		bus_space_write_2(iot, ioh, ARIADSP_DMAADDRESS, address);
   1099       1.23      kent 		bus_space_read_multi_2(iot, ioh, ARIADSP_DMADATA, rdata,
   1100        1.1  augustss 				       sc->sc_blocksize / 2);
   1101        1.1  augustss 		if (sc->sc_rintr != NULL)
   1102        1.1  augustss 			(*sc->sc_rintr)(sc->sc_rarg);
   1103        1.1  augustss 	}
   1104        1.1  augustss 
   1105        1.1  augustss 	aria_sendcmd(sc, ARIADSPC_TRANSCOMPLETE, -1, -1, -1);
   1106        1.1  augustss 
   1107        1.1  augustss 	return 1;
   1108        1.1  augustss }
   1109        1.1  augustss 
   1110        1.1  augustss int
   1111       1.23      kent aria_mixer_set_port(void *addr, mixer_ctrl_t *cp)
   1112        1.1  augustss {
   1113       1.23      kent 	struct aria_softc *sc;
   1114       1.23      kent 	int error;
   1115        1.1  augustss 
   1116        1.1  augustss 	DPRINTF(("aria_mixer_set_port\n"));
   1117       1.23      kent 	sc = addr;
   1118       1.23      kent 	error = EINVAL;
   1119        1.1  augustss 
   1120        1.1  augustss 	/* This could be done better, no mixer still has some controls. */
   1121        1.1  augustss 	if (!(ARIA_MIXER & sc->sc_hardware))
   1122        1.1  augustss 		return ENXIO;
   1123        1.1  augustss 
   1124        1.1  augustss 	if (cp->type == AUDIO_MIXER_VALUE) {
   1125        1.1  augustss 		mixer_level_t *mv = &cp->un.value;
   1126        1.1  augustss 		switch (cp->dev) {
   1127        1.1  augustss 		case ARIAMIX_MIC_LVL:
   1128        1.1  augustss 			if (mv->num_channels == 1 || mv->num_channels == 2) {
   1129       1.23      kent 				sc->aria_mix[ARIAMIX_MIC_LVL].num_channels =
   1130        1.1  augustss 					mv->num_channels;
   1131       1.23      kent 				sc->aria_mix[ARIAMIX_MIC_LVL].level[0] =
   1132        1.1  augustss 					mv->level[0];
   1133       1.23      kent 				sc->aria_mix[ARIAMIX_MIC_LVL].level[1] =
   1134        1.1  augustss 					mv->level[1];
   1135        1.1  augustss 				error = 0;
   1136        1.1  augustss 			}
   1137        1.1  augustss 			break;
   1138       1.23      kent 
   1139        1.1  augustss 		case ARIAMIX_LINE_IN_LVL:
   1140        1.1  augustss 			if (mv->num_channels == 1 || mv->num_channels == 2) {
   1141        1.1  augustss 				sc->aria_mix[ARIAMIX_LINE_IN_LVL].num_channels=
   1142        1.1  augustss 					mv->num_channels;
   1143       1.23      kent 				sc->aria_mix[ARIAMIX_LINE_IN_LVL].level[0] =
   1144        1.1  augustss 					mv->level[0];
   1145       1.23      kent 				sc->aria_mix[ARIAMIX_LINE_IN_LVL].level[1] =
   1146        1.1  augustss 					mv->level[1];
   1147        1.1  augustss 				error = 0;
   1148        1.1  augustss 			}
   1149        1.1  augustss 			break;
   1150       1.23      kent 
   1151        1.1  augustss 		case ARIAMIX_CD_LVL:
   1152        1.1  augustss 			if (mv->num_channels == 1 || mv->num_channels == 2) {
   1153       1.23      kent 				sc->aria_mix[ARIAMIX_CD_LVL].num_channels =
   1154        1.1  augustss 					mv->num_channels;
   1155       1.23      kent 				sc->aria_mix[ARIAMIX_CD_LVL].level[0] =
   1156        1.1  augustss 					mv->level[0];
   1157       1.23      kent 				sc->aria_mix[ARIAMIX_CD_LVL].level[1] =
   1158        1.1  augustss 					mv->level[1];
   1159        1.1  augustss 				error = 0;
   1160        1.1  augustss 			}
   1161        1.1  augustss 			break;
   1162       1.23      kent 
   1163        1.1  augustss 		case ARIAMIX_TEL_LVL:
   1164        1.1  augustss 			if (mv->num_channels == 1) {
   1165       1.23      kent 				sc->aria_mix[ARIAMIX_TEL_LVL].num_channels =
   1166        1.1  augustss 					mv->num_channels;
   1167       1.23      kent 				sc->aria_mix[ARIAMIX_TEL_LVL].level[0] =
   1168        1.1  augustss 					mv->level[0];
   1169        1.1  augustss 				error = 0;
   1170        1.1  augustss 			}
   1171        1.1  augustss 			break;
   1172       1.23      kent 
   1173        1.1  augustss 		case ARIAMIX_DAC_LVL:
   1174        1.1  augustss 			if (mv->num_channels == 1 || mv->num_channels == 2) {
   1175       1.23      kent 				sc->aria_mix[ARIAMIX_DAC_LVL].num_channels =
   1176        1.1  augustss 					mv->num_channels;
   1177       1.23      kent 				sc->aria_mix[ARIAMIX_DAC_LVL].level[0] =
   1178        1.1  augustss 					mv->level[0];
   1179       1.23      kent 				sc->aria_mix[ARIAMIX_DAC_LVL].level[1] =
   1180        1.1  augustss 					mv->level[1];
   1181        1.1  augustss 				error = 0;
   1182        1.1  augustss 			}
   1183        1.1  augustss 			break;
   1184        1.1  augustss 
   1185        1.1  augustss 		case ARIAMIX_AUX_LVL:
   1186        1.1  augustss 			if (mv->num_channels == 1 || mv->num_channels == 2) {
   1187       1.23      kent 				sc->aria_mix[ARIAMIX_AUX_LVL].num_channels =
   1188        1.1  augustss 					mv->num_channels;
   1189       1.23      kent 				sc->aria_mix[ARIAMIX_AUX_LVL].level[0] =
   1190        1.1  augustss 					mv->level[0];
   1191       1.23      kent 				sc->aria_mix[ARIAMIX_AUX_LVL].level[1] =
   1192        1.1  augustss 					mv->level[1];
   1193        1.1  augustss 				error = 0;
   1194        1.1  augustss 			}
   1195        1.1  augustss 			break;
   1196       1.23      kent 
   1197        1.1  augustss 		case ARIAMIX_MASTER_LVL:
   1198        1.1  augustss 			if (mv->num_channels == 1 || mv->num_channels == 2) {
   1199       1.23      kent 				sc->ariamix_master.num_channels =
   1200        1.1  augustss 					mv->num_channels;
   1201        1.1  augustss 				sc->ariamix_master.level[0] = mv->level[0];
   1202        1.1  augustss 				sc->ariamix_master.level[1] = mv->level[1];
   1203        1.1  augustss 				error = 0;
   1204        1.1  augustss 			}
   1205        1.1  augustss 			break;
   1206       1.23      kent 
   1207        1.1  augustss 		case ARIAMIX_MASTER_TREBLE:
   1208        1.1  augustss 			if (mv->num_channels == 2) {
   1209       1.23      kent 				sc->ariamix_master.treble[0] =
   1210        1.1  augustss 					mv->level[0] == 0 ? 1 : mv->level[0];
   1211       1.23      kent 				sc->ariamix_master.treble[1] =
   1212        1.1  augustss 					mv->level[1] == 0 ? 1 : mv->level[1];
   1213        1.1  augustss 				error = 0;
   1214        1.1  augustss 			}
   1215        1.1  augustss 			break;
   1216        1.1  augustss 		case ARIAMIX_MASTER_BASS:
   1217        1.1  augustss 			if (mv->num_channels == 2) {
   1218       1.23      kent 				sc->ariamix_master.bass[0] =
   1219        1.1  augustss 					mv->level[0] == 0 ? 1 : mv->level[0];
   1220       1.23      kent 				sc->ariamix_master.bass[1] =
   1221        1.1  augustss 					mv->level[1] == 0 ? 1 : mv->level[1];
   1222        1.1  augustss 				error = 0;
   1223        1.1  augustss 			}
   1224        1.1  augustss 			break;
   1225        1.1  augustss 		case ARIAMIX_OUT_LVL:
   1226        1.1  augustss 			if (mv->num_channels == 1 || mv->num_channels == 2) {
   1227        1.1  augustss 				sc->sc_gain[0] = mv->level[0];
   1228        1.1  augustss 				sc->sc_gain[1] = mv->level[1];
   1229        1.1  augustss 				error = 0;
   1230        1.1  augustss 			}
   1231        1.1  augustss 			break;
   1232        1.1  augustss 		default:
   1233       1.23      kent 			break;
   1234        1.1  augustss 		}
   1235        1.1  augustss 	}
   1236        1.1  augustss 
   1237        1.1  augustss 	if (cp->type == AUDIO_MIXER_ENUM)
   1238        1.1  augustss 		switch(cp->dev) {
   1239        1.1  augustss 		case ARIAMIX_RECORD_SOURCE:
   1240        1.1  augustss 			if (cp->un.ord>=0 && cp->un.ord<=6) {
   1241        1.1  augustss 				sc->aria_mix_source = cp->un.ord;
   1242        1.1  augustss 				error = 0;
   1243        1.1  augustss 			}
   1244        1.1  augustss 			break;
   1245        1.1  augustss 
   1246        1.1  augustss 		case ARIAMIX_MIC_MUTE:
   1247        1.1  augustss 			if (cp->un.ord == 0 || cp->un.ord == 1) {
   1248        1.1  augustss 				sc->aria_mix[ARIAMIX_MIC_LVL].mute =cp->un.ord;
   1249        1.1  augustss 				error = 0;
   1250        1.1  augustss 			}
   1251        1.1  augustss 			break;
   1252        1.1  augustss 
   1253        1.1  augustss 		case ARIAMIX_LINE_IN_MUTE:
   1254        1.1  augustss 			if (cp->un.ord == 0 || cp->un.ord == 1) {
   1255       1.23      kent 				sc->aria_mix[ARIAMIX_LINE_IN_LVL].mute =
   1256        1.1  augustss 					cp->un.ord;
   1257        1.1  augustss 				error = 0;
   1258        1.1  augustss 			}
   1259        1.1  augustss 			break;
   1260        1.1  augustss 
   1261        1.1  augustss 		case ARIAMIX_CD_MUTE:
   1262        1.1  augustss 			if (cp->un.ord == 0 || cp->un.ord == 1) {
   1263        1.1  augustss 				sc->aria_mix[ARIAMIX_CD_LVL].mute = cp->un.ord;
   1264        1.1  augustss 				error = 0;
   1265        1.1  augustss 			}
   1266        1.1  augustss 			break;
   1267        1.1  augustss 
   1268        1.1  augustss 		case ARIAMIX_DAC_MUTE:
   1269        1.1  augustss 			if (cp->un.ord == 0 || cp->un.ord == 1) {
   1270        1.1  augustss 				sc->aria_mix[ARIAMIX_DAC_LVL].mute =cp->un.ord;
   1271        1.1  augustss 				error = 0;
   1272        1.1  augustss 			}
   1273        1.1  augustss 			break;
   1274        1.1  augustss 
   1275        1.1  augustss 		case ARIAMIX_AUX_MUTE:
   1276        1.1  augustss 			if (cp->un.ord == 0 || cp->un.ord == 1) {
   1277        1.1  augustss 				sc->aria_mix[ARIAMIX_AUX_LVL].mute =cp->un.ord;
   1278        1.1  augustss 				error = 0;
   1279        1.1  augustss 			}
   1280        1.1  augustss 			break;
   1281        1.1  augustss 
   1282        1.1  augustss 		case ARIAMIX_TEL_MUTE:
   1283        1.1  augustss 			if (cp->un.ord == 0 || cp->un.ord == 1) {
   1284        1.1  augustss 				sc->aria_mix[ARIAMIX_TEL_LVL].mute =cp->un.ord;
   1285        1.1  augustss 				error = 0;
   1286        1.1  augustss 			}
   1287        1.1  augustss 			break;
   1288        1.1  augustss 
   1289        1.1  augustss 		default:
   1290        1.1  augustss 			/* NOTREACHED */
   1291        1.1  augustss 			return ENXIO;
   1292        1.1  augustss 		}
   1293        1.1  augustss 
   1294       1.23      kent 	return error;
   1295        1.1  augustss }
   1296        1.1  augustss 
   1297        1.1  augustss int
   1298       1.23      kent aria_mixer_get_port(void *addr, mixer_ctrl_t *cp)
   1299        1.1  augustss {
   1300       1.23      kent 	struct aria_softc *sc;
   1301       1.23      kent 	int error;
   1302        1.1  augustss 
   1303        1.1  augustss 	DPRINTF(("aria_mixer_get_port\n"));
   1304       1.23      kent 	sc = addr;
   1305       1.23      kent 	error = EINVAL;
   1306        1.1  augustss 
   1307        1.1  augustss 	/* This could be done better, no mixer still has some controls. */
   1308        1.1  augustss 	if (!(ARIA_MIXER&sc->sc_hardware))
   1309        1.1  augustss 		return ENXIO;
   1310        1.1  augustss 
   1311        1.1  augustss 	switch (cp->dev) {
   1312        1.1  augustss 	case ARIAMIX_MIC_LVL:
   1313        1.1  augustss 		if (cp->type == AUDIO_MIXER_VALUE) {
   1314       1.23      kent 			cp->un.value.num_channels =
   1315        1.1  augustss 				sc->aria_mix[ARIAMIX_MIC_LVL].num_channels;
   1316       1.23      kent 			cp->un.value.level[0] =
   1317        1.1  augustss 				sc->aria_mix[ARIAMIX_MIC_LVL].level[0];
   1318       1.23      kent 			cp->un.value.level[1] =
   1319        1.1  augustss 				sc->aria_mix[ARIAMIX_MIC_LVL].level[1];
   1320        1.1  augustss 			error = 0;
   1321        1.1  augustss 		}
   1322        1.1  augustss 		break;
   1323       1.23      kent 
   1324        1.1  augustss 	case ARIAMIX_LINE_IN_LVL:
   1325        1.1  augustss 		if (cp->type == AUDIO_MIXER_VALUE) {
   1326       1.23      kent 			cp->un.value.num_channels =
   1327        1.1  augustss 				sc->aria_mix[ARIAMIX_LINE_IN_LVL].num_channels;
   1328       1.23      kent 			cp->un.value.level[0] =
   1329        1.1  augustss 				sc->aria_mix[ARIAMIX_LINE_IN_LVL].level[0];
   1330       1.23      kent 			cp->un.value.level[1] =
   1331        1.1  augustss 				sc->aria_mix[ARIAMIX_LINE_IN_LVL].level[1];
   1332        1.1  augustss 			error = 0;
   1333        1.1  augustss 		}
   1334        1.1  augustss 		break;
   1335        1.1  augustss 
   1336        1.1  augustss 	case ARIAMIX_CD_LVL:
   1337        1.1  augustss 		if (cp->type == AUDIO_MIXER_VALUE) {
   1338       1.23      kent 			cp->un.value.num_channels =
   1339        1.1  augustss 				sc->aria_mix[ARIAMIX_CD_LVL].num_channels;
   1340       1.23      kent 			cp->un.value.level[0] =
   1341        1.1  augustss 				sc->aria_mix[ARIAMIX_CD_LVL].level[0];
   1342       1.23      kent 			cp->un.value.level[1] =
   1343        1.1  augustss 				sc->aria_mix[ARIAMIX_CD_LVL].level[1];
   1344        1.1  augustss 			error = 0;
   1345        1.1  augustss 		}
   1346        1.1  augustss 		break;
   1347        1.1  augustss 
   1348        1.1  augustss 	case ARIAMIX_TEL_LVL:
   1349        1.1  augustss 		if (cp->type == AUDIO_MIXER_VALUE) {
   1350       1.23      kent 			cp->un.value.num_channels =
   1351        1.1  augustss 				sc->aria_mix[ARIAMIX_TEL_LVL].num_channels;
   1352       1.23      kent 			cp->un.value.level[0] =
   1353        1.1  augustss 				sc->aria_mix[ARIAMIX_TEL_LVL].level[0];
   1354        1.1  augustss 			error = 0;
   1355        1.1  augustss 		}
   1356        1.1  augustss 		break;
   1357        1.1  augustss 	case ARIAMIX_DAC_LVL:
   1358        1.1  augustss 		if (cp->type == AUDIO_MIXER_VALUE) {
   1359       1.23      kent 			cp->un.value.num_channels =
   1360        1.1  augustss 				sc->aria_mix[ARIAMIX_DAC_LVL].num_channels;
   1361       1.23      kent 			cp->un.value.level[0] =
   1362        1.1  augustss 				sc->aria_mix[ARIAMIX_DAC_LVL].level[0];
   1363       1.23      kent 			cp->un.value.level[1] =
   1364        1.1  augustss 				sc->aria_mix[ARIAMIX_DAC_LVL].level[1];
   1365        1.1  augustss 			error = 0;
   1366        1.1  augustss 		}
   1367        1.1  augustss 		break;
   1368        1.1  augustss 
   1369        1.1  augustss 	case ARIAMIX_AUX_LVL:
   1370        1.1  augustss 		if (cp->type == AUDIO_MIXER_VALUE) {
   1371       1.23      kent 			cp->un.value.num_channels =
   1372        1.1  augustss 				sc->aria_mix[ARIAMIX_AUX_LVL].num_channels;
   1373       1.23      kent 			cp->un.value.level[0] =
   1374        1.1  augustss 				sc->aria_mix[ARIAMIX_AUX_LVL].level[0];
   1375       1.23      kent 			cp->un.value.level[1] =
   1376        1.1  augustss 				sc->aria_mix[ARIAMIX_AUX_LVL].level[1];
   1377        1.1  augustss 			error = 0;
   1378        1.1  augustss 		}
   1379        1.1  augustss 		break;
   1380        1.1  augustss 
   1381        1.1  augustss 	case ARIAMIX_MIC_MUTE:
   1382        1.1  augustss 		if (cp->type == AUDIO_MIXER_ENUM) {
   1383        1.1  augustss 			cp->un.ord = sc->aria_mix[ARIAMIX_MIC_LVL].mute;
   1384        1.1  augustss 			error = 0;
   1385        1.1  augustss 		}
   1386        1.1  augustss 		break;
   1387        1.1  augustss 
   1388        1.1  augustss 	case ARIAMIX_LINE_IN_MUTE:
   1389        1.1  augustss 		if (cp->type == AUDIO_MIXER_ENUM) {
   1390        1.1  augustss 			cp->un.ord = sc->aria_mix[ARIAMIX_LINE_IN_LVL].mute;
   1391        1.1  augustss 			error = 0;
   1392        1.1  augustss 		}
   1393        1.1  augustss 		break;
   1394        1.1  augustss 
   1395        1.1  augustss 	case ARIAMIX_CD_MUTE:
   1396        1.1  augustss 		if (cp->type == AUDIO_MIXER_ENUM) {
   1397        1.1  augustss 			cp->un.ord = sc->aria_mix[ARIAMIX_CD_LVL].mute;
   1398        1.1  augustss 			error = 0;
   1399        1.1  augustss 		}
   1400        1.1  augustss 		break;
   1401        1.1  augustss 
   1402        1.1  augustss 	case ARIAMIX_DAC_MUTE:
   1403        1.1  augustss 		if (cp->type == AUDIO_MIXER_ENUM) {
   1404        1.1  augustss 			cp->un.ord = sc->aria_mix[ARIAMIX_DAC_LVL].mute;
   1405        1.1  augustss 			error = 0;
   1406        1.1  augustss 		}
   1407        1.1  augustss 		break;
   1408        1.1  augustss 
   1409        1.1  augustss 	case ARIAMIX_AUX_MUTE:
   1410        1.1  augustss 		if (cp->type == AUDIO_MIXER_ENUM) {
   1411        1.1  augustss 			cp->un.ord = sc->aria_mix[ARIAMIX_AUX_LVL].mute;
   1412        1.1  augustss 			error = 0;
   1413        1.1  augustss 		}
   1414        1.1  augustss 		break;
   1415        1.1  augustss 
   1416        1.1  augustss 	case ARIAMIX_TEL_MUTE:
   1417        1.1  augustss 		if (cp->type == AUDIO_MIXER_ENUM) {
   1418        1.1  augustss 			cp->un.ord = sc->aria_mix[ARIAMIX_TEL_LVL].mute;
   1419        1.1  augustss 			error = 0;
   1420        1.1  augustss 		}
   1421        1.1  augustss 		break;
   1422        1.1  augustss 
   1423        1.1  augustss 	case ARIAMIX_MASTER_LVL:
   1424        1.1  augustss 		if (cp->type == AUDIO_MIXER_VALUE) {
   1425       1.23      kent 			cp->un.value.num_channels =
   1426        1.1  augustss 				sc->ariamix_master.num_channels;
   1427        1.1  augustss 			cp->un.value.level[0] = sc->ariamix_master.level[0];
   1428        1.1  augustss 			cp->un.value.level[1] = sc->ariamix_master.level[1];
   1429        1.1  augustss 			error = 0;
   1430        1.1  augustss 		}
   1431        1.1  augustss 		break;
   1432        1.1  augustss 
   1433        1.1  augustss 	case ARIAMIX_MASTER_TREBLE:
   1434        1.1  augustss 		if (cp->type == AUDIO_MIXER_VALUE) {
   1435        1.1  augustss 			cp->un.value.num_channels = 2;
   1436        1.1  augustss 			cp->un.value.level[0] = sc->ariamix_master.treble[0];
   1437        1.1  augustss 			cp->un.value.level[1] = sc->ariamix_master.treble[1];
   1438        1.1  augustss 			error = 0;
   1439        1.1  augustss 		}
   1440        1.1  augustss 		break;
   1441        1.1  augustss 
   1442        1.1  augustss 	case ARIAMIX_MASTER_BASS:
   1443        1.1  augustss 		if (cp->type == AUDIO_MIXER_VALUE) {
   1444        1.1  augustss 			cp->un.value.num_channels = 2;
   1445        1.1  augustss 			cp->un.value.level[0] = sc->ariamix_master.bass[0];
   1446        1.1  augustss 			cp->un.value.level[1] = sc->ariamix_master.bass[1];
   1447        1.1  augustss 			error = 0;
   1448        1.1  augustss 		}
   1449        1.1  augustss 		break;
   1450        1.1  augustss 
   1451        1.1  augustss 	case ARIAMIX_OUT_LVL:
   1452        1.1  augustss 		if (cp->type == AUDIO_MIXER_VALUE) {
   1453        1.1  augustss 			cp->un.value.num_channels = sc->sc_chans;
   1454        1.1  augustss 			cp->un.value.level[0] = sc->sc_gain[0];
   1455        1.1  augustss 			cp->un.value.level[1] = sc->sc_gain[1];
   1456        1.1  augustss 			error = 0;
   1457        1.1  augustss 		}
   1458        1.1  augustss 		break;
   1459        1.1  augustss 	case ARIAMIX_RECORD_SOURCE:
   1460        1.1  augustss 		if (cp->type == AUDIO_MIXER_ENUM) {
   1461        1.1  augustss 			cp->un.ord = sc->aria_mix_source;
   1462        1.1  augustss 			error = 0;
   1463        1.1  augustss 		}
   1464        1.1  augustss 		break;
   1465        1.1  augustss 
   1466        1.1  augustss 	default:
   1467        1.1  augustss 		return ENXIO;
   1468        1.1  augustss 		/* NOT REACHED */
   1469        1.1  augustss 	}
   1470        1.1  augustss 
   1471       1.23      kent 	return error;
   1472        1.1  augustss }
   1473        1.1  augustss 
   1474        1.1  augustss int
   1475       1.23      kent aria_mixer_query_devinfo(void *addr, mixer_devinfo_t *dip)
   1476        1.1  augustss {
   1477       1.23      kent 	struct aria_softc *sc;
   1478        1.1  augustss 
   1479        1.1  augustss 	DPRINTF(("aria_mixer_query_devinfo\n"));
   1480       1.23      kent 	sc = addr;
   1481        1.1  augustss 
   1482        1.1  augustss 	/* This could be done better, no mixer still has some controls. */
   1483        1.1  augustss 	if (!(ARIA_MIXER & sc->sc_hardware))
   1484        1.1  augustss 		return ENXIO;
   1485        1.1  augustss 
   1486        1.1  augustss 	dip->prev = dip->next = AUDIO_MIXER_LAST;
   1487        1.1  augustss 
   1488        1.1  augustss 	switch(dip->index) {
   1489        1.1  augustss 	case ARIAMIX_MIC_LVL:
   1490        1.1  augustss 		dip->type = AUDIO_MIXER_VALUE;
   1491        1.1  augustss 		dip->mixer_class = ARIAMIX_INPUT_CLASS;
   1492        1.1  augustss 		dip->next = ARIAMIX_MIC_MUTE;
   1493        1.1  augustss 		strcpy(dip->label.name, AudioNmicrophone);
   1494        1.1  augustss 		dip->un.v.num_channels = 2;
   1495        1.1  augustss 		strcpy(dip->un.v.units.name, AudioNvolume);
   1496        1.1  augustss 		break;
   1497        1.1  augustss 
   1498        1.1  augustss 	case ARIAMIX_LINE_IN_LVL:
   1499        1.1  augustss 		dip->type = AUDIO_MIXER_VALUE;
   1500        1.1  augustss 		dip->mixer_class = ARIAMIX_INPUT_CLASS;
   1501        1.1  augustss 		dip->next = ARIAMIX_LINE_IN_MUTE;
   1502        1.1  augustss 		strcpy(dip->label.name, AudioNline);
   1503        1.1  augustss 		dip->un.v.num_channels = 2;
   1504        1.1  augustss 		strcpy(dip->un.v.units.name, AudioNvolume);
   1505        1.1  augustss 		break;
   1506        1.1  augustss 
   1507        1.1  augustss 	case ARIAMIX_CD_LVL:
   1508        1.1  augustss 		dip->type = AUDIO_MIXER_VALUE;
   1509        1.1  augustss 		dip->mixer_class = ARIAMIX_INPUT_CLASS;
   1510        1.1  augustss 		dip->next = ARIAMIX_CD_MUTE;
   1511        1.1  augustss 		strcpy(dip->label.name, AudioNcd);
   1512        1.1  augustss 		dip->un.v.num_channels = 2;
   1513        1.1  augustss 		strcpy(dip->un.v.units.name, AudioNvolume);
   1514        1.1  augustss 		break;
   1515        1.1  augustss 
   1516        1.1  augustss 	case ARIAMIX_TEL_LVL:
   1517        1.1  augustss 		dip->type = AUDIO_MIXER_VALUE;
   1518        1.1  augustss 		dip->mixer_class = ARIAMIX_INPUT_CLASS;
   1519        1.1  augustss 		dip->next = ARIAMIX_TEL_MUTE;
   1520        1.1  augustss 		strcpy(dip->label.name, "telephone");
   1521        1.1  augustss 		dip->un.v.num_channels = 1;
   1522        1.1  augustss 		strcpy(dip->un.v.units.name, AudioNvolume);
   1523        1.1  augustss 		break;
   1524        1.1  augustss 
   1525        1.1  augustss 	case ARIAMIX_DAC_LVL:
   1526        1.1  augustss 		dip->type = AUDIO_MIXER_VALUE;
   1527        1.1  augustss 		dip->mixer_class = ARIAMIX_INPUT_CLASS;
   1528        1.1  augustss 		dip->next = ARIAMIX_DAC_MUTE;
   1529        1.1  augustss 		strcpy(dip->label.name, AudioNdac);
   1530        1.1  augustss 		dip->un.v.num_channels = 1;
   1531        1.1  augustss 		strcpy(dip->un.v.units.name, AudioNvolume);
   1532        1.1  augustss 		break;
   1533        1.1  augustss 
   1534        1.1  augustss 	case ARIAMIX_AUX_LVL:
   1535        1.1  augustss 		dip->type = AUDIO_MIXER_VALUE;
   1536        1.1  augustss 		dip->mixer_class = ARIAMIX_INPUT_CLASS;
   1537        1.1  augustss 		dip->next = ARIAMIX_AUX_MUTE;
   1538        1.1  augustss 		strcpy(dip->label.name, AudioNoutput);
   1539        1.1  augustss 		dip->un.v.num_channels = 1;
   1540        1.1  augustss 		strcpy(dip->un.v.units.name, AudioNvolume);
   1541        1.1  augustss 		break;
   1542        1.1  augustss 
   1543        1.1  augustss 	case ARIAMIX_MIC_MUTE:
   1544        1.1  augustss 		dip->prev = ARIAMIX_MIC_LVL;
   1545        1.1  augustss 		goto mute;
   1546        1.1  augustss 
   1547        1.1  augustss 	case ARIAMIX_LINE_IN_MUTE:
   1548        1.1  augustss 		dip->prev = ARIAMIX_LINE_IN_LVL;
   1549        1.1  augustss 		goto mute;
   1550       1.23      kent 
   1551        1.1  augustss 	case ARIAMIX_CD_MUTE:
   1552        1.1  augustss 		dip->prev = ARIAMIX_CD_LVL;
   1553        1.1  augustss 		goto mute;
   1554       1.23      kent 
   1555        1.1  augustss 	case ARIAMIX_DAC_MUTE:
   1556        1.1  augustss 		dip->prev = ARIAMIX_DAC_LVL;
   1557        1.1  augustss 		goto mute;
   1558        1.1  augustss 
   1559        1.1  augustss 	case ARIAMIX_AUX_MUTE:
   1560        1.1  augustss 		dip->prev = ARIAMIX_AUX_LVL;
   1561        1.1  augustss 		goto mute;
   1562        1.1  augustss 
   1563        1.1  augustss 	case ARIAMIX_TEL_MUTE:
   1564        1.1  augustss 		dip->prev = ARIAMIX_TEL_LVL;
   1565        1.1  augustss 		goto mute;
   1566        1.1  augustss 
   1567        1.1  augustss mute:
   1568        1.1  augustss 		dip->mixer_class = ARIAMIX_INPUT_CLASS;
   1569        1.1  augustss 		dip->type = AUDIO_MIXER_ENUM;
   1570        1.1  augustss 		strcpy(dip->label.name, AudioNmute);
   1571        1.1  augustss 		dip->un.e.num_mem = 2;
   1572        1.1  augustss 		strcpy(dip->un.e.member[0].label.name, AudioNoff);
   1573        1.1  augustss 		dip->un.e.member[0].ord = 0;
   1574        1.1  augustss 		strcpy(dip->un.e.member[1].label.name, AudioNon);
   1575        1.1  augustss 		dip->un.e.member[1].ord = 1;
   1576        1.1  augustss 		break;
   1577        1.1  augustss 
   1578        1.1  augustss 	case ARIAMIX_MASTER_LVL:
   1579        1.1  augustss 		dip->type = AUDIO_MIXER_VALUE;
   1580        1.1  augustss 		dip->mixer_class = ARIAMIX_OUTPUT_CLASS;
   1581        1.1  augustss 		dip->next = AUDIO_MIXER_LAST;
   1582        1.1  augustss 		strcpy(dip->label.name, AudioNvolume);
   1583        1.1  augustss 		dip->un.v.num_channels = 2;
   1584        1.1  augustss 		strcpy(dip->un.v.units.name, AudioNvolume);
   1585        1.1  augustss 		break;
   1586        1.1  augustss 
   1587        1.1  augustss 	case ARIAMIX_MASTER_TREBLE:
   1588        1.1  augustss 		dip->type = AUDIO_MIXER_VALUE;
   1589        1.1  augustss 		dip->mixer_class = ARIAMIX_EQ_CLASS;
   1590        1.1  augustss 		strcpy(dip->label.name, AudioNtreble);
   1591        1.1  augustss 		dip->un.v.num_channels = 2;
   1592        1.1  augustss 		strcpy(dip->un.v.units.name, AudioNtreble);
   1593        1.1  augustss 		break;
   1594        1.1  augustss 
   1595        1.1  augustss 	case ARIAMIX_MASTER_BASS:
   1596        1.1  augustss 		dip->type = AUDIO_MIXER_VALUE;
   1597        1.1  augustss 		dip->mixer_class = ARIAMIX_EQ_CLASS;
   1598        1.1  augustss 		strcpy(dip->label.name, AudioNbass);
   1599        1.1  augustss 		dip->un.v.num_channels = 2;
   1600        1.1  augustss 		strcpy(dip->un.v.units.name, AudioNbass);
   1601        1.1  augustss 		break;
   1602        1.1  augustss 
   1603        1.1  augustss 	case ARIAMIX_OUT_LVL:
   1604        1.1  augustss 		dip->type = AUDIO_MIXER_VALUE;
   1605        1.1  augustss 		dip->mixer_class = ARIAMIX_OUTPUT_CLASS;
   1606        1.1  augustss 		strcpy(dip->label.name, AudioNoutput);
   1607        1.1  augustss 		dip->un.v.num_channels = 2;
   1608        1.1  augustss 		strcpy(dip->un.v.units.name, AudioNvolume);
   1609        1.1  augustss 		break;
   1610        1.1  augustss 
   1611        1.1  augustss 	case ARIAMIX_RECORD_SOURCE:
   1612        1.1  augustss 		dip->mixer_class = ARIAMIX_RECORD_CLASS;
   1613        1.1  augustss 		dip->type = AUDIO_MIXER_ENUM;
   1614        1.1  augustss 		strcpy(dip->label.name, AudioNsource);
   1615        1.1  augustss 		dip->un.e.num_mem = 6;
   1616        1.1  augustss 		strcpy(dip->un.e.member[0].label.name, AudioNoutput);
   1617        1.1  augustss 		dip->un.e.member[0].ord = ARIAMIX_AUX_LVL;
   1618        1.1  augustss 		strcpy(dip->un.e.member[1].label.name, AudioNmicrophone);
   1619        1.1  augustss 		dip->un.e.member[1].ord = ARIAMIX_MIC_LVL;
   1620        1.1  augustss 		strcpy(dip->un.e.member[2].label.name, AudioNdac);
   1621        1.1  augustss 		dip->un.e.member[2].ord = ARIAMIX_DAC_LVL;
   1622        1.1  augustss 		strcpy(dip->un.e.member[3].label.name, AudioNline);
   1623        1.1  augustss 		dip->un.e.member[3].ord = ARIAMIX_LINE_IN_LVL;
   1624        1.1  augustss 		strcpy(dip->un.e.member[4].label.name, AudioNcd);
   1625        1.1  augustss 		dip->un.e.member[4].ord = ARIAMIX_CD_LVL;
   1626        1.1  augustss 		strcpy(dip->un.e.member[5].label.name, "telephone");
   1627        1.1  augustss 		dip->un.e.member[5].ord = ARIAMIX_TEL_LVL;
   1628        1.1  augustss 		break;
   1629        1.1  augustss 
   1630        1.1  augustss 	case ARIAMIX_INPUT_CLASS:
   1631        1.1  augustss 		dip->type = AUDIO_MIXER_CLASS;
   1632        1.1  augustss 		dip->mixer_class = ARIAMIX_INPUT_CLASS;
   1633        1.1  augustss 		strcpy(dip->label.name, AudioCinputs);
   1634        1.1  augustss 		break;
   1635        1.1  augustss 
   1636        1.1  augustss 	case ARIAMIX_OUTPUT_CLASS:
   1637        1.1  augustss 		dip->type = AUDIO_MIXER_CLASS;
   1638        1.1  augustss 		dip->mixer_class = ARIAMIX_OUTPUT_CLASS;
   1639        1.1  augustss 		strcpy(dip->label.name, AudioCoutputs);
   1640        1.1  augustss 		break;
   1641        1.1  augustss 
   1642        1.1  augustss 	case ARIAMIX_RECORD_CLASS:
   1643        1.1  augustss 		dip->type = AUDIO_MIXER_CLASS;
   1644        1.1  augustss 		dip->mixer_class = ARIAMIX_RECORD_CLASS;
   1645        1.1  augustss 		strcpy(dip->label.name, AudioCrecord);
   1646        1.1  augustss 		break;
   1647        1.1  augustss 
   1648        1.1  augustss 	case ARIAMIX_EQ_CLASS:
   1649        1.1  augustss 		dip->type = AUDIO_MIXER_CLASS;
   1650        1.1  augustss 		dip->mixer_class = ARIAMIX_EQ_CLASS;
   1651        1.1  augustss 		strcpy(dip->label.name, AudioCequalization);
   1652        1.1  augustss 		break;
   1653        1.1  augustss 
   1654        1.1  augustss 	default:
   1655        1.1  augustss 		return ENXIO;
   1656        1.1  augustss 		/*NOTREACHED*/
   1657        1.1  augustss 	}
   1658        1.1  augustss 	return 0;
   1659        1.1  augustss }
   1660