Takashi Sakamoto wrote:
For capturing/playbacking MIDI messages, this commit adds one MIDI conformant data channel. This channel supports 8 MPX-MIDI data streams then maximum number of supported MIDI ports is limited by 8.
And this commit allows to set PCM format even if AMDTP stream already starts. I suppose the case that PCM stream is going to be joined into AMDTP streams after AMDTP stream is already started by MIDI. Each driver must count how many MIDI substreams use AMDTP stream to stop AMDTP stream.
IEC 61883-6 refers to AMEI/MMA RP-027 for implementation of MIDI conformant data. In the specification, 'MIDI1.0-2x/3x-SPEED' mode are described with 'negotiation procedure' and 'encapsulation details'. But there is no specifications to define them. This module implement 'MIDI1.0-1x-SPEED' mode.
+++ b/sound/firewire/amdtp.c @@ -505,11 +509,46 @@ static void amdtp_fill_pcm_silence(struct amdtp_stream *s, static void amdtp_fill_midi(struct amdtp_stream *s,
- unsigned int f, port;
- u8 *b;
- for (f = 0; f < frames; f++) {
buffer[s->pcm_channels + 1] = 0x00;
This is a 32-bit value.
b = (u8 *)&buffer[s->pcm_channels + 1];
port = (s->data_block_counter + f) % 8;
if ((s->midi[port] == NULL) ||
(snd_rawmidi_transmit(s->midi[port], b + 1, 1) <= 0)) {
b[0] = 0x80;
b[1] = 0x00; /* confirm to be zero */
snd_rawmidi_transmit() will not write an unsused byte, and in any case, zero can be a valid MIDI data byte.
+static void amdtp_pull_midi(struct amdtp_stream *s,
__be32 *buffer, unsigned int frames)
+{
- for (f = 0; f < frames; f++) {
...
if (s->midi[port] == NULL)
continue;
snd_rawmidi_receive(s->midi[port], b + 1, len);
buffer += s->data_block_quadlets;
- }
The buffer pointer must be increased even when there is no active port.
+++ b/sound/firewire/amdtp.h /**
- amdtp_stream_pcm_running - check PCM stream is running or not
- @s: the AMDTP stream
- If this function returns true, PCM stream in the stream is running.
- */
+static inline bool amdtp_stream_pcm_running(struct amdtp_stream *s) +{
- return !IS_ERR_OR_NULL(s->pcm);
+}
fw_iso_context_create() can return an error code, but for s->pcm, all the IS_ERR stuff is not necessary. This should be a plain NULL check.
Regards, Clemens