Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3118088ybl; Mon, 19 Aug 2019 12:30:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqyAR0vMtBC/a7OJXH1THBZMPP8nyxmYYUf/dQRI3cq0TTUcYGB0qYEKTz26vm7I+8Yc5SGV X-Received: by 2002:a17:902:9a85:: with SMTP id w5mr24228500plp.221.1566243044722; Mon, 19 Aug 2019 12:30:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566243044; cv=none; d=google.com; s=arc-20160816; b=OdfoKlgl4ROnTMKLsWQck+/eoYT2v+4TSOgqLqiS2x2tfwPINPbwNHheh1nl5MJR+7 Zc5XDuWVnL1V5NQjsh7MKcrf1ehslI77/dKv3ofVITJqS+7ivP74vfM4ch2pYB5CbZTt WIy/vhZyL0ix6xET9xoOOyVFPOInPTnCe/+PAK7t+g8MpMApNBBcwc50RQZP5wQnnm2T mbDzJroZg+/E+nO4swoNSdLC6hs4vwfONns7gYU10Z7mk6yjSgVgQ/yYYFsQpKepedlv 8Sqzwf0YCGt9Ix7CCmaFo0RjT2DXhpdgD3lWcFmEguRCsq/2hXzj5w9q/tSUWxn7wkT4 uWgQ== 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=awkExGKN3QKPZjTYaNs5UW6bkSDVBsMoPnbbCjXucHY=; b=k6bxfVvsoOPufrm7JoREH+3sG3jvm0e0LZ+4G9nSxkj16r9DC47+FFj0fZ365T06cx 4zrVhOk0p4L3GSwJDenzsJ2wC2NId0rzGXwRv9H36umgXAd4F3yo4lk1ZK16cfEapF8S 2U9EziaqWgDKapffQO8N3VB60fTtx4ouUnFYuA2w8i2tPSf5H+EhRilosHjkXa6Mi2jm 4cMezzS5DE6L6I0swGuFtZILffBrwYFmoeTeB77kPiCk67YpuNj6acsyhIr/OOSFGgex LyfW24Herzg6Mt0Z2hWpOYkedFl0xwpuNStvMahmfJORlxLUwglHcjdv9vih9UTaG5fH 4ncQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HXlVqazD; 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=pass (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 r14si10553580pgi.513.2019.08.19.12.30.28; Mon, 19 Aug 2019 12:30:44 -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=HXlVqazD; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728646AbfHST0G (ORCPT + 99 others); Mon, 19 Aug 2019 15:26:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:41514 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728597AbfHSTZy (ORCPT ); Mon, 19 Aug 2019 15:25:54 -0400 Received: from localhost (lfbn-1-10718-76.w90-89.abo.wanadoo.fr [90.89.68.76]) (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 666FE206C1; Mon, 19 Aug 2019 19:25:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566242754; bh=r26mVi/Xdz/Vu/rKWGSR3w39MsxTxz5AOjIuGgJ5SLY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HXlVqazDIZhHBBlltb4Jwzhz6SGlPlP/HEN4yzDx9tKCrabyvbpl0jOYfffarJXwl jki4+zExNPQv0mEVS9u4h9FWhAfRbkvRxU4MwLKa1o2PJm4R20vp3XkP6pRe/Syd0d oX9NxON9J+EnGOJXga/AHQiTFJH8VIxEogrCoJrk= From: Maxime Ripard To: Chen-Yu Tsai , Maxime Ripard , lgirdwood@gmail.com, broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org, codekipper@gmail.com, linux-kernel@vger.kernel.org Subject: [PATCH 07/21] ASoC: sun4i-i2s: Don't use the oversample to calculate BCLK Date: Mon, 19 Aug 2019 21:25:14 +0200 Message-Id: X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 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 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 --- 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 3d7f4a97e0ba..ee8ee3eb2087 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -208,10 +208,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++) { @@ -300,8 +301,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; -- git-series 0.9.1