From nobody Mon Nov 25 07:29:15 2024 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2087.outbound.protection.outlook.com [40.107.105.87]) (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 F3C8E130A7D; Tue, 29 Oct 2024 02:11:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730167868; cv=fail; b=sbkEcG4IUpJhO1ltJXCswFj4mLKIt99SXaW0MCQ56dzd1+t58TkjHr9FFy0OjGs0xeUXR4vkuJWoJ0UWkXvXBDGSWmL1Es1D3kj8smvazoHBLHl1ZMcfRzaSiQr5fKBfk23ngXX3Xu6aD+UQUYPtnzK/xMeSO07gKOS8U8BNx7k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730167868; c=relaxed/simple; bh=qYZzVI0LlfJuMXguWOVx7jlkeVIN296ai7BfGvhMs2o=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=PhGR8C8aAlcgwule8R7V3Y88/I0iMPQNhfUYB0mCVGPs/zj1NYv5WS2Jra9tR2nu/QbTrzJxx3NB4ftYec2bC5fmSZjpdx1D7sF6mvjNP3hNVC4NPNry+ZkVPXDGZNAQ6nEvw2kdj0oe11eL41RzcGPLeEZpD7U5eBpKuHYroy0= 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=nLZI/R2T; arc=fail smtp.client-ip=40.107.105.87 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="nLZI/R2T" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CLg1cEUUYSeiBgtm9VHK4NOfG/0x4AnFBFKKXw9Do/HIPjAix22cX0mfGxRRGbCITBTBFXjPnpXQR27/fu0nCmue4LZbp93zzBRtTrGOThZAdn64BA0SoLl2P85Ctyta0e26l6leHNI/RwyWGd2O9xgi5opM4HqczgQ5W406RTDZXOx6F8jn96sT5yQsWRJQpI+nLOhOLAy/99N7ShLrxQ7Fv+3PIyEcCFNkHwfCXnYSmSuyJdcS9ky0g0SKsWg2z0NZKrXQv4TFhkCU8fxwvQW3lFjqO289ViFCRBZhg7d/g76uppLZtJBzhCj3jughpC4ad73a3d9cTSQFvCWKLA== 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=AjqYSBEF+harWuyMeHZEqZwNJnm1Hy5T0NuzIdWBwpY=; b=gGTQo6YBFfHv2pHxxV73ADku+nyz26NhUvFZvoEzFlgsIcilH3181Bt/Lv7fDRJq22m9TlCfzUP08LcRLmMF2YWMU8kw9egxaqMo+ed3ReZjF6Ni3Gy0bD4t0XutWfdzUaQCSo7wC+T8LNCjnliGNfgRCEWPEj5EL3jnyuLCRtPQsotHJw7EzgcvzbZHwob6ukf0QvuXOl4XcCxgxoKfZHFiXGBoKWJEDaME85GcyGO0IvTvRhIcl6v/C3UUrKrZ/rMW2/I/xRLKN/XZFtdCBFpBzshojbZFzwWNq4lx/OcXFAHWmLhRVRy1E72FfD6dPcJ7HCfLPdeUjvDF7ZotDg== 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=AjqYSBEF+harWuyMeHZEqZwNJnm1Hy5T0NuzIdWBwpY=; b=nLZI/R2TssdKosuVHO7r/CmniHRl31MjjFoHUT8qAbbKY6f8PA5dVwXdZoosPMOa1fGhGznFDT6j3/LS6VVzl3mJZtb/uUldi26VQJPQoybJrxSfAS+j2BsFOQbuEQcGAey1Q33MHLRc0584SFivovBsfiz6oWhT6zP4AJDlV8ElpJgkU4p6l9aFELYkHJJpUFTwOtGEfBAWPynzI5hCPGPQUxcfIS6cBrdtnHyRMKgQXWUUZeoGdBurfWHIc6F1D7O8qlg8THKE5w+leOv3+hedha+N+b9GCEL/qUCAEIkaOKlW2vDUnEbvGc0qTAx3d4ZJAOE/kPTawBFOp+brkQ== 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:00 +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:00 +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 1/6] ALSA: compress: Add output rate and output format support Date: Tue, 29 Oct 2024 10:20:52 +0800 Message-Id: <20241029022057.816402-2-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> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2PR01CA0031.apcprd01.prod.exchangelabs.com (2603:1096:4:192::11) To AM0PR04MB7044.eurprd04.prod.outlook.com (2603:10a6:208:191::20) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB7044:EE_|DU2PR04MB9147:EE_ X-MS-Office365-Filtering-Correlation-Id: f808c7c2-06bb-41e4-8582-08dcf7beeebb 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: =?us-ascii?Q?IAFQJCbBay/8KtSdrz9p0j8wUibzinj/TcyiDWaKPrIkINfZAklaC4phg5Ra?= =?us-ascii?Q?lMrKgQc8HHL2PMS4C2v8YAHdxWQ2PptFlhpB3k0ddqF8Twjji1VipZKfz/hN?= =?us-ascii?Q?3HFl9c8+XQN0sbIN/+IJmqwaPNLKV3i7/FF/MRnBag2fjGZ6vT4XOfjySeFw?= =?us-ascii?Q?C5LHlqbzYvsYh/uxjF/Crpd8r3xOd3XHAroBRAEvQNA6miHUEAHq2VuFy/6X?= =?us-ascii?Q?RzgUxQA6uxj2NMEyDsvQXxo2sumf5S7DrePQKdV3+CbzSg0Kliz5cWg4qGvz?= =?us-ascii?Q?VMJg98ZbL5osnjBxgqqaaALBXKg7Cpk94TeMBY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B+bdX8SL/DAlT6xMFVG+TWMoDr9dIFr41zFqJUJBAvdAYcp0i7?= =?us-ascii?Q?K+lk0DdTRS0N8J22FUUUSAqWfCNvrRLFwsC+BzKY9X4VpVHWjSrQ2wy2ZOth?= =?us-ascii?Q?/ulWwI6VyeK1PDNuDw0MT4cNfI++US7tks/7d4hQCpRP7u3HsKotC7GS1zAp?= =?us-ascii?Q?pYarSqA/RIBNYJhvLtTPzNbX9Ff4?= 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: =?us-ascii?Q?9wqgesP7Eos5M89g4uj5fNBJsPblES9gaeo91N2SvmIeRzpHuRGTGMAD3rwS?= =?us-ascii?Q?PZHTU0o6ob061CDmsMHGaj+1UKt88IeA7ANRLBIj+Oie1RaLY0mUPQG/m6iQ?= =?us-ascii?Q?FD+dSIKXbJWfLL5FDkPiE+isPuMfQTpFb3o/yU6W6TOvoBFYSy95pnovhEM8?= =?us-ascii?Q?tCGO3uRE4ANVNHUovgUc1La/Jcv0W2nRxw9KAsLxsODasmkAt+RAIBs4wNvr?= =?us-ascii?Q?5rFDMQfwC6eK3vc8GaLUTVVnCE5Spwc8/Com5wlE5AtWXxb3gSdKSlv3V5ac?= =?us-ascii?Q?5/N645teSnUlYZlfugfogw649AwrVVhDvOjMIlnB1vV37uiNFx+DW+pB7cj3?= =?us-ascii?Q?loIaCupWBBWMB9fW7h32ktUdkBSkcDjatK+ClGRfQKyvP66eK3yhXwAdQpHp?= =?us-ascii?Q?l1kGKxL1UVyRLkTSyf8SXoPP5AvHUW5CdV7Ir1EAE4gOwWQggaXtX044gfci?= =?us-ascii?Q?29GF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KS7Z/yaGzHHi?= =?us-ascii?Q?bohM7qdpMFQHeo3uTiCsSKr35T3PwQaN4JWg3cflT4UQBVnPjxObUVLMp90d?= =?us-ascii?Q?S/TTdq8EPxEGPuHa1byXkH7wcUVNFBfR26HS59Fdl9oC+vgp0+JQT7SZlt9Q?= =?us-ascii?Q?j0SI3QvPs3HwEsrgzvdtbqHX7NBgns5JZajAhDYvBq9SlwyAyq7m8B6cSk2M?= =?us-ascii?Q?2ysUKHbW5pyJ/u20Ej3P4B50B4dxjZ8mUxd+d3vp?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f808c7c2-06bb-41e4-8582-08dcf7beeebb 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:00.2858 (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: LVatfpwMWLosCkuhNtRT/wq7uExptV2yQwUeePD2CgUENzxw83uAR/IKPuRU4xw3z5DaMIYZT+x8yJkjriOuYg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB9147 Content-Type: text/plain; charset="utf-8" Add 'pcm_format' for struct snd_codec, add 'pcm_formats' for struct snd_codec_desc, these are used for accelerator usage. Current accelerator example is sample rate converter (SRC). Define struct snd_codec_desc_src for descript minmum and maxmum sample rates. And add 'src_d' in union snd_codec_options structure. These are mainly used for capbility query. Signed-off-by: Jaroslav Kysela Signed-off-by: Shengjiu Wang Acked-by: Jaroslav Kysela --- include/uapi/sound/compress_params.h | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/include/uapi/sound/compress_params.h b/include/uapi/sound/comp= ress_params.h index ddc77322d571..bc7648a30746 100644 --- a/include/uapi/sound/compress_params.h +++ b/include/uapi/sound/compress_params.h @@ -334,6 +334,14 @@ union snd_codec_options { struct snd_dec_wma wma_d; struct snd_dec_alac alac_d; struct snd_dec_ape ape_d; + struct { + __u32 out_sample_rate; + } src_d; +} __attribute__((packed, aligned(4))); + +struct snd_codec_desc_src { + __u32 out_sample_rate_min; + __u32 out_sample_rate_max; } __attribute__((packed, aligned(4))); =20 /** struct snd_codec_desc - description of codec capabilities @@ -347,6 +355,9 @@ union snd_codec_options { * @modes: Supported modes. See SND_AUDIOMODE defines * @formats: Supported formats. See SND_AUDIOSTREAMFORMAT defines * @min_buffer: Minimum buffer size handled by codec implementation + * @pcm_formats: Output (for decoders) or input (for encoders) + * PCM formats (required to accel mode, 0 for other modes) + * @u_space: union space (for codec dependent data) * @reserved: reserved for future use * * This structure provides a scalar value for profiles, modes and stream @@ -370,7 +381,12 @@ struct snd_codec_desc { __u32 modes; __u32 formats; __u32 min_buffer; - __u32 reserved[15]; + __u32 pcm_formats; + union { + __u32 u_space[6]; + struct snd_codec_desc_src src; + } __attribute__((packed, aligned(4))); + __u32 reserved[8]; } __attribute__((packed, aligned(4))); =20 /** struct snd_codec @@ -395,6 +411,8 @@ struct snd_codec_desc { * @align: Block alignment in bytes of an audio sample. * Only required for PCM or IEC formats. * @options: encoder-specific settings + * @pcm_format: Output (for decoders) or input (for encoders) + * PCM formats (required to accel mode, 0 for other modes) * @reserved: reserved for future use */ =20 @@ -411,7 +429,8 @@ struct snd_codec { __u32 format; __u32 align; union snd_codec_options options; - __u32 reserved[3]; + __u32 pcm_format; + __u32 reserved[2]; } __attribute__((packed, aligned(4))); =20 #endif --=20 2.34.1 From nobody Mon Nov 25 07:29:15 2024 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2087.outbound.protection.outlook.com [40.107.105.87]) (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 243AF1865E3; Tue, 29 Oct 2024 02:11:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730167872; cv=fail; b=e4ssvvASqgs7PvfMRT7GQtI3S6eZXaMcjRbggsnR18dt8v7PoP+Tu/tgORWHH3f899j17p9LNuwQlyHHn9EnrUHWIrPco/t1Hj/U2oprxt9kIbhp337kwz/OtoI5lHGgayMaeqhl1NycfpTQgNcb9pG/9UDjwmcUc5qKR3gmpiE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730167872; c=relaxed/simple; bh=ava76Ve8aJqozawOgULm+0WWlEIDJuGJMeLj9SKdXBc=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=mi7jKIVip7vjeiNdNmFRdmnYd8t6h+nQbcXdY1VzwIbEIHCBzKbT6eXdqAtTHG3OFSAvvBAuI2Z82ADg3MBxKE4Hz0412GMjma1zfzg3nvRK9afMwb4hH76HjVqsHNlYUAswQIb15Zkk2Xy0m2spAQnt0RQxkglGPhWvVYtXRB4= 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=JFiukXWY; arc=fail smtp.client-ip=40.107.105.87 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="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> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2PR01CA0031.apcprd01.prod.exchangelabs.com (2603:1096:4:192::11) To AM0PR04MB7044.eurprd04.prod.outlook.com (2603:10a6:208:191::20) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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: =?us-ascii?Q?/1y+fV/OQfbn33QlD0y+/ATGlh+ThzIOoHZK5hjdnh1aqHYJJEnXHvJWQdW7?= =?us-ascii?Q?CZy++VAdFPavgviJ9ND11/MAwyYR6H0w3U+fR7LKS84Cv/2mtd7UgiYkXp7w?= =?us-ascii?Q?eJ6SxtG6u8XbXxjEdvPodlv5e87y1rizhsLd+Txe+Xa/ACQ7IXMvTI4nRqR7?= =?us-ascii?Q?O9pMDb5VHZMKo/TyU8qcYG74+cd/Bg9wqfoKieflW9MYt4h7DjKZeu12DwqM?= =?us-ascii?Q?xdUM6zLYU1gB0PDUlfvI9Lwhz7Q3ykEr+U7lmpmua6IV6hL1rWaL4R+Wutfc?= =?us-ascii?Q?+ilAAi3aGJMPz9eip0Ic5YZDA8E3dJuh5/2X831uK+v4cpWo6j3myT+38KTY?= =?us-ascii?Q?a8LixnxId7uwTOJu6kpTpDyIY3gcRS7gRMv/K5IXpmpboDwuAojJ3Isg+km2?= =?us-ascii?Q?Zuxm4n/MRDM9YHME4Bjw7UmbQEJhRFW51Yw/CO54D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?Vx1ymzTJoHBvMsK/r+fj3mZ8B9doKpNq8hW/KL1VLqemyCgk96oOA4ZpbfCq?= =?us-ascii?Q?OeP3iCtKuM8mWZdkghSCK+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: =?us-ascii?Q?isG3eBmsSDebdBRXMqXf6ITQbDgwyYtSyQx55RAsQRfzv/nq70KlE+Lac2oN?= =?us-ascii?Q?dsm4aElaFgn6sAyXxRWu7zDVnF75OjNZ1aLck0mlWgxkj1NgYyS/VhkcSGWA?= =?us-ascii?Q?uG/mrp/kpc8rssgEh5W26HZY0YRMbfwU4jlictsCi47FHzLS/rz8dlvGWK+R?= =?us-ascii?Q?/+dzDb/BPh7Yj3nU7moIT/GN+AmrXnGp+y/qH1nuSEWAyDsWyvBbG9TeErfT?= =?us-ascii?Q?22iRv1dq2FD0UVsB/Jz+1Mgph8ROM2z2MmwUyzgimKjh9QIvsYec/U+QlFp5?= =?us-ascii?Q?p5nhyr4xBJOWBISedY2m6KkD8UOswELXeFFjnFgyWEdXsp2NRTR8fiEmVJaF?= =?us-ascii?Q?EXTqAAcBpXq24dmNvPbq+gjrWbn9vXsNvDOvXGluG6GSGbe2ZHDFD8NG1cn4?= =?us-ascii?Q?r2rndOTfOOga1uqZ0+OlHc6fZnL2+1QtYAoTEEzl7bLWaiYHAGOFBSz6G23I?= =?us-ascii?Q?XCpM2BdP0kcJfxxhegXwmsNvztV7Mbl6EHnL8eq3Y+cCHvpAG4NUfD7SrC1/?= =?us-ascii?Q?71yyTI0qIBTNRsHAqTMaT+xn31sdABWGNPdIYx3z8NmKM6S7An/jm/Z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X/4b6Oh8lgWKsqCYz3NNu4YHZjrMbPuQUzYdl8b2H2s8lQYw?= =?us-ascii?Q?dgI93r2a5AsUsAMmdQEOPcHq3OAw7MAB6yU36hp7EzEb63vowcO7B0PL+19P?= =?us-ascii?Q?F8CGLUS5GaQkcvocbLJZFgi9oWsF6yl2q1ll26Id?= 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 Content-Type: text/plain; charset="utf-8" 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); } =20 +/* Get sample numbers in FIFO */ +static unsigned int fsl_asrc_get_output_fifo_size(struct fsl_asrc_pair *pa= ir) +{ + struct fsl_asrc *asrc =3D pair->asrc; + enum asrc_pair_index index =3D pair->index; + u32 val; + + regmap_read(asrc->regmap, REG_ASRFST(index), &val); + + val &=3D 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 =3D pair->private; + struct fsl_asrc *asrc =3D pair->asrc; + struct device *dev =3D &asrc->pdev->dev; + struct asrc_config config; + int ret; + + /* fill config */ + config.pair =3D pair->index; + config.channel_num =3D pair->channels; + config.input_sample_rate =3D pair->rate[IN]; + config.output_sample_rate =3D pair->rate[OUT]; + config.input_format =3D pair->sample_format[IN]; + config.output_format =3D pair->sample_format[OUT]; + config.inclk =3D INCLK_NONE; + config.outclk =3D OUTCLK_ASRCK1_CLK; + + pair_priv->config =3D &config; + ret =3D fsl_asrc_config_pair(pair, true); + if (ret) { + dev_err(dev, "failed to config pair: %d\n", ret); + return ret; + } + + pair->first_convert =3D 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 =3D 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 =3D 1; + } + + return 0; +} + +/* calculate capture data length according to output data length and sampl= e 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 =3D pair->channels; + unsigned int in_samples, out_samples; + unsigned int out_length; + + in_width =3D snd_pcm_format_physical_width(pair->sample_format[IN]) / 8; + out_width =3D snd_pcm_format_physical_width(pair->sample_format[OUT]) / 8; + + in_samples =3D input_buffer_length / in_width / channels; + out_samples =3D pair->rate[OUT] * in_samples / pair->rate[IN]; + out_length =3D (out_samples - ASRC_OUTPUT_LAST_SAMPLE) * out_width * chan= nels; + + return out_length; +} + +static int fsl_asrc_m2m_get_maxburst(u8 dir, struct fsl_asrc_pair *pair) +{ + struct fsl_asrc *asrc =3D pair->asrc; + struct fsl_asrc_priv *asrc_priv =3D asrc->private; + int wml =3D (dir =3D=3D IN) ? ASRC_M2M_INPUTFIFO_WML : ASRC_M2M_OUTPUTFIF= O_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 =3D FSL_ASRC_FORMATS; + cap->fmt_out =3D FSL_ASRC_FORMATS | SNDRV_PCM_FMTBIT_S8; + + cap->rate_in =3D supported_asrc_rate; + cap->rate_in_count =3D ARRAY_SIZE(supported_asrc_rate); + cap->rate_out =3D supported_asrc_rate; + cap->rate_out_count =3D ARRAY_SIZE(supported_asrc_rate); + cap->chan_min =3D 1; + cap->chan_max =3D 10; + + return 0; +} + +static int fsl_asrc_m2m_pair_resume(struct fsl_asrc_pair *pair) +{ + struct fsl_asrc *asrc =3D pair->asrc; + int i; + + for (i =3D 0; i < pair->channels * 4; i++) + regmap_write(asrc->regmap, REG_ASRDI(pair->index), 0); + + pair->first_convert =3D 1; + return 0; +} + static int fsl_asrc_runtime_resume(struct device *dev); static int fsl_asrc_runtime_suspend(struct device *dev); =20 @@ -1147,6 +1280,15 @@ static int fsl_asrc_probe(struct platform_device *pd= ev) asrc->get_fifo_addr =3D fsl_asrc_get_fifo_addr; asrc->pair_priv_size =3D sizeof(struct fsl_asrc_pair_priv); =20 + asrc->m2m_prepare =3D fsl_asrc_m2m_prepare; + asrc->m2m_start =3D fsl_asrc_m2m_start; + asrc->m2m_stop =3D fsl_asrc_m2m_stop; + asrc->get_output_fifo_size =3D fsl_asrc_get_output_fifo_size; + asrc->m2m_calc_out_len =3D fsl_asrc_m2m_calc_out_len; + asrc->m2m_get_maxburst =3D fsl_asrc_m2m_get_maxburst; + asrc->m2m_pair_resume =3D fsl_asrc_m2m_pair_resume; + asrc->m2m_get_cap =3D fsl_asrc_m2m_get_cap; + if (of_device_is_compatible(np, "fsl,imx35-asrc")) { asrc_priv->clk_map[IN] =3D input_clk_map_imx35; asrc_priv->clk_map[OUT] =3D 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 @@ =20 #include "fsl_asrc_common.h" =20 +#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_commo= n.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 { =20 #define PAIR_CTX_NUM 0x4 =20 +/** + * 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; =20 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; }; =20 /** @@ -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_leng= th); + 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; =20 void *private; --=20 2.34.1 From nobody Mon Nov 25 07:29:15 2024 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2087.outbound.protection.outlook.com [40.107.105.87]) (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 5996E18C91F; Tue, 29 Oct 2024 02:11:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730167875; cv=fail; b=ud0NlaACTKpvFH5xR+LkwXDW0a4xo+Tr5lwD0Q4kOjQv3w1kMPo/VlTnvYV7DIHCQlsMuvn4ISsHfBzlXjkDc1uEsn75oPjS3/ncsQNlmpExHEnZyAEu6k/3VBMJyB7EwDR/h3FpQ9EpeNZxIR/oJZA2+EHm+xehRaeYl7BxByQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730167875; c=relaxed/simple; bh=pdSncvsYhLrAorO6FVqM+GPIWFy5+i+cKGmIQoIAhm8=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=IZtJDSu2Y+LpOOz2QLzBpKPqFI6gipncj9DOZ6NqFmhD7+PYzHA4Er42/WOdpBZS6Vo2DPoFhTSOVyQtX0CRfCTWbURMBneafxQL+7TLwP1PD9UiiGNCTYPrl+fpn2Cserj4JMmkN6rSysckPDtZFNSvHNJ3GCqC4W0blIWxT7Y= 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=ATNnotJ0; arc=fail smtp.client-ip=40.107.105.87 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="ATNnotJ0" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Oz0FKKpJC83pt4oFHaqm8JzkjUiKiREXflpCorO1K6I23Qg0cH76IPXehROQpYqmChqcBl7wlgVDV1dOZMo2hbQDqN1Q1U2QwKxm9fUxnP6kIejR1Rjs6vE3kY3ksFmdRQFyYnFu/RCxZTHwv6vdzr5lfNtk3J9LjFsB2SMaHBtYsA//3JCo2k4LHbL57sXQfrL59qdYK+dpnTdrFhX5MimFE3dzDMsXc47yPdaILKTv4g+R9cse3oAsZqNWXA6mpf4nPhe39kdcjqOpd5sd+GVeYT0ZpkRk+jz0KCSShKD3yciXjOuq+mpDwQjaer729oso//rrtiu6HkPYnQP8iA== 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=asHgnuhLl7u97cA8ELXln78RhYt/mxLwaxyHgw0InHM=; b=BzADbvMztVt6ZantumeTHbYY78xulRpypDonxS7bacGxP87XIwfZya46dPynI3nstQnZWbrnPatqcqyTMOmsquTpt2LPcQg/bv1UHpgDhGPkUkw5WLE2eDYqKkyLusQBxsGNUyij7d5uyXptHGjGVCf75w0ZWr83deO1LO6owMd1jDEw+ReuuG1NAq9mvwyd7E7IR//JAhLjGGhquru5KjquZFCMdTlRvomZjbXO93zgc9QRsuCUoXLcA39yi29JopmnuR7QyqdjTgAQoa6V/8xSrmCl/eS0zVYXV+cKU9/ZNEDVY+qk+QR/GDbcJ4AWUM2oiyITw36humlTIYz9Pw== 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=asHgnuhLl7u97cA8ELXln78RhYt/mxLwaxyHgw0InHM=; b=ATNnotJ0sA7mm0T8DszCSPFlEEa/LzRdiaPDmQcY4SpflfpWtu8xOlfVKA2BZ4g/vNYMo6pR3lDSkk0/avKfOnWrgUEXeOPGcHCWKzK5i9XZ3LES7ZgjKffpGFV8dSx1pYuVADCJeYjJ8TD134NDKOboF4f+AmrP8PuH0+TosBHh5I1opdaj+7fniZ3JQda8k4dUjC/ffgHlxG+tbtcvmBOGOr216yzf8WzT8/Y4tC0h20oEkWkG4LpGgBG+zvTSpdGEXvTLDILAneoG9B60L/Elu5KEvb3fpOk1oqM20ZbSFVHC/huhTa90ir9/77Y8zpr3JE5y/1OOQ6BNb+cn+g== 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:08 +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:08 +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 3/6] ASoC: fsl_easrc: define functions for memory to memory usage Date: Tue, 29 Oct 2024 10:20:54 +0800 Message-Id: <20241029022057.816402-4-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> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2PR01CA0031.apcprd01.prod.exchangelabs.com (2603:1096:4:192::11) To AM0PR04MB7044.eurprd04.prod.outlook.com (2603:10a6:208:191::20) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB7044:EE_|DU2PR04MB9147:EE_ X-MS-Office365-Filtering-Correlation-Id: d091dd3b-07da-4f53-23a0-08dcf7bef3a4 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: =?us-ascii?Q?D6+DVRqj0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FZzPPGLgibMWnhVR?= =?us-ascii?Q?xKRTaEw8FMCyLnU78XxQjV+UzcJQ3FyZyoT1G4mevwCGEBZEDFlApdKtxnQM?= =?us-ascii?Q?svpe1UlV20fjC1GO8qFkqb8Yvnwg+AG3Yhfe0i3cBcaMbrjac/ZQ/xj/bal2?= =?us-ascii?Q?/Gk0mGcRabbHIT717JVoi6TYXIQUeIYVSYg21/8ERmgVAiW9zo7jtSCr4DWQ?= =?us-ascii?Q?iPrbmQBQozrBZowhz91XItSjwGKOf4p9576AwM1Dx2LWKQThfSxdTdObdoSu?= =?us-ascii?Q?MQL1wB44AnkRsmxS4QWy4JQGVrK40+n5byW8GNODr475I6GDsrs56j3+8pfu?= =?us-ascii?Q?sczzVP+GBxRfsDIys8OibOLgqjy2hqXsGtMtuNxPnk/2pr6VQzWdbqfyrShW?= =?us-ascii?Q?2k3CGcrRk3+3TFbIGLapIXkJ9nnDUxykhaqD2dMhNSPK4Xcdli8Lyxzyp6fD?= =?us-ascii?Q?FGSMuWSCHkXenxdrNc0ImI2FHIGdThfTfhprxN6xGNHu5NniLOFNzvyqzP1Q?= =?us-ascii?Q?RkeBZa69iAK+Kw+ibUPXkdRsEHSf?= 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: =?us-ascii?Q?NJISlu6V+pd5gwO467aojuPio7sPiI7WofVJivl66cMHfcmmv8mU56Y71V4d?= =?us-ascii?Q?QiUpx75Ux2YOOZtc3biK13bqTG4y25tPyAX1wgEWGPP4Ulwf3pCUQ6WuYpZ7?= =?us-ascii?Q?KtWTVp3nNzU8dyMLfPsIMJz6nMuDmiYQcHCRj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zJsDtxbcv2ykI9A31TPeMEWtW60lXR0/JvlMnZ78SuMWGNk28?= =?us-ascii?Q?RadDq86FcBE9Zmzb/mYxwguwbWnaurc8Nq6mu+QHwb6Tba91jqe1MYmTIL8I?= =?us-ascii?Q?WzuEzOEQUReLeFs2xyqQt73zlbG/VUbe9Lr9sIWUo233u/2rmX2sx9PTsPC9?= =?us-ascii?Q?wOYA+7AzTnlUNTCqAdSoj5jQ5OBTPwI+iic8gffdsErDwgNKnodR1iUfOlS/?= =?us-ascii?Q?Ntq7PtBsVY1jDXiXdSrocBj5rz6CnKsseWK7ciAwGO23fNjMmnDW0X5wpiHU?= =?us-ascii?Q?owoWAZsUnLF1OOEDBclnfZxnIR10GyIqu84Lma9HNX01XGg1HNUstNZjDpS2?= =?us-ascii?Q?AvjVCLOAOPoRWKtcqwXzDIE5ahwdOMtnBy/yku9DvjfxRkchPZ5CF2ifVweA?= =?us-ascii?Q?NijtFZ49LcHdjMhNxQUrLjSoZ1N/sJyJEwv1oQh+/neRWpri7AgOBCWXTEkE?= =?us-ascii?Q?pMm4iKauuT6lS76YVjmNp673qBRAPeZmMJidSL3UyqHRyJF7FXHfGexWUDsj?= =?us-ascii?Q?MYVpY3hIDuUbNOHu0q6W74q4JxKpEwvSySQ1hz92?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d091dd3b-07da-4f53-23a0-08dcf7bef3a4 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:08.5653 (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: jr65gSRJtMFojErHxKDGmYdOu30KBG63Mn379bv0BwXiWHnYJzeBgM86K+lJ8ukU4IvKJ6K1dvLfohhJNr9TGg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB9147 Content-Type: text/plain; charset="utf-8" ASRC can be used on memory to memory case, define several functions for m2m usage and export them as function pointer. Signed-off-by: Shengjiu Wang Acked-by: Jaroslav Kysela --- sound/soc/fsl/fsl_easrc.c | 228 ++++++++++++++++++++++++++++++++++++++ sound/soc/fsl/fsl_easrc.h | 4 + 2 files changed, 232 insertions(+) diff --git a/sound/soc/fsl/fsl_easrc.c b/sound/soc/fsl/fsl_easrc.c index d22f0621c465..f17a185a1910 100644 --- a/sound/soc/fsl/fsl_easrc.c +++ b/sound/soc/fsl/fsl_easrc.c @@ -1861,6 +1861,224 @@ static int fsl_easrc_get_fifo_addr(u8 dir, enum asr= c_pair_index index) return REG_EASRC_FIFO(dir, index); } =20 +/* Get sample numbers in FIFO */ +static unsigned int fsl_easrc_get_output_fifo_size(struct fsl_asrc_pair *p= air) +{ + struct fsl_asrc *asrc =3D pair->asrc; + enum asrc_pair_index index =3D pair->index; + u32 val; + + regmap_read(asrc->regmap, REG_EASRC_SFS(index), &val); + val &=3D EASRC_SFS_NSGO_MASK; + + return val >> EASRC_SFS_NSGO_SHIFT; +} + +static int fsl_easrc_m2m_prepare(struct fsl_asrc_pair *pair) +{ + struct fsl_easrc_ctx_priv *ctx_priv =3D pair->private; + struct fsl_asrc *asrc =3D pair->asrc; + struct device *dev =3D &asrc->pdev->dev; + int ret; + + ctx_priv->in_params.sample_rate =3D pair->rate[IN]; + ctx_priv->in_params.sample_format =3D pair->sample_format[IN]; + ctx_priv->out_params.sample_rate =3D pair->rate[OUT]; + ctx_priv->out_params.sample_format =3D pair->sample_format[OUT]; + + ctx_priv->in_params.fifo_wtmk =3D FSL_EASRC_INPUTFIFO_WML; + ctx_priv->out_params.fifo_wtmk =3D FSL_EASRC_OUTPUTFIFO_WML; + /* Fill the right half of the re-sampler with zeros */ + ctx_priv->rs_init_mode =3D 0x2; + /* Zero fill the right half of the prefilter */ + ctx_priv->pf_init_mode =3D 0x2; + + ret =3D fsl_easrc_set_ctx_format(pair, + &ctx_priv->in_params.sample_format, + &ctx_priv->out_params.sample_format); + if (ret) { + dev_err(dev, "failed to set context format: %d\n", ret); + return ret; + } + + ret =3D fsl_easrc_config_context(asrc, pair->index); + if (ret) { + dev_err(dev, "failed to config context %d\n", ret); + return ret; + } + + ctx_priv->in_params.iterations =3D 1; + ctx_priv->in_params.group_len =3D pair->channels; + ctx_priv->in_params.access_len =3D pair->channels; + ctx_priv->out_params.iterations =3D 1; + ctx_priv->out_params.group_len =3D pair->channels; + ctx_priv->out_params.access_len =3D pair->channels; + + ret =3D fsl_easrc_set_ctx_organziation(pair); + if (ret) { + dev_err(dev, "failed to set fifo organization\n"); + return ret; + } + + /* The context start flag */ + pair->first_convert =3D 1; + return 0; +} + +static int fsl_easrc_m2m_start(struct fsl_asrc_pair *pair) +{ + /* start context once */ + if (pair->first_convert) { + fsl_easrc_start_context(pair); + pair->first_convert =3D 0; + } + + return 0; +} + +static int fsl_easrc_m2m_stop(struct fsl_asrc_pair *pair) +{ + /* Stop pair/context */ + if (!pair->first_convert) { + fsl_easrc_stop_context(pair); + pair->first_convert =3D 1; + } + + return 0; +} + +/* calculate capture data length according to output data length and sampl= e rate */ +static int fsl_easrc_m2m_calc_out_len(struct fsl_asrc_pair *pair, int inpu= t_buffer_length) +{ + struct fsl_asrc *easrc =3D pair->asrc; + struct fsl_easrc_priv *easrc_priv =3D easrc->private; + struct fsl_easrc_ctx_priv *ctx_priv =3D pair->private; + unsigned int in_rate =3D ctx_priv->in_params.norm_rate; + unsigned int out_rate =3D ctx_priv->out_params.norm_rate; + unsigned int channels =3D pair->channels; + unsigned int in_samples, out_samples; + unsigned int in_width, out_width; + unsigned int out_length; + unsigned int frac_bits; + u64 val1, val2; + + switch (easrc_priv->rs_num_taps) { + case EASRC_RS_32_TAPS: + /* integer bits =3D 5; */ + frac_bits =3D 39; + break; + case EASRC_RS_64_TAPS: + /* integer bits =3D 6; */ + frac_bits =3D 38; + break; + case EASRC_RS_128_TAPS: + /* integer bits =3D 7; */ + frac_bits =3D 37; + break; + default: + return -EINVAL; + } + + val1 =3D (u64)in_rate << frac_bits; + do_div(val1, out_rate); + val1 +=3D (s64)ctx_priv->ratio_mod << (frac_bits - 31); + + in_width =3D snd_pcm_format_physical_width(ctx_priv->in_params.sample_for= mat) / 8; + out_width =3D snd_pcm_format_physical_width(ctx_priv->out_params.sample_f= ormat) / 8; + + ctx_priv->in_filled_len +=3D input_buffer_length; + if (ctx_priv->in_filled_len <=3D ctx_priv->in_filled_sample * in_width * = channels) { + out_length =3D 0; + } else { + in_samples =3D ctx_priv->in_filled_len / (in_width * channels) - + ctx_priv->in_filled_sample; + + /* right shift 12 bit to make ratio in 32bit space */ + val2 =3D (u64)in_samples << (frac_bits - 12); + val1 =3D val1 >> 12; + do_div(val2, val1); + out_samples =3D val2; + + out_length =3D out_samples * out_width * channels; + ctx_priv->in_filled_len =3D ctx_priv->in_filled_sample * in_width * chan= nels; + } + + return out_length; +} + +static int fsl_easrc_m2m_get_maxburst(u8 dir, struct fsl_asrc_pair *pair) +{ + struct fsl_easrc_ctx_priv *ctx_priv =3D pair->private; + + if (dir =3D=3D IN) + return ctx_priv->in_params.fifo_wtmk * pair->channels; + else + return ctx_priv->out_params.fifo_wtmk * pair->channels; +} + +static int fsl_easrc_m2m_pair_suspend(struct fsl_asrc_pair *pair) +{ + fsl_easrc_stop_context(pair); + + return 0; +} + +static int fsl_easrc_m2m_pair_resume(struct fsl_asrc_pair *pair) +{ + struct fsl_easrc_ctx_priv *ctx_priv =3D pair->private; + + pair->first_convert =3D 1; + ctx_priv->in_filled_len =3D 0; + + return 0; +} + +/* val is Q31 */ +static int fsl_easrc_m2m_set_ratio_mod(struct fsl_asrc_pair *pair, int val) +{ + struct fsl_easrc_ctx_priv *ctx_priv =3D pair->private; + struct fsl_asrc *easrc =3D pair->asrc; + struct fsl_easrc_priv *easrc_priv =3D easrc->private; + unsigned int frac_bits; + + ctx_priv->ratio_mod +=3D val; + + switch (easrc_priv->rs_num_taps) { + case EASRC_RS_32_TAPS: + /* integer bits =3D 5; */ + frac_bits =3D 39; + break; + case EASRC_RS_64_TAPS: + /* integer bits =3D 6; */ + frac_bits =3D 38; + break; + case EASRC_RS_128_TAPS: + /* integer bits =3D 7; */ + frac_bits =3D 37; + break; + default: + return -EINVAL; + } + + val <<=3D (frac_bits - 31); + regmap_write(easrc->regmap, REG_EASRC_RUC(pair->index), EASRC_RSUC_RS_RM(= val)); + + return 0; +} + +static int fsl_easrc_m2m_get_cap(struct fsl_asrc_m2m_cap *cap) +{ + cap->fmt_in =3D FSL_EASRC_FORMATS; + cap->fmt_out =3D FSL_EASRC_FORMATS | SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE; + cap->rate_in =3D easrc_rates; + cap->rate_in_count =3D ARRAY_SIZE(easrc_rates); + cap->rate_out =3D easrc_rates; + cap->rate_out_count =3D ARRAY_SIZE(easrc_rates); + cap->chan_min =3D 1; + cap->chan_max =3D 32; + return 0; +} + static const struct of_device_id fsl_easrc_dt_ids[] =3D { { .compatible =3D "fsl,imx8mn-easrc",}, {} @@ -1926,6 +2144,16 @@ static int fsl_easrc_probe(struct platform_device *p= dev) easrc->release_pair =3D fsl_easrc_release_context; easrc->get_fifo_addr =3D fsl_easrc_get_fifo_addr; easrc->pair_priv_size =3D sizeof(struct fsl_easrc_ctx_priv); + easrc->m2m_prepare =3D fsl_easrc_m2m_prepare; + easrc->m2m_start =3D fsl_easrc_m2m_start; + easrc->m2m_stop =3D fsl_easrc_m2m_stop; + easrc->get_output_fifo_size =3D fsl_easrc_get_output_fifo_size; + easrc->m2m_calc_out_len =3D fsl_easrc_m2m_calc_out_len; + easrc->m2m_get_maxburst =3D fsl_easrc_m2m_get_maxburst; + easrc->m2m_pair_suspend =3D fsl_easrc_m2m_pair_suspend; + easrc->m2m_pair_resume =3D fsl_easrc_m2m_pair_resume; + easrc->m2m_set_ratio_mod =3D fsl_easrc_m2m_set_ratio_mod; + easrc->m2m_get_cap =3D fsl_easrc_m2m_get_cap; =20 easrc_priv->rs_num_taps =3D EASRC_RS_32_TAPS; easrc_priv->const_coeff =3D 0x3FF0000000000000; diff --git a/sound/soc/fsl/fsl_easrc.h b/sound/soc/fsl/fsl_easrc.h index 7c70dac52713..c9f770862662 100644 --- a/sound/soc/fsl/fsl_easrc.h +++ b/sound/soc/fsl/fsl_easrc.h @@ -601,6 +601,8 @@ struct fsl_easrc_slot { * @out_missed_sample: sample missed in output * @st1_addexp: exponent added for stage1 * @st2_addexp: exponent added for stage2 + * @ratio_mod: update ratio + * @in_filled_len: input filled length */ struct fsl_easrc_ctx_priv { struct fsl_easrc_io_params in_params; @@ -618,6 +620,8 @@ struct fsl_easrc_ctx_priv { int out_missed_sample; int st1_addexp; int st2_addexp; + int ratio_mod; + unsigned int in_filled_len; }; =20 /** --=20 2.34.1 From nobody Mon Nov 25 07:29:15 2024 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2087.outbound.protection.outlook.com [40.107.105.87]) (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 65A2D18FDC5; Tue, 29 Oct 2024 02:11:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730167879; cv=fail; b=HlEG9/nSIT4O2ugQdTqdMeq2AJn5S4wi6z4sE4N9x14Dr6xaZKPfUdZRR1X+vzk0JyfYd9/b1w0q9DVRaX4+PP47xSeYlSP3oYv3tw8sjlEh7kqtNvIEjbAYj+nr3HCvJiEniuq+ZCtj98/3Q03IbPld3GmHXVEZddYoiyb8CG0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730167879; c=relaxed/simple; bh=Gp0pnKF8kua+PCwg1bfryyG34jWScjNxKl8/zIMVDAI=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=W97Do2Uygaok0uHuaY/QgAQiHb11afVxH4qBILbG5s+TrpB4Rg9hlTWdiA8I3QJL3DweiXzN0tgffb4eAiUoWiGFjUWCzxQKHaSQT6PiqCA9TJuu4/Zj9fdE67uCfaBc7oq1dG2vpHs856fs7q0WEXfLLHiWmLFTCnQzWbCrs+U= 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=CPmBB0Li; arc=fail smtp.client-ip=40.107.105.87 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="CPmBB0Li" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TKj8oYFQJRSbp1hIsuqlWaVrkH/XRVi4ktuQvJ+Me98MDu9l8fTzM8FgfQG0alXRB8Ng102jI7+tRna+L4BYigP/IDbiGnx28l2MafnBoaqoFmbjHFnLwGobBvCHw0N/yLP37hmqGiDD5tX40KBvHOqsRrFu/o86fRT3+haUsun/sNUIXi1PWBGmKuGL7Veh7e63S1JxL5ilA5mmoBlMlitQu7QD11SpPRIMpkG7trrquBYXLjcAgBVEvTOj7V0NNrVUMUXzpzAcJZu8l8cBfGUc5kZpZgoxqaj96arLNo2kKsI7lV7VBhFQRrxW3P9cbRLpDGQj46O3EJ9QP556/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=WuobSh6p2+iPQ4MBztGLhybzFsfEt4btXYigKoePPJs=; b=M/WpHQlJTcNMBRoyzZ0oruYD98aLtuEyIAFOaQCRRPzcpEVmKaWRaAQEnz+leUEbyDn3yt15Pvfv0mcc3tyveZTv3rBa+eNhp6AcHhZt2kizmC8RAmgeMgvQlzRr+p7BpOgsuBkBxqwK6Lk//WZvhawH5FUKvmMEPP1PXCzo68g1uHQPhQ4wB2fCZBCv1M7S3CPdJypokV84bBsXgggVMctkYRmg/0m+79AxOOf1MsZE9ND9xpLxpL0KOhPtd7Wed5YZuHrAzp8FA/mFdGbwy3ukVg8Q5HPFgF75XYoQ2TonOOcHTYUU0uOTKE9UH7QzS2Ewkil+OKJ87Sz3zVa81w== 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=WuobSh6p2+iPQ4MBztGLhybzFsfEt4btXYigKoePPJs=; b=CPmBB0LiVWCQx7yvXZstidahm4JIoguQIr3b47nehPqbpEoIrVxpi8TQDVCwsnvvSCHNgB/8x0vm1yXiR7kB8FRRUwqJGZCaE3Ssk/0OXQUHMDcZbaWBbiBAxtje9y9ald3X8rEKdWggGxIbaAFmapUtPSRgFIXVWLsbEa5s7aVcWZ7Qr5hekHiWkyeIO2m2Z2ZMJ43EidWGWheE0ggvTmjclXPSSJQzAtwYbV7pPzY8VtTzWIIF4ru6+y69F12He5DGSXnZ0jsAVpAbTRAAAR2UcwqCB2V5TcVs2LHfZ0Vu9qKV/uGeQKxP2AQfhs1jbPIfUfu9iwN9US/Mr/nuvw== 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:12 +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:12 +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 4/6] ASoC: fsl_asrc_m2m: Add memory to memory function Date: Tue, 29 Oct 2024 10:20:55 +0800 Message-Id: <20241029022057.816402-5-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> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2PR01CA0031.apcprd01.prod.exchangelabs.com (2603:1096:4:192::11) To AM0PR04MB7044.eurprd04.prod.outlook.com (2603:10a6:208:191::20) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB7044:EE_|DU2PR04MB9147:EE_ X-MS-Office365-Filtering-Correlation-Id: c7f897b8-42e7-4d3a-128f-08dcf7bef61e 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: =?us-ascii?Q?lAFoXC10u6OqElDDhDR1gdnHVJeHWVKcX2wDKNRoC8PCyV92m2YDpkeK9QqW?= =?us-ascii?Q?V+Qb3mjWlmZNwfiJomw62jsv25am8reM+R8XOVGp9Z+wtg3Grwpm+Hkpfaoj?= =?us-ascii?Q?FRxS6v+RBJjQ1kpSDVR3PYrAbDjF4C8KkjUnUQUrPgJBGwJTNxxSUrBYLVnb?= =?us-ascii?Q?lAeZLUb5gb0j5e5Nntc+inZeT2nC3UPT5geHflW03wddibzZoVPKo7Ve6xqf?= =?us-ascii?Q?w03dNQDtuE+Y+mXSRyN7lVC0t8oJM5g+3eEUMFzLG94EzWRqKdkiMqCzXqBQ?= =?us-ascii?Q?QglYCdpXOOc5V9AYALIpXl+HeiDMLs/iQ88iHreO/UWTPRZuVVRXbLN6feGv?= =?us-ascii?Q?en5REfeqzYdUZH7CewxhMcJrAsJOLoKKA3XkLjxEJY5emPwzAJmIFuGSxdp+?= =?us-ascii?Q?6Ic+ww/OrioXmuNvoI5+SWRY662Ptgon8DVMr9XDlreFFarXzQkObqoThOr6?= =?us-ascii?Q?TgymsY1efaFClBQETCOmYRoP9DYs44SpeP9vzwFNt0vWnJHcFDFuXqvPffr9?= =?us-ascii?Q?j8FFBRP53cVDhiEC8TqzQGc7iYGEhveTq0ruYvb0VSub5q5akN84YuoVJ8rt?= =?us-ascii?Q?W2HXWulImLAn5zs56ZbL614nVUhJ7UX83mIqHFZ7cgR3B4EbeLIisL7r5vKM?= =?us-ascii?Q?gCesC6eqLbQS9POPCqbabUzi/k9+YJMZVd4hvbU+EKvUew3lTq2yUDyX5QbA?= =?us-ascii?Q?y5DG5x5oLvjchVAaId7yxQ8BDvniuYGdiK/N6oy+BxVt56O98rtACo91sqJ5?= =?us-ascii?Q?UbVnAUrH0wTlWRMgjNYvqSL6pG6BZ2EvywOEKc9WX5dz/1yN8iW46qVjNkdI?= =?us-ascii?Q?xEIXup4Gk8QSSNKgaNiQ1iU43ePv0mLsci0QZSLU1uw0AX4u41771dViHJDm?= =?us-ascii?Q?bZ9rRb9FmtM6zhLAF32+Y7bSG3QyvLetSybjoN1vzVbPVL+3Ko993GkORZk+?= =?us-ascii?Q?YFzX2RHTA4eY2+OgfAakdx4fcVEyMBTJCx4fELmQO6e8X/PJ8BsDmzi1uXSp?= =?us-ascii?Q?Ur6jGZLQQE+df+Drdi83QVjd8AW0tSr2G1XcADvjkanTT6NhbagaDU+rM/OJ?= =?us-ascii?Q?qFA6XFF/YAyCtzhVPRNA7BHJVDjOGf6KTJQ8NbMpKwna5/8OxNd4HTZhplSn?= =?us-ascii?Q?nPbudgJNRCBAy+p/hiNLWEICD+AAf7MgoQCqeIrVdmY5gi3tz5+bf85KcyzU?= =?us-ascii?Q?/Y9GpwWhcVbkI5i0r6gEvVRxR9d68qLDFtnave9lHEtqvQqk78ko70+tCIpk?= =?us-ascii?Q?LbGxDpWbQtCT4K4968FvNmMUcphgeocha2LzIxt6WvLs7t1bIHecMuTprSgs?= =?us-ascii?Q?N5D+RK+IMvGmK5+UWkjCJOi6HA04ClvH5gx636NP5x6TeJMSPXvWYoiXeW9L?= =?us-ascii?Q?U9R8TVSevJ7cmFpqOeW7ecvPyD9C?= 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: =?us-ascii?Q?NLMJpV39m2Fz07XUmwz0zWrCC7VY3qvL45w499r0hOjHqdCoUj3CjtXmdZeG?= =?us-ascii?Q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q3ycaI7dhDQXvEJ4+vrAD8m?= =?us-ascii?Q?e/1qNX9VOa5eEJhxd2dhgjtBcMC0wMnnyS8t8KPVhbjT6S/eVmTbQAcVpgeX?= =?us-ascii?Q?tLL6i7uLxTKq9KF4KYNE41M9yTUPUlmu+gQIZsDLZ/5QRS2uQSIaF+9yUb1I?= =?us-ascii?Q?3XgRCwz3YnV+pJ8fIiGW/aOn3K3FC5c+mzieWncxR/05y+mhVkDJEA+9OqSK?= =?us-ascii?Q?5+L4qO79l5kONDRt/uDl1x6Fro3uw4b5+hSq4nHvQuo0YPe83SGN8OrsHy4C?= =?us-ascii?Q?zJsGIMWXYkZKjcVFLWG2D3ubfCZ7eNh4q/ddJshESsnGtXrOS4dExGkY8FBP?= =?us-ascii?Q?MGY4zcURfkPhN99xknaVagmfAaI4jVEmsrAYM79zpIhpT3/3WRL+rw46waku?= =?us-ascii?Q?EFYx9VoG6lx2BfUd5V+XsdHHT13I+NvRAFiuo4roqJdwKBYyXA70PbzGlq4y?= =?us-ascii?Q?Tigw+wQyxlVFwSVhCIf3NsSUng6CmocWXdDoYn8Wln6Y8p1XDLOdjBcfhdWk?= =?us-ascii?Q?Ijlb3PBs0MZ/bvtC0axrb815vwo8wnt+kW0jikG+eTRpHCTKuYkvTGLoLH88?= =?us-ascii?Q?aec46qxYB+ZRj3JbukMH38H0ACmn7EZDnQ2EC4ZxbsttOfCVlEkaMLG9nn9+?= =?us-ascii?Q?sHbXl8GBmQcuBEyf8a1JjOhC5v2XoKyFKKQ4yHqv?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c7f897b8-42e7-4d3a-128f-08dcf7bef61e 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:12.7830 (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: W3dn8lbCqCxgSjOVvjn+jTQN5KDBIDhICxvyLn9t08LZfhWJ4Rw53/4gpIam1YcuiKl57lEysImMOyP3EsQ+Rg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB9147 Content-Type: text/plain; charset="utf-8" Implement the ASRC memory to memory function using the compress framework, user can use this function with compress ioctl interface. This feature can be shared by ASRC and EASRC drivers Signed-off-by: Shengjiu Wang Acked-by: Jaroslav Kysela --- sound/soc/fsl/Kconfig | 1 + sound/soc/fsl/Makefile | 2 +- sound/soc/fsl/fsl_asrc_common.h | 9 + sound/soc/fsl/fsl_asrc_m2m.c | 727 ++++++++++++++++++++++++++++++++ 4 files changed, 738 insertions(+), 1 deletion(-) create mode 100644 sound/soc/fsl/fsl_asrc_m2m.c diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index e283751abfef..bff9c6bda344 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -8,6 +8,7 @@ config SND_SOC_FSL_ASRC depends on HAS_DMA select REGMAP_MMIO select SND_SOC_GENERIC_DMAENGINE_PCM + select SND_COMPRESS_ACCEL help Say Y if you want to add Asynchronous Sample Rate Converter (ASRC) support for the Freescale CPUs. diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index ad97244b5cc3..d656a9ab54e3 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile @@ -10,7 +10,7 @@ obj-$(CONFIG_SND_SOC_P1022_RDK) +=3D snd-soc-p1022-rdk.o # Freescale SSI/DMA/SAI/SPDIF Support snd-soc-fsl-audmix-y :=3D fsl_audmix.o snd-soc-fsl-asoc-card-y :=3D fsl-asoc-card.o -snd-soc-fsl-asrc-y :=3D fsl_asrc.o fsl_asrc_dma.o +snd-soc-fsl-asrc-y :=3D fsl_asrc.o fsl_asrc_dma.o fsl_asrc_m2m.o snd-soc-fsl-lpc3xxx-y :=3D lpc3xxx-pcm.o lpc3xxx-i2s.o snd-soc-fsl-sai-y :=3D fsl_sai.o snd-soc-fsl-ssi-y :=3D fsl_ssi.o diff --git a/sound/soc/fsl/fsl_asrc_common.h b/sound/soc/fsl/fsl_asrc_commo= n.h index 3bdd6ea07c09..0cd595b0f629 100644 --- a/sound/soc/fsl/fsl_asrc_common.h +++ b/sound/soc/fsl/fsl_asrc_common.h @@ -60,6 +60,7 @@ struct fsl_asrc_m2m_cap { * @buf_len: buffer length of m2m * @dma_buffer: buffer pointers * @first_convert: start of conversion + * @ratio_mod_flag: flag for new ratio modifier * @ratio_mod: ratio modification */ struct fsl_asrc_pair { @@ -84,6 +85,7 @@ struct fsl_asrc_pair { unsigned int buf_len[2]; struct snd_dma_buffer dma_buffer[2]; unsigned int first_convert; + bool ratio_mod_flag; unsigned int ratio_mod; }; =20 @@ -98,6 +100,7 @@ struct fsl_asrc_pair { * @mem_clk: clock source to access register * @ipg_clk: clock source to drive peripheral * @spba_clk: SPBA clock (optional, depending on SoC design) + * @card: compress sound card * @lock: spin lock for resource protection * @pair: pair pointers * @channel_avail: non-occupied channel numbers @@ -131,6 +134,7 @@ struct fsl_asrc { struct clk *mem_clk; struct clk *ipg_clk; struct clk *spba_clk; + struct snd_card *card; spinlock_t lock; /* spin lock for resource protection */ =20 struct fsl_asrc_pair *pair[PAIR_CTX_NUM]; @@ -166,4 +170,9 @@ struct fsl_asrc { #define DRV_NAME "fsl-asrc-dai" extern struct snd_soc_component_driver fsl_asrc_component; =20 +int fsl_asrc_m2m_init(struct fsl_asrc *asrc); +void fsl_asrc_m2m_exit(struct fsl_asrc *asrc); +int fsl_asrc_m2m_resume(struct fsl_asrc *asrc); +int fsl_asrc_m2m_suspend(struct fsl_asrc *asrc); + #endif /* _FSL_ASRC_COMMON_H */ diff --git a/sound/soc/fsl/fsl_asrc_m2m.c b/sound/soc/fsl/fsl_asrc_m2m.c new file mode 100644 index 000000000000..693ec0a477a4 --- /dev/null +++ b/sound/soc/fsl/fsl_asrc_m2m.c @@ -0,0 +1,727 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Copyright (C) 2014-2016 Freescale Semiconductor, Inc. +// Copyright (C) 2019-2024 NXP +// +// Freescale ASRC Memory to Memory (M2M) driver + +#include +#include +#include +#include +#include +#include +#include + +#include "fsl_asrc_common.h" + +#define DIR_STR(dir) (dir) =3D=3D IN ? "in" : "out" + +#define ASRC_xPUT_DMA_CALLBACK(dir) \ + (((dir) =3D=3D IN) ? asrc_input_dma_callback \ + : asrc_output_dma_callback) + +/* Maximum output and capture buffer size */ +#define ASRC_M2M_BUFFER_SIZE (512 * 1024) + +/* Maximum output and capture period size */ +#define ASRC_M2M_PERIOD_SIZE (48 * 1024) + +/* dma complete callback */ +static void asrc_input_dma_callback(void *data) +{ + struct fsl_asrc_pair *pair =3D (struct fsl_asrc_pair *)data; + + complete(&pair->complete[IN]); +} + +/* dma complete callback */ +static void asrc_output_dma_callback(void *data) +{ + struct fsl_asrc_pair *pair =3D (struct fsl_asrc_pair *)data; + + complete(&pair->complete[OUT]); +} + +/** + *asrc_read_last_fifo: read all the remaining data from FIFO + *@pair: Structure pointer of fsl_asrc_pair + *@dma_vaddr: virtual address of capture buffer + *@length: payload length of capture buffer + */ +static void asrc_read_last_fifo(struct fsl_asrc_pair *pair, void *dma_vadd= r, u32 *length) +{ + struct fsl_asrc *asrc =3D pair->asrc; + enum asrc_pair_index index =3D pair->index; + u32 i, reg, size, t_size =3D 0, width; + u32 *reg32 =3D NULL; + u16 *reg16 =3D NULL; + u8 *reg24 =3D NULL; + + width =3D snd_pcm_format_physical_width(pair->sample_format[OUT]); + if (width =3D=3D 32) + reg32 =3D dma_vaddr + *length; + else if (width =3D=3D 16) + reg16 =3D dma_vaddr + *length; + else + reg24 =3D dma_vaddr + *length; +retry: + size =3D asrc->get_output_fifo_size(pair); + if (size + *length > ASRC_M2M_BUFFER_SIZE) + goto end; + + for (i =3D 0; i < size * pair->channels; i++) { + regmap_read(asrc->regmap, asrc->get_fifo_addr(OUT, index), ®); + if (reg32) { + *reg32++ =3D reg; + } else if (reg16) { + *reg16++ =3D (u16)reg; + } else { + *reg24++ =3D (u8)reg; + *reg24++ =3D (u8)(reg >> 8); + *reg24++ =3D (u8)(reg >> 16); + } + } + t_size +=3D size; + + /* In case there is data left in FIFO */ + if (size) + goto retry; +end: + /* Update payload length */ + if (reg32) + *length +=3D t_size * pair->channels * 4; + else if (reg16) + *length +=3D t_size * pair->channels * 2; + else + *length +=3D t_size * pair->channels * 3; +} + +/* config dma channel */ +static int asrc_dmaconfig(struct fsl_asrc_pair *pair, + struct dma_chan *chan, + u32 dma_addr, dma_addr_t buf_addr, u32 buf_len, + int dir, int width) +{ + struct fsl_asrc *asrc =3D pair->asrc; + struct device *dev =3D &asrc->pdev->dev; + struct dma_slave_config slave_config; + enum dma_slave_buswidth buswidth; + unsigned int sg_len, max_period_size; + struct scatterlist *sg; + int ret, i; + + switch (width) { + case 8: + buswidth =3D DMA_SLAVE_BUSWIDTH_1_BYTE; + break; + case 16: + buswidth =3D DMA_SLAVE_BUSWIDTH_2_BYTES; + break; + case 24: + buswidth =3D DMA_SLAVE_BUSWIDTH_3_BYTES; + break; + case 32: + buswidth =3D DMA_SLAVE_BUSWIDTH_4_BYTES; + break; + default: + dev_err(dev, "invalid word width\n"); + return -EINVAL; + } + + memset(&slave_config, 0, sizeof(slave_config)); + if (dir =3D=3D IN) { + slave_config.direction =3D DMA_MEM_TO_DEV; + slave_config.dst_addr =3D dma_addr; + slave_config.dst_addr_width =3D buswidth; + slave_config.dst_maxburst =3D asrc->m2m_get_maxburst(IN, pair); + } else { + slave_config.direction =3D DMA_DEV_TO_MEM; + slave_config.src_addr =3D dma_addr; + slave_config.src_addr_width =3D buswidth; + slave_config.src_maxburst =3D asrc->m2m_get_maxburst(OUT, pair); + } + + ret =3D dmaengine_slave_config(chan, &slave_config); + if (ret) { + dev_err(dev, "failed to config dmaengine for %s task: %d\n", + DIR_STR(dir), ret); + return -EINVAL; + } + + max_period_size =3D rounddown(ASRC_M2M_PERIOD_SIZE, width * pair->channel= s / 8); + /* scatter gather mode */ + sg_len =3D buf_len / max_period_size; + if (buf_len % max_period_size) + sg_len +=3D 1; + + sg =3D kmalloc_array(sg_len, sizeof(*sg), GFP_KERNEL); + if (!sg) + return -ENOMEM; + + sg_init_table(sg, sg_len); + for (i =3D 0; i < (sg_len - 1); i++) { + sg_dma_address(&sg[i]) =3D buf_addr + i * max_period_size; + sg_dma_len(&sg[i]) =3D max_period_size; + } + sg_dma_address(&sg[i]) =3D buf_addr + i * max_period_size; + sg_dma_len(&sg[i]) =3D buf_len - i * max_period_size; + + pair->desc[dir] =3D dmaengine_prep_slave_sg(chan, sg, sg_len, + slave_config.direction, + DMA_PREP_INTERRUPT); + kfree(sg); + if (!pair->desc[dir]) { + dev_err(dev, "failed to prepare dmaengine for %s task\n", DIR_STR(dir)); + return -EINVAL; + } + + pair->desc[dir]->callback =3D ASRC_xPUT_DMA_CALLBACK(dir); + pair->desc[dir]->callback_param =3D pair; + + return 0; +} + +/* main function of converter */ +static void asrc_m2m_device_run(struct fsl_asrc_pair *pair, struct snd_com= pr_task_runtime *task) +{ + struct fsl_asrc *asrc =3D pair->asrc; + struct device *dev =3D &asrc->pdev->dev; + enum asrc_pair_index index =3D pair->index; + struct snd_dma_buffer *src_buf, *dst_buf; + unsigned int in_buf_len; + unsigned int out_dma_len; + unsigned int width; + u32 fifo_addr; + int ret; + + /* set ratio mod */ + if (asrc->m2m_set_ratio_mod) { + if (pair->ratio_mod_flag) { + asrc->m2m_set_ratio_mod(pair, pair->ratio_mod); + pair->ratio_mod_flag =3D false; + } + } + + src_buf =3D &pair->dma_buffer[IN]; + dst_buf =3D &pair->dma_buffer[OUT]; + + width =3D snd_pcm_format_physical_width(pair->sample_format[IN]); + fifo_addr =3D asrc->paddr + asrc->get_fifo_addr(IN, index); + + in_buf_len =3D task->input_size; + + if (in_buf_len < width * pair->channels / 8 || + in_buf_len > ASRC_M2M_BUFFER_SIZE || + in_buf_len % (width * pair->channels / 8)) { + dev_err(dev, "out buffer size is error: [%d]\n", in_buf_len); + goto end; + } + + /* dma config for output dma channel */ + ret =3D asrc_dmaconfig(pair, + pair->dma_chan[IN], + fifo_addr, + src_buf->addr, + in_buf_len, IN, width); + if (ret) { + dev_err(dev, "out dma config error\n"); + goto end; + } + + width =3D snd_pcm_format_physical_width(pair->sample_format[OUT]); + fifo_addr =3D asrc->paddr + asrc->get_fifo_addr(OUT, index); + out_dma_len =3D asrc->m2m_calc_out_len(pair, in_buf_len); + if (out_dma_len > 0 && out_dma_len <=3D ASRC_M2M_BUFFER_SIZE) { + /* dma config for capture dma channel */ + ret =3D asrc_dmaconfig(pair, + pair->dma_chan[OUT], + fifo_addr, + dst_buf->addr, + out_dma_len, OUT, width); + if (ret) { + dev_err(dev, "cap dma config error\n"); + goto end; + } + } else if (out_dma_len > ASRC_M2M_BUFFER_SIZE) { + dev_err(dev, "cap buffer size error\n"); + goto end; + } + + reinit_completion(&pair->complete[IN]); + reinit_completion(&pair->complete[OUT]); + + /* Submit DMA request */ + dmaengine_submit(pair->desc[IN]); + dma_async_issue_pending(pair->desc[IN]->chan); + if (out_dma_len > 0) { + dmaengine_submit(pair->desc[OUT]); + dma_async_issue_pending(pair->desc[OUT]->chan); + } + + asrc->m2m_start(pair); + + if (!wait_for_completion_interruptible_timeout(&pair->complete[IN], 10 * = HZ)) { + dev_err(dev, "out DMA task timeout\n"); + goto end; + } + + if (out_dma_len > 0) { + if (!wait_for_completion_interruptible_timeout(&pair->complete[OUT], 10 = * HZ)) { + dev_err(dev, "cap DMA task timeout\n"); + goto end; + } + } + + /* read the last words from FIFO */ + asrc_read_last_fifo(pair, dst_buf->area, &out_dma_len); + /* update payload length for capture */ + task->output_size =3D out_dma_len; +end: + return; +} + +static int fsl_asrc_m2m_comp_open(struct snd_compr_stream *stream) +{ + struct fsl_asrc *asrc =3D stream->private_data; + struct snd_compr_runtime *runtime =3D stream->runtime; + struct device *dev =3D &asrc->pdev->dev; + struct fsl_asrc_pair *pair; + int size, ret; + + pair =3D kzalloc(sizeof(*pair) + asrc->pair_priv_size, GFP_KERNEL); + if (!pair) + return -ENOMEM; + + pair->private =3D (void *)pair + sizeof(struct fsl_asrc_pair); + pair->asrc =3D asrc; + + init_completion(&pair->complete[IN]); + init_completion(&pair->complete[OUT]); + + runtime->private_data =3D pair; + + size =3D ASRC_M2M_BUFFER_SIZE; + ret =3D snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, dev, size, &pair->dma_buf= fer[IN]); + if (ret) + goto error_alloc_in_buf; + + ret =3D snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, dev, size, &pair->dma_buf= fer[OUT]); + if (ret) + goto error_alloc_out_buf; + + ret =3D pm_runtime_get_sync(dev); + if (ret < 0) { + dev_err(dev, "Failed to power up asrc\n"); + goto err_pm_runtime; + } + + return 0; + +err_pm_runtime: + snd_dma_free_pages(&pair->dma_buffer[OUT]); +error_alloc_out_buf: + snd_dma_free_pages(&pair->dma_buffer[IN]); +error_alloc_in_buf: + kfree(pair); + return ret; +} + +static int fsl_asrc_m2m_comp_release(struct snd_compr_stream *stream) +{ + struct fsl_asrc *asrc =3D stream->private_data; + struct snd_compr_runtime *runtime =3D stream->runtime; + struct fsl_asrc_pair *pair =3D runtime->private_data; + struct device *dev =3D &asrc->pdev->dev; + + pm_runtime_put_sync(dev); + + snd_dma_free_pages(&pair->dma_buffer[IN]); + snd_dma_free_pages(&pair->dma_buffer[OUT]); + + kfree(runtime->private_data); + + return 0; +} + +static int fsl_asrc_m2m_comp_set_params(struct snd_compr_stream *stream, + struct snd_compr_params *params) +{ + struct fsl_asrc *asrc =3D stream->private_data; + struct snd_compr_runtime *runtime =3D stream->runtime; + struct fsl_asrc_pair *pair =3D runtime->private_data; + struct fsl_asrc_m2m_cap cap; + int ret, i; + + ret =3D asrc->m2m_get_cap(&cap); + if (ret) + return -EINVAL; + + if (pcm_format_to_bits(params->codec.format) & cap.fmt_in) + pair->sample_format[IN] =3D params->codec.format; + else + return -EINVAL; + + if (pcm_format_to_bits(params->codec.pcm_format) & cap.fmt_out) + pair->sample_format[OUT] =3D params->codec.pcm_format; + else + return -EINVAL; + + /* check input rate is in scope */ + for (i =3D 0; i < cap.rate_in_count; i++) + if (params->codec.sample_rate =3D=3D cap.rate_in[i]) { + pair->rate[IN] =3D params->codec.sample_rate; + break; + } + if (i =3D=3D cap.rate_in_count) + return -EINVAL; + + /* check output rate is in scope */ + for (i =3D 0; i < cap.rate_out_count; i++) + if (params->codec.options.src_d.out_sample_rate =3D=3D cap.rate_out[i]) { + pair->rate[OUT] =3D params->codec.options.src_d.out_sample_rate; + break; + } + if (i =3D=3D cap.rate_out_count) + return -EINVAL; + + if (params->codec.ch_in !=3D params->codec.ch_out || + params->codec.ch_in < cap.chan_min || + params->codec.ch_in > cap.chan_max) + return -EINVAL; + + pair->channels =3D params->codec.ch_in; + pair->buf_len[IN] =3D params->buffer.fragment_size; + pair->buf_len[OUT] =3D params->buffer.fragment_size; + + return 0; +} + +static int fsl_asrc_m2m_mmap(struct dma_buf *dmabuf, struct vm_area_struct= *vma) +{ + struct snd_dma_buffer *dmab =3D dmabuf->priv; + + return snd_dma_buffer_mmap(dmab, vma); +} + +static struct sg_table *fsl_asrc_m2m_map_dma_buf(struct dma_buf_attachment= *attachment, + enum dma_data_direction direction) +{ + struct snd_dma_buffer *dmab =3D attachment->dmabuf->priv; + struct sg_table *sgt; + + sgt =3D kmalloc(sizeof(*sgt), GFP_KERNEL); + if (!sgt) + return NULL; + + if (dma_get_sgtable(attachment->dev, sgt, dmab->area, dmab->addr, dmab->b= ytes) < 0) + goto free; + + if (dma_map_sgtable(attachment->dev, sgt, direction, 0)) + goto free; + + return sgt; + +free: + sg_free_table(sgt); + kfree(sgt); + return NULL; +} + +static void fsl_asrc_m2m_unmap_dma_buf(struct dma_buf_attachment *attachme= nt, + struct sg_table *table, + enum dma_data_direction direction) +{ + dma_unmap_sgtable(attachment->dev, table, direction, 0); +} + +static void fsl_asrc_m2m_release(struct dma_buf *dmabuf) +{ + /* buffer is released by fsl_asrc_m2m_comp_release() */ +} + +static const struct dma_buf_ops fsl_asrc_m2m_dma_buf_ops =3D { + .mmap =3D fsl_asrc_m2m_mmap, + .map_dma_buf =3D fsl_asrc_m2m_map_dma_buf, + .unmap_dma_buf =3D fsl_asrc_m2m_unmap_dma_buf, + .release =3D fsl_asrc_m2m_release, +}; + +static int fsl_asrc_m2m_comp_task_create(struct snd_compr_stream *stream, + struct snd_compr_task_runtime *task) +{ + DEFINE_DMA_BUF_EXPORT_INFO(exp_info_in); + DEFINE_DMA_BUF_EXPORT_INFO(exp_info_out); + struct fsl_asrc *asrc =3D stream->private_data; + struct snd_compr_runtime *runtime =3D stream->runtime; + struct fsl_asrc_pair *pair =3D runtime->private_data; + struct device *dev =3D &asrc->pdev->dev; + int ret; + + exp_info_in.ops =3D &fsl_asrc_m2m_dma_buf_ops; + exp_info_in.size =3D ASRC_M2M_BUFFER_SIZE; + exp_info_in.flags =3D O_RDWR; + exp_info_in.priv =3D &pair->dma_buffer[IN]; + task->input =3D dma_buf_export(&exp_info_in); + if (IS_ERR(task->input)) { + ret =3D PTR_ERR(task->input); + return ret; + } + + exp_info_out.ops =3D &fsl_asrc_m2m_dma_buf_ops; + exp_info_out.size =3D ASRC_M2M_BUFFER_SIZE; + exp_info_out.flags =3D O_RDWR; + exp_info_out.priv =3D &pair->dma_buffer[OUT]; + task->output =3D dma_buf_export(&exp_info_out); + if (IS_ERR(task->output)) { + ret =3D PTR_ERR(task->output); + return ret; + } + + /* Request asrc pair/context */ + ret =3D asrc->request_pair(pair->channels, pair); + if (ret) { + dev_err(dev, "failed to request pair: %d\n", ret); + goto err_request_pair; + } + + ret =3D asrc->m2m_prepare(pair); + if (ret) { + dev_err(dev, "failed to start pair part one: %d\n", ret); + goto err_start_part_one; + } + + /* Request dma channels */ + pair->dma_chan[IN] =3D asrc->get_dma_channel(pair, IN); + if (!pair->dma_chan[IN]) { + dev_err(dev, "[ctx%d] failed to get input DMA channel\n", pair->index); + ret =3D -EBUSY; + goto err_dma_channel_in; + } + + pair->dma_chan[OUT] =3D asrc->get_dma_channel(pair, OUT); + if (!pair->dma_chan[OUT]) { + dev_err(dev, "[ctx%d] failed to get output DMA channel\n", pair->index); + ret =3D -EBUSY; + goto err_dma_channel_out; + } + + return 0; + +err_dma_channel_out: + dma_release_channel(pair->dma_chan[IN]); +err_dma_channel_in: + if (asrc->m2m_unprepare) + asrc->m2m_unprepare(pair); +err_start_part_one: + asrc->release_pair(pair); +err_request_pair: + return ret; +} + +static int fsl_asrc_m2m_comp_task_start(struct snd_compr_stream *stream, + struct snd_compr_task_runtime *task) +{ + struct snd_compr_runtime *runtime =3D stream->runtime; + struct fsl_asrc_pair *pair =3D runtime->private_data; + + asrc_m2m_device_run(pair, task); + + return 0; +} + +static int fsl_asrc_m2m_comp_task_stop(struct snd_compr_stream *stream, + struct snd_compr_task_runtime *task) +{ + return 0; +} + +static int fsl_asrc_m2m_comp_task_free(struct snd_compr_stream *stream, + struct snd_compr_task_runtime *task) +{ + struct fsl_asrc *asrc =3D stream->private_data; + struct snd_compr_runtime *runtime =3D stream->runtime; + struct fsl_asrc_pair *pair =3D runtime->private_data; + + /* Stop & release pair/context */ + if (asrc->m2m_stop) + asrc->m2m_stop(pair); + + if (asrc->m2m_unprepare) + asrc->m2m_unprepare(pair); + asrc->release_pair(pair); + + /* Release dma channel */ + if (pair->dma_chan[IN]) + dma_release_channel(pair->dma_chan[IN]); + if (pair->dma_chan[OUT]) + dma_release_channel(pair->dma_chan[OUT]); + + return 0; +} + +static int fsl_asrc_m2m_get_caps(struct snd_compr_stream *cstream, + struct snd_compr_caps *caps) +{ + caps->num_codecs =3D 1; + caps->min_fragment_size =3D 4096; + caps->max_fragment_size =3D 4096; + caps->min_fragments =3D 1; + caps->max_fragments =3D 1; + caps->codecs[0] =3D SND_AUDIOCODEC_PCM; + + return 0; +} + +static int fsl_asrc_m2m_fill_codec_caps(struct fsl_asrc *asrc, + struct snd_compr_codec_caps *codec) +{ + struct fsl_asrc_m2m_cap cap; + snd_pcm_format_t k; + int j =3D 0; + int ret; + + ret =3D asrc->m2m_get_cap(&cap); + if (ret) + return -EINVAL; + + pcm_for_each_format(k) { + if (pcm_format_to_bits(k) & cap.fmt_in) { + codec->descriptor[j].max_ch =3D cap.chan_max; + memcpy(codec->descriptor[j].sample_rates, + cap.rate_in, + cap.rate_in_count * sizeof(__u32)); + codec->descriptor[j].num_sample_rates =3D cap.rate_in_count; + codec->descriptor[j].formats =3D k; + codec->descriptor[j].pcm_formats =3D cap.fmt_out; + codec->descriptor[j].src.out_sample_rate_min =3D cap.rate_out[0]; + codec->descriptor[j].src.out_sample_rate_max =3D + cap.rate_out[cap.rate_out_count - 1]; + j++; + } + } + + codec->codec =3D SND_AUDIOCODEC_PCM; + codec->num_descriptors =3D j; + return 0; +} + +static int fsl_asrc_m2m_get_codec_caps(struct snd_compr_stream *stream, + struct snd_compr_codec_caps *codec) +{ + struct fsl_asrc *asrc =3D stream->private_data; + + return fsl_asrc_m2m_fill_codec_caps(asrc, codec); +} + +static struct snd_compr_ops fsl_asrc_m2m_compr_ops =3D { + .open =3D fsl_asrc_m2m_comp_open, + .free =3D fsl_asrc_m2m_comp_release, + .set_params =3D fsl_asrc_m2m_comp_set_params, + .get_caps =3D fsl_asrc_m2m_get_caps, + .get_codec_caps =3D fsl_asrc_m2m_get_codec_caps, + .task_create =3D fsl_asrc_m2m_comp_task_create, + .task_start =3D fsl_asrc_m2m_comp_task_start, + .task_stop =3D fsl_asrc_m2m_comp_task_stop, + .task_free =3D fsl_asrc_m2m_comp_task_free, +}; + +int fsl_asrc_m2m_suspend(struct fsl_asrc *asrc) +{ + struct fsl_asrc_pair *pair; + int i; + + for (i =3D 0; i < PAIR_CTX_NUM; i++) { + pair =3D asrc->pair[i]; + if (!pair) + continue; + if (!completion_done(&pair->complete[IN])) { + if (pair->dma_chan[IN]) + dmaengine_terminate_all(pair->dma_chan[IN]); + asrc_input_dma_callback((void *)pair); + } + if (!completion_done(&pair->complete[OUT])) { + if (pair->dma_chan[OUT]) + dmaengine_terminate_all(pair->dma_chan[OUT]); + asrc_output_dma_callback((void *)pair); + } + + if (asrc->m2m_pair_suspend) + asrc->m2m_pair_suspend(pair); + } + + return 0; +} +EXPORT_SYMBOL_GPL(fsl_asrc_m2m_suspend); + +int fsl_asrc_m2m_resume(struct fsl_asrc *asrc) +{ + struct fsl_asrc_pair *pair; + int i; + + for (i =3D 0; i < PAIR_CTX_NUM; i++) { + pair =3D asrc->pair[i]; + if (!pair) + continue; + if (asrc->m2m_pair_resume) + asrc->m2m_pair_resume(pair); + } + + return 0; +} +EXPORT_SYMBOL_GPL(fsl_asrc_m2m_resume); + +int fsl_asrc_m2m_init(struct fsl_asrc *asrc) +{ + struct device *dev =3D &asrc->pdev->dev; + struct snd_card *card; + struct snd_compr *compr; + int ret; + + ret =3D snd_card_new(dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, + THIS_MODULE, 0, &card); + if (ret < 0) + return ret; + + strscpy(card->driver, "fsl-asrc-m2m", sizeof(card->driver)); + strscpy(card->shortname, "ASRC-M2M", sizeof(card->shortname)); + strscpy(card->longname, "ASRC-M2M", sizeof(card->shortname)); + + asrc->card =3D card; + + compr =3D devm_kzalloc(dev, sizeof(*compr), GFP_KERNEL); + if (!compr) { + ret =3D -ENOMEM; + goto err; + } + + compr->ops =3D &fsl_asrc_m2m_compr_ops; + compr->private_data =3D asrc; + + ret =3D snd_compress_new(card, 0, SND_COMPRESS_ACCEL, "ASRC M2M", compr); + if (ret < 0) + goto err; + + ret =3D snd_card_register(card); + if (ret < 0) + goto err; + + return 0; +err: + snd_card_free(card); + return ret; +} +EXPORT_SYMBOL_GPL(fsl_asrc_m2m_init); + +void fsl_asrc_m2m_exit(struct fsl_asrc *asrc) +{ + struct snd_card *card =3D asrc->card; + + snd_card_free(card); +} +EXPORT_SYMBOL_GPL(fsl_asrc_m2m_exit); + +MODULE_IMPORT_NS(DMA_BUF); +MODULE_AUTHOR("Shengjiu Wang "); +MODULE_DESCRIPTION("Freescale ASRC M2M driver"); +MODULE_LICENSE("GPL"); --=20 2.34.1 From nobody Mon Nov 25 07:29:15 2024 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2087.outbound.protection.outlook.com [40.107.105.87]) (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 A72F61922CC; Tue, 29 Oct 2024 02:11:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730167882; cv=fail; b=AinPzpZWwNL4CL/LKkabBIrgj/b0Q2YPYyXfXtjMKL9w0h2qvkOfseXlQPjjJ7sYwrUjyblR8KPKpZWx25sDnwFy2+iNwGJLP+4JQlB2fktDt3kdhoK4yxZREFTy58/ZMo5c8G40aEAk2PLnD2BxQht3ZTThaNn0rc2l0lhb884= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730167882; c=relaxed/simple; bh=Kga5T+ah2FU3Ou2fNm/+P5B4ui4zBo7U8oJFsAlVAeU=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=IgfbXQo5fRiKl/ozn11I+o26GzvCQNFJI5fA6iugExONfPrCPP1qv/NY+j+AACxzmqisRFKpkoIfBDyIxbI0P9WdifF0iz8QrLYAhn5xO40d3nH3lGgP2AUVaqmO+Q/BjCxmve4u8csvkhmRzXbFyl8BAi0/khpgIcB5pdwxLgc= 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=aOL2ecp8; arc=fail smtp.client-ip=40.107.105.87 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="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> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2PR01CA0031.apcprd01.prod.exchangelabs.com (2603:1096:4:192::11) To AM0PR04MB7044.eurprd04.prod.outlook.com (2603:10a6:208:191::20) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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: =?us-ascii?Q?0WvsFjvQXmSyU518eiY0qatYO18A7wHjhFSgiNOruqx9Ycd11LJS40PkyDy/?= =?us-ascii?Q?JRppbuKA7KUmnPd/F6i2uVFGxlg9Y/MhDeUHtAniv/yxU1TMSZrK6vCjP3JO?= =?us-ascii?Q?tMVWmGyFdGbw7yZrSJY/EHUms8JGl6YDiqpNcuH+p/WndSGNfRr/prwoEy7v?= =?us-ascii?Q?mtf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WAsFuxWwJ8y1QY?= =?us-ascii?Q?G472kLTa9gcEieUpxF8Odd9b4mnBsB+vLazt0wY9U8wVMlFj3yo7QnQ3ihK0?= =?us-ascii?Q?zr3ric7BB1Srfl9yJ0370PO9sBjvIsLN4gXLvynpCtIV5Kap1HQHcP0gBAR6?= =?us-ascii?Q?N1gZDEWQUhCnOe39t14xgF4eVVwFuRR1ZegCqTePz6PBz+Ju6vQFZTlBZqtD?= =?us-ascii?Q?kU7QDh6otrhUQH4VF7uwFTL9lB8XaQD/tXXmzyBA2tZHrs7Bfe+5jjdaXQx5?= =?us-ascii?Q?xvjFKGd3WHLNgqNaY/ErF4NSXzr0ZVuM8VLNBTFdVklDIFIrTBMbuaGJu7F6?= =?us-ascii?Q?effO43T9tqosJAGtsMZzDWsj5H2m?= 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: =?us-ascii?Q?+utBqn+a6OjbEFUNtA9yVzn3Cr5svIzAcVNhc9nAvMK6rPj8kRdo2ENdjra1?= =?us-ascii?Q?udnCB+V6X0bEPHI2SAHir9DOdZli3Sb4JPihEuMsqvCGA76pKYC0CVKT9cMJ?= =?us-ascii?Q?+ZPlSbk7DrvNuJF15K/2xkIbRZWU60Qcpd0zFnQ7f5ZBUzxy/7Cr/BBcVdML?= =?us-ascii?Q?AHVI4q0OI/P3kd/uHD1D06U5ODlcSkCyLTkeaxPDaoRudplG352r1qntejbC?= =?us-ascii?Q?HfI2bPe+iMNQF3D495aGRCuISgB9+SYbv5GvTzdPOeES+KW7ofmyOQP7l6ri?= =?us-ascii?Q?rU1Opp7NjpQjGlt0FsdN4J3wQRwc8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=?us-ascii?Q?csWXWLJRqB4P8+nQjFsyvRZaBWxKcX/ebd3uXWqG/V+p1YSF2odK7bSC1WO7?= =?us-ascii?Q?aXi9WXnZ6STxbrG1VzdWjKUKbER7ZQPtrHhTqJ7pVzpf72jqxz4AufR8sEm7?= =?us-ascii?Q?u+Mz3jI0LDvjV4XwF/y9uEzltmhkeeZDQzEbWk5aTd7J4U9o+egCW+jJwmhL?= =?us-ascii?Q?HHVse6UHKD9+zqk73Gh8q7SUo3/JYraLJrM9NmRAZqXmqklZFMF2V0uytPmi?= =?us-ascii?Q?5/NQ5yq8COTLxH5OaZInXj4TjJ7A0ODonljJP8P0XKQjAk1HwZUuNgauxZ7A?= =?us-ascii?Q?uLdL0NOUjmARFY3NEhGyUrR+vYe4dLHzUyCAGCt0yw/rcAyYOXdg1Ik8XuzL?= =?us-ascii?Q?66VGJT/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 Content-Type: text/plain; charset="utf-8" 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 *pd= ev) goto err_pm_get_sync; } =20 + ret =3D fsl_asrc_m2m_init(asrc); + if (ret) { + dev_err(&pdev->dev, "failed to init m2m device %d\n", ret); + return ret; + } + return 0; =20 err_pm_get_sync: @@ -1396,6 +1402,10 @@ static int fsl_asrc_probe(struct platform_device *pd= ev) =20 static void fsl_asrc_remove(struct platform_device *pdev) { + struct fsl_asrc *asrc =3D 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; } =20 +static int fsl_asrc_suspend(struct device *dev) +{ + struct fsl_asrc *asrc =3D dev_get_drvdata(dev); + int ret; + + fsl_asrc_m2m_suspend(asrc); + ret =3D pm_runtime_force_suspend(dev); + return ret; +} + +static int fsl_asrc_resume(struct device *dev) +{ + struct fsl_asrc *asrc =3D dev_get_drvdata(dev); + int ret; + + ret =3D pm_runtime_force_resume(dev); + fsl_asrc_m2m_resume(asrc); + return ret; +} + static const struct dev_pm_ops fsl_asrc_pm =3D { - SET_RUNTIME_PM_OPS(fsl_asrc_runtime_suspend, fsl_asrc_runtime_resume, NUL= L) - 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) }; =20 static const struct fsl_asrc_soc_data fsl_asrc_imx35_data =3D { @@ -1538,7 +1567,7 @@ static struct platform_driver fsl_asrc_driver =3D { .driver =3D { .name =3D "fsl-asrc", .of_match_table =3D fsl_asrc_ids, - .pm =3D &fsl_asrc_pm, + .pm =3D pm_ptr(&fsl_asrc_pm), }, }; module_platform_driver(fsl_asrc_driver); --=20 2.34.1 From nobody Mon Nov 25 07:29:15 2024 Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on2057.outbound.protection.outlook.com [40.107.103.57]) (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 7F8D48172A; Tue, 29 Oct 2024 02:11:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.103.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730167886; cv=fail; b=ETMKqdpf3UYMlRNNva7pdoWG/Ng0pWBHOsGaNGuvg+K/irS/03w3QXm9m/KDvnFtjC/irceIwZGi6+QshjsyNoHTnoEQZFEEbEE1ZN6W5c9O8lrlX1aORW/71+hg5SdeEGyVk0DDLXg37BuUcYI+lj9VJI1AigNbmCFA4Q+bQGw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730167886; c=relaxed/simple; bh=oROrbigEnbxBbJQZmQCz+t1ZoYRdoE4L/rIVMdGvE9E=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ZMDJaStbHv0neIAURtiK0Y+3fjwg+NKi7dLbmQGgXCiI930ig2eDj+t6eJa3OCkec1EgCJECeNgqNP3/sZtmAMZGlnMwadS1F4tBDTS9xycX2kWgP22xHtkArk5a1tfGG1aGnMRLR70RwhXGf1e3LlReAYc9jgAcWQnrzaHacqA= 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=E7LMXz12; arc=fail smtp.client-ip=40.107.103.57 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="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> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SI2PR01CA0031.apcprd01.prod.exchangelabs.com (2603:1096:4:192::11) To AM0PR04MB7044.eurprd04.prod.outlook.com (2603:10a6:208:191::20) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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: =?us-ascii?Q?CSn5g2pj1+RrIIq2+nsWDMRV51vRg5EAhG94ssvjkDtrp65KcPOuO71xxlab?= =?us-ascii?Q?tYM63mfNgDq30X++Vt7fuTNj6/OQoHCF2PEW+Cw9MHPn8uNcpUa9m2spAotd?= =?us-ascii?Q?qtt8to/DzP4K581F029Ir6+6Z1lyrxGK9tw32PfQrDeJB5V1v+IdYjJuTkkt?= =?us-ascii?Q?/hDP7a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Nj8KmuQLl42xcTS?= =?us-ascii?Q?aTmUlYxLRdPiDf3v7Tay1Nm9TnxgQjlfqTC/8vAdY3mlmhMJkJY/UgLDrmrS?= =?us-ascii?Q?Rac/zfo2W3MhRCPLue7XzJ/rGSGgrsGNTc4XnUpPBNyh2o7kDp6t4zAU8h+z?= =?us-ascii?Q?MkFP+0Bh4Nzxd6Bk+fZLU+0f6UIrUS5rnPdVDb+h/xwoH4aNTwg2Y2AIE+lg?= =?us-ascii?Q?xNgrTUrBb0gS4Q/owiWbkiLnlukApMAg2cS2qiXFFyVRtcRgWEmH/HjQGXfm?= =?us-ascii?Q?GzuCnteBt3AmSNrgUpOtwR/90z+h0iTyAkm0D6fLgcblHUID53K5pYLjEPqA?= =?us-ascii?Q?onL6lv5hT/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: =?us-ascii?Q?OI42LS+///UHlb5BMi3EIb7FRcU4k6At9klKP/lcgymEI2WVEvd2o4n16djJ?= =?us-ascii?Q?elg4IrkORR7KyFldTD+BK3ZK5b8vu/x9F5EtZwXQdI8EjsBQiEpD5hpzP/d0?= =?us-ascii?Q?XaoDou+iQ5RDfll6E6wbxDp0yh1Ys1vinVWzeGEXN/CmJV4xWDNsUqR/qs04?= =?us-ascii?Q?boIjW8gmrOU4oLaOr2+ZU1H2UhhY6orhyVy2JOkupjRrNbHH7XJ/bi8g2qb2?= =?us-ascii?Q?sZETG0jHLhjoh5bw8tzMjp1cE30do+/MGfNH17mEtT35ak6sogIGu7IzGGAO?= =?us-ascii?Q?eA+cEUySOzSzpkfyYDHUmZ1jc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= =?us-ascii?Q?ILrSZCTXAdcervPEfZJ8nR9pA/88S8nuq6n+yVAenkMu5tn9l9l1XOG0SqbX?= =?us-ascii?Q?MZtvb87cRQLxZzd56CT9dZYpwzyOqGzgZAsR/3t9g+Qy7d3pf6A9nN/AnvEQ?= =?us-ascii?Q?rS0dIqfwSL4ONIF58xgkN5NqyOL7NRDSS3YIa6OMM9DUSEpMgFgSY71RJUlv?= =?us-ascii?Q?MB9cKea//ffXFGdsRKtb5y9TdUq5mv6TdFyyvrZ27CrrvxDR7Gc0csRLaBJp?= =?us-ascii?Q?sf0aE8nMLeBFPgiPpAQ8Er3L2tkKFyZW73CVprJOsrEIng/IfeRVlMWUTMwn?= =?us-ascii?Q?ewpQp7GX6n86oK+Nqv2ygQVL56sYIrvKRbNXHEuyJ/2iINbMNPDzV8WvR41V?= =?us-ascii?Q?JY5PXtJKXHCKQmCr6KhXfU6rq4ZWyZ09zZiWR4ZU?= 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 Content-Type: text/plain; charset="utf-8" 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 *p= dev) goto err_pm_disable; } =20 + ret =3D fsl_asrc_m2m_init(easrc); + if (ret) { + dev_err(&pdev->dev, "failed to init m2m device %d\n", ret); + return ret; + } + return 0; =20 err_pm_disable: @@ -2213,6 +2219,10 @@ static int fsl_easrc_probe(struct platform_device *p= dev) =20 static void fsl_easrc_remove(struct platform_device *pdev) { + struct fsl_asrc *easrc =3D dev_get_drvdata(&pdev->dev); + + fsl_asrc_m2m_exit(easrc); + pm_runtime_disable(&pdev->dev); } =20 @@ -2313,10 +2323,29 @@ static int fsl_easrc_runtime_resume(struct device *= dev) return ret; } =20 +static int fsl_easrc_suspend(struct device *dev) +{ + struct fsl_asrc *easrc =3D dev_get_drvdata(dev); + int ret; + + fsl_asrc_m2m_suspend(easrc); + ret =3D pm_runtime_force_suspend(dev); + return ret; +} + +static int fsl_easrc_resume(struct device *dev) +{ + struct fsl_asrc *easrc =3D dev_get_drvdata(dev); + int ret; + + ret =3D pm_runtime_force_resume(dev); + fsl_asrc_m2m_resume(easrc); + return ret; +} + static const struct dev_pm_ops fsl_easrc_pm_ops =3D { 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) }; =20 static struct platform_driver fsl_easrc_driver =3D { --=20 2.34.1