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 13/20] ALSA: firewire-lib: pass packet descriptor to data block processing layer
Date: Mon, 22 Jul 2019 12:37:03 +0900	[thread overview]
Message-ID: <20190722033710.28107-14-o-takashi@sakamocchi.jp> (raw)
In-Reply-To: <20190722033710.28107-1-o-takashi@sakamocchi.jp>

This commit changes signature of callback function to call data block
processing layer with packet descriptor. At present, the layer is called
per packet.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 sound/firewire/amdtp-am824.c         | 32 +++++++++--------
 sound/firewire/amdtp-stream.c        |  6 ++--
 sound/firewire/amdtp-stream.h        |  5 ++-
 sound/firewire/digi00x/amdtp-dot.c   | 27 +++++++-------
 sound/firewire/fireface/amdtp-ff.c   | 23 ++++++------
 sound/firewire/motu/amdtp-motu.c     | 53 ++++++++++++++++------------
 sound/firewire/tascam/amdtp-tascam.c | 39 +++++++++++---------
 7 files changed, 97 insertions(+), 88 deletions(-)

diff --git a/sound/firewire/amdtp-am824.c b/sound/firewire/amdtp-am824.c
index 21068b23d528..ff089ffa3374 100644
--- a/sound/firewire/amdtp-am824.c
+++ b/sound/firewire/amdtp-am824.c
@@ -336,44 +336,46 @@ static void read_midi_messages(struct amdtp_stream *s, __be32 *buffer,
 }
 
 static unsigned int process_rx_data_blocks(struct amdtp_stream *s,
-				__be32 *buffer, unsigned int data_blocks,
-				unsigned int data_block_counter)
+					   const struct pkt_desc *desc,
+					   struct snd_pcm_substream *pcm)
 {
 	struct amdtp_am824 *p = s->protocol;
-	struct snd_pcm_substream *pcm = READ_ONCE(s->pcm);
 	unsigned int pcm_frames;
 
 	if (pcm) {
-		write_pcm_s32(s, pcm, buffer, data_blocks);
-		pcm_frames = data_blocks * p->frame_multiplier;
+		write_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks);
+		pcm_frames = desc->data_blocks * p->frame_multiplier;
 	} else {
-		write_pcm_silence(s, buffer, data_blocks);
+		write_pcm_silence(s, desc->ctx_payload, desc->data_blocks);
 		pcm_frames = 0;
 	}
 
-	if (p->midi_ports)
-		write_midi_messages(s, buffer, data_blocks, data_block_counter);
+	if (p->midi_ports) {
+		write_midi_messages(s, desc->ctx_payload, desc->data_blocks,
+				    desc->data_block_counter);
+	}
 
 	return pcm_frames;
 }
 
 static unsigned int process_tx_data_blocks(struct amdtp_stream *s,
-				__be32 *buffer, unsigned int data_blocks,
-				unsigned int data_block_counter)
+					   const struct pkt_desc *desc,
+					   struct snd_pcm_substream *pcm)
 {
 	struct amdtp_am824 *p = s->protocol;
-	struct snd_pcm_substream *pcm = READ_ONCE(s->pcm);
 	unsigned int pcm_frames;
 
 	if (pcm) {
-		read_pcm_s32(s, pcm, buffer, data_blocks);
-		pcm_frames = data_blocks * p->frame_multiplier;
+		read_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks);
+		pcm_frames = desc->data_blocks * p->frame_multiplier;
 	} else {
 		pcm_frames = 0;
 	}
 
-	if (p->midi_ports)
-		read_midi_messages(s, buffer, data_blocks, data_block_counter);
+	if (p->midi_ports) {
+		read_midi_messages(s, desc->ctx_payload, desc->data_blocks,
+				   desc->data_block_counter);
+	}
 
 	return pcm_frames;
 }
diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c
index 573265113a6f..db2feb68105c 100644
--- a/sound/firewire/amdtp-stream.c
+++ b/sound/firewire/amdtp-stream.c
@@ -768,13 +768,11 @@ static void process_ctx_payloads(struct amdtp_stream *s,
 
 	for (i = 0; i < packets; ++i) {
 		const struct pkt_desc *desc = descs + i;
-		struct snd_pcm_substream *pcm;
+		struct snd_pcm_substream *pcm = READ_ONCE(s->pcm);
 		unsigned int pcm_frames;
 
-		pcm_frames = s->process_data_blocks(s, desc->ctx_payload,
-				desc->data_blocks, desc->data_block_counter);
+		pcm_frames = s->process_data_blocks(s, desc, pcm);
 
-		pcm = READ_ONCE(s->pcm);
 		if (pcm && pcm_frames > 0)
 			update_pcm_pointers(s, pcm, pcm_frames);
 	}
diff --git a/sound/firewire/amdtp-stream.h b/sound/firewire/amdtp-stream.h
index 73c492c9a5d5..0e5b85100a04 100644
--- a/sound/firewire/amdtp-stream.h
+++ b/sound/firewire/amdtp-stream.h
@@ -105,9 +105,8 @@ struct pkt_desc {
 struct amdtp_stream;
 typedef unsigned int (*amdtp_stream_process_data_blocks_t)(
 						struct amdtp_stream *s,
-						__be32 *buffer,
-						unsigned int data_blocks,
-						unsigned int data_block_counter);
+						const struct pkt_desc *desc,
+						struct snd_pcm_substream *pcm);
 struct amdtp_stream {
 	struct fw_unit *unit;
 	enum cip_flags flags;
diff --git a/sound/firewire/digi00x/amdtp-dot.c b/sound/firewire/digi00x/amdtp-dot.c
index c296d1017ed3..83ac4b37f26d 100644
--- a/sound/firewire/digi00x/amdtp-dot.c
+++ b/sound/firewire/digi00x/amdtp-dot.c
@@ -330,42 +330,39 @@ void amdtp_dot_midi_trigger(struct amdtp_stream *s, unsigned int port,
 }
 
 static unsigned int process_tx_data_blocks(struct amdtp_stream *s,
-				__be32 *buffer, unsigned int data_blocks,
-				unsigned int data_block_counter)
+					   const struct pkt_desc *desc,
+					   struct snd_pcm_substream *pcm)
 {
-	struct snd_pcm_substream *pcm;
 	unsigned int pcm_frames;
 
-	pcm = READ_ONCE(s->pcm);
 	if (pcm) {
-		read_pcm_s32(s, pcm, buffer, data_blocks);
-		pcm_frames = data_blocks;
+		read_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks);
+		pcm_frames = desc->data_blocks;
 	} else {
 		pcm_frames = 0;
 	}
 
-	read_midi_messages(s, buffer, data_blocks);
+	read_midi_messages(s, desc->ctx_payload, desc->data_blocks);
 
 	return pcm_frames;
 }
 
 static unsigned int process_rx_data_blocks(struct amdtp_stream *s,
-				__be32 *buffer, unsigned int data_blocks,
-				unsigned int data_block_counter)
+					   const struct pkt_desc *desc,
+					   struct snd_pcm_substream *pcm)
 {
-	struct snd_pcm_substream *pcm;
 	unsigned int pcm_frames;
 
-	pcm = READ_ONCE(s->pcm);
 	if (pcm) {
-		write_pcm_s32(s, pcm, buffer, data_blocks);
-		pcm_frames = data_blocks;
+		write_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks);
+		pcm_frames = desc->data_blocks;
 	} else {
-		write_pcm_silence(s, buffer, data_blocks);
+		write_pcm_silence(s, desc->ctx_payload, desc->data_blocks);
 		pcm_frames = 0;
 	}
 
-	write_midi_messages(s, buffer, data_blocks, data_block_counter);
+	write_midi_messages(s, desc->ctx_payload, desc->data_blocks,
+			    desc->data_block_counter);
 
 	return pcm_frames;
 }
diff --git a/sound/firewire/fireface/amdtp-ff.c b/sound/firewire/fireface/amdtp-ff.c
index 31a60dff94ac..c36232fc4d3e 100644
--- a/sound/firewire/fireface/amdtp-ff.c
+++ b/sound/firewire/fireface/amdtp-ff.c
@@ -103,17 +103,18 @@ int amdtp_ff_add_pcm_hw_constraints(struct amdtp_stream *s,
 }
 
 static unsigned int process_rx_data_blocks(struct amdtp_stream *s,
-				__be32 *buffer, unsigned int data_blocks,
-				unsigned int data_block_counter)
+					   const struct pkt_desc *desc,
+					   struct snd_pcm_substream *pcm)
 {
-	struct snd_pcm_substream *pcm = READ_ONCE(s->pcm);
 	unsigned int pcm_frames;
 
 	if (pcm) {
-		write_pcm_s32(s, pcm, (__le32 *)buffer, data_blocks);
-		pcm_frames = data_blocks;
+		write_pcm_s32(s, pcm, (__le32 *)desc->ctx_payload,
+			      desc->data_blocks);
+		pcm_frames = desc->data_blocks;
 	} else {
-		write_pcm_silence(s, (__le32 *)buffer, data_blocks);
+		write_pcm_silence(s, (__le32 *)desc->ctx_payload,
+				  desc->data_blocks);
 		pcm_frames = 0;
 	}
 
@@ -121,15 +122,15 @@ static unsigned int process_rx_data_blocks(struct amdtp_stream *s,
 }
 
 static unsigned int process_tx_data_blocks(struct amdtp_stream *s,
-				__be32 *buffer, unsigned int data_blocks,
-				unsigned int data_block_counter)
+					   const struct pkt_desc *desc,
+					   struct snd_pcm_substream *pcm)
 {
-	struct snd_pcm_substream *pcm = READ_ONCE(s->pcm);
 	unsigned int pcm_frames;
 
 	if (pcm) {
-		read_pcm_s32(s, pcm, (__le32 *)buffer, data_blocks);
-		pcm_frames = data_blocks;
+		read_pcm_s32(s, pcm, (__le32 *)desc->ctx_payload,
+			     desc->data_blocks);
+		pcm_frames = desc->data_blocks;
 	} else {
 		pcm_frames = 0;
 	}
diff --git a/sound/firewire/motu/amdtp-motu.c b/sound/firewire/motu/amdtp-motu.c
index 30d5f87119cc..36ee2c1dd667 100644
--- a/sound/firewire/motu/amdtp-motu.c
+++ b/sound/firewire/motu/amdtp-motu.c
@@ -299,23 +299,27 @@ static void __maybe_unused copy_message(u64 *frames, __be32 *buffer,
 }
 
 static unsigned int process_tx_data_blocks(struct amdtp_stream *s,
-				__be32 *buffer, unsigned int data_blocks,
-				unsigned int data_block_counter)
+					   const struct pkt_desc *desc,
+					   struct snd_pcm_substream *pcm)
 {
 	struct amdtp_motu *p = s->protocol;
-	struct snd_pcm_substream *pcm;
+	unsigned int pcm_frames;
 
-	trace_data_block_sph(s, data_blocks, buffer);
-	trace_data_block_message(s, data_blocks, buffer);
+	trace_data_block_sph(s, desc->data_blocks, desc->ctx_payload);
+	trace_data_block_message(s, desc->data_blocks, desc->ctx_payload);
 
 	if (p->midi_ports)
-		read_midi_messages(s, buffer, data_blocks);
+		read_midi_messages(s, desc->ctx_payload, desc->data_blocks);
 
-	pcm = READ_ONCE(s->pcm);
-	if (data_blocks > 0 && pcm)
-		read_pcm_s32(s, pcm->runtime, buffer, data_blocks);
+	if (pcm) {
+		read_pcm_s32(s, pcm->runtime, desc->ctx_payload,
+			     desc->data_blocks);
+		pcm_frames = desc->data_blocks;
+	} else {
+		pcm_frames = 0;
+	}
 
-	return data_blocks;
+	return pcm_frames;
 }
 
 static inline void compute_next_elapse_from_start(struct amdtp_motu *p)
