summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMihai Serban <mihai.serban@nxp.com>2019-09-13 15:28:05 -0400
committerMark Brown <broonie@kernel.org>2019-09-17 11:56:19 -0400
commite75f4940e8ad0dd76527302a10c06b58bf7eb590 (patch)
tree4aa03850072854d477181319f253cee00e92c9f0
parentfca11622d600228bec405456f41590155b3a3eca (diff)
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: Mihai Serban <mihai.serban@nxp.com> Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com> Acked-by: Nicolin Chen <nicoleotsuka@gmail.com> Link: https://lore.kernel.org/r/20190913192807.8423-2-daniel.baluta@nxp.com Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/fsl/fsl_sai.c15
-rw-r--r--sound/soc/fsl/fsl_sai.h1
2 files changed, 16 insertions, 0 deletions
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
index ef0b74693093..b517e4bc1b87 100644
--- a/sound/soc/fsl/fsl_sai.c
+++ b/sound/soc/fsl/fsl_sai.c
@@ -628,6 +628,16 @@ static int fsl_sai_startup(struct snd_pcm_substream *substream,
628 FSL_SAI_CR3_TRCE_MASK, 628 FSL_SAI_CR3_TRCE_MASK,
629 FSL_SAI_CR3_TRCE); 629 FSL_SAI_CR3_TRCE);
630 630
631 /*
632 * EDMA controller needs period size to be a multiple of
633 * tx/rx maxburst
634 */
635 if (sai->soc_data->use_edma)
636 snd_pcm_hw_constraint_step(substream->runtime, 0,
637 SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
638 tx ? sai->dma_params_tx.maxburst :
639 sai->dma_params_rx.maxburst);
640
631 ret = snd_pcm_hw_constraint_list(substream->runtime, 0, 641 ret = snd_pcm_hw_constraint_list(substream->runtime, 0,
632 SNDRV_PCM_HW_PARAM_RATE, &fsl_sai_rate_constraints); 642 SNDRV_PCM_HW_PARAM_RATE, &fsl_sai_rate_constraints);
633 643
@@ -1026,30 +1036,35 @@ static int fsl_sai_remove(struct platform_device *pdev)
1026 1036
1027static const struct fsl_sai_soc_data fsl_sai_vf610_data = { 1037static const struct fsl_sai_soc_data fsl_sai_vf610_data = {
1028 .use_imx_pcm = false, 1038 .use_imx_pcm = false,
1039 .use_edma = false,
1029 .fifo_depth = 32, 1040 .fifo_depth = 32,
1030 .reg_offset = 0, 1041 .reg_offset = 0,
1031}; 1042};
1032 1043
1033static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = { 1044static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = {
1034 .use_imx_pcm = true, 1045 .use_imx_pcm = true,
1046 .use_edma = false,
1035 .fifo_depth = 32, 1047 .fifo_depth = 32,
1036 .reg_offset = 0, 1048 .reg_offset = 0,
1037}; 1049};
1038 1050
1039static const struct fsl_sai_soc_data fsl_sai_imx7ulp_data = { 1051static const struct fsl_sai_soc_data fsl_sai_imx7ulp_data = {
1040 .use_imx_pcm = true, 1052 .use_imx_pcm = true,
1053 .use_edma = false,
1041 .fifo_depth = 16, 1054 .fifo_depth = 16,
1042 .reg_offset = 8, 1055 .reg_offset = 8,
1043}; 1056};
1044 1057
1045static const struct fsl_sai_soc_data fsl_sai_imx8mq_data = { 1058static const struct fsl_sai_soc_data fsl_sai_imx8mq_data = {
1046 .use_imx_pcm = true, 1059 .use_imx_pcm = true,
1060 .use_edma = false,
1047 .fifo_depth = 128, 1061 .fifo_depth = 128,
1048 .reg_offset = 8, 1062 .reg_offset = 8,
1049}; 1063};
1050 1064
1051static const struct fsl_sai_soc_data fsl_sai_imx8qm_data = { 1065static const struct fsl_sai_soc_data fsl_sai_imx8qm_data = {
1052 .use_imx_pcm = true, 1066 .use_imx_pcm = true,
1067 .use_edma = true,
1053 .fifo_depth = 64, 1068 .fifo_depth = 64,
1054 .reg_offset = 0, 1069 .reg_offset = 0,
1055}; 1070};
diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h
index b12cb578f6d0..76b15deea80c 100644
--- a/sound/soc/fsl/fsl_sai.h
+++ b/sound/soc/fsl/fsl_sai.h
@@ -157,6 +157,7 @@
157 157
158struct fsl_sai_soc_data { 158struct fsl_sai_soc_data {
159 bool use_imx_pcm; 159 bool use_imx_pcm;
160 bool use_edma;
160 unsigned int fifo_depth; 161 unsigned int fifo_depth;
161 unsigned int reg_offset; 162 unsigned int reg_offset;
162}; 163};