summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNitin Pai <npai@nvidia.com>2011-09-13 17:21:57 +0530
committerRohan Somvanshi <rsomvanshi@nvidia.com>2011-09-16 08:29:36 -0700
commit13de58b54cd48310e3efe125399d3e8da56aec33 (patch)
tree9e31167bedff4070d055717201f728ed1449f9c9
parent34289e3e7df11a223a7c80f0c980a9455f44d3fc (diff)
ARM: tegra: das: Add support for custom codec type
Custom Codec types are needed for supporting TDM based audio codecs like DSPs, MOST interfaces and generic I2S interfaces. Added support for these types of codecs to be used. Change-Id: Ic2f999029ea131d3c6dfdc19eb2a5808dfd85747 Signed-off-by: Nitin Pai <npai@nvidia.com> Reviewed-on: http://git-master/r/52026 Reviewed-by: Songhee Baek <sbaek@nvidia.com> Reviewed-by: David Stemper <dstemper@nvidia.com> Reviewed-by: Scott Peterson <speterson@nvidia.com>
-rw-r--r--arch/arm/mach-tegra/audio_manager.c37
-rw-r--r--arch/arm/mach-tegra/include/mach/tegra_das.h11
-rw-r--r--sound/soc/tegra/tegra_soc_generic_codec.c45
3 files changed, 80 insertions, 13 deletions
diff --git a/arch/arm/mach-tegra/audio_manager.c b/arch/arm/mach-tegra/audio_manager.c
index 0cdff90c968d..6fa1ff8b624d 100644
--- a/arch/arm/mach-tegra/audio_manager.c
+++ b/arch/arm/mach-tegra/audio_manager.c
@@ -1151,6 +1151,41 @@ static inline int init_spdif_port(int fifo_mode)
return 0;
}
+static void init_custom_codec_ports(void)
+{
+ const struct tegra_dap_property *port_info =
+ tegra_das_pdata.tegra_dap_port_info_table;
+ int max_tbl_index =
+ ARRAY_SIZE(tegra_das_pdata.tegra_dap_port_info_table);
+ int i = 0;
+ struct audio_dev_property dev_prop;
+ int port_idx = tegra_das_port_none;
+ struct am_ch_info *ch = NULL;
+ enum tegra_audio_codec_type codec_type;
+
+ for (i = 0 ; i < max_tbl_index; i++) {
+ codec_type = port_info[i].codec_type;
+ if (
+ (codec_type >= tegra_audio_codec_type_custom_1) &&
+ (codec_type <= tegra_audio_codec_type_custom_5)
+ ) {
+
+ memset(&dev_prop,
+ 0 , sizeof(struct audio_dev_property));
+ tegra_das_get_device_property(codec_type, &dev_prop);
+ port_idx = tegra_das_get_device_i2s_port(codec_type);
+ if (port_idx != tegra_das_port_none) {
+ ch = &aud_manager->i2s_ch[port_idx];
+ ch->sfmt.bitsize =
+ get_bit_size(dev_prop.bits_per_sample);
+ ch->sfmt.channels = dev_prop.num_channels - 1;
+ ch->sfmt.samplerate = dev_prop.rate;
+ }
+ }
+ }
+ return;
+}
+
static inline int init_device_port(enum tegra_audio_codec_type codec_type)
{
struct audio_dev_property dev_prop;
@@ -1211,6 +1246,8 @@ int tegra_das_open(void)
init_spdif_port(AUDIO_TX_MODE);
+ init_custom_codec_ports();
+
return err;
fail_clock:
diff --git a/arch/arm/mach-tegra/include/mach/tegra_das.h b/arch/arm/mach-tegra/include/mach/tegra_das.h
index c4d3b890b218..192bd70d4a8c 100644
--- a/arch/arm/mach-tegra/include/mach/tegra_das.h
+++ b/arch/arm/mach-tegra/include/mach/tegra_das.h
@@ -107,7 +107,11 @@ typedef enum tegra_das_port_t {
#define MAX_DAP_PORTS (tegra_das_port_i2s4 + 1)
#endif
-/* defines possible hardware connected to DAP */
+/* Defines possible hardware connected to DAP
+ * Also, custom codec types to support
+ * TDM Audio based codecs like DSPs,
+ * MOST or generic interfaces on I2S
+ * */
enum tegra_audio_codec_type {
tegra_audio_codec_type_none = 0,
tegra_audio_codec_type_hifi,
@@ -115,6 +119,11 @@ enum tegra_audio_codec_type {
tegra_audio_codec_type_bluetooth,
tegra_audio_codec_type_baseband,
tegra_audio_codec_type_fm_radio,
+ tegra_audio_codec_type_custom_1,
+ tegra_audio_codec_type_custom_2,
+ tegra_audio_codec_type_custom_3,
+ tegra_audio_codec_type_custom_4,
+ tegra_audio_codec_type_custom_5,
};
/* index for possible connection based on the use case */
diff --git a/sound/soc/tegra/tegra_soc_generic_codec.c b/sound/soc/tegra/tegra_soc_generic_codec.c
index 7cdb6b03983f..753a1d50efad 100644
--- a/sound/soc/tegra/tegra_soc_generic_codec.c
+++ b/sound/soc/tegra/tegra_soc_generic_codec.c
@@ -28,7 +28,8 @@ extern struct snd_soc_dai tegra_i2s_dai[];
extern struct snd_soc_platform tegra_soc_platform;
static int tegra_hifi_hw_params(struct snd_pcm_substream *substream,
- struct snd_pcm_hw_params *params)
+ struct snd_pcm_hw_params *params,
+ int tegra_audio_codec_num)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
@@ -41,12 +42,10 @@ static int tegra_hifi_hw_params(struct snd_pcm_substream *substream,
data_fmt = dac_dap_data_format_i2s;
-#ifdef CONFIG_ARCH_TEGRA_2x_SOC
- data_fmt = tegra_das_get_codec_data_fmt(tegra_audio_codec_type_hifi);
- if (tegra_das_is_port_master(tegra_audio_codec_type_hifi))
+ data_fmt = tegra_das_get_codec_data_fmt(tegra_audio_codec_num);
+ if (tegra_das_is_port_master(tegra_audio_codec_num))
dai_flag |= SND_SOC_DAIFMT_CBM_CFM;
else
-#endif
dai_flag |= SND_SOC_DAIFMT_CBS_CFS;
if ((data_fmt & dac_dap_data_format_tdm))
@@ -75,6 +74,22 @@ static int tegra_hifi_hw_params(struct snd_pcm_substream *substream,
return 0;
}
+static int tegra_hifi_hw_params_codec_1(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params)
+{
+ return tegra_hifi_hw_params(substream,
+ params,
+ tegra_audio_codec_type_custom_1);
+}
+
+static int tegra_hifi_hw_params_codec_2(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params)
+{
+ return tegra_hifi_hw_params(substream,
+ params,
+ tegra_audio_codec_type_custom_2);
+}
+
void tegra_ext_control(struct snd_soc_codec *codec, int new_con)
{
return;
@@ -110,8 +125,14 @@ int tegra_soc_resume_post(struct platform_device *pdev)
return 0;
}
-static struct snd_soc_ops tegra_hifi_ops = {
- .hw_params = tegra_hifi_hw_params,
+static struct snd_soc_ops tegra_hifi_ops_codec_1 = {
+ .hw_params = tegra_hifi_hw_params_codec_1,
+ .startup = tegra_codec_startup,
+ .shutdown = tegra_codec_shutdown,
+};
+
+static struct snd_soc_ops tegra_hifi_ops_codec_2 = {
+ .hw_params = tegra_hifi_hw_params_codec_2,
.startup = tegra_codec_startup,
.shutdown = tegra_codec_shutdown,
};
@@ -171,13 +192,13 @@ generic_codec_init_fail:
* as only one of them can be active at the same time
* */
static struct snd_soc_dai_link tegra_soc_dai[] = {
- TEGRA_CREATE_SOC_DAI_LINK("Generic DIT Codec", "Multi-8",
+ TEGRA_CREATE_SOC_DAI_LINK("DIT Codec", "I2S-Digital",
&tegra_i2s_dai[0], &generic_dit_stub_dai,
- &tegra_hifi_ops),
+ &tegra_hifi_ops_codec_1),
- TEGRA_CREATE_SOC_DAI_LINK("Generic DIT Codec", "Multi-16",
- &tegra_i2s_dai[1],
- &generic_dit_stub_dai, &tegra_hifi_ops),
+ TEGRA_CREATE_SOC_DAI_LINK("DIT Codec", "I2S-Digital",
+ &tegra_i2s_dai[1], &generic_dit_stub_dai,
+ &tegra_hifi_ops_codec_2),
};
static struct tegra_audio_data audio_data = {