summaryrefslogtreecommitdiff
path: root/sound/soc/fsl/fsl_easrc_m2m.c
diff options
context:
space:
mode:
authorShengjiu Wang <shengjiu.wang@nxp.com>2020-05-15 15:51:43 +0800
committerShengjiu Wang <shengjiu.wang@nxp.com>2020-05-15 17:24:52 +0800
commitb020954c947af0ed219f6c000b88efbb57abd4fa (patch)
treebf9ce1585b713881c4a4294b5577745681cb05d0 /sound/soc/fsl/fsl_easrc_m2m.c
parentaeffa77173e66429254e85df6c2100f40e2436de (diff)
MLK-24044: ASoC: fsl_easrc_m2m: Fix output length not accurate
We need to accumulate the input data length for calculating the output length because there are data need to be prefilled in the beginning. If the fraction part beyond the integrity of sample is not considered in calculating, which may cause the output task timeout. Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com> Reviewed-by: Viorel Suman <viorel.suman@nxp.com>
Diffstat (limited to 'sound/soc/fsl/fsl_easrc_m2m.c')
-rw-r--r--sound/soc/fsl/fsl_easrc_m2m.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/sound/soc/fsl/fsl_easrc_m2m.c b/sound/soc/fsl/fsl_easrc_m2m.c
index 7f068d8ad362..82d06afbecb7 100644
--- a/sound/soc/fsl/fsl_easrc_m2m.c
+++ b/sound/soc/fsl/fsl_easrc_m2m.c
@@ -10,6 +10,7 @@ struct fsl_easrc_m2m {
unsigned int easrc_active;
unsigned int first_convert;
unsigned int sg_nodes[2];
+ unsigned int in_filled_len;
struct scatterlist sg[2][9];
struct dma_async_tx_descriptor *desc[2];
spinlock_t lock; /* protect mem resource */
@@ -181,17 +182,15 @@ static long fsl_easrc_calc_outbuf_len(struct fsl_easrc_m2m *m2m,
in_width = snd_pcm_format_physical_width(ctx->in_params.sample_format) / 8;
out_width = snd_pcm_format_physical_width(ctx->out_params.sample_format) / 8;
- in_samples = pbuf->input_buffer_length / (in_width * channels);
- out_samples = ctx->out_params.sample_rate * in_samples /
- ctx->in_params.sample_rate;
- out_length = out_samples * out_width * channels;
-
- if (out_samples <= ctx->out_missed_sample) {
+ m2m->in_filled_len += pbuf->input_buffer_length;
+ if (m2m->in_filled_len <= ctx->in_filled_sample * in_width * channels) {
out_length = 0;
- ctx->out_missed_sample -= out_samples;
} else {
- out_length -= ctx->out_missed_sample * out_width * channels;
- ctx->out_missed_sample = 0;
+ in_samples = m2m->in_filled_len / (in_width * channels) - ctx->in_filled_sample;
+ out_samples = ctx->out_params.sample_rate * in_samples /
+ ctx->in_params.sample_rate;
+ out_length = out_samples * out_width * channels;
+ m2m->in_filled_len = ctx->in_filled_sample * in_width * channels;
}
return out_length;