[PATCH 1/2] ASoC: cs530x: Calculate proper bclk rate using TDM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Calculate the proper bclk rate using the number of tdm slots
and the width of the tdm data.

Fixes: 2884c29152c0 ("ASoC: cs530x: Support for cs530x ADCs")
Signed-off-by: Paul Handrigan <paulha@xxxxxxxxxxxxxxxxxxxxx>
---
 sound/soc/codecs/cs530x.c | 15 ++++++++++-----
 sound/soc/codecs/cs530x.h |  1 +
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/sound/soc/codecs/cs530x.c b/sound/soc/codecs/cs530x.c
index 036d0f45e3ba..195739657f4e 100644
--- a/sound/soc/codecs/cs530x.c
+++ b/sound/soc/codecs/cs530x.c
@@ -526,13 +526,15 @@ static int cs530x_hw_params(struct snd_pcm_substream *substream,
 	regmap_update_bits(regmap, CS530X_CLK_CFG_1,
 			   CS530X_SAMPLE_RATE_MASK, fs_val);
 
-	if (cs530x->tdm_slots) {
+
+	if (regmap_test_bits(regmap, CS530X_SIGNAL_PATH_CFG,
+			     CS530X_TDM_EN_MASK)) {
 		dev_dbg(component->dev, "Configuring for %d %d bit TDM slots\n",
 			cs530x->tdm_slots, cs530x->tdm_width);
-		cs530x->bclk = snd_soc_calc_bclk(cs530x->fs,
-						 cs530x->tdm_width,
-						 params_channels(params),
-						 cs530x->tdm_slots);
+		cs530x->bclk = snd_soc_tdm_params_to_bclk(params,
+							  cs530x->tdm_width,
+							  cs530x->tdm_slots,
+							  1);
 	} else {
 		cs530x->bclk = snd_soc_params_to_bclk(params);
 	}
@@ -655,6 +657,9 @@ static int cs530x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
 		return -EINVAL;
 	}
 
+	cs530x->tdm_width = slot_width;
+	cs530x->tdm_slots = slots;
+
 	return regmap_update_bits(regmap, CS530X_SIGNAL_PATH_CFG,
 				  CS530X_ASP_TDM_SLOT_MASK,
 				  val << CS530X_ASP_TDM_SLOT_SHIFT);
diff --git a/sound/soc/codecs/cs530x.h b/sound/soc/codecs/cs530x.h
index 1c85310a5d03..1915a0efe829 100644
--- a/sound/soc/codecs/cs530x.h
+++ b/sound/soc/codecs/cs530x.h
@@ -96,6 +96,7 @@
 #define CS530X_ASP_TDM_SLOT_MASK	GENMASK(5, 3)
 #define CS530X_ASP_TDM_SLOT_SHIFT	3
 #define CS530X_ASP_CH_REVERSE		BIT(9)
+#define CS530X_TDM_EN_MASK		BIT(2)
 #define CS530X_ASP_FMT_I2S		0
 #define CS530X_ASP_FMT_LJ		1
 #define CS530X_ASP_FMT_DSP_A		0x6
-- 
2.34.1





[Index of Archives]     [Pulseaudio]     [Linux Audio Users]     [ALSA Devel]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux