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

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

Merge "ASoC: msm: Add support to configure compander GPIO"

parents 56a06c7c 05db5cdd
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -453,6 +453,15 @@ void msm8x16_wcd_spk_ext_pa_cb(
	msm8x16_wcd->codec_spk_ext_pa_cb = codec_spk_ext_pa;
}

void msm8x16_wcd_hph_comp_cb(
	int (*codec_hph_comp_gpio)(bool enable), struct snd_soc_codec *codec)
{
	struct msm8x16_wcd_priv *msm8x16_wcd = snd_soc_codec_get_drvdata(codec);

	pr_debug("%s: Enter\n", __func__);
	msm8x16_wcd->codec_hph_comp_gpio = codec_hph_comp_gpio;
}

static void msm8x16_wcd_compute_impedance(struct snd_soc_codec *codec, s16 l,
				s16 r, uint32_t *zl, uint32_t *zr, bool high)
{
@@ -3851,7 +3860,15 @@ static int msm8x16_wcd_codec_config_compander(struct snd_soc_codec *codec,
				MSM8X16_WCD_A_CDC_COMP0_B3_CTL, 0xFF, 0x28);
			snd_soc_update_bits(codec,
				MSM8X16_WCD_A_CDC_COMP0_B2_CTL, 0xF0, 0xB0);

			/* Enable Compander GPIO */
			if (msm8x16_wcd->codec_hph_comp_gpio)
				msm8x16_wcd->codec_hph_comp_gpio(1);
		} else if (SND_SOC_DAPM_EVENT_OFF(event)) {
			/* Disable Compander GPIO */
			if (msm8x16_wcd->codec_hph_comp_gpio)
				msm8x16_wcd->codec_hph_comp_gpio(0);

			snd_soc_update_bits(codec,
				MSM8X16_WCD_A_CDC_COMP0_B2_CTL, 0x0F, 0x05);
			snd_soc_update_bits(codec,
+5 −0
Original line number Diff line number Diff line
@@ -315,6 +315,7 @@ struct msm8x16_wcd_priv {
	struct fw_info *fw_data;
	struct blocking_notifier_head notifier;
	int (*codec_spk_ext_pa_cb)(struct snd_soc_codec *codec, int enable);
	int (*codec_hph_comp_gpio)(bool enable);
	unsigned long status_mask;
	struct wcd_imped_i_ref imped_i_ref;
	enum wcd_mbhc_imp_det_pin imped_det_pin;
@@ -333,5 +334,9 @@ extern void msm8x16_update_int_spk_boost(bool enable);
extern void msm8x16_wcd_spk_ext_pa_cb(
		int (*codec_spk_ext_pa)(struct snd_soc_codec *codec,
		int enable), struct snd_soc_codec *codec);

extern void msm8x16_wcd_hph_comp_cb(
		int (*codec_hph_comp_gpio)(bool enable),
		struct snd_soc_codec *codec);
#endif
+1 −1
Original line number Diff line number Diff line
@@ -226,7 +226,7 @@
#define MSM8X16_WCD_A_ANALOG_RX_COM_OCP_COUNT		(0x192)
#define MSM8X16_WCD_A_ANALOG_RX_COM_OCP_COUNT__POR		(0x6E)
#define MSM8X16_WCD_A_ANALOG_RX_COM_BIAS_DAC		(0x193)
#define MSM8X16_WCD_A_ANALOG_RX_COM_BIAS_DAC__POR		(0x10)
#define MSM8X16_WCD_A_ANALOG_RX_COM_BIAS_DAC__POR		(0x18)
#define MSM8X16_WCD_A_ANALOG_RX_HPH_BIAS_PA		(0x194)
#define MSM8X16_WCD_A_ANALOG_RX_HPH_BIAS_PA__POR		(0x5A)
#define MSM8X16_WCD_A_ANALOG_RX_HPH_BIAS_LDO_OCP	(0x195)
+28 −0
Original line number Diff line number Diff line
@@ -209,6 +209,33 @@ static const struct snd_soc_dapm_widget msm8952_dapm_widgets[] = {
	SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
};

static int config_hph_compander_gpio(bool enable)
{
	int ret = 0;

	pr_debug("%s: %s HPH Compander\n", __func__,
		enable ? "Enable" : "Disable");

	if (enable) {
		ret = msm_gpioset_activate(CLIENT_WCD_INT, "comp_gpio");
		if (ret) {
			pr_err("%s: gpio set cannot be activated %s\n",
				__func__, "comp_gpio");
			goto done;
		}
	} else {
		ret = msm_gpioset_suspend(CLIENT_WCD_INT, "comp_gpio");
		if (ret) {
			pr_err("%s: gpio set cannot be de-activated %s\n",
				__func__, "comp_gpio");
			goto done;
		}
	}

done:
	return ret;
}

int is_ext_spk_gpio_support(struct platform_device *pdev,
			struct msm8916_asoc_mach_data *pdata)
{
@@ -1539,6 +1566,7 @@ static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
	snd_soc_dapm_sync(dapm);

	msm8x16_wcd_spk_ext_pa_cb(enable_spk_ext_pa, codec);
	msm8x16_wcd_hph_comp_cb(config_hph_compander_gpio, codec);

	mbhc_cfg.calibration = def_msm8952_wcd_mbhc_cal();
	if (mbhc_cfg.calibration) {