@@ -361,29 +365,32 @@ static void write_sph(struct amdtp_stream *s, __be32 *buffer,
 }
 
 static unsigned int process_rx_data_blocks(struct amdtp_stream *s,
-				__be32 *buffer, unsigned int data_blocks,
-				unsigned int data_block_counter)
+					   const struct pkt_desc *desc,
+					   struct snd_pcm_substream *pcm)
 {
 	struct amdtp_motu *p = (struct amdtp_motu *)s->protocol;
-	struct snd_pcm_substream *pcm;
+	unsigned int pcm_frames;
 
 	/* TODO: how to interact control messages between userspace? */
 
 	if (p->midi_ports)
-		write_midi_messages(s, buffer, data_blocks);
+		write_midi_messages(s, desc->ctx_payload, desc->data_blocks);
 
-	pcm = READ_ONCE(s->pcm);
-	if (pcm)
-		write_pcm_s32(s, pcm->runtime, buffer, data_blocks);
-	else
-		write_pcm_silence(s, buffer, data_blocks);
+	if (pcm) {
+		write_pcm_s32(s, pcm->runtime, desc->ctx_payload,
+			      desc->data_blocks);
+		pcm_frames = desc->data_blocks;
+	} else {
+		write_pcm_silence(s, desc->ctx_payload, desc->data_blocks);
+		pcm_frames = 0;
+	}
 
-	write_sph(s, buffer, data_blocks);
+	write_sph(s, desc->ctx_payload, desc->data_blocks);
 
-	trace_data_block_sph(s, data_blocks, buffer);
-	trace_data_block_message(s, data_blocks, buffer);
+	trace_data_block_sph(s, desc->data_blocks, desc->ctx_payload);
+	trace_data_block_message(s, desc->data_blocks, desc->ctx_payload);
 
-	return data_blocks;
+	return pcm_frames;
 }
 
 int amdtp_motu_init(struct amdtp_stream *s, struct fw_unit *unit,
diff --git a/sound/firewire/tascam/amdtp-tascam.c b/sound/firewire/tascam/amdtp-tascam.c
index bc1f2d2120b4..970b1c4a8ea6 100644
--- a/sound/firewire/tascam/amdtp-tascam.c
+++ b/sound/firewire/tascam/amdtp-tascam.c
@@ -166,33 +166,38 @@ static void read_status_messages(struct amdtp_stream *s,
 }
 
 static unsigned int process_tx_data_blocks(struct amdtp_stream *s,
-				__be32 *buffer, unsigned int data_blocks,
-				unsigned int data_block_counter)
+					   const struct pkt_desc *desc,
+					   struct snd_pcm_substream *pcm)
 {
-	struct snd_pcm_substream *pcm;
+	unsigned int pcm_frames;
 
-	pcm = READ_ONCE(s->pcm);
-	if (data_blocks > 0 && pcm)
-		read_pcm_s32(s, pcm, buffer, data_blocks);
+	if (pcm) {
+		read_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks);
+		pcm_frames = desc->data_blocks;
+	} else {
+		pcm_frames = 0;
+	}
 
-	read_status_messages(s, buffer, data_blocks);
+	read_status_messages(s, desc->ctx_payload, desc->data_blocks);
 
-	return data_blocks;
+	return pcm_frames;
 }
 
 static unsigned int process_rx_data_blocks(struct amdtp_stream *s,
-				__be32 *buffer, unsigned int data_blocks,
-				unsigned int data_block_counter)
+					   const struct pkt_desc *desc,
+					   struct snd_pcm_substream *pcm)
 {
-	struct snd_pcm_substream *pcm;
+	unsigned int pcm_frames;
 
-	pcm = READ_ONCE(s->pcm);
-	if (pcm)
-		write_pcm_s32(s, pcm, buffer, data_blocks);
-	else
-		write_pcm_silence(s, buffer, data_blocks);
+	if (pcm) {
+		write_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks);
+		pcm_frames = desc->data_blocks;
+	} else {
+		write_pcm_silence(s, desc->ctx_payload, desc->data_blocks);
+		pcm_frames = 0;
+	}
 
-	return data_blocks;
+	return pcm_frames;
 }
 
 int amdtp_tscm_init(struct amdtp_stream *s, struct fw_unit *unit,
-- 
2.20.1

  parent 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 ` [PATCH 01/20] ALSA: firewire-lib: obsolete ctx_data.tx.first_dbc with CIP_UNALIGHED_DBC flag Takashi Sakamoto
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 ` Takashi Sakamoto [this message]
2019-07-22  3:37 ` [PATCH 14/20] ALSA: firewire-lib: code refactoring for AM824 data block processing layer 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-14-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.