summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Peterson <speterson@nvidia.com>2013-05-27 17:27:58 -0700
committerMandar Padmawar <mpadmawar@nvidia.com>2013-05-30 01:05:23 -0700
commit482977e3c5e948394bdafb638dfc5a3813232a3d (patch)
tree6c301dce363d80edda347cd65811b6e942e9c3a6
parent9e2e8796ce25994cba53bbb69e086f23112e8cf0 (diff)
asoc: roth: Headphone detection improvement
Improve headphone jack detection in certain scenarios. Bug 1296602 Change-Id: I748f7649680ad60edbc450c09027cb3b76552f8c Signed-off-by: Scott Peterson <speterson@nvidia.com> Reviewed-on: http://git-master/r/233081 Reviewed-by: Vinod Subbarayalu <vsubbarayalu@nvidia.com> Reviewed-by: Matt Wagner <mwagner@nvidia.com>
-rw-r--r--sound/soc/tegra/tegra_rt5640.c56
1 files changed, 41 insertions, 15 deletions
diff --git a/sound/soc/tegra/tegra_rt5640.c b/sound/soc/tegra/tegra_rt5640.c
index 717ff11960a2..f6fe7f5d2f19 100644
--- a/sound/soc/tegra/tegra_rt5640.c
+++ b/sound/soc/tegra/tegra_rt5640.c
@@ -161,8 +161,8 @@ static int tegra_rt5640_hw_params(struct snd_pcm_substream *substream,
dev_err(card->dev, "codec_dai clock not set\n");
return err;
}
- if(machine_is_roth()) {
- if(initTfa == 1) {
+ if (machine_is_roth()) {
+ if (initTfa == 1) {
i2s_tfa = i2s;
tegra_asoc_enable_clocks();
pr_info("INIT TFA\n");
@@ -429,7 +429,6 @@ static int tegra_rt5640_event_int_spk(struct snd_soc_dapm_widget *w,
struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(card);
struct tegra_asoc_platform_data *pdata = machine->pdata;
- machine->speaker_sel = 1;
if (machine->spk_reg) {
if (SND_SOC_DAPM_EVENT_ON(event)) {
regulator_enable(machine->spk_reg);
@@ -439,15 +438,24 @@ static int tegra_rt5640_event_int_spk(struct snd_soc_dapm_widget *w,
}
}
- if(machine_is_roth()) {
- if (SND_SOC_DAPM_EVENT_ON(event)) {
- if(i2s_tfa && !machine->tfa9887_on) {
- if (codec_rt)
- snd_soc_update_bits(codec_rt, RT5640_PWR_DIG1, 0x0001, 0x0000);
+ if (machine_is_roth()) {
+ if (i2s_tfa) {
+ if (SND_SOC_DAPM_EVENT_ON(event)) {
+ machine->speaker_sel = 1;
+ if (!machine->tfa9887_on) {
+ if (codec_rt)
+ snd_soc_update_bits(codec_rt,
+ RT5640_PWR_DIG1, 0x0001, 0x0000);
+ tegra_asoc_enable_clocks();
+ Tfa9887_Powerdown(0);
+ tegra_asoc_disable_clocks();
+ machine->tfa9887_on = 1;
+ }
+ } else {
tegra_asoc_enable_clocks();
- Tfa9887_Powerdown(0);
+ Tfa9887_Powerdown(1);
tegra_asoc_disable_clocks();
- machine->tfa9887_on = 1;
+ machine->tfa9887_on = 0;
}
}
}
@@ -470,6 +478,17 @@ static int tegra_rt5640_event_hp(struct snd_soc_dapm_widget *w,
struct tegra_asoc_platform_data *pdata = machine->pdata;
machine->speaker_sel = 0;
+ if (machine_is_roth()) {
+ if (i2s_tfa) {
+ if (SND_SOC_DAPM_EVENT_ON(event)) {
+ tegra_asoc_enable_clocks();
+ Tfa9887_Powerdown(1);
+ tegra_asoc_disable_clocks();
+ machine->tfa9887_on = 0;
+ }
+ }
+ }
+
if (!(machine->gpio_requested & GPIO_HP_MUTE))
return 0;
@@ -557,7 +576,6 @@ static int tegra_set_tfa9887_powerdown(struct snd_kcontrol *kcontrol,
struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(card);
data->tfa9887_powerdown = ucontrol->value.integer.value[0];
- //printk("tegra_set_tfa9887_powerdown powerdown=%d ref=%d\n",data->tfa9887_powerdown,i2s_tfa->playback_ref_count);
if (i2s_tfa->playback_ref_count <= 1) {
Tfa9887_Powerdown(data->tfa9887_powerdown);
machine->tfa9887_on = !data->tfa9887_powerdown;
@@ -723,7 +741,7 @@ static int tegra_rt5640_set_bias_level(struct snd_soc_card *card,
struct snd_soc_dapm_context *dapm, enum snd_soc_bias_level level)
{
struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(card);
- //printk("tegra_rt5640_set_bias_level level =%d spkr_sel=%d\n",level,machine->speaker_sel);
+
if (machine->bias_level == SND_SOC_BIAS_OFF &&
level != SND_SOC_BIAS_OFF && (!machine->clock_enabled)) {
machine->clock_enabled = 1;
@@ -731,11 +749,11 @@ static int tegra_rt5640_set_bias_level(struct snd_soc_card *card,
machine->bias_level = level;
}
- if(machine_is_roth()) {
+ if (machine_is_roth()) {
if (machine->speaker_sel &&
!machine->tfa9887_on &&
level > machine->bias_level) {
- if(i2s_tfa) {
+ if (i2s_tfa) {
if (codec_rt)
snd_soc_update_bits(codec_rt, RT5640_PWR_DIG1, 0x0001, 0x0000);
tegra_asoc_enable_clocks();
@@ -744,7 +762,15 @@ static int tegra_rt5640_set_bias_level(struct snd_soc_card *card,
machine->tfa9887_on = 1;
}
}
- }
+ if (level == SND_SOC_BIAS_OFF) {
+ if (i2s_tfa) {
+ tegra_asoc_enable_clocks();
+ Tfa9887_Powerdown(1);
+ tegra_asoc_disable_clocks();
+ machine->tfa9887_on = 0;
+ }
+ }
+ }
return 0;
}