extcon: madera: Fix MICD polarity check

If first MICD key range max is configured too high then
impedence will fall into the first MICD range and MICBIAS
will not be changed for polarity check.
Before skipping the polarity change, make sure the first range max
is low enough to put a wrong polarity headset in the second range.

Change-Id: I42e56172ec6d49ec66290a8ad1e531014908a8d8
Signed-off-by: Vlad Karpovich <Vlad.Karpovich@motorola.com>
Signed-off-by: Ravi Vembu <raviv@motorola.com>

Mot-CRs-Fixed: (CR)
Change-Id: Ic8db2e8da71b98b3b1da09d515ad0a25fa08df16
Reviewed-on: https://gerrit.mot.com/1209640
Reviewed-by: Rav(CR) Vembu <raviv@motorola.com>
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Submit-Approved: Jira Key
This commit is contained in:
Vlad Karpovich 2018-07-13 15:27:54 -05:00 • committed by Ravikumar Vembu
commit ea61ad7739

View file

@ -44,6 +44,8 @@
#define MADERA_MICD_CLAMP_MODE_JD1L_JD2H 0x9
#define MADERA_MICD_CLAMP_MODE_JD1H_JD2H 0xb
#define MADERA_MICD_WRONG_POLARITY 30
#define MADERA_HPDET_MAX_OHM 10000
#define MADERA_HPDET_MAX_HOHM (MADERA_HPDET_MAX_OHM * 100)
#define MADERA_HP_SHORT_IMPEDANCE_MIN 4
@ -1899,7 +1901,8 @@ int madera_micd_mic_reading(struct madera_extcon *info, int val)
* plain headphones. If both polarities report a low
* impedence then give up and report headphones.
*/
if (ohms > info->micd_ranges[0].max &&
if (((info->micd_ranges[0].max > MADERA_MICD_WRONG_POLARITY) ||
(ohms > info->micd_ranges[0].max)) &&
info->num_micd_modes > 1) {
if (info->jack_flips >= info->num_micd_modes * 10) {
dev_dbg(info->dev, "Detected HP/line\n");