Commit 272ff882 authored by Laurentiu Mihalcea's avatar Laurentiu Mihalcea Committed by Mark Brown

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: default avatarPaul Olaru <paul.olaru@nxp.com>
Reviewed-by: default avatarDaniel Baluta <daniel.baluta@nxp.com>
Signed-off-by: default avatarLaurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
Link: https://lore.kernel.org/r/20220822101502.17644-2-laurentiu.mihalcea@nxp.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent ced579dc
...@@ -297,18 +297,13 @@ static int sof_compr_trigger(struct snd_soc_component *component, ...@@ -297,18 +297,13 @@ static int sof_compr_trigger(struct snd_soc_component *component,
&reply, sizeof(reply)); &reply, sizeof(reply));
} }
static int sof_compr_copy(struct snd_soc_component *component, static int sof_compr_copy_playback(struct snd_compr_runtime *rtd,
struct snd_compr_stream *cstream,
char __user *buf, size_t count) char __user *buf, size_t count)
{ {
struct snd_compr_runtime *rtd = cstream->runtime;
unsigned int offset, n;
void *ptr; void *ptr;
unsigned int offset, n;
int ret; int ret;
if (count > rtd->buffer_size)
count = rtd->buffer_size;
div_u64_rem(rtd->total_bytes_available, rtd->buffer_size, &offset); div_u64_rem(rtd->total_bytes_available, rtd->buffer_size, &offset);
ptr = rtd->dma_area + offset; ptr = rtd->dma_area + offset;
n = rtd->buffer_size - offset; n = rtd->buffer_size - offset;
...@@ -323,6 +318,18 @@ static int sof_compr_copy(struct snd_soc_component *component, ...@@ -323,6 +318,18 @@ static int sof_compr_copy(struct snd_soc_component *component,
return count - ret; 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, static int sof_compr_pointer(struct snd_soc_component *component,
struct snd_compr_stream *cstream, struct snd_compr_stream *cstream,
struct snd_compr_tstamp *tstamp) struct snd_compr_tstamp *tstamp)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment