sound: Remove dead midi code

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This commit is contained in:
Christos Margiolis
2025-11-13 13:10:04 +01:00
parent 9d17b61b2f
commit e4b31985b5
+14 -123
View File
@@ -62,12 +62,6 @@
#include <dev/sound/midi/midiq.h>
MALLOC_DEFINE(M_MIDI, "midi buffers", "Midi data allocation area");
#define MIDI_DEV_MIDICTL 12
enum midi_states {
MIDI_IN_START, MIDI_IN_SYSEX, MIDI_IN_DATA
};
#define MIDI_NAMELEN 16
struct snd_midi {
KOBJ_FIELDS;
@@ -86,12 +80,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;
};
@@ -326,10 +314,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));
/*
@@ -341,111 +327,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;
}
@@ -480,11 +377,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;
@@ -526,7 +418,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;