From patchwork Fri Jun 9 08:52:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sugar Zhang X-Patchwork-Id: 9777721 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3DC7A6034B for ; Fri, 9 Jun 2017 09:34:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2FD6126E39 for ; Fri, 9 Jun 2017 09:34:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 219A728438; Fri, 9 Jun 2017 09:34:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,URIBL_BLACK autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C053426E39 for ; Fri, 9 Jun 2017 09:34:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=t1tLVlxLsAHFRuHjDMV56/9hITUNhri5Nv7NeTorc0w=; b=KNMgtROmlnDiq6x3dYjsudhicQ EOt833u+XRHe1FJqllasmGVUWDAGDSdhnqu2+idhYh3+61RMwBITSi+BvDGLMenyZYAEPcu0SuI9M +Q6oINXt09A3uBEZeNObHqLHlUZbkBFXe0CsCo+Zc4moqcbDMOmsZVg2F2PH8P3ens8IdxGPFPs+V jAB3FQVEoZIDiZTN8z/ediuhJhOGGyo+mLggsJnHGy0pnpO9zyrDSJSXfECye5i600qMiAfy1vhUA 8PEhR1WVcQQqUvbkKyjbPdqDwTfJ1QtcQVU9tKPuuwSY3NnvHWBGXaLAPZdX2h8hhwqBkb4YnsLy9 HWOCun6w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dJGJ2-0003nF-7c; Fri, 09 Jun 2017 09:34:12 +0000 Received: from merlin.infradead.org ([205.233.59.134]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dJGIn-0003WY-0u; Fri, 09 Jun 2017 09:33:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=rAmNberPEYY22z+RJWBA2UNBvYp0J9lOK/0l5jOKmNE=; b=FNRYXdd2OKjYY6wbdw58qkLzp nEmv0DHtRL4cU6DIY42IOy6DGyfNck/bTZlVV+FU0PjNfGLHItMJimYBo6ZYxZR63/+eBkc6SVrZS 1E84xFqR8k2u0AV7lDWSx4JgQQ3Qfe/AIVP54XdZO9wQOdqE461/43a0zxVjCSAZmjdRHvSuTDgL8 b5HGlgJ1o6Uyed5PyR/om6bQlTkeGDLeG0+XtxaQtQPreRT/2Z7TjY2znktXXUiE9MeLwIOs59vEX EPlRqmulLOdLrpDEN50WPDiPqhuFSa29CFwBWXov+o68qOOy9IHNuGzLhSS3kaJmmONmqsFHde3lH Z53lMX0IA==; Received: from regular1.263xmail.com ([211.150.99.140]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dJFjn-0002zT-V3; Fri, 09 Jun 2017 08:57:49 +0000 Received: from sugar.zhang?rock-chips.com (unknown [192.168.167.232]) by regular1.263xmail.com (Postfix) with ESMTP id 115C64BED; Fri, 9 Jun 2017 16:56:57 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id 8F26E3C6; Fri, 9 Jun 2017 16:56:56 +0800 (CST) X-RL-SENDER: sugar.zhang@rock-chips.com X-FST-TO: heiko@sntech.de X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: sugar.zhang@rock-chips.com X-UNIQUE-TAG: <9ac5126e5129fdf37cbeeeab712c3463> X-ATTACHMENT-NUM: 0 X-SENDER: zxg@rock-chips.com X-DNS-TYPE: 0 Received: from unknown (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith SMTP id 18713YH32P6; Fri, 09 Jun 2017 16:56:58 +0800 (CST) From: Sugar Zhang To: heiko@sntech.de, broonie@kernel.org Subject: [PATCH v1 4/4] ASoC: rockchip: i2s: fixup clk div Date: Fri, 9 Jun 2017 16:52:49 +0800 Message-Id: <1496998369-30556-5-git-send-email-sugar.zhang@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1496998369-30556-1-git-send-email-sugar.zhang@rock-chips.com> References: <1496998369-30556-1-git-send-email-sugar.zhang@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170609_045748_310790_ED30AE21 X-CRM114-Status: UNSURE ( 9.02 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Takashi Iwai , Liam Girdwood , Sugar Zhang , linux-rockchip@lists.infradead.org, Jaroslav Kysela , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP we found mclk maybe not precise as required because of PLL, but it still can be used and no side effect. for example, if we require mclk 11289600, but get 11289598, it doesn't matter. so using DIV_ROUND_CLOSEST to fix it. Signed-off-by: Sugar Zhang --- sound/soc/rockchip/rockchip_i2s.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c index 2a15a00..b56e00d 100644 --- a/sound/soc/rockchip/rockchip_i2s.c +++ b/sound/soc/rockchip/rockchip_i2s.c @@ -282,10 +282,10 @@ static int rockchip_i2s_hw_params(struct snd_pcm_substream *substream, if (i2s->is_master_mode) { mclk_rate = clk_get_rate(i2s->mclk); bclk_rate = i2s->bclk_fs * params_rate(params); - if (bclk_rate && mclk_rate % bclk_rate) + if (!bclk_rate) return -EINVAL; - div_bclk = mclk_rate / bclk_rate; + div_bclk = DIV_ROUND_CLOSEST(mclk_rate, bclk_rate); div_lrck = bclk_rate / params_rate(params); regmap_update_bits(i2s->regmap, I2S_CKR, I2S_CKR_MDIV_MASK,