ALSA: firewire-lib: obsolete ctx_data.tx.first_dbc with CIP_UNALIGHED_DBC flag
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Mon, 22 Jul 2019 03:36:51 +0000 (12:36 +0900)
committerTakashi Iwai <tiwai@suse.de>
Mon, 22 Jul 2019 14:04:55 +0000 (16:04 +0200)
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>
sound/firewire/amdtp-am824.c
sound/firewire/amdtp-stream.c
sound/firewire/amdtp-stream.h
sound/firewire/fireworks/fireworks_stream.c

index fd5d6b8ac557aa57035ddd66b0a83ba7dc7ea8bd..99c567ded7a3e966d8436a122bf19698d1055f37 100644 (file)
@@ -315,12 +315,16 @@ static void read_midi_messages(struct amdtp_stream *s,
                               __be32 *buffer, unsigned int frames)
 {
        struct amdtp_am824 *p = s->protocol;
-       unsigned int f, port;
        int len;
        u8 *b;
+       int f;
 
        for (f = 0; f < frames; f++) {
-               port = (8 - s->ctx_data.tx.first_dbc + s->data_block_counter + f) % 8;
+               unsigned int port = f;
+
+               if (!(s->flags & CIP_UNALIGHED_DBC))
+                       port += s->data_block_counter;
+               port %= 8;
                b = (u8 *)&buffer[p->midi_position];
 
                len = b[0] - 0x80;
index 4d71d74707cff531fd280d4afb3e394f3afadf5a..fc1e8e5b9429e1003d6ce5511b85dd10d6055bdf 100644 (file)
@@ -584,8 +584,7 @@ static int check_cip_header(struct amdtp_stream *s, const __be32 *buf,
            s->data_block_counter != UINT_MAX)
                *dbc = s->data_block_counter;
 
-       if (((s->flags & CIP_SKIP_DBC_ZERO_CHECK) &&
-            *dbc == s->ctx_data.tx.first_dbc) ||
+       if ((*dbc == 0x00 && (s->flags & CIP_SKIP_DBC_ZERO_CHECK)) ||
            s->data_block_counter == UINT_MAX) {
                lost = false;
        } else if (!(s->flags & CIP_DBC_IS_END_EVENT)) {
index 3942894c11ac2e319d30b0e86220579f668149b2..5d611122312bbab28266535ef77e420068449737 100644 (file)
@@ -33,6 +33,8 @@
  * @CIP_HEADER_WITHOUT_EOH: Only for in-stream. CIP Header doesn't include
  *     valid EOH.
  * @CIP_NO_HEADERS: a lack of headers in packets
+ * @CIP_UNALIGHED_DBC: Only for in-stream. The value of dbc is not alighed to
+ *     the value of current SYT_INTERVAL; e.g. initial value is not zero.
  */
 enum cip_flags {
        CIP_NONBLOCKING         = 0x00,
@@ -45,6 +47,7 @@ enum cip_flags {
        CIP_JUMBO_PAYLOAD       = 0x40,
        CIP_HEADER_WITHOUT_EOH  = 0x80,
        CIP_NO_HEADER           = 0x100,
+       CIP_UNALIGHED_DBC       = 0x200,
 };
 
 /**
@@ -119,8 +122,6 @@ struct amdtp_stream {
                        // Fixed interval of dbc between previos/current
                        // packets.
                        unsigned int dbc_interval;
-                       // Indicate the value of dbc field in a first packet.
-                       unsigned int first_dbc;
                } tx;
                struct {
                        // To calculate CIP data blocks and tstamp.
index e659a0b89ba5b0c784185cc65a049b94dd94b610..385fc9686365a669ce5e80b1fb49b9cbf11b93de 100644 (file)
@@ -146,7 +146,7 @@ int snd_efw_stream_init_duplex(struct snd_efw *efw)
            (efw->firmware_version == 0x5070000 ||
             efw->firmware_version == 0x5070300 ||
             efw->firmware_version == 0x5080000))
-               efw->tx_stream.ctx_data.tx.first_dbc = 0x02;
+               efw->tx_stream.flags |= CIP_UNALIGHED_DBC;
        /* AudioFire9 always reports wrong dbs. */
        if (efw->is_af9)
                efw->tx_stream.flags |= CIP_WRONG_DBS;