Home | History | Annotate | Line # | Download | only in dev
snapper.c revision 1.9.2.1
      1  1.9.2.1      yamt /*	$NetBSD: snapper.c,v 1.9.2.1 2006/09/03 15:23:20 yamt Exp $	*/
      2      1.1     grant /*	Id: snapper.c,v 1.11 2002/10/31 17:42:13 tsubai Exp	*/
      3      1.1     grant 
      4      1.1     grant /*-
      5      1.1     grant  * Copyright (c) 2002 Tsubai Masanari.  All rights reserved.
      6      1.1     grant  *
      7      1.1     grant  * Redistribution and use in source and binary forms, with or without
      8      1.1     grant  * modification, are permitted provided that the following conditions
      9      1.1     grant  * are met:
     10      1.1     grant  * 1. Redistributions of source code must retain the above copyright
     11      1.1     grant  *    notice, this list of conditions and the following disclaimer.
     12      1.1     grant  * 2. Redistributions in binary form must reproduce the above copyright
     13      1.1     grant  *    notice, this list of conditions and the following disclaimer in the
     14      1.1     grant  *    documentation and/or other materials provided with the distribution.
     15      1.1     grant  * 3. The name of the author may not be used to endorse or promote products
     16      1.1     grant  *    derived from this software without specific prior written permission.
     17      1.1     grant  *
     18      1.1     grant  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19      1.1     grant  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20      1.1     grant  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21      1.1     grant  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22      1.1     grant  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23      1.1     grant  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24      1.1     grant  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25      1.1     grant  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26      1.1     grant  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     27      1.1     grant  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28      1.1     grant  */
     29      1.1     grant 
     30      1.1     grant /*
     31      1.1     grant  * Datasheet is available from
     32      1.1     grant  * http://www.ti.com/sc/docs/products/analog/tas3004.html
     33      1.1     grant  */
     34      1.1     grant 
     35      1.1     grant #include <sys/param.h>
     36      1.1     grant #include <sys/audioio.h>
     37      1.1     grant #include <sys/device.h>
     38      1.1     grant #include <sys/systm.h>
     39      1.1     grant 
     40      1.1     grant #include <dev/auconv.h>
     41      1.1     grant #include <dev/audio_if.h>
     42      1.1     grant #include <dev/mulaw.h>
     43      1.1     grant #include <dev/ofw/openfirm.h>
     44      1.1     grant #include <macppc/dev/dbdma.h>
     45      1.1     grant 
     46      1.1     grant #include <uvm/uvm_extern.h>
     47      1.6  macallan #include <dev/i2c/i2cvar.h>
     48      1.1     grant 
     49      1.1     grant #include <machine/autoconf.h>
     50      1.1     grant #include <machine/pio.h>
     51      1.1     grant 
     52      1.6  macallan #include <macppc/dev/deqvar.h>
     53      1.6  macallan 
     54      1.1     grant #ifdef SNAPPER_DEBUG
     55      1.1     grant # define DPRINTF printf
     56      1.1     grant #else
     57      1.1     grant # define DPRINTF while (0) printf
     58      1.1     grant #endif
     59      1.1     grant 
     60      1.1     grant struct snapper_softc {
     61      1.1     grant 	struct device sc_dev;
     62      1.1     grant 	int sc_flags;
     63      1.1     grant 	int sc_node;
     64      1.1     grant 
     65      1.1     grant 	void (*sc_ointr)(void *);	/* dma completion intr handler */
     66      1.1     grant 	void *sc_oarg;			/* arg for sc_ointr() */
     67      1.1     grant 	int sc_opages;			/* # of output pages */
     68      1.1     grant 
     69      1.1     grant 	void (*sc_iintr)(void *);	/* dma completion intr handler */
     70      1.1     grant 	void *sc_iarg;			/* arg for sc_iintr() */
     71  1.9.2.1      yamt 	int sc_ipages;			/* # of input pages */
     72      1.1     grant 
     73      1.1     grant 	u_int sc_record_source;		/* recording source mask */
     74      1.1     grant 	u_int sc_output_mask;		/* output source mask */
     75      1.1     grant 
     76      1.1     grant 	u_char *sc_reg;
     77      1.6  macallan 	i2c_addr_t sc_deqaddr;
     78      1.6  macallan 	i2c_tag_t sc_i2c;
     79      1.1     grant 
     80      1.1     grant 	u_int sc_vol_l;
     81      1.1     grant 	u_int sc_vol_r;
     82      1.6  macallan 	u_int sc_treble;
     83      1.6  macallan 	u_int sc_bass;
     84      1.6  macallan 	u_int mixer[6]; /* s1_l, s2_l, an_l, s1_r, s2_r, an_r */
     85      1.1     grant 
     86      1.1     grant 	dbdma_regmap_t *sc_odma;
     87      1.1     grant 	dbdma_regmap_t *sc_idma;
     88      1.5    briggs 	unsigned char	dbdma_cmdspace[sizeof(struct dbdma_command) * 40 + 15];
     89      1.5    briggs 	struct dbdma_command *sc_odmacmd;
     90      1.5    briggs 	struct dbdma_command *sc_idmacmd;
     91      1.1     grant };
     92      1.1     grant 
     93      1.1     grant int snapper_match(struct device *, struct cfdata *, void *);
     94      1.1     grant void snapper_attach(struct device *, struct device *, void *);
     95      1.1     grant void snapper_defer(struct device *);
     96      1.1     grant int snapper_intr(void *);
     97      1.1     grant void snapper_close(void *);
     98      1.1     grant int snapper_query_encoding(void *, struct audio_encoding *);
     99      1.3      kent int snapper_set_params(void *, int, int, audio_params_t *,
    100      1.3      kent     audio_params_t *, stream_filter_list_t *, stream_filter_list_t *);
    101      1.3      kent int snapper_round_blocksize(void *, int, int, const audio_params_t *);
    102      1.1     grant int snapper_halt_output(void *);
    103      1.1     grant int snapper_halt_input(void *);
    104      1.1     grant int snapper_getdev(void *, struct audio_device *);
    105      1.1     grant int snapper_set_port(void *, mixer_ctrl_t *);
    106      1.1     grant int snapper_get_port(void *, mixer_ctrl_t *);
    107      1.1     grant int snapper_query_devinfo(void *, mixer_devinfo_t *);
    108      1.1     grant size_t snapper_round_buffersize(void *, int, size_t);
    109      1.1     grant paddr_t snapper_mappage(void *, void *, off_t, int);
    110      1.1     grant int snapper_get_props(void *);
    111      1.1     grant int snapper_trigger_output(void *, void *, void *, int, void (*)(void *),
    112      1.3      kent     void *, const audio_params_t *);
    113      1.1     grant int snapper_trigger_input(void *, void *, void *, int, void (*)(void *),
    114      1.3      kent     void *, const audio_params_t *);
    115      1.1     grant void snapper_set_volume(struct snapper_softc *, int, int);
    116      1.3      kent int snapper_set_rate(struct snapper_softc *, u_int);
    117      1.6  macallan void snapper_set_treble(struct snapper_softc *, int);
    118      1.6  macallan void snapper_set_bass(struct snapper_softc *, int);
    119      1.6  macallan void snapper_write_mixers(struct snapper_softc *);
    120      1.1     grant 
    121      1.1     grant int tas3004_write(struct snapper_softc *, u_int, const void *);
    122      1.1     grant static int gpio_read(char *);
    123      1.1     grant static void gpio_write(char *, int);
    124      1.1     grant void snapper_mute_speaker(struct snapper_softc *, int);
    125      1.1     grant void snapper_mute_headphone(struct snapper_softc *, int);
    126      1.1     grant int snapper_cint(void *);
    127      1.1     grant int tas3004_init(struct snapper_softc *);
    128      1.1     grant void snapper_init(struct snapper_softc *, int);
    129      1.1     grant 
    130      1.1     grant struct cfattach snapper_ca = {
    131      1.1     grant 	"snapper", {}, sizeof(struct snapper_softc),
    132      1.1     grant 	snapper_match, snapper_attach
    133      1.1     grant };
    134      1.1     grant 
    135      1.2      yamt const struct audio_hw_if snapper_hw_if = {
    136      1.3      kent 	NULL,			/* open */
    137      1.1     grant 	snapper_close,
    138      1.1     grant 	NULL,
    139      1.1     grant 	snapper_query_encoding,
    140      1.1     grant 	snapper_set_params,
    141      1.1     grant 	snapper_round_blocksize,
    142      1.1     grant 	NULL,
    143      1.1     grant 	NULL,
    144      1.1     grant 	NULL,
    145      1.1     grant 	NULL,
    146      1.1     grant 	NULL,
    147      1.1     grant 	snapper_halt_output,
    148      1.1     grant 	snapper_halt_input,
    149      1.1     grant 	NULL,
    150      1.1     grant 	snapper_getdev,
    151      1.1     grant 	NULL,
    152      1.1     grant 	snapper_set_port,
    153      1.1     grant 	snapper_get_port,
    154      1.1     grant 	snapper_query_devinfo,
    155      1.1     grant 	NULL,
    156      1.1     grant 	NULL,
    157      1.1     grant 	snapper_round_buffersize,
    158      1.1     grant 	snapper_mappage,
    159      1.1     grant 	snapper_get_props,
    160      1.1     grant 	snapper_trigger_output,
    161      1.1     grant 	snapper_trigger_input,
    162      1.1     grant 	NULL
    163      1.1     grant };
    164      1.1     grant 
    165      1.1     grant struct audio_device snapper_device = {
    166      1.1     grant 	"SNAPPER",
    167      1.1     grant 	"",
    168      1.1     grant 	"snapper"
    169      1.1     grant };
    170      1.1     grant 
    171      1.6  macallan const uint8_t snapper_basstab[] = {
    172      1.6  macallan 	0x96,	/* -18dB */
    173      1.6  macallan 	0x94,	/* -17dB */
    174      1.6  macallan 	0x92,	/* -16dB */
    175      1.6  macallan 	0x90,	/* -15dB */
    176      1.6  macallan 	0x8e,	/* -14dB */
    177      1.6  macallan 	0x8c,	/* -13dB */
    178      1.6  macallan 	0x8a,	/* -12dB */
    179      1.6  macallan 	0x88,	/* -11dB */
    180      1.6  macallan 	0x86,	/* -10dB */
    181      1.6  macallan 	0x84,	/* -9dB */
    182      1.6  macallan 	0x82,	/* -8dB */
    183      1.6  macallan 	0x80,	/* -7dB */
    184      1.6  macallan 	0x7e,	/* -6dB */
    185      1.6  macallan 	0x7c,	/* -5dB */
    186      1.6  macallan 	0x7a,	/* -4dB */
    187      1.6  macallan 	0x78,	/* -3dB */
    188      1.6  macallan 	0x76,	/* -2dB */
    189      1.6  macallan 	0x74,	/* -1dB */
    190      1.6  macallan 	0x72,	/* 0dB */
    191      1.6  macallan 	0x6f,	/* 1dB */
    192      1.6  macallan 	0x6d,	/* 2dB */
    193      1.6  macallan 	0x6a,	/* 3dB */
    194      1.6  macallan 	0x67,	/* 4dB */
    195      1.6  macallan 	0x65,	/* 5dB */
    196      1.6  macallan 	0x62,	/* 6dB */
    197      1.6  macallan 	0x5f,	/* 7dB */
    198      1.6  macallan 	0x5b,	/* 8dB */
    199      1.6  macallan 	0x55,	/* 9dB */
    200      1.6  macallan 	0x4f,	/* 10dB */
    201      1.6  macallan 	0x49,	/* 11dB */
    202      1.6  macallan 	0x43,	/* 12dB */
    203      1.6  macallan 	0x3b,	/* 13dB */
    204      1.6  macallan 	0x33,	/* 14dB */
    205      1.6  macallan 	0x29,	/* 15dB */
    206      1.6  macallan 	0x1e,	/* 16dB */
    207      1.6  macallan 	0x11,	/* 17dB */
    208      1.6  macallan 	0x01,	/* 18dB */
    209      1.6  macallan };
    210      1.6  macallan 
    211  1.9.2.1      yamt const uint8_t snapper_mixer_gain[178][3] = {
    212  1.9.2.1      yamt 	{ 0x7f, 0x17, 0xaf }, /* 18.0 dB */
    213  1.9.2.1      yamt 	{ 0x77, 0xfb, 0xaa }, /* 17.5 dB */
    214  1.9.2.1      yamt 	{ 0x71, 0x45, 0x75 }, /* 17.0 dB */
    215  1.9.2.1      yamt 	{ 0x6a, 0xef, 0x5d }, /* 16.5 dB */
    216  1.9.2.1      yamt 	{ 0x64, 0xf4, 0x03 }, /* 16.0 dB */
    217  1.9.2.1      yamt 	{ 0x5f, 0x4e, 0x52 }, /* 15.5 dB */
    218  1.9.2.1      yamt 	{ 0x59, 0xf9, 0x80 }, /* 15.0 dB */
    219  1.9.2.1      yamt 	{ 0x54, 0xf1, 0x06 }, /* 14.5 dB */
    220  1.9.2.1      yamt 	{ 0x50, 0x30, 0xa1 }, /* 14.0 dB */
    221  1.9.2.1      yamt 	{ 0x4b, 0xb4, 0x46 }, /* 13.5 dB */
    222  1.9.2.1      yamt 	{ 0x47, 0x78, 0x28 }, /* 13.0 dB */
    223  1.9.2.1      yamt 	{ 0x43, 0x78, 0xb0 }, /* 12.5 dB */
    224  1.9.2.1      yamt 	{ 0x3f, 0xb2, 0x78 }, /* 12.0 dB */
    225  1.9.2.1      yamt 	{ 0x3c, 0x22, 0x4c }, /* 11.5 dB */
    226  1.9.2.1      yamt 	{ 0x38, 0xc5, 0x28 }, /* 11.0 dB */
    227  1.9.2.1      yamt 	{ 0x35, 0x98, 0x2f }, /* 10.5 dB */
    228  1.9.2.1      yamt 	{ 0x32, 0x98, 0xb0 }, /* 10.0 dB */
    229  1.9.2.1      yamt 	{ 0x2f, 0xc4, 0x20 }, /* 9.5 dB */
    230  1.9.2.1      yamt 	{ 0x2d, 0x18, 0x18 }, /* 9.0 dB */
    231  1.9.2.1      yamt 	{ 0x2a, 0x92, 0x54 }, /* 8.5 dB */
    232  1.9.2.1      yamt 	{ 0x28, 0x30, 0xaf }, /* 8.0 dB */
    233  1.9.2.1      yamt 	{ 0x25, 0xf1, 0x25 }, /* 7.5 dB */
    234  1.9.2.1      yamt 	{ 0x23, 0xd1, 0xcd }, /* 7.0 dB */
    235  1.9.2.1      yamt 	{ 0x21, 0xd0, 0xd9 }, /* 6.5 dB */
    236  1.9.2.1      yamt 	{ 0x1f, 0xec, 0x98 }, /* 6.0 dB */
    237  1.9.2.1      yamt 	{ 0x1e, 0x23, 0x6d }, /* 5.5 dB */
    238  1.9.2.1      yamt 	{ 0x1c, 0x73, 0xd5 }, /* 5.0 dB */
    239  1.9.2.1      yamt 	{ 0x1a, 0xdc, 0x61 }, /* 4.5 dB */
    240  1.9.2.1      yamt 	{ 0x19, 0x5b, 0xb8 }, /* 4.0 dB */
    241  1.9.2.1      yamt 	{ 0x17, 0xf0, 0x94 }, /* 3.5 dB */
    242  1.9.2.1      yamt 	{ 0x16, 0x99, 0xc0 }, /* 3.0 dB */
    243  1.9.2.1      yamt 	{ 0x15, 0x56, 0x1a }, /* 2.5 dB */
    244  1.9.2.1      yamt 	{ 0x14, 0x24, 0x8e }, /* 2.0 dB */
    245  1.9.2.1      yamt 	{ 0x13, 0x04, 0x1a }, /* 1.5 dB */
    246  1.9.2.1      yamt 	{ 0x11, 0xf3, 0xc9 }, /* 1.0 dB */
    247  1.9.2.1      yamt 	{ 0x10, 0xf2, 0xb4 }, /* 0.5 dB */
    248  1.9.2.1      yamt 	{ 0x10, 0x00, 0x00 }, /* 0.0 dB */
    249  1.9.2.1      yamt 	{ 0x0f, 0x1a, 0xdf }, /* -0.5 dB */
    250  1.9.2.1      yamt 	{ 0x0e, 0x42, 0x90 }, /* -1.0 dB */
    251  1.9.2.1      yamt 	{ 0x0d, 0x76, 0x5a }, /* -1.5 dB */
    252  1.9.2.1      yamt 	{ 0x0c, 0xb5, 0x91 }, /* -2.0 dB */
    253  1.9.2.1      yamt 	{ 0x0b, 0xff, 0x91 }, /* -2.5 dB */
    254  1.9.2.1      yamt 	{ 0x0b, 0x53, 0xbe }, /* -3.0 dB */
    255  1.9.2.1      yamt 	{ 0x0a, 0xb1, 0x89 }, /* -3.5 dB */
    256  1.9.2.1      yamt 	{ 0x0a, 0x18, 0x66 }, /* -4.0 dB */
    257  1.9.2.1      yamt 	{ 0x09, 0x87, 0xd5 }, /* -4.5 dB */
    258  1.9.2.1      yamt 	{ 0x08, 0xff, 0x59 }, /* -5.0 dB */
    259  1.9.2.1      yamt 	{ 0x08, 0x7e, 0x80 }, /* -5.5 dB */
    260  1.9.2.1      yamt 	{ 0x08, 0x04, 0xdc }, /* -6.0 dB */
    261  1.9.2.1      yamt 	{ 0x07, 0x92, 0x07 }, /* -6.5 dB */
    262  1.9.2.1      yamt 	{ 0x07, 0x25, 0x9d }, /* -7.0 dB */
    263  1.9.2.1      yamt 	{ 0x06, 0xbf, 0x44 }, /* -7.5 dB */
    264  1.9.2.1      yamt 	{ 0x06, 0x5e, 0xa5 }, /* -8.0 dB */
    265  1.9.2.1      yamt 	{ 0x06, 0x03, 0x6e }, /* -8.5 dB */
    266  1.9.2.1      yamt 	{ 0x05, 0xad, 0x50 }, /* -9.0 dB */
    267  1.9.2.1      yamt 	{ 0x05, 0x5c, 0x04 }, /* -9.5 dB */
    268  1.9.2.1      yamt 	{ 0x05, 0x0f, 0x44 }, /* -10.0 dB */
    269  1.9.2.1      yamt 	{ 0x04, 0xc6, 0xd0 }, /* -10.5 dB */
    270  1.9.2.1      yamt 	{ 0x04, 0x82, 0x68 }, /* -11.0 dB */
    271  1.9.2.1      yamt 	{ 0x04, 0x41, 0xd5 }, /* -11.5 dB */
    272  1.9.2.1      yamt 	{ 0x04, 0x04, 0xde }, /* -12.0 dB */
    273  1.9.2.1      yamt 	{ 0x03, 0xcb, 0x50 }, /* -12.5 dB */
    274  1.9.2.1      yamt 	{ 0x03, 0x94, 0xfa }, /* -13.0 dB */
    275  1.9.2.1      yamt 	{ 0x03, 0x61, 0xaf }, /* -13.5 dB */
    276  1.9.2.1      yamt 	{ 0x03, 0x31, 0x42 }, /* -14.0 dB */
    277  1.9.2.1      yamt 	{ 0x03, 0x03, 0x8a }, /* -14.5 dB */
    278  1.9.2.1      yamt 	{ 0x02, 0xd8, 0x62 }, /* -15.0 dB */
    279  1.9.2.1      yamt 	{ 0x02, 0xaf, 0xa3 }, /* -15.5 dB */
    280  1.9.2.1      yamt 	{ 0x02, 0x89, 0x2c }, /* -16.0 dB */
    281  1.9.2.1      yamt 	{ 0x02, 0x64, 0xdb }, /* -16.5 dB */
    282  1.9.2.1      yamt 	{ 0x02, 0x42, 0x93 }, /* -17.0 dB */
    283  1.9.2.1      yamt 	{ 0x02, 0x22, 0x35 }, /* -17.5 dB */
    284  1.9.2.1      yamt 	{ 0x02, 0x03, 0xa7 }, /* -18.0 dB */
    285  1.9.2.1      yamt 	{ 0x01, 0xe6, 0xcf }, /* -18.5 dB */
    286  1.9.2.1      yamt 	{ 0x01, 0xcb, 0x94 }, /* -19.0 dB */
    287  1.9.2.1      yamt 	{ 0x01, 0xb1, 0xde }, /* -19.5 dB */
    288  1.9.2.1      yamt 	{ 0x01, 0x99, 0x99 }, /* -20.0 dB */
    289  1.9.2.1      yamt 	{ 0x01, 0x82, 0xaf }, /* -20.5 dB */
    290  1.9.2.1      yamt 	{ 0x01, 0x6d, 0x0e }, /* -21.0 dB */
    291  1.9.2.1      yamt 	{ 0x01, 0x58, 0xa2 }, /* -21.5 dB */
    292  1.9.2.1      yamt 	{ 0x01, 0x45, 0x5b }, /* -22.0 dB */
    293  1.9.2.1      yamt 	{ 0x01, 0x33, 0x28 }, /* -22.5 dB */
    294  1.9.2.1      yamt 	{ 0x01, 0x21, 0xf9 }, /* -23.0 dB */
    295  1.9.2.1      yamt 	{ 0x01, 0x11, 0xc0 }, /* -23.5 dB */
    296  1.9.2.1      yamt 	{ 0x01, 0x02, 0x70 }, /* -24.0 dB */
    297  1.9.2.1      yamt 	{ 0x00, 0xf3, 0xfb }, /* -24.5 dB */
    298  1.9.2.1      yamt 	{ 0x00, 0xe6, 0x55 }, /* -25.0 dB */
    299  1.9.2.1      yamt 	{ 0x00, 0xd9, 0x73 }, /* -25.5 dB */
    300  1.9.2.1      yamt 	{ 0x00, 0xcd, 0x49 }, /* -26.0 dB */
    301  1.9.2.1      yamt 	{ 0x00, 0xc1, 0xcd }, /* -26.5 dB */
    302  1.9.2.1      yamt 	{ 0x00, 0xb6, 0xf6 }, /* -27.0 dB */
    303  1.9.2.1      yamt 	{ 0x00, 0xac, 0xba }, /* -27.5 dB */
    304  1.9.2.1      yamt 	{ 0x00, 0xa3, 0x10 }, /* -28.0 dB */
    305  1.9.2.1      yamt 	{ 0x00, 0x99, 0xf1 }, /* -28.5 dB */
    306  1.9.2.1      yamt 	{ 0x00, 0x91, 0x54 }, /* -29.0 dB */
    307  1.9.2.1      yamt 	{ 0x00, 0x89, 0x33 }, /* -29.5 dB */
    308  1.9.2.1      yamt 	{ 0x00, 0x81, 0x86 }, /* -30.0 dB */
    309  1.9.2.1      yamt 	{ 0x00, 0x7a, 0x48 }, /* -30.5 dB */
    310  1.9.2.1      yamt 	{ 0x00, 0x73, 0x70 }, /* -31.0 dB */
    311  1.9.2.1      yamt 	{ 0x00, 0x6c, 0xfb }, /* -31.5 dB */
    312  1.9.2.1      yamt 	{ 0x00, 0x66, 0xe3 }, /* -32.0 dB */
    313  1.9.2.1      yamt 	{ 0x00, 0x61, 0x21 }, /* -32.5 dB */
    314  1.9.2.1      yamt 	{ 0x00, 0x5b, 0xb2 }, /* -33.0 dB */
    315  1.9.2.1      yamt 	{ 0x00, 0x56, 0x91 }, /* -33.5 dB */
    316  1.9.2.1      yamt 	{ 0x00, 0x51, 0xb9 }, /* -34.0 dB */
    317  1.9.2.1      yamt 	{ 0x00, 0x4d, 0x27 }, /* -34.5 dB */
    318  1.9.2.1      yamt 	{ 0x00, 0x48, 0xd6 }, /* -35.0 dB */
    319  1.9.2.1      yamt 	{ 0x00, 0x44, 0xc3 }, /* -35.5 dB */
    320  1.9.2.1      yamt 	{ 0x00, 0x40, 0xea }, /* -36.0 dB */
    321  1.9.2.1      yamt 	{ 0x00, 0x3d, 0x49 }, /* -36.5 dB */
    322  1.9.2.1      yamt 	{ 0x00, 0x39, 0xdb }, /* -37.0 dB */
    323  1.9.2.1      yamt 	{ 0x00, 0x36, 0x9e }, /* -37.5 dB */
    324  1.9.2.1      yamt 	{ 0x00, 0x33, 0x90 }, /* -38.0 dB */
    325  1.9.2.1      yamt 	{ 0x00, 0x30, 0xae }, /* -38.5 dB */
    326  1.9.2.1      yamt 	{ 0x00, 0x2d, 0xf5 }, /* -39.0 dB */
    327  1.9.2.1      yamt 	{ 0x00, 0x2b, 0x63 }, /* -39.5 dB */
    328  1.9.2.1      yamt 	{ 0x00, 0x28, 0xf5 }, /* -40.0 dB */
    329  1.9.2.1      yamt 	{ 0x00, 0x26, 0xab }, /* -40.5 dB */
    330  1.9.2.1      yamt 	{ 0x00, 0x24, 0x81 }, /* -41.0 dB */
    331  1.9.2.1      yamt 	{ 0x00, 0x22, 0x76 }, /* -41.5 dB */
    332  1.9.2.1      yamt 	{ 0x00, 0x20, 0x89 }, /* -42.0 dB */
    333  1.9.2.1      yamt 	{ 0x00, 0x1e, 0xb7 }, /* -42.5 dB */
    334  1.9.2.1      yamt 	{ 0x00, 0x1c, 0xff }, /* -43.0 dB */
    335  1.9.2.1      yamt 	{ 0x00, 0x1b, 0x60 }, /* -43.5 dB */
    336  1.9.2.1      yamt 	{ 0x00, 0x19, 0xd8 }, /* -44.0 dB */
    337  1.9.2.1      yamt 	{ 0x00, 0x18, 0x65 }, /* -44.5 dB */
    338  1.9.2.1      yamt 	{ 0x00, 0x17, 0x08 }, /* -45.0 dB */
    339  1.9.2.1      yamt 	{ 0x00, 0x15, 0xbe }, /* -45.5 dB */
    340  1.9.2.1      yamt 	{ 0x00, 0x14, 0x87 }, /* -46.0 dB */
    341  1.9.2.1      yamt 	{ 0x00, 0x13, 0x61 }, /* -46.5 dB */
    342  1.9.2.1      yamt 	{ 0x00, 0x12, 0x4b }, /* -47.0 dB */
    343  1.9.2.1      yamt 	{ 0x00, 0x11, 0x45 }, /* -47.5 dB */
    344  1.9.2.1      yamt 	{ 0x00, 0x10, 0x4e }, /* -48.0 dB */
    345  1.9.2.1      yamt 	{ 0x00, 0x0f, 0x64 }, /* -48.5 dB */
    346  1.9.2.1      yamt 	{ 0x00, 0x0e, 0x88 }, /* -49.0 dB */
    347  1.9.2.1      yamt 	{ 0x00, 0x0d, 0xb8 }, /* -49.5 dB */
    348  1.9.2.1      yamt 	{ 0x00, 0x0c, 0xf3 }, /* -50.0 dB */
    349  1.9.2.1      yamt 	{ 0x00, 0x0c, 0x3a }, /* -50.5 dB */
    350  1.9.2.1      yamt 	{ 0x00, 0x0b, 0x8b }, /* -51.0 dB */
    351  1.9.2.1      yamt 	{ 0x00, 0x0a, 0xe5 }, /* -51.5 dB */
    352  1.9.2.1      yamt 	{ 0x00, 0x0a, 0x49 }, /* -52.0 dB */
    353  1.9.2.1      yamt 	{ 0x00, 0x09, 0xb6 }, /* -52.5 dB */
    354  1.9.2.1      yamt 	{ 0x00, 0x09, 0x2b }, /* -53.0 dB */
    355  1.9.2.1      yamt 	{ 0x00, 0x08, 0xa8 }, /* -53.5 dB */
    356  1.9.2.1      yamt 	{ 0x00, 0x08, 0x2c }, /* -54.0 dB */
    357  1.9.2.1      yamt 	{ 0x00, 0x07, 0xb7 }, /* -54.5 dB */
    358  1.9.2.1      yamt 	{ 0x00, 0x07, 0x48 }, /* -55.0 dB */
    359  1.9.2.1      yamt 	{ 0x00, 0x06, 0xe0 }, /* -55.5 dB */
    360  1.9.2.1      yamt 	{ 0x00, 0x06, 0x7d }, /* -56.0 dB */
    361  1.9.2.1      yamt 	{ 0x00, 0x06, 0x20 }, /* -56.5 dB */
    362  1.9.2.1      yamt 	{ 0x00, 0x05, 0xc9 }, /* -57.0 dB */
    363  1.9.2.1      yamt 	{ 0x00, 0x05, 0x76 }, /* -57.5 dB */
    364  1.9.2.1      yamt 	{ 0x00, 0x05, 0x28 }, /* -58.0 dB */
    365  1.9.2.1      yamt 	{ 0x00, 0x04, 0xde }, /* -58.5 dB */
    366  1.9.2.1      yamt 	{ 0x00, 0x04, 0x98 }, /* -59.0 dB */
    367  1.9.2.1      yamt 	{ 0x00, 0x04, 0x56 }, /* -59.5 dB */
    368  1.9.2.1      yamt 	{ 0x00, 0x04, 0x18 }, /* -60.0 dB */
    369  1.9.2.1      yamt 	{ 0x00, 0x03, 0xdd }, /* -60.5 dB */
    370  1.9.2.1      yamt 	{ 0x00, 0x03, 0xa6 }, /* -61.0 dB */
    371  1.9.2.1      yamt 	{ 0x00, 0x03, 0x72 }, /* -61.5 dB */
    372  1.9.2.1      yamt 	{ 0x00, 0x03, 0x40 }, /* -62.0 dB */
    373  1.9.2.1      yamt 	{ 0x00, 0x03, 0x12 }, /* -62.5 dB */
    374  1.9.2.1      yamt 	{ 0x00, 0x02, 0xe6 }, /* -63.0 dB */
    375  1.9.2.1      yamt 	{ 0x00, 0x02, 0xbc }, /* -63.5 dB */
    376  1.9.2.1      yamt 	{ 0x00, 0x02, 0x95 }, /* -64.0 dB */
    377  1.9.2.1      yamt 	{ 0x00, 0x02, 0x70 }, /* -64.5 dB */
    378  1.9.2.1      yamt 	{ 0x00, 0x02, 0x4d }, /* -65.0 dB */
    379  1.9.2.1      yamt 	{ 0x00, 0x02, 0x2c }, /* -65.5 dB */
    380  1.9.2.1      yamt 	{ 0x00, 0x02, 0x0d }, /* -66.0 dB */
    381  1.9.2.1      yamt 	{ 0x00, 0x01, 0xf0 }, /* -66.5 dB */
    382  1.9.2.1      yamt 	{ 0x00, 0x01, 0xd4 }, /* -67.0 dB */
    383  1.9.2.1      yamt 	{ 0x00, 0x01, 0xba }, /* -67.5 dB */
    384  1.9.2.1      yamt 	{ 0x00, 0x01, 0xa1 }, /* -68.0 dB */
    385  1.9.2.1      yamt 	{ 0x00, 0x01, 0x8a }, /* -68.5 dB */
    386  1.9.2.1      yamt 	{ 0x00, 0x01, 0x74 }, /* -69.0 dB */
    387  1.9.2.1      yamt 	{ 0x00, 0x01, 0x5f }, /* -69.5 dB */
    388  1.9.2.1      yamt 	{ 0x00, 0x01, 0x4b }, /* -70.0 dB */
    389  1.9.2.1      yamt 	{ 0x00, 0x00, 0x00 }  /* Mute */
    390  1.9.2.1      yamt };
    391  1.9.2.1      yamt 
    392      1.3      kent #define SNAPPER_NFORMATS	1
    393      1.3      kent static const struct audio_format snapper_formats[SNAPPER_NFORMATS] = {
    394      1.3      kent 	{NULL, AUMODE_PLAY | AUMODE_RECORD, AUDIO_ENCODING_SLINEAR_BE, 16, 16,
    395      1.3      kent 	 2, AUFMT_STEREO, 3, {8000, 44100, 48000}},
    396      1.3      kent };
    397      1.3      kent 
    398      1.1     grant static u_char *amp_mute;
    399      1.1     grant static u_char *headphone_mute;
    400      1.1     grant static u_char *audio_hw_reset;
    401      1.1     grant static u_char *headphone_detect;
    402      1.1     grant static int headphone_detect_active;
    403      1.1     grant 
    404      1.1     grant 
    405      1.1     grant /* I2S registers */
    406      1.1     grant #define I2S_INT		0x00
    407      1.1     grant #define I2S_FORMAT	0x10
    408      1.1     grant #define I2S_FRAMECOUNT	0x40
    409      1.1     grant #define I2S_FRAMEMATCH	0x50
    410      1.1     grant #define I2S_WORDSIZE	0x60
    411      1.1     grant 
    412      1.1     grant /* TAS3004 registers */
    413      1.1     grant #define DEQ_MCR1	0x01	/* Main control register 1 (1byte) */
    414      1.1     grant #define DEQ_DRC		0x02	/* Dynamic range compression (6bytes?) */
    415      1.1     grant #define DEQ_VOLUME	0x04	/* Volume (6bytes) */
    416      1.1     grant #define DEQ_TREBLE	0x05	/* Treble control (1byte) */
    417      1.1     grant #define DEQ_BASS	0x06	/* Bass control (1byte) */
    418      1.1     grant #define DEQ_MIXER_L	0x07	/* Mixer left gain (9bytes) */
    419      1.1     grant #define DEQ_MIXER_R	0x08	/* Mixer right gain (9bytes) */
    420      1.1     grant #define DEQ_LB0		0x0a	/* Left biquad 0 (15bytes) */
    421      1.1     grant #define DEQ_LB1		0x0b	/* Left biquad 1 (15bytes) */
    422      1.1     grant #define DEQ_LB2		0x0c	/* Left biquad 2 (15bytes) */
    423      1.1     grant #define DEQ_LB3		0x0d	/* Left biquad 3 (15bytes) */
    424      1.1     grant #define DEQ_LB4		0x0e	/* Left biquad 4 (15bytes) */
    425      1.1     grant #define DEQ_LB5		0x0f	/* Left biquad 5 (15bytes) */
    426      1.1     grant #define DEQ_LB6		0x10	/* Left biquad 6 (15bytes) */
    427      1.1     grant #define DEQ_RB0		0x13	/* Right biquad 0 (15bytes) */
    428      1.1     grant #define DEQ_RB1		0x14	/* Right biquad 1 (15bytes) */
    429      1.1     grant #define DEQ_RB2		0x15	/* Right biquad 2 (15bytes) */
    430      1.1     grant #define DEQ_RB3		0x16	/* Right biquad 3 (15bytes) */
    431      1.1     grant #define DEQ_RB4		0x17	/* Right biquad 4 (15bytes) */
    432      1.1     grant #define DEQ_RB5		0x18	/* Right biquad 5 (15bytes) */
    433      1.1     grant #define DEQ_RB6		0x19	/* Right biquad 6 (15bytes) */
    434      1.1     grant #define DEQ_LLB		0x21	/* Left loudness biquad (15bytes) */
    435      1.1     grant #define DEQ_RLB		0x22	/* Right loudness biquad (15bytes) */
    436      1.1     grant #define DEQ_LLB_GAIN	0x23	/* Left loudness biquad gain (3bytes) */
    437      1.1     grant #define DEQ_RLB_GAIN	0x24	/* Right loudness biquad gain (3bytes) */
    438      1.1     grant #define DEQ_ACR		0x40	/* Analog control register (1byte) */
    439      1.1     grant #define DEQ_MCR2	0x43	/* Main control register 2 (1byte) */
    440      1.1     grant 
    441      1.1     grant #define DEQ_MCR1_FL	0x80	/* Fast load */
    442      1.1     grant #define DEQ_MCR1_SC	0x40	/* SCLK frequency */
    443      1.1     grant #define  DEQ_MCR1_SC_32	0x00	/*  32fs */
    444      1.1     grant #define  DEQ_MCR1_SC_64	0x40	/*  64fs */
    445      1.1     grant #define DEQ_MCR1_SM	0x30	/* Output serial port mode */
    446      1.1     grant #define  DEQ_MCR1_SM_L	0x00	/*  Left justified */
    447      1.1     grant #define  DEQ_MCR1_SM_R	0x10	/*  Right justified */
    448      1.1     grant #define  DEQ_MCR1_SM_I2S 0x20	/*  I2S */
    449      1.1     grant #define DEQ_MCR1_W	0x03	/* Serial port word length */
    450      1.1     grant #define  DEQ_MCR1_W_16	0x00	/*  16 bit */
    451      1.1     grant #define  DEQ_MCR1_W_18	0x01	/*  18 bit */
    452      1.1     grant #define  DEQ_MCR1_W_20	0x02	/*  20 bit */
    453      1.1     grant 
    454      1.1     grant #define DEQ_MCR2_DL	0x80	/* Download */
    455      1.1     grant #define DEQ_MCR2_AP	0x02	/* All pass mode */
    456      1.1     grant 
    457      1.1     grant #define DEQ_ACR_ADM	0x80	/* ADC output mode */
    458      1.1     grant #define DEQ_ACR_LRB	0x40	/* Select B input */
    459      1.1     grant #define DEQ_ACR_DM	0x0c	/* De-emphasis control */
    460      1.1     grant #define  DEQ_ACR_DM_OFF	0x00	/*  off */
    461      1.1     grant #define  DEQ_ACR_DM_48	0x04	/*  fs = 48kHz */
    462      1.1     grant #define  DEQ_ACR_DM_44	0x08	/*  fs = 44.1kHz */
    463      1.1     grant #define DEQ_ACR_INP	0x02	/* Analog input select */
    464      1.1     grant #define  DEQ_ACR_INP_A	0x00	/*  A */
    465      1.1     grant #define  DEQ_ACR_INP_B	0x02	/*  B */
    466      1.1     grant #define DEQ_ACR_APD	0x01	/* Analog power down */
    467      1.1     grant 
    468      1.1     grant struct tas3004_reg {
    469      1.1     grant 	u_char MCR1[1];
    470      1.1     grant 	u_char DRC[6];
    471      1.1     grant 	u_char VOLUME[6];
    472      1.1     grant 	u_char TREBLE[1];
    473      1.1     grant 	u_char BASS[1];
    474      1.1     grant 	u_char MIXER_L[9];
    475      1.1     grant 	u_char MIXER_R[9];
    476      1.1     grant 	u_char LB0[15];
    477      1.1     grant 	u_char LB1[15];
    478      1.1     grant 	u_char LB2[15];
    479      1.1     grant 	u_char LB3[15];
    480      1.1     grant 	u_char LB4[15];
    481      1.1     grant 	u_char LB5[15];
    482      1.1     grant 	u_char LB6[15];
    483      1.1     grant 	u_char RB0[15];
    484      1.1     grant 	u_char RB1[15];
    485      1.1     grant 	u_char RB2[15];
    486      1.1     grant 	u_char RB3[15];
    487      1.1     grant 	u_char RB4[15];
    488      1.1     grant 	u_char RB5[15];
    489      1.1     grant 	u_char RB6[15];
    490      1.1     grant 	u_char LLB[15];
    491      1.1     grant 	u_char RLB[15];
    492      1.1     grant 	u_char LLB_GAIN[3];
    493      1.1     grant 	u_char RLB_GAIN[3];
    494      1.1     grant 	u_char ACR[1];
    495      1.1     grant 	u_char MCR2[1];
    496      1.1     grant };
    497      1.1     grant 
    498      1.1     grant #define GPIO_OUTSEL	0xf0	/* Output select */
    499      1.1     grant 		/*	0x00	GPIO bit0 is output
    500      1.1     grant 			0x10	media-bay power
    501      1.1     grant 			0x20	reserved
    502      1.1     grant 			0x30	MPIC */
    503      1.1     grant 
    504      1.1     grant #define GPIO_ALTOE	0x08	/* Alternate output enable */
    505      1.1     grant 		/*	0x00	Use DDR
    506      1.1     grant 			0x08	Use output select */
    507      1.1     grant 
    508      1.1     grant #define GPIO_DDR	0x04	/* Data direction */
    509      1.1     grant #define GPIO_DDR_OUTPUT	0x04	/* Output */
    510      1.1     grant #define GPIO_DDR_INPUT	0x00	/* Input */
    511      1.1     grant 
    512      1.1     grant #define GPIO_LEVEL	0x02	/* Pin level (RO) */
    513      1.1     grant 
    514      1.1     grant #define	GPIO_DATA	0x01	/* Data */
    515      1.1     grant 
    516      1.1     grant int
    517      1.4      kent snapper_match(struct device *parent, struct cfdata *match, void *aux)
    518      1.1     grant {
    519      1.4      kent 	struct confargs *ca;
    520  1.9.2.1      yamt 	int soundbus, soundchip, soundcodec;
    521      1.1     grant 	char compat[32];
    522      1.1     grant 
    523      1.4      kent 	ca = aux;
    524      1.1     grant 	if (strcmp(ca->ca_name, "i2s") != 0)
    525      1.1     grant 		return 0;
    526      1.1     grant 
    527      1.1     grant 	if ((soundbus = OF_child(ca->ca_node)) == 0 ||
    528      1.1     grant 	    (soundchip = OF_child(soundbus)) == 0)
    529      1.1     grant 		return 0;
    530      1.1     grant 
    531      1.1     grant 	bzero(compat, sizeof compat);
    532      1.1     grant 	OF_getprop(soundchip, "compatible", compat, sizeof compat);
    533      1.1     grant 
    534  1.9.2.1      yamt 	if (strcmp(compat, "snapper") == 0)
    535  1.9.2.1      yamt 		return 1;
    536  1.9.2.1      yamt 
    537  1.9.2.1      yamt 	if (OF_getprop(soundchip,"platform-tas-codec-ref",
    538  1.9.2.1      yamt 	    &soundcodec, sizeof soundcodec) == sizeof soundcodec)
    539  1.9.2.1      yamt 		return 1;
    540      1.1     grant 
    541  1.9.2.1      yamt 	return 0;
    542      1.1     grant }
    543      1.1     grant 
    544      1.1     grant void
    545      1.4      kent snapper_attach(struct device *parent, struct device *self, void *aux)
    546      1.1     grant {
    547      1.4      kent 	struct snapper_softc *sc;
    548      1.4      kent 	struct confargs *ca;
    549      1.5    briggs 	unsigned long v;
    550      1.1     grant 	int cirq, oirq, iirq, cirq_type, oirq_type, iirq_type;
    551      1.1     grant 	int soundbus, intr[6];
    552      1.1     grant 
    553      1.4      kent 	sc = (struct snapper_softc *)self;
    554      1.4      kent 	ca = aux;
    555      1.5    briggs 
    556      1.5    briggs 	v = (((unsigned long) &sc->dbdma_cmdspace[0]) + 0xf) & ~0xf;
    557      1.5    briggs 	sc->sc_odmacmd = (struct dbdma_command *) v;
    558      1.5    briggs 	sc->sc_idmacmd = sc->sc_odmacmd + 20;
    559      1.5    briggs 
    560      1.1     grant #ifdef DIAGNOSTIC
    561      1.1     grant 	if ((vaddr_t)sc->sc_odmacmd & 0x0f) {
    562      1.1     grant 		printf(": bad dbdma alignment\n");
    563      1.1     grant 		return;
    564      1.1     grant 	}
    565      1.1     grant #endif
    566      1.1     grant 
    567      1.1     grant 	ca->ca_reg[0] += ca->ca_baseaddr;
    568      1.1     grant 	ca->ca_reg[2] += ca->ca_baseaddr;
    569      1.1     grant 	ca->ca_reg[4] += ca->ca_baseaddr;
    570      1.1     grant 
    571      1.1     grant 	sc->sc_node = ca->ca_node;
    572      1.1     grant 	sc->sc_reg = (void *)ca->ca_reg[0];
    573      1.1     grant 	sc->sc_odma = (void *)ca->ca_reg[2];
    574      1.1     grant 	sc->sc_idma = (void *)ca->ca_reg[4];
    575      1.1     grant 
    576      1.1     grant 	soundbus = OF_child(ca->ca_node);
    577      1.1     grant 	OF_getprop(soundbus, "interrupts", intr, sizeof intr);
    578      1.1     grant 	cirq = intr[0];
    579      1.1     grant 	oirq = intr[2];
    580      1.1     grant 	iirq = intr[4];
    581      1.1     grant 	cirq_type = intr[1] ? IST_LEVEL : IST_EDGE;
    582      1.1     grant 	oirq_type = intr[3] ? IST_LEVEL : IST_EDGE;
    583      1.1     grant 	iirq_type = intr[5] ? IST_LEVEL : IST_EDGE;
    584      1.1     grant 
    585      1.1     grant 	/* intr_establish(cirq, cirq_type, IPL_AUDIO, snapper_intr, sc); */
    586      1.1     grant 	intr_establish(oirq, oirq_type, IPL_AUDIO, snapper_intr, sc);
    587  1.9.2.1      yamt 	intr_establish(iirq, iirq_type, IPL_AUDIO, snapper_intr, sc);
    588      1.1     grant 
    589      1.5    briggs 	printf(": irq %d,%d,%d\n", cirq, oirq, iirq);
    590      1.1     grant 
    591      1.1     grant 	config_interrupts(self, snapper_defer);
    592      1.1     grant }
    593      1.1     grant 
    594      1.1     grant void
    595      1.1     grant snapper_defer(struct device *dev)
    596      1.1     grant {
    597      1.4      kent 	struct snapper_softc *sc;
    598      1.1     grant 	struct device *dv;
    599      1.6  macallan 	struct deq_softc *deq;
    600      1.6  macallan 
    601      1.4      kent 	sc = (struct snapper_softc *)dev;
    602      1.6  macallan 	/*
    603      1.1     grant 	for (dv = alldevs.tqh_first; dv; dv=dv->dv_list.tqe_next)
    604      1.1     grant 		if (strncmp(dv->dv_xname, "ki2c", 4) == 0 &&
    605      1.9   thorpej 		    strncmp(device_parent(dv)->dv_xname, "obio", 4) == 0)
    606      1.1     grant 			sc->sc_i2c = dv;
    607      1.6  macallan 	*/
    608      1.6  macallan 	for (dv = alldevs.tqh_first; dv; dv=dv->dv_list.tqe_next)
    609      1.6  macallan 		if (strncmp(dv->dv_xname, "deq", 3) == 0 &&
    610      1.9   thorpej 		    strncmp(device_parent(dv)->dv_xname, "ki2c", 4) == 0) {
    611      1.6  macallan 		    	deq=(struct deq_softc *)dv;
    612      1.6  macallan 			sc->sc_i2c = deq->sc_i2c;
    613      1.6  macallan 			sc->sc_deqaddr=deq->sc_address;
    614      1.6  macallan 		}
    615      1.6  macallan 
    616      1.1     grant 	if (sc->sc_i2c == NULL) {
    617      1.1     grant 		printf("%s: unable to find i2c\n", sc->sc_dev.dv_xname);
    618      1.1     grant 		return;
    619      1.1     grant 	}
    620      1.4      kent 
    621      1.1     grant 	/* XXX If i2c was failed to attach, what should we do? */
    622      1.1     grant 
    623      1.1     grant 	audio_attach_mi(&snapper_hw_if, sc, &sc->sc_dev);
    624      1.1     grant 
    625      1.1     grant 	/* ki2c_setmode(sc->sc_i2c, I2C_STDSUBMODE); */
    626      1.1     grant 	snapper_init(sc, sc->sc_node);
    627      1.1     grant }
    628      1.1     grant 
    629      1.1     grant int
    630      1.4      kent snapper_intr(void *v)
    631      1.1     grant {
    632      1.4      kent 	struct snapper_softc *sc;
    633      1.4      kent 	struct dbdma_command *cmd;
    634      1.4      kent 	int count;
    635      1.1     grant 	int status;
    636      1.1     grant 
    637      1.4      kent 	sc = v;
    638      1.4      kent 	cmd = sc->sc_odmacmd;
    639      1.4      kent 	count = sc->sc_opages;
    640      1.1     grant 	/* Fill used buffer(s). */
    641      1.1     grant 	while (count-- > 0) {
    642      1.1     grant 		if ((dbdma_ld16(&cmd->d_command) & 0x30) == 0x30) {
    643      1.1     grant 			status = dbdma_ld16(&cmd->d_status);
    644      1.1     grant 			cmd->d_status = 0;
    645      1.1     grant 			if (status)	/* status == 0x8400 */
    646      1.1     grant 				if (sc->sc_ointr)
    647      1.1     grant 					(*sc->sc_ointr)(sc->sc_oarg);
    648      1.1     grant 		}
    649      1.1     grant 		cmd++;
    650      1.1     grant 	}
    651      1.1     grant 
    652  1.9.2.1      yamt 	cmd = sc->sc_idmacmd;
    653  1.9.2.1      yamt 	count = sc->sc_ipages;
    654  1.9.2.1      yamt 	while (count-- > 0) {
    655  1.9.2.1      yamt 		if ((dbdma_ld16(&cmd->d_command) & 0x30) == 0x30) {
    656  1.9.2.1      yamt 			status = dbdma_ld16(&cmd->d_status);
    657  1.9.2.1      yamt 			cmd->d_status = 0;
    658  1.9.2.1      yamt 			if (status)	/* status == 0x8400 */
    659  1.9.2.1      yamt 				if (sc->sc_iintr)
    660  1.9.2.1      yamt 					(*sc->sc_iintr)(sc->sc_iarg);
    661  1.9.2.1      yamt 		}
    662  1.9.2.1      yamt 		cmd++;
    663  1.9.2.1      yamt 	}
    664  1.9.2.1      yamt 
    665  1.9.2.1      yamt 
    666      1.1     grant 	return 1;
    667      1.1     grant }
    668      1.1     grant 
    669      1.1     grant /*
    670      1.1     grant  * Close function is called at splaudio().
    671      1.1     grant  */
    672      1.1     grant void
    673      1.4      kent snapper_close(void *h)
    674      1.1     grant {
    675      1.4      kent 	struct snapper_softc *sc;
    676      1.1     grant 
    677      1.4      kent 	sc = h;
    678      1.1     grant 	snapper_halt_output(sc);
    679      1.1     grant 	snapper_halt_input(sc);
    680      1.1     grant 
    681      1.1     grant 	sc->sc_ointr = 0;
    682      1.1     grant 	sc->sc_iintr = 0;
    683      1.1     grant }
    684      1.1     grant 
    685      1.1     grant int
    686      1.4      kent snapper_query_encoding(void *h, struct audio_encoding *ae)
    687      1.1     grant {
    688      1.4      kent 
    689      1.1     grant 	ae->flags = AUDIO_ENCODINGFLAG_EMULATED;
    690      1.1     grant 	switch (ae->index) {
    691      1.1     grant 	case 0:
    692      1.1     grant 		strcpy(ae->name, AudioEslinear);
    693      1.1     grant 		ae->encoding = AUDIO_ENCODING_SLINEAR;
    694      1.1     grant 		ae->precision = 16;
    695      1.1     grant 		ae->flags = 0;
    696      1.1     grant 		return 0;
    697      1.1     grant 	case 1:
    698      1.1     grant 		strcpy(ae->name, AudioEslinear_be);
    699      1.1     grant 		ae->encoding = AUDIO_ENCODING_SLINEAR_BE;
    700      1.1     grant 		ae->precision = 16;
    701      1.1     grant 		ae->flags = 0;
    702      1.1     grant 		return 0;
    703      1.1     grant 	case 2:
    704      1.1     grant 		strcpy(ae->name, AudioEslinear_le);
    705      1.1     grant 		ae->encoding = AUDIO_ENCODING_SLINEAR_LE;
    706      1.1     grant 		ae->precision = 16;
    707      1.1     grant 		return 0;
    708      1.1     grant 	case 3:
    709      1.1     grant 		strcpy(ae->name, AudioEulinear_be);
    710      1.1     grant 		ae->encoding = AUDIO_ENCODING_ULINEAR_BE;
    711      1.1     grant 		ae->precision = 16;
    712      1.1     grant 		return 0;
    713      1.1     grant 	case 4:
    714      1.1     grant 		strcpy(ae->name, AudioEulinear_le);
    715      1.1     grant 		ae->encoding = AUDIO_ENCODING_ULINEAR_LE;
    716      1.1     grant 		ae->precision = 16;
    717      1.1     grant 		return 0;
    718      1.1     grant 	case 5:
    719      1.1     grant 		strcpy(ae->name, AudioEmulaw);
    720      1.1     grant 		ae->encoding = AUDIO_ENCODING_ULAW;
    721      1.1     grant 		ae->precision = 8;
    722      1.1     grant 		return 0;
    723      1.1     grant 	case 6:
    724      1.1     grant 		strcpy(ae->name, AudioEalaw);
    725      1.1     grant 		ae->encoding = AUDIO_ENCODING_ALAW;
    726      1.1     grant 		ae->precision = 8;
    727      1.1     grant 		return 0;
    728      1.1     grant 	default:
    729  1.9.2.1      yamt 		DPRINTF("snapper_query_encoding: invalid encoding %d\n", ae->index);
    730      1.1     grant 		return EINVAL;
    731      1.1     grant 	}
    732      1.1     grant }
    733      1.1     grant 
    734      1.1     grant int
    735      1.4      kent snapper_set_params(void *h, int setmode, int usemode,
    736      1.4      kent 		   audio_params_t *play, audio_params_t *rec,
    737      1.4      kent 		   stream_filter_list_t *pfil, stream_filter_list_t *rfil)
    738      1.1     grant {
    739      1.4      kent 	struct snapper_softc *sc;
    740      1.3      kent 	audio_params_t *p;
    741      1.3      kent 	stream_filter_list_t *fil;
    742      1.3      kent 	int mode;
    743      1.1     grant 
    744      1.4      kent 	sc = h;
    745      1.1     grant 	p = NULL;
    746      1.1     grant 
    747      1.1     grant 	/*
    748      1.1     grant 	 * This device only has one clock, so make the sample rates match.
    749      1.1     grant 	 */
    750      1.1     grant 	if (play->sample_rate != rec->sample_rate &&
    751      1.1     grant 	    usemode == (AUMODE_PLAY | AUMODE_RECORD)) {
    752      1.1     grant 		if (setmode == AUMODE_PLAY) {
    753      1.1     grant 			rec->sample_rate = play->sample_rate;
    754      1.1     grant 			setmode |= AUMODE_RECORD;
    755      1.1     grant 		} else if (setmode == AUMODE_RECORD) {
    756      1.1     grant 			play->sample_rate = rec->sample_rate;
    757      1.1     grant 			setmode |= AUMODE_PLAY;
    758      1.1     grant 		} else
    759      1.1     grant 			return EINVAL;
    760      1.1     grant 	}
    761      1.1     grant 
    762      1.1     grant 	for (mode = AUMODE_RECORD; mode != -1;
    763      1.1     grant 	     mode = mode == AUMODE_RECORD ? AUMODE_PLAY : -1) {
    764      1.1     grant 		if ((setmode & mode) == 0)
    765      1.1     grant 			continue;
    766      1.1     grant 
    767      1.1     grant 		p = mode == AUMODE_PLAY ? play : rec;
    768  1.9.2.1      yamt 		if (p->sample_rate < 4000 || p->sample_rate > 50000) {
    769  1.9.2.1      yamt 			DPRINTF("snapper_set_params: invalid rate %d\n",
    770  1.9.2.1      yamt 			    p->sample_rate);
    771      1.1     grant 			return EINVAL;
    772  1.9.2.1      yamt 		}
    773      1.1     grant 
    774      1.3      kent 		fil = mode == AUMODE_PLAY ? pfil : rfil;
    775      1.3      kent 		if (auconv_set_converter(snapper_formats, SNAPPER_NFORMATS,
    776  1.9.2.1      yamt 					 mode, p, TRUE, fil) < 0) {
    777  1.9.2.1      yamt 			DPRINTF("snapper_set_params: auconv_set_converter failed\n");
    778      1.1     grant 			return EINVAL;
    779  1.9.2.1      yamt 		}
    780      1.3      kent 		if (fil->req_size > 0)
    781      1.3      kent 			p = &fil->filters[0].param;
    782      1.1     grant 	}
    783      1.1     grant 
    784      1.3      kent 	/* Set the speed. p points HW encoding. */
    785      1.3      kent 	if (snapper_set_rate(sc, p->sample_rate))
    786      1.1     grant 		return EINVAL;
    787      1.1     grant 
    788      1.1     grant 	return 0;
    789      1.1     grant }
    790      1.1     grant 
    791      1.1     grant int
    792      1.4      kent snapper_round_blocksize(void *h, int size, int mode,
    793      1.4      kent 			const audio_params_t *param)
    794      1.1     grant {
    795      1.4      kent 
    796      1.1     grant 	if (size < NBPG)
    797      1.1     grant 		size = NBPG;
    798      1.1     grant 	return size & ~PGOFSET;
    799      1.1     grant }
    800      1.1     grant 
    801      1.1     grant int
    802      1.4      kent snapper_halt_output(void *h)
    803      1.1     grant {
    804      1.4      kent 	struct snapper_softc *sc;
    805      1.1     grant 
    806      1.4      kent 	sc = h;
    807      1.1     grant 	dbdma_stop(sc->sc_odma);
    808      1.1     grant 	dbdma_reset(sc->sc_odma);
    809      1.1     grant 	return 0;
    810      1.1     grant }
    811      1.1     grant 
    812      1.1     grant int
    813      1.4      kent snapper_halt_input(void *h)
    814      1.1     grant {
    815      1.4      kent 	struct snapper_softc *sc;
    816      1.1     grant 
    817      1.4      kent 	sc = h;
    818      1.1     grant 	dbdma_stop(sc->sc_idma);
    819      1.1     grant 	dbdma_reset(sc->sc_idma);
    820      1.1     grant 	return 0;
    821      1.1     grant }
    822      1.1     grant 
    823      1.1     grant int
    824      1.4      kent snapper_getdev(void *h, struct audio_device *retp)
    825      1.1     grant {
    826      1.4      kent 
    827      1.1     grant 	*retp = snapper_device;
    828      1.1     grant 	return 0;
    829      1.1     grant }
    830      1.1     grant 
    831      1.1     grant enum {
    832      1.1     grant 	SNAPPER_MONITOR_CLASS,
    833      1.1     grant 	SNAPPER_OUTPUT_CLASS,
    834      1.1     grant 	SNAPPER_RECORD_CLASS,
    835      1.1     grant 	SNAPPER_OUTPUT_SELECT,
    836      1.1     grant 	SNAPPER_VOL_OUTPUT,
    837      1.6  macallan 	SNAPPER_DIGI1,
    838      1.6  macallan 	SNAPPER_DIGI2,
    839      1.6  macallan 	SNAPPER_ANALOG,
    840      1.1     grant 	SNAPPER_INPUT_SELECT,
    841      1.1     grant 	SNAPPER_VOL_INPUT,
    842      1.6  macallan 	SNAPPER_TREBLE,
    843      1.6  macallan 	SNAPPER_BASS,
    844      1.1     grant 	SNAPPER_ENUM_LAST
    845      1.1     grant };
    846      1.1     grant 
    847      1.1     grant int
    848      1.4      kent snapper_set_port(void *h, mixer_ctrl_t *mc)
    849      1.1     grant {
    850      1.4      kent 	struct snapper_softc *sc;
    851      1.1     grant 	int l, r;
    852  1.9.2.1      yamt 	u_char data;
    853      1.1     grant 
    854      1.1     grant 	DPRINTF("snapper_set_port dev = %d, type = %d\n", mc->dev, mc->type);
    855      1.4      kent 	sc = h;
    856      1.1     grant 	l = mc->un.value.level[AUDIO_MIXER_LEVEL_LEFT];
    857      1.1     grant 	r = mc->un.value.level[AUDIO_MIXER_LEVEL_RIGHT];
    858      1.1     grant 
    859      1.1     grant 	switch (mc->dev) {
    860      1.1     grant 	case SNAPPER_OUTPUT_SELECT:
    861      1.1     grant 		/* No change necessary? */
    862      1.1     grant 		if (mc->un.mask == sc->sc_output_mask)
    863      1.1     grant 			return 0;
    864      1.1     grant 
    865      1.1     grant 		snapper_mute_speaker(sc, 1);
    866      1.1     grant 		snapper_mute_headphone(sc, 1);
    867      1.1     grant 		if (mc->un.mask & 1 << 0)
    868      1.1     grant 			snapper_mute_speaker(sc, 0);
    869      1.1     grant 		if (mc->un.mask & 1 << 1)
    870      1.1     grant 			snapper_mute_headphone(sc, 0);
    871      1.1     grant 
    872      1.1     grant 		sc->sc_output_mask = mc->un.mask;
    873      1.1     grant 		return 0;
    874      1.1     grant 
    875      1.1     grant 	case SNAPPER_VOL_OUTPUT:
    876      1.1     grant 		snapper_set_volume(sc, l, r);
    877      1.1     grant 		return 0;
    878      1.1     grant 
    879      1.1     grant 	case SNAPPER_INPUT_SELECT:
    880      1.1     grant 		/* no change necessary? */
    881      1.1     grant 		if (mc->un.mask == sc->sc_record_source)
    882      1.1     grant 			return 0;
    883      1.1     grant 		switch (mc->un.mask) {
    884  1.9.2.1      yamt 		case 1 << 0: /* microphone */
    885  1.9.2.1      yamt 			/* Select right channel of B input */
    886  1.9.2.1      yamt 			data = DEQ_ACR_ADM | DEQ_ACR_LRB | DEQ_ACR_INP_B;
    887  1.9.2.1      yamt 			tas3004_write(sc, DEQ_ACR, &data);
    888  1.9.2.1      yamt 			break;
    889  1.9.2.1      yamt 		case 1 << 1: /* line in */
    890  1.9.2.1      yamt 			/* Select both channels of A input */
    891  1.9.2.1      yamt 			data = 0;
    892  1.9.2.1      yamt 			tas3004_write(sc, DEQ_ACR, &data);
    893      1.1     grant 			break;
    894      1.1     grant 		default: /* invalid argument */
    895      1.1     grant 			return EINVAL;
    896      1.1     grant 		}
    897      1.1     grant 		sc->sc_record_source = mc->un.mask;
    898      1.1     grant 		return 0;
    899      1.1     grant 
    900      1.1     grant 	case SNAPPER_VOL_INPUT:
    901      1.1     grant 		/* XXX TO BE DONE */
    902      1.1     grant 		return 0;
    903      1.1     grant 
    904      1.6  macallan 	case SNAPPER_BASS:
    905      1.6  macallan 		snapper_set_bass(sc,l);
    906      1.6  macallan 		return 0;
    907      1.6  macallan 	case SNAPPER_TREBLE:
    908      1.6  macallan 		snapper_set_treble(sc,l);
    909      1.6  macallan 		return 0;
    910      1.6  macallan 	case SNAPPER_DIGI1:
    911      1.6  macallan 		sc->mixer[0]=l;
    912      1.6  macallan 		sc->mixer[3]=r;
    913      1.6  macallan 		snapper_write_mixers(sc);
    914      1.6  macallan 		return 0;
    915      1.6  macallan 	case SNAPPER_DIGI2:
    916      1.6  macallan 		sc->mixer[1]=l;
    917      1.6  macallan 		sc->mixer[4]=r;
    918      1.6  macallan 		snapper_write_mixers(sc);
    919      1.6  macallan 		return 0;
    920      1.6  macallan 	case SNAPPER_ANALOG:
    921      1.6  macallan 		sc->mixer[2]=l;
    922      1.6  macallan 		sc->mixer[5]=r;
    923      1.6  macallan 		snapper_write_mixers(sc);
    924      1.6  macallan 		return 0;
    925      1.6  macallan 	}
    926      1.1     grant 	return ENXIO;
    927      1.1     grant }
    928      1.1     grant 
    929      1.1     grant int
    930      1.4      kent snapper_get_port(void *h, mixer_ctrl_t *mc)
    931      1.1     grant {
    932      1.4      kent 	struct snapper_softc *sc;
    933      1.1     grant 
    934      1.1     grant 	DPRINTF("snapper_get_port dev = %d, type = %d\n", mc->dev, mc->type);
    935      1.4      kent 	sc = h;
    936      1.1     grant 	switch (mc->dev) {
    937      1.1     grant 	case SNAPPER_OUTPUT_SELECT:
    938      1.1     grant 		mc->un.mask = sc->sc_output_mask;
    939      1.1     grant 		return 0;
    940      1.1     grant 
    941      1.1     grant 	case SNAPPER_VOL_OUTPUT:
    942      1.1     grant 		mc->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = sc->sc_vol_l;
    943      1.1     grant 		mc->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = sc->sc_vol_r;
    944      1.1     grant 		return 0;
    945      1.1     grant 
    946      1.1     grant 	case SNAPPER_INPUT_SELECT:
    947      1.1     grant 		mc->un.mask = sc->sc_record_source;
    948      1.1     grant 		return 0;
    949      1.1     grant 
    950      1.1     grant 	case SNAPPER_VOL_INPUT:
    951      1.1     grant 		/* XXX TO BE DONE */
    952      1.1     grant 		mc->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = 0;
    953      1.1     grant 		mc->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = 0;
    954      1.1     grant 		return 0;
    955      1.6  macallan 	case SNAPPER_TREBLE:
    956  1.9.2.1      yamt 		mc->un.value.level[AUDIO_MIXER_LEVEL_MONO] = sc->sc_treble;
    957      1.6  macallan 		return 0;
    958      1.6  macallan 	case SNAPPER_BASS:
    959  1.9.2.1      yamt 		mc->un.value.level[AUDIO_MIXER_LEVEL_MONO] = sc->sc_bass;
    960      1.6  macallan 		return 0;
    961      1.6  macallan 	case SNAPPER_DIGI1:
    962      1.6  macallan 		mc->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = sc->mixer[0];
    963      1.6  macallan 		mc->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = sc->mixer[3];
    964      1.6  macallan 		return 0;
    965      1.6  macallan 	case SNAPPER_DIGI2:
    966      1.6  macallan 		mc->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = sc->mixer[1];
    967      1.6  macallan 		mc->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = sc->mixer[4];
    968      1.6  macallan 		return 0;
    969      1.6  macallan 	case SNAPPER_ANALOG:
    970      1.6  macallan 		mc->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = sc->mixer[2];
    971      1.6  macallan 		mc->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = sc->mixer[5];
    972      1.6  macallan 		return 0;
    973      1.1     grant 	default:
    974      1.1     grant 		return ENXIO;
    975      1.1     grant 	}
    976      1.1     grant 
    977      1.1     grant 	return 0;
    978      1.1     grant }
    979      1.1     grant 
    980      1.1     grant int
    981      1.4      kent snapper_query_devinfo(void *h, mixer_devinfo_t *dip)
    982      1.1     grant {
    983      1.1     grant 	switch (dip->index) {
    984      1.1     grant 
    985      1.1     grant 	case SNAPPER_OUTPUT_SELECT:
    986      1.1     grant 		dip->mixer_class = SNAPPER_MONITOR_CLASS;
    987      1.1     grant 		strcpy(dip->label.name, AudioNoutput);
    988      1.1     grant 		dip->type = AUDIO_MIXER_SET;
    989      1.1     grant 		dip->prev = dip->next = AUDIO_MIXER_LAST;
    990      1.1     grant 		dip->un.s.num_mem = 2;
    991      1.1     grant 		strcpy(dip->un.s.member[0].label.name, AudioNspeaker);
    992      1.1     grant 		dip->un.s.member[0].mask = 1 << 0;
    993      1.1     grant 		strcpy(dip->un.s.member[1].label.name, AudioNheadphone);
    994      1.1     grant 		dip->un.s.member[1].mask = 1 << 1;
    995      1.1     grant 		return 0;
    996      1.1     grant 
    997      1.1     grant 	case SNAPPER_VOL_OUTPUT:
    998      1.1     grant 		dip->mixer_class = SNAPPER_MONITOR_CLASS;
    999      1.1     grant 		strcpy(dip->label.name, AudioNmaster);
   1000      1.1     grant 		dip->type = AUDIO_MIXER_VALUE;
   1001      1.1     grant 		dip->prev = dip->next = AUDIO_MIXER_LAST;
   1002      1.1     grant 		dip->un.v.num_channels = 2;
   1003      1.1     grant 		strcpy(dip->un.v.units.name, AudioNvolume);
   1004      1.1     grant 		return 0;
   1005      1.1     grant 
   1006      1.1     grant 	case SNAPPER_INPUT_SELECT:
   1007      1.1     grant 		dip->mixer_class = SNAPPER_RECORD_CLASS;
   1008      1.1     grant 		strcpy(dip->label.name, AudioNsource);
   1009      1.1     grant 		dip->type = AUDIO_MIXER_SET;
   1010      1.1     grant 		dip->prev = dip->next = AUDIO_MIXER_LAST;
   1011  1.9.2.1      yamt 		dip->un.s.num_mem = 2;
   1012  1.9.2.1      yamt 		strcpy(dip->un.s.member[0].label.name, AudioNmicrophone);
   1013      1.1     grant 		dip->un.s.member[0].mask = 1 << 0;
   1014  1.9.2.1      yamt 		strcpy(dip->un.s.member[1].label.name, AudioNline);
   1015      1.1     grant 		dip->un.s.member[1].mask = 1 << 1;
   1016      1.1     grant 		return 0;
   1017      1.1     grant 
   1018      1.1     grant 	case SNAPPER_VOL_INPUT:
   1019      1.1     grant 		dip->mixer_class = SNAPPER_RECORD_CLASS;
   1020      1.1     grant 		strcpy(dip->label.name, AudioNrecord);
   1021      1.1     grant 		dip->type = AUDIO_MIXER_VALUE;
   1022      1.1     grant 		dip->prev = dip->next = AUDIO_MIXER_LAST;
   1023      1.1     grant 		dip->un.v.num_channels = 2;
   1024      1.1     grant 		strcpy(dip->un.v.units.name, AudioNvolume);
   1025      1.1     grant 		return 0;
   1026      1.1     grant 
   1027      1.1     grant 	case SNAPPER_MONITOR_CLASS:
   1028      1.1     grant 		dip->mixer_class = SNAPPER_MONITOR_CLASS;
   1029      1.1     grant 		strcpy(dip->label.name, AudioCmonitor);
   1030      1.1     grant 		dip->type = AUDIO_MIXER_CLASS;
   1031      1.1     grant 		dip->next = dip->prev = AUDIO_MIXER_LAST;
   1032      1.1     grant 		return 0;
   1033      1.1     grant 
   1034      1.1     grant 	case SNAPPER_OUTPUT_CLASS:
   1035      1.1     grant 		dip->mixer_class = SNAPPER_OUTPUT_CLASS;
   1036      1.1     grant 		strcpy(dip->label.name, AudioCoutputs);
   1037      1.1     grant 		dip->type = AUDIO_MIXER_CLASS;
   1038      1.1     grant 		dip->next = dip->prev = AUDIO_MIXER_LAST;
   1039      1.1     grant 		return 0;
   1040      1.1     grant 
   1041      1.1     grant 	case SNAPPER_RECORD_CLASS:
   1042      1.1     grant 		dip->mixer_class = SNAPPER_RECORD_CLASS;
   1043      1.1     grant 		strcpy(dip->label.name, AudioCrecord);
   1044      1.1     grant 		dip->type = AUDIO_MIXER_CLASS;
   1045      1.1     grant 		dip->next = dip->prev = AUDIO_MIXER_LAST;
   1046      1.1     grant 		return 0;
   1047      1.6  macallan 
   1048      1.6  macallan 	case SNAPPER_TREBLE:
   1049      1.6  macallan 		dip->mixer_class = SNAPPER_MONITOR_CLASS;
   1050      1.6  macallan 		strcpy(dip->label.name, AudioNtreble);
   1051      1.6  macallan 		dip->type = AUDIO_MIXER_VALUE;
   1052      1.6  macallan 		dip->prev = dip->next = AUDIO_MIXER_LAST;
   1053      1.6  macallan 		dip->un.v.num_channels = 1;
   1054      1.6  macallan 		return 0;
   1055      1.6  macallan 
   1056      1.6  macallan 	case SNAPPER_BASS:
   1057      1.6  macallan 		dip->mixer_class = SNAPPER_MONITOR_CLASS;
   1058      1.6  macallan 		strcpy(dip->label.name, AudioNbass);
   1059      1.6  macallan 		dip->type = AUDIO_MIXER_VALUE;
   1060      1.6  macallan 		dip->prev = dip->next = AUDIO_MIXER_LAST;
   1061      1.6  macallan 		dip->un.v.num_channels = 1;
   1062      1.6  macallan 		return 0;
   1063      1.6  macallan 
   1064      1.6  macallan 	case SNAPPER_DIGI1:
   1065      1.6  macallan 		dip->mixer_class = SNAPPER_MONITOR_CLASS;
   1066      1.6  macallan 		strcpy(dip->label.name, AudioNdac);
   1067      1.6  macallan 		dip->type = AUDIO_MIXER_VALUE;
   1068      1.6  macallan 		dip->prev = dip->next = AUDIO_MIXER_LAST;
   1069      1.6  macallan 		dip->un.v.num_channels = 2;
   1070      1.6  macallan 		return 0;
   1071      1.6  macallan 	case SNAPPER_DIGI2:
   1072      1.6  macallan 		dip->mixer_class = SNAPPER_MONITOR_CLASS;
   1073  1.9.2.1      yamt 		strcpy(dip->label.name, AudioNline);
   1074      1.6  macallan 		dip->type = AUDIO_MIXER_VALUE;
   1075      1.6  macallan 		dip->prev = dip->next = AUDIO_MIXER_LAST;
   1076      1.6  macallan 		dip->un.v.num_channels = 2;
   1077      1.6  macallan 		return 0;
   1078      1.6  macallan 	case SNAPPER_ANALOG:
   1079      1.6  macallan 		dip->mixer_class = SNAPPER_MONITOR_CLASS;
   1080  1.9.2.1      yamt 		strcpy(dip->label.name, AudioNmicrophone);
   1081      1.6  macallan 		dip->type = AUDIO_MIXER_VALUE;
   1082      1.6  macallan 		dip->prev = dip->next = AUDIO_MIXER_LAST;
   1083      1.6  macallan 		dip->un.v.num_channels = 2;
   1084      1.6  macallan 		return 0;
   1085      1.1     grant 	}
   1086      1.1     grant 
   1087      1.1     grant 	return ENXIO;
   1088      1.1     grant }
   1089      1.1     grant 
   1090      1.1     grant size_t
   1091      1.4      kent snapper_round_buffersize(void *h, int dir, size_t size)
   1092      1.1     grant {
   1093      1.4      kent 
   1094      1.1     grant 	if (size > 65536)
   1095      1.1     grant 		size = 65536;
   1096      1.1     grant 	return size;
   1097      1.1     grant }
   1098      1.1     grant 
   1099      1.1     grant paddr_t
   1100      1.4      kent snapper_mappage(void *h, void *mem, off_t off, int prot)
   1101      1.1     grant {
   1102      1.4      kent 
   1103      1.1     grant 	if (off < 0)
   1104      1.1     grant 		return -1;
   1105      1.1     grant 	return -1;	/* XXX */
   1106      1.1     grant }
   1107      1.1     grant 
   1108      1.1     grant int
   1109      1.4      kent snapper_get_props(void *h)
   1110      1.1     grant {
   1111      1.1     grant 	return AUDIO_PROP_FULLDUPLEX /* | AUDIO_PROP_MMAP */;
   1112      1.1     grant }
   1113      1.1     grant 
   1114      1.1     grant int
   1115      1.4      kent snapper_trigger_output(void *h, void *start, void *end, int bsize,
   1116      1.4      kent 		       void (*intr)(void *), void *arg,
   1117      1.4      kent 		       const audio_params_t *param)
   1118      1.1     grant {
   1119      1.4      kent 	struct snapper_softc *sc;
   1120      1.4      kent 	struct dbdma_command *cmd;
   1121      1.1     grant 	vaddr_t va;
   1122      1.1     grant 	int i, len, intmode;
   1123      1.1     grant 
   1124      1.1     grant 	DPRINTF("trigger_output %p %p 0x%x\n", start, end, bsize);
   1125      1.4      kent 	sc = h;
   1126      1.4      kent 	cmd = sc->sc_odmacmd;
   1127      1.1     grant 	sc->sc_ointr = intr;
   1128      1.1     grant 	sc->sc_oarg = arg;
   1129      1.1     grant 	sc->sc_opages = ((char *)end - (char *)start) / NBPG;
   1130      1.1     grant 
   1131      1.1     grant #ifdef DIAGNOSTIC
   1132      1.1     grant 	if (sc->sc_opages > 16)
   1133      1.1     grant 		panic("snapper_trigger_output");
   1134      1.1     grant #endif
   1135      1.1     grant 
   1136      1.1     grant 	va = (vaddr_t)start;
   1137      1.1     grant 	len = 0;
   1138      1.1     grant 	for (i = sc->sc_opages; i > 0; i--) {
   1139      1.1     grant 		len += NBPG;
   1140      1.1     grant 		if (len < bsize)
   1141      1.1     grant 			intmode = 0;
   1142      1.1     grant 		else {
   1143      1.1     grant 			len = 0;
   1144      1.1     grant 			intmode = DBDMA_INT_ALWAYS;
   1145      1.1     grant 		}
   1146      1.1     grant 
   1147      1.4      kent 		DBDMA_BUILD(cmd, DBDMA_CMD_OUT_MORE, 0, NBPG, vtophys(va),
   1148      1.4      kent 		    intmode, DBDMA_WAIT_NEVER, DBDMA_BRANCH_NEVER);
   1149      1.1     grant 		cmd++;
   1150      1.1     grant 		va += NBPG;
   1151      1.1     grant 	}
   1152      1.1     grant 
   1153      1.1     grant 	DBDMA_BUILD(cmd, DBDMA_CMD_NOP, 0, 0,
   1154      1.4      kent 	    0/*vtophys((vaddr_t)sc->sc_odmacmd)*/, 0, DBDMA_WAIT_NEVER,
   1155      1.4      kent 	    DBDMA_BRANCH_ALWAYS);
   1156      1.1     grant 
   1157      1.1     grant 	dbdma_st32(&cmd->d_cmddep, vtophys((vaddr_t)sc->sc_odmacmd));
   1158      1.1     grant 
   1159      1.1     grant 	dbdma_start(sc->sc_odma, sc->sc_odmacmd);
   1160      1.1     grant 
   1161      1.1     grant 	return 0;
   1162      1.1     grant }
   1163      1.1     grant 
   1164      1.1     grant int
   1165      1.4      kent snapper_trigger_input(void *h, void *start, void *end, int bsize,
   1166      1.4      kent 		      void (*intr)(void *), void *arg,
   1167      1.4      kent 		      const audio_params_t *param)
   1168      1.1     grant {
   1169  1.9.2.1      yamt 	struct snapper_softc *sc;
   1170  1.9.2.1      yamt 	struct dbdma_command *cmd;
   1171  1.9.2.1      yamt 	vaddr_t va;
   1172  1.9.2.1      yamt 	int i, len, intmode;
   1173      1.4      kent 
   1174  1.9.2.1      yamt 	DPRINTF("trigger_input %p %p 0x%x\n", start, end, bsize);
   1175  1.9.2.1      yamt 	sc = h;
   1176  1.9.2.1      yamt 	cmd = sc->sc_idmacmd;
   1177  1.9.2.1      yamt 	sc->sc_iintr = intr;
   1178  1.9.2.1      yamt 	sc->sc_iarg = arg;
   1179  1.9.2.1      yamt 	sc->sc_ipages = ((char *)end - (char *)start) / NBPG;
   1180  1.9.2.1      yamt 
   1181  1.9.2.1      yamt #ifdef DIAGNOSTIC
   1182  1.9.2.1      yamt 	if (sc->sc_ipages > 16)
   1183  1.9.2.1      yamt 		panic("snapper_trigger_input");
   1184  1.9.2.1      yamt #endif
   1185  1.9.2.1      yamt 
   1186  1.9.2.1      yamt 	va = (vaddr_t)start;
   1187  1.9.2.1      yamt 	len = 0;
   1188  1.9.2.1      yamt 	for (i = sc->sc_ipages; i > 0; i--) {
   1189  1.9.2.1      yamt 		len += NBPG;
   1190  1.9.2.1      yamt 		if (len < bsize)
   1191  1.9.2.1      yamt 			intmode = 0;
   1192  1.9.2.1      yamt 		else {
   1193  1.9.2.1      yamt 			len = 0;
   1194  1.9.2.1      yamt 			intmode = DBDMA_INT_ALWAYS;
   1195  1.9.2.1      yamt 		}
   1196  1.9.2.1      yamt 
   1197  1.9.2.1      yamt 		DBDMA_BUILD(cmd, DBDMA_CMD_IN_MORE, 0, NBPG, vtophys(va),
   1198  1.9.2.1      yamt 		    intmode, DBDMA_WAIT_NEVER, DBDMA_BRANCH_NEVER);
   1199  1.9.2.1      yamt 		cmd++;
   1200  1.9.2.1      yamt 		va += NBPG;
   1201  1.9.2.1      yamt 	}
   1202  1.9.2.1      yamt 
   1203  1.9.2.1      yamt 	DBDMA_BUILD(cmd, DBDMA_CMD_NOP, 0, 0,
   1204  1.9.2.1      yamt 	    0/*vtophys((vaddr_t)sc->sc_odmacmd)*/, 0, DBDMA_WAIT_NEVER,
   1205  1.9.2.1      yamt 	    DBDMA_BRANCH_ALWAYS);
   1206  1.9.2.1      yamt 
   1207  1.9.2.1      yamt 	dbdma_st32(&cmd->d_cmddep, vtophys((vaddr_t)sc->sc_idmacmd));
   1208  1.9.2.1      yamt 
   1209  1.9.2.1      yamt 	dbdma_start(sc->sc_idma, sc->sc_idmacmd);
   1210  1.9.2.1      yamt 
   1211  1.9.2.1      yamt 	return 0;
   1212      1.1     grant }
   1213      1.1     grant 
   1214      1.1     grant void
   1215      1.4      kent snapper_set_volume(struct snapper_softc *sc, int left, int right)
   1216      1.1     grant {
   1217  1.9.2.1      yamt 	u_char regs[6];
   1218  1.9.2.1      yamt 	int l, r;
   1219  1.9.2.1      yamt 
   1220  1.9.2.1      yamt 	/*
   1221  1.9.2.1      yamt 	 * for some insane reason the gain table for master volume and the
   1222  1.9.2.1      yamt 	 * mixer channels is almost identical - just shifted by 4 bits
   1223  1.9.2.1      yamt 	 * so we use the mixer_gain table and bit-twiddle it...
   1224  1.9.2.1      yamt 	 */
   1225  1.9.2.1      yamt 	if ((left >= 0) && (left < 256) && (right >= 0) && (right < 256)) {
   1226  1.9.2.1      yamt 		l = 177 - (left * 177 / 255);
   1227  1.9.2.1      yamt 		regs[0] =  (snapper_mixer_gain[l][0] >> 4);
   1228  1.9.2.1      yamt 		regs[1] = ((snapper_mixer_gain[l][0] & 0x0f) << 4) |
   1229  1.9.2.1      yamt 			   (snapper_mixer_gain[l][1] >> 4);
   1230  1.9.2.1      yamt 		regs[2] = ((snapper_mixer_gain[l][1] & 0x0f) << 4) |
   1231  1.9.2.1      yamt 			   (snapper_mixer_gain[l][2] >> 4);
   1232  1.9.2.1      yamt 
   1233  1.9.2.1      yamt 		r = 177 - (right * 177 / 255);
   1234  1.9.2.1      yamt 		regs[3] =  (snapper_mixer_gain[r][0] >> 4);
   1235  1.9.2.1      yamt 		regs[4] = ((snapper_mixer_gain[r][0] & 0x0f) << 4) |
   1236  1.9.2.1      yamt 			   (snapper_mixer_gain[r][1] >> 4);
   1237  1.9.2.1      yamt 		regs[5] = ((snapper_mixer_gain[r][1] & 0x0f) << 4) |
   1238  1.9.2.1      yamt 			   (snapper_mixer_gain[r][2] >> 4);
   1239  1.9.2.1      yamt 
   1240  1.9.2.1      yamt 		tas3004_write(sc, DEQ_VOLUME, regs);
   1241  1.9.2.1      yamt 
   1242  1.9.2.1      yamt 		sc->sc_vol_l = left;
   1243  1.9.2.1      yamt 		sc->sc_vol_r = right;
   1244      1.1     grant 
   1245  1.9.2.1      yamt 		DPRINTF("%d %02x %02x %02x : %d %02x %02x %02x\n", l, regs[0],
   1246  1.9.2.1      yamt 		    regs[1], regs[2], r, regs[3], regs[4], regs[5]);
   1247  1.9.2.1      yamt 	}
   1248      1.6  macallan }
   1249      1.6  macallan 
   1250      1.6  macallan void snapper_set_treble(struct snapper_softc *sc, int stuff)
   1251      1.6  macallan {
   1252      1.6  macallan 	uint8_t reg;
   1253  1.9.2.1      yamt 	if ((stuff >= 0) && (stuff <= 255) && (sc->sc_treble != stuff)) {
   1254  1.9.2.1      yamt 		reg = snapper_basstab[(stuff >> 3) + 2];
   1255  1.9.2.1      yamt 		sc->sc_treble = stuff;
   1256  1.9.2.1      yamt 		tas3004_write(sc, DEQ_TREBLE, &reg);
   1257      1.6  macallan 	}
   1258      1.6  macallan }
   1259      1.1     grant 
   1260      1.6  macallan void snapper_set_bass(struct snapper_softc *sc, int stuff)
   1261      1.6  macallan {
   1262      1.6  macallan 	uint8_t reg;
   1263  1.9.2.1      yamt 	if ((stuff >= 0) && (stuff <= 255) && (stuff != sc->sc_bass)) {
   1264  1.9.2.1      yamt 		reg = snapper_basstab[(stuff >> 3) + 2];
   1265  1.9.2.1      yamt 		sc->sc_bass = stuff;
   1266  1.9.2.1      yamt 		tas3004_write(sc, DEQ_BASS, &reg);
   1267      1.6  macallan 	}
   1268      1.6  macallan }
   1269      1.6  macallan 
   1270      1.6  macallan void snapper_write_mixers(struct snapper_softc *sc)
   1271      1.6  macallan {
   1272      1.6  macallan 	uint8_t regs[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
   1273  1.9.2.1      yamt 	int i;
   1274  1.9.2.1      yamt 
   1275  1.9.2.1      yamt 	/* Left channel of SDIN1 */
   1276  1.9.2.1      yamt 	i = 177 - (sc->mixer[0] * 177 / 255);
   1277  1.9.2.1      yamt 	regs[0] = snapper_mixer_gain[i][0];
   1278  1.9.2.1      yamt 	regs[1] = snapper_mixer_gain[i][1];
   1279  1.9.2.1      yamt 	regs[2] = snapper_mixer_gain[i][2];
   1280  1.9.2.1      yamt 
   1281  1.9.2.1      yamt 	/* Left channel of SDIN2 */
   1282  1.9.2.1      yamt 	i = 177 - (sc->mixer[1] * 177 / 255);
   1283  1.9.2.1      yamt 	regs[3] = snapper_mixer_gain[i][0];
   1284  1.9.2.1      yamt 	regs[4] = snapper_mixer_gain[i][1];
   1285  1.9.2.1      yamt 	regs[5] = snapper_mixer_gain[i][2];
   1286  1.9.2.1      yamt 
   1287  1.9.2.1      yamt 	/* Left channel of analog input */
   1288  1.9.2.1      yamt 	i = 177 - (sc->mixer[2] * 177 / 255);
   1289  1.9.2.1      yamt 	regs[6] = snapper_mixer_gain[i][0];
   1290  1.9.2.1      yamt 	regs[7] = snapper_mixer_gain[i][1];
   1291  1.9.2.1      yamt 	regs[8] = snapper_mixer_gain[i][2];
   1292  1.9.2.1      yamt 
   1293      1.6  macallan 	tas3004_write(sc, DEQ_MIXER_L, regs);
   1294  1.9.2.1      yamt 
   1295  1.9.2.1      yamt 	/* Right channel of SDIN1 */
   1296  1.9.2.1      yamt 	i = 177 - (sc->mixer[3] * 177 / 255);
   1297  1.9.2.1      yamt 	regs[0] = snapper_mixer_gain[i][0];
   1298  1.9.2.1      yamt 	regs[1] = snapper_mixer_gain[i][1];
   1299  1.9.2.1      yamt 	regs[2] = snapper_mixer_gain[i][2];
   1300  1.9.2.1      yamt 
   1301  1.9.2.1      yamt 	/* Right channel of SDIN2 */
   1302  1.9.2.1      yamt 	i = 177 - (sc->mixer[4] * 177 / 255);
   1303  1.9.2.1      yamt 	regs[3] = snapper_mixer_gain[i][0];
   1304  1.9.2.1      yamt 	regs[4] = snapper_mixer_gain[i][1];
   1305  1.9.2.1      yamt 	regs[5] = snapper_mixer_gain[i][2];
   1306  1.9.2.1      yamt 
   1307  1.9.2.1      yamt 	/* Right channel of analog input */
   1308  1.9.2.1      yamt 	i = 177 - (sc->mixer[5] * 177 / 255);
   1309  1.9.2.1      yamt 	regs[6] = snapper_mixer_gain[i][0];
   1310  1.9.2.1      yamt 	regs[7] = snapper_mixer_gain[i][1];
   1311  1.9.2.1      yamt 	regs[8] = snapper_mixer_gain[i][2];
   1312  1.9.2.1      yamt 
   1313      1.6  macallan 	tas3004_write(sc, DEQ_MIXER_R, regs);
   1314      1.1     grant }
   1315      1.1     grant 
   1316      1.1     grant #define CLKSRC_49MHz	0x80000000	/* Use 49152000Hz Osc. */
   1317      1.1     grant #define CLKSRC_45MHz	0x40000000	/* Use 45158400Hz Osc. */
   1318      1.1     grant #define CLKSRC_18MHz	0x00000000	/* Use 18432000Hz Osc. */
   1319      1.1     grant #define MCLK_DIV	0x1f000000	/* MCLK = SRC / DIV */
   1320      1.1     grant #define  MCLK_DIV1	0x14000000	/*  MCLK = SRC */
   1321      1.1     grant #define  MCLK_DIV3	0x13000000	/*  MCLK = SRC / 3 */
   1322      1.1     grant #define  MCLK_DIV5	0x12000000	/*  MCLK = SRC / 5 */
   1323      1.1     grant #define SCLK_DIV	0x00f00000	/* SCLK = MCLK / DIV */
   1324      1.1     grant #define  SCLK_DIV1	0x00800000
   1325      1.1     grant #define  SCLK_DIV3	0x00900000
   1326      1.1     grant #define SCLK_MASTER	0x00080000	/* Master mode */
   1327      1.1     grant #define SCLK_SLAVE	0x00000000	/* Slave mode */
   1328      1.1     grant #define SERIAL_FORMAT	0x00070000
   1329      1.1     grant #define  SERIAL_SONY	0x00000000
   1330      1.1     grant #define  SERIAL_64x	0x00010000
   1331      1.1     grant #define  SERIAL_32x	0x00020000
   1332      1.1     grant #define  SERIAL_DAV	0x00040000
   1333      1.1     grant #define  SERIAL_SILICON	0x00050000
   1334      1.1     grant 
   1335      1.1     grant // rate = fs = LRCLK
   1336      1.1     grant // SCLK = 64*LRCLK (I2S)
   1337      1.1     grant // MCLK = 256fs (typ. -- changeable)
   1338      1.1     grant 
   1339      1.1     grant // MCLK = clksrc / mdiv
   1340      1.1     grant // SCLK = MCLK / sdiv
   1341      1.1     grant // rate = SCLK / 64    ( = LRCLK = fs)
   1342      1.1     grant 
   1343      1.1     grant int
   1344      1.4      kent snapper_set_rate(struct snapper_softc *sc, u_int rate)
   1345      1.1     grant {
   1346      1.4      kent 	u_int reg;
   1347      1.1     grant 	int MCLK;
   1348      1.1     grant 	int clksrc, mdiv, sdiv;
   1349      1.1     grant 	int mclk_fs;
   1350      1.1     grant 
   1351      1.4      kent 	reg = 0;
   1352      1.1     grant 	switch (rate) {
   1353      1.1     grant 	case 8000:
   1354      1.1     grant 		clksrc = 18432000;		/* 18MHz */
   1355      1.1     grant 		reg = CLKSRC_18MHz;
   1356      1.1     grant 		mclk_fs = 256;
   1357      1.1     grant 		break;
   1358      1.1     grant 
   1359      1.1     grant 	case 44100:
   1360      1.1     grant 		clksrc = 45158400;		/* 45MHz */
   1361      1.1     grant 		reg = CLKSRC_45MHz;
   1362      1.1     grant 		mclk_fs = 256;
   1363      1.1     grant 		break;
   1364      1.1     grant 
   1365      1.1     grant 	case 48000:
   1366      1.1     grant 		clksrc = 49152000;		/* 49MHz */
   1367      1.1     grant 		reg = CLKSRC_49MHz;
   1368      1.1     grant 		mclk_fs = 256;
   1369      1.1     grant 		break;
   1370      1.1     grant 
   1371      1.1     grant 	default:
   1372  1.9.2.1      yamt 		DPRINTF("snapper_set_rate: invalid rate %u\n", rate);
   1373      1.1     grant 		return EINVAL;
   1374      1.1     grant 	}
   1375      1.1     grant 
   1376      1.1     grant 	MCLK = rate * mclk_fs;
   1377      1.1     grant 	mdiv = clksrc / MCLK;			// 4
   1378      1.1     grant 	sdiv = mclk_fs / 64;			// 4
   1379      1.1     grant 
   1380      1.1     grant 	switch (mdiv) {
   1381      1.1     grant 	case 1:
   1382      1.1     grant 		reg |= MCLK_DIV1;
   1383      1.1     grant 		break;
   1384      1.1     grant 	case 3:
   1385      1.1     grant 		reg |= MCLK_DIV3;
   1386      1.1     grant 		break;
   1387      1.1     grant 	case 5:
   1388      1.1     grant 		reg |= MCLK_DIV5;
   1389      1.1     grant 		break;
   1390      1.1     grant 	default:
   1391      1.1     grant 		reg |= ((mdiv / 2 - 1) << 24) & 0x1f000000;
   1392      1.1     grant 		break;
   1393      1.1     grant 	}
   1394      1.1     grant 
   1395      1.1     grant 	switch (sdiv) {
   1396      1.1     grant 	case 1:
   1397      1.1     grant 		reg |= SCLK_DIV1;
   1398      1.1     grant 		break;
   1399      1.1     grant 	case 3:
   1400      1.1     grant 		reg |= SCLK_DIV3;
   1401      1.1     grant 		break;
   1402      1.1     grant 	default:
   1403      1.1     grant 		reg |= ((sdiv / 2 - 1) << 20) & 0x00f00000;
   1404      1.1     grant 		break;
   1405      1.1     grant 	}
   1406      1.1     grant 
   1407      1.1     grant 	reg |= SCLK_MASTER;	/* XXX master mode */
   1408      1.1     grant 
   1409      1.1     grant 	reg |= SERIAL_64x;
   1410      1.1     grant 
   1411      1.1     grant 	/* stereo input and output */
   1412      1.1     grant 	DPRINTF("I2SSetDataWordSizeReg 0x%08x -> 0x%08x\n",
   1413      1.1     grant 	    in32rb(sc->sc_reg + I2S_WORDSIZE), 0x02000200);
   1414      1.1     grant 	out32rb(sc->sc_reg + I2S_WORDSIZE, 0x02000200);
   1415      1.1     grant 
   1416      1.1     grant 	DPRINTF("I2SSetSerialFormatReg 0x%x -> 0x%x\n",
   1417      1.1     grant 	    in32rb(sc->sc_reg + I2S_FORMAT), reg);
   1418      1.1     grant 	out32rb(sc->sc_reg + I2S_FORMAT, reg);
   1419      1.1     grant 
   1420      1.1     grant 	return 0;
   1421      1.1     grant }
   1422      1.1     grant 
   1423      1.6  macallan /*#define DEQaddr 0x6a*/
   1424      1.1     grant 
   1425      1.1     grant const struct tas3004_reg tas3004_initdata = {
   1426      1.1     grant 	{ DEQ_MCR1_SC_64 | DEQ_MCR1_SM_I2S | DEQ_MCR1_W_20 },	/* MCR1 */
   1427      1.1     grant 	{ 1, 0, 0, 0, 0, 0 },					/* DRC */
   1428      1.1     grant 	{ 0, 0, 0, 0, 0, 0 },					/* VOLUME */
   1429      1.1     grant 	{ 0x72 },						/* TREBLE */
   1430      1.1     grant 	{ 0x72 },						/* BASS */
   1431      1.1     grant 	{ 0x10, 0x00, 0x00, 0, 0, 0, 0, 0, 0 },			/* MIXER_L */
   1432      1.1     grant 	{ 0x10, 0x00, 0x00, 0, 0, 0, 0, 0, 0 },			/* MIXER_R */
   1433      1.1     grant 	{ 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },	/* BIQUAD */
   1434      1.1     grant 	{ 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },	/* BIQUAD */
   1435      1.1     grant 	{ 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },	/* BIQUAD */
   1436      1.1     grant 	{ 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },	/* BIQUAD */
   1437      1.1     grant 	{ 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },	/* BIQUAD */
   1438      1.1     grant 	{ 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },	/* BIQUAD */
   1439      1.1     grant 	{ 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },	/* BIQUAD */
   1440      1.1     grant 	{ 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },	/* BIQUAD */
   1441      1.1     grant 	{ 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },	/* BIQUAD */
   1442      1.1     grant 	{ 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },	/* BIQUAD */
   1443      1.1     grant 	{ 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },	/* BIQUAD */
   1444      1.1     grant 	{ 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },	/* BIQUAD */
   1445      1.1     grant 	{ 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },	/* BIQUAD */
   1446      1.1     grant 	{ 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },	/* BIQUAD */
   1447      1.1     grant 	{ 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },	/* BIQUAD */
   1448      1.1     grant 	{ 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },	/* BIQUAD */
   1449      1.1     grant 	{ 0, 0, 0 },						/* LLB_GAIN */
   1450      1.1     grant 	{ 0, 0, 0 },						/* RLB_GAIN */
   1451  1.9.2.1      yamt 	{ DEQ_ACR_ADM | DEQ_ACR_LRB | DEQ_ACR_INP_B },		/* ACR - right channel of input B is the microphone */
   1452      1.6  macallan 	{ 2 }							/* MCR2 - AllPass mode since we don't use the equalizer anyway */
   1453      1.1     grant };
   1454      1.1     grant 
   1455      1.1     grant const char tas3004_regsize[] = {
   1456      1.1     grant 	0,					/* 0x00 */
   1457      1.1     grant 	sizeof tas3004_initdata.MCR1,		/* 0x01 */
   1458      1.1     grant 	sizeof tas3004_initdata.DRC,		/* 0x02 */
   1459      1.1     grant 	0,					/* 0x03 */
   1460      1.1     grant 	sizeof tas3004_initdata.VOLUME,		/* 0x04 */
   1461      1.1     grant 	sizeof tas3004_initdata.TREBLE,		/* 0x05 */
   1462      1.1     grant 	sizeof tas3004_initdata.BASS,		/* 0x06 */
   1463      1.1     grant 	sizeof tas3004_initdata.MIXER_L,	/* 0x07 */
   1464      1.1     grant 	sizeof tas3004_initdata.MIXER_R,	/* 0x08 */
   1465      1.1     grant 	0,					/* 0x09 */
   1466      1.1     grant 	sizeof tas3004_initdata.LB0,		/* 0x0a */
   1467      1.1     grant 	sizeof tas3004_initdata.LB1,		/* 0x0b */
   1468      1.1     grant 	sizeof tas3004_initdata.LB2,		/* 0x0c */
   1469      1.1     grant 	sizeof tas3004_initdata.LB3,		/* 0x0d */
   1470      1.1     grant 	sizeof tas3004_initdata.LB4,		/* 0x0e */
   1471      1.1     grant 	sizeof tas3004_initdata.LB5,		/* 0x0f */
   1472      1.1     grant 	sizeof tas3004_initdata.LB6,		/* 0x10 */
   1473      1.1     grant 	0,					/* 0x11 */
   1474      1.1     grant 	0,					/* 0x12 */
   1475      1.1     grant 	sizeof tas3004_initdata.RB0,		/* 0x13 */
   1476      1.1     grant 	sizeof tas3004_initdata.RB1,		/* 0x14 */
   1477      1.1     grant 	sizeof tas3004_initdata.RB2,		/* 0x15 */
   1478      1.1     grant 	sizeof tas3004_initdata.RB3,		/* 0x16 */
   1479      1.1     grant 	sizeof tas3004_initdata.RB4,		/* 0x17 */
   1480      1.1     grant 	sizeof tas3004_initdata.RB5,		/* 0x18 */
   1481      1.1     grant 	sizeof tas3004_initdata.RB6,		/* 0x19 */
   1482      1.1     grant 	0,0,0,0, 0,0,
   1483      1.1     grant 	0,					/* 0x20 */
   1484      1.1     grant 	sizeof tas3004_initdata.LLB,		/* 0x21 */
   1485      1.1     grant 	sizeof tas3004_initdata.RLB,		/* 0x22 */
   1486      1.1     grant 	sizeof tas3004_initdata.LLB_GAIN,	/* 0x23 */
   1487      1.1     grant 	sizeof tas3004_initdata.RLB_GAIN,	/* 0x24 */
   1488      1.1     grant 	0,0,0,0, 0,0,0,0, 0,0,0,
   1489      1.1     grant 	0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
   1490      1.1     grant 	sizeof tas3004_initdata.ACR,		/* 0x40 */
   1491      1.1     grant 	0,					/* 0x41 */
   1492      1.1     grant 	0,					/* 0x42 */
   1493      1.1     grant 	sizeof tas3004_initdata.MCR2		/* 0x43 */
   1494      1.1     grant };
   1495      1.1     grant 
   1496      1.1     grant int
   1497      1.4      kent tas3004_write(struct snapper_softc *sc, u_int reg, const void *data)
   1498      1.1     grant {
   1499      1.1     grant 	int size;
   1500      1.6  macallan 	static char regblock[sizeof(struct tas3004_reg)+1];
   1501  1.9.2.1      yamt 
   1502      1.1     grant 	KASSERT(reg < sizeof tas3004_regsize);
   1503      1.1     grant 	size = tas3004_regsize[reg];
   1504      1.1     grant 	KASSERT(size > 0);
   1505      1.1     grant 
   1506  1.9.2.1      yamt #ifdef SNAPPER_DEBUG
   1507  1.9.2.1      yamt 	printf("reg: %x, %d %d\n", reg, size, ((const char*)data)[0]);
   1508      1.6  macallan #endif
   1509      1.6  macallan #if 0
   1510      1.6  macallan 	ki2c_setmode(sc->sc_i2c, 8); /* std+sub mode */
   1511      1.6  macallan 
   1512      1.1     grant 	if (ki2c_write(sc->sc_i2c, DEQaddr, reg, data, size))
   1513      1.1     grant 		return -1;
   1514      1.6  macallan #endif
   1515      1.6  macallan 	/* ugly, but for now... */
   1516      1.6  macallan 	regblock[0] = reg;
   1517      1.6  macallan 	memcpy(&regblock[1], data, size);
   1518      1.6  macallan 	iic_acquire_bus(sc->sc_i2c, 0);
   1519  1.9.2.1      yamt 	iic_exec(sc->sc_i2c, I2C_OP_WRITE, sc->sc_deqaddr, regblock, size + 1,
   1520      1.6  macallan 	    NULL, 0, 0);
   1521      1.6  macallan 	iic_release_bus(sc->sc_i2c, 0);
   1522      1.6  macallan 
   1523      1.1     grant 	return 0;
   1524      1.1     grant }
   1525      1.1     grant 
   1526      1.1     grant int
   1527      1.4      kent gpio_read(char *addr)
   1528      1.1     grant {
   1529      1.4      kent 
   1530      1.1     grant 	if (*addr & GPIO_DATA)
   1531      1.1     grant 		return 1;
   1532      1.1     grant 	return 0;
   1533      1.1     grant }
   1534      1.1     grant 
   1535      1.1     grant void
   1536      1.4      kent gpio_write(char *addr, int val)
   1537      1.1     grant {
   1538      1.4      kent 	u_int data;
   1539      1.1     grant 
   1540      1.4      kent 	data = GPIO_DDR_OUTPUT;
   1541      1.1     grant 	if (val)
   1542      1.1     grant 		data |= GPIO_DATA;
   1543      1.1     grant 	*addr = data;
   1544      1.8     perry 	__asm volatile ("eieio");
   1545      1.1     grant }
   1546      1.1     grant 
   1547      1.1     grant #define headphone_active 0	/* XXX OF */
   1548      1.1     grant #define amp_active 0		/* XXX OF */
   1549      1.1     grant 
   1550      1.1     grant void
   1551      1.4      kent snapper_mute_speaker(struct snapper_softc *sc, int mute)
   1552      1.1     grant {
   1553      1.1     grant 	u_int x;
   1554      1.1     grant 
   1555      1.1     grant 	DPRINTF("ampmute %d --> ", gpio_read(amp_mute));
   1556      1.1     grant 
   1557      1.1     grant 	if (mute)
   1558      1.1     grant 		x = amp_active;		/* mute */
   1559      1.1     grant 	else
   1560      1.1     grant 		x = !amp_active;	/* unmute */
   1561      1.1     grant 	if (x != gpio_read(amp_mute))
   1562      1.1     grant 		gpio_write(amp_mute, x);
   1563      1.1     grant 
   1564      1.1     grant 	DPRINTF("%d\n", gpio_read(amp_mute));
   1565      1.1     grant }
   1566      1.1     grant 
   1567      1.1     grant void
   1568      1.4      kent snapper_mute_headphone(struct snapper_softc *sc, int mute)
   1569      1.1     grant {
   1570      1.1     grant 	u_int x;
   1571      1.1     grant 
   1572      1.1     grant 	DPRINTF("headphonemute %d --> ", gpio_read(headphone_mute));
   1573      1.1     grant 
   1574      1.1     grant 	if (mute)
   1575      1.1     grant 		x = headphone_active;	/* mute */
   1576      1.1     grant 	else
   1577      1.1     grant 		x = !headphone_active;	/* unmute */
   1578      1.1     grant 	if (x != gpio_read(headphone_mute))
   1579      1.1     grant 		gpio_write(headphone_mute, x);
   1580      1.1     grant 
   1581      1.1     grant 	DPRINTF("%d\n", gpio_read(headphone_mute));
   1582      1.1     grant }
   1583      1.1     grant 
   1584      1.1     grant int
   1585      1.4      kent snapper_cint(void *v)
   1586      1.1     grant {
   1587      1.4      kent 	struct snapper_softc *sc;
   1588      1.1     grant 	u_int sense;
   1589      1.1     grant 
   1590      1.4      kent 	sc = v;
   1591      1.1     grant 	sense = *headphone_detect;
   1592      1.1     grant 	DPRINTF("headphone detect = 0x%x\n", sense);
   1593      1.1     grant 
   1594      1.1     grant 	if (((sense & 0x02) >> 1) == headphone_detect_active) {
   1595      1.1     grant 		DPRINTF("headphone is inserted\n");
   1596      1.1     grant 		snapper_mute_speaker(sc, 1);
   1597      1.1     grant 		snapper_mute_headphone(sc, 0);
   1598      1.1     grant 		sc->sc_output_mask = 1 << 1;
   1599      1.1     grant 	} else {
   1600      1.1     grant 		DPRINTF("headphone is NOT inserted\n");
   1601      1.1     grant 		snapper_mute_speaker(sc, 0);
   1602      1.1     grant 		snapper_mute_headphone(sc, 1);
   1603      1.1     grant 		sc->sc_output_mask = 1 << 0;
   1604      1.1     grant 	}
   1605      1.1     grant 
   1606      1.1     grant 	return 1;
   1607      1.1     grant }
   1608      1.1     grant 
   1609      1.1     grant #define reset_active 0	/* XXX OF */
   1610      1.1     grant 
   1611      1.1     grant #define DEQ_WRITE(sc, reg, addr) \
   1612      1.1     grant 	if (tas3004_write(sc, reg, addr)) goto err
   1613      1.1     grant 
   1614      1.1     grant int
   1615      1.4      kent tas3004_init(struct snapper_softc *sc)
   1616      1.1     grant {
   1617      1.1     grant 
   1618      1.1     grant 	/* No reset port.  Nothing to do. */
   1619      1.1     grant 	if (audio_hw_reset == NULL)
   1620      1.1     grant 		goto noreset;
   1621      1.1     grant 
   1622      1.1     grant 	/* Reset TAS3004. */
   1623      1.1     grant 	gpio_write(audio_hw_reset, !reset_active);	/* Negate RESET */
   1624      1.1     grant 	delay(100000);				/* XXX Really needed? */
   1625      1.1     grant 
   1626      1.1     grant 	gpio_write(audio_hw_reset, reset_active);	/* Assert RESET */
   1627      1.1     grant 	delay(1);
   1628      1.1     grant 
   1629      1.1     grant 	gpio_write(audio_hw_reset, !reset_active);	/* Negate RESET */
   1630      1.1     grant 	delay(10000);
   1631      1.1     grant 
   1632      1.1     grant noreset:
   1633      1.1     grant 	DEQ_WRITE(sc, DEQ_LB0, tas3004_initdata.LB0);
   1634      1.1     grant 	DEQ_WRITE(sc, DEQ_LB1, tas3004_initdata.LB1);
   1635      1.1     grant 	DEQ_WRITE(sc, DEQ_LB2, tas3004_initdata.LB2);
   1636      1.1     grant 	DEQ_WRITE(sc, DEQ_LB3, tas3004_initdata.LB3);
   1637      1.1     grant 	DEQ_WRITE(sc, DEQ_LB4, tas3004_initdata.LB4);
   1638      1.1     grant 	DEQ_WRITE(sc, DEQ_LB5, tas3004_initdata.LB5);
   1639      1.1     grant 	DEQ_WRITE(sc, DEQ_LB6, tas3004_initdata.LB6);
   1640      1.1     grant 	DEQ_WRITE(sc, DEQ_RB0, tas3004_initdata.RB0);
   1641      1.1     grant 	DEQ_WRITE(sc, DEQ_RB1, tas3004_initdata.RB1);
   1642      1.1     grant 	DEQ_WRITE(sc, DEQ_RB1, tas3004_initdata.RB1);
   1643      1.1     grant 	DEQ_WRITE(sc, DEQ_RB2, tas3004_initdata.RB2);
   1644      1.1     grant 	DEQ_WRITE(sc, DEQ_RB3, tas3004_initdata.RB3);
   1645      1.1     grant 	DEQ_WRITE(sc, DEQ_RB4, tas3004_initdata.RB4);
   1646      1.1     grant 	DEQ_WRITE(sc, DEQ_RB5, tas3004_initdata.RB5);
   1647      1.1     grant 	DEQ_WRITE(sc, DEQ_MCR1, tas3004_initdata.MCR1);
   1648      1.1     grant 	DEQ_WRITE(sc, DEQ_MCR2, tas3004_initdata.MCR2);
   1649      1.1     grant 	DEQ_WRITE(sc, DEQ_DRC, tas3004_initdata.DRC);
   1650      1.1     grant 	DEQ_WRITE(sc, DEQ_VOLUME, tas3004_initdata.VOLUME);
   1651      1.1     grant 	DEQ_WRITE(sc, DEQ_TREBLE, tas3004_initdata.TREBLE);
   1652      1.1     grant 	DEQ_WRITE(sc, DEQ_BASS, tas3004_initdata.BASS);
   1653      1.1     grant 	DEQ_WRITE(sc, DEQ_MIXER_L, tas3004_initdata.MIXER_L);
   1654      1.1     grant 	DEQ_WRITE(sc, DEQ_MIXER_R, tas3004_initdata.MIXER_R);
   1655      1.1     grant 	DEQ_WRITE(sc, DEQ_LLB, tas3004_initdata.LLB);
   1656      1.1     grant 	DEQ_WRITE(sc, DEQ_RLB, tas3004_initdata.RLB);
   1657      1.1     grant 	DEQ_WRITE(sc, DEQ_LLB_GAIN, tas3004_initdata.LLB_GAIN);
   1658      1.1     grant 	DEQ_WRITE(sc, DEQ_RLB_GAIN, tas3004_initdata.RLB_GAIN);
   1659      1.1     grant 	DEQ_WRITE(sc, DEQ_ACR, tas3004_initdata.ACR);
   1660      1.1     grant 
   1661      1.1     grant 	return 0;
   1662      1.1     grant err:
   1663      1.1     grant 	printf("tas3004_init: error\n");
   1664      1.1     grant 	return -1;
   1665      1.1     grant }
   1666      1.1     grant 
   1667      1.1     grant /* FCR(0x3c) bits */
   1668      1.1     grant #define I2S0CLKEN	0x1000
   1669      1.1     grant #define I2S0EN		0x2000
   1670      1.1     grant #define I2S1CLKEN	0x080000
   1671      1.1     grant #define I2S1EN		0x100000
   1672      1.1     grant 
   1673      1.1     grant #define FCR3C_BITMASK "\020\25I2S1EN\24I2S1CLKEN\16I2S0EN\15I2S0CLKEN"
   1674      1.1     grant 
   1675      1.1     grant void
   1676      1.4      kent snapper_init(struct snapper_softc *sc, int node)
   1677      1.1     grant {
   1678      1.1     grant 	int gpio;
   1679      1.4      kent 	int headphone_detect_intr, headphone_detect_intrtype;
   1680      1.1     grant #ifdef SNAPPER_DEBUG
   1681      1.1     grant 	char fcr[32];
   1682      1.1     grant 
   1683      1.1     grant 	bitmask_snprintf(in32rb(0x8000003c), FCR3C_BITMASK, fcr, sizeof fcr);
   1684      1.1     grant 	printf("FCR(0x3c) 0x%s\n", fcr);
   1685      1.1     grant #endif
   1686      1.4      kent 	headphone_detect_intr = -1;
   1687      1.1     grant 
   1688      1.1     grant 	gpio = getnodebyname(OF_parent(node), "gpio");
   1689      1.1     grant 	DPRINTF(" /gpio 0x%x\n", gpio);
   1690      1.1     grant 	gpio = OF_child(gpio);
   1691      1.1     grant 	while (gpio) {
   1692      1.1     grant 		char name[64], audio_gpio[64];
   1693      1.1     grant 		int intr[2];
   1694      1.1     grant 		char *addr;
   1695      1.1     grant 
   1696      1.1     grant 		bzero(name, sizeof name);
   1697      1.1     grant 		bzero(audio_gpio, sizeof audio_gpio);
   1698      1.1     grant 		addr = 0;
   1699      1.1     grant 		OF_getprop(gpio, "name", name, sizeof name);
   1700      1.1     grant 		OF_getprop(gpio, "audio-gpio", audio_gpio, sizeof audio_gpio);
   1701      1.1     grant 		OF_getprop(gpio, "AAPL,address", &addr, sizeof addr);
   1702  1.9.2.1      yamt 		DPRINTF(" 0x%x %s %s\n", gpio, name, audio_gpio);
   1703      1.1     grant 
   1704      1.1     grant 		/* gpio5 */
   1705      1.1     grant 		if (strcmp(audio_gpio, "headphone-mute") == 0)
   1706      1.1     grant 			headphone_mute = addr;
   1707      1.1     grant 		/* gpio6 */
   1708      1.1     grant 		if (strcmp(audio_gpio, "amp-mute") == 0)
   1709      1.1     grant 			amp_mute = addr;
   1710      1.1     grant 		/* extint-gpio15 */
   1711      1.1     grant 		if (strcmp(audio_gpio, "headphone-detect") == 0) {
   1712      1.1     grant 			headphone_detect = addr;
   1713      1.1     grant 			OF_getprop(gpio, "audio-gpio-active-state",
   1714      1.1     grant 			    &headphone_detect_active, 4);
   1715      1.1     grant 			OF_getprop(gpio, "interrupts", intr, 8);
   1716      1.1     grant 			headphone_detect_intr = intr[0];
   1717      1.1     grant 			headphone_detect_intrtype = intr[1];
   1718      1.1     grant 		}
   1719      1.1     grant 		/* gpio11 (keywest-11) */
   1720      1.1     grant 		if (strcmp(audio_gpio, "audio-hw-reset") == 0)
   1721      1.1     grant 			audio_hw_reset = addr;
   1722      1.1     grant 		gpio = OF_peer(gpio);
   1723      1.1     grant 	}
   1724      1.1     grant 	DPRINTF(" headphone-mute %p\n", headphone_mute);
   1725      1.1     grant 	DPRINTF(" amp-mute %p\n", amp_mute);
   1726      1.1     grant 	DPRINTF(" headphone-detect %p\n", headphone_detect);
   1727      1.1     grant 	DPRINTF(" headphone-detect active %x\n", headphone_detect_active);
   1728      1.1     grant 	DPRINTF(" headphone-detect intr %x\n", headphone_detect_intr);
   1729      1.1     grant 	DPRINTF(" audio-hw-reset %p\n", audio_hw_reset);
   1730      1.1     grant 
   1731      1.1     grant 	if (headphone_detect_intr != -1)
   1732      1.1     grant 		intr_establish(headphone_detect_intr, IST_EDGE, IPL_AUDIO,
   1733      1.1     grant 		    snapper_cint, sc);
   1734      1.1     grant 
   1735      1.1     grant 	/* "sample-rates" (44100, 48000) */
   1736      1.1     grant 	snapper_set_rate(sc, 44100);
   1737      1.1     grant 
   1738      1.1     grant 	/* Enable headphone interrupt? */
   1739      1.1     grant 	*headphone_detect |= 0x80;
   1740      1.8     perry 	__asm volatile ("eieio");
   1741      1.1     grant 
   1742      1.1     grant 	/* i2c_set_port(port); */
   1743      1.1     grant 
   1744      1.6  macallan #if 0
   1745      1.1     grant 	/* Enable I2C interrupts. */
   1746      1.1     grant #define IER 4
   1747      1.1     grant #define I2C_INT_DATA 0x01
   1748      1.1     grant #define I2C_INT_ADDR 0x02
   1749      1.1     grant #define I2C_INT_STOP 0x04
   1750      1.1     grant 	ki2c_writereg(sc->sc_i2c, IER,I2C_INT_DATA|I2C_INT_ADDR|I2C_INT_STOP);
   1751      1.1     grant #endif
   1752      1.1     grant 
   1753      1.1     grant 	if (tas3004_init(sc))
   1754      1.1     grant 		return;
   1755      1.1     grant 
   1756      1.1     grant 	/* Update headphone status. */
   1757      1.1     grant 	snapper_cint(sc);
   1758      1.1     grant 
   1759      1.1     grant 	snapper_set_volume(sc, 80, 80);
   1760      1.6  macallan 
   1761      1.6  macallan 	sc->sc_bass = 128;
   1762      1.6  macallan 	sc->sc_treble = 128;
   1763  1.9.2.1      yamt 
   1764  1.9.2.1      yamt 	/* Record source defaults to microphone.  This reflects the
   1765  1.9.2.1      yamt 	 * default value for the ACR (see tas3004_initdata).
   1766  1.9.2.1      yamt 	 */
   1767  1.9.2.1      yamt 	sc->sc_record_source = 1 << 0;
   1768      1.6  macallan 
   1769      1.6  macallan 	/* We mute the analog input for now */
   1770      1.6  macallan 	sc->mixer[0] = 80;
   1771      1.6  macallan 	sc->mixer[1] = 80;
   1772      1.6  macallan 	sc->mixer[2] = 0;
   1773      1.6  macallan 	sc->mixer[3] = 80;
   1774      1.6  macallan 	sc->mixer[4] = 80;
   1775      1.6  macallan 	sc->mixer[5] = 0;
   1776      1.6  macallan 	snapper_write_mixers(sc);
   1777      1.1     grant }
   1778