]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/commitdiff
ASoC: tegra-alt: add dma buffer size parse
authorAhung Cheng <ahcheng@nvidia.com>
Tue, 18 Apr 2017 09:01:51 +0000 (17:01 +0800)
committermobile promotions <svcmobile_promotions@nvidia.com>
Thu, 11 May 2017 12:00:29 +0000 (05:00 -0700)
Add dma-buffer-size parsing in device tree for pcm
driver to allocate required size for each pcm node

Bug 200299289

Change-Id: Ia579c66413912dd0ef7fda34cd47887eec3599f7
Signed-off-by: Ahung Cheng <ahcheng@nvidia.com>
Reviewed-on: http://git-master/r/1478988
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
sound/soc/tegra-alt/tegra210_admaif_alt.c
sound/soc/tegra-alt/tegra_pcm_alt.c
sound/soc/tegra-alt/tegra_pcm_alt.h

index 1741a44300f51563fcdf7f8b021e9a720d1929d1..1813c9ddbd9fa13607ae14d059415e108fb66e7e 100644 (file)
@@ -936,6 +936,7 @@ static int tegra210_admaif_probe(struct platform_device *pdev)
        struct resource *res;
        const struct of_device_id *match;
        struct tegra210_admaif_soc_data *soc_data;
+       unsigned int buffer_size;
 
        match = of_match_device(tegra210_admaif_of_match, &pdev->dev);
        if (!match) {
@@ -1029,6 +1030,15 @@ static int tegra210_admaif_probe(struct platform_device *pdev)
                        ret = -ENODEV;
                        goto err_suspend;
                }
+               buffer_size = 0;
+               if (of_property_read_u32_index(pdev->dev.of_node,
+                               "dma-buffer-size",
+                               (i * 2) + 1,
+                               &buffer_size) < 0) {
+                       dev_dbg(&pdev->dev,
+                               "Missing property nvidia,dma-buffer-size\n");
+               }
+               admaif->playback_dma_data[i].buffer_size = buffer_size;
 
                admaif->capture_dma_data[i].wrap = 4;
                admaif->capture_dma_data[i].width = 32;
@@ -1042,6 +1052,15 @@ static int tegra210_admaif_probe(struct platform_device *pdev)
                        ret = -ENODEV;
                        goto err_suspend;
                }
+               buffer_size = 0;
+               if (of_property_read_u32_index(pdev->dev.of_node,
+                               "dma-buffer-size",
+                               (i * 2),
+                               &buffer_size) < 0) {
+                       dev_dbg(&pdev->dev,
+                               "Missing property nvidia,dma-buffer-size\n");
+               }
+               admaif->capture_dma_data[i].buffer_size = buffer_size;
        }
 
        ret = snd_soc_register_component(&pdev->dev,
index 43ba0b483360115e1e88cdf2e04dc8152af6f9fa..eb979bd9ff0fd8ecdf5adb3a54b2e964d130a354 100644 (file)
@@ -232,6 +232,8 @@ static int tegra_alt_pcm_dma_allocate(struct snd_soc_pcm_runtime *rtd,
 {
        struct snd_card *card = rtd->card->snd_card;
        struct snd_pcm *pcm = rtd->pcm;
+       struct tegra_alt_pcm_dma_params *dmap;
+       size_t buffer_size = size;
        int ret = 0;
 
        if (!card->dev->dma_mask)
@@ -239,18 +241,26 @@ static int tegra_alt_pcm_dma_allocate(struct snd_soc_pcm_runtime *rtd,
        if (!card->dev->coherent_dma_mask)
                card->dev->coherent_dma_mask = tegra_dma_mask;
 
+       dmap = snd_soc_dai_get_dma_data(rtd->cpu_dai,
+                       pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream);
+       if (dmap->buffer_size > size)
+               buffer_size = dmap->buffer_size;
        if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
                ret = tegra_alt_pcm_preallocate_dma_buffer(pcm,
                                                SNDRV_PCM_STREAM_PLAYBACK,
-                                               size);
+                                               buffer_size);
                if (ret)
                        goto err;
        }
 
+       dmap = snd_soc_dai_get_dma_data(rtd->cpu_dai,
+                       pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream);
+       if (dmap->buffer_size > size)
+               buffer_size = dmap->buffer_size;
        if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
                ret = tegra_alt_pcm_preallocate_dma_buffer(pcm,
                                                SNDRV_PCM_STREAM_CAPTURE,
-                                               size);
+                                               buffer_size);
                if (ret)
                        goto err_free_play;
        }
index 0e4348673bbdc1485d91446cef66983331d0b766..13297c67f61100de14f45f6ebb57230a62171e21 100644 (file)
@@ -39,6 +39,7 @@ struct tegra_alt_pcm_dma_params {
        unsigned long width;
        unsigned long req_sel;
        const char *chan_name;
+       size_t buffer_size;
 };
 
 int tegra_alt_pcm_platform_register(struct device *dev);