Loading sound/soc/codecs/wcd-mbhc-v2.c +19 −8 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ #define FW_READ_ATTEMPTS 15 #define FW_READ_TIMEOUT 4000000 #define FAKE_REM_RETRY_ATTEMPTS 3 #define MAX_IMPED 60000 #define WCD_MBHC_BTN_PRESS_COMPL_TIMEOUT_MS 50 Loading Loading @@ -628,8 +629,10 @@ static void wcd_mbhc_report_plug(struct wcd_mbhc *mbhc, int insertion, (mbhc->mbhc_cfg->linein_th != 0)) { mbhc->mbhc_cb->compute_impedance(mbhc, &mbhc->zl, &mbhc->zr); if ((mbhc->zl > mbhc->mbhc_cfg->linein_th) && (mbhc->zr > mbhc->mbhc_cfg->linein_th) && if ((mbhc->zl > mbhc->mbhc_cfg->linein_th && mbhc->zl < MAX_IMPED) && (mbhc->zr > mbhc->mbhc_cfg->linein_th && mbhc->zr < MAX_IMPED) && (jack_type == SND_JACK_HEADPHONE)) { jack_type = SND_JACK_LINEOUT; mbhc->current_plug = MBHC_PLUG_TYPE_HIGH_HPH; Loading Loading @@ -770,7 +773,7 @@ static int wcd_check_cross_conn(struct wcd_mbhc *mbhc) WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ELECT_SCHMT_ISRC, reg1); pr_debug("%s: leave, plug type: %d\n", __func__, plug_type); return (plug_type == MBHC_PLUG_TYPE_GND_MIC_SWAP) ? 1 : 0; return (plug_type == MBHC_PLUG_TYPE_GND_MIC_SWAP) ? true : false; } static bool wcd_is_special_headset(struct wcd_mbhc *mbhc) Loading Loading @@ -936,8 +939,8 @@ static void wcd_correct_swch_plug(struct work_struct *work) bool is_pa_on = false; bool micbias2 = false; bool micbias1 = false; int rc; int ret = 0; int rc; pr_debug("%s: enter\n", __func__); Loading Loading @@ -1036,8 +1039,8 @@ correct_plug_type: */ msleep(180); if ((!hs_comp_res) && (!is_pa_on)) { ret = wcd_check_cross_conn(mbhc); /* Check for cross connection*/ ret = wcd_check_cross_conn(mbhc); if (ret < 0) { continue; } else if (ret > 0) { Loading Loading @@ -1258,8 +1261,10 @@ static void wcd_mbhc_swch_irq_handler(struct wcd_mbhc *mbhc) if (!mbhc->mbhc_cfg->hs_ext_micbias && mbhc->mbhc_cb->micb_internal) /* Enable Tx2 RBias if the headset * is using internal micbias*/ /* * Enable Tx2 RBias if the headset * is using internal micbias */ mbhc->mbhc_cb->micb_internal(codec, 1, true); /* Remove micbias pulldown */ Loading Loading @@ -1994,6 +1999,8 @@ int wcd_mbhc_set_keycode(struct wcd_mbhc *mbhc) i, btn_key_code[i]); } } if (btn_key_code[0]) mbhc->is_btn_already_regd = true; return result; } Loading @@ -2007,7 +2014,7 @@ int wcd_mbhc_start(struct wcd_mbhc *mbhc, mbhc->mbhc_cfg = mbhc_cfg; /* Set btn key code */ if (wcd_mbhc_set_keycode(mbhc)) if ((!mbhc->is_btn_already_regd) && wcd_mbhc_set_keycode(mbhc)) pr_err("Set btn key code error!!!\n"); if (!mbhc->mbhc_cfg->read_fw_bin || Loading @@ -2030,6 +2037,10 @@ EXPORT_SYMBOL(wcd_mbhc_start); void wcd_mbhc_stop(struct wcd_mbhc *mbhc) { pr_debug("%s: enter\n", __func__); if (mbhc->current_plug != MBHC_PLUG_TYPE_NONE) { if (mbhc->mbhc_cb && mbhc->mbhc_cb->skip_imped_detect) mbhc->mbhc_cb->skip_imped_detect(mbhc->codec); } mbhc->current_plug = MBHC_PLUG_TYPE_NONE; mbhc->hph_status = 0; mbhc->mbhc_cb->irq_control(mbhc->codec, mbhc->intr_ids->hph_left_ocp, Loading sound/soc/codecs/wcd-mbhc-v2.h +5 −2 Original line number Diff line number Diff line Loading @@ -346,6 +346,7 @@ struct wcd_mbhc_cb { enum mbhc_hs_pullup_iref); int (*mbhc_micbias_control)(struct snd_soc_codec *, int req); void (*mbhc_micb_ramp_control)(struct snd_soc_codec *, bool); void (*skip_imped_detect)(struct snd_soc_codec *); bool (*extn_use_mb)(struct snd_soc_codec *); int (*mbhc_micb_ctrl_thr_mic)(struct snd_soc_codec *, int, bool); void (*mbhc_gnd_det_ctrl)(struct snd_soc_codec *, bool); Loading Loading @@ -376,6 +377,8 @@ struct wcd_mbhc { bool btn_press_intr; bool is_hs_recording; bool is_extn_cable; bool skip_imped_detection; bool is_btn_already_regd; struct snd_soc_codec *codec; /* Work to perform MBHC Firmware Read */ Loading Loading @@ -407,10 +410,10 @@ struct wcd_mbhc { struct notifier_block nblock; struct wcd_mbhc_register *wcd_mbhc_regs; struct mutex hphl_pa_lock; struct mutex hphr_pa_lock; struct completion btn_press_compl; struct mutex hphl_pa_lock; struct mutex hphr_pa_lock; }; #define WCD_MBHC_CAL_SIZE(buttons, rload) ( \ sizeof(struct wcd_mbhc_general_cfg) + \ Loading Loading
sound/soc/codecs/wcd-mbhc-v2.c +19 −8 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ #define FW_READ_ATTEMPTS 15 #define FW_READ_TIMEOUT 4000000 #define FAKE_REM_RETRY_ATTEMPTS 3 #define MAX_IMPED 60000 #define WCD_MBHC_BTN_PRESS_COMPL_TIMEOUT_MS 50 Loading Loading @@ -628,8 +629,10 @@ static void wcd_mbhc_report_plug(struct wcd_mbhc *mbhc, int insertion, (mbhc->mbhc_cfg->linein_th != 0)) { mbhc->mbhc_cb->compute_impedance(mbhc, &mbhc->zl, &mbhc->zr); if ((mbhc->zl > mbhc->mbhc_cfg->linein_th) && (mbhc->zr > mbhc->mbhc_cfg->linein_th) && if ((mbhc->zl > mbhc->mbhc_cfg->linein_th && mbhc->zl < MAX_IMPED) && (mbhc->zr > mbhc->mbhc_cfg->linein_th && mbhc->zr < MAX_IMPED) && (jack_type == SND_JACK_HEADPHONE)) { jack_type = SND_JACK_LINEOUT; mbhc->current_plug = MBHC_PLUG_TYPE_HIGH_HPH; Loading Loading @@ -770,7 +773,7 @@ static int wcd_check_cross_conn(struct wcd_mbhc *mbhc) WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ELECT_SCHMT_ISRC, reg1); pr_debug("%s: leave, plug type: %d\n", __func__, plug_type); return (plug_type == MBHC_PLUG_TYPE_GND_MIC_SWAP) ? 1 : 0; return (plug_type == MBHC_PLUG_TYPE_GND_MIC_SWAP) ? true : false; } static bool wcd_is_special_headset(struct wcd_mbhc *mbhc) Loading Loading @@ -936,8 +939,8 @@ static void wcd_correct_swch_plug(struct work_struct *work) bool is_pa_on = false; bool micbias2 = false; bool micbias1 = false; int rc; int ret = 0; int rc; pr_debug("%s: enter\n", __func__); Loading Loading @@ -1036,8 +1039,8 @@ correct_plug_type: */ msleep(180); if ((!hs_comp_res) && (!is_pa_on)) { ret = wcd_check_cross_conn(mbhc); /* Check for cross connection*/ ret = wcd_check_cross_conn(mbhc); if (ret < 0) { continue; } else if (ret > 0) { Loading Loading @@ -1258,8 +1261,10 @@ static void wcd_mbhc_swch_irq_handler(struct wcd_mbhc *mbhc) if (!mbhc->mbhc_cfg->hs_ext_micbias && mbhc->mbhc_cb->micb_internal) /* Enable Tx2 RBias if the headset * is using internal micbias*/ /* * Enable Tx2 RBias if the headset * is using internal micbias */ mbhc->mbhc_cb->micb_internal(codec, 1, true); /* Remove micbias pulldown */ Loading Loading @@ -1994,6 +1999,8 @@ int wcd_mbhc_set_keycode(struct wcd_mbhc *mbhc) i, btn_key_code[i]); } } if (btn_key_code[0]) mbhc->is_btn_already_regd = true; return result; } Loading @@ -2007,7 +2014,7 @@ int wcd_mbhc_start(struct wcd_mbhc *mbhc, mbhc->mbhc_cfg = mbhc_cfg; /* Set btn key code */ if (wcd_mbhc_set_keycode(mbhc)) if ((!mbhc->is_btn_already_regd) && wcd_mbhc_set_keycode(mbhc)) pr_err("Set btn key code error!!!\n"); if (!mbhc->mbhc_cfg->read_fw_bin || Loading @@ -2030,6 +2037,10 @@ EXPORT_SYMBOL(wcd_mbhc_start); void wcd_mbhc_stop(struct wcd_mbhc *mbhc) { pr_debug("%s: enter\n", __func__); if (mbhc->current_plug != MBHC_PLUG_TYPE_NONE) { if (mbhc->mbhc_cb && mbhc->mbhc_cb->skip_imped_detect) mbhc->mbhc_cb->skip_imped_detect(mbhc->codec); } mbhc->current_plug = MBHC_PLUG_TYPE_NONE; mbhc->hph_status = 0; mbhc->mbhc_cb->irq_control(mbhc->codec, mbhc->intr_ids->hph_left_ocp, Loading
sound/soc/codecs/wcd-mbhc-v2.h +5 −2 Original line number Diff line number Diff line Loading @@ -346,6 +346,7 @@ struct wcd_mbhc_cb { enum mbhc_hs_pullup_iref); int (*mbhc_micbias_control)(struct snd_soc_codec *, int req); void (*mbhc_micb_ramp_control)(struct snd_soc_codec *, bool); void (*skip_imped_detect)(struct snd_soc_codec *); bool (*extn_use_mb)(struct snd_soc_codec *); int (*mbhc_micb_ctrl_thr_mic)(struct snd_soc_codec *, int, bool); void (*mbhc_gnd_det_ctrl)(struct snd_soc_codec *, bool); Loading Loading @@ -376,6 +377,8 @@ struct wcd_mbhc { bool btn_press_intr; bool is_hs_recording; bool is_extn_cable; bool skip_imped_detection; bool is_btn_already_regd; struct snd_soc_codec *codec; /* Work to perform MBHC Firmware Read */ Loading Loading @@ -407,10 +410,10 @@ struct wcd_mbhc { struct notifier_block nblock; struct wcd_mbhc_register *wcd_mbhc_regs; struct mutex hphl_pa_lock; struct mutex hphr_pa_lock; struct completion btn_press_compl; struct mutex hphl_pa_lock; struct mutex hphr_pa_lock; }; #define WCD_MBHC_CAL_SIZE(buttons, rload) ( \ sizeof(struct wcd_mbhc_general_cfg) + \ Loading