From 674c45bd044f7c85d41d245e13677c2709e8f2d0 Mon Sep 17 00:00:00 2001 From: Cameron Grant Date: Mon, 17 Apr 2000 16:57:12 +0000 Subject: [PATCH] make drivers start at beginning of buffer when triggered - improves mmap. not all tested. not sure about aureal.c or csapcm.c --- sys/dev/sound/isa/ad1816.c | 1 + sys/dev/sound/isa/ess.c | 2 +- sys/dev/sound/pci/es137x.c | 34 +++++++++++++++++++++++----------- sys/dev/sound/pci/t4dwave.c | 9 +++++++-- 4 files changed, 32 insertions(+), 14 deletions(-) diff --git a/sys/dev/sound/isa/ad1816.c b/sys/dev/sound/isa/ad1816.c index e1bc75ed7a29..549ed51b735d 100644 --- a/sys/dev/sound/isa/ad1816.c +++ b/sys/dev/sound/isa/ad1816.c @@ -413,6 +413,7 @@ ad1816chan_trigger(void *data, int go) if (!(io_rd(ad1816, reg) & AD1816_ENABLE)) { int cnt = ((ch->buffer->dl) >> 2) - 1; ad1816_write(ad1816, wr? 8 : 10, cnt); /* count */ + ad1816_write(ad1816, wr? 9 : 11, 0); /* reset cur cnt */ ad1816_write(ad1816, 1, ad1816_read(ad1816, 1) | (wr? 0x8000 : 0x4000)); /* enable int */ /* enable playback */ diff --git a/sys/dev/sound/isa/ess.c b/sys/dev/sound/isa/ess.c index f6c33953334b..60727644cd84 100644 --- a/sys/dev/sound/isa/ess.c +++ b/sys/dev/sound/isa/ess.c @@ -38,7 +38,7 @@ #include #include -#define ESS_BUFFSIZE (16384) +#define ESS_BUFFSIZE (4096) #define ABS(x) (((x) < 0)? -(x) : (x)) /* audio2 never generates irqs and sounds very noisy */ diff --git a/sys/dev/sound/pci/es137x.c b/sys/dev/sound/pci/es137x.c index 46975ea87d34..7e72a49a2b90 100644 --- a/sys/dev/sound/pci/es137x.c +++ b/sys/dev/sound/pci/es137x.c @@ -378,6 +378,12 @@ eschan_trigger(void *data, int go) es->sctrl |= SCTRL_P2INTEN | (b << SCTRL_SH_P2ENDINC); bus_space_write_4(es->st, es->sh, ES1370_REG_DAC2_SCOUNT, cnt); + /* start at beginning of buffer */ + bus_space_write_4(es->st, es->sh, ES1370_REG_MEMPAGE, + ES1370_REG_DAC2_FRAMECNT >> 8); + bus_space_write_4(es->st, es->sh, + ES1370_REG_DAC2_FRAMECNT & 0xff, + (ch->buffer->bufsize >> 2) - 1); } else es->ctrl &= ~CTRL_DAC2_EN; } else { if (go == PCMTRIG_START) { @@ -386,6 +392,12 @@ eschan_trigger(void *data, int go) es->sctrl |= SCTRL_R1INTEN; bus_space_write_4(es->st, es->sh, ES1370_REG_ADC_SCOUNT, cnt); + /* start at beginning of buffer */ + bus_space_write_4(es->st, es->sh, ES1370_REG_MEMPAGE, + ES1370_REG_ADC_FRAMECNT >> 8); + bus_space_write_4(es->st, es->sh, + ES1370_REG_ADC_FRAMECNT & 0xff, + (ch->buffer->bufsize >> 2) - 1); } else es->ctrl &= ~CTRL_ADC_EN; } bus_space_write_4(es->st, es->sh, ES1370_REG_SERIAL_CONTROL, es->sctrl); @@ -398,17 +410,17 @@ eschan_getptr(void *data) { struct es_chinfo *ch = data; struct es_info *es = ch->parent; - if (ch->dir == PCMDIR_PLAY) { - bus_space_write_4(es->st, es->sh, ES1370_REG_MEMPAGE, - ES1370_REG_DAC2_FRAMECNT >> 8); - return (bus_space_read_4(es->st, es->sh, - ES1370_REG_DAC2_FRAMECNT & 0xff) >> 14) & 0x3fffc; - } else { - bus_space_write_4(es->st, es->sh, ES1370_REG_MEMPAGE, - ES1370_REG_ADC_FRAMECNT >> 8); - return (bus_space_read_4(es->st, es->sh, - ES1370_REG_ADC_FRAMECNT & 0xff) >> 14) & 0x3fffc; - } + u_int32_t reg, cnt; + + if (ch->dir == PCMDIR_PLAY) + reg = ES1370_REG_DAC2_FRAMECNT; + else + reg = ES1370_REG_ADC_FRAMECNT; + + bus_space_write_4(es->st, es->sh, ES1370_REG_MEMPAGE, reg >> 8); + cnt = bus_space_read_4(es->st, es->sh, reg & 0x000000ff) >> 16; + /* cnt is longwords */ + return cnt << 2; } static pcmchan_caps * diff --git a/sys/dev/sound/pci/t4dwave.c b/sys/dev/sound/pci/t4dwave.c index 1d8659afbe1f..135641f28bad 100644 --- a/sys/dev/sound/pci/t4dwave.c +++ b/sys/dev/sound/pci/t4dwave.c @@ -487,10 +487,15 @@ trchan_trigger(void *data, int go) { struct tr_chinfo *ch = data; struct tr_info *tr = ch->parent; + if (go == PCMTRIG_EMLDMAWR) return 0; if (ch->index >= 0) { - if (go == PCMTRIG_START) tr_startch(tr, ch->index); - else tr_stopch(tr, ch->index); + if (go == PCMTRIG_START) { + tr_rdch(tr, ch->index, ch); + ch->cso = 0; + tr_wrch(tr, ch->index, ch); + tr_startch(tr, ch->index); + } else tr_stopch(tr, ch->index); } else { u_int32_t i = tr_rd(tr, TR_REG_SBCTRL, 1) & ~7; tr_wr(tr, TR_REG_SBCTRL, i | (go == PCMTRIG_START)? 1 : 0, 1);