From patchwork Tue Nov 3 01:33:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caesar Wang X-Patchwork-Id: 7539181 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E61DABF90C for ; Tue, 3 Nov 2015 01:35:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 15CF420631 for ; Tue, 3 Nov 2015 01:35:31 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id D1CD7204D9 for ; Tue, 3 Nov 2015 01:35:29 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id DD1E72650B0; Tue, 3 Nov 2015 02:35:28 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, RCVD_IN_DNSWL_LOW, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 0CF5C264F37; Tue, 3 Nov 2015 02:35:00 +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 D2F632650FE; Tue, 3 Nov 2015 02:34:58 +0100 (CET) Received: from mail-pa0-f45.google.com (mail-pa0-f45.google.com [209.85.220.45]) by alsa0.perex.cz (Postfix) with ESMTP id 16482264F50 for ; Tue, 3 Nov 2015 02:34:27 +0100 (CET) Received: by pabfh17 with SMTP id fh17so2694753pab.0 for ; Mon, 02 Nov 2015 17:34:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8L4EjrsymDuRLf4902XO9aThAOG4WGC/weLwDhxbcYM=; b=YDXH+oUlngxVItbW83kKNBEoltKr/Aq17MAjlpKxE1vNz0UiedmUHFUNLAO+bvnOSV eP9vZfu5M+ycfYWa117ziw5c87LJAkjY6rESKxvK2tfZyqQtiYVHgNY8wTjdpg4VbksE 1+DpzVt+Wr1c41eNDWKrsxgqRp9pqXbCE2tnKliT+M4NoQgjmAfu/Ci53ccrrE490VLu Mdq8XbM+b4E3sGyb8EgN7TQsfEk8feYt3PFtKZ4yxA7HsZR6azWqn5nQHoDWlFTvAE5N ljN5PgP1NnnbKATDrEVEK7AaeVY26kDozCgNWLEfEqR6kTvjlsGmXA8XuPbNWAkXYDh3 IaMg== X-Received: by 10.66.227.38 with SMTP id rx6mr31033619pac.85.1446514466037; Mon, 02 Nov 2015 17:34:26 -0800 (PST) Received: from localhost.localdomain ([103.47.144.138]) by smtp.gmail.com with ESMTPSA id yp5sm26371345pac.38.2015.11.02.17.34.18 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Nov 2015 17:34:25 -0800 (PST) From: Caesar Wang To: Heiko Stuebner , Mark Brown Date: Tue, 3 Nov 2015 09:33:54 +0800 Message-Id: <1446514438-13922-2-git-send-email-wxt@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1446514438-13922-1-git-send-email-wxt@rock-chips.com> References: <1446514438-13922-1-git-send-email-wxt@rock-chips.com> Cc: alsa-devel@alsa-project.org, Liam Girdwood , linux-kernel@vger.kernel.org, Takashi Iwai , Doug Anderson , linux-rockchip@lists.infradead.org, Dylan Reid , Cheng-Yi Chiang , Sonny Rao , linux-arm-kernel@lists.infradead.org, Caesar Wang Subject: [alsa-devel] [PATCH v1 1/5] ASoC: rockchip: i2s: Support to set the divider clock API 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 In order to support more sample rates, add the divider clock api. As the input source clock to the module is MCLK_I2S, and by the divider of the module, the clock generator generates SCLK and LRCK to transmitter and receiver. Signed-off-by: Caesar Wang --- Changes in v1: - change the subject and commit. - remove the print message dev_dbg(). sound/soc/rockchip/rockchip_i2s.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c index b936102..23c867f 100644 --- a/sound/soc/rockchip/rockchip_i2s.c +++ b/sound/soc/rockchip/rockchip_i2s.c @@ -286,6 +286,32 @@ static int rockchip_i2s_trigger(struct snd_pcm_substream *substream, return ret; } +static int rockchip_i2s_set_clkdiv(struct snd_soc_dai *cpu_dai, + int div_id, int div) +{ + struct rk_i2s_dev *i2s = to_info(cpu_dai); + unsigned int val = 0; + + switch (div_id) { + case ROCKCHIP_DIV_BCLK: + val |= I2S_CKR_TSD(div); + val |= I2S_CKR_RSD(div); + regmap_update_bits(i2s->regmap, I2S_CKR, + I2S_CKR_TSD_MASK | I2S_CKR_RSD_MASK, + val); + break; + case ROCKCHIP_DIV_MCLK: + val |= I2S_CKR_MDIV(div); + regmap_update_bits(i2s->regmap, I2S_CKR, + I2S_CKR_MDIV_MASK, val); + break; + default: + return -EINVAL; + } + + return 0; +} + static int rockchip_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, int clk_id, unsigned int freq, int dir) { @@ -311,6 +337,7 @@ static int rockchip_i2s_dai_probe(struct snd_soc_dai *dai) static const struct snd_soc_dai_ops rockchip_i2s_dai_ops = { .hw_params = rockchip_i2s_hw_params, + .set_clkdiv = rockchip_i2s_set_clkdiv, .set_sysclk = rockchip_i2s_set_sysclk, .set_fmt = rockchip_i2s_set_fmt, .trigger = rockchip_i2s_trigger,