From patchwork Sat May 3 18:30:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 4106571 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 60B999F3EE for ; Sat, 3 May 2014 18:37:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 95EFD2015D for ; Sat, 3 May 2014 18:36:59 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 62F9A20117 for ; Sat, 3 May 2014 18:36:58 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 7848B261AEC; Sat, 3 May 2014 20:36:56 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: 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 546D22616BF; Sat, 3 May 2014 20:34:55 +0200 (CEST) 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 1F4692617A6; Sat, 3 May 2014 20:34:54 +0200 (CEST) Received: from vps0.lunn.ch (vps0.lunn.ch [178.209.37.122]) by alsa0.perex.cz (Postfix) with ESMTP id CAA1E2619D7 for ; Sat, 3 May 2014 20:34:03 +0200 (CEST) Received: from lunn by vps0.lunn.ch with local (Exim 4.80) (envelope-from ) id 1Wgehg-0006En-Im; Sat, 03 May 2014 20:30:28 +0200 From: Andrew Lunn To: Jason Cooper , broonie@kernel.org Date: Sat, 3 May 2014 20:30:15 +0200 Message-Id: <1399141819-23924-6-git-send-email-andrew@lunn.ch> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1399141819-23924-1-git-send-email-andrew@lunn.ch> References: <1399141819-23924-1-git-send-email-andrew@lunn.ch> Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, linux ARM , Andrew Lunn Subject: [alsa-devel] [PATCH v2 5/9] ASoC: simple-card: Support setting mclk via a fixed factor 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 Some platforms require that the codecs mclk is a fixed multiplication factor of the audio stream rate. Add a optional property to the binding to hold this factor and implement a hw_params() function to make use of it. Signed-off-by: Andrew Lunn Acked-by: Jason Cooper --- v1->v2: s/factor/fs/g --- .../devicetree/bindings/sound/simple-card.txt | 2 ++ sound/soc/generic/simple-card.c | 28 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt index 131aa2ad7f1a..34d1b845edcc 100644 --- a/Documentation/devicetree/bindings/sound/simple-card.txt +++ b/Documentation/devicetree/bindings/sound/simple-card.txt @@ -18,6 +18,8 @@ Optional properties: Each entry is a pair of strings, the first being the connection's sink, the second being the connection's source. +- simple-audio-card,mclk-fs : Multiplication factor between stream rate and codec + mclk. - dai-tdm-slot-num : Please refer to tdm-slot.txt. - dai-tdm-slot-width : Please refer to tdm-slot.txt. diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 21f1ccbdf582..e5a3be97096c 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -24,6 +24,7 @@ struct simple_card_data { struct asoc_simple_dai cpu_dai; struct asoc_simple_dai codec_dai; } *dai_props; + unsigned int mclk_fs; struct snd_soc_dai_link dai_link[]; /* dynamically allocated */ }; @@ -151,6 +152,28 @@ asoc_simple_card_sub_parse_of(struct device_node *np, return 0; } +static int simple_card_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card); + unsigned int mclk; + int ret = 0; + + if (priv->mclk_fs) { + mclk = params_rate(params) * priv->mclk_fs; + ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk, + SND_SOC_CLOCK_IN); + } + + return ret; +} + +static struct snd_soc_ops simple_card_ops = { + .hw_params = simple_card_hw_params, +}; + static int simple_card_cpu_codec_of(struct device_node *node, int daifmt, struct snd_soc_dai_link *dai_link, @@ -255,6 +278,7 @@ static int asoc_simple_card_parse_of(struct device_node *node, sprintf(name, "%s-%s", dai_link->cpu_dai_name, dai_link->codec_dai_name); dai_link->name = dai_link->stream_name = name; + dai_link->ops = &simple_card_ops; if (!multi) break; @@ -263,6 +287,10 @@ static int asoc_simple_card_parse_of(struct device_node *node, dai_props++; } + /* Factor to mclk, used in hw_params() */ + of_property_read_u32(node, "simple-audio-card,mclk-fs", + &priv->mclk_fs); + /* card name is created from CPU/CODEC dai name */ dai_link = priv->snd_card.dai_link; if (!priv->snd_card.name)