From patchwork Fri Nov 14 15:43: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: 25073 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 3C8F6C32DB for ; Fri, 14 Nov 2025 15:41:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C07D960A80; Fri, 14 Nov 2025 16:41:54 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="eI/iGl3S"; dkim-atps=neutral Received: from MRWPR03CU001.outbound.protection.outlook.com (mail-francesouthazlp170110003.outbound.protection.outlook.com [IPv6:2a01:111:f403:c207::3]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4DDA8609D8 for ; Fri, 14 Nov 2025 16:41:52 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EJ5rOJogrkSkchSCmoh03M50WvlUHu2Y1yf0tXdinTDqij937CRKElifZsP6hST2lGxozT8W5uUCIf/qe6/4Ug5uxJM3MKDkwDUZxB2rQ9XG3k9VhI2cGkpxOZZoCFTeVh+wEMJzWiChVT1pSs++Jz9qcnev6e2WfOQsS2vgsobEWP2CUizfaThjtjcAinC2sMKqr5ouTkmsmNtjvzZfw0i2ym/m4QQdYfghvsbUU9+dVLJtcOexIc/RKREYLvmp2BZeBYScTU+l0oqq2TwK7C69gKJWUFpAQR0+DeeiSkNIvIZ58lOtPn/kkkvx9xEZmr5EnD3TbYqnEnbSljtFpw== 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=JRexS7c3AqEGKu5NQLAj5oGpqtUjrovH5NEuBy84eEI=; b=L3fgk9vDu5PxjN9TZPcc6SbZk/Md5cf6cIV2TeNTL72sFqVJA7iOClyHO5jCFUhUxv3GdDcCluBnzme0/fwuBM5mQjxkXNTRWMwczCsph+/zwYdsvclZLa/zMS0yKK61bwutEZXC1lR7Azo1MHRxFar/HUVsxfMgpQSbJRae0IBdltq9Jq+3MVA9H2WsI/EZbY1yduj1fXv307iMWPfuQQNn64STR9vWw68DonhMr5uvOaw5mpEFOTEYCjvMW1h4YuW27YWkt986zWKp1d2c11ujHBR0tbqRqlFw+zVLSRURC+GUlv9bo+S57u0yo5YjEpyWXxXf6h8/8gz59xTocQ== 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=JRexS7c3AqEGKu5NQLAj5oGpqtUjrovH5NEuBy84eEI=; b=eI/iGl3So2tpfJ1tYg+V9rOV7578h7IOrRp2eUjEfc2qka00sh1ZO/GZlq5/oSMURrUr551BfbTYW4NVhxEegFijC6TnTAyCwgTCvAyjARxHvA4pjqIW357jVIGbLBI7OBk2CEqAwvqAd55oS73+a+8JjGt8Qhwbt6EmQWYOFooAYzqb9oDNmF28T1Ny87adkOmViYAwYhaJSgrabQUmwc5cvTns274YRzxvKWFa6kE9w35mBl2LPJB4f25kWkoxl505m0DPZfo4Cpmtm6iyRpK+zgi+z/jUT8Qk/SI8BUdj9V5Si/h9f3i3N/YZKzb4CLyhJBppZpLHSJbj8YgDQQ== 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 GV1PR04MB10108.eurprd04.prod.outlook.com (2603:10a6:150:1a2::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.16; Fri, 14 Nov 2025 15:41:51 +0000 Received: from GVXPR04MB9831.eurprd04.prod.outlook.com ([fe80::4634:3d9c:c4a:641a]) by GVXPR04MB9831.eurprd04.prod.outlook.com ([fe80::4634:3d9c:c4a:641a%6]) with mapi id 15.20.9320.018; Fri, 14 Nov 2025 15:41:51 +0000 From: Antoine Bouyer To: libcamera-devel@lists.libcamera.org Cc: julien.vuillaumier@nxp.com, jacopo.mondi@ideasonboard.com, barnabas.pocze@ideasonboard.com, Andrei Gansari , Antoine Bouyer Subject: [PATCH v2 1/2] libamera: media_pipeline: Add accessor for MediaPipeline list of entities Date: Fri, 14 Nov 2025 16:43:40 +0100 Message-Id: <20251114154341.654850-2-antoine.bouyer@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251114154341.654850-1-antoine.bouyer@nxp.com> References: <20251114154341.654850-1-antoine.bouyer@nxp.com> X-ClientProxiedBy: AS4P192CA0039.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:658::20) To GVXPR04MB9831.eurprd04.prod.outlook.com (2603:10a6:150:11c::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GVXPR04MB9831:EE_|GV1PR04MB10108:EE_ X-MS-Office365-Filtering-Correlation-Id: 5a548076-00ae-4a43-1f8c-08de2394543b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|19092799006|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: +JYBcoCyoKg2EWyew/aDLDEirPemqNb5zLDSew6dMocxtM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J6YmUpkKJM5hykvy0eRlus9RE+0e3YN76DESEJk2ZRz0NJ+Sqj24sm3vr2/clWNkae9jozBcSKm1hFSLY5u0W9UNsBvSsV20E+CgzF93B3MsJOrx8H5v0QUsswx7AY5cLwfj7I7VpOKD8SZFCbIlxEjQfRfHYTFekcuPTcD5qBX0m7iTEyxLtlSZDvK8qXOloow1DmTNFOhd/Pd9cN16LBEa9znlCJ6XP40rRIIaQzMOjyCAywkxTtKiBL3pfBuNdxfFkK7wq8LT8uTbvdSlkYEaJWwv96HeXT/1D1XMRwcTjHDQpo8Y6IYuoINFRRTMSpcSsw9Z1nvVGo0epqNZ/d7m2jbEFqKMOa1BBfNTMTOjf1HPEp2Bwe5TgEZAEad0htT9posDPnNBpaTN2Kzs9WkKS 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)(19092799006)(376014)(1800799024)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: M78TTe1j+32zWkQbbuA2EWmNOB2CsleGv43ATWEZ6ce/zTJiJAUjArc2i6c9HQZiJDJrgauLNoLiYXZeTZ017mpJ8766QE7YL7JcN6OsSHZ0Tr1fyXdmMr3Bsm76u4qvRAMOTCKeCXEdOjr8+UlWQbWcFf02vZ4aufrsnji79zxJGBk10rDdMdgaGJhAGNxtQHUebok3YWuGK08Kn4iDB17BstcalnTCDSBwJzDyVwLwxe/LGRq2qlkLZxhelw10VrQ7cpyqAJTPu1xiE1mIGdoLzKXNq3Qpi+9xsw9tAArnXhnvlWMQmfxYEOGZotV+O2NLVjtWFA7K5RLlJ9rLRd56RKUeAj+IJCxKo8edNLP+NTcd1YhQZ9GYDFKS/OC1aqlXAILiyU0VWWC6bd0BOGUsfzyvrH5hLiWIjWu1GOQ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I14z4eexRV46FQ0ck+FX4jX6OBQj0af4xmzIYg6ZtDYEn1sXTHNc9nuB5Kz3lM2vsdBqxaEK8iNXBg/xKtY1TuN1YNDHacrC7Y14xewMXmjovyRWU+zMvzV76P9KwCWBvPBng== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5a548076-00ae-4a43-1f8c-08de2394543b X-MS-Exchange-CrossTenant-AuthSource: GVXPR04MB9831.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2025 15:41:51.0165 (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: yrTmNsN1Dn5A9QrrcmqsJ4wo6LtSLt7Qa7MKBeF+5Vi08BlNAOqnMfkF3t8CsVsvgZreSo75cmgXFAi3oPlS7Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB10108 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" From: Andrei Gansari Exposes internal MediaEntity::Entity list to help extracting more information regarding linked entities. For example, when the pad index of the last device in the list need to be retrieved from the media pipeline user. Exposes as const to with a dedicated access to prevent any corruption from user. Then it is still protected so as when the list was private. Since MediaPipeline::Entity needs also to be moved to public, then need to add some documentation in cpp source. Existing documentation from header file is applied when available. Signed-off-by: Andrei Gansari Signed-off-by: Antoine Bouyer Reviewed-by: Jacopo Mondi --- include/libcamera/internal/media_pipeline.h | 29 ++++---------- src/libcamera/media_pipeline.cpp | 44 +++++++++++++++++++++ 2 files changed, 51 insertions(+), 22 deletions(-) diff --git a/include/libcamera/internal/media_pipeline.h b/include/libcamera/internal/media_pipeline.h index a7a4b8c559cd..f62e3e8c58b0 100644 --- a/include/libcamera/internal/media_pipeline.h +++ b/include/libcamera/internal/media_pipeline.h @@ -23,36 +23,21 @@ struct V4L2SubdeviceFormat; class MediaPipeline { public: - int init(MediaEntity *source, std::string_view sink); - int initLinks(); - int configure(CameraSensor *sensor, V4L2SubdeviceFormat *); - -private: struct Entity { - /* The media entity, always valid. */ MediaEntity *entity; - /* - * Whether or not the entity is a subdev that supports the - * routing API. - */ bool supportsRouting; - /* - * The local sink pad connected to the upstream entity, null for - * the camera sensor at the beginning of the pipeline. - */ const MediaPad *sink; - /* - * The local source pad connected to the downstream entity, null - * for the video node at the end of the pipeline. - */ const MediaPad *source; - /* - * The link on the source pad, to the downstream entity, null - * for the video node at the end of the pipeline. - */ MediaLink *sourceLink; }; + int init(MediaEntity *source, std::string_view sink); + int initLinks(); + int configure(CameraSensor *sensor, V4L2SubdeviceFormat *); + + const std::list &entities() const { return entities_; } + +private: std::list entities_; }; diff --git a/src/libcamera/media_pipeline.cpp b/src/libcamera/media_pipeline.cpp index c4e9f69b8f6a..1bb55a507fce 100644 --- a/src/libcamera/media_pipeline.cpp +++ b/src/libcamera/media_pipeline.cpp @@ -43,6 +43,50 @@ LOG_DEFINE_CATEGORY(MediaPipeline) * two entities in a media graph. */ +/** + * \struct MediaPipeline::Entity + * \brief A node composing the media pipeline + * + * The MediaPipeline::Entity struct stores how a MediaEntity composing a + * media pipeline is connected to other media entities. Source and sink pads + * are stored, so as whether the entity itself does support internal routing. + */ + +/** + * \var MediaPipeline::Entity::entity + * Pointer to the libcamera::MediaEntity, always valid + */ + +/** + * \var MediaPipeline::Entity::supportsRouting + * Whether or not the entity is a subdev that supports the routing API + */ + +/** + * \var MediaPipeline::Entity::sink + * The local libcamera::MediaPad sink pad connected to the upstream entity, + * null for the camera sensor at the beginning of the pipeline. + */ + +/** + * \var MediaPipeline::Entity::source + * The local libcamera::MediaPad source pad connected to the upstream entity, + * null for the last node at the end of the pipeline. + */ + +/** + * \var MediaPipeline::Entity::sourceLink + * The link on the libcamera::MediaLink source pad, to the downstream entity, + * null for the last node at the end of the pipeline. + */ + +/** + * \fn MediaPipeline::entities() + * \brief Retrieve list of entities composing the media pipeline + * \return The list of MediaPipeline::Entity entities composing the media + * pipeline. + */ + /** * \brief Retrieve all source pads connected to a sink pad through active routes * From patchwork Fri Nov 14 15:43: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: 25074 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 8257FC3241 for ; Fri, 14 Nov 2025 15:41:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6126460AA3; Fri, 14 Nov 2025 16:41:56 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="YSsQDyYk"; dkim-atps=neutral Received: from MRWPR03CU001.outbound.protection.outlook.com (mail-francesouthazlp170110003.outbound.protection.outlook.com [IPv6:2a01:111:f403:c207::3]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CAA77609D8 for ; Fri, 14 Nov 2025 16:41:52 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OhA24JWRkj9hFXiayUsBiPT5Fg/aCOKKiUAyvENH4fDHJ6OlS10/NbLLdaGpqsGtNIm2gNGpcCdmYVa94YzfVZ7LCVig4gvHaOHAL7WsyYbBo+2xR6RCkaXRRYSLzGfeb0ZPERSi4YBh/kF/mhyUU/I2u5EsFbY792H2gdCUieXrY8zq+GYF08//w6P+3Dl8K2gms6vtTZeO0IiinMftK6zrvPHi8DOPnMN6LBZtaVc9MbmM+PvhuNRxzQd0To75SPQxw36pMA+u/Sk9v3V6pAZ8fGLVi1R2bHbomZT4wfrqXaSpWT5CddpmMh4NK/Mz1FpHGL9ty5yF82R6a9ARpA== 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=SpUqncjHtUOgBWdmD8IwRZZJxhKUyakQtneBrT0pEwc=; b=mWeRjE0FDMUjDrm5L6VdjtVWhvPNuoOSRkTUVnUNIsxnySYtZQceoan0HXIipz7534/CAByKn6r25r5Yr8mk6mya8yTq0QW9htCqL9k9QQUu3nrjvbZCxl6hVOLPM8X58Pu7EuvJ/Skv6Gsh9YOAAl1ki3eivaWtVxDCiybEbv4a7GgbGCT0/T0M7f5T8/NUHykg0V8mmzOSVs+xG3aJvs6cIrAaVH96ISXo9pdRug7eQSRWxRCk9X+ayto597fLjb74hMOOmtA9sZABaTU3Zo4uBtOj50n+mHsNoDvOo0dcQyk/UJJAnEL4ITwIV15SFVxcjUQTfbKKNk7L3d8i+Q== 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=SpUqncjHtUOgBWdmD8IwRZZJxhKUyakQtneBrT0pEwc=; b=YSsQDyYkd11wO8Os3L/63MBV1QvQjujW294vLVnrzDwQChHGS89OiF3mKLuMNoUHzFGnxVjbNpMc1zOwpsv0pZNCOfS0Sxyi9p/eqdLwAhcuTjulURes9sRiZu5Z+wTqHk9NUiutoTPy7brdwcvUrgzCBVFtDagVq0as7QLalT8pjMDQIjm9Xnt9qsLlUNrB5aDmeLgsKB9NoSRTK39fvdvXCwgPaKN3OyS+52NLgR4Cg5PwbMdejex+VaduMUK+6kzQzqlGyR9Y2hF3xlsbNNXql05JfSiulRvUmhCqScFBnvwgHo8zlQBEKT0LMu2zEvjDT/ZBRyeycKsLbe/nzg== 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 GV1PR04MB10108.eurprd04.prod.outlook.com (2603:10a6:150:1a2::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.16; Fri, 14 Nov 2025 15:41:51 +0000 Received: from GVXPR04MB9831.eurprd04.prod.outlook.com ([fe80::4634:3d9c:c4a:641a]) by GVXPR04MB9831.eurprd04.prod.outlook.com ([fe80::4634:3d9c:c4a:641a%6]) with mapi id 15.20.9320.018; Fri, 14 Nov 2025 15:41:51 +0000 From: Antoine Bouyer To: libcamera-devel@lists.libcamera.org Cc: julien.vuillaumier@nxp.com, jacopo.mondi@ideasonboard.com, barnabas.pocze@ideasonboard.com, Andrei Gansari , Antoine Bouyer Subject: [PATCH v2 2/2] pipeline: imx8-isi: Integrating MediaPipeline class Date: Fri, 14 Nov 2025 16:43:41 +0100 Message-Id: <20251114154341.654850-3-antoine.bouyer@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251114154341.654850-1-antoine.bouyer@nxp.com> References: <20251114154341.654850-1-antoine.bouyer@nxp.com> X-ClientProxiedBy: AS4P192CA0039.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:658::20) To GVXPR04MB9831.eurprd04.prod.outlook.com (2603:10a6:150:11c::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GVXPR04MB9831:EE_|GV1PR04MB10108:EE_ X-MS-Office365-Filtering-Correlation-Id: e18d2fb9-574c-4edc-43f8-08de239454a9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|19092799006|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: YT7VLeyT5N7qUJK4LQw64+o01GVlT7WEKg7M9N/p7mIX7Aoh0PEiRKKeqr81RFAVJwdK8latJmscImVck+sthxMHFY9fD4Otv/uY87DqY2+RrRPU1d5SgPL32CO0cMLE1gEhkIpR7urF+KgoDofhq8QyFxXFmJGjxHwT7McKDTfSO+cS11pT3HgBtK6Ry0VQ2wl1fuHNNaEShFJJ3dcqEmgZ0ofQvjj7SZ9q9WtusdZEqPNdcmf1/6ZUe8NxTIodEaXLg8aEUg0Y440dumv8qiWwv1ML8CyXni4Uij1qUhlqONo6wM0wK56u11Atb/tJF1PYb2QsF1YYmKXZlawhg1r5SV1mxA2Hhpp9KviH2F0ScqirND4t/aMajM2zgaY6AOMBy9n1Bsi5mw7b1XB7DlkvKG28ZuW0b5tTIjdYTUBH9FwhV4tvO13iDdGJD6jVIMx5eE61pbcWJ5HUeaTlETFV1rBJLi2gFuNsydj7vsmTEfKir1N4VZ/1TUFNLlFz6JizExx+RoLXJkjtXqphwpy+oOzRJXkJfdyxEdMQjDcFtGMnwGLPHCM62AsTv8OCaAYdRYMEmFm7nsFUdbXEcuDVhVRkIVLSdsHv6L11c+Sfj3Wn0zwGbhLnKWMZWSbSCLqD1ftn1+sBG+ApR7XV1R2AzNyd+o/+1ab/wfaKAIs6YwIF30fUX8Y07liBwntMX3SIz+VWAhqktbo0hJUJVwoTriqh9xRmbfIOYH2kEaL4DbEgDbM02zPfmt5TbAWNDl/2rsIeNeOuG92MMJxQ5008Z31ibiW2m7iW1zUXr2pKssqR82uGMuwJ0Le+pntsYFPyzicGIlW+6nrBwEJfVs1DwD5kB4KP2Cn4jaeY7M0DCeVXI+51nOqyv9LZsUhNREeX1mdDxMnv6t0328sc2NXs3eCPUhy/FKq9+AV3lRwcOZkwp8ESwRnsK8xRjC5gfJdZO3/n9OiYLmqgK77IseyTWj6mqvUoZ+ACfDYeJP56FQX0W6xPhSBuEDDS81GnHqAai9EL1e1DUjzgQwbs9/kyHNBDV3pBo8s9/cu4JNSWglgktTQ3z3LMfymyOJAVVnX0zoRM9ggogDU25kGHZr13rYfMfv7vFBe+Rqwusn+GBTxeUznnNPHlLqTAJptBPFY1weppZ7rJ1/jwMS1jKbHBwW1q280MaZLyXyzR6a4f1HyNHXHfxctVJ5ZXn4MZT+CpVwf5QXfHLkgeCyOwgocvbAxYXDSIVARrvsnE/qB0oPbX8q46+9qrAZBYYUG+X1YbBig08aISW7aIR2Ho3P9dXdbmBw47qClXIy8X85MwolGG718nyF4pS9PwA48hx0kuWsHmGpJWPFDYYk1ARB3o7AJ7FNHhK1jTYRr5zJeT/8OnYqxNB0cevwT1HHDF/ztmQVo23ZoPn6zhXZqyt+9+X+ruh/1acKzAE7SzuTl7EZBRCE4a2SIRB6p3xVoAUNa8uUowgSFSI1SZ41bZ69obZErBd2I++lZuvjIvrau0iBY8J9JxAFFTpccOVZwz 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)(19092799006)(376014)(1800799024)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: a+1Ot1M5qwJTHF7c+hak7SahZ77YbJgdIlB0RgqQCQJIul55qUvuTACF6MV0nIJqhH9D9lMgpNyTMf/6Hc2mgxF3+Ntc2ZEk06fJhdvamuQh2h080K6XsCyKq0TO4isjOHYqItzJ3/tMRFn7aASm3mLouozjQqr9WMXk0A+iSArrv6zheFL9zuKdNYZ7WDjWXmVZT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fa6mkOKMqa2jW/ufb6nD7SUQlo4NUmA0iE/97+BIR1PXfwTl58MfwowUNttGtC/PJbQTZoyx6WZ6IqsWdHsifbmj/w29zUZYY8DWkRw2RHNPrDC5yDDqCkOg6oCUPPzbTmAGHDZSe30xknmHxytw+5+mwHJcaGMo6TQuExrIcKzYfopx4LhFJSLEc0lzrHBwypbR07tS3N8S2YwiU5quPy5UgMdeKN1agm1US4Qm7HIjX+K638mZ/NHOAm9d9khTCemYoxgmw22J2qkkxu3i+8GLUXwyNL3nO+P0fq3U/uRp8CxjOwJ6kles3h5ETJ+PEV0pbifDWaDxw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e18d2fb9-574c-4edc-43f8-08de239454a9 X-MS-Exchange-CrossTenant-AuthSource: GVXPR04MB9831.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2025 15:41:51.7090 (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: Rg3qXaa1r/yn7D4mU4pY2CIhhHV2mo1HHcOl6fDMJLKb3RtImpy5sy3v6vuXhdnmY6yM4REB12GbzhXmAn3VMw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB10108 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" From: Andrei Gansari This change integrates the MediaPipeline class into the imx8-isi pipeline handler. Purpose is to allow a dynamic discovery and configuration of the actual subdevices graph between the sensor and the ISI crossbar. This brings support for more complex topologies and simplifies the implementation. Signed-off-by: Andrei Gansari Signed-off-by: Antoine Bouyer --- src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 159 ++++++++++++------- 1 file changed, 98 insertions(+), 61 deletions(-) diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp index 9550f54600c4..aefc0ee60a11 100644 --- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp +++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp @@ -25,6 +25,7 @@ #include "libcamera/internal/camera_sensor.h" #include "libcamera/internal/device_enumerator.h" #include "libcamera/internal/media_device.h" +#include "libcamera/internal/media_pipeline.h" #include "libcamera/internal/pipeline_handler.h" #include "libcamera/internal/v4l2_subdevice.h" #include "libcamera/internal/v4l2_videodevice.h" @@ -62,14 +63,15 @@ public: unsigned int getYuvMediaBusFormat(const PixelFormat &pixelFormat) const; unsigned int getMediaBusFormat(PixelFormat *pixelFormat) const; + /* All entities, from the sensor to the ISI. */ + MediaPipeline mediaPipeline_; + std::unique_ptr sensor_; - std::unique_ptr csis_; std::vector streams_; std::vector enabledStreams_; - unsigned int xbarSink_ = 0; unsigned int xbarSourceOffset_ = 0; }; @@ -141,6 +143,8 @@ private: void bufferReady(FrameBuffer *buffer); + std::vector locateSensors(MediaDevice *media); + MediaDevice *isiDev_; std::unique_ptr crossbar_; @@ -164,10 +168,6 @@ int ISICameraData::init() if (!sensor_) return -ENODEV; - int ret = csis_->open(); - if (ret) - return ret; - properties_ = sensor_->properties(); return 0; @@ -811,18 +811,29 @@ int PipelineHandlerISI::configure(Camera *camera, CameraConfiguration *c) { ISICameraConfiguration *camConfig = static_cast(c); ISICameraData *data = cameraData(camera); + CameraSensor *sensor = data->sensor_.get(); + int ret; - /* Apply format to the sensor, CSIS receiver and crossbar sink pad. */ - V4L2SubdeviceFormat format = camConfig->sensorFormat_; - int ret = data->sensor_->setFormat(&format); - if (ret) + /* + * Enable the links all the way up to the ISI, through any connected CSI + * receiver and optional formatter. + */ + ret = data->mediaPipeline_.initLinks(); + if (ret) { + LOG(ISI, Error) << "Failed to set up pipe links"; return ret; + } - ret = data->csis_->setFormat(0, &format); + /* + * Configure the format on the sensor output and propagate it through + * the pipeline. + */ + V4L2SubdeviceFormat format = camConfig->sensorFormat_; + ret = sensor->setFormat(&format); if (ret) return ret; - ret = crossbar_->setFormat(data->xbarSink_, &format); + ret = data->mediaPipeline_.configure(sensor, &format); if (ret) return ret; @@ -979,13 +990,8 @@ bool PipelineHandlerISI::match(DeviceEnumerator *enumerator) 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++; - } + std::vector sensorEntities = locateSensors(isiDev_); + unsigned cameraCount = sensorEntities.size(); if (!cameraCount) { LOG(ISI, Error) << "No camera sensor found"; @@ -1048,60 +1054,28 @@ bool PipelineHandlerISI::match(DeviceEnumerator *enumerator) * 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; - for (MediaPad *pad : crossbar_->entity()->pads()) { - unsigned int sink = numSinks; - - if (!(pad->flags() & MEDIA_PAD_FL_SINK)) - continue; - - /* - * Count each crossbar sink pad to correctly configure - * routing and format for this camera. - */ - numSinks++; - - if (pad->links().empty()) - continue; - - MediaEntity *csi = pad->links()[0]->source()->entity(); - if (csi->pads().size() != 2) { - LOG(ISI, Debug) << "Skip unsupported CSI-2 receiver " - << csi->name(); - continue; - } - - pad = csi->pads()[0]; - if (!(pad->flags() & MEDIA_PAD_FL_SINK) || pad->links().empty()) - continue; - - MediaEntity *sensor = pad->links()[0]->source()->entity(); - if (sensor->function() != MEDIA_ENT_F_CAM_SENSOR) { - LOG(ISI, Debug) << "Skip unsupported subdevice " - << sensor->name(); - continue; - } - - /* All links are immutable except the sensor -> csis link. */ - const MediaPad *sensorSrc = sensor->getPadByIndex(0); - sensorSrc->links()[0]->setEnabled(true); - + for (MediaEntity *sensor : sensorEntities) { /* Create the camera data. */ std::unique_ptr data = std::make_unique(this, maxStreams); + ret = data->mediaPipeline_.init(sensor, "crossbar"); + if (ret) + continue; + + const MediaPipeline::Entity *xbarEntity = &data->mediaPipeline_.entities().back(); + unsigned int xbarSinkIndex = xbarEntity->sink->index(); + 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() - << " sink " << data->xbarSink_ + << " sink " << xbarSinkIndex << " offset " << data->xbarSourceOffset_; ret = data->init(); @@ -1120,7 +1094,7 @@ bool PipelineHandlerISI::match(DeviceEnumerator *enumerator) /* 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 }, + routing_.emplace_back(V4L2Subdevice::Stream{ xbarSinkIndex, 0 }, V4L2Subdevice::Stream{ sourcePad, 0 }, V4L2_SUBDEV_ROUTE_FL_ACTIVE); } @@ -1163,6 +1137,69 @@ void PipelineHandlerISI::bufferReady(FrameBuffer *buffer) completeRequest(request); } +/* Original function taken from simple.cpp */ +std::vector +PipelineHandlerISI::locateSensors(MediaDevice *media) +{ + std::vector entities; + + /* + * Gather all the camera sensor entities based on the function they + * expose. + */ + for (MediaEntity *entity : media->entities()) { + if (entity->function() == MEDIA_ENT_F_CAM_SENSOR) + entities.push_back(entity); + } + + if (entities.empty()) + return {}; + + /* + * Sensors can be made of multiple entities. For instance, a raw sensor + * can be connected to an ISP, and the combination of both should be + * treated as one sensor. To support this, as a crude heuristic, check + * the downstream entity from the camera sensor, and if it is an ISP, + * use it instead of the sensor. + */ + std::vector sensors; + + for (MediaEntity *entity : entities) { + /* + * Locate the downstream entity by following the first link + * from a source pad. + */ + const MediaLink *link = nullptr; + + for (const MediaPad *pad : entity->pads()) { + if ((pad->flags() & MEDIA_PAD_FL_SOURCE) && + !pad->links().empty()) { + link = pad->links()[0]; + break; + } + } + + if (!link) + continue; + + MediaEntity *remote = link->sink()->entity(); + if (remote->function() == MEDIA_ENT_F_PROC_VIDEO_ISP) + sensors.push_back(remote); + else + sensors.push_back(entity); + } + + /* + * Remove duplicates, in case multiple sensors are connected to the + * same ISP. + */ + std::sort(sensors.begin(), sensors.end()); + auto last = std::unique(sensors.begin(), sensors.end()); + sensors.erase(last, sensors.end()); + + return sensors; +} + REGISTER_PIPELINE_HANDLER(PipelineHandlerISI, "imx8-isi") } /* namespace libcamera */