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: 36439 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f198.google.com (mail-yk0-f198.google.com [209.85.160.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3897D20C7F for ; Tue, 2 Sep 2014 03:30:57 +0000 (UTC) Received: by mail-yk0-f198.google.com with SMTP id q200sf21453494ykb.1 for ; Mon, 01 Sep 2014 20:30:57 -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=UDWr0lm3CLKUvOJEy89QEyb74itsLYXpSNWGTccHnfRZxwi6Zn6BfuypZSuribjEVw 4UVSM/5W9wXO92DBaTc8OkGzDHI81PdfUJilEhTIojiTHZb5RGoWGUTlls3rGefpDMWP jqmbmF6PY18b/DnMjI/lIHzYggQCaIHfU6UtIM1tAYy/WUVmz4KIola3MX7FjjkvIgwu ZkQNebijTE9p/FTTCY8Vz/z/VOvwzaxH3Dlk5MA0sDj5Lc3F6lA560MXCMuXWLzHzfrV L8esZExhSHdkzUiDNZ1HXXjIvxa4LKYXHpEWagRz2WPlSDeF4I8MrQg0kPELi13cpWYK w6vA== X-Gm-Message-State: ALoCoQn3EwQvSwZh/hBjyTVKbvkMR/hJ5zlj2GhFQYwfYJ1WzCE8957a5ZowE9POFU7TIEIadS+t X-Received: by 10.236.16.165 with SMTP id h25mr17738192yhh.30.1409628657060; Mon, 01 Sep 2014 20:30:57 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.39.10 with SMTP id u10ls2279404qgu.64.gmail; Mon, 01 Sep 2014 20:30:57 -0700 (PDT) X-Received: by 10.52.136.196 with SMTP id qc4mr23710146vdb.22.1409628656975; Mon, 01 Sep 2014 20:30:56 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id vp6si1769003vdc.5.2014.09.01.20.30.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Sep 2014 20:30:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id la4so6357748vcb.37 for ; Mon, 01 Sep 2014 20:30:56 -0700 (PDT) X-Received: by 10.220.114.5 with SMTP id c5mr26601127vcq.28.1409628656888; Mon, 01 Sep 2014 20:30:56 -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 uj3csp465340vcb; Mon, 1 Sep 2014 20:30:56 -0700 (PDT) X-Received: by 10.66.66.198 with SMTP id h6mr43083619pat.72.1409628656052; Mon, 01 Sep 2014 20:30:56 -0700 (PDT) Received: from Kraken ([124.219.7.128]) by mx.google.com with ESMTP id qe5si3895888pbc.29.2014.09.01.20.30.54 for ; Mon, 01 Sep 2014 20:30:56 -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 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 Cc: lars@metafoo.de, ckeepax@opensource.wolfsonmicro.com, Xavier Hsu , Andy Green Subject: [PATCHv3 5/9] Using the constraint based on wm8971_set_dai_sysclk 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> 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.178 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,