Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1428567ybt; Sun, 14 Jun 2020 23:09:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgjxBWVxpPHc3sIvjNuea9yPQ2EQPoZK3EClY7ZMLXu88hrqprknAk0mtWRr46E4EgQ9Ei X-Received: by 2002:a17:907:369:: with SMTP id rs9mr23593433ejb.187.1592201395690; Sun, 14 Jun 2020 23:09:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592201395; cv=none; d=google.com; s=arc-20160816; b=g0WLfd2UrHT2Mexc8t/A2FjfKyzfj6hyTvk62Pvgh9ZBJEtrXT/ldyWLEHHwpu1vjN NkgDZR9hR9bwiJIafLJdpf0URxX8n09+FIWtEFwzR7MG1sqLIbxJ+DriBm99HupNjrOB LfyXn7pObs3f5y9X9J5Cfe11lnWAPfvM9jguQgDA02UMO/qgbnbm3u4I1E12cyOHs8O9 DHqUHj4oXtsYgPcLBBPhBUL5o+9G9WoTYwvUSzqAaztCD6EFO0SmEy0SzMnhFOfizmPY UQVN2a/rZ+hbUg16JFM6q97aROPr4wD8q0Mb7KbIaXXvp5p+VKu1mVmf96lRvhN/N438 TN4w== 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=ZEk1A8WdQOxksEqzMxoSz4g6T+fvRzewCMjQD6xkeZE=; b=qC/TiXT1WR0e8AQFS+6z8ZSHDcUEZOQ/re+my639ct5HddgQHLvuCSmsCxSOfJ3lpy wOIH/9eWzYIS203o/iHCs5y6gRbRhSdjc33QhVCh9RKLFrYMOTQKdwXe/abiQXZdu78k kgGoSbA2F2KZIzNClvX6/o5xWLa/BznIGTSru89seZKSv/G/wHaj11RUz0OAgadsPqMg Np8wF794epgQWZsxhJ4jm9sJfYtAfWqWt3QZ6XorY3BUQMGJuKQioUeXIJ7G8B4CXvTy 4hDyT8mIPagT7mr54XSYnzjP1AguZPQnA8nm6LJ2FhcTYipyPvIl27sELm+lZ0QswZXk wyQA== 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 r25si7651234edi.172.2020.06.14.23.09.33; Sun, 14 Jun 2020 23:09:55 -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 S1728311AbgFOGHX (ORCPT + 99 others); Mon, 15 Jun 2020 02:07:23 -0400 Received: from inva021.nxp.com ([92.121.34.21]:56700 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728304AbgFOGHX (ORCPT ); Mon, 15 Jun 2020 02:07:23 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id E10F520133E; Mon, 15 Jun 2020 08:07:20 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id B8DBA201343; Mon, 15 Jun 2020 08:07:16 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 370E64030D; Mon, 15 Jun 2020 14:07:11 +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 v2] ASoC: fsl_ssi: Fix bclk calculation for mono channel Date: Mon, 15 Jun 2020 13:56:18 +0800 Message-Id: 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 famula 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 v2 - refine patch for Network mode and Normal mode. sound/soc/fsl/fsl_ssi.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index bad89b0d129e..cbf67d132fda 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -678,7 +678,8 @@ 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 channels = params_channels(hw_params); + unsigned int slots; unsigned int slot_width = 32; u64 sub, savesub = 100000; unsigned int freq; @@ -688,9 +689,15 @@ 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) - slot_width = ssi->slot_width; + else + /* Apply two slots for mono channel, because DC = 2 */ + slots = (channels == 1) ? 2 : channels; + + /* ...but keep 32 bits if I2S Master mode */ + if ((ssi->i2s_net & SSI_SCR_I2S_MODE_MASK) != SSI_SCR_I2S_MODE_MASTER || + channels == 1) + slot_width = ssi->slot_width ? ssi->slot_width : + params_width(hw_params); /* Generate bit clock based on the slot number and slot width */ freq = slots * slot_width * params_rate(hw_params); -- 2.21.0