summaryrefslogtreecommitdiff
path: root/sound/soc/tegra/tegra_pcm.c
diff options
context:
space:
mode:
authorNitin Pai <npai@nvidia.com>2012-04-26 19:04:54 +0530
committerSimone Willett <swillett@nvidia.com>2012-05-01 14:25:50 -0700
commit24c1b0906d11919aae53d840b385be356183b4be (patch)
tree1713cd6afd2d721183ff8f931982bf56505cf069 /sound/soc/tegra/tegra_pcm.c
parent30dee27a399ea53f18c714c7d6bf6a1a63090165 (diff)
asoc: tegra: Add PCM driver for TDM mode
Modified existing pcm driver to take dma mode/ hw structure. Exported the functions needed for other pcm mode driver. Added new TDM mode hw param structure. Added pass SINGLE/DOUBLE buffered dma mode params. Bug 948478 Change-Id: I58309d52748f813b3303a8d6a052fbb6cc7ca87a Signed-off-by: Nitin Pai <npai@nvidia.com> Reviewed-on: http://git-master/r/99146 Reviewed-by: Simone Willett <swillett@nvidia.com> Tested-by: Simone Willett <swillett@nvidia.com>
Diffstat (limited to 'sound/soc/tegra/tegra_pcm.c')
-rw-r--r--sound/soc/tegra/tegra_pcm.c50
1 files changed, 34 insertions, 16 deletions
diff --git a/sound/soc/tegra/tegra_pcm.c b/sound/soc/tegra/tegra_pcm.c
index 65d89c8b1280..89fd3ff8fb15 100644
--- a/sound/soc/tegra/tegra_pcm.c
+++ b/sound/soc/tegra/tegra_pcm.c
@@ -131,7 +131,9 @@ static void setup_dma_rx_request(struct tegra_dma_req *req,
req->req_sel = dmap->req_sel;
}
-static int tegra_pcm_open(struct snd_pcm_substream *substream)
+int tegra_pcm_allocate(struct snd_pcm_substream *substream,
+ int dma_mode,
+ const struct snd_pcm_hardware *pcm_hardware)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct tegra_runtime_data *prtd;
@@ -157,7 +159,7 @@ static int tegra_pcm_open(struct snd_pcm_substream *substream)
prtd->dma_req[i].dev = prtd;
prtd->dma_chan = tegra_dma_allocate_channel(
- TEGRA_DMA_MODE_CONTINUOUS_SINGLE,
+ dma_mode,
"pcm");
if (prtd->dma_chan == NULL) {
ret = -ENOMEM;
@@ -166,7 +168,7 @@ static int tegra_pcm_open(struct snd_pcm_substream *substream)
}
/* Set HW params now that initialization is complete */
- snd_soc_set_runtime_hwparams(substream, &tegra_pcm_hardware);
+ snd_soc_set_runtime_hwparams(substream, pcm_hardware);
/* Ensure period size is multiple of 8 */
ret = snd_pcm_hw_constraint_step(runtime, 0,
@@ -192,7 +194,15 @@ err:
return ret;
}
-static int tegra_pcm_close(struct snd_pcm_substream *substream)
+static int tegra_pcm_open(struct snd_pcm_substream *substream)
+{
+ return tegra_pcm_allocate(substream,
+ TEGRA_DMA_MODE_CONTINUOUS_SINGLE,
+ &tegra_pcm_hardware);
+
+}
+
+int tegra_pcm_close(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct tegra_runtime_data *prtd = runtime->private_data;
@@ -205,7 +215,7 @@ static int tegra_pcm_close(struct snd_pcm_substream *substream)
return 0;
}
-static int tegra_pcm_hw_params(struct snd_pcm_substream *substream,
+int tegra_pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_pcm_runtime *runtime = substream->runtime;
@@ -235,14 +245,14 @@ static int tegra_pcm_hw_params(struct snd_pcm_substream *substream,
return 0;
}
-static int tegra_pcm_hw_free(struct snd_pcm_substream *substream)
+int tegra_pcm_hw_free(struct snd_pcm_substream *substream)
{
snd_pcm_set_runtime_buffer(substream, NULL);
return 0;
}
-static int tegra_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
+int tegra_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct tegra_runtime_data *prtd = runtime->private_data;
@@ -284,7 +294,7 @@ static int tegra_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
return 0;
}
-static snd_pcm_uframes_t tegra_pcm_pointer(struct snd_pcm_substream *substream)
+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;
@@ -297,7 +307,7 @@ static snd_pcm_uframes_t tegra_pcm_pointer(struct snd_pcm_substream *substream)
bytes_to_frames(runtime, dma_transfer_count);
}
-static int tegra_pcm_mmap(struct snd_pcm_substream *substream,
+int tegra_pcm_mmap(struct snd_pcm_substream *substream,
struct vm_area_struct *vma)
{
struct snd_pcm_runtime *runtime = substream->runtime;
@@ -319,11 +329,11 @@ static struct snd_pcm_ops tegra_pcm_ops = {
.mmap = tegra_pcm_mmap,
};
-static int tegra_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream)
+static int tegra_pcm_preallocate_dma_buffer(struct snd_pcm *pcm,
+ int stream , size_t size)
{
struct snd_pcm_substream *substream = pcm->streams[stream].substream;
struct snd_dma_buffer *buf = &substream->dma_buffer;
- size_t size = tegra_pcm_hardware.buffer_bytes_max;
buf->area = dma_alloc_writecombine(pcm->card->dev, size,
&buf->addr, GFP_KERNEL);
@@ -338,7 +348,7 @@ static int tegra_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream)
return 0;
}
-static void tegra_pcm_deallocate_dma_buffer(struct snd_pcm *pcm, int stream)
+void tegra_pcm_deallocate_dma_buffer(struct snd_pcm *pcm, int stream)
{
struct snd_pcm_substream *substream;
struct snd_dma_buffer *buf;
@@ -358,7 +368,7 @@ static void tegra_pcm_deallocate_dma_buffer(struct snd_pcm *pcm, int stream)
static u64 tegra_dma_mask = DMA_BIT_MASK(32);
-static int tegra_pcm_new(struct snd_soc_pcm_runtime *rtd)
+int tegra_pcm_dma_allocate(struct snd_soc_pcm_runtime *rtd, size_t size)
{
struct snd_card *card = rtd->card->snd_card;
struct snd_soc_dai *dai = rtd->cpu_dai;
@@ -372,14 +382,16 @@ static int tegra_pcm_new(struct snd_soc_pcm_runtime *rtd)
if (dai->driver->playback.channels_min) {
ret = tegra_pcm_preallocate_dma_buffer(pcm,
- SNDRV_PCM_STREAM_PLAYBACK);
+ SNDRV_PCM_STREAM_PLAYBACK,
+ size);
if (ret)
goto err;
}
if (dai->driver->capture.channels_min) {
ret = tegra_pcm_preallocate_dma_buffer(pcm,
- SNDRV_PCM_STREAM_CAPTURE);
+ SNDRV_PCM_STREAM_CAPTURE,
+ size);
if (ret)
goto err_free_play;
}
@@ -392,7 +404,13 @@ err:
return ret;
}
-static void tegra_pcm_free(struct snd_pcm *pcm)
+int tegra_pcm_new(struct snd_soc_pcm_runtime *rtd)
+{
+ return tegra_pcm_dma_allocate(rtd ,
+ tegra_pcm_hardware.buffer_bytes_max);
+}
+
+void tegra_pcm_free(struct snd_pcm *pcm)
{
tegra_pcm_deallocate_dma_buffer(pcm, SNDRV_PCM_STREAM_CAPTURE);
tegra_pcm_deallocate_dma_buffer(pcm, SNDRV_PCM_STREAM_PLAYBACK);