Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3114697ybl; Mon, 19 Aug 2019 12:27:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqxqhmW8Kze2msyAX5mTqleGlCjqy24R8xaOBi2+43J+Ukv8h8bOkazjziqa8mxnW+6+Y054 X-Received: by 2002:a17:902:fe11:: with SMTP id g17mr4203022plj.154.1566242837489; Mon, 19 Aug 2019 12:27:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566242837; cv=none; d=google.com; s=arc-20160816; b=uLzw39UsjD3Sviide3hk8UdYUt9d+QcbUODK9R7/fBMYFzRGIHec4qYUAKbaxHW0+X JVu3B5Y8H5tBdFJ1aEUqzbKpUqNm/axyvZfm+JXmrn66aZYWhO7kmy4S2TyITmQ6vvN/ H7qBwLB2TPZyXt5Oq2U5vA/K2mMp90qIixfTFaN93d92qPMGUNHIC/ZVAqQqxMQ4KOEg iVKQZijVguh+PZlSUkSQbS8qYm0PP39zinVMYC2vpIhYcO2r34c07jX5bzM4NGCfWITg egYtv3qn16XtblsASa1HxJjvNGuE3f90iZWCSvT3PGM/ajMLUoOXWwQBrWxhHOafEirj aMZQ== 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=MKuOLCRytv6VvENF2tVjS6XX1x/WxBSDrxheUyedGUc=; b=Tq4T2I0utB6hnY2sMK8oJj76VA46OnS585V2ZSBcTtFxeYl0w93MyckKh/rTVP2ipZ ZjTwqZzwmNcheYn7Gf0jd84gh76MYeA2ofje1JG9F56QEt1hhJqh40yPkQGs62ZHMlks XJRcl5PJWzIWfSS9ghzyHNADDAouNUdL2/Y77A8LnSZ+sxAynSGKjmy4GE3NS6/jjy/6 KPYG0HXwUPQfZIqsfpaDArUDhWllbJzHQdTrWd/pOOIBlDGX0/GqL+4gKV0w5CqNigBC yhckTInK1TfvgLfFu4RZ7R0XebyUD0U+D3TF28upjdw1KozMTtfURf2Enj8aw/PbJJDq KhDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BWCrO89c; 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 w3si10270136plq.237.2019.08.19.12.27.01; Mon, 19 Aug 2019 12:27:17 -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=BWCrO89c; 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 S1728603AbfHSTZz (ORCPT + 99 others); Mon, 19 Aug 2019 15:25:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:41442 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728576AbfHSTZv (ORCPT ); Mon, 19 Aug 2019 15:25:51 -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 6DDAE22CF4; Mon, 19 Aug 2019 19:25:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566242751; bh=/JNyZbS922uUvEBM9yhHQYNhX5F4WMOEyf2ebWw0n0E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BWCrO89c9XDY0UhUVpOQONJNeLuIT+5uAK3YO8yGBX6Zouk5HrANAYF4b1cAosRvb OBSfij1YvI4G4M3MkuSzL61k5Bxp9jo27X288iA2Zz8/v3q3ueGBMO5UhvmDp5Epd8 Nu1kslqvVOR7xstBCpxEKbXNUjyzaHutoRGSzpS8= 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 06/21] ASoC: sun4i-i2s: Rework MCLK divider calculation Date: Mon, 19 Aug 2019 21:25:13 +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 MCLK divider calculation is currently computing the ideal divider using the oversample rate, the sample rate and the parent rate. However, since we have access to the frequency is supposed to be running at already, and as it turns out we're using it to compute the oversample rate, we can just use the ratio between the parent rate and the MCLK rate to simplify a bit the formula. Signed-off-by: Maxime Ripard --- sound/soc/sunxi/sun4i-i2s.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index fbbedb660cc6..3d7f4a97e0ba 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -225,11 +225,10 @@ static int sun4i_i2s_get_bclk_div(struct sun4i_i2s *i2s, } static int sun4i_i2s_get_mclk_div(struct sun4i_i2s *i2s, - unsigned int oversample_rate, - unsigned int module_rate, - unsigned int sampling_rate) + unsigned long parent_rate, + unsigned long mclk_rate) { - int div = module_rate / sampling_rate / oversample_rate; + int div = parent_rate / mclk_rate; int i; for (i = 0; i < ARRAY_SIZE(sun4i_i2s_mclk_div); i++) { @@ -308,8 +307,7 @@ static int sun4i_i2s_set_clk_rate(struct snd_soc_dai *dai, return -EINVAL; } - mclk_div = sun4i_i2s_get_mclk_div(i2s, oversample_rate, - clk_rate, rate); + mclk_div = sun4i_i2s_get_mclk_div(i2s, clk_rate, i2s->mclk_freq); if (mclk_div < 0) { dev_err(dai->dev, "Unsupported MCLK divider: %d\n", mclk_div); return -EINVAL; -- git-series 0.9.1