ASoC: wcd9310: enhance mbhc button press detection performance

If interrupt handler is not quicker than voltage ramp up by button
release, driver requested measurement won't see stable voltage.
Enhance button press detection performance by comparing voltage
measurements from codec hardware only.

CRs-fixed: 376825
Change-Id: I294239df02fb5afeb3527dda85924c06ab15e54c
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
This commit is contained in:
Joonwoo Park 2012-07-23 19:27:52 -07:00 committed by Stephen Boyd
parent 6dfcc72deb
commit d4eafd9091

View file

@ -5936,7 +5936,7 @@ static irqreturn_t tabla_dce_handler(int irq, void *data)
{
int i, mask;
short dce, sta;
s32 mv, mv_s, stamv_s;
s32 mv, mv_s, stamv, stamv_s;
bool vddio;
u16 *btn_high;
int btn = -1, meas = 0;
@ -5988,35 +5988,34 @@ static irqreturn_t tabla_dce_handler(int irq, void *data)
pr_debug("%s: Button is already released shortly after "
"resume\n", __func__);
n_btn_meas = 0;
} else {
pr_debug("%s: Button is already released without "
"resume", __func__);
sta = tabla_codec_read_sta_result(codec);
stamv_s = tabla_codec_sta_dce_v(codec, 0, sta);
if (vddio)
stamv_s = tabla_scale_v_micb_vddio(priv,
stamv_s,
false);
btn = tabla_determine_button(priv, mv_s);
if (btn != tabla_determine_button(priv, stamv_s))
btn = -1;
goto done;
}
}
/* determine pressed button */
/* save hw dce */
btnmeas[meas++] = tabla_determine_button(priv, mv_s);
pr_debug("%s: meas %d - DCE %d,%d,%d button %d\n", __func__,
meas - 1, dce, mv, mv_s, btnmeas[meas - 1]);
if (n_btn_meas == 0)
btn = btnmeas[0];
pr_debug("%s: meas HW - DCE %x,%d,%d button %d\n", __func__,
dce, mv, mv_s, btnmeas[0]);
if (n_btn_meas == 0) {
sta = tabla_codec_read_sta_result(codec);
stamv_s = stamv = tabla_codec_sta_dce_v(codec, 0, sta);
if (vddio)
stamv_s = tabla_scale_v_micb_vddio(priv, stamv, false);
btn = tabla_determine_button(priv, stamv_s);
pr_debug("%s: meas HW - STA %x,%d,%d button %d\n", __func__,
sta, stamv, stamv_s, btn);
BUG_ON(meas != 1);
if (btnmeas[0] != btn)
btn = -1;
}
/* determine pressed button */
for (; ((d->n_btn_meas) && (meas < (d->n_btn_meas + 1))); meas++) {
dce = tabla_codec_sta_dce(codec, 1, false);
mv = tabla_codec_sta_dce_v(codec, 1, dce);
mv_s = vddio ? tabla_scale_v_micb_vddio(priv, mv, false) : mv;
btnmeas[meas] = tabla_determine_button(priv, mv_s);
pr_debug("%s: meas %d - DCE %d,%d,%d button %d\n",
pr_debug("%s: meas %d - DCE %x,%d,%d button %d\n",
__func__, meas, dce, mv, mv_s, btnmeas[meas]);
/* if large enough measurements are collected,
* start to check if last all n_btn_con measurements were