From dda4d6bc3be22a7c83b4717593db29c99a76a750 Mon Sep 17 00:00:00 2001 From: Shengjiu Wang <shengjiu.wang@nxp.com> Date: Fri, 1 Apr 2022 09:15:45 +0800 Subject: [PATCH] LF-5909-1: ASoC: fsl_sai: Refine the slots number according to bclk_ratio The bclk_ratio is set by .set_bclk_ratio API. bclk_ratio = slots * slot_width So if slots is not set by .set_tdm_slot, then can be calculated by bclk_ratio. Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com> Reviewed-by: Chancel Liu <chancel.liu@nxp.com> --- sound/soc/fsl/fsl_sai.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index 956051268b516..5cf6711393246 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -547,8 +547,13 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream, int ret, i, trce_mask = 0, dl_cfg_cnt, dl_cfg_idx = 0; struct fsl_sai_dl_cfg *dl_cfg; + if (sai->slot_width) + slot_width = sai->slot_width; + if (sai->slots) slots = sai->slots; + else if (sai->bclk_ratio) + slots = sai->bclk_ratio / slot_width; pins = DIV_ROUND_UP(channels, slots); sai->is_dsd = fsl_is_dsd(params); @@ -574,9 +579,6 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - if (sai->slot_width) - slot_width = sai->slot_width; - bclk = rate*(sai->bclk_ratio ? sai->bclk_ratio : slots * slot_width); if (!IS_ERR_OR_NULL(sai->pinctrl)) { -- GitLab