Use the trigger interface, and clean up a pile of cruft.

This commit is contained in:
mycroft 1999-02-17 23:05:28 +00:00
parent a651e1a07b
commit 27963c294a
9 changed files with 98 additions and 235 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ad1848.c,v 1.3 1998/08/27 18:45:12 pk Exp $ */
/* $NetBSD: ad1848.c,v 1.4 1999/02/17 23:05:28 mycroft Exp $ */
/*
* Copyright (c) 1994 John Brezak
@ -318,8 +318,6 @@ ad1848_attach(sc)
struct audio_params pparams, rparams;
int timeout;
sc->sc_locked = 0;
/* Initialize the ad1848... */
for (i = 0; i < 0x10; i++) {
ad_write(sc, i, ad1848_init_values[i]);
@ -968,8 +966,6 @@ ad1848_open(addr, flags)
DPRINTF(("ad1848_open: sc=%p\n", sc));
sc->sc_locked = 0;
/* Enable interrupts */
DPRINTF(("ad1848_open: enable intrs\n"));
ad_write(sc, SP_PIN_CONTROL,
@ -1199,7 +1195,6 @@ ad1848_halt_out(addr)
reg = ad_read(sc, SP_INTERFACE_CONFIG);
ad_write(sc, SP_INTERFACE_CONFIG, (reg & ~PLAYBACK_ENABLE));
sc->sc_locked = 0;
return(0);
}
@ -1215,7 +1210,6 @@ ad1848_halt_in(addr)
reg = ad_read(sc, SP_INTERFACE_CONFIG);
ad_write(sc, SP_INTERFACE_CONFIG, (reg & ~CAPTURE_ENABLE));
sc->sc_locked = 0;
return(0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ad1848var.h,v 1.2 1998/08/27 18:45:12 pk Exp $ */
/* $NetBSD: ad1848var.h,v 1.3 1999/02/17 23:05:28 mycroft Exp $ */
/*
* Copyright (c) 1994 John Brezak
@ -53,9 +53,6 @@ struct ad1848_softc {
void *parent;
u_short sc_locked; /* true when doing HS DMA */
int sc_mode; /* half-duplex record/play */
/* We keep track of these */
struct ad1848_volume gains[6];
struct ad1848_volume rec_gain;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ad1848_isa.c,v 1.5 1999/02/17 02:37:39 mycroft Exp $ */
/* $NetBSD: ad1848_isa.c,v 1.6 1999/02/17 23:05:28 mycroft Exp $ */
/*
* Copyright (c) 1994 John Brezak
@ -359,18 +359,18 @@ ad1848_isa_attach(isc)
sc->sc_readreg = ad1848_isa_read;
sc->sc_writereg = ad1848_isa_write;
isc->sc_playrun = NOTRUNNING;
isc->sc_recrun = NOTRUNNING;
isc->sc_playrun = 0;
isc->sc_recrun = 0;
if (isc->sc_drq != -1) {
if (isa_dmamap_create(isc->sc_ic, isc->sc_drq, MAX_ISADMA,
if (isc->sc_playdrq != -1) {
if (isa_dmamap_create(isc->sc_ic, isc->sc_playdrq, MAX_ISADMA,
BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW)) {
printf("ad1848_attach: can't create map for drq %d\n",
isc->sc_drq);
isc->sc_playdrq);
return;
}
}
if (isc->sc_recdrq != -1 && isc->sc_recdrq != isc->sc_drq) {
if (isc->sc_recdrq != -1 && isc->sc_recdrq != isc->sc_playdrq) {
if (isa_dmamap_create(isc->sc_ic, isc->sc_recdrq, MAX_ISADMA,
BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW)) {
printf("ad1848_attach: can't create map for drq %d\n",
@ -382,19 +382,6 @@ ad1848_isa_attach(isc)
ad1848_attach(sc);
}
int
ad1848_isa_round_blocksize(addr, blk)
void *addr;
int blk;
{
struct ad1848_isa_softc *sc = addr;
sc->sc_lastcc = -1;
/* Round to a multiple of the biggest sample size. */
return (blk &= -4);
}
int
ad1848_isa_open(addr, flags)
void *addr;
@ -404,7 +391,6 @@ ad1848_isa_open(addr, flags)
DPRINTF(("ad1848_isa_open: sc=%p\n", sc));
sc->sc_lastcc = -1;
sc->sc_intr = 0;
return (ad1848_open(&sc->sc_ad1848, flags));
@ -422,183 +408,84 @@ ad1848_isa_close(addr)
sc->sc_intr = 0;
DPRINTF(("ad1848_isa_close: stop DMA\n"));
if (sc->sc_playrun != NOTRUNNING) {
isa_dmaabort(sc->sc_ic, sc->sc_drq);
sc->sc_playrun = NOTRUNNING;
if (sc->sc_playrun) {
isa_dmaabort(sc->sc_ic, sc->sc_playdrq);
sc->sc_playrun = 0;
}
if (sc->sc_recrun != NOTRUNNING) {
if (sc->sc_recrun) {
isa_dmaabort(sc->sc_ic, sc->sc_recdrq);
sc->sc_recrun = NOTRUNNING;
sc->sc_recrun = 0;
}
ad1848_close(&sc->sc_ad1848);
}
int
ad1848_isa_dma_init_input(addr, buf, cc)
ad1848_isa_trigger_input(addr, start, end, blksize, intr, arg, param)
void *addr;
void *buf;
int cc;
{
struct ad1848_isa_softc *isc = addr;
isc->sc_recrun = DMARUNNING;
isc->sc_dma_flags = DMAMODE_READ | DMAMODE_LOOP;
isc->sc_dma_bp = buf;
isc->sc_dma_cnt = cc;
isa_dmastart(isc->sc_ic, isc->sc_recdrq, buf, cc, NULL,
isc->sc_dma_flags, BUS_DMA_NOWAIT);
DPRINTF(("ad1848_isa_dma_init_input: %p %d\n", buf, cc));
return 0;
}
/*
* DMA input/output are called at splaudio().
*/
int
ad1848_isa_dma_input(addr, p, cc, intr, arg)
void *addr;
void *p;
int cc;
void *start, *end;
int blksize;
void (*intr) __P((void *));
void *arg;
struct audio_params *param;
{
struct ad1848_isa_softc *isc = addr;
struct ad1848_softc *sc = (struct ad1848_softc *)&isc->sc_ad1848;
u_char reg;
u_int8_t reg;
if (sc->sc_locked) {
DPRINTF(("ad1848_isa_dma_input: locked\n"));
return 0;
}
isa_dmastart(isc->sc_ic, isc->sc_recdrq, start,
(char *)end - (char *)start, NULL, DMAMODE_READ | DMAMODE_LOOP,
BUS_DMA_NOWAIT);
#ifdef AUDIO_DEBUG
if (ad1848debug > 1)
printf("ad1848_isa_dma_input: cc=%d %p (%p)\n", cc, intr, arg);
#endif
sc->sc_locked = 1;
isc->sc_recrun = 1;
isc->sc_intr = intr;
isc->sc_arg = arg;
switch (isc->sc_recrun) {
case NOTRUNNING:
isc->sc_dma_flags = DMAMODE_READ;
isc->sc_dma_bp = p;
isc->sc_dma_cnt = cc;
isa_dmastart(isc->sc_ic, isc->sc_recdrq, p, cc, NULL,
DMAMODE_READ, BUS_DMA_NOWAIT);
goto startpcm;
case DMARUNNING:
isc->sc_recrun = PCMRUNNING;
startpcm:
if (sc->precision == 16)
cc >>= 1;
if (sc->channels == 2)
cc >>= 1;
cc--;
blksize = (blksize * 8) / (param->precision * param->factor * param->channels) - 1;
if (isc->sc_lastcc != cc || sc->sc_mode != AUMODE_RECORD) {
ad_write(sc, SP_LOWER_BASE_COUNT, cc & 0xff);
ad_write(sc, SP_UPPER_BASE_COUNT, cc >> 8);
if (sc->mode == 2) {
ad_write(sc, CS_LOWER_REC_CNT, cc & 0xff);
ad_write(sc, CS_UPPER_REC_CNT, cc >> 8);
}
reg = ad_read(sc, SP_INTERFACE_CONFIG);
ad_write(sc, SP_INTERFACE_CONFIG, CAPTURE_ENABLE|reg);
isc->sc_lastcc = cc;
sc->sc_mode = AUMODE_RECORD;
#ifdef AUDIO_DEBUG
if (ad1848debug > 1)
printf("ad1848_dma_input: started capture\n");
#endif
}
case PCMRUNNING:
break;
if (sc->mode == 2) {
ad_write(sc, CS_LOWER_REC_CNT, blksize & 0xff);
ad_write(sc, CS_UPPER_REC_CNT, blksize >> 8);
} else {
ad_write(sc, SP_LOWER_BASE_COUNT, blksize & 0xff);
ad_write(sc, SP_UPPER_BASE_COUNT, blksize >> 8);
}
return 0;
reg = ad_read(sc, SP_INTERFACE_CONFIG);
ad_write(sc, SP_INTERFACE_CONFIG, CAPTURE_ENABLE|reg);
return (0);
}
int
ad1848_isa_dma_init_output(addr, buf, cc)
ad1848_isa_trigger_output(addr, start, end, blksize, intr, arg, param)
void *addr;
void *buf;
int cc;
{
struct ad1848_isa_softc *isc = addr;
isc->sc_playrun = DMARUNNING;
isc->sc_dma_flags = DMAMODE_WRITE | DMAMODE_LOOP;
isc->sc_dma_bp = buf;
isc->sc_dma_cnt = cc;
isa_dmastart(isc->sc_ic, isc->sc_drq, buf, cc, NULL,
isc->sc_dma_flags, BUS_DMA_NOWAIT);
DPRINTF(("ad1848_isa_dma_init_output: %p %d\n", buf, cc));
return 0;
}
int
ad1848_isa_dma_output(addr, p, cc, intr, arg)
void *addr;
void *p;
int cc;
void *start, *end;
int blksize;
void (*intr) __P((void *));
void *arg;
struct audio_params *param;
{
struct ad1848_isa_softc *isc = addr;
struct ad1848_softc *sc = (struct ad1848_softc *)&isc->sc_ad1848;
u_char reg;
u_int8_t reg;
if (sc->sc_locked) {
DPRINTF(("ad1848_isa_dma_output: locked\n"));
return 0;
}
isa_dmastart(isc->sc_ic, isc->sc_playdrq, start,
(char *)end - (char *)start, NULL, DMAMODE_WRITE | DMAMODE_LOOP,
BUS_DMA_NOWAIT);
#ifdef AUDIO_DEBUG
if (ad1848debug > 0)
printf("ad1848_isa_dma_output: cc=%d at %p 0x%p (0x%p)\n",
cc, p, intr, arg);
#endif
sc->sc_locked = 1;
isc->sc_playrun = 1;
isc->sc_intr = intr;
isc->sc_arg = arg;
switch (isc->sc_playrun) {
case NOTRUNNING:
isc->sc_dma_flags = DMAMODE_WRITE;
isc->sc_dma_bp = p;
isc->sc_dma_cnt = cc;
isa_dmastart(isc->sc_ic, isc->sc_drq, p, cc, NULL,
DMAMODE_WRITE, BUS_DMA_NOWAIT);
goto startpcm;
case DMARUNNING:
isc->sc_playrun = PCMRUNNING;
startpcm:
if (sc->precision == 16)
cc >>= 1;
if (sc->channels == 2)
cc >>= 1;
cc--;
blksize = (blksize * 8) / (param->precision * param->factor * param->channels) - 1;
if (isc->sc_lastcc != cc || sc->sc_mode != AUMODE_PLAY) {
ad_write(sc, SP_LOWER_BASE_COUNT, cc & 0xff);
ad_write(sc, SP_UPPER_BASE_COUNT, cc >> 8);
ad_write(sc, SP_LOWER_BASE_COUNT, blksize & 0xff);
ad_write(sc, SP_UPPER_BASE_COUNT, blksize >> 8);
reg = ad_read(sc, SP_INTERFACE_CONFIG);
ad_write(sc, SP_INTERFACE_CONFIG, PLAYBACK_ENABLE|reg);
reg = ad_read(sc, SP_INTERFACE_CONFIG);
ad_write(sc, SP_INTERFACE_CONFIG, PLAYBACK_ENABLE|reg);
isc->sc_lastcc = cc;
sc->sc_mode = AUMODE_PLAY;
}
break;
case PCMRUNNING:
break;
}
return 0;
return (0);
}
int
@ -617,16 +504,10 @@ ad1848_isa_intr(arg)
if (ad1848debug > 1)
printf("ad1848_isa_intr: intr=%p status=%x\n", isc->sc_intr, status);
#endif
sc->sc_locked = 0;
isc->sc_interrupts++;
/* Handle interrupt */
if (isc->sc_intr && (status & INTERRUPT_STATUS)) {
/* ACK DMA read because it may be in a bounce buffer */
/* XXX Do write to mask DMA ? */
if ((isc->sc_dma_flags & DMAMODE_READ) &&
isc->sc_recrun == NOTRUNNING)
isa_dmadone(isc->sc_ic, isc->sc_recdrq);
(*isc->sc_intr)(isc->sc_arg);
retval = 1;
}
@ -649,7 +530,7 @@ ad1848_isa_malloc(addr, direction, size, pool, flags)
int drq;
if (direction == AUMODE_PLAY)
drq = isc->sc_drq;
drq = isc->sc_playdrq;
else
drq = isc->sc_recdrq;
return (isa_malloc(isc->sc_ic, drq, size, pool, flags));
@ -692,5 +573,5 @@ ad1848_isa_get_props(addr)
struct ad1848_isa_softc *isc = addr;
return (AUDIO_PROP_MMAP |
(isc->sc_drq != isc->sc_recdrq ? AUDIO_PROP_FULLDUPLEX : 0));
(isc->sc_playdrq != isc->sc_recdrq ? AUDIO_PROP_FULLDUPLEX : 0));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ad1848var.h,v 1.26 1999/02/17 02:37:39 mycroft Exp $ */
/* $NetBSD: ad1848var.h,v 1.27 1999/02/17 23:05:29 mycroft Exp $ */
/*
* Copyright (c) 1994 John Brezak
@ -46,22 +46,11 @@ struct ad1848_isa_softc {
isa_chipset_tag_t sc_ic; /* ISA chipset info */
int sc_iooffs; /* offset from handle */
u_int sc_lastcc; /* size of last DMA xfer */
#ifndef NEWCONFIG
int sc_dma_flags;
void *sc_dma_bp;
u_int sc_dma_cnt;
#endif
char sc_playrun; /* running in continuous mode */
char sc_recrun; /* running in continuous mode */
#define NOTRUNNING 0
#define DMARUNNING 1
#define PCMRUNNING 2
int sc_irq; /* interrupt */
int sc_drq; /* DMA */
int sc_playdrq; /* playback DMA */
int sc_recdrq; /* record/capture DMA */
u_long sc_interrupts; /* number of interrupts taken */
@ -81,14 +70,10 @@ void ad1848_isa_attach __P((struct ad1848_isa_softc *));
int ad1848_isa_open __P((void *, int));
void ad1848_isa_close __P((void *));
int ad1848_isa_round_blocksize __P((void *, int));
int ad1848_isa_dma_init_output __P((void *, void *, int));
int ad1848_isa_dma_init_input __P((void *, void *, int));
int ad1848_isa_dma_output __P((void *, void *, int,
void (*)(void *), void*));
int ad1848_isa_dma_input __P((void *, void *, int,
void (*)(void *), void*));
int ad1848_isa_trigger_output __P((void *, void *, void *, int,
void (*)(void *), void *, struct audio_params *));
int ad1848_isa_trigger_input __P((void *, void *, void *, int,
void (*)(void *), void *, struct audio_params *));
int ad1848_isa_intr __P((void *));

View File

@ -1,4 +1,4 @@
/* $NetBSD: pss.c,v 1.51 1999/02/17 02:37:41 mycroft Exp $ */
/* $NetBSD: pss.c,v 1.52 1999/02/17 23:05:29 mycroft Exp $ */
/*
* Copyright (c) 1994 John Brezak
@ -226,12 +226,12 @@ struct audio_hw_if pss_audio_if = {
NULL,
ad1848_query_encoding,
ad1848_set_params,
ad1848_isa_round_blocksize,
ad1848_round_blocksize,
ad1848_commit_settings,
ad1848_isa_dma_init_output,
ad1848_isa_dma_init_input,
ad1848_isa_dma_output,
ad1848_isa_dma_input,
NULL,
NULL,
NULL,
NULL,
ad1848_halt_out,
ad1848_halt_in,
pss_speaker_ctl,
@ -245,6 +245,8 @@ struct audio_hw_if pss_audio_if = {
ad1848_isa_round_buffersize,
ad1848_isa_mappage,
ad1848_isa_get_props,
ad1848_isa_trigger_output,
ad1848_isa_trigger_input,
};
/* Interrupt translation for WSS config */
@ -887,18 +889,18 @@ spfind(parent, sc, ia)
return 0;
}
else {
sc->sc_drq = cf->cf_drq = i;
sc->sc_playdrq = cf->cf_drq = i;
DPRINTF(("sp: found DMA %d free\n", i));
}
}
else {
if (pss_testdma(pc, sc->sc_drq) == 0) {
printf("sp: configured DMA channel unavailable (%d)\n", sc->sc_drq);
if (pss_testdma(pc, sc->sc_playdrq) == 0) {
printf("sp: configured DMA channel unavailable (%d)\n", sc->sc_playdrq);
return 0;
}
sc->sc_drq = cf->cf_drq;
sc->sc_playdrq = cf->cf_drq;
}
sc->sc_recdrq = sc->sc_drq;
sc->sc_recdrq = sc->sc_playdrq;
/* Set WSS config registers */
if ((bits = wss_interrupt_bits[sc->sc_irq]) == 0xff) {
@ -910,7 +912,7 @@ spfind(parent, sc, ia)
if ((inb(sc->sc_iobase+WSS_STATUS) & 0x40) == 0) /* XXX What do these bits mean ? */
DPRINTF(("sp: IRQ %x\n", inb(sc->sc_iobase+WSS_STATUS)));
outb(sc->sc_iobase+WSS_CONFIG, (bits | wss_dma_bits[sc->sc_drq]));
outb(sc->sc_iobase+WSS_CONFIG, (bits | wss_dma_bits[sc->sc_playdrq]));
pc->ad1848_sc = (struct ad1848_softc *)sc;
sc->sc_ad1848.parent = pc;
@ -1001,7 +1003,7 @@ spattach(parent, self, aux)
}
sc->sc_iobase = iobase;
sc->sc_drq = cf->cf_drq;
sc->sc_playdrq = cf->cf_drq;
#ifdef NEWCONFIG
isa_establish(&sc->sc_id, &sc->sc_dev);

View File

@ -1,4 +1,4 @@
/* $NetBSD: wss.c,v 1.55 1999/02/17 02:37:42 mycroft Exp $ */
/* $NetBSD: wss.c,v 1.56 1999/02/17 23:05:29 mycroft Exp $ */
/*
* Copyright (c) 1994 John Brezak
@ -87,12 +87,12 @@ struct audio_hw_if wss_hw_if = {
NULL,
ad1848_query_encoding,
ad1848_set_params,
ad1848_isa_round_blocksize,
ad1848_round_blocksize,
ad1848_commit_settings,
ad1848_isa_dma_init_output,
ad1848_isa_dma_init_input,
ad1848_isa_dma_output,
ad1848_isa_dma_input,
NULL,
NULL,
NULL,
NULL,
ad1848_halt_out,
ad1848_halt_in,
NULL,
@ -106,6 +106,8 @@ struct audio_hw_if wss_hw_if = {
ad1848_isa_round_buffersize,
ad1848_isa_mappage,
ad1848_isa_get_props,
ad1848_isa_trigger_output,
ad1848_isa_trigger_input,
};
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: wss_isa.c,v 1.6 1998/10/15 04:05:53 mycroft Exp $ */
/* $NetBSD: wss_isa.c,v 1.7 1999/02/17 23:05:29 mycroft Exp $ */
/*
* Copyright (c) 1994 John Brezak
@ -148,10 +148,10 @@ wssfind(parent, sc, ia)
goto bad;
}
#endif
sc->wss_drq = ia->ia_drq;
sc->wss_ic = ia->ia_ic;
sc->wss_playdrq = ia->ia_drq;
sc->wss_ic = ia->ia_ic;
if (sc->wss_drq != DRQUNK && !isa_drq_isfree(sc->wss_ic, sc->wss_drq))
if (sc->wss_playdrq != DRQUNK && !isa_drq_isfree(sc->wss_ic, sc->wss_playdrq))
goto bad;
#if 0
@ -168,7 +168,7 @@ wssfind(parent, sc, ia)
sc->wss_recdrq =
ac->mode > 1 && ia->ia_drq2 != DRQUNK ?
ia->ia_drq2 : ia->ia_drq;
if (sc->wss_recdrq != sc->wss_drq && !isa_drq_isfree(sc->wss_ic,
if (sc->wss_recdrq != sc->wss_playdrq && !isa_drq_isfree(sc->wss_ic,
sc->wss_recdrq))
goto bad;

View File

@ -1,4 +1,4 @@
/* $NetBSD: wssvar.h,v 1.4 1998/08/25 22:34:31 pk Exp $ */
/* $NetBSD: wssvar.h,v 1.5 1999/02/17 23:05:29 mycroft Exp $ */
/*
* Copyright (c) 1994 John Brezak
@ -57,10 +57,10 @@
struct wss_softc {
struct ad1848_isa_softc sc_ad1848;
#define wss_ic sc_ad1848.sc_ic
#define wss_irq sc_ad1848.sc_irq
#define wss_drq sc_ad1848.sc_drq
#define wss_recdrq sc_ad1848.sc_recdrq
#define wss_ic sc_ad1848.sc_ic
#define wss_irq sc_ad1848.sc_irq
#define wss_playdrq sc_ad1848.sc_playdrq
#define wss_recdrq sc_ad1848.sc_recdrq
#if 0
struct isadev sc_id; /* ISA device */

View File

@ -1,4 +1,4 @@
/* $NetBSD: ym.c,v 1.7 1999/02/17 02:37:42 mycroft Exp $ */
/* $NetBSD: ym.c,v 1.8 1999/02/17 23:05:29 mycroft Exp $ */
/*
@ -70,12 +70,12 @@ struct audio_hw_if ym_hw_if = {
NULL,
ad1848_query_encoding,
ad1848_set_params,
ad1848_isa_round_blocksize,
ad1848_round_blocksize,
ad1848_commit_settings,
ad1848_isa_dma_init_output,
ad1848_isa_dma_init_input,
ad1848_isa_dma_output,
ad1848_isa_dma_input,
NULL,
NULL,
NULL,
NULL,
ad1848_halt_out,
ad1848_halt_in,
NULL,
@ -89,6 +89,8 @@ struct audio_hw_if ym_hw_if = {
ad1848_isa_round_buffersize,
ad1848_isa_mappage,
ad1848_isa_get_props,
ad1848_isa_trigger_output,
ad1848_isa_trigger_input,
};