summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWalter Yang <yandongy@codeaurora.org>2016-07-11 19:08:21 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2016-08-18 19:59:13 -0700
commit30a5b12e27de61cf7b00778dc0147badfae5979c (patch)
tree948b71ce1da4d7941d2d94b2c6c10008261c2838
parent031202970b44f033b4f2fbe437a487d2a32a52cf (diff)
ASoC: wcd-mbhc: move the moisture config to mbhc driver
Move the moisture config from machine driver to mbhc driver. As generally moisture config doesn't vary with sound card. Change-Id: I6c4bb19d3155567b9bc4f3a653e2ac8214d04146 Signed-off-by: Walter Yang <yandongy@codeaurora.org>
-rw-r--r--sound/soc/codecs/wcd-mbhc-v2.c21
-rw-r--r--sound/soc/codecs/wcd-mbhc-v2.h12
-rw-r--r--sound/soc/codecs/wcd9335.c35
-rw-r--r--sound/soc/codecs/wcd934x/wcd934x-mbhc.c21
-rw-r--r--sound/soc/msm/msm8996.c2
-rw-r--r--sound/soc/msm/msmcobalt.c2
6 files changed, 52 insertions, 41 deletions
diff --git a/sound/soc/codecs/wcd-mbhc-v2.c b/sound/soc/codecs/wcd-mbhc-v2.c
index 71cc156cd8ad..60a7ad1b01c2 100644
--- a/sound/soc/codecs/wcd-mbhc-v2.c
+++ b/sound/soc/codecs/wcd-mbhc-v2.c
@@ -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;
@@ -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);
diff --git a/sound/soc/codecs/wcd-mbhc-v2.h b/sound/soc/codecs/wcd-mbhc-v2.h
index e3eb60729e94..ab42b3bb6e7d 100644
--- a/sound/soc/codecs/wcd-mbhc-v2.h
+++ b/sound/soc/codecs/wcd-mbhc-v2.h
@@ -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,
@@ -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 {
@@ -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;
@@ -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 {
diff --git a/sound/soc/codecs/wcd9335.c b/sound/soc/codecs/wcd9335.c
index e6338b081cba..158b9ae08642 100644
--- a/sound/soc/codecs/wcd9335.c
+++ b/sound/soc/codecs/wcd9335.c
@@ -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
@@ -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",
@@ -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,
@@ -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,
@@ -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;
diff --git a/sound/soc/codecs/wcd934x/wcd934x-mbhc.c b/sound/soc/codecs/wcd934x/wcd934x-mbhc.c
index 4c5ddec807b2..22712d163c6f 100644
--- a/sound/soc/codecs/wcd934x/wcd934x-mbhc.c
+++ b/sound/soc/codecs/wcd934x/wcd934x-mbhc.c
@@ -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] = {
@@ -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",
@@ -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,
@@ -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(
diff --git a/sound/soc/msm/msm8996.c b/sound/soc/msm/msm8996.c
index 225726cad812..84d4ede33e3f 100644
--- a/sound/soc/msm/msm8996.c
+++ b/sound/soc/msm/msm8996.c
@@ -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,
diff --git a/sound/soc/msm/msmcobalt.c b/sound/soc/msm/msmcobalt.c
index 1ff695ed982f..5be5137f447f 100644
--- a/sound/soc/msm/msmcobalt.c
+++ b/sound/soc/msm/msmcobalt.c
@@ -248,7 +248,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,
};
static struct snd_soc_dapm_route wcd_audio_paths[] = {