Home | History | Annotate | Line # | Download | only in ic
tms320av110.c revision 1.21.36.1
      1  1.21.36.1  jmcneill /*	$NetBSD: tms320av110.c,v 1.21.36.1 2011/11/20 15:48:52 jmcneill Exp $	*/
      2        1.1        is 
      3        1.1        is /*-
      4        1.8        is  * Copyright (c) 1997 The NetBSD Foundation, Inc.
      5        1.7        is  * All rights reserved.
      6        1.7        is  *
      7        1.7        is  * This code is derived from software contributed to The NetBSD Foundation
      8        1.7        is  * by Ignatios Souvatzis.
      9        1.1        is  *
     10        1.1        is  * Redistribution and use in source and binary forms, with or without
     11        1.1        is  * modification, are permitted provided that the following conditions
     12        1.1        is  * are met:
     13        1.1        is  * 1. Redistributions of source code must retain the above copyright
     14        1.1        is  *    notice, this list of conditions and the following disclaimer.
     15        1.1        is  * 2. Redistributions in binary form must reproduce the above copyright
     16        1.1        is  *    notice, this list of conditions and the following disclaimer in the
     17        1.1        is  *    documentation and/or other materials provided with the distribution.
     18        1.1        is  *
     19        1.7        is  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20        1.7        is  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21        1.7        is  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22        1.7        is  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23        1.7        is  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24        1.7        is  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25        1.7        is  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26        1.7        is  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27        1.7        is  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28        1.7        is  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29        1.7        is  * POSSIBILITY OF SUCH DAMAGE.
     30        1.1        is  */
     31        1.1        is 
     32        1.1        is /*
     33        1.1        is  * Machine independent part of TMS320AV110 driver.
     34        1.1        is  *
     35        1.1        is  * Currently, only minimum support for audio output. For audio/video
     36        1.1        is  * synchronization, more is needed.
     37        1.1        is  */
     38       1.10     lukem 
     39       1.10     lukem #include <sys/cdefs.h>
     40  1.21.36.1  jmcneill __KERNEL_RCSID(0, "$NetBSD: tms320av110.c,v 1.21.36.1 2011/11/20 15:48:52 jmcneill Exp $");
     41        1.1        is 
     42        1.1        is #include <sys/param.h>
     43        1.1        is #include <sys/systm.h>
     44        1.1        is #include <sys/kernel.h>
     45        1.1        is #include <sys/device.h>
     46        1.1        is #include <sys/proc.h>
     47        1.1        is 
     48        1.1        is #include <sys/audioio.h>
     49        1.1        is #include <dev/audio_if.h>
     50        1.1        is 
     51        1.1        is #include <dev/ic/tms320av110reg.h>
     52        1.1        is #include <dev/ic/tms320av110var.h>
     53        1.1        is 
     54       1.19        ad #include <sys/bus.h>
     55        1.1        is 
     56       1.17      kent int tav_open(void *, int);
     57       1.17      kent void tav_close(void *);
     58       1.17      kent int tav_drain(void *);
     59       1.17      kent int tav_query_encoding(void *, struct audio_encoding *);
     60       1.17      kent int tav_set_params(void *, int, int, audio_params_t *, audio_params_t *,
     61       1.17      kent     stream_filter_list_t *, stream_filter_list_t *);
     62       1.17      kent int tav_round_blocksize(void *, int, int, const audio_params_t *);
     63       1.17      kent int tav_init_output(void *, void *, int);
     64       1.17      kent int tav_start_output(void *, void *, int, void (*)(void *), void *);
     65       1.17      kent int tav_start_input(void *, void *, int, void (*)(void *), void *);
     66       1.17      kent int tav_halt_output(void *);
     67       1.17      kent int tav_halt_input(void *);
     68       1.17      kent int tav_speaker_ctl(void *, int);
     69       1.17      kent int tav_getdev(void *, struct audio_device *);
     70       1.17      kent int tav_setfd(void *, int);
     71       1.17      kent int tav_set_port(void *, mixer_ctrl_t *);
     72       1.17      kent int tav_get_port(void *, mixer_ctrl_t *);
     73       1.17      kent int tav_query_devinfo(void *, mixer_devinfo_t *);
     74       1.17      kent int tav_get_props(void *);
     75  1.21.36.1  jmcneill void tav_get_locks(void *, kmutex_t **, kmutex_t **);
     76        1.1        is 
     77       1.15      yamt const struct audio_hw_if tav_audio_if = {
     78        1.1        is 	tav_open,
     79        1.1        is 	tav_close,
     80        1.1        is 	0 /* tav_drain*/,		/* optional */
     81        1.1        is 	tav_query_encoding,
     82        1.1        is 	tav_set_params,
     83        1.1        is 	tav_round_blocksize,
     84        1.1        is 	0 /* commit_settings */,	/* optional */
     85        1.1        is 	tav_init_output,		/* optional */
     86        1.1        is 	0 /* tav_init_input */,		/* optional */
     87        1.1        is 	tav_start_output,
     88        1.1        is 	tav_start_input,
     89        1.1        is 	tav_halt_output,
     90        1.1        is 	tav_halt_input,
     91        1.1        is 	tav_speaker_ctl,		/* optional */
     92        1.1        is 	tav_getdev,
     93        1.1        is 	0 /* setfd */,			/* optional */
     94        1.1        is 	tav_set_port,
     95        1.1        is 	tav_get_port,
     96        1.1        is 	tav_query_devinfo,
     97        1.1        is 	0 /* alloc */,			/* optional */
     98        1.1        is 	0 /* free */,			/* optional */
     99        1.1        is 	0 /* round_buffersize */,	/* optional */
    100        1.1        is 	0 /* mappage */,		/* optional */
    101        1.9  augustss 	tav_get_props,
    102  1.21.36.1  jmcneill 	0, /* trigger_output */
    103  1.21.36.1  jmcneill 	0, /* trigger_input */
    104  1.21.36.1  jmcneill 	0, /* dev_ioctl */		/* optional */
    105  1.21.36.1  jmcneill 	0, /* powerhook */		/* optional */
    106  1.21.36.1  jmcneill 	tav_get_locks,
    107        1.1        is };
    108        1.1        is 
    109        1.1        is void
    110       1.17      kent tms320av110_attach_mi(struct tav_softc *sc)
    111        1.1        is {
    112       1.17      kent 	bus_space_tag_t iot;
    113       1.17      kent 	bus_space_handle_t ioh;
    114        1.1        is 
    115       1.17      kent 	iot = sc->sc_iot;
    116       1.17      kent 	ioh = sc->sc_ioh;
    117        1.1        is 	tav_write_byte(iot, ioh, TAV_RESET, 1);
    118        1.1        is 	while (tav_read_byte(iot, ioh, TAV_RESET))
    119        1.1        is 		delay(250);
    120        1.1        is 
    121        1.1        is 	tav_write_byte(iot, ioh, TAV_PCM_ORD, sc->sc_pcm_ord);
    122        1.1        is 	tav_write_byte(iot, ioh, TAV_PCM_18, sc->sc_pcm_18);
    123        1.1        is 	tav_write_byte(iot, ioh, TAV_DIF, sc->sc_dif);
    124        1.1        is 	tav_write_byte(iot, ioh, TAV_PCM_DIV, sc->sc_pcm_div);
    125        1.1        is 
    126        1.1        is 	printf(": chip rev. %d, %d bytes buffer\n",
    127        1.1        is 	    tav_read_byte(iot, ioh, TAV_VERSION),
    128        1.1        is 	    TAV_DRAM_SIZE(tav_read_byte(iot, ioh, TAV_DRAM_EXT)));
    129        1.1        is 
    130        1.1        is 	tav_write_byte(iot, ioh, TAV_AUD_ID_EN, 0);
    131        1.1        is 	tav_write_byte(iot, ioh, TAV_SKIP, 0);
    132        1.1        is 	tav_write_byte(iot, ioh, TAV_REPEAT, 0);
    133        1.1        is 	tav_write_byte(iot, ioh, TAV_MUTE, 0);
    134        1.1        is 	tav_write_byte(iot, ioh, TAV_PLAY, 1);
    135        1.1        is 	tav_write_byte(iot, ioh, TAV_SYNC_ECM, 0);
    136        1.1        is 	tav_write_byte(iot, ioh, TAV_CRC_ECM, 0);
    137        1.1        is 	tav_write_byte(iot, ioh, TAV_ATTEN_L, 0);
    138        1.1        is 	tav_write_byte(iot, ioh, TAV_ATTEN_R, 0);
    139        1.3        is 	tav_write_short(iot, ioh, TAV_FREE_FORM, 0);
    140        1.1        is 	tav_write_byte(iot, ioh, TAV_SIN_EN, 0);
    141        1.1        is 	tav_write_byte(iot, ioh, TAV_SYNC_ECM, TAV_ECM_REPEAT);
    142        1.1        is 	tav_write_byte(iot, ioh, TAV_CRC_ECM, TAV_ECM_REPEAT);
    143        1.1        is 
    144        1.6  augustss 	audio_attach_mi(&tav_audio_if, sc, &sc->sc_dev);
    145        1.1        is }
    146        1.1        is 
    147        1.1        is int
    148       1.17      kent tms320av110_intr(void *p)
    149        1.1        is {
    150       1.17      kent 	struct tav_softc *sc;
    151       1.17      kent 	uint16_t intlist;
    152        1.1        is 
    153       1.17      kent 	sc = p;
    154  1.21.36.1  jmcneill 
    155  1.21.36.1  jmcneill 	mutex_spin_enter(&sc->sc_intr_lock);
    156  1.21.36.1  jmcneill 
    157        1.1        is 	intlist = tav_read_short(sc->sc_iot, sc->sc_ioh, TAV_INTR)
    158        1.1        is 	    /* & tav_read_short(sc->sc_iot, sc->sc_ioh, TAV_INTR_EN)*/;
    159        1.1        is 
    160        1.1        is 	if (!intlist)
    161        1.1        is 		return 0;
    162        1.1        is 
    163       1.12       wiz 	/* ack now, so that we don't miss later interrupts */
    164        1.1        is 	if (sc->sc_intack)
    165        1.1        is 		(sc->sc_intack)(sc);
    166        1.1        is 
    167        1.1        is 	if (intlist & TAV_INTR_LOWWATER) {
    168        1.1        is 		(*sc->sc_intr)(sc->sc_intrarg);
    169        1.1        is 	}
    170        1.1        is 
    171        1.1        is 	if (intlist & TAV_INTR_PCM_OUTPUT_UNDERFLOW) {
    172  1.21.36.1  jmcneill 		 cv_broadcast(&sc->sc_cv);
    173        1.1        is 	}
    174        1.1        is 
    175  1.21.36.1  jmcneill 	mutex_spin_exit(&sc->sc_intr_lock);
    176  1.21.36.1  jmcneill 
    177        1.1        is 	return 1;
    178        1.1        is }
    179        1.1        is 
    180        1.1        is struct audio_encoding tav_encodings[] = {
    181        1.2  augustss 	{0, AudioEmpeg_l2_stream, AUDIO_ENCODING_MPEG_L2_STREAM, 1, 0,},
    182        1.2  augustss 	{1, AudioEmpeg_l2_packets, AUDIO_ENCODING_MPEG_L2_PACKETS, 1, 0,},
    183        1.4        is 	{2, AudioEmpeg_l2_system, AUDIO_ENCODING_MPEG_L2_SYSTEM, 1, 0,},
    184        1.2  augustss 	{3, AudioEslinear_be, AUDIO_ENCODING_SLINEAR_BE, 16, 0,},
    185        1.1        is };
    186        1.1        is 
    187        1.1        is int
    188       1.17      kent tav_open(void *hdl, int flags)
    189        1.1        is {
    190       1.17      kent 
    191        1.1        is 	/* dummy */
    192        1.1        is 	return 0;
    193        1.1        is }
    194        1.1        is 
    195        1.1        is void
    196       1.17      kent tav_close(void *hdl)
    197        1.1        is {
    198       1.17      kent 	struct tav_softc *sc;
    199        1.1        is 	bus_space_tag_t iot;
    200        1.1        is 	bus_space_handle_t ioh;
    201        1.1        is 
    202        1.1        is 	sc = hdl;
    203        1.1        is 	iot = sc->sc_iot;
    204        1.1        is 	ioh = sc->sc_ioh;
    205        1.1        is 
    206       1.12       wiz 	/* re"start" chip, also clears interrupts and interrupt enable */
    207        1.1        is 	tav_write_short(iot, ioh, TAV_INTR_EN, 0);
    208        1.1        is 	if (sc->sc_intack)
    209        1.1        is 		(*sc->sc_intack)(sc);
    210        1.1        is }
    211        1.1        is 
    212        1.1        is int
    213       1.17      kent tav_drain(void *hdl)
    214        1.1        is {
    215       1.17      kent 	struct tav_softc *sc;
    216        1.1        is 	bus_space_tag_t iot;
    217        1.1        is 	bus_space_handle_t ioh;
    218        1.1        is 	u_int16_t mask;
    219        1.1        is 
    220       1.17      kent 	sc = hdl;
    221        1.1        is 	iot = sc->sc_iot;
    222        1.1        is 	ioh = sc->sc_ioh;
    223        1.1        is 
    224  1.21.36.1  jmcneill 	mutex_spin_enter(&sc->sc_intr_lock);
    225  1.21.36.1  jmcneill 
    226        1.1        is 	/*
    227  1.21.36.1  jmcneill 	 * wait for underflow interrupt.
    228        1.1        is 	 */
    229        1.1        is 	if (tav_read_short(iot, ioh, TAV_BUFF)) {
    230        1.1        is 		mask = tav_read_short(iot, ioh, TAV_INTR_EN);
    231        1.1        is 		tav_write_short(iot, ioh, TAV_INTR_EN,
    232        1.1        is 		    mask|TAV_INTR_PCM_OUTPUT_UNDERFLOW);
    233        1.1        is 
    234        1.1        is 		/* still more than zero? */
    235  1.21.36.1  jmcneill 		if (tav_read_short(iot, ioh, TAV_BUFF)) {
    236  1.21.36.1  jmcneill 			(void)cv_timedwait_sig(&sc->sc_cv,
    237  1.21.36.1  jmcneill 			    &sc->sc_intr_lock, 32*hz);
    238  1.21.36.1  jmcneill 		}
    239        1.1        is 
    240        1.1        is 		/* can be really that long for mpeg */
    241        1.1        is 
    242        1.1        is 		mask = tav_read_short(iot, ioh, TAV_INTR_EN);
    243        1.1        is 		tav_write_short(iot, ioh, TAV_INTR_EN,
    244        1.1        is 		    mask & ~TAV_INTR_PCM_OUTPUT_UNDERFLOW);
    245        1.1        is 	}
    246       1.17      kent 
    247  1.21.36.1  jmcneill 	mutex_spin_exit(&sc->sc_intr_lock);
    248  1.21.36.1  jmcneill 
    249        1.1        is 	return 0;
    250        1.1        is }
    251        1.1        is 
    252        1.1        is int
    253       1.17      kent tav_query_encoding(void *hdl, struct audio_encoding *ae)
    254        1.1        is {
    255       1.17      kent 	struct tav_softc *sc;
    256        1.1        is 
    257        1.1        is 	sc = hdl;
    258        1.1        is 	if (ae->index >= sizeof(tav_encodings)/sizeof(*ae))
    259        1.1        is 		return EINVAL;
    260        1.1        is 
    261        1.1        is 	*ae = tav_encodings[ae->index];
    262        1.1        is 
    263        1.1        is 	return 0;
    264        1.1        is }
    265        1.1        is 
    266        1.1        is int
    267       1.17      kent tav_start_input(void *hdl, void *block, int bsize,
    268       1.17      kent     void (*intr)(void *), void *intrarg)
    269        1.1        is {
    270       1.17      kent 
    271        1.1        is 	return ENOTTY;
    272        1.1        is }
    273        1.1        is 
    274        1.1        is int
    275       1.17      kent tav_halt_input(void *hdl)
    276        1.1        is {
    277       1.17      kent 
    278        1.1        is 	return ENOTTY;
    279        1.1        is }
    280        1.1        is 
    281        1.1        is int
    282       1.17      kent tav_start_output(void *hdl, void *block, int bsize,
    283       1.17      kent     void (*intr)(void *), void *intrarg)
    284        1.1        is {
    285       1.17      kent 	struct tav_softc *sc;
    286        1.1        is 	bus_space_tag_t iot;
    287        1.1        is 	bus_space_handle_t ioh;
    288       1.17      kent 	uint8_t *ptr;
    289        1.1        is 	int count;
    290        1.1        is 
    291       1.17      kent 	sc = hdl;
    292        1.1        is 	iot = sc->sc_iot;
    293        1.1        is 	ioh = sc->sc_ioh;
    294        1.1        is 	ptr = block;
    295        1.1        is 	count = bsize;
    296       1.17      kent 
    297        1.1        is 	sc->sc_intr = intr;
    298        1.1        is 	sc->sc_intrarg = intrarg;
    299        1.1        is 
    300        1.5        is 	bus_space_write_multi_1(iot, ioh, TAV_DATAIN, ptr, count);
    301        1.1        is 	tav_write_short(iot, ioh, TAV_INTR_EN, TAV_INTR_LOWWATER);
    302        1.1        is 
    303        1.1        is 	return 0;
    304        1.1        is }
    305        1.1        is 
    306        1.1        is int
    307       1.17      kent tav_init_output(void *hdl, void *buffer, int size)
    308        1.1        is {
    309       1.17      kent 	struct tav_softc *sc;
    310        1.1        is 	bus_space_tag_t iot;
    311        1.1        is 	bus_space_handle_t ioh;
    312        1.1        is 
    313       1.17      kent 	sc = hdl;
    314        1.1        is 	iot = sc->sc_iot;
    315        1.1        is 	ioh = sc->sc_ioh;
    316        1.1        is 
    317        1.1        is 	tav_write_byte(iot, ioh, TAV_PLAY, 1);
    318        1.1        is 	tav_write_byte(iot, ioh, TAV_MUTE, 0);
    319        1.1        is 
    320        1.1        is 	return 0;
    321        1.1        is }
    322        1.1        is 
    323        1.1        is int
    324       1.17      kent tav_halt_output(void *hdl)
    325        1.1        is {
    326       1.17      kent 	struct tav_softc *sc;
    327        1.1        is 	bus_space_tag_t iot;
    328        1.1        is 	bus_space_handle_t ioh;
    329        1.1        is 
    330       1.17      kent 	sc = hdl;
    331        1.1        is 	iot = sc->sc_iot;
    332        1.1        is 	ioh = sc->sc_ioh;
    333        1.1        is 
    334        1.1        is 	tav_write_byte(iot, ioh, TAV_PLAY, 0);
    335        1.1        is 
    336        1.1        is 	return 0;
    337        1.1        is }
    338        1.1        is 
    339        1.1        is int
    340       1.17      kent tav_getdev(void *hdl, struct audio_device *ret)
    341        1.1        is {
    342       1.17      kent 	struct tav_softc *sc;
    343        1.1        is 	bus_space_tag_t iot;
    344        1.1        is 	bus_space_handle_t ioh;
    345        1.1        is 
    346       1.17      kent 	sc = hdl;
    347        1.1        is 	iot = sc->sc_iot;
    348        1.1        is 	ioh = sc->sc_ioh;
    349        1.1        is 
    350       1.13    itojun 	strlcpy(ret->name, "tms320av110", sizeof(ret->name));
    351       1.13    itojun 	/* guaranteed to be <= 4 in length */
    352       1.13    itojun 	snprintf(ret->version, sizeof(ret->version), "%u",
    353        1.1        is 	    tav_read_byte(iot, ioh, TAV_VERSION));
    354       1.20    cegger 	strlcpy(ret->config, device_xname(&sc->sc_dev), sizeof(ret->config));
    355        1.1        is 
    356        1.1        is 	return 0;
    357        1.1        is }
    358        1.1        is 
    359        1.1        is int
    360       1.17      kent tav_round_blocksize(void *hdl, int size, int mode, const audio_params_t *param)
    361        1.1        is {
    362       1.17      kent 	struct tav_softc *sc;
    363        1.1        is 	bus_space_tag_t iot;
    364        1.1        is 	bus_space_handle_t ioh;
    365        1.1        is 	int maxhalf;
    366        1.1        is 
    367       1.17      kent 	sc = hdl;
    368        1.1        is 	iot = sc->sc_iot;
    369        1.1        is 	ioh = sc->sc_ioh;
    370        1.1        is 
    371        1.1        is 	maxhalf = TAV_DRAM_HSIZE(tav_read_byte(iot, ioh, TAV_DRAM_EXT));
    372        1.1        is 	if (size > maxhalf)
    373        1.1        is 		size = maxhalf;
    374        1.1        is 
    375        1.1        is 	/* XXX should round to 128 bytes limits for audio bypass */
    376        1.1        is 	size &= ~3;
    377        1.1        is 
    378        1.1        is 	tav_write_short(iot, ioh, TAV_BALE_LIM, size/8);
    379        1.1        is 
    380        1.1        is 	/* the buffer limits are in units of 4 bytes */
    381        1.1        is 	return (size);
    382        1.1        is }
    383        1.1        is 
    384        1.1        is int
    385       1.17      kent tav_get_props(void *hdl)
    386        1.1        is {
    387        1.1        is 	return 0;
    388        1.1        is }
    389        1.1        is 
    390  1.21.36.1  jmcneill void
    391  1.21.36.1  jmcneill tav_get_locks(void *hdl, kmutex_t **intr, kmutex_t **thread)
    392  1.21.36.1  jmcneill {
    393  1.21.36.1  jmcneill 	struct tav_softc *sc;
    394  1.21.36.1  jmcneill 
    395  1.21.36.1  jmcneill 	sc = hdl;
    396  1.21.36.1  jmcneill 	*intr = &sc->sc_intr_lock;
    397  1.21.36.1  jmcneill 	*thread = &sc->sc_lock;
    398  1.21.36.1  jmcneill }
    399  1.21.36.1  jmcneill 
    400        1.1        is int
    401       1.17      kent tav_set_params(void *hdl, int setmode, int usemode, audio_params_t *p,
    402       1.17      kent     audio_params_t *r, stream_filter_list_t *pfil, stream_filter_list_t *rfil)
    403        1.1        is {
    404       1.16      kent 	struct tav_softc *sc;
    405        1.1        is 	bus_space_tag_t iot;
    406        1.1        is 	bus_space_handle_t ioh;
    407        1.1        is 
    408       1.16      kent 	sc = hdl;
    409        1.1        is 	iot = sc->sc_iot;
    410        1.1        is 	ioh = sc->sc_ioh;
    411        1.1        is 
    412        1.1        is 	if (!(setmode & AUMODE_PLAY))
    413        1.1        is 		return 0;
    414        1.1        is 
    415        1.1        is 	if (p->encoding == AUDIO_ENCODING_ULAW)
    416        1.1        is 		p->encoding = AUDIO_ENCODING_MPEG_L2_STREAM;
    417        1.1        is 
    418        1.1        is 	switch(p->encoding) {
    419        1.1        is 	default:
    420        1.1        is 		return EINVAL;
    421        1.1        is 
    422        1.1        is 	case AUDIO_ENCODING_SLINEAR_BE:
    423        1.1        is 
    424       1.17      kent 		/* XXX: todo: add 8bit and mono using software */
    425        1.1        is 		p->precision = 16;
    426        1.1        is 		p->channels = 2;
    427        1.1        is 
    428       1.17      kent 		/* XXX: this might depend on the specific board.
    429        1.1        is 		   should be handled by the backend */
    430        1.1        is 
    431        1.1        is 		p->sample_rate = 44100;
    432        1.1        is 
    433       1.17      kent 		bus_space_write_1(iot, ioh, TAV_STR_SEL,
    434        1.1        is 		    TAV_STR_SEL_AUDIO_BYPASS);
    435        1.1        is 		break;
    436        1.1        is 
    437        1.1        is 	/* XXX: later: add ULINEAR, and LE using software encoding */
    438        1.1        is 
    439        1.1        is 	case AUDIO_ENCODING_MPEG_L1_STREAM:
    440        1.1        is 		/* FALLTHROUGH */
    441        1.1        is 	case AUDIO_ENCODING_MPEG_L2_STREAM:
    442        1.1        is 		bus_space_write_1(iot, ioh, TAV_STR_SEL,
    443        1.1        is 		    TAV_STR_SEL_MPEG_AUDIO_STREAM);
    444        1.1        is 		p->sample_rate = 44100;
    445        1.1        is 		p->precision = 1;
    446        1.1        is 		break;
    447        1.1        is 
    448        1.1        is 	case AUDIO_ENCODING_MPEG_L1_PACKETS:
    449        1.1        is 		/* FALLTHROUGH */
    450        1.1        is 	case AUDIO_ENCODING_MPEG_L2_PACKETS:
    451        1.1        is 		bus_space_write_1(iot, ioh, TAV_STR_SEL,
    452        1.1        is 		    TAV_STR_SEL_MPEG_AUDIO_PACKETS);
    453        1.1        is 		p->sample_rate = 44100;
    454        1.1        is 		p->precision = 1;
    455        1.1        is 		break;
    456        1.1        is 
    457        1.1        is 	case AUDIO_ENCODING_MPEG_L1_SYSTEM:
    458        1.1        is 		/* FALLTHROUGH */
    459        1.1        is 	case AUDIO_ENCODING_MPEG_L2_SYSTEM:
    460        1.1        is 		bus_space_write_1(iot, ioh, TAV_STR_SEL,
    461        1.1        is 		    TAV_STR_SEL_MPEG_SYSTEM_STREAM);
    462        1.1        is 		p->sample_rate = 44100;
    463        1.1        is 		p->precision = 1;
    464        1.1        is 		break;
    465        1.1        is 	}
    466        1.1        is 	tav_write_byte(iot, ioh, TAV_RESTART, 1);
    467        1.1        is 	do {
    468        1.1        is 		delay(10);
    469        1.1        is 	} while (tav_read_byte(iot, ioh, TAV_RESTART));
    470        1.1        is 
    471        1.1        is 	return 0;
    472        1.1        is }
    473        1.1        is 
    474        1.1        is int
    475       1.17      kent tav_set_port(void *hdl, mixer_ctrl_t *mc)
    476        1.1        is {
    477       1.17      kent 	struct tav_softc *sc;
    478        1.1        is 
    479        1.1        is 	sc = hdl;
    480        1.1        is 	/* dummy */
    481        1.1        is 	return 0;
    482        1.1        is }
    483        1.1        is 
    484        1.1        is int
    485       1.17      kent tav_get_port(void *hdl, mixer_ctrl_t *mc)
    486        1.1        is {
    487       1.17      kent 	struct tav_softc *sc;
    488        1.1        is 
    489        1.1        is 	sc = hdl;
    490        1.1        is 	/* dummy */
    491        1.1        is 	return 0;
    492        1.1        is }
    493        1.1        is 
    494        1.1        is int
    495       1.17      kent tav_query_devinfo(void *hdl, mixer_devinfo_t *di)
    496        1.1        is {
    497        1.2  augustss 	return ENXIO;
    498        1.1        is }
    499        1.1        is 
    500        1.1        is int
    501       1.17      kent tav_speaker_ctl(void *hdl, int value)
    502        1.1        is {
    503       1.17      kent 	struct tav_softc *sc;
    504        1.1        is 	bus_space_tag_t iot;
    505        1.1        is 	bus_space_handle_t ioh;
    506        1.1        is 
    507        1.1        is 	sc = hdl;
    508        1.1        is 	iot = sc->sc_iot;
    509        1.1        is 	ioh = sc->sc_ioh;
    510        1.1        is 
    511        1.1        is 	tav_write_byte(iot, ioh, TAV_MUTE, !value);
    512        1.1        is 
    513        1.1        is 	return 0;
    514        1.1        is }
    515