From patchwork Tue Nov 26 11:54:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chancel Liu X-Patchwork-Id: 13885835 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2055.outbound.protection.outlook.com [40.107.247.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51F481CF5C6; Tue, 26 Nov 2024 11:55:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.247.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732622121; cv=fail; b=QaYA3TQF3gnGue9ZETly1asCJaQ74EBqPTG5Tjs5zGY3Lip8JMbzz+SNyY5FK2cbHclN5nh9Kww9vvo9FY2rURyXrukQo5S23M6TaTWDYwYbqYiGdu9RI0YWOMjeVeldFYBTzybWusNAwhfxV1T4nRjExlEmnRjUG7V0YlzfEtY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732622121; c=relaxed/simple; bh=HgyJNrpzZ2QoHLkyenNxqWLlceCJxg3QWZUvhS4XqNE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=nsY5lp63hhkzojwZ6k1plK0nY6lK+75/aO/1KNDKJEGJq4JOSfYo01qZBXw8cXqj0eY4OUIvC0/C4I9cBynzwToCy7CHlm2dnI/AJ6tVtRjl6y9Qyox0hbnlpzPU1GU7RjjJ0EwACvz0rUcQ2ek2UhBrhGFKZpsvYiP2GFI2Rq8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=JoL2Z/zT; arc=fail smtp.client-ip=40.107.247.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="JoL2Z/zT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RTu1UxZ6MZX7HeoPE7kguPzOtGCL1/66sqmLWqn6BTQ9n7dlC9FFkcnkEhyPM0gsnFk0/lixGtpBybwKtZvycKuO+flPFKHqi7ZtJ5TsspV59z0CF2gMeqUAnBPpt0L7SqOqvq+ke4cfRgb59X7bhDUIuuhxDlrZz/yoMOzzfBTtDmzpBEZnoA2e3IoQ9bU2iReAe/b8ggkVlqZABeZvVJmwZA5Ih7q1Tl/F58I//DlWztbf7tnfjM/tw1nIE+jvKcFK8CL6PVPomJSsY/6nA9YcdcidJyA+AxXO9eMFqARiYunzQG07YSys5GmzW5FX+0JFf1FmNNlIAiZAK6w8tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Fk+uqzNjfiUIgmzzhqDaMO9X9dX9HqbjRWfo924qcXc=; b=Fs8LwPcBnr+QLqLtAfOIXftuvrEKm9KS6DFERGYW/K8/M7H5NBYF1fxr33FkNmlWsdDfd8aM5GiCPBvEBJYgfL4UTV9q1/IbgQrocyuvAqy/HF7hYqmtwAvChT3aSrha97Uo3G1tRlNGEbFZvP7Kgxpb09DObrzucW0S/YfZ5XDq5o/QijxK2F1nJTYyFtD9jcDtloBReDQu/m5ufzdAIFU3/OObuvzXqAvsSNRXmNMV7fX/pDbDgeyU1LNcG9JIiRc++oPrHVQPIBRCG4XgAQG/PkudrMZioflLxvMqMTrED4NccgCHWPNeDNgfb/FVhuJq+a6sv7eSCNbDvgDwCw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none 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=Fk+uqzNjfiUIgmzzhqDaMO9X9dX9HqbjRWfo924qcXc=; b=JoL2Z/zTEqPJ9spMocNkb3v4MjxLZo7WH6MDU6C01/0foLhg8iPHr1i1qgmLYJ1hHnZptHl8t0OqSltq4yTlKqK9fDNbmTinyFIFcmLnDaP4w0nbxwiXSbq0Rk7Iof6UGE1HDN/jJoAm94riXbxI4s77v4/ofYqJnUfgYkkXLlPTqDrmW+WP7xfyIc0qU0MN+9SmlvZHjAicTAb3y3nJJzTOwmaUej9mdBeDu2O27SuQSY+UwKL+AO1suCsZgKo4esVeK7wKKleGTixIyyS8ji/BBZYs+bPhPfL6cPfyvEAv51e+0XFd0yu0tdvgRCoWMygZffZ2y3HcYTP4hZ4xog== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB9PR04MB9498.eurprd04.prod.outlook.com (2603:10a6:10:360::21) by DU2PR04MB8504.eurprd04.prod.outlook.com (2603:10a6:10:2d3::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.21; Tue, 26 Nov 2024 11:55:16 +0000 Received: from DB9PR04MB9498.eurprd04.prod.outlook.com ([fe80::24fa:6f9:8247:c5dc]) by DB9PR04MB9498.eurprd04.prod.outlook.com ([fe80::24fa:6f9:8247:c5dc%5]) with mapi id 15.20.8182.018; Tue, 26 Nov 2024 11:55:16 +0000 From: Chancel Liu To: shengjiu.wang@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, nicoleotsuka@gmail.com, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sound@vger.kernel.org Cc: Chancel Liu Subject: [PATCH 1/4] ASoC: fsl_utils: Add function to constrain rates Date: Tue, 26 Nov 2024 20:54:37 +0900 Message-ID: <20241126115440.3929061-2-chancel.liu@nxp.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241126115440.3929061-1-chancel.liu@nxp.com> References: <20241126115440.3929061-1-chancel.liu@nxp.com> X-ClientProxiedBy: SI2P153CA0017.APCP153.PROD.OUTLOOK.COM (2603:1096:4:140::10) To DB9PR04MB9498.eurprd04.prod.outlook.com (2603:10a6:10:360::21) Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR04MB9498:EE_|DU2PR04MB8504:EE_ X-MS-Office365-Filtering-Correlation-Id: 0278719f-c722-4eb0-b2b8-08dd0e113191 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|7416014|1800799024|366016|38350700014|921020; X-Microsoft-Antispam-Message-Info: YjhOP/Ppweg3u772NWEQVQjkqIByweLiK9+IiC0Zk0entXGVcOWA5gPoXLix1NjTU+2ZfJqDGlJSl/IG63XqirmFkkF/ZCqyso97rzyUCSczNpjKt20OtH9cHgBOkYXgpQ494fXOSPygJY1zk4gc6daEDNc+Km4R6EXCiM4s7symY5GICQmrXjBlSI06N1vE8owysKHKvUVrsjRJTGjK4xGGssBIJ0/sEMwKfusZ805s0JIdNrhbZINly+x5qc68IHPDorQDJZ+RLxvMCrtMIgmfIP4qoVdeImPhu6mt5uGdeTlZ3rcX7wODYIUVbCpoxtk104U+u/NsEYsrmblhvmsBmmmLvvNFAKQLQ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4D1R5RmPtjIVig1WT9NY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR04MB9498.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(7416014)(1800799024)(366016)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1EyY0ykPhjlaSjMc0fGDgx0ewEiRiCW/Gv5LfZZ2PBN3OX1/jQFIyWcHBpIgi/RqrLb9HuoJMX15ERvy52d517r+PCi296fBuNDMYfY4dUZj0SE5lJydUT82BPP6tTBMkVUB9u4g0BDgtPIF00rcNsfLnOJz+AaKDIjZxDE3TnnM3WRwoNvSdlhKzvSMuHIO3he5PHMD9VD6cGfJFQcuc0Agh+Ruq2L7u0PlZUvxY/7FYQq+0Qq85uIAwyl2PGjSHcql6q9/DZ1OTEgBF1cwp3BUctXs/oeOHplfBI3ngQcSkQLUrlgmMj6IErpFvGRJ46m7wXf0yA4RT5aV05CztPvlBFDIn9hWYiakgJDqZfar1eIsNyUcdqEutKaISITDqlhe/DaJC8MUmA0s8s6Eb2v01RnY1Xrzm+elNbzvQbN906WD2gnN9fr5JwPw8SoVnQULDDRO8s7k8dXIuB4XIFK9N6PTsRaFfX12/D01lT2yfIz9UVhomPmFe05p5fQG+Ln2nwqy4WheQjRkA4Qj/uVq/CXD2UBQtMpuh15jeahBfJljNhXOmpjGKOj8L4/3Aq2njtlUhZ7tgITsmGCGzPOXc3ATDRIA+8c5SBGJ54alP0lHP65TTYXMRKTO6wLHl+Hvmel0a1uqhCAnbd3EzbjqA7n8e7eD4f74uKQZAeFiPry850ex0r094bz3R77BDXjNtgd9zE8fZhTU+TAF523XLE5y3IXxw08jCGXTyp8OaPcXjtw+aww3enLUPdZ3FTfV2ng5231jT7BhfBvZ1Fotd6rPINj3L3Ni/YphxfEr/o6F3kNMoHP4S871mjWUHOurgampCtb1amDtho+W2wqyGefwisLcg1MuXgIXzlpyseyGv85n6W/F6lZen5hfTZx/PRj50AmmziIC4itIWTQqd+ZfR+pQlleX5uePnpGEwpAQsbIdYyXWMxR23ZR8Yghx7vFt0E4MfXOtzC7zA0ELyWhEr608fuqLuB85TvF55ViflfIrSoQngRpiYIy0x5bIm2FD1G3gIjd+XH/eVQN4CkHOjt0eyV/4bApG45bv80UvEMe2ZhUuObaAvri0R/2NOB5wZaz1AjdVTXi7XFN2UeQ/+2wp6HUG1+UNd6wWHO26dyT0h6PdhWctKRLkE6Pwpc4yLa2hnH4D+1nACWOEfROltJL1GYY3B28P2lLQ0ZK5qcZY1cmYzGqI2g7Tq9SdAc1F+t43TzNSG+7EntDwZDVsaKPeiQy7iYS9Up8KyW4fjLlw4y41/6Y0wlw/BSs0zdKktPDAickar0zAFymTAqNd7zLPOJQHuauRJmRPB+Lc/AVfLr23NMKuoYXlqYBIuYl9G+pVYpgbZuiY0nmJQVMgfRI+vgfHFMu/1OPnTZisyaa7Ec9UFXO7kJweDFD8/zRyGXdNvVfCC0SRLJMSuOOucxqXTsV37mIvXXWtDNnGLS382p1putxHkSGymwDIjCsWMyuDLvyshpnq7DAJ5zlCnLAQNzVUEYi2nVL1dGYpI3qZ4G4l/gCdnl6g0IhnoYAzfsugZm10QtMonaPk67dl2MoAC7HssVvfkGFkalRm83YMrfP3CXHO6dxy X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0278719f-c722-4eb0-b2b8-08dd0e113191 X-MS-Exchange-CrossTenant-AuthSource: DB9PR04MB9498.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Nov 2024 11:55:16.7010 (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-CrossTenant-UserPrincipalName: ut32hddKgrYEkwBGk7/I1DWzrYEDIAmWWSkGJYNOzE3sXHWAIn2c/KEaq24Cs7dzbLFxLm49bLSCbcAYI5Ot0g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8504 Platforms like i.MX93/91 only have one audio PLL. Some sample rates are not supported. Add common function to constrain rates according to different clock sources. Signed-off-by: Chancel Liu --- sound/soc/fsl/fsl_utils.c | 45 +++++++++++++++++++++++++++++++++++++++ sound/soc/fsl/fsl_utils.h | 5 +++++ 2 files changed, 50 insertions(+) diff --git a/sound/soc/fsl/fsl_utils.c b/sound/soc/fsl/fsl_utils.c index a5ab27c2f711..d69a6b9795bf 100644 --- a/sound/soc/fsl/fsl_utils.c +++ b/sound/soc/fsl/fsl_utils.c @@ -152,6 +152,51 @@ void fsl_asoc_reparent_pll_clocks(struct device *dev, struct clk *clk, } EXPORT_SYMBOL(fsl_asoc_reparent_pll_clocks); +/** + * fsl_asoc_constrain_rates - constrain rates according to clocks + * + * @target_constr: target constraint + * @original_constr: original constraint + * @pll8k_clk: PLL clock pointer for 8kHz + * @pll11k_clk: PLL clock pointer for 11kHz + * @ext_clk: External clock pointer + * @target_rates: target rates array + * + * This function constrain rates according to clocks + */ +void fsl_asoc_constrain_rates(struct snd_pcm_hw_constraint_list *target_constr, + const struct snd_pcm_hw_constraint_list *original_constr, + struct clk *pll8k_clk, struct clk *pll11k_clk, + struct clk *ext_clk, int *target_rates) +{ + int i, j, k = 0; + u64 clk_rate[3]; + + *target_constr = *original_constr; + if (pll8k_clk || pll11k_clk || ext_clk) { + target_constr->list = target_rates; + target_constr->count = 0; + for (i = 0; i < original_constr->count; i++) { + clk_rate[0] = clk_get_rate(pll8k_clk); + clk_rate[1] = clk_get_rate(pll11k_clk); + clk_rate[2] = clk_get_rate(ext_clk); + for (j = 0; j < 3; j++) { + if (clk_rate[j] != 0 && + do_div(clk_rate[j], original_constr->list[i]) == 0) { + target_rates[k++] = original_constr->list[i]; + target_constr->count++; + break; + } + } + } + + /* protection for if there is no proper rate found*/ + if (!target_constr->count) + *target_constr = *original_constr; + } +} +EXPORT_SYMBOL(fsl_asoc_constrain_rates); + MODULE_AUTHOR("Timur Tabi "); MODULE_DESCRIPTION("Freescale ASoC utility code"); MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/fsl/fsl_utils.h b/sound/soc/fsl/fsl_utils.h index 4d5f3d93bc81..21b25a11ecda 100644 --- a/sound/soc/fsl/fsl_utils.h +++ b/sound/soc/fsl/fsl_utils.h @@ -26,4 +26,9 @@ void fsl_asoc_get_pll_clocks(struct device *dev, struct clk **pll8k_clk, void fsl_asoc_reparent_pll_clocks(struct device *dev, struct clk *clk, struct clk *pll8k_clk, struct clk *pll11k_clk, u64 ratio); + +void fsl_asoc_constrain_rates(struct snd_pcm_hw_constraint_list *target_constr, + const struct snd_pcm_hw_constraint_list *original_constr, + struct clk *pll8k_clk, struct clk *pll11k_clk, + struct clk *ext_clk, int *target_rates); #endif /* _FSL_UTILS_H */ From patchwork Tue Nov 26 11:54:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chancel Liu X-Patchwork-Id: 13885836 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2055.outbound.protection.outlook.com [40.107.247.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 856BA1D0B82; Tue, 26 Nov 2024 11:55:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.247.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732622123; cv=fail; b=ihbIh6flTAstqf+GTMbAzOwwimHSQKLO++UZk2CEjkqbd4ycJTB5pIW5knyZtmRIzZIGK6biEMYSLCqFVkCxSOnoIi+8B6lfgGsrHYlj7si6prbJTr3Hdgico72zvsrIFSqGAaOujUbhH6dTBLsPoJdx4K+uL6K44aWLzmYsnUM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732622123; c=relaxed/simple; bh=r9DEGxKf8a/KjVkM+W/wOdoeDj74irsLs8pDmLiwGAA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=an/O4/uWAe4kv0kvf/G8FdcmtPBtrQP00NNeIPlI9i30CG9jcCcVuy+SvmP4KQFO3n3vABquLWu1MRdsmV60W0wYFpXSQl17fcKlaGZZ3AAHlHSNLv3h2l44q3h17ttbIWhvb3HuWKJtNcJJs4m7M2s/jO0htBagVugTwSlxrss= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=Lb4pfG7/; arc=fail smtp.client-ip=40.107.247.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="Lb4pfG7/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tyF0jNtX9B7IocbgPV+prFiaDdGHnVmKDYUhqHs4tgqgz6S7qYWhg9xIEtjU4WNLw1aUW0eoMbE8hK5CIfmcS8DUCtO0gYq4+FHQyQpMyxell6cn40Fu6XOi88tHW5FjoVFgHM2OZuejgvXsupqkQsjY7EpkqgnvV82bmy2NLWo/frC38MCRmLYV5+YzAiwUU/HG8Hr7sZkVDmLowAuScJ4aVLaW+y9SGZcbHm8PPKa0oCKQP0tAEA+1d7E9YvgE2zEYFb7Y/hcmHKI2IgyYDp1NX4st/nvTq5+SQOw6Cb8JN6cvq3DvTiCcoo34ZaMPvZNEYc1bg6Fj5MjAM+b81w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IJFfd4SuEfSSWyBka0cEXifU9TdRzIwtY0KkNpGWjOc=; b=GKLkiwWhMFFNPZbK4J5tyLHmm97I4oX6xQglX2iEQkAugU1KUtbhzBDtY2hp5nzrxCTDQjEbLwSHTbO01fJhxLnkHzYr+7jXPDbsTKqHUiaxOekIsBjsAL/eW5U/veXxzHnDAaojw+PHso5IbveDm/lbop5Wwd/21dgirFMC6bJMIT5rXRelwBJiWz+XdA39GZnXm4ZsDhjZzcF77HlpO4Xc5jsq5GlV6S0Cbi6n9hAGFBOVVX6QKnsRu4PupMUH1WQ26+Gwe4fQyulrm88EJN9uVBIgWDXnv7mLQhu6vaf3RVOY66SSy+Bdx9H9rX9KHO8xYpjbieVdDVDIIUYZcg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none 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=IJFfd4SuEfSSWyBka0cEXifU9TdRzIwtY0KkNpGWjOc=; b=Lb4pfG7/jCMac8KyapLE4XhoOyZIQ/KXpjQSnyy+uD0W+qyfSrWcyDeFZcNa7HvcY3g65t/hfyAD3BwFAMTS5PiEkSAF5+IUm/I0gHnk2tO4HDs88R3wHaBsYySX7eqFouVLyHMODWYlo3J+Ad5aZ760cIdqeyUC2Z2aWDf7uzZ+h9AHk3kFEBli6me8L41WjbYyT1JFNxSWXV6iQHPO5G8EG4fCeDGlsd5bIqIgMFfcXFkqzPSY222Fma64ip9FOMmJMuFIJM9R474UneBqdkpqymbC7ClIe4szbt0EF48Xx5TkoCv97PE0tg61EBEhlr9UmDuz8H2LZjeTgdMtQg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB9PR04MB9498.eurprd04.prod.outlook.com (2603:10a6:10:360::21) by DU2PR04MB8504.eurprd04.prod.outlook.com (2603:10a6:10:2d3::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.21; Tue, 26 Nov 2024 11:55:20 +0000 Received: from DB9PR04MB9498.eurprd04.prod.outlook.com ([fe80::24fa:6f9:8247:c5dc]) by DB9PR04MB9498.eurprd04.prod.outlook.com ([fe80::24fa:6f9:8247:c5dc%5]) with mapi id 15.20.8182.018; Tue, 26 Nov 2024 11:55:20 +0000 From: Chancel Liu To: shengjiu.wang@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, nicoleotsuka@gmail.com, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sound@vger.kernel.org Cc: Chancel Liu Subject: [PATCH 2/4] ASoC: fsl_micfil: Switch to common sample rate constraint function Date: Tue, 26 Nov 2024 20:54:38 +0900 Message-ID: <20241126115440.3929061-3-chancel.liu@nxp.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241126115440.3929061-1-chancel.liu@nxp.com> References: <20241126115440.3929061-1-chancel.liu@nxp.com> X-ClientProxiedBy: SI2P153CA0017.APCP153.PROD.OUTLOOK.COM (2603:1096:4:140::10) To DB9PR04MB9498.eurprd04.prod.outlook.com (2603:10a6:10:360::21) Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR04MB9498:EE_|DU2PR04MB8504:EE_ X-MS-Office365-Filtering-Correlation-Id: e78a6e27-8653-4d45-d74c-08dd0e1133ca X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|7416014|1800799024|366016|38350700014|921020; X-Microsoft-Antispam-Message-Info: lXeEaHSP2YIfvGJGimfvQe0ldxflQN7ODNCRjZGtq/oK/l5yME7NigzG+9FRXmyiCDn392RnXCc6snssqaCRsWxbRWCKrIosaaN8/ZzEGM3FBvKVyKfIgdwwq/suDXPllXhUZHRvhsEmB7OswSlmA6V/aKk4djFtgj1yN6Rsfomd9t+tX8rj+LXvULwivlEc10k6OOADrIIl+14uSNMRu5Gg+1xN+++FQKzbZXbfTb8bWeFHnp+Wc0XKZyMDe5BhLL/92swJm0K8bwispZbbjMtNCd37Z6e+lpCvZBYJuqLOxuJpS0qGZc/LAA1oscyNqKZikFq3xenGPUEoYrOwh3W9zBNCgYUYTmI9YIA/vZLo8BG/XOA3FG/JqQxI/lZ09m5ucWy4On6FVxT7d94n02s8l0OctZ1f5pJUUDp66YCyUVWCKrUebMGupCU4kC3AZusPo7y8PFeBEL99ljsTCgFiBhVPFg6OKuO+9WhzAfltCt4cKywCeJwTZPoXSXQhrHVIItat1sALkRtSpN206CbWr/ZsJ4V2sFMbiDFN3t0ktRKJdhCAHPYbUDP4GEoiH0B3zc8Z2CudETSWcIIr/iQKDaY/MmBVn7tMCq+bQqxtZs7QUnVfsrVtgqZF/Pdz+hwnKhWSd9aqP+wru2/UQxjiKGdjW40LB45HTN5h+qmIRTU5QJZRvDwx71cYp+ulltGDSwFCc5YBiheDipbV28JSkhsNMYv+yZrLjCNO8TI2yQ9U0nvpPFSA26x+Z6ZzMq1pLg7KAgvzUToCuPiNELtblGCFwkK8Mx0+8ONHt7dSHgm5Dt/2fyjx+oGqupuYH9Ut3VEaNebRZqwznLZ+TVd0kIkgTQhVlDpoKCi1upoJSMyv+3v0N+wRyzng2KKGoowX686MqTa7giNFMIa4J0brKZbZHuf1vCxYSYYsdt8wi3su0yWcKsHIlL4AYP8q+YCjrlhAiU5aJ5EYxxpR8DsYw8aXHyfi3RCWQ665lc0vmyrYA+O1+lW7UJcMLAiRxdBwlmrc2MM4BJaJaN7S0SbUDh3awAGfpbNCllf3EPeYSYIZjqSDy4XHVGaarcYccU4ELrbAo7LJ7XJfXISM+7IghB/r3f1bT/dXSDLoLyr5czpgnjYCbcqrRMn/N5Evj2wbpA3sYUSusH3Pc5y4NL3lu7eLKaKCP7cIyPrhnfNZstOIEsPVD470luzposvJ6LHlxMvl2cVvMCXb0GyY1CNvNRkmpRjxtkYxCvYgXvhBudnFIVDOAL6OEMP5sNPFB/YzMiTTEpyKNvQMCwg4dfAw4/Pso0YqAN1M5kYliaShQxFUHUW8x0CDyZgLTtyyvLeHvXBkgeQK9I2lnPeSqi99eKD1FykCjhUQDoDMr3Gw3KASJvL+OfYYqDQC41DwKlr990pJI3jYxkEpRW2P0DnUT3O6n8mmQMI1k+aEAnU= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR04MB9498.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(7416014)(1800799024)(366016)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qs7Xb3RczoSG+xOybyBPPOCr05BO5xm//lcqprhu8NaciDEMLg2PCu0JqicUW0Wc/R3czve5It8iARbKaVz2Wv17EsAKZRXFBnFZGcpFAQhQC7MvdKVdZgNn3KGVNslPQJMlN9xdc7rJvVy8V1K8gWPrGk/cwrtDLXvzk0V4a7hwBVkfZUUL6Ei3ynpxAzb+SUXIzfYeqsaW7XEMjNgQWyk16FCyGyv9Q/zDiPGRQ92n314ZsDFlBT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Vz1rPUkyY3pdJEPazKcWqEfzD7UZAbE7/BkhZFW3NgGrRTZu7Htcsjy5GL4fXca8K0lgySsK52ADZ0nHK92IAYVo7Kv3mo6EM6v9NF2a/82IXIJHyjd1uHdGHk/J+DnXvKMFLh0marMXMa3sOEpDUXgeMU25A4SX0IfbQ+FH+VC5KAoZZ8ocqYuTXrWr+HTNe/tdeQrEJJBnGlC55aeIq3zvVgJUWXkjmpyZhr9QPAVgY/y+o/M0SGLv1lbNYQjPbEOGcpeGXhL/jmrC1iG1eku X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e78a6e27-8653-4d45-d74c-08dd0e1133ca X-MS-Exchange-CrossTenant-AuthSource: DB9PR04MB9498.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Nov 2024 11:55:20.4329 (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-CrossTenant-UserPrincipalName: amQgUvnli7JSr7z9y0UQxrPYgntRhMuEyHqAjwCw7egaPV2gWHLN4ek4JjuGHfCqo0PDQ0qS57At0L7tE1f19A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8504 fsl_asoc_constrain_rates() is a common function to constrain rates. Let's switch to this function. Signed-off-by: Chancel Liu --- sound/soc/fsl/fsl_micfil.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/sound/soc/fsl/fsl_micfil.c b/sound/soc/fsl/fsl_micfil.c index 8c15389c9a04..e908cfb594ab 100644 --- a/sound/soc/fsl/fsl_micfil.c +++ b/sound/soc/fsl/fsl_micfil.c @@ -35,6 +35,15 @@ #define MICFIL_AUDIO_PLL2 1 #define MICFIL_CLK_EXT3 2 +static const unsigned int fsl_micfil_rates[] = { + 8000, 11025, 16000, 22050, 32000, 44100, 48000, +}; + +static const struct snd_pcm_hw_constraint_list fsl_micfil_rate_constraints = { + .count = ARRAY_SIZE(fsl_micfil_rates), + .list = fsl_micfil_rates, +}; + enum quality { QUALITY_HIGH, QUALITY_MEDIUM, @@ -486,29 +495,12 @@ static int fsl_micfil_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct fsl_micfil *micfil = snd_soc_dai_get_drvdata(dai); - unsigned int rates[MICFIL_NUM_RATES] = {8000, 11025, 16000, 22050, 32000, 44100, 48000}; - int i, j, k = 0; - u64 clk_rate; if (!micfil) { dev_err(dai->dev, "micfil dai priv_data not set\n"); return -EINVAL; } - micfil->constraint_rates.list = micfil->constraint_rates_list; - micfil->constraint_rates.count = 0; - - for (j = 0; j < MICFIL_NUM_RATES; j++) { - for (i = 0; i < MICFIL_CLK_SRC_NUM; i++) { - clk_rate = clk_get_rate(micfil->clk_src[i]); - if (clk_rate != 0 && do_div(clk_rate, rates[j]) == 0) { - micfil->constraint_rates_list[k++] = rates[j]; - micfil->constraint_rates.count++; - break; - } - } - } - if (micfil->constraint_rates.count > 0) snd_pcm_hw_constraint_list(substream->runtime, 0, SNDRV_PCM_HW_PARAM_RATE, @@ -1239,6 +1231,13 @@ static int fsl_micfil_probe(struct platform_device *pdev) if (IS_ERR(micfil->clk_src[MICFIL_CLK_EXT3])) micfil->clk_src[MICFIL_CLK_EXT3] = NULL; + fsl_asoc_constrain_rates(&micfil->constraint_rates, + &fsl_micfil_rate_constraints, + micfil->clk_src[MICFIL_AUDIO_PLL1], + micfil->clk_src[MICFIL_AUDIO_PLL2], + micfil->clk_src[MICFIL_CLK_EXT3], + micfil->constraint_rates_list); + /* init regmap */ regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res); if (IS_ERR(regs)) From patchwork Tue Nov 26 11:54:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chancel Liu X-Patchwork-Id: 13885837 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2060.outbound.protection.outlook.com [40.107.247.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC1DD1D4354; Tue, 26 Nov 2024 11:55:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.247.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732622129; cv=fail; b=usTnP3Hwg/e0hPhQSGeNHD+Ci+oMk5ObEPss7iIrWdiH5+OFVGEAAIG3gyEPCYl2UVZWTGoyubS4Ff7Rbg/6PuiGZ8ZgN4jLibLzWFoxl7M7iEL2NexWgR2+2TIIadpWYD4pFdTOE2dp1lxykW4dX0XIcqoiDM/EkY1X4P5bk+A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732622129; c=relaxed/simple; bh=A7yKnkg4+yDtaj42lmWEC4lMDT5drrIPeA+ZX8MzAng=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=htwQN/30q9N55biwVGDK3jvD7QAQcEjKIsB87dNurFzKTIZAegbXmqo9cmyNTu6w3l7kMOeqBB0J1FWwkGKkxqTqGxM4ZSHCkpQxaP0TPoOP/3Io2iQCThCXxK83G7jkxwYKq/2m6YzOuwOvQe9b+NLCStTTuSZGGzp/tSsKUfs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=Mui+NVJY; arc=fail smtp.client-ip=40.107.247.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="Mui+NVJY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bPE6rlhKanFMJQVX2cwuwjp5+SCLD6IHMLp3s9mY3jxemHMs68FZCp8lrj43H0YsRRlaxhujBA2oFIJkqVu67KpTrEvrGpL1v5N/ybHhesT7+sy2ubfnVxcvrlUJE94gHkGKvBqvVgVHbkBSaMTB+UiyllJynCLYnG6iQCoWFtdkAxS2S/p6yOAU7Kho9tNfrX7X3Mq+hl2Dp/i9ldPaaFl+u3vpcFAmdQOXf5M1xdBddR140p3pVjDLDUrQFM5SIgSJS8Kv5UXbQEU7+JRA73FSP2LfLVxHshh9hYpjMiqZf5V3XpYExOjuFBjEXBSfYvNkFhQTSkhhnKDdBPMcMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mZDcaZXrO7LOFmVJ9wk5PjCmIicB+f6nXstNqL8s2yE=; b=eWAW7zDP0Rgy7+fkF9UdkJFaCddLho22y7EHlHbz3GAKMWy1s10bXuO0v3l5KxGf5ayzLT6niWj9ZM7YdjUsh9jJgB3zzjT6yjAC+tgGMrfVxkyK+OwL6HsSqpE0dwVMniqOP3bCNruC3wZ1BhhkFwN6b4mxWJzzvhRnVMOXYcK2UsttYYq9EghxkLtHYVTD9V4cHFV3CvWo3pVGwAWNZYj5OgAAQyiajQuNlNguddqmz+uLkIqcZ3x/0FNz069vg42DCL1Xqcf1ZfJNMXZnrhjegpfANfyOYCPHEaUF9FdWThzcYe3Oub4/6igynuEgk6NV0oW6HAJdvwci1nFBXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none 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=mZDcaZXrO7LOFmVJ9wk5PjCmIicB+f6nXstNqL8s2yE=; b=Mui+NVJYriOrLCNI8GQdgqu1T5Ew10o4XWUYPJz0Z60nZ580QkVW/YyNgKshP7N9iG1RFsaiH08NvogR1JdQk0ciSvpcrhZHKVWocQZshs7Ax7lHtv8/IXhaeioLX5zlIfvR5vJj9vbFX2zCRmfgXbSREQ4/cFopdTpq4ROQyphuO3m7eM3O+sYDwVZUZh5z3cjtbkt2PdYI9Pw2UuyraHP3Vr2eDkjfZHuDbaWJCIz/JAyvCVilVTeE+tlbt58LdXvEi+A+wspMZM5XY7zkU1vLom5ALl2KoYSuiCg8jrTAj7203Q2s+kP5aAmhTxIYULYl4jMlvdAgSQw8+eMCXA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB9PR04MB9498.eurprd04.prod.outlook.com (2603:10a6:10:360::21) by DU2PR04MB8504.eurprd04.prod.outlook.com (2603:10a6:10:2d3::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.21; Tue, 26 Nov 2024 11:55:24 +0000 Received: from DB9PR04MB9498.eurprd04.prod.outlook.com ([fe80::24fa:6f9:8247:c5dc]) by DB9PR04MB9498.eurprd04.prod.outlook.com ([fe80::24fa:6f9:8247:c5dc%5]) with mapi id 15.20.8182.018; Tue, 26 Nov 2024 11:55:24 +0000 From: Chancel Liu To: shengjiu.wang@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, nicoleotsuka@gmail.com, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sound@vger.kernel.org Cc: Chancel Liu Subject: [PATCH 3/4] ASoC: fsl_xcvr: Add sample rate constraint Date: Tue, 26 Nov 2024 20:54:39 +0900 Message-ID: <20241126115440.3929061-4-chancel.liu@nxp.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241126115440.3929061-1-chancel.liu@nxp.com> References: <20241126115440.3929061-1-chancel.liu@nxp.com> X-ClientProxiedBy: SI2P153CA0017.APCP153.PROD.OUTLOOK.COM (2603:1096:4:140::10) To DB9PR04MB9498.eurprd04.prod.outlook.com (2603:10a6:10:360::21) Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR04MB9498:EE_|DU2PR04MB8504:EE_ X-MS-Office365-Filtering-Correlation-Id: 204046ed-ccaa-41fd-fe13-08dd0e113600 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|7416014|1800799024|366016|38350700014|921020; X-Microsoft-Antispam-Message-Info: Ja2Y6hHaipjrBcLrEVgpw2lM1AKnscWMyPcDHHFLUs+d2RJto1i2ZZa/kLYZ7l4nltnPk3kjyTuFw509VRi8vcZyIieaZRlMvHELtxu+q4yjxVV43LOVb20NlJCq0dWN/XwA/VulitdKEdKZghxaqPQADZ4Szs58l5ye1H4449pp8BF2PZpp+LAfj7Bzew7BALoURDuWdkHr22HofDIDRo6VlHaD9Yob1cMVeg2vVG1pV4sPPXmg2mbaqXA3UGa9PveWYGV/Vw74tG1QGwWLCG6axGjpaG4rcsIN6vZv//TyhS6dcpovChnI0G5QvBh4vimgnkgRyxusafRESWbNbopqaptXR42rusnu34JvKYk/tri+9KkxMbORarDLb+ww20EuRQRGQ83yTFJuALQmVFctScnhAAiXsr3rIJvlBsKq6emzo6Jiiujcny4UqRKq1yvsdR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B9PR04MB9498.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(7416014)(1800799024)(366016)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Lif3cfzjBat1RVgpnwU4lqXA/GRM4dnOHJV+eNC34vIQZiKUocUZKib1OE68f4jPPq/0E6h1I9YeQjvRBwUGpI2u60W/qP9nc6MbH2VTFKvFvUOIQcINfzn2yPgyRgzw/KKGP/krvIyotefNEElH70XI4MgrHpAroMHKhrdpiYdWdexv96ux9PTwzMHmeLL2EImxyN9FoHbFhePcqLStsrYcaRtAnozjliazixXuCsjiyU+Lf9OdBG4QFhcphdHaS+sL3Iw/Tfbsfrbvv2uaogwNyFxLIS4m1GQPZHD5zoX52ROszCK9Pp0xmt275JNjka7Fxe2c1KZQnpyS7QuFhKA+mqeZv4vnG1jFyWqshvwutSs2k2ATTWtrIYmir6KobB7nNDfDprE1m772iPkeZMijtClV8lZr651iuLG/ziKh99DUj7kaJS3uuAUv2iPmR2YCdXVsfrl3hynrbNakgiTIIuVBiIKQSdGwYhU5vZd01/tg2pz7+6JXPI4NhWFP+jqNYgaA0ERQSCmpS4IxTAi3amAM4oBSy46k/KgJcmJvvxYofcXhu7H5MvoyRHco0SygyJ32b8QMZr5h7mO83yyNHTIax5afuZZRQzjdQPFN4ojSyTTvWndmRZrtduUw7RNbLnGpaU75DGqsQoMy0N8Nlpod6Q/RJXYlVbGFRksxQbERVfIY4NjR8cWcx+9vxGc1G0JmMkyPkCMIkE3CMdiDX8PggNcnwuGCuEBgVhkqxFiGxIC2PEoNHqfyKZreC6YUCrKomQpqAT0A0izx9D40xz2GLsRcKn+wg+HY8db7rX36yDCnzY2Oz4KK23K67tgTQwgQZvfZaTngPC+7d37/8mu2LzeUJtguAxADSbrc4zYa5ogh66g/VzqDI4TA9IFkTWH3Uy2MRxFDh+I4Ldv4RAP4ZyB+FZn/lyHWkH+ofWW9nQA5Jt3/2qjlrt70ped0JxU0mARHqTitbi0HaIxpu/Fd4mBW1zql6MC4OJM4Kh9qCS8GLv+gUq3WlLo9itRk0KNc6PR+v2HtmoJQ9MikEHhk7qArUErTxOWbn05DXsNhRoEw/aI/B90ENEsDYgSdTr5VpKycW2NlYHArB5uiVPg2PqS7RZNuAiHz/F2wvx5DHR29znaLEX5vPc8DxlIUN2MEwECxD0mlC8IzupAp2nPORl/MQwq/vSUTHOdLIvrgXF6BDa7FECrukFiUJle6mAfVuqOt6CcnOJkPO4KQseKFGAlEo6zZxaY4dLWXDu9ImThSYNX8Rs/JfLwkYdOH10ncQWJ5jYpqoyJMQwTwyMfZD83I4rjwTD2XFSx8JnEfE3uvQhRHrZJOArurHhtiZkLkXdOM9VCYlkbfVuw/TvK2AhJxkwsm7vWvuIu7LCgiIU05ieCfMnixdoYMgBafPGPl39ac+lWbsQa1dbJ7k4x3qERVLXKF4SEbWPKyunfCWn+YxrDD1Ezj7cN4edIO5nBRyXQZTmKMKDn6qx6Tbupm7arwXMPTngkl2lL8AQTVHHw2DXwH54hZBOU6gwmpf1DbrsADgW3g6ujoqGEX8lADFpC/WT0yP7DGHCEIpTdmFGF40xy8B9XjvyQv X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 204046ed-ccaa-41fd-fe13-08dd0e113600 X-MS-Exchange-CrossTenant-AuthSource: DB9PR04MB9498.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Nov 2024 11:55:24.1622 (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-CrossTenant-UserPrincipalName: CfNtk3BRpljVdutFwwMIiKiak+SwwQZaaYCVQYwAtyfMPlxaxAltYqOIES8sxlm8fECIcqHim76EUTI5N/LNHQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8504 Platforms like i.MX93/91 only have one audio PLL. Some sample rates are not supported. If the PLL source is used for 8kHz series rates, then 11kHz series rates can't be supported. Use fsl_asoc_constrain_rates() to constrain rates according to PLL sources. This constraint is merely applicable to playback cases on SPDIF only platforms. Signed-off-by: Chancel Liu --- sound/soc/fsl/fsl_xcvr.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/sound/soc/fsl/fsl_xcvr.c b/sound/soc/fsl/fsl_xcvr.c index 1e0bfd59d511..bc625f9fce61 100644 --- a/sound/soc/fsl/fsl_xcvr.c +++ b/sound/soc/fsl/fsl_xcvr.c @@ -19,6 +19,7 @@ #include "imx-pcm.h" #define FSL_XCVR_CAPDS_SIZE 256 +#define SPDIF_NUM_RATES 7 enum fsl_xcvr_pll_verison { PLL_MX8MP, @@ -55,6 +56,8 @@ struct fsl_xcvr { u8 cap_ds[FSL_XCVR_CAPDS_SIZE]; struct work_struct work_rst; spinlock_t lock; /* Protect hw_reset and trigger */ + struct snd_pcm_hw_constraint_list spdif_constr_rates; + u32 spdif_constr_rates_list[SPDIF_NUM_RATES]; }; static const struct fsl_xcvr_pll_conf { @@ -585,8 +588,12 @@ static int fsl_xcvr_startup(struct snd_pcm_substream *substream, switch (xcvr->mode) { case FSL_XCVR_MODE_SPDIF: case FSL_XCVR_MODE_ARC: - ret = fsl_xcvr_constr(substream, &fsl_xcvr_spdif_channels_constr, - &fsl_xcvr_spdif_rates_constr); + if (xcvr->soc_data->spdif_only && tx) + ret = fsl_xcvr_constr(substream, &fsl_xcvr_spdif_channels_constr, + &xcvr->spdif_constr_rates); + else + ret = fsl_xcvr_constr(substream, &fsl_xcvr_spdif_channels_constr, + &fsl_xcvr_spdif_rates_constr); break; case FSL_XCVR_MODE_EARC: ret = fsl_xcvr_constr(substream, &fsl_xcvr_earc_channels_constr, @@ -1405,6 +1412,15 @@ static int fsl_xcvr_probe(struct platform_device *pdev) fsl_asoc_get_pll_clocks(dev, &xcvr->pll8k_clk, &xcvr->pll11k_clk); + if (xcvr->soc_data->spdif_only) { + if (!(xcvr->pll8k_clk || xcvr->pll11k_clk)) + xcvr->pll8k_clk = xcvr->phy_clk; + fsl_asoc_constrain_rates(&xcvr->spdif_constr_rates, + &fsl_xcvr_spdif_rates_constr, + xcvr->pll8k_clk, xcvr->pll11k_clk, NULL, + xcvr->spdif_constr_rates_list); + } + xcvr->ram_addr = devm_platform_ioremap_resource_byname(pdev, "ram"); if (IS_ERR(xcvr->ram_addr)) return PTR_ERR(xcvr->ram_addr); From patchwork Tue Nov 26 11:54:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chancel Liu X-Patchwork-Id: 13885838 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2060.outbound.protection.outlook.com [40.107.247.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0BE101C4616; Tue, 26 Nov 2024 11:55:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.247.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732622131; cv=fail; b=VrccMdQsExndDRlRbk1hpWjtiiuQvcFCGddT9b4p85aNbF0cLx/lzF5GQCtYnd563kPqoDbywdsmHeopz1QBO36Bsl/3ZiOG0lxzwb4rcKE5gZD33Ada7CDlrfm66/5VelLkSc65QQb+Hd3TvwBKwIw7lbcoxv4a1Qq6IlXEF1w= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732622131; c=relaxed/simple; bh=bLVPcubGdZTk8VXsL01cyNbcpYtUQ+BQshxQlf5omZA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=DjDzTdf74lcMYAN1Zrbtez4sx8WRf9iQI1LHHkTjd+w+pmmxN0jLOaTsj+EcK+JWgqRSmba+Gt1I3Gghd2s6voLT2yCbzx9eihuu4C09ZxXTYj9hPrT9cbBCoCOWuwHobP5C6dWRutnjgecTFhuCF8e8mndBjFOHN7cgK2qiKDE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=mQKT2C5x; arc=fail smtp.client-ip=40.107.247.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="mQKT2C5x" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ey/fPVqwPhADELWoctPrbE+TfZM8zm6gJevih9YCcWUDATs2ysGS4MpCMzavdGnOsfZYV4JQwSVlzOtlx2TtAn+u3pFcorudLku0X4e6H/Zxqtnz6jOcBamX9jo8bi40vjcacaE/xsraZy7ytAeolg2Dmlap42wSb/ZLgx7FINWdPgd9A6MI/R7eZz6juaI0qmtYD9VLA6n5GYxErVxJHamNISqlkB7uszuOFOmGboCefZSXty3m3u+3yxOwRBovb1fTd0A20cawF2im1pUKXCqtMfWFtY/dw+2t0Ch8f6br8a9XjOtXVWqIszI+AGw3pHeKRVOlsWIgvTTP+Q5qlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PRF7Wg8B6y7Y1fqLOG/QTuzs8XBxESemNeQV7BuQdsQ=; b=KkHkSaz+hO33vp0X+6GrFDO0xUbeDGzUf6xQBx4lvC9V+G+nORqfJIDN8jtKLwfyS5NhZrA3N7ch1xJuVhWn7bvHRdjHcYpFPfS6Em7Z/ssWgxBLFD8Yu2NDngvaq+JcKImzLEE0tKxjhV1WqPkN35fMSogKBn4p9c9UhyLPF8IhjZa4ueZJvpT3Mv6ruXfm9jpFdJwA2ga9vEakq8k2JoKCn7syaZN1rYlB4M9jsCqfNCOBiZj/8tRTthyaR1nvAV8kgPQMeEhRnUjdRkkzc5Wdtgyxhp7OUahcfm1XrUaWbAhopLgm6SsV0B+N9RYizgCJgBr3MPICvhaX4SopfA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none 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=PRF7Wg8B6y7Y1fqLOG/QTuzs8XBxESemNeQV7BuQdsQ=; b=mQKT2C5xQh4mHh7J7uxwN1rpAxWV1jt9BqOfLdxxvzm1jZVHCRcSMKOahf9WS0DbuDYUo0yHh5chanL8K37ijKEq5yu1vM7H7IYdXu/CpSN2+e73PH8Tn6zMOwuw1JEiOw9JOz9OCj/l7YsML7bP2gMyCbJnnul6Ev1LC1fARL2WNWh+lPUSnUdn82AyNy9BNfUP60UkluBvpz63DuLqdoiUfv4LWIQxay991/PCl3AKilDSVyiR94vs5hUqQ90e8cVlGd/uot/e8bi3GskEuak3m4CA/NpRDI1IDEcCbjL/2oxuKkqrGdqrmChE7cAbtXB6tMZklspjZ6fO1T+yrw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB9PR04MB9498.eurprd04.prod.outlook.com (2603:10a6:10:360::21) by DU2PR04MB8504.eurprd04.prod.outlook.com (2603:10a6:10:2d3::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.21; Tue, 26 Nov 2024 11:55:28 +0000 Received: from DB9PR04MB9498.eurprd04.prod.outlook.com ([fe80::24fa:6f9:8247:c5dc]) by DB9PR04MB9498.eurprd04.prod.outlook.com ([fe80::24fa:6f9:8247:c5dc%5]) with mapi id 15.20.8182.018; Tue, 26 Nov 2024 11:55:28 +0000 From: Chancel Liu To: shengjiu.wang@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, nicoleotsuka@gmail.com, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-sound@vger.kernel.org Cc: Chancel Liu Subject: [PATCH 4/4] ASoC: fsl_sai: Add sample rate constraint Date: Tue, 26 Nov 2024 20:54:40 +0900 Message-ID: <20241126115440.3929061-5-chancel.liu@nxp.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241126115440.3929061-1-chancel.liu@nxp.com> References: <20241126115440.3929061-1-chancel.liu@nxp.com> X-ClientProxiedBy: SI2P153CA0017.APCP153.PROD.OUTLOOK.COM (2603:1096:4:140::10) To DB9PR04MB9498.eurprd04.prod.outlook.com (2603:10a6:10:360::21) Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR04MB9498:EE_|DU2PR04MB8504:EE_ X-MS-Office365-Filtering-Correlation-Id: 1bed7ee7-7a3d-4d9d-85c0-08dd0e113840 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|7416014|1800799024|366016|38350700014|921020; X-Microsoft-Antispam-Message-Info: uES1/8jusCq1upH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+XfwUQ1J3mOFJ4kYbcPNYocf/UaDBqnJ20aG/9EPKtSNHy9AScVnG4skvmKHsf6g0+enoolR1ysfWgrxAITnA1/h4ZIKChhXeqXmYRoXkLYLdw4WhBkY794ieqPvyyRCTX+l1KsHvr82n5ka22apVjkrszwmLR+Br0aSj6YPbwOqRahUfU6qA/6kvlQGrydrPlb/TQLHyYjVTy7cwMDkM/TFUxVmSH18MsCuhXBsCl2Kfg2OMpKOoqTjsr7xtqrQ8I50sZDryUKtymamif7eFeCJn+crtBo/3cL82hWnMC3UBzf0fmB2qyrCcxKbOLJxjjx48nX65oH+EIiODl3J3seNVNsj6a9IfFLsfA= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR04MB9498.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(7416014)(1800799024)(366016)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +Cv9tovx8YZC/961u/vMPc2mebWdhMbBVSKH9EMqPJt70Kj271N0W0Xb2SA59okrP2c951VnJQY+/FHurOshPyMn3/u2Ebq3xiR+pk9qmsvu6upZ4qZIRWpQiZEw00iW/yD2jxYA22rK4jgC0wCoCrl09SMHJoNqNH5Zt4Dc0GNbD2IkqIiZGyDz3B4vwgDJSL48zapfm15cBYEclajKFV6MxH4Auo5C0OT/dOo4+5AOlvnTOCNiGl6NyaAaa8hgsKXmV0hAY3UC5x03tuysmuC5vYsnDqZutGTI4v/8OWj0O7SH0llS+a+C3G1k3BPbJLcFKqKurHGkRAOqQDsyBZKKIJIQMGX1fLjKmwcNHnmpHpai6rbzmHTLAVLkXF1NBtRwwWpmN6CmAKCTxR+D8CQcdUKRWQZIgnvAlveSuxaV1aXFZCGkdW8okfJg4WbId4WHbLfJy0WyaV6Sy2rGbAMZzXTo+2jI6UryOdVYF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R7cjE34TgCVwM1i4592aBkAHFYWMPJpkwlI8/xElAjqGlJyjQ X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1bed7ee7-7a3d-4d9d-85c0-08dd0e113840 X-MS-Exchange-CrossTenant-AuthSource: DB9PR04MB9498.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Nov 2024 11:55:27.9469 (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-CrossTenant-UserPrincipalName: /uqdsGTBm/Ydc90hADJfxagnQXqNDws8oJIPmWsyqKHEas94/D0ThDfCXySb3rCZ3MvKyPnKqGzCwcYzEXiSqQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8504 Platforms like i.MX93/91 only have one audio PLL. Some sample rates are not supported. If the PLL source is used for 8kHz series rates, then 11kHz series rates can't be supported. Use fsl_asoc_constrain_rates() to constrain rates according to PLL sources. Signed-off-by: Chancel Liu --- sound/soc/fsl/fsl_sai.c | 7 ++++++- sound/soc/fsl/fsl_sai.h | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index 634168d2bb6e..c4eb87c5d39e 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -885,7 +885,7 @@ static int fsl_sai_startup(struct snd_pcm_substream *substream, sai->dma_params_rx.maxburst); ret = snd_pcm_hw_constraint_list(substream->runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, &fsl_sai_rate_constraints); + SNDRV_PCM_HW_PARAM_RATE, &sai->constraint_rates); return ret; } @@ -1442,6 +1442,11 @@ static int fsl_sai_probe(struct platform_device *pdev) fsl_asoc_get_pll_clocks(&pdev->dev, &sai->pll8k_clk, &sai->pll11k_clk); + fsl_asoc_constrain_rates(&sai->constraint_rates, + &fsl_sai_rate_constraints, + sai->pll8k_clk, sai->pll11k_clk, NULL, + sai->constraint_rates_list); + /* Use Multi FIFO mode depending on the support from SDMA script */ ret = of_property_read_u32_array(np, "dmas", dmas, 4); if (!sai->soc_data->use_edma && !ret && dmas[2] == IMX_DMATYPE_MULTI_SAI) diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h index 9c4d19fe22c6..0e25e2fc7ce0 100644 --- a/sound/soc/fsl/fsl_sai.h +++ b/sound/soc/fsl/fsl_sai.h @@ -9,6 +9,7 @@ #include #include +#define FAL_SAI_NUM_RATES 20 #define FSL_SAI_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\ SNDRV_PCM_FMTBIT_S20_3LE |\ SNDRV_PCM_FMTBIT_S24_LE |\ @@ -309,6 +310,8 @@ struct fsl_sai { struct pinctrl *pinctrl; struct pinctrl_state *pins_state; struct sdma_peripheral_config audio_config[2]; + struct snd_pcm_hw_constraint_list constraint_rates; + unsigned int constraint_rates_list[FAL_SAI_NUM_RATES]; }; #define TX 1