ASoC: tegra: configure the dma request if dma data is set
Nikesh Oswal [Sun, 6 Nov 2011 04:42:31 +0000 (09:42 +0530)]
configure the dma request if dma data is set by the cpu
dai. In voice call use case we open a pcm device with
alsa driver which has a codec dai for configuring the
codec and a dummy cpu dai, which had no dma data since
we dont want any dma for this device as the flow
of data is directly between the baseband and codec.

Bug: 862023

Change-Id: Ia64dee48ff5e102b334f4a3d64286787e6db415b
Signed-off-by: Nikesh Oswal <noswal@nvidia.com>
Reviewed-on: http://git-master/r/62621
Reviewed-by: Rohan Somvanshi <rsomvanshi@nvidia.com>

Rebase-Id: Rb144e52e059eb7240e09ac0d63825a490e3542af

sound/soc/tegra/tegra_pcm.c

index dc54167..e583a0c 100644 (file)
@@ -147,24 +147,27 @@ static int tegra_pcm_open(struct snd_pcm_substream *substream)
 
        spin_lock_init(&prtd->lock);
 
-       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-               dmap = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
-               setup_dma_tx_request(&prtd->dma_req[0], dmap);
-               setup_dma_tx_request(&prtd->dma_req[1], dmap);
-       } else {
-               dmap = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
-               setup_dma_rx_request(&prtd->dma_req[0], dmap);
-               setup_dma_rx_request(&prtd->dma_req[1], dmap);
-       }
-
-       prtd->dma_req[0].dev = prtd;
-       prtd->dma_req[1].dev = prtd;
-
-       prtd->dma_chan = tegra_dma_allocate_channel(
-                               TEGRA_DMA_MODE_CONTINUOUS_SINGLE, "pcm");
-       if (prtd->dma_chan == NULL) {
-               ret = -ENOMEM;
-               goto err;
+       dmap = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
+
+       if (dmap) {
+               if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+                       setup_dma_tx_request(&prtd->dma_req[0], dmap);
+                       setup_dma_tx_request(&prtd->dma_req[1], dmap);
+               } else {
+                       setup_dma_rx_request(&prtd->dma_req[0], dmap);
+                       setup_dma_rx_request(&prtd->dma_req[1], dmap);
+               }
+
+               prtd->dma_req[0].dev = prtd;
+               prtd->dma_req[1].dev = prtd;
+
+               prtd->dma_chan = tegra_dma_allocate_channel(
+                                       TEGRA_DMA_MODE_CONTINUOUS_SINGLE,
+                                       "pcm");
+               if (prtd->dma_chan == NULL) {
+                       ret = -ENOMEM;
+                       goto err;
+               }
        }
 
        /* Set HW params now that initialization is complete */
@@ -199,7 +202,8 @@ static int tegra_pcm_close(struct snd_pcm_substream *substream)
        struct snd_pcm_runtime *runtime = substream->runtime;
        struct tegra_runtime_data *prtd = runtime->private_data;
 
-       tegra_dma_free_channel(prtd->dma_chan);
+       if (prtd->dma_chan)
+               tegra_dma_free_channel(prtd->dma_chan);
 
        kfree(prtd);