Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: cs42xx8: add error checks for constraints in TDM mode

In the TDM format the ADC and DAC serial ports will only operate as a
slave, the sysclk should not be less than 256FS and Quad-Speed Mode (100
to 200 kHz sample rates) is not supported by ADC. So add error checks
for these constraints.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://patch.msgid.link/20260225100907.686470-1-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Shengjiu Wang and committed by
Mark Brown
da37bfe7 2974aa42

+22
+22
sound/soc/codecs/cs42xx8.c
··· 40 40 struct clk *clk; 41 41 42 42 bool slave_mode; 43 + bool is_tdm_mode; 43 44 unsigned long sysclk; 44 45 u32 tx_channels; 45 46 struct gpio_desc *gpiod_reset; ··· 215 214 struct cs42xx8_priv *cs42xx8 = snd_soc_component_get_drvdata(component); 216 215 u32 val; 217 216 217 + cs42xx8->is_tdm_mode = false; 218 + 218 219 /* Set DAI format */ 219 220 switch (format & SND_SOC_DAIFMT_FORMAT_MASK) { 220 221 case SND_SOC_DAIFMT_LEFT_J: ··· 230 227 break; 231 228 case SND_SOC_DAIFMT_DSP_A: 232 229 val = CS42XX8_INTF_DAC_DIF_TDM | CS42XX8_INTF_ADC_DIF_TDM; 230 + cs42xx8->is_tdm_mode = true; 233 231 break; 234 232 default: 235 233 dev_err(component->dev, "unsupported dai format\n"); ··· 251 247 break; 252 248 default: 253 249 dev_err(component->dev, "unsupported master/slave mode\n"); 250 + return -EINVAL; 251 + } 252 + 253 + if (cs42xx8->is_tdm_mode && !cs42xx8->slave_mode) { 254 + dev_err(component->dev, "TDM mode is supported only in slave mode\n"); 254 255 return -EINVAL; 255 256 } 256 257 ··· 340 331 } 341 332 342 333 cs42xx8->rate[tx] = params_rate(params); 334 + 335 + if (cs42xx8->is_tdm_mode) { 336 + if (cs42xx8->sysclk < 256 * cs42xx8->rate[tx]) { 337 + dev_err(component->dev, "Unsupported sysclk in TDM mode\n"); 338 + return -EINVAL; 339 + } 340 + 341 + if (!tx && cs42xx8->rate[tx] > 100000) { 342 + dev_err(component->dev, 343 + "ADC does not support Quad-Speed Mode in TDM mode\n"); 344 + return -EINVAL; 345 + } 346 + } 343 347 344 348 mask = CS42XX8_FUNCMOD_MFREQ_MASK; 345 349 val = cs42xx8_ratios[i].mfreq;