Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3988539yba; Wed, 17 Apr 2019 02:05:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqxPdOyPcrDZUZCu6kAzmkcbMJJMrVrICLZmTdg+ZKiISOInRPN89pCA9KXMgqUR+oTX914l X-Received: by 2002:a17:902:8a8b:: with SMTP id p11mr87518891plo.227.1555491952680; Wed, 17 Apr 2019 02:05:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555491952; cv=none; d=google.com; s=arc-20160816; b=nfFo/YYabdT50DTSrpaRm1jhhYx6U3VzABye+BYr52i3i3X3DLh+nrsPVi5HloaP07 VN0e32K4c1vk7AKygB6gr81daJvD849PFY5YPsoWKH+O/L6d/HLQdTChm9s2OcVJ/poJ +SWxGpNAB32Pz0wvh3InXTSUDZDDyw3NonUaUsQBA5FS+DYgX1rbDAlMxZ7ZzDWpu8AN rM3MiJpxamuL4Xwa8aRnHV1huGOHY/89FeAzkzMUk7OV+W+oJowT8AsaWpQKauh4wDE7 nySE0KvSBp50e3Ay1N0n5nXZ4YQnC3K1X816la9pS5cL8+lJwkmDL8aitA8RS7NaOsNc x/KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature; bh=fwjob00YzK3C4sOi8ZTHvHprXhem2LA70B5tKlraN4w=; b=LDxQ3CqyXLbdyJZoyj2y4ptJ2ML01MzgeKkz4OKKgvGCsz3mhVpFwy6CwLNi7H3H6C MnxiFwgfWgfnG9zzQn9B+81vvYEq3KXMWlNHlV5E9aJO5RxRZpjUNfUy6TPAgKXDSNRm dv7rdv5uCY/QAG2uclNoMDkknXrvCPHK+/haPMU2Xs6bn9Oh2rxgUxO04QaTLM78Fu7m bLvxsh1Dw3Xg3q865+pIecBOGCT31EnYLdYaclLce/5aAasaSdUt1kw50DyzGB7vJ5TJ ulRt7pYdKGi4sC41h+HylmaChtZ0HYnrZvuzL4ZiDX/c2k9Iyeru2mwYVwX0ZD4JmHvj zqFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b=knZ9o+0b; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e184si44057065pfe.118.2019.04.17.02.05.37; Wed, 17 Apr 2019 02:05:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b=knZ9o+0b; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731412AbfDQJEH (ORCPT + 99 others); Wed, 17 Apr 2019 05:04:07 -0400 Received: from mail-eopbgr10058.outbound.protection.outlook.com ([40.107.1.58]:22752 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728446AbfDQJEG (ORCPT ); Wed, 17 Apr 2019 05:04:06 -0400 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:X-MS-Exchange-SenderADCheck; bh=fwjob00YzK3C4sOi8ZTHvHprXhem2LA70B5tKlraN4w=; b=knZ9o+0bic10Cuzbs6aFDZ4o0E0w3Eq3tdwVaR6A/FYSJBFEErVYqlI5wOOE4t+NA8ZbjmNDFEK1133PDbnjZLWrsLN7WugIYG6jXCejd6bjuLMYaCZlOQT2+p7UKhfVkkhteQlws+pqj05VLwCsyd7BUMJPTPW+iFqrC2ZwIeM= Received: from VE1PR04MB6479.eurprd04.prod.outlook.com (20.179.233.80) by VE1PR04MB6431.eurprd04.prod.outlook.com (20.179.232.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1792.17; Wed, 17 Apr 2019 09:04:01 +0000 Received: from VE1PR04MB6479.eurprd04.prod.outlook.com ([fe80::6c03:86ad:729d:e311]) by VE1PR04MB6479.eurprd04.prod.outlook.com ([fe80::6c03:86ad:729d:e311%7]) with mapi id 15.20.1792.018; Wed, 17 Apr 2019 09:04:01 +0000 From: "S.j. Wang" To: Nicolin Chen CC: "timur@kernel.org" , "Xiubo.Lee@gmail.com" , "festevam@gmail.com" , "broonie@kernel.org" , "alsa-devel@alsa-project.org" , "linuxppc-dev@lists.ozlabs.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH V2 1/2] ASoC: fsl_asrc: replace the process_option table with function Thread-Topic: [PATCH V2 1/2] ASoC: fsl_asrc: replace the process_option table with function Thread-Index: AdT0/GcG100TVa/MRHKfxlkKyc55XQ== Date: Wed, 17 Apr 2019 09:04:01 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=shengjiu.wang@nxp.com; x-originating-ip: [92.121.36.197] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 5e61cf4a-46e4-40d0-56e2-08d6c313a281 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600140)(711020)(4605104)(4618075)(2017052603328)(7193020);SRVR:VE1PR04MB6431; x-ms-traffictypediagnostic: VE1PR04MB6431: x-microsoft-antispam-prvs: x-forefront-prvs: 0010D93EFE x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(979002)(136003)(366004)(396003)(346002)(39860400002)(376002)(199004)(189003)(102836004)(8936002)(81156014)(81166006)(26005)(68736007)(486006)(186003)(8676002)(14454004)(476003)(86362001)(74316002)(5660300002)(97736004)(52536014)(71190400001)(71200400001)(2906002)(7736002)(305945005)(6116002)(25786009)(3846002)(6506007)(316002)(6436002)(4326008)(33656002)(256004)(54906003)(229853002)(6916009)(7696005)(1411001)(99286004)(6246003)(9686003)(55016002)(106356001)(66066001)(53936002)(105586002)(478600001)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:VE1PR04MB6431;H:VE1PR04MB6479.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: BGeDk0WtkgJGtj10SgrE/dGsE5K5h0kdsTVt2k9PoRpIsZals+W/CbmwZUjZN8/7cU1F/20YLAAys2hWCSwEaoeMGxOxU7xNsUJLKMqrXgdqAwS2bbWCpudvpmYuZjYMa6BXkiG7mLgj+MxxqcXYbqUJKw05Lnd2Y3jph2l9gcYgmh2NntFf62JWObvo1UxbGHbHa1ho2dR6FNLRbMzIzgFzY4VClD/75BZc+tG4lOczL8CzArifMyHjs+wyInqlmr26WYJGfxUI62d6Qnade3YXUbRbXxuspX5qlit7evNVKyB3jyu31fzVn6KlelNalacHoJYjKFc/yTrWuSr6p0ItM+MhZYyed8rE1jcz0QkQ7G6J6KdvP1bBWWBjm/DrbSLeINuDdJ2xpAcogRAn7i+0c4iX18XurHwTKWV+sUc= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e61cf4a-46e4-40d0-56e2-08d6c313a281 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Apr 2019 09:04:01.6423 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6431 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi >=20 >=20 > On Thu, Apr 11, 2019 at 09:39:06AM +0000, S.j. Wang wrote: >=20 > > +/* > > + * Select the pre-processing and post-processing options >=20 > By aligning with other function comments: > /** > * Select the pre-processing and post-processing options >=20 > > + * > > + * Fsin: input sample rate > > + * Fsout: output sample rate >=20 > I would suggest to use inrate and outrate to keep naming consistent. >=20 > > + * pre_proc: return value for pre-processing option > > + * post_proc: return value for post-processing option */ static int > > +fsl_asrc_sel_proc(int Fsin, int Fsout, int *pre_proc, int *post_proc) > > +{ > > + bool det_out_op2_cond; > > + bool det_out_op0_cond; >=20 > By looking at the comments below. Probably better to rename them > bool post_proc_cond2, post_proc_cond0; >=20 > > + /* Codition for selection of post-processing */ >=20 > "Codition" -> "Conditions" >=20 > > + det_out_op2_cond =3D (((Fsin * 15 > Fsout * 16) & (Fsout < 56000)= ) | > > + ((Fsin > 56000) & (Fsout < > > + 56000))); >=20 > Combining Daniel's comments + indentation alignment: > det_out_op2_cond =3D (Fsin * 15 > Fsout * 16 && Fsout < 56000) || > (Fsin > 56000 && Fsout < 56000); >=20 > > + det_out_op0_cond =3D (Fsin * 23 < Fsout * 8); > > + > > + /* > > + * unsupported case: Tsout>16.125*Tsin, and Tsout>8.125*Tsin. >=20 > Funny thing is that there'd be no point in checking the 16.125, if Tsout = is > bigger than 8.125 times of Tsin, i.e. only one condition: > Tsout > 8.125 * Tsin >=20 > > + * Tsout>16.125*Tsin -> Fsin * 8 > 129 * Fsout > > + * Tsout>8.125*Tsin -> Fsin * 8 > 65 * Fsout > > + * Tsout>4.125*Tsin -> Fsin * 8 > 33 * Fsout > > + * Tsout>1.875*Tsin -> Fsin * 8 > 15 * Fsout >=20 > Took me a while to understand what it is saying.... >=20 > Better to write like this: > /* Does not support cases: Tsout > 8.125 * Tsin */ > if (Fsin * 8 > 65 * Fsout) { > pair_err("Does not support %d > 8.125 * %d\n", Fsout, Fsi= n); > return -EINVAL; > } >=20 > /* Otherwise, select pre_proc between [0, 2] */ > if (Fsin * 8 > 33 * Fsout) > > + *pre_proc =3D 2; > > + else if (Fsin * 8 > 15 * Fsout) { > > + if (Fsin > 152000) > > + *pre_proc =3D 2; > > + else > > + *pre_proc =3D 1; > > + } else if (Fsin < 76000) > > + *pre_proc =3D 0; > > + else if (Fsin > 152000) > > + *pre_proc =3D 2; > > + else > > + *pre_proc =3D 1; >=20 > <=3D=3D Would look better by moving post_cond calculations here. >=20 > > + if (det_out_op2_cond) > > + *post_proc =3D 2; > > + else if (det_out_op0_cond) > > + *post_proc =3D 0; > > + else > > + *post_proc =3D 1; >=20 > And we could remove this check below: > > + /* unsupported options */ > > + if (*pre_proc =3D=3D 4 || *pre_proc =3D=3D 5) > > + return -EINVAL; >=20 > So basically we are doing: > 1) Error out unsupported cases > 2) Select pre_proc > 3) Calculate conditions for post_proc > 4) Select post_proc >=20 > Thanks Thanks for reviewing, will send v3.