From patchwork Tue Oct 29 02:20:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shengjiu Wang X-Patchwork-Id: 839356 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AD638D5B861 for ; Tue, 29 Oct 2024 02:12:29 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 1874E14DD; Tue, 29 Oct 2024 03:12:18 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1874E14DD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1730167948; bh=ava76Ve8aJqozawOgULm+0WWlEIDJuGJMeLj9SKdXBc=; h=From:To:Subject:Date:In-Reply-To:References:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From; b=qn/U0gr36q8FOod6rQfUmrsI5IGyXsjUzHuzRQJ/HLQQiW28EAdsJCfUS69/doZFJ bvCXZFMDz9QEv7EGJDgXlMcVyGdYhwudaff4iyumBItCj6hobJCV34e9KjtLiu+xpB 2kotLTYnYPeEzxA8kAvZuJ4gJ6DCmd0bLdZ5DooI= Received: by alsa1.perex.cz (Postfix, from userid 50401) id A9A92F805FB; Tue, 29 Oct 2024 03:11:24 +0100 (CET) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 79CC9F805FA; Tue, 29 Oct 2024 03:11:24 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 730E1F80269; Tue, 29 Oct 2024 03:11:08 +0100 (CET) Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on20606.outbound.protection.outlook.com [IPv6:2a01:111:f403:260c::606]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 887BAF800E5 for ; Tue, 29 Oct 2024 03:11:06 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 887BAF800E5 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=nxp.com header.i=@nxp.com header.a=rsa-sha256 header.s=selector1 header.b=JFiukXWY ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sUdOqpL0fv1pkeEDN1askesJEqFIZtCTuWzVp1R60cIYKISk9KOQgQOmPSHMEYjfHscTyc2Lc9Z/8CBDAHiwpioR1QvtyMMMSRF3eKy6/6Vo3gp63EIyFuKwiY+7KSTueA80xrHLlM5J2qPGA2S+ry04u1jNyIoRv0kFjNQe82Rng0gtGpx11PhLuGSdhaUkSJ5c4Wo9UOm1IecLsi4lU4+5nqrOPljotHGTkvfAPY7Y666oS5tGlzMAQkEaBcD7yrYBGox+8Cl9oLzNZSuNjtzXSpi2I6fzQPa38x7p5O5w4Yy2omz150yf8egVN5QOfNB0X+gy1lD85BNZHa/5JA== 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=8f6ttwYZXSGqEAL54j0qzoFjSj4HqsYoO6Te5HL+rSE=; b=QPzgZ93zOEbK4T558b+w7l/D9urpZ2iBORw72h3tHD8LMD0o0T6sYB9GnRd8GZ+PLUG0lUhAheMeT+HlhJXHdj1S//1AlcH9I/r5Fer6BthCezPQbirhaDuaAug0aufnvmUSyjsM79UiY8CO0RwZ7C6fAWLyudghu6rEfcZUMl9zolSzJVenvHnkAm/XIOy4BDVsdk2qru2rg06pbXNH1CunC/Ab2XB9ORBq0M0PMo+XqO4Rw4tDse/nW4JBXlro5VAT15PvpFxfuTcA8x3BmfoUvhxxr03rEORBbV8OvLj8OHG2dc7sBQhX8FYpzCeZOXL7MtNQer4mwOjvEtcWHA== 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=8f6ttwYZXSGqEAL54j0qzoFjSj4HqsYoO6Te5HL+rSE=; b=JFiukXWYatUzHxvq9J3jY8VpT6E2B3yuG7tu6Oe2ZRBgCp9sjoRIM2slmFO941hgtSRxt4KK+xD4kZaFxfwlPA+XNFHjd+XI+vzkrG+pMG7ANQvamAfvuSS57ly/ODA6eVOPR7KB6L6w9eKeSlZL1Q6gm3wA6tCCDTOqfc/mYuLkbscxBWuHRLisNYVZmBY69OYQwwzOoC71Qs7nhcX0eqDXJcPAq+z6aU3Uhd/zEn/m51lhvnWNilEdQwidK0kjBi4JOYzooKpYZ3uWob09l80XWb6p7clEVLfDitRokohUhG599pnqGf18urlRnF9fcnI+ucUwwIvQbo9Xzf6fGg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB7044.eurprd04.prod.outlook.com (2603:10a6:208:191::20) by DU2PR04MB9147.eurprd04.prod.outlook.com (2603:10a6:10:2f6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Tue, 29 Oct 2024 02:11:04 +0000 Received: from AM0PR04MB7044.eurprd04.prod.outlook.com ([fe80::7be0:296:768c:e891]) by AM0PR04MB7044.eurprd04.prod.outlook.com ([fe80::7be0:296:768c:e891%6]) with mapi id 15.20.8093.023; Tue, 29 Oct 2024 02:11:04 +0000 From: Shengjiu Wang To: vkoul@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, shengjiu.wang@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, nicoleotsuka@gmail.com, lgirdwood@gmail.com, broonie@kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH v5 2/6] ASoC: fsl_asrc: define functions for memory to memory usage Date: Tue, 29 Oct 2024 10:20:53 +0800 Message-Id: <20241029022057.816402-3-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20241029022057.816402-1-shengjiu.wang@nxp.com> References: <20241029022057.816402-1-shengjiu.wang@nxp.com> X-ClientProxiedBy: SI2PR01CA0031.apcprd01.prod.exchangelabs.com (2603:1096:4:192::11) To AM0PR04MB7044.eurprd04.prod.outlook.com (2603:10a6:208:191::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB7044:EE_|DU2PR04MB9147:EE_ X-MS-Office365-Filtering-Correlation-Id: a048be78-b605-4614-6e86-08dcf7bef12e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|7416014|376014|52116014|1800799024|366016|38350700014|921020; X-Microsoft-Antispam-Message-Info: /1y+fV/OQfbn33QlD0y+/ATGlh+ThzIOoHZK5hjdnh1aqHYJJEnXHvJWQdW7CZy++VAdFPavgviJ9ND11/MAwyYR6H0w3U+fR7LKS84Cv/2mtd7UgiYkXp7weJ6SxtG6u8XbXxjEdvPodlv5e87y1rizhsLd+Txe+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tSSO7I4VPSC2B3RbhFT4XjvNQh86PxSCG/HzVS3XhjzI/9vnxJUA+PbZNXir0ycd8ejG1JYGrVDsr0cp1tHpDGeFJam1qZ1rVx1ymzTJoHBvMsK/r+fj3mZ8B9doKpNq8hW/KL1VLqemyCgk96oOA4ZpbfCqOeP3iCtKuM8mWZdkghSCK+HxYG3G X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB7044.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(7416014)(376014)(52116014)(1800799024)(366016)(38350700014)(921020); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: isG3eBmsSDebdBRXMqXf6ITQbDgwyYtSyQx55RAsQRfzv/nq70KlE+Lac2oNdsm4aElaFgn6sAyXxRWu7zDVnF75OjNZ1aLck0mlWgxkj1NgYyS/VhkcSGWAuG/mrp/kpc8rssgEh5W26HZY0YRMbfwU4jlictsCi47FHzLS/rz8dlvGWK+R/+dzDb/BPh7Yj3nU7moIT/GN+AmrXnGp+y/qH1nuSEWAyDsWyvBbG9TeErfT22iRv1dq2FD0UVsB/Jz+1Mgph8ROM2z2MmwUyzgimKjh9QIvsYec/U+QlFp5p5nhyr4xBJOWBISedY2m6KkD8UOswELXeFFjnFgyWEdXsp2NRTR8fiEmVJaFEXTqAAcBpXq24dmNvPbq+gjrWbn9vXsNvDOvXGluG6GSGbe2ZHDFD8NG1cn4r2rndOTfOOga1uqZ0+OlHc6fZnL2+1QtYAoTEEzl7bLWaiYHAGOFBSz6G23IXCpM2BdP0kcJfxxhegXwmsNvztV7Mbl6EHnL8eq3Y+cCHvpAG4NUfD7SrC1/71yyTI0qIBTNRsHAqTMaT+xn31sdABWGNPdIYx3z8NmKM6S7An/jm/Zrw8UfNtr+U3qipKgjPyzLdGRQDgG1hUOVi52QkOQI6NkcoLI6gaXeYzr2dcVLwqR6QnQJIjCsAaO58V6kQSE3bzDlEwa2c4cXJHwLG9Yz8vjb2IGnmDzX7t3Hhu0N12Io8mcjkeh37G5hA24ks5CBwARWxJ6i1MoZ/NfoabJkzxAg+qNIydU13H787rnF5tKhvwUCT30+4xgJPTpDLlEmvSF5JjMmU+6yVl8+hVbrPjQ58BSAZVcUKSkyzp7Xd/EgfHCaPomyZxlMASdpuGXKdLnkHkESNCIfUWUR2eFHA6dHMn7LAkIEc5J//rgFgzju0wVaD6tMFZIgAemfOe/5bC97KNwFi8zyfS0ztxxO3mwpeGdYdt6ZRdO3RNpxoKhIpr/8E8kcKZZ5vU6/ARfkmEvp/UGRWajvrvFc7rtQyZHO8KlsqBNTYFbkANnmiZvRYIcuMlRMPOZ/8+x7MrpEoa2peVdF1g9DajrTADS5IP+rmWW8rynjnZEwbXXhtRVGzbia/9Zbw6VWe9TG8++Jrg4dHdlptR2rNGwNmpZHMA+aGwf08Sc23NrV1XWgx+12IhaA3bdm/+zkpnHjuHEymsGO3YOEYPlN+fX1OPnPxQV2NLu3T4aR+vK/I3JKF94LgknFqrIganBGykwqcD7Sp+eDKZ7egNZwfz92pHvsqiGsbElxIrGKYo0sJRU6zyiTexxA1cnT/AYZ1Xb/WH8/W4XS+Is2bYjk1NE1CBX5+lYEVAx2POlp6pM7K4ffN/ftjZeTh5/Fx1H3TfyuvWkR0bIrprL8wB/3FVtK45mjeU/YGW6x88MNg1t1khzL8gOsBv35JWIAMd6IespTYfjYEYJtX/4b6Oh8lgWKsqCYz3NNu4YHZjrMbPuQUzYdl8b2H2s8lQYwdgI93r2a5AsUsAMmdQEOPcHq3OAw7MAB6yU36hp7EzEb63vowcO7B0PL+19PF8CGLUS5GaQkcvocbLJZFgi9oWsF6yl2q1ll26Id X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a048be78-b605-4614-6e86-08dcf7bef12e X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB7044.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 02:11:04.5255 (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: 21XftQy0JUf/YBg3qXSxhJG6BvLmLud6/+hsxA5hsp2PQDTc0rAaF9j/pUAxrs06AOBar+ng4VJoNepbr8+wjA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB9147 Message-ID-Hash: 4UEQPLCLTKNQKV2NOSO44IWKEN5VVUCQ X-Message-ID-Hash: 4UEQPLCLTKNQKV2NOSO44IWKEN5VVUCQ X-MailFrom: shengjiu.wang@nxp.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: ASRC can be used on memory to memory case, define several functions for m2m usage. m2m_prepare: prepare for the start step m2m_start: the start step m2m_unprepare: unprepare for stop step, optional m2m_stop: stop step m2m_check_format: check format is supported or not m2m_calc_out_len: calculate output length according to input length m2m_get_maxburst: burst size for dma m2m_pair_suspend: suspend function of pair, optional. m2m_pair_resume: resume function of pair get_output_fifo_size: get remaining data size in FIFO Signed-off-by: Shengjiu Wang Acked-by: Jaroslav Kysela --- sound/soc/fsl/fsl_asrc.c | 142 ++++++++++++++++++++++++++++++++ sound/soc/fsl/fsl_asrc.h | 2 + sound/soc/fsl/fsl_asrc_common.h | 61 ++++++++++++++ 3 files changed, 205 insertions(+) diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c index bd5c46d763c0..471753276209 100644 --- a/sound/soc/fsl/fsl_asrc.c +++ b/sound/soc/fsl/fsl_asrc.c @@ -1063,6 +1063,139 @@ static int fsl_asrc_get_fifo_addr(u8 dir, enum asrc_pair_index index) return REG_ASRDx(dir, index); } +/* Get sample numbers in FIFO */ +static unsigned int fsl_asrc_get_output_fifo_size(struct fsl_asrc_pair *pair) +{ + struct fsl_asrc *asrc = pair->asrc; + enum asrc_pair_index index = pair->index; + u32 val; + + regmap_read(asrc->regmap, REG_ASRFST(index), &val); + + val &= ASRFSTi_OUTPUT_FIFO_MASK; + + return val >> ASRFSTi_OUTPUT_FIFO_SHIFT; +} + +static int fsl_asrc_m2m_prepare(struct fsl_asrc_pair *pair) +{ + struct fsl_asrc_pair_priv *pair_priv = pair->private; + struct fsl_asrc *asrc = pair->asrc; + struct device *dev = &asrc->pdev->dev; + struct asrc_config config; + int ret; + + /* fill config */ + config.pair = pair->index; + config.channel_num = pair->channels; + config.input_sample_rate = pair->rate[IN]; + config.output_sample_rate = pair->rate[OUT]; + config.input_format = pair->sample_format[IN]; + config.output_format = pair->sample_format[OUT]; + config.inclk = INCLK_NONE; + config.outclk = OUTCLK_ASRCK1_CLK; + + pair_priv->config = &config; + ret = fsl_asrc_config_pair(pair, true); + if (ret) { + dev_err(dev, "failed to config pair: %d\n", ret); + return ret; + } + + pair->first_convert = 1; + + return 0; +} + +static int fsl_asrc_m2m_start(struct fsl_asrc_pair *pair) +{ + if (pair->first_convert) { + fsl_asrc_start_pair(pair); + pair->first_convert = 0; + } + /* + * Clear DMA request during the stall state of ASRC: + * During STALL state, the remaining in input fifo would never be + * smaller than the input threshold while the output fifo would not + * be bigger than output one. Thus the DMA request would be cleared. + */ + fsl_asrc_set_watermarks(pair, ASRC_FIFO_THRESHOLD_MIN, + ASRC_FIFO_THRESHOLD_MAX); + + /* Update the real input threshold to raise DMA request */ + fsl_asrc_set_watermarks(pair, ASRC_M2M_INPUTFIFO_WML, + ASRC_M2M_OUTPUTFIFO_WML); + + return 0; +} + +static int fsl_asrc_m2m_stop(struct fsl_asrc_pair *pair) +{ + if (!pair->first_convert) { + fsl_asrc_stop_pair(pair); + pair->first_convert = 1; + } + + return 0; +} + +/* calculate capture data length according to output data length and sample rate */ +static int fsl_asrc_m2m_calc_out_len(struct fsl_asrc_pair *pair, int input_buffer_length) +{ + unsigned int in_width, out_width; + unsigned int channels = pair->channels; + unsigned int in_samples, out_samples; + unsigned int out_length; + + in_width = snd_pcm_format_physical_width(pair->sample_format[IN]) / 8; + out_width = snd_pcm_format_physical_width(pair->sample_format[OUT]) / 8; + + in_samples = input_buffer_length / in_width / channels; + out_samples = pair->rate[OUT] * in_samples / pair->rate[IN]; + out_length = (out_samples - ASRC_OUTPUT_LAST_SAMPLE) * out_width * channels; + + return out_length; +} + +static int fsl_asrc_m2m_get_maxburst(u8 dir, struct fsl_asrc_pair *pair) +{ + struct fsl_asrc *asrc = pair->asrc; + struct fsl_asrc_priv *asrc_priv = asrc->private; + int wml = (dir == IN) ? ASRC_M2M_INPUTFIFO_WML : ASRC_M2M_OUTPUTFIFO_WML; + + if (!asrc_priv->soc->use_edma) + return wml * pair->channels; + else + return 1; +} + +static int fsl_asrc_m2m_get_cap(struct fsl_asrc_m2m_cap *cap) +{ + cap->fmt_in = FSL_ASRC_FORMATS; + cap->fmt_out = FSL_ASRC_FORMATS | SNDRV_PCM_FMTBIT_S8; + + cap->rate_in = supported_asrc_rate; + cap->rate_in_count = ARRAY_SIZE(supported_asrc_rate); + cap->rate_out = supported_asrc_rate; + cap->rate_out_count = ARRAY_SIZE(supported_asrc_rate); + cap->chan_min = 1; + cap->chan_max = 10; + + return 0; +} + +static int fsl_asrc_m2m_pair_resume(struct fsl_asrc_pair *pair) +{ + struct fsl_asrc *asrc = pair->asrc; + int i; + + for (i = 0; i < pair->channels * 4; i++) + regmap_write(asrc->regmap, REG_ASRDI(pair->index), 0); + + pair->first_convert = 1; + return 0; +} + static int fsl_asrc_runtime_resume(struct device *dev); static int fsl_asrc_runtime_suspend(struct device *dev); @@ -1147,6 +1280,15 @@ static int fsl_asrc_probe(struct platform_device *pdev) asrc->get_fifo_addr = fsl_asrc_get_fifo_addr; asrc->pair_priv_size = sizeof(struct fsl_asrc_pair_priv); + asrc->m2m_prepare = fsl_asrc_m2m_prepare; + asrc->m2m_start = fsl_asrc_m2m_start; + asrc->m2m_stop = fsl_asrc_m2m_stop; + asrc->get_output_fifo_size = fsl_asrc_get_output_fifo_size; + asrc->m2m_calc_out_len = fsl_asrc_m2m_calc_out_len; + asrc->m2m_get_maxburst = fsl_asrc_m2m_get_maxburst; + asrc->m2m_pair_resume = fsl_asrc_m2m_pair_resume; + asrc->m2m_get_cap = fsl_asrc_m2m_get_cap; + if (of_device_is_compatible(np, "fsl,imx35-asrc")) { asrc_priv->clk_map[IN] = input_clk_map_imx35; asrc_priv->clk_map[OUT] = output_clk_map_imx35; diff --git a/sound/soc/fsl/fsl_asrc.h b/sound/soc/fsl/fsl_asrc.h index 86d2422ad606..1c492eb237f5 100644 --- a/sound/soc/fsl/fsl_asrc.h +++ b/sound/soc/fsl/fsl_asrc.h @@ -12,6 +12,8 @@ #include "fsl_asrc_common.h" +#define ASRC_M2M_INPUTFIFO_WML 0x4 +#define ASRC_M2M_OUTPUTFIFO_WML 0x2 #define ASRC_DMA_BUFFER_NUM 2 #define ASRC_INPUTFIFO_THRESHOLD 32 #define ASRC_OUTPUTFIFO_THRESHOLD 32 diff --git a/sound/soc/fsl/fsl_asrc_common.h b/sound/soc/fsl/fsl_asrc_common.h index 7e1c13ca37f1..3bdd6ea07c09 100644 --- a/sound/soc/fsl/fsl_asrc_common.h +++ b/sound/soc/fsl/fsl_asrc_common.h @@ -21,6 +21,26 @@ enum asrc_pair_index { #define PAIR_CTX_NUM 0x4 +/** + * struct fsl_asrc_m2m_cap - capability data + * @fmt_in: input sample format + * @fmt_out: output sample format + * @chan_min: minimum channel number + * @chan_max: maximum channel number + * @rate_in: minimum rate + * @rate_out: maximum rete + */ +struct fsl_asrc_m2m_cap { + u64 fmt_in; + u64 fmt_out; + int chan_min; + int chan_max; + const unsigned int *rate_in; + int rate_in_count; + const unsigned int *rate_out; + int rate_out_count; +}; + /** * fsl_asrc_pair: ASRC Pair common data * @@ -34,6 +54,13 @@ enum asrc_pair_index { * @pos: hardware pointer position * @req_dma_chan: flag to release dev_to_dev chan * @private: pair private area + * @complete: dma task complete + * @sample_format: format of m2m + * @rate: rate of m2m + * @buf_len: buffer length of m2m + * @dma_buffer: buffer pointers + * @first_convert: start of conversion + * @ratio_mod: ratio modification */ struct fsl_asrc_pair { struct fsl_asrc *asrc; @@ -49,6 +76,15 @@ struct fsl_asrc_pair { bool req_dma_chan; void *private; + + /* used for m2m */ + struct completion complete[2]; + snd_pcm_format_t sample_format[2]; + unsigned int rate[2]; + unsigned int buf_len[2]; + struct snd_dma_buffer dma_buffer[2]; + unsigned int first_convert; + unsigned int ratio_mod; }; /** @@ -72,6 +108,17 @@ struct fsl_asrc_pair { * @request_pair: function pointer * @release_pair: function pointer * @get_fifo_addr: function pointer + * @m2m_get_cap: function pointer + * @m2m_prepare: function pointer + * @m2m_start: function pointer + * @m2m_unprepare: function pointer + * @m2m_stop: function pointer + * @m2m_calc_out_len: function pointer + * @m2m_get_maxburst: function pointer + * @m2m_pair_suspend: function pointer + * @m2m_pair_resume: function pointer + * @m2m_set_ratio_mod: function pointer + * @get_output_fifo_size: function pointer * @pair_priv_size: size of pair private struct. * @private: private data structure */ @@ -97,6 +144,20 @@ struct fsl_asrc { int (*request_pair)(int channels, struct fsl_asrc_pair *pair); void (*release_pair)(struct fsl_asrc_pair *pair); int (*get_fifo_addr)(u8 dir, enum asrc_pair_index index); + int (*m2m_get_cap)(struct fsl_asrc_m2m_cap *cap); + + int (*m2m_prepare)(struct fsl_asrc_pair *pair); + int (*m2m_start)(struct fsl_asrc_pair *pair); + int (*m2m_unprepare)(struct fsl_asrc_pair *pair); + int (*m2m_stop)(struct fsl_asrc_pair *pair); + + int (*m2m_calc_out_len)(struct fsl_asrc_pair *pair, int input_buffer_length); + int (*m2m_get_maxburst)(u8 dir, struct fsl_asrc_pair *pair); + int (*m2m_pair_suspend)(struct fsl_asrc_pair *pair); + int (*m2m_pair_resume)(struct fsl_asrc_pair *pair); + int (*m2m_set_ratio_mod)(struct fsl_asrc_pair *pair, int val); + + unsigned int (*get_output_fifo_size)(struct fsl_asrc_pair *pair); size_t pair_priv_size; void *private; From patchwork Tue Oct 29 02:20:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shengjiu Wang X-Patchwork-Id: 839355 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B8AE9D5B840 for ; Tue, 29 Oct 2024 02:13:00 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id EBB70E82; Tue, 29 Oct 2024 03:12:48 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz EBB70E82 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1730167979; bh=Kga5T+ah2FU3Ou2fNm/+P5B4ui4zBo7U8oJFsAlVAeU=; h=From:To:Subject:Date:In-Reply-To:References:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From; b=ezIHOXIxaEnguCZPh97La/P9eufhk9/t4RT0Nul71hcjJ+qBEfdq66PD+K7CjS+yF YymEOU+xDW0Dznq7Rd70tS5YFTa8+XRpGgrhqzlMs2rOBShnAqWj4qRPalOKXpM/A2 /cbialADRDUqZXciwqhi2fEBLn5BwZwxh/G4d83o= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 80521F8063D; Tue, 29 Oct 2024 03:11:33 +0100 (CET) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 744B2F8065D; Tue, 29 Oct 2024 03:11:33 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6D8C7F805EA; Tue, 29 Oct 2024 03:11:22 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on20602.outbound.protection.outlook.com [IPv6:2a01:111:f403:2614::602]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id AA9B4F805E5 for ; Tue, 29 Oct 2024 03:11:19 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz AA9B4F805E5 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=nxp.com header.i=@nxp.com header.a=rsa-sha256 header.s=selector1 header.b=aOL2ecp8 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TBZkCS3hU1ki8Qbz3YPLdxYHkzGcPpGb/YkVUdhmirVKr4JJ+Q4T02GzUjc70mrJemMtozMrQc34B+nDd/DCaZnnDwP+yhRiSs/nyqsgyBAD2s7YGDnBlWf/kthOF1suivQSFXC1jPaiTjSPdOJHLAela4SR7r9DZ0mMO5NOEcsDaTrmjOyq2juECZ1D2s30WcGgbtC6Uh2VijkbB4Zre2IHPHYLETzUWpMS6UVXj23GhovR20R2np/DGX2plmtzU19d5ykzd7dMwB6+5xAmxZIRv3kwL8/omXtsfMFXMMPjqksc0aNCMMfHTNvqH123zUbMk59YQoPcx9Ed9/YL/g== 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=Gx4r59MsUrRSAYnRBL2LULLZNbMWnLuBxzcN1FydhN0=; b=dvCybpT4QjK1gZ3p+ErgfwKL3LufPCamknLi7pP4Pd5oGnbk6hwPxRkWBhJt3VNZNn5MxqBv8hM3CAL0Jbw2u4MUeY4N62LRktOiXv5kd7CViY8Jjo/KeUJebKrXSf6a0uWDQuPzwKSsjc5RCacMdGfH4VWrfE+plN7Qz8VPtKt1Bdnr4rQ/IjTdqodRk0egU12n+nHzpSgx+5NtfjczuGXDwJ7rkj25A4AyJZBTlEi6/dNYlo+bTYUGI41Ptsi6a0qF4sujm7WHmKerss/nH4oN11NtnLoy7AQAia19rd8f9Pp14rgOU+5cVpnwgFnP9mXoFYKVGDjBJn247tm03w== 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=Gx4r59MsUrRSAYnRBL2LULLZNbMWnLuBxzcN1FydhN0=; b=aOL2ecp8vC6w0n8PpwGe9ysa54x7ufbhe9+dlX1WDatg1WLHm/nPcdSxymvq52Dw3JJZiIJiTA/nX9jDFhdWTamUrm19P82yBXd/mqvjGRY6ujiPNDPHTKMCR07Wi5rlakKFEHJcFc2+tLpi6mQ+92RkmFPO7y+SqbwzMNf1NZSkio/CzxIETVOuGNWQ0v2+5ZsyUwqPb77jQFgCxN+0421W9aCXSkVslVWPMqHu+5DJM7Y0w8BOJSsPKLWmCSAo8ONf9yRvS/vRuzXf/egY/FuIKiEbu0LERHpfgvl1nqPA4vJ66O5bWizYCVo1ZMS0N619cHC4FeOrFieQnnZodQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB7044.eurprd04.prod.outlook.com (2603:10a6:208:191::20) by DU2PR04MB9147.eurprd04.prod.outlook.com (2603:10a6:10:2f6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Tue, 29 Oct 2024 02:11:17 +0000 Received: from AM0PR04MB7044.eurprd04.prod.outlook.com ([fe80::7be0:296:768c:e891]) by AM0PR04MB7044.eurprd04.prod.outlook.com ([fe80::7be0:296:768c:e891%6]) with mapi id 15.20.8093.023; Tue, 29 Oct 2024 02:11:17 +0000 From: Shengjiu Wang To: vkoul@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, shengjiu.wang@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, nicoleotsuka@gmail.com, lgirdwood@gmail.com, broonie@kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH v5 5/6] ASoC: fsl_asrc: register m2m platform device Date: Tue, 29 Oct 2024 10:20:56 +0800 Message-Id: <20241029022057.816402-6-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20241029022057.816402-1-shengjiu.wang@nxp.com> References: <20241029022057.816402-1-shengjiu.wang@nxp.com> X-ClientProxiedBy: SI2PR01CA0031.apcprd01.prod.exchangelabs.com (2603:1096:4:192::11) To AM0PR04MB7044.eurprd04.prod.outlook.com (2603:10a6:208:191::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB7044:EE_|DU2PR04MB9147:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f95093f-d085-4eda-ad8e-08dcf7bef8c7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|7416014|376014|52116014|1800799024|366016|38350700014|921020; X-Microsoft-Antispam-Message-Info: 0WvsFjvQXmSyU518eiY0qatYO18A7wHjhFSgiNOruqx9Ycd11LJS40PkyDy/JRppbuKA7KUmnPd/F6i2uVFGxlg9Y/MhDeUHtAniv/yxU1TMSZrK6vCjP3JOtMVWmGyFdGbw7yZrSJY/EHUms8JGl6YDiqpNcuH+p/WndSGNfRr/prwoEy7vmtfg0d/U8SMP49Shf9X8wXZbW15LBzis67OrnC8rNsN40Fw2YtyuqSTIsO1plJJU9T4/fdo2e0qTEf/M/1jiMJtwdTT5ezs6/0aYu8T7BkDRV4nNTiX0b+y5ezDHUV5aqDhkfzyUxxCpKQvcoEAag7W9Y4zFSS1zdXWNs+hSbEFtwWdQ4pZMfWKcQjw2fbSKRTVXWxOlB2SgUYRAP5deeyLfLi4k+H6Vvf3MakFtkAnBibMo8tjkzj5kUkItbNha485DjUML3rE8h4hz1YRb2AHh2lRTn1Kuox6yiuBFa+9LzkcSTCMHuTWVTaQkvLKRO4ngZIZTmghzNGwlTCK6RzeKKWjzwk3yLMu1cIOLZD9Fp+NVFmTZiFxrsYNbpXV1PRc6GAKm2qrsxuHfCKV2+mhoaPvDLX2CQpkBPrbvQ+N71tS4iD+2c4l9XjwVDG1p4hMvtJLIkssebatbsSH4zbL2rW1BXidKZSpO1awL1CrrVo8zsFKw93nXfE63KF1O7HN/rMImeKpF+W27XbUZBqQahUSRiQH2CcaUtJZmNsJuE4N+kqu/PqgmI3fbo0I8c6q+t/jpAYFDczysCVPikPSwaFP02rKzWsbsuEps4kfC2dzet5ptbN2lMSfDeCfWV8osztS/h0TlF2gc/MnzOT82KKALO2E7twOaebrNt08YM8yHdANtT19mjEspzUUfVp8yiEu9yLyYa19f9Cn4w+mxbRMLItzTCxaV+wP3cV5tcBhSTLAOBrFGQMuGvZ3DZfCAdWWH1N3Bkz9VQYlQsnyiy28SoPHFfV9w6W00PiZQ7QYnVVna2/soaluuMqTVobyTsMDCNWHrq/kR3gDXjIoRBNuV9MjdialxsQ20OA1z+B4Qou8nktWAsFuxWwJ8y1QYG472kLTa9gcEieUpxF8Odd9b4mnBsB+vLazt0wY9U8wVMlFj3yo7QnQ3ihK0zr3ric7BB1Srfl9yJ0370PO9sBjvIsLN4gXLvynpCtIV5Kap1HQHcP0gBAR6N1gZDEWQUhCnOe39t14xgF4eVVwFuRR1ZegCqTePz6PBz+Ju6vQFZTlBZqtDkU7QDh6otrhUQH4VF7uwFTL9lB8XaQD/tXXmzyBA2tZHrs7Bfe+5jjdaXQx5xvjFKGd3WHLNgqNaY/ErF4NSXzr0ZVuM8VLNBTFdVklDIFIrTBMbuaGJu7F6effO43T9tqosJAGtsMZzDWsj5H2m X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB7044.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(7416014)(376014)(52116014)(1800799024)(366016)(38350700014)(921020); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +utBqn+a6OjbEFUNtA9yVzn3Cr5svIzAcVNhc9nAvMK6rPj8kRdo2ENdjra1udnCB+V6X0bEPHI2SAHir9DOdZli3Sb4JPihEuMsqvCGA76pKYC0CVKT9cMJ+ZPlSbk7DrvNuJF15K/2xkIbRZWU60Qcpd0zFnQ7f5ZBUzxy/7Cr/BBcVdMLAHVI4q0OI/P3kd/uHD1D06U5ODlcSkCyLTkeaxPDaoRudplG352r1qntejbCHfI2bPe+iMNQF3D495aGRCuISgB9+SYbv5GvTzdPOeES+KW7ofmyOQP7l6rirU1Opp7NjpQjGlt0FsdN4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Vse6UHKD9+zqk73Gh8q7SUo3/JYraLJrM9NmRAZqXmqklZFMF2V0uytPmi5/NQ5yq8COTLxH5OaZInXj4TjJ7A0ODonljJP8P0XKQjAk1HwZUuNgauxZ7AuLdL0NOUjmARFY3NEhGyUrR+vYe4dLHzUyCAGCt0yw/rcAyYOXdg1Ik8XuzL66VGJT/wLCCK8SMfv/kcGgUYI+GpWbGiuNFEF51p X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8f95093f-d085-4eda-ad8e-08dcf7bef8c7 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB7044.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 02:11:17.2169 (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: kYmqjwN6PBY9NkC15EvlOJsr0OpHTGXKuywFbc2Mqkr+IEL3733hO+GKRiSOz2qi7kQSH5KVH+jhwikGCZCAnQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB9147 Message-ID-Hash: GFANGKQNBQ2KPUH7OIESTTNWHB7T3WQA X-Message-ID-Hash: GFANGKQNBQ2KPUH7OIESTTNWHB7T3WQA X-MailFrom: shengjiu.wang@nxp.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Register m2m platform device, that user can use M2M feature. Signed-off-by: Shengjiu Wang Acked-by: Jaroslav Kysela --- sound/soc/fsl/fsl_asrc.c | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c index 471753276209..677529916dc0 100644 --- a/sound/soc/fsl/fsl_asrc.c +++ b/sound/soc/fsl/fsl_asrc.c @@ -1384,6 +1384,12 @@ static int fsl_asrc_probe(struct platform_device *pdev) goto err_pm_get_sync; } + ret = fsl_asrc_m2m_init(asrc); + if (ret) { + dev_err(&pdev->dev, "failed to init m2m device %d\n", ret); + return ret; + } + return 0; err_pm_get_sync: @@ -1396,6 +1402,10 @@ static int fsl_asrc_probe(struct platform_device *pdev) static void fsl_asrc_remove(struct platform_device *pdev) { + struct fsl_asrc *asrc = dev_get_drvdata(&pdev->dev); + + fsl_asrc_m2m_exit(asrc); + pm_runtime_disable(&pdev->dev); if (!pm_runtime_status_suspended(&pdev->dev)) fsl_asrc_runtime_suspend(&pdev->dev); @@ -1497,10 +1507,29 @@ static int fsl_asrc_runtime_suspend(struct device *dev) return 0; } +static int fsl_asrc_suspend(struct device *dev) +{ + struct fsl_asrc *asrc = dev_get_drvdata(dev); + int ret; + + fsl_asrc_m2m_suspend(asrc); + ret = pm_runtime_force_suspend(dev); + return ret; +} + +static int fsl_asrc_resume(struct device *dev) +{ + struct fsl_asrc *asrc = dev_get_drvdata(dev); + int ret; + + ret = pm_runtime_force_resume(dev); + fsl_asrc_m2m_resume(asrc); + return ret; +} + static const struct dev_pm_ops fsl_asrc_pm = { - SET_RUNTIME_PM_OPS(fsl_asrc_runtime_suspend, fsl_asrc_runtime_resume, NULL) - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, - pm_runtime_force_resume) + RUNTIME_PM_OPS(fsl_asrc_runtime_suspend, fsl_asrc_runtime_resume, NULL) + SYSTEM_SLEEP_PM_OPS(fsl_asrc_suspend, fsl_asrc_resume) }; static const struct fsl_asrc_soc_data fsl_asrc_imx35_data = { @@ -1538,7 +1567,7 @@ static struct platform_driver fsl_asrc_driver = { .driver = { .name = "fsl-asrc", .of_match_table = fsl_asrc_ids, - .pm = &fsl_asrc_pm, + .pm = pm_ptr(&fsl_asrc_pm), }, }; module_platform_driver(fsl_asrc_driver); From patchwork Tue Oct 29 02:20:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shengjiu Wang X-Patchwork-Id: 839354 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 47986D5B861 for ; Tue, 29 Oct 2024 02:13:34 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 5041C14F7; Tue, 29 Oct 2024 03:13:22 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5041C14F7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1730168012; bh=oROrbigEnbxBbJQZmQCz+t1ZoYRdoE4L/rIVMdGvE9E=; h=From:To:Subject:Date:In-Reply-To:References:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From; b=rCNvxgUjXfCTRLD/Vw5pI5YL2HmuEkgn+y3yHAR2jy6ddxCKdiyyRm2ManctIbPP2 ngZf7ax0yY5vRQmbiNdMfXJShqfq8NqYLo6UZx61tfXv22t82la5r/tNU+b2y3BOcG 4NEAYju3/FNJ9snQZ4lwUhS2+xrHyv1G5PLFL1lc= Received: by alsa1.perex.cz (Postfix, from userid 50401) id CB949F806AC; Tue, 29 Oct 2024 03:11:40 +0100 (CET) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id E797EF806AD; Tue, 29 Oct 2024 03:11:39 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E724CF80605; Tue, 29 Oct 2024 03:11:25 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on20617.outbound.protection.outlook.com [IPv6:2a01:111:f403:2613::617]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 6685DF805E8 for ; Tue, 29 Oct 2024 03:11:22 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6685DF805E8 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=nxp.com header.i=@nxp.com header.a=rsa-sha256 header.s=selector1 header.b=E7LMXz12 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=apPFZ3jvfwTYMeKUmjYcmRSzXRnT/Wc2mqS/P6rDGaF26ZlDAMwgj+H+A9XaRRqQ0caggmcqzjP+XFOmUbmYMEl6t0Y18Ji1vnyElthjQCAsOPTi76/v169a5CSHP1A5vLFQ3C+ahMA+jpUv3RF088rGNtMycfNobMo2MdnwoKqxKppE3OzDPpKg/pY6I08t/mUevuguTqx0Hus4d4DJppNDNInoelAzuWi3rGswb7tdVsmFHUsscCvHbuj4ucYGAMnX88KaHz2iDFLWsMbSk2vQTnBoMrqp22hjYQA6qIHzSwOCaDFHvHGGVYDKCXgQFguV5sAug/m5o/FQnVaByg== 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=mJK8WWOvDdKnJn03HGc+yupP/YXIOxc9ngBNgUkeoqw=; b=cP5g4Zbt9sQ9EbwwaD6e1d1Zp5OOV1Q2743J1gGBoNG1LK54KW8PBpZcn1f5EZeNOVKUpGpY5if9PHRAnycesKeuK0/KsVUfRHQb1rYtfhfLmkrbztXYIS+iZhHI0tb5SwlchY/WgGmFOlZ0XOZNFhZa5SvDzuWa6wOL1utpVPwFlVMjf6CaLByR8wtNAuPaGAUbsNSzYd+08nc3Hwx4m7NBdg21YCNQ1QXn9rGEQi7T9HXStzwxinElCF1ojQDocX5ak+E+swDHgxi8mNN5yTVbxCBcBnvtMadQK4CDTCSrP+SQ/cFA6Yp4PTsQJW+ica4KCoa9YZzoe25hBiPzSg== 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=mJK8WWOvDdKnJn03HGc+yupP/YXIOxc9ngBNgUkeoqw=; b=E7LMXz12oYjBIXSmkGyreSOxg2zwTYpCaD6amLdiMX0ODhuykxHQftAFQseXo2ZNG0rfZRYpNtMbLEtIXmov/TOVw2Ebyv6cFWLTnILR+cWcAvqQ3Vr9s6YHZHHJBvesHwnM1dJBPUL/NGMzV5+HolUt4ptgdF5VaVBZOOuGWQ19cRd1FEP4+RjBZik98sewAWzvgnUgDVFKdDrRCis4B+j48XUqpELA9iTaQtPm3vQBJ3ygWF8XB/Y+tRrxrsNVGVDyq+rdI2lovK069UKRLmvJ9VsQ/oFR2Ms9zmuiqX3RylaRLKSgQIW3B67YVYuPqeDYWBMnyu6eUQf5l2CyMg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB7044.eurprd04.prod.outlook.com (2603:10a6:208:191::20) by DU2PR04MB9147.eurprd04.prod.outlook.com (2603:10a6:10:2f6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Tue, 29 Oct 2024 02:11:21 +0000 Received: from AM0PR04MB7044.eurprd04.prod.outlook.com ([fe80::7be0:296:768c:e891]) by AM0PR04MB7044.eurprd04.prod.outlook.com ([fe80::7be0:296:768c:e891%6]) with mapi id 15.20.8093.023; Tue, 29 Oct 2024 02:11:21 +0000 From: Shengjiu Wang To: vkoul@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, shengjiu.wang@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, nicoleotsuka@gmail.com, lgirdwood@gmail.com, broonie@kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH v5 6/6] ASoC: fsl_easrc: register m2m platform device Date: Tue, 29 Oct 2024 10:20:57 +0800 Message-Id: <20241029022057.816402-7-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20241029022057.816402-1-shengjiu.wang@nxp.com> References: <20241029022057.816402-1-shengjiu.wang@nxp.com> X-ClientProxiedBy: SI2PR01CA0031.apcprd01.prod.exchangelabs.com (2603:1096:4:192::11) To AM0PR04MB7044.eurprd04.prod.outlook.com (2603:10a6:208:191::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB7044:EE_|DU2PR04MB9147:EE_ X-MS-Office365-Filtering-Correlation-Id: 69298e5c-ef12-41e4-fb96-08dcf7befb71 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|7416014|376014|52116014|1800799024|366016|38350700014|921020; X-Microsoft-Antispam-Message-Info: CSn5g2pj1+RrIIq2+nsWDMRV51vRg5EAhG94ssvjkDtrp65KcPOuO71xxlabtYM63mfNgDq30X++Vt7fuTNj6/OQoHCF2PEW+Cw9MHPn8uNcpUa9m2spAotdqtt8to/DzP4K581F029Ir6+6Z1lyrxGK9tw32PfQrDeJB5V1v+IdYjJuTkkt/hDP7a8u6WMAybSnuD9Oxeh6+iSThJ+USTUdvOLxHyqyryjtUn4fwLj1OhGYZ/6of4zvyRcWfIF5faF9zPYXdZSTLp+AOcZ0yje6pSZ5CqgPK3iPuA3ThUIwhpVzFP3cwbX+coV2hcG6Z4iidO9anIewNfVNHCWnf8xZ1YJRrp8N++gsXx/rN5LK42GjJs3JC3ifTe2AeZtUpq/yIeev5K39+I/FueaeBqvf4gPpOaLvsZ4JTUjZ/dxOKEjsSBls8v1TZre7yRE4CLFJNQ97Y9I/Xdbud7xGXacUvcgsscklXhMaTTAj+Vg00p0YjE3Xs4YFJQnRkwdmUCf+UUgiBmgxZv24vVNFH/mfYqGSmXGGsIp0mYrwd+fx97iiJeRoZgMQyOC6X0OQpekivpRm4xilpNuwbN4oo1r3wOoeBuHkgc7VGp53xwyjlPPqgvAojI0KNMBwOxK9NOBaIMhC9TUZaRlnGOAvhEgnu1jSbZ/EJ8bfA5KQegQakvcMz/0pityYLOuQQCdOygTLwWPCZ/pvCZp7sk9RDS4dTKKKGHAeX1wzZl7DRjAfddChqr1y7ltBTVj9iG2BcezcVBwObHVONtt3jSKZJICsjHUyBxGd/NvPHqjplML4ZNsZ6FjYwAp1KAfqMwl9iqQDM8pHqjKbSpfzgJQ9EUySUHztveDrh8kAudD0mZKo4YEHm+t/DqANqGFr0mDIhkk0gpdMHQDEo9nZn7OMFuBQkGRj0DhCWEOsnhZH7s6aNIAVohcPthEL5yo7cSiCumu2mtk4NFrh6BmOvCnjJnMV6s20arjvMPHfwOUp+897RL2vSQ/FRKKawgELdggq4LDmhtSBcPgK05PdLOyhVzUlsVohYnolsQ8LjD3/8Nj8KmuQLl42xcTSaTmUlYxLRdPiDf3v7Tay1Nm9TnxgQjlfqTC/8vAdY3mlmhMJkJY/UgLDrmrSRac/zfo2W3MhRCPLue7XzJ/rGSGgrsGNTc4XnUpPBNyh2o7kDp6t4zAU8h+zMkFP+0Bh4Nzxd6Bk+fZLU+0f6UIrUS5rnPdVDb+h/xwoH4aNTwg2Y2AIE+lgxNgrTUrBb0gS4Q/owiWbkiLnlukApMAg2cS2qiXFFyVRtcRgWEmH/HjQGXfmGzuCnteBt3AmSNrgUpOtwR/90z+h0iTyAkm0D6fLgcblHUID53K5pYLjEPqAonL6lv5hT/AsdDwT2G+e57nUpiK4 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB7044.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(7416014)(376014)(52116014)(1800799024)(366016)(38350700014)(921020); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OI42LS+///UHlb5BMi3EIb7FRcU4k6At9klKP/lcgymEI2WVEvd2o4n16djJelg4IrkORR7KyFldTD+BK3ZK5b8vu/x9F5EtZwXQdI8EjsBQiEpD5hpzP/d0XaoDou+iQ5RDfll6E6wbxDp0yh1Ys1vinVWzeGEXN/CmJV4xWDNsUqR/qs04boIjW8gmrOU4oLaOr2+ZU1H2UhhY6orhyVy2JOkupjRrNbHH7XJ/bi8g2qb2sZETG0jHLhjoh5bw8tzMjp1cE30do+/MGfNH17mEtT35ak6sogIGu7IzGGAOeA+cEUySOzSzpkfyYDHUmZ1jc84R/gJ4Aol0uwHFeHMKxUzMXjPtrfy87ALiFYxEOvAcAQnz6cWo6YJ50RaPbyjB5Id0qSe780Kva7hM2dt/eWRBu75WU/KrCCOzCG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lMWUTMwnewpQp7GX6n86oK+Nqv2ygQVL56sYIrvKRbNXHEuyJ/2iINbMNPDzV8WvR41VJY5PXtJKXHCKQmCr6KhXfU6rq4ZWyZ09zZiWR4ZU X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 69298e5c-ef12-41e4-fb96-08dcf7befb71 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB7044.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 02:11:21.5923 (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: Grd7qM20T7rOtnabkVaTjgNBercQV4Din8A2QQoax4Dtky9WzwyQ/UIvFsYB4+dM8raSTWdG4X2W/FqcEafTNg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB9147 Message-ID-Hash: 5FZRYSPYXVPIJG4AVCDL3WYBQ6AZEPOF X-Message-ID-Hash: 5FZRYSPYXVPIJG4AVCDL3WYBQ6AZEPOF X-MailFrom: shengjiu.wang@nxp.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Register m2m platform device,that user can use M2M feature. Signed-off-by: Shengjiu Wang Acked-by: Jaroslav Kysela --- sound/soc/fsl/fsl_easrc.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/sound/soc/fsl/fsl_easrc.c b/sound/soc/fsl/fsl_easrc.c index f17a185a1910..f404a39009e1 100644 --- a/sound/soc/fsl/fsl_easrc.c +++ b/sound/soc/fsl/fsl_easrc.c @@ -2204,6 +2204,12 @@ static int fsl_easrc_probe(struct platform_device *pdev) goto err_pm_disable; } + ret = fsl_asrc_m2m_init(easrc); + if (ret) { + dev_err(&pdev->dev, "failed to init m2m device %d\n", ret); + return ret; + } + return 0; err_pm_disable: @@ -2213,6 +2219,10 @@ static int fsl_easrc_probe(struct platform_device *pdev) static void fsl_easrc_remove(struct platform_device *pdev) { + struct fsl_asrc *easrc = dev_get_drvdata(&pdev->dev); + + fsl_asrc_m2m_exit(easrc); + pm_runtime_disable(&pdev->dev); } @@ -2313,10 +2323,29 @@ static int fsl_easrc_runtime_resume(struct device *dev) return ret; } +static int fsl_easrc_suspend(struct device *dev) +{ + struct fsl_asrc *easrc = dev_get_drvdata(dev); + int ret; + + fsl_asrc_m2m_suspend(easrc); + ret = pm_runtime_force_suspend(dev); + return ret; +} + +static int fsl_easrc_resume(struct device *dev) +{ + struct fsl_asrc *easrc = dev_get_drvdata(dev); + int ret; + + ret = pm_runtime_force_resume(dev); + fsl_asrc_m2m_resume(easrc); + return ret; +} + static const struct dev_pm_ops fsl_easrc_pm_ops = { RUNTIME_PM_OPS(fsl_easrc_runtime_suspend, fsl_easrc_runtime_resume, NULL) - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, - pm_runtime_force_resume) + SYSTEM_SLEEP_PM_OPS(fsl_easrc_suspend, fsl_easrc_resume) }; static struct platform_driver fsl_easrc_driver = {