From nobody Mon Jun 8 23:58:06 2026 Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010021.outbound.protection.outlook.com [52.101.69.21]) (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 2356134A3A5; Mon, 25 May 2026 08:11:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.21 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779696699; cv=fail; b=FhhDQOdgya0YsGFZO5pEiAJu3HmYqytMdJ8xX79FaR3MrwpI3a4REpJsv+yiWxQLJhvBgcLWOmkdZa3prpQoG61/NCeUVgm/6YbFUz5xIMjk6/DpwDH9ujUNAxKe9+IvN8O/+LbJiJtZrzGraZME0WVqtIFSBxeeyODo7yBzZek= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779696699; c=relaxed/simple; bh=BY7xCohUr3K97UJsCK22/e7O2thwxIqMTPQt4fLq4NI=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=J4pANd3GdDNFdNVH78X4YVtUzumJBA/5YCATAxmfeVL9/NKDSZBsSpPR0I3D6yhCFzuxCqhDeZ2bnpgUhW54Z8NIg43RF9c9k+Ky3KcuasB6XbSiSg6mRA5h30Y0aYz/2Z9/HtTRjLkGxvN9LZUxXeJZMsVk/5SyS9cptckJBKY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=arfgRGe1; arc=fail smtp.client-ip=52.101.69.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="arfgRGe1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=n8UljJzBCinE8HixlZ6WixThZXhAY3nPcUmNrCecEfDdmrGd+eQVkd6UdGcjnGXvlHDvaaUis8Ci9Se5FAN7coIoM5gCiBqyTnRrzYfCzG+v56XMspe2Kgm/j2JgsuEEf0yhrCJ52wpnA6pd57axwVUS2tEtJIkRHgiHkRfCarEcJiE/V8gPAqID3yWWGhsWuceO07h7d2j6C4p3hPCVpNB+NHai3VCwB3MElsMgVwOsArtNfa9qLtaMikjzKX7p8spBE+Q2wqXb/h7upeFpBk/AcfuEoR+UZL1dSWsrjyIbKubL243NSR0FXp3x2aLYqjYsu5Nz9Ur4Yr52Ur+8fQ== 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=Qm85wkEA2ap+HdL3dSzLODWHGpSCQH+bwQlKT7jSlh4=; b=Q4JGvGydFw7JEO108fifb7K12Q6yo1HVI9QtjgMkpZz2HbuABTLb+m6puJoBNmTXeVzTCBCk6GSOzRwUQ2xJ1DXHPh4jzztvLfzrPp7OWftY3m9L9y1FYno2LHyoVzF9QIXFztXfn5AmlNzzZxJ+i6vTaLIXMsW1SZlWlN+aGAW6WTD/ysdtCK4JuUelpQefY5/u0nCwi+6cgjv9drwEd9MNONnQTjHdl84d0KR+2AnjF9gzluU/Op1r5fJbKFK/q8U5J3iJZBronBzFPomWn+GULmeEQaN192Om5qNA84sjBDJIuTI/hJRARPc/AloMVcsmqPdPumG6dtCa8hJncQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Qm85wkEA2ap+HdL3dSzLODWHGpSCQH+bwQlKT7jSlh4=; b=arfgRGe1DyA2r6ZJ+ZSt3wla9bXP/kpWDn5XKKN+b+fi2rTBPbfXVGSngWu021uVI0kPerAxseDfSYMmrPoyH8B/wfMKIgeoj4+lAkkZg8jnE54SEJ5JBgy0yMe3oFAk15oUs1MjzNPXvlGk7imyShvSuoB2A3M6VPAqVCQ6ozkHPVUCJ/1MNRV92fi3+NHvO4RWcjfcAJFKvKNJWvBmbtlVwq1quRlpTyaOxDX4qyuJ4U7+3hUqAjxZOop5Oyz1C4+UlnHeyujCfxcVlwAhUM8tOjiRPAifR/a5bxWQsTJPOrW8qlihmjKfkMEf12pQhah/YQKwsgFodIADJA+U/g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AS8PR04MB9080.eurprd04.prod.outlook.com (2603:10a6:20b:447::16) by GVXPR04MB12265.eurprd04.prod.outlook.com (2603:10a6:150:30f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.48.20; Mon, 25 May 2026 08:10:04 +0000 Received: from AS8PR04MB9080.eurprd04.prod.outlook.com ([fe80::92c2:2e03:bf99:68eb]) by AS8PR04MB9080.eurprd04.prod.outlook.com ([fe80::92c2:2e03:bf99:68eb%6]) with mapi id 15.21.0048.016; Mon, 25 May 2026 08:10:04 +0000 From: Guoniu Zhou Date: Mon, 25 May 2026 16:12:22 +0800 Subject: [PATCH v8 1/2] media: dt-bindings: Add CSI Pixel Formatter DT bindings Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260525-csi_formatter-v8-1-6b646231224b@oss.nxp.com> References: <20260525-csi_formatter-v8-0-6b646231224b@oss.nxp.com> In-Reply-To: <20260525-csi_formatter-v8-0-6b646231224b@oss.nxp.com> To: Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Laurent Pinchart , Frank Li Cc: imx@lists.linux.dev, linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Guoniu Zhou , Frank Li , Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1779696771; l=3479; i=guoniu.zhou@oss.nxp.com; s=20250815; h=from:subject:message-id; bh=johQ4RKAJItBaT0lZRnkXFEYmsq1OdVQdhsviVHn/zQ=; b=sW0hJryhcUiRUfsoT9V587vp5vMeJkr4/z6oNdJgPAK/LuqruQMHur+urncz3QQ7Dh+GQHR5G jx8bqA/1xQaCbrILO5I5fWxXHUg1LCxv0pqZQElWgU/CSFxLWcujiZD X-Developer-Key: i=guoniu.zhou@oss.nxp.com; a=ed25519; pk=MM+/XICg5S78/gs+f9wtGP6yIvkyjTdZwfaxXeu5rlo= X-ClientProxiedBy: SI3PR02CA0007.apcprd02.prod.outlook.com (2603:1096:4:295::9) To AS8PR04MB9080.eurprd04.prod.outlook.com (2603:10a6:20b:447::16) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB9080:EE_|GVXPR04MB12265:EE_ X-MS-Office365-Filtering-Correlation-Id: 3383ad81-df8b-428f-d0ee-08deba3506f7 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|7416014|376014|366016|19092799006|921020|38350700014|11063799006|3023799007|56012099003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: potbUqwZugPdFdh5D5gI3pHgFV00suRP8825m1pfl9DGUdy1/FseWL6fO6mf3ddU3K+SY7jt5nXlE/NxdDNYsc1F5W3Aa8w3NJAXPpwwqtDYr6MCWvJ/rsl2VpGpp2glWJfcq2/wsn++mYe8Sl3pO3K68JVEUaZAOz+pW5/9s9JwpI409mfShijxB1SWXFqxa0LK5ZusQv3WCEzga5FQ3aQF6xgXafb0+mhYoA36tPha6ajQXa0Nh/nXDjvWCSpTlbGibFQoTVy4ehtNDfABTCfOxc2Bm0YudwEmVxUGTkZRg04hc8m/c/W3SoOAZnUtrygLBZ6PyDFl3afvGI0zwsoqczO4kZ0Yca1HSvGwEgW4+Y+soclOpSREkoFrTgWym/HG5BMVBAaXKO5LiBkMN+aoMZuyALsBP80tNSyscpvh+EaXoarx/o9mAg5YenCAhxhPRXC7iZefkNWGq6CMyznn/d2mYL3MDi6E73Jya/r5bcPf8naTu6hT3wuyb1yEpt1r/TYIIV48x7ecTrX1TcwbaZHP6n3a7tqzQ70WW3rO2oyJlqgGQg783eNO4EmPciekvBiwnkcOlptmJqawFW2Fh1dRKI+DiLBpYdXB2Y+i07tXUH5inAxMHOo9y4LlL5kAc/VOzeU8vbj/lsdTlVNB+Ks1LiYlLFjXcegbD1rQNHaFVPPg695N8FhJ/YM/1oWzpg62089IMZR0FVjwpQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR04MB9080.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(52116014)(7416014)(376014)(366016)(19092799006)(921020)(38350700014)(11063799006)(3023799007)(56012099003)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?UTF4TG54UlVBVDFBMExaL1R0d3hjNks1cGZmUFZ1Z0MzbU91OFZkejhYRncr?= =?utf-8?B?Wnpma2FtS05rRXNnUnF0MWhIaWYyWFNtenEzSHVxL2laa2NkME5WMnZOSFFh?= =?utf-8?B?Q2dTc1NrRmJtV3RaMTZ2K0dKcmtJd2lsakozZCtGUEgxRnBqdThZWHdBWW5x?= =?utf-8?B?amNHeEQrWXlJaUxUTG96Wm1HZlAyR3dRRXNjY1ZlaEZXcVViWUdjbDhnNDJU?= =?utf-8?B?b0dKN0NnbnhjZXBXNEdmaENReWphYU9UUENQT204ZHBSM3RYUnIyWkFSRjAr?= =?utf-8?B?aFlKWjk0akk3NHJtMG5MN09iNzFZNGxkU0JJamJaWEJYYUlPWFg0ZzVVRjdw?= =?utf-8?B?VkR0c1FOMklJMlhxWCtjQnU3L0cyOWpQeHFTS1ZjZm45dEpMWjI1MWg1Q21N?= =?utf-8?B?cDZwcWkzM2lLWHRBT1ZVemZnNXZLN3VJS0JMeGs4K3dhT2UzY0V4a0J0RTJp?= =?utf-8?B?T2dhQm83Z2dvaWh4b0crOGd2aEZqV1dKK015QitvTmdySkxOWjNndVRsMWZI?= =?utf-8?B?NitraldUZUVJaWF0T2RlNWxUcGhZU3FYajNzTzFIT2RtU2pZeGNxNTFJaE9P?= =?utf-8?B?UFd4N2E2bHByQlVwcmx6TTVEQkhZVHVNalNRUUUvMVJXanVocisrYWdZOXdk?= =?utf-8?B?aThXK2cyRXpxMTFWM2hpdWJCS0Q0RVJjSGwrd3lteWxNMlZCUG9IK2JFOW5o?= =?utf-8?B?eThkdnNPQ2tYY0ZNU2dob0ZucVp2WkxEYUZXcmlYUkx0UmpZTVZMVzRqTHFT?= =?utf-8?B?bXBZRkV6Q1FINHJ5Umxub0ZyQkRmSlcyRXFWSHg5ejdkbmNDYytqcHBtN2dy?= =?utf-8?B?aVJ3ekFpRHc0ZUQyU3Zock8xMjFRMmhxdXNpRkVla25GTTQrTWJqT2xhNENB?= =?utf-8?B?Y3BTb1hhUDl0NDJYU0dwdE5iNGF4RTB4NWh1cDN5MTUyU3BaM0pCdDNBMnVE?= =?utf-8?B?Q1I2NE5GUS9WWDZ2bWdUUVkrWlM2YWVrd2tzaVlwaUZTZWhweVlYbnB6RFFp?= =?utf-8?B?d1Rtb04vL0N2S21UTW9UM1B6UkdTWUNXbnpDRzZ6VWlvUVIzZklCTDk2d2gw?= =?utf-8?B?MkNjdytFRzBJcmpMTTNkQ2tGM1BtcEFVZGFyNVFMa3RPbkRpdzFOd1JKT21V?= =?utf-8?B?SGZOQ0RDeGxPZk0ydkxva00rL0JuRENPTHZqK0FJcStpbXVGWnJuTktGbTAz?= =?utf-8?B?T2d5UkhIZFhUNG1WMUszV3B4VGtOUFErdlFtaEc3aDgvQ3FEL3prbUk4RWJu?= =?utf-8?B?RmZKeHpSZk91MGFiQWFrVitFTkxZM3hjbVordmkyQ3hEU08vaVhVZkVwcHJn?= =?utf-8?B?NUYzemU5UlBhSllCVHN2dDBKeUpqcWt2WjBTQmdzOTg1eXVFN1lYdWpuekxL?= =?utf-8?B?Q2ZmUVROTW1BSlkyYVlNeE15aUpneTNaTWNPTk93Y2JYaGlNSlk1MFN4K1g0?= =?utf-8?B?dTNXRzFIZEhHWHpVMjVvZFAycmRBMndyTURQY2FYRGNEbDNDMXhGb05yRk1r?= =?utf-8?B?MVhXMlFiQndTb3RETGw4Q2VoOURwWGhRU0l1ZHBieEtKdDkyb3BtZ21jcmY1?= =?utf-8?B?NHZHY3AybjVKS2pqTGwzMHVkTEVuUFB0WWFXNEpCakZoQzA2M1NtamV1WGZD?= =?utf-8?B?OFg1MjJNd2FaeERkMmM3TkdwUTU0UWU1ZVJ4elg2YjBCWXVOMTFuaVFENDRL?= =?utf-8?B?dGZRcGI3Q3p1MWZXOXQ1WDFWdmdCOEJyZC93Y2tscEZRUWM4ZHJpS0NGNEtD?= =?utf-8?B?eU9udnVzL0hUNzA1ZDVGS2NIUG43cnI1WmhmL2o1RlBlVFNpZGhrdXdTZEkx?= =?utf-8?B?dUlJZWhxZ2xqdUNrbmZhaUUzeVBTZ3hZWTBRZ1FlNHRjSmU4ZGpyWGtJb3Vo?= =?utf-8?B?T21VOERxaThuakExYlpIZHpXd2xhNFJNWVZFWWI4K2dkaDJyVWNuK2QwMUU2?= =?utf-8?B?REVsM1pTK09vZ3FZV3hHdFZ0NTIrRGhOZHpZclA4Yk8vS3NDNnRKb3NnTkZB?= =?utf-8?B?VVVrSEU3K2g2RzRHalQybzdnbmxjaUJDdmdrK29IQ0tWUHY3TG4wajhGY0dU?= =?utf-8?B?RDRoc0YzaUVZcG9mK0t1Ny9OYTl6R2d3SzV1eWhMU2x2cVQ4UEVvSC8vL3Zt?= =?utf-8?B?L0MzUnpxRUkwdHZjSW50YXBtTGdSVEtoVkV6aUFWVDdlS3ZDRlZkY0VrVWdm?= =?utf-8?B?WXFPOWFPU0t0QS9BUDZZNWEzWDMrZ082YVQ4dTNiTEZWdVBjdWp6NDNMa2R3?= =?utf-8?B?SFJRM2JkR3NlbDEvdWRXMXB1Ukt6b3FxQStVcU9jNUR6K2pVbmNqaVU4N0dn?= =?utf-8?B?QWM5bjJnREJJV2NldVhleGI4YWxpa3I2aUM4WHJBbE9tbCtFNWkyUT09?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3383ad81-df8b-428f-d0ee-08deba3506f7 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB9080.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 May 2026 08:10:04.7875 (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: 8c6yXGLIMOSm5Mrc7Y7mRjF7YKZdxJ/b99J3+FOHKvfSAvkv1+tBtNUMP25qiKqgeHzCrZbzhTCpQfIXEFkTtQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR04MB12265 From: Guoniu Zhou The i.MX95 CSI pixel formatting module uses packet info, pixel and non-pixel data from the CSI-2 host controller and reformat them to match Pixel Link(PL) definition. Reviewed-by: Frank Li Reviewed-by: Krzysztof Kozlowski Signed-off-by: Guoniu Zhou --- Changes in v8: - Use standard port reference instead of video-interfaces.yaml - Add parent syscon node in example to show device integration - Add required constraints for port@0 and port@1 in ports node Changes in v7: - Change compatible to imx95-csi-formatter as IP is i.MX95 specific per Mar= co's suggestion Link: https://lore.kernel.org/linux-media/20260511-csi_formatter-v6-0-010= 28e312e2b@oss.nxp.com/T/#mcd135b3de179b3cb69daa1fd6e0e8e27c85b3332 --- .../bindings/media/fsl,imx95-csi-formatter.yaml | 92 ++++++++++++++++++= ++++ 1 file changed, 92 insertions(+) diff --git a/Documentation/devicetree/bindings/media/fsl,imx95-csi-formatte= r.yaml b/Documentation/devicetree/bindings/media/fsl,imx95-csi-formatter.ya= ml new file mode 100644 index 000000000000..bc2f5d448fe5 --- /dev/null +++ b/Documentation/devicetree/bindings/media/fsl,imx95-csi-formatter.yaml @@ -0,0 +1,92 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/fsl,imx95-csi-formatter.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: i.MX95 CSI Pixel Formatter + +maintainers: + - Guoniu Zhou + +description: + The CSI pixel formatting module found on i.MX95 uses packet info, pixel + and non-pixel data from the CSI-2 host controller and reformat them to + match Pixel Link(PL) definition. + +properties: + compatible: + const: fsl,imx95-csi-formatter + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + power-domains: + maxItems: 1 + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: MIPI CSI-2 RX IDI interface + + port@1: + $ref: /schemas/graph.yaml#/properties/port + description: Pixel Link Interface + + required: + - port@0 + - port@1 + +required: + - compatible + - reg + - clocks + - power-domains + - ports + +additionalProperties: false + +examples: + - | + #include + + syscon@4ac10000 { + compatible =3D "nxp,imx95-camera-csr", "syscon"; + reg =3D <0x0 0x4ac10000 0x0 0x10000>; + #address-cells =3D <1>; + #size-cells =3D <1>; + + formatter@20 { + compatible =3D "fsl,imx95-csi-formatter"; + reg =3D <0x20 0x100>; + clocks =3D <&cameramix_csr IMX95_CLK_CAMBLK_CSI2_FOR0>; + power-domains =3D <&scmi_devpd 3>; + + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + port@0 { + reg =3D <0>; + + endpoint { + remote-endpoint =3D <&mipi_csi_0_out>; + }; + }; + + port@1 { + reg =3D <1>; + + endpoint { + remote-endpoint =3D <&isi_in_2>; + }; + }; + }; + }; + }; --=20 2.34.1 From nobody Mon Jun 8 23:58:06 2026 Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010069.outbound.protection.outlook.com [52.101.69.69]) (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 5F5033DCDA0; Mon, 25 May 2026 08:10:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779696661; cv=fail; b=TyXenAsaxCaNU9r2LAHPThSmOEKhZ71ZnZDsj/EqzQoXt3geFb+2yhuxVbBImv9CYbj3m/QE2r02K+4JK6VqpsxLuNLBzlijSxJYtMA2G7PWQj8Ev6zLwli4FUnGN2+58esvL03b4NiAQq4Bof/UpWX1SKTML0ZUmG8SWQyc5lo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779696661; c=relaxed/simple; bh=6igy+fMrh/y+6RZ1iMcVBar57A8ZpwpiamSn2LhhU0Y=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=FrjehkiX0ABCEMtrdTEXvgh6cPaklqYSqzkkuPajVz7pet0+yBlC1AoHlZ9JRAuWZ3AT0dJ5M8uQZ7NOz5Lq0AXEZq0tTRDTKNuGwIYWntR0khlKai4zP1xQKPhUCgnjxdNwXfSJy5JIcDoDV4bf0nCSoNFSGiPi3iBuJsuRr7s= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=Okake7co; arc=fail smtp.client-ip=52.101.69.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="Okake7co" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=i7imcruqqe4mHQgb+0J1E+2GRBI0Fi151cX5C23EHr46MhBlwOpkIFBQUsWQGLiGjcuVHFlJ4WHdFIAlFxNfkKY/oV5iJhi+cJw8wKjyB3Hq8iwR2dCkSaVyGmltdNMtN55AYDFACA009U9a9c3R61YYHDTIPLsduyvuuKtHmGh1z9RCS+QtZLIaG/sQCd1RscGzXtJ8JsuVHR39+0v0gWoX317FLkDTnv42yqqAnJi385NaCSCYODaGoKJeccab3mwfclw3smXza9JKRKRZ3+FVoYGIFpIZIF1gGUcEgR4Zu2qR3wGDNH1MgRChNiSl8VgXi2QJqegMfXEwIWgPQA== 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=I8Fdrizxx5ed/cGLwhnZTGHDPgUoypXXB2cB33NaVdY=; b=M/WOrhc9RGf9xn5FLmf8jnSvEHkj/TVsDO2HWIVCoQtO2B7ktc7JJIBVwp/yL0GHMvX6tSlYpGkH1pq0fwQxyCSgBJyQdyg0puwIHVWnkwkMmYzFZUpWEjZHDETyZF/d0oXhY1rTbA41W8e+JKwB+ps+zSXAVbsOSfNywadVdeEGdAU0AWiNP/hcIwCIDtiMtiYg0XLSothwUIfMAHhaXNLu8lP4HyQCPd8ie0x0O2afsPIAL+mWAjOL74UIZ3bOMmP6kX2qzgPqTpsUDD2DAhu9m4+kNuEWYE9V14HqA2Sa5Nvk4jfJEH00dx09BHweLjWRQXKnigrNxT1N++S+dA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I8Fdrizxx5ed/cGLwhnZTGHDPgUoypXXB2cB33NaVdY=; b=Okake7co8TEg9eS9DUy0Si7KhWmyWqpdUgdAQlxK6gKYQ9uPTULc1JlxKIuXFdy+9FaTUXWtsknWtmS30assnzo+Gf2DeSWfiZLPzUBuJLWJ68SbJYIq6RJJJEC3UogqRTcCgSUv1cO/3d9TS5op29AgK8SaVc99wRhfylfl5sqTVpeXDY+wypAMuGeCMYv8nxizosQ0fUGx1XQ5Ug84Ju/XFDmTerjn2iLI+U2FMBqndpQ2WCpjvIJGyC/1PYyk2EIXf6Gm9v5MRxzWZcd/rCdJJPRdAdWMsgv8HLprskudyS/+eSvvGaZ+rFRpeCOATiyPjaN46zp5U9EgfyBTMA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AS8PR04MB9080.eurprd04.prod.outlook.com (2603:10a6:20b:447::16) by GVXPR04MB12265.eurprd04.prod.outlook.com (2603:10a6:150:30f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.48.20; Mon, 25 May 2026 08:10:16 +0000 Received: from AS8PR04MB9080.eurprd04.prod.outlook.com ([fe80::92c2:2e03:bf99:68eb]) by AS8PR04MB9080.eurprd04.prod.outlook.com ([fe80::92c2:2e03:bf99:68eb%6]) with mapi id 15.21.0048.016; Mon, 25 May 2026 08:10:16 +0000 From: Guoniu Zhou Date: Mon, 25 May 2026 16:12:23 +0800 Subject: [PATCH v8 2/2] media: nxp: Add i.MX95 CSI pixel formatter v4l2 driver Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260525-csi_formatter-v8-2-6b646231224b@oss.nxp.com> References: <20260525-csi_formatter-v8-0-6b646231224b@oss.nxp.com> In-Reply-To: <20260525-csi_formatter-v8-0-6b646231224b@oss.nxp.com> To: Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Laurent Pinchart , Frank Li Cc: imx@lists.linux.dev, linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Guoniu Zhou , Frank Li X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1779696771; l=27144; i=guoniu.zhou@oss.nxp.com; s=20250815; h=from:subject:message-id; bh=JL7w7oaO7hqHcuR8qlVRM2YXzXRvN3qmtD9yEC/OPxs=; b=eUgdctRvahEq98L5w7F9HgHBuYH2qA9GTVAAMq5gjS1BC/RZ8ou774jA4Bgslsvc6Hvl6AMTS 7iKyZUfRlSLCmn+Awy0x1bg0GNoKSwt2/VedVXGKumf3v8atNQJyXMq X-Developer-Key: i=guoniu.zhou@oss.nxp.com; a=ed25519; pk=MM+/XICg5S78/gs+f9wtGP6yIvkyjTdZwfaxXeu5rlo= X-ClientProxiedBy: SI3PR02CA0007.apcprd02.prod.outlook.com (2603:1096:4:295::9) To AS8PR04MB9080.eurprd04.prod.outlook.com (2603:10a6:20b:447::16) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB9080:EE_|GVXPR04MB12265:EE_ X-MS-Office365-Filtering-Correlation-Id: 396d309a-5d27-444a-2587-08deba350dd7 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|7416014|376014|366016|19092799006|921020|38350700014|6133799003|11063799006|3023799007|56012099003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: O/rCO+M7WFOc7zBC01SmNZ3+5TKMWbezWmlgsNZlvWNKU+Llr5cpmMSlcTwDY5l9DBdLn2zDCfZf7BRWQGjkdhsifRzApW5gw6m/GLfLW9fbJ+pqhUWEZIqpZpdiSN7CfEo/UJQ0K26epCsrVU0O5Ih1cn/1cLeyh3WMZQFr/aaa1IVzUDrCdxUntE6MfMbCH7ZklaV+0cijm1vchtW9G+Yyfc7CWM902ubtV6+PmZyMSnJhrJD1Wun29X7SlyLLv00p7qrmroEVUgt9MWObuQke7iWCXhJrLXYv7oXSajbGbKklIkfGZd32mCsB8plQZt05lxIq0Uvu77+PlikU+VzlUR3ot17BWs1GidbsrSoBi7Y+iM5YL0xil3omh3YZDBje+TS9cDa8E3+6MvbmvrUD9RupjYofOJSYnSF9l6Wsfj+KZ1yHmnTQpzOkYvlMZyGgAuCxLsBO419XbOwqP+yRVpRI1aKQdcX9beU3Xe5E53paP4AlBihUn4yWHXMUUzAbOBtymAmm41fHrjzllz7rSfH9U/oMolUGkgk34TzxTxbmJ4X8wP8RtHuvETwQ+128Sp4YccFTNwcGqJOXBitKPKaK7egn+zGXy0Cvqyf7Ugr014O53QYfU4MipSq19HFHgR+Pc9VTEBiyDEzqm4GiUDrtqDOSQdspOPP5u8h2BWnoquy+hc/tHI5j6QhMQ8IR+hY/UHr2emydYY3pORAjXgdeWsbNNerpAMv+HLpYwZyjp0KmHsmAsDlAFC5wYx163cAisTjORAuvWdpCsg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR04MB9080.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(52116014)(7416014)(376014)(366016)(19092799006)(921020)(38350700014)(6133799003)(11063799006)(3023799007)(56012099003)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?QkdVOHh2NjlhUXcxL0gzMFRXeDRrZmxPRUZsRmRHQ0o0cUVOWjZSZXV1UUMv?= =?utf-8?B?cmtNSGg2QzJoRXNySmtVSE9xVFFKWi9Nb1lpY3k5TCttVE9PNjJpUXp5bkhu?= =?utf-8?B?b3pjQmRHVGViOXQ0TURiL0FjY1NHMVVSZVRzZHhBZWZ6T3hBaEtweWtzaHEr?= =?utf-8?B?bkV4UWlFNGw0dzU3Q2tlc2VObUdkWW5WT0ZpRGRtcXFCSlgrUEF4R2w2V0Jw?= =?utf-8?B?VzYwaW1oL0F4Y2p1bmFGek5jL21pNXVwM3lvOXduTzVoN0dVc254QjhGdnZv?= =?utf-8?B?cnZua2RQV0ZKUktlMlkyVEpjcWgwandZYmpzNTducVkrSFNpNVZWTTdvNm0y?= =?utf-8?B?bDBIQkZHdjIxSTJ6NlNDQUJ0azBrVXZxeHU2TWE2ay9NU1BpSkV4bndJRlhY?= =?utf-8?B?ZUs0V1ExOCtiWmU4dnZnRzdPRFQzM1U2VEFGZFFnZCtyT1BYTjR1aURjcm9W?= =?utf-8?B?Tk1MWkJRbHVFeDFtNmhMM0lYQzJSL1JNazgrVmZuSXVVRCtNVVNOUlJvcWNN?= =?utf-8?B?Z0U2Q0hDbCtUNlcrRkxMYXF1OHNwVjk4cC9nSjVxRTNTQUNjN1AzWFhudENh?= =?utf-8?B?ZjdCQ3F5R3BPMk5ld3VraXBEMmlwRTJWRWZMeUt2WG1TNjlsVStQK1RZOGpx?= =?utf-8?B?UXVBM2FpRkdMRGNkK2cwVlVaY3VselNMaVg5MEVabUxwMHZJQlk0MTdjeFND?= =?utf-8?B?ZjlTc1crOXBHNzZKMkY3bWgvR2U3OFl5SlczaVN5Sms5YUkyR3NacnhTTW9z?= =?utf-8?B?TkxjTTRxMjVxQ3VGa2REOVRUL3V3b2J4b0Y1SE5HQU51VWNjVjg3YlhYZEN0?= =?utf-8?B?S3FydVNTd3lCVzYxdjJ0NWVlQUVGS3U3VVRxd1Q1ckx2TlhJL0hmTWFHL2M1?= =?utf-8?B?bHNua3lyeXNvckZ3aEx5Wmw2M2VFMXRnQ2N6SW1rY3ZMVHJFTDh2Mm4vWkhi?= =?utf-8?B?VGpmNmhnWHZkZ2t3Z2UyVVU4TUlDSktNYWw1dkxNNEhpVjdIVCtXU3BCaVlY?= =?utf-8?B?QWxVWHBGbVFjNkFDcnA1YmdIb1hoYW9UMEZoTm83bTJSYnNkbC93aFY0dEEz?= =?utf-8?B?b1dJaWkvRHhoS1JrbTQzQlorYjVEWEdSOWplcDlsZVBQVzJhZHN2TDlvaWpj?= =?utf-8?B?K3o0Snc0MksvcGdyWnBHelYyQWJyRUZSam5obzNHV21nbFNOTU9VbWlUeDVy?= =?utf-8?B?STgvOXB1U2NmUEl5M1BQak9FMjJVYmhYcnlvU05YRHFBdWx1d2NtbDE1TGdX?= =?utf-8?B?dlFOQU4xYUEvODYrYTl1ZDE1UmI2NUZENDQzb0hia0k2RUgwcWZubS9rbnRV?= =?utf-8?B?ZDVtVTV6ZmlYYTR4U2ExZExuU0VhZW5GMWZNNVcvT01uMmIvd1JyeXFKNWty?= =?utf-8?B?Y1htQWI1UFBzMWtEVm9RbUtYY2svb2d1bk5CWUZZNUtoWXY5M291MFNYelVz?= =?utf-8?B?VzVlZE1tR0tPT1FQdjBYYXNlZjJYd2NvdUJ3ZCtlZFVqSjczU1JpZWZocGEw?= =?utf-8?B?VDVDWGFWTmFkcnpSaU0zZm9ZZFFmeTNEdEJZS2NLSnlXc25rOWFQei9MM0RM?= =?utf-8?B?WUJLUUVtTEZyb3RPYWt5b1J5Qkh5RFAvTkJ4aUhaVXYzK2Q2dmowNmMrVzdT?= =?utf-8?B?MktIQXk3eVNHTnEycnFpTDAranVORVJ0Q0FUVHpkbXZ5QWx2UTdQTHVMMEtm?= =?utf-8?B?Nm1RSE1hUU5ESmJYM0dkVTdFTjdpUkRLZUhZWWtOSU9PSTRDZFR4NDlSRjg5?= =?utf-8?B?RUNXQThBQmZxMDR6Um5teVRBSnVtRDREQ3U0cGVtSldPeEp2dmJtaDBxLzdN?= =?utf-8?B?SThmS3BSdlpQaXpPU0VmZEtYTlNBNEVQcmJtSGZHR0xRSjFCbDhoK1lScVln?= =?utf-8?B?RElLNzlDZmtwZEZOcGRWVzMyZTJoQzc5OW5JKy9ZWnE3L2xsVWlLeElScmRl?= =?utf-8?B?ejBFaWd0aFRoMzJkMW0wYXc3MW96WlZiTjlXQTM4MGNXNnB0ZkV1TzFtS0Zl?= =?utf-8?B?M1BWcTVVcElud2dMNWlLeVMrbTE2TUo5RDI3M1E2TDY0Q2R2RjhNdk5qVjhL?= =?utf-8?B?UXFBM2kvbjJhVGVQMEFreHJsRGxqT0VmWXZ4NEYzWmNRL05kU2Jya3pxWmZ3?= =?utf-8?B?dGxyc0pjQzdpLzFKWWxvcExVWXhlTWJXWDF2OHZNdVliUDJyMzJheU9NUThD?= =?utf-8?B?L2xFdWRDK1ljTXZWZlluQ0xzK1doZnRNQWRIbmxPL1ZPYW1mQlAzS2k0bnpa?= =?utf-8?B?M3dVTDNjaDZseG05WExodzMxUHNyM1ZTUHlWUEdyNmhJNDdXNHlhczBUN1R6?= =?utf-8?B?bmZLZWNReDVsVW5LdmR6SjBRaXVXMlRSUGx6QVJEaXdGUkhxVjVUQT09?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 396d309a-5d27-444a-2587-08deba350dd7 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB9080.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 May 2026 08:10:16.4716 (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: RrWwgVArsTWEKCGU2RIyrzDr7qwvZrXSEFxuPsdzyU+8KnL5P4kq8hzGwodA8fBfTVEdidGW/kdCbL0oTC5DKw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR04MB12265 From: Guoniu Zhou The CSI pixel formatter is a module found on i.MX95 used to reformat packet info, pixel and non-pixel data from CSI-2 host controller to match Pixel Link(PL) definition. Add data formatting support. Reviewed-by: Frank Li Signed-off-by: Guoniu Zhou --- Changes in v8: - Remove fmt field and look up format from subdev state instead - Unify function and structure naming to use csi_formatter_ prefix - Remove misleading alignment comment from set_fmt function - Optimize get_frame_desc to call once per start_stream - Replace V4L2_FRAME_DESC_ENTRY_MAX with CSI_FORMATTER_VC_NUM in loops - Remove redundant debug message in enable_streams - Use MEDIA_PAD_FL_MUST_CONNECT flag instead of manual link check - Fix typo: Formater -> Formatter in Kconfig help text - Improve grammar in data type index mapping comment Changes in v7: - Update references from imx9 to imx95 for consistency with dt-bindings - Enable PM runtime before async registration Changes in v6: - Remove unused header includes - Unify macro naming: VCx/VCX -> VC and parameter x -> vc - Remove unused format field from csi_formatter struct - Use compact initialization for formats array - Make find_csi_format() return NULL instead of default format - Use unsigned int for array index in find_csi_format() - Add err_ prefix to error handling labels - Add v4l2_subdev_cleanup() and reorder cleanup sequence - Update enable_streams debug output format - Rename VC_MAX to VC_NUM and fix boundary check - Update CSI formatter Kconfig description - Use v4l2_subdev_get_frame_desc_passthrough() helper - Fix error paths in async registration and probe - Add mutex to protect enabled_streams - Switch to devm_pm_runtime_enable() - Remove redundant num_routes check in set_routing - Optimize get_index_by_dt() and add warning for unsupported type - csi_formatter_start/stop_stream: Process all streams in mask --- MAINTAINERS | 8 + drivers/media/platform/nxp/Kconfig | 14 + drivers/media/platform/nxp/Makefile | 1 + drivers/media/platform/nxp/imx95-csi-formatter.c | 757 +++++++++++++++++++= ++++ 4 files changed, 780 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 3124500ff432..5229b75d930a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19269,6 +19269,14 @@ S: Maintained F: Documentation/devicetree/bindings/media/nxp,imx8-jpeg.yaml F: drivers/media/platform/nxp/imx-jpeg =20 +NXP i.MX 95 CSI PIXEL FORMATTER V4L2 DRIVER +M: Guoniu Zhou +L: imx@lists.linux.dev +L: linux-media@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/media/fsl,imx95-csi-formatter.yaml +F: drivers/media/platform/nxp/imx95-csi-formatter.c + NXP i.MX CLOCK DRIVERS M: Abel Vesa R: Peng Fan diff --git a/drivers/media/platform/nxp/Kconfig b/drivers/media/platform/nx= p/Kconfig index 40e3436669e2..1eccf128d149 100644 --- a/drivers/media/platform/nxp/Kconfig +++ b/drivers/media/platform/nxp/Kconfig @@ -28,6 +28,20 @@ config VIDEO_IMX8MQ_MIPI_CSI2 Video4Linux2 driver for the MIPI CSI-2 receiver found on the i.MX8MQ SoC. =20 +config VIDEO_IMX95_CSI_FORMATTER + tristate "NXP i.MX95 CSI Pixel Formatter driver" + depends on ARCH_MXC || COMPILE_TEST + depends on VIDEO_DEV + select MEDIA_CONTROLLER + select V4L2_FWNODE + select VIDEO_V4L2_SUBDEV_API + help + This driver provides support for the CSI Pixel Formatter found on + i.MX95 series SoCs. This module unpacks the pixels received from the + CSI-2 interface and reformats them to meet pixel link requirements. + + Say Y here to enable CSI Pixel Formatter module for i.MX95 SoC. + config VIDEO_IMX_MIPI_CSIS tristate "NXP MIPI CSI-2 CSIS receiver found on i.MX7 and i.MX8 models" depends on ARCH_MXC || COMPILE_TEST diff --git a/drivers/media/platform/nxp/Makefile b/drivers/media/platform/n= xp/Makefile index 4d90eb713652..6410115d870e 100644 --- a/drivers/media/platform/nxp/Makefile +++ b/drivers/media/platform/nxp/Makefile @@ -6,6 +6,7 @@ obj-y +=3D imx8-isi/ =20 obj-$(CONFIG_VIDEO_IMX7_CSI) +=3D imx7-media-csi.o obj-$(CONFIG_VIDEO_IMX8MQ_MIPI_CSI2) +=3D imx8mq-mipi-csi2.o +obj-$(CONFIG_VIDEO_IMX95_CSI_FORMATTER) +=3D imx95-csi-formatter.o obj-$(CONFIG_VIDEO_IMX_MIPI_CSIS) +=3D imx-mipi-csis.o obj-$(CONFIG_VIDEO_IMX_PXP) +=3D imx-pxp.o obj-$(CONFIG_VIDEO_MX2_EMMAPRP) +=3D mx2_emmaprp.o diff --git a/drivers/media/platform/nxp/imx95-csi-formatter.c b/drivers/med= ia/platform/nxp/imx95-csi-formatter.c new file mode 100644 index 000000000000..671979444d48 --- /dev/null +++ b/drivers/media/platform/nxp/imx95-csi-formatter.c @@ -0,0 +1,757 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2025 NXP + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +/* CSI Pixel Formatter registers map */ + +#define CSI_VC_INTERLACED_LINE_CNT(vc) (0x00 + (vc) * 0x04) +#define INTERLACED_ODD_LINE_CNT_SET(x) FIELD_PREP(GENMASK(13, 0), (x)) +#define INTERLACED_EVEN_LINE_CNT_SET(x) FIELD_PREP(GENMASK(29, 16), (x)) + +#define CSI_VC_INTERLACED_CTRL 0x20 + +#define CSI_VC_INTERLACED_ERR 0x24 +#define CSI_VC_ERR_MASK GENMASK(7, 0) +#define CSI_VC_ERR(vc) BIT((vc)) + +#define CSI_VC_YUV420_FIRST_LINE_EVEN 0x28 +#define YUV420_FIRST_LINE_EVEN(vc) BIT((vc)) + +#define CSI_RAW32_CTRL 0x30 +#define CSI_VC_RAW32_MODE(vc) BIT((vc)) +#define CSI_VC_RAW32_SWAP_MODE(vc) BIT((vc) + 8) + +#define CSI_STREAM_FENCING_CTRL 0x34 +#define CSI_VC_STREAM_FENCING(vc) BIT((vc)) +#define CSI_VC_STREAM_FENCING_RST(vc) BIT((vc) + 8) + +#define CSI_STREAM_FENCING_STS 0x38 +#define CSI_STREAM_FENCING_STS_MASK GENMASK(7, 0) + +#define CSI_VC_NON_PIXEL_DATA_TYPE(vc) (0x40 + (vc) * 0x04) + +#define CSI_VC_PIXEL_DATA_CTRL(vc) (0x60 + (vc) * 0x04) +#define NEW_VC(vc) FIELD_PREP(GENMASK(3, 1), vc) +#define REROUTE_VC_ENABLE BIT(0) + +#define CSI_VC_ROUTE_PIXEL_DATA_TYPE(vc) (0x80 + (vc) * 0x04) + +#define CSI_VC_NON_PIXEL_DATA_CTRL(vc) (0xa0 + (vc) * 0x04) + +#define CSI_VC_PIXEL_DATA_TYPE(vc) (0xc0 + (vc) * 0x04) + +#define CSI_VC_PIXEL_DATA_TYPE_ERR(vc) (0xe0 + (vc) * 0x04) + +#define CSI_FORMATTER_PAD_SINK 0 +#define CSI_FORMATTER_PAD_SOURCE 1 +#define CSI_FORMATTER_PAD_NUM 2 + +#define CSI_FORMATTER_VC_NUM 8 /* Number of virtual channels */ + +struct csi_formatter_pix_format { + u32 code; + u32 data_type; +}; + +struct csi_formatter { + struct device *dev; + struct regmap *regs; + struct clk *clk; + + struct v4l2_subdev sd; + struct v4l2_subdev *csi_sd; + struct v4l2_async_notifier notifier; + struct media_pad pads[CSI_FORMATTER_PAD_NUM]; + + u32 remote_pad; + u32 reg_offset; + + /* Protects enabled_streams */ + struct mutex lock; + u64 enabled_streams; +}; + +struct csi_formatter_dt_index { + u8 dtype; + u8 index; +}; + +/* + * The index corresponds to the bit index in the register that enables + * the data type of pixel data transported by the Formatter. + */ +static const struct csi_formatter_dt_index formatter_dt_to_index_map[] =3D= { + { .dtype =3D MIPI_CSI2_DT_YUV420_8B, .index =3D 0 }, + { .dtype =3D MIPI_CSI2_DT_YUV420_8B_LEGACY, .index =3D 2 }, + { .dtype =3D MIPI_CSI2_DT_YUV422_8B, .index =3D 6 }, + { .dtype =3D MIPI_CSI2_DT_RGB444, .index =3D 8 }, + { .dtype =3D MIPI_CSI2_DT_RGB555, .index =3D 9 }, + { .dtype =3D MIPI_CSI2_DT_RGB565, .index =3D 10 }, + { .dtype =3D MIPI_CSI2_DT_RGB666, .index =3D 11 }, + { .dtype =3D MIPI_CSI2_DT_RGB888, .index =3D 12 }, + { .dtype =3D MIPI_CSI2_DT_RAW6, .index =3D 16 }, + { .dtype =3D MIPI_CSI2_DT_RAW7, .index =3D 17 }, + { .dtype =3D MIPI_CSI2_DT_RAW8, .index =3D 18 }, + { .dtype =3D MIPI_CSI2_DT_RAW10, .index =3D 19 }, + { .dtype =3D MIPI_CSI2_DT_RAW12, .index =3D 20 }, + { .dtype =3D MIPI_CSI2_DT_RAW14, .index =3D 21 }, + { .dtype =3D MIPI_CSI2_DT_RAW16, .index =3D 22 }, +}; + +static const struct csi_formatter_pix_format formats[] =3D { + /* YUV formats */ + { MEDIA_BUS_FMT_UYVY8_1X16, MIPI_CSI2_DT_YUV422_8B }, + /* RGB formats */ + { MEDIA_BUS_FMT_RGB565_1X16, MIPI_CSI2_DT_RGB565 }, + { MEDIA_BUS_FMT_RGB888_1X24, MIPI_CSI2_DT_RGB888 }, + /* RAW (Bayer and greyscale) formats */ + { MEDIA_BUS_FMT_SBGGR8_1X8, MIPI_CSI2_DT_RAW8 }, + { MEDIA_BUS_FMT_SGBRG8_1X8, MIPI_CSI2_DT_RAW8 }, + { MEDIA_BUS_FMT_SGRBG8_1X8, MIPI_CSI2_DT_RAW8 }, + { MEDIA_BUS_FMT_SRGGB8_1X8, MIPI_CSI2_DT_RAW8 }, + { MEDIA_BUS_FMT_Y8_1X8, MIPI_CSI2_DT_RAW8 }, + { MEDIA_BUS_FMT_SBGGR10_1X10, MIPI_CSI2_DT_RAW10 }, + { MEDIA_BUS_FMT_SGBRG10_1X10, MIPI_CSI2_DT_RAW10 }, + { MEDIA_BUS_FMT_SGRBG10_1X10, MIPI_CSI2_DT_RAW10 }, + { MEDIA_BUS_FMT_SRGGB10_1X10, MIPI_CSI2_DT_RAW10 }, + { MEDIA_BUS_FMT_Y10_1X10, MIPI_CSI2_DT_RAW10 }, + { MEDIA_BUS_FMT_SBGGR12_1X12, MIPI_CSI2_DT_RAW12 }, + { MEDIA_BUS_FMT_SGBRG12_1X12, MIPI_CSI2_DT_RAW12 }, + { MEDIA_BUS_FMT_SGRBG12_1X12, MIPI_CSI2_DT_RAW12 }, + { MEDIA_BUS_FMT_SRGGB12_1X12, MIPI_CSI2_DT_RAW12 }, + { MEDIA_BUS_FMT_Y12_1X12, MIPI_CSI2_DT_RAW12 }, + { MEDIA_BUS_FMT_SBGGR14_1X14, MIPI_CSI2_DT_RAW14 }, + { MEDIA_BUS_FMT_SGBRG14_1X14, MIPI_CSI2_DT_RAW14 }, + { MEDIA_BUS_FMT_SGRBG14_1X14, MIPI_CSI2_DT_RAW14 }, + { MEDIA_BUS_FMT_SRGGB14_1X14, MIPI_CSI2_DT_RAW14 }, + { MEDIA_BUS_FMT_SBGGR16_1X16, MIPI_CSI2_DT_RAW16 }, + { MEDIA_BUS_FMT_SGBRG16_1X16, MIPI_CSI2_DT_RAW16 }, + { MEDIA_BUS_FMT_SGRBG16_1X16, MIPI_CSI2_DT_RAW16 }, + { MEDIA_BUS_FMT_SRGGB16_1X16, MIPI_CSI2_DT_RAW16 }, +}; + +static const struct v4l2_mbus_framefmt formatter_default_fmt =3D { + .code =3D MEDIA_BUS_FMT_UYVY8_1X16, + .width =3D 1920U, + .height =3D 1080U, + .field =3D V4L2_FIELD_NONE, + .colorspace =3D V4L2_COLORSPACE_SMPTE170M, + .xfer_func =3D V4L2_MAP_XFER_FUNC_DEFAULT(V4L2_COLORSPACE_SMPTE170M), + .ycbcr_enc =3D V4L2_MAP_YCBCR_ENC_DEFAULT(V4L2_COLORSPACE_SMPTE170M), + .quantization =3D V4L2_QUANTIZATION_LIM_RANGE, +}; + +static const struct csi_formatter_pix_format *csi_formatter_find_format(u3= 2 code) +{ + unsigned int i; + + for (i =3D 0; i < ARRAY_SIZE(formats); i++) + if (code =3D=3D formats[i].code) + return &formats[i]; + + return NULL; +} + +/* -----------------------------------------------------------------------= ------ + * V4L2 subdev operations + */ + +static inline struct csi_formatter *sd_to_formatter(struct v4l2_subdev *sd= ev) +{ + return container_of(sdev, struct csi_formatter, sd); +} + +static int __csi_formatter_subdev_set_routing(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, + struct v4l2_subdev_krouting *routing) +{ + int ret; + + ret =3D v4l2_subdev_routing_validate(sd, routing, + V4L2_SUBDEV_ROUTING_ONLY_1_TO_1); + if (ret) + return ret; + + return v4l2_subdev_set_routing_with_fmt(sd, state, routing, + &formatter_default_fmt); +} + +static int csi_formatter_subdev_init_state(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state) +{ + struct v4l2_subdev_route routes[] =3D { + { + .sink_pad =3D CSI_FORMATTER_PAD_SINK, + .sink_stream =3D 0, + .source_pad =3D CSI_FORMATTER_PAD_SOURCE, + .source_stream =3D 0, + .flags =3D V4L2_SUBDEV_ROUTE_FL_ACTIVE, + }, + }; + + struct v4l2_subdev_krouting routing =3D { + .num_routes =3D ARRAY_SIZE(routes), + .routes =3D routes, + }; + + return __csi_formatter_subdev_set_routing(sd, sd_state, &routing); +} + +static int csi_formatter_subdev_enum_mbus_code(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_mbus_code_enum *code) +{ + if (code->pad =3D=3D CSI_FORMATTER_PAD_SOURCE) { + struct v4l2_mbus_framefmt *fmt; + + if (code->index > 0) + return -EINVAL; + + fmt =3D v4l2_subdev_state_get_format(sd_state, code->pad, + code->stream); + code->code =3D fmt->code; + return 0; + } + + if (code->index >=3D ARRAY_SIZE(formats)) + return -EINVAL; + + code->code =3D formats[code->index].code; + + return 0; +} + +static int csi_formatter_subdev_set_fmt(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_format *sdformat) +{ + struct csi_formatter_pix_format const *format; + struct v4l2_mbus_framefmt *fmt; + + if (sdformat->pad =3D=3D CSI_FORMATTER_PAD_SOURCE) + return v4l2_subdev_get_fmt(sd, sd_state, sdformat); + + format =3D csi_formatter_find_format(sdformat->format.code); + if (!format) + format =3D &formats[0]; + + v4l_bound_align_image(&sdformat->format.width, 1, 0xffff, 2, + &sdformat->format.height, 1, 0xffff, 0, 0); + + fmt =3D v4l2_subdev_state_get_format(sd_state, sdformat->pad, + sdformat->stream); + *fmt =3D sdformat->format; + + /* Set default code if user set an invalid value */ + fmt->code =3D format->code; + + /* Propagate the format from sink stream to source stream */ + fmt =3D v4l2_subdev_state_get_opposite_stream_format(sd_state, sdformat->= pad, + sdformat->stream); + if (!fmt) + return -EINVAL; + + *fmt =3D sdformat->format; + + return 0; +} + +static int csi_formatter_subdev_set_routing(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, + enum v4l2_subdev_format_whence which, + struct v4l2_subdev_krouting *routing) +{ + if (which =3D=3D V4L2_SUBDEV_FORMAT_ACTIVE && + media_entity_is_streaming(&sd->entity)) + return -EBUSY; + + return __csi_formatter_subdev_set_routing(sd, state, routing); +} + +static inline void csi_formatter_write(struct csi_formatter *formatter, + unsigned int reg, unsigned int value) +{ + u32 offset =3D formatter->reg_offset; + + regmap_write(formatter->regs, reg + offset, value); +} + +static u8 csi_formatter_get_index_by_dt(u8 data_type) +{ + unsigned int i; + + for (i =3D 0; i < ARRAY_SIZE(formatter_dt_to_index_map); ++i) { + const struct csi_formatter_dt_index *entry =3D + &formatter_dt_to_index_map[i]; + + if (data_type =3D=3D entry->dtype) + return entry->index; + } + + pr_warn_once("Unsupported data type 0x%x, using default\n", data_type); + + return formatter_dt_to_index_map[0].index; +} + +static int csi_formatter_get_vc(struct csi_formatter *formatter, + struct v4l2_mbus_frame_desc *fd, + unsigned int stream) +{ + struct v4l2_mbus_frame_desc_entry *entry =3D NULL; + unsigned int i; + int vc; + + for (i =3D 0; i < fd->num_entries; ++i) { + if (fd->entry[i].stream =3D=3D stream) { + entry =3D &fd->entry[i]; + break; + } + } + + if (!entry) { + dev_err(formatter->dev, + "No frame desc entry for stream %u\n", stream); + return -EPIPE; + } + + vc =3D entry->bus.csi2.vc; + + if (vc < 0 || vc >=3D CSI_FORMATTER_VC_NUM) { + dev_err(formatter->dev, "Invalid virtual channel %d\n", vc); + return -EINVAL; + } + + return vc; +} + +static void csi_formatter_stop_stream(struct csi_formatter *formatter, + u64 stream_mask) +{ + unsigned int i; + + for (i =3D 0; i < CSI_FORMATTER_VC_NUM; ++i) { + if (!(stream_mask & BIT(i))) + continue; + + csi_formatter_write(formatter, CSI_VC_PIXEL_DATA_TYPE(i), 0); + } +} + +static int csi_formatter_start_stream(struct csi_formatter *formatter, + struct v4l2_subdev_state *state, + u64 stream_mask) +{ + const struct csi_formatter_pix_format *pix_fmt; + struct v4l2_mbus_framefmt *fmt; + struct v4l2_mbus_frame_desc fd =3D {}; + u64 configured_streams =3D 0; + unsigned int i; + u32 val; + int vc; + int ret; + + ret =3D v4l2_subdev_call(formatter->csi_sd, pad, get_frame_desc, + formatter->remote_pad, &fd); + if (ret < 0 && ret !=3D -ENOIOCTLCMD) { + dev_err(formatter->dev, "Failed to get frame desc: %d\n", ret); + return ret; + } + + for (i =3D 0; i < CSI_FORMATTER_VC_NUM; ++i) { + if (!(stream_mask & BIT(i))) + continue; + + fmt =3D v4l2_subdev_state_get_format(state, + CSI_FORMATTER_PAD_SINK, i); + + pix_fmt =3D csi_formatter_find_format(fmt->code); + + val =3D BIT(csi_formatter_get_index_by_dt(pix_fmt->data_type)); + + if (ret =3D=3D -ENOIOCTLCMD) { + /* + * Source doesn't implement get_frame_desc, use + * default VC 0 + */ + vc =3D 0; + } else { + vc =3D csi_formatter_get_vc(formatter, &fd, i); + if (vc < 0) { + ret =3D vc; + goto err_cleanup; + } + } + + csi_formatter_write(formatter, CSI_VC_PIXEL_DATA_TYPE(vc), val); + configured_streams |=3D BIT(i); + } + + return 0; + +err_cleanup: + csi_formatter_stop_stream(formatter, configured_streams); + return ret; +} + +static int csi_formatter_subdev_enable_streams(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, + u32 pad, u64 streams_mask) +{ + struct csi_formatter *formatter =3D sd_to_formatter(sd); + struct device *dev =3D formatter->dev; + u64 sink_streams; + int ret; + + sink_streams =3D v4l2_subdev_state_xlate_streams(state, + CSI_FORMATTER_PAD_SOURCE, + CSI_FORMATTER_PAD_SINK, + &streams_mask); + if (!sink_streams || !streams_mask) + return -EINVAL; + + guard(mutex)(&formatter->lock); + + if (!formatter->enabled_streams) { + ret =3D pm_runtime_resume_and_get(formatter->dev); + if (ret < 0) { + dev_err(dev, "Failed to resume runtime PM: %d\n", ret); + return ret; + } + } + + ret =3D csi_formatter_start_stream(formatter, state, streams_mask); + if (ret) + goto err_runtime_put; + + ret =3D v4l2_subdev_enable_streams(formatter->csi_sd, + formatter->remote_pad, + sink_streams); + if (ret) + goto err_stop_stream; + + formatter->enabled_streams |=3D streams_mask; + + return 0; + +err_stop_stream: + csi_formatter_stop_stream(formatter, streams_mask); +err_runtime_put: + if (!formatter->enabled_streams) + pm_runtime_put(formatter->dev); + return ret; +} + +static int csi_formatter_subdev_disable_streams(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, + u32 pad, u64 streams_mask) +{ + struct csi_formatter *formatter =3D sd_to_formatter(sd); + u64 sink_streams; + int ret; + + sink_streams =3D v4l2_subdev_state_xlate_streams(state, + CSI_FORMATTER_PAD_SOURCE, + CSI_FORMATTER_PAD_SINK, + &streams_mask); + if (!sink_streams || !streams_mask) + return -EINVAL; + + guard(mutex)(&formatter->lock); + + ret =3D v4l2_subdev_disable_streams(formatter->csi_sd, formatter->remote_= pad, + sink_streams); + if (ret) + dev_err(formatter->dev, "Failed to disable streams: %d\n", ret); + + csi_formatter_stop_stream(formatter, streams_mask); + + formatter->enabled_streams &=3D ~streams_mask; + + if (!formatter->enabled_streams) + pm_runtime_put(formatter->dev); + + return ret; +} + +static const struct v4l2_subdev_pad_ops formatter_subdev_pad_ops =3D { + .enum_mbus_code =3D csi_formatter_subdev_enum_mbus_code, + .get_fmt =3D v4l2_subdev_get_fmt, + .set_fmt =3D csi_formatter_subdev_set_fmt, + .get_frame_desc =3D v4l2_subdev_get_frame_desc_passthrough, + .set_routing =3D csi_formatter_subdev_set_routing, + .enable_streams =3D csi_formatter_subdev_enable_streams, + .disable_streams =3D csi_formatter_subdev_disable_streams, +}; + +static const struct v4l2_subdev_ops formatter_subdev_ops =3D { + .pad =3D &formatter_subdev_pad_ops, +}; + +static const struct v4l2_subdev_internal_ops formatter_internal_ops =3D { + .init_state =3D csi_formatter_subdev_init_state, +}; + +/* -----------------------------------------------------------------------= ------ + * Media entity operations + */ + +static const struct media_entity_operations formatter_entity_ops =3D { + .link_validate =3D v4l2_subdev_link_validate, + .get_fwnode_pad =3D v4l2_subdev_get_fwnode_pad_1_to_1, +}; + +static int csi_formatter_subdev_init(struct csi_formatter *formatter) +{ + struct v4l2_subdev *sd =3D &formatter->sd; + int ret; + + v4l2_subdev_init(sd, &formatter_subdev_ops); + + snprintf(sd->name, sizeof(sd->name), "%s", dev_name(formatter->dev)); + sd->internal_ops =3D &formatter_internal_ops; + + sd->flags |=3D V4L2_SUBDEV_FL_HAS_DEVNODE | + V4L2_SUBDEV_FL_HAS_EVENTS | + V4L2_SUBDEV_FL_STREAMS; + sd->entity.function =3D MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER; + sd->entity.ops =3D &formatter_entity_ops; + sd->dev =3D formatter->dev; + + formatter->pads[CSI_FORMATTER_PAD_SINK].flags =3D MEDIA_PAD_FL_SINK + | MEDIA_PAD_FL_MUST_CONNECT; + formatter->pads[CSI_FORMATTER_PAD_SOURCE].flags =3D MEDIA_PAD_FL_SOURCE; + + ret =3D media_entity_pads_init(&sd->entity, CSI_FORMATTER_PAD_NUM, + formatter->pads); + if (ret) { + dev_err(formatter->dev, "Failed to init pads\n"); + return ret; + } + + ret =3D v4l2_subdev_init_finalize(sd); + if (ret) + media_entity_cleanup(&sd->entity); + + return ret; +} + +static inline struct csi_formatter * +notifier_to_csi_formatter(struct v4l2_async_notifier *n) +{ + return container_of(n, struct csi_formatter, notifier); +} + +static int csi_formatter_notify_bound(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *sd, + struct v4l2_async_connection *asc) +{ + const unsigned int link_flags =3D MEDIA_LNK_FL_IMMUTABLE + | MEDIA_LNK_FL_ENABLED; + struct csi_formatter *formatter =3D notifier_to_csi_formatter(notifier); + struct v4l2_subdev *sdev =3D &formatter->sd; + struct media_pad *sink =3D &sdev->entity.pads[CSI_FORMATTER_PAD_SINK]; + struct media_pad *remote_pad; + int ret; + + formatter->csi_sd =3D sd; + + dev_dbg(formatter->dev, "Bound subdev: %s pad\n", sd->name); + + ret =3D v4l2_create_fwnode_links_to_pad(sd, sink, link_flags); + if (ret < 0) + return ret; + + remote_pad =3D media_pad_remote_pad_first(sink); + if (!remote_pad) { + dev_err(formatter->dev, "Pipe not setup correctly\n"); + return -EPIPE; + } + formatter->remote_pad =3D remote_pad->index; + + return 0; +} + +static const struct v4l2_async_notifier_operations formatter_notify_ops = =3D { + .bound =3D csi_formatter_notify_bound, +}; + +static int csi_formatter_async_register(struct csi_formatter *formatter) +{ + struct device *dev =3D formatter->dev; + struct v4l2_async_connection *asc; + int ret; + + struct fwnode_handle *ep __free(fwnode_handle) =3D + fwnode_graph_get_endpoint_by_id(dev_fwnode(dev), 0, 0, + FWNODE_GRAPH_ENDPOINT_NEXT); + if (!ep) + return -ENOTCONN; + + v4l2_async_subdev_nf_init(&formatter->notifier, &formatter->sd); + + asc =3D v4l2_async_nf_add_fwnode_remote(&formatter->notifier, ep, + struct v4l2_async_connection); + if (IS_ERR(asc)) { + ret =3D PTR_ERR(asc); + goto err_cleanup_notifier; + } + + formatter->notifier.ops =3D &formatter_notify_ops; + + ret =3D v4l2_async_nf_register(&formatter->notifier); + if (ret) + goto err_cleanup_notifier; + + ret =3D v4l2_async_register_subdev(&formatter->sd); + if (ret) + goto err_unregister_notifier; + + return 0; + +err_unregister_notifier: + v4l2_async_nf_unregister(&formatter->notifier); +err_cleanup_notifier: + v4l2_async_nf_cleanup(&formatter->notifier); + return ret; +} + +static void csi_formatter_async_unregister(struct csi_formatter *formatter) +{ + v4l2_async_unregister_subdev(&formatter->sd); + v4l2_async_nf_unregister(&formatter->notifier); + v4l2_async_nf_cleanup(&formatter->notifier); +} + +/* -----------------------------------------------------------------------= ------ + * Suspend/resume + */ + +static int csi_formatter_runtime_suspend(struct device *dev) +{ + struct v4l2_subdev *sd =3D dev_get_drvdata(dev); + struct csi_formatter *formatter =3D sd_to_formatter(sd); + + clk_disable_unprepare(formatter->clk); + + return 0; +} + +static int csi_formatter_runtime_resume(struct device *dev) +{ + struct v4l2_subdev *sd =3D dev_get_drvdata(dev); + struct csi_formatter *formatter =3D sd_to_formatter(sd); + + return clk_prepare_enable(formatter->clk); +} + +static DEFINE_RUNTIME_DEV_PM_OPS(csi_formatter_pm_ops, + csi_formatter_runtime_suspend, + csi_formatter_runtime_resume, NULL); + +static int csi_formatter_probe(struct platform_device *pdev) +{ + struct device *dev =3D &pdev->dev; + struct csi_formatter *formatter; + u32 val; + int ret; + + formatter =3D devm_kzalloc(dev, sizeof(*formatter), GFP_KERNEL); + if (!formatter) + return -ENOMEM; + + formatter->dev =3D dev; + + ret =3D devm_mutex_init(dev, &formatter->lock); + if (ret) + return ret; + + formatter->regs =3D syscon_node_to_regmap(dev->parent->of_node); + if (IS_ERR(formatter->regs)) + return dev_err_probe(dev, PTR_ERR(formatter->regs), + "Failed to get csi formatter regmap\n"); + + ret =3D of_property_read_u32(dev->of_node, "reg", &val); + if (ret < 0) + return dev_err_probe(dev, ret, "Failed to get csi formatter reg property= \n"); + + formatter->reg_offset =3D val; + + formatter->clk =3D devm_clk_get(dev, NULL); + if (IS_ERR(formatter->clk)) + return dev_err_probe(dev, PTR_ERR(formatter->clk), + "Failed to get pixel clock\n"); + + ret =3D csi_formatter_subdev_init(formatter); + if (ret < 0) + return dev_err_probe(dev, ret, "Failed to initialize formatter subdev\n"= ); + + platform_set_drvdata(pdev, &formatter->sd); + + /* Enable runtime PM. */ + ret =3D devm_pm_runtime_enable(dev); + if (ret) + goto err_cleanup_subdev; + + ret =3D csi_formatter_async_register(formatter); + if (ret < 0) { + dev_err_probe(dev, ret, "Failed to register async subdevice\n"); + goto err_cleanup_subdev; + } + + return 0; + +err_cleanup_subdev: + v4l2_subdev_cleanup(&formatter->sd); + media_entity_cleanup(&formatter->sd.entity); + return ret; +} + +static void csi_formatter_remove(struct platform_device *pdev) +{ + struct v4l2_subdev *sd =3D platform_get_drvdata(pdev); + struct csi_formatter *formatter =3D sd_to_formatter(sd); + + csi_formatter_async_unregister(formatter); + + v4l2_subdev_cleanup(&formatter->sd); + media_entity_cleanup(&formatter->sd.entity); +} + +static const struct of_device_id csi_formatter_of_match[] =3D { + { .compatible =3D "fsl,imx95-csi-formatter" }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, csi_formatter_of_match); + +static struct platform_driver csi_formatter_device_driver =3D { + .driver =3D { + .name =3D "csi-pixel-formatter", + .of_match_table =3D csi_formatter_of_match, + .pm =3D pm_ptr(&csi_formatter_pm_ops), + }, + .probe =3D csi_formatter_probe, + .remove =3D csi_formatter_remove, +}; + +module_platform_driver(csi_formatter_device_driver); + +MODULE_AUTHOR("NXP Semiconductor, Inc."); +MODULE_DESCRIPTION("NXP i.MX95 CSI Pixel Formatter driver"); +MODULE_LICENSE("GPL"); --=20 2.34.1