Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2133830ybt; Mon, 15 Jun 2020 20:07:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxXJg9XIjo7BKyU6Ozphk86ydH5nJgcolCjXwqz10lwj96VTkd7JPbNcGdnMerrEtElDR3 X-Received: by 2002:a17:906:39a:: with SMTP id b26mr841074eja.204.1592276827086; Mon, 15 Jun 2020 20:07:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592276827; cv=none; d=google.com; s=arc-20160816; b=0dcJ2Xfqq6Xu+iY/zTM1HilFJnPyomYyS6yoH6pVHzZzmWMBjQODaepqFbZiHnk3JY Lki6lY29seLMlslUJgy0vTAQ09bT0eJkjL9vu6ifxwCmmEtjGO7hlpLP7Ah4B2tiroqr qp6yhUvQrv4hwOfLDh/j/AFHTBJoxTl7sDi7y4L8FK7hkbC4FrzwJpixqkgvzg/9GBM6 +C+r6UHduv8lbURRceOEcwuqQqYVMqsyMq1c46LXyTli8ugjjSC6ymxANgk3I0Yq6/zS hHVf637IYGQoX0G0wsAy0wPCTwHUQC2d2pRtXXZ+/PXd4x38JxNBNZJOpUTkwfDSoeuX zRnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=nSJcW1jcXIUWwy2aEuz7GT0ocO83KzxSGCw3k4xCuO8=; b=eNiJD+vFW6kmzPtzmSLS9tlRIJc3wzGfwbiITZJ452YJevMgFOX4XvKB0pBAwVYyMl 22J+hIOxyQDvwjyHNB9z/EPStw7I/+hM7ICi7MtTiOxIj7yFwzecHvI6IgSF/eeSCIdS NlGXJMfSB6RU4/FFxyhjOJf+ZSzC8rfulyK6CkCZDzkotocn2VgHDbffifGAVvn5v18g uzX6PEIowLPkgTldIJGBZ32guuZul75JLAj7+WyFBcAkeyUi/+dkta5AnTNB8/k/nM6k ar3u0sFujGWWTvkZ72QjBWTQsez7fH2HdtnhgjvlJmIxfMivXvfRQTliMnrsbfra8D7l VRQg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y3si9995650edv.448.2020.06.15.20.06.43; Mon, 15 Jun 2020 20:07:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726261AbgFPDE4 (ORCPT + 99 others); Mon, 15 Jun 2020 23:04:56 -0400 Received: from inva020.nxp.com ([92.121.34.13]:35558 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725978AbgFPDE4 (ORCPT ); Mon, 15 Jun 2020 23:04:56 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id E0AF81A0547; Tue, 16 Jun 2020 05:04:53 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id B6E321A053B; Tue, 16 Jun 2020 05:04:49 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 4B8E8402D0; Tue, 16 Jun 2020 11:04:44 +0800 (SGT) From: Shengjiu Wang To: timur@kernel.org, nicoleotsuka@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH v3] ASoC: fsl_ssi: Fix bclk calculation for mono channel Date: Tue, 16 Jun 2020 10:53:48 +0800 Message-Id: <034eff1435ff6ce300b6c781130cefd9db22ab9a.1592276147.git.shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For mono channel, SSI will switch to Normal mode. In Normal mode and Network mode, the Word Length Control bits control the word length divider in clock generator, which is different with I2S Master mode (the word length is fixed to 32bit), it should be the value of params_width(hw_params). The condition "slots == 2" is not good for I2S Master mode, because for Network mode and Normal mode, the slots can also be 2. Then we need to use (ssi->i2s_net & SSI_SCR_I2S_MODE_MASK) to check if it is I2S Master mode. So we refine the formula for mono channel, otherwise there will be sound issue for S24_LE. Fixes: b0a7043d5c2c ("ASoC: fsl_ssi: Caculate bit clock rate using slot number and width") Signed-off-by: Shengjiu Wang --- changes in v3 - update according to Nicolin's comments changes in v2 - refine patch for Network mode and Normal mode. sound/soc/fsl/fsl_ssi.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index bad89b0d129e..1a2fa7f18142 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -678,8 +678,9 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream, struct regmap *regs = ssi->regs; u32 pm = 999, div2, psr, stccr, mask, afreq, factor, i; unsigned long clkrate, baudrate, tmprate; - unsigned int slots = params_channels(hw_params); - unsigned int slot_width = 32; + unsigned int channels = params_channels(hw_params); + unsigned int slot_width = params_width(hw_params); + unsigned int slots = 2; u64 sub, savesub = 100000; unsigned int freq; bool baudclk_is_used; @@ -688,10 +689,14 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream, /* Override slots and slot_width if being specifically set... */ if (ssi->slots) slots = ssi->slots; - /* ...but keep 32 bits if slots is 2 -- I2S Master mode */ - if (ssi->slot_width && slots != 2) + if (ssi->slot_width) slot_width = ssi->slot_width; + /* ...but force 32 bits for stereo audio using I2S Master Mode */ + if (channels == 2 && + (ssi->i2s_net & SSI_SCR_I2S_MODE_MASK) == SSI_SCR_I2S_MODE_MASTER) + slot_width = 32; + /* Generate bit clock based on the slot number and slot width */ freq = slots * slot_width * params_rate(hw_params); -- 2.21.0