Skip to content

Commit bff8e64

Browse files
povikjannau
authored andcommitted
NOT UPSTREAMABLE: ASoC: tas2764: Redo I/V sense logic
* Only set up I/V sense transmission in case the slots are described in devicetree, never use defaults. * Move the enablement of I/V sense transmission away from hw_params up into component probe, do not condition it on the measurements itself being enabled. * Move the slot configuration from set_tdm_slot into component probe, so it's not separate from other configuration. Since this makes I/V sense unavailable in some configurations where it formerly was, and it also changes behavior depending on the pairing with a machine-level driver (depending on set_tdm_slot calls), it's probably not upstreamable as is. Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
1 parent 8dcfdf5 commit bff8e64

1 file changed

Lines changed: 23 additions & 38 deletions

File tree

sound/soc/codecs/tas2764.c

Lines changed: 23 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ static int tas2764_mute(struct snd_soc_dai *dai, int mute, int direction)
261261
static int tas2764_set_bitwidth(struct tas2764_priv *tas2764, int bitwidth)
262262
{
263263
struct snd_soc_component *component = tas2764->component;
264-
int sense_en;
265264
int val;
266265
int ret;
267266

@@ -296,28 +295,6 @@ static int tas2764_set_bitwidth(struct tas2764_priv *tas2764, int bitwidth)
296295
if (val < 0)
297296
return val;
298297

299-
if (val & (1 << TAS2764_VSENSE_POWER_EN))
300-
sense_en = 0;
301-
else
302-
sense_en = TAS2764_TDM_CFG5_VSNS_ENABLE;
303-
304-
ret = snd_soc_component_update_bits(tas2764->component, TAS2764_TDM_CFG5,
305-
TAS2764_TDM_CFG5_VSNS_ENABLE,
306-
sense_en);
307-
if (ret < 0)
308-
return ret;
309-
310-
if (val & (1 << TAS2764_ISENSE_POWER_EN))
311-
sense_en = 0;
312-
else
313-
sense_en = TAS2764_TDM_CFG6_ISNS_ENABLE;
314-
315-
ret = snd_soc_component_update_bits(tas2764->component, TAS2764_TDM_CFG6,
316-
TAS2764_TDM_CFG6_ISNS_ENABLE,
317-
sense_en);
318-
if (ret < 0)
319-
return ret;
320-
321298
return 0;
322299
}
323300

@@ -447,7 +424,6 @@ static int tas2764_set_dai_tdm_slot(struct snd_soc_dai *dai,
447424
int slots, int slot_width)
448425
{
449426
struct snd_soc_component *component = dai->component;
450-
struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component);
451427
int left_slot, right_slot;
452428
int slots_cfg;
453429
int slot_size;
@@ -494,15 +470,26 @@ static int tas2764_set_dai_tdm_slot(struct snd_soc_dai *dai,
494470
if (ret < 0)
495471
return ret;
496472

497-
ret = snd_soc_component_update_bits(component, TAS2764_TDM_CFG5,
473+
return 0;
474+
}
475+
476+
static int tas2764_set_ivsense_transmit(struct tas2764_priv *tas2764, int i_slot, int v_slot)
477+
{
478+
int ret;
479+
480+
ret = snd_soc_component_update_bits(tas2764->component, TAS2764_TDM_CFG5,
481+
TAS2764_TDM_CFG5_VSNS_ENABLE |
498482
TAS2764_TDM_CFG5_50_MASK,
499-
tas2764->v_sense_slot);
483+
TAS2764_TDM_CFG5_VSNS_ENABLE |
484+
v_slot);
500485
if (ret < 0)
501486
return ret;
502487

503-
ret = snd_soc_component_update_bits(component, TAS2764_TDM_CFG6,
488+
ret = snd_soc_component_update_bits(tas2764->component, TAS2764_TDM_CFG6,
489+
TAS2764_TDM_CFG6_ISNS_ENABLE |
504490
TAS2764_TDM_CFG6_50_MASK,
505-
tas2764->i_sense_slot);
491+
TAS2764_TDM_CFG6_ISNS_ENABLE |
492+
i_slot);
506493
if (ret < 0)
507494
return ret;
508495

@@ -695,15 +682,13 @@ static int tas2764_codec_probe(struct snd_soc_component *component)
695682
dev_warn(tas2764->dev, "failed to request IRQ: %d\n", ret);
696683
}
697684

698-
ret = snd_soc_component_update_bits(tas2764->component, TAS2764_TDM_CFG5,
699-
TAS2764_TDM_CFG5_VSNS_ENABLE, 0);
700-
if (ret < 0)
701-
return ret;
685+
if (tas2764->i_sense_slot != -1 && tas2764->v_sense_slot != -1) {
686+
ret = tas2764_set_ivsense_transmit(tas2764, tas2764->i_sense_slot,
687+
tas2764->v_sense_slot);
702688

703-
ret = snd_soc_component_update_bits(tas2764->component, TAS2764_TDM_CFG6,
704-
TAS2764_TDM_CFG6_ISNS_ENABLE, 0);
705-
if (ret < 0)
706-
return ret;
689+
if (ret < 0)
690+
return ret;
691+
}
707692

708693
switch (tas2764->devid) {
709694
case DEVID_SN012776:
@@ -856,12 +841,12 @@ static int tas2764_parse_dt(struct device *dev, struct tas2764_priv *tas2764)
856841
ret = fwnode_property_read_u32(dev->fwnode, "ti,imon-slot-no",
857842
&tas2764->i_sense_slot);
858843
if (ret)
859-
tas2764->i_sense_slot = 0;
844+
tas2764->i_sense_slot = -1;
860845

861846
ret = fwnode_property_read_u32(dev->fwnode, "ti,vmon-slot-no",
862847
&tas2764->v_sense_slot);
863848
if (ret)
864-
tas2764->v_sense_slot = 2;
849+
tas2764->v_sense_slot = -1;
865850

866851
return 0;
867852
}

0 commit comments

Comments
 (0)