Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0d69e0dd authored by Shengjiu Wang's avatar Shengjiu Wang Committed by Mark Brown
Browse files

ASoC: fsl: Add dedicated DMA buffer size for each cpu dai



As the ssi is not the only cpu dai, there are esai, spdif, sai.
and imx_pcm_dma can be used by all of them. Especially ESAI need
a larger DMA buffer size. So Add dedicated DMA buffer for each cpu
dai.

Signed-off-by: default avatarShengjiu Wang <shengjiu.wang@freescale.com>
Acked-by: default avatarNicolin Chen <nicoleotsuka@gmail.com>
Acked-by: default avatarTimur Tabi <timur@tabi.org>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent d770e558
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -839,7 +839,7 @@ static int fsl_esai_probe(struct platform_device *pdev)
		return ret;
	}

	ret = imx_pcm_dma_init(pdev);
	ret = imx_pcm_dma_init(pdev, IMX_ESAI_DMABUF_SIZE);
	if (ret)
		dev_err(&pdev->dev, "failed to init imx pcm dma: %d\n", ret);

+1 −1
Original line number Diff line number Diff line
@@ -791,7 +791,7 @@ static int fsl_sai_probe(struct platform_device *pdev)
		return ret;

	if (sai->sai_on_imx)
		return imx_pcm_dma_init(pdev);
		return imx_pcm_dma_init(pdev, IMX_SAI_DMABUF_SIZE);
	else
		return devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0);
}
+1 −1
Original line number Diff line number Diff line
@@ -1255,7 +1255,7 @@ static int fsl_spdif_probe(struct platform_device *pdev)
		return ret;
	}

	ret = imx_pcm_dma_init(pdev);
	ret = imx_pcm_dma_init(pdev, IMX_SPDIF_DMABUF_SIZE);
	if (ret)
		dev_err(&pdev->dev, "imx_pcm_dma_init failed: %d\n", ret);

+1 −1
Original line number Diff line number Diff line
@@ -1257,7 +1257,7 @@ static int fsl_ssi_imx_probe(struct platform_device *pdev,
		if (ret)
			goto error_pcm;
	} else {
		ret = imx_pcm_dma_init(pdev);
		ret = imx_pcm_dma_init(pdev, IMX_SSI_DMABUF_SIZE);
		if (ret)
			goto error_pcm;
	}
+21 −4
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ static const struct snd_pcm_hardware imx_pcm_hardware = {
		SNDRV_PCM_INFO_MMAP_VALID |
		SNDRV_PCM_INFO_PAUSE |
		SNDRV_PCM_INFO_RESUME,
	.buffer_bytes_max = IMX_SSI_DMABUF_SIZE,
	.buffer_bytes_max = IMX_DEFAULT_DMABUF_SIZE,
	.period_bytes_min = 128,
	.period_bytes_max = 65535, /* Limited by SDMA engine */
	.periods_min = 2,
@@ -52,13 +52,30 @@ static const struct snd_dmaengine_pcm_config imx_dmaengine_pcm_config = {
	.pcm_hardware = &imx_pcm_hardware,
	.prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
	.compat_filter_fn = filter,
	.prealloc_buffer_size = IMX_SSI_DMABUF_SIZE,
	.prealloc_buffer_size = IMX_DEFAULT_DMABUF_SIZE,
};

int imx_pcm_dma_init(struct platform_device *pdev)
int imx_pcm_dma_init(struct platform_device *pdev, size_t size)
{
	struct snd_dmaengine_pcm_config *config;
	struct snd_pcm_hardware *pcm_hardware;

	config = devm_kzalloc(&pdev->dev,
			sizeof(struct snd_dmaengine_pcm_config), GFP_KERNEL);
	*config = imx_dmaengine_pcm_config;
	if (size)
		config->prealloc_buffer_size = size;

	pcm_hardware = devm_kzalloc(&pdev->dev,
			sizeof(struct snd_pcm_hardware), GFP_KERNEL);
	*pcm_hardware = imx_pcm_hardware;
	if (size)
		pcm_hardware->buffer_bytes_max = size;

	config->pcm_hardware = pcm_hardware;

	return devm_snd_dmaengine_pcm_register(&pdev->dev,
		&imx_dmaengine_pcm_config,
		config,
		SND_DMAENGINE_PCM_FLAG_COMPAT);
}
EXPORT_SYMBOL_GPL(imx_pcm_dma_init);
Loading