ASoC: fsl: Add dedicated DMA buffer size for each cpu dai
authorShengjiu Wang <shengjiu.wang@freescale.com>
Tue, 23 Jun 2015 10:23:53 +0000 (18:23 +0800)
committerMark Brown <broonie@kernel.org>
Tue, 7 Jul 2015 12:16:12 +0000 (13:16 +0100)
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: Shengjiu Wang <shengjiu.wang@freescale.com>
Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>
Acked-by: Timur Tabi <timur@tabi.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/fsl/fsl_esai.c
sound/soc/fsl/fsl_sai.c
sound/soc/fsl/fsl_spdif.c
sound/soc/fsl/fsl_ssi.c
sound/soc/fsl/imx-pcm-dma.c
sound/soc/fsl/imx-pcm.h
sound/soc/fsl/imx-ssi.c

index 5c7597191e3ffc682d1f813cdd9a6da8afbde397..8c2ddc1ea954c903873b02462a42012782336d62 100644 (file)
@@ -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);
 
index 5c73bea7b11ef89ae09bb3a472ff42d420e3c11e..a18fd92c4a85c3d67306c544c1af6652789d1467 100644 (file)
@@ -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);
 }
index 8e932219cb3af924398f5296ea77758313d0ca7b..d1e9be771f84e52ee6dd8ab3f9f1e6f9e236a2a9 100644 (file)
@@ -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);
 
index c7647e066cfd76b07f6b1acd4d2a68ac04bae3bc..e122dab944f4f1bb8e1e9ea25c1003ffa4ae61e1 100644 (file)
@@ -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;
        }
index 0db94f492e97d6e7533909e841edad2fa57ecb9a..1fc01ed3279dbee0991a343c082aa6c9ea5f042b 100644 (file)
@@ -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);
index c79cb27473be771d9ee355cacf52229f5da6c40d..133c4470acad67f3a94354e607b0536180cc3bb9 100644 (file)
  */
 #define IMX_SSI_DMABUF_SIZE    (64 * 1024)
 
+#define IMX_DEFAULT_DMABUF_SIZE        (64 * 1024)
+#define IMX_SAI_DMABUF_SIZE    (64 * 1024)
+#define IMX_SPDIF_DMABUF_SIZE  (64 * 1024)
+#define IMX_ESAI_DMABUF_SIZE   (256 * 1024)
+
 static inline void
 imx_pcm_dma_params_init_data(struct imx_dma_data *dma_data,
        int dma, enum sdma_peripheral_type peripheral_type)
@@ -39,9 +44,9 @@ struct imx_pcm_fiq_params {
 };
 
 #if IS_ENABLED(CONFIG_SND_SOC_IMX_PCM_DMA)
-int imx_pcm_dma_init(struct platform_device *pdev);
+int imx_pcm_dma_init(struct platform_device *pdev, size_t size);
 #else
-static inline int imx_pcm_dma_init(struct platform_device *pdev)
+static inline int imx_pcm_dma_init(struct platform_device *pdev, size_t size)
 {
        return -ENODEV;
 }
index 461ce27b884f0f0b22dd6bb03216a1ee05f7e0fc..48b2d24dd1f0a9a639c6bd7e7549035ed38f8e15 100644 (file)
@@ -603,7 +603,7 @@ 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);
+       ssi->dma_init = imx_pcm_dma_init(pdev, IMX_SSI_DMABUF_SIZE);
 
        if (ssi->fiq_init && ssi->dma_init) {
                ret = ssi->fiq_init;