summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/isa/mpu401.c3
-rw-r--r--sys/dev/isa/sb.c4
-rw-r--r--sys/dev/isa/ym.c3
-rw-r--r--sys/dev/midi.c44
-rw-r--r--sys/dev/midi_if.h3
-rw-r--r--sys/dev/midisyn.c3
-rw-r--r--sys/dev/pci/autri.c3
-rw-r--r--sys/dev/pci/cs4280.c5
-rw-r--r--sys/dev/pci/eap.c3
-rw-r--r--sys/dev/usb/umidi.c223
-rw-r--r--sys/dev/usb/umidivar.h20
11 files changed, 202 insertions, 112 deletions
diff --git a/sys/dev/isa/mpu401.c b/sys/dev/isa/mpu401.c
index e602cdb03e3..3d393c5c5bd 100644
--- a/sys/dev/isa/mpu401.c
+++ b/sys/dev/isa/mpu401.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mpu401.c,v 1.9 2004/01/09 21:32:24 brad Exp $ */
+/* $OpenBSD: mpu401.c,v 1.10 2006/04/07 22:41:33 jsg Exp $ */
/* $NetBSD: mpu401.c,v 1.3 1998/11/25 22:17:06 augustss Exp $ */
/*
@@ -84,6 +84,7 @@ struct midi_hw_if mpu_midi_hw_if = {
mpu_open,
mpu_close,
mpu_output,
+ 0, /* flush */
mpu_getinfo,
0, /* ioctl */
};
diff --git a/sys/dev/isa/sb.c b/sys/dev/isa/sb.c
index 2b29d34e9c5..78af4793722 100644
--- a/sys/dev/isa/sb.c
+++ b/sys/dev/isa/sb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sb.c,v 1.23 2003/04/27 11:22:53 ho Exp $ */
+/* $OpenBSD: sb.c,v 1.24 2006/04/07 22:41:33 jsg Exp $ */
/* $NetBSD: sb.c,v 1.57 1998/01/12 09:43:46 thorpej Exp $ */
/*
@@ -75,6 +75,7 @@ struct midi_hw_if sb_midi_hw_if = {
sbdsp_midi_open,
sbdsp_midi_close,
sbdsp_midi_output,
+ 0, /* flush */
sbdsp_midi_getinfo,
0, /* ioctl */
};
@@ -83,6 +84,7 @@ struct midi_hw_if sb_mpu401_hw_if = {
sb_mpu401_open,
sb_mpu401_close,
sb_mpu401_output,
+ 0, /* flush */
sb_mpu401_getinfo,
0, /* ioctl */
};
diff --git a/sys/dev/isa/ym.c b/sys/dev/isa/ym.c
index d96cc31f40c..7d418659ce7 100644
--- a/sys/dev/isa/ym.c
+++ b/sys/dev/isa/ym.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ym.c,v 1.12 2003/04/27 11:22:53 ho Exp $ */
+/* $OpenBSD: ym.c,v 1.13 2006/04/07 22:41:33 jsg Exp $ */
/*
@@ -121,6 +121,7 @@ struct midi_hw_if ym_mpu401_hw_if = {
ym_mpu401_open,
ym_mpu401_close,
ym_mpu401_output,
+ 0, /* flush */
ym_mpu401_getinfo,
0, /* ioctl */
};
diff --git a/sys/dev/midi.c b/sys/dev/midi.c
index 881f86d5a01..9c2aaf04bf8 100644
--- a/sys/dev/midi.c
+++ b/sys/dev/midi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: midi.c,v 1.12 2004/09/22 22:17:44 deraadt Exp $ */
+/* $OpenBSD: midi.c,v 1.13 2006/04/07 22:41:32 jsg Exp $ */
/*
* Copyright (c) 2003, 2004 Alexandre Ratchov
@@ -48,6 +48,7 @@
#include <dev/audio_if.h>
#include <dev/midivar.h>
+
int midiopen(dev_t, int, int, struct proc *);
int midiclose(dev_t, int, int, struct proc *);
int midiread(dev_t, struct uio *, int);
@@ -223,34 +224,53 @@ midi_out_do(struct midi_softc *sc)
{
struct midi_buffer *mb = &sc->outbuf;
unsigned i, max;
- unsigned data;
int error;
/*
* If output interrupts are not supported then we write MIDI_MAXWRITE
* bytes instead of 1, and then we wait sc->wait
- */
-
+ */
+
max = sc->props & MIDI_PROP_OUT_INTR ? 1 : MIDI_MAXWRITE;
for (i = max; i != 0;) {
if (mb->used == 0)
break;
-
- MIDIBUF_READ(mb, data);
- error = sc->hw_if->output(sc->hw_hdl, data);
+ error = sc->hw_if->output(sc->hw_hdl, mb->data[mb->start]);
/*
- * EINPROGRESS means that data has been handled,
- * but will not be sent immediately and thus will
- * not generate interrupt, in this case we can
- * send another byte
+ * 0 means that data is being sent, an interrupt will
+ * be generated when the interface becomes ready again
+ *
+ * EINPROGRESS means that data has been queued, but
+ * will not be sent immediately and thus will not
+ * generate interrupt, in this case we can send
+ * another byte. The flush() method can be called
+ * to force the tranfer.
+ *
+ * EAGAIN means that data cannot be queued or sent;
+ * because the interface isn't ready. An interrupt
+ * will be generated once the interface is ready again
+ *
+ * any other (fatal) error code means that data couldn't
+ * be sent and was lost, interrupt will not be generated
*/
if (error == EINPROGRESS) {
+ MIDIBUF_REMOVE(mb, 1);
if (MIDIBUF_ISEMPTY(mb)) {
+ if (sc->hw_if->flush != NULL)
+ sc->hw_if->flush(sc->hw_hdl);
midi_out_stop(sc);
return;
}
- } else
+ } else if (error == 0) {
+ MIDIBUF_REMOVE(mb, 1);
i--;
+ } else if (error == EAGAIN) {
+ break;
+ } else {
+ MIDIBUF_INIT(mb);
+ midi_out_stop(sc);
+ return;
+ }
}
if (!(sc->props & MIDI_PROP_OUT_INTR)) {
diff --git a/sys/dev/midi_if.h b/sys/dev/midi_if.h
index 7c7b0276fad..4a2c7ee1440 100644
--- a/sys/dev/midi_if.h
+++ b/sys/dev/midi_if.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: midi_if.h,v 1.5 2002/03/15 01:20:04 millert Exp $ */
+/* $OpenBSD: midi_if.h,v 1.6 2006/04/07 22:41:32 jsg Exp $ */
/* $NetBSD: midi_if.h,v 1.3 1998/11/25 22:17:07 augustss Exp $ */
/*
@@ -56,6 +56,7 @@ struct midi_hw_if {
void *);
void (*close)(void *); /* close hardware */
int (*output)(void *, int); /* output a byte */
+ void (*flush)(void *); /* flush the output */
void (*getinfo)(void *, struct midi_info *);
int (*ioctl)(void *, u_long, caddr_t, int, struct proc *);
};
diff --git a/sys/dev/midisyn.c b/sys/dev/midisyn.c
index 86e29965324..41cfc9198b8 100644
--- a/sys/dev/midisyn.c
+++ b/sys/dev/midisyn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: midisyn.c,v 1.5 2005/11/21 18:16:38 millert Exp $ */
+/* $OpenBSD: midisyn.c,v 1.6 2006/04/07 22:41:32 jsg Exp $ */
/* $NetBSD: midisyn.c,v 1.5 1998/11/25 22:17:07 augustss Exp $ */
/*
@@ -84,6 +84,7 @@ struct midi_hw_if midisyn_hw_if = {
midisyn_open,
midisyn_close,
midisyn_output,
+ NULL, /* flush */
midisyn_getinfo,
midisyn_ioctl,
};
diff --git a/sys/dev/pci/autri.c b/sys/dev/pci/autri.c
index f6ee18c3dad..41c85d333ed 100644
--- a/sys/dev/pci/autri.c
+++ b/sys/dev/pci/autri.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: autri.c,v 1.17 2006/02/22 18:12:24 brad Exp $ */
+/* $OpenBSD: autri.c,v 1.18 2006/04/07 22:41:33 jsg Exp $ */
/*
* Copyright (c) 2001 SOMEYA Yoshihiko and KUROSAWA Takahiro.
@@ -184,6 +184,7 @@ struct midi_hw_if autri_midi_hw_if = {
autri_midi_open,
autri_midi_close,
autri_midi_output,
+ NULL, /* flush */
autri_midi_getinfo,
NULL, /* ioctl */
};
diff --git a/sys/dev/pci/cs4280.c b/sys/dev/pci/cs4280.c
index 274116cefe5..2032fbd8f70 100644
--- a/sys/dev/pci/cs4280.c
+++ b/sys/dev/pci/cs4280.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cs4280.c,v 1.24 2005/11/29 05:42:17 tedu Exp $ */
+/* $OpenBSD: cs4280.c,v 1.25 2006/04/07 22:41:33 jsg Exp $ */
/* $NetBSD: cs4280.c,v 1.5 2000/06/26 04:56:23 simonb Exp $ */
/*
@@ -277,8 +277,9 @@ struct midi_hw_if cs4280_midi_hw_if = {
cs4280_midi_open,
cs4280_midi_close,
cs4280_midi_output,
+ 0, /* flush */
cs4280_midi_getinfo,
- 0,
+ 0, /* ioctl */
};
#endif
diff --git a/sys/dev/pci/eap.c b/sys/dev/pci/eap.c
index 66a4ed5dc0e..177cda3f732 100644
--- a/sys/dev/pci/eap.c
+++ b/sys/dev/pci/eap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eap.c,v 1.28 2005/08/09 04:10:11 mickey Exp $ */
+/* $OpenBSD: eap.c,v 1.29 2006/04/07 22:41:33 jsg Exp $ */
/* $NetBSD: eap.c,v 1.46 2001/09/03 15:07:37 reinoud Exp $ */
/*
@@ -272,6 +272,7 @@ struct midi_hw_if eap_midi_hw_if = {
eap_midi_open,
eap_midi_close,
eap_midi_output,
+ 0, /* flush */
eap_midi_getinfo,
0, /* ioctl */
};
diff --git a/sys/dev/usb/umidi.c b/sys/dev/usb/umidi.c
index 582e54cb5ef..8731d5c445f 100644
--- a/sys/dev/usb/umidi.c
+++ b/sys/dev/usb/umidi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: umidi.c,v 1.14 2005/11/21 18:16:44 millert Exp $ */
+/* $OpenBSD: umidi.c,v 1.15 2006/04/07 22:41:33 jsg Exp $ */
/* $NetBSD: umidi.c,v 1.16 2002/07/11 21:14:32 augustss Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -76,6 +76,7 @@ static int umidi_open(void *, int,
void (*)(void *, int), void (*)(void *), void *);
static void umidi_close(void *);
static int umidi_output(void *, int);
+static void umidi_flush(void *);
static void umidi_getinfo(void *, struct midi_info *);
static usbd_status alloc_pipe(struct umidi_endpoint *);
@@ -121,15 +122,17 @@ static void init_packet(struct umidi_packet *);
static usbd_status start_input_transfer(struct umidi_endpoint *);
static usbd_status start_output_transfer(struct umidi_endpoint *);
static int out_jack_output(struct umidi_jack *, int);
+static void out_jack_flush(struct umidi_jack *);
static void in_intr(usbd_xfer_handle, usbd_private_handle, usbd_status);
static void out_intr(usbd_xfer_handle, usbd_private_handle, usbd_status);
-static int out_build_packet(int, struct umidi_packet *, uByte);
+static int out_build_packet(int, struct umidi_packet *, uByte, u_char *);
struct midi_hw_if umidi_hw_if = {
umidi_open,
umidi_close,
umidi_output,
+ umidi_flush, /* flush */
umidi_getinfo,
0, /* ioctl */
};
@@ -323,6 +326,17 @@ umidi_output(void *addr, int d)
}
void
+umidi_flush(void *addr)
+{
+ struct umidi_mididev *mididev = addr;
+
+ if (!mididev->out_jack || !mididev->opened)
+ return;
+
+ return out_jack_flush(mididev->out_jack);
+}
+
+void
umidi_getinfo(void *addr, struct midi_info *mi)
{
struct umidi_mididev *mididev = addr;
@@ -346,7 +360,10 @@ alloc_pipe(struct umidi_endpoint *ep)
usbd_status err;
DPRINTF(("%s: alloc_pipe %p\n", USBDEVNAME(sc->sc_dev), ep));
- TAILQ_INIT(&ep->queue_head);
+ SIMPLEQ_INIT(&ep->intrq);
+ ep->pending = 0;
+ ep->busy = 0;
+ ep->used = 0;
ep->xfer = usbd_alloc_xfer(sc->sc_udev);
if (ep->xfer == NULL) {
return USBD_NOMEM;
@@ -477,7 +494,6 @@ alloc_all_endpoints_fixed_ep(struct umidi_softc *sc)
sc->sc_out_num_jacks += fp->out_ep[i].num_jacks;
ep->num_open = 0;
memset(ep->jacks, 0, sizeof(ep->jacks));
- TAILQ_INIT(&ep->queue_head);
ep++;
}
ep = &sc->sc_in_ep[0];
@@ -594,7 +610,7 @@ alloc_all_endpoints_yamaha(struct umidi_softc *sc)
sc->sc_out_ep = sc->sc_endpoints;
sc->sc_out_ep->sc = sc;
sc->sc_out_ep->addr = out_addr;
- sc->sc_out_ep->packetsize = UMIDI_PACKET_SIZE;
+ sc->sc_out_ep->packetsize = UGETW(epd->wMaxPacketSize);
sc->sc_out_ep->num_jacks = sc->sc_out_num_jacks;
sc->sc_out_ep->num_open = 0;
memset(sc->sc_out_ep->jacks, 0, sizeof(sc->sc_out_ep->jacks));
@@ -736,6 +752,9 @@ alloc_all_jacks(struct umidi_softc *sc)
jack->binded = 0;
jack->arg = NULL;
jack->u.out.intr = NULL;
+#ifdef DIAGNOSTIC
+ jack->wait = 0;
+#endif
jack->cable_number = i;
jack++;
}
@@ -897,11 +916,6 @@ static void
close_out_jack(struct umidi_jack *jack)
{
if (jack->opened) {
-#ifdef UMIDI_DEBUG
- if (!TAILQ_EMPTY(&jack->endpoint->queue_head)) {
- printf("close_out_jack: queue_head still not empty\n");
- }
-#endif
jack->opened = 0;
jack->endpoint->num_open--;
}
@@ -1125,7 +1139,7 @@ start_output_transfer(struct umidi_endpoint *ep)
usbd_status err;
usbd_setup_xfer(ep->xfer, ep->pipe,
(usbd_private_handle)ep,
- ep->buffer, UMIDI_PACKET_SIZE,
+ ep->buffer, ep->used,
USBD_NO_COPY, USBD_NO_TIMEOUT, out_intr);
err = usbd_transfer(ep->xfer);
if (err != USBD_NORMAL_COMPLETION && err != USBD_IN_PROGRESS) {
@@ -1133,9 +1147,11 @@ start_output_transfer(struct umidi_endpoint *ep)
USBDEVNAME(ep->sc->sc_dev), usbd_errstr(err)));
return err;
}
+ ep->used = ep->packetsize;
return USBD_NORMAL_COMPLETION;
}
+
#ifdef UMIDI_DEBUG
#define DPR_PACKET(dir, sc, p) \
DPRINTFN(500, \
@@ -1150,40 +1166,84 @@ start_output_transfer(struct umidi_endpoint *ep)
#endif
static int
-out_jack_output(struct umidi_jack *out_jack, int d)
+out_jack_output(struct umidi_jack *j, int d)
{
- struct umidi_endpoint *ep = out_jack->endpoint;
+ struct umidi_endpoint *ep = j->endpoint;
struct umidi_softc *sc = ep->sc;
int s;
if (sc->sc_dying)
return EIO;
-
- if (!out_jack->opened) {
+ if (!j->opened)
return ENODEV;
- }
-
- if (out_build_packet(out_jack->cable_number, &out_jack->packet, d)) {
- DPR_PACKET(out, sc, &out_jack->packet);
- s = splusb();
- if (TAILQ_EMPTY(&ep->queue_head)) {
- memcpy(ep->buffer,
- out_jack->packet.buffer,
- UMIDI_PACKET_SIZE);
- TAILQ_INSERT_TAIL(&ep->queue_head,
- out_jack, u.out.queue_entry);
- start_output_transfer(ep);
+
+ s = splusb();
+ if (ep->used == ep->packetsize) {
+#ifdef DIAGNOSTIC
+ if (j->wait == 0) {
+ j->wait = 1;
+#endif
+ SIMPLEQ_INSERT_TAIL(&ep->intrq, j, intrq_entry);
+ ep->pending++;
+#ifdef DIAGNOSTIC
} else {
- DPRINTF(("%s: out_jack_output: packet ignored\n", USBDEVNAME(sc->sc_dev)));
+ printf("umidi: (again) %d: already on intrq\n",
+ j->cable_number);
}
+#endif
splx(s);
- return 0;
+ return EAGAIN;
}
- return EINPROGRESS;
+ if (!out_build_packet(j->cable_number, &j->packet, d,
+ ep->buffer + ep->used)) {
+ splx(s);
+ return EINPROGRESS;
+ }
+ ep->used += UMIDI_PACKET_SIZE;
+ if (ep->used < ep->packetsize) {
+ splx(s);
+ return EINPROGRESS;
+ }
+#ifdef DIAGNOSTIC
+ if (j->wait == 0) {
+ j->wait = 1;
+#endif
+ SIMPLEQ_INSERT_TAIL(&ep->intrq, j, intrq_entry);
+ ep->pending++;
+#ifdef DIAGNOSTIC
+ } else {
+ printf("umidi: (ok) %d: already on intrq\n",
+ j->cable_number);
+ }
+#endif
+ if (!ep->busy) {
+ ep->busy = 1;
+ start_output_transfer(ep);
+ }
+ splx(s);
+ return 0;
}
static void
+out_jack_flush(struct umidi_jack *j)
+{
+ struct umidi_endpoint *ep = j->endpoint;
+ int s;
+
+ if (ep->sc->sc_dying || !j->opened)
+ return;
+
+ s = splusb();
+ if (ep->used != 0 && !ep->busy) {
+ ep->busy = 1;
+ start_output_transfer(ep);
+ }
+ splx(s);
+}
+
+
+static void
in_intr(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
{
int cn, evlen, remain, i;
@@ -1196,9 +1256,9 @@ in_intr(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
usbd_get_xfer_status(xfer, NULL, NULL, &remain, NULL);
if (status != USBD_NORMAL_COMPLETION) {
- DPRINTF(("umidi: in_intr: abnormal status: %s\n", usbd_errstr(status)));
- goto quit;
- }
+ DPRINTF(("in_intr: abnormal status: %s\n", usbd_errstr(status)));
+ return;
+ }
buf = ep->buffer;
while (remain >= UMIDI_PACKET_SIZE) {
cn = GET_CN(buf[0]);
@@ -1207,21 +1267,10 @@ in_intr(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
evlen = packet_length[GET_CIN(buf[0])];
for (i=0; i<evlen; i++)
(*jack->u.in.intr)(jack->arg, buf[i+1]);
- } else
- DPRINTFN(10, ("in_intr: unused packet %02x %02x %02x %02x\n",
- buf[0], buf[1], buf[2], buf[3]));
-
+ }
buf += UMIDI_PACKET_SIZE;
remain -= UMIDI_PACKET_SIZE;
}
-
-#ifdef UMIDI_DEBUG
- if (remain != 0) {
- DPRINTF(("umidi: in_intr: remain != 0\n"));
- }
-#endif
-
-quit:
(void)start_input_transfer(ep);
}
@@ -1230,26 +1279,35 @@ out_intr(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
{
struct umidi_endpoint *ep = (struct umidi_endpoint *)priv;
struct umidi_softc *sc = ep->sc;
- struct umidi_jack *jack;
- int s;
+ struct umidi_jack *j;
+ unsigned pending;
if (sc->sc_dying)
return;
- s = splusb();
- jack = TAILQ_FIRST(&ep->queue_head);
- if (jack) {
- TAILQ_REMOVE(&ep->queue_head, jack, u.out.queue_entry);
- if (!TAILQ_EMPTY(&ep->queue_head)) {
- memcpy(ep->buffer,
- TAILQ_FIRST(&ep->queue_head)->packet.buffer,
- UMIDI_PACKET_SIZE);
- (void)start_output_transfer(ep);
+ ep->used = 0;
+ for (pending = ep->pending; pending > 0; pending--) {
+ j = SIMPLEQ_FIRST(&ep->intrq);
+#ifdef DIAGNOSTIC
+ if (j == NULL) {
+ printf("umidi: missing intr entry\n");
+ break;
}
- if (jack->opened && jack->u.out.intr)
- (*jack->u.out.intr)(jack->arg);
+#endif
+ SIMPLEQ_REMOVE_HEAD(&ep->intrq, intrq_entry);
+ ep->pending--;
+#ifdef DIAGNOSTIC
+ j->wait = 0;
+#endif
+ if (j->opened && j->u.out.intr)
+ (*j->u.out.intr)(j->arg);
+ }
+
+ if (ep->used == 0) {
+ ep->busy = 0;
+ } else {
+ start_output_transfer(ep);
}
- splx(s);
}
#define UMIDI_VOICELEN(status) (umidi_evlen[((status) >> 4) & 7])
@@ -1263,20 +1321,20 @@ unsigned umidi_evlen[] = { 4, 4, 4, 4, 3, 3, 4 };
#define EV_SYSEX_STOP 0xf7
static int
-out_build_packet(int cable_number, struct umidi_packet *packet, uByte data)
+out_build_packet(int cable_number, struct umidi_packet *packet,
+ uByte data, u_char *obuf)
{
if (data >= 0xf8) { /* is it a realtime message ? */
- packet->buffer_rt[0] = data >> 4 | cable_number << 4;
- packet->buffer_rt[1] = data;
- packet->buffer_rt[2] = 0;
- packet->buffer_rt[3] = 0;
- packet->buffer = packet->buffer_rt;
+ obuf[0] = data >> 4 | cable_number << 4;
+ obuf[1] = data;
+ obuf[2] = 0;
+ obuf[3] = 0;
return 1;
}
if (data >= 0xf0) { /* is it a common message ? */
switch(data) {
case EV_SYSEX:
- packet->buffer_com[1] = packet->status = data;
+ packet->buf[1] = packet->status = data;
packet->index = 2;
break;
case EV_SYSEX_STOP:
@@ -1284,12 +1342,12 @@ out_build_packet(int cable_number, struct umidi_packet *packet, uByte data)
if (packet->index == 0)
packet->index = 1;
packet->status = data;
- packet->buffer_com[packet->index++] = data;
- packet->buffer_com[0] = (0x4 - 1 + packet->index) | cable_number << 4;
+ packet->buf[packet->index++] = data;
+ packet->buf[0] = (0x4 - 1 + packet->index) | cable_number << 4;
goto packetready;
case EV_TUNE_REQ:
packet->status = data;
- packet->buffer_com[0] = 0x5 | cable_number << 4;
+ packet->buf[0] = 0x5 | cable_number << 4;
packet->index = 1;
goto packetready;
default:
@@ -1311,27 +1369,27 @@ out_build_packet(int cable_number, struct umidi_packet *packet, uByte data)
if (packet->index == 0)
packet->index = 1;
- packet->buffer_com[packet->index++] = data;
+ packet->buf[packet->index++] = data;
if (packet->index >= UMIDI_PACKET_SIZE) {
- packet->buffer_com[0] = 0x4 | cable_number << 4;
+ packet->buf[0] = 0x4 | cable_number << 4;
goto packetready;
}
break;
case EV_MTC: /* messages with 1 data byte */
case EV_SONGSEL:
- packet->buffer_com[0] = 0x2 | cable_number << 4;
- packet->buffer_com[1] = packet->status;
- packet->buffer_com[2] = data;
+ packet->buf[0] = 0x2 | cable_number << 4;
+ packet->buf[1] = packet->status;
+ packet->buf[2] = data;
packet->index = 3;
goto packetready;
case EV_SPP: /* messages with 2 data bytes */
if (packet->index == 0) {
- packet->buffer_com[0] = 0x3 | cable_number << 4;
+ packet->buf[0] = 0x3 | cable_number << 4;
packet->index = 1;
}
- packet->buffer_com[packet->index++] = data;
+ packet->buf[packet->index++] = data;
if (packet->index >= UMIDI_PACKET_SIZE) {
- packet->buffer_com[1] = packet->status;
+ packet->buf[1] = packet->status;
goto packetready;
}
break;
@@ -1342,11 +1400,11 @@ out_build_packet(int cable_number, struct umidi_packet *packet, uByte data)
}
if (packet->status >= 0x80) { /* is it a voice message ? */
if (packet->index == 0) {
- packet->buffer_com[0] = packet->status >> 4 | cable_number << 4;
- packet->buffer_com[1] = packet->status;
+ packet->buf[0] = packet->status >> 4 | cable_number << 4;
+ packet->buf[1] = packet->status;
packet->index = 2;
}
- packet->buffer_com[packet->index++] = data;
+ packet->buf[packet->index++] = data;
if (packet->index >= UMIDI_VOICELEN(packet->status))
goto packetready;
}
@@ -1355,9 +1413,8 @@ out_build_packet(int cable_number, struct umidi_packet *packet, uByte data)
packetready:
while (packet->index < UMIDI_PACKET_SIZE)
- packet->buffer_com[packet->index++] = 0;
-
+ packet->buf[packet->index++] = 0;
packet->index = 0;
- packet->buffer = packet->buffer_com;
+ memcpy(obuf, packet->buf, UMIDI_PACKET_SIZE);
return 1;
}
diff --git a/sys/dev/usb/umidivar.h b/sys/dev/usb/umidivar.h
index 77889e386fe..3cfec867fa5 100644
--- a/sys/dev/usb/umidivar.h
+++ b/sys/dev/usb/umidivar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: umidivar.h,v 1.9 2005/09/07 06:57:09 jsg Exp $ */
+/* $OpenBSD: umidivar.h,v 1.10 2006/04/07 22:41:33 jsg Exp $ */
/* $NetBSD: umidivar.h,v 1.5 2002/09/12 21:00:42 augustss Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -40,9 +40,7 @@
struct umidi_packet {
unsigned status;
unsigned index;
- unsigned char buffer_rt[UMIDI_PACKET_SIZE]; /* real time packet */
- unsigned char buffer_com[UMIDI_PACKET_SIZE]; /* common/voice packet */
- unsigned char *buffer;
+ unsigned char buf[UMIDI_PACKET_SIZE]; /* common/voice packet */
};
/*
@@ -76,13 +74,16 @@ struct umidi_jack {
void *arg;
int binded;
int opened;
+ SIMPLEQ_ENTRY(umidi_jack) intrq_entry;
+#ifdef DIAGNOSTIC
+ unsigned wait;
+#endif
union {
struct {
- void (*intr)(void *);
- TAILQ_ENTRY(umidi_jack) queue_entry;
+ void (*intr)(void *);
} out;
struct {
- void (*intr)(void *, int);
+ void (*intr)(void *, int);
} in;
} u;
};
@@ -100,7 +101,10 @@ struct umidi_endpoint {
int num_open;
int num_jacks;
struct umidi_jack *jacks[UMIDI_MAX_EPJACKS];
- TAILQ_HEAD(, umidi_jack) queue_head;
+ unsigned used;
+ unsigned busy;
+ unsigned pending;
+ SIMPLEQ_HEAD(, umidi_jack) intrq;
};
/* software context */