diff --git a/sys/dev/midi.c b/sys/dev/midi.c index 616437ec04fd..43c54428f5cf 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 bd5f1599cde1..bf40a7c17d92 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 62f7b0347c74..8648b0202ea7 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); }