summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2019-07-21 23:36:51 -0400
committerTakashi Iwai <tiwai@suse.de>2019-07-22 10:04:55 -0400
commit588f2e2caf6795ca29d50a45ea1e1438274e75e0 (patch)
treed73ca445224a9c07d1c81ab00a9ddeea87fb036f
parent4df4888b17c433255ec023df13261b3728d858ad (diff)
ALSA: firewire-lib: obsolete ctx_data.tx.first_dbc with CIP_UNALIGHED_DBC flag
Recent firmware for Fireworks board module have a quirk to start transmission of CIP with non-zero value for its data block counter. In current implementation of ALSA firewire stack, the quirk is handled by 'struct amdtp_stream.ctx_data.tx.first_dbc' with value 0x02. However, the value comes from reverse engineering. It's better to handle this quirk without the explicit value. In a process to parse CIP header, the quirk of data block counter affects decision of sequence index in sequence-multiplexed data channel; i.e. MIDI conformant data channel. In Fireworks, the index is decided by the number of data blocks from top of the same CIP, thus the value of data block counter is useless. This commit adds CIP_UNALIGHED_DBC flag and obsoletes the explicit value for this quirk. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/firewire/amdtp-am824.c8
-rw-r--r--sound/firewire/amdtp-stream.c3
-rw-r--r--sound/firewire/amdtp-stream.h5
-rw-r--r--sound/firewire/fireworks/fireworks_stream.c2
4 files changed, 11 insertions, 7 deletions
diff --git a/sound/firewire/amdtp-am824.c b/sound/firewire/amdtp-am824.c
index fd5d6b8ac557..99c567ded7a3 100644
--- a/sound/firewire/amdtp-am824.c
+++ b/sound/firewire/amdtp-am824.c
@@ -315,12 +315,16 @@ static void read_midi_messages(struct amdtp_stream *s,
315 __be32 *buffer, unsigned int frames) 315 __be32 *buffer, unsigned int frames)
316{ 316{
317 struct amdtp_am824 *p = s->protocol; 317 struct amdtp_am824 *p = s->protocol;
318 unsigned int f, port;
319 int len; 318 int len;
320 u8 *b; 319 u8 *b;
320 int f;
321 321
322 for (f = 0; f < frames; f++) { 322 for (f = 0; f < frames; f++) {
323 port = (8 - s->ctx_data.tx.first_dbc + s->data_block_counter + f) % 8; 323 unsigned int port = f;
324
325 if (!(s->flags & CIP_UNALIGHED_DBC))
326 port += s->data_block_counter;
327 port %= 8;
324 b = (u8 *)&buffer[p->midi_position]; 328 b = (u8 *)&buffer[p->midi_position];
325 329
326 len = b[0] - 0x80; 330 len = b[0] - 0x80;
diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c
index 4d71d74707cf..fc1e8e5b9429 100644
--- a/sound/firewire/amdtp-stream.c
+++ b/sound/firewire/amdtp-stream.c
@@ -584,8 +584,7 @@ static int check_cip_header(struct amdtp_stream *s, const __be32 *buf,
584 s->data_block_counter != UINT_MAX) 584 s->data_block_counter != UINT_MAX)
585 *dbc = s->data_block_counter; 585 *dbc = s->data_block_counter;
586 586
587 if (((s->flags & CIP_SKIP_DBC_ZERO_CHECK) && 587 if ((*dbc == 0x00 && (s->flags & CIP_SKIP_DBC_ZERO_CHECK)) ||
588 *dbc == s->ctx_data.tx.first_dbc) ||
589 s->data_block_counter == UINT_MAX) { 588 s->data_block_counter == UINT_MAX) {
590 lost = false; 589 lost = false;
591 } else if (!(s->flags & CIP_DBC_IS_END_EVENT)) { 590 } else if (!(s->flags & CIP_DBC_IS_END_EVENT)) {
diff --git a/sound/firewire/amdtp-stream.h b/sound/firewire/amdtp-stream.h
index 3942894c11ac..5d611122312b 100644
--- a/sound/firewire/amdtp-stream.h
+++ b/sound/firewire/amdtp-stream.h
@@ -33,6 +33,8 @@
33 * @CIP_HEADER_WITHOUT_EOH: Only for in-stream. CIP Header doesn't include 33 * @CIP_HEADER_WITHOUT_EOH: Only for in-stream. CIP Header doesn't include
34 * valid EOH. 34 * valid EOH.
35 * @CIP_NO_HEADERS: a lack of headers in packets 35 * @CIP_NO_HEADERS: a lack of headers in packets
36 * @CIP_UNALIGHED_DBC: Only for in-stream. The value of dbc is not alighed to
37 * the value of current SYT_INTERVAL; e.g. initial value is not zero.
36 */ 38 */
37enum cip_flags { 39enum cip_flags {
38 CIP_NONBLOCKING = 0x00, 40 CIP_NONBLOCKING = 0x00,
@@ -45,6 +47,7 @@ enum cip_flags {
45 CIP_JUMBO_PAYLOAD = 0x40, 47 CIP_JUMBO_PAYLOAD = 0x40,
46 CIP_HEADER_WITHOUT_EOH = 0x80, 48 CIP_HEADER_WITHOUT_EOH = 0x80,
47 CIP_NO_HEADER = 0x100, 49 CIP_NO_HEADER = 0x100,
50 CIP_UNALIGHED_DBC = 0x200,
48}; 51};
49 52
50/** 53/**
@@ -119,8 +122,6 @@ struct amdtp_stream {
119 // Fixed interval of dbc between previos/current 122 // Fixed interval of dbc between previos/current
120 // packets. 123 // packets.
121 unsigned int dbc_interval; 124 unsigned int dbc_interval;
122 // Indicate the value of dbc field in a first packet.
123 unsigned int first_dbc;
124 } tx; 125 } tx;
125 struct { 126 struct {
126 // To calculate CIP data blocks and tstamp. 127 // To calculate CIP data blocks and tstamp.
diff --git a/sound/firewire/fireworks/fireworks_stream.c b/sound/firewire/fireworks/fireworks_stream.c
index e659a0b89ba5..385fc9686365 100644
--- a/sound/firewire/fireworks/fireworks_stream.c
+++ b/sound/firewire/fireworks/fireworks_stream.c
@@ -146,7 +146,7 @@ int snd_efw_stream_init_duplex(struct snd_efw *efw)
146 (efw->firmware_version == 0x5070000 || 146 (efw->firmware_version == 0x5070000 ||
147 efw->firmware_version == 0x5070300 || 147 efw->firmware_version == 0x5070300 ||
148 efw->firmware_version == 0x5080000)) 148 efw->firmware_version == 0x5080000))
149 efw->tx_stream.ctx_data.tx.first_dbc = 0x02; 149 efw->tx_stream.flags |= CIP_UNALIGHED_DBC;
150 /* AudioFire9 always reports wrong dbs. */ 150 /* AudioFire9 always reports wrong dbs. */
151 if (efw->is_af9) 151 if (efw->is_af9)
152 efw->tx_stream.flags |= CIP_WRONG_DBS; 152 efw->tx_stream.flags |= CIP_WRONG_DBS;