summaryrefslogtreecommitdiff
path: root/sound/soc/tegra/tegra_i2s.c
diff options
context:
space:
mode:
authorSumit Bhattacharya <sumitb@nvidia.com>2011-03-10 04:32:57 +0530
committerVarun Colbert <vcolbert@nvidia.com>2011-03-17 21:39:18 -0800
commit769ff2f06c1747487e51a8e878ed08bf9226bfca (patch)
treefd6c485b47177546278c3ce86d0cb333b32992f8 /sound/soc/tegra/tegra_i2s.c
parent6eacb310350b0a42ef23b9e982411f066707938e (diff)
tegra-alsa: Integrate spdif driver with alsa
Bug 783013 Bug 788021 Change-Id: I97425d5a24095fe8e8e5b76b9a30eb621999e507 Reviewed-on: http://git-master/r/22330 Reviewed-by: Varun Colbert <vcolbert@nvidia.com> Tested-by: Sumit Bhattacharya <sumitb@nvidia.com> Reviewed-by: Scott Peterson <speterson@nvidia.com> Reviewed-by: Vijay Mali <vmali@nvidia.com>
Diffstat (limited to 'sound/soc/tegra/tegra_i2s.c')
-rw-r--r--sound/soc/tegra/tegra_i2s.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/sound/soc/tegra/tegra_i2s.c b/sound/soc/tegra/tegra_i2s.c
index 9055a3121219..004384041e99 100644
--- a/sound/soc/tegra/tegra_i2s.c
+++ b/sound/soc/tegra/tegra_i2s.c
@@ -34,11 +34,12 @@ struct tegra_i2s_info {
int irq;
/* Control for whole I2S (Data format, etc.) */
unsigned int bit_format;
+ int ref_count;
struct i2s_runtime_data i2s_regs;
struct das_regs_cache das_regs;
};
-void setup_dma_request(struct snd_pcm_substream *substream,
+void setup_i2s_dma_request(struct snd_pcm_substream *substream,
struct tegra_dma_req *req,
void (*dma_callback)(struct tegra_dma_req *req),
void *dma_data)
@@ -266,11 +267,6 @@ static int tegra_i2s_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
if (info && info->i2s_clk) {
clk_set_rate(info->i2s_clk, pdata->i2s_clk_rate);
- if (clk_enable(info->i2s_clk)) {
- pr_err("%s: failed to enable i2s-%d clock\n", __func__,
- cpu_dai->id+1);
- return -EIO;
- }
}
else {
pr_err("%s: could not get i2s-%d clock\n", __func__,
@@ -357,6 +353,8 @@ int tegra_i2s_suspend(struct snd_soc_dai *cpu_dai)
i2s_get_all_regs(cpu_dai->id, &info->i2s_regs);
tegra_das_get_all_regs(&info->das_regs);
+ clk_disable(info->dap_mclk);
+
return 0;
}
@@ -364,6 +362,8 @@ int tegra_i2s_resume(struct snd_soc_dai *cpu_dai)
{
struct tegra_i2s_info *info = cpu_dai->private_data;
+ clk_enable(info->dap_mclk);
+
tegra_das_set_all_regs(&info->das_regs);
i2s_set_all_regs(cpu_dai->id, &info->i2s_regs);
@@ -380,12 +380,14 @@ static int tegra_i2s_startup(struct snd_pcm_substream *substream,
{
struct tegra_i2s_info *info = dai->private_data;
- clk_enable(info->dap_mclk);
- clk_enable(info->audio_sync_clk);
-
- /* set das pins state to normal */
- tegra_das_power_mode(true);
+ if (!info->ref_count) {
+ /* set das pins state to normal */
+ tegra_das_power_mode(true);
+ clk_enable(info->audio_sync_clk);
+ clk_enable(info->i2s_clk);
+ }
+ info->ref_count++;
return 0;
}
@@ -394,11 +396,16 @@ static void tegra_i2s_shutdown(struct snd_pcm_substream *substream,
{
struct tegra_i2s_info *info = dai->private_data;
- /* set das pins state to tristate */
- tegra_das_power_mode(false);
+ if (info->ref_count > 0)
+ info->ref_count--;
- clk_disable(info->dap_mclk);
- clk_disable(info->audio_sync_clk);
+ if (!info->ref_count) {
+ clk_disable(info->i2s_clk);
+ clk_disable(info->audio_sync_clk);
+
+ /* set das pins state to tristate */
+ tegra_das_power_mode(false);
+ }
return;
}
@@ -530,6 +537,7 @@ static int tegra_i2s_driver_probe(struct platform_device *pdev)
err = PTR_ERR(info->dap_mclk);
goto fail_unmap_mem;
}
+ clk_enable(info->dap_mclk);
info->audio_sync_clk = i2s_get_clock_by_name(
info->pdata->audio_sync_clk);