ALSA: firewire-lib: fix to process MIDI conformant data channel for AM824 format
In IEC 61883-6, 8 MIDI data streams are multiplexed into single MIDI
conformant data channel. The index of stream is calculated by modulo 8
of the value of data block counter. Therefore data block processing
layer requires valid value of data block counter.
In recent changes of ALSA IEC 61883-1/6 engine, the value of data block
counter is changed before calling data block processing layer. This
brings miss detection of MIDI messages in non-blocking transmission
method is used.
This commit fixes the bug by changing chached data block counter after
calling data block processing layer.
Fixes: e335425b65
("ALSA: firewire-lib: split helper function to check incoming CIP header")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
alistair/sunxi64-5.4-dsi
parent
76864868db
commit
973b059ca9
|
@ -614,11 +614,10 @@ static int check_cip_header(struct amdtp_stream *s, const __be32 *buf,
|
||||||
static int parse_ir_ctx_header(struct amdtp_stream *s, unsigned int cycle,
|
static int parse_ir_ctx_header(struct amdtp_stream *s, unsigned int cycle,
|
||||||
const __be32 *ctx_header,
|
const __be32 *ctx_header,
|
||||||
unsigned int *payload_length,
|
unsigned int *payload_length,
|
||||||
unsigned int *data_blocks,
|
unsigned int *data_blocks, unsigned int *dbc,
|
||||||
unsigned int *syt, unsigned int index)
|
unsigned int *syt, unsigned int index)
|
||||||
{
|
{
|
||||||
const __be32 *cip_header;
|
const __be32 *cip_header;
|
||||||
unsigned int dbc;
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
*payload_length = be32_to_cpu(ctx_header[0]) >> ISO_DATA_LENGTH_SHIFT;
|
*payload_length = be32_to_cpu(ctx_header[0]) >> ISO_DATA_LENGTH_SHIFT;
|
||||||
|
@ -633,32 +632,28 @@ static int parse_ir_ctx_header(struct amdtp_stream *s, unsigned int cycle,
|
||||||
if (!(s->flags & CIP_NO_HEADER)) {
|
if (!(s->flags & CIP_NO_HEADER)) {
|
||||||
cip_header = ctx_header + 2;
|
cip_header = ctx_header + 2;
|
||||||
err = check_cip_header(s, cip_header, *payload_length,
|
err = check_cip_header(s, cip_header, *payload_length,
|
||||||
data_blocks, &dbc, syt);
|
data_blocks, dbc, syt);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
if (err != -EAGAIN)
|
if (err != -EAGAIN)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
*data_blocks = 0;
|
*data_blocks = 0;
|
||||||
dbc = s->data_block_counter;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cip_header = NULL;
|
cip_header = NULL;
|
||||||
err = 0;
|
err = 0;
|
||||||
*data_blocks = *payload_length / sizeof(__be32) /
|
*data_blocks = *payload_length / sizeof(__be32) /
|
||||||
s->data_block_quadlets;
|
s->data_block_quadlets;
|
||||||
dbc = s->data_block_counter;
|
*dbc = s->data_block_counter;
|
||||||
*syt = 0;
|
*syt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err >= 0 && s->flags & CIP_DBC_IS_END_EVENT)
|
if (err >= 0 && s->flags & CIP_DBC_IS_END_EVENT)
|
||||||
s->data_block_counter = dbc;
|
s->data_block_counter = *dbc;
|
||||||
|
|
||||||
trace_amdtp_packet(s, cycle, cip_header, *payload_length, *data_blocks,
|
trace_amdtp_packet(s, cycle, cip_header, *payload_length, *data_blocks,
|
||||||
index);
|
index);
|
||||||
|
|
||||||
if (err >= 0 && !(s->flags & CIP_DBC_IS_END_EVENT))
|
|
||||||
s->data_block_counter = (dbc + *data_blocks) & 0xff;
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -761,7 +756,8 @@ static void in_stream_callback(struct fw_iso_context *context, u32 tstamp,
|
||||||
for (i = 0; i < packets; i++) {
|
for (i = 0; i < packets; i++) {
|
||||||
u32 cycle;
|
u32 cycle;
|
||||||
unsigned int payload_length;
|
unsigned int payload_length;
|
||||||
unsigned int data_block;
|
unsigned int data_blocks;
|
||||||
|
unsigned int dbc;
|
||||||
unsigned int syt;
|
unsigned int syt;
|
||||||
__be32 *buffer;
|
__be32 *buffer;
|
||||||
unsigned int pcm_frames = 0;
|
unsigned int pcm_frames = 0;
|
||||||
|
@ -771,13 +767,19 @@ static void in_stream_callback(struct fw_iso_context *context, u32 tstamp,
|
||||||
|
|
||||||
cycle = compute_cycle_count(ctx_header[1]);
|
cycle = compute_cycle_count(ctx_header[1]);
|
||||||
err = parse_ir_ctx_header(s, cycle, ctx_header, &payload_length,
|
err = parse_ir_ctx_header(s, cycle, ctx_header, &payload_length,
|
||||||
&data_block, &syt, i);
|
&data_blocks, &dbc, &syt, i);
|
||||||
if (err < 0 && err != -EAGAIN)
|
if (err < 0 && err != -EAGAIN)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (err >= 0) {
|
if (err >= 0) {
|
||||||
buffer = s->buffer.packets[s->packet_index].buffer;
|
buffer = s->buffer.packets[s->packet_index].buffer;
|
||||||
pcm_frames = s->process_data_blocks(s, buffer,
|
pcm_frames = s->process_data_blocks(s, buffer,
|
||||||
data_block, &syt);
|
data_blocks, &syt);
|
||||||
|
|
||||||
|
if (!(s->flags & CIP_DBC_IS_END_EVENT)) {
|
||||||
|
s->data_block_counter =
|
||||||
|
(dbc + data_blocks) & 0xff;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (queue_in_packet(s, ¶ms) < 0)
|
if (queue_in_packet(s, ¶ms) < 0)
|
||||||
|
|
Loading…
Reference in New Issue