From patchwork Sun Mar 15 12:11:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Kleine-Budde X-Patchwork-Id: 6012861 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 25A179F318 for ; Sun, 15 Mar 2015 12:12:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4D1CB20274 for ; Sun, 15 Mar 2015 12:12:20 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id E45D72024F for ; Sun, 15 Mar 2015 12:12:18 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 58B91260708; Sun, 15 Mar 2015 13:12:17 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 70AD626049B; Sun, 15 Mar 2015 13:12:10 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 725A42604F8; Sun, 15 Mar 2015 13:12:08 +0100 (CET) Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [92.198.50.35]) by alsa0.perex.cz (Postfix) with ESMTP id 87913260417 for ; Sun, 15 Mar 2015 13:12:01 +0100 (CET) Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1YX7Oi-0006AZ-TW; Sun, 15 Mar 2015 13:12:00 +0100 Received: from mkl by dude.hi.pengutronix.de with local (Exim 4.84) (envelope-from ) id 1YX7Oi-0001Ie-ML; Sun, 15 Mar 2015 13:12:00 +0100 From: Marc Kleine-Budde To: alsa-devel@alsa-project.org Date: Sun, 15 Mar 2015 13:11:59 +0100 Message-Id: <1426421519-2224-1-git-send-email-mkl@pengutronix.de> X-Mailer: git-send-email 2.1.4 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mkl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: alsa-devel@alsa-project.org Cc: Sascha Hauer , Marc Kleine-Budde , kernel@pengutronix.de Subject: [alsa-devel] [PATCH] ASoC: fsl-ssi: Fix bitclock calculation for master mode X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sascha Hauer in fsl_ssi_set_bclk we are looking for the best divider by iterating over all possible dividers. The divider is in the range 1..256, so make this clear by using 'div' as name for the loop counter and iterate from 1 to 256 instead of 0 to 255. This makes obvious that tmprate is calculated wrong, it has to be freq * factor * div, not freq * factor * (i + 2). Signed-off-by: Sascha Hauer Signed-off-by: Marc Kleine-Budde --- sound/soc/fsl/fsl_ssi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index b9fabbf69db6..b8af08e49085 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -578,7 +578,7 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream, struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai); struct regmap *regs = ssi_private->regs; int synchronous = ssi_private->cpu_dai_drv.symmetric_rates, ret; - u32 pm = 999, div2, psr, stccr, mask, afreq, factor, i; + u32 pm = 999, div2, psr, stccr, mask, afreq, factor, div; unsigned long clkrate, baudrate, tmprate; u64 sub, savesub = 100000; unsigned int freq; @@ -602,8 +602,8 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream, factor = (div2 + 1) * (7 * psr + 1) * 2; - for (i = 0; i < 255; i++) { - tmprate = freq * factor * (i + 2); + for (div = 1; div < 256; div++) { + tmprate = freq * factor * div; if (baudclk_is_used) clkrate = clk_get_rate(ssi_private->baudclk); @@ -618,7 +618,7 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream, continue; clkrate /= factor; - afreq = clkrate / (i + 1); + afreq = clkrate / div; if (freq == afreq) sub = 0; @@ -636,7 +636,7 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream, if (sub < savesub) { baudrate = tmprate; savesub = sub; - pm = i; + pm = div - 1; } /* We are lucky */