Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp97379ybp; Thu, 3 Oct 2019 10:42:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqxutEdAuimVApuHyKcn7Inz3FQw0Ttf4kOF0irGUneppVr45MLwruDmCtEZyr0BiwgPTUxl X-Received: by 2002:a17:906:4a06:: with SMTP id w6mr8825866eju.214.1570124571052; Thu, 03 Oct 2019 10:42:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570124571; cv=none; d=google.com; s=arc-20160816; b=QOLkM0kdbHbqleJc8QdzOP89rXpWiqFPUEf79OUwXw++7gCK1l74l2B37mFUA3kuSd Iywk7QqyVv19+wdPfdjasFfRfpF7zxJ75stVO2HO+0zhhawwnH+vrT5TN/5s67zsQpBz B8yT+FnDccPSQzFcTrW4+zV8XWeP0xJ65ZvLnLlVizPvrd6Tiq7oVmPaSdw8fCH4yI44 KFDH+RYUJFEqyteNHpf9+ikh6ZiEN3053U9ljKUpef1Sk7m5ea+YFbNt0JZcujrxjJ0q TquMCDIxZ8V6/gC2NpoNUQonyBvOF7m/8ZZB7jNxY4bGILPqBQYiITn0usEUMf264fdm 9brg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jOyXNPttdllM2zBHBc4Yjzu3flp2mY+R2nIrpByMCDs=; b=log8czhiutQU0sjzLo/FpvQmBLIXz0h6Ln5LC5g5GuuMy8iA3FggYl0L1qjnDzRDYA 7LRqdFqsYPg6etXXbLh3TmB1HsoJPaG2xuemne5yccp1+KNBVJfXqAkeWA2Y80PMQzcb svF0L9ZSffX/ucK1IMAL6I+BF+SwSM234mcBWPc2DA5YgSOheVRadqZktCSgcBST2yaa oUURsQJwkd1ES0IpEkr9S9Gc9PXgblyqF13DZUpoG4bh4UL6XWA+Rra5FhRTjSeuR4CB +kWO8+9uEK10+yXk1CsGSW1FrrUTgB+NNqsVXCe2HZmlUyVp47Od9OCLOqbvnjOWnS8Y Vu9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cZL0OY5h; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e4si1784743edy.295.2019.10.03.10.42.26; Thu, 03 Oct 2019 10:42:51 -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; dkim=pass header.i=@kernel.org header.s=default header.b=cZL0OY5h; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390594AbfJCRUg (ORCPT + 99 others); Thu, 3 Oct 2019 13:20:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:44788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387734AbfJCQSQ (ORCPT ); Thu, 3 Oct 2019 12:18:16 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9AE2820700; Thu, 3 Oct 2019 16:18:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570119496; bh=D1XWRJt6ClMhPXFxGI9JJL0/zQQhSHeSVvnHbT7ij5U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cZL0OY5h+qYBxvkklmWMSM5oEUMnhOWu3V8h/InpddYlO4UmWeNBqUz+YlRMp2u/c ixspXcLW3UU336DsnVlcXXceWRug1YjMfLXgqTaqVXg9K1TksyTIiPYHMoqFVGjbY3 F+28I71uk7dkGnoLmeqbahDQJBky3BBLBHn1p688= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maxime Ripard , Mark Brown , Sasha Levin Subject: [PATCH 4.19 087/211] ASoC: sun4i-i2s: Dont use the oversample to calculate BCLK Date: Thu, 3 Oct 2019 17:52:33 +0200 Message-Id: <20191003154506.862226120@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154447.010950442@linuxfoundation.org> References: <20191003154447.010950442@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Maxime Ripard [ Upstream commit 7df8f9a20196072162d9dc8fe99943f2d35f23d5 ] 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 Signed-off-by: Sasha Levin --- 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 6173dd86c62ce..18cf8404d27ca 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -223,10 +223,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++) { @@ -316,8 +317,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