Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3026037ybt; Mon, 29 Jun 2020 13:14:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygIBhb6d9yQEC3yh99PwXf5lINrq8If53q9i6DakUCgrSQm6eSOU/R64etUhVOlZ2+a6bR X-Received: by 2002:a17:906:7247:: with SMTP id n7mr15523691ejk.105.1593461684575; Mon, 29 Jun 2020 13:14:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593461684; cv=none; d=google.com; s=arc-20160816; b=jU2mBGfHDRwl3P9HAOvqGvazAeOiuysx1Ot1hdcVJ2Mq8EgE3kUPmE2wJw0m4g1WNO d7sdl5gMc2m7YQJ7aouwjd4TMktj33Q75abCnxT+eYMfewtQvL8bXMrx62i0J45PEiZs EJXz37+kdHj5PPzFtMDMwz5feMSAGZWFPK2D8cvD/YeoV2gngAR8TOfpdJii6GhTSHr2 IXXB9IzaVR9t683OXFCl9LajczuOXewcZ2zTfg+VCjWapzihwps3U/eacFwNSe5OWEKd hdQda3/4KdRvWpuBNtDs0ZnueQomqMQB+ROtI1kQmw3wYTKHwhLbj+KKhJc+TJaFfb5K 2hpA== 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=0AQ6k3/Wz/W1Tpp3Mh9nzYUpziCPVRWm4D+sxn688zE=; b=jhYYEDIm+vZinsXwB34Q3HQbI/hRYugFd7OW5HdBNnVD62gkMojA9fl7hSLZmtG1tr oyw4TfnQpQgHEdoafex1k0rDdhzfUunl+srBfEaGwLST9qwcVa91P8NF901JT+1g2LUt d2a+ET367Xl1eNNyTC6yTBUpb8HyezZT6we65/DpSOmI9BqcFOE3fiCr1U5l4R2mkpaw esVUmCOHys6/BBdYm7YIWW9Ri9SVT3N72SZzgO3a/LudNQJx6WxATbeKSwA0D3wmSH9D ikVniQrrvj3MCRezQ7OMKHfIufL9uwQPDYrLWF+Rv5FA/P5NL7wqan5VeLHygi/Qb6ZZ Q00Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aNd01lr8; 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 e7si360034ejm.25.2020.06.29.13.14.21; Mon, 29 Jun 2020 13:14:44 -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=aNd01lr8; 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 S1728062AbgF2UM6 (ORCPT + 99 others); Mon, 29 Jun 2020 16:12:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:40608 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732869AbgF2TaU (ORCPT ); Mon, 29 Jun 2020 15:30:20 -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 2D93B25254; Mon, 29 Jun 2020 15:36:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593444966; bh=Prp7NLKLWcgBgbbd5HUw0mfypWzzrlEeyiwEN/3vqJY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aNd01lr8hdRRkSp3mYoEXcqcmWDNCcyX9WAGu422voFyHw1JqjwcNc06vGCTP3FX/ CbGH7fzZ2OK3KAnXhoOAzDr3O1yPgGxeBydM/55hZpgpMEavGzf03tVYtHxqX2v92q +XG3vaE37MMB2+oCraOeAPc8nNd1VnhbaQ2yy6gM= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Shengjiu Wang , Nicolin Chen , Mark Brown , Sasha Levin Subject: [PATCH 4.19 065/131] ASoC: fsl_ssi: Fix bclk calculation for mono channel Date: Mon, 29 Jun 2020 11:33:56 -0400 Message-Id: <20200629153502.2494656-66-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200629153502.2494656-1-sashal@kernel.org> References: <20200629153502.2494656-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.131-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.19.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.19.131-rc1 X-KernelTest-Deadline: 2020-07-01T15:34+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 d83be26d64467..0e2bdad373d66 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