From nobody Sun Feb 8 21:47:54 2026 Received: from SA9PR02CU001.outbound.protection.outlook.com (mail-southcentralusazon11013071.outbound.protection.outlook.com [40.93.196.71]) (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 DCAA248C8BA; Wed, 21 Jan 2026 13:54:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.196.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003691; cv=fail; b=GguCzcpqmlc7valEI3dukLxFynhqmAVis6Vy+DxDTd1bPYT75IiV44g+F+l11Pb0+KK3AQBcHsSsRPxJB++iiwr4f9Rt5O+gzbR9MTa5JpEIsmcCHId5ntDhOLLGKFZrHu6Bk6cDN7vfLL74JC7seZEgkUxDZ2EMYV0CyKNO+Qc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003691; c=relaxed/simple; bh=u8b4MfIRq4LyNu21j/SiQF7ET4XUYywxe61kp26gAdA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cE91Co3I7VlpD9ExIdmZUzZ/lHUpIiyObRP+Fcrxk4wtHRkH+RspChkPxlIXEFXRAALFi6cYnjp/0emqeKQds5CmF1xGAx+To6bn/yYBskiLILe2NXFp80644Es6+aSO4j4xU/ETMIDns/njFYTqrr7qSnYi4g77PoyMnES4WUM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=aa98BFor; arc=fail smtp.client-ip=40.93.196.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="aa98BFor" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=w834ehQJEz0O3qbXGKDIWIkOQWinfuZji/EvdbN5tEVZI33qSN54zKVYtjjyhey5XmFdvbl+NWpq6tb3bvaAFJJ0Cg0Fmskmeot6U9UChVf65CAKw2H8xynFmx4DfgUOYZLCJVTfoasViHi7CCrJnijjxIr2eaUH3+gkLc5TLcHWgLqSj9OoFYhpEH+zTANJ3Ah16QI6++Mptr7I7omMPTNGXXwy8Zrhoc/5d0Qq68h8Xn0ZwoQbRLylfzqg87c2qiIQcxfFM+uIGGH4tUEl6scsBmw6sFmyLrvGN9z6/wIYTr+h9jaK2DzZvuXPhYzrjtlfUGg5rc40SZsYySuybA== 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=XYXYTgGde7ltf/08jScCgV0DRV/+RS2VHZtsmTT0uzY=; b=vYeQHiS6Nskuaxq47UldJkeushc3rNM+YVsGFRooD3kj/fOAdUai0d4M//Vx4JQ+PJs8i8YXojoyLpIhB/KgxGbIuEqu6W3pZ/sN6PN4SOgzj//9GivIROdfy62hbLkPRXMyc7isfrY3gv7a098W1VHaq8SI/50y7vpV8h2EOfvrj3zH2yuwE5xuHbnwS/sEAOggILrBskBCqAa9zYMNlSVpWlpxcoQ4p9x8Ue8v5z0po36+NKr+Sw8Zf7pivHH4SL9BLEvjfgCYAR43G0vxB69EuPEWpq0fuQGWydgUkUQ94dwpocXvb255ZcVQcUsVOCWSdH+PTqnOHY0NG9Mz2w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.194) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XYXYTgGde7ltf/08jScCgV0DRV/+RS2VHZtsmTT0uzY=; b=aa98BForEhk35kCo2VvoDk9cvy+mqz1HvbkdzcPRQvUKzRWTtxcv4Y4OfOH8JHcr3OxO8TeOKfu5kL5cnX3WLQ/hGQsYLSHZLT9E2uASFNoQfYhusZjtS1N7UvPUOW/NaW+lPY+GplAjx2ZzK1yvXjO/rKf5nouBVTc7fVFabfE= Received: from IA1P220CA0019.NAMP220.PROD.OUTLOOK.COM (2603:10b6:208:464::6) by CY5PR10MB6070.namprd10.prod.outlook.com (2603:10b6:930:3a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.9; Wed, 21 Jan 2026 13:54:42 +0000 Received: from BN2PEPF000044AA.namprd04.prod.outlook.com (2603:10b6:208:464:cafe::f0) by IA1P220CA0019.outlook.office365.com (2603:10b6:208:464::6) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9542.10 via Frontend Transport; Wed, 21 Jan 2026 13:54:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.194; helo=flwvzet200.ext.ti.com; pr=C Received: from flwvzet200.ext.ti.com (198.47.21.194) by BN2PEPF000044AA.mail.protection.outlook.com (10.167.243.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.4 via Frontend Transport; Wed, 21 Jan 2026 13:54:40 +0000 Received: from DFLE204.ent.ti.com (10.64.6.62) by flwvzet200.ext.ti.com (10.248.192.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:54:39 -0600 Received: from DFLE201.ent.ti.com (10.64.6.59) by DFLE204.ent.ti.com (10.64.6.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:54:39 -0600 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE201.ent.ti.com (10.64.6.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend Transport; Wed, 21 Jan 2026 07:54:39 -0600 Received: from ws.dhcp.ti.com (ws.dhcp.ti.com [172.24.233.149]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 60LDsPI73104105; Wed, 21 Jan 2026 07:54:32 -0600 From: Rishikesh Donadkar To: , , CC: , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 01/18] media: ti: j721e-csi2rx: Remove word size alignment on frame width Date: Wed, 21 Jan 2026 19:24:07 +0530 Message-ID: <20260121135424.1185710-2-r-donadkar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260121135424.1185710-1-r-donadkar@ti.com> References: <20260121135424.1185710-1-r-donadkar@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044AA:EE_|CY5PR10MB6070:EE_ X-MS-Office365-Filtering-Correlation-Id: f98756f9-c36c-40e7-4948-08de58f49f6b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?AGf2BDOAlgIoIfCLR7wm/mXGKEBrBoagPTc5bRYuclmzlUaaOb/dgKKanHz9?= =?us-ascii?Q?8W2LZ3A8IFWLCu5MTmjEVZFmopWXft9xuZYqlT+lVY+nBjJ7k8wqmYYS2dkn?= =?us-ascii?Q?9V09ay8ze658SxGqgd8sybPForyLZv65j34Wz0xgBLR5+bUzCqGCl6L3UrnJ?= =?us-ascii?Q?cS8fGIUwI+aXBSCXGVt3XmEXbqkEkXJvZhCUZPM1qbAg5ZdPO5k9lFqTMSRO?= =?us-ascii?Q?Lmh01kAUc967fV3eeOQ8+wj6qJIuoBwdGYPptDR/DcVwkhBmD2tRO4XTAaNR?= =?us-ascii?Q?SOt0urLpwDDVL7qZy8huFYQUnmrYKycRcVKoekYhxPJLaH8zasPRlDchzlFN?= =?us-ascii?Q?rTdqH13I0UKA/iyuyspdcQH/OUm/xOHM2Fqik0QnHyed5Nmqzz4k6re11sL3?= =?us-ascii?Q?N/LtwMy5pwyEH27bmbFYC9zfLJuWTPTXwEwLB7vlHQV+l4JrDULwn5htq8tL?= =?us-ascii?Q?1UqRtIqZD7lSKJkNbo30CQ4d60CowHxqrEsnnNUg0Ksu09BBbdpUHETVCM3V?= =?us-ascii?Q?CUTruy93NE1YvI3KQV0Z3CEAXL5o3u5y4CtEUHDHqDwj+BubA7qMUc5Wj7A/?= =?us-ascii?Q?5fD/LW9flUPvNxxr2uJ9JiuUMtBl0/IVIQi5QIzNGtCSi6tsIwBZa11VPc+n?= =?us-ascii?Q?zO7qiVE5gVVqBuBV+XO9Xi4wD+oIUA7rE3pPX9UNd7JhOQMJLoQGdwZwAG7+?= =?us-ascii?Q?f9cglSyWQzD9HvbQIZB3ZilKb1ySstQyHhSgsy+vjhjvngstzCbTu1hhJi5F?= =?us-ascii?Q?+WNA99bTbp/7vlY7v96Z4vXd5X+DC6nZny2MIYMHV6OxRYBpzO6j6liTGG3c?= =?us-ascii?Q?9ou3tUHVe7DNX9hJ8SHmWSxWcH2IRYCaiujVJZVSSDQjhebJWrQCa7I33lzl?= =?us-ascii?Q?zknldenoznbX2W/Xk2sK11weLnJjLEu0g5jPRLIss8joVgDsvhjvVMK7mLO6?= =?us-ascii?Q?m/oX9/lkVEt7bAksXpwcDTfVYF1xUrD8HyJHIMInC3m69Ayi5uyLy9Wvi/E+?= =?us-ascii?Q?VheKTKWI2DapYbEAmQ4dZpF1B5KPfOmYuxFNKQZpPa7JUqr6wioRZFsQY6pi?= =?us-ascii?Q?QD4KS130fc3kAMZXLe62j3vdDCFEDjo06v1h8i7YSU2t055uD4+6F0Fm48Ez?= =?us-ascii?Q?tOsfxEbVZmqht2hxfeIsHWwIK7W6+fZAp9KMJk0VS5tkYr0vEOsZZSco3px/?= =?us-ascii?Q?Yw1LnRnCmbDN8UeLYEfR7bmR9vm7UkUUEEamUwt+XrZ/FeH7Vt7EA3ZxeQCZ?= =?us-ascii?Q?NIprbeaTNGbHOBOvOV78Ko7ImrB5+dQIx+fqj3/P8rt9PVreSDQ9woKqUbE7?= =?us-ascii?Q?AaBOZxfl9ixBscMsITFb+FpMgamhSzjRNfP2en6ai1j8Tqis04meLKXWpQtv?= =?us-ascii?Q?I5NdTnJ5xvfjLPPiHf7u6DwMkQd/0g19/oL9Dk05EAsD+nhsb2d0OLfi+6ur?= =?us-ascii?Q?4/Xt+dqAWshllNS5kYOie1MDnctA0IwQzS2uzHWYnkcUyESI0k2xAzU4pggK?= =?us-ascii?Q?dBk5yeGohOuGZ9alKBiqlExGQzKSVJ31XPDqsh7ENM+boG8eGzdXHmKNXdPL?= =?us-ascii?Q?+yYYhcvjSosCCID/ixWNAm9rpv2rLklaUBhOK/RLbXMhAdl5hgcsRUH7aPcD?= =?us-ascii?Q?zjSJq+C+FuniJhXTWO5xgL4gTBJT1U/B1KFXRGCBndO0qQnrtOu2/BVaL5ae?= =?us-ascii?Q?Hadx3g=3D=3D?= X-Forefront-Antispam-Report: CIP:198.47.21.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet200.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2026 13:54:40.1861 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f98756f9-c36c-40e7-4948-08de58f49f6b X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.194];Helo=[flwvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF000044AA.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR10MB6070 Content-Type: text/plain; charset="utf-8" j721e-csi2rx driver has a limitation of frame width being a multiple word size. However, there is no such limitation imposed by the hardware [1]. Remove this limitation from the driver. Link: https://www.ti.com/lit/pdf/spruj16 Reviewed-by: Yemike Abhilash Chandra Reviewed-by: Tomi Valkeinen Signed-off-by: Rishikesh Donadkar --- .../platform/ti/j721e-csi2rx/j721e-csi2rx.c | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/driver= s/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c index b75aa363d1bf2..710d05a053539 100644 --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c @@ -43,7 +43,6 @@ #define SHIM_PSI_CFG0_DST_TAG GENMASK(31, 16) =20 #define TI_CSI2RX_MAX_PIX_PER_CLK 4 -#define PSIL_WORD_SIZE_BYTES 16 /* * There are no hard limits on the width or height. The DMA engine can han= dle * all sizes. The max width and height are arbitrary numbers for this driv= er. @@ -250,19 +249,12 @@ static void ti_csi2rx_fill_fmt(const struct ti_csi2rx= _fmt *csi_fmt, struct v4l2_format *v4l2_fmt) { struct v4l2_pix_format *pix =3D &v4l2_fmt->fmt.pix; - unsigned int pixels_in_word; - - pixels_in_word =3D PSIL_WORD_SIZE_BYTES * 8 / csi_fmt->bpp; =20 /* Clamp width and height to sensible maximums (16K x 16K) */ pix->width =3D clamp_t(unsigned int, pix->width, - pixels_in_word, - MAX_WIDTH_BYTES * 8 / csi_fmt->bpp); + 1, MAX_WIDTH_BYTES * 8 / csi_fmt->bpp); pix->height =3D clamp_t(unsigned int, pix->height, 1, MAX_HEIGHT_LINES); =20 - /* Width should be a multiple of transfer word-size */ - pix->width =3D rounddown(pix->width, pixels_in_word); - v4l2_fmt->type =3D V4L2_BUF_TYPE_VIDEO_CAPTURE; pix->pixelformat =3D csi_fmt->fourcc; pix->bytesperline =3D pix->width * (csi_fmt->bpp / 8); @@ -360,23 +352,15 @@ static int ti_csi2rx_enum_framesizes(struct file *fil= e, void *fh, struct v4l2_frmsizeenum *fsize) { const struct ti_csi2rx_fmt *fmt; - unsigned int pixels_in_word; =20 fmt =3D find_format_by_fourcc(fsize->pixel_format); if (!fmt || fsize->index !=3D 0) return -EINVAL; =20 - /* - * Number of pixels in one PSI-L word. The transfer happens in multiples - * of PSI-L word sizes. - */ - pixels_in_word =3D PSIL_WORD_SIZE_BYTES * 8 / fmt->bpp; - fsize->type =3D V4L2_FRMSIZE_TYPE_STEPWISE; - fsize->stepwise.min_width =3D pixels_in_word; - fsize->stepwise.max_width =3D rounddown(MAX_WIDTH_BYTES * 8 / fmt->bpp, - pixels_in_word); - fsize->stepwise.step_width =3D pixels_in_word; + fsize->stepwise.min_width =3D 1; + fsize->stepwise.max_width =3D MAX_WIDTH_BYTES * 8 / fmt->bpp; + fsize->stepwise.step_width =3D 1; fsize->stepwise.min_height =3D 1; fsize->stepwise.max_height =3D MAX_HEIGHT_LINES; fsize->stepwise.step_height =3D 1; --=20 2.34.1 From nobody Sun Feb 8 21:47:54 2026 Received: from SN4PR0501CU005.outbound.protection.outlook.com (mail-southcentralusazon11011062.outbound.protection.outlook.com [40.93.194.62]) (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 A5DD847ECC2; Wed, 21 Jan 2026 13:54:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.194.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003700; cv=fail; b=CTBouov6lQFsJ2k6LsdGIRACs2yXyofDglAD7zsv0PzEt4BKSmw1ArQVNbSRCngn8lYulhZBPkp5VVE6OBWlOE0jqvZztThn3FAQOm9HJCFipigV2O4HuTCXHinH6OQkxSuMz/2nujTWa/ZDstjk8HkpYNaB8IOVcpTrMSdRtBI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003700; c=relaxed/simple; bh=s1Z6i8nmkzcw+5uOaYPg9pWYsuDmjnhT7v4WJaHkyLk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QiFdHno0pw+w0bXh79mFhazdDwz8iFL0vKBxHjXPRR3wDio4DsRxTaRhKZFwNgPXe3Ib9kwEgIqdvoYWTaShzaHFj8wVklA98GrXbLfQGaB88BhpCxVp/JEZ4yh+ze5vMmj5Q3HFYvSfGPVDQUNz7ku5JcVigDPx6rkyfuu7gI4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=aniKXOiX; arc=fail smtp.client-ip=40.93.194.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="aniKXOiX" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ar4Uc8+oOIbkoTHuzdFXm1j83ghoS/8v6WYsl5unEYgz03GMRcJvzymdlqMYGLRkZKEU9QuKn2HzM5rb5prYjk5TR0ASfo0FaN2dVnk+dAZELvSN2oe+5OhxQ2Qe15RTidvdJXyEHC0Ehqng9zy+T3joGf8jo2GCkGNJ4NZLideuFcyzs7igS04xXmQ0rtNHkQ8Qi1CikskptQ8GafWAv0suaj+joIRUdhjwk/hIzM2/zG9Q0U5NoD9lq8Xf4B9rPsZeOFLklS7EzcpYWl+X5vUT6sZKTy7srEqz3UPxdsaV3gjxqGTr05eAt3T6qAJTfCG5ukJw5eAbMf3sRQH0jA== 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=RKOGeTrdANEFIeSncdxz10Hh/ukJDG922e6712afheg=; b=N2/igoKaZQW/41RILuKs23GaT+H53fLRJCB5PD+Bgegp/n5R4sJxcqnbXvJ5KQvyKcqNyhQRDGBCiNwu7Tq4wiGJFymJXBrSSKiRZU4rV430tS9SSW/z445ZJPoOZgSygHfnkJ1k2g/gyqQ1RFp10Lt5e81k82VyX4tYefbqarzz8KymTPhjCj322sIvzgaBpAl/nNo3nZkbk+1nGs3uLstaNBXQdcO4IYe+Y8zvNRQVTgg1hdy2RBNybD8gbs0JBEXgNm9BiT64kjBsyT6nU/GIhLjhMqff4eDBA5B/sJ1Eci3noBC0sxwyQwIB/Iu6bdZkdYiT9AmZlneyciz2Nw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.194) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RKOGeTrdANEFIeSncdxz10Hh/ukJDG922e6712afheg=; b=aniKXOiXg8ehIveVxdhSJ5aUwbqcAa5z+T+aTMe7vH1maPTkevDhYRJciYgP4aBbNsO1Chc6yDi4FS+IIECMJt3/eshOnkoNeyuBSkRpy18+m5/t6wGnxUSaEaOW2mmgIQmExrUB7PnTCEEmR/x8jfXnPGpC/+GdHyYXAyGWgrs= Received: from BL1PR13CA0236.namprd13.prod.outlook.com (2603:10b6:208:2bf::31) by IA1PR10MB6219.namprd10.prod.outlook.com (2603:10b6:208:3a4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.9; Wed, 21 Jan 2026 13:54:49 +0000 Received: from BN2PEPF000044A8.namprd04.prod.outlook.com (2603:10b6:208:2bf:cafe::5f) by BL1PR13CA0236.outlook.office365.com (2603:10b6:208:2bf::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9564.2 via Frontend Transport; Wed, 21 Jan 2026 13:54:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.194; helo=flwvzet200.ext.ti.com; pr=C Received: from flwvzet200.ext.ti.com (198.47.21.194) by BN2PEPF000044A8.mail.protection.outlook.com (10.167.243.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.4 via Frontend Transport; Wed, 21 Jan 2026 13:54:47 +0000 Received: from DFLE207.ent.ti.com (10.64.6.65) by flwvzet200.ext.ti.com (10.248.192.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:54:46 -0600 Received: from DFLE205.ent.ti.com (10.64.6.63) by DFLE207.ent.ti.com (10.64.6.65) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:54:46 -0600 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE205.ent.ti.com (10.64.6.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend Transport; Wed, 21 Jan 2026 07:54:46 -0600 Received: from ws.dhcp.ti.com (ws.dhcp.ti.com [172.24.233.149]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 60LDsPI83104105; Wed, 21 Jan 2026 07:54:39 -0600 From: Rishikesh Donadkar To: , , CC: , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 02/18] dt-bindings: media: ti,j721e-csi2rx-shim: Support 32 dma chans Date: Wed, 21 Jan 2026 19:24:08 +0530 Message-ID: <20260121135424.1185710-3-r-donadkar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260121135424.1185710-1-r-donadkar@ti.com> References: <20260121135424.1185710-1-r-donadkar@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044A8:EE_|IA1PR10MB6219:EE_ X-MS-Office365-Filtering-Correlation-Id: 37f00d8d-e64c-4bb4-267d-08de58f4a39c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|7416014|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?rbFbzEa7zzpy+uo9Vq/ON6h0FEz2ERStWcxVjhtoZNwjK/IBlwfGAWtDx/lT?= =?us-ascii?Q?ueEeDjLmEz+rTVj1P8nMesX/2rrXywMZnBZUwD5IRmfUfx+Mut2MRs+qB8J0?= =?us-ascii?Q?VgyuZMtbED/RIqwH/dW2R21DiH0qa85Hp6ji+JZNXMTeHnKBgKF0NAiRHgAX?= =?us-ascii?Q?UQWOC65ZNsjhA0G9h79VBzKpueYseWdluPOV2kfWm5lp/DwQeY7+Dee5qk86?= =?us-ascii?Q?oceXCh7RTmrnt5jIpHwWaOSSZAt6ekDBX1dBF8fk6NK3JBWdyyphC+aJyqfJ?= =?us-ascii?Q?lGV5GDvABgxgW+b9q5fhbeXuSXQ6S8tRm216ApE95g+QixsS0NUmith5ZAED?= =?us-ascii?Q?Qf+EvabOaEuY2Qc7RyUkkECGF2G8sadYjzfhS28/ogDznYvmJhHWKbP7tJzu?= =?us-ascii?Q?VMBMvYuWl74XCZagmB0Pb5v4iMkOScblJGPHOLMi5yCInw1pFw+t95dzvPJ7?= =?us-ascii?Q?ebZMmU8fQZC29FwThunfBkVw/ysKULQ1Nkr3z/T09YJygs2hJG1mOE73xFjr?= =?us-ascii?Q?YUkX5PSQJI5TZRdDIWQx2TUhtZF04eexaWm360niyEXh/YobLCjIA/hqdZgs?= =?us-ascii?Q?UNm6tmn5EXSh+fIdoCEmq1TZJJEuAmrtvJ6Iq7U8jr5dP3PoR4Xa5rWNLJk9?= =?us-ascii?Q?iuIn4Jc7xqF2rFd0DdB6iK2Pq7vR2kGZre/rSHl7hFeAIJwAKcYeyplgdLJV?= =?us-ascii?Q?bn33W6r7eNSjR/uIfFFDqIb6nKOpIhMrCOeSsMBrqg9kH8P9c5yc3/6bW0Nl?= =?us-ascii?Q?li+1fhscv8GkQwwjwAVK5dgdFiL723TFHUqLgzzSo/gaf/QAfl2grQWTjIGh?= =?us-ascii?Q?ivsITo8WLIOoQxyS6blp8i+zwDwhDp1ilyqHHj4satJd12sfsI4AmaKh6ntb?= =?us-ascii?Q?KwX/7Uon7hKSiB72X1Bu04ErqEXb0iy+F5STT+RlGJMPZ94xc1XE4uRvhmFR?= =?us-ascii?Q?FK8cPoW9Vwp45a1aUS/DP5S4iQCtbMu35EjGCMKRe7Egh0vpub/Fe0W4MM8Y?= =?us-ascii?Q?But5w1r1IrmZIWDWPUveB+ferCTbfxsRRUZvPeid4gcdj+EuHmBWKPPSYabV?= =?us-ascii?Q?L2OJbz9nsTJOBtYs3VyUzrcpCUxf+qQedTxH3eLr+Zp0UPV1724RYr6juJpP?= =?us-ascii?Q?qXwzbsYbKSwqpeNzF5tDNcfExPHLm+jQrUveKnxu2/XVymchIPL6/g1xUTEi?= =?us-ascii?Q?rkF4E54l2H9r0aF0UMqj5phviOxm8nWqLSlod79fw+HPsDO+emFY0wZyJORa?= =?us-ascii?Q?y7skF8EadKoAr6N8NBtraycb75BVprk+etPZvfS/aHhLafOqK2FayY5zUKkX?= =?us-ascii?Q?C9+eEgu3BKSIbQ46KOKBnpi/jDI/rGyoqHD8SWfmlXu8KP8QxTfjNOCI0FHL?= =?us-ascii?Q?fAnnYe9QUnt+OUgJATJJRBknU9BDbxnzeMSIT87d8SInOrqEH65zbk2ZVVpr?= =?us-ascii?Q?15k/usP3SH1nbMTB92cy5hNeKqq1g7NRNQmymKp72m5RMjmMGrxtRzcXiY5X?= =?us-ascii?Q?2tlL+FsMq6tj/YTFwuBQmVWzkR88qu8wK4r7rIqATOhopGFSdX7G+SUj45YS?= =?us-ascii?Q?gdbjUQ/ONRdOt1aRkqZZZGGVGiP28ehCCS+nUneKHRL50SIJdFRERbi+VI+Y?= =?us-ascii?Q?s+/VzZP2DnbFyq4bXft3tUiwvbUA/aV5rskEnPd+OIJ7w9KdVB/33snMEmu2?= =?us-ascii?Q?7xkG7g=3D=3D?= X-Forefront-Antispam-Report: CIP:198.47.21.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet200.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(7416014)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2026 13:54:47.2200 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 37f00d8d-e64c-4bb4-267d-08de58f4a39c X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.194];Helo=[flwvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF000044A8.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB6219 Content-Type: text/plain; charset="utf-8" From: Jai Luthra The CSI2RX SHIM IP can support 32x DMA channels. These can be used to split incoming "streams" of data on the CSI-RX port, distinguished by MIPI Virtual Channel (or Data Type), into different locations in memory. Actual number of DMA channels allocated to CSI-RX is dependent on the usecase, and can be modified using the K3 Resource Partitioning tool [1]. So set the minimum channels as 1 and maximum as 32. Link: https://software-dl.ti.com/processor-sdk-linux/esd/AM62X/10_00_07_04/= exports/docs/linux/How_to_Guides/Host/K3_Resource_Partitioning_Tool.html [1] Link: https://www.ti.com/lit/pdf/spruiv7 Signed-off-by: Jai Luthra Reviewed-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart Reviewed-by: Rob Herring (Arm) Reviewed-by: Yemike Abhilash Chandra Signed-off-by: Rishikesh Donadkar --- .../bindings/media/ti,j721e-csi2rx-shim.yaml | 39 +++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/media/ti,j721e-csi2rx-shim.y= aml b/Documentation/devicetree/bindings/media/ti,j721e-csi2rx-shim.yaml index b9f033f2f3ce4..bf62998b0445a 100644 --- a/Documentation/devicetree/bindings/media/ti,j721e-csi2rx-shim.yaml +++ b/Documentation/devicetree/bindings/media/ti,j721e-csi2rx-shim.yaml @@ -20,11 +20,44 @@ properties: const: ti,j721e-csi2rx-shim =20 dmas: - maxItems: 1 + minItems: 1 + maxItems: 32 =20 dma-names: + minItems: 1 items: - const: rx0 + - const: rx1 + - const: rx2 + - const: rx3 + - const: rx4 + - const: rx5 + - const: rx6 + - const: rx7 + - const: rx8 + - const: rx9 + - const: rx10 + - const: rx11 + - const: rx12 + - const: rx13 + - const: rx14 + - const: rx15 + - const: rx16 + - const: rx17 + - const: rx18 + - const: rx19 + - const: rx20 + - const: rx21 + - const: rx22 + - const: rx23 + - const: rx24 + - const: rx25 + - const: rx26 + - const: rx27 + - const: rx28 + - const: rx29 + - const: rx30 + - const: rx31 =20 reg: maxItems: 1 @@ -62,8 +95,8 @@ examples: =20 ti_csi2rx0: ticsi2rx@4500000 { compatible =3D "ti,j721e-csi2rx-shim"; - dmas =3D <&main_udmap 0x4940>; - dma-names =3D "rx0"; + dmas =3D <&main_udmap 0x4940>, <&main_udmap 0x4941>; + dma-names =3D "rx0", "rx1"; reg =3D <0x4500000 0x1000>; power-domains =3D <&k3_pds 26 TI_SCI_PD_EXCLUSIVE>; #address-cells =3D <1>; --=20 2.34.1 From nobody Sun Feb 8 21:47:54 2026 Received: from DM1PR04CU001.outbound.protection.outlook.com (mail-centralusazon11010005.outbound.protection.outlook.com [52.101.61.5]) (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 2615E47CC6F; Wed, 21 Jan 2026 13:55:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.61.5 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003709; cv=fail; b=mvItFZVsyKP3jEeZZraWQtSeafwSv41gZpomGzulR36luaJ2CQz+6Jt1gBCJ06ljVj3YGlGT+AeqfxIXqm7CaT+mdRlfCCc0JU0Q+w0N1W4PCsnXkkhk3GRmyvPLyEtqSY9XOulsZWw1CBtM5fYlg2xs1CkPtD5Akr40hc45B/U= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003709; c=relaxed/simple; bh=wVop2nav+d4ORBxkvdYrZ2TjQx/iSrxQZPxMGtZLp3I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Tq3/EIJ8pyuyXbAPudnt5+lHqfS/WQtzliW3ZyOxBa4wh1MNEtjiwqkBTkz0z1/lK8oO3bPECF+V17Js3DSHLs3ON4Kiz02aAl8mQHyRTj9FG1lNdDz/zYp16ooukfAkczOAOv2yJnLegznwOR97xXCZnVzIPampxTJc51OwGE0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=v++kFhLt; arc=fail smtp.client-ip=52.101.61.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="v++kFhLt" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bwjM+dY+JSf5LXxtUxOLhgvOXfV2E8mY8jCsdqp3EZNO7jOMAqqaPRvMdlYMq4gAU4R7EI+vv9T0rLR+yuKOo6FQqVd2bGfvN8GCJazDA7+MXpwYDdR+PiIIHCBWExmHErmgLvn4V1QvoFzL5z5JjMt/xGQwtA0a0nAHOeqv+HmYwQN9gFfpULELN6/hpycsww9wNY3WfZ5jtpJk5xKQdtX8c+pDo9X8ppARny/mooBZ5Gmpp753Y7Y19Wt4R2jj14p6dCoW0JkEHV1F6vJkZsVP264Bkn8coQFYgPIh9BM28okQ77q8kvxejggbUUIOlfSNLmiAKMgCDmQiyccBTA== 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=7bXk63iDezCt2psOMOzpLnVMeSYg+MD9VY7fXVcl8jQ=; b=KFnG2WqNiOIrse4Q1VeqFYl6H4m02RIVpTlbI54SX0jIq+BbbNGH19fX2+okqHnEeEDodDQDRX9gmQAqC1RsYRcze2jpAhODKEe9xeIOQx2AHEzE8icopDAZukyOYHIrAkIClhh+4mn1gjaDm0cGIQOdOSaYEEvTyHKznESPCWlV9LIl85sK0R4o8u6Av1YgfME1d/uJMsWo5stW0ator5K0brmd3Bl7Eqjfj3facO3tTtVcKEXOC2sYpUJU/zc/doZxbBUr5X/qGFwRBt8Q9U8Gb45nw62ts2REESWcimWLsJatO1+xqEHyxIhyhsJW5DAA5H2rCdUwOO0F+lUcsg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.195) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7bXk63iDezCt2psOMOzpLnVMeSYg+MD9VY7fXVcl8jQ=; b=v++kFhLtPyodqktuwwcFKvu1FrJxH4Hc2UpQ3DAw9CY44QSpV6iGipwhzMEXshBmh6CE9yWcCrf9/ZNlgj3CTWIpUgI0yr5eVvS7xiq3N6oSX+JCvIP4KGFB8D2q6arMPtFi9hzynMSb9yDWONemRFon/g3EbN7RX8S8rEM2oZs= Received: from PH7PR17CA0002.namprd17.prod.outlook.com (2603:10b6:510:324::22) by CY8PR10MB6657.namprd10.prod.outlook.com (2603:10b6:930:55::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.9; Wed, 21 Jan 2026 13:54:55 +0000 Received: from SA2PEPF000015C7.namprd03.prod.outlook.com (2603:10b6:510:324:cafe::30) by PH7PR17CA0002.outlook.office365.com (2603:10b6:510:324::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9542.10 via Frontend Transport; Wed, 21 Jan 2026 13:54:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.195; helo=flwvzet201.ext.ti.com; pr=C Received: from flwvzet201.ext.ti.com (198.47.21.195) by SA2PEPF000015C7.mail.protection.outlook.com (10.167.241.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.4 via Frontend Transport; Wed, 21 Jan 2026 13:54:54 +0000 Received: from DFLE214.ent.ti.com (10.64.6.72) by flwvzet201.ext.ti.com (10.248.192.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:54:53 -0600 Received: from DFLE210.ent.ti.com (10.64.6.68) by DFLE214.ent.ti.com (10.64.6.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:54:53 -0600 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE210.ent.ti.com (10.64.6.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend Transport; Wed, 21 Jan 2026 07:54:53 -0600 Received: from ws.dhcp.ti.com (ws.dhcp.ti.com [172.24.233.149]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 60LDsPI93104105; Wed, 21 Jan 2026 07:54:46 -0600 From: Rishikesh Donadkar To: , , CC: , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 03/18] media: ti: j721e-csi2rx: separate out device and context Date: Wed, 21 Jan 2026 19:24:09 +0530 Message-ID: <20260121135424.1185710-4-r-donadkar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260121135424.1185710-1-r-donadkar@ti.com> References: <20260121135424.1185710-1-r-donadkar@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015C7:EE_|CY8PR10MB6657:EE_ X-MS-Office365-Filtering-Correlation-Id: 525de34a-ab22-4479-cc1a-08de58f4a7b7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|7416014|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?/6t6crvIBEBCf5wmW9gHfe+wuhHsgtrfas6ZeJc/rrWLFATXK79PasTLHDb/?= =?us-ascii?Q?juX5YaA18Q+y07Ydeuukl0DD8rykphnzzIkMRIvHJySheclhVjbZKyWMTwUa?= =?us-ascii?Q?Q2hIgIiKYrjbp49iClCtx4W1oYppEn1wIvyie28tjVtrOg/I2IAnJB5K6wtZ?= =?us-ascii?Q?QFuWBUtJLDhfw45LhVitITTqpY+zB3nH+TdQ0Nar0ugKTZkJ3IaF4rUsemZ1?= =?us-ascii?Q?6iGPx98cb4mb0l2zHwUI1HgdoRELTC8EelB83NTZlkkhe9KpXXJf5u9cVPoD?= =?us-ascii?Q?B70Bnh0hq5WGvjDIjRdxEY/OO+amQc9sLFHeh2NEWgvZDmXU0AHOq3673p5w?= =?us-ascii?Q?HgOl+7AZ0JDGAGlslRjvZY62ltxkKZcYl7PtnNSkCQKL567cjqWFyFzDI8Rn?= =?us-ascii?Q?Y3/mjqkQ74qM/BDXiH1+l4SwsdAU6b3ElhKLzI00bp09imz/kvx9ugSvN5ty?= =?us-ascii?Q?Xnw8hsAAevY44UfNayutcGvZWzQjMlVwSva9uz4WtdyEAq4HR7QPDhRYG3wt?= =?us-ascii?Q?H1owlOWOtE40yqTSjLYo8qWHqdBqIoR1nQzC2ZhZYjm39HXrDRIswTV2ykdv?= =?us-ascii?Q?Pkuhnc/Mhp1P5XLIcM1qPy3uzHlik9hMKXQhB5liM0VQmYf5C5g5/Sf/ms53?= =?us-ascii?Q?UOOGmxneZNDt8kRbmoMKAwubmTHBilLCVBhoFLevQCLVgUgO7df95VmkKTw5?= =?us-ascii?Q?RWU9WwxVt+LLgAB+lkS3C4hC7dgxsRPVwCPyZ049t6KzxbHyyHhP0S/rH20+?= =?us-ascii?Q?IoL4TQDAXiAU8VSn5+n6qOSNs6WSoL+DSQMj4V8FXOJDsD5yg5YPrbDwK1CF?= =?us-ascii?Q?mraQ2O2jnmuLJ4yUtaINBMfXGbrmCqVaIWQEi1nh6hoQ0lClQQoAcEEtvXMj?= =?us-ascii?Q?gpLpPm3FrRxRt6o+Go8rFEpH5GIOwK7+6Ab5Ek0H3aPO3JfACSDEJea02oXa?= =?us-ascii?Q?kCENIsTPXh0SgcN+moKwpVnCAJyuiDJpoFVgy6ixiwTgI74pzttG0XuvGAds?= =?us-ascii?Q?hFmssIW7bxbrXYd1nyn2hUxn+tbc5wuNh9ADrt6L8kFmf/uZaHvFEjF/n9iC?= =?us-ascii?Q?qoypVDsA//7E1nEtYSWZLJMRl4/UbNg3kirlW3nLKLxDLKN++LWH5gGp4vVi?= =?us-ascii?Q?JMR92zV9VZbD+NThpvXBWU0PdjekyE3uFhu5p6CjpR/eP0huTbHZwSJCGV+0?= =?us-ascii?Q?7nc/GcAH5hIYf8vypNJBOU1/GDu7w6QN7DTF4jKWN44PFY8ctLIbrLgbcFSC?= =?us-ascii?Q?WZxcmJCXLBZBh1OoTHaqp0ilzHxj+uG5FvY1UALGzMXvU5ZCJpfj07zwXcL6?= =?us-ascii?Q?myK1ntsapM8JPblXQ+NpD4V+Iw+vOEsmBtuziC71hXE8hEDuhIpPL+eBUASz?= =?us-ascii?Q?kdW2b61R4AW/yBbYMnQzs2Ct9r5VFwNP4tqfYXeKe44xanvTlMUzk7pOVID2?= =?us-ascii?Q?ILvE9XrG6bYj/NB0c2mlE0MoK+UeT9e3nmSpyFTR1vlzGgAdJM8i12euF8nY?= =?us-ascii?Q?PXX+yWHM/ypCzjwGppgYYxuU4oGWVltnFO6404xbtvUrVrIx/AoPwTeuh7UR?= =?us-ascii?Q?637UVCaQh4ae1Em9kAauNzYp9VY/gUI5YErMLi7MfboIHHbJpKqrGtZrCvA0?= =?us-ascii?Q?C3b4eogccFnRmIOvN6PQvVPJxWt5rzbiHeAJK3pKi3tE?= X-Forefront-Antispam-Report: CIP:198.47.21.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet201.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(7416014)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2026 13:54:54.1522 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 525de34a-ab22-4479-cc1a-08de58f4a7b7 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.195];Helo=[flwvzet201.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF000015C7.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR10MB6657 Content-Type: text/plain; charset="utf-8" From: Jai Luthra The TI CSI2RX wrapper has two parts: the main device and the DMA contexts. The driver was originally written with single camera capture in mind, so only one DMA context was needed. For the sake of simplicity, the context specific stuff was not modeled different to the main device. To enable multiplexed stream capture, the contexts need to be separated out from the main device. Create a struct ti_csi2rx_ctx that holds the DMA context specific things. Separate out functions handling the device and context related functionality. Reviewed-by: Yemike Abhilash Chandra Reviewed-by: Tomi Valkeinen Co-developed-by: Pratyush Yadav Signed-off-by: Pratyush Yadav Signed-off-by: Jai Luthra Signed-off-by: Rishikesh Donadkar --- .../platform/ti/j721e-csi2rx/j721e-csi2rx.c | 423 ++++++++++-------- 1 file changed, 234 insertions(+), 189 deletions(-) diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/driver= s/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c index 710d05a053539..23717a3b6c4cf 100644 --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c @@ -43,6 +43,8 @@ #define SHIM_PSI_CFG0_DST_TAG GENMASK(31, 16) =20 #define TI_CSI2RX_MAX_PIX_PER_CLK 4 +#define TI_CSI2RX_NUM_CTX 1 + /* * There are no hard limits on the width or height. The DMA engine can han= dle * all sizes. The max width and height are arbitrary numbers for this driv= er. @@ -69,7 +71,7 @@ struct ti_csi2rx_buffer { /* Common v4l2 buffer. Must be first. */ struct vb2_v4l2_buffer vb; struct list_head list; - struct ti_csi2rx_dev *csi; + struct ti_csi2rx_ctx *ctx; }; =20 enum ti_csi2rx_dma_state { @@ -89,30 +91,38 @@ struct ti_csi2rx_dma { * Queue of buffers submitted to DMA engine. */ struct list_head submitted; - /* Buffer to drain stale data from PSI-L endpoint */ - struct { - void *vaddr; - dma_addr_t paddr; - size_t len; - } drain; +}; + +struct ti_csi2rx_dev; + +struct ti_csi2rx_ctx { + struct ti_csi2rx_dev *csi; + struct video_device vdev; + struct vb2_queue vidq; + struct mutex mutex; /* To serialize ioctls. */ + struct v4l2_format v_fmt; + struct ti_csi2rx_dma dma; + u32 sequence; + u32 idx; }; =20 struct ti_csi2rx_dev { struct device *dev; void __iomem *shim; struct v4l2_device v4l2_dev; - struct video_device vdev; struct media_device mdev; struct media_pipeline pipe; struct media_pad pad; struct v4l2_async_notifier notifier; struct v4l2_subdev *source; - struct vb2_queue vidq; - struct mutex mutex; /* To serialize ioctls. */ - struct v4l2_format v_fmt; - struct ti_csi2rx_dma dma; - u32 sequence; + struct ti_csi2rx_ctx ctx[TI_CSI2RX_NUM_CTX]; u8 pix_per_clk; + /* Buffer to drain stale data from PSI-L endpoint */ + struct { + void *vaddr; + dma_addr_t paddr; + size_t len; + } drain; }; =20 static const struct ti_csi2rx_fmt ti_csi2rx_formats[] =3D { @@ -218,7 +228,7 @@ static const struct ti_csi2rx_fmt ti_csi2rx_formats[] = =3D { }; =20 /* Forward declaration needed by ti_csi2rx_dma_callback. */ -static int ti_csi2rx_start_dma(struct ti_csi2rx_dev *csi, +static int ti_csi2rx_start_dma(struct ti_csi2rx_ctx *ctx, struct ti_csi2rx_buffer *buf); =20 static const struct ti_csi2rx_fmt *find_format_by_fourcc(u32 pixelformat) @@ -301,7 +311,7 @@ static int ti_csi2rx_enum_fmt_vid_cap(struct file *file= , void *priv, static int ti_csi2rx_g_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) { - struct ti_csi2rx_dev *csi =3D video_drvdata(file); + struct ti_csi2rx_ctx *csi =3D video_drvdata(file); =20 *f =3D csi->v_fmt; =20 @@ -332,7 +342,7 @@ static int ti_csi2rx_try_fmt_vid_cap(struct file *file,= void *priv, static int ti_csi2rx_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) { - struct ti_csi2rx_dev *csi =3D video_drvdata(file); + struct ti_csi2rx_ctx *csi =3D video_drvdata(file); struct vb2_queue *q =3D &csi->vidq; int ret; =20 @@ -410,26 +420,35 @@ static int csi_async_notifier_bound(struct v4l2_async= _notifier *notifier, static int csi_async_notifier_complete(struct v4l2_async_notifier *notifie= r) { struct ti_csi2rx_dev *csi =3D dev_get_drvdata(notifier->v4l2_dev->dev); - struct video_device *vdev =3D &csi->vdev; - int ret; + int ret, i; =20 - ret =3D video_register_device(vdev, VFL_TYPE_VIDEO, -1); - if (ret) - return ret; - - ret =3D media_create_pad_link(&csi->source->entity, CSI2RX_BRIDGE_SOURCE_= PAD, - &vdev->entity, csi->pad.index, - MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED); + for (i =3D 0; i < TI_CSI2RX_NUM_CTX; i++) { + struct ti_csi2rx_ctx *ctx =3D &csi->ctx[i]; + struct video_device *vdev =3D &ctx->vdev; =20 - if (ret) { - video_unregister_device(vdev); - return ret; + ret =3D video_register_device(vdev, VFL_TYPE_VIDEO, -1); + if (ret) + goto unregister_dev; } =20 + ret =3D media_create_pad_link(&csi->source->entity, + CSI2RX_BRIDGE_SOURCE_PAD, + &csi->ctx[0].vdev.entity, csi->pad.index, + MEDIA_LNK_FL_IMMUTABLE | + MEDIA_LNK_FL_ENABLED); + if (ret) + goto unregister_dev; + ret =3D v4l2_device_register_subdev_nodes(&csi->v4l2_dev); if (ret) - video_unregister_device(vdev); + goto unregister_dev; =20 + return 0; + +unregister_dev: + i--; + for (; i >=3D 0; i--) + video_unregister_device(&csi->ctx[i].vdev); return ret; } =20 @@ -474,13 +493,14 @@ static int ti_csi2rx_notifier_register(struct ti_csi2= rx_dev *csi) } =20 /* Request maximum possible pixels per clock from the bridge */ -static void ti_csi2rx_request_max_ppc(struct ti_csi2rx_dev *csi) +static void ti_csi2rx_request_max_ppc(struct ti_csi2rx_ctx *ctx) { + struct ti_csi2rx_dev *csi =3D ctx->csi; u8 ppc =3D TI_CSI2RX_MAX_PIX_PER_CLK; struct media_pad *pad; int ret; =20 - pad =3D media_entity_remote_source_pad_unique(&csi->vdev.entity); + pad =3D media_entity_remote_source_pad_unique(&ctx->vdev.entity); if (IS_ERR(pad)) return; =20 @@ -493,19 +513,20 @@ static void ti_csi2rx_request_max_ppc(struct ti_csi2r= x_dev *csi) } } =20 -static void ti_csi2rx_setup_shim(struct ti_csi2rx_dev *csi) +static void ti_csi2rx_setup_shim(struct ti_csi2rx_ctx *ctx) { + struct ti_csi2rx_dev *csi =3D ctx->csi; const struct ti_csi2rx_fmt *fmt; unsigned int reg; =20 - fmt =3D find_format_by_fourcc(csi->v_fmt.fmt.pix.pixelformat); + fmt =3D find_format_by_fourcc(ctx->v_fmt.fmt.pix.pixelformat); =20 /* De-assert the pixel interface reset. */ reg =3D SHIM_CNTL_PIX_RST; writel(reg, csi->shim + SHIM_CNTL); =20 /* Negotiate pixel count from the source */ - ti_csi2rx_request_max_ppc(csi); + ti_csi2rx_request_max_ppc(ctx); =20 reg =3D SHIM_DMACNTX_EN; reg |=3D FIELD_PREP(SHIM_DMACNTX_FMT, fmt->csi_dt); @@ -572,8 +593,9 @@ static void ti_csi2rx_drain_callback(void *param) * To prevent that stale data corrupting the subsequent transactions, it is * required to issue DMA requests to drain it out. */ -static int ti_csi2rx_drain_dma(struct ti_csi2rx_dev *csi) +static int ti_csi2rx_drain_dma(struct ti_csi2rx_ctx *ctx) { + struct ti_csi2rx_dev *csi =3D ctx->csi; struct dma_async_tx_descriptor *desc; struct completion drain_complete; dma_cookie_t cookie; @@ -581,8 +603,8 @@ static int ti_csi2rx_drain_dma(struct ti_csi2rx_dev *cs= i) =20 init_completion(&drain_complete); =20 - desc =3D dmaengine_prep_slave_single(csi->dma.chan, csi->dma.drain.paddr, - csi->dma.drain.len, DMA_DEV_TO_MEM, + desc =3D dmaengine_prep_slave_single(ctx->dma.chan, csi->drain.paddr, + csi->drain.len, DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); if (!desc) { ret =3D -EIO; @@ -597,11 +619,11 @@ static int ti_csi2rx_drain_dma(struct ti_csi2rx_dev *= csi) if (ret) goto out; =20 - dma_async_issue_pending(csi->dma.chan); + dma_async_issue_pending(ctx->dma.chan); =20 if (!wait_for_completion_timeout(&drain_complete, msecs_to_jiffies(DRAIN_TIMEOUT_MS))) { - dmaengine_terminate_sync(csi->dma.chan); + dmaengine_terminate_sync(ctx->dma.chan); dev_dbg(csi->dev, "DMA transfer timed out for drain buffer\n"); ret =3D -ETIMEDOUT; goto out; @@ -613,8 +635,9 @@ static int ti_csi2rx_drain_dma(struct ti_csi2rx_dev *cs= i) static void ti_csi2rx_dma_callback(void *param) { struct ti_csi2rx_buffer *buf =3D param; - struct ti_csi2rx_dev *csi =3D buf->csi; - struct ti_csi2rx_dma *dma =3D &csi->dma; + struct ti_csi2rx_ctx *ctx =3D buf->ctx; + struct ti_csi2rx_dev *csi =3D ctx->csi; + struct ti_csi2rx_dma *dma =3D &ctx->dma; unsigned long flags; =20 /* @@ -622,7 +645,7 @@ static void ti_csi2rx_dma_callback(void *param) * hardware monitor registers. */ buf->vb.vb2_buf.timestamp =3D ktime_get_ns(); - buf->vb.sequence =3D csi->sequence++; + buf->vb.sequence =3D ctx->sequence++; =20 spin_lock_irqsave(&dma->lock, flags); =20 @@ -634,7 +657,7 @@ static void ti_csi2rx_dma_callback(void *param) while (!list_empty(&dma->queue)) { buf =3D list_entry(dma->queue.next, struct ti_csi2rx_buffer, list); =20 - if (ti_csi2rx_start_dma(csi, buf)) { + if (ti_csi2rx_start_dma(ctx, buf)) { dev_err(csi->dev, "Failed to queue the next buffer for DMA\n"); list_del(&buf->list); vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); @@ -649,17 +672,17 @@ static void ti_csi2rx_dma_callback(void *param) spin_unlock_irqrestore(&dma->lock, flags); } =20 -static int ti_csi2rx_start_dma(struct ti_csi2rx_dev *csi, +static int ti_csi2rx_start_dma(struct ti_csi2rx_ctx *ctx, struct ti_csi2rx_buffer *buf) { unsigned long addr; struct dma_async_tx_descriptor *desc; - size_t len =3D csi->v_fmt.fmt.pix.sizeimage; + size_t len =3D ctx->v_fmt.fmt.pix.sizeimage; dma_cookie_t cookie; int ret =3D 0; =20 addr =3D vb2_dma_contig_plane_dma_addr(&buf->vb.vb2_buf, 0); - desc =3D dmaengine_prep_slave_single(csi->dma.chan, addr, len, + desc =3D dmaengine_prep_slave_single(ctx->dma.chan, addr, len, DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); if (!desc) @@ -673,20 +696,20 @@ static int ti_csi2rx_start_dma(struct ti_csi2rx_dev *= csi, if (ret) return ret; =20 - dma_async_issue_pending(csi->dma.chan); + dma_async_issue_pending(ctx->dma.chan); =20 return 0; } =20 -static void ti_csi2rx_stop_dma(struct ti_csi2rx_dev *csi) +static void ti_csi2rx_stop_dma(struct ti_csi2rx_ctx *ctx) { - struct ti_csi2rx_dma *dma =3D &csi->dma; + struct ti_csi2rx_dma *dma =3D &ctx->dma; enum ti_csi2rx_dma_state state; unsigned long flags; int ret; =20 spin_lock_irqsave(&dma->lock, flags); - state =3D csi->dma.state; + state =3D ctx->dma.state; dma->state =3D TI_CSI2RX_DMA_STOPPED; spin_unlock_irqrestore(&dma->lock, flags); =20 @@ -697,30 +720,30 @@ static void ti_csi2rx_stop_dma(struct ti_csi2rx_dev *= csi) * is stopped, as the module-level pixel reset cannot be * enforced before terminating DMA. */ - ret =3D ti_csi2rx_drain_dma(csi); + ret =3D ti_csi2rx_drain_dma(ctx); if (ret && ret !=3D -ETIMEDOUT) - dev_warn(csi->dev, + dev_warn(ctx->csi->dev, "Failed to drain DMA. Next frame might be bogus\n"); } =20 - ret =3D dmaengine_terminate_sync(csi->dma.chan); + ret =3D dmaengine_terminate_sync(ctx->dma.chan); if (ret) - dev_err(csi->dev, "Failed to stop DMA: %d\n", ret); + dev_err(ctx->csi->dev, "Failed to stop DMA: %d\n", ret); } =20 -static void ti_csi2rx_cleanup_buffers(struct ti_csi2rx_dev *csi, +static void ti_csi2rx_cleanup_buffers(struct ti_csi2rx_ctx *ctx, enum vb2_buffer_state state) { - struct ti_csi2rx_dma *dma =3D &csi->dma; + struct ti_csi2rx_dma *dma =3D &ctx->dma; struct ti_csi2rx_buffer *buf, *tmp; unsigned long flags; =20 spin_lock_irqsave(&dma->lock, flags); - list_for_each_entry_safe(buf, tmp, &csi->dma.queue, list) { + list_for_each_entry_safe(buf, tmp, &ctx->dma.queue, list) { list_del(&buf->list); vb2_buffer_done(&buf->vb.vb2_buf, state); } - list_for_each_entry_safe(buf, tmp, &csi->dma.submitted, list) { + list_for_each_entry_safe(buf, tmp, &ctx->dma.submitted, list) { list_del(&buf->list); vb2_buffer_done(&buf->vb.vb2_buf, state); } @@ -731,8 +754,8 @@ static int ti_csi2rx_queue_setup(struct vb2_queue *q, u= nsigned int *nbuffers, unsigned int *nplanes, unsigned int sizes[], struct device *alloc_devs[]) { - struct ti_csi2rx_dev *csi =3D vb2_get_drv_priv(q); - unsigned int size =3D csi->v_fmt.fmt.pix.sizeimage; + struct ti_csi2rx_ctx *ctx =3D vb2_get_drv_priv(q); + unsigned int size =3D ctx->v_fmt.fmt.pix.sizeimage; =20 if (*nplanes) { if (sizes[0] < size) @@ -748,11 +771,11 @@ static int ti_csi2rx_queue_setup(struct vb2_queue *q,= unsigned int *nbuffers, =20 static int ti_csi2rx_buffer_prepare(struct vb2_buffer *vb) { - struct ti_csi2rx_dev *csi =3D vb2_get_drv_priv(vb->vb2_queue); - unsigned long size =3D csi->v_fmt.fmt.pix.sizeimage; + struct ti_csi2rx_ctx *ctx =3D vb2_get_drv_priv(vb->vb2_queue); + unsigned long size =3D ctx->v_fmt.fmt.pix.sizeimage; =20 if (vb2_plane_size(vb, 0) < size) { - dev_err(csi->dev, "Data will not fit into plane\n"); + dev_err(ctx->csi->dev, "Data will not fit into plane\n"); return -EINVAL; } =20 @@ -762,15 +785,15 @@ static int ti_csi2rx_buffer_prepare(struct vb2_buffer= *vb) =20 static void ti_csi2rx_buffer_queue(struct vb2_buffer *vb) { - struct ti_csi2rx_dev *csi =3D vb2_get_drv_priv(vb->vb2_queue); + struct ti_csi2rx_ctx *ctx =3D vb2_get_drv_priv(vb->vb2_queue); struct ti_csi2rx_buffer *buf; - struct ti_csi2rx_dma *dma =3D &csi->dma; + struct ti_csi2rx_dma *dma =3D &ctx->dma; bool restart_dma =3D false; unsigned long flags =3D 0; int ret; =20 buf =3D container_of(vb, struct ti_csi2rx_buffer, vb.vb2_buf); - buf->csi =3D csi; + buf->ctx =3D ctx; =20 spin_lock_irqsave(&dma->lock, flags); /* @@ -799,18 +822,18 @@ static void ti_csi2rx_buffer_queue(struct vb2_buffer = *vb) * the application and will only confuse it. Issue a DMA * transaction to drain that up. */ - ret =3D ti_csi2rx_drain_dma(csi); + ret =3D ti_csi2rx_drain_dma(ctx); if (ret && ret !=3D -ETIMEDOUT) - dev_warn(csi->dev, + dev_warn(ctx->csi->dev, "Failed to drain DMA. Next frame might be bogus\n"); =20 spin_lock_irqsave(&dma->lock, flags); - ret =3D ti_csi2rx_start_dma(csi, buf); + ret =3D ti_csi2rx_start_dma(ctx, buf); if (ret) { vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); dma->state =3D TI_CSI2RX_DMA_IDLE; spin_unlock_irqrestore(&dma->lock, flags); - dev_err(csi->dev, "Failed to start DMA: %d\n", ret); + dev_err(ctx->csi->dev, "Failed to start DMA: %d\n", ret); } else { list_add_tail(&buf->list, &dma->submitted); spin_unlock_irqrestore(&dma->lock, flags); @@ -820,8 +843,9 @@ static void ti_csi2rx_buffer_queue(struct vb2_buffer *v= b) =20 static int ti_csi2rx_start_streaming(struct vb2_queue *vq, unsigned int co= unt) { - struct ti_csi2rx_dev *csi =3D vb2_get_drv_priv(vq); - struct ti_csi2rx_dma *dma =3D &csi->dma; + struct ti_csi2rx_ctx *ctx =3D vb2_get_drv_priv(vq); + struct ti_csi2rx_dev *csi =3D ctx->csi; + struct ti_csi2rx_dma *dma =3D &ctx->dma; struct ti_csi2rx_buffer *buf; unsigned long flags; int ret =3D 0; @@ -833,18 +857,18 @@ static int ti_csi2rx_start_streaming(struct vb2_queue= *vq, unsigned int count) if (ret) return ret; =20 - ret =3D video_device_pipeline_start(&csi->vdev, &csi->pipe); + ret =3D video_device_pipeline_start(&ctx->vdev, &csi->pipe); if (ret) goto err; =20 - ti_csi2rx_setup_shim(csi); + ti_csi2rx_setup_shim(ctx); =20 - csi->sequence =3D 0; + ctx->sequence =3D 0; =20 spin_lock_irqsave(&dma->lock, flags); buf =3D list_entry(dma->queue.next, struct ti_csi2rx_buffer, list); =20 - ret =3D ti_csi2rx_start_dma(csi, buf); + ret =3D ti_csi2rx_start_dma(ctx, buf); if (ret) { dev_err(csi->dev, "Failed to start DMA: %d\n", ret); spin_unlock_irqrestore(&dma->lock, flags); @@ -862,22 +886,23 @@ static int ti_csi2rx_start_streaming(struct vb2_queue= *vq, unsigned int count) return 0; =20 err_dma: - ti_csi2rx_stop_dma(csi); + ti_csi2rx_stop_dma(ctx); err_pipeline: - video_device_pipeline_stop(&csi->vdev); + video_device_pipeline_stop(&ctx->vdev); writel(0, csi->shim + SHIM_CNTL); writel(0, csi->shim + SHIM_DMACNTX); err: - ti_csi2rx_cleanup_buffers(csi, VB2_BUF_STATE_QUEUED); + ti_csi2rx_cleanup_buffers(ctx, VB2_BUF_STATE_QUEUED); return ret; } =20 static void ti_csi2rx_stop_streaming(struct vb2_queue *vq) { - struct ti_csi2rx_dev *csi =3D vb2_get_drv_priv(vq); + struct ti_csi2rx_ctx *ctx =3D vb2_get_drv_priv(vq); + struct ti_csi2rx_dev *csi =3D ctx->csi; int ret; =20 - video_device_pipeline_stop(&csi->vdev); + video_device_pipeline_stop(&ctx->vdev); =20 writel(0, csi->shim + SHIM_CNTL); writel(0, csi->shim + SHIM_DMACNTX); @@ -886,8 +911,8 @@ static void ti_csi2rx_stop_streaming(struct vb2_queue *= vq) if (ret) dev_err(csi->dev, "Failed to stop subdev stream\n"); =20 - ti_csi2rx_stop_dma(csi); - ti_csi2rx_cleanup_buffers(csi, VB2_BUF_STATE_ERROR); + ti_csi2rx_stop_dma(ctx); + ti_csi2rx_cleanup_buffers(ctx, VB2_BUF_STATE_ERROR); } =20 static const struct vb2_ops csi_vb2_qops =3D { @@ -898,20 +923,43 @@ static const struct vb2_ops csi_vb2_qops =3D { .stop_streaming =3D ti_csi2rx_stop_streaming, }; =20 -static int ti_csi2rx_init_vb2q(struct ti_csi2rx_dev *csi) +static void ti_csi2rx_cleanup_v4l2(struct ti_csi2rx_dev *csi) { - struct vb2_queue *q =3D &csi->vidq; + media_device_unregister(&csi->mdev); + v4l2_device_unregister(&csi->v4l2_dev); + media_device_cleanup(&csi->mdev); +} + +static void ti_csi2rx_cleanup_notifier(struct ti_csi2rx_dev *csi) +{ + v4l2_async_nf_unregister(&csi->notifier); + v4l2_async_nf_cleanup(&csi->notifier); +} + +static void ti_csi2rx_cleanup_ctx(struct ti_csi2rx_ctx *ctx) +{ + dma_release_channel(ctx->dma.chan); + vb2_queue_release(&ctx->vidq); + + video_unregister_device(&ctx->vdev); + + mutex_destroy(&ctx->mutex); +} + +static int ti_csi2rx_init_vb2q(struct ti_csi2rx_ctx *ctx) +{ + struct vb2_queue *q =3D &ctx->vidq; int ret; =20 q->type =3D V4L2_BUF_TYPE_VIDEO_CAPTURE; q->io_modes =3D VB2_MMAP | VB2_DMABUF; - q->drv_priv =3D csi; + q->drv_priv =3D ctx; q->buf_struct_size =3D sizeof(struct ti_csi2rx_buffer); q->ops =3D &csi_vb2_qops; q->mem_ops =3D &vb2_dma_contig_memops; q->timestamp_flags =3D V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; - q->dev =3D dmaengine_get_dma_device(csi->dma.chan); - q->lock =3D &csi->mutex; + q->dev =3D dmaengine_get_dma_device(ctx->dma.chan); + q->lock =3D &ctx->mutex; q->min_queued_buffers =3D 1; q->allow_cache_hints =3D 1; =20 @@ -919,7 +967,7 @@ static int ti_csi2rx_init_vb2q(struct ti_csi2rx_dev *cs= i) if (ret) return ret; =20 - csi->vdev.queue =3D q; + ctx->vdev.queue =3D q; =20 return 0; } @@ -928,8 +976,9 @@ static int ti_csi2rx_link_validate(struct media_link *l= ink) { struct media_entity *entity =3D link->sink->entity; struct video_device *vdev =3D media_entity_to_video_device(entity); - struct ti_csi2rx_dev *csi =3D container_of(vdev, struct ti_csi2rx_dev, vd= ev); - struct v4l2_pix_format *csi_fmt =3D &csi->v_fmt.fmt.pix; + struct ti_csi2rx_ctx *ctx =3D container_of(vdev, struct ti_csi2rx_ctx, vd= ev); + struct ti_csi2rx_dev *csi =3D ctx->csi; + struct v4l2_pix_format *csi_fmt =3D &ctx->v_fmt.fmt.pix; struct v4l2_subdev_format source_fmt =3D { .which =3D V4L2_SUBDEV_FORMAT_ACTIVE, .pad =3D link->source->index, @@ -982,47 +1031,63 @@ static const struct media_entity_operations ti_csi2r= x_video_entity_ops =3D { .link_validate =3D ti_csi2rx_link_validate, }; =20 -static int ti_csi2rx_init_dma(struct ti_csi2rx_dev *csi) +static int ti_csi2rx_init_dma(struct ti_csi2rx_ctx *ctx) { struct dma_slave_config cfg =3D { .src_addr_width =3D DMA_SLAVE_BUSWIDTH_16_BYTES, }; int ret; =20 - INIT_LIST_HEAD(&csi->dma.queue); - INIT_LIST_HEAD(&csi->dma.submitted); - spin_lock_init(&csi->dma.lock); - - csi->dma.state =3D TI_CSI2RX_DMA_STOPPED; + ctx->dma.chan =3D dma_request_chan(ctx->csi->dev, "rx0"); + if (IS_ERR(ctx->dma.chan)) + return PTR_ERR(ctx->dma.chan); =20 - csi->dma.chan =3D dma_request_chan(csi->dev, "rx0"); - if (IS_ERR(csi->dma.chan)) - return PTR_ERR(csi->dma.chan); - - ret =3D dmaengine_slave_config(csi->dma.chan, &cfg); + ret =3D dmaengine_slave_config(ctx->dma.chan, &cfg); if (ret) { - dma_release_channel(csi->dma.chan); + dma_release_channel(ctx->dma.chan); return ret; } =20 - csi->dma.drain.len =3D DRAIN_BUFFER_SIZE; - csi->dma.drain.vaddr =3D dma_alloc_coherent(csi->dev, csi->dma.drain.len, - &csi->dma.drain.paddr, - GFP_KERNEL); - if (!csi->dma.drain.vaddr) - return -ENOMEM; - return 0; } =20 static int ti_csi2rx_v4l2_init(struct ti_csi2rx_dev *csi) { struct media_device *mdev =3D &csi->mdev; - struct video_device *vdev =3D &csi->vdev; + int ret; + + mdev->dev =3D csi->dev; + mdev->hw_revision =3D 1; + strscpy(mdev->model, "TI-CSI2RX", sizeof(mdev->model)); + + media_device_init(mdev); + + csi->v4l2_dev.mdev =3D mdev; + + ret =3D v4l2_device_register(csi->dev, &csi->v4l2_dev); + if (ret) + return ret; + + ret =3D media_device_register(mdev); + if (ret) { + v4l2_device_unregister(&csi->v4l2_dev); + media_device_cleanup(mdev); + return ret; + } + + return 0; +} + +static int ti_csi2rx_init_ctx(struct ti_csi2rx_ctx *ctx) +{ + struct ti_csi2rx_dev *csi =3D ctx->csi; + struct video_device *vdev =3D &ctx->vdev; const struct ti_csi2rx_fmt *fmt; - struct v4l2_pix_format *pix_fmt =3D &csi->v_fmt.fmt.pix; + struct v4l2_pix_format *pix_fmt =3D &ctx->v_fmt.fmt.pix; int ret; =20 + mutex_init(&ctx->mutex); + fmt =3D find_format_by_fourcc(V4L2_PIX_FMT_UYVY); if (!fmt) return -EINVAL; @@ -1031,19 +1096,20 @@ static int ti_csi2rx_v4l2_init(struct ti_csi2rx_dev= *csi) pix_fmt->height =3D 480; pix_fmt->field =3D V4L2_FIELD_NONE; pix_fmt->colorspace =3D V4L2_COLORSPACE_SRGB; - pix_fmt->ycbcr_enc =3D V4L2_YCBCR_ENC_601; - pix_fmt->quantization =3D V4L2_QUANTIZATION_LIM_RANGE; - pix_fmt->xfer_func =3D V4L2_XFER_FUNC_SRGB; - - ti_csi2rx_fill_fmt(fmt, &csi->v_fmt); + pix_fmt->ycbcr_enc =3D V4L2_YCBCR_ENC_601, + pix_fmt->quantization =3D V4L2_QUANTIZATION_LIM_RANGE, + pix_fmt->xfer_func =3D V4L2_XFER_FUNC_SRGB, =20 - mdev->dev =3D csi->dev; - mdev->hw_revision =3D 1; - strscpy(mdev->model, "TI-CSI2RX", sizeof(mdev->model)); + ti_csi2rx_fill_fmt(fmt, &ctx->v_fmt); =20 - media_device_init(mdev); + csi->pad.flags =3D MEDIA_PAD_FL_SINK; + vdev->entity.ops =3D &ti_csi2rx_video_entity_ops; + ret =3D media_entity_pads_init(&ctx->vdev.entity, 1, &csi->pad); + if (ret) + return ret; =20 - strscpy(vdev->name, TI_CSI2RX_MODULE_NAME, sizeof(vdev->name)); + snprintf(vdev->name, sizeof(vdev->name), "%s context %u", + dev_name(csi->dev), ctx->idx); vdev->v4l2_dev =3D &csi->v4l2_dev; vdev->vfl_dir =3D VFL_DIR_RX; vdev->fops =3D &csi_fops; @@ -1051,61 +1117,33 @@ static int ti_csi2rx_v4l2_init(struct ti_csi2rx_dev= *csi) vdev->release =3D video_device_release_empty; vdev->device_caps =3D V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | V4L2_CAP_IO_MC; - vdev->lock =3D &csi->mutex; - video_set_drvdata(vdev, csi); - - csi->pad.flags =3D MEDIA_PAD_FL_SINK; - vdev->entity.ops =3D &ti_csi2rx_video_entity_ops; - ret =3D media_entity_pads_init(&csi->vdev.entity, 1, &csi->pad); - if (ret) - return ret; + vdev->lock =3D &ctx->mutex; + video_set_drvdata(vdev, ctx); =20 - csi->v4l2_dev.mdev =3D mdev; + INIT_LIST_HEAD(&ctx->dma.queue); + INIT_LIST_HEAD(&ctx->dma.submitted); + spin_lock_init(&ctx->dma.lock); + ctx->dma.state =3D TI_CSI2RX_DMA_STOPPED; =20 - ret =3D v4l2_device_register(csi->dev, &csi->v4l2_dev); + ret =3D ti_csi2rx_init_dma(ctx); if (ret) return ret; =20 - ret =3D media_device_register(mdev); - if (ret) { - v4l2_device_unregister(&csi->v4l2_dev); - media_device_cleanup(mdev); - return ret; - } + ret =3D ti_csi2rx_init_vb2q(ctx); + if (ret) + goto cleanup_dma; =20 return 0; -} - -static void ti_csi2rx_cleanup_dma(struct ti_csi2rx_dev *csi) -{ - dma_free_coherent(csi->dev, csi->dma.drain.len, - csi->dma.drain.vaddr, csi->dma.drain.paddr); - csi->dma.drain.vaddr =3D NULL; - dma_release_channel(csi->dma.chan); -} - -static void ti_csi2rx_cleanup_v4l2(struct ti_csi2rx_dev *csi) -{ - media_device_unregister(&csi->mdev); - v4l2_device_unregister(&csi->v4l2_dev); - media_device_cleanup(&csi->mdev); -} =20 -static void ti_csi2rx_cleanup_subdev(struct ti_csi2rx_dev *csi) -{ - v4l2_async_nf_unregister(&csi->notifier); - v4l2_async_nf_cleanup(&csi->notifier); -} - -static void ti_csi2rx_cleanup_vb2q(struct ti_csi2rx_dev *csi) -{ - vb2_queue_release(&csi->vidq); +cleanup_dma: + dma_release_channel(ctx->dma.chan); + return ret; } =20 static int ti_csi2rx_probe(struct platform_device *pdev) { struct ti_csi2rx_dev *csi; - int ret; + int ret, i; =20 csi =3D devm_kzalloc(&pdev->dev, sizeof(*csi), GFP_KERNEL); if (!csi) @@ -1114,62 +1152,69 @@ static int ti_csi2rx_probe(struct platform_device *= pdev) csi->dev =3D &pdev->dev; platform_set_drvdata(pdev, csi); =20 - mutex_init(&csi->mutex); csi->shim =3D devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(csi->shim)) { ret =3D PTR_ERR(csi->shim); - goto err_mutex; + return ret; } =20 - ret =3D ti_csi2rx_init_dma(csi); - if (ret) - goto err_mutex; + csi->drain.len =3D DRAIN_BUFFER_SIZE; + csi->drain.vaddr =3D dma_alloc_coherent(csi->dev, csi->drain.len, + &csi->drain.paddr, + GFP_KERNEL); + if (!csi->drain.vaddr) + return -ENOMEM; =20 ret =3D ti_csi2rx_v4l2_init(csi); - if (ret) - goto err_dma; - - ret =3D ti_csi2rx_init_vb2q(csi); if (ret) goto err_v4l2; =20 + for (i =3D 0; i < TI_CSI2RX_NUM_CTX; i++) { + csi->ctx[i].idx =3D i; + csi->ctx[i].csi =3D csi; + ret =3D ti_csi2rx_init_ctx(&csi->ctx[i]); + if (ret) + goto err_ctx; + } + ret =3D ti_csi2rx_notifier_register(csi); if (ret) - goto err_vb2q; + goto err_ctx; =20 ret =3D devm_of_platform_populate(csi->dev); if (ret) { dev_err(csi->dev, "Failed to create children: %d\n", ret); - goto err_subdev; + goto err_notifier; } =20 return 0; =20 -err_subdev: - ti_csi2rx_cleanup_subdev(csi); -err_vb2q: - ti_csi2rx_cleanup_vb2q(csi); -err_v4l2: +err_notifier: + ti_csi2rx_cleanup_notifier(csi); +err_ctx: + i--; + for (; i >=3D 0; i--) + ti_csi2rx_cleanup_ctx(&csi->ctx[i]); ti_csi2rx_cleanup_v4l2(csi); -err_dma: - ti_csi2rx_cleanup_dma(csi); -err_mutex: - mutex_destroy(&csi->mutex); +err_v4l2: + dma_free_coherent(csi->dev, csi->drain.len, csi->drain.vaddr, + csi->drain.paddr); return ret; } =20 static void ti_csi2rx_remove(struct platform_device *pdev) { struct ti_csi2rx_dev *csi =3D platform_get_drvdata(pdev); + unsigned int i; =20 - video_unregister_device(&csi->vdev); + for (i =3D 0; i < TI_CSI2RX_NUM_CTX; i++) + ti_csi2rx_cleanup_ctx(&csi->ctx[i]); =20 - ti_csi2rx_cleanup_vb2q(csi); - ti_csi2rx_cleanup_subdev(csi); + ti_csi2rx_cleanup_notifier(csi); ti_csi2rx_cleanup_v4l2(csi); - ti_csi2rx_cleanup_dma(csi); =20 - mutex_destroy(&csi->mutex); + dma_free_coherent(csi->dev, csi->drain.len, csi->drain.vaddr, + csi->drain.paddr); } =20 static const struct of_device_id ti_csi2rx_of_match[] =3D { --=20 2.34.1 From nobody Sun Feb 8 21:47:54 2026 Received: from MW6PR02CU001.outbound.protection.outlook.com (mail-westus2azon11012015.outbound.protection.outlook.com [52.101.48.15]) (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 26C72492511; Wed, 21 Jan 2026 13:55:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.48.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003711; cv=fail; b=S/XbhuL1FO2Sdlowq9p6gxLstiSohdLJfSbVwaedaWViz5879len9C+K2YCjY2kTuTiHq/UEn3oGGoND/1NEJv98GAbIfGyKtvYo+2HI419WvLkGFM+JhzpmHxl//BBiNCUmTiqfFgPt6uhLzDNeQ9cmhiRZW2Y0F/bEU8Us3pw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003711; c=relaxed/simple; bh=2AzDDQ/c33gDTUejdZzmjwebk2IrQn3OwFoYgpL3lnQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=g9sIJH9N8V8FP+/+PeMMnyig/0zA3WJzV1aoyqHIOFEuXy0NZSqRbu/VRt3JrPgNnTRcPOKY7nudVF5+HpMuFvZP9dWPPAaO46NsoJLHf2SAfCuUhhcXhiHexzXVnW23DZE0R7cRNEHbiea1AgjHka8KcSoeZRE4H69GMWOjtZY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=da2CX6T0; arc=fail smtp.client-ip=52.101.48.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="da2CX6T0" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KqI1/JZpZOV2eMR1pRTzK7UiJtvFonrRsERRkoKJZHF4P9Dh7s3jlfXtgahbq+tVxVJ/sbz2EHulhjqnaTKuvxpCWZVXwyCj4W0/JLPeIQM6PH5gECo71B61zbc1l9skfBjZkmo0qPGBC2fvk+vjBY+ZpfMKB1Q8Grk8knyNRFn6K7K3XksfApDb6fEQK9GlLgE6Rl4SpkL6Zd4+eWdojHyy3nHwEAc3Wx5//ETSolbO/6xQmXi8LFESKjTniQW7SaxfHMtCi2Dd3xk3TTj9NM3W8DD5zsYFrEn6s670Vz33bGhGx3rOBQc+Qo9ve7U1WoKzYWU2O7Vo4Y7U4FJvnw== 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=m2uVnM4fJLG2Q8yNrNtcnhK4gAywDIJhuWg84A8RS4A=; b=lgy/Cq/RdMX/oaQE1xwFAtqOd+VMpJc8eleqwYwvCBgpNCfLmH147x7+iKuCVglGyQCc6ezqt9ea0h1/VBu2ZdAE+wbcshAlWQ33alNBcdY7FzityEZkjaneQY/nuTcs0i17qjKOU0pOQoHp1KMCxJ/tN4gCbBoiQPzF7TwounnjBSxy8hB+BzPXmYdPBtIhlANBdL8R3OqSJxvw4j5wFHzqn3gFFPb0vCFH+q5NtIOvMq/9GiRAEIXmuGnhMfIMciJT2+XnAl7CYf4w+my/Nkg/ruui6KY2tSxhPUlo83jtge1VnMFOQNMY+8UiEsABx6VKp1gBUgQW9UZC6VoLig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.194) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=m2uVnM4fJLG2Q8yNrNtcnhK4gAywDIJhuWg84A8RS4A=; b=da2CX6T09O/VBsWp/UCX2+pcpuE1KL5k+Wz4r/1WhgU1ZSz+dzOAdfhkoaJDFinBi+WZRe5pHfqL9kzX79jLkzqaEc8Wnxw2Up1VTx7fGPmNauQdAU8RiiT3HRXa1r1831cTUwCgC3SmnO82pTLjvErngXF+2qGKwOD5L1X6MN0= Received: from BYAPR07CA0074.namprd07.prod.outlook.com (2603:10b6:a03:12b::15) by CY5PR10MB6238.namprd10.prod.outlook.com (2603:10b6:930:42::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.9; Wed, 21 Jan 2026 13:55:03 +0000 Received: from CO1PEPF000044FB.namprd21.prod.outlook.com (2603:10b6:a03:12b:cafe::6) by BYAPR07CA0074.outlook.office365.com (2603:10b6:a03:12b::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9542.10 via Frontend Transport; Wed, 21 Jan 2026 13:55:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.194; helo=lewvzet200.ext.ti.com; pr=C Received: from lewvzet200.ext.ti.com (198.47.23.194) by CO1PEPF000044FB.mail.protection.outlook.com (10.167.241.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9564.0 via Frontend Transport; Wed, 21 Jan 2026 13:55:02 +0000 Received: from DLEE209.ent.ti.com (157.170.170.98) by lewvzet200.ext.ti.com (10.4.14.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:55:01 -0600 Received: from DLEE210.ent.ti.com (157.170.170.112) by DLEE209.ent.ti.com (157.170.170.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:55:01 -0600 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DLEE210.ent.ti.com (157.170.170.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend Transport; Wed, 21 Jan 2026 07:55:01 -0600 Received: from ws.dhcp.ti.com (ws.dhcp.ti.com [172.24.233.149]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 60LDsPIA3104105; Wed, 21 Jan 2026 07:54:53 -0600 From: Rishikesh Donadkar To: , , CC: , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 04/18] media: ti: j721e-csi2rx: prepare SHIM code for multiple contexts Date: Wed, 21 Jan 2026 19:24:10 +0530 Message-ID: <20260121135424.1185710-5-r-donadkar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260121135424.1185710-1-r-donadkar@ti.com> References: <20260121135424.1185710-1-r-donadkar@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044FB:EE_|CY5PR10MB6238:EE_ X-MS-Office365-Filtering-Correlation-Id: feb3f0ce-fa31-46fb-7cc4-08de58f4aca0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?lFIfM3vCyslVvGzeNwaOGdfWXvPLdcOz+Sm0FIxF/lZ/q1jAWexZpKciA/cV?= =?us-ascii?Q?FCkm/sHiWf6JfF0df+dX0f+bMajcxwMLrWc7eRMOhgUU7JgngMlJPMDOoHDA?= =?us-ascii?Q?KNr71YfK3U0AXOVykshyLi/97kL9s/EUqMrjOegdStx56/hPrh1Y6s0qtkKs?= =?us-ascii?Q?M+X1G/EmkSl7BGFcDJ0N58bmJNvETDU2QdXLce07iL4yIRwo4Jh6EmV5Om0p?= =?us-ascii?Q?ojmwRqnu1Pl7yqLKuYgOB98X1AvnperhKQgaQ8dpm1gghframYF9VgQXuKsz?= =?us-ascii?Q?nwpH9n6aBS70yssi+O008+vY9vOIBMlkVTTVEiOPWT5/9BRvAYzz9fDahu++?= =?us-ascii?Q?LQS26tDfsnHgzmoPFBfu76PUg+HNhUNRaGxGIZUFjaEsDB0oHePkhcJ++iwT?= =?us-ascii?Q?fYgbrPhYUcN2Wu1siDSZm6B/9KL/WX/080PnVbDLWVGkMXlZUw7e3Z3m7bPu?= =?us-ascii?Q?BVIvCQpUDC0TIcTvqmr8nk7WDR/oPPysPYN0j4d4ygGPtM2QGo+4edzjp82i?= =?us-ascii?Q?D5vu6VAiETpBDQkF+M+NMPc2z86kxkXICEDUZiZtACHQvr/CxAolJaQ4+hDa?= =?us-ascii?Q?8V2fpaTtkCgQypaA3XvqGQjFbwmi+qYi/AJUPyYLRgs6i4IbNxqy19kbpWJm?= =?us-ascii?Q?5nokYTHqLcxfGrOTTBv8fAwN/rSl3hwbaK5suY0owvNMlO1Z06fvODRffgFz?= =?us-ascii?Q?ggJz+517EGNKUNeYh/9HMNgJYNNj8I+YvnGYjAPcLBcMwkZvOWMUFQh6ITAq?= =?us-ascii?Q?1a3ryPEyWRwEkvR59g1FwGuYjIcUwvQ6pl2hq3nXqLMxZGxgJ3dgMLn7i0Un?= =?us-ascii?Q?epgdq5zlWvHSgqC71qoGtffz0zKxLMdYuZAJ94dai1E5Snz942fCJYR0kPPX?= =?us-ascii?Q?bFvBpI5MM3BGIJ3AfurJuGwckWu2k8HYcVe/1t7J3UDzsriefPDsKtpKMlge?= =?us-ascii?Q?w/Mdrpoe1EcoqZanWdnELaol7D+OdR2G3EISevD81wbDlqpddSrXvfPrNjva?= =?us-ascii?Q?BzSegwitAviWJef6+fmxKF5D+afcdV7yXNP91FbiZedKpf92yPn4C+Hn3g+A?= =?us-ascii?Q?fFlRByQwo5UY6zepNweayIoigZmPZsR8EoFCCwuEZ+gPsy6vd5e0o+0mblT5?= =?us-ascii?Q?eKsNXKgyux0dhJRnN8Ci/lAQS3inkPSgvRgXhPGTJXv1xGsyzx1GNc0aVZEx?= =?us-ascii?Q?V6NNxDzHoWWKAhlmveb/ErKc+aNz5HXflSLnlCs2qFPvcfJpVuw3UGj1/onP?= =?us-ascii?Q?3ey/SuMUwg5xEJRUubyMYQtj5Tlw+AgseTM0Qib/PM3nP1jVxYCdLAxgv/PL?= =?us-ascii?Q?1vShZrV2DvDYpSiIAGyBDUNTl0532dx16yl0QvXWaIP4EVXU6Hh3coYsNSnA?= =?us-ascii?Q?1AmFyOYOygmuKbjpuql5Jg4wn7LbdLkvIDnj+AwSO6tyR1zi1TfxJzi0rQEs?= =?us-ascii?Q?o/o/s7F85N2n3IXnDGfA1+ITCrKoYjO1YcnapET+R7tt/iuEyMLmftNSvJ8z?= =?us-ascii?Q?Muy2v45ont7Cj5xrSkTeQzdpfw9gCcS+zv92uGhCPPbZD7noPUDhsSCNNEVL?= =?us-ascii?Q?Y8vTuLL969SZ7Z++8rebsE70E0DIXlqlOYMtY+G+x3Ogi9Nh8JbkfGPAwv4c?= =?us-ascii?Q?9ltDRL/Mf8K4jNJn847hjwj16aR1GiB3wb5SOrXPo1t6Is2ZwIDxpyZz/jMG?= =?us-ascii?Q?ucbtLw=3D=3D?= X-Forefront-Antispam-Report: CIP:198.47.23.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet200.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2026 13:55:02.3381 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: feb3f0ce-fa31-46fb-7cc4-08de58f4aca0 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.194];Helo=[lewvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044FB.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR10MB6238 Content-Type: text/plain; charset="utf-8" From: Pratyush Yadav Currently the SHIM code to configure the context only touches the first context. Add support for writing to the context's registers based on the context index. Signed-off-by: Pratyush Yadav Signed-off-by: Jai Luthra Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Reviewed-by: Yemike Abhilash Chandra Reviewed-by: Tomi Valkeinen Signed-off-by: Rishikesh Donadkar --- .../media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/driver= s/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c index 23717a3b6c4cf..fdbe72df5c5f8 100644 --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c @@ -27,7 +27,7 @@ #define SHIM_CNTL 0x10 #define SHIM_CNTL_PIX_RST BIT(0) =20 -#define SHIM_DMACNTX 0x20 +#define SHIM_DMACNTX(i) (0x20 + ((i) * 0x20)) #define SHIM_DMACNTX_EN BIT(31) #define SHIM_DMACNTX_YUV422 GENMASK(27, 26) #define SHIM_DMACNTX_DUAL_PCK_CFG BIT(24) @@ -38,7 +38,7 @@ #define SHIM_DMACNTX_SIZE_16 1 #define SHIM_DMACNTX_SIZE_32 2 =20 -#define SHIM_PSI_CFG0 0x24 +#define SHIM_PSI_CFG0(i) (0x24 + ((i) * 0x20)) #define SHIM_PSI_CFG0_SRC_TAG GENMASK(15, 0) #define SHIM_PSI_CFG0_DST_TAG GENMASK(31, 16) =20 @@ -568,11 +568,13 @@ static void ti_csi2rx_setup_shim(struct ti_csi2rx_ctx= *ctx) break; } =20 - writel(reg, csi->shim + SHIM_DMACNTX); + reg |=3D FIELD_PREP(SHIM_DMACNTX_SIZE, fmt->size); + + writel(reg, csi->shim + SHIM_DMACNTX(ctx->idx)); =20 reg =3D FIELD_PREP(SHIM_PSI_CFG0_SRC_TAG, 0) | FIELD_PREP(SHIM_PSI_CFG0_DST_TAG, 0); - writel(reg, csi->shim + SHIM_PSI_CFG0); + writel(reg, csi->shim + SHIM_PSI_CFG0(ctx->idx)); } =20 static void ti_csi2rx_drain_callback(void *param) @@ -890,7 +892,7 @@ static int ti_csi2rx_start_streaming(struct vb2_queue *= vq, unsigned int count) err_pipeline: video_device_pipeline_stop(&ctx->vdev); writel(0, csi->shim + SHIM_CNTL); - writel(0, csi->shim + SHIM_DMACNTX); + writel(0, csi->shim + SHIM_DMACNTX(ctx->idx)); err: ti_csi2rx_cleanup_buffers(ctx, VB2_BUF_STATE_QUEUED); return ret; @@ -905,7 +907,7 @@ static void ti_csi2rx_stop_streaming(struct vb2_queue *= vq) video_device_pipeline_stop(&ctx->vdev); =20 writel(0, csi->shim + SHIM_CNTL); - writel(0, csi->shim + SHIM_DMACNTX); + writel(0, csi->shim + SHIM_DMACNTX(ctx->idx)); =20 ret =3D v4l2_subdev_call(csi->source, video, s_stream, 0); if (ret) --=20 2.34.1 From nobody Sun Feb 8 21:47:54 2026 Received: from SJ2PR03CU001.outbound.protection.outlook.com (mail-westusazon11012017.outbound.protection.outlook.com [52.101.43.17]) (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 173CD23AE9B; Wed, 21 Jan 2026 13:55:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.43.17 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003715; cv=fail; b=QDXgiN6ZIRddSYdbSeRkUwlX4ffXvaQ8PR9hSxXG8lHVG3sD5hN+WsvmZposS+fRTsvWb9Ac5TMl5pnoJtpNEjjHWKxFt82GrO5D4g1idOe5Fz66GXcvFqI0jskkkRsZXrAwKNXG1yfKwsHeXecAfr+mSDbizf4vPwsf+3a7Pgo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003715; c=relaxed/simple; bh=4rBwKidSbn9blA+n5wuerKp3imV0bTVzcWPaBuglL20=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uuDEkqjb0NrTiE6bxk+8uoiPLZxCyMfjT2zw+aiEootLYoF5oHqQQdluLMjTcN4L6uPJwSu19s/8wSC4tAe1+cHgis++wZ8yrKbJE9woA74lvSgcZM+iK5UZa1mxuFAhM0nRASfu5vaXza26LyXzcky5X5m04wirNn5l/lX64PI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=Q04RjZZ7; arc=fail smtp.client-ip=52.101.43.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="Q04RjZZ7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MKljFUnvQaEBWDe22jl4pyTrvuvkrb8ArL9mUWjx2y9ocIPYkIaqt+/DpvrhBWfnlK2GryfwIDmay6Xu6u6wIJLE0DxWj+8RxC7qm8z/4HGgaAN2BYNnRn3FmjcwVvc+zpJGaUoonbQobRBYo+NGjaFwtc1L7OcriU15Jaa+QCO9DOhz0GTGKx6D6SfotU/+akQZQitAiVjv6mMB3xrCSvyzElUVixQtUz//053QMjdWVW0zbF/myu9jUrtTRqfTQbG4f7JVAihm7zWynGr7lgSUQmTFE1EDLEBVmcCe7PXf3QCFAcPa1Dr/p/FYPdMBbZvanqmHepe9l0bD/h15NA== 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=GyVyCVqgCQoXvGXC4P8xhVLXQaOeR+l2SevswnZsEgA=; b=tzvppVsSuelOKF5zrpjLpIPXK2hOkOuIdKNR9fg52/3Zh2SzbTxl+aLBe5HXhjBpb264yj9KD5PO/inIAdMZKnPsWP0FRGQxnsUaG6XCWWFbu9V8ZvsSPgZK0RyXH88GbgoFthRqVy4Q/oUFb2RwgZYXmgubm5nLpptu4bHN7slrjPWUtOYOkTLUhFogbHqkWLsu9eFWi72hULkhfwtPkmymMopahh0lge82MTqMhF4iaLZm7glFmifDES/BBMgHiK7mLHZRhF7F9zuLVvgccMg2pcjcWOt837b8v8VIQ1BamDebS+VkpMppu35ld9cn/y+K42DjpD0Rc5b+bi8PDQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.194) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GyVyCVqgCQoXvGXC4P8xhVLXQaOeR+l2SevswnZsEgA=; b=Q04RjZZ7wy2NiMY/GDah1JYQid5fHSBnWIbKroMcrnhlfwXbERdkCKisQBqSfmNiyUI3pSQ2kzshfJVg6uUHLb46E2EHOHvcwPdwuI6ZUSrH0sDmyH3RdWaf06i6rMtlOHv0O3N7cZ0Qn471fzaq6rmeqxK8xdYROhr5rFzPf7Y= Received: from IA1P220CA0018.NAMP220.PROD.OUTLOOK.COM (2603:10b6:208:464::9) by PH7PR10MB7803.namprd10.prod.outlook.com (2603:10b6:510:30d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.9; Wed, 21 Jan 2026 13:55:10 +0000 Received: from BN2PEPF000044AA.namprd04.prod.outlook.com (2603:10b6:208:464:cafe::c2) by IA1P220CA0018.outlook.office365.com (2603:10b6:208:464::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9542.10 via Frontend Transport; Wed, 21 Jan 2026 13:55:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.194; helo=flwvzet200.ext.ti.com; pr=C Received: from flwvzet200.ext.ti.com (198.47.21.194) by BN2PEPF000044AA.mail.protection.outlook.com (10.167.243.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.4 via Frontend Transport; Wed, 21 Jan 2026 13:55:08 +0000 Received: from DFLE211.ent.ti.com (10.64.6.69) by flwvzet200.ext.ti.com (10.248.192.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:55:08 -0600 Received: from DFLE208.ent.ti.com (10.64.6.66) by DFLE211.ent.ti.com (10.64.6.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:55:08 -0600 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE208.ent.ti.com (10.64.6.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend Transport; Wed, 21 Jan 2026 07:55:08 -0600 Received: from ws.dhcp.ti.com (ws.dhcp.ti.com [172.24.233.149]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 60LDsPIB3104105; Wed, 21 Jan 2026 07:55:01 -0600 From: Rishikesh Donadkar To: , , CC: , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 05/18] media: ti: j721e-csi2rx: allocate DMA channel based on context index Date: Wed, 21 Jan 2026 19:24:11 +0530 Message-ID: <20260121135424.1185710-6-r-donadkar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260121135424.1185710-1-r-donadkar@ti.com> References: <20260121135424.1185710-1-r-donadkar@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044AA:EE_|PH7PR10MB7803:EE_ X-MS-Office365-Filtering-Correlation-Id: 3d9e03e7-2cf6-4be4-8e97-08de58f4b088 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?yzUHbRQ/u0+dy5pAc5trE6bfTx0OA8/Ad1i4OoO7LjfWXEK3IWQcE7pTWnk6?= =?us-ascii?Q?IDio/BHY13ZBD6m32q7cMs8jxzViCePYnR3jahJ24/4HSmfYYqTYY4+BGfhd?= =?us-ascii?Q?caYMMz9GK4vS+Dn4F5g1Ppw8vxBOKGx/f56iy2cCIzaqBaCZ4FKsxMOyU/cS?= =?us-ascii?Q?4OuuVM+B5M9b0B3To86s7J5Uw9z2nPfumcipqHsPRsCC4r2shOvOJAEAZbvi?= =?us-ascii?Q?Hcg/Th9XZMH0X2d6l0fWLe6KQbA9pj6TETArlyBqAlX44GTO+TfOj91Agcq/?= =?us-ascii?Q?oyPcrIwyigcxOpw85L7TQNTS8q6erHTZQsEO5SWtsX7PLYR8CyRcgxCpytKc?= =?us-ascii?Q?Ggej9JO2CfgMHFzIxQlOqwHB5S9qEjTgr3rmpPiU2M4NZlL6zFot7fVzSvxN?= =?us-ascii?Q?s6QevfzWtCJDgDL7n1NpIELW8aaTah/jdtAE2l/ydSe8IvavOPOG6iM180rg?= =?us-ascii?Q?u6MRMjEuZPkPdI1wBvDZH1LbZQxW67+VKtVQM1h33UFZteXNat4BIm2A0GGr?= =?us-ascii?Q?9pl/ylw9JPY8enkKfH/b8zVmeWIDZHmDU7i6fb2Vab6VsqNkvzmQP07EBffe?= =?us-ascii?Q?UeBk4oPSbnSlcSHfUANgH+1wXyGu9hUb3icOI+w43Wc5aqjeWAEs+FzM90Qg?= =?us-ascii?Q?z/ahWi18g/9W5jT/9g+QemmrJj6cIMRkGZZc0RQfy40xwlIH4wINkvgA02Ti?= =?us-ascii?Q?f4S8yQ7i9yMB6K2iWzRl/Hexzsm7p3bn11jhimtX69yhUrcPZg/upVGce2/H?= =?us-ascii?Q?YcoUj7gLCCa0I4O2eJ4g8joZdTfyaqfaxHr5ZrfNlkydCxnbmZV4qpl9V6Wj?= =?us-ascii?Q?wEXt1LEt7Rnz0kCf8F4eYqvbafUri4cFwsMqt62yeXonl0V4u0sJdl6PLj5k?= =?us-ascii?Q?jWMjEuOh+cQw3KSjUbTTiegtzdl2Wziy9uA8HlZSdU0LzGgu/MjrvMeWKCQG?= =?us-ascii?Q?8G4mDmXJhXPL+LErQekSL6SwMXrq/R9woDMm9uPtlQ9ALoWFdSDz0SUm6JzG?= =?us-ascii?Q?q7FZmoCXICExgsDqBuhNNGUt52VIN+VnMxvVxBTWdTUQlzLOrvYJ4FywwY/m?= =?us-ascii?Q?1VMjPfRAgfnjkHH24P/0teV7ArmqHOOXvVgOwVx9zI6K9aXkOK9Zt/vbi4uA?= =?us-ascii?Q?n5nDnTnUTR5yQ3JVPk6KpE+rpgTRPVewRo9JovLabdrvadSIPOzEgtP/UXMi?= =?us-ascii?Q?1Z5dHmm5eUfz3m7sMJTEWWnaUXATiS2Fk4Kq7ayE5g+LLzPwMhO7l2EaU2mO?= =?us-ascii?Q?ne9pnzLSksOKOGiO++vYDOFG6VxWVJHMr8pxelcyr8YAOChEcX4Waw1h7dxy?= =?us-ascii?Q?wwrVVJPGMqhbwHIqpENqsQX7Yl6CX7WxJJszG4lbLf1QpfqWGSoGKlVVYgME?= =?us-ascii?Q?sHMIyNp98ADAWdFIIBa5oHnIYOuIvxTt5hNaCMC4LrYSyKaNlDFGc3FrUBSO?= =?us-ascii?Q?a3U2DGJ7Pwc/KT6uw8yltu4Qmdq6aflbFOZ64T5Glebqhd9G6l3YQq6GqLJX?= =?us-ascii?Q?ArytWhoXyDRHYXkrhlGd2qvrWx9NTpRqBobo9G++aMcBL9kz2GoQskNgdLAp?= =?us-ascii?Q?Cd71+9/FcmLOCplGZgfVgDID1gkuyq/dtdPlYF0rG7AJqShFCtZAcadazfpq?= =?us-ascii?Q?BnlOZ0BQbtN75i4ttw+pSaMRoGVCrGM4oeRiuljOL2wczX80nu7iD6EDOXUJ?= =?us-ascii?Q?UI69jQ=3D=3D?= X-Forefront-Antispam-Report: CIP:198.47.21.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet200.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(376014)(7416014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2026 13:55:08.9046 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3d9e03e7-2cf6-4be4-8e97-08de58f4b088 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.194];Helo=[flwvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF000044AA.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB7803 Content-Type: text/plain; charset="utf-8" From: Pratyush Yadav With multiple contexts, there needs to be a different DMA channel for each context. Earlier, the DMA channel name was hard coded to "rx0" for the sake of simplicity. Generate the DMA channel name based on its index and get the channel corresponding to the context. Signed-off-by: Pratyush Yadav Signed-off-by: Jai Luthra Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Reviewed-by: Yemike Abhilash Chandra Reviewed-by: Tomi Valkeinen Signed-off-by: Rishikesh Donadkar --- drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/driver= s/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c index fdbe72df5c5f8..f66d68edcd57a 100644 --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c @@ -1038,9 +1038,11 @@ static int ti_csi2rx_init_dma(struct ti_csi2rx_ctx *= ctx) struct dma_slave_config cfg =3D { .src_addr_width =3D DMA_SLAVE_BUSWIDTH_16_BYTES, }; + char name[5]; int ret; =20 - ctx->dma.chan =3D dma_request_chan(ctx->csi->dev, "rx0"); + snprintf(name, sizeof(name), "rx%u", ctx->idx); + ctx->dma.chan =3D dma_request_chan(ctx->csi->dev, name); if (IS_ERR(ctx->dma.chan)) return PTR_ERR(ctx->dma.chan); =20 --=20 2.34.1 From nobody Sun Feb 8 21:47:54 2026 Received: from SJ2PR03CU001.outbound.protection.outlook.com (mail-westusazon11012015.outbound.protection.outlook.com [52.101.43.15]) (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 90BB9478E52; Wed, 21 Jan 2026 13:55:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.43.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003723; cv=fail; b=rmmfVKuzaXSCpbUDifd3JNm7JQSQPrJEbqBIpZRslnD7JP1uoMhESSifcP+1UBd6e7VoyfnMcxeexI8p9LZsCVVXlT3bb5+Uvjush9kp6AHJi9x1Ah/31DQoMVjfC/4mAKFRuE+ITn7kRAb00AvAoR/1GsQvMGhA0kymSEqAS+w= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003723; c=relaxed/simple; bh=bPjGW2FSGyZImLCTPHag17ddrCkWncBG9ClmiKcBSdM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TU4y8EdRiLSFnatYtNBEj7cExoY8mI4en8aqJ1eniQBs3c81t1bgOEmJiFb1qZGY6RAs4iSL2Rwh66a73a2zJGNjt2BfXwBMWQZ4CZzvLkD35PcT0aEO3snwaUzkrUbLAxDwN3sspUGSwKRKDevvhUksYml/g+zUzFsBBEiEyNk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=W5HoXJIS; arc=fail smtp.client-ip=52.101.43.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="W5HoXJIS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YRLyOQ8U9cAHMEvAiKCcE1NtoVANdA/EpkfaNZb4ppkvojQIMavXwxUkMzdKk2s5FEhZ/c+4sDqTBM0lkmcyWgbHiVWUNz+oKFBaqwjWwuVuevPS1C7RoDRNcGBsC70D80NaG3jONkT1UKga40aPyyR82lVUCll+blEi2jRkgz8U4Zr9SRE9Gi1cE4EF9OSnwkd8y0BYrRt6DnHSydRGkOdeE1h0NaQrlJaosx3uiKT/l+7B5YHmlcFtA+8Ih7cCtjKkkcGULC7ANkNP2evyvEf2E0idggb4LKKKAMLPvxYdf8aa28wrtekG7+pASnHTa+F6kXaTgHLKoYWiqLfnBQ== 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=sLII4DjNTn+ffSwex1UOV1cGQuGsPpcs8u0JFcM4XeA=; b=iahLuWPjrKvgyS9G4PkWUzLuhogDiQDn5P3rGjKJCwC1szSBVlYuVBsmaRHu9OHxvPQNuQyOivNQFuNVYHlaSd+0w20yfWw5JzsL97/YSMWf9JcjKKnFsnW71p/n6BctyBUhHzhgwrfQNZeJlIIQW3aHXUCoHsq+eP5Y6yr45rl8CG/YM8wpJOaur432BP6jkcf+8qLKeiovONHQZNAXBmWah7B0b6rHKQX/U8uxTL8t5CW8MYUO2DIjRbdfS84cIl7jsndXQfL2A0JLEAVQqfkbflu/y95Vh+OhK4ET8LhHrrQoD9IoY5IK/bAB6EYhQ6boIqmNuBYWuWtyqbyvOQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.194) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sLII4DjNTn+ffSwex1UOV1cGQuGsPpcs8u0JFcM4XeA=; b=W5HoXJIS9FmTbhnfovI7epszyfHNUOIyNGSWuXLnKdRIEbsBU3XV0n+Er3eglzc/8DDlTQMNfedDu4oUBnj8Cgyey1vMQ8L3TZGG2DXgPgMVBNmtbs3LbBYvCEUH0bbYZvfezmjaLOZvsRiGlo28BUlUtJr0z7Z2LhMWQf74xCg= Received: from IA1P220CA0022.NAMP220.PROD.OUTLOOK.COM (2603:10b6:208:464::11) by DM3PPF120DC3FA4.namprd10.prod.outlook.com (2603:10b6:f:fc00::c09) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.11; Wed, 21 Jan 2026 13:55:17 +0000 Received: from BN2PEPF000044AA.namprd04.prod.outlook.com (2603:10b6:208:464:cafe::9e) by IA1P220CA0022.outlook.office365.com (2603:10b6:208:464::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9542.10 via Frontend Transport; Wed, 21 Jan 2026 13:55:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.194; helo=flwvzet200.ext.ti.com; pr=C Received: from flwvzet200.ext.ti.com (198.47.21.194) by BN2PEPF000044AA.mail.protection.outlook.com (10.167.243.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.4 via Frontend Transport; Wed, 21 Jan 2026 13:55:16 +0000 Received: from DFLE202.ent.ti.com (10.64.6.60) by flwvzet200.ext.ti.com (10.248.192.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:55:15 -0600 Received: from DFLE214.ent.ti.com (10.64.6.72) by DFLE202.ent.ti.com (10.64.6.60) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:55:15 -0600 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE214.ent.ti.com (10.64.6.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend Transport; Wed, 21 Jan 2026 07:55:15 -0600 Received: from ws.dhcp.ti.com (ws.dhcp.ti.com [172.24.233.149]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 60LDsPIC3104105; Wed, 21 Jan 2026 07:55:08 -0600 From: Rishikesh Donadkar To: , , CC: , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 06/18] media: ti: j721e-csi2rx: add a subdev for the core device Date: Wed, 21 Jan 2026 19:24:12 +0530 Message-ID: <20260121135424.1185710-7-r-donadkar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260121135424.1185710-1-r-donadkar@ti.com> References: <20260121135424.1185710-1-r-donadkar@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044AA:EE_|DM3PPF120DC3FA4:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a7a5d29-c2f7-4652-50eb-08de58f4b4c6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|7416014|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?QlFooJaJEHNkSJAT1ceWFscpN0QCfel4uI8tni4Gyh3np81BOJwqSjefIPAw?= =?us-ascii?Q?NIBP8AgucMZWWmgEWAVn82Cn9qO+PSYoCXGRjPdrKWPfIB0qEn0JSy5y68/1?= =?us-ascii?Q?/siuFF8lCy6RFPyoXK40gLYRKrJa2ilSATN5CTH26tCoDzswTJBhjA11aesy?= =?us-ascii?Q?PQdMKAT77jw3Osel8xWw04UyW2jMjWPKJ0s0l/vz0XWgNRowFhl6QYsJx8My?= =?us-ascii?Q?uIa62MIAPoArh3DhNcZlmn1WWF8+Vz+D/pVaOFaTqp7aAtYU5fKJFcWpZkaP?= =?us-ascii?Q?oAl0JOaR4H5p9k9OgZ5920bVLwKyHRrwBnjeSPhk48fu/NAfw7ey5j89yDzS?= =?us-ascii?Q?SJL+4OemKqyKmJ1PsGWrW62cWHrEVdYg9TwbpfWpJI0wIfjgSh8C4pF0O5FH?= =?us-ascii?Q?RKabvLwERJspYHzqpvrbZe6LquTF4CpoP4JjSWP368qOrMjF659FpVMjCwhL?= =?us-ascii?Q?vUGHm21MIynlNMu1SmHzgxFMQBjGaNcmtyNNuqVkHKOHROXzoPE75ce5xXkK?= =?us-ascii?Q?HHYW2IhgVpLPSckuMUZte12xZbh/ymDhrl92R4lFmeg4XSRb8jP1Um+t1tYB?= =?us-ascii?Q?zSk5uDT+LDsnvRtvCkMr1Qxp9TL1QpJtbv6P3Y8YslT1ZFpLo5VcQo9OrQ4q?= =?us-ascii?Q?Y2HXmX5xRuN63edJEQj6UnMQwHn06kkYDBrigBGo9y6v9jlZr6f3bRGxu3XV?= =?us-ascii?Q?g5G7N5E1oqMnLUK3CESt4NtTaQso83CFtWGCHzUE6yxBofquftZkZI+Px+J+?= =?us-ascii?Q?KYZM/dsAHWSYWweTL6+NruLtTUHlEN5UGldPUoKrlKETh77GrviY1PPkTi/V?= =?us-ascii?Q?8lmJ7fQe2IfkiXeBavc0WK1V3tYNS7viSl2k4VA3moSGYf03PLJSEcNwl1q5?= =?us-ascii?Q?PSrMyCZPq4ozrpC1SmaQ6mEI9vtHBdr05GakU5Kioc/+MrwvlyQc/R+21A5c?= =?us-ascii?Q?XQq9EBY+1XWcuZEuBQ72BO1yUKBwxsYBnh2rKbJ6i9nBky5wPeecZX3a7az/?= =?us-ascii?Q?JhsmycjnRbiUiKeCe9aqN9+2aMe1PV8LSX6DPjQVri3ALhSPFI5gStQtZVtD?= =?us-ascii?Q?nWGg430+k9dgSZ+0GjLZeVZH+AyOy1WXsMwXBUJNTtp9m9meVSTnnbr7XojD?= =?us-ascii?Q?w0gPJ6OiOeLkgwbelyCdzeG6mQ0OUwI5xJ38pXJdR3/YUHI0KKupgEqcyCns?= =?us-ascii?Q?Yw4hicLHJquUzukY5/3Ulm8LuBrIsAJNyYzB69ARL4WjBtu92wTG8on3jzZi?= =?us-ascii?Q?0m4hKp5RDzgnLqC2LnuQnRDthBrPlHRanwo8uYDkZFlavtzj0ubQ64wdkWtc?= =?us-ascii?Q?DBKHA9+T1VCoeuqzm6HhhoqN7jMIHGczYFQEYoZyjj81ocF7M6hd2rDD8Jbx?= =?us-ascii?Q?xG54N3N00+7INdgoTBozQLampKY2RP2xWuT8M2Xchyp8ZoUapUzgoCi67dfD?= =?us-ascii?Q?622ipkyMn/oAICkh8r5343vzTdtiCe+/GQayfi6cpX7lXQy7dpVKIjpbxkN7?= =?us-ascii?Q?XUOu3p5WAk3HVm3t5VBjnCok7yKT3Ubv9gPeiysiZcfhEbfAGhZ4QYC506jY?= =?us-ascii?Q?BbBefXh1JENu5i6pEOziiXDlliTLGiykz52XlEzvXG5xfgHTvUICanSjFHBE?= =?us-ascii?Q?Zbdtwtwcr5SMg6A09GmbZdSCzPaFy3iddAjUqmMRtMBdcMAzuHDXXRZIhmgl?= =?us-ascii?Q?Yt39uA=3D=3D?= X-Forefront-Antispam-Report: CIP:198.47.21.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet200.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(82310400026)(7416014)(376014)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2026 13:55:16.0152 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8a7a5d29-c2f7-4652-50eb-08de58f4b4c6 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.194];Helo=[flwvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF000044AA.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PPF120DC3FA4 Content-Type: text/plain; charset="utf-8" From: Jai Luthra With single stream capture, it was simpler to use the video device as the media entity representing the main TI CSI2RX device. Now with multi stream capture coming into the picture, the model has shifted to each video device having a link to the main device's subdev. The routing would then be set on this subdev. Add this subdev, link each context to this subdev's entity and link the subdev's entity to the source. Also add an array of media pads. It will have one sink pad and source pads equal to the number of contexts. Support the new enable_stream()/disable_stream() APIs in the subdev instead of s_stream() hook. Reviewed-by: Yemike Abhilash Chandra Co-developed-by: Pratyush Yadav Signed-off-by: Pratyush Yadav Signed-off-by: Jai Luthra Signed-off-by: Rishikesh Donadkar Reviewed-by: Tomi Valkeinen --- .../platform/ti/j721e-csi2rx/j721e-csi2rx.c | 287 +++++++++++++++--- 1 file changed, 243 insertions(+), 44 deletions(-) diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/driver= s/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c index f66d68edcd57a..8e1da5d3e11b6 100644 --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c @@ -54,6 +54,11 @@ #define MAX_WIDTH_BYTES SZ_16K #define MAX_HEIGHT_LINES SZ_16K =20 +#define TI_CSI2RX_PAD_SINK 0 +#define TI_CSI2RX_PAD_FIRST_SOURCE 1 +#define TI_CSI2RX_NUM_SOURCE_PADS 1 +#define TI_CSI2RX_NUM_PADS (1 + TI_CSI2RX_NUM_SOURCE_PADS) + #define DRAIN_TIMEOUT_MS 50 #define DRAIN_BUFFER_SIZE SZ_32K =20 @@ -102,6 +107,7 @@ struct ti_csi2rx_ctx { struct mutex mutex; /* To serialize ioctls. */ struct v4l2_format v_fmt; struct ti_csi2rx_dma dma; + struct media_pad pad; u32 sequence; u32 idx; }; @@ -109,12 +115,14 @@ struct ti_csi2rx_ctx { struct ti_csi2rx_dev { struct device *dev; void __iomem *shim; + unsigned int enable_count; struct v4l2_device v4l2_dev; struct media_device mdev; struct media_pipeline pipe; - struct media_pad pad; + struct media_pad pads[TI_CSI2RX_NUM_PADS]; struct v4l2_async_notifier notifier; struct v4l2_subdev *source; + struct v4l2_subdev subdev; struct ti_csi2rx_ctx ctx[TI_CSI2RX_NUM_CTX]; u8 pix_per_clk; /* Buffer to drain stale data from PSI-L endpoint */ @@ -125,6 +133,22 @@ struct ti_csi2rx_dev { } drain; }; =20 +static inline struct ti_csi2rx_dev *to_csi2rx_dev(struct v4l2_subdev *sd) +{ + return container_of(sd, struct ti_csi2rx_dev, subdev); +} + +static const struct v4l2_mbus_framefmt ti_csi2rx_default_fmt =3D { + .width =3D 640, + .height =3D 480, + .code =3D MEDIA_BUS_FMT_UYVY8_1X16, + .field =3D V4L2_FIELD_NONE, + .colorspace =3D V4L2_COLORSPACE_SRGB, + .ycbcr_enc =3D V4L2_YCBCR_ENC_601, + .quantization =3D V4L2_QUANTIZATION_LIM_RANGE, + .xfer_func =3D V4L2_XFER_FUNC_SRGB, +}; + static const struct ti_csi2rx_fmt ti_csi2rx_formats[] =3D { { .fourcc =3D V4L2_PIX_FMT_YUYV, @@ -422,6 +446,18 @@ static int csi_async_notifier_complete(struct v4l2_asy= nc_notifier *notifier) struct ti_csi2rx_dev *csi =3D dev_get_drvdata(notifier->v4l2_dev->dev); int ret, i; =20 + /* Create link from source to subdev */ + ret =3D media_create_pad_link(&csi->source->entity, + CSI2RX_BRIDGE_SOURCE_PAD, + &csi->subdev.entity, + TI_CSI2RX_PAD_SINK, + MEDIA_LNK_FL_IMMUTABLE | + MEDIA_LNK_FL_ENABLED); + + if (ret) + return ret; + + /* Create and link video nodes for all DMA contexts */ for (i =3D 0; i < TI_CSI2RX_NUM_CTX; i++) { struct ti_csi2rx_ctx *ctx =3D &csi->ctx[i]; struct video_device *vdev =3D &ctx->vdev; @@ -429,15 +465,17 @@ static int csi_async_notifier_complete(struct v4l2_as= ync_notifier *notifier) ret =3D video_register_device(vdev, VFL_TYPE_VIDEO, -1); if (ret) goto unregister_dev; - } =20 - ret =3D media_create_pad_link(&csi->source->entity, - CSI2RX_BRIDGE_SOURCE_PAD, - &csi->ctx[0].vdev.entity, csi->pad.index, - MEDIA_LNK_FL_IMMUTABLE | - MEDIA_LNK_FL_ENABLED); - if (ret) - goto unregister_dev; + ret =3D media_create_pad_link(&csi->subdev.entity, + TI_CSI2RX_PAD_FIRST_SOURCE + ctx->idx, + &vdev->entity, 0, + MEDIA_LNK_FL_IMMUTABLE | + MEDIA_LNK_FL_ENABLED); + if (ret) { + video_unregister_device(vdev); + goto unregister_dev; + } + } =20 ret =3D v4l2_device_register_subdev_nodes(&csi->v4l2_dev); if (ret) @@ -447,8 +485,10 @@ static int csi_async_notifier_complete(struct v4l2_asy= nc_notifier *notifier) =20 unregister_dev: i--; - for (; i >=3D 0; i--) + for (; i >=3D 0; i--) { + media_entity_remove_links(&csi->ctx[i].vdev.entity); video_unregister_device(&csi->ctx[i].vdev); + } return ret; } =20 @@ -493,14 +533,13 @@ static int ti_csi2rx_notifier_register(struct ti_csi2= rx_dev *csi) } =20 /* Request maximum possible pixels per clock from the bridge */ -static void ti_csi2rx_request_max_ppc(struct ti_csi2rx_ctx *ctx) +static void ti_csi2rx_request_max_ppc(struct ti_csi2rx_dev *csi) { - struct ti_csi2rx_dev *csi =3D ctx->csi; u8 ppc =3D TI_CSI2RX_MAX_PIX_PER_CLK; struct media_pad *pad; int ret; =20 - pad =3D media_entity_remote_source_pad_unique(&ctx->vdev.entity); + pad =3D media_entity_remote_source_pad_unique(&csi->subdev.entity); if (IS_ERR(pad)) return; =20 @@ -526,7 +565,7 @@ static void ti_csi2rx_setup_shim(struct ti_csi2rx_ctx *= ctx) writel(reg, csi->shim + SHIM_CNTL); =20 /* Negotiate pixel count from the source */ - ti_csi2rx_request_max_ppc(ctx); + ti_csi2rx_request_max_ppc(csi); =20 reg =3D SHIM_DMACNTX_EN; reg |=3D FIELD_PREP(SHIM_DMACNTX_FMT, fmt->csi_dt); @@ -881,7 +920,9 @@ static int ti_csi2rx_start_streaming(struct vb2_queue *= vq, unsigned int count) dma->state =3D TI_CSI2RX_DMA_ACTIVE; spin_unlock_irqrestore(&dma->lock, flags); =20 - ret =3D v4l2_subdev_call(csi->source, video, s_stream, 1); + ret =3D v4l2_subdev_enable_streams(&csi->subdev, + TI_CSI2RX_PAD_FIRST_SOURCE, + BIT_U64(0)); if (ret) goto err_dma; =20 @@ -909,7 +950,9 @@ static void ti_csi2rx_stop_streaming(struct vb2_queue *= vq) writel(0, csi->shim + SHIM_CNTL); writel(0, csi->shim + SHIM_DMACNTX(ctx->idx)); =20 - ret =3D v4l2_subdev_call(csi->source, video, s_stream, 0); + ret =3D v4l2_subdev_disable_streams(&csi->subdev, + TI_CSI2RX_PAD_FIRST_SOURCE, + BIT_U64(0)); if (ret) dev_err(csi->dev, "Failed to stop subdev stream\n"); =20 @@ -925,8 +968,121 @@ static const struct vb2_ops csi_vb2_qops =3D { .stop_streaming =3D ti_csi2rx_stop_streaming, }; =20 +static int ti_csi2rx_enum_mbus_code(struct v4l2_subdev *subdev, + struct v4l2_subdev_state *state, + struct v4l2_subdev_mbus_code_enum *code_enum) +{ + if (code_enum->index >=3D ARRAY_SIZE(ti_csi2rx_formats)) + return -EINVAL; + + code_enum->code =3D ti_csi2rx_formats[code_enum->index].code; + + return 0; +} + +static int ti_csi2rx_sd_set_fmt(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, + struct v4l2_subdev_format *format) +{ + struct v4l2_mbus_framefmt *fmt; + + /* No transcoding, don't allow setting source fmt */ + if (format->pad > TI_CSI2RX_PAD_SINK) + return v4l2_subdev_get_fmt(sd, state, format); + + if (!find_format_by_code(format->format.code)) + format->format.code =3D ti_csi2rx_formats[0].code; + + format->format.field =3D V4L2_FIELD_NONE; + + fmt =3D v4l2_subdev_state_get_format(state, format->pad, format->stream); + *fmt =3D format->format; + + fmt =3D v4l2_subdev_state_get_format(state, TI_CSI2RX_PAD_FIRST_SOURCE, + format->stream); + *fmt =3D format->format; + + return 0; +} + +static int ti_csi2rx_sd_init_state(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state) +{ + struct v4l2_mbus_framefmt *fmt; + + fmt =3D v4l2_subdev_state_get_format(state, TI_CSI2RX_PAD_SINK); + *fmt =3D ti_csi2rx_default_fmt; + + fmt =3D v4l2_subdev_state_get_format(state, TI_CSI2RX_PAD_FIRST_SOURCE); + *fmt =3D ti_csi2rx_default_fmt; + + return 0; +} + +static int ti_csi2rx_sd_enable_streams(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, + u32 pad, u64 streams_mask) +{ + struct ti_csi2rx_dev *csi =3D to_csi2rx_dev(sd); + struct media_pad *remote_pad; + int ret =3D 0; + + remote_pad =3D media_entity_remote_source_pad_unique(&csi->subdev.entity); + if (!remote_pad) + return -ENODEV; + + ret =3D v4l2_subdev_enable_streams(csi->source, remote_pad->index, + BIT_U64(0)); + if (ret) + return ret; + + csi->enable_count++; + + return 0; +} + +static int ti_csi2rx_sd_disable_streams(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, + u32 pad, u64 streams_mask) +{ + struct ti_csi2rx_dev *csi =3D to_csi2rx_dev(sd); + struct media_pad *remote_pad; + int ret =3D 0; + + remote_pad =3D media_entity_remote_source_pad_unique(&csi->subdev.entity); + if (!remote_pad) + return -ENODEV; + + if (csi->enable_count =3D=3D 0) + return -EINVAL; + + ret =3D v4l2_subdev_disable_streams(csi->source, remote_pad->index, + BIT_U64(0)); + if (!ret) + --csi->enable_count; + + return 0; +} + +static const struct v4l2_subdev_pad_ops ti_csi2rx_subdev_pad_ops =3D { + .enum_mbus_code =3D ti_csi2rx_enum_mbus_code, + .get_fmt =3D v4l2_subdev_get_fmt, + .set_fmt =3D ti_csi2rx_sd_set_fmt, + .enable_streams =3D ti_csi2rx_sd_enable_streams, + .disable_streams =3D ti_csi2rx_sd_disable_streams, +}; + +static const struct v4l2_subdev_ops ti_csi2rx_subdev_ops =3D { + .pad =3D &ti_csi2rx_subdev_pad_ops, +}; + +static const struct v4l2_subdev_internal_ops ti_csi2rx_internal_ops =3D { + .init_state =3D ti_csi2rx_sd_init_state, +}; + static void ti_csi2rx_cleanup_v4l2(struct ti_csi2rx_dev *csi) { + v4l2_subdev_cleanup(&csi->subdev); media_device_unregister(&csi->mdev); v4l2_device_unregister(&csi->v4l2_dev); media_device_cleanup(&csi->mdev); @@ -981,48 +1137,52 @@ static int ti_csi2rx_link_validate(struct media_link= *link) struct ti_csi2rx_ctx *ctx =3D container_of(vdev, struct ti_csi2rx_ctx, vd= ev); struct ti_csi2rx_dev *csi =3D ctx->csi; struct v4l2_pix_format *csi_fmt =3D &ctx->v_fmt.fmt.pix; - struct v4l2_subdev_format source_fmt =3D { - .which =3D V4L2_SUBDEV_FORMAT_ACTIVE, - .pad =3D link->source->index, - }; + struct v4l2_mbus_framefmt *format; + struct v4l2_subdev_state *state; const struct ti_csi2rx_fmt *ti_fmt; - int ret; =20 - ret =3D v4l2_subdev_call_state_active(csi->source, pad, - get_fmt, &source_fmt); - if (ret) - return ret; + state =3D v4l2_subdev_lock_and_get_active_state(&csi->subdev); + format =3D v4l2_subdev_state_get_format(state, link->source->index, 0); + v4l2_subdev_unlock_state(state); =20 - if (source_fmt.format.width !=3D csi_fmt->width) { + if (!format) { + dev_dbg(csi->dev, + "Skipping validation as no format present on \"%s\":%u:0\n", + link->source->entity->name, link->source->index); + return 0; + } + + if (format->width !=3D csi_fmt->width) { dev_dbg(csi->dev, "Width does not match (source %u, sink %u)\n", - source_fmt.format.width, csi_fmt->width); + format->width, csi_fmt->width); return -EPIPE; } =20 - if (source_fmt.format.height !=3D csi_fmt->height) { + if (format->height !=3D csi_fmt->height) { dev_dbg(csi->dev, "Height does not match (source %u, sink %u)\n", - source_fmt.format.height, csi_fmt->height); + format->height, csi_fmt->height); return -EPIPE; } =20 - if (source_fmt.format.field !=3D csi_fmt->field && + if (format->field !=3D csi_fmt->field && csi_fmt->field !=3D V4L2_FIELD_NONE) { dev_dbg(csi->dev, "Field does not match (source %u, sink %u)\n", - source_fmt.format.field, csi_fmt->field); + format->field, csi_fmt->field); return -EPIPE; } =20 - ti_fmt =3D find_format_by_code(source_fmt.format.code); + ti_fmt =3D find_format_by_code(format->code); if (!ti_fmt) { dev_dbg(csi->dev, "Media bus format 0x%x not supported\n", - source_fmt.format.code); + format->code); return -EPIPE; } =20 if (ti_fmt->fourcc !=3D csi_fmt->pixelformat) { dev_dbg(csi->dev, - "Cannot transform source fmt 0x%x to sink fmt 0x%x\n", - ti_fmt->fourcc, csi_fmt->pixelformat); + "Cannot transform \"%s\":%u format %p4cc to %p4cc\n", + link->source->entity->name, link->source->index, + &ti_fmt->fourcc, &csi_fmt->pixelformat); return -EPIPE; } =20 @@ -1033,6 +1193,10 @@ static const struct media_entity_operations ti_csi2r= x_video_entity_ops =3D { .link_validate =3D ti_csi2rx_link_validate, }; =20 +static const struct media_entity_operations ti_csi2rx_subdev_entity_ops = =3D { + .link_validate =3D v4l2_subdev_link_validate, +}; + static int ti_csi2rx_init_dma(struct ti_csi2rx_ctx *ctx) { struct dma_slave_config cfg =3D { @@ -1058,6 +1222,7 @@ static int ti_csi2rx_init_dma(struct ti_csi2rx_ctx *c= tx) static int ti_csi2rx_v4l2_init(struct ti_csi2rx_dev *csi) { struct media_device *mdev =3D &csi->mdev; + struct v4l2_subdev *sd =3D &csi->subdev; int ret; =20 mdev->dev =3D csi->dev; @@ -1070,16 +1235,51 @@ static int ti_csi2rx_v4l2_init(struct ti_csi2rx_dev= *csi) =20 ret =3D v4l2_device_register(csi->dev, &csi->v4l2_dev); if (ret) - return ret; + goto cleanup_media; =20 ret =3D media_device_register(mdev); - if (ret) { - v4l2_device_unregister(&csi->v4l2_dev); - media_device_cleanup(mdev); - return ret; - } + if (ret) + goto unregister_v4l2; + + v4l2_subdev_init(sd, &ti_csi2rx_subdev_ops); + sd->internal_ops =3D &ti_csi2rx_internal_ops; + sd->entity.function =3D MEDIA_ENT_F_VID_IF_BRIDGE; + sd->flags =3D V4L2_SUBDEV_FL_HAS_DEVNODE; + strscpy(sd->name, dev_name(csi->dev), sizeof(sd->name)); + sd->dev =3D csi->dev; + sd->entity.ops =3D &ti_csi2rx_subdev_entity_ops; + + csi->pads[TI_CSI2RX_PAD_SINK].flags =3D MEDIA_PAD_FL_SINK; + + for (unsigned int i =3D TI_CSI2RX_PAD_FIRST_SOURCE; + i < TI_CSI2RX_NUM_PADS; i++) + csi->pads[i].flags =3D MEDIA_PAD_FL_SOURCE; + + ret =3D media_entity_pads_init(&sd->entity, ARRAY_SIZE(csi->pads), + csi->pads); + if (ret) + goto unregister_media; + + ret =3D v4l2_subdev_init_finalize(sd); + if (ret) + goto unregister_media; + + ret =3D v4l2_device_register_subdev(&csi->v4l2_dev, sd); + if (ret) + goto cleanup_subdev; =20 return 0; + +cleanup_subdev: + v4l2_subdev_cleanup(sd); +unregister_media: + media_device_unregister(mdev); +unregister_v4l2: + v4l2_device_unregister(&csi->v4l2_dev); +cleanup_media: + media_device_cleanup(mdev); + + return ret; } =20 static int ti_csi2rx_init_ctx(struct ti_csi2rx_ctx *ctx) @@ -1106,9 +1306,9 @@ static int ti_csi2rx_init_ctx(struct ti_csi2rx_ctx *c= tx) =20 ti_csi2rx_fill_fmt(fmt, &ctx->v_fmt); =20 - csi->pad.flags =3D MEDIA_PAD_FL_SINK; + ctx->pad.flags =3D MEDIA_PAD_FL_SINK; vdev->entity.ops =3D &ti_csi2rx_video_entity_ops; - ret =3D media_entity_pads_init(&ctx->vdev.entity, 1, &csi->pad); + ret =3D media_entity_pads_init(&ctx->vdev.entity, 1, &ctx->pad); if (ret) return ret; =20 @@ -1216,7 +1416,6 @@ static void ti_csi2rx_remove(struct platform_device *= pdev) =20 ti_csi2rx_cleanup_notifier(csi); ti_csi2rx_cleanup_v4l2(csi); - dma_free_coherent(csi->dev, csi->drain.len, csi->drain.vaddr, csi->drain.paddr); } --=20 2.34.1 From nobody Sun Feb 8 21:47:54 2026 Received: from CH4PR04CU002.outbound.protection.outlook.com (mail-northcentralusazon11013006.outbound.protection.outlook.com [40.107.201.6]) (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 7707D4963B2; Wed, 21 Jan 2026 13:55:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.201.6 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003733; cv=fail; b=ogo02m2Ovlgea5yl5arLI93FMfkL/uaMqY5O39bDC/fTeVXmnhY+Ezv1YXbD0VwaVCTN/E5lEi5SD/wGfy1PiX5rSqzUZBKzaDTU2/9ERohMPaKK1j7q2Pgwd4wLKKCpVFmHdIYWgn02UB/coUyxFyptynuj2Hwl5J3Y5TOR4EE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003733; c=relaxed/simple; bh=MIg4lygrCuC3JAv2bm+nGmRPQ2hCQeg8+In26W2VHSs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Z0Sh2omt1DSqUbgK2Rx9wcuAHayqIic6tX6UIPvBCJ80EXbIY7x3b1mEAVySNEHBKjqrriPnSHO2BlRizbrS/QWYN/mNoh9BgIuTb2ZzhFlN89oi03sL2niVqs93jlvwzbO3vK26bk9SGrxamV5Zfy9279++VMFIHycnCx+Ceis= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=BbFaZTyT; arc=fail smtp.client-ip=40.107.201.6 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="BbFaZTyT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=U054iAF8Asn/w18vAAsXgeLD9Ad/yHxgNBvqSgDHIyAECyxv+wpwqmc5HmpiYvXdfRc2NhcIRXxow115kQDnDvd5Mm/eNjn2eA+f1PLR8Lf3VdIY2TnspE8fnbt0PuDWWR4Nk6Z9XU+rtxHXgYZy0OYOB2FQ02XkMiHpVSIDAX8VqJyFsGYYnYtHpulJ1xt0dgBo6p2CXwrHrqpIdUZv9QdyQktvCB7rKWBOrm6hZbXDgSxyqCI3D4G7jrjTyfCGRnKSGwc4muw9Ad+8jiKaHc7R1RAmJJ8Qcu14UzzneIBZT45xxuL6Z5ZQQU2RbuWnH3WcyghMM6mJKCLftvoeDw== 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=1ORcoSYJKdVknbZfoHLTPqUFXkyfBU5YN5QOo9vecPc=; b=xMvtd525Ca95uDpJoxZkr2dTTBWiWx0sXm/CvHBdcINXlc4ak67lv84Wcux4nXzvAKwCKR+AZNmiAX8jAMOcuqOWvQMBmeHXIYzV6UVnwqy0PPdzfRTWpLUW4qkfDSMQI5/pK0gNfU7KFZw8TwU4bNMrF2DAJs2us8+GHYIMLb2HgeNKrnN0vIrvwYxNDz3iMP4Snp8k95tICOqhiRrTIWThFVkkS7/5/iyUvsULUFwrBktwW28NuOdPLv7j6z56/GB2peauEwqy4/E1FFi21UG2RRBXRwZ65EJEIAwLCQ30gndvKYSeYt43u/c/F7VdAYvvY3S5H/vX/WjylWFD3g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.195) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1ORcoSYJKdVknbZfoHLTPqUFXkyfBU5YN5QOo9vecPc=; b=BbFaZTyTUeQyS1G2uRv9o+z9lflVjc4jF21NegZInwdXJc/BtF+pZUkDyteneS9yl77vhnWrqaMg67h9FmBdV9uYJZ4gpu6b3ynrivwT0JdQ7i0fhlNM/QelLfBHx4IrgQI+zQ3K9FpdobL/jkgYbtGUnHFYEHk8jAJ5z8jLQjc= Received: from SJ0PR05CA0143.namprd05.prod.outlook.com (2603:10b6:a03:33d::28) by SJ5PPF0447EC1A8.namprd10.prod.outlook.com (2603:10b6:a0f:fc02::784) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.9; Wed, 21 Jan 2026 13:55:27 +0000 Received: from SJ5PEPF00000203.namprd05.prod.outlook.com (2603:10b6:a03:33d:cafe::a6) by SJ0PR05CA0143.outlook.office365.com (2603:10b6:a03:33d::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9564.3 via Frontend Transport; Wed, 21 Jan 2026 13:55:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.195; helo=lewvzet201.ext.ti.com; pr=C Received: from lewvzet201.ext.ti.com (198.47.23.195) by SJ5PEPF00000203.mail.protection.outlook.com (10.167.244.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.4 via Frontend Transport; Wed, 21 Jan 2026 13:55:26 +0000 Received: from DLEE207.ent.ti.com (157.170.170.95) by lewvzet201.ext.ti.com (10.4.14.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:55:22 -0600 Received: from DLEE213.ent.ti.com (157.170.170.116) by DLEE207.ent.ti.com (157.170.170.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:55:22 -0600 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DLEE213.ent.ti.com (157.170.170.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend Transport; Wed, 21 Jan 2026 07:55:22 -0600 Received: from ws.dhcp.ti.com (ws.dhcp.ti.com [172.24.233.149]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 60LDsPID3104105; Wed, 21 Jan 2026 07:55:15 -0600 From: Rishikesh Donadkar To: , , CC: , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 07/18] media: cadence: csi2rx: Move to .enable/disable_streams API Date: Wed, 21 Jan 2026 19:24:13 +0530 Message-ID: <20260121135424.1185710-8-r-donadkar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260121135424.1185710-1-r-donadkar@ti.com> References: <20260121135424.1185710-1-r-donadkar@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF00000203:EE_|SJ5PPF0447EC1A8:EE_ X-MS-Office365-Filtering-Correlation-Id: 79507b20-54b6-4847-d5ff-08de58f4bb4f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|7416014|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?E09wlSSMl673kMtdAczR7xRiJHQK3fcJzH4FAu4jz0WB7ZktlyqfOeFtU8B+?= =?us-ascii?Q?61hHlaDjHbT79pAWD8tuhmBNffFGGxA/N3ZLuifSvfghYprMGFZJod8R6WVj?= =?us-ascii?Q?1rY5+yHIogx/hyUFonq8X0Ycw0xSGPMDU1caUTG6rTv9GEmaFjGPnSSHud+Y?= =?us-ascii?Q?pNTH4ZW8MnxrchXcM9KuimPC0Q+2uMYhE3xVkwL5pA2EeklcewHUWPJUWVHv?= =?us-ascii?Q?Cv7i59d7jDpmoC4jCXOj0w6ZvEmJIbkd4vU3jJ1QyMLe38ZBtHcafNsC/744?= =?us-ascii?Q?Tim9BMfM4oqha75EZHZmKuOPUSvOZZvO3Paz8aEyNAhczpuaqGKhP35N0w7H?= =?us-ascii?Q?N8+k1tlhiSIR156CSnvF/Kk1P4hj3WjWy55wBogy2Ri7mjt5s6kmv7R8Uflk?= =?us-ascii?Q?2xu0haZM8tSLMVDB9wt/w4lOPc4emfWf+OGyaN0/Hac2X3jeKr1bsvlr3mrp?= =?us-ascii?Q?BJ2LyISEaLlaBlEd/GHd5MHVkQ6oueDSy0VuM6zIsNUkZMkyKBffkJJM2BvO?= =?us-ascii?Q?EG4x/GbgCA47ti8IOUtiDw7Lbsl5EPnxOtQnInq0BKG2wYleXmTmaYqYaW+9?= =?us-ascii?Q?tUfZgeNXvHNi7L6JluVICia3rS3tM/nxH3hCVZxHWJdzU9vFwgRV86WHzEAw?= =?us-ascii?Q?zmqxjTUcy46hAmmNDeZKxShpinzJNJGJnGKFZfbyzDn2pQk5ngrc4Ju+f+1A?= =?us-ascii?Q?wj5y7MEePpFr450v9tZ8Ht1JtyRV2tHu3ubx5mjum+Qd1hlzpmWQRqzdNfTj?= =?us-ascii?Q?puO8c6nNciyJLtSWOlevZ/vURcuJxV1Fa7diqYzQzlSpj4Tqw/joeeNbX2xT?= =?us-ascii?Q?hG40vxutd+Wgje18i5mK8V5khA1wPRIYQTcpsHd5fvYfNjeOtefk+ekcUjRw?= =?us-ascii?Q?falbYIqmvyf2aB0PsoSbxxgg7yG3tLCIjUmeogs/0o5E+CEAiH5m2GAZCAdp?= =?us-ascii?Q?GsGRgyNKtPupt6GUfkGpN48zLmjyoG3CDnRJFvZiKBr/EPnq+D9kRrHsLK8e?= =?us-ascii?Q?ER32Mm7/3fT0/BXMgfaaDkGrOSQPdQBFIXypUXqTX/bsDMj/fn+pn01AK5FV?= =?us-ascii?Q?WWYFE5ruM1LfCVnqxfyjdz2/VeBzHO84HbOV+1x1zeh/ujLZTnexWCJWmARH?= =?us-ascii?Q?28ZXDLB87MWG85I6suHt82HjnkLUCZHvo0aZEjWgHsw/9DKKcw0W2izWHXOp?= =?us-ascii?Q?eqxhIIWJD7AeVD8ipNoGpzNBjEij4lnyKAY6CTBY9XTNtW4bnBTc6EKxCkQY?= =?us-ascii?Q?VVuG7cIcV58ifTFllQ9enkzqIW2p/pcs6GBNpePD7nBQ3oz5sxEPqxllcfBM?= =?us-ascii?Q?ig1CQKWaoD6N914/N/iaKmYU+OLTpnfRHtZarjTWacP1zHpFJI8kvTmww+I2?= =?us-ascii?Q?XAaHPdtkQHw2iMRq4HUOh5ACZuNI/6iMnTQcGGccKOs947P0Tv2oRvNBYQZe?= =?us-ascii?Q?/8alLRCQzgNPozyjOZ7l2Hxs6A/dKlOoHwt8BL2xchj7Jc+T+0VgEWxU482Z?= =?us-ascii?Q?VSwivKq+GcqL0NXjn5gmo7WYNd+Y86izgFHoP15gkmBDHiidFbOV62YzxqJx?= =?us-ascii?Q?/y6RyOM4IsBUD2JT/HcorkeyZ52Q5u998BRYpMMQ1jNQ2WNac+J85fSUiNvI?= =?us-ascii?Q?KAvuBuLFA/UNDzegz3WqDQktS281+AEla+Ni8SnmiFkavsLnaUeqeLZYEvRm?= =?us-ascii?Q?oMaFIQ=3D=3D?= X-Forefront-Antispam-Report: CIP:198.47.23.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet201.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(7416014)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2026 13:55:26.9683 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 79507b20-54b6-4847-d5ff-08de58f4bb4f X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.195];Helo=[lewvzet201.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF00000203.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ5PPF0447EC1A8 Content-Type: text/plain; charset="utf-8" The enable_streams() API in v4l2 supports passing a bitmask to enable each pad/stream combination individually on any media subdev. Use this API instead of s_stream() API. Implement the enable_stream and disable_stream hooks in place of the stream-unaware s_stream hook. Remove the lock that was used to serialize stream starts/stops which is not required anymore since the v4l2-core serializes the enable/disable_streams() calls for the subdev. Reviewed-by: Tomi Valkeinen Signed-off-by: Rishikesh Donadkar --- drivers/media/platform/cadence/cdns-csi2rx.c | 108 +++++++++---------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/p= latform/cadence/cdns-csi2rx.c index 8c19f125da3e5..8e7af2da62262 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -125,12 +125,6 @@ struct csi2rx_priv { unsigned int count; int error_irq; =20 - /* - * Used to prevent race conditions between multiple, - * concurrent calls to start and stop. - */ - struct mutex lock; - void __iomem *base; struct clk *sys_clk; struct clk *p_clk; @@ -268,20 +262,21 @@ static int csi2rx_configure_ext_dphy(struct csi2rx_pr= iv *csi2rx) &csi2rx->source_subdev->entity.pads[csi2rx->source_pad]; union phy_configure_opts opts =3D { }; struct phy_configure_opts_mipi_dphy *cfg =3D &opts.mipi_dphy; - struct v4l2_subdev_format sd_fmt =3D { - .which =3D V4L2_SUBDEV_FORMAT_ACTIVE, - .pad =3D CSI2RX_PAD_SINK, - }; + struct v4l2_subdev_state *state; + struct v4l2_mbus_framefmt *framefmt; const struct csi2rx_fmt *fmt; s64 link_freq; int ret; =20 - ret =3D v4l2_subdev_call_state_active(&csi2rx->subdev, pad, get_fmt, - &sd_fmt); - if (ret < 0) - return ret; + state =3D v4l2_subdev_get_locked_active_state(&csi2rx->subdev); =20 - fmt =3D csi2rx_get_fmt_by_code(sd_fmt.format.code); + framefmt =3D v4l2_subdev_state_get_format(state, CSI2RX_PAD_SINK, 0); + if (!framefmt) { + dev_err(csi2rx->dev, "Did not find active sink format\n"); + return -EINVAL; + } + + fmt =3D csi2rx_get_fmt_by_code(framefmt->code); =20 link_freq =3D v4l2_get_link_freq(src_pad, fmt->bpp, 2 * csi2rx->num_lanes); @@ -401,16 +396,10 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) =20 reset_control_deassert(csi2rx->sys_rst); =20 - ret =3D v4l2_subdev_call(csi2rx->source_subdev, video, s_stream, true); - if (ret) - goto err_disable_sysclk; - clk_disable_unprepare(csi2rx->p_clk); =20 return 0; =20 -err_disable_sysclk: - clk_disable_unprepare(csi2rx->sys_clk); err_disable_pixclk: for (; i > 0; i--) { reset_control_assert(csi2rx->pixel_rst[i - 1]); @@ -459,9 +448,6 @@ static void csi2rx_stop(struct csi2rx_priv *csi2rx) reset_control_assert(csi2rx->p_rst); clk_disable_unprepare(csi2rx->p_clk); =20 - if (v4l2_subdev_call(csi2rx->source_subdev, video, s_stream, false)) - dev_warn(csi2rx->dev, "Couldn't disable our subdev\n"); - if (csi2rx->dphy) { writel(0, csi2rx->base + CSI2RX_DPHY_LANE_CTRL_REG); =20 @@ -485,38 +471,56 @@ static int csi2rx_log_status(struct v4l2_subdev *sd) return 0; } =20 -static int csi2rx_s_stream(struct v4l2_subdev *subdev, int enable) +static int csi2rx_enable_streams(struct v4l2_subdev *subdev, + struct v4l2_subdev_state *state, u32 pad, + u64 streams_mask) { struct csi2rx_priv *csi2rx =3D v4l2_subdev_to_csi2rx(subdev); - int ret =3D 0; - - mutex_lock(&csi2rx->lock); - - if (enable) { - /* - * If we're not the first users, there's no need to - * enable the whole controller. - */ - if (!csi2rx->count) { - ret =3D csi2rx_start(csi2rx); - if (ret) - goto out; - } + int ret; =20 - csi2rx->count++; - } else { - csi2rx->count--; + /* + * If we're not the first users, there's no need to + * enable the whole controller. + */ + if (!csi2rx->count) { + ret =3D csi2rx_start(csi2rx); + if (ret) + return ret; + } =20 - /* - * Let the last user turn off the lights. - */ + /* Start streaming on the source */ + ret =3D v4l2_subdev_enable_streams(csi2rx->source_subdev, csi2rx->source_= pad, + BIT_U64(0)); + if (ret) { + dev_err(csi2rx->dev, + "Failed to start streams %d on subdev\n", 0); if (!csi2rx->count) csi2rx_stop(csi2rx); + return ret; } =20 -out: - mutex_unlock(&csi2rx->lock); - return ret; + csi2rx->count++; + return 0; +} + +static int csi2rx_disable_streams(struct v4l2_subdev *subdev, + struct v4l2_subdev_state *state, u32 pad, + u64 streams_mask) +{ + struct csi2rx_priv *csi2rx =3D v4l2_subdev_to_csi2rx(subdev); + + if (v4l2_subdev_disable_streams(csi2rx->source_subdev, + csi2rx->source_pad, BIT_U64(0))) { + dev_err(csi2rx->dev, "Couldn't disable our subdev\n"); + } + + csi2rx->count--; + + /* Let the last user turn off the lights. */ + if (!csi2rx->count) + csi2rx_stop(csi2rx); + + return 0; } =20 static int csi2rx_enum_mbus_code(struct v4l2_subdev *subdev, @@ -611,10 +615,8 @@ static const struct v4l2_subdev_pad_ops csi2rx_pad_ops= =3D { .enum_mbus_code =3D csi2rx_enum_mbus_code, .get_fmt =3D v4l2_subdev_get_fmt, .set_fmt =3D csi2rx_set_fmt, -}; - -static const struct v4l2_subdev_video_ops csi2rx_video_ops =3D { - .s_stream =3D csi2rx_s_stream, + .enable_streams =3D csi2rx_enable_streams, + .disable_streams =3D csi2rx_disable_streams, }; =20 static const struct v4l2_subdev_core_ops csi2rx_core_ops =3D { @@ -623,7 +625,6 @@ static const struct v4l2_subdev_core_ops csi2rx_core_op= s =3D { =20 static const struct v4l2_subdev_ops csi2rx_subdev_ops =3D { .core =3D &csi2rx_core_ops, - .video =3D &csi2rx_video_ops, .pad =3D &csi2rx_pad_ops, }; =20 @@ -829,7 +830,6 @@ static int csi2rx_probe(struct platform_device *pdev) return -ENOMEM; platform_set_drvdata(pdev, csi2rx); csi2rx->dev =3D &pdev->dev; - mutex_init(&csi2rx->lock); =20 ret =3D csi2rx_get_resources(csi2rx, pdev); if (ret) --=20 2.34.1 From nobody Sun Feb 8 21:47:54 2026 Received: from DM5PR21CU001.outbound.protection.outlook.com (mail-centralusazon11011044.outbound.protection.outlook.com [52.101.62.44]) (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 989074963DC; Wed, 21 Jan 2026 13:55:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.62.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003735; cv=fail; b=N62ClCfqFEpGRpnVLZkpn6d9uVFewX54rUbduxbi1z8DwLN2/2ICNt/uLAu+DfbpH1VyzTpF3gNIaHcgLv8UFvWtRTh8KSaul1feSu7YCDueru72k+dGdQZx+f6m1hhR2OTPGc/WTHqhHQKK7r0KLvjwGGdHoJ5qOl1UFHS3mWY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003735; c=relaxed/simple; bh=5WxgwShzBDFN4NeXnY000poizPf2PZQgstvnKXIg8WU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bVm6QXe/Niru10OwHWtJXmPSoRImqNvUOv9Hz/VjFEkw9NH27KvA+pw82DoInTzoAlX3GKCaKdXnFLS4LvqKs9YHqCgcb6rXATwRX44NIQsb1ObRtjThyghd4/PGAFQ6Ydwd0ubRqSU7nJiXco7qZ5l+0Ewb9YYVQ9E86Y7J290= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=cqmtwEsB; arc=fail smtp.client-ip=52.101.62.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="cqmtwEsB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=f35zqrvDqm3foEoquzNro1xRMZjBh8n/JmxPNeF6bXfgY6MNeIDeZd06WUekKKx1NIQiRaTSCrp5o/w7c8SYCmGph3vPxw86LxXgo9k7NSFLoIEQqK6q0Exw15wd58BzHfuIb2DN9pYj1hGcNMxcQQE67p8v/MWywlstAtaorjPdco3ScwGxHZkvZbcxjM8fsEq1ijH05zpPVgwhuBYU1EctyktCdgqfek3/THahacct6TkNTXCoW+pB4ntXbZIFnls4BupvXoZY/PtxL5Fteay6PVxIe9aZWWguB5vGgkP9Ksx0HuGCVTz3rutbkxGibYtRFbbDvSzG92UHycKoBw== 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=JoFv2Gj9j7UCPGt/pr7u/AHRrjuKkIRly9huy0dMzOI=; b=tQ6JfKCZjVTKy8+n7Gs6DRnB0oJG49YGaW3uJU+NSKCyzulF8VlQTL1HOutOSHFmYJfAm4YyTG5iVQ+j6wtv6QJyN5twq75qcOnKuOeBFb+wxyXDxUwJuKABgF9xNDPe2sY/Q1OvyvmIZwNKR9NiQzfS5a+r33N/ea191nK/l2gu5exnagekRp+WUux9cmahEsDWGeflidyouQlaCHMMPzz3ah7EDUJ1AzYFO/Y8+ISkn/fVYxgV8OzWBgvdy8wZL9Qro+fgYGEVXtDsO1m88UwrnphDjqI1st6dhBVNF+2cIscb2rbMhqCvPd81sdx81AjWCXvzPWMo1yAJowlxOA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.194) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JoFv2Gj9j7UCPGt/pr7u/AHRrjuKkIRly9huy0dMzOI=; b=cqmtwEsBOaAzoq367oc18q+OiVUfwTJ5pYFH5ICcIMuIDQnTiZY0NV1bv2I83o+EElbvkW+ZceUN2kjQtpNSps39kRF781XHFPbGFHRFx5q16zxyZ01vlFHoJH2iNvwiqYTPYA+jPqjEbhgruupG5F+or4Y9syCQ02R7l1K7rj4= Received: from SJ0PR03CA0288.namprd03.prod.outlook.com (2603:10b6:a03:39e::23) by CY8PR10MB6778.namprd10.prod.outlook.com (2603:10b6:930:99::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.9; Wed, 21 Jan 2026 13:55:30 +0000 Received: from CO1PEPF000044F6.namprd21.prod.outlook.com (2603:10b6:a03:39e:cafe::4f) by SJ0PR03CA0288.outlook.office365.com (2603:10b6:a03:39e::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9542.10 via Frontend Transport; Wed, 21 Jan 2026 13:55:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.194; helo=lewvzet200.ext.ti.com; pr=C Received: from lewvzet200.ext.ti.com (198.47.23.194) by CO1PEPF000044F6.mail.protection.outlook.com (10.167.241.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9564.0 via Frontend Transport; Wed, 21 Jan 2026 13:55:30 +0000 Received: from DLEE201.ent.ti.com (157.170.170.76) by lewvzet200.ext.ti.com (10.4.14.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:55:29 -0600 Received: from DLEE210.ent.ti.com (157.170.170.112) by DLEE201.ent.ti.com (157.170.170.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:55:29 -0600 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DLEE210.ent.ti.com (157.170.170.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend Transport; Wed, 21 Jan 2026 07:55:29 -0600 Received: from ws.dhcp.ti.com (ws.dhcp.ti.com [172.24.233.149]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 60LDsPIE3104105; Wed, 21 Jan 2026 07:55:22 -0600 From: Rishikesh Donadkar To: , , CC: , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 08/18] media: ti: j721e-csi2rx: get number of contexts from device tree Date: Wed, 21 Jan 2026 19:24:14 +0530 Message-ID: <20260121135424.1185710-9-r-donadkar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260121135424.1185710-1-r-donadkar@ti.com> References: <20260121135424.1185710-1-r-donadkar@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F6:EE_|CY8PR10MB6778:EE_ X-MS-Office365-Filtering-Correlation-Id: e75970ca-40b6-4455-4e23-08de58f4bd49 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?rnSVbRS2wMcR1SpI2GPALkl2U3MPevCl2Riq1bjroxEDv78r1ZPL1r+Ovy6A?= =?us-ascii?Q?IsuZvIwoTc2VtNEVa55ik19WfRTIvaHRRjtZApeYBakBUsvQpwB83Ywa9W45?= =?us-ascii?Q?Pd74g2b82dDWgwMEovCrUKt7SCauWo/pEubf5s3l9wxBGx/dj1B4j3tI9ite?= =?us-ascii?Q?d8EfGLFAkrWIyWgqWkDfLFmGJ7jyngO/3wsAJbVLc1Gr5iJ+L/7mQVRLDiOH?= =?us-ascii?Q?eLYdpRTJ1jqXFgneLY5KqBz5sGLL2TI4/ElfaRHrif18DPYhqY3GtkrQG2aW?= =?us-ascii?Q?cnI/je0zlKE7yMgXOdts1jQ6vMVNgvK0ZsRpxdpIPIyHLed9R82qrqTV4a4l?= =?us-ascii?Q?fFo9EPnwEs3Y+Ew99ZQmORZQEz9faeANhrXEqIsCCS3ewgSt+8WO8/roeK1O?= =?us-ascii?Q?F9dmnRI18xCRJkyMQIgZPSUxtxPKsUMYp5qDaLIm3jUQfBd9M/Rs9ZXu3ddh?= =?us-ascii?Q?XMYJXpgSUNuNlKzxZpk+JiKnlCJPsJIUIb0TI3XmZtzc+TvA+ZxGaDUZ+UF9?= =?us-ascii?Q?gH6jDvKkwKnyUvlANrYiQdHJe+u3ncr7fmsF7P5ave6DDUSEfO0k68JsXbg9?= =?us-ascii?Q?sVDZkYmUn0g0gqMRwJ77efbiwS3kYHmlkiyCeCW2wOzxC2zLlq7Tl8ZDp+j/?= =?us-ascii?Q?xjkqChIEYZ5Zd/767qfuAhIC4WtM9eHIhzaj/C/QwcJLoO7s/A2WKe/pjCG9?= =?us-ascii?Q?/bLlvYAIOZKJFXnGm/8AcGjQ9EDfKzidgRKFMzRdHZobP2qRC5ijTqxvzyFX?= =?us-ascii?Q?+SSwq6qzZnlV4rGBqSQWTKxzdupRTH3Dd+9voEWGPGjHqdBjoka58PHldiWy?= =?us-ascii?Q?9jJVzkMwrS+zRTBT0kzj7heSNnVGhFPqiXt7YtxVztXPBSYf+WXffm+EgCIQ?= =?us-ascii?Q?G5qa8FBJmhzlfZIBtMsM008d25uQcY2JSl3M5aFztrxc4jkGERv9b0IfCVQC?= =?us-ascii?Q?mR86sHfor7mRxve/9R2uoLgdvu8bsdy0pENKSegbPMdhM36en2IkmioE3alq?= =?us-ascii?Q?qpFUe/Z30txjsl9C3v2yw0ypymBHAizYx8AXsuu375SNMKrRmEEywYFv+XYG?= =?us-ascii?Q?gRAPwEVZLzHamIPYHUqNVj/dkaAcK4UIG4SVBNb2fcrc24V9LfYFCXXWImIX?= =?us-ascii?Q?MGgh/G8FgpQmANtcKgKKjtrWkirddgpFqUElNC933yv+j8jCamoHutNV8fzT?= =?us-ascii?Q?bsozL/vgLho8FRXDi2vviDjR4F38n/rbVl2VCXRi1le/k+CUgDxocWlPwd5F?= =?us-ascii?Q?bwgJK1SNwE0GViT5Vadm5qRKUvq36UyyTexvMhoyLCHmD1TNqy4e4ycN5vch?= =?us-ascii?Q?tA1ApzOdOJeOIzuDV+HBXa/JvGkK1pAJDg3+DXVg/9jB4LCJdJqO0ApFag5R?= =?us-ascii?Q?3zG+P91jFnjDDWBUkBKqCi93+hX485nKQSXzTvhFrXrXg7kj+yJxsHVUuF3g?= =?us-ascii?Q?pfOBzsjTu34h6lzq94Ku8y8nhKIaiAyfKEbmgGwuz7bOHhPA24BGD+cugB7R?= =?us-ascii?Q?VDKpM6f+n9Kv0HJEBRYPp+c7jvoNFVCgsNBteP8jZ91dApfNenPetrDxV10p?= =?us-ascii?Q?lzYPdDx2SXwtQUW7amnhWH4LACfqSIkwtvTnRNG0Ex3Jv+/nraH5rlwRC2lx?= =?us-ascii?Q?KpEx5p1oaNq2HvxqvvP3sSrXP2E45dOw5CNxFVjeRvd8n3x37sOaolBU0AgM?= =?us-ascii?Q?2sx25g=3D=3D?= X-Forefront-Antispam-Report: CIP:198.47.23.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet200.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(1800799024)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2026 13:55:30.2828 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e75970ca-40b6-4455-4e23-08de58f4bd49 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.194];Helo=[lewvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F6.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR10MB6778 Content-Type: text/plain; charset="utf-8" From: Pratyush Yadav Different platforms that use this driver might have different number of DMA channels allocated for CSI. So only as many DMA contexts can be used as the number of DMA channels available. Get the number of channels provided via device tree and only configure that many contexts, and hence only that many pads. Reviewed-by: Yemike Abhilash Chandra Reviewed-by: Tomi Valkeinen Signed-off-by: Pratyush Yadav Co-developed-by: Jai Luthra Signed-off-by: Jai Luthra Signed-off-by: Rishikesh Donadkar --- .../platform/ti/j721e-csi2rx/j721e-csi2rx.c | 46 +++++++++++++------ 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/driver= s/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c index 8e1da5d3e11b6..aa038d1badc07 100644 --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c @@ -43,7 +43,7 @@ #define SHIM_PSI_CFG0_DST_TAG GENMASK(31, 16) =20 #define TI_CSI2RX_MAX_PIX_PER_CLK 4 -#define TI_CSI2RX_NUM_CTX 1 +#define TI_CSI2RX_MAX_CTX 32 =20 /* * There are no hard limits on the width or height. The DMA engine can han= dle @@ -56,8 +56,8 @@ =20 #define TI_CSI2RX_PAD_SINK 0 #define TI_CSI2RX_PAD_FIRST_SOURCE 1 -#define TI_CSI2RX_NUM_SOURCE_PADS 1 -#define TI_CSI2RX_NUM_PADS (1 + TI_CSI2RX_NUM_SOURCE_PADS) +#define TI_CSI2RX_MAX_SOURCE_PADS TI_CSI2RX_MAX_CTX +#define TI_CSI2RX_MAX_PADS (1 + TI_CSI2RX_MAX_SOURCE_PADS) =20 #define DRAIN_TIMEOUT_MS 50 #define DRAIN_BUFFER_SIZE SZ_32K @@ -116,14 +116,15 @@ struct ti_csi2rx_dev { struct device *dev; void __iomem *shim; unsigned int enable_count; + unsigned int num_ctx; struct v4l2_device v4l2_dev; struct media_device mdev; struct media_pipeline pipe; - struct media_pad pads[TI_CSI2RX_NUM_PADS]; + struct media_pad pads[TI_CSI2RX_MAX_PADS]; struct v4l2_async_notifier notifier; struct v4l2_subdev *source; struct v4l2_subdev subdev; - struct ti_csi2rx_ctx ctx[TI_CSI2RX_NUM_CTX]; + struct ti_csi2rx_ctx ctx[TI_CSI2RX_MAX_CTX]; u8 pix_per_clk; /* Buffer to drain stale data from PSI-L endpoint */ struct { @@ -458,7 +459,7 @@ static int csi_async_notifier_complete(struct v4l2_asyn= c_notifier *notifier) return ret; =20 /* Create and link video nodes for all DMA contexts */ - for (i =3D 0; i < TI_CSI2RX_NUM_CTX; i++) { + for (i =3D 0; i < csi->num_ctx; i++) { struct ti_csi2rx_ctx *ctx =3D &csi->ctx[i]; struct video_device *vdev =3D &ctx->vdev; =20 @@ -1252,10 +1253,11 @@ static int ti_csi2rx_v4l2_init(struct ti_csi2rx_dev= *csi) csi->pads[TI_CSI2RX_PAD_SINK].flags =3D MEDIA_PAD_FL_SINK; =20 for (unsigned int i =3D TI_CSI2RX_PAD_FIRST_SOURCE; - i < TI_CSI2RX_NUM_PADS; i++) + i < TI_CSI2RX_PAD_FIRST_SOURCE + csi->num_ctx; i++) csi->pads[i].flags =3D MEDIA_PAD_FL_SOURCE; =20 - ret =3D media_entity_pads_init(&sd->entity, ARRAY_SIZE(csi->pads), + ret =3D media_entity_pads_init(&sd->entity, + TI_CSI2RX_PAD_FIRST_SOURCE + csi->num_ctx, csi->pads); if (ret) goto unregister_media; @@ -1346,8 +1348,9 @@ static int ti_csi2rx_init_ctx(struct ti_csi2rx_ctx *c= tx) =20 static int ti_csi2rx_probe(struct platform_device *pdev) { + struct device_node *np =3D pdev->dev.of_node; struct ti_csi2rx_dev *csi; - int ret, i; + int ret =3D 0, i, count; =20 csi =3D devm_kzalloc(&pdev->dev, sizeof(*csi), GFP_KERNEL); if (!csi) @@ -1369,11 +1372,28 @@ static int ti_csi2rx_probe(struct platform_device *= pdev) if (!csi->drain.vaddr) return -ENOMEM; =20 + /* Only use as many contexts as the number of DMA channels allocated. */ + count =3D of_property_count_strings(np, "dma-names"); + if (count < 0) { + dev_err(csi->dev, "Failed to get DMA channel count: %d\n", count); + ret =3D count; + goto err_dma_chan; + } + + csi->num_ctx =3D count; + if (csi->num_ctx > TI_CSI2RX_MAX_CTX) { + dev_err(csi->dev, + "%u DMA channels passed. Maximum is %u.\n", + csi->num_ctx, TI_CSI2RX_MAX_CTX); + ret =3D -EINVAL; + goto err_dma_chan; + } + ret =3D ti_csi2rx_v4l2_init(csi); if (ret) - goto err_v4l2; + goto err_dma_chan; =20 - for (i =3D 0; i < TI_CSI2RX_NUM_CTX; i++) { + for (i =3D 0; i < csi->num_ctx; i++) { csi->ctx[i].idx =3D i; csi->ctx[i].csi =3D csi; ret =3D ti_csi2rx_init_ctx(&csi->ctx[i]); @@ -1400,7 +1420,7 @@ static int ti_csi2rx_probe(struct platform_device *pd= ev) for (; i >=3D 0; i--) ti_csi2rx_cleanup_ctx(&csi->ctx[i]); ti_csi2rx_cleanup_v4l2(csi); -err_v4l2: +err_dma_chan: dma_free_coherent(csi->dev, csi->drain.len, csi->drain.vaddr, csi->drain.paddr); return ret; @@ -1411,7 +1431,7 @@ static void ti_csi2rx_remove(struct platform_device *= pdev) struct ti_csi2rx_dev *csi =3D platform_get_drvdata(pdev); unsigned int i; =20 - for (i =3D 0; i < TI_CSI2RX_NUM_CTX; i++) + for (i =3D 0; i < csi->num_ctx; i++) ti_csi2rx_cleanup_ctx(&csi->ctx[i]); =20 ti_csi2rx_cleanup_notifier(csi); --=20 2.34.1 From nobody Sun Feb 8 21:47:54 2026 Received: from DM1PR04CU001.outbound.protection.outlook.com (mail-centralusazon11010041.outbound.protection.outlook.com [52.101.61.41]) (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 642CB49690A; Wed, 21 Jan 2026 13:55:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.61.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003741; cv=fail; b=EH3980gnSz9KcZRqZIC7xaxJsuSblLQ+XpUdJcztskvqWDcZyX9i4zmQtfwAj2hlI9mgkvfuDkcWs2wV4L5K/xj8CJrwlkHVqzwsx+rdxKe02a27Oo3si8Q8HhgOE4nfamSNR+YRb8BJ7AqIEsufqMcUt65cNPmXyOajsyUN0bY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003741; c=relaxed/simple; bh=IH3F7G+w5fetQiIALjKxf847cLClmOHyl7UDjNgl4Ss=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XrX1Teuso+38wog7tc6fvxwM4FM5hII58XGWQOQQq9Djb84r1zcyDvCqbHEnacFpla8EW+TrYYBpVvrdMk8PX3kxCjM5TPkDfRY4EJ9BHt+Sxky/nW+k6YtSvhSUxPRt35B84uVsLPeurKwfNKfFT40akXV+tcGKZCf2ZtnnlHQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=QS4aO91o; arc=fail smtp.client-ip=52.101.61.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="QS4aO91o" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QnvVOZtxukpmUJ9OTUM8vIav1k/3tLkSa3afev8nPNeXgkaKfgAQZX+8IHZpLF4BwwJlnvR3nolPKKB6ncjxouS90f8peKDlQUSI0n8w/HSpjrF9MwWrXyqCyoKboQzN7uIhYxHZb7+lFftFHuXIO2MP8rapbZn/bHiZXD9U6M/cE6nhBelmzT2mmQEaQJ3KFiZAcm9ytw1+i28HDijiQ55N7dvKYf4/rkiVyvu3uQdF5HP9qR9k87AlHKhuUp/3j573bMy588merkjltoQq1ne1GcIwElWrccUm4ODBFK9s+kamlc+CRU2mLDnejtLmqvS+qVRM7R42MQKnAofJoA== 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=MQ9vYNcNXMmrBjisIAL1F3J5QBDB51ZpGQQJNhw5C3M=; b=Ncgs1ivtKw2fIUngSWOqb4Tz+932SuiT10IY3tKYnbtjwO/INpv8f/5GG/e6bcRegwMUtR2rMsQCowD6rxVn9Sj29sZbzSpF5k4xA3MR0MkY5k/LCl3VALwUUC1ZBty9jEHqdPGs+KPLhOiyKe0vFWjhY7Th2kDAbuOMHCCLjVBYtmxTbmjTFj8Lz6mna4WiWceL88hMj1xicpvABSMW0TkGMsxc7p83A15UVCNgLCZp++J2cjU7nkkoyAqSiA1VnaqwCypJ84mHjx2XTV9nCzLdOXAbxORLUZXCLkTDXrNiyrZ4yCd2XVRohf/LGyGUuuu2D9zMB9kUufu6TqrGJA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.194) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MQ9vYNcNXMmrBjisIAL1F3J5QBDB51ZpGQQJNhw5C3M=; b=QS4aO91oV7QPF7iYRa5dF2WfeHijrOpsqjXiBPE4sYcT6jGQghASDLDbuWNPDj+blGhK+LTDDXDl/WDMMhBd5vodQErCA1iH+Hu0VLkpyes6o9GA0kxcYrkXp3KRE2wCTscm94V7jFRonT3hfFkzFOsKYgdxmqTP8Wz5s4n4Qu8= Received: from BY5PR13CA0023.namprd13.prod.outlook.com (2603:10b6:a03:180::36) by CO1PR10MB4484.namprd10.prod.outlook.com (2603:10b6:303:90::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.11; Wed, 21 Jan 2026 13:55:37 +0000 Received: from CO1PEPF000044F8.namprd21.prod.outlook.com (2603:10b6:a03:180:cafe::8) by BY5PR13CA0023.outlook.office365.com (2603:10b6:a03:180::36) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9542.9 via Frontend Transport; Wed, 21 Jan 2026 13:55:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.194; helo=lewvzet200.ext.ti.com; pr=C Received: from lewvzet200.ext.ti.com (198.47.23.194) by CO1PEPF000044F8.mail.protection.outlook.com (10.167.241.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9564.0 via Frontend Transport; Wed, 21 Jan 2026 13:55:37 +0000 Received: from DLEE201.ent.ti.com (157.170.170.76) by lewvzet200.ext.ti.com (10.4.14.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:55:36 -0600 Received: from DLEE208.ent.ti.com (157.170.170.97) by DLEE201.ent.ti.com (157.170.170.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:55:36 -0600 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DLEE208.ent.ti.com (157.170.170.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend Transport; Wed, 21 Jan 2026 07:55:36 -0600 Received: from ws.dhcp.ti.com (ws.dhcp.ti.com [172.24.233.149]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 60LDsPIF3104105; Wed, 21 Jan 2026 07:55:29 -0600 From: Rishikesh Donadkar To: , , CC: , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 09/18] media: cadence: csi2rx: add get_frame_desc wrapper Date: Wed, 21 Jan 2026 19:24:15 +0530 Message-ID: <20260121135424.1185710-10-r-donadkar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260121135424.1185710-1-r-donadkar@ti.com> References: <20260121135424.1185710-1-r-donadkar@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F8:EE_|CO1PR10MB4484:EE_ X-MS-Office365-Filtering-Correlation-Id: d5eb5419-f3d3-4a53-2e8c-08de58f4c161 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?0kKy3uOjQaaf/RAQZsmZUFIiMu6xT8XjL8Cpv7HK2ZtR16RsmdsT5oS359pN?= =?us-ascii?Q?D1Nbvd6p6hGLXNQ+lFVfmmsvJRBzIUcAVMLySE2jtMsytc4SYCHpYgiNY/x7?= =?us-ascii?Q?60VSNn6jRcP/wabGULdcEImDpubiPzHNqcynLKkhV3KDjQY4kmwNlACJfLK3?= =?us-ascii?Q?CBOf8H9UTkBg5JmhveIaoPEvKRI6Ex3htGB3P7MFhNJ3j8dIHbNKfLdt7FRS?= =?us-ascii?Q?2Qqca6iseTgHmwOye6HhrGhfzzXWEHnejevNnkxalL06HbXpxa+hV/78uJIn?= =?us-ascii?Q?IIQ2YOAjIqBfKf3cvy5QtWEhMxZFahdo+Nt91kqrQPbQXblmn5AjGB7kY3ej?= =?us-ascii?Q?qjTf5viPaYrksiiv2rbZxJ4LugRNSkw+HFXs/O544MXrg7IixIlgojFV8eHX?= =?us-ascii?Q?D47wROmfTbtD1h9Ih28Ke65BIBhhZ7v7TsnL1foa0MFb4uhIgt4BZV4drSkP?= =?us-ascii?Q?qACukSNk4lfZgvSHaD1EQSh5liy1j6UY5asujGeOMid6k1IhzXD8jpwHU4V9?= =?us-ascii?Q?6USHrTfjdy7PJnOb5AikTc8UJTMBQ+trrjYmWgx5jbfZIuF+g7o/tnwff71+?= =?us-ascii?Q?ZdT6EispfktLBNJaZjk86XHzIv9w7ZPKbja2lN23NZV70upA473k7SGOSgtU?= =?us-ascii?Q?P2VnwzHM9EEF9BJt0c0CedXJOAHvX0eeL8dawD51eAzaQfPz0+ERyXbQmuGH?= =?us-ascii?Q?nHhYFSrQQ0CQaxaZ0v3BlGCZ9nZpypIZCWECF9fJKXSxOjF21qCkNGV7VcVj?= =?us-ascii?Q?oAprMyrhdQOdf0kSF/TRV3UumKpANr/DpgC05Y/M7Y/HJKMCD0Lz1ER6Swmh?= =?us-ascii?Q?elxX/ss5xhaDTU4QyMV22KG47iu2WWMU2HIYK6YJdV6W9c02q9gi7rBScgjT?= =?us-ascii?Q?bokRLgfE9PxE0dl7DGHIhcJCVRFj76H2XJ8CclC+gAipj1eEaD/t1nYs16+d?= =?us-ascii?Q?GtgGavPE1VUnGNHoPK5E0uvTcG/3d1p46uZblFq39vDfnccd5X49Rx1tEdnZ?= =?us-ascii?Q?EHN8+kNcywU+geY15Y7HEbPTWVkk8rDjn9X3sW/4LAim0D72yCM7z/O9S0vY?= =?us-ascii?Q?kkuQfgL+SPsK1zdv7O4QLYo4Ra0S8pAxKRWIBOWSPsYJU+R8xNIzR31V6LOp?= =?us-ascii?Q?L5IPgKPumn52cS2tZFjlDimXyL+SXNlcD5lXL5/gJSaQ9DRtDWb+7pKx8A48?= =?us-ascii?Q?SAFp9401DLgydgW/9eGHS7TGN1dRaGNWwbZzLZILPlkiWB5f24K0pQb8xO3Q?= =?us-ascii?Q?yym1Rg+UWHoXqLWZErCsbK3Q11BQ7kDrEb6VZoZIZj34E4UwGC4cagshWtrz?= =?us-ascii?Q?Htb0AOTR08gW8F3uQIpdB+4H5vNcb+l9+L8KiM1M/fJifNOndnUbgfFVOYOT?= =?us-ascii?Q?OrE9UBbui4HoTIF6lRgw1tfJL3xglVt5XYZovJMzX7GDJhpG9l3rpwPgCr73?= =?us-ascii?Q?Dk3tINELIIUZnwuqkFWuJjr0sMrXGPBgCmlfq9JUTRqQNRNSmfHwH2HKxFtQ?= =?us-ascii?Q?mEcxpGWCiy1UM5gUsU53jvepcweN8etk2l8yccqU3MeE2DY4B5w6eEoUWODt?= =?us-ascii?Q?X4GsydqmE+WvBgwQgY7X8V04q5DEnMVeKFsGNWuA0hHBEmLIkrNfylftUUw0?= =?us-ascii?Q?valb//aeuTt1cEF5nH7tZQn7yMPpdR6bSyjPM36lX7h9?= X-Forefront-Antispam-Report: CIP:198.47.23.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet200.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2026 13:55:37.1541 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d5eb5419-f3d3-4a53-2e8c-08de58f4c161 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.194];Helo=[lewvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F8.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4484 Content-Type: text/plain; charset="utf-8" From: Pratyush Yadav J721E wrapper CSI2RX driver needs to get the frame descriptor from the source to find out info about virtual channel. This driver itself does not touch the routing or virtual channels in any way. So simply pass the descriptor through from the source. Signed-off-by: Pratyush Yadav Signed-off-by: Jai Luthra Reviewed-by: Jacopo Mondi Reviewed-by: Changhuang Liang Reviewed-by: Laurent Pinchart Reviewed-by: Yemike Abhilash Chandra Reviewed-by: Tomi Valkeinen Signed-off-by: Rishikesh Donadkar --- drivers/media/platform/cadence/cdns-csi2rx.c | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/p= latform/cadence/cdns-csi2rx.c index 8e7af2da62262..65c6acb02f85b 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -229,6 +229,21 @@ static const struct csi2rx_fmt *csi2rx_get_fmt_by_code= (u32 code) return NULL; } =20 +static int csi2rx_get_frame_desc_from_source(struct csi2rx_priv *csi2rx, + struct v4l2_mbus_frame_desc *fd) +{ + struct media_pad *remote_pad; + + remote_pad =3D media_entity_remote_source_pad_unique(&csi2rx->subdev.enti= ty); + if (!remote_pad) { + dev_err(csi2rx->dev, "No remote pad found for sink\n"); + return -ENODEV; + } + + return v4l2_subdev_call(csi2rx->source_subdev, pad, get_frame_desc, + remote_pad->index, fd); +} + static inline struct csi2rx_priv *v4l2_subdev_to_csi2rx(struct v4l2_subdev *subdev) { @@ -611,12 +626,21 @@ int cdns_csi2rx_negotiate_ppc(struct v4l2_subdev *sub= dev, unsigned int pad, } EXPORT_SYMBOL_FOR_MODULES(cdns_csi2rx_negotiate_ppc, "j721e-csi2rx"); =20 +static int csi2rx_get_frame_desc(struct v4l2_subdev *subdev, unsigned int = pad, + struct v4l2_mbus_frame_desc *fd) +{ + struct csi2rx_priv *csi2rx =3D v4l2_subdev_to_csi2rx(subdev); + + return csi2rx_get_frame_desc_from_source(csi2rx, fd); +} + static const struct v4l2_subdev_pad_ops csi2rx_pad_ops =3D { .enum_mbus_code =3D csi2rx_enum_mbus_code, .get_fmt =3D v4l2_subdev_get_fmt, .set_fmt =3D csi2rx_set_fmt, .enable_streams =3D csi2rx_enable_streams, .disable_streams =3D csi2rx_disable_streams, + .get_frame_desc =3D csi2rx_get_frame_desc, }; =20 static const struct v4l2_subdev_core_ops csi2rx_core_ops =3D { --=20 2.34.1 From nobody Sun Feb 8 21:47:54 2026 Received: from CH1PR05CU001.outbound.protection.outlook.com (mail-northcentralusazon11010027.outbound.protection.outlook.com [52.101.193.27]) (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 AF38C49553B; Wed, 21 Jan 2026 13:55:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.193.27 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003751; cv=fail; b=Nj76xepvC3L0tvqxfXcy5fhBRlYVVi1EqMyqjzVDj+wViALuthif7czRIJMg7PijmSX76PD0FzFTr30DNgAhhmH2LpHeSu7Un7BDK211CBUa+b7Z/vF/t43eHKUNLoGmg3VB4SLrEsUcOovSFUif+IfCX3PstOLI/Ni5vtHMSVE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003751; c=relaxed/simple; bh=EnKzAVgrka77LP26Zt9rYBkJ4+lj61TViRMgwNk1Gp8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TjTap1O6PpDDh7JWmYLO2DT0vOKQUeDER+NVXppJKiRFnFk9Hr1VWSqp4mQPXHyqIypZ/oUZhYDmlj9+VWaPuYjwxg904M/h1UBeU5Z1gon4rvIs6uFLL4u835UwNunpwPXy3Xz3BllssS08RGijXOg7sw76OgFZP2ymzb2J7Ww= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=cmxobkdD; arc=fail smtp.client-ip=52.101.193.27 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="cmxobkdD" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SH3UsJmP7YucQv2o8cvq7kvL7tFGyV8eifuqi5C7o8S3msS3sPvK3Bo2KM2aONHzhasebXdAOogg2wUA1sMsO1TDDYDxbkaeQ+K1tQgScUAmFcZQGFrAiOUHC/eevPeB2RSBdtPKtE77UdPPXTqlQKnYUvoN6OuX1vxUBpX6Qmbn+q+rteYYS7msp/3YjoPEWxrv9o8d084X9Mr5d0sO2Zu8FDtXBJg8e4CcWDeaBx3Vi90HYpZsLar0+c8aorXq/vGDlX8p1sqW7haSL/9SCruKNrjM+G13zqPCDGgMBnaK/ig66Lb7kDS27BBfdYfYzsCcK7nfHOzLJh252AXwcw== 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=oRQb1xfhobyyQd8pxONvKgzkLVyWHBaYmUmTKv81df8=; b=HNiAs5p7GIbzfnCih2jmfZiViv2X7/T65V8C3tvYh41fjEj/0mElIceuDAcAH5j10e5X8UY8CPy1+26PziOeblaVL7uQJ/A5vxK225+UnUZIse62tXLm4RBfuYDvFV2w+o31eiVfUorYkGCF7n/PLHYtnkadzK33evBDXMiMKthcnMlH2clb6PnQxnNZ7GuIuBjrvECFvy9vcIPN+4mNA9RuRRRNyAvhZ3WZiLuBT3/bMfpZ4lq22Ua3+tMrItL+kdgpihQxCBwEMNyGflsjb89G+ELjt7/znXGwKva4JA5JfTTpNxtd95smdO0iCyBc9GLSFu8qdiba6ZM85dJFOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.194) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oRQb1xfhobyyQd8pxONvKgzkLVyWHBaYmUmTKv81df8=; b=cmxobkdDR30tF/DPEZOT3qIlG99F4hd71cDBMbmL9Y7UNCYuTNm5XTIyI6hV5wfe9wzXcflSUDGDB1rcUW37FFZ95gNce05Yx73Gr/R8doYnVP5GBAjlGUAZJVmetFOndTBBRDn2lBSiMhwpaTik2pHWR6Fi6M/hm9z6x37Hy/I= Received: from BY5PR04CA0025.namprd04.prod.outlook.com (2603:10b6:a03:1d0::35) by SA1PR10MB6295.namprd10.prod.outlook.com (2603:10b6:806:252::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.6; Wed, 21 Jan 2026 13:55:47 +0000 Received: from CO1PEPF000042AD.namprd03.prod.outlook.com (2603:10b6:a03:1d0:cafe::41) by BY5PR04CA0025.outlook.office365.com (2603:10b6:a03:1d0::35) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9542.10 via Frontend Transport; Wed, 21 Jan 2026 13:55:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.194; helo=flwvzet200.ext.ti.com; pr=C Received: from flwvzet200.ext.ti.com (198.47.21.194) by CO1PEPF000042AD.mail.protection.outlook.com (10.167.243.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.4 via Frontend Transport; Wed, 21 Jan 2026 13:55:44 +0000 Received: from DFLE201.ent.ti.com (10.64.6.59) by flwvzet200.ext.ti.com (10.248.192.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:55:43 -0600 Received: from DFLE208.ent.ti.com (10.64.6.66) by DFLE201.ent.ti.com (10.64.6.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:55:43 -0600 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE208.ent.ti.com (10.64.6.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend Transport; Wed, 21 Jan 2026 07:55:43 -0600 Received: from ws.dhcp.ti.com (ws.dhcp.ti.com [172.24.233.149]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 60LDsPIG3104105; Wed, 21 Jan 2026 07:55:36 -0600 From: Rishikesh Donadkar To: , , CC: , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 10/18] media: ti: j721e-csi2rx: add support for processing virtual channels Date: Wed, 21 Jan 2026 19:24:16 +0530 Message-ID: <20260121135424.1185710-11-r-donadkar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260121135424.1185710-1-r-donadkar@ti.com> References: <20260121135424.1185710-1-r-donadkar@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042AD:EE_|SA1PR10MB6295:EE_ X-MS-Office365-Filtering-Correlation-Id: 809cd43c-7ab5-4315-a970-08de58f4c5e8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?og4mQD/mQ1VF2OJmUThC8aWdEDa9eY4+9H7oRt6q7dNz/PtLG78EyTQ5DQeF?= =?us-ascii?Q?W9gLXaD2cgqSb7ycXFArvqnbxBQk4FWPKK/y97RdrQxU6pnEwzyVxdWMa5cU?= =?us-ascii?Q?dYynbvBgeJyAX7JF4VlSdHUvPleo25jRRy4iTjPobH+Crfcvhqbwiu7T3cnd?= =?us-ascii?Q?o5OH4pcdqGvgBfFf2ghanbt+eyL2r0OQa3bfX4KeWwBL5OYb1cHnpgdViI9r?= =?us-ascii?Q?khltcKQeXvmCqiCobwIbb11MB3lbX9nRel6V15U8mMT5R/VfOT190+IzmtEP?= =?us-ascii?Q?o5e4JG2AukLRYjQ96Sm/3BPLI7azjK9UkwZ3Wxn2ZqjoxhFnHglt/ZxXSYyd?= =?us-ascii?Q?x5i2uX5iIKx7fQ0AgwjBwybeSHWpcIhtKaOoCqPPBYxC2e4PWkYAbv5Cj+RR?= =?us-ascii?Q?weEts8Y+SByUPaq7w9SJGAYo0036vzkcx3R42PIGAtnTG6a0PpzD6gEaFloy?= =?us-ascii?Q?CdXjmVuMThLIMmeOXNhs34zepv59fRYULKcT0Sxm+SgomeD8f4hkuX+yIP3g?= =?us-ascii?Q?aN3kEQ458VGIYamftHJEi/vV8ZrVOkCAUA3VJXEoWtb2JqQURpmKFDmfCfGc?= =?us-ascii?Q?Vlaqf2Q4y/90cRGfcz9Z+EFH+SdjfUxd/EdngzJC0VF8SxTt3nVoLRBXf9E0?= =?us-ascii?Q?e6iKtLhSVdjXZzLU/ppYGnYRl+sL6Z/LzEwIe7jIWh/Jwpd47QEvmuVd+w5F?= =?us-ascii?Q?Af8chPUOT+ODMcSA7qese/E/HN7J2Klz7ZYNtTTz2EEzMrR2bIFOpWCYGAZF?= =?us-ascii?Q?4MGpGpfQB1oYYLbiL0EaZEJD10684U/DaF90ZQMEWOwRsGnzdSLc8R3qmNUk?= =?us-ascii?Q?ioYpgRya/dt4mifm/mkHzdqaBLV298STPD3Pjd3xAW4m+V0SgXJ+O20c2hTy?= =?us-ascii?Q?HKeBt3ao07aizEYMvSW7aB3QXQv9k7VM0jRjZKd5gxm+fhDgiRIIYbeB+YEN?= =?us-ascii?Q?qph5LPmDq5a2rdP+XQ6rygT2rYW9jKXwRmZDgsf36q6ZPvCzGWtK14EC9NL5?= =?us-ascii?Q?6+QVFc1BdId6hv/D9likWMno4cqgD691jqsDanfEomHA0sOoIaIku1kyn8GL?= =?us-ascii?Q?E3W4c1+mWSsB44ZTCa5AyDtb/GLJNusnMetvNUHEWTKk/fjSblgzEGF9/IYI?= =?us-ascii?Q?/HSds6L+i9P5nXHf0ilBEU6mPUxFxM90t/WKU87b8rlmDkrBjVWme01+TX2z?= =?us-ascii?Q?dX/SRn0/5ZXcFn4snkexeJIaTwPPQPLqbPtdCiyh22I15qrA1+1zB5cHJjBT?= =?us-ascii?Q?QBUTZ+Go8QlMK51OjNZENQvK3k0AbiIr4JhdmLubxbOFR1+Tac0lgbSBPPZu?= =?us-ascii?Q?yD3zmTnWVKIOq8D5jcow3EFY05BbGEcakCzGblAXe1PvmUMmvX33prDTw5z3?= =?us-ascii?Q?SNYujaudiZy0fdAixtX0x69HQY5XUeWb3O/js/s81E4GiAKGqaHAx0jDZLox?= =?us-ascii?Q?fXLHTEkDOegQdSmmyEexRcAxHfpsj2+zi94wJGgTWuD+1d81YpLxlV6j0LDL?= =?us-ascii?Q?a8Q8oWWnipnpy1ljPHZk7pYHMmI3OZYFXd8B4clQOa0umNvG9vl+qoehzTk5?= =?us-ascii?Q?NcQwz52AjdKJ8XAX1yJeAW8wE1LaUO4juUcQq+rcEOYsuvyAysPOf3bIspOr?= =?us-ascii?Q?sqZtrRTtx0Fsx8e+2T0pgMsdXNondHlS1u4Vcnk90n99LVV4avvwkLorfa/W?= =?us-ascii?Q?5RuUig=3D=3D?= X-Forefront-Antispam-Report: CIP:198.47.21.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet200.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2026 13:55:44.7534 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 809cd43c-7ab5-4315-a970-08de58f4c5e8 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.194];Helo=[flwvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000042AD.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB6295 Content-Type: text/plain; charset="utf-8" From: Jai Luthra Use get_frame_desc() to get the frame desc from the connected source, and use the provided virtual channel instead of VC 0. As we don't support multiple streams yet, we will just always use stream 0. If the source doesn't support get_frame_desc(), fall back to the previous method of always capturing virtual channel 0. Reviewed-by: Yemike Abhilash Chandra Co-developed-by: Pratyush Yadav Signed-off-by: Pratyush Yadav Signed-off-by: Jai Luthra Signed-off-by: Rishikesh Donadkar Reviewed-by: Tomi Valkeinen --- .../platform/ti/j721e-csi2rx/j721e-csi2rx.c | 50 ++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/driver= s/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c index aa038d1badc07..81c86e2cc4a50 100644 --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c @@ -32,6 +32,7 @@ #define SHIM_DMACNTX_YUV422 GENMASK(27, 26) #define SHIM_DMACNTX_DUAL_PCK_CFG BIT(24) #define SHIM_DMACNTX_SIZE GENMASK(21, 20) +#define SHIM_DMACNTX_VC GENMASK(9, 6) #define SHIM_DMACNTX_FMT GENMASK(5, 0) #define SHIM_DMACNTX_YUV422_MODE_11 3 #define SHIM_DMACNTX_SIZE_8 0 @@ -110,6 +111,9 @@ struct ti_csi2rx_ctx { struct media_pad pad; u32 sequence; u32 idx; + u32 vc; + u32 dt; + u32 stream; }; =20 struct ti_csi2rx_dev { @@ -569,7 +573,7 @@ static void ti_csi2rx_setup_shim(struct ti_csi2rx_ctx *= ctx) ti_csi2rx_request_max_ppc(csi); =20 reg =3D SHIM_DMACNTX_EN; - reg |=3D FIELD_PREP(SHIM_DMACNTX_FMT, fmt->csi_dt); + reg |=3D FIELD_PREP(SHIM_DMACNTX_FMT, ctx->dt); =20 /* * The hardware assumes incoming YUV422 8-bit data on MIPI CSI2 bus @@ -609,6 +613,7 @@ static void ti_csi2rx_setup_shim(struct ti_csi2rx_ctx *= ctx) } =20 reg |=3D FIELD_PREP(SHIM_DMACNTX_SIZE, fmt->size); + reg |=3D FIELD_PREP(SHIM_DMACNTX_VC, ctx->vc); =20 writel(reg, csi->shim + SHIM_DMACNTX(ctx->idx)); =20 @@ -883,12 +888,46 @@ static void ti_csi2rx_buffer_queue(struct vb2_buffer = *vb) } } =20 +static int ti_csi2rx_get_vc_and_dt(struct ti_csi2rx_ctx *ctx) +{ + struct ti_csi2rx_dev *csi =3D ctx->csi; + struct v4l2_mbus_frame_desc fd; + struct media_pad *pad; + int ret, i; + + pad =3D media_entity_remote_pad_unique(&csi->subdev.entity, MEDIA_PAD_FL_= SOURCE); + if (!pad) + return -ENODEV; + + ret =3D v4l2_subdev_call(csi->source, pad, get_frame_desc, pad->index, &f= d); + if (ret) + return ret; + + if (fd.type !=3D V4L2_MBUS_FRAME_DESC_TYPE_CSI2) + return -EINVAL; + + for (i =3D 0; i < fd.num_entries; i++) { + if (ctx->stream =3D=3D fd.entry[i].stream) { + ctx->vc =3D fd.entry[i].bus.csi2.vc; + ctx->dt =3D fd.entry[i].bus.csi2.dt; + break; + } + + /* Return error if no matching stream found */ + if (i =3D=3D fd.num_entries) + return -EINVAL; + } + + return 0; +} + static int ti_csi2rx_start_streaming(struct vb2_queue *vq, unsigned int co= unt) { struct ti_csi2rx_ctx *ctx =3D vb2_get_drv_priv(vq); struct ti_csi2rx_dev *csi =3D ctx->csi; struct ti_csi2rx_dma *dma =3D &ctx->dma; struct ti_csi2rx_buffer *buf; + const struct ti_csi2rx_fmt *fmt; unsigned long flags; int ret =3D 0; =20 @@ -903,6 +942,15 @@ static int ti_csi2rx_start_streaming(struct vb2_queue = *vq, unsigned int count) if (ret) goto err; =20 + ret =3D ti_csi2rx_get_vc_and_dt(ctx); + if (ret =3D=3D -ENOIOCTLCMD) { + ctx->vc =3D 0; + fmt =3D find_format_by_fourcc(ctx->v_fmt.fmt.pix.pixelformat); + ctx->dt =3D fmt->csi_dt; + } else if (ret < 0) { + goto err; + } + ti_csi2rx_setup_shim(ctx); =20 ctx->sequence =3D 0; --=20 2.34.1 From nobody Sun Feb 8 21:47:54 2026 Received: from DM1PR04CU001.outbound.protection.outlook.com (mail-centralusazon11010035.outbound.protection.outlook.com [52.101.61.35]) (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 DECE84A139F; Wed, 21 Jan 2026 13:55:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.61.35 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003756; cv=fail; b=eQ0lwlmgN4xcZc+89f8fFfQc5VjOzy6B6im1qTBolIj+iSRitr4QqPleOKh9wpj7NHaFhyqDkIhPMLy+7FhiLTusoN3r+hqFmgNOWWtoBFl+IOj6ybIZsY3bsR6UgJ9icPLc1C+xfcYMiT+DjfTAqM7Bqm22dP9+StEV8cf70jk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003756; c=relaxed/simple; bh=ryeu9Zb3VQrKbwrK/RNa/VwiR0Q0X4WQJ90Gr/lJDGk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LUfh1kBsdoWhswJ1+ON0gNwPqXael1BfcXpwCutab2XKrYQBQpx1wxFkl7wVSMi0IXrsT2gIRoP8YsJllqRL+LNFJBqpC32H+h1vq0laUgwwoRrtVYMZEv3Ik2jR2hPvHsUpW4xVPazdf8dJq91TI3plHTzep9cSgwViGcRVCV0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=MwgFav9b; arc=fail smtp.client-ip=52.101.61.35 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="MwgFav9b" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NBDCTAI5VQuGcn9Um5uXfE0WKGaiMFr1mDA7VaJYX+n9pkKOm4dZvCHx/RYJBG0DBztHTVxqCx9hwCiYxnoKvOxE8yIAeORja5VjFjmuejDexe8UB/CTRNiGCvB6oml9gxdKLaY3L6N4dIfM0/gwN+iG1A3XBmYvxMm56rbNkOgQuCef2e5a31zFxGNDVPSWwFQ9ui8njOZly9RzBuLFGeko9z9T78s6RwSHgyP1YRipxz42doHm2wGgbuvNZM8ac/aCczKAC/qswXUamKinV7ZXu5lsQbOtRniUGJZmdN3RdQVIMe1vwVPb6RpWwwJY6Q2on5dBHOu7c5n/7piJTw== 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=OgAeiagqUeNXwACET1h2vrSfF7HWyCytFR5kzgQ4fUY=; b=dFFYgQxk8xlyGSuM/Vo9QiVZcp3U+lgl2Op2RR00dcnK9QDk01xhaXS8jrilulq9lQcB7H8vPPfGNpiTAl1mFVtjkm+asgWkKxPGa8e+1NDBSd4Omb06IrAEyovdYzrvxwn+qn8+v/dX5X68r8LoUBItE/Vh2877kcKtFMuQEqn2dG13/56vGwzF9mo125St66pX7uVzCehJATLVhGBDrAVccnX+xTwvdHrl+nT0NyvyvWYu/h3fYSkHnrOWBqjkLyLmZif1Ue8/OuEVPfleZ8O1Duzlsmm7xUM7v7IocBmPNdOed6NYtA9kJ3XFJvo7qiCp01oNRdpeRtFQm+teJw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.195) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OgAeiagqUeNXwACET1h2vrSfF7HWyCytFR5kzgQ4fUY=; b=MwgFav9bY6oOo9zZNlnBR78mOPbin3GkY+3R4Tl/7+qMDZLEmZpUOboHfu4AjSv2QChCXgR5fgl+6odkiomOGVZlBtVRTjmpTphdThm1jl1mgSLksF1imGUFXFpGw+JT5kXxsJgMig3xN3hYB42bCVB3STBi4Muhz7KP5tieaP8= Received: from SJ0PR05CA0055.namprd05.prod.outlook.com (2603:10b6:a03:33f::30) by PH7PR10MB6458.namprd10.prod.outlook.com (2603:10b6:510:1ed::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.9; Wed, 21 Jan 2026 13:55:51 +0000 Received: from SJ5PEPF00000208.namprd05.prod.outlook.com (2603:10b6:a03:33f:cafe::3f) by SJ0PR05CA0055.outlook.office365.com (2603:10b6:a03:33f::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9520.4 via Frontend Transport; Wed, 21 Jan 2026 13:55:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.195; helo=lewvzet201.ext.ti.com; pr=C Received: from lewvzet201.ext.ti.com (198.47.23.195) by SJ5PEPF00000208.mail.protection.outlook.com (10.167.244.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.4 via Frontend Transport; Wed, 21 Jan 2026 13:55:51 +0000 Received: from DLEE202.ent.ti.com (157.170.170.77) by lewvzet201.ext.ti.com (10.4.14.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:55:50 -0600 Received: from DLEE206.ent.ti.com (157.170.170.90) by DLEE202.ent.ti.com (157.170.170.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:55:50 -0600 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DLEE206.ent.ti.com (157.170.170.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend Transport; Wed, 21 Jan 2026 07:55:50 -0600 Received: from ws.dhcp.ti.com (ws.dhcp.ti.com [172.24.233.149]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 60LDsPIH3104105; Wed, 21 Jan 2026 07:55:43 -0600 From: Rishikesh Donadkar To: , , CC: , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 11/18] media: cadence: csi2rx: add multistream support Date: Wed, 21 Jan 2026 19:24:17 +0530 Message-ID: <20260121135424.1185710-12-r-donadkar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260121135424.1185710-1-r-donadkar@ti.com> References: <20260121135424.1185710-1-r-donadkar@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF00000208:EE_|PH7PR10MB6458:EE_ X-MS-Office365-Filtering-Correlation-Id: 1676de88-7ba1-4fe8-d548-08de58f4c9e1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|7416014|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?GC7ihBmu/noQtWPLrdh5WYgk3brV+1V9VIOPM3jDtYioVodGxTZwdBaNGhvJ?= =?us-ascii?Q?f8/GqBv01+Cav3l10zpbt4jS6DQt2k2rRrVxKVLgRvGRCHpJ1NS10q7BFLZk?= =?us-ascii?Q?Gh4gQRVwlWrf144atlisuTmGTBqMSlpoEsIr2NZ4ocffnFNGhl6LFxdam2aM?= =?us-ascii?Q?gipt8b5Ra+g1Gt7W1AhJwsYIqBAT1Dw3Nh2Y5Dn9Lqk+cM971+GT0A8IxE8L?= =?us-ascii?Q?Zuq02ZJedC+ggI+oj4ai6yRWt96QE/Vm6FXdXv0CpRxoIn3JzlYCfHhgGxKg?= =?us-ascii?Q?QvovWecWWWKfhK0SL1Dgr+wUCh7rgsgyUECfPBXmiSzsA+cqdbI4TOtIJP68?= =?us-ascii?Q?x6DPSJkixCNVZd7MKeYQfrUECEgfsw2MGs9nrzdf6YbOrcZdPjuD8ZDZzG+T?= =?us-ascii?Q?uKId9PVgD9vgfvYy0agAd/LGbyyhW29YOS1/SEKdSqxaX0v1oXKzGZXsCzsL?= =?us-ascii?Q?O1IzaOVICtWX2m8NLYHxCAz6WRov8folUTlsgMkax8D8C8s+lYhmj90Jm0Eh?= =?us-ascii?Q?1nYHwI3tD0dJjPUYPz/VExRgIBaBzhbyk6eCPFSJwTO+ZVMZCf+3Yl4Tk2Xp?= =?us-ascii?Q?tgShcNYd5Wg9W3/uy7TCYdgIi0Tvr68B0+3YlFbYuLanWbkQ8Gqdsq3VVoPs?= =?us-ascii?Q?xEXCTYsbaUcMQMP7U67v24r6AFv1oVi5sI/llhkRZ0+EwylcD7OQryK9WalU?= =?us-ascii?Q?4W4HVfwqiu2qbI5w6VLcvoOaSqrDVYsiNy/CLokFgmzBhQQ6UO0Woo/G9Zt+?= =?us-ascii?Q?/j8P/b22CfmlCYNGTEXukjuP4zCX9j3iDg5zmTOoa1J2lldUCvtgpGiIoUW8?= =?us-ascii?Q?OniYGScJVJopEm94k1173l9sscqBm2FhYXbA0GlIL0YIEHB0zQFO+prINXp4?= =?us-ascii?Q?AKRIBjE7GqPNNqvfCWN/k+Avpfu6HBQ7R8ZnYJrRH1Qblxx+EW8TEDVMInJP?= =?us-ascii?Q?A7hyllUwITanJJs/0PJ85/cErk1wPREY8sRU1/mADAE3K1lpZ9J6Cs13OGKR?= =?us-ascii?Q?m2h/9LPgev54kaoqEpGviPvq1NsVgq1pXx75gucrXOu9SDzs6wkrcVv8OY9D?= =?us-ascii?Q?3A4HJZWtlcMOeXCV+nIouLZvN4RIA8wcdqPyY2hmf5rW3fr9Aj/S1RLIsk7U?= =?us-ascii?Q?H7L76E/5dQho+H50C/QGXQBpMqvuT0Hzm4Ag1FoML+KR8jiKwqxAc4t7bMxy?= =?us-ascii?Q?VnOWtXbxZ937aLOYtGw0as6RsdAQGFYZ6nlvVnbEujzTL35nnK+vebVUMAdd?= =?us-ascii?Q?OgvfcdY/liBxtjiysb3yq8R49EnwRpWjzcaQd/LP2CAO8MVV4hknExyqK41A?= =?us-ascii?Q?f8JnMiLNelmTdt5NyRsvO53y0BNTwOVG5LOInyvZ8t2TCSm1WD/GapUZJggw?= =?us-ascii?Q?1KP3qZuyI4zBwoqvTUCpMvoa5oSw42eg3uc6HZhMF/iha4CQqBIYlvVCabxw?= =?us-ascii?Q?kYfX1XcdLy9Aebj/nACUrepv/3HN/VYOmTQQTKzbes0lZEe6SxdwCir8FRdk?= =?us-ascii?Q?IOZtO+I0tkdenD0FHU8x/yLL9xw84/KdfXrPmyXkZZGtnE1Y0L3nCCrpPMAH?= =?us-ascii?Q?K3/pzzGKZNCTr7C5oBm9s3oOj2o9ZMdemMzhRBYF2eMT0k0wHGYHUQg7bbP0?= =?us-ascii?Q?L+2VukeyMoSONqlZTxg33dapZqXptY3aDi3bUQ6dApCDLVp4lByTv/EaFKxG?= =?us-ascii?Q?y+1wMQ=3D=3D?= X-Forefront-Antispam-Report: CIP:198.47.23.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet201.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(7416014)(376014)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2026 13:55:51.4091 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1676de88-7ba1-4fe8-d548-08de58f4c9e1 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.195];Helo=[lewvzet201.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF00000208.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6458 Content-Type: text/plain; charset="utf-8" From: Jai Luthra Cadence CSI-2 bridge IP supports capturing multiple virtual "streams" of data over the same physical interface using MIPI Virtual Channels. While the hardware IP supports usecases where streams coming in the sink pad can be broadcasted to multiple source pads, the driver will need significant re-architecture to make that possible. The two users of this IP in mainline linux are TI Shim and StarFive JH7110 CAMSS, and both have only integrated the first source pad i.e stream0 of this IP. So for now keep it simple and only allow 1-to-1 mapping of streams from sink to source, without any broadcasting. Signed-off-by: Jai Luthra Reviewed-by: Changhuang Liang Reviewed-by: Yemike Abhilash Chandra Reviewed-by: Tomi Valkeinen Co-developed-by: Rishikesh Donadkar Signed-off-by: Rishikesh Donadkar --- drivers/media/platform/cadence/cdns-csi2rx.c | 246 +++++++++++++++---- 1 file changed, 199 insertions(+), 47 deletions(-) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/p= latform/cadence/cdns-csi2rx.c index 65c6acb02f85b..175366f889115 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -135,6 +135,7 @@ struct csi2rx_priv { struct phy *dphy; =20 u8 num_pixels[CSI2RX_STREAMS_MAX]; + u32 vc_select[CSI2RX_STREAMS_MAX]; u8 lanes[CSI2RX_LANES_MAX]; u8 num_lanes; u8 max_lanes; @@ -273,30 +274,43 @@ static void csi2rx_reset(struct csi2rx_priv *csi2rx) =20 static int csi2rx_configure_ext_dphy(struct csi2rx_priv *csi2rx) { - struct media_pad *src_pad =3D - &csi2rx->source_subdev->entity.pads[csi2rx->source_pad]; union phy_configure_opts opts =3D { }; struct phy_configure_opts_mipi_dphy *cfg =3D &opts.mipi_dphy; - struct v4l2_subdev_state *state; struct v4l2_mbus_framefmt *framefmt; + struct v4l2_subdev_state *state; const struct csi2rx_fmt *fmt; + int source_pad =3D csi2rx->source_pad; + struct media_pad *pad =3D &csi2rx->source_subdev->entity.pads[source_pad]; s64 link_freq; int ret; + u32 bpp; =20 state =3D v4l2_subdev_get_locked_active_state(&csi2rx->subdev); =20 - framefmt =3D v4l2_subdev_state_get_format(state, CSI2RX_PAD_SINK, 0); - if (!framefmt) { - dev_err(csi2rx->dev, "Did not find active sink format\n"); - return -EINVAL; - } + /* + * For multi-stream transmitters there is no single pixel rate. + * + * In multistream usecase pass bpp as 0 so that v4l2_get_link_freq() + * returns an error if it falls back to V4L2_CID_PIXEL_RATE. + */ + if (state->routing.num_routes > 1) { + bpp =3D 0; + } else { + framefmt =3D v4l2_subdev_state_get_format(state, CSI2RX_PAD_SINK, 0); + if (!framefmt) { + dev_err(csi2rx->dev, "Did not find active sink format\n"); + return -EINVAL; + } =20 - fmt =3D csi2rx_get_fmt_by_code(framefmt->code); + fmt =3D csi2rx_get_fmt_by_code(framefmt->code); + bpp =3D fmt->bpp; + } =20 - link_freq =3D v4l2_get_link_freq(src_pad, - fmt->bpp, 2 * csi2rx->num_lanes); - if (link_freq < 0) + link_freq =3D v4l2_get_link_freq(pad, bpp, 2 * csi2rx->num_lanes); + if (link_freq < 0) { + dev_err(csi2rx->dev, "Unable to calculate link frequency\n"); return link_freq; + } =20 ret =3D phy_mipi_dphy_get_default_config_for_hsclk(link_freq, csi2rx->num_lanes, cfg); @@ -394,11 +408,7 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) csi2rx->num_pixels[i]), csi2rx->base + CSI2RX_STREAM_CFG_REG(i)); =20 - /* - * Enable one virtual channel. When multiple virtual channels - * are supported this will have to be changed. - */ - writel(CSI2RX_STREAM_DATA_CFG_VC_SELECT(0), + writel(csi2rx->vc_select[i], csi2rx->base + CSI2RX_STREAM_DATA_CFG_REG(i)); =20 writel(CSI2RX_STREAM_CTRL_START, @@ -486,18 +496,57 @@ static int csi2rx_log_status(struct v4l2_subdev *sd) return 0; } =20 +static void csi2rx_update_vc_select(struct csi2rx_priv *csi2rx, + struct v4l2_subdev_state *state) +{ + struct v4l2_mbus_frame_desc fd =3D {0}; + struct v4l2_subdev_route *route; + unsigned int i; + int ret; + + ret =3D csi2rx_get_frame_desc_from_source(csi2rx, &fd); + if (ret || fd.type !=3D V4L2_MBUS_FRAME_DESC_TYPE_CSI2) { + dev_dbg(csi2rx->dev, + "Failed to get source frame desc, allowing only VC=3D0\n"); + for (i =3D 0; i < CSI2RX_STREAMS_MAX; i++) + csi2rx->vc_select[i] =3D CSI2RX_STREAM_DATA_CFG_VC_SELECT(0); + return; + } + + /* If source provides per-stream VC info, use it to filter by VC */ + memset(csi2rx->vc_select, 0, sizeof(csi2rx->vc_select)); + + for_each_active_route(&state->routing, route) { + u32 cdns_stream =3D route->source_pad - CSI2RX_PAD_SOURCE_STREAM0; + + for (i =3D 0; i < fd.num_entries; i++) { + if (fd.entry[i].stream !=3D route->sink_stream) + continue; + + csi2rx->vc_select[cdns_stream] |=3D + CSI2RX_STREAM_DATA_CFG_VC_SELECT(fd.entry[i].bus.csi2.vc); + } + } +} + static int csi2rx_enable_streams(struct v4l2_subdev *subdev, struct v4l2_subdev_state *state, u32 pad, u64 streams_mask) { struct csi2rx_priv *csi2rx =3D v4l2_subdev_to_csi2rx(subdev); + u64 sink_streams; int ret; =20 + sink_streams =3D v4l2_subdev_state_xlate_streams(state, pad, + CSI2RX_PAD_SINK, + &streams_mask); + /* * If we're not the first users, there's no need to * enable the whole controller. */ if (!csi2rx->count) { + csi2rx_update_vc_select(csi2rx, state); ret =3D csi2rx_start(csi2rx); if (ret) return ret; @@ -505,10 +554,11 @@ static int csi2rx_enable_streams(struct v4l2_subdev *= subdev, =20 /* Start streaming on the source */ ret =3D v4l2_subdev_enable_streams(csi2rx->source_subdev, csi2rx->source_= pad, - BIT_U64(0)); + sink_streams); if (ret) { dev_err(csi2rx->dev, - "Failed to start streams %d on subdev\n", 0); + "Failed to start streams %#llx on subdev\n", + sink_streams); if (!csi2rx->count) csi2rx_stop(csi2rx); return ret; @@ -523,9 +573,14 @@ static int csi2rx_disable_streams(struct v4l2_subdev *= subdev, u64 streams_mask) { struct csi2rx_priv *csi2rx =3D v4l2_subdev_to_csi2rx(subdev); + u64 sink_streams; + + sink_streams =3D v4l2_subdev_state_xlate_streams(state, pad, + CSI2RX_PAD_SINK, + &streams_mask); =20 if (v4l2_subdev_disable_streams(csi2rx->source_subdev, - csi2rx->source_pad, BIT_U64(0))) { + csi2rx->source_pad, sink_streams)) { dev_err(csi2rx->dev, "Couldn't disable our subdev\n"); } =20 @@ -550,12 +605,56 @@ static int csi2rx_enum_mbus_code(struct v4l2_subdev *= subdev, return 0; } =20 +static int _csi2rx_set_routing(struct v4l2_subdev *subdev, + struct v4l2_subdev_state *state, + struct v4l2_subdev_krouting *routing) +{ + static const struct v4l2_mbus_framefmt format =3D { + .width =3D 640, + .height =3D 480, + .code =3D MEDIA_BUS_FMT_UYVY8_1X16, + .field =3D V4L2_FIELD_NONE, + .colorspace =3D V4L2_COLORSPACE_SRGB, + .ycbcr_enc =3D V4L2_YCBCR_ENC_601, + .quantization =3D V4L2_QUANTIZATION_LIM_RANGE, + .xfer_func =3D V4L2_XFER_FUNC_SRGB, + }; + int ret; + + if (routing->num_routes > V4L2_FRAME_DESC_ENTRY_MAX) + return -EINVAL; + + ret =3D v4l2_subdev_routing_validate(subdev, routing, + V4L2_SUBDEV_ROUTING_ONLY_1_TO_1); + if (ret) + return ret; + + return v4l2_subdev_set_routing_with_fmt(subdev, state, routing, &format); +} + +static int csi2rx_set_routing(struct v4l2_subdev *subdev, + struct v4l2_subdev_state *state, + enum v4l2_subdev_format_whence which, + struct v4l2_subdev_krouting *routing) +{ + struct csi2rx_priv *csi2rx =3D v4l2_subdev_to_csi2rx(subdev); + int ret; + + if (which =3D=3D V4L2_SUBDEV_FORMAT_ACTIVE && csi2rx->count) + return -EBUSY; + + ret =3D _csi2rx_set_routing(subdev, state, routing); + if (ret) + return ret; + + return 0; +} + static int csi2rx_set_fmt(struct v4l2_subdev *subdev, struct v4l2_subdev_state *state, struct v4l2_subdev_format *format) { struct v4l2_mbus_framefmt *fmt; - unsigned int i; =20 /* No transcoding, source and sink formats must match. */ if (format->pad !=3D CSI2RX_PAD_SINK) @@ -567,14 +666,16 @@ static int csi2rx_set_fmt(struct v4l2_subdev *subdev, format->format.field =3D V4L2_FIELD_NONE; =20 /* Set sink format */ - fmt =3D v4l2_subdev_state_get_format(state, format->pad); + fmt =3D v4l2_subdev_state_get_format(state, format->pad, format->stream); *fmt =3D format->format; =20 - /* Propagate to source formats */ - for (i =3D CSI2RX_PAD_SOURCE_STREAM0; i < CSI2RX_PAD_MAX; i++) { - fmt =3D v4l2_subdev_state_get_format(state, i); - *fmt =3D format->format; - } + /* Propagate to source format */ + fmt =3D v4l2_subdev_state_get_opposite_stream_format(state, format->pad, + format->stream); + if (!fmt) + return -EINVAL; + + *fmt =3D format->format; =20 return 0; } @@ -582,21 +683,22 @@ static int csi2rx_set_fmt(struct v4l2_subdev *subdev, static int csi2rx_init_state(struct v4l2_subdev *subdev, struct v4l2_subdev_state *state) { - struct v4l2_subdev_format format =3D { - .pad =3D CSI2RX_PAD_SINK, - .format =3D { - .width =3D 640, - .height =3D 480, - .code =3D MEDIA_BUS_FMT_UYVY8_1X16, - .field =3D V4L2_FIELD_NONE, - .colorspace =3D V4L2_COLORSPACE_SRGB, - .ycbcr_enc =3D V4L2_YCBCR_ENC_601, - .quantization =3D V4L2_QUANTIZATION_LIM_RANGE, - .xfer_func =3D V4L2_XFER_FUNC_SRGB, + struct v4l2_subdev_route routes[] =3D { + { + .sink_pad =3D CSI2RX_PAD_SINK, + .sink_stream =3D 0, + .source_pad =3D CSI2RX_PAD_SOURCE_STREAM0, + .source_stream =3D 0, + .flags =3D V4L2_SUBDEV_ROUTE_FL_ACTIVE, }, }; =20 - return csi2rx_set_fmt(subdev, state, &format); + struct v4l2_subdev_krouting routing =3D { + .num_routes =3D ARRAY_SIZE(routes), + .routes =3D routes, + }; + + return _csi2rx_set_routing(subdev, state, &routing); } =20 int cdns_csi2rx_negotiate_ppc(struct v4l2_subdev *subdev, unsigned int pad, @@ -630,17 +732,66 @@ static int csi2rx_get_frame_desc(struct v4l2_subdev *= subdev, unsigned int pad, struct v4l2_mbus_frame_desc *fd) { struct csi2rx_priv *csi2rx =3D v4l2_subdev_to_csi2rx(subdev); + struct v4l2_mbus_frame_desc source_fd =3D {0}; + struct v4l2_subdev_route *route; + struct v4l2_subdev_state *state; + int ret; =20 - return csi2rx_get_frame_desc_from_source(csi2rx, fd); + ret =3D csi2rx_get_frame_desc_from_source(csi2rx, &source_fd); + if (ret) + return ret; + + fd->type =3D V4L2_MBUS_FRAME_DESC_TYPE_CSI2; + + state =3D v4l2_subdev_lock_and_get_active_state(subdev); + + for_each_active_route(&state->routing, route) { + struct v4l2_mbus_frame_desc_entry *source_entry =3D NULL; + unsigned int i; + + if (route->source_pad !=3D pad) + continue; + + for (i =3D 0; i < source_fd.num_entries; i++) { + if (source_fd.entry[i].stream =3D=3D route->sink_stream) { + source_entry =3D &source_fd.entry[i]; + break; + } + } + + if (!source_entry) { + dev_err(csi2rx->dev, + "Failed to find stream from source frame desc\n"); + ret =3D -EPIPE; + goto err_missing_stream; + } + + fd->entry[fd->num_entries].stream =3D route->source_stream; + fd->entry[fd->num_entries].flags =3D source_entry->flags; + fd->entry[fd->num_entries].length =3D source_entry->length; + fd->entry[fd->num_entries].pixelcode =3D source_entry->pixelcode; + fd->entry[fd->num_entries].bus.csi2.vc =3D + source_entry->bus.csi2.vc; + fd->entry[fd->num_entries].bus.csi2.dt =3D + source_entry->bus.csi2.dt; + + fd->num_entries++; + } + +err_missing_stream: + v4l2_subdev_unlock_state(state); + + return ret; } =20 static const struct v4l2_subdev_pad_ops csi2rx_pad_ops =3D { - .enum_mbus_code =3D csi2rx_enum_mbus_code, - .get_fmt =3D v4l2_subdev_get_fmt, - .set_fmt =3D csi2rx_set_fmt, - .enable_streams =3D csi2rx_enable_streams, - .disable_streams =3D csi2rx_disable_streams, - .get_frame_desc =3D csi2rx_get_frame_desc, + .enum_mbus_code =3D csi2rx_enum_mbus_code, + .get_fmt =3D v4l2_subdev_get_fmt, + .set_fmt =3D csi2rx_set_fmt, + .get_frame_desc =3D csi2rx_get_frame_desc, + .set_routing =3D csi2rx_set_routing, + .enable_streams =3D csi2rx_enable_streams, + .disable_streams =3D csi2rx_disable_streams, }; =20 static const struct v4l2_subdev_core_ops csi2rx_core_ops =3D { @@ -876,7 +1027,8 @@ static int csi2rx_probe(struct platform_device *pdev) csi2rx->pads[CSI2RX_PAD_SINK].flags =3D MEDIA_PAD_FL_SINK; for (i =3D CSI2RX_PAD_SOURCE_STREAM0; i < CSI2RX_PAD_MAX; i++) csi2rx->pads[i].flags =3D MEDIA_PAD_FL_SOURCE; - csi2rx->subdev.flags |=3D V4L2_SUBDEV_FL_HAS_DEVNODE; + csi2rx->subdev.flags =3D V4L2_SUBDEV_FL_HAS_DEVNODE | + V4L2_SUBDEV_FL_STREAMS; csi2rx->subdev.entity.ops =3D &csi2rx_media_ops; =20 ret =3D media_entity_pads_init(&csi2rx->subdev.entity, CSI2RX_PAD_MAX, --=20 2.34.1 From nobody Sun Feb 8 21:47:54 2026 Received: from BYAPR05CU005.outbound.protection.outlook.com (mail-westusazon11010014.outbound.protection.outlook.com [52.101.85.14]) (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 4231E3A7F66; Wed, 21 Jan 2026 13:56:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.85.14 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003769; cv=fail; b=pGtD1jJAGFAYLXBI5Qekbl5i7KyY1aNCmUFUP87UN1lR325K1XuHDzhVQj3+N6+ifFq5yWSL+Vms/8gD4jNX13q7J/HHJKPOzClwwGtoxlPa1MEUSq1+2PcjDuO7duyQVudMsN6EjBZkNBRnXVFjEGttZATx2Hynaz4BOlPM3ls= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003769; c=relaxed/simple; bh=ALtflz9xSGJuoZCHLdOd4GjHfuclL2rl+j3XCtd48+Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IYzvQeI1VwuJYGdMDTw5C1BhySkMrLA4dXKF9sQvB5b/vlYvtqjkbxdmzxbBUTSl/MM+TbvC/xMYbfVo+Ti1qNtylWnu8jp2jc0k/yt4HNwmHUwZIUd2ORYqVlBjOSKJrkql5q65LEASB0gUHgDC3mXnscTCMThCUw/JW76uR7E= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=ZYt/1ul4; arc=fail smtp.client-ip=52.101.85.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="ZYt/1ul4" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lGjLmKnLLLAn7RSySJc4cnwMXJsMVCEv1oNHW3Yu8U/Vd2U1k9L677a1pUXDFBQa0rhPRE1MYKgaM9LEh8IvG7wlTsapzKtTFolaJJFZJ/BP0BenZv4WZCAjWofbg7JMJ+mPKP6W3aBbRrxCgf2HDwPPcQlx8TyejX7oSMg/8t2oxwjGIkbJpSIuhImJuzfpnkre0Bwb79ScP2X1EdB6twBM/4J96ebANZOx3N/KUvNk00lqFGqytM9VWwPdmIed5U/ZHp9AqN4ZgG+PqVuMy8ImWZUFQOu9vA5KZiWMX5THoIwFVd1m736xZ4NQ35U+6NvO4i9olkS/KZ7m8UN3GQ== 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=CjDRBu7BMMjrFdQ06EEbWQYucOWlgAjZSOqsg2Ow8kI=; b=oiuIIS+Q90YMqlf8E179iBHkjiEZRSTL85HdmPUAjivDLdXgzC1pIw2dAvxQX+xAtKDeTNDGifaGWsGql/Wjf3hSGsIk71ShOhDqXlQNq7KNmgZ+YwojqeIVOb6B2Qw/wAq8Yv5lVLJ4/tECgVf5ve3Dfe1q5qjyzuk+TL1xee748o/ZVZtZQFVSWKY6Ju6cV26dEla1JtuxKT4jDg9aAm6jPFQu8Hu/0vTkzwDwqZpigq1GDCC7g5w3mKOP98WNazVNZX2KWFKZ5BfMPC4XS4UUKajgYFZOm+n9g7lcqb/q1rl0Dp9K19gr2zUYIb8FSaShohypF309yk7GDuNOKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.194) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CjDRBu7BMMjrFdQ06EEbWQYucOWlgAjZSOqsg2Ow8kI=; b=ZYt/1ul4phPB8jaZT0UANB6s09zuBf0nV32NYqa9SO6fpn/gVWcn+Dn7aJ4Egof19nLddtJoeNAZbbpv5yYdQ7hJVNBv6nGcjy+isJfoT/duUdHx8LHJ1S/dDC4wLpk3BCmDdod3aFIQK93pODq8rZqEzgV7wVvCON4owG7t+k4= Received: from PH7P221CA0087.NAMP221.PROD.OUTLOOK.COM (2603:10b6:510:328::23) by BN0PR10MB4967.namprd10.prod.outlook.com (2603:10b6:408:123::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.9; Wed, 21 Jan 2026 13:56:01 +0000 Received: from CO1PEPF000044F7.namprd21.prod.outlook.com (2603:10b6:510:328:cafe::b2) by PH7P221CA0087.outlook.office365.com (2603:10b6:510:328::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9542.10 via Frontend Transport; Wed, 21 Jan 2026 13:55:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.194; helo=lewvzet200.ext.ti.com; pr=C Received: from lewvzet200.ext.ti.com (198.47.23.194) by CO1PEPF000044F7.mail.protection.outlook.com (10.167.241.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9564.0 via Frontend Transport; Wed, 21 Jan 2026 13:56:00 +0000 Received: from DLEE208.ent.ti.com (157.170.170.97) by lewvzet200.ext.ti.com (10.4.14.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:55:57 -0600 Received: from DLEE209.ent.ti.com (157.170.170.98) by DLEE208.ent.ti.com (157.170.170.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:55:57 -0600 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DLEE209.ent.ti.com (157.170.170.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend Transport; Wed, 21 Jan 2026 07:55:57 -0600 Received: from ws.dhcp.ti.com (ws.dhcp.ti.com [172.24.233.149]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 60LDsPII3104105; Wed, 21 Jan 2026 07:55:50 -0600 From: Rishikesh Donadkar To: , , CC: , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 12/18] media: cadence: csi2rx: Use the stream from route to get format Date: Wed, 21 Jan 2026 19:24:18 +0530 Message-ID: <20260121135424.1185710-13-r-donadkar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260121135424.1185710-1-r-donadkar@ti.com> References: <20260121135424.1185710-1-r-donadkar@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F7:EE_|BN0PR10MB4967:EE_ X-MS-Office365-Filtering-Correlation-Id: 0246c57d-3ee8-4448-3d19-08de58f4cf18 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|7416014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?I6GmtonA5YkTRUcjDB+OpqCXGKp30JZKEKllaMYNQxt2Lvhafw2BVoj/gSl4?= =?us-ascii?Q?PBUqLIPS6dAKD2gkTUMcGMCD6IQPS8K6q3aqtUT3L6PclkEes5mhEYrmHAB8?= =?us-ascii?Q?bfnAz4gJSDmfYpiOITXaiPw6FP2ZwS1s/pDrN48MDFwOl5Bo2XkitaWFALuG?= =?us-ascii?Q?zPU7WJyfq5/VBhr04JqPLj2gI8uqcKtvjlJKs73Q8/E2WjRQGwbByk/5brbn?= =?us-ascii?Q?cZHJJtQO/WggCDcLIT/tWOPOZZryZC/X+OwGBKse5JcRmru/y9mOLkKmpNBb?= =?us-ascii?Q?E3KSfuq3nnDqsdrvgm14j9HOX09WnEd/DHJCjvCIa7NG8LzO/jCSMHz1o8lU?= =?us-ascii?Q?0YRWKJZmZJ6DnSb+8MgLiEPpgDCEBAj7bU2x8k8ELUMvig6S+J5bdZ5Bhnzw?= =?us-ascii?Q?SGcQLOG6fiNwdto/URSiOSbpZg7/cM2J7eiJMsKHoyYB62iwyJLv+b5zC5k9?= =?us-ascii?Q?bKFgMX9sxwcb6cI/BFTWw0oeDpHPDWJKVI72SgRL15XNU1anfJa6EQGybL3E?= =?us-ascii?Q?E4+3v/aQb90DhwiQI9SzvoMyw0VxIxv0SkkeqjNdZ1WqVg9yNv0Qxu8EKlLI?= =?us-ascii?Q?xeEgnevQDSezfMKBNd9Bquph8+w9LiUNXFCcpREaIprB6K5rLlxhwPlABEWt?= =?us-ascii?Q?LzLia/5cHaXoVLrTGK2gaBRTY7bH8M7xaZPaefAHuBa5TFAumI2P1o2SPxse?= =?us-ascii?Q?b3d0oc0soc0eXZnPYBJii5p4+bKfLwCUdnjIwY64CtLUF70YHxyIj5huLbjF?= =?us-ascii?Q?g9GPTr9I795BvD1KlO4UYEgjUuA0MbAtR7rXuLSoNU+KiiSm1kNiSUyC/K+W?= =?us-ascii?Q?GCG47GWikjTCcdTFJjplEjHDCSlA7bcdu7HwaimajxCfIl4o6EHi4+PiyFoe?= =?us-ascii?Q?13WRvn1JcAx09KnpZPt01Cz1aQogf7T+bsg0Ys0CCp8fBZeSxZBylewQCnnC?= =?us-ascii?Q?JXCiTJxKIMDYecLyXnItLo760E+KzrZGQMOYZRzFnx5o+/iot3zZByXYL9OY?= =?us-ascii?Q?nTMZfE2SjqcXGq2fcm6noOohinunkMF9jq8DJ2ECP6yNDDcWxngWX6FUocwe?= =?us-ascii?Q?K989QWIiz2AozB35cSYDjoeESrc2ibubsxX0w1y4JxcJpV1blgxC0UzfXF+n?= =?us-ascii?Q?/ebAYsn/+WB98NcqGppgFAc4jLv/YjPTOO3LVJU9P+EHfLmAqvdKYLryMGWB?= =?us-ascii?Q?QypaDzIEGKztJUnMude7BVqESOinaDc6HiIR9nyl5iCRHsqbfqTZDLH78t8C?= =?us-ascii?Q?H5bknnPpI2mpS0b9tH3M7pCIGhq7IWG15ICFBKh6Xfs9hM2BPD9eBkbBG4xQ?= =?us-ascii?Q?hkExyMYu+4sWaNcDfgxhq6aYw62uJtM+lakr89fjeci+ihC+ilrGlSRD1iw6?= =?us-ascii?Q?Cun0v6v5kVVyPbDEWo9LXLdzSU+6sBsDJ+qAe2fSiuR41+Ao73eqZWVspD/o?= =?us-ascii?Q?jY3whFfaJWBQH6ypMwdxGhP8dfrwWNWiFiJeKsr8zx8u+S7k8BsFQyGKmyKz?= =?us-ascii?Q?gxM+PeTJ32StVoJUQLKsUAQNTrloLdKiGs4///CJzUjhQZfETO2C2C26Eh+C?= =?us-ascii?Q?2nTjijECHfilp6axaHEqjOxBk03u19ol2GjNx4EUK6AG6YrXneIi7pYejdTd?= =?us-ascii?Q?yczlyetDW/oT98ZrGSTxNTngC6cVemf4oW42TDv9EOAbXAGkhheb/Kp6Vyb0?= =?us-ascii?Q?VuO4Iw=3D=3D?= X-Forefront-Antispam-Report: CIP:198.47.23.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet200.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(82310400026)(7416014)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2026 13:56:00.1559 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0246c57d-3ee8-4448-3d19-08de58f4cf18 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.194];Helo=[lewvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F7.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB4967 Content-Type: text/plain; charset="utf-8" In multistream configurations, different streams can have different formats. Update the driver to use the stream number from the routing configuration when retrieving formats instead of hardcoding stream 0 or ignoring streams. In csi2rx_configure_ext_dphy(), use the sink_stream from the first route instead of always using stream 0. In cdns_csi2rx_negotiate_ppc(), iterate through all active routes for the requested pad and retrieve the format using both pad and stream information. Signed-off-by: Rishikesh Donadkar Reviewed-by: Tomi Valkeinen --- drivers/media/platform/cadence/cdns-csi2rx.c | 34 ++++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/p= latform/cadence/cdns-csi2rx.c index 175366f889115..db9871fdbe3a4 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -279,6 +279,7 @@ static int csi2rx_configure_ext_dphy(struct csi2rx_priv= *csi2rx) struct v4l2_mbus_framefmt *framefmt; struct v4l2_subdev_state *state; const struct csi2rx_fmt *fmt; + struct v4l2_subdev_route *route; int source_pad =3D csi2rx->source_pad; struct media_pad *pad =3D &csi2rx->source_subdev->entity.pads[source_pad]; s64 link_freq; @@ -296,7 +297,9 @@ static int csi2rx_configure_ext_dphy(struct csi2rx_priv= *csi2rx) if (state->routing.num_routes > 1) { bpp =3D 0; } else { - framefmt =3D v4l2_subdev_state_get_format(state, CSI2RX_PAD_SINK, 0); + route =3D &state->routing.routes[0]; + framefmt =3D v4l2_subdev_state_get_format(state, CSI2RX_PAD_SINK, + route->sink_stream); if (!framefmt) { dev_err(csi2rx->dev, "Did not find active sink format\n"); return -EINVAL; @@ -706,25 +709,44 @@ int cdns_csi2rx_negotiate_ppc(struct v4l2_subdev *sub= dev, unsigned int pad, { struct csi2rx_priv *csi2rx =3D v4l2_subdev_to_csi2rx(subdev); const struct csi2rx_fmt *csi_fmt; + struct v4l2_subdev_route *route; struct v4l2_subdev_state *state; struct v4l2_mbus_framefmt *fmt; + int ret =3D 0; =20 if (!ppc || pad < CSI2RX_PAD_SOURCE_STREAM0 || pad >=3D CSI2RX_PAD_MAX) return -EINVAL; =20 state =3D v4l2_subdev_lock_and_get_active_state(subdev); - fmt =3D v4l2_subdev_state_get_format(state, pad); - csi_fmt =3D csi2rx_get_fmt_by_code(fmt->code); + /* Check all streams on requested pad */ + for_each_active_route(&state->routing, route) { + if (route->source_pad !=3D pad) + continue; + + fmt =3D v4l2_subdev_state_get_format(state, route->source_pad, + route->source_stream); + if (!fmt) { + ret =3D -EPIPE; + *ppc =3D 1; + break; + } =20 - /* Reduce requested PPC if it is too high */ - *ppc =3D min(*ppc, csi_fmt->max_pixels); + csi_fmt =3D csi2rx_get_fmt_by_code(fmt->code); + if (!csi_fmt) { + ret =3D -EINVAL; + *ppc =3D 1; + break; + } =20 + /* Reduce requested PPC if it is too high for this stream */ + *ppc =3D min(*ppc, csi_fmt->max_pixels); + } v4l2_subdev_unlock_state(state); =20 csi2rx->num_pixels[pad - CSI2RX_PAD_SOURCE_STREAM0] =3D CSI2RX_STREAM_CFG_NUM_PIXELS(*ppc); =20 - return 0; + return ret; } EXPORT_SYMBOL_FOR_MODULES(cdns_csi2rx_negotiate_ppc, "j721e-csi2rx"); =20 --=20 2.34.1 From nobody Sun Feb 8 21:47:54 2026 Received: from CH5PR02CU005.outbound.protection.outlook.com (mail-northcentralusazon11012063.outbound.protection.outlook.com [40.107.200.63]) (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 ABDAB4A2E07; Wed, 21 Jan 2026 13:56:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.200.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003774; cv=fail; b=NVXMozMEO7NM6rTW21LrabnO75+iv3bCB6SpOGC9wkCsXl99yDB18YcKtYWkilvF70IlV4cy1r+o/qbQR3rtnpybSSyLt3Eg4hrTBJV1nV5rwAlfcowb6vvSFIaHvusP+kU7GX3db19Qewc+Yh7BpTujCcwoYXriuqDGWMhDkYw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003774; c=relaxed/simple; bh=H++gB9Yab98NyINbB4j8/KdMdNNqoU88eqNkR74do6E=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NYMQrpbUB/Q/h2yrj0oy3VY19C6Ds+dUoasAFs5J9zs0dYtKP43G5QQXYlcNj8mA8fgbfyS0SuUVvkMwD0GWDhy2A4PwrYj43VCHbvwjfVKx1z6eZRpdtE5MN1ZVu/2APC1Dlz0CFSigJjJfAX0YGilaDMs2FQrYzpXfNeofGD8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=R6WiQV7l; arc=fail smtp.client-ip=40.107.200.63 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="R6WiQV7l" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JeNmCrc1pwvGqfOyuVTeNQzN4J6DeozjBYD8gnGhEUeuEhZrkTjpIhO3DFIdKB/NtvzDtAVSeaETm8dq4PBg8crk64Hr9jLpaate4enZdGpU5/9Xm11zMty/VVAjB38vtbJsEhu6ft+qLVii28xHUOL+vnhZQ6BETJuubIA19tx2WxlTe3DTR4FF2YNaNoWS8krLrgjyF2QzdhmXEKiaZloDQLBfIFzX3IVnpLaTWszeobAOiMkS6kvo7J2301wqbHfzE+nQ/0WpUcJmqyblKI/tV30Jm5RNxJSESS8BZTkPYFjY/+NugpetBVYtM5l2pnhrwz2gDG4IA+hdhYBLfg== 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=0TvQMR08VYf7melrPVVIO8QEqf21n3qx5yu/5XtDoHg=; b=HqzTk3XjywQXS9NNQvVqET0zQbk/lCWOm1/YUdK6dVSdv5l9r2TRiH9k88kLHG+r8APZesRzr7WG1IqD2FboAlok0GDIH1lLZA/BfAQRkT+oF/4WEj99EK2OOhXJ06u2UJMUpswdaQ7AqPEBnR11Z/vAFk4ILbQFOtLNGNdqyib+/wvRvwDyDmRj/cGf4GQ6k81KsYLeYxtKm1TJiXk7AEaUnR7r2C68JnA31YbkBMy5bdmJ6IBaK3Dl1zYYqKr+5MWNcYfrcEhb0DIZeyCl0Hqlx0Zs3EPO94ceVd6PiX5K/sEuLxQnteHOcOpXG4cR/9jPzomVjpoU5z9VpkuRtg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.195) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0TvQMR08VYf7melrPVVIO8QEqf21n3qx5yu/5XtDoHg=; b=R6WiQV7lsWv89RIWHO6s23a/yBQSk6iToL/punZRCga59dj48pNJjulf3Z8KkJQhk5/2Q/DdEFoemE7cc8hLoni5nq83mDP5WH0uY6JkHpUc7PgaIo4QDBS4v2I8aPB8DOmsatPtLB+ohZjmu4sZ8ZFW65ThbPSDcyA4o85HT/E= Received: from SA9PR13CA0154.namprd13.prod.outlook.com (2603:10b6:806:28::9) by PH7PR10MB5724.namprd10.prod.outlook.com (2603:10b6:510:125::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.9; Wed, 21 Jan 2026 13:56:07 +0000 Received: from SA2PEPF000015C9.namprd03.prod.outlook.com (2603:10b6:806:28:cafe::dc) by SA9PR13CA0154.outlook.office365.com (2603:10b6:806:28::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9542.7 via Frontend Transport; Wed, 21 Jan 2026 13:56:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.195; helo=flwvzet201.ext.ti.com; pr=C Received: from flwvzet201.ext.ti.com (198.47.21.195) by SA2PEPF000015C9.mail.protection.outlook.com (10.167.241.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.4 via Frontend Transport; Wed, 21 Jan 2026 13:56:05 +0000 Received: from DFLE205.ent.ti.com (10.64.6.63) by flwvzet201.ext.ti.com (10.248.192.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:56:05 -0600 Received: from DFLE209.ent.ti.com (10.64.6.67) by DFLE205.ent.ti.com (10.64.6.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:56:04 -0600 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE209.ent.ti.com (10.64.6.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend Transport; Wed, 21 Jan 2026 07:56:04 -0600 Received: from ws.dhcp.ti.com (ws.dhcp.ti.com [172.24.233.149]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 60LDsPIJ3104105; Wed, 21 Jan 2026 07:55:58 -0600 From: Rishikesh Donadkar To: , , CC: , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 13/18] media: ti: j721e-csi2rx: add multistream support Date: Wed, 21 Jan 2026 19:24:19 +0530 Message-ID: <20260121135424.1185710-14-r-donadkar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260121135424.1185710-1-r-donadkar@ti.com> References: <20260121135424.1185710-1-r-donadkar@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015C9:EE_|PH7PR10MB5724:EE_ X-MS-Office365-Filtering-Correlation-Id: 061726f9-3cb6-475f-7ca2-08de58f4d231 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?zqZQjv5//bYilEfpG/+4LgmM6VBLE5EowqzAruC0UPEJeq1ljnEiWYe0y9I3?= =?us-ascii?Q?iUoi4akKQmDiA8UWsVU8mXfhJyv2PSq+LjEFLHcBml0Ln/yYG6n6r061LeyB?= =?us-ascii?Q?Y4HS2237okIHwugOK0Mwr2f2yt3FiTxzu9+PDOJyQ3W+PE8XCZhuX7+aUXQH?= =?us-ascii?Q?JANE/lWWM4bHkcSyWzM1V/zWUZSVBJmHsHTSnFkQh8cfAUxUrltGg7R7sbwq?= =?us-ascii?Q?D7Aa1Ej1Guzz7pzJiOdDbzLbDijJ4p7AXtfu2o7g0ywEvJiyt37RUVRI4Tr/?= =?us-ascii?Q?Xj3HKXb0XSDSeohvpM7jVc/jUY6hCzKBTCfsN6CVkD/xffTXDTF/maaLqc+y?= =?us-ascii?Q?hiAJMqskzIjiv5uPJ8rgIhNzloW8v+JRH+LpyuUErHLpkV2/aFlUCTZHGvmD?= =?us-ascii?Q?ljivScTTW7i1fi8v5HrfCpJYPJmH2/RnPzfUfqdijTNbWtgjP2bUevAzkSzc?= =?us-ascii?Q?fUQRExD7Oq9IvlpedX8526jdsnHiFY+pfGs0Xg21L2bEzD5f5lURhLXcmZxI?= =?us-ascii?Q?6Vd51gvLD/6/UEao8nIXtNoYstx7gvxIJtWBUcsyaoucVZkcX7xYAhUP7JOb?= =?us-ascii?Q?2tXKcwuyIy3O9Zbegm842AlPlJdeJGH1qKrFCeeSHWe/RQDFqVzFynrbpAAy?= =?us-ascii?Q?oNnPQVlVVEwiJwI/mbKb29XHjPatULAN7gUMx+uzJVGTUFu1k18HREC5hjgf?= =?us-ascii?Q?LqVfrXYAhYcNx5VG2IP+FzpM6trzkxAjN9p3IHzSiq1Xa4wSF+r5cmiM7yuu?= =?us-ascii?Q?8oqmtJMnohOOwFl0ypJl10LMu+lOzbt8eDv5ICr1kfVMJfa3t1cQZRxKlvBk?= =?us-ascii?Q?BUZFNvOXEYlK044UfDyadJcXjKRuf76BfIKtHYD4yZnBFq802xRa84BqwPQK?= =?us-ascii?Q?4cvKGDv1Ca2QUdzKNNK0u7d9h1SmynHKNOBY8dSooFB17fYtJzvIVU8iifB/?= =?us-ascii?Q?NGQtDX7dQ8Yf/iH+1YMTscquow2dTK7lIOQa4oPep/YHxfqDGPRXsq6Glwmj?= =?us-ascii?Q?VXFP3ivd1sAcSp5bmuW0h8qWDyqwiJIZbTOb6W6t2oA7Lse1XhquSVsQPA51?= =?us-ascii?Q?5RWAJsiwOWPcFiRWzCVcoZcJ5PdHkERST1pAr/aKJOPCxt+xt03yEA7Codyv?= =?us-ascii?Q?EooTA8YwyCzlWWcbwexSTsUlJzRB1py/oTcPOBpk+3uyRLWUiodmHN/NIq+b?= =?us-ascii?Q?WDat8NBNgTS13r7U6QQyW+LTiCxq7j0IFXMLagivVj1oOo6urvV3zjusrYbj?= =?us-ascii?Q?tqdQ+JzQHsKboLUxgyIxLx8bLTPbAAFS94fK9NotKm1LSvKW6ccN80c0TtBn?= =?us-ascii?Q?RXIri+sEHZV5kGJIMwctY22C3uLPyMkO1M8El0PZvKfPTYpBEzujfHn0ywTL?= =?us-ascii?Q?KBxw4rNUf8sy6CW1dojArgiezDDOrM4CCk1myY6vec+HZavNHBSBcK2uW2/r?= =?us-ascii?Q?Odf5hlN5EUB6sJ2PNC36UcDbw4365pWTbA0ktEYbdCabfYidf8pgMG18eJPl?= =?us-ascii?Q?jQtStQq0JfD2P1yHD9ZWohRM6H4NKOGPXheZK9kxfbUOVvFU2SgFxqHhoYMc?= =?us-ascii?Q?0v6WN30t9gWug8LRBoX2/cXXMtZWK1Mr3prSSrlSZ7walmv0l8ALzil277LD?= =?us-ascii?Q?RgAK76OrB7vCLJCU9So4riIr9XsmBgFiP+IfD6jqbVf6u5O6vx+LqsVklHAb?= =?us-ascii?Q?RmCE4A=3D=3D?= X-Forefront-Antispam-Report: CIP:198.47.21.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet201.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(376014)(7416014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2026 13:56:05.4025 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 061726f9-3cb6-475f-7ca2-08de58f4d231 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.195];Helo=[flwvzet201.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF000015C9.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB5724 Content-Type: text/plain; charset="utf-8" From: Jai Luthra Each CSI2 stream can be multiplexed into 32 independent streams, each identified by its virtual channel number and data type. The incoming data from these streams can be filtered on the basis of either the virtual channel or the data type. To capture this multiplexed stream, the application needs to tell the driver how it wants to route the data. It needs to specify which context should process which stream. This is done via the new routing APIs. Add ioctls to accept routing information from the application and save that in the driver. This can be used when starting streaming on a context to determine which route and consequently which virtual channel it should process. De-assert the pixel interface reset on first start_streaming() and assert it on the last stop_streaming(). Reviewed-by: Yemike Abhilash Chandra Co-developed-by: Pratyush Yadav Signed-off-by: Pratyush Yadav Signed-off-by: Jai Luthra Co-developed-by: Rishikesh Donadkar Signed-off-by: Rishikesh Donadkar Reviewed-by: Tomi Valkeinen --- .../platform/ti/j721e-csi2rx/j721e-csi2rx.c | 271 ++++++++++++------ 1 file changed, 191 insertions(+), 80 deletions(-) diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/driver= s/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c index 81c86e2cc4a50..4dabb99792d44 100644 --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c @@ -143,17 +143,6 @@ static inline struct ti_csi2rx_dev *to_csi2rx_dev(stru= ct v4l2_subdev *sd) return container_of(sd, struct ti_csi2rx_dev, subdev); } =20 -static const struct v4l2_mbus_framefmt ti_csi2rx_default_fmt =3D { - .width =3D 640, - .height =3D 480, - .code =3D MEDIA_BUS_FMT_UYVY8_1X16, - .field =3D V4L2_FIELD_NONE, - .colorspace =3D V4L2_COLORSPACE_SRGB, - .ycbcr_enc =3D V4L2_YCBCR_ENC_601, - .quantization =3D V4L2_QUANTIZATION_LIM_RANGE, - .xfer_func =3D V4L2_XFER_FUNC_SRGB, -}; - static const struct ti_csi2rx_fmt ti_csi2rx_formats[] =3D { { .fourcc =3D V4L2_PIX_FMT_YUYV, @@ -565,10 +554,6 @@ static void ti_csi2rx_setup_shim(struct ti_csi2rx_ctx = *ctx) =20 fmt =3D find_format_by_fourcc(ctx->v_fmt.fmt.pix.pixelformat); =20 - /* De-assert the pixel interface reset. */ - reg =3D SHIM_CNTL_PIX_RST; - writel(reg, csi->shim + SHIM_CNTL); - /* Negotiate pixel count from the source */ ti_csi2rx_request_max_ppc(csi); =20 @@ -888,34 +873,75 @@ static void ti_csi2rx_buffer_queue(struct vb2_buffer = *vb) } } =20 +static int ti_csi2rx_get_stream(struct ti_csi2rx_ctx *ctx) +{ + struct ti_csi2rx_dev *csi =3D ctx->csi; + struct media_pad *pad; + struct v4l2_subdev_state *state; + struct v4l2_subdev_route *r; + + /* Get the source pad connected to this ctx */ + pad =3D media_entity_remote_source_pad_unique(ctx->pad.entity); + if (!pad) { + dev_err(csi->dev, "No pad connected to ctx %d\n", ctx->idx); + return -ENODEV; + } + + state =3D v4l2_subdev_get_locked_active_state(&csi->subdev); + + for_each_active_route(&state->routing, r) { + if (r->source_pad =3D=3D pad->index) { + ctx->stream =3D r->sink_stream; + return 0; + } + } + + /* No route found for this ctx */ + return -ENODEV; +} + static int ti_csi2rx_get_vc_and_dt(struct ti_csi2rx_ctx *ctx) { struct ti_csi2rx_dev *csi =3D ctx->csi; + struct ti_csi2rx_ctx *curr_ctx; struct v4l2_mbus_frame_desc fd; - struct media_pad *pad; - int ret, i; + struct media_pad *source_pad; + int ret; + unsigned int i, j; =20 - pad =3D media_entity_remote_pad_unique(&csi->subdev.entity, MEDIA_PAD_FL_= SOURCE); - if (!pad) + /* Get the frame desc form source */ + source_pad =3D media_entity_remote_pad_unique(&csi->subdev.entity, MEDIA_= PAD_FL_SOURCE); + if (!source_pad) return -ENODEV; =20 - ret =3D v4l2_subdev_call(csi->source, pad, get_frame_desc, pad->index, &f= d); + ret =3D v4l2_subdev_call(csi->source, pad, get_frame_desc, source_pad->in= dex, &fd); if (ret) return ret; =20 if (fd.type !=3D V4L2_MBUS_FRAME_DESC_TYPE_CSI2) return -EINVAL; =20 - for (i =3D 0; i < fd.num_entries; i++) { - if (ctx->stream =3D=3D fd.entry[i].stream) { - ctx->vc =3D fd.entry[i].bus.csi2.vc; - ctx->dt =3D fd.entry[i].bus.csi2.dt; - break; - } + for (i =3D 0; i < csi->num_ctx; i++) { + curr_ctx =3D &csi->ctx[i]; =20 - /* Return error if no matching stream found */ - if (i =3D=3D fd.num_entries) - return -EINVAL; + /* Capture VC 0 by default */ + curr_ctx->vc =3D 0; + + ret =3D ti_csi2rx_get_stream(curr_ctx); + if (ret) + continue; + + for (j =3D 0; j < fd.num_entries; j++) { + if (curr_ctx->stream =3D=3D fd.entry[j].stream) { + curr_ctx->vc =3D fd.entry[j].bus.csi2.vc; + curr_ctx->dt =3D fd.entry[j].bus.csi2.dt; + break; + } + + /* Return error if no matching stream found */ + if (j =3D=3D fd.num_entries) + return -EINVAL; + } } =20 return 0; @@ -926,8 +952,6 @@ static int ti_csi2rx_start_streaming(struct vb2_queue *= vq, unsigned int count) struct ti_csi2rx_ctx *ctx =3D vb2_get_drv_priv(vq); struct ti_csi2rx_dev *csi =3D ctx->csi; struct ti_csi2rx_dma *dma =3D &ctx->dma; - struct ti_csi2rx_buffer *buf; - const struct ti_csi2rx_fmt *fmt; unsigned long flags; int ret =3D 0; =20 @@ -942,35 +966,9 @@ static int ti_csi2rx_start_streaming(struct vb2_queue = *vq, unsigned int count) if (ret) goto err; =20 - ret =3D ti_csi2rx_get_vc_and_dt(ctx); - if (ret =3D=3D -ENOIOCTLCMD) { - ctx->vc =3D 0; - fmt =3D find_format_by_fourcc(ctx->v_fmt.fmt.pix.pixelformat); - ctx->dt =3D fmt->csi_dt; - } else if (ret < 0) { - goto err; - } - - ti_csi2rx_setup_shim(ctx); - - ctx->sequence =3D 0; - - spin_lock_irqsave(&dma->lock, flags); - buf =3D list_entry(dma->queue.next, struct ti_csi2rx_buffer, list); - - ret =3D ti_csi2rx_start_dma(ctx, buf); - if (ret) { - dev_err(csi->dev, "Failed to start DMA: %d\n", ret); - spin_unlock_irqrestore(&dma->lock, flags); - goto err_pipeline; - } - - list_move_tail(&buf->list, &dma->submitted); - dma->state =3D TI_CSI2RX_DMA_ACTIVE; - spin_unlock_irqrestore(&dma->lock, flags); - + /* Start stream 0, we don't allow multiple streams on the source pad */ ret =3D v4l2_subdev_enable_streams(&csi->subdev, - TI_CSI2RX_PAD_FIRST_SOURCE, + TI_CSI2RX_PAD_FIRST_SOURCE + ctx->idx, BIT_U64(0)); if (ret) goto err_dma; @@ -979,7 +977,6 @@ static int ti_csi2rx_start_streaming(struct vb2_queue *= vq, unsigned int count) =20 err_dma: ti_csi2rx_stop_dma(ctx); -err_pipeline: video_device_pipeline_stop(&ctx->vdev); writel(0, csi->shim + SHIM_CNTL); writel(0, csi->shim + SHIM_DMACNTX(ctx->idx)); @@ -996,11 +993,8 @@ static void ti_csi2rx_stop_streaming(struct vb2_queue = *vq) =20 video_device_pipeline_stop(&ctx->vdev); =20 - writel(0, csi->shim + SHIM_CNTL); - writel(0, csi->shim + SHIM_DMACNTX(ctx->idx)); - ret =3D v4l2_subdev_disable_streams(&csi->subdev, - TI_CSI2RX_PAD_FIRST_SOURCE, + TI_CSI2RX_PAD_FIRST_SOURCE + ctx->idx, BIT_U64(0)); if (ret) dev_err(csi->dev, "Failed to stop subdev stream\n"); @@ -1047,25 +1041,84 @@ static int ti_csi2rx_sd_set_fmt(struct v4l2_subdev = *sd, fmt =3D v4l2_subdev_state_get_format(state, format->pad, format->stream); *fmt =3D format->format; =20 - fmt =3D v4l2_subdev_state_get_format(state, TI_CSI2RX_PAD_FIRST_SOURCE, - format->stream); + fmt =3D v4l2_subdev_state_get_opposite_stream_format(state, format->pad, + format->stream); + if (!fmt) + return -EINVAL; + *fmt =3D format->format; =20 return 0; } =20 -static int ti_csi2rx_sd_init_state(struct v4l2_subdev *sd, - struct v4l2_subdev_state *state) +static int _ti_csi2rx_sd_set_routing(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, + struct v4l2_subdev_krouting *routing) { - struct v4l2_mbus_framefmt *fmt; + int ret; =20 - fmt =3D v4l2_subdev_state_get_format(state, TI_CSI2RX_PAD_SINK); - *fmt =3D ti_csi2rx_default_fmt; + static const struct v4l2_mbus_framefmt format =3D { + .width =3D 640, + .height =3D 480, + .code =3D MEDIA_BUS_FMT_UYVY8_1X16, + .field =3D V4L2_FIELD_NONE, + .colorspace =3D V4L2_COLORSPACE_SRGB, + .ycbcr_enc =3D V4L2_YCBCR_ENC_601, + .quantization =3D V4L2_QUANTIZATION_LIM_RANGE, + .xfer_func =3D V4L2_XFER_FUNC_SRGB, + }; =20 - fmt =3D v4l2_subdev_state_get_format(state, TI_CSI2RX_PAD_FIRST_SOURCE); - *fmt =3D ti_csi2rx_default_fmt; + ret =3D v4l2_subdev_routing_validate(sd, routing, + V4L2_SUBDEV_ROUTING_ONLY_1_TO_1 | + V4L2_SUBDEV_ROUTING_NO_SOURCE_MULTIPLEXING); =20 - return 0; + if (ret) + return ret; + + /* Only stream ID 0 allowed on source pads */ + for (unsigned int i =3D 0; i < routing->num_routes; ++i) { + const struct v4l2_subdev_route *route =3D &routing->routes[i]; + + if (route->source_stream !=3D 0) + return -EINVAL; + } + + ret =3D v4l2_subdev_set_routing_with_fmt(sd, state, routing, &format); + + return ret; +} + +static int ti_csi2rx_sd_set_routing(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, + enum v4l2_subdev_format_whence which, + struct v4l2_subdev_krouting *routing) +{ + struct ti_csi2rx_dev *csi =3D to_csi2rx_dev(sd); + + if (csi->enable_count > 0) + return -EBUSY; + + return _ti_csi2rx_sd_set_routing(sd, state, routing); +} + +static int ti_csi2rx_sd_init_state(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state) +{ + struct v4l2_subdev_route routes[] =3D { { + .sink_pad =3D 0, + .sink_stream =3D 0, + .source_pad =3D TI_CSI2RX_PAD_FIRST_SOURCE, + .source_stream =3D 0, + .flags =3D V4L2_SUBDEV_ROUTE_FL_ACTIVE, + } }; + + struct v4l2_subdev_krouting routing =3D { + .num_routes =3D 1, + .routes =3D routes, + }; + + /* Initialize routing to single route to the fist source pad */ + return _ti_csi2rx_sd_set_routing(sd, state, &routing); } =20 static int ti_csi2rx_sd_enable_streams(struct v4l2_subdev *sd, @@ -1073,15 +1126,62 @@ static int ti_csi2rx_sd_enable_streams(struct v4l2_= subdev *sd, u32 pad, u64 streams_mask) { struct ti_csi2rx_dev *csi =3D to_csi2rx_dev(sd); + struct ti_csi2rx_ctx *ctx =3D &csi->ctx[pad - TI_CSI2RX_PAD_FIRST_SOURCE]; + struct ti_csi2rx_dma *dma =3D &ctx->dma; struct media_pad *remote_pad; + struct ti_csi2rx_buffer *buf; + const struct ti_csi2rx_fmt *fmt; + unsigned long flags; + u64 sink_streams; int ret =3D 0; + unsigned int reg; + + ret =3D ti_csi2rx_get_stream(ctx); + if (ret) + return ret; + + /* Get the VC and DT for all enabled ctx on first stream start */ + if (!csi->enable_count) { + ret =3D ti_csi2rx_get_vc_and_dt(ctx); + if (ret =3D=3D -ENOIOCTLCMD) { + ctx->vc =3D 0; + fmt =3D find_format_by_fourcc(ctx->v_fmt.fmt.pix.pixelformat); + ctx->dt =3D fmt->csi_dt; + } else if (ret < 0) { + return ret; + } + + /* De-assert the pixel interface reset. */ + reg =3D SHIM_CNTL_PIX_RST; + writel(reg, csi->shim + SHIM_CNTL); + } + + ti_csi2rx_setup_shim(ctx); + ctx->sequence =3D 0; + + spin_lock_irqsave(&dma->lock, flags); + buf =3D list_entry(dma->queue.next, struct ti_csi2rx_buffer, list); + + ret =3D ti_csi2rx_start_dma(ctx, buf); + if (ret) { + dev_err(csi->dev, "Failed to start DMA: %d\n", ret); + spin_unlock_irqrestore(&dma->lock, flags); + return ret; + } + + list_move_tail(&buf->list, &dma->submitted); + dma->state =3D TI_CSI2RX_DMA_ACTIVE; + spin_unlock_irqrestore(&dma->lock, flags); =20 remote_pad =3D media_entity_remote_source_pad_unique(&csi->subdev.entity); if (!remote_pad) return -ENODEV; + sink_streams =3D v4l2_subdev_state_xlate_streams(state, pad, + TI_CSI2RX_PAD_SINK, + &streams_mask); =20 ret =3D v4l2_subdev_enable_streams(csi->source, remote_pad->index, - BIT_U64(0)); + sink_streams); if (ret) return ret; =20 @@ -1095,18 +1195,28 @@ static int ti_csi2rx_sd_disable_streams(struct v4l2= _subdev *sd, u32 pad, u64 streams_mask) { struct ti_csi2rx_dev *csi =3D to_csi2rx_dev(sd); + struct ti_csi2rx_ctx *ctx =3D &csi->ctx[pad - TI_CSI2RX_PAD_FIRST_SOURCE]; struct media_pad *remote_pad; + u64 sink_streams; int ret =3D 0; =20 + WARN_ON(csi->enable_count =3D=3D 0); + + writel(0, csi->shim + SHIM_DMACNTX(ctx->idx)); + + /* assert pixel reset to prevent stale data */ + if (csi->enable_count =3D=3D 1) + writel(0, csi->shim + SHIM_CNTL); + remote_pad =3D media_entity_remote_source_pad_unique(&csi->subdev.entity); if (!remote_pad) return -ENODEV; - - if (csi->enable_count =3D=3D 0) - return -EINVAL; + sink_streams =3D v4l2_subdev_state_xlate_streams(state, pad, + TI_CSI2RX_PAD_SINK, + &streams_mask); =20 ret =3D v4l2_subdev_disable_streams(csi->source, remote_pad->index, - BIT_U64(0)); + sink_streams); if (!ret) --csi->enable_count; =20 @@ -1115,6 +1225,7 @@ static int ti_csi2rx_sd_disable_streams(struct v4l2_s= ubdev *sd, =20 static const struct v4l2_subdev_pad_ops ti_csi2rx_subdev_pad_ops =3D { .enum_mbus_code =3D ti_csi2rx_enum_mbus_code, + .set_routing =3D ti_csi2rx_sd_set_routing, .get_fmt =3D v4l2_subdev_get_fmt, .set_fmt =3D ti_csi2rx_sd_set_fmt, .enable_streams =3D ti_csi2rx_sd_enable_streams, @@ -1293,7 +1404,7 @@ static int ti_csi2rx_v4l2_init(struct ti_csi2rx_dev *= csi) v4l2_subdev_init(sd, &ti_csi2rx_subdev_ops); sd->internal_ops =3D &ti_csi2rx_internal_ops; sd->entity.function =3D MEDIA_ENT_F_VID_IF_BRIDGE; - sd->flags =3D V4L2_SUBDEV_FL_HAS_DEVNODE; + sd->flags =3D V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_STREAMS; strscpy(sd->name, dev_name(csi->dev), sizeof(sd->name)); sd->dev =3D csi->dev; sd->entity.ops =3D &ti_csi2rx_subdev_entity_ops; --=20 2.34.1 From nobody Sun Feb 8 21:47:54 2026 Received: from CH4PR04CU002.outbound.protection.outlook.com (mail-northcentralusazon11013018.outbound.protection.outlook.com [40.107.201.18]) (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 120593382D3; Wed, 21 Jan 2026 13:56:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.201.18 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003788; cv=fail; b=h5nT99YOZYhJAKJ8ro7i3ciB+R+ji7qZi4G8O0LhAgNh2YuArYb169AkrXnR4IcwKmRcPpQDgopyXDR3frqu+RYrTASW/pwlRL8AOiByxRTe9KDnB6TQtzo5WhVdHDFslyrNTSJj8x5jujI5KGDHph6CIWOUho2LF6l+349BNfI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003788; c=relaxed/simple; bh=hQvA8JOq+hevoIB7Kz6CIus4GXGqiv0GAvp8vz21DUE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=a792cpjNu84TZ30XiPv2T/jnafG5afdgI8uI+wMXDKFjYAdHoeNGMb0GJacX1grNjPxMEzG+HwzzG6pGtc/c1Vp/kLzo914k5n5GarR685m2tyc+Mwa9aEqc5Rb8WuWFW1LgaHLo0Mg/RjY+M7iK/AKvERFVOCuspfuG9yFV724= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=HqGrO+IY; arc=fail smtp.client-ip=40.107.201.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="HqGrO+IY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=p3lAOB1AW5LheqVcvlkGLTxqDdKNu3rsXXYwLCJEdXNQNUPiWEvhuAhNZEn+QeJu4bPfnXmaF1I64m++t2EX7gK/qIssDpmnsLlmGM+kks3C1XVGNj+Xy2IsmPxIaOembxpI9/MMMOd8pn/7hsg2BTIDR5jwkf2CegmnObDREEwG8RPvlf5m8CwwgetTcOPhSJWKAxeUm+4t9dBtPIiajx0uOZs5VrW/AwVFUzjThxv7rIOv6JIKOwPfmnOdSUSEn1+L+QxqaoShZS+tIyiSsPOySC4HtqyKpEbTHtzJK7J4pAvK5XWBD/8j3hFXr58qnLKJWDZT5xCxYDbCb8HFIg== 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=ns5eTUTpwDrs7kw6PBr2u2XaBK7aGGr4asl8ORPZTPU=; b=HWRmGk9qVAq4GMXAB3RuI8cZlGeAVPaRnlwS7qPHTxleaOC2iq0lmMKh2HtsKps+rlvwfferhKcFomtVeZVBVT8XgSu0UxTvmmx8mGEqzhenNyABgj/Kl6BiHuX5YtYlQgreQqZxZx2bZqP6T34qMkTt7YiO2eoJIsgyTQixI2VSkvW01609XVFBSli5ZPs2zpC8ejevR85k0GZc2hvQuFkzMcxrc2Tvuq7V8alt1N+N9D3gqLzBTX8jqIbwFD+vbLCMTrjl5+rma90Cg2sjB8sK+Gz+d/iV9hwPmINvhJ/bLdpDz5ykIbIR6L5kJFDdAQcePrycUQGueNwyBmwmWQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.194) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ns5eTUTpwDrs7kw6PBr2u2XaBK7aGGr4asl8ORPZTPU=; b=HqGrO+IYMp2j2TsKr3jauIf+rNdHjoP/Dqxb2AkXHXHZhAaOJ6wJHiBWijfrLzMhGDa2+ENnh4BSnOAgUL6uhlQ5e/rST1vHQ9WtZpyP8yKVDg1H9i7vCdnBdpLtJjuq8X196MkyJh/p91sW4/iPwgnGz2lvupBJH3+Aue/huDM= Received: from SJ0PR03CA0088.namprd03.prod.outlook.com (2603:10b6:a03:331::33) by DS7PR10MB7374.namprd10.prod.outlook.com (2603:10b6:8:eb::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.9; Wed, 21 Jan 2026 13:56:19 +0000 Received: from CO1PEPF000042AE.namprd03.prod.outlook.com (2603:10b6:a03:331:cafe::ed) by SJ0PR03CA0088.outlook.office365.com (2603:10b6:a03:331::33) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9542.9 via Frontend Transport; Wed, 21 Jan 2026 13:56:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.194; helo=flwvzet200.ext.ti.com; pr=C Received: from flwvzet200.ext.ti.com (198.47.21.194) by CO1PEPF000042AE.mail.protection.outlook.com (10.167.243.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.4 via Frontend Transport; Wed, 21 Jan 2026 13:56:18 +0000 Received: from DFLE201.ent.ti.com (10.64.6.59) by flwvzet200.ext.ti.com (10.248.192.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:56:12 -0600 Received: from DFLE204.ent.ti.com (10.64.6.62) by DFLE201.ent.ti.com (10.64.6.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:56:11 -0600 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE204.ent.ti.com (10.64.6.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend Transport; Wed, 21 Jan 2026 07:56:11 -0600 Received: from ws.dhcp.ti.com (ws.dhcp.ti.com [172.24.233.149]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 60LDsPIK3104105; Wed, 21 Jan 2026 07:56:05 -0600 From: Rishikesh Donadkar To: , , CC: , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 14/18] media: ti: j721e-csi2rx: Submit all available buffers Date: Wed, 21 Jan 2026 19:24:20 +0530 Message-ID: <20260121135424.1185710-15-r-donadkar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260121135424.1185710-1-r-donadkar@ti.com> References: <20260121135424.1185710-1-r-donadkar@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042AE:EE_|DS7PR10MB7374:EE_ X-MS-Office365-Filtering-Correlation-Id: eb04c9ce-d659-44bc-8cd9-08de58f4d9c7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?FoOzMKdLQLNjMEfYv5ndnJ+x3SbEB8VpFqF2yXyd27n1JZnSyZasqwGfDX8k?= =?us-ascii?Q?1pFeUQsRS96Z9vqZnZQke/TePdJ8bb3oFa7Y1HhMfeOLoxX8GHFPTFKJB8cq?= =?us-ascii?Q?XSSWLQ24IyeomFdmS6QjkiASuzueLhBAux0SRmno9bDqOlbNtUNyRBdB8xdc?= =?us-ascii?Q?2aPECy/9eVpRL7K5gnS3CeUpnZFuqVISt/wsqUll7Zu1wrVWCyO3MjVNPIvQ?= =?us-ascii?Q?JCbJcfgNWWd8IzFcEEkC48X1gBCsrvVF+xzYFPCsmYWI2Rio4HqrfcbKvQ0s?= =?us-ascii?Q?S6cohIItNbubXZVK6sy/qSDIicp7AmAoCs8105XwHVJtFzLsUL1n8OiHU9v8?= =?us-ascii?Q?qBmOs+0DUBqNqqmnxymIJmR192OBj6z7nUZS0d5gjegjo281zwisSNsjdhhS?= =?us-ascii?Q?4s2gfDBIOIUY5AZNGPXBcBvXxgjNCVMxnbaqcpKJeIYgrH+gP07MtnBmC/yY?= =?us-ascii?Q?USYhcojbS5ugg6piQzOWwlQisLHvNB+cY0w3wQR6E69xTmn2/00EJM2xbZVp?= =?us-ascii?Q?1mmrkCbgqtWyKIgI4DVNqkWBNxoJy812u4xcWv3mRhfAkD3UACIpgmZR4few?= =?us-ascii?Q?Mz/nT6jm9X0g3zGjdXHmHmSoCNAWMFvdPC8M7r6la15p6JIY2E5L3W4LOD6j?= =?us-ascii?Q?eshD0z5LYCBGQg8aj1C5QZwtYGRdQfSPL7lLSdmKWmUeqvOd7YcncmyK05Cn?= =?us-ascii?Q?+Kq4viB/CSIIJEDm8yteVVnxqBmhgsUUHa9S5UEpWzzCvP25PQ+ayt8U5yF1?= =?us-ascii?Q?CemNDunJ4B2vp+NyWjdssZA6lGTyGeggLxVaVgdhbGttdOCsbkq9V6iI8QL3?= =?us-ascii?Q?RbG7+rBf+qpDlrbotrO69NgnDq0KjNTMOsIafyOIFwoEQmd0lSfbTfM8Iq7F?= =?us-ascii?Q?Sz7ftsOdL7OfC0P6ti4c5VjODjSt4bipmZFcVKNAuZsdjIRLi814cw96VP45?= =?us-ascii?Q?9nypDHSfuuczC2Fr0GExi5DEDL+yPX9C2JRfeZbGHA6ZGou2evmRr/S37AYH?= =?us-ascii?Q?kD5IuPMubwVDpha96faGYMVgF257nGOE1FV6IhQL+yPIYG/dytlNNpYYLMlk?= =?us-ascii?Q?DQXd17EUD5fedkQNHHaK3cTY2e2JyOfFNEco6p4lx2pDbip13LEgi6C7XNsA?= =?us-ascii?Q?yPTWoQCzQK544qHG3tqGdPFmwhmaJY6iIDlK5aIN9EeTOSIvO1dNBMdhVP+C?= =?us-ascii?Q?KndWxy6qnS0CW+hg35ceSDIQYLRFyVADxIe9010BqJv44VPK5B4BW+rwhAg5?= =?us-ascii?Q?b8eJHMTMeTjPBkBpTxUXhFJ/j5dV6whKj34a7c0pejd4mya7HDaiSaGuzrln?= =?us-ascii?Q?xFlVAgsMyE4pFgWqfHi6W8ulwLdTI/Fy5C+aort7Fj+fAWXzzNpZTRZvgQhX?= =?us-ascii?Q?sxFHuOh9KzksTxTsc+5UyEtWyOXXsWUTQLh4kRtMSrkM7sqstqkghdhqfhtO?= =?us-ascii?Q?rH0Xjdbxm8ICMmJKdSbsnjcn1gFtv2Ej/RhKII+gp2RuBjj0t7wGAtaBxiRU?= =?us-ascii?Q?C4YLaOxxodgozGNMYxIgj0eSC6qH6rl2eGsHu3+e8rfxNh1BPWbZx1YNAN8v?= =?us-ascii?Q?PdXS3iRhp8BtyZij/yA0a7LKvqb0lWPsFC/vk/wwg1kEJQ30/QXtLwePIU4K?= =?us-ascii?Q?MklJgSWMjpmYtFkYhQPcvAVaZ5cMsTR3MpdK4CPXxce6DIXRNcRNco/FiDt3?= =?us-ascii?Q?j7E6DA=3D=3D?= X-Forefront-Antispam-Report: CIP:198.47.21.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet200.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(82310400026)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2026 13:56:18.1372 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eb04c9ce-d659-44bc-8cd9-08de58f4d9c7 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.194];Helo=[flwvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000042AE.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB7374 Content-Type: text/plain; charset="utf-8" From: Jai Luthra We already make sure to submit all available buffers to DMA in each DMA completion callback. Move that logic in a separate function, and use it during stream start as well, as most application queue all their buffers before stream on. Signed-off-by: Jai Luthra Reviewed-by: Tomi Valkeinen Reviewed-by: Yemike Abhilash Chandra Co-developed-by: Rishikesh Donadkar Signed-off-by: Rishikesh Donadkar --- .../platform/ti/j721e-csi2rx/j721e-csi2rx.c | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/driver= s/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c index 4dabb99792d44..5bb726f7d4f44 100644 --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c @@ -664,11 +664,32 @@ static int ti_csi2rx_drain_dma(struct ti_csi2rx_ctx *= ctx) return ret; } =20 +static int ti_csi2rx_dma_submit_pending(struct ti_csi2rx_ctx *ctx) +{ + struct ti_csi2rx_dma *dma =3D &ctx->dma; + struct ti_csi2rx_buffer *buf; + int ret =3D 0; + + /* If there are more buffers to process then start their transfer. */ + while (!list_empty(&dma->queue)) { + buf =3D list_entry(dma->queue.next, struct ti_csi2rx_buffer, list); + ret =3D ti_csi2rx_start_dma(ctx, buf); + if (ret) { + dev_err(ctx->csi->dev, + "Failed to queue the next buffer for DMA\n"); + vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); + list_del(&buf->list); + } else { + list_move_tail(&buf->list, &dma->submitted); + } + } + return ret; +} + static void ti_csi2rx_dma_callback(void *param) { struct ti_csi2rx_buffer *buf =3D param; struct ti_csi2rx_ctx *ctx =3D buf->ctx; - struct ti_csi2rx_dev *csi =3D ctx->csi; struct ti_csi2rx_dma *dma =3D &ctx->dma; unsigned long flags; =20 @@ -685,18 +706,7 @@ static void ti_csi2rx_dma_callback(void *param) vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); list_del(&buf->list); =20 - /* If there are more buffers to process then start their transfer. */ - while (!list_empty(&dma->queue)) { - buf =3D list_entry(dma->queue.next, struct ti_csi2rx_buffer, list); - - if (ti_csi2rx_start_dma(ctx, buf)) { - dev_err(csi->dev, "Failed to queue the next buffer for DMA\n"); - list_del(&buf->list); - vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); - } else { - list_move_tail(&buf->list, &dma->submitted); - } - } + ti_csi2rx_dma_submit_pending(ctx); =20 if (list_empty(&dma->submitted)) dma->state =3D TI_CSI2RX_DMA_IDLE; @@ -1129,7 +1139,6 @@ static int ti_csi2rx_sd_enable_streams(struct v4l2_su= bdev *sd, struct ti_csi2rx_ctx *ctx =3D &csi->ctx[pad - TI_CSI2RX_PAD_FIRST_SOURCE]; struct ti_csi2rx_dma *dma =3D &ctx->dma; struct media_pad *remote_pad; - struct ti_csi2rx_buffer *buf; const struct ti_csi2rx_fmt *fmt; unsigned long flags; u64 sink_streams; @@ -1160,16 +1169,13 @@ static int ti_csi2rx_sd_enable_streams(struct v4l2_= subdev *sd, ctx->sequence =3D 0; =20 spin_lock_irqsave(&dma->lock, flags); - buf =3D list_entry(dma->queue.next, struct ti_csi2rx_buffer, list); =20 - ret =3D ti_csi2rx_start_dma(ctx, buf); + ret =3D ti_csi2rx_dma_submit_pending(ctx); if (ret) { - dev_err(csi->dev, "Failed to start DMA: %d\n", ret); spin_unlock_irqrestore(&dma->lock, flags); return ret; } =20 - list_move_tail(&buf->list, &dma->submitted); dma->state =3D TI_CSI2RX_DMA_ACTIVE; spin_unlock_irqrestore(&dma->lock, flags); =20 --=20 2.34.1 From nobody Sun Feb 8 21:47:54 2026 Received: from PH8PR06CU001.outbound.protection.outlook.com (mail-westus3azon11012052.outbound.protection.outlook.com [40.107.209.52]) (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 DC37B2D2481; Wed, 21 Jan 2026 13:56:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.209.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003792; cv=fail; b=rPcPsHl30goerklqF/qNiysbLxofi5EqFmKDOKzr9xjUuuaBcna32fndE4KtM8DBi+BrnZ3nE+KtJP+422Vx76L2oehN8nrx4fAUf+Xa4hgsm5NNwm9iWzEqIttxpX9m6CUVezOgW9OKtIyrlSpqy0qADzP5omg46mwYUqeLew8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003792; c=relaxed/simple; bh=1Y56v1FTIjQf0EbfLr0xCH86rdIcYZhoMwfTPL5Zwc4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=K2/TY7I98V+QHxgqJ0D0hnR0WDDMUVFcnEkEOTnkNcvhMKYIHj40FniA1974WEK8NfWECSuGQk0N9ywFGQQZMrMP6xrcKs7dOxxDPjKA2laSepntvD0jt3xMeHK5DsOGhYIk/X3DG1+oj1KDdnkJnL/jr8csO93sUj9qd6RhlTU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=gctrK7rm; arc=fail smtp.client-ip=40.107.209.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="gctrK7rm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MhlsyMFQD525kOINPqJyzmshcDvt7bTrMr8KCXcKbtNNefTBJNgSO4M7QAPJWLrXNGasod6a21AckYkkHWqLVlS+Zp+hP9uOQRI2Hkjip9EIRbZqHUhZmig8MtyuxgwdeNXYTKg1mp3uBbkTgfEoza1TJm/4JTlV6PHACqNMS4Rk7aNBaevTJcSYjQKi3u7oGptTmVtW/fG1zqTYrPfqS2v/PGNBNSN1R/DF9K6YkkAsvtRPBLN4eqLDBfiFUWD5IfYy/vIU8qu5QQheSITlxe8HxU9kSuaAfOquR4zijyzUBikgGb/rDLQ7FM+e0HOBPb/VZhJ2Y2EULYimUU1ADw== 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=AWDZzGItCZn9s3zCdhs1+A3P/gnHd7ghEJPnlgIDkFk=; b=eWO8tDFrh15nYT0NBKV78PMgz5L5OYdoewawo/JvzNEEpj9FMoydqeW+uFGa6BGzJSWgF+dZSiCO/8+tA6XmRzp4q9m3CderylRJRRqVS+M1u8b3JAY+mKyigb/sX/fKyE1cwTo+RUGBzsfDOJvseVyEWlbptMOcQdpVhLX0Chh77JspoyOSqZJeB0hvUk0DcfeHHnmpbgxBA9PucCPU5xGYsgKJ9Zk2/xuFkKwLiIjhuFVF0DkVvdNZ6gfoUsctPwpi0e2uzOFMfWBZxhdu3j4yvVLjz2u9SHxcRwOVj7beVdB+aEJiZ7Df3ILWwrupEmHUmeQ2vx1r/qZ2WHieyQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.21.195) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AWDZzGItCZn9s3zCdhs1+A3P/gnHd7ghEJPnlgIDkFk=; b=gctrK7rmaZfqGmg+9oRV7FYFskMpUi4QlO7VMG5Gmg6tQdt20WboyBlf8ooXoAOSBL9JBm4XCLbAnfjKfuS95xOeNvM3/mESrvaqfMJ67JKWCGQU/mNFi7KD8QRB7jllPpT4+M89aTwvWhtqwk71gshabb6Y+Yhyt1Vso6qQpg8= Received: from PH7PR17CA0018.namprd17.prod.outlook.com (2603:10b6:510:324::9) by PH8PR10MB6621.namprd10.prod.outlook.com (2603:10b6:510:223::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.9; Wed, 21 Jan 2026 13:56:27 +0000 Received: from SA2PEPF000015C7.namprd03.prod.outlook.com (2603:10b6:510:324:cafe::23) by PH7PR17CA0018.outlook.office365.com (2603:10b6:510:324::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9542.10 via Frontend Transport; Wed, 21 Jan 2026 13:56:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.21.195) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.21.195 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.21.195; helo=flwvzet201.ext.ti.com; pr=C Received: from flwvzet201.ext.ti.com (198.47.21.195) by SA2PEPF000015C7.mail.protection.outlook.com (10.167.241.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.4 via Frontend Transport; Wed, 21 Jan 2026 13:56:25 +0000 Received: from DFLE206.ent.ti.com (10.64.6.64) by flwvzet201.ext.ti.com (10.248.192.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:56:19 -0600 Received: from DFLE202.ent.ti.com (10.64.6.60) by DFLE206.ent.ti.com (10.64.6.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:56:18 -0600 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE202.ent.ti.com (10.64.6.60) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend Transport; Wed, 21 Jan 2026 07:56:18 -0600 Received: from ws.dhcp.ti.com (ws.dhcp.ti.com [172.24.233.149]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 60LDsPIL3104105; Wed, 21 Jan 2026 07:56:12 -0600 From: Rishikesh Donadkar To: , , CC: , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 15/18] media: ti: j721e-csi2rx: Change the drain architecture for multistream Date: Wed, 21 Jan 2026 19:24:21 +0530 Message-ID: <20260121135424.1185710-16-r-donadkar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260121135424.1185710-1-r-donadkar@ti.com> References: <20260121135424.1185710-1-r-donadkar@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015C7:EE_|PH8PR10MB6621:EE_ X-MS-Office365-Filtering-Correlation-Id: c33a73c4-d5fb-4305-5104-08de58f4de69 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|7416014|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?PLuPMXCswWb+8xcbH2uxPdqweus6z0meyCikV9Mp0DLpnl0Z54KVspju7LFU?= =?us-ascii?Q?1ff11hwUSYPgl8Jt+9pVzEpTtX5qt0xveh+TKHSMJ6lodE8/vRcrIFtBW/G1?= =?us-ascii?Q?zLfCara2Uuw86D7SolXz7n+L8e1RH8UtdcB6qD4ebIIfDxg9xn8HHkoKXa+l?= =?us-ascii?Q?qXhXrkMTDzEa6kNJEEmT3qaKr3SxZsKoZZW01oarvjhyUQPcznp455cHX3Mf?= =?us-ascii?Q?C+95K0LCKFBqtbJddIU//HWuH05mYafCosYtuMVD25DUZ+sa1j9YGml5Yti+?= =?us-ascii?Q?d9YL3YvdoKCevqzWsn376JXLbWX3AB44n4n0wQlc8cvpktOWXznBAdK19kw9?= =?us-ascii?Q?i7exNfPB9Y5am4+3dNlIQ/4xQwBv+Hb3cDmtN2slzvJLsDxsSNyp1MzfNuoE?= =?us-ascii?Q?FLDe5ePw3z9UB1P7pbQvAq+EheJD0ux6CJa0SXX8fQRKKCeTov5+dxPewAeP?= =?us-ascii?Q?BOEokIVL96Y5/zfAQEgu30+KOHgxrAGFd3za+fyRIrkEwVf22+8z0hQvr5ij?= =?us-ascii?Q?f8Iq5OZawuP/mj1YBLoHGDLkdahlCIRlFH0WgjL99oX9LrfWY4KcI3zcucvf?= =?us-ascii?Q?qBnF/9464SsYtnvZzrTBUE9XyCrTlCBRPBrCFdEwvm+8K6f876JiPfS0D7Dn?= =?us-ascii?Q?XYY8XBN9hzzt64K8wKcgIEs6PHYDXF2dXQgxICRPMhMrynayXouqrkPCQouL?= =?us-ascii?Q?e0KBwZFSVnQbkRQD3/5dbIeMTcBRxIZZTT7oS47AyIse1gL/IG4kim4SBos6?= =?us-ascii?Q?RsYXe7GOyz5/t9D6gm2JIdf7usMEsWFNPlczHt2MEdNyCCWQgZZ5eK2JsuST?= =?us-ascii?Q?WysIqajy7Npo1PKqZNkF9FuVpbX4Sjewn6DnE1e9IRl7Nv6yt3HITpDSvRws?= =?us-ascii?Q?0Oh5W8l9qcEq2gUARvyXKweId6dYjTNYTfVg7+rIl9v8dXqHGYFynIvUtM0b?= =?us-ascii?Q?nQZL3dJooQmwwFSbJU8WOzd+oiOliscwa+CgE0lULH0PD6/wR4PqikDhrvFb?= =?us-ascii?Q?3N37HTW9bbOv2l3KsOHzvBCornBEJnuzif7J2C/Vkd+wwjoCiBiyAHtUrmEd?= =?us-ascii?Q?i4dAu+m4CljerxPjE2pu+VaktdREAEqy/gT2+vr9A/4nFWQTI3Fan3gY+MR8?= =?us-ascii?Q?NU0Se2erKBFZyqjrpy2MPbtqCSfYAEWj8LPegVrP7pzCux7ssjNfo8zAoX5P?= =?us-ascii?Q?bjp6i2yHXpaAsQ65/Kz3GOi/pSZRrRqkc1rkfXD4lLLcX3603JEll4DtNtgQ?= =?us-ascii?Q?TMvJ6C3RcgvcYarrh0043gZsBkXpXYlRI0Ae4St7vETGQrUZciZPjF5YbzWQ?= =?us-ascii?Q?Ot2NBQnORXE6wdWMEoPjwaAP2JntwFi5H9+YZZD8KbNZfRVXSJfrFopOWeVz?= =?us-ascii?Q?BIFImgEfNKQHXH03yRScr/nF/iq+Ku1UW2IrN662u73gorYZe5K5idoqNsKu?= =?us-ascii?Q?a4ocWOCR2bjjtvYSXlBtQX9PhrU3bBcc2QmkX6uVuAfu7Bwcvcgg7LfXMNtu?= =?us-ascii?Q?4yr6ToqdufnlQXpQmSgoABkOe31KdMgtpa8rMVTKSfeL6fGkBEdxeqCP4v9r?= =?us-ascii?Q?EPR1yGVvczmnvYAggwOa8xC/898hsTMECBidu/Oh+1ffk4briKC861wk4HgQ?= =?us-ascii?Q?MoYDcsneB8dPuHnKUvbjkZtcQqLpBFb3Sr/Im4Qsh7mwL7lXHx5ADOlzkV/F?= =?us-ascii?Q?Zx/Ljg=3D=3D?= X-Forefront-Antispam-Report: CIP:198.47.21.195;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:flwvzet201.ext.ti.com;PTR:ErrorRetry;CAT:NONE;SFS:(13230040)(82310400026)(7416014)(376014)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2026 13:56:25.9533 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c33a73c4-d5fb-4305-5104-08de58f4de69 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.21.195];Helo=[flwvzet201.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF000015C7.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR10MB6621 Content-Type: text/plain; charset="utf-8" On buffer starvation the DMA is marked IDLE, and the stale data in the internal FIFOs gets drained only on the next VIDIOC_QBUF call from the userspace. This approach works fine for a single stream case. But in multistream scenarios, buffer starvation for one stream can block the shared HW FIFO of the CSI2RX IP. This can stall the pipeline for all other streams, even if buffers are available for them. This patch introduces a new architecture, that continuously drains data from the shared HW FIFO into a small (32KiB) buffer if no buffers are made available to the driver from the userspace. This ensures independence between different streams, where a slower downstream element for one camera does not block streaming for other cameras. Additionally, after we drain for a stream, the next frame will be a partial frame, as a portion of its data will have already been drained before a valid buffer is queued by user space to the driver. Return the partial frame to user space with VB2_BUF_STATE_ERROR. Use wait for completion barrier to make sure the shared hardware FIFO is cleared of the data at the end of stream after the source has stopped sending data. Reviewed-by: Jai Luthra Reviewed-by: Yemike Abhilash Chandra Signed-off-by: Rishikesh Donadkar Reviewed-by: Tomi Valkeinen --- .../platform/ti/j721e-csi2rx/j721e-csi2rx.c | 123 +++++++++--------- 1 file changed, 60 insertions(+), 63 deletions(-) diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/driver= s/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c index 5bb726f7d4f44..42ef8c553883f 100644 --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c @@ -82,8 +82,8 @@ struct ti_csi2rx_buffer { =20 enum ti_csi2rx_dma_state { TI_CSI2RX_DMA_STOPPED, /* Streaming not started yet. */ - TI_CSI2RX_DMA_IDLE, /* Streaming but no pending DMA operation. */ TI_CSI2RX_DMA_ACTIVE, /* Streaming and pending DMA operation. */ + TI_CSI2RX_DMA_DRAINING, /* Dumping all the data in drain buffer */ }; =20 struct ti_csi2rx_dma { @@ -109,6 +109,7 @@ struct ti_csi2rx_ctx { struct v4l2_format v_fmt; struct ti_csi2rx_dma dma; struct media_pad pad; + struct completion drain_complete; u32 sequence; u32 idx; u32 vc; @@ -249,6 +250,10 @@ static const struct ti_csi2rx_fmt ti_csi2rx_formats[] = =3D { static int ti_csi2rx_start_dma(struct ti_csi2rx_ctx *ctx, struct ti_csi2rx_buffer *buf); =20 +/* Forward declarations needed by ti_csi2rx_drain_callback. */ +static int ti_csi2rx_drain_dma(struct ti_csi2rx_ctx *ctx); +static int ti_csi2rx_dma_submit_pending(struct ti_csi2rx_ctx *ctx); + static const struct ti_csi2rx_fmt *find_format_by_fourcc(u32 pixelformat) { unsigned int i; @@ -609,9 +614,32 @@ static void ti_csi2rx_setup_shim(struct ti_csi2rx_ctx = *ctx) =20 static void ti_csi2rx_drain_callback(void *param) { - struct completion *drain_complete =3D param; + struct ti_csi2rx_ctx *ctx =3D param; + struct ti_csi2rx_dma *dma =3D &ctx->dma; + unsigned long flags; + + spin_lock_irqsave(&dma->lock, flags); + + if (dma->state =3D=3D TI_CSI2RX_DMA_STOPPED) { + complete(&ctx->drain_complete); + spin_unlock_irqrestore(&dma->lock, flags); + return; + } =20 - complete(drain_complete); + /* + * If dma->queue is empty, it indicates that no buffer has been + * provided by user space. In this case, initiate a transactions + * to drain the DMA. Since one drain of size DRAIN_BUFFER_SIZE + * will be done here, the subsequent frame will be a + * partial frame, with a size of frame_size - DRAIN_BUFFER_SIZE + */ + if (list_empty(&dma->queue)) { + if (ti_csi2rx_drain_dma(ctx)) + dev_warn(ctx->csi->dev, "DMA drain failed\n"); + } else { + ti_csi2rx_dma_submit_pending(ctx); + } + spin_unlock_irqrestore(&dma->lock, flags); } =20 /* @@ -629,12 +657,9 @@ static int ti_csi2rx_drain_dma(struct ti_csi2rx_ctx *c= tx) { struct ti_csi2rx_dev *csi =3D ctx->csi; struct dma_async_tx_descriptor *desc; - struct completion drain_complete; dma_cookie_t cookie; int ret; =20 - init_completion(&drain_complete); - desc =3D dmaengine_prep_slave_single(ctx->dma.chan, csi->drain.paddr, csi->drain.len, DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); @@ -644,7 +669,7 @@ static int ti_csi2rx_drain_dma(struct ti_csi2rx_ctx *ct= x) } =20 desc->callback =3D ti_csi2rx_drain_callback; - desc->callback_param =3D &drain_complete; + desc->callback_param =3D ctx; =20 cookie =3D dmaengine_submit(desc); ret =3D dma_submit_error(cookie); @@ -653,13 +678,6 @@ static int ti_csi2rx_drain_dma(struct ti_csi2rx_ctx *c= tx) =20 dma_async_issue_pending(ctx->dma.chan); =20 - if (!wait_for_completion_timeout(&drain_complete, - msecs_to_jiffies(DRAIN_TIMEOUT_MS))) { - dmaengine_terminate_sync(ctx->dma.chan); - dev_dbg(csi->dev, "DMA transfer timed out for drain buffer\n"); - ret =3D -ETIMEDOUT; - goto out; - } out: return ret; } @@ -703,14 +721,24 @@ static void ti_csi2rx_dma_callback(void *param) spin_lock_irqsave(&dma->lock, flags); =20 WARN_ON(!list_is_first(&buf->list, &dma->submitted)); - vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); + + if (dma->state =3D=3D TI_CSI2RX_DMA_DRAINING) { + vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); + dma->state =3D TI_CSI2RX_DMA_ACTIVE; + } else { + vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); + } + list_del(&buf->list); =20 ti_csi2rx_dma_submit_pending(ctx); =20 - if (list_empty(&dma->submitted)) - dma->state =3D TI_CSI2RX_DMA_IDLE; - + if (list_empty(&dma->submitted)) { + dma->state =3D TI_CSI2RX_DMA_DRAINING; + if (ti_csi2rx_drain_dma(ctx)) + dev_warn(ctx->csi->dev, + "DMA drain failed on one of the transactions\n"); + } spin_unlock_irqrestore(&dma->lock, flags); } =20 @@ -746,6 +774,7 @@ static int ti_csi2rx_start_dma(struct ti_csi2rx_ctx *ct= x, static void ti_csi2rx_stop_dma(struct ti_csi2rx_ctx *ctx) { struct ti_csi2rx_dma *dma =3D &ctx->dma; + struct ti_csi2rx_dev *csi =3D ctx->csi; enum ti_csi2rx_dma_state state; unsigned long flags; int ret; @@ -755,6 +784,8 @@ static void ti_csi2rx_stop_dma(struct ti_csi2rx_ctx *ct= x) dma->state =3D TI_CSI2RX_DMA_STOPPED; spin_unlock_irqrestore(&dma->lock, flags); =20 + init_completion(&ctx->drain_complete); + if (state !=3D TI_CSI2RX_DMA_STOPPED) { /* * Normal DMA termination does not clean up pending data on @@ -763,11 +794,20 @@ static void ti_csi2rx_stop_dma(struct ti_csi2rx_ctx *= ctx) * enforced before terminating DMA. */ ret =3D ti_csi2rx_drain_dma(ctx); - if (ret && ret !=3D -ETIMEDOUT) + if (ret) dev_warn(ctx->csi->dev, "Failed to drain DMA. Next frame might be bogus\n"); } =20 + /* We wait for the drain to complete so that the stream stops + * cleanly, making sure the shared hardware FIFO is cleared of + * data from the current stream. No more data will be coming from + * the source after this. + */ + if (!wait_for_completion_timeout(&ctx->drain_complete, + msecs_to_jiffies(DRAIN_TIMEOUT_MS))) + dev_dbg(csi->dev, "DMA transfer timed out for drain buffer\n"); + ret =3D dmaengine_terminate_sync(ctx->dma.chan); if (ret) dev_err(ctx->csi->dev, "Failed to stop DMA: %d\n", ret); @@ -830,57 +870,14 @@ static void ti_csi2rx_buffer_queue(struct vb2_buffer = *vb) struct ti_csi2rx_ctx *ctx =3D vb2_get_drv_priv(vb->vb2_queue); struct ti_csi2rx_buffer *buf; struct ti_csi2rx_dma *dma =3D &ctx->dma; - bool restart_dma =3D false; unsigned long flags =3D 0; - int ret; =20 buf =3D container_of(vb, struct ti_csi2rx_buffer, vb.vb2_buf); buf->ctx =3D ctx; =20 spin_lock_irqsave(&dma->lock, flags); - /* - * Usually the DMA callback takes care of queueing the pending buffers. - * But if DMA has stalled due to lack of buffers, restart it now. - */ - if (dma->state =3D=3D TI_CSI2RX_DMA_IDLE) { - /* - * Do not restart DMA with the lock held because - * ti_csi2rx_drain_dma() might block for completion. - * There won't be a race on queueing DMA anyway since the - * callback is not being fired. - */ - restart_dma =3D true; - dma->state =3D TI_CSI2RX_DMA_ACTIVE; - } else { - list_add_tail(&buf->list, &dma->queue); - } + list_add_tail(&buf->list, &dma->queue); spin_unlock_irqrestore(&dma->lock, flags); - - if (restart_dma) { - /* - * Once frames start dropping, some data gets stuck in the DMA - * pipeline somewhere. So the first DMA transfer after frame - * drops gives a partial frame. This is obviously not useful to - * the application and will only confuse it. Issue a DMA - * transaction to drain that up. - */ - ret =3D ti_csi2rx_drain_dma(ctx); - if (ret && ret !=3D -ETIMEDOUT) - dev_warn(ctx->csi->dev, - "Failed to drain DMA. Next frame might be bogus\n"); - - spin_lock_irqsave(&dma->lock, flags); - ret =3D ti_csi2rx_start_dma(ctx, buf); - if (ret) { - vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); - dma->state =3D TI_CSI2RX_DMA_IDLE; - spin_unlock_irqrestore(&dma->lock, flags); - dev_err(ctx->csi->dev, "Failed to start DMA: %d\n", ret); - } else { - list_add_tail(&buf->list, &dma->submitted); - spin_unlock_irqrestore(&dma->lock, flags); - } - } } =20 static int ti_csi2rx_get_stream(struct ti_csi2rx_ctx *ctx) --=20 2.34.1 From nobody Sun Feb 8 21:47:54 2026 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011039.outbound.protection.outlook.com [52.101.52.39]) (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 A7FDF4A3401; Wed, 21 Jan 2026 13:56:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.52.39 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003794; cv=fail; b=lLlGvqnledjQOXOy7hNLxAlKezzop06/xx497N7MNV2u/swqdEU6dtTqkN/NU98ZlHamcdSiGUFUpj22Rk2joCd0qZps6a1M7Og8mSiUzySgn557WQg5XPkvyaMxuTqJaRr2sio0EtmeU3rOOw71CzXz17JXEq7SnT93VCchT+M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003794; c=relaxed/simple; bh=Emrsvc2fQrq9w3u3/wua3InwnKbMSxntVTEA2sz8JQo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dbXWr1sHHGioRGOUDkNVkdh2DJvdvjPC+0XSZZjr/YOc/WlV5tUuUJ+YZ4ap7AJPPK9MrG7oTWuLWfdrvP6Gjz2ZzgCbgIjOoVfKO3HJQhWw3srQV6GK7JfCulljWgpvU8ja+fPeFjHX3tCckCbjBB1PKP8BbDQn8urw1ENYWJk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=QjB6eg6B; arc=fail smtp.client-ip=52.101.52.39 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="QjB6eg6B" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ogjt5+N11mxTw72DR+oELY5GMYpKToGLEdxQK8jo73uTmlvAnairoJYsGdDm7XbhF3rPpYcp6g6gnevnEwQvGwtEmOPk4Y6lFvynFyqxGx6QVqH32sAxlGArowDiKFDedjtuPiNtLpuQmXuxpNnCXyCoY6MhiEMSVwrXBFdyigkIxCs5zKkrn2lSMd366oSOrBhMS7fDWO3SdomCscHC3yFov7FaS8z+7W1jopfyMvQ90Qo6xnjNVYQKWnUU9UlDJce16V79e67NxO2XF7JsJPM9xLIBAEuxfUf4xfbfbENkYnkvN/yCpuwQTsEEnWABKwNyY5tBSGl4VaQwumVy1g== 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=BVUHTzGSq+DUecXAoKien2prvgKA84n0KTS5YvenEmY=; b=vL23I6krJS1z2yNx/Jv/dlU7OsMIM/BX3nlU2ddDCpF2aBm2vLu7tzvs9SuhUdt4P+UiJUoJmb+X3lcHPTD9tfuEBHm+t3MVW3Nvv+xGPMwYhL9Z0vrvQ1cCJtNB/BtJjc8Y1/kd1ZRY+sSJgSc5KIhFAdezvoXXOWbLMJKhvQeOvJqqfUZ8dfJEc5gwho0NioJZogRSKccHib20sBJDdmmcmuYCWFgZE1a3X+7jXFC/ny1wWtpQdUCJ1Dd/4nIdhnGgXTEQSJYtdIZ8CLLQ0Jer12CEd6xQI0DRFsnaDiMZ8iMdT+RrlyKmtJfBELT0KrQp1nQYkshTH0WAC+N8KQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.194) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BVUHTzGSq+DUecXAoKien2prvgKA84n0KTS5YvenEmY=; b=QjB6eg6ByztDd1+a0hyfUvBK3u1VY7Asuqt4o9U7kGpWmOk1dhjpwTxcrCm79cLCQfCrDNvF60rYFuytiqZhYmM4kPn7UbRtaEH2iI5cU8bodQ5pdGTihNm8bAa6hkwuW+ka7SW1TdpEZ660/O4ZgudeGI/LOIScSlrhjpDD4n0= Received: from PH7P220CA0168.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:33b::19) by DS7PR10MB5950.namprd10.prod.outlook.com (2603:10b6:8:85::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.9; Wed, 21 Jan 2026 13:56:28 +0000 Received: from CO1PEPF000044FC.namprd21.prod.outlook.com (2603:10b6:510:33b:cafe::69) by PH7P220CA0168.outlook.office365.com (2603:10b6:510:33b::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9542.10 via Frontend Transport; Wed, 21 Jan 2026 13:56:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.194; helo=lewvzet200.ext.ti.com; pr=C Received: from lewvzet200.ext.ti.com (198.47.23.194) by CO1PEPF000044FC.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9564.0 via Frontend Transport; Wed, 21 Jan 2026 13:56:27 +0000 Received: from DLEE212.ent.ti.com (157.170.170.114) by lewvzet200.ext.ti.com (10.4.14.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:56:26 -0600 Received: from DLEE204.ent.ti.com (157.170.170.84) by DLEE212.ent.ti.com (157.170.170.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:56:25 -0600 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DLEE204.ent.ti.com (157.170.170.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend Transport; Wed, 21 Jan 2026 07:56:25 -0600 Received: from ws.dhcp.ti.com (ws.dhcp.ti.com [172.24.233.149]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 60LDsPIM3104105; Wed, 21 Jan 2026 07:56:19 -0600 From: Rishikesh Donadkar To: , , CC: , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 16/18] media: cadence: csi2rx: Support runtime PM Date: Wed, 21 Jan 2026 19:24:22 +0530 Message-ID: <20260121135424.1185710-17-r-donadkar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260121135424.1185710-1-r-donadkar@ti.com> References: <20260121135424.1185710-1-r-donadkar@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044FC:EE_|DS7PR10MB5950:EE_ X-MS-Office365-Filtering-Correlation-Id: 07817f65-29ca-47a8-eeba-08de58f4df6c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?NtmjAs4XJaALVqT3MqjVvXKHvqV2BsNUZJ+10Yd2sPokhKrnA9Rbt8YPeuFg?= =?us-ascii?Q?Y36XyaWx8RWsuSLxGiaFSabp3iOQzaCsxz67NvBDWnDQ+L69Iu7vTGtUy5Oe?= =?us-ascii?Q?9TxN7gEkvJjGEMoYGds09A+we30CSLfXhDQx+7Cg4ckvMI3uGD7VpKh4dV7B?= =?us-ascii?Q?BzV5Rl5zhpCyd9V+U2ofDs88D8iiYbXYJreSwfR2Mb0vD/VDzAuUXbzsY9/Z?= =?us-ascii?Q?sXcawhGpFlV45jDcrIrAjhWXkFxk4W8tE4TFGvOq3VY9tEZZ8yzNEr+pXfk9?= =?us-ascii?Q?VaIkeg7tb4w+QqrEpvz4zajAZ94r8pPW8in6QCftjsofQnAbRbihupLYVSom?= =?us-ascii?Q?56R/5aljq09ynHP0eCCiJGmTPqrZ34Jf/DOENQYYrzEvS3PIeg2mv3BZzrSz?= =?us-ascii?Q?uU2s7EnlRmjTThFE7p5TmiofRrOoz6daTevRZYzZo+a4MQ8o3IJxjMSD0dFJ?= =?us-ascii?Q?LfbXP+UbP9vty383O2bWemgteZbGG0Smq9+u4jWn4C1et78XPnmQ/P3Bxk5O?= =?us-ascii?Q?OSXRkbna6ofYip1GAzrrOLdFCFmK7iD1swgwlhJIoSVLqsvWI332ZA3oOfiT?= =?us-ascii?Q?hQOuq9p670++VRjZhxpKYWZYoIqkdLbDGvQoBHTbk4MfDWwpmREJGfGChFrW?= =?us-ascii?Q?qOFBSL7WuYMsJpDKA41AYA3s1Td1HI2xdEV5gflT9ul/7DRRBmuaGpPmaCeP?= =?us-ascii?Q?MhTkUw0phQblL7XKzz5fERZ30G+VjPxzkum22duxdUWWtz0AHLxelJqwXpjz?= =?us-ascii?Q?DS5LI0puk6YhRPF81gaa0Wlopm4IjdTLtN3kKMhR+xnTrNcYASKRBjwoXCa0?= =?us-ascii?Q?TnPp/9FQmuAyjUQQMW4PuzKLxkk1MfrA3pm9xS+a9WDPU3kfkpE5dKu2LnMR?= =?us-ascii?Q?HTjzU2FFWkCakzGHV2q8azudQFD21TD76xr8KhxCyS8hvWFvEIbvYGHPT+0/?= =?us-ascii?Q?7LwQdTzTec5A9f8OQ+v0dTdKByGgevlyy22Hq0ucpq9AiUQFEQMfifiKmjU2?= =?us-ascii?Q?Lz//1EENFQDqv2eYT1sebxKp88w1brqo/+Nfjn9d21E0ZAkDCLHI0EsARFID?= =?us-ascii?Q?Mb5EIkmmxvwMYQyRVad7Ley3/lenivTYVzQBeRY/qkCaGJgTKs90GnvpkvLs?= =?us-ascii?Q?Q6Q1ceVfNiE7zd1xutulHGjNJZcmKSeuupC8cFEW/sALlmToF2PBkfSnUZyf?= =?us-ascii?Q?dRVME1SI2cRaObx97INBOIEam137LHnofaFWHNNXpTPiLSEVDOXNqdhW1VAG?= =?us-ascii?Q?ge33YkqCfiURhR93KEe3HEF/s3W0MvTVB2ja5AmQGa7VCVTiBGoa52GgsGVv?= =?us-ascii?Q?2/BoCNKrkX5zN3GLDd17EwOmiobuOaEncXMOnCxr93b5QHy6eWfobXRn60zX?= =?us-ascii?Q?JglT0zXeVNzoydW1bV9xNzKbCKM4HpIaZYpDFhbGTsjeptIU9M7GDU+mdnQf?= =?us-ascii?Q?kvScPwbsq/ofn8GGrJ/QdwHdhto+oBC3MrTAx7aoQRMNa8iUShpdMrYo6UBC?= =?us-ascii?Q?W9W2DHqRdgrcrtSF5bQyYObWxNo8OBwFVSIMyD1c3/e2iwrAdmsdtKLUWUQT?= =?us-ascii?Q?8wkFUCICRm44f+ZokC3rsePLNzbFasZnEKgQf6slfVCs+UCtKb1cicRVStZA?= =?us-ascii?Q?ir6t6t1Vs/o0Tj8OacxJUIu79zLMjbQO4Sf7oLA8OSv/ghwVhk1UgWHtHHf4?= =?us-ascii?Q?9ZPsuQ=3D=3D?= X-Forefront-Antispam-Report: CIP:198.47.23.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet200.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2026 13:56:27.5574 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 07817f65-29ca-47a8-eeba-08de58f4df6c X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.194];Helo=[lewvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044FC.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB5950 Content-Type: text/plain; charset="utf-8" From: Changhuang Liang Use runtime power management hooks to save power when CSI-RX is not in use. Also, shift to goto based error handling in csi2rx_enable_streams() function Signed-off-by: Changhuang Liang Tested-by: Rishikesh Donadkar Reviewed-by: Rishikesh Donadkar Reviewed-by: Tomi Valkeinen Signed-off-by: Jai Luthra Signed-off-by: Rishikesh Donadkar --- drivers/media/platform/cadence/Kconfig | 1 + drivers/media/platform/cadence/cdns-csi2rx.c | 136 ++++++++++++------- 2 files changed, 88 insertions(+), 49 deletions(-) diff --git a/drivers/media/platform/cadence/Kconfig b/drivers/media/platfor= m/cadence/Kconfig index 1aa608c00dbce..ea85ef82760e6 100644 --- a/drivers/media/platform/cadence/Kconfig +++ b/drivers/media/platform/cadence/Kconfig @@ -5,6 +5,7 @@ comment "Cadence media platform drivers" config VIDEO_CADENCE_CSI2RX tristate "Cadence MIPI-CSI2 RX Controller" depends on VIDEO_DEV + depends on PM select MEDIA_CONTROLLER select VIDEO_V4L2_SUBDEV_API select V4L2_FWNODE diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/p= latform/cadence/cdns-csi2rx.c index db9871fdbe3a4..041d9288af3ba 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -340,11 +340,6 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) u32 reg; int ret; =20 - ret =3D clk_prepare_enable(csi2rx->p_clk); - if (ret) - return ret; - - reset_control_deassert(csi2rx->p_rst); csi2rx_reset(csi2rx); =20 if (csi2rx->error_irq >=3D 0) @@ -385,7 +380,7 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) if (ret) { dev_err(csi2rx->dev, "Failed to configure external DPHY: %d\n", ret); - goto err_disable_pclk; + return ret; } } =20 @@ -400,12 +395,6 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) * hence the reference counting. */ for (i =3D 0; i < csi2rx->max_streams; i++) { - ret =3D clk_prepare_enable(csi2rx->pixel_clk[i]); - if (ret) - goto err_disable_pixclk; - - reset_control_deassert(csi2rx->pixel_rst[i]); - writel(CSI2RX_STREAM_CFG_FIFO_MODE_LARGE_BUF | FIELD_PREP(CSI2RX_STREAM_CFG_NUM_PIXELS_MASK, csi2rx->num_pixels[i]), @@ -418,30 +407,8 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) csi2rx->base + CSI2RX_STREAM_CTRL_REG(i)); } =20 - ret =3D clk_prepare_enable(csi2rx->sys_clk); - if (ret) - goto err_disable_pixclk; - - reset_control_deassert(csi2rx->sys_rst); - - clk_disable_unprepare(csi2rx->p_clk); =20 return 0; - -err_disable_pixclk: - for (; i > 0; i--) { - reset_control_assert(csi2rx->pixel_rst[i - 1]); - clk_disable_unprepare(csi2rx->pixel_clk[i - 1]); - } - - if (csi2rx->dphy) { - writel(0, csi2rx->base + CSI2RX_DPHY_LANE_CTRL_REG); - phy_power_off(csi2rx->dphy); - } -err_disable_pclk: - clk_disable_unprepare(csi2rx->p_clk); - - return ret; } =20 static void csi2rx_stop(struct csi2rx_priv *csi2rx) @@ -450,10 +417,6 @@ static void csi2rx_stop(struct csi2rx_priv *csi2rx) u32 val; int ret; =20 - clk_prepare_enable(csi2rx->p_clk); - reset_control_assert(csi2rx->sys_rst); - clk_disable_unprepare(csi2rx->sys_clk); - writel(0, csi2rx->base + CSI2RX_ERROR_IRQS_MASK_REG); =20 for (i =3D 0; i < csi2rx->max_streams; i++) { @@ -468,14 +431,8 @@ static void csi2rx_stop(struct csi2rx_priv *csi2rx) if (ret) dev_warn(csi2rx->dev, "Failed to stop streaming on pad%u\n", i); - - reset_control_assert(csi2rx->pixel_rst[i]); - clk_disable_unprepare(csi2rx->pixel_clk[i]); } =20 - reset_control_assert(csi2rx->p_rst); - clk_disable_unprepare(csi2rx->p_clk); - if (csi2rx->dphy) { writel(0, csi2rx->base + CSI2RX_DPHY_LANE_CTRL_REG); =20 @@ -549,10 +506,15 @@ static int csi2rx_enable_streams(struct v4l2_subdev *= subdev, * enable the whole controller. */ if (!csi2rx->count) { + ret =3D pm_runtime_resume_and_get(csi2rx->dev); + if (ret < 0) + goto err; + csi2rx_update_vc_select(csi2rx, state); + ret =3D csi2rx_start(csi2rx); if (ret) - return ret; + goto err_put_pm; } =20 /* Start streaming on the source */ @@ -562,13 +524,20 @@ static int csi2rx_enable_streams(struct v4l2_subdev *= subdev, dev_err(csi2rx->dev, "Failed to start streams %#llx on subdev\n", sink_streams); - if (!csi2rx->count) - csi2rx_stop(csi2rx); - return ret; + goto err_stop_csi; } =20 csi2rx->count++; return 0; + +err_stop_csi: + if (!csi2rx->count) + csi2rx_stop(csi2rx); +err_put_pm: + if (!csi2rx->count) + pm_runtime_put(csi2rx->dev); +err: + return ret; } =20 static int csi2rx_disable_streams(struct v4l2_subdev *subdev, @@ -590,8 +559,10 @@ static int csi2rx_disable_streams(struct v4l2_subdev *= subdev, csi2rx->count--; =20 /* Let the last user turn off the lights. */ - if (!csi2rx->count) + if (!csi2rx->count) { csi2rx_stop(csi2rx); + pm_runtime_put(csi2rx->dev); + } =20 return 0; } @@ -1077,6 +1048,7 @@ static int csi2rx_probe(struct platform_device *pdev) if (ret) goto err_cleanup; =20 + pm_runtime_enable(csi2rx->dev); ret =3D v4l2_async_register_subdev(&csi2rx->subdev); if (ret < 0) goto err_free_state; @@ -1091,6 +1063,7 @@ static int csi2rx_probe(struct platform_device *pdev) =20 err_free_state: v4l2_subdev_cleanup(&csi2rx->subdev); + pm_runtime_disable(csi2rx->dev); err_cleanup: v4l2_async_nf_unregister(&csi2rx->notifier); v4l2_async_nf_cleanup(&csi2rx->notifier); @@ -1109,9 +1082,73 @@ static void csi2rx_remove(struct platform_device *pd= ev) v4l2_async_unregister_subdev(&csi2rx->subdev); v4l2_subdev_cleanup(&csi2rx->subdev); media_entity_cleanup(&csi2rx->subdev.entity); + pm_runtime_disable(csi2rx->dev); kfree(csi2rx); } =20 +static int csi2rx_runtime_suspend(struct device *dev) +{ + struct csi2rx_priv *csi2rx =3D dev_get_drvdata(dev); + unsigned int i; + + reset_control_assert(csi2rx->sys_rst); + clk_disable_unprepare(csi2rx->sys_clk); + + for (i =3D 0; i < csi2rx->max_streams; i++) { + reset_control_assert(csi2rx->pixel_rst[i]); + clk_disable_unprepare(csi2rx->pixel_clk[i]); + } + + reset_control_assert(csi2rx->p_rst); + clk_disable_unprepare(csi2rx->p_clk); + + return 0; +} + +static int csi2rx_runtime_resume(struct device *dev) +{ + struct csi2rx_priv *csi2rx =3D dev_get_drvdata(dev); + unsigned int i; + int ret; + + ret =3D clk_prepare_enable(csi2rx->p_clk); + if (ret) + return ret; + + reset_control_deassert(csi2rx->p_rst); + + for (i =3D 0; i < csi2rx->max_streams; i++) { + ret =3D clk_prepare_enable(csi2rx->pixel_clk[i]); + if (ret) + goto err_disable_pixclk; + + reset_control_deassert(csi2rx->pixel_rst[i]); + } + + ret =3D clk_prepare_enable(csi2rx->sys_clk); + if (ret) + goto err_disable_pixclk; + + reset_control_deassert(csi2rx->sys_rst); + + return 0; + +err_disable_pixclk: + for (; i > 0; i--) { + reset_control_assert(csi2rx->pixel_rst[i - 1]); + clk_disable_unprepare(csi2rx->pixel_clk[i - 1]); + } + + reset_control_assert(csi2rx->p_rst); + clk_disable_unprepare(csi2rx->p_clk); + + return ret; +} + +static const struct dev_pm_ops csi2rx_pm_ops =3D { + RUNTIME_PM_OPS(csi2rx_runtime_suspend, csi2rx_runtime_resume, NULL) +}; + static const struct of_device_id csi2rx_of_table[] =3D { { .compatible =3D "starfive,jh7110-csi2rx" }, { .compatible =3D "cdns,csi2rx" }, @@ -1126,6 +1163,7 @@ static struct platform_driver csi2rx_driver =3D { .driver =3D { .name =3D "cdns-csi2rx", .of_match_table =3D csi2rx_of_table, + .pm =3D &csi2rx_pm_ops, }, }; module_platform_driver(csi2rx_driver); --=20 2.34.1 From nobody Sun Feb 8 21:47:54 2026 Received: from CH4PR04CU002.outbound.protection.outlook.com (mail-northcentralusazon11013036.outbound.protection.outlook.com [40.107.201.36]) (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 4D85B4A5AF6; Wed, 21 Jan 2026 13:56:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.201.36 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003799; cv=fail; b=jPm/m95wIFI/F5AIDXhgvZ9aI2tatDySM4B7qbFMiUF6xa3j0gjNzPPwb1ryV/K0eawunj3OBVPq+sZwc7O8ls7ZD2A6OMNqlUE1zCiR8exjhxriK1MLKaFbt3LskrA9/7aN2gRYsAM/yLYZdFfh+HEhP/0ZihS9udlsOS9bjcY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003799; c=relaxed/simple; bh=ctgakOB8M3/wpyJzPeVWUjr0zi9SqROwsYpILl0av78=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LfVxyYfyGmt18SNq1nuxEl0EF+7tHMi/uqv4nqXeP3/G94rJgCilGz4d0WG1g7s/ZkMbGXEC9+r2pVSOobQPVLPgboXv1KoFg47+Cn/++gxJddqXMW3G7PFGYrjLmPaqXxSK4UkCz5/sSdDJEfm0EWf6bWvDHGtgF6EC42AkDyo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=C5Dn2t3b; arc=fail smtp.client-ip=40.107.201.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="C5Dn2t3b" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RZL6d1j3aSBLAKbCFACz6XQvkWXAeq+sBbuYnqN/2+KhTX5vEAtpLzVmla32qBB9afjKRyD/u4ENVYEhJ2D2aSVTfoAaeaYyKvF12H0x768FATHk1mZRzvrN9mQ/6m/KV02PsCWNdMgdmvFOSj+mu3x9S4RNgiZHPmq2f3MwKRtQrNWrg+s8TcWY8aqpqwzcBhTtyYIa1CNSQAFJCuTtDhjOsvb+FePdyc42GM7/5ohHUsjvHb+xCZUBcwV31DTIMPjQOXt700WSYbxPDz0QVClI65oiQbtK4FGpQwbZyUIfqWB1xN2VKk5tE7EdGxGKmZyiCUBpcahgd/XTY5SaoQ== 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=NuWynR4xJE7UMn65qZaTYrCo7ciVYjb70ApZ2KjgbiY=; b=AfNr/10z+q5R2JH5dayUjuVq4ZNHwfIWF6IdpOQwMkypa2krPKzT+HQF55SYRATPFYbJn1JFgiz6Z/ncRTU2VeN7tlvktSZ1iXtV3IMdwcq4o+c2vu+tbfAkZXBJpxNI5+AC12bGRu5UhPkifwkOMXN+++wLSYm63PDyIsfDlFf2I3SNjK1ngBJZBKQwZ49UUWi6WXol6XSxIgj2gP4cdcWod4Ly2dER4POtS0/SolHvT6pPJ8dWf67lX9JX1nJXiSzdZNz3e1UmcExBWw4QPKzJvu4K7lYPk0hWBeaJ2m82PgB12bZoOjj+sYJLF3DWLVGERxIlWVGIbdyx2qgkaA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.194) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NuWynR4xJE7UMn65qZaTYrCo7ciVYjb70ApZ2KjgbiY=; b=C5Dn2t3bhVVzdMomn0wWGa2RdSKum0dgA68941ek9OxZ7JakFxcY++SCAKvQi1WrsR/VNmb/10wM6Nk5Y6tGp/D472Eq0zFvWkipQIAcix8Kx6aZUFUlIIPShuqu5e011q+9eb1ge7NgzGSAwCrQ98gEwWi7F+YtVXc8eR5BeOo= Received: from PH2PEPF00003847.namprd17.prod.outlook.com (2603:10b6:518:1::64) by CO6PR10MB5554.namprd10.prod.outlook.com (2603:10b6:303:141::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.9; Wed, 21 Jan 2026 13:56:34 +0000 Received: from CO1PEPF000044F9.namprd21.prod.outlook.com (2a01:111:f403:c91d::4) by PH2PEPF00003847.outlook.office365.com (2603:1036:903:48::3) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9542.10 via Frontend Transport; Wed, 21 Jan 2026 13:56:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.194; helo=lewvzet200.ext.ti.com; pr=C Received: from lewvzet200.ext.ti.com (198.47.23.194) by CO1PEPF000044F9.mail.protection.outlook.com (10.167.241.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9564.0 via Frontend Transport; Wed, 21 Jan 2026 13:56:34 +0000 Received: from DLEE211.ent.ti.com (157.170.170.113) by lewvzet200.ext.ti.com (10.4.14.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:56:33 -0600 Received: from DLEE215.ent.ti.com (157.170.170.118) by DLEE211.ent.ti.com (157.170.170.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:56:32 -0600 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DLEE215.ent.ti.com (157.170.170.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend Transport; Wed, 21 Jan 2026 07:56:32 -0600 Received: from ws.dhcp.ti.com (ws.dhcp.ti.com [172.24.233.149]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 60LDsPIN3104105; Wed, 21 Jan 2026 07:56:26 -0600 From: Rishikesh Donadkar To: , , CC: , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 17/18] media: ti: j721e-csi2rx: Support runtime suspend Date: Wed, 21 Jan 2026 19:24:23 +0530 Message-ID: <20260121135424.1185710-18-r-donadkar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260121135424.1185710-1-r-donadkar@ti.com> References: <20260121135424.1185710-1-r-donadkar@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F9:EE_|CO6PR10MB5554:EE_ X-MS-Office365-Filtering-Correlation-Id: 8bb6a1bd-8f68-427b-6363-08de58f4e347 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|36860700013|82310400026|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?664p/7Dtj4x/K97A7wS/+hLQN7yl6IGf22U4XglsryQRnfJdY3pjASVtkRRD?= =?us-ascii?Q?qVAna7JgXB/VZ2nWhm5FutdT9WDodrONE//oJKHYf7FnboQs/ZMI6WlKh8+8?= =?us-ascii?Q?hMeWrKFTOZcIwRoBH+dJr/X5bq9QfKby6tn0pyAtFklB/xCI0k9c3nQunccQ?= =?us-ascii?Q?/uvFP6rARPZG5bgwIPjxvtfhuL0Js83Pa0F1/n2XEoRw++N75WJliuH0KEZP?= =?us-ascii?Q?RM0yYNxhkQNZs+eDotVQ3kL0cvAv+446AITo2TvK32WqKe8P4FSEXY0dekTK?= =?us-ascii?Q?GUEwHevK9YxRSbUsZhTZl0gqxWI87gdd/HfRud2zGEd2xV9HRfMB8PLjL31J?= =?us-ascii?Q?UYv0Sx4cFdVEshnDRBSbIGdEX4rQC1Kn2OTGpu77OqRNjUUimOiOQeOl0/OM?= =?us-ascii?Q?W9UE2DJFY/OcOZO0RCNLKgHEnhYQyMuyFgSiomuZ0kIAYpr3w0Uq7iroHFRW?= =?us-ascii?Q?fnw2T3bMkBjMhaP4s7+3Eb9EfWu1Tb3iZp34m4/km4h2LxZLc40OsM6FqHqf?= =?us-ascii?Q?mcAoF3DqpPZFBOnqq5c7GyFQaEWlw9lcOUzZ/Nt1p2qcdvA5E6Rfcyys7clI?= =?us-ascii?Q?g+n0RPtRHCUW7q5+BOsQ+XFhlutk1Kpe8MDcAie/lSvbmVz2WwiI01208luT?= =?us-ascii?Q?prsZR6F3kuAnh8bqgo9mvVG9PMIIuZo2nBBY4YfwWVo9OqB8n+v+E/EYZYGX?= =?us-ascii?Q?YhDaVKLyd/lOy+0hq9iG6gDMkVZY2sQf3N4cR1Q82GiSUD+51FAcATA10FuU?= =?us-ascii?Q?A/c4MWP+7/7F+/qWLvO5Qp3F2VnTXWEe9ToaLIQbTNvOIi4Yd1bZL2wlzl8s?= =?us-ascii?Q?VuFBZFiDRZszbv/U2YeQeJyNBJV+cugf1vXvaes0BLDGj/NyRkg4y/c/ZGbp?= =?us-ascii?Q?r/4WIHbPBTR2kVVI3/caB2pIOyPuG8udus4UYjSMPVoebMqCML36roPBdRTK?= =?us-ascii?Q?l4JKwomKH56YWygmQwEPRV45qGFqpY2MFQrMX9KChMUamoPo8xsbwk+R+KiL?= =?us-ascii?Q?LyUevWW4lvFTITa/0fRpyWrZrFUuaf4a3Ijpg2QzdqoL8SIr8gDodpWERCdb?= =?us-ascii?Q?3PXs57pFgWyuog4cY38K1GKTwYkue7RSqkY1NBa0frWQsw5ZxkGeUzxd34Ag?= =?us-ascii?Q?4NMZzN3KH89gMyN8whIXc8CpQvrTQt48UTKPqIo0usk7AVc/0pTjgxMcClMA?= =?us-ascii?Q?j9vei0sey33DzQKlSyy+BEEM8ySjt0yix2hnpF+oJQxE317SkDEScFcexH9g?= =?us-ascii?Q?IapFd2h3CbIau8CuJ4YRzrv63d7Wk0s4froq/VwcK67KcYLAJkB8XBNSgWQ6?= =?us-ascii?Q?64wH5+BztIHfPJ1tx2xLf9TzId0HVFP5Er7LXPDJQvp2wxa8bKos996x7i2n?= =?us-ascii?Q?pBHgoNNDFLgHLjYFJ9fqVsHqug6neoComKvpOUUknJKN4h4ULgL3nwpt8nGR?= =?us-ascii?Q?rboUPSXm4tE8eY4gjYQVvjHSrn20IsF5rd5JVXa8MhhpLhl9Yvh1uOOXq3IK?= =?us-ascii?Q?J78o8TABxEhaLxSupmmG7TxdtO3FUkn5+z0C3gBig7JSlzWaa5a/DPS8W9Zk?= =?us-ascii?Q?YoNkf6yvJUXFPUNQ46/8rTv4R7d4XuheeDgT/C/FJYaKX1Lb4eKYTDHJe1du?= =?us-ascii?Q?sNYB5LN3QtXKcovUefuBPPJuCrwThA3NfNZf7hp5um61K/pke1OLZopmLxT6?= =?us-ascii?Q?0QGznw=3D=3D?= X-Forefront-Antispam-Report: CIP:198.47.23.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet200.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(1800799024)(36860700013)(82310400026)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2026 13:56:34.0236 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8bb6a1bd-8f68-427b-6363-08de58f4e347 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.194];Helo=[lewvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F9.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5554 Content-Type: text/plain; charset="utf-8" From: Jai Luthra Add support for runtime power-management to enable powering off the shared power domain between Cadence CSI2RX and TI CSI2RX wrapper when the device(s) are not in use. When powering off the IP, the PSI-L endpoint loses the paired DMA channels. Thus we have to release the DMA channels at runtime suspend and request them again at resume. Tested-by: Rishikesh Donadkar Reviewed-by: Rishikesh Donadkar Reviewed-by: Tomi Valkeinen Signed-off-by: Jai Luthra Co-developed-by: Rishikesh Donadkar Signed-off-by: Rishikesh Donadkar --- drivers/media/platform/ti/Kconfig | 1 + .../platform/ti/j721e-csi2rx/j721e-csi2rx.c | 59 +++++++++++++++---- 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/ti/Kconfig b/drivers/media/platform/ti/= Kconfig index da33facf44678..d0cb05481bd85 100644 --- a/drivers/media/platform/ti/Kconfig +++ b/drivers/media/platform/ti/Kconfig @@ -83,6 +83,7 @@ config VIDEO_TI_J721E_CSI2RX depends on VIDEO_CADENCE_CSI2RX depends on PHY_CADENCE_DPHY_RX || COMPILE_TEST depends on ARCH_K3 || COMPILE_TEST + depends on PM select VIDEOBUF2_DMA_CONTIG select V4L2_FWNODE help diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/driver= s/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c index 42ef8c553883f..c01905680e108 100644 --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c @@ -13,6 +13,7 @@ #include #include #include +#include #include =20 #include @@ -962,12 +963,16 @@ static int ti_csi2rx_start_streaming(struct vb2_queue= *vq, unsigned int count) unsigned long flags; int ret =3D 0; =20 + ret =3D pm_runtime_resume_and_get(csi->dev); + if (ret) + return ret; + spin_lock_irqsave(&dma->lock, flags); if (list_empty(&dma->queue)) ret =3D -EIO; spin_unlock_irqrestore(&dma->lock, flags); if (ret) - return ret; + goto err; =20 ret =3D video_device_pipeline_start(&ctx->vdev, &csi->pipe); if (ret) @@ -989,6 +994,8 @@ static int ti_csi2rx_start_streaming(struct vb2_queue *= vq, unsigned int count) writel(0, csi->shim + SHIM_DMACNTX(ctx->idx)); err: ti_csi2rx_cleanup_buffers(ctx, VB2_BUF_STATE_QUEUED); + pm_runtime_put(csi->dev); + return ret; } =20 @@ -1008,6 +1015,7 @@ static void ti_csi2rx_stop_streaming(struct vb2_queue= *vq) =20 ti_csi2rx_stop_dma(ctx); ti_csi2rx_cleanup_buffers(ctx, VB2_BUF_STATE_ERROR); + pm_runtime_put(csi->dev); } =20 static const struct vb2_ops csi_vb2_qops =3D { @@ -1259,7 +1267,6 @@ static void ti_csi2rx_cleanup_notifier(struct ti_csi2= rx_dev *csi) =20 static void ti_csi2rx_cleanup_ctx(struct ti_csi2rx_ctx *ctx) { - dma_release_channel(ctx->dma.chan); vb2_queue_release(&ctx->vidq); =20 video_unregister_device(&ctx->vdev); @@ -1279,7 +1286,7 @@ static int ti_csi2rx_init_vb2q(struct ti_csi2rx_ctx *= ctx) q->ops =3D &csi_vb2_qops; q->mem_ops =3D &vb2_dma_contig_memops; q->timestamp_flags =3D V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; - q->dev =3D dmaengine_get_dma_device(ctx->dma.chan); + q->dev =3D ctx->csi->dev; q->lock =3D &ctx->mutex; q->min_queued_buffers =3D 1; q->allow_cache_hints =3D 1; @@ -1493,21 +1500,46 @@ static int ti_csi2rx_init_ctx(struct ti_csi2rx_ctx = *ctx) spin_lock_init(&ctx->dma.lock); ctx->dma.state =3D TI_CSI2RX_DMA_STOPPED; =20 - ret =3D ti_csi2rx_init_dma(ctx); + ret =3D ti_csi2rx_init_vb2q(ctx); if (ret) return ret; =20 - ret =3D ti_csi2rx_init_vb2q(ctx); - if (ret) - goto cleanup_dma; + return 0; +} + +static int ti_csi2rx_runtime_suspend(struct device *dev) +{ + struct ti_csi2rx_dev *csi =3D dev_get_drvdata(dev); + int i; + + if (csi->enable_count !=3D 0) + return -EBUSY; + + for (i =3D 0; i < csi->num_ctx; i++) + dma_release_channel(csi->ctx[i].dma.chan); =20 return 0; +} =20 -cleanup_dma: - dma_release_channel(ctx->dma.chan); - return ret; +static int ti_csi2rx_runtime_resume(struct device *dev) +{ + struct ti_csi2rx_dev *csi =3D dev_get_drvdata(dev); + unsigned int ret, i; + + for (i =3D 0; i < csi->num_ctx; i++) { + ret =3D ti_csi2rx_init_dma(&csi->ctx[i]); + if (ret) + return ret; + } + + return 0; } =20 +static const struct dev_pm_ops ti_csi2rx_pm_ops =3D { + RUNTIME_PM_OPS(ti_csi2rx_runtime_suspend, ti_csi2rx_runtime_resume, + NULL) +}; + static int ti_csi2rx_probe(struct platform_device *pdev) { struct device_node *np =3D pdev->dev.of_node; @@ -1563,6 +1595,8 @@ static int ti_csi2rx_probe(struct platform_device *pd= ev) goto err_ctx; } =20 + pm_runtime_enable(csi->dev); + ret =3D ti_csi2rx_notifier_register(csi); if (ret) goto err_ctx; @@ -1593,6 +1627,9 @@ static void ti_csi2rx_remove(struct platform_device *= pdev) struct ti_csi2rx_dev *csi =3D platform_get_drvdata(pdev); unsigned int i; =20 + if (!pm_runtime_status_suspended(&pdev->dev)) + pm_runtime_set_suspended(&pdev->dev); + for (i =3D 0; i < csi->num_ctx; i++) ti_csi2rx_cleanup_ctx(&csi->ctx[i]); =20 @@ -1600,6 +1637,7 @@ static void ti_csi2rx_remove(struct platform_device *= pdev) ti_csi2rx_cleanup_v4l2(csi); dma_free_coherent(csi->dev, csi->drain.len, csi->drain.vaddr, csi->drain.paddr); + pm_runtime_disable(&pdev->dev); } =20 static const struct of_device_id ti_csi2rx_of_match[] =3D { @@ -1614,6 +1652,7 @@ static struct platform_driver ti_csi2rx_pdrv =3D { .driver =3D { .name =3D TI_CSI2RX_MODULE_NAME, .of_match_table =3D ti_csi2rx_of_match, + .pm =3D &ti_csi2rx_pm_ops, }, }; =20 --=20 2.34.1 From nobody Sun Feb 8 21:47:54 2026 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011024.outbound.protection.outlook.com [52.101.52.24]) (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 7CAED481FC0; Wed, 21 Jan 2026 13:56:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.52.24 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003808; cv=fail; b=q8uCyBYQLNs8uesN7MCAlWim5TCnk9PEljLJvYTsT4e7vMP0/hX2/71R5dN888HPI1x0C3ghoibNytLP1e3V2kq1q46j42mmlK7wEJxt0DICv1Fxo7DT3YiyvOc5Iapucxjde0T78AOiFYuJXi4Ub4irh3MSwR5Mkazsg//L+uQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769003808; c=relaxed/simple; bh=IqBC618vVkrvMWOgTqTWroI/kDeYrreU4ezTqXAsh7E=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jmQOxpAEDB5LP/a0vocJEYFa1Eu1rUDC7IdpP7yDG72JGtQYM4BgpP5AWpy+1Pe3HKz0Eld1MUMPYEHpVhVQ6ezblFVXxefbqEDxS4bqDPYMTxRYx6RqGJCFq4Ao3UOMPXhCefc6W+EhOv+q0AFdQqYB8EitlkBl2FQf7B149Rk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=t+4qdiQG; arc=fail smtp.client-ip=52.101.52.24 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="t+4qdiQG" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ha9Kqb9aUI5YvmaOPPp/Omo7cHfLBcvUASnH5LGGlR4Ma9JtDfDEaiUHdOg+7Asu39jvc+gCFpa7Sve0glrsTdrcyjEPtD8ryWYubfRYothI2Rjmk6TNPari/1aXdjPRxeAxsYCFUFKPIGdFLaTIexh1QID15tMcU6IvEKF5Qs+LbH2t1QByafoRy24cpjd6PKQ3hp8Qf+OH4KfZdVf7aE/l3plMg6Yuc+p9W+sjKNk5nOha2AEWwtrt7QRi+La8xnZ166SH+gEeSskNpT4wQRXFgjYcaWfAsrhVmKzcm/CkddX55QjwMz0IgJ686ldo5yEMMetK+cJErYA/ej7pEA== 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=xM2TtWtGehoZ9NoQFehU6+3Qsu1JqP66eqeb04iisnA=; b=ci7tbpOfwTKRQNNW1uQDSpc/9hBBEUpgG+JuDyoGDrQXgpTo5RbuuLz7dKUe+rkx3qYdHRd/iNI/BHxRjrfSJjFcK3HcYbovTHFQ8Czt1P9ou/BzAd5sGcdTIT1IPOiQY1aia4pRspA9ql3q074C1C/d29wX6KB+HPQ1MsoPmgITWiZ/4lFEc7PZeisFO4hJ4NTSdGPSgQbfbgHBlRuFtxMhRMHJWqlFSZuxTtDYHhGo9DAjP88srZz7YjQOpzPl43EjBNVP9puLYE6bjQBFsk1mklNzFj8PDVPoGc5BXbmwvi8xXHJXYHxUANf8T1OOD07b+2duBeKbvINu6mD13w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 198.47.23.194) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=ti.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xM2TtWtGehoZ9NoQFehU6+3Qsu1JqP66eqeb04iisnA=; b=t+4qdiQGHy+SV/J8zscFrncmcyUq9Vto0RPnoBcg7a4q2N9lZK1esZSYusHnfsSEkONrDR6SB2Yh/ugnyGK/YFwMDTaGvqKeoiehUpbdv4Em/OpJd0Op7U0A5P8Wv+Z0YSk0/45LH7JPOF4gDyXVrbwS6c4L1Il+bFezGQeiwNQ= Received: from PH2PEPF0000385D.namprd17.prod.outlook.com (2603:10b6:518:1::6b) by BN0PR10MB5128.namprd10.prod.outlook.com (2603:10b6:408:117::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.11; Wed, 21 Jan 2026 13:56:42 +0000 Received: from CO1PEPF000044F9.namprd21.prod.outlook.com (2a01:111:f403:c91d::4) by PH2PEPF0000385D.outlook.office365.com (2603:1036:903:48::3) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9542.10 via Frontend Transport; Wed, 21 Jan 2026 13:56:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 198.47.23.194) smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ti.com; Received-SPF: Pass (protection.outlook.com: domain of ti.com designates 198.47.23.194 as permitted sender) receiver=protection.outlook.com; client-ip=198.47.23.194; helo=lewvzet200.ext.ti.com; pr=C Received: from lewvzet200.ext.ti.com (198.47.23.194) by CO1PEPF000044F9.mail.protection.outlook.com (10.167.241.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9564.0 via Frontend Transport; Wed, 21 Jan 2026 13:56:42 +0000 Received: from DLEE214.ent.ti.com (157.170.170.117) by lewvzet200.ext.ti.com (10.4.14.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:56:40 -0600 Received: from DLEE210.ent.ti.com (157.170.170.112) by DLEE214.ent.ti.com (157.170.170.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Wed, 21 Jan 2026 07:56:39 -0600 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DLEE210.ent.ti.com (157.170.170.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend Transport; Wed, 21 Jan 2026 07:56:39 -0600 Received: from ws.dhcp.ti.com (ws.dhcp.ti.com [172.24.233.149]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 60LDsPIO3104105; Wed, 21 Jan 2026 07:56:33 -0600 From: Rishikesh Donadkar To: , , CC: , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 18/18] media: ti: j721e-csi2rx: Support system suspend using pm_notifier Date: Wed, 21 Jan 2026 19:24:24 +0530 Message-ID: <20260121135424.1185710-19-r-donadkar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260121135424.1185710-1-r-donadkar@ti.com> References: <20260121135424.1185710-1-r-donadkar@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F9:EE_|BN0PR10MB5128:EE_ X-MS-Office365-Filtering-Correlation-Id: b39ce0fe-f8eb-45bc-ae97-08de58f4e845 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?j8HYG2MLYkfdtnEsyvTyIo4EPTC9IJ3iq+zt6hcaY+oXf+ojl4TvD5+Ph/g5?= =?us-ascii?Q?hUBdg69GK0hcI/PcQflqWEjM8zQvsNBRtkdmoqCNYR1IY2wjiOGeAxsrl8EN?= =?us-ascii?Q?LJX1HfaHFcNOrOknMvAEKznROKHakmPIvu/8Odar4lYf2ow0zZRS+/VHVksr?= =?us-ascii?Q?kulBCyxrn/MscUZ3K6RmoWbCFMQPFXhr9/fAtmPImpqu/fgI7uOfaMS2ovZk?= =?us-ascii?Q?KVpuB7EhYp/maA8Grpo9ZZao4f+yAtkOaDKQVJ7Ue0FACXqzOzSTga+2lTzz?= =?us-ascii?Q?dV1KjcsEqJ365gkY0U5VTZYZpIk256WnpJBbC+ffhN5NERAyjOS54c3cgY7w?= =?us-ascii?Q?cA5yFGG9UDf2PsGhfOC0VrFnPtLHRCayPvOXEWQNUkQ/kwL5uGXXkTns07Kk?= =?us-ascii?Q?GSzRVeGOqT9WaqJuHpFsJKg9/JKPfiCKLj4MuggqYywWj+suvNazVwx4e059?= =?us-ascii?Q?i8oTNdHRfLlKF8XWvm9yMu1gEFUhJ+cHP9SB9sWD3DT95b9n2ikoXVK96E7N?= =?us-ascii?Q?My3MTDEJwj86POen10HZHRc9WBP2seBKJzXwa+kBIEh31QfWqCwB7NTopvSl?= =?us-ascii?Q?c8IUyk7u5laGbDmGAI8NR4LCDbsjG8axhy1ro1lYB8+0qYlbBpBC9rIAMAPN?= =?us-ascii?Q?Lyz3N0AjLSQD46I+pcpQuvF/TnXXk9ItQKPFZy5j4CW2kGGkII2mq27ZGw34?= =?us-ascii?Q?+Bjr8079Zf+bxBUm0VdbTY6YMUDVNqX1RPVJDbq89QJOsifkfZaw+d4d8Xdx?= =?us-ascii?Q?dBjjc7P2LAvS5vYoN7ma5kWVgqHUBdP9Kv7kmH8xAk0uCGjTXCArfM0VFaLj?= =?us-ascii?Q?2io5AGQNaU0pmRk4eaNP8/szzdydtEgFWzghNMW4yxDht0yqU7DhGdHwqu6m?= =?us-ascii?Q?i83rJHyhl454uEG3ZDPzE/8+eKc5Dozr9aTivIfd9KbXtT3/VafdPVTCUIj7?= =?us-ascii?Q?ktrdZAvjcSWlX0dwLxDQdJQ4y5jUrKd7oqwntG732qk5biJzLgdlTKdbSv+R?= =?us-ascii?Q?tNd8yNyVjQT+3cZRnbSKlfv59wtlNmIFbSCDi7IWe/jC10LAC8C+scYE4PeL?= =?us-ascii?Q?SK38FYaGDcEccpoI+l9HaLcMUYyU3RrfSn5m2vGex6/deBqWNawNnbqK7Miu?= =?us-ascii?Q?ooUSkzArUnw7cZBzMH8ZVLbgOuFoBaquVLQxiOGsmlDTW0+QQzdlD2JSMXrH?= =?us-ascii?Q?ghcrsRrh/E1GIXoJACDO9pR3iB4dxbFkJpwj6k4Pb0/EhiVXip7fa5Q/ijEd?= =?us-ascii?Q?lQXnetJqySq0K2sZ1Ho7hDhuSFVJZhxgNtQ3gRkwpg6JjFyRxt4X95LiWUkK?= =?us-ascii?Q?vt+NOFQB9vuVmlQ/BOw4EZOK/kDmFSPv1nEIxS2JEuer4vbclsjS2jthlWWi?= =?us-ascii?Q?BL/wORFqCqN974RuJzGF6lEhvUG6q5vCbX6rRmX0hii8TkO9nftCG6isH7qU?= =?us-ascii?Q?SB9Rd4MaSI9KArz3t5yWOiK3GwQJ0QqD+62zXM+0k6iqGo5qt01ImEB2b2Qe?= =?us-ascii?Q?BtkTLbwfgfMXkPuQHB50Q6PhxJVv+yDIqnyHAcnH4BgVFcaVXTz17v6FndAI?= =?us-ascii?Q?3BydizMZjYTUJwRtOaUlb2XHI0mhwJz5xTMGPNwai5UeZa8wL+fZVFM1ghlt?= =?us-ascii?Q?jL4FxCzZe80H3Fg6lK2fSj90UXjCpggkWlf8QOaQU7BGnEnNPytgSpaDip8A?= =?us-ascii?Q?iqrlDQ=3D=3D?= X-Forefront-Antispam-Report: CIP:198.47.23.194;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:lewvzet200.ext.ti.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(82310400026)(376014)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: ti.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2026 13:56:42.4017 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b39ce0fe-f8eb-45bc-ae97-08de58f4e845 X-MS-Exchange-CrossTenant-Id: e5b49634-450b-4709-8abb-1e2b19b982b7 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7;Ip=[198.47.23.194];Helo=[lewvzet200.ext.ti.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F9.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5128 Content-Type: text/plain; charset="utf-8" From: Jai Luthra As this device is the "orchestrator" for the rest of the media pipeline, we need to stop all on-going streams before system suspend and enable them back when the system wakes up from sleep. Using .suspend/.resume callbacks does not work, as the order of those callbacks amongst various devices in the camera pipeline like the sensor, FPD serdes, CSI bridge etc. is impossible to enforce, even with device links. For example, the Cadence CSI bridge is a child device of this device, thus we cannot create a device link with the CSI bridge as a provider and this device as consumer. This can lead to situations where all the dependencies for the bridge have not yet resumed when we request the subdev to start streaming again through the .resume callback defined in this device. Instead here we register a notifier callback with the PM framework which is triggered when the system is fully functional. At this point we can cleanly stop or start the streams, because we know all other devices and their dependencies are functional. A downside of this approach is that the userspace is also alive (not frozen yet, or just thawed), so the suspend notifier might complete before the userspace has completed all ioctls, like QBUF/DQBUF/STREAMON/STREAMOFF. Tested-by: Rishikesh Donadkar Reviewed-by: Rishikesh Donadkar Signed-off-by: Jai Luthra Signed-off-by: Rishikesh Donadkar Reviewed-by: Tomi Valkeinen --- .../platform/ti/j721e-csi2rx/j721e-csi2rx.c | 135 ++++++++++++++++++ 1 file changed, 135 insertions(+) diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/driver= s/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c index c01905680e108..335aa89bcd959 100644 --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c @@ -131,6 +131,7 @@ struct ti_csi2rx_dev { struct v4l2_subdev *source; struct v4l2_subdev subdev; struct ti_csi2rx_ctx ctx[TI_CSI2RX_MAX_CTX]; + struct notifier_block pm_notifier; u8 pix_per_clk; /* Buffer to drain stale data from PSI-L endpoint */ struct { @@ -1535,6 +1536,124 @@ static int ti_csi2rx_runtime_resume(struct device *= dev) return 0; } =20 +static int ti_csi2rx_suspend(struct device *dev) +{ + struct ti_csi2rx_dev *csi =3D dev_get_drvdata(dev); + enum ti_csi2rx_dma_state state; + struct ti_csi2rx_ctx *ctx; + struct ti_csi2rx_dma *dma; + unsigned long flags =3D 0; + int i, ret =3D 0; + + /* If device was not in use we can simply suspend */ + if (pm_runtime_status_suspended(dev)) + return 0; + + /* + * If device is running, assert the pixel reset to cleanly stop any + * on-going streams before we suspend. + */ + writel(0, csi->shim + SHIM_CNTL); + + for (i =3D 0; i < csi->num_ctx; i++) { + ctx =3D &csi->ctx[i]; + dma =3D &ctx->dma; + + spin_lock_irqsave(&dma->lock, flags); + state =3D dma->state; + spin_unlock_irqrestore(&dma->lock, flags); + + if (state !=3D TI_CSI2RX_DMA_STOPPED) { + /* Disable source */ + ret =3D v4l2_subdev_disable_streams(&csi->subdev, + TI_CSI2RX_PAD_FIRST_SOURCE + ctx->idx, + BIT(0)); + if (ret) + dev_err(csi->dev, "Failed to stop subdev stream\n"); + } + + /* Stop any on-going streams */ + writel(0, csi->shim + SHIM_DMACNTX(ctx->idx)); + + /* Drain DMA */ + ti_csi2rx_drain_dma(ctx); + + /* Terminate DMA */ + ret =3D dmaengine_terminate_sync(ctx->dma.chan); + if (ret) + dev_err(csi->dev, "Failed to stop DMA\n"); + } + + return ret; +} + +static int ti_csi2rx_resume(struct device *dev) +{ + struct ti_csi2rx_dev *csi =3D dev_get_drvdata(dev); + struct ti_csi2rx_ctx *ctx; + struct ti_csi2rx_dma *dma; + struct ti_csi2rx_buffer *buf; + unsigned long flags =3D 0; + unsigned int reg; + int i, ret =3D 0; + + /* If device was not in use, we can simply wakeup */ + if (pm_runtime_status_suspended(dev)) + return 0; + + /* If device was in use before, restore all the running streams */ + reg =3D SHIM_CNTL_PIX_RST; + writel(reg, csi->shim + SHIM_CNTL); + + for (i =3D 0; i < csi->num_ctx; i++) { + ctx =3D &csi->ctx[i]; + dma =3D &ctx->dma; + spin_lock_irqsave(&dma->lock, flags); + if (dma->state !=3D TI_CSI2RX_DMA_STOPPED) { + /* Re-submit all previously submitted buffers to DMA */ + list_for_each_entry(buf, &ctx->dma.submitted, list) { + ti_csi2rx_start_dma(ctx, buf); + } + spin_unlock_irqrestore(&dma->lock, flags); + + /* Restore stream config */ + ti_csi2rx_setup_shim(ctx); + + ret =3D v4l2_subdev_enable_streams(&csi->subdev, + TI_CSI2RX_PAD_FIRST_SOURCE + ctx->idx, + BIT(0)); + if (ret) + dev_err(ctx->csi->dev, "Failed to start subdev\n"); + } else { + spin_unlock_irqrestore(&dma->lock, flags); + } + } + + return ret; +} + +static int ti_csi2rx_pm_notifier(struct notifier_block *nb, + unsigned long action, void *data) +{ + struct ti_csi2rx_dev *csi =3D + container_of(nb, struct ti_csi2rx_dev, pm_notifier); + + switch (action) { + case PM_HIBERNATION_PREPARE: + case PM_SUSPEND_PREPARE: + case PM_RESTORE_PREPARE: + ti_csi2rx_suspend(csi->dev); + break; + case PM_POST_SUSPEND: + case PM_POST_HIBERNATION: + case PM_POST_RESTORE: + ti_csi2rx_resume(csi->dev); + break; + } + + return NOTIFY_DONE; +} + static const struct dev_pm_ops ti_csi2rx_pm_ops =3D { RUNTIME_PM_OPS(ti_csi2rx_runtime_suspend, ti_csi2rx_runtime_resume, NULL) @@ -1607,6 +1726,20 @@ static int ti_csi2rx_probe(struct platform_device *p= dev) goto err_notifier; } =20 + /* + * Use PM notifier instead of .suspend/.resume callbacks because the + * ordering of callbacks among camera pipeline devices (sensor, serdes, + * CSI bridge) cannot be enforced even with device links. The notifier + * is called when the system is fully functional, ensuring all + * dependencies are available when stopping/starting streams. + */ + csi->pm_notifier.notifier_call =3D ti_csi2rx_pm_notifier; + ret =3D register_pm_notifier(&csi->pm_notifier); + if (ret) { + dev_err(csi->dev, "Failed to create PM notifier: %d\n", ret); + goto err_notifier; + } + return 0; =20 err_notifier: @@ -1634,6 +1767,8 @@ static void ti_csi2rx_remove(struct platform_device *= pdev) ti_csi2rx_cleanup_ctx(&csi->ctx[i]); =20 ti_csi2rx_cleanup_notifier(csi); + unregister_pm_notifier(&csi->pm_notifier); + ti_csi2rx_cleanup_v4l2(csi); dma_free_coherent(csi->dev, csi->drain.len, csi->drain.vaddr, csi->drain.paddr); --=20 2.34.1