diff mbox series

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

Message ID 20240710160416.2617173-1-paulha@opensource.cirrus.com (mailing list archive)
State Accepted
Commit c62bec0fe36873ab6c87c9ae84a6b661d09244c4
Headers show
Series [1/2] ASoC: cs530x: Calculate proper bclk rate using TDM | expand

Commit Message

Paul Handrigan July 10, 2024, 4:04 p.m. UTC
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@opensource.cirrus.com>
---
 sound/soc/codecs/cs530x.c | 15 ++++++++++-----
 sound/soc/codecs/cs530x.h |  1 +
 2 files changed, 11 insertions(+), 5 deletions(-)

Comments

Mark Brown July 10, 2024, 11:26 p.m. UTC | #1
On Wed, 10 Jul 2024 11:04:15 -0500, Paul Handrigan wrote:
> Calculate the proper bclk rate using the number of tdm slots
> and the width of the tdm data.
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/2] ASoC: cs530x: Calculate proper bclk rate using TDM
      commit: c62bec0fe36873ab6c87c9ae84a6b661d09244c4
[2/2] ASoC: cs530x: Remove bclk from private structure
      commit: 0d1ebba74fad7b6b3eb0e2bc08d649d20c7aa7c9

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
diff mbox series

Patch

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