Skip to content

Commit f0066c8

Browse files
povikbroonie
authored andcommitted
ASoC: tas2770: Fix and redo I/V sense TDM slot setting logic
The former code sets the V slot from inside set_bitwidth according to the bitwidth of the PCM format. That's wrong, since: * It overrides the V slot parsed from DT binding. * The V slot is set shifted behind the I slot by the length of the PCM bitwidth, but the PCM bitwidth has no assured relation to the TDM slot width. Replace the former logic by setting up the I/V sense transmission only in case of both I/V slots being specified in devicetree, and never override those values. In case the slots are left unspecified, disable the transmission completely. There's an improbable case someone is relying on the old behavior, but if so, that's a setup that only works by accident, and cannot be sanely supported going forward. There's no indication anyone is consuming the I/V sense data up to today, so break the former behavior. 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 6553ee0 commit f0066c8

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

sound/soc/codecs/tas2770.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,19 +224,16 @@ static int tas2770_set_bitwidth(struct tas2770_priv *tas2770, int bitwidth)
224224
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG2,
225225
TAS2770_TDM_CFG_REG2_RXW_MASK,
226226
TAS2770_TDM_CFG_REG2_RXW_16BITS);
227-
tas2770->v_sense_slot = tas2770->i_sense_slot + 2;
228227
break;
229228
case SNDRV_PCM_FORMAT_S24_LE:
230229
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG2,
231230
TAS2770_TDM_CFG_REG2_RXW_MASK,
232231
TAS2770_TDM_CFG_REG2_RXW_24BITS);
233-
tas2770->v_sense_slot = tas2770->i_sense_slot + 4;
234232
break;
235233
case SNDRV_PCM_FORMAT_S32_LE:
236234
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG2,
237235
TAS2770_TDM_CFG_REG2_RXW_MASK,
238236
TAS2770_TDM_CFG_REG2_RXW_32BITS);
239-
tas2770->v_sense_slot = tas2770->i_sense_slot + 4;
240237
break;
241238

242239
default:
@@ -246,11 +243,6 @@ static int tas2770_set_bitwidth(struct tas2770_priv *tas2770, int bitwidth)
246243
if (ret < 0)
247244
return ret;
248245

249-
ret = tas2770_set_ivsense_transmit(tas2770, tas2770->i_sense_slot,
250-
tas2770->v_sense_slot);
251-
if (ret < 0)
252-
return ret;
253-
254246
return 0;
255247
}
256248

@@ -505,6 +497,7 @@ static int tas2770_codec_probe(struct snd_soc_component *component)
505497
{
506498
struct tas2770_priv *tas2770 =
507499
snd_soc_component_get_drvdata(component);
500+
int ret;
508501

509502
tas2770->component = component;
510503

@@ -516,6 +509,14 @@ static int tas2770_codec_probe(struct snd_soc_component *component)
516509
tas2770_reset(tas2770);
517510
regmap_reinit_cache(tas2770->regmap, &tas2770_i2c_regmap);
518511

512+
if (tas2770->i_sense_slot != -1 && tas2770->v_sense_slot != -1) {
513+
ret = tas2770_set_ivsense_transmit(tas2770, tas2770->i_sense_slot,
514+
tas2770->v_sense_slot);
515+
516+
if (ret < 0)
517+
return ret;
518+
}
519+
519520
return 0;
520521
}
521522

@@ -643,7 +644,7 @@ static int tas2770_parse_dt(struct device *dev, struct tas2770_priv *tas2770)
643644
dev_info(tas2770->dev, "Property %s is missing setting default slot\n",
644645
"ti,imon-slot-no");
645646

646-
tas2770->i_sense_slot = 0;
647+
tas2770->i_sense_slot = -1;
647648
}
648649

649650
rc = fwnode_property_read_u32(dev->fwnode, "ti,vmon-slot-no",
@@ -652,7 +653,7 @@ static int tas2770_parse_dt(struct device *dev, struct tas2770_priv *tas2770)
652653
dev_info(tas2770->dev, "Property %s is missing setting default slot\n",
653654
"ti,vmon-slot-no");
654655

655-
tas2770->v_sense_slot = 2;
656+
tas2770->v_sense_slot = -1;
656657
}
657658

658659
tas2770->sdz_gpio = devm_gpiod_get_optional(dev, "shutdown", GPIOD_OUT_HIGH);

0 commit comments

Comments
 (0)