Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3088977ybt; Mon, 29 Jun 2020 15:04:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsb2WU5TY696yWbdSVARpfF1n/81i2mDFMhIA7GS1Gt7upOt1nioOx4EJYAgpHCO/BGgSO X-Received: by 2002:aa7:d8cf:: with SMTP id k15mr19300991eds.250.1593468268133; Mon, 29 Jun 2020 15:04:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593468268; cv=none; d=google.com; s=arc-20160816; b=PR3r06OdxvLTY5Vk0Qnvypq3NWmif8BDGUZT/9CgHy0vVmuXrrEMx5yg59CRnPeSfO zJJOdisDq986UJeMSMWVLSO/RagrC2ni4BFemu69SowytbUSs53xjcqSpka9QldM5r2D jZjpNvLUD30khi8tEHObZsyX5sfFCi8fnLbcRhLZ+5oFUQ+tq0MnkC7Rh6nz5rsi7fT+ R05CdMJWz7etwOq1953SL8aw27i4JxPxUmJeEoFBho7XM1Tzgh3yhJ6sa4sNpBSYl7Qq W6Lndib4lYZboC0npo61ywokIFsu+12Tzgm55QSrtY31t3EslijHqRCvalRBN52sCEE+ vHqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NWXSmPjG1DPtGBgnsKU5N2RD1pPmyMiwz5ke7KwZ+K0=; b=MEbjg6nGiwLwaUCwleU0gasbEJFZ4c9Jj6Oj+6SVWUx5A26sW43Xzuf5FgVVz4sT4W jsIHPKrcTKEL/+6GaIh+zs5U/iqBnovaNDQNRraaQkz0WK7Ez7Qi89s+LOURswHtLrc9 N8ZvHjIsHCZdv/RsXGfvRPUt+z5XD+7LetEhkgY/ASzH9MiWCXX4c7Qi+vrJqNuWG226 MyoPeI5lfWSo5x48Na7geeL8dPMngE9mX61+alX58TgDkqmSuUXaVUavxH6dJghH5jlY wWwwSJDpe3rDK+4K6BNFJxvcCp0aggGoOk2eFSmCD+s2/lSHakhi6vVcT6jgfxCx4Hc9 DySw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=V7SGgFss; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p3si497404edr.104.2020.06.29.15.04.04; Mon, 29 Jun 2020 15:04:28 -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; dkim=pass header.i=@kernel.org header.s=default header.b=V7SGgFss; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390453AbgF2WDC (ORCPT + 99 others); Mon, 29 Jun 2020 18:03:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:56886 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726226AbgF2SfX (ORCPT ); Mon, 29 Jun 2020 14:35:23 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C6FCC246AE; Mon, 29 Jun 2020 15:20:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593444011; bh=j2PgZ/whi0LQa51s89tNZ3et6wNy7JuSHDp1a9QO73A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V7SGgFssjOgpxsr375i0F/0Me5PwsAYUE6AO+NszV2MNtNa7aaG/X4B4bW58uDa0G WPA9045TDOmYTSRe0ihmmq89oqzJJcXsJAIvxKzbX0QZq6NrWM3ZdLmwbOT3XGfmgC MPna5n6BxNHIcDTpZH/gipwj4zBBd7Tec86iasmE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Shengjiu Wang , Nicolin Chen , Mark Brown , Sasha Levin Subject: [PATCH 5.7 117/265] ASoC: fsl_ssi: Fix bclk calculation for mono channel Date: Mon, 29 Jun 2020 11:15:50 -0400 Message-Id: <20200629151818.2493727-118-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200629151818.2493727-1-sashal@kernel.org> References: <20200629151818.2493727-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.7.7-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.7.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.7.7-rc1 X-KernelTest-Deadline: 2020-07-01T15:14+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Shengjiu Wang [ Upstream commit ed1220df6e666500ebf58c4f2fccc681941646fb ] 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 Reviewed-by: Nicolin Chen Link: https://lore.kernel.org/r/034eff1435ff6ce300b6c781130cefd9db22ab9a.1592276147.git.shengjiu.wang@nxp.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- 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 bad89b0d129e7..1a2fa7f181423 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.25.1