Commit c62bec0f authored by Paul Handrigan's avatar Paul Handrigan Committed by Mark Brown

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: 2884c291 ("ASoC: cs530x: Support for cs530x ADCs")
Signed-off-by: default avatarPaul Handrigan <paulha@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20240710160416.2617173-1-paulha@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent e021e0ee
...@@ -526,13 +526,15 @@ static int cs530x_hw_params(struct snd_pcm_substream *substream, ...@@ -526,13 +526,15 @@ static int cs530x_hw_params(struct snd_pcm_substream *substream,
regmap_update_bits(regmap, CS530X_CLK_CFG_1, regmap_update_bits(regmap, CS530X_CLK_CFG_1,
CS530X_SAMPLE_RATE_MASK, fs_val); 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", dev_dbg(component->dev, "Configuring for %d %d bit TDM slots\n",
cs530x->tdm_slots, cs530x->tdm_width); cs530x->tdm_slots, cs530x->tdm_width);
cs530x->bclk = snd_soc_calc_bclk(cs530x->fs, cs530x->bclk = snd_soc_tdm_params_to_bclk(params,
cs530x->tdm_width, cs530x->tdm_width,
params_channels(params), cs530x->tdm_slots,
cs530x->tdm_slots); 1);
} else { } else {
cs530x->bclk = snd_soc_params_to_bclk(params); 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, ...@@ -655,6 +657,9 @@ static int cs530x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
return -EINVAL; return -EINVAL;
} }
cs530x->tdm_width = slot_width;
cs530x->tdm_slots = slots;
return regmap_update_bits(regmap, CS530X_SIGNAL_PATH_CFG, return regmap_update_bits(regmap, CS530X_SIGNAL_PATH_CFG,
CS530X_ASP_TDM_SLOT_MASK, CS530X_ASP_TDM_SLOT_MASK,
val << CS530X_ASP_TDM_SLOT_SHIFT); val << CS530X_ASP_TDM_SLOT_SHIFT);
......
...@@ -96,6 +96,7 @@ ...@@ -96,6 +96,7 @@
#define CS530X_ASP_TDM_SLOT_MASK GENMASK(5, 3) #define CS530X_ASP_TDM_SLOT_MASK GENMASK(5, 3)
#define CS530X_ASP_TDM_SLOT_SHIFT 3 #define CS530X_ASP_TDM_SLOT_SHIFT 3
#define CS530X_ASP_CH_REVERSE BIT(9) #define CS530X_ASP_CH_REVERSE BIT(9)
#define CS530X_TDM_EN_MASK BIT(2)
#define CS530X_ASP_FMT_I2S 0 #define CS530X_ASP_FMT_I2S 0
#define CS530X_ASP_FMT_LJ 1 #define CS530X_ASP_FMT_LJ 1
#define CS530X_ASP_FMT_DSP_A 0x6 #define CS530X_ASP_FMT_DSP_A 0x6
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment