mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-16 04:13:31 +00:00
100 lines
3.1 KiB
Diff
100 lines
3.1 KiB
Diff
From 25cfbd57efaf69fbbf65c4db2c4d541b8715e5f8 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Martin=20Povi=C5=A1er?= <povik+lin@cutebit.org>
|
|
Date: Sat, 19 Feb 2022 09:49:34 +0100
|
|
Subject: [PATCH 073/171] ASoC: tas2770: Set correct FSYNC polarity
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Fix setting of FSYNC polarity for DAI formats other than I2S. Also
|
|
add support for polarity inversion.
|
|
|
|
Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
|
|
---
|
|
sound/soc/codecs/tas2770.c | 21 ++++++++++++++++++++-
|
|
sound/soc/codecs/tas2770.h | 3 +++
|
|
2 files changed, 23 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/sound/soc/codecs/tas2770.c b/sound/soc/codecs/tas2770.c
|
|
index c1dbd978d550..2b214223265e 100644
|
|
--- a/sound/soc/codecs/tas2770.c
|
|
+++ b/sound/soc/codecs/tas2770.c
|
|
@@ -337,7 +337,7 @@ static int tas2770_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
|
|
struct snd_soc_component *component = dai->component;
|
|
struct tas2770_priv *tas2770 =
|
|
snd_soc_component_get_drvdata(component);
|
|
- u8 tdm_rx_start_slot = 0, asi_cfg_1 = 0;
|
|
+ u8 tdm_rx_start_slot = 0, invert_fpol = 0, fpol_preinv = 0, asi_cfg_1 = 0;
|
|
int ret;
|
|
|
|
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
|
|
@@ -349,9 +349,15 @@ static int tas2770_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
|
|
}
|
|
|
|
switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
|
|
+ case SND_SOC_DAIFMT_NB_IF:
|
|
+ invert_fpol = 1;
|
|
+ fallthrough;
|
|
case SND_SOC_DAIFMT_NB_NF:
|
|
asi_cfg_1 |= TAS2770_TDM_CFG_REG1_RX_RSING;
|
|
break;
|
|
+ case SND_SOC_DAIFMT_IB_IF:
|
|
+ invert_fpol = 1;
|
|
+ fallthrough;
|
|
case SND_SOC_DAIFMT_IB_NF:
|
|
asi_cfg_1 |= TAS2770_TDM_CFG_REG1_RX_FALING;
|
|
break;
|
|
@@ -369,15 +375,19 @@ static int tas2770_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
|
|
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
|
|
case SND_SOC_DAIFMT_I2S:
|
|
tdm_rx_start_slot = 1;
|
|
+ fpol_preinv = 0;
|
|
break;
|
|
case SND_SOC_DAIFMT_DSP_A:
|
|
tdm_rx_start_slot = 0;
|
|
+ fpol_preinv = 1;
|
|
break;
|
|
case SND_SOC_DAIFMT_DSP_B:
|
|
tdm_rx_start_slot = 1;
|
|
+ fpol_preinv = 1;
|
|
break;
|
|
case SND_SOC_DAIFMT_LEFT_J:
|
|
tdm_rx_start_slot = 0;
|
|
+ fpol_preinv = 1;
|
|
break;
|
|
default:
|
|
dev_err(tas2770->dev,
|
|
@@ -391,6 +401,15 @@ static int tas2770_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
+
|
|
+ ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG0,
|
|
+ TAS2770_TDM_CFG_REG0_FPOL_MASK,
|
|
+ (fpol_preinv ^ invert_fpol)
|
|
+ ? TAS2770_TDM_CFG_REG0_FPOL_RSING
|
|
+ : TAS2770_TDM_CFG_REG0_FPOL_FALING);
|
|
+ if (ret < 0)
|
|
+ return ret;
|
|
+
|
|
return 0;
|
|
}
|
|
|
|
diff --git a/sound/soc/codecs/tas2770.h b/sound/soc/codecs/tas2770.h
|
|
index d156666bcc55..42277fb6bc10 100644
|
|
--- a/sound/soc/codecs/tas2770.h
|
|
+++ b/sound/soc/codecs/tas2770.h
|
|
@@ -41,6 +41,9 @@
|
|
#define TAS2770_TDM_CFG_REG0_31_44_1_48KHZ 0x6
|
|
#define TAS2770_TDM_CFG_REG0_31_88_2_96KHZ 0x8
|
|
#define TAS2770_TDM_CFG_REG0_31_176_4_192KHZ 0xa
|
|
+#define TAS2770_TDM_CFG_REG0_FPOL_MASK BIT(0)
|
|
+#define TAS2770_TDM_CFG_REG0_FPOL_RSING 0
|
|
+#define TAS2770_TDM_CFG_REG0_FPOL_FALING 1
|
|
/* TDM Configuration Reg1 */
|
|
#define TAS2770_TDM_CFG_REG1 TAS2770_REG(0X0, 0x0B)
|
|
#define TAS2770_TDM_CFG_REG1_MASK GENMASK(5, 1)
|
|
--
|
|
2.34.1
|
|
|