ASoC: wcd-mbhc: fix inconsistent detection of euro headset

Cross connection sometimes gets detected late. The issue faced is
cable is reported as headset initially, cross connection is
detected later. But before confirming cross connection, playback
starts on headset, so checking for cross connection is not
confirmed. Cable remains reported as headset. So check for cross
connection just before reporting headset.

CRs-Fixed: 1028002
Change-Id: Ida4f277f13c9a193cd7c92063b99bcf1104f107e
Signed-off-by: Divya Ojha <dojha@codeaurora.org>
This commit is contained in:
dojha 2016-07-07 14:25:16 +05:30 committed by Gerrit - the friendly Code Review server
parent 2116b44bd3
commit 3f963e0e82

View file

@ -1166,6 +1166,8 @@ static void wcd_correct_swch_plug(struct work_struct *work)
bool micbias1 = false;
int ret = 0;
int rc, spl_hs_count = 0;
int cross_conn;
int try = 0;
pr_debug("%s: enter\n", __func__);
@ -1183,11 +1185,6 @@ static void wcd_correct_swch_plug(struct work_struct *work)
wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);
if (mbhc->current_plug == MBHC_PLUG_TYPE_GND_MIC_SWAP) {
mbhc->current_plug = MBHC_PLUG_TYPE_NONE;
goto correct_plug_type;
}
/* Enable HW FSM */
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 1);
/*
@ -1215,8 +1212,23 @@ static void wcd_correct_swch_plug(struct work_struct *work)
plug_type = MBHC_PLUG_TYPE_INVALID;
}
pr_debug("%s: Valid plug found, plug type is %d\n",
do {
cross_conn = wcd_check_cross_conn(mbhc);
try++;
} while (try < GND_MIC_SWAP_THRESHOLD);
/*
* check for cross coneection 4 times.
* conisder the result of the fourth iteration.
*/
if (cross_conn > 0) {
pr_debug("%s: cross con found, start polling\n",
__func__);
plug_type = MBHC_PLUG_TYPE_GND_MIC_SWAP;
pr_debug("%s: Plug found, plug type is %d\n",
__func__, plug_type);
goto correct_plug_type;
}
if ((plug_type == MBHC_PLUG_TYPE_HEADSET ||
plug_type == MBHC_PLUG_TYPE_HEADPHONE) &&
(!wcd_swch_level_remove(mbhc))) {
@ -1456,10 +1468,7 @@ exit:
static void wcd_mbhc_detect_plug_type(struct wcd_mbhc *mbhc)
{
struct snd_soc_codec *codec = mbhc->codec;
enum wcd_mbhc_plug_type plug_type;
bool micbias1 = false;
int cross_conn;
int try = 0;
pr_debug("%s: enter\n", __func__);
WCD_MBHC_RSC_ASSERT_LOCKED(mbhc);
@ -1480,21 +1489,6 @@ static void wcd_mbhc_detect_plug_type(struct wcd_mbhc *mbhc)
else
wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB);
do {
cross_conn = wcd_check_cross_conn(mbhc);
try++;
} while (try < GND_MIC_SWAP_THRESHOLD);
if (cross_conn > 0) {
pr_debug("%s: cross con found, start polling\n",
__func__);
plug_type = MBHC_PLUG_TYPE_GND_MIC_SWAP;
if (!mbhc->current_plug)
mbhc->current_plug = plug_type;
pr_debug("%s: Plug found, plug type is %d\n",
__func__, plug_type);
}
/* Re-initialize button press completion object */
reinit_completion(&mbhc->btn_press_compl);
wcd_schedule_hs_detect_plug(mbhc, &mbhc->correct_plug_swch);