From patchwork Tue Nov 3 01:33:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caesar Wang X-Patchwork-Id: 7539191 Return-Path: X-Original-To: patchwork-linux-rockchip@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 30CA2BEEA4 for ; Tue, 3 Nov 2015 01:35:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5B8E320306 for ; Tue, 3 Nov 2015 01:35:50 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 76FC2202EB for ; Tue, 3 Nov 2015 01:35:49 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZtQVo-0007I4-Qz; Tue, 03 Nov 2015 01:35:48 +0000 Received: from mail-pa0-f48.google.com ([209.85.220.48]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZtQVT-0005t5-Op; Tue, 03 Nov 2015 01:35:30 +0000 Received: by pacfv9 with SMTP id fv9so2737728pac.3; Mon, 02 Nov 2015 17:35:06 -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=qNn/n+M1SFSYtJQ3dLlodtW3TK6koaju6Da94ltzl9Y=; b=Zswr+Snx5mtu8Io10VnQUAvGglRjf8EUsNMVMrJgswSLlAkiGZAWIQlN1OR/PIKnQr PUg+mysvqR4gdo48gRIibw1uv2LCtQD5A5BAmjtKx/MQoj7Z4xfngOI/fbEEWPIijREw O3KDe8uszrDRb1KGKUPduHO3DQ9wJ4Sxwybr87f2byCBM8DDliH98QtRnyiTvuxzD93l Y9W5iU352wjy7SF2V/KoMakfJnfZOgm7Qw28sd8YGH5brGxsAbWnXUXDB8aTT0BGs4zA EngpljHdADubu0cEb15vpqswLfuDW7KGE6OFjQkG3ykHsR8WqC6EPueXKmS7Krnf0hOh GgfQ== X-Received: by 10.66.243.225 with SMTP id xb1mr30654894pac.1.1446514506854; Mon, 02 Nov 2015 17:35:06 -0800 (PST) Received: from localhost.localdomain ([103.47.144.138]) by smtp.gmail.com with ESMTPSA id yp5sm26371345pac.38.2015.11.02.17.34.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Nov 2015 17:35:05 -0800 (PST) From: Caesar Wang To: Heiko Stuebner , Mark Brown Subject: [PATCH v1 5/5] ASoC: rockchip-rt5645: Add the divider clock for cpu Date: Tue, 3 Nov 2015 09:33:58 +0800 Message-Id: <1446514438-13922-6-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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151102_173528_208267_42A4014A X-CRM114-Status: GOOD ( 13.82 ) X-Spam-Score: -2.4 (--) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 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, Liam Girdwood , linux-kernel@vger.kernel.org, Takashi Iwai , Doug Anderson , Jaroslav Kysela , linux-rockchip@lists.infradead.org, Dylan Reid , Cheng-Yi Chiang , Sonny Rao , linux-arm-kernel@lists.infradead.org, Caesar Wang MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add to set the cpu/codec DAI configure, let's divider the Transmit/Receive clock for cpu. In master mode, The SCLK and LRCK are configured as output, this patch should can set each divider to arrange the clock distribution. Signed-off-by: Caesar Wang --- Changes in v1: - Fix a subject missspell. sound/soc/rockchip/rockchip_rt5645.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/sound/soc/rockchip/rockchip_rt5645.c b/sound/soc/rockchip/rockchip_rt5645.c index edff07f..4c1a693 100644 --- a/sound/soc/rockchip/rockchip_rt5645.c +++ b/sound/soc/rockchip/rockchip_rt5645.c @@ -74,8 +74,25 @@ static int rk_aif1_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai = rtd->codec_dai; + int dai_fmt = rtd->card->dai_link->dai_fmt; int mclk; + /* set codec DAI configuration */ + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + if (ret < 0) { + dev_err(codec_dai->dev, + "failed to set the format for codec side\n"); + return ret; + } + + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + if (ret < 0) { + dev_err(codec_dai->dev, + "failed to set the format for cpu side\n"); + return ret; + } + switch (params_rate(params)) { case 8000: case 16000: @@ -109,6 +126,21 @@ static int rk_aif1_hw_params(struct snd_pcm_substream *substream, return ret; } + /* The codec is master mode, that's not needed set clkdiv for cpu */ + if ((dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBM_CFM) + return ret; + + /* the LRCK clock for cpu */ + ret = snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK, + (mclk / 4) / params_rate(params)); + if (ret < 0) + return ret; + + /* the SCLK clock for cpu */ + snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_MCLK, 4); + if (ret < 0) + return ret; + return ret; }