summaryrefslogtreecommitdiff
path: root/sound/soc/sof/compress.c
diff options
context:
space:
mode:
authorLaurentiu Mihalcea <laurentiu.mihalcea@nxp.com>2022-08-22 13:15:01 +0300
committerMark Brown <broonie@kernel.org>2022-08-31 14:12:58 +0300
commit272ff8828f35658aace17e3227624fbbd68a6bcf (patch)
treebf5ac1f072c7095adea3f3bbceecd560bfecab2c /sound/soc/sof/compress.c
parentced579dcaaa45fe16ac6c12fe847d650734af7bb (diff)
downloadlinux-272ff8828f35658aace17e3227624fbbd68a6bcf.tar.xz
ASoC: SOF: compress: Move sof_compr_copy functionality
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> Link: https://lore.kernel.org/r/20220822101502.17644-2-laurentiu.mihalcea@nxp.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/sof/compress.c')
-rw-r--r--sound/soc/sof/compress.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/sound/soc/sof/compress.c b/sound/soc/sof/compress.c
index c8ae778a50d1..2ee81096bec5 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)