ASoC: Tegra: return accurate pcm pointer position
Sumit Bhattacharya [Wed, 7 Dec 2011 14:50:43 +0000 (19:50 +0530)]
Use DMA driver tegra_dma_get_transfer_count api to get current DMA
position and use it to return accurate PCM poiter position.

Change-Id: I28906a1f2dd47dd91f03b8a79f53196752be6083
Signed-off-by: Sumit Bhattacharya <sumitb@nvidia.com>
Reviewed-on: http://git-master/r/68692
Reviewed-by: Lokesh Pathak <lpathak@nvidia.com>
Tested-by: Lokesh Pathak <lpathak@nvidia.com>

sound/soc/tegra/tegra_pcm.c

index 53f4e4c..a27f65f 100644 (file)
@@ -292,10 +292,15 @@ static snd_pcm_uframes_t tegra_pcm_pointer(struct snd_pcm_substream *substream)
 {
        struct snd_pcm_runtime *runtime = substream->runtime;
        struct tegra_runtime_data *prtd = runtime->private_data;
+       int dma_transfer_count;
 
-       return prtd->period_index * runtime->period_size;
-}
+       dma_transfer_count = tegra_dma_get_transfer_count(prtd->dma_chan,
+                                       &prtd->dma_req[prtd->dma_req_idx],
+                                       false);
 
+       return prtd->period_index * runtime->period_size +
+               bytes_to_frames(runtime, dma_transfer_count);
+}
 
 static int tegra_pcm_mmap(struct snd_pcm_substream *substream,
                                struct vm_area_struct *vma)