summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorScottPeterson <speterson@nvidia.com>2011-07-14 11:21:28 -0700
committerVarun Colbert <vcolbert@nvidia.com>2011-08-01 18:43:36 -0700
commit0743587f8d6ce188f43b74548c490680c4733e7d (patch)
tree53ceb23f50d6aad7e93a8762cb0588c6be88cbc1 /sound
parent01a3bb2e27cd34b1c1716c127b7e82e428506bfb (diff)
ASOC: tegra: Add I2S slave support
Add support for I2S slave mode to alsa driver Change-Id: Id463cb22f57db64f7d6f5859f87ece91424be8cb Reviewed-on: http://git-master/r/43099 Reviewed-by: Varun Colbert <vcolbert@nvidia.com> Tested-by: Varun Colbert <vcolbert@nvidia.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/tegra/tegra_i2s.c2
-rw-r--r--sound/soc/tegra/tegra_soc.h6
-rw-r--r--sound/soc/tegra/tegra_soc_max98088.c67
-rw-r--r--sound/soc/tegra/tegra_soc_wm8753.c27
-rw-r--r--sound/soc/tegra/tegra_soc_wm8903.c30
5 files changed, 75 insertions, 57 deletions
diff --git a/sound/soc/tegra/tegra_i2s.c b/sound/soc/tegra/tegra_i2s.c
index b62f7b6a692e..2e0ac92699fc 100644
--- a/sound/soc/tegra/tegra_i2s.c
+++ b/sound/soc/tegra/tegra_i2s.c
@@ -252,6 +252,8 @@ static int tegra_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai,
static int tegra_i2s_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
int clk_id, unsigned int freq, int dir)
{
+ struct tegra_i2s_info *info = cpu_dai->private_data;
+ am_clock_set_rate(&info->i2sdev_info, freq);
return 0;
}
diff --git a/sound/soc/tegra/tegra_soc.h b/sound/soc/tegra/tegra_soc.h
index 566a82d7274b..a2ff63f3d511 100644
--- a/sound/soc/tegra/tegra_soc.h
+++ b/sound/soc/tegra/tegra_soc.h
@@ -69,9 +69,9 @@
#define STATE_EXITED 3
#define STATE_INVALID 4
-#define I2S1_CLK 11289600
+#define I2S1_CLK 12288000
#define I2S2_CLK 2000000
-#define TEGRA_DEFAULT_SR 44100
+#define TEGRA_DEFAULT_SR 48000
#define TEGRA_INT_I2SLOOPBACK_ON 1
#define TEGRA_INT_I2SLOOPBACK_OFF 0
@@ -123,6 +123,7 @@ struct tegra_audio_data {
int codec_con;
};
+
/* i2s controller */
struct tegra_i2s_info {
struct platform_device *pdev;
@@ -135,6 +136,7 @@ struct tegra_i2s_info {
struct das_regs_cache das_regs;
};
+
void tegra_ext_control(struct snd_soc_codec *codec, int new_con);
int tegra_controls_init(struct snd_soc_codec *codec);
diff --git a/sound/soc/tegra/tegra_soc_max98088.c b/sound/soc/tegra/tegra_soc_max98088.c
index 82e0c88cd239..e5886893e45c 100644
--- a/sound/soc/tegra/tegra_soc_max98088.c
+++ b/sound/soc/tegra/tegra_soc_max98088.c
@@ -74,54 +74,39 @@ static int tegra_hifi_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
int sys_clk;
int err;
-
-#if 0
-#ifdef CONFIG_ARCH_TEGRA_2x_SOC
- int dai_flag = 0;
+ int dai_flag = SND_SOC_DAIFMT_NB_NF;
enum dac_dap_data_format data_fmt;
+ struct audio_dev_property dev_prop;
+#ifdef CONFIG_ARCH_TEGRA_2x_SOC
if (tegra_das_is_port_master(tegra_audio_codec_type_hifi))
+#else
+ if(tegra_das_is_device_master(tegra_audio_codec_type_hifi))
+#endif
dai_flag |= SND_SOC_DAIFMT_CBM_CFM;
else
-#endif
dai_flag |= SND_SOC_DAIFMT_CBS_CFS;
+
#ifdef CONFIG_ARCH_TEGRA_2x_SOC
data_fmt = tegra_das_get_codec_data_fmt(tegra_audio_codec_type_hifi);
-
+#else
+ tegra_das_get_device_property(tegra_audio_codec_type_hifi,&dev_prop);
+ data_fmt = dev_prop.dac_dap_data_comm_format;
+#endif
/* We are supporting DSP and I2s format for now */
if (data_fmt & dac_dap_data_format_dsp)
dai_flag |= SND_SOC_DAIFMT_DSP_A;
else
-#endif
dai_flag |= SND_SOC_DAIFMT_I2S;
- err = snd_soc_dai_set_fmt(codec_dai, dai_flag);
- if (err < 0) {
- pr_err("codec_dai fmt not set\n");
- return err;
- }
-
- err = snd_soc_dai_set_fmt(cpu_dai, dai_flag);
- if (err < 0) {
- pr_err("cpu_dai fmt not set\n");
- return err;
- }
-#endif
-
- err = snd_soc_dai_set_fmt(codec_dai,
- SND_SOC_DAIFMT_I2S | \
- SND_SOC_DAIFMT_NB_NF | \
- SND_SOC_DAIFMT_CBS_CFS);
+ err = snd_soc_dai_set_fmt(codec_dai,dai_flag);
if (err < 0) {
pr_err("codec_dai fmt not set\n");
return err;
}
- err = snd_soc_dai_set_fmt(cpu_dai,
- SND_SOC_DAIFMT_I2S | \
- SND_SOC_DAIFMT_NB_NF | \
- SND_SOC_DAIFMT_CBS_CFS);
+ err = snd_soc_dai_set_fmt(cpu_dai,dai_flag);
if (err < 0) {
pr_err("cpu_dai fmt not set\n");
return err;
@@ -153,24 +138,29 @@ static int tegra_voice_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
int dai_flag = 0, sys_clk;
int err;
-
-#ifdef CONFIG_ARCH_TEGRA_2x_SOC
enum dac_dap_data_format data_fmt;
+ struct audio_dev_property dev_prop;
+#ifdef CONFIG_ARCH_TEGRA_2x_SOC
if (tegra_das_is_port_master(tegra_audio_codec_type_bluetooth))
+#else
+ if(tegra_das_is_device_master(tegra_audio_codec_type_bluetooth))
+#endif
dai_flag |= SND_SOC_DAIFMT_CBM_CFM;
else
-#endif
dai_flag |= SND_SOC_DAIFMT_CBS_CFS;
+
#ifdef CONFIG_ARCH_TEGRA_2x_SOC
data_fmt = tegra_das_get_codec_data_fmt(tegra_audio_codec_type_bluetooth);
-
+#else
+ tegra_das_get_device_property(tegra_audio_codec_type_bluetooth,&dev_prop);
+ data_fmt = dev_prop.dac_dap_data_comm_format;
+#endif
/* We are supporting DSP and I2s format for now */
if (data_fmt & dac_dap_data_format_i2s)
dai_flag |= SND_SOC_DAIFMT_I2S;
else
-#endif
dai_flag |= SND_SOC_DAIFMT_DSP_A;
err = snd_soc_dai_set_fmt(codec_dai, dai_flag);
@@ -390,9 +380,9 @@ static const struct snd_soc_dapm_widget tegra_dapm_widgets[] = {
SND_SOC_DAPM_HP("Headset Out", NULL),
SND_SOC_DAPM_MIC("Headset In", NULL),
SND_SOC_DAPM_SPK("Lineout", NULL),
- SND_SOC_DAPM_SPK("Int Spk", tegra_dapm_event_int_spk),
- SND_SOC_DAPM_MIC("Ext Mic", tegra_dapm_event_ext_mic),
- SND_SOC_DAPM_MIC("Int Mic", tegra_dapm_event_int_mic),
+ SND_SOC_DAPM_SPK("Int Spk", NULL),
+ SND_SOC_DAPM_MIC("Ext Mic", NULL),
+ SND_SOC_DAPM_MIC("Int Mic", NULL),
SND_SOC_DAPM_LINE("Linein", NULL),
};
@@ -404,11 +394,16 @@ static const struct snd_soc_dapm_route audio_map[] = {
/* Headset connected to HPL and HPR */
{"Headset Out", NULL, "HPL"},
{"Headset Out", NULL, "HPR"},
+ {"MIC2", NULL, "Headset In"},
/* Speaker connected to SPKL and SPKR */
{"Int Spk", NULL, "SPKL"},
{"Int Spk", NULL, "SPKR"},
+ /* internal mic */
+ {"MIC1", NULL, "Int Mic"},
+ {"MIC1", NULL, "Int Mic"},
+
/*
* To be complete, add remained in/out devices such as built-in mic
* and headset mic.
diff --git a/sound/soc/tegra/tegra_soc_wm8753.c b/sound/soc/tegra/tegra_soc_wm8753.c
index d8afe93246cd..72c5751f50a4 100644
--- a/sound/soc/tegra/tegra_soc_wm8753.c
+++ b/sound/soc/tegra/tegra_soc_wm8753.c
@@ -157,23 +157,28 @@ static int tegra_hifi_hw_params(struct snd_pcm_substream *substream,
int dai_flag = 0, sys_clk;
unsigned int value;
int err;
+ enum dac_dap_data_format data_fmt;
+ struct audio_dev_property dev_prop;
#ifdef CONFIG_ARCH_TEGRA_2x_SOC
- enum dac_dap_data_format data_fmt;
if (tegra_das_is_port_master(tegra_audio_codec_type_hifi))
+#else
+ if(tegra_das_is_device_master(tegra_audio_codec_type_hifi))
+#endif
dai_flag |= SND_SOC_DAIFMT_CBM_CFM;
else
-#endif
dai_flag |= SND_SOC_DAIFMT_CBS_CFS;
#ifdef CONFIG_ARCH_TEGRA_2x_SOC
data_fmt = tegra_das_get_codec_data_fmt(tegra_audio_codec_type_hifi);
-
+#else
+ tegra_das_get_device_property(tegra_audio_codec_type_hifi,&dev_prop);
+ data_fmt = dev_prop.dac_dap_data_comm_format;
+#endif
/* We are supporting DSP and I2s format for now */
if (data_fmt & dac_dap_data_format_dsp)
dai_flag |= SND_SOC_DAIFMT_DSP_A;
else
-#endif
dai_flag |= SND_SOC_DAIFMT_I2S;
err = snd_soc_dai_set_fmt(codec_dai, dai_flag);
@@ -323,24 +328,28 @@ static int tegra_voice_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
int dai_flag = 0, sys_clk;
int err;
-
-#ifdef CONFIG_ARCH_TEGRA_2x_SOC
enum dac_dap_data_format data_fmt;
+ struct audio_dev_property dev_prop;
+#ifdef CONFIG_ARCH_TEGRA_2x_SOC
if (tegra_das_is_port_master(tegra_audio_codec_type_bluetooth))
+#else
+ if(tegra_das_is_device_master(tegra_audio_codec_type_bluetooth))
+#endif
dai_flag |= SND_SOC_DAIFMT_CBM_CFM;
else
-#endif
dai_flag |= SND_SOC_DAIFMT_CBS_CFS;
#ifdef CONFIG_ARCH_TEGRA_2x_SOC
data_fmt = tegra_das_get_codec_data_fmt(tegra_audio_codec_type_bluetooth);
-
+#else
+ tegra_das_get_device_property(tegra_audio_codec_type_bluetooth,&dev_prop);
+ data_fmt = dev_prop.dac_dap_data_comm_format;
+#endif
/* We are supporting DSP and I2s format for now */
if (data_fmt & dac_dap_data_format_i2s)
dai_flag |= SND_SOC_DAIFMT_I2S;
else
-#endif
dai_flag |= SND_SOC_DAIFMT_DSP_A;
err = snd_soc_dai_set_fmt(codec_dai, dai_flag);
diff --git a/sound/soc/tegra/tegra_soc_wm8903.c b/sound/soc/tegra/tegra_soc_wm8903.c
index 203b1ecadb05..4e747fa8b100 100644
--- a/sound/soc/tegra/tegra_soc_wm8903.c
+++ b/sound/soc/tegra/tegra_soc_wm8903.c
@@ -74,26 +74,31 @@ static int tegra_hifi_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
struct snd_soc_codec *codec = codec_dai->codec;
+ struct tegra_i2s_info *info = cpu_dai->private_data;
int dai_flag = 0, sys_clk;
int err;
-
-#ifdef CONFIG_ARCH_TEGRA_2x_SOC
enum dac_dap_data_format data_fmt;
+ struct audio_dev_property dev_prop;
+#ifdef CONFIG_ARCH_TEGRA_2x_SOC
if (tegra_das_is_port_master(tegra_audio_codec_type_hifi))
+#else
+ if(tegra_das_is_device_master(tegra_audio_codec_type_hifi))
+#endif
dai_flag |= SND_SOC_DAIFMT_CBM_CFM;
else
-#endif
dai_flag |= SND_SOC_DAIFMT_CBS_CFS;
#ifdef CONFIG_ARCH_TEGRA_2x_SOC
data_fmt = tegra_das_get_codec_data_fmt(tegra_audio_codec_type_hifi);
-
+#else
+ tegra_das_get_device_property(tegra_audio_codec_type_hifi,&dev_prop);
+ data_fmt = dev_prop.dac_dap_data_comm_format;
+#endif
/* We are supporting DSP and I2s format for now */
if (data_fmt & dac_dap_data_format_dsp)
dai_flag |= SND_SOC_DAIFMT_DSP_A;
else
-#endif
dai_flag |= SND_SOC_DAIFMT_I2S;
err = snd_soc_dai_set_fmt(codec_dai, dai_flag);
@@ -211,26 +216,31 @@ static int tegra_voice_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
+ struct tegra_i2s_info *info = cpu_dai->private_data;
int dai_flag = 0, sys_clk;
int err;
-
-#ifdef CONFIG_ARCH_TEGRA_2x_SOC
enum dac_dap_data_format data_fmt;
+ struct audio_dev_property dev_prop;
+#ifdef CONFIG_ARCH_TEGRA_2x_SOC
if (tegra_das_is_port_master(tegra_audio_codec_type_bluetooth))
+#else
+ if(tegra_das_is_device_master(tegra_audio_codec_type_bluetooth))
+#endif
dai_flag |= SND_SOC_DAIFMT_CBM_CFM;
else
-#endif
dai_flag |= SND_SOC_DAIFMT_CBS_CFS;
#ifdef CONFIG_ARCH_TEGRA_2x_SOC
data_fmt = tegra_das_get_codec_data_fmt(tegra_audio_codec_type_bluetooth);
-
+#else
+ tegra_das_get_device_property(tegra_audio_codec_type_bluetooth,&dev_prop);
+ data_fmt = dev_prop.dac_dap_data_comm_format;
+#endif
/* We are supporting DSP and I2s format for now */
if (data_fmt & dac_dap_data_format_i2s)
dai_flag |= SND_SOC_DAIFMT_I2S;
else
-#endif
dai_flag |= SND_SOC_DAIFMT_DSP_A;
err = snd_soc_dai_set_fmt(codec_dai, dai_flag);