ASoC: WCD9310: Add Calibration voltages for button polling
For accurate button press detection, it is required to program
the MBHC registers with threshold values for microphone voltage.
This enables the MBHC hardware to generate a button press interrupt
only when the microphone voltage is below the programmed thershold
Change-Id: Ib8a38874357e00fe0c797ad40c3da040bbc83cc2
Signed-off-by: Bhalchandra Gajare <gajare@codeaurora.org>
diff --git a/sound/soc/codecs/wcd9310.c b/sound/soc/codecs/wcd9310.c
index 080b458..ff66566 100644
--- a/sound/soc/codecs/wcd9310.c
+++ b/sound/soc/codecs/wcd9310.c
@@ -1935,9 +1935,11 @@
static void tabla_codec_calibrate_hs_polling(struct snd_soc_codec *codec)
{
/* TODO store register values in calibration */
+ snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B5_CTL, 0x20);
+ snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B6_CTL, 0xFF);
snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B10_CTL, 0xFF);
- snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B9_CTL, 0x00);
+ snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B9_CTL, 0x20);
snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B4_CTL, 0x08);
snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B3_CTL, 0xEE);
@@ -2420,9 +2422,12 @@
tabla_disable_irq(codec->control_data, TABLA_IRQ_MBHC_POTENTIAL);
bias_value = tabla_codec_read_dce_result(codec);
- pr_debug("%s: button press interrupt, bias value is %d\n",
+ pr_debug("%s: button press interrupt, bias value(DCE Read)=%d\n",
__func__, bias_value);
+ bias_value = tabla_codec_read_sta_result(codec);
+ pr_debug("%s: button press interrupt, bias value(STA Read)=%d\n",
+ __func__, bias_value);
/*
* TODO: If button pressed is not button 0,
* report the button press event immediately.
@@ -2446,6 +2451,10 @@
pr_debug("%s\n", __func__);
tabla_disable_irq(codec->control_data, TABLA_IRQ_MBHC_RELEASE);
+ mic_voltage = tabla_codec_read_dce_result(codec);
+ pr_debug("%s: Microphone Voltage on release(DCE Read) = %d\n",
+ __func__, mic_voltage);
+
if (priv->buttons_pressed & SND_JACK_BTN_0) {
ret = cancel_delayed_work(&priv->btn0_dwork);
@@ -2462,7 +2471,7 @@
mic_voltage =
tabla_codec_measure_micbias_voltage(codec, 0);
- pr_debug("%s: Microphone Voltage on release = %d\n",
+ pr_debug("%s: Mic Voltage on release(new STA) = %d\n",
__func__, mic_voltage);
if (mic_voltage < -2000 || mic_voltage > -670) {