From 04633df51e49bfc90d92be9b1dedf041e7bc2e9d Mon Sep 17 00:00:00 2001 From: Sebastien Guiriec Date: Sun, 28 Aug 2011 13:36:17 -0500 Subject: ASoC: SDP4430: Use ABE DC offset cancellation Read headset and handsfree trimming values to compensate in ABE by reading HSOTRIM and HFOTRIM registers of TWL6040, passing these offsets to ABE for appropriate DC offset cancellation. According to Phoenix IC revision the trimming steps are different for the headset path. Change-Id: I2bef4208132eebe01353c148aad2b43bdd38d417 Signed-off-by: Sebastien Guiriec Signed-off-by: Misael Lopez Cruz --- sound/soc/omap/sdp4430.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) mode change 100644 => 100755 sound/soc/omap/sdp4430.c (limited to 'sound') diff --git a/sound/soc/omap/sdp4430.c b/sound/soc/omap/sdp4430.c old mode 100644 new mode 100755 index 5079f1e..30ff72b --- a/sound/soc/omap/sdp4430.c +++ b/sound/soc/omap/sdp4430.c @@ -37,6 +37,7 @@ #include "omap-mcpdm.h" #include "omap-abe.h" +#include "omap-abe-dsp.h" #include "omap-pcm.h" #include "omap-mcbsp.h" #include "../codecs/twl6040.h" @@ -247,6 +248,7 @@ static int sdp4430_set_power_mode(struct snd_kcontrol *kcontrol, return 0; twl6040_power_mode = ucontrol->value.integer.value[0]; + abe_dsp_set_power_mode(twl6040_power_mode); return 1; } @@ -321,8 +323,10 @@ static void sdp4430_mcpdm_twl6040_post(struct snd_pcm_substream *substream) static int sdp4430_twl6040_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_codec *codec = rtd->codec; + struct twl6040 *twl6040 = codec->control_data; struct snd_soc_dapm_context *dapm = &codec->dapm; - int ret; + int hsotrim, left_offset, right_offset, mode, ret; + /* Add SDP4430 specific controls */ ret = snd_soc_add_controls(codec, sdp4430_controls, @@ -373,6 +377,20 @@ static int sdp4430_twl6040_init(struct snd_soc_pcm_runtime *rtd) else snd_soc_jack_report(&hs_jack, SND_JACK_HEADSET, SND_JACK_HEADSET); + /* DC offset cancellation computation */ + hsotrim = snd_soc_read(codec, TWL6040_REG_HSOTRIM); + right_offset = (hsotrim & TWL6040_HSRO) >> TWL6040_HSRO_OFFSET; + left_offset = hsotrim & TWL6040_HSLO; + + if (twl6040_get_icrev(twl6040) < TWL6040_REV_1_3) + /* For ES under ES_1.3 HS step is 2 mV */ + mode = 2; + else + /* For ES_1.3 HS step is 1 mV */ + mode = 1; + + abe_dsp_set_hs_offset(left_offset, right_offset, mode); + /* don't wait before switching of HS power */ rtd->pmdown_time = 0; @@ -381,6 +399,16 @@ static int sdp4430_twl6040_init(struct snd_soc_pcm_runtime *rtd) static int sdp4430_twl6040_dl2_init(struct snd_soc_pcm_runtime *rtd) { + struct snd_soc_codec *codec = rtd->codec; + int hfotrim, left_offset, right_offset; + + /* DC offset cancellation computation */ + hfotrim = snd_soc_read(codec, TWL6040_REG_HFOTRIM); + right_offset = (hfotrim & TWL6040_HFRO) >> TWL6040_HFRO_OFFSET; + left_offset = hfotrim & TWL6040_HFLO; + + abe_dsp_set_hf_offset(left_offset, right_offset); + /* don't wait before switching of HF power */ rtd->pmdown_time = 0; -- cgit v1.1