Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5e4d1b84 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ASoC: wcd9xxx: Maintain micbias for headsets with threshold on mic"

parents 4d90151b 72abaa13
Loading
Loading
Loading
Loading
+37 −1
Original line number Diff line number Diff line
@@ -50,6 +50,8 @@
#define BITS_PER_REG		8
#define MSM8X10_WCD_TX_PORT_NUMBER	4

#define DAPM_MICBIAS_EXTERNAL_STANDALONE "MIC BIAS External Standalone"

#define MSM8X10_WCD_I2S_MASTER_MODE_MASK	0x08
#define MSM8X10_DINO_CODEC_BASE_ADDR		0xFE043000
#define MSM8X10_DINO_CODEC_REG_SIZE		0x200
@@ -1643,6 +1645,8 @@ static int msm8x10_wcd_codec_enable_micbias(struct snd_soc_dapm_widget *w,

		/* Always pull up TxFe for TX2 to Micbias */
		snd_soc_update_bits(codec, micb_int_reg, 0x04, 0x04);
		snd_soc_update_bits(codec, MSM8X10_WCD_A_MICB_1_CTL,
					0x80, 0x80);
		break;
	case SND_SOC_DAPM_POST_PMU:
		usleep_range(20000, 20100);
@@ -1650,6 +1654,8 @@ static int msm8x10_wcd_codec_enable_micbias(struct snd_soc_dapm_widget *w,
		wcd9xxx_resmgr_notifier_call(&msm8x10_wcd->resmgr, e_post_on);
		break;
	case SND_SOC_DAPM_POST_PMD:
		snd_soc_update_bits(codec, MSM8X10_WCD_A_MICB_1_CTL,
					0x80, 0x00);
		/* Let MBHC module know so micbias switch to be off */
		wcd9xxx_resmgr_notifier_call(&msm8x10_wcd->resmgr, e_post_off);

@@ -2471,6 +2477,11 @@ static const struct snd_soc_dapm_widget msm8x10_wcd_dapm_widgets[] = {
		MSM8X10_WCD_A_MICB_1_CTL, 7, 0,
		msm8x10_wcd_codec_enable_micbias, SND_SOC_DAPM_PRE_PMU |
		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
	SND_SOC_DAPM_MICBIAS_E(DAPM_MICBIAS_EXTERNAL_STANDALONE,
		MSM8X10_WCD_A_MICB_1_CTL,
		7, 0, msm8x10_wcd_codec_enable_micbias,
		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
		SND_SOC_DAPM_POST_PMD),

	SND_SOC_DAPM_ADC_E("ADC1", NULL, MSM8X10_WCD_A_TX_1_EN, 7, 0,
		msm8x10_wcd_codec_enable_adc, SND_SOC_DAPM_PRE_PMU |
@@ -2722,6 +2733,30 @@ static int msm8x10_wcd_enable_ext_mb_source(struct snd_soc_codec *codec,
	return ret;
}

static int msm8x10_wcd_enable_mbhc_micbias(struct snd_soc_codec *codec,
	 bool enable)
{
	int rc;

	if (enable)
		rc = snd_soc_dapm_force_enable_pin(&codec->dapm,
			DAPM_MICBIAS_EXTERNAL_STANDALONE);
	else
		rc = snd_soc_dapm_disable_pin(&codec->dapm,
			DAPM_MICBIAS_EXTERNAL_STANDALONE);
	snd_soc_dapm_sync(&codec->dapm);

	snd_soc_update_bits(codec, WCD9XXX_A_MICB_1_CTL,
		0x80, enable ? 0x80 : 0x00);
	if (rc)
		pr_debug("%s: Failed to force %s micbias", __func__,
			enable ? "enable" : "disable");
	else
		pr_debug("%s: Trying force %s micbias", __func__,
			enable ? "enable" : "disable");
	return rc;
}

static void msm8x10_wcd_micb_internal(struct snd_soc_codec *codec, bool on)
{
	snd_soc_update_bits(codec, MSM8X10_WCD_A_MICB_1_INT_RBIAS,
@@ -3210,7 +3245,8 @@ static int msm8x10_wcd_codec_probe(struct snd_soc_codec *codec)

	ret = wcd9xxx_mbhc_init(&msm8x10_wcd_priv->mbhc,
				&msm8x10_wcd_priv->resmgr,
				codec, NULL, &mbhc_cb, &cdc_intr_ids,
				codec, msm8x10_wcd_enable_mbhc_micbias,
				&mbhc_cb, &cdc_intr_ids,
				HELICON_MCLK_CLK_9P6MHZ, true);
	if (ret) {
		dev_err(msm8x10_wcd->dev, "%s: Failed to initialize mbhc\n",
+8 −0
Original line number Diff line number Diff line
@@ -4269,6 +4269,14 @@ static int wcd9xxx_event_notify(struct notifier_block *self, unsigned long val,
			if (!mbhc->polling_active)
				wcd9xxx_enable_mbhc_txfe(mbhc, false);
		}
		if (mbhc->micbias_enable && mbhc->polling_active &&
		    !(snd_soc_read(mbhc->codec, mbhc->mbhc_bias_regs.ctl_reg)
		    & 0x80)) {
			pr_debug("%s:Micbias turned off by recording, set up again",
				 __func__);
			snd_soc_update_bits(codec, mbhc->mbhc_bias_regs.ctl_reg,
					    0x80, 0x80);
		}
		break;
	/* PA usage change */
	case WCD9XXX_EVENT_PRE_HPHL_PA_ON:
+1 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ static struct wcd9xxx_mbhc_config mbhc_cfg = {
	.insert_detect = true,
	.swap_gnd_mic = NULL,
	.use_int_rbias = false,
	.micbias_enable_flags = 1 << MBHC_MICBIAS_ENABLE_THRESHOLD_HEADSET,
	.cs_enable_flags = (1 << MBHC_CS_ENABLE_POLLING |
			    1 << MBHC_CS_ENABLE_INSERTION |
			    1 << MBHC_CS_ENABLE_REMOVAL),