Unverified Commit 6553ee02 authored by Martin Povišer's avatar Martin Povišer Committed by Mark Brown
Browse files

ASoC: tas2770: Factor out set_ivsense_slots



Add a new explicit function for the setting of I/V sense TDM slots.

Reviewed-by: default avatarNeal Gompa <neal@gompa.dev>
Signed-off-by: default avatarMartin Povišer <povik+lin@cutebit.org>
Signed-off-by: default avatarJames Calligeros <jcalligeros99@gmail.com>
Link: https://patch.msgid.link/20250227-apple-codec-changes-v3-5-cbb130030acf@gmail.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent f8d5f28e
Loading
Loading
Loading
Loading
+27 −13
Original line number Diff line number Diff line
@@ -189,6 +189,31 @@ static int tas2770_mute(struct snd_soc_dai *dai, int mute, int direction)
	return tas2770_update_pwr_ctrl(tas2770);
}

static int tas2770_set_ivsense_transmit(struct tas2770_priv *tas2770,
					int i_slot, int v_slot)
{
	struct snd_soc_component *component = tas2770->component;
	int ret;

	ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG5,
					    TAS2770_TDM_CFG_REG5_VSNS_MASK |
					    TAS2770_TDM_CFG_REG5_50_MASK,
					    TAS2770_TDM_CFG_REG5_VSNS_ENABLE |
					    v_slot);
	if (ret < 0)
		return ret;

	ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG6,
					    TAS2770_TDM_CFG_REG6_ISNS_MASK |
					    TAS2770_TDM_CFG_REG6_50_MASK,
					    TAS2770_TDM_CFG_REG6_ISNS_ENABLE |
					    i_slot);
	if (ret < 0)
		return ret;

	return 0;
}

static int tas2770_set_bitwidth(struct tas2770_priv *tas2770, int bitwidth)
{
	int ret;
@@ -221,22 +246,11 @@ static int tas2770_set_bitwidth(struct tas2770_priv *tas2770, int bitwidth)
	if (ret < 0)
		return ret;

	ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG5,
					    TAS2770_TDM_CFG_REG5_VSNS_MASK |
					    TAS2770_TDM_CFG_REG5_50_MASK,
					    TAS2770_TDM_CFG_REG5_VSNS_ENABLE |
	ret = tas2770_set_ivsense_transmit(tas2770, tas2770->i_sense_slot,
					   tas2770->v_sense_slot);
	if (ret < 0)
		return ret;

	ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG6,
					    TAS2770_TDM_CFG_REG6_ISNS_MASK |
					    TAS2770_TDM_CFG_REG6_50_MASK,
					    TAS2770_TDM_CFG_REG6_ISNS_ENABLE |
					    tas2770->i_sense_slot);
	if (ret < 0)
		return ret;

	return 0;
}