vidcaudio.c revision 1.40.2.1       1 /*	$NetBSD: vidcaudio.c,v 1.40.2.1 2005/01/03 16:42:52 kent Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1995 Melvin Tang-Richardson
      5  *
      6  * Redistribution and use in source and binary forms, with or without
      7  * modification, are permitted provided that the following conditions
      8  * are met:
      9  * 1. Redistributions of source code must retain the above copyright
     10  *    notice, this list of conditions and the following disclaimer.
     11  * 2. Redistributions in binary form must reproduce the above copyright
     12  *    notice, this list of conditions and the following disclaimer in the
     13  *    documentation and/or other materials provided with the distribution.
     14  * 3. All advertising materials mentioning features or use of this software
     15  *    must display the following acknowledgement:
     16  *	This product includes software developed by the RiscBSD team.
     17  * 4. The name of the author may not be used to endorse or promote products
     18  *    derived from this software without specific prior written permission.
     19  *
     20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 /*-
     33  * Copyright (c) 2003 Ben Harris
     34  * All rights reserved.
     35  *
     36  * Redistribution and use in source and binary forms, with or without
     37  * modification, are permitted provided that the following conditions
     38  * are met:
     39  * 1. Redistributions of source code must retain the above copyright
     40  *    notice, this list of conditions and the following disclaimer.
     41  * 2. Redistributions in binary form must reproduce the above copyright
     42  *    notice, this list of conditions and the following disclaimer in the
     43  *    documentation and/or other materials provided with the distribution.
     44  * 3. The name of the author may not be used to endorse or promote products
     45  *    derived from this software without specific prior written permission.
     46  *
     47  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     48  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     49  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     50  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     51  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     52  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     53  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     54  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     55  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     56  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     57  */
     58 
     59 /*
     60  * audio driver for the RiscPC 8/16 bit sound
     61  *
     62  * Interfaces with the NetBSD generic audio driver to provide SUN
     63  * /dev/audio (partial) compatibility.
     64  */
     65 
     66 #include <sys/param.h>	/* proc.h */
     67 
     68 __KERNEL_RCSID(0, "$NetBSD: vidcaudio.c,v 1.40.2.1 2005/01/03 16:42:52 kent Exp $");
     69 
     70 #include <sys/audioio.h>
     71 #include <sys/conf.h>   /* autoconfig functions */
     72 #include <sys/device.h> /* device calls */
     73 #include <sys/errno.h>
     74 #include <sys/malloc.h>
     75 #include <sys/proc.h>	/* device calls */
     76 #include <sys/systm.h>
     77 
     78 #include <uvm/uvm_extern.h>
     79 
     80 #include <dev/audio_if.h>
     81 #include <dev/audiobellvar.h>
     82 #include <dev/auconv.h>
     83 #include <dev/mulaw.h>
     84 
     85 #include <machine/intr.h>
     86 #include <machine/machdep.h>
     87 #include <arm/arm32/katelib.h>
     88 
     89 #include <arm/iomd/vidcaudiovar.h>
     90 #include <arm/iomd/iomdreg.h>
     91 #include <arm/iomd/iomdvar.h>
     92 #include <arm/iomd/vidc.h>
     93 #include <arm/mainbus/mainbus.h>
     94 
     95 #include "pckbd.h"
     96 #if NPCKBD > 0
     97 #include <dev/pckbport/pckbdvar.h>
     98 #endif
     99 
    100 #include "rpckbd.h"
    101 #if NRPCKBD > 0
    102 #include <arm/iomd/rpckbdvar.h>
    103 #endif
    104 
    105 #include "vt.h"
    106 #if NVT > 0
    107 extern void vt_hookup_bell(void (*)(void *, u_int, u_int, u_int, int), void *);
    108 #endif
    109 
    110 extern int *vidc_base;
    111 
    112 #ifdef VIDCAUDIO_DEBUG
    113 #define DPRINTF(x)	printf x
    114 #else
    115 #define DPRINTF(x)
    116 #endif
    117 
    118 struct vidcaudio_softc {
    119 	struct	device sc_dev;
    120 
    121 	irqhandler_t	sc_ih;
    122 	int	sc_dma_intr;
    123 
    124 	int	sc_is16bit;
    125 
    126 	size_t	sc_pblksize;
    127 	vm_offset_t	sc_poffset;
    128 	vm_offset_t	sc_pbufsize;
    129 	paddr_t	*sc_ppages;
    130 	void	(*sc_pintr)(void *);
    131 	void	*sc_parg;
    132 	int	sc_pcountdown;
    133 };
    134 
    135 static int  vidcaudio_probe(struct device *, struct cfdata *, void *);
    136 static void vidcaudio_attach(struct device *, struct device *, void *);
    137 static int  vidcaudio_open(void *, int);
    138 static void vidcaudio_close(void *);
    139 
    140 static int vidcaudio_intr(void *);
    141 static void vidcaudio_rate(int);
    142 static void vidcaudio_ctrl(int);
    143 static void vidcaudio_stereo(int, int);
    144 static stream_filter_factory_t mulaw_to_vidc;
    145 static stream_filter_factory_t mulaw_to_vidc_stereo;
    146 static int mulaw_to_vidc_fetch_to(stream_fetcher_t *, audio_stream_t *, int);
    147 static int mulaw_to_vidc_stereo_fetch_to(stream_fetcher_t *,
    148     audio_stream_t *, int);
    149 
    150 CFATTACH_DECL(vidcaudio, sizeof(struct vidcaudio_softc),
    151     vidcaudio_probe, vidcaudio_attach, NULL, NULL);
    152 
    153 static int    vidcaudio_query_encoding(void *, struct audio_encoding *);
    154 static int    vidcaudio_set_params(void *, int, int, audio_params_t *,
    155     audio_params_t *, stream_filter_list_t *, stream_filter_list_t *);
    156 static int    vidcaudio_round_blocksize(void *, int);
    157 static int    vidcaudio_trigger_output(void *, void *, void *, int,
    158     void (*)(void *), void *, const audio_params_t *);
    159 static int    vidcaudio_trigger_input(void *, void *, void *, int,
    160     void (*)(void *), void *, const audio_params_t *);
    161 static int    vidcaudio_halt_output(void *);
    162 static int    vidcaudio_halt_input(void *);
    163 static int    vidcaudio_getdev(void *, struct audio_device *);
    164 static int    vidcaudio_set_port(void *, mixer_ctrl_t *);
    165 static int    vidcaudio_get_port(void *, mixer_ctrl_t *);
    166 static int    vidcaudio_query_devinfo(void *, mixer_devinfo_t *);
    167 static int    vidcaudio_get_props(void *);
    168 
    169 static struct audio_device vidcaudio_device = {
    170 	"ARM VIDC",
    171 	"",
    172 	"vidcaudio"
    173 };
    174 
    175 static const struct audio_hw_if vidcaudio_hw_if = {
    176 	vidcaudio_open,
    177 	vidcaudio_close,
    178 	NULL,
    179 	vidcaudio_query_encoding,
    180 	vidcaudio_set_params,
    181 	vidcaudio_round_blocksize,
    182 	NULL,
    183 	NULL,
    184 	NULL,
    185 	NULL,
    186 	NULL,
    187 	vidcaudio_halt_output,
    188 	vidcaudio_halt_input,
    189 	NULL,
    190 	vidcaudio_getdev,
    191 	NULL,
    192 	vidcaudio_set_port,
    193 	vidcaudio_get_port,
    194 	vidcaudio_query_devinfo,
    195 	NULL,
    196 	NULL,
    197 	NULL,
    198 	NULL,
    199 	vidcaudio_get_props,
    200 	vidcaudio_trigger_output,
    201 	vidcaudio_trigger_input,
    202 	NULL,
    203 };
    204 
    205 static int
    206 vidcaudio_probe(struct device *parent, struct cfdata *cf, void *aux)
    207 {
    208 	int id;
    209 
    210 	id = IOMD_ID;
    211 
    212 	/* So far I only know about this IOMD */
    213 	switch (id) {
    214 	case RPC600_IOMD_ID:
    215 	case ARM7500_IOC_ID:
    216 	case ARM7500FE_IOC_ID:
    217 		return 1;
    218 	default:
    219 		aprint_error("vidcaudio: Unknown IOMD id=%04x", id);
    220 		return 0;
    221 	}
    222 }
    223 
    224 
    225 static void
    226 vidcaudio_attach(struct device *parent, struct device *self, void *aux)
    227 {
    228 	struct vidcaudio_softc *sc = (void *)self;
    229 	struct device *beepdev;
    230 
    231 	switch (IOMD_ID) {
    232 #ifndef EB7500ATX
    233 	case RPC600_IOMD_ID:
    234 		sc->sc_is16bit = (cmos_read(0xc4) >> 5) & 1;
    235 		sc->sc_dma_intr = IRQ_DMASCH0;
    236 		break;
    237 #endif
    238 	case ARM7500_IOC_ID:
    239 	case ARM7500FE_IOC_ID:
    240 		sc->sc_is16bit = TRUE;
    241 		sc->sc_dma_intr = IRQ_SDMA;
    242 		break;
    243 	default:
    244 		aprint_error(": strange IOMD\n");
    245 		return;
    246 	}
    247 
    248 	if (sc->sc_is16bit)
    249 		aprint_normal(": 16-bit external DAC\n");
    250 	else
    251 		aprint_normal(": 8-bit internal DAC\n");
    252 
    253 	/* Install the irq handler for the DMA interrupt */
    254 	sc->sc_ih.ih_func = vidcaudio_intr;
    255 	sc->sc_ih.ih_arg = sc;
    256 	sc->sc_ih.ih_level = IPL_AUDIO;
    257 	sc->sc_ih.ih_name = self->dv_xname;
    258 
    259 	if (irq_claim(sc->sc_dma_intr, &sc->sc_ih) != 0) {
    260 		aprint_error("%s: couldn't claim IRQ %d\n",
    261 		    self->dv_xname, sc->sc_dma_intr);
    262 		return;
    263 	}
    264 
    265 	disable_irq(sc->sc_dma_intr);
    266 
    267 	beepdev = audio_attach_mi(&vidcaudio_hw_if, sc, self);
    268 #if NPCKBD > 0
    269 	pckbd_hookup_bell(audiobell, beepdev);
    270 #endif
    271 #if NRPCKBD > 0
    272 	rpckbd_hookup_bell(audiobell, beepdev);
    273 #endif
    274 #if NVT > 0
    275 	vt_hookup_bell(audiobell, beepdev);
    276 #endif
    277 }
    278 
    279 static int
    280 vidcaudio_open(void *addr, int flags)
    281 {
    282 
    283 	DPRINTF(("DEBUG: vidcaudio_open called\n"));
    284 	return 0;
    285 }
    286 
    287 static void
    288 vidcaudio_close(void *addr)
    289 {
    290 	struct vidcaudio_softc *sc = addr;
    291 
    292 	DPRINTF(("DEBUG: vidcaudio_close called\n"));
    293 	/*
    294 	 * We do this here rather than in vidcaudio_halt_output()
    295 	 * because the latter can be called from interrupt context
    296 	 * (audio_pint()->audio_clear()->vidcaudio_halt_output()).
    297 	 */
    298 	if (sc->sc_ppages != NULL) {
    299 		free(sc->sc_ppages, M_DEVBUF);
    300 		sc->sc_ppages = NULL;
    301 	}
    302 }
    303 
    304 /*
    305  * Interface to the generic audio driver
    306  */
    307 
    308 static int
    309 vidcaudio_query_encoding(void *addr, struct audio_encoding *fp)
    310 {
    311 	struct vidcaudio_softc *sc = addr;
    312 
    313 	switch (fp->index) {
    314 	case 0:
    315 		strcpy(fp->name, AudioEmulaw);
    316 		fp->encoding = AUDIO_ENCODING_ULAW;
    317 		fp->precision = 8;
    318 		fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
    319 		break;
    320 
    321 	case 1:
    322 		if (sc->sc_is16bit) {
    323 			strcpy(fp->name, AudioEslinear_le);
    324 			fp->encoding = AUDIO_ENCODING_SLINEAR_LE;
    325 			fp->precision = 16;
    326 			fp->flags = 0;
    327 			break;
    328 		}
    329 		/* FALLTHROUGH */
    330 	default:
    331 		return EINVAL;
    332 	}
    333 	return 0;
    334 }
    335 
    336 #define MULAW_TO_VIDC(m) (~((m) << 1 | (m) >> 7))
    337 
    338 static stream_filter_t *
    339 mulaw_to_vidc(struct audio_softc *sc, const audio_params_t *from,
    340 	      const audio_params_t *to)
    341 {
    342 	return auconv_nocontext_filter_factory(mulaw_to_vidc_fetch_to);
    343 }
    344 
    345 static int
    346 mulaw_to_vidc_fetch_to(stream_fetcher_t *self, audio_stream_t *dst, int max_used)
    347 {
    348 	stream_filter_t *this;
    349 	uint8_t *d;
    350 	const uint8_t *s;
    351 	int m, err;
    352 	int used_dst, used_src;
    353 
    354 	this = (stream_filter_t *)self;
    355 	if ((err = this->prev->fetch_to(this->prev, this->src, max_used)))
    356 		return err;
    357 	m = dst->end - dst->start;
    358 	m = min(m, max_used);
    359 	d = dst->inp;
    360 	s = this->src->outp;
    361 	used_dst = audio_stream_get_used(dst);
    362 	used_src = audio_stream_get_used(this->src);
    363 	while (used_dst < m && used_src > 0) {
    364 		*d = MULAW_TO_VIDC(*s);
    365 		d = audio_stream_add_inp(dst, d, 1);
    366 		s = audio_stream_add_outp(this->src, s, 1);
    367 		used_dst++;
    368 		used_src--;
    369 	}
    370 	dst->inp = d;
    371 	this->src->outp = s;
    372 	return 0;
    373 }
    374 
    375 static stream_filter_t *
    376 mulaw_to_vidc_stereo(struct audio_softc *sc, const audio_params_t *from,
    377 		     const audio_params_t *to)
    378 {
    379 	return auconv_nocontext_filter_factory(mulaw_to_vidc_stereo_fetch_to);
    380 }
    381 
    382 static int
    383 mulaw_to_vidc_stereo_fetch_to(stream_fetcher_t *self, audio_stream_t *dst,
    384 			      int max_used)
    385 {
    386 	stream_filter_t *this;
    387 	uint8_t *d;
    388 	const uint8_t *s;
    389 	int m, err;
    390 	int used_dst, used_src;
    391 
    392 	this = (stream_filter_t *)self;
    393 	max_used = (max_used + 1) & ~1;
    394 	if ((err = this->prev->fetch_to(this->prev, this->src, max_used / 2)))
    395 		return err;
    396 	m = (dst->end - dst->start) & ~1;
    397 	m = min(m, max_used);
    398 	d = dst->inp;
    399 	s = this->src->outp;
    400 	used_dst = audio_stream_get_used(dst);
    401 	used_src = audio_stream_get_used(this->src);
    402 	while (used_dst < m && used_src > 0) {
    403 		d[0] = d[1] = MULAW_TO_VIDC(*s);
    404 		d = audio_stream_add_inp(dst, d, 2);
    405 		s = audio_stream_add_outp(this->src, s, 1);
    406 		used_dst += 2;
    407 		used_src--;
    408 	}
    409 	dst->inp = d;
    410 	this->src->outp = s;
    411 	return 0;
    412 }
    413 
    414 static int
    415 vidcaudio_set_params(void *addr, int setmode, int usemode,
    416     audio_params_t *p, audio_params_t *r,
    417     stream_filter_list_t *pfil, stream_filter_list_t *rfil)
    418 {
    419 	audio_params_t hw;
    420 	struct vidcaudio_softc *sc = addr;
    421 	int sample_period, ch;
    422 
    423 	if ((setmode & AUMODE_PLAY) == 0)
    424 		return 0;
    425 
    426 	if (sc->sc_is16bit) {
    427 		/* ARM7500ish, 16-bit, two-channel */
    428 		hw = *p;
    429 		if (p->encoding == AUDIO_ENCODING_ULAW && p->precision == 8) {
    430 			hw.encoding = AUDIO_ENCODING_SLINEAR_LE;
    431 			hw.precision = hw.validbits = 16;
    432 			pfil->append(pfil, mulaw_to_linear16, &hw);
    433 		} else if (p->encoding != AUDIO_ENCODING_SLINEAR_LE ||
    434 		    p->precision != 16)
    435 			return EINVAL;
    436 		sample_period = 705600 / 4 / p->sample_rate;
    437 		if (sample_period < 3) sample_period = 3;
    438 		vidcaudio_rate(sample_period - 2);
    439 		vidcaudio_ctrl(SCR_SERIAL);
    440 		hw.sample_rate = 705600 / 4 / sample_period;
    441 		hw.channels = 2;
    442 		pfil->append(pfil, aurateconv, &hw);
    443 	} else {
    444 		/* VIDC20ish, u-law, 8-channel */
    445 		if (p->encoding != AUDIO_ENCODING_ULAW || p->precision != 8)
    446 			return EINVAL;
    447 		/*
    448 		 * We always use two hardware channels, because using
    449 		 * one at 8kHz gives a nasty whining sound from the
    450 		 * speaker.  The aurateconv mechanism doesn't support
    451 		 * ulaw, so we do the channel duplication ourselves,
    452 		 * and don't try to do rate conversion.
    453 		 */
    454 		sample_period = 1000000 / 2 / p->sample_rate;
    455 		if (sample_period < 3) sample_period = 3;
    456 		p->sample_rate = 1000000 / 2 / sample_period;
    457 		hw = *p;
    458 		hw.encoding = AUDIO_ENCODING_NONE;
    459 		hw.precision = 8;
    460 		vidcaudio_rate(sample_period - 2);
    461 		vidcaudio_ctrl(SCR_SDAC | SCR_CLKSEL);
    462 		if (p->channels == 1) {
    463 			pfil->append(pfil, mulaw_to_vidc_stereo, &hw);
    464 			for (ch = 0; ch < 8; ch++)
    465 				vidcaudio_stereo(ch, SIR_CENTRE);
    466 		} else {
    467 			pfil->append(pfil, mulaw_to_vidc, &hw);
    468 			for (ch = 0; ch < 8; ch += 2)
    469 				vidcaudio_stereo(ch, SIR_LEFT_100);
    470 			for (ch = 1; ch < 8; ch += 2)
    471 				vidcaudio_stereo(ch, SIR_RIGHT_100);
    472 		}
    473 	}
    474 	return 0;
    475 }
    476 
    477 static int
    478 vidcaudio_round_blocksize(void *addr, int wantblk)
    479 {
    480 	int blk;
    481 
    482 	/*
    483 	 * Find the smallest power of two that's larger than the
    484 	 * requested block size, but don't allow < 32 (DMA burst is 16
    485 	 * bytes, and single bursts are tricky) or > PAGE_SIZE (DMA is
    486 	 * confined to a page).
    487 	 */
    488 
    489 	for (blk = 32; blk < PAGE_SIZE; blk <<= 1)
    490 		if (blk >= wantblk) return blk;
    491 	return blk;
    492 }
    493 
    494 static int
    495 vidcaudio_trigger_output(void *addr, void *start, void *end, int blksize,
    496     void (*intr)(void *), void *arg, const audio_params_t *params)
    497 {
    498 	struct vidcaudio_softc *sc = addr;
    499 	size_t npages, i;
    500 
    501 	DPRINTF(("vidcaudio_trigger_output %p-%p/0x%x\n",
    502 	    start, end, blksize));
    503 
    504 	KASSERT(blksize == vidcaudio_round_blocksize(addr, blksize));
    505 	KASSERT((vaddr_t)start % blksize == 0);
    506 
    507 	sc->sc_pblksize = blksize;
    508 	sc->sc_pbufsize = (char *)end - (char *)start;
    509 	npages = sc->sc_pbufsize >> PGSHIFT;
    510 	if (sc->sc_ppages != NULL)
    511 		free(sc->sc_ppages, M_DEVBUF);
    512 	sc->sc_ppages = malloc(npages * sizeof(paddr_t), M_DEVBUF, M_WAITOK);
    513 	if (sc->sc_ppages == NULL) return ENOMEM;
    514 	for (i = 0; i < npages; i++)
    515 		if (!pmap_extract(pmap_kernel(),
    516 		    (vaddr_t)start + i * PAGE_SIZE, &sc->sc_ppages[i]))
    517 			return EIO;
    518 	sc->sc_poffset = 0;
    519 	sc->sc_pintr = intr;
    520 	sc->sc_parg = arg;
    521 
    522 	IOMD_WRITE_WORD(IOMD_SD0CR, IOMD_DMACR_CLEAR | IOMD_DMACR_QUADWORD);
    523 	IOMD_WRITE_WORD(IOMD_SD0CR, IOMD_DMACR_ENABLE | IOMD_DMACR_QUADWORD);
    524 
    525 	/*
    526 	 * Queue up the first two blocks, but don't tell audio code
    527 	 * we're finished with them yet.
    528 	 */
    529 	sc->sc_pcountdown = 2;
    530 
    531 	enable_irq(sc->sc_dma_intr);
    532 
    533 	return 0;
    534 }
    535 
    536 static int
    537 vidcaudio_trigger_input(void *addr, void *start, void *end, int blksize,
    538     void (*intr)(void *), void *arg, const audio_params_t *params)
    539 {
    540 
    541 	return ENODEV;
    542 }
    543 
    544 static int
    545 vidcaudio_halt_output(void *addr)
    546 {
    547 	struct vidcaudio_softc *sc = addr;
    548 
    549 	DPRINTF(("vidcaudio_halt_output\n"));
    550 	disable_irq(sc->sc_dma_intr);
    551 	IOMD_WRITE_WORD(IOMD_SD0CR, IOMD_DMACR_CLEAR | IOMD_DMACR_QUADWORD);
    552 	return 0;
    553 }
    554 
    555 static int
    556 vidcaudio_halt_input(void *addr)
    557 {
    558 
    559 	return ENODEV;
    560 }
    561 
    562 static int
    563 vidcaudio_getdev(void *addr, struct audio_device *retp)
    564 {
    565 
    566 	*retp = vidcaudio_device;
    567 	return 0;
    568 }
    569 
    570 
    571 static int
    572 vidcaudio_set_port(void *addr, mixer_ctrl_t *cp)
    573 {
    574 
    575 	return EINVAL;
    576 }
    577 
    578 static int
    579 vidcaudio_get_port(void *addr, mixer_ctrl_t *cp)
    580 {
    581 
    582 	return EINVAL;
    583 }
    584 
    585 static int
    586 vidcaudio_query_devinfo(void *addr, mixer_devinfo_t *dip)
    587 {
    588 
    589 	return ENXIO;
    590 }
    591 
    592 static int
    593 vidcaudio_get_props(void *addr)
    594 {
    595 
    596 	return 0;
    597 }
    598 
    599 static void
    600 vidcaudio_rate(int rate)
    601 {
    602 
    603 	WriteWord(vidc_base, VIDC_SFR | rate);
    604 }
    605 
    606 static void
    607 vidcaudio_ctrl(int ctrl)
    608 {
    609 
    610 	WriteWord(vidc_base, VIDC_SCR | ctrl);
    611 }
    612 
    613 static void
    614 vidcaudio_stereo(int channel, int position)
    615 {
    616 
    617 	channel = channel << 24 | VIDC_SIR0;
    618 	WriteWord(vidc_base, channel | position);
    619 }
    620 
    621 static int
    622 vidcaudio_intr(void *arg)
    623 {
    624 	struct vidcaudio_softc *sc = arg;
    625 	int status;
    626 	paddr_t pnext, pend;
    627 
    628 	status = IOMD_READ_BYTE(IOMD_SD0ST);
    629 	DPRINTF(("I[%x]", status));
    630 	if ((status & IOMD_DMAST_INT) == 0)
    631 		return 0;
    632 
    633 	pnext = sc->sc_ppages[sc->sc_poffset >> PGSHIFT] |
    634 	    (sc->sc_poffset & PGOFSET);
    635 	pend = (pnext + sc->sc_pblksize - 16) & IOMD_DMAEND_OFFSET;
    636 
    637 	switch (status &
    638 	    (IOMD_DMAST_OVERRUN | IOMD_DMAST_INT | IOMD_DMAST_BANKB)) {
    639 
    640 	case (IOMD_DMAST_INT | IOMD_DMAST_BANKA):
    641 	case (IOMD_DMAST_OVERRUN | IOMD_DMAST_INT | IOMD_DMAST_BANKB):
    642 		DPRINTF(("B<0x%08lx,0x%03lx>", pnext, pend));
    643 		IOMD_WRITE_WORD(IOMD_SD0CURB, pnext);
    644 		IOMD_WRITE_WORD(IOMD_SD0ENDB, pend);
    645 		break;
    646 
    647 	case (IOMD_DMAST_INT | IOMD_DMAST_BANKB):
    648 	case (IOMD_DMAST_OVERRUN | IOMD_DMAST_INT | IOMD_DMAST_BANKA):
    649 		DPRINTF(("A<0x%08lx,0x%03lx>", pnext, pend));
    650 		IOMD_WRITE_WORD(IOMD_SD0CURA, pnext);
    651 		IOMD_WRITE_WORD(IOMD_SD0ENDA, pend);
    652 		break;
    653 	}
    654 
    655 	sc->sc_poffset += sc->sc_pblksize;
    656 	if (sc->sc_poffset >= sc->sc_pbufsize)
    657 		sc->sc_poffset = 0;
    658 
    659 	if (sc->sc_pcountdown > 0)
    660 		sc->sc_pcountdown--;
    661 	else
    662 		(*sc->sc_pintr)(sc->sc_parg);
    663 
    664 	return 1;
    665 }
    666