From nobody Mon May 25 05:55:53 2026 Received: from AM0PR02CU008.outbound.protection.outlook.com (mail-westeuropeazon11013065.outbound.protection.outlook.com [52.101.72.65]) (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 3D37921FF30; Mon, 18 May 2026 02:17:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.72.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779070640; cv=fail; b=L/JMkn/JDl+PtfO1H7xa8d8EpIfj6YDEHeFuAm2gSK99ZxEgRQmJvj68ZmB9h6IrJnOLe/kokUg2csNuyMnZIGzGmSAxRY1Sg8EzIc/Q5IwW+uyN/RTtg+/f+WYxHqx3YWql3PprZJOn+j0mylQn3c1r4/SAodzBW3eGasiC0tY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779070640; c=relaxed/simple; bh=d0fmodqxKgNr6ABavYyMbhg/wVSURJOK5CDPMZXk+nM=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=ohntCtrVltY3dT3UHx9KgkMTi/QMjyRHTLC0hw+Jc3Zpe1qfkJDTlWZiEpn8zb5zP1T1v2CaxzQW5sqE4ya+Ei3yqpM5BNh9h88eJn+QTHiQyPxi7yO0KAtTE1UI4HgV+cxYNdmqneGsfyrGeYKkOUWV1bxUTmBQtvb5qj71QX0= 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=sENFjXYP; arc=fail smtp.client-ip=52.101.72.65 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="sENFjXYP" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hYs848njsBHtTQBg9w0BrTVjVqEZj+QO0T+9A6r4JSmaU3qQrpDtFIgodyeiNNITXT+1LpPrsEGC9f51Dvi65RzewhF+HY4OVv8Vami4pcna0k90f3ZohUtsuGJhVZ8X1sKLdhon4ksoWnJeoeneTv/jYQh85qj005Q76LU/HVmQGuy7/N29N26oa81/fZA4oS54X6h8tseJFHlfLKzU7sVKNNzej5fowyRTkFMQdnKM2vcJN+f/EFAo0SV7sdp0RZOj64RWVjyHt2ekXF0593RSGRln1YMVDX3sbGEM4IzdSwJkfz4LlYx/F3lsf4KAPBLuiEjodAabONbjCUPa/Q== 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=BHWE3KnYFoCNTNAqiYS1qJxQoY0QUdfoW+pGsmZ0eNA=; b=WGuUAJtCYBbVcEAy1nYaFW8f9d0CcXDR2Sl2G8gyvTsjev7GL5Kh9Ql+wB49Pzw1lMajCxywp4AbdqqipbxeeYxJTF0i3E0vmjiJD3/BYciDzHZ3e3+7udJRw5y+HHLvPbaWvQ1+o7cmAFzxHr6m5D27rn+B7+a0sPRvyeS5IaHFAFa748u+tkulOvafB5avnoqbxaAecEi7IReb99NiZn+oyK0BYOQsUNU45xdeEP6ScU1pYPcHCh9eTtGrcBEVc+aaZ4gpdzkUuE9NbFRQ8IQOVjIjgXB+02eoL8tbFVANCqNWsCaQ0yRkP7p9LQaSzcxACJURSwxB7Q3DXD1TJQ== 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=BHWE3KnYFoCNTNAqiYS1qJxQoY0QUdfoW+pGsmZ0eNA=; b=sENFjXYPMhAyRyMRp4wYi55NSfCfcbpJTcTrq7v3gG+b85qrh1ahciNiNrl45Pz/lvezOd3GoNRv8fSLjSN9uOzpSrzK4uZIRf057Akc3ZSLJwaVwur0ErANjTNsWpjXh8241LyLhgbuHfEThJhMYpn/0HYbOrxBSPLuebQt2KJCdikeN0BH/jTNTd0qcq9OeETBYIO7YWb282wG2ynrO9QBkrDQTxPZkq5K7zlEr/EHxjUdKncIr5prbAbsUYWvC6zgBiFiRYUIduvx5zRkwZZEfZw/8gmXYJTRB2zyLMSBKphHPhNI2w+bDi8TAW/7NfzX79C1GupcASUAsy/IQQ== 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 DB8PR04MB7179.eurprd04.prod.outlook.com (2603:10a6:10:124::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.25.23; Mon, 18 May 2026 02:17:15 +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.0025.022; Mon, 18 May 2026 02:17:14 +0000 From: Guoniu Zhou Date: Mon, 18 May 2026 10:19:46 +0800 Subject: [PATCH v7 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: <20260518-csi_formatter-v7-1-562b750557e3@oss.nxp.com> References: <20260518-csi_formatter-v7-0-562b750557e3@oss.nxp.com> In-Reply-To: <20260518-csi_formatter-v7-0-562b750557e3@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=1779070804; l=3108; i=guoniu.zhou@oss.nxp.com; s=20250815; h=from:subject:message-id; bh=wf760uCgsG+wUpFBLE5Il4kLNLGkLKR9Szl79UUNhec=; b=bdQQBt1CnufUV5vQRyQ5+E+LpIrAEf/mOZm7MSRzneJUlXnEfnnjgZdkUQlO8t6cscrZIkWeK W4/27/I8cTuCK429u55LKsKesy6yMwo8heMyYBFUIFsAe83KjejIyWv X-Developer-Key: i=guoniu.zhou@oss.nxp.com; a=ed25519; pk=MM+/XICg5S78/gs+f9wtGP6yIvkyjTdZwfaxXeu5rlo= X-ClientProxiedBy: MAXP287CA0014.INDP287.PROD.OUTLOOK.COM (2603:1096:a00:49::25) 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_|DB8PR04MB7179:EE_ X-MS-Office365-Filtering-Correlation-Id: cbc34e74-a00d-404f-7b17-08deb48393e2 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|7416014|376014|52116014|19092799006|1800799024|366016|3023799003|11063799003|38350700014|921020|56012099003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: 4tHc4x8OuJpW4YjIMOF1pOq8lzyJR/mVatC91HW9g2Mj6A/2Nkn/7/26w9hRwnvOTxII2lgWKRw+mlBfShg+NMHHfwhqYuDhxKD9zRb0DSZOFI83rDX4fmWKTKdt4Q0POJuU9Okzmn6uBBnNwBq9mCq0lPlpJb2/kzEC0R2WVR72PjmGyZLB8SBnqv0Y3uhE70b0UcAx1a0Jvbij/L/CQJzhDd1b1KKwjPXWBCqOXV3wyg05bt3c7tQHmp1gh/Z54qWCNK2Q0MLEmn3inNIYsMMSvf2PopKip3+fSvsiwBT3T40I6TDb8KW86YdhKNqwZDqcMm6XwDOxbnQrfymZivuEHT8ZytbXKUbK4rgqe563pJ95EBuOso5oS8tCIohIGnAEsUnPx2QqSVW56b0iaoL/ftHdwyV0Hx5brC1UZtGyLq+HohSBI0lYVGEkM36R8b7dcOzzOpyMwwRSI1+uGRBOiL8SSDY/tDgCaDhLdy49zGxHn/jmeSW3zf1WGM6WTg/7tTkKAheGqga3AUoWVEjcd7lkThY9/O/NXtG/nMzej6aucuZcPCa8nKyYWs+lrzlfg2hUzGuAx3QJnDsVO9M7kdqMt83LWvMhT8/j6oiNA2KMtporF1VKci1WWRcJthkt32kTvkLevX/ue8l9+gZkFPZic+vkpYOoX4+8OYuoB+6XBSDZB6Hph54oUjalx/NM0jmfO/lnurqCHQqJrQ== 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)(7416014)(376014)(52116014)(19092799006)(1800799024)(366016)(3023799003)(11063799003)(38350700014)(921020)(56012099003)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?aXU4dTNXVjdhY0ZuaHpCYmNGQlBNd2NTbjdGWU5qbmhtTVZwUjE2WWQvUFFN?= =?utf-8?B?UENRUVF4TkVTMmhQK3U0bVZ6d1plZ0ErYzFoRXJZamUxSEpVSlhKa0h3dVJv?= =?utf-8?B?NXNaQVZzYm93eCs3U3ZSV1JFTkdNcWhyakEzOU5kMTRwS1gvRTlmbzdUTFN6?= =?utf-8?B?VU5YRlAxaWN5WGRSRldJc3IrYWd1TENkOFd3a3paanFjL1o3c3lpZGw5N2c2?= =?utf-8?B?R1RHZEtsNEgwWWl1amI2Mk5ja2RuZkdmdkNoMzNaUWN2Rnk5eFY2cWdjeWRq?= =?utf-8?B?N1A4aWxjUUNQUWhwTzdJbUs1bXdmajlzdm9RWVZEM0hIWEZUMlp5Vm5Qb1F4?= =?utf-8?B?NDNqT0RlZStjeDQ2Sjl3SXJkbGxrSHk1S2FBaFFJaGVLbE5VN0pwM2hCTzFJ?= =?utf-8?B?Mk9GWFRSbGpVeUxCRFVkd1FKYlF1QTJzNWZhN2NacUNnWXN5N1JCVzVLdGgz?= =?utf-8?B?b3UybDBEZDdlV0JjeCsvQ3RHMEpxUjhsOXE3VDErN3pDTjA5L0ZqWVljcjVJ?= =?utf-8?B?MGZOc2E1Ym5QQVhYT1B6OTk0QWNpdjQweDNvV0t3SmhMa0FybUxhVE9aY0N6?= =?utf-8?B?WHVuclg1bzBEeHl3WEdPUXVqcEM0N3dxcUNsWk4ycXkzM3VJMjdRWkJOUjNW?= =?utf-8?B?K0VtaUdVMU84S2czellxamdvc25yeGVjbnd2RCtRVVlaTkcwMzh4eWRjVExZ?= =?utf-8?B?a1B0dk9DQzVkRHhMK1U1L3NYRUdPWjBJNEI3anZlNmN3TkpPOFU4dThrbkRl?= =?utf-8?B?QURDQXJ5L0xaNzZuOTVEMUJCaXdSSEgvTVcySEFEdVhtMVVrd0t4MnJNcGQr?= =?utf-8?B?YUdvK2dLbHVOSjU0MkNZeCtUOGZGR2UzeU1IYXBNNTBrUUk0TGFhTjdBelJ2?= =?utf-8?B?OGlocWY5ajV6WkllWWx1cDUwNU5oRTdxaUh2MUd4Znd1R3p6eGExVjArMUF3?= =?utf-8?B?cTdNTVIzdVdmUVNIaWk2OTNsUmx0cjR1U21LQmQyamhpaG1STy8rT2I1eHpJ?= =?utf-8?B?aFRKMFZCZmZUazE0anVyakh3S01SYUs1SXU5MjdPbUNmRTdyKzhnY01iSHN3?= =?utf-8?B?U09tU0ljN3JlM3A2bHUyT3JXYjh4cHFPekhFYW9GRWYzYjZvcTA3OFlKcG82?= =?utf-8?B?WjNlZ0Z3NWRxVElKd2Q3SXpCWXJYcW5CYkFZOWZVUnF3VGpENGRaeEJMUXVz?= =?utf-8?B?RmFCSWV5NXllbDJUaitBd1laR28rSnh5Zjl5UllDdHJONnJaWlh2UnZZNUlQ?= =?utf-8?B?cmhISGNzS1lzQUc0OVdkSWppVzE0bDI0WU5ITmxoM1AvR2ozRDNRemVPRjcr?= =?utf-8?B?VVVlRE03NUlZb3UvWUJYOXcxMXR5UWd4dFkxMFZYOWRmUzYxRDUzN3RqdTdT?= =?utf-8?B?WWhwNU84YU1xUGwxR0txem9uQkF6YTdIYXY5cWYwcERIcDBSWklVWnZkWWhY?= =?utf-8?B?YUphUElqY0lzYVZDK1dVV1o0Tk5aTFRjZmZ3MzZWbkNmTmVjdHV5T2ZSWnAr?= =?utf-8?B?aTNNcHhPWmVWL3o1eWNrU0ErOURWYkE1d1BNc2xIODR4NDkxdmxNcGhxQVB6?= =?utf-8?B?ZUNycCt2NTlxclJRNUpjczZJemZHRUppRGI4QnEwekxzaC8xVSs2eWRvMEwz?= =?utf-8?B?K0VKL1A4ZnkxUXhiRXIrN28wcHErVDViNkt5SHUyR1M4T1d4ZExJMFFuSUpz?= =?utf-8?B?c1pLTTl4dXV5WjVqYlJrTDA3Y0dTZDN0S0tIWDMvd2kya2REVGFoUUM5cE9O?= =?utf-8?B?aEpNYkNyeVlPRENWcWNMMVlWallnK0xkMFJieVBsNkFwSk45N2RNbWxtWmY2?= =?utf-8?B?c1pKcUZ5Z0srcXlJTDFhT3RiZXlOWTNmUi9oN0UzZjVudWhwZlF5SGdUMlFT?= =?utf-8?B?U0REUTAvR0lTdldDVDJKRE12eWdPUWF1RjFsZWlORDVUSitwcnJwQmNraWFS?= =?utf-8?B?MGtDcUYyQ3lGTzhHMmZDZTdQTHdKWVRHUCtoY1ZVbVY3blV6d1BKT0EzNXpK?= =?utf-8?B?MlFId1I0NDhWc3JMYk5jM0V6WXlCbzlZZTRlWDhWWkpKK3F5N0pWT3hjc2hQ?= =?utf-8?B?Q2xmM1d5YUdBWW0rdy9ReDVHNnRRTWxOSUxMNE9QNTJsNHc2WHhuRHZFbXYx?= =?utf-8?B?YUNNMkxKNEtBM2xxMk15bnZOazl6OEFWNmE4aXFDYzFhRi9iRzNqbEpzdFNW?= =?utf-8?B?dTRZU2k5TTlpSUNaVkFDY05xSys1REdJanpsYTBZUXUvbjQ5MHgwK0hib2JE?= =?utf-8?B?YlJOWTVSb3JlNDh1a3FYUXdwd2srR25COCt1amU2dzlhcmx1NU9VL0lxQU9G?= =?utf-8?B?R3ZtS1RuVWYwWUx4QlgyVzIvdlYxNWhTM1p4eTFEZnZCbmZWM1M1dz09?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: cbc34e74-a00d-404f-7b17-08deb48393e2 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB9080.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2026 02:17:14.9386 (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: GAGBNrztBzDR6RJkcvVBqi/kvyynf5shUlrKrIaLQFcu8pFS3jmvI9hTwhrPnEvdHYFZUq06c+dGEIUmN28itg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB7179 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 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 | 87 ++++++++++++++++++= ++++ 1 file changed, 87 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..28adea06c494 --- /dev/null +++ b/Documentation/devicetree/bindings/media/fsl,imx95-csi-formatter.yaml @@ -0,0 +1,87 @@ +# 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#/$defs/port-base + unevaluatedProperties: false + description: MIPI CSI-2 RX IDI interface + + properties: + endpoint: + $ref: video-interfaces.yaml# + unevaluatedProperties: false + + port@1: + $ref: /schemas/graph.yaml#/properties/port + description: Pixel Link Interface + +required: + - compatible + - reg + - clocks + - power-domains + - ports + +additionalProperties: false + +examples: + - | + #include + + 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 May 25 05:55:53 2026 Received: from GVXPR05CU001.outbound.protection.outlook.com (mail-swedencentralazon11013031.outbound.protection.outlook.com [52.101.83.31]) (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 905512DBF75; Mon, 18 May 2026 02:17:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.83.31 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779070646; cv=fail; b=n0w/WR8CW0BEdoPyk1aQf/96zk4O7r2dL8IpqAivWk+MyiPvbkmXtlJidn07qGr2JMsmFVokupQqA/D2ndiiiw2P3QGownPBegwFVILLgebpD2CzwfETsAb3diRzL1r7iKizjpGoLM1ICkEkE8yUGp6nOgA77GewLzFiaFPNMk8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779070646; c=relaxed/simple; bh=+IAd+OGu3x8qGss1aVArBVfiG8EV/qX15PRWSwmUSJM=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=RcLms6neuSaQLJBxmLMvrWXrt6roF86XU842+hDOfkwN93u68iQLj5Pk9vBcKx/N14FDMdymBZ8C+NLyGiLf/4oZL1SB6LYKM3ZYSgzXpjL9kDZqgVG4Xv6mJras/DrYT/wwkBvSlhCGFMYvdoT3juZufcJj+vYizdqjasiHQRg= 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=fRar5+ti; arc=fail smtp.client-ip=52.101.83.31 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="fRar5+ti" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lIHQnxU6Cdm3DcsS5GWeotsKlSCPXcdauQR+ggWN4xSbfXvuSrv9CRbv8PfvGsvtL+KqDY48zTtIU2TLyK84Ku6gYDaHV1mghkQImyPVmoKVZ59VAN9IRhCipTfSF1IGCpOVESIFN7z9Y+xY0cc7oYGQdPEgkxZi/3LnYGX59VVJ7jPKEVlqU6FyW8q1CzSxQWoya93YPSdkfBHeKaEnCJ64CVoaaR0PZS08+vx5wUSUy9ZLKzolU1JS8IW51DLsiAb24MFeOZm7jPNjQUDCl7gK4eK56koIhQ15E2YM5rEEqiixDe6kJ6FO3PxQeJzZhJeWj5FERjMgxvfoklqBfg== 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=k17YzR4L4kzYy6dt3K4+OhCnyI/duvLjLr0B+7o64f0=; b=AXy9yrQp756ShtJQdmWS6TqTb/v1ILEuAZFI7JpdoweL4sfX3tsHaQktkrPC/h/IPryuBweUNbqYa0fx0NCOIBzgJ/lqex/WA53ctxDaE8EOY1gODIblV5Azo28K0NGefXK+gAxKnSWhoK3Gx+UfyPeMI74Yp7Lin1GuuCvgs9uOyUhDEIn4Nt8FrW7ENUZeP4OmsdVAcOrPNJMJorYBMyzziVlIQmfOF6bZU2eH2lLkOAa9KJvTpHEZOYeXxhToiZbbL1y0S8vrOy4Q6WcIsyLWCQgFQbqwuLdoIi9cZP8hvE5nJI5s3pXwnRLB61z41zvIneyX7+iWo+ftzeorvA== 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=k17YzR4L4kzYy6dt3K4+OhCnyI/duvLjLr0B+7o64f0=; b=fRar5+tioCbJx1VAWMelFbdMr6y2wfVJ/qEQHMDICwqaQindds+ZoFsiHNvOOz3Dxr5yvhNrsQmpPlF/brH1e+tMurRcR3u7tVahRG/BRPxsi68Jl+/GA1sptNyg3UbRRZsNAKc4D+XBjs6jRhhNGm5QeQDkeVl6BYqaHly4DotcgWwZu+boGFZa16Y8Zmo5qyl4YJEjwvMf3hcIwmKnWB5XvvlU25IvnwAWA8pW9gF2xWdSV9jPHrvojJEfuKDBqne8HCSMPguca0io0TmCXpWhynHJSB1/7jvwXOOpQyFATM2QidID89Jy9q6q5L1oLqOSatarzmg6bTpR62u7Fw== 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 DB8PR04MB7179.eurprd04.prod.outlook.com (2603:10a6:10:124::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.25.23; Mon, 18 May 2026 02:17:20 +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.0025.022; Mon, 18 May 2026 02:17:20 +0000 From: Guoniu Zhou Date: Mon, 18 May 2026 10:19:47 +0800 Subject: [PATCH v7 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: <20260518-csi_formatter-v7-2-562b750557e3@oss.nxp.com> References: <20260518-csi_formatter-v7-0-562b750557e3@oss.nxp.com> In-Reply-To: <20260518-csi_formatter-v7-0-562b750557e3@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=1779070804; l=26988; i=guoniu.zhou@oss.nxp.com; s=20250815; h=from:subject:message-id; bh=T3flvOqfInCuhus11slRgHgYVMbE7N/foY7N14u1ggk=; b=mohtlXVdit0aoeGngeFPhXCOG3PwqljTQhgsLSEXvFPYrN9fXfBAwLPWHMAbviHQmIDT2CemA b52p3QCVrfeBXDuk/5a6fxot6CiKdHDIg+lQPnliBorHtKJ8cV8m38H X-Developer-Key: i=guoniu.zhou@oss.nxp.com; a=ed25519; pk=MM+/XICg5S78/gs+f9wtGP6yIvkyjTdZwfaxXeu5rlo= X-ClientProxiedBy: MAXP287CA0014.INDP287.PROD.OUTLOOK.COM (2603:1096:a00:49::25) 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_|DB8PR04MB7179:EE_ X-MS-Office365-Filtering-Correlation-Id: 55fbfbec-d0b1-411e-0247-08deb48396f1 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|7416014|376014|52116014|19092799006|1800799024|366016|3023799003|11063799003|38350700014|921020|56012099003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: TiOZYSEFuNNQsY38lDI7rvbElVk6TxKPGrsp1sS4YIske7urk2VDoWzS3qeRYD+AtR0v+wtTW1cOP7Xs4x90z8UJiPuM5GxToEGDJzsinku8eIFR1Dts2Jllwe/BHlkUjmetzNKbUAFxk3AFJroU0muQZweq3QTHyHDKvp/ataLbVxgDz5vZrDk099HVwW1OYLhSWXNYagIt+ek4NI9qPzVYgoEqkZ0Shm708t8LXq7RLzhI8AhL7mudhKCPd9WTiLlippGmzQfroWmFepiLxOWZnY7nEs1FC6G1KBUVmD9IAbcP/ZDq70jvzpmmAw6AoJTM1Di8Qb9wMGQpuLoLMZUjlh1zQ7jQfccaOl5ONUwqdCAoNLtS0QNoo4CE9FDfqIcO6J8RX+jSS6aGPb+uGSNMH4RrMJg9mDENTXP7Lualn0rMxIKm2ZPJAn6aApgzdxCMKZJdG5TrVT4c8AjB3kMuZjJHLQNDT1WUDYdwVvXw0BV/RnC2XtrE929BNptRrSA2oQ45JZq4GVSXqgZ3+9E+rpitnJFMCjBz2O3/FmASjGim+33t1jhSyqH5TaaWMcEMa3FVn8SIr39j0spx50ms4p814HA7CnCHY1259hXhoi7u/HXAWr3s2wWvMkufGfCisJqygg60uC/20Hyv33YPrInAApLxiS3MBwcgFq3Or8bCC4ow8p7lNQf0f3XdJY3mWc7ePeUq+rfo+l4rKt208U4+1qE5EhNnXko/FOqQ1LodO5UwvfY3nv1+lPzhjhuN9UMcf+6aPUvJKht+iQ== 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)(7416014)(376014)(52116014)(19092799006)(1800799024)(366016)(3023799003)(11063799003)(38350700014)(921020)(56012099003)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?dEZ2V2RhdXZMQWZZNkR5dTZDTTdORW1SMW0wemUxTkxQeXpXdW1yK2k5RERj?= =?utf-8?B?VWIrelNxSGFncnVzbVhieTNPYWs5SXhjaUNVVW0yVlgrcnJDcnRtYi9EWVRu?= =?utf-8?B?TU93SVI4cHNuenppbWczem56OS9qbGcyQjNJanFUaFhjZFRuNk9vREgrQXlL?= =?utf-8?B?cmNmZWR6NjhURVBvUFdXcEJRVWcrSDFHdFdwc2Q3U1lOdnJSTFVQMVY0YnZ6?= =?utf-8?B?VXVJNGhIWktNL1hpaXQ4bHpIZXNPbzVESGU4ZXd4YzBRN3pMeEpBbitiR0tR?= =?utf-8?B?WEs5WS9aUmhwZ0dXU0JsT1hWVmtRKzM5bllmcFEwNEpzd2RXMmRiSVNpZUpx?= =?utf-8?B?c3QwNkk1dDlZUGpHeW1TY25UMUR3TUpSMlJjb2wrbUZXRHBkTDFDVXJtUG5Z?= =?utf-8?B?b1FURmNQenhRbE9FY1dxaUJvakd3WHkzWFpsQ3RZOWNzWkFWakFjY1AyTDhG?= =?utf-8?B?MUQ5a2ltRnBDbWJMZmZvdkdKay81a1FkVW5hWkNYRHlNT1hXNjRyZVMzRFVv?= =?utf-8?B?elRRdjRocnE5eHREZFFENTN5ZVJYeTZ1T2dKeXQ5Qmd2bVBid2lUdjJ5Vm5Y?= =?utf-8?B?ajBNL0tmai9GRlVPZldUK3JhOG9WalFLc1AwL3BsdStKbFVISnY0d3Bud1JL?= =?utf-8?B?RDhacDA1NUlseDkvOWxRWExmWlR3a1FmTDcyQXF0eDkzRWR0S05rT0FURWcv?= =?utf-8?B?eE1ZbTU3TlNHbTRXemJUdVY2Wk50UlNoZFBnNTBpWjIxR3VxUmtqcjJjREgv?= =?utf-8?B?MHpSenh0V29zdEhYc3lwaDBibWRBVCtCdGh2OFFjNG1xYjFCSllubXM4REtO?= =?utf-8?B?Y2FrbUNQZUhtb0czQkZjOHZBYWtEcGwzRFJHNG1BcS8rSi96MWt0WHJjNlpW?= =?utf-8?B?ckJOdnRLVURkUXhLbUl2d0cxWjJYQkNCUmUrYUJGOFNOdXN0TFR5dHZVUlBF?= =?utf-8?B?T3BITE9tS21jZFoxOEpwbjhVS1RVQytxcnlyTzh3NmRNcUtSVXdYanRTSi85?= =?utf-8?B?b3orVTBJVkpUNDFQeU9yek92a3ZETHBtWllUWUNXejZmenc1R1FlNFRNR0Fi?= =?utf-8?B?bjZ4aHFsbGVjOXFHWjE1ZC9ibzF0TXJiSStOb3NpdGszbWtjREdTbE5Hb0wy?= =?utf-8?B?TU8yOWcxMHZvRkRkTlUwa25oN3lqL01nYStyTW1LUGNhR2MvMVFVdm5YR0JX?= =?utf-8?B?bVFncDBiMDg3cjNHT09lQXJrL1pNR2ZUTkRCUXZQMlY3WlQ0bXAzTitwaFFz?= =?utf-8?B?cDRUaFN0WGVTekhyaVh1Vm1LVlZwVUttekY5aDFBRFpUeHFNek5mZEdHT1Bw?= =?utf-8?B?eis0ODNQVk83Z0ZUcTJQUjZHOUdrR1JxMG5WeVN6YkZQTW1rdjJHcEo3a2FF?= =?utf-8?B?YTRuWlhQWCtXMlludzZ5OE9vbnlEcDRaNExGSmNyQXh0ZDExU0VVcVhubWNs?= =?utf-8?B?aTJ1V3pCOEFOSmZFZlBCd1oyN3FHMWZqL1N6V2xTMXVXS2o4VEUxdWpsZWFZ?= =?utf-8?B?Wk5DU2JwZm01Sk05YmNPbHVPQzQ5b3Zvek5mczNtZENTaHA4MlVoaTZxRXE3?= =?utf-8?B?bExMKzR0SEZLQldWaUU3VDdCVlRTT2hQODVFQjRHOGc4WWNxK0FZN1pNLzFr?= =?utf-8?B?NHpscTNpaWM0OGhPMlJRUTcxcjB5M2NpRi9zNTlmREhxb21vZWJYaTYrZTB5?= =?utf-8?B?NXY4Y2hpdmdyVjlYbUo4UWkrbGpWNjQzZWtyQXlUNW5tLzFNRDJwd1FKbDRH?= =?utf-8?B?OFJrVFFMMWNxcDFLSDJSVWpZWlMwYVd2LzVOd3k5S1ZxVngyUi9FY1VRS3Fv?= =?utf-8?B?V2RPN0s5QlNMS1dRMHVVWXhKNDN6aDMwNHJvdHE3QkYyTmhOZFB2a2x0RmRt?= =?utf-8?B?NWpxSG5Ia3BUa25uWktUVFNnbGgzM3Zwb295NFlvaUs1Qm83QTVqR0xDdEVD?= =?utf-8?B?SGkxZTNFRlVZWmd4WCtCVk9UVzJobS84elVKalhOK0pMdFhJNC9UMThzR0px?= =?utf-8?B?V0NVc2xNbEExZmxaVlcvRGJmSVBneElxOWdEalplWFVEVnhxVHBlMWU1M2dh?= =?utf-8?B?QmVSS1ZmclJUK3lKZEdEOE9KRTBwNkxuODdjTVZSc0pMTHJFY3RYbktsZnBt?= =?utf-8?B?c2JyaHN3RWRkbW16dnRqaTNYdTBybWYyZE80MEROaU9mSDdlTnZBUUZiQmJI?= =?utf-8?B?WGY2aXpudUZkS2JycWZUSmdUbHlCOGRvZXp4V1RrZ3cwRkRpNTFtZEpBTVE2?= =?utf-8?B?U3pnVjQ2Y3d5ZzJCVjROQ1AzbHI5ZHYvdTNocWlRZCtHbEpEY3RpWGJmWDlt?= =?utf-8?B?a3dsclEzbTJiRDM3N3ZoLzZMS1JzcWVEeXNUYVpXQWo4bm4xc0pBUT09?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 55fbfbec-d0b1-411e-0247-08deb48396f1 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB9080.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2026 02:17:20.0536 (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: JgZDclbHeR7ch2J+8c2WrIj38Bo0w7+pgOLgp/QECdLI6Ks5M1H6vCPXENUFP6EuKlfE1ttTRtFoO5ttQEOIqg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB7179 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 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 | 776 +++++++++++++++++++= ++++ 4 files changed, 799 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 81d53481d3f7..837e14fe7a12 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19265,6 +19265,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..82caae94a728 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 Formater 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..45240b7422b4 --- /dev/null +++ b/drivers/media/platform/nxp/imx95-csi-formatter.c @@ -0,0 +1,776 @@ +// 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 STREAM_FENCING_CTRL 0x34 +#define CSI_VC_STREAM_FENCING(vc) BIT((vc)) +#define CSI_VC_STREAM_FENCING_RST(vc) BIT((vc) + 8) + +#define STREAM_FENCING_STS 0x38 +#define 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 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]; + const struct formatter_pix_format *fmt; + + u32 remote_pad; + u32 reg_offset; + + /* Protects enabled_streams */ + struct mutex lock; + u64 enabled_streams; +}; + +struct dt_index { + u8 dtype; + u8 index; +}; + +/* + * The index should correspond to the bit index define in register + * which enable the data type of pixel data transported by Formatter. + */ +static const struct 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 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 formatter_pix_format *find_csi_format(u32 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 __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 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 __formatter_subdev_set_routing(sd, sd_state, &routing); +} + +static int 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 formatter_subdev_set_fmt(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_format *sdformat) +{ + struct csi_formatter *formatter =3D sd_to_formatter(sd); + struct 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); + + /* + * Validate the media bus code and clamp and align the size. + * + * The total number of bits per line must be a multiple of 8. We thus + * need to align the width for formats that are not multiples of 8 + * bits. + */ + format =3D find_csi_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; + + /* Store the CSIS format descriptor for active formats. */ + if (sdformat->which =3D=3D V4L2_SUBDEV_FORMAT_ACTIVE) + formatter->fmt =3D format; + + return 0; +} + +static int 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 __formatter_subdev_set_routing(sd, state, routing); +} + +static inline void 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 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 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 get_vc(struct csi_formatter *formatter, unsigned int stream) +{ + struct v4l2_mbus_frame_desc source_fd; + struct v4l2_mbus_frame_desc_entry *entry =3D NULL; + unsigned int i; + int vc; + int ret; + + /* + * Return virtual channel 0 as default value when remote subdev + * don't implement .get_frame_desc subdev callback + */ + ret =3D v4l2_subdev_call(formatter->csi_sd, pad, get_frame_desc, + formatter->remote_pad, &source_fd); + if (ret < 0) + return (ret =3D=3D -ENOIOCTLCMD) ? 0 : ret; + + for (i =3D 0; i < source_fd.num_entries; ++i) { + if (source_fd.entry[i].stream =3D=3D stream) { + entry =3D &source_fd.entry[i]; + break; + } + } + + if (!entry) { + dev_err(formatter->dev, + "Can't find valid frame desc corresponding to stream %d\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; + int ret; + int vc; + + for (i =3D 0; i < V4L2_FRAME_DESC_ENTRY_MAX; ++i) { + if (!(stream_mask & BIT(i))) + continue; + + ret =3D get_vc(formatter, i); + if (WARN_ON(ret < 0)) { + dev_err(formatter->dev, + "Failed to get VC for stream %d: %d\n", i, ret); + continue; + } + + vc =3D ret; + + formatter_write(formatter, CSI_VC_PIXEL_DATA_TYPE(vc), 0); + } +} + +static int csi_formatter_start_stream(struct csi_formatter *formatter, + u64 stream_mask) +{ + const struct formatter_pix_format *fmt =3D formatter->fmt; + u64 configured_streams =3D 0; + unsigned int i; + u32 val; + int ret; + int vc; + + for (i =3D 0; i < V4L2_FRAME_DESC_ENTRY_MAX; ++i) { + if (!(stream_mask & BIT(i))) + continue; + + val =3D BIT(get_index_by_dt(fmt->data_type)); + + ret =3D get_vc(formatter, i); + if (ret < 0) + goto err_cleanup; + + vc =3D ret; + + 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 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; + + dev_dbg(dev, "Enable streams: pad=3D%u sink=3D0x%llx source=3D0x%llx\n", + formatter->remote_pad, sink_streams, streams_mask); + + if (!formatter->csi_sd) { + dev_err(dev, "CSI controller not linked with formatter\n"); + return -EPIPE; + } + + 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, 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 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 formatter_subdev_enum_mbus_code, + .get_fmt =3D v4l2_subdev_get_fmt, + .set_fmt =3D formatter_subdev_set_fmt, + .get_frame_desc =3D v4l2_subdev_get_frame_desc_passthrough, + .set_routing =3D formatter_subdev_set_routing, + .enable_streams =3D formatter_subdev_enable_streams, + .disable_streams =3D 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 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; + 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_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_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, "formatter subdev init fail\n"); + + /* Initialize formatter pixel format */ + formatter->fmt =3D &formats[0]; + + 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