staticint fill_message(struct snd_fw_async_midi_port *port, struct snd_rawmidi_substream *substream)
{ int i, len, consume;
u8 *label, *msg;
u8 status;
/* The first byte is used for label, the rest for MIDI bytes. */
label = port->buf;
msg = port->buf + 1;
consume = snd_rawmidi_transmit_peek(substream, msg, 3); if (consume == 0) return0;
/* On exclusive message. */ if (port->on_sysex) { /* Seek the end of exclusives. */ for (i = 0; i < consume; ++i) { if (msg[i] == 0xf7) {
port->on_sysex = false; break;
}
}
/* At the end of exclusive message, use label 0x07. */ if (!port->on_sysex) {
consume = i + 1;
*label = (substream->number << 4) | 0x07; /* During exclusive message, use label 0x04. */
} elseif (consume == 3) {
*label = (substream->number << 4) | 0x04; /* We need to fill whole 3 bytes. Go to next change. */
} else { return0;
}
len = consume;
} else { /* The beginning of exclusives. */ if (msg[0] == 0xf0) { /* Transfer it in next chance in another condition. */
port->on_sysex = true; return0;
} else { /* On running-status. */ if ((msg[0] & 0x80) != 0x80)
status = port->running_status; else
status = msg[0];
/* Calculate consume bytes. */
len = calculate_message_bytes(status); if (len <= 0) return0;
/* On running-status. */ if ((msg[0] & 0x80) != 0x80) { /* Enough MIDI bytes were not retrieved. */ if (consume < len - 1) return0;
consume = len - 1;
msg[2] = msg[1];
msg[1] = msg[0];
msg[0] = port->running_status;
} else { /* Enough MIDI bytes were not retrieved. */ if (consume < len) return0;
consume = len;
staticvoid handle_midi_tx(struct fw_card *card, struct fw_request *request, int tcode, int destination, int source, int generation, unsignedlonglong offset, void *data, size_t length, void *callback_data)
{ struct snd_tscm *tscm = callback_data;
u32 *buf = (u32 *)data; unsignedint messages; unsignedint i; unsignedint port; struct snd_rawmidi_substream *substream;
u8 *b; int bytes;
if (offset != tscm->async_handler.offset) goto end;
messages = length / 8; for (i = 0; i < messages; i++) {
b = (u8 *)(buf + i * 2);
port = b[0] >> 4; /* TODO: support virtual MIDI ports. */ if (port >= tscm->spec->midi_capture_ports) goto end;
/* Assume the message length. */
bytes = calculate_message_bytes(b[1]); /* On MIDI data or exclusives. */ if (bytes <= 0) { /* Seek the end of exclusives. */ for (bytes = 1; bytes < 4; bytes++) { if (b[bytes] == 0xf7) break;
} if (bytes == 4)
bytes = 3;
}
substream = READ_ONCE(tscm->tx_midi_substreams[port]); if (substream != NULL)
snd_rawmidi_receive(substream, b + 1, bytes);
}
end:
fw_send_response(card, request, RCODE_COMPLETE);
}
/* At bus reset, these registers are cleared. */ int snd_tscm_transaction_reregister(struct snd_tscm *tscm)
{ struct fw_device *device = fw_parent_device(tscm->unit);
__be32 reg; int err;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.