diff options
author | Paul Handrigan <paulha@opensource.cirrus.com> | 2024-07-10 19:04:15 +0300 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2024-07-10 20:45:24 +0300 |
commit | c62bec0fe36873ab6c87c9ae84a6b661d09244c4 (patch) | |
tree | 40fd3550ab768ad1acc98512e46bbb1a96f9cb94 /sound/soc | |
parent | e021e0eecba99d7ec68f6e7972a72175f54ff6e3 (diff) | |
download | linux-c62bec0fe36873ab6c87c9ae84a6b661d09244c4.tar.xz |
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: 2884c29152c0 ("ASoC: cs530x: Support for cs530x ADCs")
Signed-off-by: Paul Handrigan <paulha@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20240710160416.2617173-1-paulha@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc')
-rw-r--r-- | sound/soc/codecs/cs530x.c | 15 | ||||
-rw-r--r-- | 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 |