{"id":23544,"url":"https://patchwork.libcamera.org/api/1.1/covers/23544/?format=json","web_url":"https://patchwork.libcamera.org/cover/23544/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20250611142431.33306-1-mzamazal@redhat.com>","date":"2025-06-11T14:24:16","name":"[v9,00/13] Add global configuration file","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/1.1/people/177/?format=json","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"mbox":"https://patchwork.libcamera.org/cover/23544/mbox/","series":[{"id":5215,"url":"https://patchwork.libcamera.org/api/1.1/series/5215/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5215","date":"2025-06-11T14:24:16","name":"Add global configuration file","version":9,"mbox":"https://patchwork.libcamera.org/series/5215/mbox/"}],"comments":"https://patchwork.libcamera.org/api/covers/23544/comments/","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id BD27FC3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 11 Jun 2025 14:24:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6858D68DC2;\n\tWed, 11 Jun 2025 16:24:44 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A910961552\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 11 Jun 2025 16:24:42 +0200 (CEST)","from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com\n\t(ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63])\n\tby relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n\tcipher=TLS_AES_256_GCM_SHA384) id us-mta-437-Lwz9PW4WPtCup4mP_irJUg-1;\n\tWed, 11 Jun 2025 10:24:37 -0400","from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com\n\t(mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com\n\t[10.30.177.111])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (2048 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS id 0FA3719560B0; Wed, 11 Jun 2025 14:24:36 +0000 (UTC)","from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.44.33.76])\n\tby mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id 0B6AD18003FC; Wed, 11 Jun 2025 14:24:33 +0000 (UTC)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"L/5Bu1VT\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1749651881;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding;\n\tbh=lJhLAF4iDBBkghm22O64H9M5kehie/fIbXTsPJn98sU=;\n\tb=L/5Bu1VTXWqHX8toF/WJ2YDBYeVcFEERxxK9dG5VLG5MjwkSVl9/A1pNyLjee0hRsZNgXj\n\t08G4V3bLS5AFc0Dt65w6qTuAYmfk9C4K53ZSzb+HWys5BSOy65CiAUFquRpXDTmzlEC/p+\n\tLWUPx5YNI7bHstQOhcv7fk/VZ8+BQnE=","X-MC-Unique":"Lwz9PW4WPtCup4mP_irJUg-1","X-Mimecast-MFC-AGG-ID":"Lwz9PW4WPtCup4mP_irJUg_1749651876","From":"Milan Zamazal <mzamazal@redhat.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Milan Zamazal <mzamazal@redhat.com>, Kieran Bingham\n\t<kieran.bingham@ideasonboard.com>, =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?=\n\t<pobrn@protonmail.com>, Laurent Pinchart\n\t<laurent.pinchart@ideasonboard.com>","Subject":"[PATCH v9 00/13] Add global configuration file","Date":"Wed, 11 Jun 2025 16:24:16 +0200","Message-ID":"<20250611142431.33306-1-mzamazal@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.4.1 on 10.30.177.111","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"ZwpTwq4lDdiS7RCgkc-e1vDe3ax2uXJ9EVmi8fBDfDc_1749651876","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"This patch series introduces global configuration file for libcamera, to\nprovide runtime configuration means other than environment variables.\nInstead of, or in addition to, the growing list of configuration\nenvironment variables, the whole configuration can be specified in a\nsingle configuration file.  This is both simpler and more flexible.\n\nThis is not a replacement for specific configuration files already\npresent in libcamera.\n\nThe patches implement what is needed to introduce a configuration file\nthat can handle the current environment variables and software ISP\nTODOs.  They demonstrate how to deal with the key points that must be\nconsidered.  See commit messages for more details.\n\nThe configuration file is a YAML file.  It is looked up in user’s home\ndirectory or, if not present, in system-wide libcamera directories.\nBoth the directories and file name of the configuration file can be\noverridden using newly introduced environment variables.\n\nThe current configuration environment variables are still supported and\ntake precedence, if defined, over the corresponding entries in the YAML\nfile.\n\nThis patch series is not exhaustive, there can be future enhancements,\nmost notably configuration file validation to avoid confusions caused by\ntypos etc.\n\nNot everything has been tested because some of the patches are related\nto specific hardware.\n\nAlso, not everything is necessarily C++ elegant, suggestions for\nimprovements are welcome.  Note that there is an obstacle in that\nconfiguration initialization may call logging and logging queries\nconfiguration, as explained in the commit messages.  This complicates\ntransparent encapsulation.\n\nChanges in v9:\n- The configuration instance is now stored in CameraManager and accessed\n  from there rather than being a separate singleton wrapped by global\n  accessors.  This solves the ugly problem of delayed initialization but\n  I don’t like anything else about it.  I played a bit with the idea of\n  attaching it to Logger instead, see the commit message of patch 03 for\n  some discussion, but stayed with the CameraManager proposal\n  eventually.\n- I’ve given up on the logging configuration now when the configuration\n  is stored in CameraManager and removed the corresponding patches.  I\n  think it’s possible to add it later, but for now, it’s already\n  complicated enough.\n- Not much tested, let’s see first if the current implementation gets in\n  an acceptable direction.\n\nChanges in v8:\n- Rebased on current master.\n- Anniversary edition: 400 days since v1 posted. ;-)\n\nChanges in v7:\n- Rebased on current master.\n- Tuning file path configuration updated for recent changes.\n  A significant change is that the tuning file configuration is no\n  longer sensor dependent as there is apparently no access to the sensor\n  info in the IPA proxy.\n- Minor improvements of some commit messages.\n\nChanges in v6:\n- Rebased on master.\n- File names from file header descriptions removed.\n- Indentation fix in moved code as requested by checkstyle.py.\n- Unneeded const_cast's removed.\n- Using GlobalConfiguration namespace rather than a class.\n- Path configuration options are defined as sequences in YAML.\n- A patch introducing LIBCAMERA_CONFIG_NAME added.\n- A patch introducing LIBCAMERA_CONFIG_DIR added.\n- Miscellaneous minor code changes suggested by Barnabás.\n\nChanges in v5:\n- A pointer is used to store the global configuration singleton rather\n  than a static variable.  This makes the things more robust and fixes\n  the problem with re-entrancy on logging and a failing\n  camera_reconfigure test.\n- In relation to the change above, a new initialization method\n  GlobalConfiguration::initialize() was introduced that replaces the\n  initialization calls in CameraManager and IPAManager.\n- Logging YAML errors when reading the configuration was also fixed.\n- Global configuration is placed to base directly, without an\n  intermediate patch.\n- An `optional' value comparison simplified.\n- A temporary typo in a comment fixed.\n- Unused stdint.h include removed.\n\nChanges in v4:\n- Rebased on current master.\n- Configuration option for LIBCAMERA_IPA_PROXY_PATH added.\n- Added a patch to include stdlib.h instead of cstdlib in yaml_parser.cpp.\n\nChanges in v3:\n- Added a configuration item for the newly introduced\n  LIBCAMERA_PIPELINES_MATCH_LIST variable.\n- A minor indentation fix.\n- Fixed `pipelines.' x `pipeline.' configuration item naming mismatch.\n- Tuning files are looked up now by particular cameras attached rather than\n  being specified for the whole pipeline.\n- Helpers use std::string& instead of char* for confPath arguments.\n- Protection against returning YamlObject::empty as a regular value (the\n  problem has been probably exposed by addition of\n  LIBCAMERA_PIPELINES_MATCH_LIST).\n\nChanges in v2:\n- Rebased on master.\n- Various cleanups, documentation improvements and minor fixes.\n- Configuration option for LIBCAMERA_RPI_TUNING_FILE added (Naush).\n- Two more patches for software ISP configuration added.\n\nMilan Zamazal (13):\n  yaml: Move yaml_parser.cpp to base\n  config: Introduce global runtime configuration\n  config: Make GlobalConfiguration instance\n  config: Add configuration retrieval helpers\n  config: Look up rpi config path in configuration file\n  config: Look up IPA configurables in configuration file\n  config: Look up pipelines match list in configuration file\n  config: Allow enabling software ISP in runtime\n  config: Add global configuration file documentation\n  libcamera: software_isp: Make input buffer copying configurable\n  libcamera: software_isp: Make measurement configurable\n  config: Make configuration file configurable\n  config: Make configuration directories configurable\n\n Documentation/documentation-contents.rst      |   2 +-\n Documentation/index.rst                       |   2 +-\n Documentation/meson.build                     |   2 +-\n ...ariables.rst => runtime_configuration.rst} | 119 +++++++-\n include/libcamera/internal/camera_manager.h   |   5 +\n .../libcamera/internal/global_configuration.h |  72 +++++\n include/libcamera/internal/ipa_manager.h      |   8 +-\n include/libcamera/internal/ipa_proxy.h        |   5 +-\n include/libcamera/internal/meson.build        |   1 +\n src/libcamera/base/global_configuration.cpp   | 268 ++++++++++++++++++\n src/libcamera/base/meson.build                |  15 +\n src/libcamera/{ => base}/yaml_parser.cpp      |  13 +-\n src/libcamera/camera_manager.cpp              |  22 +-\n src/libcamera/ipa_manager.cpp                 |  37 ++-\n src/libcamera/ipa_proxy.cpp                   |  72 ++---\n src/libcamera/meson.build                     |  14 -\n src/libcamera/pipeline/ipu3/ipu3.cpp          |   3 +-\n src/libcamera/pipeline/mali-c55/mali-c55.cpp  |   2 +\n src/libcamera/pipeline/rkisp1/rkisp1.cpp      |   4 +-\n .../pipeline/rpi/common/pipeline_base.cpp     |  11 +-\n src/libcamera/pipeline/simple/simple.cpp      |  13 +\n src/libcamera/pipeline/vimc/vimc.cpp          |   3 +-\n src/libcamera/software_isp/TODO               |  36 ---\n src/libcamera/software_isp/debayer_cpu.cpp    |  32 ++-\n src/libcamera/software_isp/debayer_cpu.h      |  10 +-\n src/libcamera/software_isp/software_isp.cpp   |   6 +-\n test/ipa/ipa_interface_test.cpp               |   3 +-\n .../module_ipa_proxy.cpp.tmpl                 |   4 +-\n .../module_ipa_proxy.h.tmpl                   |   2 +-\n 29 files changed, 633 insertions(+), 153 deletions(-)\n rename Documentation/{environment_variables.rst => runtime_configuration.rst} (60%)\n create mode 100644 include/libcamera/internal/global_configuration.h\n create mode 100644 src/libcamera/base/global_configuration.cpp\n rename src/libcamera/{ => base}/yaml_parser.cpp (98%)"}