Skip to content

Commit 6553ee0

Browse files
povikbroonie
authored andcommitted
ASoC: tas2770: Factor out set_ivsense_slots
Add a new explicit function for the setting of I/V sense TDM slots. Reviewed-by: Neal Gompa <[email protected]> Signed-off-by: Martin Povišer <[email protected]> Signed-off-by: James Calligeros <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent f8d5f28 commit 6553ee0

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

sound/soc/codecs/tas2770.c

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,31 @@ static int tas2770_mute(struct snd_soc_dai *dai, int mute, int direction)
189189
return tas2770_update_pwr_ctrl(tas2770);
190190
}
191191

192+
static int tas2770_set_ivsense_transmit(struct tas2770_priv *tas2770,
193+
int i_slot, int v_slot)
194+
{
195+
struct snd_soc_component *component = tas2770->component;
196+
int ret;
197+
198+
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG5,
199+
TAS2770_TDM_CFG_REG5_VSNS_MASK |
200+
TAS2770_TDM_CFG_REG5_50_MASK,
201+
TAS2770_TDM_CFG_REG5_VSNS_ENABLE |
202+
v_slot);
203+
if (ret < 0)
204+
return ret;
205+
206+
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG6,
207+
TAS2770_TDM_CFG_REG6_ISNS_MASK |
208+
TAS2770_TDM_CFG_REG6_50_MASK,
209+
TAS2770_TDM_CFG_REG6_ISNS_ENABLE |
210+
i_slot);
211+
if (ret < 0)
212+
return ret;
213+
214+
return 0;
215+
}
216+
192217
static int tas2770_set_bitwidth(struct tas2770_priv *tas2770, int bitwidth)
193218
{
194219
int ret;
@@ -221,19 +246,8 @@ static int tas2770_set_bitwidth(struct tas2770_priv *tas2770, int bitwidth)
221246
if (ret < 0)
222247
return ret;
223248

224-
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG5,
225-
TAS2770_TDM_CFG_REG5_VSNS_MASK |
226-
TAS2770_TDM_CFG_REG5_50_MASK,
227-
TAS2770_TDM_CFG_REG5_VSNS_ENABLE |
228-
tas2770->v_sense_slot);
229-
if (ret < 0)
230-
return ret;
231-
232-
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG6,
233-
TAS2770_TDM_CFG_REG6_ISNS_MASK |
234-
TAS2770_TDM_CFG_REG6_50_MASK,
235-
TAS2770_TDM_CFG_REG6_ISNS_ENABLE |
236-
tas2770->i_sense_slot);
249+
ret = tas2770_set_ivsense_transmit(tas2770, tas2770->i_sense_slot,
250+
tas2770->v_sense_slot);
237251
if (ret < 0)
238252
return ret;
239253

0 commit comments

Comments
 (0)