ASoC: wcd-mbhc: add support to read new headset detection parameters
To config different headset detection parameters for different hardware, add two new headset detection parameters in device tree and read it in mbhc driver. Change-Id: I10457b7d5eae54eba8a4cd273885a63ebad3ccb3 Signed-off-by: Meng Wang <mwang@codeaurora.org>
This commit is contained in:
parent
383f3df747
commit
4d6a6bef32
3 changed files with 49 additions and 13 deletions
|
@ -370,11 +370,18 @@ 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);
|
||||
adc_threshold = ((WCD_MBHC_ADC_HS_THRESHOLD_MV *
|
||||
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);
|
||||
adc_hph_threshold = ((WCD_MBHC_ADC_HPH_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);
|
||||
|
||||
if (output_mv > adc_threshold || output_mv < adc_hph_threshold) {
|
||||
spl_hs = false;
|
||||
|
@ -426,8 +433,10 @@ static bool wcd_is_special_headset(struct wcd_mbhc *mbhc)
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
adc_threshold = ((WCD_MBHC_ADC_HS_THRESHOLD_MV *
|
||||
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);
|
||||
|
||||
|
@ -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 (adc_result < WCD_MBHC_ADC_HPH_THRESHOLD_MV)
|
||||
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 < 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;
|
||||
|
@ -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
|
||||
|
@ -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)) {
|
||||
|
@ -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)) {
|
||||
|
@ -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;
|
||||
|
|
|
@ -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__);
|
||||
|
||||
|
@ -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);
|
||||
|
|
|
@ -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…
Add table
Reference in a new issue