Loading sound/soc/codecs/wcd-mbhc-v2.c +2 −19 Original line number Diff line number Diff line Loading @@ -2053,24 +2053,6 @@ static irqreturn_t wcd_mbhc_hphr_ocp_irq(int irq, void *data) return IRQ_HANDLED; } static void wcd_mbhc_moisture_config(struct wcd_mbhc *mbhc) { if (mbhc->mbhc_cfg->moist_cfg.m_vref_ctl == V_OFF) return; /* Donot enable moisture detection if jack type is NC */ if (!mbhc->hphl_swh) { pr_debug("%s: disable moisture detection for NC\n", __func__); return; } WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MOISTURE_VREF, mbhc->mbhc_cfg->moist_cfg.m_vref_ctl); if (mbhc->mbhc_cb->hph_pull_up_control) mbhc->mbhc_cb->hph_pull_up_control(mbhc->codec, mbhc->mbhc_cfg->moist_cfg.m_iref_ctl); } static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc) { int ret = 0; Loading @@ -2085,7 +2067,8 @@ static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc) else WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HS_L_DET_PULL_UP_CTRL, 3); wcd_mbhc_moisture_config(mbhc); if (mbhc->mbhc_cfg->moisture_en && mbhc->mbhc_cb->mbhc_moisture_config) mbhc->mbhc_cb->mbhc_moisture_config(mbhc); WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HPHL_PLUG_TYPE, mbhc->hphl_swh); WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_GND_PLUG_TYPE, mbhc->gnd_swh); Loading sound/soc/codecs/wcd-mbhc-v2.h +7 −5 Original line number Diff line number Diff line Loading @@ -62,7 +62,6 @@ enum wcd_mbhc_register_function { WCD_MBHC_HPHL_PA_EN, WCD_MBHC_HPH_PA_EN, WCD_MBHC_SWCH_LEVEL_REMOVE, WCD_MBHC_MOISTURE_VREF, WCD_MBHC_PULLDOWN_CTRL, WCD_MBHC_ANC_DET_EN, WCD_MBHC_FSM_STATUS, Loading Loading @@ -237,9 +236,11 @@ enum mbhc_hs_pullup_iref { I_3P0_UA, }; struct wcd_mbhc_moisture_cfg { enum mbhc_moisture_vref m_vref_ctl; enum mbhc_hs_pullup_iref m_iref_ctl; enum mbhc_moisture_rref { R_OFF, R_24_KOHM, R_84_KOHM, R_184_KOHM, }; struct wcd_mbhc_config { Loading @@ -252,7 +253,7 @@ struct wcd_mbhc_config { bool gnd_det_en; int key_code[WCD_MBHC_KEYCODE_NUM]; uint32_t linein_th; struct wcd_mbhc_moisture_cfg moist_cfg; bool moisture_en; int mbhc_micbias; int anc_micbias; bool enable_anc_mic_detect; Loading Loading @@ -363,6 +364,7 @@ struct wcd_mbhc_cb { int (*mbhc_micb_ctrl_thr_mic)(struct snd_soc_codec *, int, bool); void (*mbhc_gnd_det_ctrl)(struct snd_soc_codec *, bool); void (*hph_pull_down_ctrl)(struct snd_soc_codec *, bool); void (*mbhc_moisture_config)(struct wcd_mbhc *); }; struct wcd_mbhc { Loading sound/soc/codecs/wcd9335.c +22 −13 Original line number Diff line number Diff line Loading @@ -116,6 +116,8 @@ /* z value compared in milliOhm */ #define TASHA_MBHC_IS_SECOND_RAMP_REQUIRED(z) ((z > 400000) || (z < 32000)) #define TASHA_MBHC_ZDET_CONST (86 * 16384) #define TASHA_MBHC_MOISTURE_VREF V_45_MV #define TASHA_MBHC_MOISTURE_IREF I_3P0_UA #define TASHA_VERSION_ENTRY_SIZE 17 Loading Loading @@ -671,13 +673,6 @@ static struct wcd_mbhc_register WCD9335_ANA_HPH, 0xC0, 6, 0), WCD_MBHC_REGISTER("WCD_MBHC_SWCH_LEVEL_REMOVE", WCD9335_ANA_MBHC_RESULT_3, 0x10, 4, 0), /* * Initialize moisture register as "0" and based on codec * version, the register, mask fields get populated. * Register "0" is not a valid register for MBHC. */ WCD_MBHC_REGISTER("WCD_MBHC_MOISTURE_VREF", 0, 0, 0, 0), WCD_MBHC_REGISTER("WCD_MBHC_PULLDOWN_CTRL", 0, 0, 0, 0), WCD_MBHC_REGISTER("WCD_MBHC_ANC_DET_EN", Loading Loading @@ -2185,6 +2180,25 @@ static void tasha_mbhc_hph_pull_down_ctrl(struct snd_soc_codec *codec, } } static void tasha_mbhc_moisture_config(struct wcd_mbhc *mbhc) { struct snd_soc_codec *codec = mbhc->codec; if (TASHA_MBHC_MOISTURE_VREF == V_OFF) return; /* Donot enable moisture detection if jack type is NC */ if (!mbhc->hphl_swh) { dev_dbg(codec->dev, "%s: disable moisture detection for NC\n", __func__); return; } snd_soc_update_bits(codec, WCD9335_MBHC_CTL_2, 0x0C, TASHA_MBHC_MOISTURE_VREF << 2); tasha_mbhc_hph_l_pull_up_control(codec, TASHA_MBHC_MOISTURE_IREF); } static const struct wcd_mbhc_cb mbhc_cb = { .request_irq = tasha_mbhc_request_irq, .irq_control = tasha_mbhc_irq_control, Loading @@ -2206,6 +2220,7 @@ static const struct wcd_mbhc_cb mbhc_cb = { .compute_impedance = tasha_wcd_mbhc_calc_impedance, .mbhc_gnd_det_ctrl = tasha_mbhc_gnd_det_ctrl, .hph_pull_down_ctrl = tasha_mbhc_hph_pull_down_ctrl, .mbhc_moisture_config = tasha_mbhc_moisture_config, }; static int tasha_get_anc_slot(struct snd_kcontrol *kcontrol, Loading Loading @@ -13234,12 +13249,6 @@ static int tasha_codec_probe(struct snd_soc_codec *codec) /* Initialize MBHC module */ if (TASHA_IS_2_0(tasha->wcd9xxx->version)) { wcd_mbhc_registers[WCD_MBHC_MOISTURE_VREF].reg = WCD9335_MBHC_CTL_2; wcd_mbhc_registers[WCD_MBHC_MOISTURE_VREF].mask = 0x0C; wcd_mbhc_registers[WCD_MBHC_MOISTURE_VREF].offset = 2; wcd_mbhc_registers[WCD_MBHC_FSM_STATUS].reg = WCD9335_MBHC_FSM_STATUS; wcd_mbhc_registers[WCD_MBHC_FSM_STATUS].mask = 0x01; Loading sound/soc/codecs/wcd934x/wcd934x-mbhc.c +47 −2 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ /* Z value compared in milliOhm */ #define TAVIL_MBHC_IS_SECOND_RAMP_REQUIRED(z) ((z > 400000) || (z < 32000)) #define TAVIL_MBHC_ZDET_CONST (86 * 16384) #define TAVIL_MBHC_MOISTURE_RREF R_24_KOHM static struct wcd_mbhc_register wcd_mbhc_registers[WCD_MBHC_REG_FUNC_MAX] = { Loading Loading @@ -109,8 +110,6 @@ static struct wcd_mbhc_register WCD934X_ANA_HPH, 0xC0, 6, 0), WCD_MBHC_REGISTER("WCD_MBHC_SWCH_LEVEL_REMOVE", WCD934X_ANA_MBHC_RESULT_3, 0x10, 4, 0), WCD_MBHC_REGISTER("WCD_MBHC_MOISTURE_VREF", WCD934X_MBHC_NEW_CTL_2, 0x0C, 2, 0), WCD_MBHC_REGISTER("WCD_MBHC_PULLDOWN_CTRL", 0, 0, 0, 0), WCD_MBHC_REGISTER("WCD_MBHC_ANC_DET_EN", Loading Loading @@ -761,6 +760,23 @@ static void tavil_mbhc_hph_pull_down_ctrl(struct snd_soc_codec *codec, 0x10, 0x00); } } static void tavil_mbhc_moisture_config(struct wcd_mbhc *mbhc) { struct snd_soc_codec *codec = mbhc->codec; if (TAVIL_MBHC_MOISTURE_RREF == R_OFF) return; /* Donot enable moisture detection if jack type is NC */ if (!mbhc->hphl_swh) { dev_dbg(codec->dev, "%s: disable moisture detection for NC\n", __func__); return; } snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_2, 0x0C, TAVIL_MBHC_MOISTURE_RREF << 2); } static const struct wcd_mbhc_cb mbhc_cb = { .request_irq = tavil_mbhc_request_irq, Loading @@ -783,6 +799,7 @@ static const struct wcd_mbhc_cb mbhc_cb = { .compute_impedance = tavil_wcd_mbhc_calc_impedance, .mbhc_gnd_det_ctrl = tavil_mbhc_gnd_det_ctrl, .hph_pull_down_ctrl = tavil_mbhc_hph_pull_down_ctrl, .mbhc_moisture_config = tavil_mbhc_moisture_config, }; static struct regulator *tavil_codec_find_ondemand_regulator( Loading @@ -804,6 +821,31 @@ static struct regulator *tavil_codec_find_ondemand_regulator( return NULL; } static int tavil_get_hph_type(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(codec); struct wcd_mbhc *mbhc; if (!wcd934x_mbhc) { dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__); return -EINVAL; } mbhc = &wcd934x_mbhc->wcd_mbhc; ucontrol->value.integer.value[0] = (u32) mbhc->hph_type; dev_dbg(codec->dev, "%s: hph_type = %u\n", __func__, mbhc->hph_type); return 0; } static const struct snd_kcontrol_new hph_type_detect_controls[] = { SOC_SINGLE_EXT("HPH Type", 0, 0, UINT_MAX, 0, tavil_get_hph_type, NULL), }; /* * tavil_mbhc_hs_detect: starts mbhc insertion/removal functionality * @codec: handle to snd_soc_codec * Loading Loading @@ -883,6 +925,9 @@ int tavil_mbhc_init(struct wcd934x_mbhc **mbhc, struct snd_soc_codec *codec, 0; } snd_soc_add_codec_controls(codec, hph_type_detect_controls, ARRAY_SIZE(hph_type_detect_controls)); snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_1, 0x04, 0x04); snd_soc_update_bits(codec, WCD934X_MBHC_CTL_BCS, 0x01, 0x01); Loading sound/soc/msm/msm8996.c +1 −1 Original line number Diff line number Diff line Loading @@ -192,7 +192,7 @@ static struct wcd_mbhc_config wcd_mbhc_cfg = { .key_code[6] = 0, .key_code[7] = 0, .linein_th = 5000, .moist_cfg = { V_45_MV, I_3P0_UA }, .moisture_en = true, .mbhc_micbias = MIC_BIAS_2, .anc_micbias = MIC_BIAS_2, .enable_anc_mic_detect = false, Loading Loading
sound/soc/codecs/wcd-mbhc-v2.c +2 −19 Original line number Diff line number Diff line Loading @@ -2053,24 +2053,6 @@ static irqreturn_t wcd_mbhc_hphr_ocp_irq(int irq, void *data) return IRQ_HANDLED; } static void wcd_mbhc_moisture_config(struct wcd_mbhc *mbhc) { if (mbhc->mbhc_cfg->moist_cfg.m_vref_ctl == V_OFF) return; /* Donot enable moisture detection if jack type is NC */ if (!mbhc->hphl_swh) { pr_debug("%s: disable moisture detection for NC\n", __func__); return; } WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MOISTURE_VREF, mbhc->mbhc_cfg->moist_cfg.m_vref_ctl); if (mbhc->mbhc_cb->hph_pull_up_control) mbhc->mbhc_cb->hph_pull_up_control(mbhc->codec, mbhc->mbhc_cfg->moist_cfg.m_iref_ctl); } static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc) { int ret = 0; Loading @@ -2085,7 +2067,8 @@ static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc) else WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HS_L_DET_PULL_UP_CTRL, 3); wcd_mbhc_moisture_config(mbhc); if (mbhc->mbhc_cfg->moisture_en && mbhc->mbhc_cb->mbhc_moisture_config) mbhc->mbhc_cb->mbhc_moisture_config(mbhc); WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HPHL_PLUG_TYPE, mbhc->hphl_swh); WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_GND_PLUG_TYPE, mbhc->gnd_swh); Loading
sound/soc/codecs/wcd-mbhc-v2.h +7 −5 Original line number Diff line number Diff line Loading @@ -62,7 +62,6 @@ enum wcd_mbhc_register_function { WCD_MBHC_HPHL_PA_EN, WCD_MBHC_HPH_PA_EN, WCD_MBHC_SWCH_LEVEL_REMOVE, WCD_MBHC_MOISTURE_VREF, WCD_MBHC_PULLDOWN_CTRL, WCD_MBHC_ANC_DET_EN, WCD_MBHC_FSM_STATUS, Loading Loading @@ -237,9 +236,11 @@ enum mbhc_hs_pullup_iref { I_3P0_UA, }; struct wcd_mbhc_moisture_cfg { enum mbhc_moisture_vref m_vref_ctl; enum mbhc_hs_pullup_iref m_iref_ctl; enum mbhc_moisture_rref { R_OFF, R_24_KOHM, R_84_KOHM, R_184_KOHM, }; struct wcd_mbhc_config { Loading @@ -252,7 +253,7 @@ struct wcd_mbhc_config { bool gnd_det_en; int key_code[WCD_MBHC_KEYCODE_NUM]; uint32_t linein_th; struct wcd_mbhc_moisture_cfg moist_cfg; bool moisture_en; int mbhc_micbias; int anc_micbias; bool enable_anc_mic_detect; Loading Loading @@ -363,6 +364,7 @@ struct wcd_mbhc_cb { int (*mbhc_micb_ctrl_thr_mic)(struct snd_soc_codec *, int, bool); void (*mbhc_gnd_det_ctrl)(struct snd_soc_codec *, bool); void (*hph_pull_down_ctrl)(struct snd_soc_codec *, bool); void (*mbhc_moisture_config)(struct wcd_mbhc *); }; struct wcd_mbhc { Loading
sound/soc/codecs/wcd9335.c +22 −13 Original line number Diff line number Diff line Loading @@ -116,6 +116,8 @@ /* z value compared in milliOhm */ #define TASHA_MBHC_IS_SECOND_RAMP_REQUIRED(z) ((z > 400000) || (z < 32000)) #define TASHA_MBHC_ZDET_CONST (86 * 16384) #define TASHA_MBHC_MOISTURE_VREF V_45_MV #define TASHA_MBHC_MOISTURE_IREF I_3P0_UA #define TASHA_VERSION_ENTRY_SIZE 17 Loading Loading @@ -671,13 +673,6 @@ static struct wcd_mbhc_register WCD9335_ANA_HPH, 0xC0, 6, 0), WCD_MBHC_REGISTER("WCD_MBHC_SWCH_LEVEL_REMOVE", WCD9335_ANA_MBHC_RESULT_3, 0x10, 4, 0), /* * Initialize moisture register as "0" and based on codec * version, the register, mask fields get populated. * Register "0" is not a valid register for MBHC. */ WCD_MBHC_REGISTER("WCD_MBHC_MOISTURE_VREF", 0, 0, 0, 0), WCD_MBHC_REGISTER("WCD_MBHC_PULLDOWN_CTRL", 0, 0, 0, 0), WCD_MBHC_REGISTER("WCD_MBHC_ANC_DET_EN", Loading Loading @@ -2185,6 +2180,25 @@ static void tasha_mbhc_hph_pull_down_ctrl(struct snd_soc_codec *codec, } } static void tasha_mbhc_moisture_config(struct wcd_mbhc *mbhc) { struct snd_soc_codec *codec = mbhc->codec; if (TASHA_MBHC_MOISTURE_VREF == V_OFF) return; /* Donot enable moisture detection if jack type is NC */ if (!mbhc->hphl_swh) { dev_dbg(codec->dev, "%s: disable moisture detection for NC\n", __func__); return; } snd_soc_update_bits(codec, WCD9335_MBHC_CTL_2, 0x0C, TASHA_MBHC_MOISTURE_VREF << 2); tasha_mbhc_hph_l_pull_up_control(codec, TASHA_MBHC_MOISTURE_IREF); } static const struct wcd_mbhc_cb mbhc_cb = { .request_irq = tasha_mbhc_request_irq, .irq_control = tasha_mbhc_irq_control, Loading @@ -2206,6 +2220,7 @@ static const struct wcd_mbhc_cb mbhc_cb = { .compute_impedance = tasha_wcd_mbhc_calc_impedance, .mbhc_gnd_det_ctrl = tasha_mbhc_gnd_det_ctrl, .hph_pull_down_ctrl = tasha_mbhc_hph_pull_down_ctrl, .mbhc_moisture_config = tasha_mbhc_moisture_config, }; static int tasha_get_anc_slot(struct snd_kcontrol *kcontrol, Loading Loading @@ -13234,12 +13249,6 @@ static int tasha_codec_probe(struct snd_soc_codec *codec) /* Initialize MBHC module */ if (TASHA_IS_2_0(tasha->wcd9xxx->version)) { wcd_mbhc_registers[WCD_MBHC_MOISTURE_VREF].reg = WCD9335_MBHC_CTL_2; wcd_mbhc_registers[WCD_MBHC_MOISTURE_VREF].mask = 0x0C; wcd_mbhc_registers[WCD_MBHC_MOISTURE_VREF].offset = 2; wcd_mbhc_registers[WCD_MBHC_FSM_STATUS].reg = WCD9335_MBHC_FSM_STATUS; wcd_mbhc_registers[WCD_MBHC_FSM_STATUS].mask = 0x01; Loading
sound/soc/codecs/wcd934x/wcd934x-mbhc.c +47 −2 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ /* Z value compared in milliOhm */ #define TAVIL_MBHC_IS_SECOND_RAMP_REQUIRED(z) ((z > 400000) || (z < 32000)) #define TAVIL_MBHC_ZDET_CONST (86 * 16384) #define TAVIL_MBHC_MOISTURE_RREF R_24_KOHM static struct wcd_mbhc_register wcd_mbhc_registers[WCD_MBHC_REG_FUNC_MAX] = { Loading Loading @@ -109,8 +110,6 @@ static struct wcd_mbhc_register WCD934X_ANA_HPH, 0xC0, 6, 0), WCD_MBHC_REGISTER("WCD_MBHC_SWCH_LEVEL_REMOVE", WCD934X_ANA_MBHC_RESULT_3, 0x10, 4, 0), WCD_MBHC_REGISTER("WCD_MBHC_MOISTURE_VREF", WCD934X_MBHC_NEW_CTL_2, 0x0C, 2, 0), WCD_MBHC_REGISTER("WCD_MBHC_PULLDOWN_CTRL", 0, 0, 0, 0), WCD_MBHC_REGISTER("WCD_MBHC_ANC_DET_EN", Loading Loading @@ -761,6 +760,23 @@ static void tavil_mbhc_hph_pull_down_ctrl(struct snd_soc_codec *codec, 0x10, 0x00); } } static void tavil_mbhc_moisture_config(struct wcd_mbhc *mbhc) { struct snd_soc_codec *codec = mbhc->codec; if (TAVIL_MBHC_MOISTURE_RREF == R_OFF) return; /* Donot enable moisture detection if jack type is NC */ if (!mbhc->hphl_swh) { dev_dbg(codec->dev, "%s: disable moisture detection for NC\n", __func__); return; } snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_2, 0x0C, TAVIL_MBHC_MOISTURE_RREF << 2); } static const struct wcd_mbhc_cb mbhc_cb = { .request_irq = tavil_mbhc_request_irq, Loading @@ -783,6 +799,7 @@ static const struct wcd_mbhc_cb mbhc_cb = { .compute_impedance = tavil_wcd_mbhc_calc_impedance, .mbhc_gnd_det_ctrl = tavil_mbhc_gnd_det_ctrl, .hph_pull_down_ctrl = tavil_mbhc_hph_pull_down_ctrl, .mbhc_moisture_config = tavil_mbhc_moisture_config, }; static struct regulator *tavil_codec_find_ondemand_regulator( Loading @@ -804,6 +821,31 @@ static struct regulator *tavil_codec_find_ondemand_regulator( return NULL; } static int tavil_get_hph_type(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(codec); struct wcd_mbhc *mbhc; if (!wcd934x_mbhc) { dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__); return -EINVAL; } mbhc = &wcd934x_mbhc->wcd_mbhc; ucontrol->value.integer.value[0] = (u32) mbhc->hph_type; dev_dbg(codec->dev, "%s: hph_type = %u\n", __func__, mbhc->hph_type); return 0; } static const struct snd_kcontrol_new hph_type_detect_controls[] = { SOC_SINGLE_EXT("HPH Type", 0, 0, UINT_MAX, 0, tavil_get_hph_type, NULL), }; /* * tavil_mbhc_hs_detect: starts mbhc insertion/removal functionality * @codec: handle to snd_soc_codec * Loading Loading @@ -883,6 +925,9 @@ int tavil_mbhc_init(struct wcd934x_mbhc **mbhc, struct snd_soc_codec *codec, 0; } snd_soc_add_codec_controls(codec, hph_type_detect_controls, ARRAY_SIZE(hph_type_detect_controls)); snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_1, 0x04, 0x04); snd_soc_update_bits(codec, WCD934X_MBHC_CTL_BCS, 0x01, 0x01); Loading
sound/soc/msm/msm8996.c +1 −1 Original line number Diff line number Diff line Loading @@ -192,7 +192,7 @@ static struct wcd_mbhc_config wcd_mbhc_cfg = { .key_code[6] = 0, .key_code[7] = 0, .linein_th = 5000, .moist_cfg = { V_45_MV, I_3P0_UA }, .moisture_en = true, .mbhc_micbias = MIC_BIAS_2, .anc_micbias = MIC_BIAS_2, .enable_anc_mic_detect = false, Loading