Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1750559pxb; Mon, 23 Aug 2021 03:51:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8NP7bPWt8RErbWXF4cwIjLWv0UOkbt8O19PxE+FIDVqBa2lmG3tYt0LbjP6jgeVmWRbyv X-Received: by 2002:aa7:cc83:: with SMTP id p3mr37105775edt.365.1629715868613; Mon, 23 Aug 2021 03:51:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629715868; cv=none; d=google.com; s=arc-20160816; b=zdQrowHUHRAiQnnFDlJRthcJLs16iEnm10yqVSBzQ7pwgZCb2AEpwJ9eGmri7S3jve 8yne3d4hovApWxSTgwH4EpJ1EYlE+5mhx/6iuxYPwCFizhQz8U2d1dsh3T5cXLHXgb18 DnFYF3NZj0LHDHd4qsPbvN7kKU077af43wT/nzknKlu1Nkr3yvlh/INTHxi3/ms1vixx znBXH663cpVdumLgiMQUCe9vXifTGCZNNkqYA4dlsn4Z1EaCGl6CgT1DlUkCl01aAL1v zWdl/O+W8OYPUkUP8xFvE63gVYL9xlqtZraA1jXYwU/LuMJoGjYGfXv8huGJMDqHil4/ XCHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=6j3SjITKIWwyolHwMqNM7B+wBHN4sVFkPbZpNS4N5qk=; b=BnesgWPBfsjvWUZudvapr5gANLJEANZyG7ZeQEdw003sd5BV80xzif8PQ1dYUU89SP mqPXSdw82q3fXQNVnViMrOQ3RT8pQ6si0EqSPLFI3pKrRazqgPY27GZ7tnefIXBVeZVv e2SbH2JYhb7moOJYLsh/U0qtizkYtOUiTqdb0Vb6TFfUwFPJ4xYFAwrN2wCIi95basJR 5EevbIJQR7GQL0BKBggPDSc/JRBNYcrKCvlotCD53jSGNmS0JbnRB6pInUMn15ujN1zy CMHdHcI0tDxsVcAkQghhA81W0VGEXjcaCOoagbUa86S5bJPnP0SwNzYqVdkjKB2AK5ZC +uEA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id by17si14420331edb.481.2021.08.23.03.50.45; Mon, 23 Aug 2021 03:51:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236064AbhHWKuK (ORCPT + 99 others); Mon, 23 Aug 2021 06:50:10 -0400 Received: from lucky1.263xmail.com ([211.157.147.131]:59512 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234962AbhHWKuJ (ORCPT ); Mon, 23 Aug 2021 06:50:09 -0400 Received: from localhost (unknown [192.168.167.235]) by lucky1.263xmail.com (Postfix) with ESMTP id F199AC29AB; Mon, 23 Aug 2021 18:49:24 +0800 (CST) X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ADDR-CHECKED4: 1 X-SKE-CHECKED: 1 X-ANTISPAM-LEVEL: 2 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (postfix) whith ESMTP id P32763T139760957703936S1629715760494266_; Mon, 23 Aug 2021 18:49:25 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: X-RL-SENDER: sugar.zhang@rock-chips.com X-SENDER: zxg@rock-chips.com X-LOGIN-NAME: sugar.zhang@rock-chips.com X-FST-TO: broonie@kernel.org X-RCPT-COUNT: 10 X-SENDER-IP: 58.22.7.114 X-ATTACHMENT-NUM: 0 X-System-Flag: 0 From: Sugar Zhang To: broonie@kernel.org, heiko@sntech.de Cc: linux-rockchip@lists.infradead.org, Sugar Zhang , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 02/15] ASoC: rockchip: i2s: Fixup clk div error Date: Mon, 23 Aug 2021 18:48:16 +0800 Message-Id: <1629715710-21137-3-git-send-email-sugar.zhang@rock-chips.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1629715710-21137-1-git-send-email-sugar.zhang@rock-chips.com> References: <1629715710-21137-1-git-send-email-sugar.zhang@rock-chips.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org MCLK maybe not precise as required because of PLL, but which still can be used and no side effect. so, using DIV_ROUND_CLOSEST instead div. e.g. set mclk to 11289600 Hz, but get 11289598 Hz. 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 c9d5c52..05fce2c 100644 --- a/sound/soc/rockchip/rockchip_i2s.c +++ b/sound/soc/rockchip/rockchip_i2s.c @@ -280,10 +280,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_ratio * params_rate(params); - if (bclk_rate == 0 || 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, -- 2.7.4