All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: clemens@ladisch.de, tiwai@suse.de
Cc: alsa-devel@alsa-project.org
Subject: [PATCH 01/20] ALSA: firewire-lib: obsolete ctx_data.tx.first_dbc with CIP_UNALIGHED_DBC flag
Date: Mon, 22 Jul 2019 12:36:51 +0900	[thread overview]
Message-ID: <20190722033710.28107-2-o-takashi@sakamocchi.jp> (raw)
In-Reply-To: <20190722033710.28107-1-o-takashi@sakamocchi.jp>

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>
---
 sound/firewire/amdtp-am824.c                | 8 ++++++--
 sound/firewire/amdtp-stream.c               | 3 +--
 sound/firewire/amdtp-stream.h               | 5 +++--
 sound/firewire/fireworks/fireworks_stream.c | 2 +-
 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,
 			       __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;
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,
 	    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)) {
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 @@
  * @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.
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)
 	    (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;
-- 
2.20.1

  reply	other threads:[~2019-07-22  3:37 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-22  3:36 [PATCH 00/20] ALSA: firewire-lib: use packet descriptor to represent sequence of packet Takashi Sakamoto
2019-07-22  3:36 ` Takashi Sakamoto [this message]
2019-07-22  3:36 ` [PATCH 02/20] ALSA: firewire-lib: pass data block count as an argument to tracepoints event Takashi Sakamoto
2019-07-22  3:36 ` [PATCH 03/20] ALSA: firewire-lib: pass data block counter to data block processing layer Takashi Sakamoto
2019-07-22  3:36 ` [PATCH 04/20] ALSA: firewire-lib: operate data block counter in top level of processing for IT context Takashi Sakamoto
2019-07-22  3:36 ` [PATCH 05/20] ALSA: firewire-lib: operate data block counter in top level of processing for IR context Takashi Sakamoto
2019-07-22  3:36 ` [PATCH 06/20] ALSA: firewire-lib: add syt_override member for some protocols Takashi Sakamoto
2019-07-22  3:36 ` [PATCH 07/20] ALSA: firewire-lib: pass no syt information to data block processing layer Takashi Sakamoto
2019-07-22  3:36 ` [PATCH 08/20] ALSA: firewire-lib: add list of packet descriptor Takashi Sakamoto
2019-07-22  3:36 ` [PATCH 09/20] ALSA: firewire-lib: use packet descriptor for IT context Takashi Sakamoto
2019-07-22  3:37 ` [PATCH 10/20] ALSA: firewire-lib: use packet descriptor for IR context Takashi Sakamoto
2019-07-22  3:37 ` [PATCH 11/20] ALSA: firewire-lib: code refactoring to process PCM substream Takashi Sakamoto
2019-07-22  3:37 ` [PATCH 12/20] ALSA: firewire-lib: code refactoring to process context payloads Takashi Sakamoto
2019-07-22  3:37 ` [PATCH 13/20] ALSA: firewire-lib: pass packet descriptor to data block processing layer Takashi Sakamoto
2019-07-22  3:37 ` [PATCH 14/20] ALSA: firewire-lib: code refactoring for AM824 " Takashi Sakamoto
2019-07-22  3:37 ` [PATCH 15/20] ALSA: firewire-digi00x: code refactoring for DOT " Takashi Sakamoto
2019-07-22  3:37 ` [PATCH 16/20] ALSA: firewire-tascam: code refactoring for TASCAM " Takashi Sakamoto
2019-07-22  3:37 ` [PATCH 17/20] ALSA: firewire-motu: code refactoring for MOTU " Takashi Sakamoto
2019-07-22  3:37 ` [PATCH 18/20] ALSA: fireface: code refactoring for FF " Takashi Sakamoto
2019-07-22  3:37 ` [PATCH 19/20] ALSA: firewire-lib: process payload of isoc context according to packet descriptors Takashi Sakamoto
2019-07-22  3:37 ` [PATCH 20/20] ALSA: firewire-motu: more code refactoring for MOTU data block processing layer Takashi Sakamoto
2019-07-22 14:12 ` [PATCH 00/20] ALSA: firewire-lib: use packet descriptor to represent sequence of packet Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190722033710.28107-2-o-takashi@sakamocchi.jp \
    --to=o-takashi@sakamocchi.jp \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.