Merge "ASoC: wcd-mbhc: update electrical removal detection logic"
This commit is contained in:

committed by
Gerrit - the friendly Code Review server

commit
50091ca0c6
@@ -915,6 +915,8 @@ static irqreturn_t wcd_mbhc_adc_hs_rem_irq(int irq, void *data)
|
||||
struct wcd_mbhc *mbhc = data;
|
||||
unsigned long timeout;
|
||||
int adc_threshold, output_mv, retry = 0;
|
||||
bool hphpa_on = false;
|
||||
u8 moisture_status = 0;
|
||||
|
||||
pr_debug("%s: enter\n", __func__);
|
||||
WCD_MBHC_RSC_LOCK(mbhc);
|
||||
@@ -948,17 +950,59 @@ static irqreturn_t wcd_mbhc_adc_hs_rem_irq(int irq, void *data)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/*
|
||||
* ADC COMPLETE and ELEC_REM interrupts are both enabled for HEADPHONE,
|
||||
* need to reject the ADC COMPLETE interrupt which follows ELEC_REM one
|
||||
* when HEADPHONE is removed.
|
||||
*/
|
||||
if (mbhc->current_plug == MBHC_PLUG_TYPE_HEADPHONE)
|
||||
mbhc->extn_cable_hph_rem = true;
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_DETECTION_DONE, 0);
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ADC_MODE, 0);
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ADC_EN, 0);
|
||||
wcd_mbhc_elec_hs_report_unplug(mbhc);
|
||||
if (mbhc->mbhc_cfg->moisture_en) {
|
||||
if (mbhc->mbhc_cb->hph_pa_on_status)
|
||||
if (mbhc->mbhc_cb->hph_pa_on_status(mbhc->codec)) {
|
||||
hphpa_on = true;
|
||||
WCD_MBHC_REG_UPDATE_BITS(
|
||||
WCD_MBHC_HPHL_PA_EN, 0);
|
||||
WCD_MBHC_REG_UPDATE_BITS(
|
||||
WCD_MBHC_HPH_PA_EN, 0);
|
||||
}
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HPHR_GND, 1);
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HPHL_GND, 1);
|
||||
/* wait for 50ms to get moisture status */
|
||||
usleep_range(50000, 50100);
|
||||
|
||||
WCD_MBHC_REG_READ(WCD_MBHC_MOISTURE_STATUS, moisture_status);
|
||||
}
|
||||
|
||||
if (mbhc->mbhc_cfg->moisture_en && !moisture_status) {
|
||||
pr_debug("%s: moisture present in jack\n", __func__);
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_L_DET_EN, 0);
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MECH_DETECTION_TYPE, 1);
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_L_DET_EN, 1);
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 0);
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_BTN_ISRC_CTL, 0);
|
||||
mbhc->btn_press_intr = false;
|
||||
mbhc->is_btn_press = false;
|
||||
if (mbhc->current_plug == MBHC_PLUG_TYPE_HEADSET)
|
||||
wcd_mbhc_report_plug(mbhc, 0, SND_JACK_HEADSET);
|
||||
else if (mbhc->current_plug == MBHC_PLUG_TYPE_HEADPHONE)
|
||||
wcd_mbhc_report_plug(mbhc, 0, SND_JACK_HEADPHONE);
|
||||
else if (mbhc->current_plug == MBHC_PLUG_TYPE_GND_MIC_SWAP)
|
||||
wcd_mbhc_report_plug(mbhc, 0, SND_JACK_UNSUPPORTED);
|
||||
else if (mbhc->current_plug == MBHC_PLUG_TYPE_HIGH_HPH)
|
||||
wcd_mbhc_report_plug(mbhc, 0, SND_JACK_LINEOUT);
|
||||
} else {
|
||||
/*
|
||||
* ADC COMPLETE and ELEC_REM interrupts are both enabled for
|
||||
* HEADPHONE, need to reject the ADC COMPLETE interrupt which
|
||||
* follows ELEC_REM one when HEADPHONE is removed.
|
||||
*/
|
||||
if (mbhc->current_plug == MBHC_PLUG_TYPE_HEADPHONE)
|
||||
mbhc->extn_cable_hph_rem = true;
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_DETECTION_DONE, 0);
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ADC_MODE, 0);
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ADC_EN, 0);
|
||||
wcd_mbhc_elec_hs_report_unplug(mbhc);
|
||||
|
||||
if (hphpa_on) {
|
||||
hphpa_on = false;
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HPHL_PA_EN, 1);
|
||||
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HPH_PA_EN, 1);
|
||||
}
|
||||
}
|
||||
exit:
|
||||
WCD_MBHC_RSC_UNLOCK(mbhc);
|
||||
pr_debug("%s: leave\n", __func__);
|
||||
|
Reference in New Issue
Block a user