From: Wen Xie Date: Tue, 28 May 2019 03:14:34 +0000 (+0800) Subject: Extcon: Fix mic high level of noise. X-Git-Tag: MMI-QSB30.62-17~111 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ff1413ffa5acbb92eb11b8b25f807673441a43f2;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git Extcon: Fix mic high level of noise. cirrus vendor patch: Fix mic high level of noise Set MICD_RATE and POLARITY_INV bit to 0 when a headset with mic is plugged in and set it in a Defenderault state at removail. Change-Id: I7ed17ef425cc3e9e0d03541996e9ea1427ee8013 Signed-off-by: Wen Xie Reviewed-on: https://gerrit.mot.com/1362099 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Zhengming Yao Reviewed-by: Xiangpo Zhao Submit-Approved: Jira Key --- diff --git a/drivers/extcon/extcon-madera.c b/drivers/extcon/extcon-madera.c index 32b278827732..403bc9f685b7 100755 --- a/drivers/extcon/extcon-madera.c +++ b/drivers/extcon/extcon-madera.c @@ -1594,6 +1594,31 @@ static void madera_hpdet_start_micd(struct madera_extcon *info) MADERA_MICD_ENA, MADERA_MICD_ENA); } +void madera_set_magic_bit(struct madera_extcon *info, bool on) +{ + int rate = 1; + struct madera *madera = info->madera; + if (on) { + regmap_update_bits(madera->regmap, + MADERA_ACCESSORY_DETECT_MODE_1, + MADERA_ACCDET_POLARITY_INV_ENA_MASK, + 0); + regmap_update_bits(madera->regmap, MADERA_MIC_DETECT_1_CONTROL_1, + MADERA_MICD_RATE_MASK , + 0); + } else { + if (info->pdata->micd_rate) + rate = info->pdata->micd_rate; + regmap_update_bits(madera->regmap, + MADERA_ACCESSORY_DETECT_MODE_1, + MADERA_ACCDET_POLARITY_INV_ENA_MASK, + MADERA_ACCDET_POLARITY_INV_ENA); + regmap_update_bits(madera->regmap, MADERA_MIC_DETECT_1_CONTROL_1, + MADERA_MICD_RATE_MASK , + rate << MADERA_MICD_RATE_SHIFT); + } +} + static void madera_hpdet_stop_micd(struct madera_extcon *info) { struct madera *madera = info->madera; @@ -1795,6 +1820,8 @@ void madera_hpdet_stop(struct madera_extcon *info) /* Reset back to starting range */ madera_hpdet_stop_micd(info); + madera_set_magic_bit(info, info->have_mic); + regmap_update_bits(madera->regmap, MADERA_HEADPHONE_DETECT_1, MADERA_HP_IMPEDANCE_RANGE_MASK | MADERA_HP_POLL, info->hpdet_init_range << @@ -2434,6 +2461,8 @@ static irqreturn_t madera_jackdet(int irq, void *data) madera_set_headphone_imp(info, MADERA_HP_Z_OPEN); madera_extcon_notify_micd(info, false, 0); + + madera_set_magic_bit(info, false); } out: