From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DFD6C3A589 for ; Tue, 20 Aug 2019 17:41:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 644C122DD6 for ; Tue, 20 Aug 2019 17:41:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566322878; bh=FYVfMHt40niVuahDgCxsBhpOHaXwGDVn93lPCWEk/yI=; h=From:To:Cc:Subject:In-Reply-To:Date:List-ID:From; b=luBUkK4Fiu0uHzzXK0j91YX8cSxrEaSaxKkju75hSMdq/+J/4vZalvhw4G9XUn2b0 28nOsmi+LLjuPsXbMlfXKtvjSGV8Y9nq7sD4LK8bkvRZx7vzQTpCzKd+f+q8lcbmue K9dFMKG4a7IPMhsE/g5z+MbUIuV6T0MC0fI9KPtw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730673AbfHTRlR (ORCPT ); Tue, 20 Aug 2019 13:41:17 -0400 Received: from mail-wr1-f99.google.com ([209.85.221.99]:38697 "EHLO mail-wr1-f99.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730615AbfHTRlK (ORCPT ); Tue, 20 Aug 2019 13:41:10 -0400 Received: by mail-wr1-f99.google.com with SMTP id g17so13295200wrr.5 for ; Tue, 20 Aug 2019 10:41:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:message-id:date; bh=yCDyVLCiFyaHGZVMltg2SfBdT7xmop4SmEPuiPFwdPM=; b=NSRU/5RRDfG21PgNwEoB6jIUA+kRW6RxJCPyOyeXq5xHvwm75mWu9HmxCTRInTG6u7 t0RUUdauMBBRtd7jDRuWtB0hqkxIWTrIX2FCsGU7ZZE2IA+RgizDY9uCq32503Y4PXxI Z5qYOyhs2ARS9OWMigfLkQ7RWzo5+O4WFc4ZNA57BS6aoUdXSNV/gnxPdB62zwuwK0DL IIZwin+H9UKgvQS4mtoMv0uJN380kvOAWNvLqu42mrJInEESwr5Qd3xUZ4ySH4eG1rM3 P//iIkN2rYlViO8OLTJ+FeJY8VrtRQHExTi3CBeZomazc9HpHA2XKLhKlUpz8V3lw23T 2QtA== X-Gm-Message-State: APjAAAWZU3/hzzgnTLVjuHk6jarBVLcU/d/zjMdeqpBMjJjP1RB/faxu cra9HtEzXV10Mp4oFL2QHRAF7ua6nKLO7ES4aIKXvvF4IuJneRo6kPmMh5g6VIoZtQ== X-Google-Smtp-Source: APXvYqz5YHpKm90mjMqOxMGkNMOoE2BSG7fts0HS8pd2YGeQKJqMEr3P96B8XrAPliZ9bt9z/gCCJ/bhsYWk X-Received: by 2002:adf:e710:: with SMTP id c16mr36940977wrm.292.1566322868040; Tue, 20 Aug 2019 10:41:08 -0700 (PDT) Received: from heliosphere.sirena.org.uk (heliosphere.sirena.org.uk. [2a01:7e01::f03c:91ff:fed4:a3b6]) by smtp-relay.gmail.com with ESMTPS id y18sm299785wrn.82.2019.08.20.10.41.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 10:41:08 -0700 (PDT) X-Relaying-Domain: sirena.org.uk Received: from ypsilon.sirena.org.uk ([2001:470:1f1d:6b5::7]) by heliosphere.sirena.org.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1i0883-00033J-LP; Tue, 20 Aug 2019 17:41:07 +0000 Received: by ypsilon.sirena.org.uk (Postfix, from userid 1000) id 0F796274314E; Tue, 20 Aug 2019 18:41:07 +0100 (BST) From: Mark Brown To: Maxime Ripard Cc: alsa-devel@alsa-project.org, broonie@kernel.org, Chen-Yu Tsai , codekipper@gmail.com, lgirdwood@gmail.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mark Brown , Maxime Ripard Subject: Applied "ASoC: sun4i-i2s: Don't use the oversample to calculate BCLK" to the asoc tree In-Reply-To: X-Patchwork-Hint: ignore Message-Id: <20190820174107.0F796274314E@ypsilon.sirena.org.uk> Date: Tue, 20 Aug 2019 18:41:07 +0100 (BST) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The patch ASoC: sun4i-i2s: Don't use the oversample to calculate BCLK has been applied to the asoc tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.4 All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >From 7df8f9a20196072162d9dc8fe99943f2d35f23d5 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Mon, 19 Aug 2019 21:25:14 +0200 Subject: [PATCH] ASoC: sun4i-i2s: Don't use the oversample to calculate BCLK The BCLK divider should be calculated using the parameters that actually make the BCLK rate: the number of channels, the sampling rate and the sample width. We've been using the oversample_rate previously because in the former SoCs, the BCLK's parent is MCLK, which in turn is being used to generate the oversample rate, so we end up with something like this: oversample = mclk_rate / sampling_rate bclk_div = oversample / word_size / channels So, bclk_div = mclk_rate / sampling_rate / word_size / channels. And this is actually better, since the oversampling ratio only plays a role because the MCLK is its parent, not because of what BCLK is supposed to be. Furthermore, that assumption of MCLK being the parent has been broken on newer SoCs, so let's use the proper formula, and have the parent rate as an argument. Fixes: 7d2993811a1e ("ASoC: sun4i-i2s: Add support for H3") Fixes: 21faaea1343f ("ASoC: sun4i-i2s: Add support for A83T") Fixes: 66ecce332538 ("ASoC: sun4i-i2s: Add compatibility with A64 codec I2S") Signed-off-by: Maxime Ripard Link: https://lore.kernel.org/r/c3595e3a9788c2ef2dcc30aa3c8c4953bb5cc249.1566242458.git-series.maxime.ripard@bootlin.com Signed-off-by: Mark Brown --- sound/soc/sunxi/sun4i-i2s.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index 70608fa30bf2..d879db581073 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -222,10 +222,11 @@ static const struct sun4i_i2s_clk_div sun4i_i2s_mclk_div[] = { }; static int sun4i_i2s_get_bclk_div(struct sun4i_i2s *i2s, - unsigned int oversample_rate, + unsigned long parent_rate, + unsigned int sampling_rate, unsigned int word_size) { - int div = oversample_rate / word_size / 2; + int div = parent_rate / sampling_rate / word_size / 2; int i; for (i = 0; i < ARRAY_SIZE(sun4i_i2s_bclk_div); i++) { @@ -315,8 +316,8 @@ static int sun4i_i2s_set_clk_rate(struct snd_soc_dai *dai, return -EINVAL; } - bclk_div = sun4i_i2s_get_bclk_div(i2s, oversample_rate, - word_size); + bclk_div = sun4i_i2s_get_bclk_div(i2s, i2s->mclk_freq, + rate, word_size); if (bclk_div < 0) { dev_err(dai->dev, "Unsupported BCLK divider: %d\n", bclk_div); return -EINVAL; -- 2.20.1 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark Brown Subject: Applied "ASoC: sun4i-i2s: Don't use the oversample to calculate BCLK" to the asoc tree Date: Tue, 20 Aug 2019 18:41:07 +0100 (BST) Message-ID: <20190820174107.0F796274314E@ypsilon.sirena.org.uk> References: Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Maxime Ripard Cc: alsa-devel@alsa-project.org, broonie@kernel.org, Chen-Yu Tsai , codekipper@gmail.com, lgirdwood@gmail.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.orgMark Brown , Maxime Ripard List-Id: alsa-devel@alsa-project.org The patch ASoC: sun4i-i2s: Don't use the oversample to calculate BCLK has been applied to the asoc tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.4 All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >>From 7df8f9a20196072162d9dc8fe99943f2d35f23d5 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Mon, 19 Aug 2019 21:25:14 +0200 Subject: [PATCH] ASoC: sun4i-i2s: Don't use the oversample to calculate BCLK The BCLK divider should be calculated using the parameters that actually make the BCLK rate: the number of channels, the sampling rate and the sample width. We've been using the oversample_rate previously because in the former SoCs, the BCLK's parent is MCLK, which in turn is being used to generate the oversample rate, so we end up with something like this: oversample = mclk_rate / sampling_rate bclk_div = oversample / word_size / channels So, bclk_div = mclk_rate / sampling_rate / word_size / channels. And this is actually better, since the oversampling ratio only plays a role because the MCLK is its parent, not because of what BCLK is supposed to be. Furthermore, that assumption of MCLK being the parent has been broken on newer SoCs, so let's use the proper formula, and have the parent rate as an argument. Fixes: 7d2993811a1e ("ASoC: sun4i-i2s: Add support for H3") Fixes: 21faaea1343f ("ASoC: sun4i-i2s: Add support for A83T") Fixes: 66ecce332538 ("ASoC: sun4i-i2s: Add compatibility with A64 codec I2S") Signed-off-by: Maxime Ripard Link: https://lore.kernel.org/r/c3595e3a9788c2ef2dcc30aa3c8c4953bb5cc249.1566242458.git-series.maxime.ripard@bootlin.com Signed-off-by: Mark Brown --- sound/soc/sunxi/sun4i-i2s.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index 70608fa30bf2..d879db581073 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -222,10 +222,11 @@ static const struct sun4i_i2s_clk_div sun4i_i2s_mclk_div[] = { }; static int sun4i_i2s_get_bclk_div(struct sun4i_i2s *i2s, - unsigned int oversample_rate, + unsigned long parent_rate, + unsigned int sampling_rate, unsigned int word_size) { - int div = oversample_rate / word_size / 2; + int div = parent_rate / sampling_rate / word_size / 2; int i; for (i = 0; i < ARRAY_SIZE(sun4i_i2s_bclk_div); i++) { @@ -315,8 +316,8 @@ static int sun4i_i2s_set_clk_rate(struct snd_soc_dai *dai, return -EINVAL; } - bclk_div = sun4i_i2s_get_bclk_div(i2s, oversample_rate, - word_size); + bclk_div = sun4i_i2s_get_bclk_div(i2s, i2s->mclk_freq, + rate, word_size); if (bclk_div < 0) { dev_err(dai->dev, "Unsupported BCLK divider: %d\n", bclk_div); return -EINVAL; -- 2.20.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E736C3A59D for ; Tue, 20 Aug 2019 17:45:31 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1233822DA7 for ; Tue, 20 Aug 2019 17:45:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="cthL8u4v"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="NeKUmqUK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1233822DA7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id: In-Reply-To:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: References:List-Owner; bh=Ao0NUAOq+7oT+m3/wszavBdjtru+VEqlz5SSUwdNgvE=; b=cth L8u4vEHE9PLvSYwH0BwYkEVTPLzXVoZMLd009RJjZlcSSyooFWrMlCee5N2zk+ROSDa2QmfK7HvAl ccn40hXU3MrdfAUZOtsJeJbH/AdDAuHtcT9fGwLgvQv7rAONz4VmmoseegVunX3uwT/4zoulenM8p dwQ19X1JqA2Sw2Mxe720mD9AYuxIZ44h5ShIKq/dpbCAaNPFrI6Ftm/qxRgoPqQw3RMvyj7w9VR7p KQgenIyGiRcPc+fX59n5Kvb/vS/Q8tYEmqQF9E3CGQDncjFRmbN19EWwordDhtUH6UBacz5bKppsm BvAVSTQgHJEsaD1zPK3uzUHJyDVdWqg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i08CC-0007wZ-Tw; Tue, 20 Aug 2019 17:45:24 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i088D-00026l-GJ for linux-arm-kernel@bombadil.infradead.org; Tue, 20 Aug 2019 17:41:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Date:Message-Id:In-Reply-To:Subject:Cc: To:From:Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:References:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=yCDyVLCiFyaHGZVMltg2SfBdT7xmop4SmEPuiPFwdPM=; b=NeKUmqUKzVYTJgV0hz9JErKcfs dqazP5hgmUwRQ3FF2s0FJFlf37UgA9B1Npwr/0lUfxvgmcd/HVGntXd9cHIHKvDNY+zLLnDy2taOV ps804UD7lICdbC7pgbXQdy78HQeo0izlz1MRCvJxe4n9Edqoq0/v7VmRYLGv9LA9QsTEvW09yVIiE 6bh4d6DDX7+c/C0yTYmhaMT3hJdohix/nzL4zyHElghxaSQXTyg65J3WsFFL2ASUJLG2Yvy9qR0TX ssvLLS3xcXXto455zG+vbDKI6eErog+F5wOS2ArK+8iz+Xcqg16qKh2/uL6yJXe50xgqaciTLQOxe gWD5785Q==; Received: from mail-wr1-f100.google.com ([209.85.221.100]) by merlin.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i088A-0002z2-JR for linux-arm-kernel@lists.infradead.org; Tue, 20 Aug 2019 17:41:15 +0000 Received: by mail-wr1-f100.google.com with SMTP id r3so13285387wrt.3 for ; Tue, 20 Aug 2019 10:41:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:message-id:date; bh=yCDyVLCiFyaHGZVMltg2SfBdT7xmop4SmEPuiPFwdPM=; b=p3mRxZcuF8L/7CGlc9f6IA4jxgKE4qCfV7MUcTnVCbX3LqyeBNDNzKgPN4PYG8hYYJ Q+bfOBbrpzmel5jpu4lqXdVuJR2YiGddJKNTISNTdzkfHIIXpqB3+G2upKzr9gIcKWrf 9O2+m6S6KswWcY3FqAGZbfpbZye0B+/+Va41El8rgt003wQ+sYFqMN90nFtkxfrSK5/P nXN968pz+yC49f9yRweuGjLUpjKlh8cipZoBe2UB9N5MIClbroerX4R7biUgwfoMUTqO IzEgF6mxS1qjVHISMciYSNLTVl3b42XOd2q0IXD+quI8OaiZLYvV3jQmEFmskeXQ7gPm BjTQ== X-Gm-Message-State: APjAAAV17Z4RolM14mR19gQq1oUrGGubdb1+1ytK96WpPpmCoo2IFAd6 3dLChKQSnq2kUvwfO0f59FBynVXDkqLp+atpns6Z3mdXRTXnZhVD/7yScXD8nwJMtw== X-Google-Smtp-Source: APXvYqz5YHpKm90mjMqOxMGkNMOoE2BSG7fts0HS8pd2YGeQKJqMEr3P96B8XrAPliZ9bt9z/gCCJ/bhsYWk X-Received: by 2002:adf:e710:: with SMTP id c16mr36940977wrm.292.1566322868040; Tue, 20 Aug 2019 10:41:08 -0700 (PDT) Received: from heliosphere.sirena.org.uk (heliosphere.sirena.org.uk. [2a01:7e01::f03c:91ff:fed4:a3b6]) by smtp-relay.gmail.com with ESMTPS id y18sm299785wrn.82.2019.08.20.10.41.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 10:41:08 -0700 (PDT) X-Relaying-Domain: sirena.org.uk Received: from ypsilon.sirena.org.uk ([2001:470:1f1d:6b5::7]) by heliosphere.sirena.org.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1i0883-00033J-LP; Tue, 20 Aug 2019 17:41:07 +0000 Received: by ypsilon.sirena.org.uk (Postfix, from userid 1000) id 0F796274314E; Tue, 20 Aug 2019 18:41:07 +0100 (BST) From: Mark Brown To: Maxime Ripard Subject: Applied "ASoC: sun4i-i2s: Don't use the oversample to calculate BCLK" to the asoc tree In-Reply-To: X-Patchwork-Hint: ignore Message-Id: <20190820174107.0F796274314E@ypsilon.sirena.org.uk> Date: Tue, 20 Aug 2019 18:41:07 +0100 (BST) X-Bad-Reply: In-Reply-To but no 'Re:' in Subject. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, Maxime Ripard , linux-kernel@vger.kernel.org, codekipper@gmail.com, Chen-Yu Tsai , Mark Brown , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org The patch ASoC: sun4i-i2s: Don't use the oversample to calculate BCLK has been applied to the asoc tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.4 All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >From 7df8f9a20196072162d9dc8fe99943f2d35f23d5 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Mon, 19 Aug 2019 21:25:14 +0200 Subject: [PATCH] ASoC: sun4i-i2s: Don't use the oversample to calculate BCLK The BCLK divider should be calculated using the parameters that actually make the BCLK rate: the number of channels, the sampling rate and the sample width. We've been using the oversample_rate previously because in the former SoCs, the BCLK's parent is MCLK, which in turn is being used to generate the oversample rate, so we end up with something like this: oversample = mclk_rate / sampling_rate bclk_div = oversample / word_size / channels So, bclk_div = mclk_rate / sampling_rate / word_size / channels. And this is actually better, since the oversampling ratio only plays a role because the MCLK is its parent, not because of what BCLK is supposed to be. Furthermore, that assumption of MCLK being the parent has been broken on newer SoCs, so let's use the proper formula, and have the parent rate as an argument. Fixes: 7d2993811a1e ("ASoC: sun4i-i2s: Add support for H3") Fixes: 21faaea1343f ("ASoC: sun4i-i2s: Add support for A83T") Fixes: 66ecce332538 ("ASoC: sun4i-i2s: Add compatibility with A64 codec I2S") Signed-off-by: Maxime Ripard Link: https://lore.kernel.org/r/c3595e3a9788c2ef2dcc30aa3c8c4953bb5cc249.1566242458.git-series.maxime.ripard@bootlin.com Signed-off-by: Mark Brown --- sound/soc/sunxi/sun4i-i2s.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index 70608fa30bf2..d879db581073 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -222,10 +222,11 @@ static const struct sun4i_i2s_clk_div sun4i_i2s_mclk_div[] = { }; static int sun4i_i2s_get_bclk_div(struct sun4i_i2s *i2s, - unsigned int oversample_rate, + unsigned long parent_rate, + unsigned int sampling_rate, unsigned int word_size) { - int div = oversample_rate / word_size / 2; + int div = parent_rate / sampling_rate / word_size / 2; int i; for (i = 0; i < ARRAY_SIZE(sun4i_i2s_bclk_div); i++) { @@ -315,8 +316,8 @@ static int sun4i_i2s_set_clk_rate(struct snd_soc_dai *dai, return -EINVAL; } - bclk_div = sun4i_i2s_get_bclk_div(i2s, oversample_rate, - word_size); + bclk_div = sun4i_i2s_get_bclk_div(i2s, i2s->mclk_freq, + rate, word_size); if (bclk_div < 0) { dev_err(dai->dev, "Unsupported BCLK divider: %d\n", bclk_div); return -EINVAL; -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel