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 15/20] ALSA: firewire-digi00x: code refactoring for DOT data block processing layer
Date: Mon, 22 Jul 2019 12:37:05 +0900	[thread overview]
Message-ID: <20190722033710.28107-16-o-takashi@sakamocchi.jp> (raw)
In-Reply-To: <20190722033710.28107-1-o-takashi@sakamocchi.jp>

This is code refactoring for DOT data block processing layer so that
it can receive list of packet descriptor.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 sound/firewire/digi00x/amdtp-dot.c | 45 +++++++++++++++++++-----------
 1 file changed, 28 insertions(+), 17 deletions(-)

diff --git a/sound/firewire/digi00x/amdtp-dot.c b/sound/firewire/digi00x/amdtp-dot.c
index 83ac4b37f26d..cef5caf97236 100644
--- a/sound/firewire/digi00x/amdtp-dot.c
+++ b/sound/firewire/digi00x/amdtp-dot.c
@@ -143,17 +143,23 @@ int amdtp_dot_set_parameters(struct amdtp_stream *s, unsigned int rate,
 }
 
 static void write_pcm_s32(struct amdtp_stream *s, struct snd_pcm_substream *pcm,
-			  __be32 *buffer, unsigned int frames)
+			  __be32 *buffer, unsigned int frames,
+			  unsigned int pcm_frames)
 {
 	struct amdtp_dot *p = s->protocol;
+	unsigned int channels = p->pcm_channels;
 	struct snd_pcm_runtime *runtime = pcm->runtime;
-	unsigned int channels, remaining_frames, i, c;
+	unsigned int pcm_buffer_pointer;
+	int remaining_frames;
 	const u32 *src;
+	int i, c;
+
+	pcm_buffer_pointer = s->pcm_buffer_pointer + pcm_frames;
+	pcm_buffer_pointer %= runtime->buffer_size;
 
-	channels = p->pcm_channels;
 	src = (void *)runtime->dma_area +
-			frames_to_bytes(runtime, s->pcm_buffer_pointer);
-	remaining_frames = runtime->buffer_size - s->pcm_buffer_pointer;
+				frames_to_bytes(runtime, pcm_buffer_pointer);
+	remaining_frames = runtime->buffer_size - pcm_buffer_pointer;
 
 	buffer++;
 	for (i = 0; i < frames; ++i) {
@@ -169,17 +175,23 @@ static void write_pcm_s32(struct amdtp_stream *s, struct snd_pcm_substream *pcm,
 }
 
 static void read_pcm_s32(struct amdtp_stream *s, struct snd_pcm_substream *pcm,
-			 __be32 *buffer, unsigned int frames)
+			 __be32 *buffer, unsigned int frames,
+			 unsigned int pcm_frames)
 {
 	struct amdtp_dot *p = s->protocol;
+	unsigned int channels = p->pcm_channels;
 	struct snd_pcm_runtime *runtime = pcm->runtime;
-	unsigned int channels, remaining_frames, i, c;
+	unsigned int pcm_buffer_pointer;
+	int remaining_frames;
 	u32 *dst;
+	int i, c;
+
+	pcm_buffer_pointer = s->pcm_buffer_pointer + pcm_frames;
+	pcm_buffer_pointer %= runtime->buffer_size;
 
-	channels = p->pcm_channels;
 	dst  = (void *)runtime->dma_area +
-			frames_to_bytes(runtime, s->pcm_buffer_pointer);
-	remaining_frames = runtime->buffer_size - s->pcm_buffer_pointer;
+				frames_to_bytes(runtime, pcm_buffer_pointer);
+	remaining_frames = runtime->buffer_size - pcm_buffer_pointer;
 
 	buffer++;
 	for (i = 0; i < frames; ++i) {
@@ -333,13 +345,12 @@ static unsigned int process_tx_data_blocks(struct amdtp_stream *s,
 					   const struct pkt_desc *desc,
 					   struct snd_pcm_substream *pcm)
 {
-	unsigned int pcm_frames;
+	unsigned int pcm_frames = 0;
 
 	if (pcm) {
-		read_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks);
+		read_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks,
+			     pcm_frames);
 		pcm_frames = desc->data_blocks;
-	} else {
-		pcm_frames = 0;
 	}
 
 	read_midi_messages(s, desc->ctx_payload, desc->data_blocks);
@@ -351,14 +362,14 @@ static unsigned int process_rx_data_blocks(struct amdtp_stream *s,
 					   const struct pkt_desc *desc,
 					   struct snd_pcm_substream *pcm)
 {
-	unsigned int pcm_frames;
+	unsigned int pcm_frames = 0;
 
 	if (pcm) {
-		write_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks);
+		write_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks,
+			      pcm_frames);
 		pcm_frames = desc->data_blocks;
 	} else {
 		write_pcm_silence(s, desc->ctx_payload, desc->data_blocks);
-		pcm_frames = 0;
 	}
 
 	write_midi_messages(s, desc->ctx_payload, desc->data_blocks,
-- 
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 ` [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 ` Takashi Sakamoto [this message]
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-16-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.