From 6d267cc2f6d7cbbf34326f34bc92d3f3f01dec03 Mon Sep 17 00:00:00 2001 From: Hariharan Sivaraman Date: Mon, 20 May 2019 16:37:42 +0530 Subject: [PATCH] adsp: add buffer size constraint for pcm buffer During pcm_open for ADSP pcm devices, the buffer allocated is not constrained to be multiple of 4. This results in the apm_process being called continuously for this APM since data is available. However ADMA is not started because of the size mismatch. Setting constraint of period and buffer size (in frames) to be multiple of 4 fixes these issues Bug 2599016 Change-Id: Idaabba29142d9577a4dc72d97aa6bb3cd4f791de Signed-off-by: Hariharan Sivaraman Reviewed-on: https://git-master.nvidia.com/r/2122112 (cherry picked from commit 82d702154bf2c1a903f32e50a9bc4afdf271d74f) Reviewed-on: https://git-master.nvidia.com/r/2124176 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Uday Gupta GVS: Gerrit_Virtual_Submit Reviewed-by: Nitin Pai Reviewed-by: mobile promotions Tested-by: mobile promotions --- sound/soc/tegra-alt/tegra210_adsp_alt.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/sound/soc/tegra-alt/tegra210_adsp_alt.c b/sound/soc/tegra-alt/tegra210_adsp_alt.c index 86b82bff..352c4ee8 100644 --- a/sound/soc/tegra-alt/tegra210_adsp_alt.c +++ b/sound/soc/tegra-alt/tegra210_adsp_alt.c @@ -1779,9 +1779,19 @@ static int tegra210_adsp_pcm_open(struct snd_pcm_substream *substream) /* Ensure period size is multiple of 4 */ ret = snd_pcm_hw_constraint_step(substream->runtime, 0, - SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 0x4); + SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 0x4); if (ret) { - dev_err(adsp->dev, "failed to set constraint %d\n", ret); + dev_err(adsp->dev, + "failed to set period_size constraint %d\n", ret); + return ret; + } + + /* Ensure buffer size is multiple of 4 */ + ret = snd_pcm_hw_constraint_step(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0x4); + if (ret) { + dev_err(adsp->dev, + "failed to set buffer_size constraint %d\n", ret); return ret; } substream->runtime->private_data = prtd;