From patchwork Thu Apr 11 09:39:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shengjiu Wang X-Patchwork-Id: 10895525 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 04F4614DB for ; Thu, 11 Apr 2019 09:41:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E148A28CB4 for ; Thu, 11 Apr 2019 09:41:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4F2828CB7; Thu, 11 Apr 2019 09:41:00 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6EA3D28CB4 for ; Thu, 11 Apr 2019 09:40:59 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 07D43860; Thu, 11 Apr 2019 11:40:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 07D43860 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1554975657; bh=u+vD1Gfm88z93WKgRJ/2AG2UXC9P0+Ccp2yMvAJg11g=; h=From:To:Date:References:In-Reply-To:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=N6r1P6nlVPIWCn3PvFk+rdDo3KCOTUZjngr5QRpm/efQ5AnIihA2YhLzBjBRnuQbn eiegU8T08JdyfCTVjwXw1ffB43RPmnqZJA14vpS7jeLV63P7Skiio81l1rj6HMyo8f S5hJEBkfwOuKOfyRRQuOiGzflbkPwhJAedNqjqEI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id E013DF89712; Thu, 11 Apr 2019 11:39:13 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id C4816F89712; Thu, 11 Apr 2019 11:39:11 +0200 (CEST) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80083.outbound.protection.outlook.com [40.107.8.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id B2F77F89616 for ; Thu, 11 Apr 2019 11:39:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B2F77F89616 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="Ekcg+unx" 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=K/ZEuF4NtMLE4WQ0iZHgZeV/Kk2ouMUetAw4cIRRmSo=; b=Ekcg+unxzPz/F0OBnpdEasIYHY89I3207fpfxqxgprfhkfpxrRKsmn7vt987s4ekWrDZ1+6skM5ggPhDV7HWAIcB7XPNJbkisz8MoL6TMJYZnOPPXRa2URDEXUbQzKVwp1rUT3jiYgnTLpheRPcPIZUnNCBeKo7CdLgGCFgajVU= Received: from AM0PR04MB6468.eurprd04.prod.outlook.com (20.179.253.81) by AM0PR04MB5492.eurprd04.prod.outlook.com (20.178.115.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1792.17; Thu, 11 Apr 2019 09:39:06 +0000 Received: from AM0PR04MB6468.eurprd04.prod.outlook.com ([fe80::107:1bdc:981e:e292]) by AM0PR04MB6468.eurprd04.prod.outlook.com ([fe80::107:1bdc:981e:e292%4]) with mapi id 15.20.1792.009; Thu, 11 Apr 2019 09:39:06 +0000 From: "S.j. Wang" To: "timur@kernel.org" , "nicoleotsuka@gmail.com" , "Xiubo.Lee@gmail.com" , "festevam@gmail.com" , "broonie@kernel.org" , "alsa-devel@alsa-project.org" Thread-Topic: [PATCH V2 1/2] ASoC: fsl_asrc: replace the process_option table with function Thread-Index: AQHU8EpnMj7ynpC4/EOtw74lVQaA/A== Date: Thu, 11 Apr 2019 09:39:06 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 1.9.1 x-clientproxiedby: HK2PR02CA0160.apcprd02.prod.outlook.com (2603:1096:201:1f::20) To AM0PR04MB6468.eurprd04.prod.outlook.com (2603:10a6:208:16e::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=shengjiu.wang@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.66] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: fced1889-ff37-46c6-374a-08d6be618a0e x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600139)(711020)(4605104)(4618075)(2017052603328)(7193020); SRVR:AM0PR04MB5492; x-ms-traffictypediagnostic: AM0PR04MB5492: x-microsoft-antispam-prvs: x-forefront-prvs: 00046D390F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(136003)(366004)(376002)(39860400002)(396003)(189003)(199004)(52116002)(50226002)(36756003)(8936002)(2616005)(106356001)(476003)(6512007)(71190400001)(446003)(486006)(11346002)(66066001)(81166006)(81156014)(8676002)(118296001)(105586002)(14444005)(256004)(2201001)(68736007)(5660300002)(97736004)(6436002)(54906003)(14454004)(110136005)(6486002)(2906002)(86362001)(6116002)(3846002)(316002)(7736002)(305945005)(508600001)(2501003)(25786009)(102836004)(71200400001)(99286004)(186003)(26005)(76176011)(53936002)(386003)(4326008)(6506007); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR04MB5492; H:AM0PR04MB6468.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: l/j20L6f9M2d7NQR08UsZShDko+IKdsMzIuB5FZLePNGsJK+3/rlQoi8vGe3AUnYdxgwH014GgkRVzoWE+T6fIEaQGpq4rVtUQecsCQVbPmD/0QU/KmC0au3jD0ZMCQL1fN5mMZd+365Zvz5ijZ7dZKbuR+iTsCXIxnMRt/bKrQ7OAjAigsZpQrNQ0tDQ3jDdrwXEAAjPd9FbZjY9zdGubeCcCooomGFNMX7o4uE5jaN8bN7+AL2EszOHtEpqcLO1Q3D/UoUPlNpQpcxZYyUSaYLQWhlHwwMsA4YTRMgpmtyy8siXSnEUXQjVbweiHHW65uWd7qENZIJNNao6QMjyPpHhxvF0GyNHSaUcsd1hJewpsx6VSvAEAS7+ihP98fpzoG9g7cB2A0m2pvpep9ugW7flxjbJML8/FKTmJxdpHc= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fced1889-ff37-46c6-374a-08d6be618a0e X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Apr 2019 09:39:06.0909 (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: AM0PR04MB5492 Cc: "linuxppc-dev@lists.ozlabs.org" , "linux-kernel@vger.kernel.org" Subject: [alsa-devel] [PATCH V2 1/2] ASoC: fsl_asrc: replace the process_option table with function X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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" X-Virus-Scanned: ClamAV using ClamSMTP When we want to support more sample rate, for example 12kHz/24kHz we need update the process_option table, if we want to support more sample rate next time, the table need to be updated again. which is not flexible. We got a function fsl_asrc_sel_proc to replace the table, which can give the pre-processing and post-processing options according to the sample rate. Signed-off-by: Shengjiu Wang --- sound/soc/fsl/fsl_asrc.c | 87 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 67 insertions(+), 20 deletions(-) diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c index 0b937924d2e4..5857d383d962 100644 --- a/sound/soc/fsl/fsl_asrc.c +++ b/sound/soc/fsl/fsl_asrc.c @@ -26,24 +26,6 @@ #define pair_dbg(fmt, ...) \ dev_dbg(&asrc_priv->pdev->dev, "Pair %c: " fmt, 'A' + index, ##__VA_ARGS__) -/* Sample rates are aligned with that defined in pcm.h file */ -static const u8 process_option[][12][2] = { - /* 8kHz 11.025kHz 16kHz 22.05kHz 32kHz 44.1kHz 48kHz 64kHz 88.2kHz 96kHz 176kHz 192kHz */ - {{0, 1}, {0, 1}, {0, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},}, /* 5512Hz */ - {{0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},}, /* 8kHz */ - {{0, 2}, {0, 1}, {0, 1}, {0, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},}, /* 11025Hz */ - {{1, 2}, {0, 2}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},}, /* 16kHz */ - {{1, 2}, {1, 2}, {0, 2}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},}, /* 22050Hz */ - {{1, 2}, {2, 1}, {2, 1}, {0, 2}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 0}, {0, 0}, {0, 0},}, /* 32kHz */ - {{2, 2}, {2, 2}, {2, 1}, {2, 1}, {0, 2}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 0}, {0, 0},}, /* 44.1kHz */ - {{2, 2}, {2, 2}, {2, 1}, {2, 1}, {0, 2}, {0, 2}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 0}, {0, 0},}, /* 48kHz */ - {{2, 2}, {2, 2}, {2, 2}, {2, 1}, {1, 2}, {0, 2}, {0, 2}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 0},}, /* 64kHz */ - {{2, 2}, {2, 2}, {2, 2}, {2, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1},}, /* 88.2kHz */ - {{2, 2}, {2, 2}, {2, 2}, {2, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1},}, /* 96kHz */ - {{2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1},}, /* 176kHz */ - {{2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1},}, /* 192kHz */ -}; - /* Corresponding to process_option */ static int supported_input_rate[] = { 5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000, 64000, 88200, @@ -79,6 +61,63 @@ static unsigned char *clk_map[2]; +/* + * Select the pre-processing and post-processing options + * + * Fsin: input sample rate + * Fsout: output sample rate + * 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; + + /* Codition for selection of post-processing */ + det_out_op2_cond = (((Fsin * 15 > Fsout * 16) & (Fsout < 56000)) | + ((Fsin > 56000) & (Fsout < 56000))); + det_out_op0_cond = (Fsin * 23 < Fsout * 8); + + /* + * unsupported case: Tsout>16.125*Tsin, and Tsout>8.125*Tsin. + * 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 + */ + if (Fsin * 8 > 129 * Fsout) + *pre_proc = 5; + else if (Fsin * 8 > 65 * Fsout) + *pre_proc = 4; + else if (Fsin * 8 > 33 * Fsout) + *pre_proc = 2; + else if (Fsin * 8 > 15 * Fsout) { + if (Fsin > 152000) + *pre_proc = 2; + else + *pre_proc = 1; + } else if (Fsin < 76000) + *pre_proc = 0; + else if (Fsin > 152000) + *pre_proc = 2; + else + *pre_proc = 1; + + if (det_out_op2_cond) + *post_proc = 2; + else if (det_out_op0_cond) + *post_proc = 0; + else + *post_proc = 1; + + /* unsupported options */ + if (*pre_proc == 4 || *pre_proc == 5) + return -EINVAL; + + return 0; +} + /** * Request ASRC pair * @@ -239,8 +278,10 @@ static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair) u32 inrate, outrate, indiv, outdiv; u32 clk_index[2], div[2]; int in, out, channels; + int pre_proc, post_proc; struct clk *clk; bool ideal; + int ret; if (!config) { pair_err("invalid pair config\n"); @@ -289,6 +330,12 @@ static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair) return -EINVAL; } + ret = fsl_asrc_sel_proc(inrate, outrate, &pre_proc, &post_proc); + if (ret) { + pair_err("No supported pre-processing options\n"); + return ret; + } + /* Validate input and output clock sources */ clk_index[IN] = clk_map[IN][config->inclk]; clk_index[OUT] = clk_map[OUT][config->outclk]; @@ -380,8 +427,8 @@ static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair) /* Apply configurations for pre- and post-processing */ regmap_update_bits(asrc_priv->regmap, REG_ASRCFG, ASRCFG_PREMODi_MASK(index) | ASRCFG_POSTMODi_MASK(index), - ASRCFG_PREMOD(index, process_option[in][out][0]) | - ASRCFG_POSTMOD(index, process_option[in][out][1])); + ASRCFG_PREMOD(index, pre_proc) | + ASRCFG_POSTMOD(index, post_proc)); return fsl_asrc_set_ideal_ratio(pair, inrate, outrate); } From patchwork Thu Apr 11 09:39:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shengjiu Wang X-Patchwork-Id: 10895527 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9A97417E6 for ; Thu, 11 Apr 2019 09:41:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8264C28CAA for ; Thu, 11 Apr 2019 09:41:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 769AD28CB5; Thu, 11 Apr 2019 09:41:46 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B7FB628CAA for ; Thu, 11 Apr 2019 09:41:44 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0DD4086C; Thu, 11 Apr 2019 11:40:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0DD4086C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1554975703; bh=Bls28WvsAmsXjlWn69K3VzIJuNHboe7sHwzyEIEix8U=; h=From:To:Date:References:In-Reply-To:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=OYy4P1YWpZASYJ4WcZbffXJUib54woETevU0l/W6OjPuzH5vyy+sZiBD7mWpdPoJO 2wseo6mqGyFHTu7RGaRuMp7t0JV5SZsnFiOX3nrlE52Z+CC7FxF93Qj/qgW5UW/tzM 1bPmSKR45LL61FvXd147hq0A6w0mrXxFekg7dJ5E= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 4021FF8971B; Thu, 11 Apr 2019 11:39:17 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5CFA6F8971B; Thu, 11 Apr 2019 11:39:15 +0200 (CEST) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80042.outbound.protection.outlook.com [40.107.8.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 64EEEF8963E for ; Thu, 11 Apr 2019 11:39:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 64EEEF8963E Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="c4heea4F" 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=8+MVm1V/x7SJ5cLfhEfEx7/QOiK+PsRDP3DsTIHN3Qc=; b=c4heea4Ff+dNAAQrU6LnLq+BEWZ3epxMo2ERrFGFLL/H7/D3sGZZ/357uLUUZM9Kx5oTXKVP+Rg+9RiX4/Pj43A4HLdn4NVJq/SbzZJ2I3L5MJWpgZVHuvyiHgJpVwGkg3hXvAexk8Gv8sPAFVHA3h9osVVhRZeO+srtsIT6UP8= Received: from AM0PR04MB6468.eurprd04.prod.outlook.com (20.179.253.81) by AM0PR04MB5492.eurprd04.prod.outlook.com (20.178.115.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1792.17; Thu, 11 Apr 2019 09:39:09 +0000 Received: from AM0PR04MB6468.eurprd04.prod.outlook.com ([fe80::107:1bdc:981e:e292]) by AM0PR04MB6468.eurprd04.prod.outlook.com ([fe80::107:1bdc:981e:e292%4]) with mapi id 15.20.1792.009; Thu, 11 Apr 2019 09:39:09 +0000 From: "S.j. Wang" To: "timur@kernel.org" , "nicoleotsuka@gmail.com" , "Xiubo.Lee@gmail.com" , "festevam@gmail.com" , "broonie@kernel.org" , "alsa-devel@alsa-project.org" Thread-Topic: [PATCH V2 2/2] ASoC: fsl_asrc: Unify the supported input and output rate Thread-Index: AQHU8EppMuNFFQY80EyrmodXmkmWqQ== Date: Thu, 11 Apr 2019 09:39:09 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 1.9.1 x-clientproxiedby: HK2PR02CA0160.apcprd02.prod.outlook.com (2603:1096:201:1f::20) To AM0PR04MB6468.eurprd04.prod.outlook.com (2603:10a6:208:16e::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=shengjiu.wang@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.66] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 133b2430-25bb-4507-c514-08d6be618bf5 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600139)(711020)(4605104)(4618075)(2017052603328)(7193020); SRVR:AM0PR04MB5492; x-ms-traffictypediagnostic: AM0PR04MB5492: x-microsoft-antispam-prvs: x-forefront-prvs: 00046D390F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(136003)(366004)(376002)(39860400002)(396003)(189003)(199004)(52116002)(50226002)(36756003)(8936002)(2616005)(106356001)(476003)(6512007)(71190400001)(446003)(486006)(11346002)(66066001)(81166006)(81156014)(8676002)(118296001)(105586002)(14444005)(19627235002)(256004)(2201001)(68736007)(5660300002)(97736004)(6436002)(54906003)(14454004)(110136005)(6486002)(2906002)(86362001)(6116002)(3846002)(316002)(7736002)(305945005)(508600001)(2501003)(25786009)(102836004)(71200400001)(99286004)(186003)(26005)(76176011)(53936002)(386003)(4326008)(6506007); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR04MB5492; H:AM0PR04MB6468.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: gReJVSqXsyzAJBpaJ7aNzdhDQWVDJ/6rnJcLjoWz+h/P6LsiuV6w/rMHZpkKwWhwNHrMFjvQo7v4X0HDkrYY2YNK6l9cHCFVu+uFZMEHPk0/zJ9j97jmBlw8zhmH3t7Z6TwlWftbLXuniwczkpvvhOYG+waH5RMai+eBzaVDV7o0FRb39E6E74pqWdyvqaiVv2+Gpk4cYPJ22ADxTJM+Wbj60X9TBD3Dla/hOrc9ScJy2zrd98G3k4tL4m2LCT9tpBYx0EWhw/kick2zq72kAi+BvXZ8I8VxlgxxN4HAtUwKXMQmlmfAEWW4K3Lh3O1KOKwZbig8i3uGgSPFUcGwcEBrwbpu6rgQQxeTtEs50KAb3ZQzCtoRElPlQG+VVQlBop/imiHKzF+UXDchgGw23g9vyK/zpImJSjmU04saoIY= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 133b2430-25bb-4507-c514-08d6be618bf5 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Apr 2019 09:39:09.2441 (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: AM0PR04MB5492 Cc: "linuxppc-dev@lists.ozlabs.org" , "linux-kernel@vger.kernel.org" Subject: [alsa-devel] [PATCH V2 2/2] ASoC: fsl_asrc: Unify the supported input and output rate X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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" X-Virus-Scanned: ClamAV using ClamSMTP Unify the supported input and output rate, add the 12kHz/24kHz/128kHz to the support list Signed-off-by: Shengjiu Wang --- sound/soc/fsl/fsl_asrc.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c index 5857d383d962..44bcc4a7b23b 100644 --- a/sound/soc/fsl/fsl_asrc.c +++ b/sound/soc/fsl/fsl_asrc.c @@ -27,13 +27,14 @@ dev_dbg(&asrc_priv->pdev->dev, "Pair %c: " fmt, 'A' + index, ##__VA_ARGS__) /* Corresponding to process_option */ -static int supported_input_rate[] = { - 5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000, 64000, 88200, - 96000, 176400, 192000, +static unsigned int supported_asrc_rate[] = { + 5512, 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000, + 64000, 88200, 96000, 128000, 176400, 192000, }; -static int supported_asrc_rate[] = { - 8000, 11025, 16000, 22050, 32000, 44100, 48000, 64000, 88200, 96000, 176400, 192000, +static struct snd_pcm_hw_constraint_list fsl_asrc_rate_constraints = { + .count = ARRAY_SIZE(supported_asrc_rate), + .list = supported_asrc_rate, }; /** @@ -305,11 +306,11 @@ static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair) ideal = config->inclk == INCLK_NONE; /* Validate input and output sample rates */ - for (in = 0; in < ARRAY_SIZE(supported_input_rate); in++) - if (inrate == supported_input_rate[in]) + for (in = 0; in < ARRAY_SIZE(supported_asrc_rate); in++) + if (inrate == supported_asrc_rate[in]) break; - if (in == ARRAY_SIZE(supported_input_rate)) { + if (in == ARRAY_SIZE(supported_asrc_rate)) { pair_err("unsupported input sample rate: %dHz\n", inrate); return -EINVAL; } @@ -502,7 +503,9 @@ static int fsl_asrc_dai_startup(struct snd_pcm_substream *substream, snd_pcm_hw_constraint_step(substream->runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 2); - return 0; + + return snd_pcm_hw_constraint_list(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, &fsl_asrc_rate_constraints); } static int fsl_asrc_dai_hw_params(struct snd_pcm_substream *substream, @@ -626,14 +629,18 @@ static int fsl_asrc_dai_probe(struct snd_soc_dai *dai) .stream_name = "ASRC-Playback", .channels_min = 1, .channels_max = 10, - .rates = FSL_ASRC_RATES, + .rate_min = 5512, + .rate_max = 192000, + .rates = SNDRV_PCM_RATE_KNOT, .formats = FSL_ASRC_FORMATS, }, .capture = { .stream_name = "ASRC-Capture", .channels_min = 1, .channels_max = 10, - .rates = FSL_ASRC_RATES, + .rate_min = 5512, + .rate_max = 192000, + .rates = SNDRV_PCM_RATE_KNOT, .formats = FSL_ASRC_FORMATS, }, .ops = &fsl_asrc_dai_ops,