Commit e75f4940 authored by Mihai Serban's avatar Mihai Serban Committed by Mark Brown

ASoC: fsl_sai: Fix noise when using EDMA

EDMA requires the period size to be multiple of maxburst. Otherwise the
remaining bytes are not transferred and thus noise is produced.

We can handle this issue by adding a constraint on
SNDRV_PCM_HW_PARAM_PERIOD_SIZE to be multiple of tx/rx maxburst value.
Signed-off-by: default avatarMihai Serban <mihai.serban@nxp.com>
Signed-off-by: default avatarDaniel Baluta <daniel.baluta@nxp.com>
Acked-by: default avatarNicolin Chen <nicoleotsuka@gmail.com>
Link: https://lore.kernel.org/r/20190913192807.8423-2-daniel.baluta@nxp.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent fca11622
...@@ -628,6 +628,16 @@ static int fsl_sai_startup(struct snd_pcm_substream *substream, ...@@ -628,6 +628,16 @@ static int fsl_sai_startup(struct snd_pcm_substream *substream,
FSL_SAI_CR3_TRCE_MASK, FSL_SAI_CR3_TRCE_MASK,
FSL_SAI_CR3_TRCE); FSL_SAI_CR3_TRCE);
/*
* EDMA controller needs period size to be a multiple of
* tx/rx maxburst
*/
if (sai->soc_data->use_edma)
snd_pcm_hw_constraint_step(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
tx ? sai->dma_params_tx.maxburst :
sai->dma_params_rx.maxburst);
ret = snd_pcm_hw_constraint_list(substream->runtime, 0, ret = snd_pcm_hw_constraint_list(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_RATE, &fsl_sai_rate_constraints); SNDRV_PCM_HW_PARAM_RATE, &fsl_sai_rate_constraints);
...@@ -1026,30 +1036,35 @@ static int fsl_sai_remove(struct platform_device *pdev) ...@@ -1026,30 +1036,35 @@ static int fsl_sai_remove(struct platform_device *pdev)
static const struct fsl_sai_soc_data fsl_sai_vf610_data = { static const struct fsl_sai_soc_data fsl_sai_vf610_data = {
.use_imx_pcm = false, .use_imx_pcm = false,
.use_edma = false,
.fifo_depth = 32, .fifo_depth = 32,
.reg_offset = 0, .reg_offset = 0,
}; };
static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = { static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = {
.use_imx_pcm = true, .use_imx_pcm = true,
.use_edma = false,
.fifo_depth = 32, .fifo_depth = 32,
.reg_offset = 0, .reg_offset = 0,
}; };
static const struct fsl_sai_soc_data fsl_sai_imx7ulp_data = { static const struct fsl_sai_soc_data fsl_sai_imx7ulp_data = {
.use_imx_pcm = true, .use_imx_pcm = true,
.use_edma = false,
.fifo_depth = 16, .fifo_depth = 16,
.reg_offset = 8, .reg_offset = 8,
}; };
static const struct fsl_sai_soc_data fsl_sai_imx8mq_data = { static const struct fsl_sai_soc_data fsl_sai_imx8mq_data = {
.use_imx_pcm = true, .use_imx_pcm = true,
.use_edma = false,
.fifo_depth = 128, .fifo_depth = 128,
.reg_offset = 8, .reg_offset = 8,
}; };
static const struct fsl_sai_soc_data fsl_sai_imx8qm_data = { static const struct fsl_sai_soc_data fsl_sai_imx8qm_data = {
.use_imx_pcm = true, .use_imx_pcm = true,
.use_edma = true,
.fifo_depth = 64, .fifo_depth = 64,
.reg_offset = 0, .reg_offset = 0,
}; };
......
...@@ -157,6 +157,7 @@ ...@@ -157,6 +157,7 @@
struct fsl_sai_soc_data { struct fsl_sai_soc_data {
bool use_imx_pcm; bool use_imx_pcm;
bool use_edma;
unsigned int fifo_depth; unsigned int fifo_depth;
unsigned int reg_offset; unsigned int reg_offset;
}; };
......
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