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//TyhS6dcpovChnI0G5QvBh4vimgnkgRyxusafRESWbNbopqaptXR42rusn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X6PnDb/941PigMXOljaukmA= 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: 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);