Skip to content

Commit c62bec0

Browse files
Paul Handriganbroonie
authored andcommitted
ASoC: cs530x: Calculate proper bclk rate using TDM
Calculate the proper bclk rate using the number of tdm slots and the width of the tdm data. Fixes: 2884c29 ("ASoC: cs530x: Support for cs530x ADCs") Signed-off-by: Paul Handrigan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent e021e0e commit c62bec0

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

sound/soc/codecs/cs530x.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -526,13 +526,15 @@ static int cs530x_hw_params(struct snd_pcm_substream *substream,
526526
regmap_update_bits(regmap, CS530X_CLK_CFG_1,
527527
CS530X_SAMPLE_RATE_MASK, fs_val);
528528

529-
if (cs530x->tdm_slots) {
529+
530+
if (regmap_test_bits(regmap, CS530X_SIGNAL_PATH_CFG,
531+
CS530X_TDM_EN_MASK)) {
530532
dev_dbg(component->dev, "Configuring for %d %d bit TDM slots\n",
531533
cs530x->tdm_slots, cs530x->tdm_width);
532-
cs530x->bclk = snd_soc_calc_bclk(cs530x->fs,
533-
cs530x->tdm_width,
534-
params_channels(params),
535-
cs530x->tdm_slots);
534+
cs530x->bclk = snd_soc_tdm_params_to_bclk(params,
535+
cs530x->tdm_width,
536+
cs530x->tdm_slots,
537+
1);
536538
} else {
537539
cs530x->bclk = snd_soc_params_to_bclk(params);
538540
}
@@ -655,6 +657,9 @@ static int cs530x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
655657
return -EINVAL;
656658
}
657659

660+
cs530x->tdm_width = slot_width;
661+
cs530x->tdm_slots = slots;
662+
658663
return regmap_update_bits(regmap, CS530X_SIGNAL_PATH_CFG,
659664
CS530X_ASP_TDM_SLOT_MASK,
660665
val << CS530X_ASP_TDM_SLOT_SHIFT);

sound/soc/codecs/cs530x.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
#define CS530X_ASP_TDM_SLOT_MASK GENMASK(5, 3)
9797
#define CS530X_ASP_TDM_SLOT_SHIFT 3
9898
#define CS530X_ASP_CH_REVERSE BIT(9)
99+
#define CS530X_TDM_EN_MASK BIT(2)
99100
#define CS530X_ASP_FMT_I2S 0
100101
#define CS530X_ASP_FMT_LJ 1
101102
#define CS530X_ASP_FMT_DSP_A 0x6

0 commit comments

Comments
 (0)