Skip to content

Commit

Permalink
ENGR00283079-1 ASoC: fsl: Implement different DMA buffer sizes
Browse files Browse the repository at this point in the history
Each CPU DAI driver has its own defined DMA buffer size, so this patch just
drops the original one that uses a fixed size for all drivers and implements
a different DMA buffer size to each driver.

Acked-by: Wang Shengjiu <[email protected]>
Signed-off-by: Nicolin Chen <[email protected]>
  • Loading branch information
Nicolin Chen authored and linux4kix committed Aug 12, 2014
1 parent bea3803 commit 6b3943b
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 10 deletions.
3 changes: 2 additions & 1 deletion sound/soc/fsl/fsl_asrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,8 @@ static int fsl_asrc_p2p_probe(struct platform_device *pdev)

ret = imx_pcm_dma_init(asrc_p2p->soc_platform_pdev, SND_DMAENGINE_PCM_FLAG_NO_RESIDUE |
SND_DMAENGINE_PCM_FLAG_NO_DT |
SND_DMAENGINE_PCM_FLAG_COMPAT);
SND_DMAENGINE_PCM_FLAG_COMPAT,
IMX_ASRC_DMABUF_SIZE);
if (ret) {
dev_err(&pdev->dev, "init pcm dma failed\n");
goto failed_pcm_init;
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/fsl/fsl_esai.c
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ static int fsl_esai_probe(struct platform_device *pdev)
return ret;
}

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

Expand Down
3 changes: 2 additions & 1 deletion sound/soc/fsl/fsl_spdif.c
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,8 @@ static int fsl_spdif_probe(struct platform_device *pdev)
return ret;
}

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

Expand Down
3 changes: 2 additions & 1 deletion sound/soc/fsl/fsl_ssi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,8 @@ static int fsl_ssi_probe(struct platform_device *pdev)
if (ret)
goto error_pcm;
} else {
ret = imx_pcm_dma_init(pdev, SND_DMAENGINE_PCM_FLAG_NO_RESIDUE);
ret = imx_pcm_dma_init(pdev, SND_DMAENGINE_PCM_FLAG_NO_RESIDUE,
IMX_SSI_DMABUF_SIZE);
if (ret)
goto error_pcm;
}
Expand Down
22 changes: 19 additions & 3 deletions sound/soc/fsl/imx-pcm-dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,26 @@ static const struct snd_dmaengine_pcm_config imx_dmaengine_pcm_config = {
.prealloc_buffer_size = IMX_DEFAULT_DMABUF_SIZE,
};

int imx_pcm_dma_init(struct platform_device *pdev, unsigned int flags)
int imx_pcm_dma_init(struct platform_device *pdev, unsigned int flags, size_t size)
{
return devm_snd_dmaengine_pcm_register(&pdev->dev,
&imx_dmaengine_pcm_config, flags);
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, config, flags);
}
EXPORT_SYMBOL_GPL(imx_pcm_dma_init);

Expand Down
4 changes: 2 additions & 2 deletions sound/soc/fsl/imx-pcm.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ struct imx_pcm_fiq_params {
};

#if IS_ENABLED(CONFIG_SND_SOC_IMX_PCM_DMA)
int imx_pcm_dma_init(struct platform_device *pdev, unsigned int flags);
int imx_pcm_dma_init(struct platform_device *pdev, unsigned int flags, size_t size);
#else
static inline int imx_pcm_dma_init(struct platform_device *pdev,
unsigned int flags)
unsigned int flags, size_t size)
{
return -ENODEV;
}
Expand Down
3 changes: 2 additions & 1 deletion sound/soc/fsl/imx-ssi.c
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,8 @@ static int imx_ssi_probe(struct platform_device *pdev)
ssi->fiq_params.dma_params_tx = &ssi->dma_params_tx;

ssi->fiq_init = imx_pcm_fiq_init(pdev, &ssi->fiq_params);
ssi->dma_init = imx_pcm_dma_init(pdev, SND_DMAENGINE_PCM_FLAG_NO_RESIDUE);
ssi->dma_init = imx_pcm_dma_init(pdev, SND_DMAENGINE_PCM_FLAG_NO_RESIDUE,
IMX_SSI_DMABUF_SIZE);

if (ssi->fiq_init && ssi->dma_init) {
ret = ssi->fiq_init;
Expand Down

0 comments on commit 6b3943b

Please sign in to comment.