Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753785AbdCOLnz (ORCPT ); Wed, 15 Mar 2017 07:43:55 -0400 Received: from mail-eopbgr00058.outbound.protection.outlook.com ([40.107.0.58]:29828 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753756AbdCOLn2 (ORCPT ); Wed, 15 Mar 2017 07:43:28 -0400 From: Daniel Baluta To: "ckeepax@opensource.wolfsonmicro.com" , "broonie@kernel.org" CC: "linux-kernel@vger.kernel.org" , "shengjiu.wang@freescale.com" , "patches@opensource.wolfsonmicro.com" , "tiwai@suse.com" , "lgirdwood@gmail.com" , Viorel Suman , Mihai Serban , "alsa-devel@alsa-project.org" Subject: Re: [RFC PATCH] ASoC: wm8960: Use physical width for bclk Thread-Topic: [RFC PATCH] ASoC: wm8960: Use physical width for bclk Thread-Index: AQHSnW0Qv8UXuLdGukWrWIoVae3ckqGVx9mA Date: Wed, 15 Mar 2017 11:43:24 +0000 Message-ID: <1489578203.15165.46.camel@nxp.com> References: <1489510622-30981-1-git-send-email-daniel.baluta@nxp.com> <20170315091901.GF6986@localhost.localdomain> In-Reply-To: <20170315091901.GF6986@localhost.localdomain> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: opensource.wolfsonmicro.com; dkim=none (message not signed) header.d=none;opensource.wolfsonmicro.com; dmarc=none action=none header.from=nxp.com; x-originating-ip: [192.88.146.1] x-ms-office365-filtering-correlation-id: f9dc5122-e02a-4b54-1f52-08d46b987d13 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(48565401081);SRVR:AM3PR04MB1204; x-microsoft-exchange-diagnostics: 1;AM3PR04MB1204;7:E/rFKF1jWDrB5v20jWo+ZQa9IwJNoXlI4d19c1XLJ+2LzGI2YEt0JWiy9oJHfzAtFzSmjuIMlNBnn6oW0N/Fw5w839KLlLPgfNU3FZeYXDfjxmg9Z5hH2QbpZISQAFgP5BlgFFN6AxzmDXIcG5CEmxD6L8xpwKLvRUhfufJbaNsLPU/Hx8p0c0JzdsOXoMw/iIKU5Q58tlRhg5A9PkkVVAFBdGBhMVhX751LUNgMesljMSISCh0e/INHmE1Unf63UGVRkefwXZmvbjHVZctO8gvpqDJpByi9rrGAyNEso5Wg+EIrCqM9Pei36Cri53uHSnv6+5miCss+pPXl38cavQ== x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(185117386973197); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6041248)(20161123564025)(20161123560025)(20161123555025)(20161123558025)(20161123562025)(6072148);SRVR:AM3PR04MB1204;BCL:0;PCL:0;RULEID:;SRVR:AM3PR04MB1204; x-forefront-prvs: 02475B2A01 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(39860400002)(39850400002)(39410400002)(39840400002)(39450400003)(377424004)(24454002)(3280700002)(4326008)(7736002)(3660700001)(2950100002)(305945005)(33646002)(229853002)(103116003)(36756003)(2900100001)(8936002)(2501003)(5250100002)(1720100001)(39060400002)(189998001)(5660300001)(6512007)(54906002)(6306002)(54356999)(50986999)(76176999)(53936002)(6436002)(6116002)(99286003)(3846002)(6506006)(102836003)(2906002)(86362001)(6486002)(575784001)(966004)(66066001)(6246003)(38730400002)(53376002)(8676002)(81166006)(10126625002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM3PR04MB1204;H:AM3PR04MB500.eurprd04.prod.outlook.com;FPR:;SPF:None;MLV:ovrnspm;PTR:InfoNoRecords;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" Content-ID: MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Mar 2017 11:43:24.2595 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR04MB1204 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id v2FBi3Mw008289 Content-Length: 1962 Lines: 49 On Mi, 2017-03-15 at 09:19 +0000, Charles Keepax wrote: > On Tue, Mar 14, 2017 at 06:57:02PM +0200, Daniel Baluta wrote: > > > > bclk is derived from sysclk with the help of bclk_divs. Anyhow, for > > S20_3LE format there is no bclk_divs that could be used to derive > > an exact bclk. > > > > We can fix this by using storage size instead the exact > > number of bits of the sample when computing bclk. > > > > With this approach we can play S20_3LE encoded files at the cost of > > some unused BCLK cycles for S20_3LE and S24_LE. > > > > Signed-off-by: Daniel Baluta > > --- > >  sound/soc/codecs/wm8960.c | 3 ++- > >  1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c > > index e1429e3..18ca5fc 100644 > > --- a/sound/soc/codecs/wm8960.c > > +++ b/sound/soc/codecs/wm8960.c > > @@ -722,7 +722,8 @@ static int wm8960_hw_params(struct > > snd_pcm_substream *substream, > >   bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; > >   int i; > >   > > - wm8960->bclk = snd_soc_params_to_bclk(params); > > + wm8960->bclk = params_physical_width(params) * > > + params_channels(params) * params_rate(params); > >   if (params_channels(params) == 1) > >   wm8960->bclk *= 2; > Would quite like to see Mark's thoughts on this. Feels a bit to > me (although I am not certain) like we are solving the problem in > the wrong place, isn't this really setting the desired BCLK and > then in wm8960_configure_clocking we should set the lowest BCLK > we can that is greater than or equal to the desired. Is there any standard way of doing this in ASoC? Couldn't find any example where the bitclk is relaxed to lowest value greater than the desired one. I have prepared some patches with this approach, you can look at them here: http://pastebin.com/0xW0E82N - some refactoring of sysclk search http://pastebin.com/QRt1UT7Q - relax bitclk value Daniel.