Message ID | a933bafd2d6a60a69f840d9d4b613337efcf2816.1588320656.git.shengjiu.wang@nxp.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | ASoC: fsl_esai: Add support for imx8qm | expand |
On Fri, May 01, 2020 at 04:12:05PM +0800, Shengjiu Wang wrote: > The difference for esai on imx8qm is that DMA device is EDMA. > > EDMA requires the period size to be multiple of maxburst. Otherwise > the remaining bytes are not transferred and thus noise is produced. If this constraint comes from the DMA controller then normally you'd expect the DMA controller integration to be enforcing this - is there no information in the DMA API that lets us know that this constraint is there?
Hi On Fri, May 1, 2020 at 6:23 PM Mark Brown <broonie@kernel.org> wrote: > > On Fri, May 01, 2020 at 04:12:05PM +0800, Shengjiu Wang wrote: > > The difference for esai on imx8qm is that DMA device is EDMA. > > > > EDMA requires the period size to be multiple of maxburst. Otherwise > > the remaining bytes are not transferred and thus noise is produced. > > If this constraint comes from the DMA controller then normally you'd > expect the DMA controller integration to be enforcing this - is there no > information in the DMA API that lets us know that this constraint is > there? No, I can't find one API for this. Do you have a recommendation? best regards wang shengjiu
Hi Mark, Nicolin On Wed, May 6, 2020 at 10:33 AM Shengjiu Wang <shengjiu.wang@gmail.com> wrote: > > Hi > > On Fri, May 1, 2020 at 6:23 PM Mark Brown <broonie@kernel.org> wrote: > > > > On Fri, May 01, 2020 at 04:12:05PM +0800, Shengjiu Wang wrote: > > > The difference for esai on imx8qm is that DMA device is EDMA. > > > > > > EDMA requires the period size to be multiple of maxburst. Otherwise > > > the remaining bytes are not transferred and thus noise is produced. > > > > If this constraint comes from the DMA controller then normally you'd > > expect the DMA controller integration to be enforcing this - is there no > > information in the DMA API that lets us know that this constraint is > > there? > > No, I can't find one API for this. > Do you have a recommendation? > could you please recommend which DMA API can I use? best regards wang shengjiu
On Tue, May 12, 2020 at 10:48:41AM +0800, Shengjiu Wang wrote: > On Wed, May 6, 2020 at 10:33 AM Shengjiu Wang <shengjiu.wang@gmail.com> wrote: > > On Fri, May 1, 2020 at 6:23 PM Mark Brown <broonie@kernel.org> wrote: > > > > EDMA requires the period size to be multiple of maxburst. Otherwise > > > > the remaining bytes are not transferred and thus noise is produced. > > > If this constraint comes from the DMA controller then normally you'd > > > expect the DMA controller integration to be enforcing this - is there no > > > information in the DMA API that lets us know that this constraint is > > > there? > > No, I can't find one API for this. > > Do you have a recommendation? > could you please recommend which DMA API can I use? Not off-hand, you'd probably need to extend the API to export the information.
On Tue, May 12, 2020 at 8:38 PM Mark Brown <broonie@kernel.org> wrote: > > On Tue, May 12, 2020 at 10:48:41AM +0800, Shengjiu Wang wrote: > > On Wed, May 6, 2020 at 10:33 AM Shengjiu Wang <shengjiu.wang@gmail.com> wrote: > > > On Fri, May 1, 2020 at 6:23 PM Mark Brown <broonie@kernel.org> wrote: > > > > > > EDMA requires the period size to be multiple of maxburst. Otherwise > > > > > the remaining bytes are not transferred and thus noise is produced. > > > > > If this constraint comes from the DMA controller then normally you'd > > > > expect the DMA controller integration to be enforcing this - is there no > > > > information in the DMA API that lets us know that this constraint is > > > > there? > > > > No, I can't find one API for this. > > > Do you have a recommendation? > > > could you please recommend which DMA API can I use? > > Not off-hand, you'd probably need to extend the API to export the > information. Thanks. I will think about if I can find a better solution. And I will drop this change and send v2 of this patch-set.
diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c index bac65ba7fbad..61b5c0bde788 100644 --- a/sound/soc/fsl/fsl_esai.c +++ b/sound/soc/fsl/fsl_esai.c @@ -26,10 +26,12 @@ * * @imx: for imx platform * @reset_at_xrun: flags for enable reset operaton + * @use_edma: edma is used. */ struct fsl_esai_soc_data { bool imx; bool reset_at_xrun; + bool use_edma; }; /** @@ -88,16 +90,25 @@ struct fsl_esai { static struct fsl_esai_soc_data fsl_esai_vf610 = { .imx = false, .reset_at_xrun = true, + .use_edma = false, }; static struct fsl_esai_soc_data fsl_esai_imx35 = { .imx = true, .reset_at_xrun = true, + .use_edma = false, }; static struct fsl_esai_soc_data fsl_esai_imx6ull = { .imx = true, .reset_at_xrun = false, + .use_edma = false, +}; + +static struct fsl_esai_soc_data fsl_esai_imx8qm = { + .imx = true, + .reset_at_xrun = false, + .use_edma = true, }; static irqreturn_t esai_isr(int irq, void *devid) @@ -513,6 +524,7 @@ static int fsl_esai_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct fsl_esai *esai_priv = snd_soc_dai_get_drvdata(dai); + bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; if (!dai->active) { /* Set synchronous mode */ @@ -527,6 +539,12 @@ static int fsl_esai_startup(struct snd_pcm_substream *substream, ESAI_xCCR_xDC_MASK, ESAI_xCCR_xDC(2)); } + if (esai_priv->soc->use_edma) + snd_pcm_hw_constraint_step(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_PERIOD_SIZE, + tx ? esai_priv->dma_params_tx.maxburst : + esai_priv->dma_params_rx.maxburst); + return 0; } @@ -1094,6 +1112,7 @@ static const struct of_device_id fsl_esai_dt_ids[] = { { .compatible = "fsl,imx35-esai", .data = &fsl_esai_imx35 }, { .compatible = "fsl,vf610-esai", .data = &fsl_esai_vf610 }, { .compatible = "fsl,imx6ull-esai", .data = &fsl_esai_imx6ull }, + { .compatible = "fsl,imx8qm-esai", .data = &fsl_esai_imx8qm }, {} }; MODULE_DEVICE_TABLE(of, fsl_esai_dt_ids);
The difference for esai on imx8qm is that DMA device is 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: Shengjiu Wang <shengjiu.wang@nxp.com> --- sound/soc/fsl/fsl_esai.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)