Loading sound/soc/codecs/wcd9xxx-mbhc.c +26 −22 Original line number Diff line number Diff line Loading @@ -98,7 +98,7 @@ * Invalid voltage range for the detection * of plug type with current source */ #define WCD9XXX_CS_MEAS_INVALD_RANGE_LOW_MV 110 #define WCD9XXX_CS_MEAS_INVALD_RANGE_LOW_MV 160 #define WCD9XXX_CS_MEAS_INVALD_RANGE_HIGH_MV 265 /* Loading @@ -121,7 +121,7 @@ #define WCD9XXX_V_CS_HS_MAX 500 #define WCD9XXX_V_CS_NO_MIC 5 #define WCD9XXX_MB_MEAS_DELTA_MAX_MV 80 #define WCD9XXX_CS_MEAS_DELTA_MAX_MV 10 #define WCD9XXX_CS_MEAS_DELTA_MAX_MV 12 static int impedance_detect_en; module_param(impedance_detect_en, int, Loading Loading @@ -1352,7 +1352,6 @@ wcd9xxx_cs_find_plug_type(struct wcd9xxx_mbhc *mbhc, vdce = __wcd9xxx_codec_sta_dce_v(mbhc, true, d->dce, dce_z, (u32)mb_mv); d->_vdces = vdce; if (d->_vdces < no_mic) d->_type = PLUG_TYPE_HEADPHONE; Loading Loading @@ -1386,14 +1385,6 @@ wcd9xxx_cs_find_plug_type(struct wcd9xxx_mbhc *mbhc, } } if (event_state & (1 << MBHC_EVENT_PA_HPHL)) { pr_debug("%s: HPHL PA was ON\n", __func__); } else if (ch != sz && ch > 0) { pr_debug("%s: Invalid, inconsistent HPHL\n", __func__); type = PLUG_TYPE_INVALID; goto exit; } delta_thr = ((highhph_cnt == sz) || highhph) ? WCD9XXX_MB_MEAS_DELTA_MAX_MV : WCD9XXX_CS_MEAS_DELTA_MAX_MV; Loading Loading @@ -1445,6 +1436,30 @@ wcd9xxx_cs_find_plug_type(struct wcd9xxx_mbhc *mbhc, } } if (type == PLUG_TYPE_HEADSET && dgnd && !dgnd->mic_bias) { /* if plug type is Headphone report as GND_MIC_SWAP */ if (dgnd->_type == PLUG_TYPE_HEADPHONE) { pr_debug("%s: GND_MIC_SWAP\n", __func__); type = PLUG_TYPE_GND_MIC_SWAP; /* * if type is GND_MIC_SWAP we should not check * HPHL status hence goto exit */ goto exit; } else if (dgnd->_type != PLUG_TYPE_HEADSET && !dmicbias) { pr_debug("%s: Invalid, inconsistent types\n", __func__); type = PLUG_TYPE_INVALID; } } if (event_state & (1 << MBHC_EVENT_PA_HPHL)) { pr_debug("%s: HPHL PA was ON\n", __func__); } else if (ch != sz && ch > 0) { pr_debug("%s: Invalid, inconsistent HPHL..\n", __func__); type = PLUG_TYPE_INVALID; goto exit; } if (!(event_state & (1UL << MBHC_EVENT_PA_HPHL))) { if (((type == PLUG_TYPE_HEADSET || type == PLUG_TYPE_HEADPHONE) && ch != sz)) { Loading @@ -1453,17 +1468,6 @@ wcd9xxx_cs_find_plug_type(struct wcd9xxx_mbhc *mbhc, type = PLUG_TYPE_INVALID; } } if (type == PLUG_TYPE_HEADSET && dgnd && !dgnd->mic_bias) { if ((dgnd->_vdces + WCD9XXX_CS_GM_SWAP_THRES_MIN_MV < minv) && (dgnd->_vdces + WCD9XXX_CS_GM_SWAP_THRES_MAX_MV > maxv)) type = PLUG_TYPE_GND_MIC_SWAP; else if (dgnd->_type != PLUG_TYPE_HEADSET && !dmicbias) { pr_debug("%s: Invalid, inconsistent types\n", __func__); type = PLUG_TYPE_INVALID; } } exit: pr_debug("%s: Plug type %d detected\n", __func__, type); return type; Loading Loading
sound/soc/codecs/wcd9xxx-mbhc.c +26 −22 Original line number Diff line number Diff line Loading @@ -98,7 +98,7 @@ * Invalid voltage range for the detection * of plug type with current source */ #define WCD9XXX_CS_MEAS_INVALD_RANGE_LOW_MV 110 #define WCD9XXX_CS_MEAS_INVALD_RANGE_LOW_MV 160 #define WCD9XXX_CS_MEAS_INVALD_RANGE_HIGH_MV 265 /* Loading @@ -121,7 +121,7 @@ #define WCD9XXX_V_CS_HS_MAX 500 #define WCD9XXX_V_CS_NO_MIC 5 #define WCD9XXX_MB_MEAS_DELTA_MAX_MV 80 #define WCD9XXX_CS_MEAS_DELTA_MAX_MV 10 #define WCD9XXX_CS_MEAS_DELTA_MAX_MV 12 static int impedance_detect_en; module_param(impedance_detect_en, int, Loading Loading @@ -1352,7 +1352,6 @@ wcd9xxx_cs_find_plug_type(struct wcd9xxx_mbhc *mbhc, vdce = __wcd9xxx_codec_sta_dce_v(mbhc, true, d->dce, dce_z, (u32)mb_mv); d->_vdces = vdce; if (d->_vdces < no_mic) d->_type = PLUG_TYPE_HEADPHONE; Loading Loading @@ -1386,14 +1385,6 @@ wcd9xxx_cs_find_plug_type(struct wcd9xxx_mbhc *mbhc, } } if (event_state & (1 << MBHC_EVENT_PA_HPHL)) { pr_debug("%s: HPHL PA was ON\n", __func__); } else if (ch != sz && ch > 0) { pr_debug("%s: Invalid, inconsistent HPHL\n", __func__); type = PLUG_TYPE_INVALID; goto exit; } delta_thr = ((highhph_cnt == sz) || highhph) ? WCD9XXX_MB_MEAS_DELTA_MAX_MV : WCD9XXX_CS_MEAS_DELTA_MAX_MV; Loading Loading @@ -1445,6 +1436,30 @@ wcd9xxx_cs_find_plug_type(struct wcd9xxx_mbhc *mbhc, } } if (type == PLUG_TYPE_HEADSET && dgnd && !dgnd->mic_bias) { /* if plug type is Headphone report as GND_MIC_SWAP */ if (dgnd->_type == PLUG_TYPE_HEADPHONE) { pr_debug("%s: GND_MIC_SWAP\n", __func__); type = PLUG_TYPE_GND_MIC_SWAP; /* * if type is GND_MIC_SWAP we should not check * HPHL status hence goto exit */ goto exit; } else if (dgnd->_type != PLUG_TYPE_HEADSET && !dmicbias) { pr_debug("%s: Invalid, inconsistent types\n", __func__); type = PLUG_TYPE_INVALID; } } if (event_state & (1 << MBHC_EVENT_PA_HPHL)) { pr_debug("%s: HPHL PA was ON\n", __func__); } else if (ch != sz && ch > 0) { pr_debug("%s: Invalid, inconsistent HPHL..\n", __func__); type = PLUG_TYPE_INVALID; goto exit; } if (!(event_state & (1UL << MBHC_EVENT_PA_HPHL))) { if (((type == PLUG_TYPE_HEADSET || type == PLUG_TYPE_HEADPHONE) && ch != sz)) { Loading @@ -1453,17 +1468,6 @@ wcd9xxx_cs_find_plug_type(struct wcd9xxx_mbhc *mbhc, type = PLUG_TYPE_INVALID; } } if (type == PLUG_TYPE_HEADSET && dgnd && !dgnd->mic_bias) { if ((dgnd->_vdces + WCD9XXX_CS_GM_SWAP_THRES_MIN_MV < minv) && (dgnd->_vdces + WCD9XXX_CS_GM_SWAP_THRES_MAX_MV > maxv)) type = PLUG_TYPE_GND_MIC_SWAP; else if (dgnd->_type != PLUG_TYPE_HEADSET && !dmicbias) { pr_debug("%s: Invalid, inconsistent types\n", __func__); type = PLUG_TYPE_INVALID; } } exit: pr_debug("%s: Plug type %d detected\n", __func__, type); return type; Loading