summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authoraugustss <augustss@NetBSD.org>1998-08-24 17:59:25 +0000
committeraugustss <augustss@NetBSD.org>1998-08-24 17:59:25 +0000
commit4e7c07c2b494a3080b6ca517bd0f8e97d794c8a5 (patch)
tree6ff4b8ec2dceba466516b9cd502a2da27228dd11 /sys/dev
parent2da237ca1fa07fcae179f4a65098995c16a15b8c (diff)
Write MIDI data from the sequencer to the device in a more sane way.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/midi.c41
-rw-r--r--sys/dev/midi_if.h3
-rw-r--r--sys/dev/sequencer.c27
3 files changed, 49 insertions, 22 deletions
diff --git a/sys/dev/midi.c b/sys/dev/midi.c
index 616437ec04f..43c54428f5c 100644
--- a/sys/dev/midi.c
+++ b/sys/dev/midi.c
@@ -1,4 +1,4 @@
-/* $NetBSD: midi.c,v 1.4 1998/08/17 21:16:11 augustss Exp $ */
+/* $NetBSD: midi.c,v 1.5 1998/08/24 17:59:25 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -582,6 +582,45 @@ midiwrite(dev, uio, ioflag)
return error;
}
+/*
+ * This write routine is only called from sequencer code and expect
+ * a write that is smaller than the MIDI buffer.
+ */
+int
+midi_writebytes(unit, buf, cc)
+ int unit;
+ u_char *buf;
+ int cc;
+{
+ struct midi_softc *sc = midi_cd.cd_devs[unit];
+ struct midi_buffer *mb = &sc->outbuf;
+ int n, s;
+
+ DPRINTFN(2, ("midi_writebytes: %p, unit=%d, cc=%d\n", sc, unit, cc));
+
+ s = splaudio();
+ if (mb->used + cc >= mb->usedhigh) {
+ splx(s);
+ return (EWOULDBLOCK);
+ }
+ n = mb->end - mb->inp;
+ if (cc < n)
+ n = cc;
+ memcpy(mb->inp, buf, cc);
+ mb->inp += n;
+ if (mb->inp >= mb->end) {
+ mb->inp = mb->start;
+ cc -= n;
+ if (cc > 0) {
+ memcpy(mb->inp, buf + n, cc);
+ mb->inp += cc;
+ }
+ }
+ mb->used += cc;
+ splx(s);
+ return (midi_start_output(sc, 0));
+}
+
int
midiioctl(dev, cmd, addr, flag, p)
dev_t dev;
diff --git a/sys/dev/midi_if.h b/sys/dev/midi_if.h
index bd5f1599cde..bf40a7c17d9 100644
--- a/sys/dev/midi_if.h
+++ b/sys/dev/midi_if.h
@@ -1,4 +1,4 @@
-/* $NetBSD: midi_if.h,v 1.1 1998/08/17 21:16:12 augustss Exp $ */
+/* $NetBSD: midi_if.h,v 1.2 1998/08/24 17:59:26 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -63,5 +63,6 @@ void midi_attach_mi __P((struct midi_hw_if *, void *, struct device *));
int midi_unit_count __P((void));
void midi_getinfo __P((dev_t, struct midi_info *));
+int midi_writebytes __P((int, u_char *, int));
#endif /* _SYS_DEV_MIDI_IF_H_ */
diff --git a/sys/dev/sequencer.c b/sys/dev/sequencer.c
index 62f7b0347c7..8648b0202ea 100644
--- a/sys/dev/sequencer.c
+++ b/sys/dev/sequencer.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sequencer.c,v 1.9 1998/08/20 10:59:09 augustss Exp $ */
+/* $NetBSD: sequencer.c,v 1.10 1998/08/24 17:59:27 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -1133,28 +1133,15 @@ midiseq_out(md, buf, cc, chk)
u_int cc;
int chk;
{
- struct uio uio;
- struct iovec iovec;
-
DPRINTFN(5, ("midiseq_out: m=%p, unit=%d, buf[0]=0x%02x, cc=%d\n",
md->msc, md->unit, buf[0], cc));
-#if 1
+
/* The MIDI "status" byte does not have to be repeated. */
if (chk && md->last_cmd == buf[0])
buf++, cc--;
else
-#endif
md->last_cmd = buf[0];
- iovec.iov_base = (char *)buf;
- iovec.iov_len = cc;
- uio.uio_iov = &iovec;
- uio.uio_iovcnt = 1;
- uio.uio_offset = 0;
- uio.uio_resid = cc;
- uio.uio_segflg = UIO_SYSSPACE;
- uio.uio_rw = UIO_WRITE;
- uio.uio_procp = 0; /* process not needed for UIO_SYSSPACE */
- return midiwrite(makedev(0, md->unit), &uio, 0);
+ return midi_writebytes(md->unit, buf, cc);
}
int
@@ -1379,10 +1366,10 @@ midiclose(dev, flags, ifmt, p)
}
int
-midiwrite(dev, uio, ioflag)
- dev_t dev;
- struct uio *uio;
- int ioflag;
+midi_writebytes(unit, buf, cc)
+ int unit;
+ u_char *buf;
+ int cc;
{
return (ENXIO);
}