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

Commit 5bbc78bb 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: Realign the ANC coefficients index"

parents 539ec528 8c1b0965
Loading
Loading
Loading
Loading
+44 −0
Original line number Diff line number Diff line
@@ -2468,6 +2468,44 @@ static int tasha_codec_enable_rx_bias(struct snd_soc_dapm_widget *w,
	return 0;
}

static void tasha_realign_anc_coeff(struct snd_soc_codec *codec,
				    u16 reg1, u16 reg2)
{
	u8 val1, val2, tmpval1, tmpval2;

	snd_soc_write(codec, reg1, 0x00);
	tmpval1 = snd_soc_read(codec, reg2);
	tmpval2 = snd_soc_read(codec, reg2);
	snd_soc_write(codec, reg1, 0x00);
	snd_soc_write(codec, reg2, 0xFF);
	snd_soc_write(codec, reg1, 0x01);
	snd_soc_write(codec, reg2, 0xFF);

	snd_soc_write(codec, reg1, 0x00);
	val1 = snd_soc_read(codec, reg2);
	val2 = snd_soc_read(codec, reg2);

	if (val1 == 0x0F && val2 == 0xFF) {
		dev_dbg(codec->dev, "%s: ANC0 co-eff index re-aligned\n",
			__func__);
		snd_soc_read(codec, reg2);
		snd_soc_write(codec, reg1, 0x00);
		snd_soc_write(codec, reg2, tmpval2);
		snd_soc_write(codec, reg1, 0x01);
		snd_soc_write(codec, reg2, tmpval1);
	} else if (val1 == 0xFF && val2 == 0x0F) {
		dev_dbg(codec->dev, "%s: ANC0 co-eff index already aligned\n",
			__func__);
		snd_soc_write(codec, reg1, 0x00);
		snd_soc_write(codec, reg2, tmpval1);
		snd_soc_write(codec, reg1, 0x01);
		snd_soc_write(codec, reg2, tmpval2);
	} else {
		dev_err(codec->dev, "%s: ANC0 co-eff index not aligned\n",
			__func__);
	}
}

static int tasha_codec_enable_anc(struct snd_soc_dapm_widget *w,
				  struct snd_kcontrol *kcontrol, int event)
{
@@ -2567,6 +2605,12 @@ static int tasha_codec_enable_anc(struct snd_soc_dapm_widget *w,
			goto err;
		}

		tasha_realign_anc_coeff(codec,
					WCD9335_CDC_ANC0_IIR_COEFF_1_CTL,
					WCD9335_CDC_ANC0_IIR_COEFF_2_CTL);
		tasha_realign_anc_coeff(codec,
					WCD9335_CDC_ANC1_IIR_COEFF_1_CTL,
					WCD9335_CDC_ANC1_IIR_COEFF_2_CTL);
		i = 0;
		anc_cal_size = anc_writes_size;