From de2eeab0f0603cfb468962f05b0c4efffb048ef9 Mon Sep 17 00:00:00 2001 From: huangys Date: Fri, 27 Jul 2018 12:13:12 +0800 Subject: [PATCH] extcon-madera: delay to enable mic bias there is obvious noise can be heared when heaset plug in. if we enable micbias when the headset has not been inserted totally. the noise can be transfered to HPHL/HPHR Propagated from: (CR) Change-Id: I9afc1cb0c7a5bad1381ac448774131d4b56a645c Signed-off-by: huangys Reviewed-on: https://gerrit.mot.com/1216722 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Guobin Zhang Submit-Approved: Jira Key --- Documentation/devicetree/bindings/extcon/extcon-madera.txt | 3 +++ drivers/extcon/extcon-madera.c | 6 ++++++ include/linux/extcon/extcon-madera-pdata.h | 3 +++ 3 files changed, 12 insertions(+) diff --git a/Documentation/devicetree/bindings/extcon/extcon-madera.txt b/Documentation/devicetree/bindings/extcon/extcon-madera.txt index 30b8df8bb833..7201c1c37634 100644 --- a/Documentation/devicetree/bindings/extcon/extcon-madera.txt +++ b/Documentation/devicetree/bindings/extcon/extcon-madera.txt @@ -29,6 +29,9 @@ Child node mandatory properties: - reg : output number this configuration applies to, must be 1 Child node optional properties: + - cirrus,init-mic-delay-ms : Additional delay to wait headset plug in totally + delay specified in milliseconds + - cirrus,micd-detect-debounce-ms : Additional software microphone detection debounce specified in milliseconds diff --git a/drivers/extcon/extcon-madera.c b/drivers/extcon/extcon-madera.c index c07cf65d7593..dad5aa8dcd45 100644 --- a/drivers/extcon/extcon-madera.c +++ b/drivers/extcon/extcon-madera.c @@ -2223,6 +2223,9 @@ static irqreturn_t madera_jackdet(int irq, void *data) info->have_mic = false; info->jack_flips = 0; + if (info->pdata->init_mic_delay_ms) + msleep(info->pdata->init_mic_delay_ms); + if (info->pdata->custom_jd) madera_jds_set_state(info, info->pdata->custom_jd); else if (info->pdata->micd_software_compare) @@ -2450,6 +2453,9 @@ static void madera_extcon_process_accdet_node(struct madera_extcon *info, pdata->enabled = true; /* implied by presence of properties node */ pdata->output = out_num; + fwnode_property_read_u32(node, "cirrus,init-mic-delay-ms", + &pdata->init_mic_delay_ms); + fwnode_property_read_u32(node, "cirrus,micd-detect-debounce-ms", &pdata->micd_detect_debounce_ms); diff --git a/include/linux/extcon/extcon-madera-pdata.h b/include/linux/extcon/extcon-madera-pdata.h index 012cad881b17..be31cd326a1a 100644 --- a/include/linux/extcon/extcon-madera-pdata.h +++ b/include/linux/extcon/extcon-madera-pdata.h @@ -92,6 +92,9 @@ struct madera_accdet_pdata { */ u32 hpdet_channel; + /* Extra delay time to wait the headset plug in totally (milliseconds) */ + u32 init_mic_delay_ms; + /** Extra debounce timeout during initial mic detect (milliseconds) */ u32 micd_detect_debounce_ms;