Loading asoc/codecs/wcd-mbhc-adc.c +33 −13 Original line number Diff line number Diff line Loading @@ -370,8 +370,15 @@ static bool wcd_mbhc_adc_check_for_spl_headset(struct wcd_mbhc *mbhc, * btn press/relesae for HEADSET type during correct work. */ output_mv = wcd_measure_adc_once(mbhc, MUX_CTL_IN2P); if (mbhc->hs_thr) adc_threshold = mbhc->hs_thr; else adc_threshold = ((WCD_MBHC_ADC_HS_THRESHOLD_MV * wcd_mbhc_get_micbias(mbhc))/WCD_MBHC_ADC_MICBIAS_MV); if (mbhc->hph_thr) adc_hph_threshold = mbhc->hph_thr; else adc_hph_threshold = ((WCD_MBHC_ADC_HPH_THRESHOLD_MV * wcd_mbhc_get_micbias(mbhc))/ WCD_MBHC_ADC_MICBIAS_MV); Loading Loading @@ -426,7 +433,9 @@ static bool wcd_is_special_headset(struct wcd_mbhc *mbhc) return false; } } if (mbhc->hs_thr) adc_threshold = mbhc->hs_thr; else adc_threshold = ((WCD_MBHC_ADC_HS_THRESHOLD_MV * wcd_mbhc_get_micbias(mbhc)) / WCD_MBHC_ADC_MICBIAS_MV); Loading Loading @@ -556,14 +565,25 @@ static void wcd_micbias_disable(struct wcd_mbhc *mbhc) } } static int wcd_mbhc_get_plug_from_adc(int adc_result) static int wcd_mbhc_get_plug_from_adc(struct wcd_mbhc *mbhc, int adc_result) { enum wcd_mbhc_plug_type plug_type = MBHC_PLUG_TYPE_INVALID; u32 hph_thr = 0, hs_thr = 0; if (mbhc->hs_thr) hs_thr = mbhc->hs_thr; else hs_thr = WCD_MBHC_ADC_HS_THRESHOLD_MV; if (mbhc->hph_thr) hph_thr = mbhc->hph_thr; else hph_thr = WCD_MBHC_ADC_HPH_THRESHOLD_MV; if (adc_result < WCD_MBHC_ADC_HPH_THRESHOLD_MV) if (adc_result < hph_thr) plug_type = MBHC_PLUG_TYPE_HEADPHONE; else if (adc_result > WCD_MBHC_ADC_HS_THRESHOLD_MV) else if (adc_result > hs_thr) plug_type = MBHC_PLUG_TYPE_HIGH_HPH; else plug_type = MBHC_PLUG_TYPE_HEADSET; Loading Loading @@ -612,7 +632,7 @@ static void wcd_correct_swch_plug(struct work_struct *work) } /* Find plug type */ output_mv = wcd_measure_adc_continuous(mbhc); plug_type = wcd_mbhc_get_plug_from_adc(output_mv); plug_type = wcd_mbhc_get_plug_from_adc(mbhc, output_mv); /* * Report plug type if it is either headset or headphone Loading Loading @@ -667,7 +687,7 @@ static void wcd_correct_swch_plug(struct work_struct *work) * instead of hogging system by contineous polling, wait for * sometime and re-check stop request again. */ plug_type = wcd_mbhc_get_plug_from_adc(output_mv); plug_type = wcd_mbhc_get_plug_from_adc(mbhc, output_mv); if ((output_mv > WCD_MBHC_ADC_HS_THRESHOLD_MV) && (spl_hs_count < WCD_MBHC_SPL_HS_CNT)) { Loading Loading @@ -713,7 +733,7 @@ static void wcd_correct_swch_plug(struct work_struct *work) no_gnd_mic_swap_cnt++; pt_gnd_mic_swap_cnt = 0; plug_type = wcd_mbhc_get_plug_from_adc( output_mv); mbhc, output_mv); if ((no_gnd_mic_swap_cnt < GND_MIC_SWAP_THRESHOLD) && (spl_hs_count != WCD_MBHC_SPL_HS_CNT)) { Loading Loading @@ -747,7 +767,7 @@ static void wcd_correct_swch_plug(struct work_struct *work) plug_type); if (plug_type != MBHC_PLUG_TYPE_GND_MIC_SWAP) { plug_type = wcd_mbhc_get_plug_from_adc( output_mv); mbhc, output_mv); if (!spl_hs_reported && spl_hs_count == WCD_MBHC_SPL_HS_CNT) { spl_hs_reported = true; Loading asoc/codecs/wcd-mbhc-v2.c +14 −0 Original line number Diff line number Diff line Loading @@ -1838,6 +1838,8 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec, struct snd_soc_card *card = codec->component.card; const char *hph_switch = "qcom,msm-mbhc-hphl-swh"; const char *gnd_switch = "qcom,msm-mbhc-gnd-swh"; const char *hs_thre = "qcom,msm-mbhc-hs-mic-max-threshold-mv"; const char *hph_thre = "qcom,msm-mbhc-hs-mic-min-threshold-mv"; pr_debug("%s: enter\n", __func__); Loading @@ -1855,6 +1857,18 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec, goto err; } ret = of_property_read_u32(card->dev->of_node, hs_thre, &(mbhc->hs_thr)); if (ret) dev_dbg(card->dev, "%s: missing %s in dt node\n", __func__, hs_thre); ret = of_property_read_u32(card->dev->of_node, hph_thre, &(mbhc->hph_thr)); if (ret) dev_dbg(card->dev, "%s: missing %s in dt node\n", __func__, hph_thre); ret = of_property_read_u32_array(card->dev->of_node, "qcom,msm-mbhc-moist-cfg", hph_moist_config, 3); Loading asoc/codecs/wcd-mbhc-v2.h +2 −0 Original line number Diff line number Diff line Loading @@ -518,6 +518,8 @@ struct wcd_mbhc { bool in_swch_irq_handler; bool hphl_swh; /*track HPHL switch NC / NO */ bool gnd_swh; /*track GND switch NC / NO */ u32 hs_thr; u32 hph_thr; u32 moist_vref; u32 moist_iref; u32 moist_rref; Loading Loading
asoc/codecs/wcd-mbhc-adc.c +33 −13 Original line number Diff line number Diff line Loading @@ -370,8 +370,15 @@ static bool wcd_mbhc_adc_check_for_spl_headset(struct wcd_mbhc *mbhc, * btn press/relesae for HEADSET type during correct work. */ output_mv = wcd_measure_adc_once(mbhc, MUX_CTL_IN2P); if (mbhc->hs_thr) adc_threshold = mbhc->hs_thr; else adc_threshold = ((WCD_MBHC_ADC_HS_THRESHOLD_MV * wcd_mbhc_get_micbias(mbhc))/WCD_MBHC_ADC_MICBIAS_MV); if (mbhc->hph_thr) adc_hph_threshold = mbhc->hph_thr; else adc_hph_threshold = ((WCD_MBHC_ADC_HPH_THRESHOLD_MV * wcd_mbhc_get_micbias(mbhc))/ WCD_MBHC_ADC_MICBIAS_MV); Loading Loading @@ -426,7 +433,9 @@ static bool wcd_is_special_headset(struct wcd_mbhc *mbhc) return false; } } if (mbhc->hs_thr) adc_threshold = mbhc->hs_thr; else adc_threshold = ((WCD_MBHC_ADC_HS_THRESHOLD_MV * wcd_mbhc_get_micbias(mbhc)) / WCD_MBHC_ADC_MICBIAS_MV); Loading Loading @@ -556,14 +565,25 @@ static void wcd_micbias_disable(struct wcd_mbhc *mbhc) } } static int wcd_mbhc_get_plug_from_adc(int adc_result) static int wcd_mbhc_get_plug_from_adc(struct wcd_mbhc *mbhc, int adc_result) { enum wcd_mbhc_plug_type plug_type = MBHC_PLUG_TYPE_INVALID; u32 hph_thr = 0, hs_thr = 0; if (mbhc->hs_thr) hs_thr = mbhc->hs_thr; else hs_thr = WCD_MBHC_ADC_HS_THRESHOLD_MV; if (mbhc->hph_thr) hph_thr = mbhc->hph_thr; else hph_thr = WCD_MBHC_ADC_HPH_THRESHOLD_MV; if (adc_result < WCD_MBHC_ADC_HPH_THRESHOLD_MV) if (adc_result < hph_thr) plug_type = MBHC_PLUG_TYPE_HEADPHONE; else if (adc_result > WCD_MBHC_ADC_HS_THRESHOLD_MV) else if (adc_result > hs_thr) plug_type = MBHC_PLUG_TYPE_HIGH_HPH; else plug_type = MBHC_PLUG_TYPE_HEADSET; Loading Loading @@ -612,7 +632,7 @@ static void wcd_correct_swch_plug(struct work_struct *work) } /* Find plug type */ output_mv = wcd_measure_adc_continuous(mbhc); plug_type = wcd_mbhc_get_plug_from_adc(output_mv); plug_type = wcd_mbhc_get_plug_from_adc(mbhc, output_mv); /* * Report plug type if it is either headset or headphone Loading Loading @@ -667,7 +687,7 @@ static void wcd_correct_swch_plug(struct work_struct *work) * instead of hogging system by contineous polling, wait for * sometime and re-check stop request again. */ plug_type = wcd_mbhc_get_plug_from_adc(output_mv); plug_type = wcd_mbhc_get_plug_from_adc(mbhc, output_mv); if ((output_mv > WCD_MBHC_ADC_HS_THRESHOLD_MV) && (spl_hs_count < WCD_MBHC_SPL_HS_CNT)) { Loading Loading @@ -713,7 +733,7 @@ static void wcd_correct_swch_plug(struct work_struct *work) no_gnd_mic_swap_cnt++; pt_gnd_mic_swap_cnt = 0; plug_type = wcd_mbhc_get_plug_from_adc( output_mv); mbhc, output_mv); if ((no_gnd_mic_swap_cnt < GND_MIC_SWAP_THRESHOLD) && (spl_hs_count != WCD_MBHC_SPL_HS_CNT)) { Loading Loading @@ -747,7 +767,7 @@ static void wcd_correct_swch_plug(struct work_struct *work) plug_type); if (plug_type != MBHC_PLUG_TYPE_GND_MIC_SWAP) { plug_type = wcd_mbhc_get_plug_from_adc( output_mv); mbhc, output_mv); if (!spl_hs_reported && spl_hs_count == WCD_MBHC_SPL_HS_CNT) { spl_hs_reported = true; Loading
asoc/codecs/wcd-mbhc-v2.c +14 −0 Original line number Diff line number Diff line Loading @@ -1838,6 +1838,8 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec, struct snd_soc_card *card = codec->component.card; const char *hph_switch = "qcom,msm-mbhc-hphl-swh"; const char *gnd_switch = "qcom,msm-mbhc-gnd-swh"; const char *hs_thre = "qcom,msm-mbhc-hs-mic-max-threshold-mv"; const char *hph_thre = "qcom,msm-mbhc-hs-mic-min-threshold-mv"; pr_debug("%s: enter\n", __func__); Loading @@ -1855,6 +1857,18 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec, goto err; } ret = of_property_read_u32(card->dev->of_node, hs_thre, &(mbhc->hs_thr)); if (ret) dev_dbg(card->dev, "%s: missing %s in dt node\n", __func__, hs_thre); ret = of_property_read_u32(card->dev->of_node, hph_thre, &(mbhc->hph_thr)); if (ret) dev_dbg(card->dev, "%s: missing %s in dt node\n", __func__, hph_thre); ret = of_property_read_u32_array(card->dev->of_node, "qcom,msm-mbhc-moist-cfg", hph_moist_config, 3); Loading
asoc/codecs/wcd-mbhc-v2.h +2 −0 Original line number Diff line number Diff line Loading @@ -518,6 +518,8 @@ struct wcd_mbhc { bool in_swch_irq_handler; bool hphl_swh; /*track HPHL switch NC / NO */ bool gnd_swh; /*track GND switch NC / NO */ u32 hs_thr; u32 hph_thr; u32 moist_vref; u32 moist_iref; u32 moist_rref; Loading