Fix MBHC wired headphone autodetection across all targets for a1125 (ampere)
Retain PM8909 MBHC digital debounce clock (DIG_CLK_CTL_D_MBHC_CLK_EN) and master bias (CDC_A_MASTER_BIAS_CTL = 0x30) across s2 standby gating while keeping the 100 uA button ISRC and button IRQs disabled when unplugged, check CDC_A_MBHC_RESULT_2 on boot/set_jack/switch IRQs with 3/4-pole FSM classification, fix iface=CARD jack queries, event coalescing, and stale unplugged Headphones boot fallback in bananarchy-soundmonitor and sxmo audio scripts, harden host tests against CPU contention, and rebuild all a1125 (ampere) target images.
This commit is contained in:
1 parent
aba38a58f2
commit
9619cc9541
19 files changed
+516
-93
No files matched your search
@@ -1,5 +1,5 @@
|
||||
diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c
|
||||
index 257f780..457b552 100644
|
||||
index 257f780..f820437 100644
|
||||
--- a/sound/soc/codecs/msm8916-wcd-analog.c
|
||||
+++ b/sound/soc/codecs/msm8916-wcd-analog.c
|
||||
@@ -82,6 +82,7 @@
|
||||
@@ -10,7 +10,16 @@ index 257f780..457b552 100644
|
||||
#define CDC_A_INT_RT_STS (0xf110)
|
||||
#define CDC_A_INT_SET_TYPE (0xf111)
|
||||
#define CDC_A_INT_POLARITY_HIGH (0xf112)
|
||||
@@ -220,20 +221,28 @@
|
||||
@@ -191,6 +192,8 @@
|
||||
CDC_A_MBHC_BTN_VREF_FINE_MASK)
|
||||
#define CDC_A_MBHC_RESULT_1 (0xf158)
|
||||
#define CDC_A_MBHC_RESULT_1_BTN_RESULT_MASK GENMASK(4, 0)
|
||||
+#define CDC_A_MBHC_RESULT_2 (0xf159)
|
||||
+#define CDC_A_MBHC_RESULT_2_SWCH_LEVEL_REMOVE BIT(4)
|
||||
#define CDC_A_TX_1_EN (0xf160)
|
||||
#define CDC_A_TX_2_EN (0xf161)
|
||||
#define CDC_A_TX_1_2_TEST_CTL_1 (0xf162)
|
||||
@@ -220,20 +223,28 @@
|
||||
#define CDC_A_RX_HPH_BIAS_LDO_OCP (0xf195)
|
||||
#define CDC_A_RX_HPH_BIAS_CNP (0xf196)
|
||||
#define CDC_A_RX_HPH_CNP_EN (0xf197)
|
||||
@@ -39,7 +48,7 @@ index 257f780..457b552 100644
|
||||
|
||||
#define CDC_A_SPKR_DAC_CTL (0xf1B0)
|
||||
#define SPKR_DAC_CTL_DAC_RESET_MASK BIT(4)
|
||||
@@ -249,10 +258,13 @@
|
||||
@@ -249,10 +260,13 @@
|
||||
#define SPKR_DRV_BOOST_SET BIT(2)
|
||||
#define SPKR_DRV_CMFB_SET BIT(1)
|
||||
#define SPKR_DRV_GAIN_SET BIT(0)
|
||||
@@ -53,25 +62,53 @@ index 257f780..457b552 100644
|
||||
#define CDC_A_SPKR_OCP_CTL (0xf1B4)
|
||||
#define CDC_A_SPKR_PWRSTG_CTL (0xf1B5)
|
||||
#define SPKR_PWRSTG_CTL_DAC_EN_MASK BIT(0)
|
||||
@@ -314,6 +326,7 @@ struct pm8916_wcd_analog_priv {
|
||||
@@ -314,6 +328,8 @@ struct pm8916_wcd_analog_priv {
|
||||
bool audio_active;
|
||||
bool jack_inserted;
|
||||
bool s2_enabled;
|
||||
+ bool is_cajon;
|
||||
+ int jack_report;
|
||||
};
|
||||
|
||||
static const char *const adc2_mux_text[] = { "ZERO", "INP2", "INP3" };
|
||||
@@ -435,6 +448,9 @@ static int pm8916_wcd_analog_enable_micbias2(struct snd_soc_dapm_widget *w,
|
||||
@@ -435,6 +451,36 @@ static int pm8916_wcd_analog_enable_micbias2(struct snd_soc_dapm_widget *w,
|
||||
|
||||
}
|
||||
|
||||
+static void pm8916_wcd_analog_apply_defaults(struct snd_soc_component *component,
|
||||
+ bool preserve_switch);
|
||||
+static int pm8916_wcd_analog_switch_check(struct pm8916_wcd_analog_priv *priv, bool ins);
|
||||
+
|
||||
+static bool pm8916_mbhc_plug_present(struct snd_soc_component *component)
|
||||
+{
|
||||
+ int res2 = snd_soc_component_read(component, CDC_A_MBHC_RESULT_2);
|
||||
+
|
||||
+ if (res2 < 0)
|
||||
+ return false;
|
||||
+ return !(res2 & CDC_A_MBHC_RESULT_2_SWCH_LEVEL_REMOVE);
|
||||
+}
|
||||
+
|
||||
+static void pm8916_mbhc_disable_btn_bias(struct snd_soc_component *component)
|
||||
+{
|
||||
+ snd_soc_component_update_bits(component, CDC_A_MBHC_FSM_CTL,
|
||||
+ CDC_A_MBHC_FSM_CTL_BTN_ISRC_CTRL_MASK |
|
||||
+ CDC_A_MBHC_FSM_CTL_MBHC_FSM_EN_MASK,
|
||||
+ 0);
|
||||
+ if (!(snd_soc_component_read(component, CDC_A_MICB_2_EN) &
|
||||
+ CDC_A_MICB_2_EN_ENABLE)) {
|
||||
+ snd_soc_component_update_bits(component, CDC_A_MICB_1_INT_RBIAS,
|
||||
+ MICB_1_INT_TX2_INT_RBIAS_EN_MASK,
|
||||
+ 0);
|
||||
+ snd_soc_component_update_bits(component, CDC_A_MICB_2_EN,
|
||||
+ CDC_A_MICB_2_PULL_DOWN_EN_MASK,
|
||||
+ CDC_A_MICB_2_PULL_DOWN_EN);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static int pm8916_wcd_analog_update_power_locked(struct snd_soc_component *component)
|
||||
{
|
||||
struct pm8916_wcd_analog_priv *priv = snd_soc_component_get_drvdata(component);
|
||||
@@ -446,7 +462,10 @@ static int pm8916_wcd_analog_update_power_locked(struct snd_soc_component *compo
|
||||
@@ -446,19 +492,31 @@ static int pm8916_wcd_analog_update_power_locked(struct snd_soc_component *compo
|
||||
if (!ret) {
|
||||
priv->s2_enabled = true;
|
||||
usleep_range(1000, 1500);
|
||||
@@ -80,10 +117,37 @@ index 257f780..457b552 100644
|
||||
+ pm8916_wcd_analog_apply_defaults(component, true);
|
||||
+ else
|
||||
+ snd_soc_component_write(component, CDC_A_MASTER_BIAS_CTL, 0x30);
|
||||
+ /*
|
||||
+ * Keep digital MBHC debounce clock running so jack
|
||||
+ * insertion/removal edges work cleanly even when playback starts idle.
|
||||
+ */
|
||||
+ snd_soc_component_update_bits(component, CDC_D_CDC_DIG_CLK_CTL,
|
||||
+ DIG_CLK_CTL_D_MBHC_CLK_EN_MASK,
|
||||
+ DIG_CLK_CTL_D_MBHC_CLK_EN);
|
||||
} else {
|
||||
dev_err(component->dev, "failed to enable vdd-cdc-tx-rx-cx (%d)\n", ret);
|
||||
}
|
||||
@@ -698,37 +717,81 @@ static int pm8916_wcd_analog_enable_spk_pa(struct snd_soc_dapm_widget *w,
|
||||
} else if (!need_s2 && priv->s2_enabled) {
|
||||
- snd_soc_component_update_bits(component, CDC_A_MBHC_FSM_CTL,
|
||||
- CDC_A_MBHC_FSM_CTL_BTN_ISRC_CTRL_MASK |
|
||||
- CDC_A_MBHC_FSM_CTL_MBHC_FSM_EN_MASK,
|
||||
- 0);
|
||||
+ pm8916_mbhc_disable_btn_bias(component);
|
||||
+ /*
|
||||
+ * Gate the 100uA button current source and s2 Linux vote while
|
||||
+ * preserving MASTER_BIAS_CTL and DIG_CLK_CTL_D_MBHC_CLK_EN so the
|
||||
+ * 3uA HPHL insertion comparator/debouncer keeps waking from idle.
|
||||
+ */
|
||||
snd_soc_component_update_bits(component, CDC_D_CDC_DIG_CLK_CTL,
|
||||
DIG_CLK_CTL_D_MBHC_CLK_EN_MASK,
|
||||
- 0);
|
||||
- snd_soc_component_write(component, CDC_A_MASTER_BIAS_CTL, 0x00);
|
||||
+ DIG_CLK_CTL_D_MBHC_CLK_EN);
|
||||
+ snd_soc_component_write(component, CDC_A_MASTER_BIAS_CTL, 0x30);
|
||||
regulator_disable(priv->supplies[1].consumer);
|
||||
priv->s2_enabled = false;
|
||||
}
|
||||
@@ -698,37 +756,81 @@ static int pm8916_wcd_analog_enable_spk_pa(struct snd_soc_dapm_widget *w,
|
||||
int event)
|
||||
{
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
|
||||
@@ -182,7 +246,7 @@ index 257f780..457b552 100644
|
||||
|
||||
snd_soc_component_update_bits(component, CDC_A_SPKR_DAC_CTL,
|
||||
SPKR_DAC_CTL_DAC_RESET_MASK,
|
||||
@@ -745,11 +808,15 @@ static int pm8916_wcd_analog_enable_ear_pa(struct snd_soc_dapm_widget *w,
|
||||
@@ -745,11 +847,15 @@ static int pm8916_wcd_analog_enable_ear_pa(struct snd_soc_dapm_widget *w,
|
||||
int event)
|
||||
{
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
|
||||
@@ -199,7 +263,7 @@ index 257f780..457b552 100644
|
||||
break;
|
||||
case SND_SOC_DAPM_POST_PMU:
|
||||
snd_soc_component_update_bits(component, CDC_A_RX_EAR_CTL,
|
||||
@@ -762,7 +829,114 @@ static int pm8916_wcd_analog_enable_ear_pa(struct snd_soc_dapm_widget *w,
|
||||
@@ -762,7 +868,114 @@ static int pm8916_wcd_analog_enable_ear_pa(struct snd_soc_dapm_widget *w,
|
||||
/* Delay to reduce ear turn off pop */
|
||||
usleep_range(7000, 7100);
|
||||
snd_soc_component_update_bits(component, CDC_A_RX_EAR_CTL,
|
||||
@@ -315,7 +379,7 @@ index 257f780..457b552 100644
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
@@ -787,10 +961,59 @@ static const struct reg_default wcd_reg_defaults_2_0[] = {
|
||||
@@ -787,10 +1000,59 @@ static const struct reg_default wcd_reg_defaults_2_0[] = {
|
||||
{CDC_A_MASTER_BIAS_CTL, 0x30},
|
||||
};
|
||||
|
||||
@@ -376,7 +440,7 @@ index 257f780..457b552 100644
|
||||
|
||||
err = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies);
|
||||
if (err != 0) {
|
||||
@@ -806,16 +1029,17 @@ static int pm8916_wcd_analog_probe(struct snd_soc_component *component)
|
||||
@@ -806,16 +1068,17 @@ static int pm8916_wcd_analog_probe(struct snd_soc_component *component)
|
||||
snd_soc_component_set_drvdata(component, priv);
|
||||
priv->pmic_rev = snd_soc_component_read(component, CDC_D_REVISION1);
|
||||
priv->codec_version = snd_soc_component_read(component, CDC_D_PERPH_SUBTYPE);
|
||||
@@ -399,7 +463,45 @@ index 257f780..457b552 100644
|
||||
|
||||
priv->component = component;
|
||||
|
||||
@@ -981,14 +1205,27 @@ static const struct snd_soc_dapm_widget pm8916_wcd_analog_dapm_widgets[] = {
|
||||
@@ -824,24 +1087,21 @@ static int pm8916_wcd_analog_probe(struct snd_soc_component *component)
|
||||
RST_CTL_DIG_SW_RST_N_REMOVE_RESET);
|
||||
|
||||
pm8916_wcd_setup_mbhc(priv);
|
||||
- usleep_range(1000, 1500);
|
||||
+ usleep_range(5000, 6000);
|
||||
|
||||
- mutex_lock(&priv->power_lock);
|
||||
- if (!priv->jack_inserted) {
|
||||
- u32 det_ctl = snd_soc_component_read(component, CDC_A_MBHC_DET_CTL_1);
|
||||
- u32 rt_sts = snd_soc_component_read(component, CDC_D_INT_RT_STS);
|
||||
-
|
||||
- if (!(det_ctl & CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_MASK) ||
|
||||
- (rt_sts & MBHC_SWITCH_INT))
|
||||
- priv->jack_inserted = true;
|
||||
+ if (!priv->jack_gpio.report && pm8916_mbhc_plug_present(component)) {
|
||||
+ pm8916_wcd_analog_switch_check(priv, true);
|
||||
+ } else {
|
||||
+ mutex_lock(&priv->power_lock);
|
||||
+ if (!priv->jack_inserted && priv->mbhc_btn_enabled)
|
||||
+ snd_soc_component_write(component, CDC_D_INT_EN_CLR,
|
||||
+ MBHC_BUTTON_PRESS_DET |
|
||||
+ MBHC_BUTTON_RELEASE_DET);
|
||||
+ err = pm8916_wcd_analog_update_power_locked(component);
|
||||
+ mutex_unlock(&priv->power_lock);
|
||||
+ if (err)
|
||||
+ dev_warn(component->dev, "failed initial wcd power sync (%d)\n", err);
|
||||
}
|
||||
- if (!priv->jack_inserted && priv->mbhc_btn_enabled)
|
||||
- snd_soc_component_write(component, CDC_D_INT_EN_CLR,
|
||||
- MBHC_BUTTON_PRESS_DET | MBHC_BUTTON_RELEASE_DET);
|
||||
- err = pm8916_wcd_analog_update_power_locked(component);
|
||||
- mutex_unlock(&priv->power_lock);
|
||||
- if (err)
|
||||
- dev_warn(component->dev, "failed initial wcd power sync (%d)\n", err);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -981,14 +1241,27 @@ static const struct snd_soc_dapm_widget pm8916_wcd_analog_dapm_widgets[] = {
|
||||
SND_SOC_DAPM_MUX("EAR_S", SND_SOC_NOPM, 0, 0, &ear_mux),
|
||||
SND_SOC_DAPM_SUPPLY("EAR CP", CDC_A_NCP_EN, 4, 0, NULL, 0),
|
||||
|
||||
@@ -433,6 +535,146 @@ index 257f780..457b552 100644
|
||||
SND_SOC_DAPM_MIXER("SPK DAC", SND_SOC_NOPM, 0, 0,
|
||||
spkr_switch, ARRAY_SIZE(spkr_switch)),
|
||||
|
||||
@@ -1094,6 +1367,14 @@ static int pm8916_wcd_analog_set_jack(struct snd_soc_component *component,
|
||||
}
|
||||
|
||||
wcd->jack = jack;
|
||||
+ if (jack && !wcd->jack_gpio.report) {
|
||||
+ int initial_report;
|
||||
+
|
||||
+ mutex_lock(&wcd->power_lock);
|
||||
+ initial_report = wcd->jack_inserted ? wcd->jack_report : 0;
|
||||
+ mutex_unlock(&wcd->power_lock);
|
||||
+ snd_soc_jack_report(jack, initial_report, hs_jack_mask);
|
||||
+ }
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1164,9 +1445,14 @@ static int pm8916_wcd_analog_switch_check(struct pm8916_wcd_analog_priv *priv, b
|
||||
CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_MASK,
|
||||
(!ins << CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_SHIFT));
|
||||
|
||||
-
|
||||
if (ins) { /* hs insertion */
|
||||
bool micbias_enabled = false;
|
||||
+ int rt_sts;
|
||||
+
|
||||
+ if (priv->mbhc_btn_enabled)
|
||||
+ snd_soc_component_write(component, CDC_D_INT_EN_CLR,
|
||||
+ MBHC_BUTTON_PRESS_DET |
|
||||
+ MBHC_BUTTON_RELEASE_DET);
|
||||
|
||||
mutex_lock(&priv->power_lock);
|
||||
priv->jack_inserted = true;
|
||||
@@ -1176,33 +1462,56 @@ static int pm8916_wcd_analog_switch_check(struct pm8916_wcd_analog_priv *priv, b
|
||||
snd_soc_component_update_bits(component, CDC_D_CDC_DIG_CLK_CTL,
|
||||
DIG_CLK_CTL_D_MBHC_CLK_EN_MASK,
|
||||
DIG_CLK_CTL_D_MBHC_CLK_EN);
|
||||
- if (priv->mbhc_btn_enabled)
|
||||
- snd_soc_component_update_bits(component, CDC_D_INT_EN_SET,
|
||||
- MBHC_BUTTON_PRESS_DET |
|
||||
- MBHC_BUTTON_RELEASE_DET,
|
||||
- MBHC_BUTTON_PRESS_DET |
|
||||
- MBHC_BUTTON_RELEASE_DET);
|
||||
|
||||
if (snd_soc_component_read(component, CDC_A_MICB_2_EN) &
|
||||
CDC_A_MICB_2_EN_ENABLE)
|
||||
micbias_enabled = true;
|
||||
|
||||
+ snd_soc_component_update_bits(component, CDC_A_MBHC_FSM_CTL,
|
||||
+ CDC_A_MBHC_FSM_CTL_MBHC_FSM_EN_MASK,
|
||||
+ 0);
|
||||
pm8916_mbhc_configure_bias(priv, micbias_enabled);
|
||||
+ msleep(25);
|
||||
+ rt_sts = snd_soc_component_read(component, CDC_D_INT_RT_STS);
|
||||
+ if (rt_sts >= 0 && (rt_sts & MBHC_BUTTON_PRESS_DET)) {
|
||||
+ msleep(75);
|
||||
+ rt_sts = snd_soc_component_read(component, CDC_D_INT_RT_STS);
|
||||
+ }
|
||||
+
|
||||
+ if (!priv->jack_gpio.report && !pm8916_mbhc_plug_present(component)) {
|
||||
+ snd_soc_component_update_bits(component, CDC_A_MBHC_DET_CTL_1,
|
||||
+ CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_MASK,
|
||||
+ CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_INSERTION);
|
||||
+ goto remove;
|
||||
+ }
|
||||
|
||||
/*
|
||||
- * if only a btn0 press event is receive just before
|
||||
- * insert event then its a 3 pole headphone else if
|
||||
- * both press and release event received then its
|
||||
- * a headset.
|
||||
+ * After MBHC FSM settling, a 4-pole headset pulls MIC above BTN0
|
||||
+ * (no BTN_PRESS_DET) or releases BTN0; a 3-pole headphone shorts
|
||||
+ * MIC to GND (BTN_PRESS_DET stays asserted), so keep 100uA ISRC
|
||||
+ * and button IRQs disabled on 3-pole plugs.
|
||||
*/
|
||||
- if (priv->mbhc_btn0_released)
|
||||
+ if (priv->mbhc_btn0_released ||
|
||||
+ (rt_sts >= 0 && !(rt_sts & MBHC_BUTTON_PRESS_DET))) {
|
||||
report = SND_JACK_HEADSET;
|
||||
- else
|
||||
+ if (priv->mbhc_btn_enabled)
|
||||
+ snd_soc_component_update_bits(component, CDC_D_INT_EN_SET,
|
||||
+ MBHC_BUTTON_PRESS_DET |
|
||||
+ MBHC_BUTTON_RELEASE_DET,
|
||||
+ MBHC_BUTTON_PRESS_DET |
|
||||
+ MBHC_BUTTON_RELEASE_DET);
|
||||
+ } else {
|
||||
report = SND_JACK_HEADPHONE;
|
||||
+ pm8916_mbhc_disable_btn_bias(component);
|
||||
+ }
|
||||
|
||||
priv->detect_accessory_type = false;
|
||||
+ mutex_lock(&priv->power_lock);
|
||||
+ priv->jack_report = report;
|
||||
+ mutex_unlock(&priv->power_lock);
|
||||
|
||||
} else { /* removal */
|
||||
+remove:
|
||||
report = 0;
|
||||
priv->detect_accessory_type = true;
|
||||
priv->mbhc_btn0_released = false;
|
||||
@@ -1210,8 +1519,10 @@ static int pm8916_wcd_analog_switch_check(struct pm8916_wcd_analog_priv *priv, b
|
||||
snd_soc_component_write(component, CDC_D_INT_EN_CLR,
|
||||
MBHC_BUTTON_PRESS_DET |
|
||||
MBHC_BUTTON_RELEASE_DET);
|
||||
+ pm8916_mbhc_disable_btn_bias(component);
|
||||
mutex_lock(&priv->power_lock);
|
||||
priv->jack_inserted = false;
|
||||
+ priv->jack_report = 0;
|
||||
pm8916_wcd_analog_update_power_locked(component);
|
||||
mutex_unlock(&priv->power_lock);
|
||||
}
|
||||
@@ -1223,15 +1534,22 @@ static irqreturn_t pm8916_mbhc_switch_irq_handler(int irq, void *arg)
|
||||
{
|
||||
struct pm8916_wcd_analog_priv *priv = arg;
|
||||
struct snd_soc_component *component = priv->component;
|
||||
- bool ins = false;
|
||||
+ u32 det_ctl;
|
||||
+ bool waiting_ins, phys_ins;
|
||||
int report;
|
||||
|
||||
- if (snd_soc_component_read(component, CDC_A_MBHC_DET_CTL_1) &
|
||||
- CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_MASK)
|
||||
- ins = true;
|
||||
+ if (!component)
|
||||
+ return IRQ_HANDLED;
|
||||
+
|
||||
+ det_ctl = snd_soc_component_read(component, CDC_A_MBHC_DET_CTL_1);
|
||||
+ waiting_ins = !!(det_ctl & CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_MASK);
|
||||
+ phys_ins = pm8916_mbhc_plug_present(component);
|
||||
+ if (phys_ins != waiting_ins)
|
||||
+ return IRQ_HANDLED;
|
||||
|
||||
- report = pm8916_wcd_analog_switch_check(priv, ins);
|
||||
- snd_soc_jack_report(priv->jack, report, hs_jack_mask);
|
||||
+ report = pm8916_wcd_analog_switch_check(priv, phys_ins);
|
||||
+ if (priv->jack)
|
||||
+ snd_soc_jack_report(priv->jack, report, hs_jack_mask);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
diff --git a/sound/soc/codecs/msm8916-wcd-digital.c b/sound/soc/codecs/msm8916-wcd-digital.c
|
||||
index 81d1134..fc2520e 100644
|
||||
--- a/sound/soc/codecs/msm8916-wcd-digital.c
|
||||
|
||||
Reference in new issue
Block a user