From patchwork Thu Apr 6 11:51:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Baluta X-Patchwork-Id: 9666921 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BCCDE601EB for ; Thu, 6 Apr 2017 11:52:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9D89283F4 for ; Thu, 6 Apr 2017 11:52:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D9D928533; Thu, 6 Apr 2017 11:52:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE84C283F4 for ; Thu, 6 Apr 2017 11:52:51 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 5CD902672C1; Thu, 6 Apr 2017 13:52:20 +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 E1D3B2672BB; Thu, 6 Apr 2017 13:52:16 +0200 (CEST) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50065.outbound.protection.outlook.com [40.107.5.65]) by alsa0.perex.cz (Postfix) with ESMTP id AF0E92672B9 for ; Thu, 6 Apr 2017 13:52:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=vCOX8cObntkXD+zLXzc7KTo6Un4voot3z8EBRIzhbDo=; b=IPCHh9cXEh/+UorKT3xYGh5ghjxW0KctGSQMd/YMhj1iNuO1lPGoT69l3/eAl6jlPq10VwYr++Xvfl6swwQavMX8/BNYfgF2ED9/yyGv2xG4r8XJo9dzG7AqrMIdN9TVN5+G0SAQHLQepzJvMpzYpYFYgsQe2GMDBH/ZTbj0BSk= Authentication-Results: alsa-project.org; dkim=none (message not signed) header.d=none; alsa-project.org; dmarc=none action=none header.from=nxp.com; Received: from fsr-ub1664-118.ea.freescale.net (192.88.146.1) by DBXPR04MB511.eurprd04.prod.outlook.com (10.141.233.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.991.14; Thu, 6 Apr 2017 11:52:04 +0000 From: Daniel Baluta To: Date: Thu, 6 Apr 2017 14:51:54 +0300 Message-ID: <1491479514-24862-3-git-send-email-daniel.baluta@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491479514-24862-1-git-send-email-daniel.baluta@nxp.com> References: <1491479514-24862-1-git-send-email-daniel.baluta@nxp.com> MIME-Version: 1.0 X-Originating-IP: [192.88.146.1] X-ClientProxiedBy: AM4PR0202CA0023.eurprd02.prod.outlook.com (10.171.80.33) To DBXPR04MB511.eurprd04.prod.outlook.com (10.141.233.16) X-MS-Office365-Filtering-Correlation-Id: c3dc2106-d9d8-42ef-487d-08d47ce358e9 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(201703131423075)(201703031133081); SRVR:DBXPR04MB511; X-Microsoft-Exchange-Diagnostics: 1; DBXPR04MB511; 3:o5YPpoBkTr6vDwD0XLERf2ZlemqYgHw7FMFUCj2/Rajtsqd6v+AcOLy176KBUWk/QqMQgsZ93UE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koqdmCa+FK0wOgvr+uu9xawiR6W0D3eprks+gJB77tbh+142Qauv5hN1YrI8Gpa6HLceBI6ibDjNfh4He1dvcMHnDfD9Sd52kYCCwwS+ROn/PECPv8BKaZKsDUGI4kzgVc/9AoiSnfGL1FtNw1eP4UOFnNEY6MPHENxgvfU5ez3WQRuOqbDHbdCsj4hmV32ImVRWj0b0HGcbBVsit/hkF4WT4f6gXKO5ha+VTUzKT8gIsVwsTSKNm83piMvBOj9wLRiHpJfVaeRTveXJVQqcVUBePhjqp+aBZ1+v/IHxRqUUJ/Z6biJbwUM12A49vzeKS4rq5C18IaKhiHdboJHNNcNTbpUROoTkzw8c7WuY5o5/LllSQJnBxBlUjxs1jwoUMYuu4T2k76+CH23ophiMqzPOmNZRV+VmmuFGBGiAKShwRY1m9MKTztq/ZgQzBsf3BUWove6VpSL5mQYTx/ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(10201501046)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(20161123555025)(20161123562025)(20161123564025)(20161123560025)(6072148); SRVR:DBXPR04MB511; BCL:0; PCL:0; RULEID:; SRVR:DBXPR04MB511; X-Microsoft-Exchange-Diagnostics: 1; DBXPR04MB511; 4:n72zBJO9+o3xwdKalNwkNemFWaiIhUsBH5a16VZgmUQgW8ukg39am+vFGhzS3dZ0eLVJhqoS5KlX3Y87mYNU19iiCD/YOlpXZ3ahx1Of58rOHX9Fx1gpSPKL3XnPkzikDaLVkhshwuf3l6lfE7iqq+nYAYSCukmfqYooQ5c6RdcBGngU0diqcVVHzknhk0++GpjOIIXU5Yrhii4G55LxKOuluJ7FUxKwq1lCmC8j516goQwDwV3ybYN0H1CLTISOZO5GCwURLes6th9AVkPApYWvbGeeYQEsn5AXgbF5ri+p+M1UPN5jfu9u3KpK65knk15GswlYdRP58lrXQ+aPRkS2j1jjII0BHKWe1/BG/SFaxWnYFSzExUnz2/8sxVAzYGYDRHqU5yNDp/rtal2aDH2r86zNPtnCpFLSVTKlTFS8rZmrB/1o81u7w5AIjpNV29RMs2vqk/2HygRxtDcEGhMuw5xArR8D+MMnvX/ghvyqK34VrGVUf0MRZZBYbM7QmVaQFG9aGC3cLMhVg3y/QhEPLx86pexPdTrf5/u6sSqWzfVWA0zILpoz514XJdOJm5vs241BZIvn672kA6fVOn45GkXw1WBXBkkJqw31X63zv9mW4bK9ytxihJ1eNleD4Y0AKb9FexoJElQF2gkIYZIImlFAG0gDFxSAL2jS7tDUceRG4U8Ccq9j+pWQP1XXC7LYxWsEQrX4omiic9/uCdAm3izuYrf5cg246T9DKZ0KL3kd6SC/LyKtOnBw3u4o3WwCbyrmS3mPVKAjKv+x/Q== X-Forefront-PRVS: 02698DF457 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39840400002)(39860400002)(39410400002)(39400400002)(39850400002)(39450400003)(86362001)(54906002)(7736002)(2351001)(110136004)(6506006)(3846002)(6116002)(5003940100001)(50226002)(33646002)(8676002)(53936002)(6512007)(305945005)(575784001)(81166006)(42186005)(38730400002)(36756003)(189998001)(50986999)(6666003)(4326008)(6486002)(5660300001)(25786009)(76176999)(2906002)(66066001)(47776003)(6916009)(2950100002)(48376002); DIR:OUT; SFP:1101; SCL:1; SRVR:DBXPR04MB511; H:fsr-ub1664-118.ea.freescale.net; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DBXPR04MB511; 23:cpX4aHbmL5FPGwF6O7Z7ZCGNbI5DXBf/BsN5cfp2bN?= =?us-ascii?Q?PITU4ga0pmfQr3qfu38/XwP2gwAru7W522I45znmGBoFh0QZXThojc5VQ7VD?= =?us-ascii?Q?xwFnZaK7CRIxfLVMzR08t80K75vS/o52e+IZ2m1dy4ZQVTNPSLitUfzJybcs?= =?us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xsU97Qy+I7I5bl4jivqPkdUGRjE5ShkCTQCeqthhvSB?= =?us-ascii?Q?am75wD/TNpGRo/ZccWWXpjfp59?= X-Microsoft-Exchange-Diagnostics: 1; DBXPR04MB511; 6:aykabNNp2J5Dv475ox8PBmYM3rgNk3Xzz1Y+4Zf5aPAB7PGFoF3V6r50HM5xoqo97lFu43XVQyfWPKhe9qbJBr6bIF88CwHryb/c44NOz2+LHdE/Phs+zGhz1bu/6p11nJ9aXheZ5tietvgineIRWSGkvaO3xlRYySQ/Ov7P0W0J/8IlrWbJ6y4LtGcQTqoGZFSNKYjNXK9/QPXT6NMPUhum2Ac9jjTjN8xnA6HfSPsUF+q/qN/G+X0aeGav1aJ02uC4d8NTfxVsFNQurW7cBeHcnBTFMuMtC2Q22QakQWS0COk39naC8czWBzlFI7SxGh5cpklYqo8HAWppGO614rOnidnSe6xhikJJM8wOtZ9D6n+XgqXfQwpBPu+DhxCGMfT9DLIsCgqUgTNZVbvndmOsur4KvCMAytH7qRcd3t8=; 5:XlHuEzNg4m5xjvZS/Z2s1JYKhubE/J5hhm9ph6yR3C95L5uku3aACt90hbl/0tEwwHKeK3OGKjMIcUuVRf8ar2/ypfGUyX/Uu6i4JrsO/MexzfuVarnw5RtRpMdJkhYoD24LZu9ag9MDrNCb2VHAlQ==; 24:uJWIhWECxug9ZTxqjD6W7lnDsSICf1geXcpeJRaPpVuMnA1KXihROLMM1ShBrg4eny67Dma3PTngaTbTdvy1Dfu7mHFskMQLa0+FksJqrdk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DBXPR04MB511; 7:tuN12aaXTxtlJIt0iM5W93l0SzI/jZwjPdP+diF1SzauizAe9UzLz95KHJiXgNVrCMY/cmGJw3kMrvRzMKq9u8oLkC5miBlSLuGSRMbCBgV2Bu4cCwJRu/tbofKTnGz53sS/QCPGwzCUkGUe8lxH286QPUKNgHq/0q9zo7bGvtsvlT0QEt4W7Qf7VL/+Z06Do1Mu2kNRCrZz0OAC1iYLZPkSb8Df6bjxO7+5pBL1xd+aaM4Y3DcMMoBFBGCXAVzxOfJbjhKAZMJD1Mm0EeXRoGkIhSRfjbsWtuWEXS8kOfF25PIZI2nqXYCJMs403XZ8WTuX3hLgedhh0ZRwNdKlkg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2017 11:52:04.8399 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBXPR04MB511 Cc: lgirdwood@gmail.com, shengjiu.wang@nxp.com, patches@opensource.wolfsonmicro.com, linux-kernel@vger.kernel.org, tiwai@suse.com, broonie@kernel.org, viorel.suman@nxp.com, mihai.serban@nxp.com, ckeepax@opensource.wolfsonmicro.com Subject: [alsa-devel] [PATCH 2/2] ASoC: codec: wm8960: Relax bit clock computation when using PLL 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Bitclk is derived from sysclk using bclk_divs. Sysclk can be derived in two ways: (1) directly from MLCK (2) MCLK via PLL Commit 3c01b9ee2ab9d0d ("ASoC: codec: wm8960: Relax bit clock computation") relaxed bitclk computation when sysclk is directly derived from MCLK. Lets do the same thing when sysclk is derived via PLL. Signed-off-by: Daniel Baluta Acked-by: Charles Keepax --- sound/soc/codecs/wm8960.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c index ace69da..8ab9fa2 100644 --- a/sound/soc/codecs/wm8960.c +++ b/sound/soc/codecs/wm8960.c @@ -679,6 +679,10 @@ int wm8960_configure_sysclk(struct wm8960_priv *wm8960, int mclk, * - freq_out = sysclk * sysclk_divs * - 10 * sysclk = bclk * bclk_divs * + * If we cannot find an exact match for (sysclk, lrclk, bclk) + * triplet, we relax the bclk such that bclk is chosen as the + * closest available frequency greater than expected bclk. + * * @codec: codec structure * @freq_in: input frequency used to derive freq out via PLL * @sysclk_idx: sysclk_divs index for found sysclk @@ -696,13 +700,14 @@ int wm8960_configure_pll(struct snd_soc_codec *codec, int freq_in, { struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); int sysclk, bclk, lrclk, freq_out; - int diff, best_freq_out; + int diff, closest, best_freq_out = 0; int i, j, k; bclk = wm8960->bclk; lrclk = wm8960->lrclk; + closest = freq_in; - *bclk_idx = -1; + *bclk_idx = *dac_idx = *sysclk_idx = -1; for (i = 0; i < ARRAY_SIZE(sysclk_divs); ++i) { if (sysclk_divs[i] == -1) @@ -723,6 +728,13 @@ int wm8960_configure_pll(struct snd_soc_codec *codec, int freq_in, best_freq_out = freq_out; break; } + if (diff > 0 && closest > diff) { + *sysclk_idx = i; + *dac_idx = j; + *bclk_idx = k; + closest = diff; + best_freq_out = freq_out; + } } if (k != ARRAY_SIZE(bclk_divs)) break;