aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/sound/midi
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/sound/midi')
-rw-r--r--sys/dev/sound/midi/midi.c164
-rw-r--r--sys/dev/sound/midi/mpu401.c15
2 files changed, 25 insertions, 154 deletions
diff --git a/sys/dev/sound/midi/midi.c b/sys/dev/sound/midi/midi.c
index 6753f864ba9c..e14a28557406 100644
--- a/sys/dev/sound/midi/midi.c
+++ b/sys/dev/sound/midi/midi.c
@@ -32,45 +32,30 @@
#include <sys/param.h>
#include <sys/systm.h>
-#include <sys/queue.h>
+#include <sys/conf.h>
+#include <sys/fcntl.h>
#include <sys/kernel.h>
+#include <sys/kobj.h>
#include <sys/lock.h>
+#include <sys/module.h>
#include <sys/mutex.h>
-#include <sys/proc.h>
-#include <sys/signalvar.h>
-#include <sys/conf.h>
+#include <sys/poll.h>
+#include <sys/queue.h>
#include <sys/selinfo.h>
-#include <sys/sysctl.h>
-#include <sys/malloc.h>
#include <sys/sx.h>
-#include <sys/proc.h>
-#include <sys/fcntl.h>
-#include <sys/types.h>
+#include <sys/sysctl.h>
#include <sys/uio.h>
-#include <sys/poll.h>
-#include <sys/sbuf.h>
-#include <sys/kobj.h>
-#include <sys/module.h>
#ifdef HAVE_KERNEL_OPTION_HEADERS
#include "opt_snd.h"
#endif
#include <dev/sound/midi/midi.h>
-#include "mpu_if.h"
-
#include <dev/sound/midi/midiq.h>
-MALLOC_DEFINE(M_MIDI, "midi buffers", "Midi data allocation area");
-
-#ifndef KOBJMETHOD_END
-#define KOBJMETHOD_END { NULL, NULL }
-#endif
-#define MIDI_DEV_MIDICTL 12
+#include "mpu_if.h"
-enum midi_states {
- MIDI_IN_START, MIDI_IN_SYSEX, MIDI_IN_DATA
-};
+MALLOC_DEFINE(M_MIDI, "midi buffers", "Midi data allocation area");
#define MIDI_NAMELEN 16
struct snd_midi {
@@ -90,12 +75,6 @@ struct snd_midi {
struct selinfo rsel, wsel;
int hiwat; /* QLEN(outq)>High-water -> disable
* writes from userland */
- enum midi_states inq_state;
- int inq_status, inq_left; /* Variables for the state machine in
- * Midi_in, this is to provide that
- * signals only get issued only
- * complete command packets. */
- struct proc *async;
struct cdev *dev;
TAILQ_ENTRY(snd_midi) link;
};
@@ -330,10 +309,8 @@ static int midi_lengths[] = {2, 2, 2, 2, 1, 1, 2, 0};
int
midi_in(struct snd_midi *m, uint8_t *buf, int size)
{
- /* int i, sig, enq; */
int used;
- /* uint8_t data; */
MIDI_DEBUG(5, printf("midi_in: m=%p size=%d\n", m, size));
/*
@@ -345,111 +322,22 @@ midi_in(struct snd_midi *m, uint8_t *buf, int size)
used = 0;
mtx_lock(&m->qlock);
-#if 0
- /*
- * Don't bother queuing if not in read mode. Discard everything and
- * return size so the caller doesn't freak out.
- */
-
- if (!(m->flags & M_RX))
- return size;
-
- for (i = sig = 0; i < size; i++) {
- data = buf[i];
- enq = 0;
- if (data == MIDI_ACK)
- continue;
-
- switch (m->inq_state) {
- case MIDI_IN_START:
- if (MIDI_IS_STATUS(data)) {
- switch (data) {
- case 0xf0: /* Sysex */
- m->inq_state = MIDI_IN_SYSEX;
- break;
- case 0xf1: /* MTC quarter frame */
- case 0xf3: /* Song select */
- m->inq_state = MIDI_IN_DATA;
- enq = 1;
- m->inq_left = 1;
- break;
- case 0xf2: /* Song position pointer */
- m->inq_state = MIDI_IN_DATA;
- enq = 1;
- m->inq_left = 2;
- break;
- default:
- if (MIDI_IS_COMMON(data)) {
- enq = 1;
- sig = 1;
- } else {
- m->inq_state = MIDI_IN_DATA;
- enq = 1;
- m->inq_status = data;
- m->inq_left = MIDI_LENGTH(data);
- }
- break;
- }
- } else if (MIDI_IS_STATUS(m->inq_status)) {
- m->inq_state = MIDI_IN_DATA;
- if (!MIDIQ_FULL(m->inq)) {
- used++;
- MIDIQ_ENQ(m->inq, &m->inq_status, 1);
- }
- enq = 1;
- m->inq_left = MIDI_LENGTH(m->inq_status) - 1;
- }
- break;
- /*
- * End of case MIDI_IN_START:
- */
-
- case MIDI_IN_DATA:
- enq = 1;
- if (--m->inq_left <= 0)
- sig = 1;/* deliver data */
- break;
- case MIDI_IN_SYSEX:
- if (data == MIDI_SYSEX_END)
- m->inq_state = MIDI_IN_START;
- break;
- }
-
- if (enq)
- if (!MIDIQ_FULL(m->inq)) {
- MIDIQ_ENQ(m->inq, &data, 1);
- used++;
- }
- /*
- * End of the state machines main "for loop"
- */
+ MIDI_DEBUG(6, printf("midi_in: len %jd avail %jd\n",
+ (intmax_t)MIDIQ_LEN(m->inq),
+ (intmax_t)MIDIQ_AVAIL(m->inq)));
+ if (MIDIQ_AVAIL(m->inq) > size) {
+ used = size;
+ MIDIQ_ENQ(m->inq, buf, size);
+ } else {
+ MIDI_DEBUG(4, printf("midi_in: Discarding data qu\n"));
+ mtx_unlock(&m->qlock);
+ return 0;
}
- if (sig) {
-#endif
- MIDI_DEBUG(6, printf("midi_in: len %jd avail %jd\n",
- (intmax_t)MIDIQ_LEN(m->inq),
- (intmax_t)MIDIQ_AVAIL(m->inq)));
- if (MIDIQ_AVAIL(m->inq) > size) {
- used = size;
- MIDIQ_ENQ(m->inq, buf, size);
- } else {
- MIDI_DEBUG(4, printf("midi_in: Discarding data qu\n"));
- mtx_unlock(&m->qlock);
- return 0;
- }
- if (m->rchan) {
- wakeup(&m->rchan);
- m->rchan = 0;
- }
- selwakeup(&m->rsel);
- if (m->async) {
- PROC_LOCK(m->async);
- kern_psignal(m->async, SIGIO);
- PROC_UNLOCK(m->async);
- }
-#if 0
+ if (m->rchan) {
+ wakeup(&m->rchan);
+ m->rchan = 0;
}
-#endif
+ selwakeup(&m->rsel);
mtx_unlock(&m->qlock);
return used;
}
@@ -484,11 +372,6 @@ midi_out(struct snd_midi *m, uint8_t *buf, int size)
m->wchan = 0;
}
selwakeup(&m->wsel);
- if (m->async) {
- PROC_LOCK(m->async);
- kern_psignal(m->async, SIGIO);
- PROC_UNLOCK(m->async);
- }
}
mtx_unlock(&m->qlock);
return used;
@@ -530,7 +413,6 @@ midi_open(struct cdev *i_dev, int flags, int mode, struct thread *td)
m->rchan = 0;
m->wchan = 0;
- m->async = 0;
if (flags & FREAD) {
m->flags |= M_RX | M_RXEN;
diff --git a/sys/dev/sound/midi/mpu401.c b/sys/dev/sound/midi/mpu401.c
index 224ebb1b01f4..7d3edb6323ef 100644
--- a/sys/dev/sound/midi/mpu401.c
+++ b/sys/dev/sound/midi/mpu401.c
@@ -27,17 +27,10 @@
*/
#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/queue.h>
-#include <sys/kernel.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>
-#include <sys/proc.h>
#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/kernel.h>
#include <sys/kobj.h>
-#include <sys/malloc.h>
-#include <sys/bus.h> /* to get driver_intr_t */
#ifdef HAVE_KERNEL_OPTION_HEADERS
#include "opt_snd.h"
@@ -49,10 +42,6 @@
#include "mpu_if.h"
#include "mpufoi_if.h"
-#ifndef KOBJMETHOD_END
-#define KOBJMETHOD_END { NULL, NULL }
-#endif
-
#define MPU_DATAPORT 0
#define MPU_CMDPORT 1
#define MPU_STATPORT 1