Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp4360622ybl; Tue, 20 Aug 2019 10:42:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqw+RlEe6hJGHfAyg0MOABWOkE+xFsH6ixTNU/+hMdmY9WgzixTNBjhSC7cjLNxqy0RY7lt+ X-Received: by 2002:a63:550d:: with SMTP id j13mr25998514pgb.173.1566322943368; Tue, 20 Aug 2019 10:42:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566322943; cv=none; d=google.com; s=arc-20160816; b=L2rqgtP24XVtHbNak/I/FaCwJ4k5Oxi+WGGCAhGY06nNffz2iNzQK22phjOedqBriG M3qLC6wC3zsbnAeEDrJSlT6orI19XTFFM3sK0Lk//y8GPKN3kHWTaMKxSqa766QltRNh oKmLZ17Po1FM/Q2lAYJRckELBhZl/PGe3zOQJWLgOZMr3zMe7sZBSqWntzWTIpLQE7ww 9Wh3FdwT9JeUtNNgCIl5LtsQap0hGndrsijfds1B048ZLeFL/t3P4mALN9U+8M6PHMkp VMK1hrYNwMxCrdED8Eg5B0SuXATIZH8/dNMADj0OVfrr6fn7X21XaHV2bnSrqEGnB6Xb Ph9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:message-id:in-reply-to:subject:cc:to :from; bh=yCDyVLCiFyaHGZVMltg2SfBdT7xmop4SmEPuiPFwdPM=; b=BJxlfS2WFKdNFkICYEZDt4tKRq4IIWjEM7k1sM17twb/1yjDWZptntrHH18YpsUYbq Zk0UXES6SbhI9jjd9Y0O0N6qA4ys3jVFDWAq2DwCB+fZN+tc7gCGjhcTmAmgu5tQ7xdu VPvJO+yarZ44wiAYLDf41LZlDnJ4HuMfC6TQlaFAJFj1mO4EDzceb3dQ2kKLydIwP3o0 0BAPzeyVmLpyTcKxvx6lkEiwQDDN7uvfndqe8Gz+acotzO3wjJKIyqmRpOklQP1Lm/cl DpESwgcJeA2Bc5f/yfJQmHU8Qed7qowdziVA6ztxM7YfQH3KXKFITOmUjjuZKobNjW6d G2+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 38si12845704pla.216.2019.08.20.10.42.08; Tue, 20 Aug 2019 10:42:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730667AbfHTRlP (ORCPT + 99 others); Tue, 20 Aug 2019 13:41:15 -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-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