diff options
author | Nikesh Oswal <noswal@nvidia.com> | 2011-08-09 19:32:17 +0530 |
---|---|---|
committer | Varun Colbert <vcolbert@nvidia.com> | 2011-08-18 16:33:44 -0700 |
commit | 53117d4aaac8b5aff8682866644427958e2441b0 (patch) | |
tree | b0ba39cb5a355f65caad6ba6525ac943238b6cc4 | |
parent | c52a7398c2a1960865ddfc75d94403757b1af256 (diff) |
asoc: tegra: bt-sco bringup on enterprise
add code for bt-sco playback and record support
Bug 864984
Change-Id: I003b58f333bcba371129a9069c2b453e1e8380c0
Reviewed-on: http://git-master/r/46084
Tested-by: Nikesh Oswal <noswal@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
-rw-r--r-- | arch/arm/mach-tegra/audio_manager.c | 54 | ||||
-rw-r--r-- | sound/soc/tegra/tegra_soc_max98088.c | 57 |
2 files changed, 92 insertions, 19 deletions
diff --git a/arch/arm/mach-tegra/audio_manager.c b/arch/arm/mach-tegra/audio_manager.c index a983cace9a3f..21bdc0431830 100644 --- a/arch/arm/mach-tegra/audio_manager.c +++ b/arch/arm/mach-tegra/audio_manager.c @@ -389,6 +389,15 @@ int default_record_connection(aud_dev_info *devinfo) } +int default_playback_bt_connection(aud_dev_info *devinfo) +{ + struct am_dev_fns *am_fn = &init_am_dev_fns[devinfo->dev_type]; + return am_fn->aud_dev_get_dma_requestor(devinfo->dev_id, + AUDIO_TX_MODE); + +} + + int default_playback_connection(struct am_ch_info *ch, int ifc, int fifo_mode) { /* get unused dam channel first */ @@ -443,6 +452,7 @@ conn_fail: return -ENOENT; } + int free_dam_connection(aud_dev_info *devinfo) { int damch = 0; @@ -537,24 +547,36 @@ int am_get_dma_requestor(aud_dev_info* devinfo) ch->ahubtx_index = ahubindex; if (fifo_mode == AUDIO_TX_MODE) { - - err = default_playback_connection(ch, - dev_id, fifo_mode); - if (err) - goto fail_conn; - - if (devinfo->dev_type == AUDIO_I2S_DEVICE) { - i2s_set_dma_channel(dev_id, - fifo_mode, (ch->dmach[fifo_mode] - 1)); - i2s_set_acif(dev_id, fifo_mode, &ch->inacif); - } else if (devinfo->dev_type == AUDIO_SPDIF_DEVICE) { - spdif_set_dma_channel(dev_id, - fifo_mode, (ch->dmach[fifo_mode] - 1)); - spdif_set_acif(dev_id, - fifo_mode, (void *)&ch->inacif); + if (dev_id != aud_manager->bt_port_idx) { + err = default_playback_connection(ch, + dev_id, fifo_mode); + if (err) + goto fail_conn; + + if (devinfo->dev_type == AUDIO_I2S_DEVICE) { + i2s_set_dma_channel(dev_id, + fifo_mode, (ch->dmach[fifo_mode] - 1)); + i2s_set_acif(dev_id, fifo_mode, + &ch->inacif); + } else if (devinfo->dev_type + == AUDIO_SPDIF_DEVICE) { + spdif_set_dma_channel(dev_id, + fifo_mode, (ch->dmach[fifo_mode] - 1)); + spdif_set_acif(dev_id, + fifo_mode, (void *)&ch->inacif); + } + } else { + struct am_dev_fns *am_fn = + &init_am_dev_fns[devinfo->dev_type]; + + am_fn->aud_dev_clock_enable(devinfo->dev_id, + fifo_mode); + ch->dmach[fifo_mode] = + default_playback_bt_connection(devinfo); } } else { - struct am_dev_fns *am_fn = &init_am_dev_fns[devinfo->dev_type]; + struct am_dev_fns *am_fn = + &init_am_dev_fns[devinfo->dev_type]; am_fn->aud_dev_clock_enable(devinfo->dev_id, fifo_mode); ch->dmach[fifo_mode] = diff --git a/sound/soc/tegra/tegra_soc_max98088.c b/sound/soc/tegra/tegra_soc_max98088.c index bd38faaf6680..f8bef65e84a5 100644 --- a/sound/soc/tegra/tegra_soc_max98088.c +++ b/sound/soc/tegra/tegra_soc_max98088.c @@ -122,6 +122,51 @@ static int tegra_hifi_hw_params(struct snd_pcm_substream *substream, return 0; } +#ifndef CONFIG_ARCH_TEGRA_2x_SOC +static int tegra_bt_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + 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; + int sys_clk; + int err; + int dai_flag = SND_SOC_DAIFMT_NB_NF; + enum dac_dap_data_format data_fmt; + struct audio_dev_property dev_prop; + + if (tegra_das_is_device_master(tegra_audio_codec_type_bluetooth)) + dai_flag |= SND_SOC_DAIFMT_CBM_CFM; + else + dai_flag |= SND_SOC_DAIFMT_CBS_CFS; + + tegra_das_get_device_property(tegra_audio_codec_type_bluetooth, + &dev_prop); + + data_fmt = dev_prop.dac_dap_data_comm_format; + + /* 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 + 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; + } + + return 0; +} +#endif + static int tegra_voice_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { @@ -207,6 +252,12 @@ static struct snd_soc_ops tegra_voice_ops = { .shutdown = tegra_codec_shutdown, }; +static struct snd_soc_ops tegra_bt_ops = { + .hw_params = tegra_bt_hw_params, + .startup = tegra_codec_startup, + .shutdown = tegra_codec_shutdown, +}; + static struct snd_soc_ops tegra_spdif_ops = { .hw_params = tegra_spdif_hw_params, }; @@ -386,9 +437,9 @@ static struct snd_soc_dai_link tegra_soc_dai[] = { &tegra_i2s_dai[1], &tegra_generic_codec_dai[2], &tegra_voice_ops), #else - TEGRA_CREATE_SOC_DAI_LINK("Tegra-generic", "Tegra Generic Voice", - &tegra_i2s_dai[0], &max98088_dai[0], - &tegra_voice_ops), + TEGRA_CREATE_SOC_DAI_LINK("Tegra-generic", "Tegra BT Voice", + &tegra_i2s_dai[3], &tegra_generic_codec_dai[2], + &tegra_bt_ops), TEGRA_CREATE_SOC_DAI_LINK("Tegra-voice-call", "Tegra Voice Call Max HiFi", |