summaryrefslogtreecommitdiff
path: root/sys/dev/pci/envy.c
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2018-03-17 13:33:09 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2018-03-17 13:33:09 +0000
commit4c7d7d724ed0157993e15cf6b048e05c702a3722 (patch)
treeeabc6c5c9e74eb530551e9bfd96732a157b4f412 /sys/dev/pci/envy.c
parent6498191c5f667a660080fda007c0da68a38537fc (diff)
Set base DMA pointers when DMA starts.
The allocm() functions are supposed to allocate memory and it's bad style to access the hardware there, so move the DMA base pointers setup to the trigger_xxx(). ok kettenis@
Diffstat (limited to 'sys/dev/pci/envy.c')
-rw-r--r--sys/dev/pci/envy.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/sys/dev/pci/envy.c b/sys/dev/pci/envy.c
index c620a27335c..a12d15e4bd6 100644
--- a/sys/dev/pci/envy.c
+++ b/sys/dev/pci/envy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: envy.c,v 1.70 2017/03/28 05:23:15 ratchov Exp $ */
+/* $OpenBSD: envy.c,v 1.71 2018/03/17 13:33:08 ratchov Exp $ */
/*
* Copyright (c) 2007 Alexandre Ratchov <alex@caoua.org>
*
@@ -1742,17 +1742,11 @@ void *
envy_allocm(void *self, int dir, size_t size, int type, int flags)
{
struct envy_softc *sc = (struct envy_softc *)self;
- int err, basereg, wait;
+ int err, wait;
struct envy_buf *buf;
bus_addr_t dma_addr;
- if (dir == AUMODE_RECORD) {
- buf = &sc->ibuf;
- basereg = ENVY_MT_RADDR;
- } else {
- buf = &sc->obuf;
- basereg = ENVY_MT_PADDR;
- }
+ buf = (dir == AUMODE_RECORD) ? &sc->ibuf : &sc->obuf;
if (buf->addr != NULL) {
DPRINTF("%s: multiple alloc, dir = %d\n", DEVNAME(sc), dir);
return NULL;
@@ -1789,7 +1783,6 @@ envy_allocm(void *self, int dir, size_t size, int type, int flags)
printf("%s: DMA address beyond 0x10000000\n", DEVNAME(sc));
goto err_unload;
}
- envy_mt_write_4(sc, basereg, dma_addr);
return buf->addr;
err_unload:
bus_dmamap_unload(sc->pci_dmat, buf->map);
@@ -2051,6 +2044,7 @@ envy_trigger_output(void *self, void *start, void *end, int blksz,
}
#endif
mtx_enter(&audio_lock);
+ envy_mt_write_4(sc, ENVY_MT_PADDR, sc->obuf.map->dm_segs[0].ds_addr);
envy_mt_write_2(sc, ENVY_MT_PBUFSZ, bufsz / 4 - 1);
envy_mt_write_2(sc, ENVY_MT_PBLKSZ(sc), blksz / 4 - 1);
@@ -2097,6 +2091,7 @@ envy_trigger_input(void *self, void *start, void *end, int blksz,
}
#endif
mtx_enter(&audio_lock);
+ envy_mt_write_4(sc, ENVY_MT_RADDR, sc->ibuf.map->dm_segs[0].ds_addr);
envy_mt_write_2(sc, ENVY_MT_RBUFSZ, bufsz / 4 - 1);
envy_mt_write_2(sc, ENVY_MT_RBLKSZ, blksz / 4 - 1);