summaryrefslogtreecommitdiffstats
path: root/sys/dev/sound/pci/es137x.c
diff options
context:
space:
mode:
authorcg <cg@FreeBSD.org>2000-12-23 03:16:13 +0000
committercg <cg@FreeBSD.org>2000-12-23 03:16:13 +0000
commitd0b795f25b705ff883368ba3e49f31c3541d3b11 (patch)
tree076eb63fe5bbf4764062f83df117a0ee11cfc3ed /sys/dev/sound/pci/es137x.c
parent818087b543b4be6d1211cb39cb7b7204e9ae9f6c (diff)
downloadFreeBSD-src-d0b795f25b705ff883368ba3e49f31c3541d3b11.zip
FreeBSD-src-d0b795f25b705ff883368ba3e49f31c3541d3b11.tar.gz
update code dealing with snd_dbuf objects to do so using a functional interface
modify chn_setblocksize() to pick a default soft-blocksize appropriate to the sample rate and format in use. it will aim for a power of two size small enough to generate block sizes of at most 20ms. it will also set the hard-blocksize taking into account rate/format conversions in use. update drivers to implement setblocksize correctly: updated, tested: sb16, emu10k1, maestro, solo updated, untested: ad1816, ess, mss, sb8, csa not updated: ds1, es137x, fm801, neomagic, t4dwave, via82c686 i lack hardware to test: ad1816, csa, fm801, neomagic others will be updated/tested in the next few days.
Diffstat (limited to 'sys/dev/sound/pci/es137x.c')
-rw-r--r--sys/dev/sound/pci/es137x.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/sys/dev/sound/pci/es137x.c b/sys/dev/sound/pci/es137x.c
index 15779e8..0206dce 100644
--- a/sys/dev/sound/pci/es137x.c
+++ b/sys/dev/sound/pci/es137x.c
@@ -253,9 +253,8 @@ eschan_init(kobj_t obj, void *devinfo, snd_dbuf *b, pcm_channel *c, int dir)
ch->parent = es;
ch->channel = c;
ch->buffer = b;
- ch->buffer->bufsize = ES_BUFFSIZE;
ch->num = ch->parent->num++;
- if (chn_allocbuf(ch->buffer, es->parent_dmat) == -1) return NULL;
+ if (sndbuf_alloc(ch->buffer, es->parent_dmat, ES_BUFFSIZE) == -1) return NULL;
return ch;
}
@@ -269,16 +268,16 @@ eschan_setdir(kobj_t obj, void *data, int dir)
bus_space_write_1(es->st, es->sh, ES1370_REG_MEMPAGE,
ES1370_REG_DAC2_FRAMEADR >> 8);
bus_space_write_4(es->st, es->sh, ES1370_REG_DAC2_FRAMEADR & 0xff,
- vtophys(ch->buffer->buf));
+ vtophys(sndbuf_getbuf(ch->buffer)));
bus_space_write_4(es->st, es->sh, ES1370_REG_DAC2_FRAMECNT & 0xff,
- (ch->buffer->bufsize >> 2) - 1);
+ (sndbuf_getsize(ch->buffer) >> 2) - 1);
} else {
bus_space_write_1(es->st, es->sh, ES1370_REG_MEMPAGE,
ES1370_REG_ADC_FRAMEADR >> 8);
bus_space_write_4(es->st, es->sh, ES1370_REG_ADC_FRAMEADR & 0xff,
- vtophys(ch->buffer->buf));
+ vtophys(sndbuf_getbuf(ch->buffer)));
bus_space_write_4(es->st, es->sh, ES1370_REG_ADC_FRAMECNT & 0xff,
- (ch->buffer->bufsize >> 2) - 1);
+ (sndbuf_getsize(ch->buffer) >> 2) - 1);
}
ch->dir = dir;
return 0;
@@ -346,10 +345,7 @@ eschan_trigger(kobj_t obj, void *data, int go)
if (go == PCMTRIG_EMLDMAWR || go == PCMTRIG_EMLDMARD)
return 0;
- ss = 1;
- ss <<= (ch->fmt & AFMT_STEREO)? 1 : 0;
- ss <<= (ch->fmt & AFMT_16BIT)? 1 : 0;
- cnt = ch->buffer->dl / ss - 1;
+ cnt = (sndbuf_runsz(ch->buffer) / sndbuf_getbps(ch->buffer)) - 1;
if (ch->dir == PCMDIR_PLAY) {
if (go == PCMTRIG_START) {
@@ -366,7 +362,7 @@ eschan_trigger(kobj_t obj, void *data, int go)
ES1370_REG_DAC2_FRAMECNT >> 8);
bus_space_write_4(es->st, es->sh,
ES1370_REG_DAC2_FRAMECNT & 0xff,
- (ch->buffer->bufsize >> 2) - 1);
+ (sndbuf_getsize(ch->buffer) >> 2) - 1);
} else es->ctrl &= ~CTRL_DAC2_EN;
} else {
if (go == PCMTRIG_START) {
@@ -380,7 +376,7 @@ eschan_trigger(kobj_t obj, void *data, int go)
ES1370_REG_ADC_FRAMECNT >> 8);
bus_space_write_4(es->st, es->sh,
ES1370_REG_ADC_FRAMECNT & 0xff,
- (ch->buffer->bufsize >> 2) - 1);
+ (sndbuf_getsize(ch->buffer) >> 2) - 1);
} else es->ctrl &= ~CTRL_ADC_EN;
}
bus_space_write_4(es->st, es->sh, ES1370_REG_SERIAL_CONTROL, es->sctrl);
OpenPOWER on IntegriCloud