aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/sound/isa
diff options
context:
space:
mode:
authorYoshihiro Takahashi <nyan@FreeBSD.org>2003-02-07 14:05:34 +0000
committerYoshihiro Takahashi <nyan@FreeBSD.org>2003-02-07 14:05:34 +0000
commit3febcc57ecb5fb54e123852ee8b07557b4bde0fe (patch)
treebb7186a3521199202c6d88ec66567221b0ead322 /sys/dev/sound/isa
parent6780ab54325a71e7e70112b11657973edde8655e (diff)
downloadsrc-3febcc57ecb5fb54e123852ee8b07557b4bde0fe.tar.gz
src-3febcc57ecb5fb54e123852ee8b07557b4bde0fe.zip
- Clean up ISA DMA supports.
- Rename all sndbuf_isadma* functions to sndbuf_dma* and move them into sys/dev/sound/isa/sndbuf_dma.c. No response from: sound
Notes
Notes: svn path=/head/; revision=110499
Diffstat (limited to 'sys/dev/sound/isa')
-rw-r--r--sys/dev/sound/isa/ad1816.c8
-rw-r--r--sys/dev/sound/isa/ess.c12
-rw-r--r--sys/dev/sound/isa/mss.c8
-rw-r--r--sys/dev/sound/isa/sb16.c32
-rw-r--r--sys/dev/sound/isa/sb8.c8
-rw-r--r--sys/dev/sound/isa/sbc.c2
-rw-r--r--sys/dev/sound/isa/sndbuf_dma.c103
7 files changed, 144 insertions, 29 deletions
diff --git a/sys/dev/sound/isa/ad1816.c b/sys/dev/sound/isa/ad1816.c
index 6f14d9acd5d5..2554af2a8655 100644
--- a/sys/dev/sound/isa/ad1816.c
+++ b/sys/dev/sound/isa/ad1816.c
@@ -29,6 +29,8 @@
#include <dev/sound/pcm/sound.h>
#include <dev/sound/isa/ad1816.h>
+#include <isa/isavar.h>
+
#include "mixer_if.h"
SND_DECLARE_FILE("$FreeBSD$");
@@ -322,7 +324,7 @@ ad1816chan_setdir(kobj_t obj, void *data, int dir)
struct ad1816_chinfo *ch = data;
struct ad1816_info *ad1816 = ch->parent;
- sndbuf_isadmasetup(ch->buffer, (dir == PCMDIR_PLAY)? ad1816->drq1 : ad1816->drq2);
+ sndbuf_dmasetup(ch->buffer, (dir == PCMDIR_PLAY)? ad1816->drq1 : ad1816->drq2);
ch->dir = dir;
return 0;
}
@@ -407,7 +409,7 @@ ad1816chan_trigger(kobj_t obj, void *data, int go)
if (go == PCMTRIG_EMLDMAWR || go == PCMTRIG_EMLDMARD)
return 0;
- sndbuf_isadma(ch->buffer, go);
+ sndbuf_dma(ch->buffer, go);
wr = (ch->dir == PCMDIR_PLAY);
reg = wr? AD1816_PLAY : AD1816_CAPT;
ad1816_lock(ad1816);
@@ -453,7 +455,7 @@ static int
ad1816chan_getptr(kobj_t obj, void *data)
{
struct ad1816_chinfo *ch = data;
- return sndbuf_isadmaptr(ch->buffer);
+ return sndbuf_dmaptr(ch->buffer);
}
static struct pcmchan_caps *
diff --git a/sys/dev/sound/isa/ess.c b/sys/dev/sound/isa/ess.c
index 35c4fffac80c..38e3198e3e62 100644
--- a/sys/dev/sound/isa/ess.c
+++ b/sys/dev/sound/isa/ess.c
@@ -34,6 +34,8 @@
#include <dev/sound/isa/sb.h>
#include <dev/sound/chip.h>
+#include <isa/isavar.h>
+
#include "mixer_if.h"
SND_DECLARE_FILE("$FreeBSD$");
@@ -367,7 +369,7 @@ ess_intr(void *arg)
chn_intr(sc->pch.channel);
if (sc->pch.stopping) {
sc->pch.run = 0;
- sndbuf_isadma(sc->pch.buffer, PCMTRIG_STOP);
+ sndbuf_dma(sc->pch.buffer, PCMTRIG_STOP);
sc->pch.stopping = 0;
if (sc->pch.hwch == 1)
ess_write(sc, 0xb8, ess_read(sc, 0xb8) & ~0x01);
@@ -381,7 +383,7 @@ ess_intr(void *arg)
chn_intr(sc->rch.channel);
if (sc->rch.stopping) {
sc->rch.run = 0;
- sndbuf_isadma(sc->rch.buffer, PCMTRIG_STOP);
+ sndbuf_dma(sc->rch.buffer, PCMTRIG_STOP);
sc->rch.stopping = 0;
/* XXX: will this stop audio2? */
ess_write(sc, 0xb8, ess_read(sc, 0xb8) & ~0x01);
@@ -565,7 +567,7 @@ esschan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *
ch->hwch = 1;
if ((dir == PCMDIR_PLAY) && (sc->duplex))
ch->hwch = 2;
- sndbuf_isadmasetup(ch->buffer, (ch->hwch == 1)? sc->drq1 : sc->drq2);
+ sndbuf_dmasetup(ch->buffer, (ch->hwch == 1)? sc->drq1 : sc->drq2);
return ch;
}
@@ -612,7 +614,7 @@ esschan_trigger(kobj_t obj, void *data, int go)
switch (go) {
case PCMTRIG_START:
ch->run = 1;
- sndbuf_isadma(ch->buffer, go);
+ sndbuf_dma(ch->buffer, go);
ess_start(ch);
break;
@@ -630,7 +632,7 @@ esschan_getptr(kobj_t obj, void *data)
{
struct ess_chinfo *ch = data;
- return sndbuf_isadmaptr(ch->buffer);
+ return sndbuf_dmaptr(ch->buffer);
}
static struct pcmchan_caps *
diff --git a/sys/dev/sound/isa/mss.c b/sys/dev/sound/isa/mss.c
index 8f7a37885654..dc0c43e30d35 100644
--- a/sys/dev/sound/isa/mss.c
+++ b/sys/dev/sound/isa/mss.c
@@ -36,6 +36,8 @@ SND_DECLARE_FILE("$FreeBSD$");
#include <dev/sound/isa/sb.h>
#include <dev/sound/chip.h>
+#include <isa/isavar.h>
+
#include "mixer_if.h"
#define MSS_DEFAULT_BUFSZ (4096)
@@ -1127,7 +1129,7 @@ msschan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *
ch->buffer = b;
ch->dir = dir;
if (sndbuf_alloc(ch->buffer, mss->parent_dmat, mss->bufsize) == -1) return NULL;
- sndbuf_isadmasetup(ch->buffer, (dir == PCMDIR_PLAY)? mss->drq1 : mss->drq2);
+ sndbuf_dmasetup(ch->buffer, (dir == PCMDIR_PLAY)? mss->drq1 : mss->drq2);
return ch;
}
@@ -1177,7 +1179,7 @@ msschan_trigger(kobj_t obj, void *data, int go)
if (go == PCMTRIG_EMLDMAWR || go == PCMTRIG_EMLDMARD)
return 0;
- sndbuf_isadma(ch->buffer, go);
+ sndbuf_dma(ch->buffer, go);
mss_lock(mss);
mss_trigger(ch, go);
mss_unlock(mss);
@@ -1188,7 +1190,7 @@ static int
msschan_getptr(kobj_t obj, void *data)
{
struct mss_chinfo *ch = data;
- return sndbuf_isadmaptr(ch->buffer);
+ return sndbuf_dmaptr(ch->buffer);
}
static struct pcmchan_caps *
diff --git a/sys/dev/sound/isa/sb16.c b/sys/dev/sound/isa/sb16.c
index fa167017f6f5..4851eeb42e02 100644
--- a/sys/dev/sound/isa/sb16.c
+++ b/sys/dev/sound/isa/sb16.c
@@ -34,6 +34,8 @@
#include <dev/sound/isa/sb.h>
#include <dev/sound/chip.h>
+#include <isa/isavar.h>
+
#include "mixer_if.h"
SND_DECLARE_FILE("$FreeBSD$");
@@ -540,43 +542,43 @@ sb_setup(struct sb_info *sb)
sb_lock(sb);
if (sb->bd_flags & BD_F_DMARUN)
- sndbuf_isadma(sb->pch.buffer, PCMTRIG_STOP);
+ sndbuf_dma(sb->pch.buffer, PCMTRIG_STOP);
if (sb->bd_flags & BD_F_DMARUN2)
- sndbuf_isadma(sb->rch.buffer, PCMTRIG_STOP);
+ sndbuf_dma(sb->rch.buffer, PCMTRIG_STOP);
sb->bd_flags &= ~(BD_F_DMARUN | BD_F_DMARUN2);
sb_reset_dsp(sb);
if (sb->bd_flags & BD_F_SB16X) {
pprio = sb->pch.run? 1 : 0;
- sndbuf_isadmasetup(sb->pch.buffer, pprio? sb->drq1 : NULL);
+ sndbuf_dmasetup(sb->pch.buffer, pprio? sb->drq1 : NULL);
sb->pch.dch = pprio? 1 : 0;
- sndbuf_isadmasetup(sb->rch.buffer, pprio? sb->drq2 : sb->drq1);
+ sndbuf_dmasetup(sb->rch.buffer, pprio? sb->drq2 : sb->drq1);
sb->rch.dch = pprio? 2 : 1;
} else {
if (sb->pch.run && sb->rch.run) {
pprio = (sb->rch.fmt & AFMT_16BIT)? 0 : 1;
- sndbuf_isadmasetup(sb->pch.buffer, pprio? sb->drq2 : sb->drq1);
+ sndbuf_dmasetup(sb->pch.buffer, pprio? sb->drq2 : sb->drq1);
sb->pch.dch = pprio? 2 : 1;
- sndbuf_isadmasetup(sb->rch.buffer, pprio? sb->drq1 : sb->drq2);
+ sndbuf_dmasetup(sb->rch.buffer, pprio? sb->drq1 : sb->drq2);
sb->rch.dch = pprio? 1 : 2;
} else {
if (sb->pch.run) {
- sndbuf_isadmasetup(sb->pch.buffer, (sb->pch.fmt & AFMT_16BIT)? sb->drq2 : sb->drq1);
+ sndbuf_dmasetup(sb->pch.buffer, (sb->pch.fmt & AFMT_16BIT)? sb->drq2 : sb->drq1);
sb->pch.dch = (sb->pch.fmt & AFMT_16BIT)? 2 : 1;
- sndbuf_isadmasetup(sb->rch.buffer, (sb->pch.fmt & AFMT_16BIT)? sb->drq1 : sb->drq2);
+ sndbuf_dmasetup(sb->rch.buffer, (sb->pch.fmt & AFMT_16BIT)? sb->drq1 : sb->drq2);
sb->rch.dch = (sb->pch.fmt & AFMT_16BIT)? 1 : 2;
} else if (sb->rch.run) {
- sndbuf_isadmasetup(sb->pch.buffer, (sb->rch.fmt & AFMT_16BIT)? sb->drq1 : sb->drq2);
+ sndbuf_dmasetup(sb->pch.buffer, (sb->rch.fmt & AFMT_16BIT)? sb->drq1 : sb->drq2);
sb->pch.dch = (sb->rch.fmt & AFMT_16BIT)? 1 : 2;
- sndbuf_isadmasetup(sb->rch.buffer, (sb->rch.fmt & AFMT_16BIT)? sb->drq2 : sb->drq1);
+ sndbuf_dmasetup(sb->rch.buffer, (sb->rch.fmt & AFMT_16BIT)? sb->drq2 : sb->drq1);
sb->rch.dch = (sb->rch.fmt & AFMT_16BIT)? 2 : 1;
}
}
}
- sndbuf_isadmasetdir(sb->pch.buffer, PCMDIR_PLAY);
- sndbuf_isadmasetdir(sb->rch.buffer, PCMDIR_REC);
+ sndbuf_dmasetdir(sb->pch.buffer, PCMDIR_PLAY);
+ sndbuf_dmasetdir(sb->rch.buffer, PCMDIR_REC);
/*
printf("setup: [pch = %d, pfmt = %d, pgo = %d] [rch = %d, rfmt = %d, rgo = %d]\n",
@@ -604,7 +606,7 @@ sb_setup(struct sb_info *sb)
v = (ch->fmt & AFMT_STEREO)? DSP_F16_STEREO : 0;
v |= (ch->fmt & AFMT_SIGNED)? DSP_F16_SIGNED : 0;
sb_cmd2(sb, v, l);
- sndbuf_isadma(ch->buffer, PCMTRIG_START);
+ sndbuf_dma(ch->buffer, PCMTRIG_START);
sb->bd_flags |= BD_F_DMARUN;
}
@@ -629,7 +631,7 @@ sb_setup(struct sb_info *sb)
v = (ch->fmt & AFMT_STEREO)? DSP_F16_STEREO : 0;
v |= (ch->fmt & AFMT_SIGNED)? DSP_F16_SIGNED : 0;
sb_cmd2(sb, v, l);
- sndbuf_isadma(ch->buffer, PCMTRIG_START);
+ sndbuf_dma(ch->buffer, PCMTRIG_START);
sb->bd_flags |= BD_F_DMARUN2;
}
sb_unlock(sb);
@@ -710,7 +712,7 @@ sb16chan_getptr(kobj_t obj, void *data)
{
struct sb_chinfo *ch = data;
- return sndbuf_isadmaptr(ch->buffer);
+ return sndbuf_dmaptr(ch->buffer);
}
static struct pcmchan_caps *
diff --git a/sys/dev/sound/isa/sb8.c b/sys/dev/sound/isa/sb8.c
index a57671e31b5d..095d817b38d2 100644
--- a/sys/dev/sound/isa/sb8.c
+++ b/sys/dev/sound/isa/sb8.c
@@ -34,6 +34,8 @@
#include <dev/sound/isa/sb.h>
#include <dev/sound/chip.h>
+#include <isa/isavar.h>
+
#include "mixer_if.h"
SND_DECLARE_FILE("$FreeBSD$");
@@ -582,7 +584,7 @@ sbchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c
ch->buffer = b;
if (sndbuf_alloc(ch->buffer, sb->parent_dmat, sb->bufsize) == -1)
return NULL;
- sndbuf_isadmasetup(ch->buffer, sb->drq);
+ sndbuf_dmasetup(ch->buffer, sb->drq);
return ch;
}
@@ -621,7 +623,7 @@ sbchan_trigger(kobj_t obj, void *data, int go)
if (go == PCMTRIG_EMLDMAWR || go == PCMTRIG_EMLDMARD)
return 0;
- sndbuf_isadma(ch->buffer, go);
+ sndbuf_dma(ch->buffer, go);
if (go == PCMTRIG_START)
sb_start(ch);
else
@@ -634,7 +636,7 @@ sbchan_getptr(kobj_t obj, void *data)
{
struct sb_chinfo *ch = data;
- return sndbuf_isadmaptr(ch->buffer);
+ return sndbuf_dmaptr(ch->buffer);
}
static struct pcmchan_caps *
diff --git a/sys/dev/sound/isa/sbc.c b/sys/dev/sound/isa/sbc.c
index 01f451c7600c..21cb6394f7c4 100644
--- a/sys/dev/sound/isa/sbc.c
+++ b/sys/dev/sound/isa/sbc.c
@@ -28,6 +28,8 @@
#include <dev/sound/pcm/sound.h>
#include <dev/sound/isa/sb.h>
+#include <isa/isavar.h>
+
SND_DECLARE_FILE("$FreeBSD$");
#define IO_MAX 3
diff --git a/sys/dev/sound/isa/sndbuf_dma.c b/sys/dev/sound/isa/sndbuf_dma.c
new file mode 100644
index 000000000000..d07c30145277
--- /dev/null
+++ b/sys/dev/sound/isa/sndbuf_dma.c
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 1999 Cameron Grant <gandalf@vilnya.demon.co.uk>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <dev/sound/pcm/sound.h>
+
+#include <isa/isavar.h>
+
+SND_DECLARE_FILE("$FreeBSD$");
+
+int
+sndbuf_dmasetup(struct snd_dbuf *b, struct resource *drq)
+{
+ /* should do isa_dma_acquire/isa_dma_release here */
+ if (drq == NULL) {
+ b->dmachan = -1;
+ } else {
+ sndbuf_setflags(b, SNDBUF_F_DMA, 1);
+ b->dmachan = rman_get_start(drq);
+ }
+ return 0;
+}
+
+int
+sndbuf_dmasetdir(struct snd_dbuf *b, int dir)
+{
+ KASSERT(b, ("sndbuf_dmasetdir called with b == NULL"));
+ KASSERT(sndbuf_getflags(b) & SNDBUF_F_DMA, ("sndbuf_dmasetdir called on non-ISA buffer"));
+
+ b->dir = (dir == PCMDIR_PLAY)? ISADMA_WRITE : ISADMA_READ;
+ return 0;
+}
+
+void
+sndbuf_dma(struct snd_dbuf *b, int go)
+{
+ KASSERT(b, ("sndbuf_dma called with b == NULL"));
+ KASSERT(sndbuf_getflags(b) & SNDBUF_F_DMA, ("sndbuf_dma called on non-ISA buffer"));
+
+ switch (go) {
+ case PCMTRIG_START:
+ /* isa_dmainit(b->chan, size); */
+ isa_dmastart(b->dir | ISADMA_RAW, b->buf, b->bufsize, b->dmachan);
+ break;
+
+ case PCMTRIG_STOP:
+ case PCMTRIG_ABORT:
+ isa_dmastop(b->dmachan);
+ isa_dmadone(b->dir | ISADMA_RAW, b->buf, b->bufsize, b->dmachan);
+ break;
+ }
+
+ DEB(printf("buf 0x%p ISA DMA %s, channel %d\n",
+ b,
+ (go == PCMTRIG_START)? "started" : "stopped",
+ b->dmachan));
+}
+
+int
+sndbuf_dmaptr(struct snd_dbuf *b)
+{
+ int i;
+
+ KASSERT(b, ("sndbuf_dmaptr called with b == NULL"));
+ KASSERT(sndbuf_getflags(b) & SNDBUF_F_DMA, ("sndbuf_dmaptr called on non-ISA buffer"));
+
+ if (!sndbuf_runsz(b))
+ return 0;
+ i = isa_dmastatus(b->dmachan);
+ KASSERT(i >= 0, ("isa_dmastatus returned %d", i));
+ return b->bufsize - i;
+}
+
+void
+sndbuf_dmabounce(struct snd_dbuf *b)
+{
+ KASSERT(b, ("sndbuf_dmabounce called with b == NULL"));
+ KASSERT(sndbuf_getflags(b) & SNDBUF_F_DMA, ("sndbuf_dmabounce called on non-ISA buffer"));
+
+ /* tell isa_dma to bounce data in/out */
+}