From patchwork Mon Mar 4 18:18:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Vuillaumier X-Patchwork-Id: 19628 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 0CEC5C326B for ; Mon, 4 Mar 2024 18:18:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B64BB62867; Mon, 4 Mar 2024 19:18:49 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="ZgOqS42u"; dkim-atps=neutral Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on20601.outbound.protection.outlook.com [IPv6:2a01:111:f403:2612::601]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 044F2627FC for ; Mon, 4 Mar 2024 19:18:48 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RGB/4wTeIJUiFCaedC4T5YKZ0yv+xpdDW61hw8n9adlVGTWPsR1uaP2ErRiGMdCAmtIjJVDy0BlxmroloJ2Q8os/VMUS6PG9pKytU70LFaxzmDR/jvTKnlnj45ckDO/EuPBr1Kk4jXXEkC61tyyu61vH7eFt4PpkQ363EWaiXOfine/7yciQcumuhzg9HJk7oGQyW/nyALJOxjp/33rfGhqZgeRkiHVbBqyA294xgs+3BwOem4nPWsaNReEZSfwzNjStBDuhlFxyZ4CfHTfGlTNIlyLevFiRYUG2FZ4AAqgRg/XC53+l81UZVnEqtbMvQJ2IIfeps/qlbEWiK5sjGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=gwObTKw9+MxjEWFrUG+zgt/jcwhAF0/g7RIJ0SN5B9M=; b=E5ckG8UNkEGozftJkjl3WZ82XfP1s64Rr7y/PJn2EF1cFIoySSTvwpN5wtHqE+Dj9p8OuJHXa9enZmHrfQXdUY984aYiZ/2CUeOHfocj0f38qI8S+nUzgwF7Uot1dIv3ki1lvRt6W4MUgR4QSHjFq1nKJzyLOFOOY6489u5FCpdQ0dCHep2Zc2Vhh9vKYPO8aXEfJaxRdazWjJWNb4QCnPc1xG8hFsulCxLU+HGrni8yHlD3z+l4M0Ii7fVteASPtkgtJhVSodEzFQRRj/pO7L5MGvPX/1twatvMz80/LyNz3GHmRsHdO/a+ThmcASGyn3NTFCJXXQQUkWN9ZArRwA== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gwObTKw9+MxjEWFrUG+zgt/jcwhAF0/g7RIJ0SN5B9M=; b=ZgOqS42uU4KFNscXMJ/7JHJ9hAR0RXzLPY5HCbOjM9BeGcYVjOuLq2fi4P5JR5hNyD5TOC7vwxWxX4R4rhHWu+qYHUlRFblZOv+xt6aI3ZHRbs1jUsHQnP4WD39m5Lozcg+SHWLFwg1wYvIkIZaV/L7hrbHVY1Zl2gbKNY9rR+A= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8147.eurprd04.prod.outlook.com (2603:10a6:20b:3e0::22) by AM8PR04MB7394.eurprd04.prod.outlook.com (2603:10a6:20b:1d1::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.39; Mon, 4 Mar 2024 18:18:47 +0000 Received: from AM9PR04MB8147.eurprd04.prod.outlook.com ([fe80::3fdf:4cf8:d542:1b49]) by AM9PR04MB8147.eurprd04.prod.outlook.com ([fe80::3fdf:4cf8:d542:1b49%4]) with mapi id 15.20.7339.035; Mon, 4 Mar 2024 18:18:47 +0000 From: Julien Vuillaumier To: libcamera-devel@lists.libcamera.org Subject: [PATCH v1 1/1] libcamera: camera_manager: Add environment variable to order pipelines match Date: Mon, 4 Mar 2024 19:18:16 +0100 Message-Id: <20240304181816.2361334-2-julien.vuillaumier@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240304181816.2361334-1-julien.vuillaumier@nxp.com> References: <20240304181816.2361334-1-julien.vuillaumier@nxp.com> X-ClientProxiedBy: AS4P191CA0015.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:5d5::12) To AM9PR04MB8147.eurprd04.prod.outlook.com (2603:10a6:20b:3e0::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8147:EE_|AM8PR04MB7394:EE_ X-MS-Office365-Filtering-Correlation-Id: c134b2cc-5940-447e-49f4-08dc3c778894 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fc8bBXjykYxyKbZrmEj8nUJiZg7Fyc7fK7lNYEDEN7hNs8FhL0fSRD4nhIZldQCP1KPv6JwZ5heqqHdIGhMseOp+dIH5tnJTN0urcX8EoDNL8yeOzKrI7WImzX4N4X76frzZmywlpwEBTFt5/oZmxE68xAofP3dMAM+loCXcwzOJAaSj5o0rvzQ5/G5tw5kneVnCgJAsC0DM//TiW6KAORpswE7c0h6bn+/9VHRoxEONP6/0XVAq8zGIbY+Vr1VzoQUTmiBPpScWf9qGhPso8uQ0tzy832hxmNDFnhSjQZbSjxQezBDqeJO44inQfwAxb1ngUPDff2FYM0zJPkB+pQ7JAu/hjuxX0OxYVVz3T3058UKX53hRG28+LGurbs2lCxFBZWiYCADgZIRYDTax9RH4RMTAmg0xINcXZx6SuemCDt5cQAD5IYZhHXFWa+TeGnaOL0nxdLZKNcSe5G0IFPfmVjMdmxYS6LrrtPpChT6arRujKw7WKvYGdbhxG6if0OgohjFdyPWYWYWAcX46kW4PnP9v4GZfdjr/MCuZ4pcOYjbXa22c6MMuAhdfYg3QbmUF95zRP+6xuejSZ4pxC+fgtVCeDJ5wcL0zOkVmrm4VmJrXxWS+I+JkCmVYhmP8DdBV/oLqrkiuSrq9/es8Q/Z87Ph0BlfxOH1LbHtHMk1/Qs0Jo2eJ60dEjLUcaGUGQTBD8oYnBJvG64KVcitXww== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR04MB8147.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(376005)(38350700005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 38q9msaBLPb8/PONnyMQ3iN0SwY9G2AmHKRX0gUtdk+BlQzDw4lJ+40AKe80yMXOGwnEklQP2gJ235Ai896CViHl62FAD/G8N+uo9Rhs6jCit1o0vPl1CBH31rrDWQ+Gs75x6vhA448bIXKfUl9XRQf6unKpNfF5JDe8G6fnEGZzJFA1ElG8hl9LdsDVu3GrUz/LRSdQZiq7k6sERCFDZHpB/4KR7ntwgm0SfYahVJ/RDdlrCSv0XIOlkBvQLd/Ud2YeY1q0i53gC+gzM7NlxlrZ9rsw8uiN/ECWExrOWkfhR3YvWODfH1BlTWAEHZy1ao/8gWcBX13PUaWJ9MaN4cAKkbVIiu7T34z7knjSyNUy0vWYlMK82BDuJCt5r0tVDum1CwrSBtOC7hKusAmBFkjstByxqg/hRxpJ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c9sy6iwh78Pez1SeaCqWl41u4scg7ZfH7RqP2vk1nIrVoQ+9ebO4K7gLrNF+rTxrQNfEQAERvaZvWMYHqAUTnjDf/LDFf9eExhYkNq5ss18sVNKUlg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c134b2cc-5940-447e-49f4-08dc3c778894 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8147.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2024 18:18:47.1466 (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: l+UUrAsxeq0ZinMOB+jIjhDePpJDwrqYn/74Tk4dLDoD8qnOr79rFBXDXDP6F/RebbCsVyHgFWWHghQyl63mUkpDB4Q7rB0reRYN2SnOWxQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7394 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" To match the enumerated media devices, each pipeline handler registered is used in no specific order. It is a limitation when several pipelines can match the devices, and user has to select a specific pipeline. For this purpose, environment variable LIBCAMERA_PIPELINES_MATCH_LIST is created that gives the option to define an ordered list of pipelines to invoke during the match process. LIBCAMERA_PIPELINES_MATCH_LIST="[,[,...]]]" Example: LIBCAMERA_PIPELINES_MATCH_LIST="PipelineHandlerRkISP1,SimplePipelineHandler" Signed-off-by: Julien Vuillaumier --- Documentation/environment_variables.rst | 5 +++ src/libcamera/camera_manager.cpp | 51 +++++++++++++++++++++---- 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/Documentation/environment_variables.rst b/Documentation/environment_variables.rst index a9b230bc..f3a0d431 100644 --- a/Documentation/environment_variables.rst +++ b/Documentation/environment_variables.rst @@ -37,6 +37,11 @@ LIBCAMERA_IPA_MODULE_PATH Example value: ``${HOME}/.libcamera/lib:/opt/libcamera/vendor/lib`` +LIBCAMERA_PIPELINES_MATCH_LIST + Define ordered list of pipelines to be used to match the media devices. + + Example value: ``PipelineHandlerRkISP1,SimplePipelineHandler`` + LIBCAMERA_RPI_CONFIG_FILE Define a custom configuration file to use in the Raspberry Pi pipeline handler. diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp index 355f3ada..9568801e 100644 --- a/src/libcamera/camera_manager.cpp +++ b/src/libcamera/camera_manager.cpp @@ -109,14 +109,7 @@ void CameraManager::Private::createPipelineHandlers() const std::vector &factories = PipelineHandlerFactoryBase::factories(); - for (const PipelineHandlerFactoryBase *factory : factories) { - LOG(Camera, Debug) - << "Found registered pipeline handler '" - << factory->name() << "'"; - /* - * Try each pipeline handler until it exhaust - * all pipelines it can provide. - */ + auto pipeMatch = [&](const PipelineHandlerFactoryBase *factory) { while (1) { std::shared_ptr pipe = factory->create(o); if (!pipe->match(enumerator_.get())) @@ -126,6 +119,48 @@ void CameraManager::Private::createPipelineHandlers() << "Pipeline handler \"" << factory->name() << "\" matched"; } + }; + + /* + * When a list of preferred pipelines is defined, iterate through the + * ordered list to match the devices enumerated. + * Otherwise, devices matching is done in no specific order with each + * pipeline handler registered. + */ + const char *pipesLists = + utils::secure_getenv("LIBCAMERA_PIPELINES_MATCH_LIST"); + if (pipesLists) { + for (const auto &pipeName : utils::split(pipesLists, ",")) { + if (pipeName.empty()) + continue; + + auto nameMatch = [pipeName](const PipelineHandlerFactoryBase *f) { + return (f->name() == pipeName); + }; + + auto iter = std::find_if(factories.begin(), + factories.end(), + nameMatch); + + if (iter != factories.end()) { + LOG(Camera, Debug) + << "Found pipeline handler from list '" + << (*iter)->name() << "'"; + pipeMatch(*iter); + } + } + return; + } + + for (const PipelineHandlerFactoryBase *factory : factories) { + LOG(Camera, Debug) + << "Found registered pipeline handler '" + << factory->name() << "'"; + /* + * Try each pipeline handler until it exhausts + * all pipelines it can provide. + */ + pipeMatch(factory); } }