From patchwork Tue Sep 2 03:27:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xavier Hsu X-Patchwork-Id: 36431 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f70.google.com (mail-yh0-f70.google.com [209.85.213.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 019AA20C7F for ; Tue, 2 Sep 2014 03:28:00 +0000 (UTC) Received: by mail-yh0-f70.google.com with SMTP id b6sf23754644yha.1 for ; Mon, 01 Sep 2014 20:28:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=5rdFZAqvlQnypYYTCktoLO86di0zU82uHLXMqs6kbMw=; b=K7d6sALPvMieP6EH8KJYsuoBkyY5mMcsG1MG6Ixs9td0urFcRdDUqqzIniueui3Ies XX31I1d3f45KI21bpjzchuN7cBscUDF1H48UXVrvsb5gu1axt7l2XVJxG00d0spLKcve I2biatAgYEKKZD6Zd2o0zN+Ri5QL2w47Cop7guXqOUBKMTnFOWu9ASi1/yyvqfTq+//q EXOda60KD9uo2PunVYOq6a7wSWgyhX03t1AoM/1cGI9RG/dauyLksAgM61wtRv6GQOxU HFHyF2js3lR9R5vt/mnw2C21VkmhLg91dqhzlcv/YiS+yWD/K1ZZ5fe/bKAWSZ0oNYN5 BGng== X-Gm-Message-State: ALoCoQnOYo/2+8vyAdGhCnLchCUj1TtG1dUa6jcLIsxIwe9gHcLD6Es+yCcH/c9nwBcWvn+h/NaJ X-Received: by 10.236.125.33 with SMTP id y21mr17894324yhh.20.1409628480817; Mon, 01 Sep 2014 20:28:00 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.106.136 with SMTP id e8ls2158199qgf.36.gmail; Mon, 01 Sep 2014 20:28:00 -0700 (PDT) X-Received: by 10.52.170.211 with SMTP id ao19mr23644850vdc.23.1409628480748; Mon, 01 Sep 2014 20:28:00 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id mn6si1756016vcb.40.2014.09.01.20.28.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Sep 2014 20:28:00 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id hq11so6206596vcb.8 for ; Mon, 01 Sep 2014 20:28:00 -0700 (PDT) X-Received: by 10.220.122.194 with SMTP id m2mr26682204vcr.17.1409628480687; Mon, 01 Sep 2014 20:28:00 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp465116vcb; Mon, 1 Sep 2014 20:28:00 -0700 (PDT) X-Received: by 10.70.88.237 with SMTP id bj13mr44254682pdb.57.1409628478572; Mon, 01 Sep 2014 20:27:58 -0700 (PDT) Received: from Kraken ([124.219.7.128]) by mx.google.com with ESMTP id ds5si3523208pbb.207.2014.09.01.20.27.57 for ; Mon, 01 Sep 2014 20:27:58 -0700 (PDT) Received-SPF: none (google.com: xavier@kraken does not designate permitted sender hosts) client-ip=124.219.7.128; Received: by Kraken (Postfix, from userid 1011) id 006746A27A5; Tue, 2 Sep 2014 11:27:55 +0800 (CST) From: Xavier Hsu To: alsa-devel@alsa-project.org, patches@opensource.wolfsonmicro.com, patches@linaro.org Cc: Xavier Hsu , Andy Green Subject: [PATCHv3 5/9] Using the constraint based on wm8971_set_dai_sysclk Date: Tue, 2 Sep 2014 11:27:46 +0800 Message-Id: <1409628470-13059-5-git-send-email-xavier.hsu@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1409628470-13059-1-git-send-email-xavier.hsu@linaro.org> References: <1409628470-13059-1-git-send-email-xavier.hsu@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: xavier.hsu@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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,