From patchwork Tue Sep 2 03:30:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xavier Hsu X-Patchwork-Id: 4822891 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0C565C0338 for ; Tue, 2 Sep 2014 03:40:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 380B92018B for ; Tue, 2 Sep 2014 03:40:12 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id F29D6200D4 for ; Tue, 2 Sep 2014 03:40:10 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id F09BD2654D1; Tue, 2 Sep 2014 05:40:09 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 0E61E265329; Tue, 2 Sep 2014 05:35:17 +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 4B706265274; Tue, 2 Sep 2014 05:35:14 +0200 (CEST) Received: from Kraken (unknown [124.219.7.128]) by alsa0.perex.cz (Postfix) with ESMTP id BE7702652AE for ; Tue, 2 Sep 2014 05:30:54 +0200 (CEST) Received: by Kraken (Postfix, from userid 1011) id D7D8A6A27A5; Tue, 2 Sep 2014 11:30:52 +0800 (CST) From: Xavier Hsu To: alsa-devel@alsa-project.org, patches@opensource.wolfsonmicro.com, patches@linaro.org Date: Tue, 2 Sep 2014 11:30:44 +0800 Message-Id: <1409628648-13732-5-git-send-email-xavier.hsu@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1409628648-13732-1-git-send-email-xavier.hsu@linaro.org> References: <1409628648-13732-1-git-send-email-xavier.hsu@linaro.org> Cc: Xavier Hsu , ckeepax@opensource.wolfsonmicro.com, lars@metafoo.de, Andy Green Subject: [alsa-devel] [PATCHv3 5/9] Using the constraint based on wm8971_set_dai_sysclk 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 This patch improves WM8971. We use the constraint based on the function of wm8971_set_dai_sysclk(). Any comments about improving the patch are welcome. Thanks. Signed-off-by: Xavier Hsu Signed-off-by: Andy Green --- sound/soc/codecs/wm8971.c | 77 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 71 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/wm8971.c b/sound/soc/codecs/wm8971.c index 64ed226..20cfdd3 100755 --- a/sound/soc/codecs/wm8971.c +++ b/sound/soc/codecs/wm8971.c @@ -41,6 +41,7 @@ static struct workqueue_struct *wm8971_workq; /* codec private data */ struct wm8971_priv { unsigned int sysclk; + struct snd_pcm_hw_constraint_list *sysclk_constraints; int playback_fs; bool deemph; }; @@ -528,6 +529,53 @@ static int get_coeff(int mclk, int rate) return -EINVAL; } +/* The set of rates we can generate from the above for each SYSCLK */ +static const unsigned int rates_12288[] = { + 8000, 12000, 16000, 24000, 32000, 48000, 96000 +}; + +static struct snd_pcm_hw_constraint_list constraints_12288 = { + .count = ARRAY_SIZE(rates_12288), + .list = rates_12288, +}; + +static const unsigned int rates_112896[] = { + 8000, 11025, 22050, 44100, 88200 +}; + +static struct snd_pcm_hw_constraint_list constraints_112896 = { + .count = ARRAY_SIZE(rates_112896), + .list = rates_112896, +}; + +static const unsigned int rates_18432[] = { + 8000, 12000, 16000, 24000, 32000, 48000, 96000 +}; + +static struct snd_pcm_hw_constraint_list constraints_18432 = { + .count = ARRAY_SIZE(rates_18432), + .list = rates_18432, +}; + +static const unsigned int rates_169344[] = { + 8000, 11025, 22050, 44100, 88200 +}; + +static struct snd_pcm_hw_constraint_list constraints_169344 = { + .count = ARRAY_SIZE(rates_169344), + .list = rates_169344, +}; + +static const unsigned int rates_12[] = { + 8000, 11025, 12000, 16000, 22050, 2400, 32000, 41100, 48000, + 48000, 88235, 96000, +}; + +static struct snd_pcm_hw_constraint_list constraints_12 = { + .count = ARRAY_SIZE(rates_12), + .list = rates_12, +}; + static int wm8971_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { @@ -535,15 +583,32 @@ static int wm8971_set_dai_sysclk(struct snd_soc_dai *codec_dai, struct wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec); switch (freq) { - case 11289600: - case 12000000: case 12288000: - case 16934400: + case 24576000: + wm8971->sysclk_constraints = &constraints_12288; + break; + case 11289600: + case 22579200: + wm8971->sysclk_constraints = &constraints_112896; + break; case 18432000: - wm8971->sysclk = freq; - return 0; + wm8971->sysclk_constraints = &constraints_18432; + break; + case 16934400: + case 33868800: + wm8971->sysclk_constraints = &constraints_169344; + break; + case 12000000: + case 24000000: + wm8971->sysclk_constraints = &constraints_12; + break; + default: + return -EINVAL; } - return -EINVAL; + + wm8971->sysclk = freq; + + return 0; } static int wm8971_set_dai_fmt(struct snd_soc_dai *codec_dai,