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

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

Merge "ASoC: wcd9335: Add support for smart boost default configuration"

parents d799989b b01195a6
Loading
Loading
Loading
Loading
+64 −2
Original line number Diff line number Diff line
@@ -608,8 +608,65 @@ struct tasha_priv {

	int (*machine_codec_event_cb)(struct snd_soc_codec *codec,
				      enum wcd9335_codec_event);
	int spkr_mode;
};

static const struct tasha_reg_mask_val tasha_spkr_default[] = {
	{WCD9335_CDC_COMPANDER7_CTL3, 0x80, 0x80},
	{WCD9335_CDC_COMPANDER8_CTL3, 0x80, 0x80},
	{WCD9335_CDC_COMPANDER7_CTL7, 0x01, 0x01},
	{WCD9335_CDC_COMPANDER8_CTL7, 0x01, 0x01},
	{WCD9335_CDC_BOOST0_BOOST_CTL, 0x7C, 0x50},
	{WCD9335_CDC_BOOST1_BOOST_CTL, 0x7C, 0x50},
};

static const struct tasha_reg_mask_val tasha_spkr_mode1[] = {
	{WCD9335_CDC_COMPANDER7_CTL3, 0x80, 0x00},
	{WCD9335_CDC_COMPANDER8_CTL3, 0x80, 0x00},
	{WCD9335_CDC_COMPANDER7_CTL7, 0x01, 0x00},
	{WCD9335_CDC_COMPANDER8_CTL7, 0x01, 0x00},
	{WCD9335_CDC_BOOST0_BOOST_CTL, 0x7C, 0x34},
	{WCD9335_CDC_BOOST1_BOOST_CTL, 0x7C, 0x34},
};

/**
 * tasha_set_spkr_mode - Configures speaker compander and smartboost
 * settings based on speaker mode.
 *
 * @codec: codec instance
 * @mode: Indicates speaker configuration mode.
 *
 * Returns 0 on success or -EINVAL on error.
 */
int tasha_set_spkr_mode(struct snd_soc_codec *codec, int mode)
{
	struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec);
	int i;
	const struct tasha_reg_mask_val *regs;
	int size;

	if (!priv)
		return -EINVAL;

	switch (mode) {
	case SPKR_MODE_1:
		regs = tasha_spkr_mode1;
		size = ARRAY_SIZE(tasha_spkr_mode1);
		break;
	default:
		regs = tasha_spkr_default;
		size = ARRAY_SIZE(tasha_spkr_default);
		break;
	}

	priv->spkr_mode = mode;
	for (i = 0; i < size; i++)
		snd_soc_update_bits(codec, regs[i].reg,
				    regs[i].mask, regs[i].val);
	return 0;
}
EXPORT_SYMBOL(tasha_set_spkr_mode);

int tasha_enable_efuse_sensing(struct snd_soc_codec *codec)
{
	tasha_cdc_mclk_enable(codec, true, false);
@@ -8867,8 +8924,8 @@ static const struct tasha_reg_mask_val tasha_codec_reg_init_common_val[] = {
	{WCD9335_CDC_CLSH_K2_MSB, 0x0F, 0x00},
	{WCD9335_CDC_CLSH_K2_LSB, 0xFF, 0x60},
	{WCD9335_CPE_SS_DMIC_CFG, 0x80, 0x00},
	{WCD9335_CDC_BOOST0_BOOST_CTL, 0x70, 0x40},
	{WCD9335_CDC_BOOST1_BOOST_CTL, 0x70, 0x40},
	{WCD9335_CDC_BOOST0_BOOST_CTL, 0x70, 0x50},
	{WCD9335_CDC_BOOST1_BOOST_CTL, 0x70, 0x50},
	{WCD9335_CDC_RX7_RX_PATH_CFG1, 0x08, 0x08},
	{WCD9335_CDC_RX8_RX_PATH_CFG1, 0x08, 0x08},
	{WCD9335_ANA_LO_1_2, 0x3C, 0X3C},
@@ -8882,6 +8939,10 @@ static const struct tasha_reg_mask_val tasha_codec_reg_init_common_val[] = {
	{WCD9335_CDC_TX10_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
	{WCD9335_CDC_TX11_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
	{WCD9335_CDC_TX12_SPKR_PROT_PATH_CFG0, 0x01, 0x01},
	{WCD9335_CDC_COMPANDER7_CTL3, 0x80, 0x80},
	{WCD9335_CDC_COMPANDER8_CTL3, 0x80, 0x80},
	{WCD9335_CDC_COMPANDER7_CTL7, 0x01, 0x01},
	{WCD9335_CDC_COMPANDER8_CTL7, 0x01, 0x01},
};

static const struct tasha_reg_mask_val tasha_codec_reg_init_1_x_val[] = {
@@ -9691,6 +9752,7 @@ static int tasha_post_reset_cb(struct wcd9xxx *wcd9xxx)
	}

	tasha_enable_efuse_sensing(codec);
	tasha_set_spkr_mode(codec, tasha->spkr_mode);
	wcd_cpe_ssr_event(tasha->cpe_core, WCD_CPE_BUS_UP_EVENT);

err:
+9 −0
Original line number Diff line number Diff line
@@ -99,6 +99,14 @@ struct tasha_reg_mask_val {
	u8 val;
};

/* Selects compander and smart boost settings
 * for a given speaker mode
 */
enum {
	SPKR_MODE_DEFAULT,
	SPKR_MODE_1,          /* COMP Gain = 12dB, Smartboost Max = 5.5V */
};

extern void *tasha_get_afe_config(struct snd_soc_codec *codec,
				  enum afe_config_type config_type);
extern int tasha_cdc_mclk_enable(struct snd_soc_codec *codec, int enable,
@@ -119,4 +127,5 @@ extern void tasha_event_register(
extern int tasha_codec_enable_standalone_micbias(struct snd_soc_codec *codec,
						 int micb_num,
						 bool enable);
extern int tasha_set_spkr_mode(struct snd_soc_codec *codec, int mode);
#endif