From patchwork Tue Jul 1 08:58:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoine Bouyer X-Patchwork-Id: 23698 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 990ACC3237 for ; Tue, 1 Jul 2025 09:00:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 063CD68E17; Tue, 1 Jul 2025 11:00:31 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="VCU7XR3R"; dkim-atps=neutral Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazlp170110003.outbound.protection.outlook.com [IPv6:2a01:111:f403:c201::3]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1547A61528 for ; Tue, 1 Jul 2025 11:00:29 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=B1sR1JSeTcCctCqNIpp6MYRdrxJeGv/wuApDXGNbX73FaIC9GGWxxBrSHiM46/AijQWIoczS0kGOfBrDzhV3Aa3J+eDzlMwlaG3vvxp9MY/Kz3ost/rDKVOCht0riLskiCtgNCOqRWnDqaQu4pejuDh0brO2K2NKtZwHXmk1HtC9vthBJKWPMkXPkKziaTdBcSyjiVY25LlzGb0fhxtL6bM3uAEKrcqic0z9RuwUgb2v147/ImZ6H2cV3ACbLRDKuhtwK5gssuGKcOwSFMGh+rrYzZdwKvE13gaa7J6ohVePbfV3GT3gNRgVF0JxLaW4K8V+bI5o9W+/gfgQdc9Nlw== 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=9julfzi0G+JMJJYqCFRmgHdsy/+ZT++VVxWau0ySsYs=; b=Lm+5cTqWQhQVwSnC0zyoAsxZxMvppU/Hy4pPioUsKKf1q+ymCuyOsJLP4mShaerrOTPrSMR4wHtQkv5H7BrPdhGw8IP03X8hUgVToSm6YAD9yBDt7UOEyw1Frxdyb+2VaI32UvLrhSZsismi4ph0Tej93L34sC6DtCKikDW0nzn+gTWEfvItg3Aq6qOfSQAMfBk1G5DIKI/LWAIBVVvFELCAaY2qXBQ96xzB8yF/PTX3GAsCrXhtH2f5rcONgthiF6fH5tIlcLanUSlUzO7DiiQD7ojCdm5JWperxNVoGGfaAQdwz2nqPdK06g5fba3vf2I5Iix1rqAQDnLhOCzTMw== 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=9julfzi0G+JMJJYqCFRmgHdsy/+ZT++VVxWau0ySsYs=; b=VCU7XR3R4hIPyHZ0dkZUo/LNDd7QN3+mpZECktS9Vfqb3ojRflKEGejVaIEkhJ+mZssGfTDCnr8p8REY4c8Z7pnffOTN1O2I8dQFOTncBm54cFzvMZQzMJK8VJP1ooY0/w7eEW8OZ+FRjFPrWL84lG+MQ5sZyEhpIJKHjoHVZV9TMAQlGcWK3wuUtgSjOxaYvg2T9ptdG1rmHJ2UzWpY07gTYE7sLoIzJ9UJcdhJQfhAXB6KluVwvEzys1rKfGrkBEYmRJs1sQbIVkUj28lsZDpa5dtb+o3nOUsEP7Dcjijk6a0O6WOjB/30iJYAJNuLSgSvKPofFMESgFXRyuY8fA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from GVXPR04MB9831.eurprd04.prod.outlook.com (2603:10a6:150:11c::8) by AS8PR04MB7896.eurprd04.prod.outlook.com (2603:10a6:20b:2a2::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8880.23; Tue, 1 Jul 2025 09:00:27 +0000 Received: from GVXPR04MB9831.eurprd04.prod.outlook.com ([fe80::4634:3d9c:c4a:641a]) by GVXPR04MB9831.eurprd04.prod.outlook.com ([fe80::4634:3d9c:c4a:641a%5]) with mapi id 15.20.8901.018; Tue, 1 Jul 2025 09:00:26 +0000 From: Antoine Bouyer To: libcamera-devel@lists.libcamera.org Cc: julien.vuillaumier@nxp.com, Antoine Bouyer , Laurent Pinchart Subject: [PATCH v4 1/2] pipeline: imx8-isi: Add constexpr for maximum pipeline and resize if needed Date: Tue, 1 Jul 2025 10:58:16 +0200 Message-Id: <20250701085818.2447600-2-antoine.bouyer@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250701085818.2447600-1-antoine.bouyer@nxp.com> References: <20250701085818.2447600-1-antoine.bouyer@nxp.com> X-ClientProxiedBy: FR4P281CA0220.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e4::15) To GVXPR04MB9831.eurprd04.prod.outlook.com (2603:10a6:150:11c::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GVXPR04MB9831:EE_|AS8PR04MB7896:EE_ X-MS-Office365-Filtering-Correlation-Id: ce28a2b7-b3c8-435d-f9d5-08ddb87db817 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|366016|376014|19092799006|1800799024|38350700014; X-Microsoft-Antispam-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x26vMdl597wOJ47tE1G6Y6oEhxgXa035t7LKTrvI+qR6LiI7t9Pi277fhYoFRoKb/MGRip+j/oV6NKIegm13ckhBnUjfXSMCk1OZ13FxvpqW5vO6PFeRJY5I5m1Dp5XpwZXN0PnwPoCHvH7M9KcWNNCnrOL1sQ13I82HHgUhdZhiU7hMbR9NZNCWY7SJ67jAUc7oQd16sN+cWbpUiijpB+M5haZIK6YGBh2DIZ97ZN24KJKEHOkkqdcL+P3BDlflMSP29eJCXFDw1HI6Mfa1Y8KX/GNTtB2R+6PaPe4pbTFGUsWtzVCAPIEzZesIgZ396B5vKVBMC16FkeGS5vCxb+yUrk6wHo+8JA/J6vsHgytoSaoBzCo594+DB/1D0APqgFqC2t9VIV0Colpp8GFqU3+z6plUneeQWw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:GVXPR04MB9831.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(52116014)(366016)(376014)(19092799006)(1800799024)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 41hiVhSkUCgCLI3e6ZlUBMMmyflnlachFY62CRJYxE9kjfoYLDwvSp7qgConTuOkW2sqVvb2mBrhxN9dU5UOt8KqtW77aCRcMIZOblrmlzA7UO0Tu5jeNUoVzjoPpePckDHiPxQxA1YuxwWAlwhi3DZ/njF/FvEkwLelYHBz8lPhLN5pXR87O40VAMCQHhUYBCo58uDgBiITkzHLa5/dbLzVUlgMzEspj+gHiHFDbL6Oc/PJqfrYSAoWFKxDkuFQG3z6wlgSCCrCiSJMFVrxHnCArC6L+bEOQUkhBl8P/o0B5o6iHcDGuAZLe/+6tMlb0O+GfWLhpfYSekRiDlOi4HoX4/DxZBCRPSt0Yv4o1/NsMZqVc4aIJGTZrg0lrYNH0IXmo3MntXvt6Y1OZ+vqopRgSiTe+JTu8paYtR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m3f/VtNbHx3oFHcFglkXApZcsTbcpd+t+telKYpnn981rduqCThKR3ancp8JplF1rnhRtF7at7f2Y1tD/j+nvQywNzhp9rMJ06T7Kxo5q9hODw1A== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ce28a2b7-b3c8-435d-f9d5-08ddb87db817 X-MS-Exchange-CrossTenant-AuthSource: GVXPR04MB9831.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2025 09:00:25.7711 (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: idgxRgsGaEGy8FuUyr3bqj9EJTqJVDB4SaHenNM3gKCNtGbC139k9UNxR2xYeLu4O5CC+lOyRdXowSRva36epg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7896 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 Reviewed-by: Laurent Pinchart --- 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 f4014b95df45..4e632e852ebf 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(); @@ -1050,8 +1049,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 Tue Jul 1 08:58:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoine Bouyer X-Patchwork-Id: 23699 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 7904FC3293 for ; Tue, 1 Jul 2025 09:00:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2549468E1C; Tue, 1 Jul 2025 11:00:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="OEpH7Dx1"; dkim-atps=neutral Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazlp170110003.outbound.protection.outlook.com [IPv6:2a01:111:f403:c201::3]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3431368E14 for ; Tue, 1 Jul 2025 11:00:29 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=X3CpJF6MYcx3wW5s6RKbn/77w6Sawmr24cgg+bDlQj6mbKNV3zGLHIV9dHR4TaswWWyKIwkfCYCjNqMQ7Ls0+izcwhtET4l307zjw3nBlrn1gjs2DipM9UlUXhz5FJCrUJcdFCjkMKvm44aSME0X3bc77t46bA1TmhpymI8cT6jIEIEnceqGtFI4YCKuMnFLEky/aFcrurg7ZEqjkAmVKbtWr8MoprUimzuam9A9ctvfKJGss/dbfSgf37fr/+WzKDw6cMb3ZVs6S0KuygWUC2/5ECaSenA9agzJJsxpI/N/zqRWd7e65to862vgv5XKNBjoDyZpeoFntva643pgZw== 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=QRlsf8El1s0fYDgbYG3OXQ3Zk+cyQvlWW1pdWrtidvo=; b=gLEyy+M62ekxu4LaIVgvVvSSftDXFzefjns7z4C4dE4a7SvMkTZOdFrALQKNMnkVM1yYV/eI/zH34rf1Wctcr+HivtIjzgiyDdBxO1R3SeAXo7xqLl3rkvi6vccmGygAfvflNser0Mzv437M14QboXJz+qiPVn+HrG0djZ/lUwCHuROVpHg/oFdF2nqMPFRSXkcXRAH5P9LXv49Uqcj6XXeUQ5kApM69X432Db/I8tVRCVi2h0f6l1+bXdJbaI1+2kQo/pknrA46fdpk14NcaUcyJRFY1E/1NjPGGpuMXTGuf+dBP/MxIUkBpcG2LPbw72HcXMyjipzWekr2XlTSbw== 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=QRlsf8El1s0fYDgbYG3OXQ3Zk+cyQvlWW1pdWrtidvo=; b=OEpH7Dx18Mzhyc8PRCDzejLC5k7MU7EB5v6CTfe9/vUBAZhR8HjPGla/5JJSC/XJ7bXaLTDC64AoEYg+ofJr5xpQ8mUwHOVv2PTEQXQaN40P0SvIuOEnJYweDh3KkkdyZBhZSxwUWqmzonH8FsfC4htA/143ir0MhE9yn5VUgDMkUjjubVdTFqydt1/BawVMAAONGlH2gDhdPCk/UQsEt7qI8SYGYkgukVpKIAljF2E+TJUYuP/UvpbS27NX4enCqaVY4biSYWXGU6nkxwvr+jLAUyH9ETL9FXMG+M/r9I2Uohg4z+jSRXUwCIJrrRilnGvlqBVcJwxxWuhRCuwWIg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from GVXPR04MB9831.eurprd04.prod.outlook.com (2603:10a6:150:11c::8) by AS8PR04MB7896.eurprd04.prod.outlook.com (2603:10a6:20b:2a2::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8880.23; Tue, 1 Jul 2025 09:00:28 +0000 Received: from GVXPR04MB9831.eurprd04.prod.outlook.com ([fe80::4634:3d9c:c4a:641a]) by GVXPR04MB9831.eurprd04.prod.outlook.com ([fe80::4634:3d9c:c4a:641a%5]) with mapi id 15.20.8901.018; Tue, 1 Jul 2025 09:00:27 +0000 From: Antoine Bouyer To: libcamera-devel@lists.libcamera.org Cc: julien.vuillaumier@nxp.com, Antoine Bouyer , Laurent Pinchart Subject: [PATCH v4 2/2] pipeline: imx8-isi: Add multicamera support Date: Tue, 1 Jul 2025 10:58:17 +0200 Message-Id: <20250701085818.2447600-3-antoine.bouyer@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250701085818.2447600-1-antoine.bouyer@nxp.com> References: <20250701085818.2447600-1-antoine.bouyer@nxp.com> X-ClientProxiedBy: FR4P281CA0220.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:e4::15) To GVXPR04MB9831.eurprd04.prod.outlook.com (2603:10a6:150:11c::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GVXPR04MB9831:EE_|AS8PR04MB7896:EE_ X-MS-Office365-Filtering-Correlation-Id: 38ec3f06-583d-48b7-7330-08ddb87db88a X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|366016|376014|19092799006|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: X40MP9Rrf8DG0YY5Sp1OGRTsWvGVPnZszsqG17lV09lpOXGH8Uty+ptZL6TOdaaVSD4SlK8055mXE0qA7sa0JzDgzZse4TZoAMSRLp/D94nVcKldKWgq3v/ClD4fNWOlQYD2/doAo11DABkJWOWMis5RHQsn1Ay+63M+l6CXzxahlgm3Jq5hZAbSse7WxhdS8n2mufE9yuvh5PmhnlzFXDnIfiWH3MaFGNhXsmx4FSc/bGMtntBcjltn2lb4Z5ex73FkLMSgk0ILbQeNE4gYfN2+mVIyu0ewcWx+wmQmjnr1GuyRJVlIxKEYw7As4NZGQ7DSvwvxFX2NaN/Tl1Ene4aOupu1t86bBAkt9Mau5+8lPpCVJLL+7wFBefcNa8dlvc3Dw4zmbkzKecjBk51wFrZdhjWmLrwZGjwIal45O0w0h71PzfUo8nlYnWU8yaNFyCsBKCVonS5oughwW9pn2VY7TO7x/yKlIAXUaFZ1oN86Jaj99DEyFmFISqtP5ssuMCB9D9jaSBtx1/nNTByU2nkAzTsAc5Ya6el+Vs7oooITnN2iKOARWXODnXmN2TNnuJaS/Cq+YB5N3+xyCQ6UdeGSl74B5W0ypcSpzm8QV9gTHBWFrJRnGZOrE9UdhMD69TCt3Sj5KdJq6O+YIxehROisIPjuWGUUOjcxnHUK38wktvQeJ9rqPGfMRgF7qammVrR1V26/8n8aDeHZuiJWDY7dZNm6uAOGQtiGXWDx9RBI7RRY3uNINlYiokwsS35cqEMnOC4S5895cO2YlhM9yJcz0OCU3Rg10L3zZ6uukx4CcySKH/piClyCpLS6n3+2hFoXG37VfWqV4zL1CqhPz6T2gPgufuIYUyNuQ6wOQMPArP6KCB0RnIsAaDY2hgU8ZhSlGVdGcgDgk8ECmuq7IHRpT8+AtCvOe3lI2Maf9EBLPcy26GmnOMrVMSLpyh4oiu9LkpCnIlXnQIbo2+atlTKYpZS9WakxUCZxnrzUqOaCsGVPp6m8Pbb5jxunDDOsaoDF/z+LLp3hSSZcsN1QAq8POtm2K5nbU6uaLoF+qw5/3a3grsd1l3JISCkSkpqLia1kLmVQcZbLAzphV2Y0Eop6k6cDO1SrDZm5M7AMiQ/H5Hdc0ZE7LvoKkF8Hg0BtlNfEJamI+Y7acFb05oi37lAqHIaq7jNCaC0tGVNwKofsy+1nTVdllNLINgYy7kwAr+oGKnIgaIx6WCBcao79V4mOdDbYZ0a6NW8oejHzprEJysd/H+W8Cc2ObDB5EQCZG8lmnkkMIdjUTzwLU5u7LnD/tkwCFordMU5ZLyuJpD8ckbAlPwvD+qCo6z0pH6DVIIROn5Red7g7BSXjt4n7bNuRajPjruLMfD2S9L/hQ1jWijKv5dq98rl1fLNF/g0lxmUDVR/eWfkDkqLM65dHN7y7Dqzrvk5BBIaLCc8rOmJNE4pXD97vLnCmPnVdILMQvHT3ObqnFpzd9BuPjnQY9g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:GVXPR04MB9831.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(52116014)(366016)(376014)(19092799006)(1800799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Eyve2SX47o4XF2B0VfpDwCwFjkqC/+VXRiAzoC/ZSiygyH/FX/kSMdtzSwwnFxzK4NK+6ZoFpgo3GCghdIdFcJpF+PE9dDcKdP/dqMwI8GUXVec7BfQIEahVOR+hhFUaFB9FHXJXwp5ZeWZMFcpei8dIUPaGPa+avNsI0XkYcaJ31Hw/sPY9XLo766suXAo7ZEK022UrFIC2w1blhfmrh+Yy0iMwWMTrN35AL4Xh7d61c/+zlGpERy2hMgTr0OnHJN/oyz/3r3x3tLfbRqozRaYr7p0ExXU3pR7uFN9Vd2p8sj3XnWHQXoY2G4pqg+aJkDtS2dXsYFroQAGLiMcdNHRQUtb+3IDs/TFKnZ3RL9EiBeaPIFjU/0nITsJvAEwPqedTQuVda5R47KWQYJW+SLcBjjanu6w7LtaR1a/8vitdvZdqrFgcJJjIp9QKusDj+vkVtVir3XI26Z6CFgd25Fb6w9Tw9FL/RMKJuZS6ReZjLYHDtPF4MbIvvcCqmt1/s3hPfxxeUjctZu9xdWFfn6dphJFpgbc60UbLCFZ3myrDM7r3bif3+2/4fb0guTdSqJ+CDbi85vh4tfAqY/iymeqhQvSvdIY0VSBdkutVRrKi8b+sGjuQwq71J54/Cr9SDA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 38ec3f06-583d-48b7-7330-08ddb87db88a X-MS-Exchange-CrossTenant-AuthSource: GVXPR04MB9831.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2025 09:00:26.6066 (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: 7nKkBMnbVsC4jlL6MZeRFZ8QtEjd3T58OPPayV9xGlVyN+83p95qJo5jKCM2b3rGBGmZxLdw9nthkTKKNgITNA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7896 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 Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 112 ++++++++++++------- 1 file changed, 74 insertions(+), 38 deletions(-) diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp index 4e632e852ebf..72e055e400c6 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 @@ -807,34 +808,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() - pipes_.size(); - - 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; @@ -846,10 +822,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 @@ -858,6 +841,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 @@ -969,6 +961,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. @@ -1012,12 +1018,24 @@ 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. + * + * In multicamera case, limit maximum amount of streams to allow all + * sensors to get at least one dedicated pipe. */ unsigned int numCameras = 0; unsigned int numSinks = 0; + const unsigned int xbarFirstSource = crossbar_->entity()->pads().size() - pipes_.size(); + const unsigned int maxStreams = pipes_.size() / cameraCount; + V4L2Subdevice::Routing routing = {}; + for (MediaPad *pad : crossbar_->entity()->pads()) { unsigned int sink = numSinks; @@ -1048,17 +1066,23 @@ bool PipelineHandlerISI::match(DeviceEnumerator *enumerator) continue; } + /* All links are immutable except the sensor -> csis link. */ + const MediaPad *sensorSrc = sensor->getPadByIndex(0); + sensorSrc->links()[0]->setEnabled(true); + /* 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, 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) { @@ -1073,6 +1097,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); @@ -1080,6 +1112,10 @@ bool PipelineHandlerISI::match(DeviceEnumerator *enumerator) numCameras++; } + ret = crossbar_->setRouting(&routing, V4L2Subdevice::ActiveFormat); + if (ret) + return false; + return numCameras > 0; }