mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
To: alsa-devel@alsa-project.org, broonie@kernel.org
Cc: pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com,
	peter.ujfalusi@linux.intel.com,
	ranjani.sridharan@linux.intel.com,
	yung-chuan.liao@linux.intel.com, kai.vehmanen@linux.intel.com,
	linux-kernel@vger.kernel.org,
	Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>,
	Paul Olaru <paul.olaru@nxp.com>,
	Daniel Baluta <daniel.baluta@nxp.com>
Subject: [PATCH 1/2] ASoC: SOF: compress: Move sof_compr_copy functionality
Date: Mon, 22 Aug 2022 13:15:01 +0300	[thread overview]
Message-ID: <20220822101502.17644-2-laurentiu.mihalcea@nxp.com> (raw)
In-Reply-To: <20220822101502.17644-1-laurentiu.mihalcea@nxp.com>

Since we're preparing to add support for compress capture,
we need to move the content of sof_compr_copy into a
separate function which handles the playback direction just
like the initial sof_compr_copy.

Reviewed-by: Paul Olaru <paul.olaru@nxp.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
---
 sound/soc/sof/compress.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/sound/soc/sof/compress.c b/sound/soc/sof/compress.c
index 174b3d8e67dd..1b0b8b43723b 100644
--- a/sound/soc/sof/compress.c
+++ b/sound/soc/sof/compress.c
@@ -297,18 +297,13 @@ static int sof_compr_trigger(struct snd_soc_component *component,
 				  &reply, sizeof(reply));
 }
 
-static int sof_compr_copy(struct snd_soc_component *component,
-			  struct snd_compr_stream *cstream,
-			  char __user *buf, size_t count)
+static int sof_compr_copy_playback(struct snd_compr_runtime *rtd,
+				   char __user *buf, size_t count)
 {
-	struct snd_compr_runtime *rtd = cstream->runtime;
-	unsigned int offset, n;
 	void *ptr;
+	unsigned int offset, n;
 	int ret;
 
-	if (count > rtd->buffer_size)
-		count = rtd->buffer_size;
-
 	div_u64_rem(rtd->total_bytes_available, rtd->buffer_size, &offset);
 	ptr = rtd->dma_area + offset;
 	n = rtd->buffer_size - offset;
@@ -323,6 +318,18 @@ static int sof_compr_copy(struct snd_soc_component *component,
 	return count - ret;
 }
 
+static int sof_compr_copy(struct snd_soc_component *component,
+			  struct snd_compr_stream *cstream,
+			  char __user *buf, size_t count)
+{
+	struct snd_compr_runtime *rtd = cstream->runtime;
+
+	if (count > rtd->buffer_size)
+		count = rtd->buffer_size;
+
+	return sof_compr_copy_playback(rtd, buf, count);
+}
+
 static int sof_compr_pointer(struct snd_soc_component *component,
 			     struct snd_compr_stream *cstream,
 			     struct snd_compr_tstamp *tstamp)
-- 
2.34.1


  reply	other threads:[~2022-08-22 10:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-22 10:15 [PATCH 0/2] ASoC: SOF: compress: Add support for timestamp on capture Laurentiu Mihalcea
2022-08-22 10:15 ` Laurentiu Mihalcea [this message]
2022-08-22 10:15 ` [PATCH 2/2] ASoC: SOF: compress: Add copy function for capture case Laurentiu Mihalcea
2022-08-31 12:52 ` [PATCH 0/2] ASoC: SOF: compress: Add support for timestamp on capture Mark Brown

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=20220822101502.17644-2-laurentiu.mihalcea@nxp.com \
    --to=laurentiu.mihalcea@nxp.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=daniel.baluta@nxp.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul.olaru@nxp.com \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=ranjani.sridharan@linux.intel.com \
    --cc=yung-chuan.liao@linux.intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®