From patchwork Wed Jun 18 12:45:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoine Bouyer X-Patchwork-Id: 23596 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 9369ABDE6B for ; Wed, 18 Jun 2025 12:44:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B3FC868DCE; Wed, 18 Jun 2025 14:44:44 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="lay0aaMq"; dkim-atps=neutral Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazlp170100001.outbound.protection.outlook.com [IPv6:2a01:111:f403:c201::1]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 49F9668DC9 for ; Wed, 18 Jun 2025 14:44:40 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TktNAgGlkYAcg9PkR8K2N/x7QGarGekBvZq/KievuGgdD1TvV/7zoD7LPxaYm7aoFeIS0WrpEYRBiCsU00gwdtFInp/ikd/5fJpsTDjyhbIlLcW+3MtSIWxtG06yThmVTBzahpe3XXhigIN0nLyfUeI//n4IzhVPlRuGGkWQKjuN8d7tb7WcqQh6OhoX25yrwGYA7CVDd97OEXCVnZPlV7wIBF6bgrAROIvvFmKZpJ65oIl10P9oBY8ki0ugrsMR2JydlbDjJ0X0oL3LESED9Sc6PKBAmbP8py7bAWqB0oGxyAC4xbd6G2C9p2e7QCuIFykgCnhQXQbZ2aGnpJp+cQ== 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=hTEF7pYw5YdqXJ8zarRLMx0KlhnsLJL0ZKMHluXPDb0=; b=UJKItFMw081jiXZpwEXUHveHg7jeJ3/fTfUvP2RPRG5zdV9sgjy5Q+zArmOWHYng1rbaUqo7WM8fmJi74bj3IEJuUnOZRtvlgmIl3RQF03EvrD2z8LkiJKPARrs6Q3udxR0JS2m96AHp76PUMJEBEL0VFaTL5oM5QeV1WycQFJqV73XpYar9H5YTXd/CRZBW8eB8HD/joYc2r5uHrAghQP6hSefu0cZNMb9OGFMr2cMdboq4G7Wd3CGBoJuVPvhJkyxrKAAMU8RpRhQ6dfnSyDDGEoa/JBpj/nxa9hmG4hihbEMhmByArfoFhxe48zFiRA+FfHUEdiyc9cXwTwBkHg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hTEF7pYw5YdqXJ8zarRLMx0KlhnsLJL0ZKMHluXPDb0=; b=lay0aaMqi+ptx/o3sglt9eGyRCQLMtigL/DuH5X3mENfXO58xaqhIvPbTK57fpUTSDjhjRDfBilQfl/06NL71khQOpB7E+lm1mB0EYWzgXaR9GXv7mNgiUt/+KbB8ZK/6ghg5dgu+Bx+wpm6jaLLb0ucStcouUxVkPLTjLtjGHiYCN/sHS4Cr0ZbCsZnrhdDT6sdYRwN/tShaZMCdeqgXlCn2X4xVx7wz7BWhI5HVX8EO+MSogkdx5e0INybVUtNKr4WssBE63bwSYQ0bUfmf3MPq9lcTZWJPJsOys65Uc6KhCIqZrlABQpJ1Nk2CcDw7fXOO+P6rR+PG77DcC2lBQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB9PR04MB9817.eurprd04.prod.outlook.com (2603:10a6:10:4f0::16) by PAXPR04MB8272.eurprd04.prod.outlook.com (2603:10a6:102:1c1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8857.19; Wed, 18 Jun 2025 12:44:38 +0000 Received: from DB9PR04MB9817.eurprd04.prod.outlook.com ([fe80::144:cb06:336d:abb3]) by DB9PR04MB9817.eurprd04.prod.outlook.com ([fe80::144:cb06:336d:abb3%4]) with mapi id 15.20.8835.027; Wed, 18 Jun 2025 12:44:38 +0000 From: Antoine Bouyer To: libcamera-devel@lists.libcamera.org Cc: julien.vuillaumier@nxp.com, Antoine Bouyer Subject: [PATCH v2 1/2] pipeline: imx8-isi: Add constexpr for maximum pipeline and resize if needed Date: Wed, 18 Jun 2025 14:45:40 +0200 Message-Id: <20250618124541.2340270-2-antoine.bouyer@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250618124541.2340270-1-antoine.bouyer@nxp.com> References: <20250618124541.2340270-1-antoine.bouyer@nxp.com> X-ClientProxiedBy: AM0PR02CA0106.eurprd02.prod.outlook.com (2603:10a6:208:154::47) To DB9PR04MB9817.eurprd04.prod.outlook.com (2603:10a6:10:4f0::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR04MB9817:EE_|PAXPR04MB8272:EE_ X-MS-Office365-Filtering-Correlation-Id: 0d8ef6e3-6b64-4498-3ab3-08ddae65e2ef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: wWLEqTc5h7i/2mCVyU/XEnSXjQd1r+K6xJeEvXGh0AJWnUaPeQQG2/C6c1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dbIa/pR0n0EK76vvZQWOV3aMGQXE5aeM0zC/bhIUwTopmGlMdIPMehFe1FwS4WhpCR3xVw3FY3EEZLHcARRv2Xare0mCC2eU1ovZGtOrxfM3IMoP0ZdfqJQwOTi1NfFq3H9NDruG1nW2Qw8OytHarGK24MfWMgA9cKPYabDUEIYwfpnT+uvcmaK3OxrfZXl/B47k76c7EYQhS2NqY3WirvpTA6uLcRbjoqy1NDzB8kXECChLdBWV8fpIp9hBT4Z4jfd8bPpmVrXJE5Hzs4ng65ePzbNpe4OIgUXap5bAu3FZh1kDdJuy35pI+bS1zRE29W0a8brBk1Iut370Ln9ftEaEM95QDnoDRzh50royqvyA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9PR04MB9817.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(52116014)(366016)(1800799024)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TRwZ0jox/JKvHnc0dCJ3f4v5uEF1mv349gNeJ1+vp6MFbmak5kxIiFxGC1tiME0WoG9ejLxnP3j8Kd136/kXeVoVYU1W/nWn8lf/HyYvkACt/D/+zkjzj5dmzLzkq+BHQm3ACA7FxKIrB49S4xF69wOuI7QZoeRduL46itbFgifz7jgTD5PGTelc7QZ/mJAwdcvsp7bu+O4oFDP+bOvaIJrhC338SBZ96rkJCtbf4UowpkhKl0fXvEUfgR3ux1/To2T3QLsAJFcKk19vtea/k8e1FtG5BmY8tiktvnyPRxUqHwSZ/paJ8h4+NbzL1k3HzGik07gMv2l0GWErLfWHvyI/oAU987Od+e2hdP3wFn1afqyRpYTloFzvmma3BDjgxgymMSLT5O+ouWMb1vHwTpuynrUka54swOSJtFPkC2RtKdIJgYwGNYMy3rgGuoxQDzf5j4Ij8A7F+o83RON2q41MMN2Q8AEYgfQR7LHttdcBvRAoEAS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HfMij+Er1osH1fEjJMFpjDR/TW6KA1BTTlhadOTParV7wkEz3g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d8ef6e3-6b64-4498-3ab3-08ddae65e2ef X-MS-Exchange-CrossTenant-AuthSource: DB9PR04MB9817.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jun 2025 12:44:38.0302 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vdbOCIsJ0Lz5mnj2S5nhBf1fDq+hRfOBm1ppoVTS/S6+/+yMVMG5ZzBOfJEDFy7YdwG0lsQbXQWOeoGV1Olgqw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8272 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This patch adds number of streams per camera as constructor parameter, and limits stream count to 3. Some applications may need up to 3 streams for preview + capture + video record. Currently, imx8-isi pipeline only supports up to 2. Increase constant parameter to 3 to match these applications' requirements. Minimum value between default value 3, and total amount of ISI's pipes is now applied. For SOCs which only have 1 ISI pipe (ie i.MX93), available stream count becomes 1. Signed-off-by: Antoine Bouyer --- src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp index ecda426a6021..186b623df186 100644 --- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp +++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp @@ -40,14 +40,13 @@ class PipelineHandlerISI; class ISICameraData : public Camera::Private { public: - ISICameraData(PipelineHandler *ph) + /* Maximum amount of streams (i.e. pipes) per camera. */ + static constexpr unsigned int kNumStreams = 3; + + ISICameraData(PipelineHandler *ph, unsigned int numStreams) : Camera::Private(ph) { - /* - * \todo Assume 2 channels only for now, as that's the number of - * available channels on i.MX8MP. - */ - streams_.resize(2); + streams_.resize(std::min(kNumStreams, numStreams)); } PipelineHandlerISI *pipe(); @@ -1052,8 +1051,12 @@ bool PipelineHandlerISI::match(DeviceEnumerator *enumerator) } /* Create the camera data. */ + /* + * \todo compute available pipes per camera instead of using + * pipes_.size() for multi cameras case. + */ std::unique_ptr data = - std::make_unique(this); + std::make_unique(this, pipes_.size()); data->sensor_ = CameraSensorFactoryBase::create(sensor); data->csis_ = std::make_unique(csi); From patchwork Wed Jun 18 12:45:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoine Bouyer X-Patchwork-Id: 23597 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 95B6EBDE6B for ; Wed, 18 Jun 2025 12:44:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 935FC68DDB; Wed, 18 Jun 2025 14:44:45 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="Dqq4ceen"; dkim-atps=neutral Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazlp170100001.outbound.protection.outlook.com [IPv6:2a01:111:f403:c201::1]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 678E668DCB for ; Wed, 18 Jun 2025 14:44:40 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GLWN1neZUWPmmm+uBEqxUjR/JmSPLdYX5Yk842Z69opuOrBsmLLQLmy3+iEvrZEuyhvgPwVXu23RpDoTDQZb3W65FIKBEsilLEfW4rMbRJYNKV9BcL01M0j5DQ5ubQktZ2Q3/QVYtVwlFdyuI9E618nAL/kbH6IzrrB/ILOAO9Vmjw5C7LVzRtMPraRTTVdkKS5iLdUCKuWYZ9ghCRb8kdQqSnHnLSlTSV6oUXV7ESRMR2IO71DiQJihMY0fr1dwJHFBWHZE6oKXFoj7d7R3czFzlfclcNJJoCWnkMQuTgJJ2l+cT9HGygtKZ5ixDqmElEjKs+U5HSfa8jJ5DOel5w== 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=6dPEwT6wKuyq5HfCUyd5UR0+OUmZ1jvBKqqeJbjqwAQ=; b=GQ+49zJyM0RSez5kgg83pqForu1Mvmaq2CF9fhRAqX60/7DrscGCEE7u2RksHi70YZbfZvVNDCClGGfgXarAhjfbiAiWLnD5ROxUWdoqRvIqno0scVC2RAwdQ3j4pn+rNrw5hlwrSQBuWyyLNsl2t9LHwtfpdRzWOIzOiRtd5VyoWCS3UuGn5J0uhQaZj+xzQzVcKTZ8i96ox9z6u0dzIwG2Y+kv98Ao3+MVK3MobotknOQDUzdllkCj3tIJVdHlQvbU1Y/t6dP5NtRwLpDbfyTfc1a9DYorMiMgWm+qaO2STlWu3R6EApRqv9Xm4RXDIOpK9rbQJyxrr+t5bL23cw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6dPEwT6wKuyq5HfCUyd5UR0+OUmZ1jvBKqqeJbjqwAQ=; b=Dqq4ceenXgh8ysX60Y+eMbSdioqG+8E9Nam6T2eYl9sOOJoL8QkpiWy+5iSOhuggovL4cZaKWBZKHi16eUUSXobsEsXwLHRNsCBtfcFhWuDqD0fzAd7igoNmjYePjMGcLqlWYGl5WCQFQGNg8PAXEVCoGPDFU4oa9maYRy5WGHLUDKZlK0SPJaZCov/jRKwFsqzHEXlvMpkvY/XGf2LDlF0T0nql8FRhqPpqkkNUJtZA6DtC9dI9TOMP+46YBSfUkWb+R50y14Xj5b4ZCvWepigZsEHEosWFVZq0qQpZcq1682Qu1OlJjpuCG6jHXFBa2UF4/ljASpMI18/sWYCiKw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB9PR04MB9817.eurprd04.prod.outlook.com (2603:10a6:10:4f0::16) by PAXPR04MB8272.eurprd04.prod.outlook.com (2603:10a6:102:1c1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8857.19; Wed, 18 Jun 2025 12:44:38 +0000 Received: from DB9PR04MB9817.eurprd04.prod.outlook.com ([fe80::144:cb06:336d:abb3]) by DB9PR04MB9817.eurprd04.prod.outlook.com ([fe80::144:cb06:336d:abb3%4]) with mapi id 15.20.8835.027; Wed, 18 Jun 2025 12:44:38 +0000 From: Antoine Bouyer To: libcamera-devel@lists.libcamera.org Cc: julien.vuillaumier@nxp.com, Antoine Bouyer Subject: [PATCH v2 2/2] pipeline: imx8-isi: Add multicamera support Date: Wed, 18 Jun 2025 14:45:41 +0200 Message-Id: <20250618124541.2340270-3-antoine.bouyer@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250618124541.2340270-1-antoine.bouyer@nxp.com> References: <20250618124541.2340270-1-antoine.bouyer@nxp.com> X-ClientProxiedBy: AM0PR02CA0106.eurprd02.prod.outlook.com (2603:10a6:208:154::47) To DB9PR04MB9817.eurprd04.prod.outlook.com (2603:10a6:10:4f0::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR04MB9817:EE_|PAXPR04MB8272:EE_ X-MS-Office365-Filtering-Correlation-Id: c0a835bc-bfd5-4220-178c-08ddae65e340 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: eIA9VmKzdCS8+vSF44eG15mLtJQ95qgGZT5pCpXDo4dwu9P+Ki06eX5WuTmgz5dMKu84BSwfvSnvXL9M8k7VkBHs7/BVrfWBgeBANV2yqB+PM8+yS7NMHsAhaN/4cDVIP5+vxhv7dwterGeBkrtW3cRJ79iUnHFzdyMpsitflx4O3e5Iznkw/K8PbqvztV1mk9youeiueDrf9yaLWVfTwU8gAVjjjeBzdLvsBvowncjbCA5vUo//F5Tt3au2EH2tGxErl2oKUqQwe2RkKO+Kn/56DmEhSIQ84xujHE+PzbizRty7JBJaqWDs5mGfFqw5ap2Tw1cVNUEzpmRZK12hUaaHutYRSb7438YF0qwvMtHLun0UhQuCFjZ+Yoxj3+IyNzJMInuc7zf/UlOLR/2pIVwxpvl+Nn6lSxm9ADhK2ThBw1aWpYfpAaZiXNQ25kh1J4Mxwz0ixuGqVIZ8xtU5V8IAhvg4Hkg1GNVOdkpjHyRHZ89i6SbdlEwuoLdskVvjD6b/cT9LTZ/BGlJy5Y8skhIHoPRJ4qjjymfizWtD9+JaCzjDf0W95BwY7jjvUZ6x+L7jvzy4AxfBUzglg6zlUA2RSfCmpdp9NB7vRPncPmc0w5GIAtcbbztOtFDCiGXQA7TKsCflaOxW/iWjYgtJwjSmWQth0mXDH986L3d/x8qWNxsUFA+28gsMYviPQRIawSPsrjLFmjpOpLAsdhgNuWk+I05gFpereZN3bPg9G+WBnw+s3XvlfJz28SBixPJuiwoFoPF5RicqzeRxvZmy7rlwtPDxjkw7ePQA/FcDifcBMi4yTh9U82Wd2f9pc/QUIpER5xPXPVzdC6ULVgS0FkN+646o6oxybHk1JGalqhnylELd15MMSAfkOoB5N4SkF4fGyNvYDYFLLZXhdit29GrEf+MbUeBGMl+FDr2Z65kzTwOOrh7t9BVOkS66eC2wIEvyuDgiiteoky6LvUXm4eAXlkTBfrB0fKXWvMGymxVkoiEOdCa9ULTbqdNIrkqwk780d8si8D8JXQPbYIsl6J90EgTEMyfkzyNLxbEvH3nInKVp4DQETWNNCJeDo2jlzBQx+vuDa5Y9umNwpdDw5lwGrci9lb+jl0PvMs/piOMpsQy3dsgN1ilagybkeNabBp5yDZ1KQZCd4mSo/m6Z7uX0KxXgRO091wmjD0XBngeSM5hswAHndr+aiHhLKIOAC9e6aFTqHSj6juDOR6Uj+EPzs9dZhPU2c2M0mN7ehvDnzRDbWohltz3u86HwjGPk4AY4pbngoFBJMmD3wXWRj+l3Z+UwdfrVr29Jq2tfROHhYcg3Fh6mVQ05i2w4+t1S061EKt2xpuSxmWv7m0A5IOTZit/vZmd7Le5eIFTw6eR2nPwYI8DJ+/YEM4enVAqaJ/DcqJ9ispfzfP5PhmlOCIe17lOvUve7w980TUtb1xUGUfYP5UoL9/JbwEdhOHy0OmRSIXfx/kq5/YaiCs3qmA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9PR04MB9817.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(52116014)(366016)(1800799024)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ddpVvOamyxwrJczAf1VoyYeFPjbFyBIi0Qszjp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ut17ZXGWt4CKM57Ckpllta3K3RPbjmYjz+kVHfcVs8lAQjQ7hs/5sXX8iB8ANOffEZJBCmqVx8g0H104Kn2iGbR0W3r9VPZGf3AaKSFUf/HBmde0lJux0YhwWVxwJ2tPBE7wJqQD4KHAVwtugkHCnm4cxQmaQ51VolYX2tOJ4ngIuXDy+hCZOaUT+zi+ahdZc83NSk4J/VkESjG2/tvrEjZMhdR7cLRojDPaml3iEn727k8Fx8Ms5Em45yisF0xDXmdxUU6PlGRSCYbXnJ7JqN3/ZqJQkMavHBGC9eiKfjl5cmtJiIfr5oAfZOZQLTBKaGPMTnJxgiuG28Kd6ZzhjhQnu5YeWRulw3KjUQkfzMCndQecwXqAjDjdLMFfn0ivsaryGJ1nHnngXIoebrtj3Q1FgdjXD7yLP+YgFbK8+gBFUt558GF54fu3VaNJfE+4RvbKTGnoRfwAmsVZd2TRZaXkyaczfUJm87WwzUXgpWEZOa6U09UK4bEHE28lk8lCtouebkaOg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c0a835bc-bfd5-4220-178c-08ddae65e340 X-MS-Exchange-CrossTenant-AuthSource: DB9PR04MB9817.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jun 2025 12:44:38.5835 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Wa9qs+2r3YZGc8sCSFj1ZVES5Xe+y2cXHE6AY4GvoP/KLc7k3+56xEEIBRxUDTBOvfoVls+cc+KBtYxlqpeQvw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8272 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" ISI can be used to support multiple cameras at the same time in the media device. A dedicated pad is assigned to each camera by HW (dts). We then assign one (or more) source pad(s) depending on ISI constraints in the SoC. Since ISI may have different number of pipes depending on SoC, the number of cameras is computed _before_ going through all pipeline's components, to limit number of pipes that could be assigned to a camera. For instance, 3 is targeted as maximum amount of streams per camera as defined by 'kNumStreams' constant. If 2 cameras are connected, with only 5 ISI pipes, this target cannot be achieved. In such case, 2 streams are assigned to each camera. On the other hand, if ISI has 8 source pads (from index 6 to 13) and 2 cameras, first three source pads [6:8] are assigned to first camera, and the three next source pads [9:11] are assigned to the second camera. All these pads (sink and sources) must have same format to prevent configuration mismatch during start. However, since ISI routing must be performed _before_ any stream becomes active, 'setRouting' is now executed during the 'match' step, instead of 'configure'. Indeed, it is up to the application to decide when a camera 'start' is executed: this could happen before or after the other camera configuration is executed. Moving routing into the 'match' step makes sure the routing is correctly applied before any 'start' is executed. Signed-off-by: Antoine Bouyer --- src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 112 +++++++++++++------ 1 file changed, 75 insertions(+), 37 deletions(-) diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp index 186b623df186..5a22d761aefe 100644 --- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp +++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp @@ -55,7 +55,7 @@ public: unsigned int pipeIndex(const Stream *stream) { - return stream - &*streams_.begin(); + return stream - &*streams_.begin() + xbarSourceOffset_; } unsigned int getRawMediaBusFormat(PixelFormat *pixelFormat) const; @@ -69,7 +69,8 @@ public: std::vector enabledStreams_; - unsigned int xbarSink_; + unsigned int xbarSink_ = 0; + unsigned int xbarSourceOffset_ = 0; }; class ISICameraConfiguration : public CameraConfiguration @@ -809,34 +810,9 @@ int PipelineHandlerISI::configure(Camera *camera, CameraConfiguration *c) ISICameraConfiguration *camConfig = static_cast(c); ISICameraData *data = cameraData(camera); - /* All links are immutable except the sensor -> csis link. */ - const MediaPad *sensorSrc = data->sensor_->entity()->getPadByIndex(0); - sensorSrc->links()[0]->setEnabled(true); - - /* - * Reset the crossbar switch routing and enable one route for each - * requested stream configuration. - * - * \todo Handle concurrent usage of multiple cameras by adjusting the - * routing table instead of resetting it. - */ - V4L2Subdevice::Routing routing = {}; - unsigned int xbarFirstSource = crossbar_->entity()->pads().size() / 2 + 1; - - for (const auto &[idx, config] : utils::enumerate(*c)) { - uint32_t sourcePad = xbarFirstSource + idx; - routing.emplace_back(V4L2Subdevice::Stream{ data->xbarSink_, 0 }, - V4L2Subdevice::Stream{ sourcePad, 0 }, - V4L2_SUBDEV_ROUTE_FL_ACTIVE); - } - - int ret = crossbar_->setRouting(&routing, V4L2Subdevice::ActiveFormat); - if (ret) - return ret; - - /* Apply format to the sensor and CSIS receiver. */ + /* Apply format to the sensor, CSIS receiver and crossbar sink pad. */ V4L2SubdeviceFormat format = camConfig->sensorFormat_; - ret = data->sensor_->setFormat(&format); + int ret = data->sensor_->setFormat(&format); if (ret) return ret; @@ -848,10 +824,17 @@ int PipelineHandlerISI::configure(Camera *camera, CameraConfiguration *c) if (ret) return ret; - /* Now configure the ISI and video node instances, one per stream. */ - data->enabledStreams_.clear(); - for (const auto &config : *c) { - Pipe *pipe = pipeFromStream(camera, config.stream()); + /* + * As links on the output of the crossbar switch are immutable, the + * routing table configured at match() time creates a media pipeline + * that includes all the ISI pipelines corresponding to streams of this + * camera, regardless of whether or not the streams are used in the + * camera configuration. Set the format on the sink pad of all + * corresponding ISI pipelines to avoid link validation failures when + * starting streaming on the media pipeline. + */ + for (unsigned i = 0; i < data->streams_.size(); i++) { + Pipe *pipe = &pipes_.at(data->xbarSourceOffset_ + i); /* * Set the format on the ISI sink pad: it must match what is @@ -860,6 +843,15 @@ int PipelineHandlerISI::configure(Camera *camera, CameraConfiguration *c) ret = pipe->isi->setFormat(0, &format); if (ret) return ret; + } + + /* + * Now configure the ISI pipeline source pad and video node instances, + * one per enabled stream. + */ + data->enabledStreams_.clear(); + for (const auto &config : *c) { + Pipe *pipe = pipeFromStream(camera, config.stream()); /* * Configure the ISI sink compose rectangle to downscale the @@ -971,6 +963,20 @@ bool PipelineHandlerISI::match(DeviceEnumerator *enumerator) if (!isiDev_) return false; + /* Count the number of sensors, to create one camera per sensor. */ + unsigned cameraCount = 0; + for (MediaEntity *entity : isiDev_->entities()) { + if (entity->function() != MEDIA_ENT_F_CAM_SENSOR) + continue; + + cameraCount++; + } + + if (!cameraCount) { + LOG(ISI, Error) << "No camera sensor found"; + return false; + } + /* * Acquire the subdevs and video nodes for the crossbar switch and the * processing pipelines. @@ -1014,12 +1020,19 @@ bool PipelineHandlerISI::match(DeviceEnumerator *enumerator) return false; } + if (cameraCount > pipes_.size()) { + LOG(ISI, Error) << "Too many cameras"; + return false; + } + /* * Loop over all the crossbar switch sink pads to find connected CSI-2 * receivers and camera sensors. */ unsigned int numCameras = 0; unsigned int numSinks = 0; + unsigned int xbarFirstSource = crossbar_->entity()->pads().size() - pipes_.size(); + V4L2Subdevice::Routing routing = {}; for (MediaPad *pad : crossbar_->entity()->pads()) { unsigned int sink = numSinks; @@ -1050,17 +1063,30 @@ bool PipelineHandlerISI::match(DeviceEnumerator *enumerator) continue; } - /* Create the camera data. */ + /* All links are immutable except the sensor -> csis link. */ + const MediaPad *sensorSrc = sensor->getPadByIndex(0); + sensorSrc->links()[0]->setEnabled(true); + /* - * \todo compute available pipes per camera instead of using - * pipes_.size() for multi cameras case. + * Define maximum amount of streams per camera. In case of + * multiple cameras, limit maximum amount of streams to allow + * all cameras to get at least one dedicated pipe. */ + unsigned int maxStreams = pipes_.size() / cameraCount; + + /* Create the camera data. */ std::unique_ptr data = - std::make_unique(this, pipes_.size()); + std::make_unique(this, maxStreams); data->sensor_ = CameraSensorFactoryBase::create(sensor); data->csis_ = std::make_unique(csi); data->xbarSink_ = sink; + data->xbarSourceOffset_ = numCameras * data->streams_.size(); + + LOG(ISI, Debug) + << "cam" << numCameras + << " streams " << data->streams_.size() + << " offset " << data->xbarSourceOffset_; ret = data->init(); if (ret) { @@ -1075,6 +1101,14 @@ bool PipelineHandlerISI::match(DeviceEnumerator *enumerator) std::inserter(streams, streams.end()), [](Stream &s) { return &s; }); + /* Add routes to the crossbar switch routing table. */ + for (unsigned i = 0; i < data->streams_.size(); i++) { + unsigned int sourcePad = xbarFirstSource + data->xbarSourceOffset_ + i; + routing.emplace_back(V4L2Subdevice::Stream{ data->xbarSink_, 0 }, + V4L2Subdevice::Stream{ sourcePad, 0 }, + V4L2_SUBDEV_ROUTE_FL_ACTIVE); + } + std::shared_ptr camera = Camera::create(std::move(data), id, streams); @@ -1082,6 +1116,10 @@ bool PipelineHandlerISI::match(DeviceEnumerator *enumerator) numCameras++; } + ret = crossbar_->setRouting(&routing, V4L2Subdevice::ActiveFormat); + if (ret) + return false; + return numCameras > 0; }