Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932213AbdDDQpr (ORCPT ); Tue, 4 Apr 2017 12:45:47 -0400 Received: from mail-ve1eur01on0080.outbound.protection.outlook.com ([104.47.1.80]:20992 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932072AbdDDQpa (ORCPT ); Tue, 4 Apr 2017 12:45:30 -0400 Authentication-Results: alsa-project.org; dkim=none (message not signed) header.d=none;alsa-project.org; dmarc=none action=none header.from=nxp.com; From: Daniel Baluta To: CC: , , , , , , , , , Subject: [PATCH 2/2] ASoC: codec: wm8960: Relax bit clock computation when using PLL Date: Tue, 4 Apr 2017 19:45:14 +0300 Message-ID: <1491324314-27067-3-git-send-email-daniel.baluta@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491324314-27067-1-git-send-email-daniel.baluta@nxp.com> References: <1491324314-27067-1-git-send-email-daniel.baluta@nxp.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [192.88.146.1] X-ClientProxiedBy: VI1PR09CA0066.eurprd09.prod.outlook.com (2603:10a6:802:28::34) To DB4PR04MB506.eurprd04.prod.outlook.com (2a01:111:e400:983a::14) X-MS-Office365-Filtering-Correlation-Id: 8c6c7991-b820-41c5-7311-08d47b79feae X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(48565401081)(201703131423075)(201703031133081);SRVR:DB4PR04MB506; X-Microsoft-Exchange-Diagnostics: 1;DB4PR04MB506;3:qvx0SXYaQmMVMIb4J9sch7QOA7QTEK0nqVTh2FUG65gHjzFR4jjAXHk2ZpVNPJyrfeuLg4DTV0tCY0Umj96uqAdgd4Y95p+BmkcuBZzgcK0sTPk90pfv9qCMv4/DeEBI94tXHlmTpLB4w9VpiRVt5lHCNxED5SQ+HriOxNgaWDPiLfLQYw99X5vBs833IaA/KwpCX+nrgX1Gx6+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LJo/PX60AYEsi/z6dFQUoE2w8yrCeTvXSXUwOHeyiGMu9vYAw3Zf6lKCE9IXQfVIAsSqXxH7PkeGiSCGgMYjhLxar268NJ6uJt7EPQrkX+6XWDv2sqzbNnvUlgbPXdVG0J7YE37tnjEb2491He2aVHhq+Ri4DzDULWo6RxwfwrGjClIHvO84azoTSsvms5T5DL2fUezSyN9eHvafuMsMB1B3Bf0E3Kkum+vExHZZ4KqlyDYEMe9uv82bANy0783+saTvuWOMGHQW6c6d9w2qgt3ZFOZ1ttO05p5TR5scPb3/i/LKTrfePykytGw34j1sWI/wYpSBZ1VTpnWkGaCoODpbn71GKd4o4pT1+EQfQ7BP+dTM7+Lm9n/iPLKFYJ3W 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)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(20161123560025)(20161123564025)(6072148);SRVR:DB4PR04MB506;BCL:0;PCL:0;RULEID:;SRVR:DB4PR04MB506; X-Microsoft-Exchange-Diagnostics: 1;DB4PR04MB506;4:ztQaCnO2tL34uCRWV41ie8cfeQkjAZ2aVSRHpth1xXO7RAAQUQvudvOmRFynLSWLun2FbRGy++pHj7PZI85aoKTMWtxGm/0cvHKQ1RqTTKPGiIJTF3UWuRx93q+GQY8m1PwFMuyNG2K2GI7SU+SMDT3H7T2fZ4/h5daFdNjA/KJeHo8hctKvBVPnouq3ofB2UC5es19skz3ci8e3dttFaztUxqPTCAkvfoCPmkK3zFAtg03e1HJzf0IIG9OfI0rsNJHoR4Riqdxa/LnSwSjAzrP8K63/thIN7RKvi0nrvIgTwYDA9NuYSzVoqjQwuELcwRbSmiNuN/FZX7bL+p5qo/CavBVrb/xnntPxnSilFLgWOXyz3P1expN9ibVVru+9FRgYWQSl9z2vdkDvq/kZTXatx/K4jw5Wluh83xdef51CKHuA3utXphRKTUE1bP7Cmzw/cXKpKiF+w43JL5GL6ZvKKCSmsvGFPV3CS2E+4AEWyYzAn5QVcagXk1zqwrCGI2nRgiCUyFH9GxfrRbz134DdIhO7a37DNXhQIRcRlENAn6za5Ry++icyWUge4JRpHXQYb/DnQRtdAKx1hYEX76WcW7Ulv5s4zmp3bu3saMh2pnvUA5FAF9gvcCTb43lx7qWBSmYDsxymoAh5mBfXo6/Bb05qKJIexJyjjU4w3aEVZx7nz2OcLI181Uku0e5+O3Y1JkQAjyvHFXj5dRevgIHHWfQCv0LF8euAUKArbgyIjUyQYJEjz20s9JwzDa8kh7HBW0RSmSdC2rMA0Bpwmg== X-Forefront-PRVS: 0267E514F9 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(39410400002)(39850400002)(39400400002)(39840400002)(39860400002)(39450400003)(5660300001)(66066001)(50226002)(6486002)(2906002)(6506006)(6116002)(54906002)(53936002)(36756003)(25786009)(305945005)(47776003)(6512007)(50986999)(76176999)(50466002)(5003940100001)(48376002)(86362001)(575784001)(3846002)(38730400002)(81166006)(2351001)(8676002)(4326008)(42186005)(6916009)(2950100002)(110136004)(33646002)(189998001)(7736002)(6666003);DIR:OUT;SFP:1101;SCL:1;SRVR:DB4PR04MB506;H:fsr-ub1664-118.ea.freescale.net;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DB4PR04MB506;23:NI2QKdahqBhdBg7cJZ47+S35eLE7XhMSKz6DkABcUc?= =?us-ascii?Q?4qInOQIouPUZsO5vJ+1SLDahYgrSqCXIJj/7appn3wirL7UbN2Su5mr7qWbU?= =?us-ascii?Q?0s1RsNpLSovOWYBEkSz/CPDadm002Z0FG2ZPY41BR4ZK/lDOplKCI8PxbdxZ?= =?us-ascii?Q?Zj/so7W5bXaDTd5FQYdQ5mInl1e4CjQFIQTDzVp8OLqO3Wu0ildKy4OXR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JCHW2ObyAEUwAX2OJOrPHswanDazwYqdmEFOscJadInVxxDn3Ocb7pXljr7R1RahZvJTS1WFesyJnhtGcA97et0N8Mg1YOk6vNXmoGLTy0jX+4Vp4pg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2017 16:45:24.8317 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR04MB506 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1840 Lines: 60 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 --- sound/soc/codecs/wm8960.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c index 36c8454..e8cb764 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,11 +700,12 @@ 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; int i, j, k; bclk = wm8960->bclk; lrclk = wm8960->lrclk; + closest = freq_in; *bclk_idx = -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; + } } } } -- 2.7.4