Skip to content

Commit d1a10f1

Browse files
povikbroonie
authored andcommitted
ASoC: tas2764: Fix and extend FSYNC polarity handling
Fix setting of FSYNC polarity in case of LEFT_J and DSP_A/B formats. Do NOT set the SCFG field as was previously done, because that is not correct and is also in conflict with the "ASI1 Source" control which sets the same SCFG field! Also add support for explicit polarity inversion. Fixes: 827ed8a ("ASoC: tas2764: Add the driver for the TAS2764") Signed-off-by: Martin Povišer <povik+lin@cutebit.org> Link: https://lore.kernel.org/r/20220630075135.2221-2-povik+lin@cutebit.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent cd10bb8 commit d1a10f1

2 files changed

Lines changed: 19 additions & 17 deletions

File tree

sound/soc/codecs/tas2764.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ static const char * const tas2764_ASI1_src[] = {
135135
};
136136

137137
static SOC_ENUM_SINGLE_DECL(
138-
tas2764_ASI1_src_enum, TAS2764_TDM_CFG2, 4, tas2764_ASI1_src);
138+
tas2764_ASI1_src_enum, TAS2764_TDM_CFG2, TAS2764_TDM_CFG2_SCFG_SHIFT,
139+
tas2764_ASI1_src);
139140

140141
static const struct snd_kcontrol_new tas2764_asi1_mux =
141142
SOC_DAPM_ENUM("ASI1 Source", tas2764_ASI1_src_enum);
@@ -333,20 +334,22 @@ static int tas2764_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
333334
{
334335
struct snd_soc_component *component = dai->component;
335336
struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component);
336-
u8 tdm_rx_start_slot = 0, asi_cfg_1 = 0;
337-
int iface;
337+
u8 tdm_rx_start_slot = 0, asi_cfg_0 = 0, asi_cfg_1 = 0;
338338
int ret;
339339

340340
switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
341+
case SND_SOC_DAIFMT_NB_IF:
342+
asi_cfg_0 ^= TAS2764_TDM_CFG0_FRAME_START;
343+
fallthrough;
341344
case SND_SOC_DAIFMT_NB_NF:
342345
asi_cfg_1 = TAS2764_TDM_CFG1_RX_RISING;
343346
break;
347+
case SND_SOC_DAIFMT_IB_IF:
348+
asi_cfg_0 ^= TAS2764_TDM_CFG0_FRAME_START;
349+
fallthrough;
344350
case SND_SOC_DAIFMT_IB_NF:
345351
asi_cfg_1 = TAS2764_TDM_CFG1_RX_FALLING;
346352
break;
347-
default:
348-
dev_err(tas2764->dev, "ASI format Inverse is not found\n");
349-
return -EINVAL;
350353
}
351354

352355
ret = snd_soc_component_update_bits(component, TAS2764_TDM_CFG1,
@@ -357,13 +360,13 @@ static int tas2764_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
357360

358361
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
359362
case SND_SOC_DAIFMT_I2S:
363+
asi_cfg_0 ^= TAS2764_TDM_CFG0_FRAME_START;
364+
fallthrough;
360365
case SND_SOC_DAIFMT_DSP_A:
361-
iface = TAS2764_TDM_CFG2_SCFG_I2S;
362366
tdm_rx_start_slot = 1;
363367
break;
364368
case SND_SOC_DAIFMT_DSP_B:
365369
case SND_SOC_DAIFMT_LEFT_J:
366-
iface = TAS2764_TDM_CFG2_SCFG_LEFT_J;
367370
tdm_rx_start_slot = 0;
368371
break;
369372
default:
@@ -372,14 +375,15 @@ static int tas2764_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
372375
return -EINVAL;
373376
}
374377

375-
ret = snd_soc_component_update_bits(component, TAS2764_TDM_CFG1,
376-
TAS2764_TDM_CFG1_MASK,
377-
(tdm_rx_start_slot << TAS2764_TDM_CFG1_51_SHIFT));
378+
ret = snd_soc_component_update_bits(component, TAS2764_TDM_CFG0,
379+
TAS2764_TDM_CFG0_FRAME_START,
380+
asi_cfg_0);
378381
if (ret < 0)
379382
return ret;
380383

381-
ret = snd_soc_component_update_bits(component, TAS2764_TDM_CFG2,
382-
TAS2764_TDM_CFG2_SCFG_MASK, iface);
384+
ret = snd_soc_component_update_bits(component, TAS2764_TDM_CFG1,
385+
TAS2764_TDM_CFG1_MASK,
386+
(tdm_rx_start_slot << TAS2764_TDM_CFG1_51_SHIFT));
383387
if (ret < 0)
384388
return ret;
385389

sound/soc/codecs/tas2764.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#define TAS2764_TDM_CFG0_MASK GENMASK(3, 1)
4848
#define TAS2764_TDM_CFG0_44_1_48KHZ BIT(3)
4949
#define TAS2764_TDM_CFG0_88_2_96KHZ (BIT(3) | BIT(1))
50+
#define TAS2764_TDM_CFG0_FRAME_START BIT(0)
5051

5152
/* TDM Configuration Reg1 */
5253
#define TAS2764_TDM_CFG1 TAS2764_REG(0X0, 0x09)
@@ -66,10 +67,7 @@
6667
#define TAS2764_TDM_CFG2_RXS_16BITS 0x0
6768
#define TAS2764_TDM_CFG2_RXS_24BITS BIT(0)
6869
#define TAS2764_TDM_CFG2_RXS_32BITS BIT(1)
69-
#define TAS2764_TDM_CFG2_SCFG_MASK GENMASK(5, 4)
70-
#define TAS2764_TDM_CFG2_SCFG_I2S 0x0
71-
#define TAS2764_TDM_CFG2_SCFG_LEFT_J BIT(4)
72-
#define TAS2764_TDM_CFG2_SCFG_RIGHT_J BIT(5)
70+
#define TAS2764_TDM_CFG2_SCFG_SHIFT 4
7371

7472
/* TDM Configuration Reg3 */
7573
#define TAS2764_TDM_CFG3 TAS2764_REG(0X0, 0x0c)

0 commit comments

Comments
 (0)