{"id":22746,"url":"https://patchwork.libcamera.org/api/1.1/covers/22746/?format=json","web_url":"https://patchwork.libcamera.org/cover/22746/","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":"<20250206161607.50738-1-mzamazal@redhat.com>","date":"2025-02-06T16:15:51","name":"[v7,00/15] 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/22746/mbox/","series":[{"id":4993,"url":"https://patchwork.libcamera.org/api/1.1/series/4993/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4993","date":"2025-02-06T16:15:51","name":"Add global configuration file","version":7,"mbox":"https://patchwork.libcamera.org/series/4993/mbox/"}],"comments":"https://patchwork.libcamera.org/api/covers/22746/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 596D9C32EF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  6 Feb 2025 16:16:20 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3A8EC685E4;\n\tThu,  6 Feb 2025 17:16:19 +0100 (CET)","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 2E24D6053F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  6 Feb 2025 17:16:18 +0100 (CET)","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-463-UH2OPRgQNi20GtIEdG2gCQ-1;\n\tThu, 06 Feb 2025 11:16:14 -0500","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 0F14519560B1; Thu,  6 Feb 2025 16:16:13 +0000 (UTC)","from mzamazal-thinkpadp1gen3.tpbc.com (unknown [10.43.17.31])\n\tby mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id 2194D18004A7; Thu,  6 Feb 2025 16:16:10 +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=\"EPgask1j\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1738858577;\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=nw0K93QMPis/Id6NwwVC5PP3Ciu9fJuoKLE5FFZ7AlE=;\n\tb=EPgask1j+EZEvJ3WTRmtITbiPEOkAv5STekr0tEFkZmWFUefM4T0vPc+Ofpfah9RyIvA1D\n\t+TVL9S89JEPdZMq4v5nkM9lmqY9QPimuEMpgaxcvaPLCRnfDDNl2ZuWrhLeMrIpc20s9Cg\n\tTLruClAsTKHkf3YQtkkGzeqM5AL+ar4=","X-MC-Unique":"UH2OPRgQNi20GtIEdG2gCQ-1","X-Mimecast-MFC-AGG-ID":"UH2OPRgQNi20GtIEdG2gCQ","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>, Naushir Patuck\n\t<naush@raspberrypi.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 v7 00/15] Add global configuration file","Date":"Thu,  6 Feb 2025 17:15:51 +0100","Message-ID":"<20250206161607.50738-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":"z4xJCuGIpPJAGVPrlqmXC234S8hCY-FLkCTXzwwnlMU_1738858573","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 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 (15):\n  yaml: Move yaml_parser.cpp to base\n  config: Introduce global runtime configuration\n  config: Look up logging levels in the configuration file\n  config: Add configuration retrieval helpers\n  config: Look up log file in configuration file\n  config: Look up log color configuration in configuration file\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} | 133 +++++++-\n .../libcamera/internal/global_configuration.h |  60 ++++\n include/libcamera/internal/meson.build        |   1 +\n src/libcamera/base/global_configuration.cpp   | 289 ++++++++++++++++++\n src/libcamera/base/log.cpp                    |  24 +-\n src/libcamera/base/meson.build                |  15 +\n src/libcamera/{ => base}/yaml_parser.cpp      |  13 +-\n src/libcamera/camera_manager.cpp              |  10 +-\n src/libcamera/ipa_manager.cpp                 |  35 ++-\n src/libcamera/ipa_proxy.cpp                   |  65 ++--\n src/libcamera/meson.build                     |  14 -\n .../pipeline/rpi/common/pipeline_base.cpp     |   8 +-\n src/libcamera/pipeline/simple/simple.cpp      |  12 +\n src/libcamera/process.cpp                     |  11 +-\n src/libcamera/software_isp/TODO               |  36 ---\n src/libcamera/software_isp/debayer_cpu.cpp    |  30 +-\n src/libcamera/software_isp/debayer_cpu.h      |   7 +-\n 20 files changed, 625 insertions(+), 144 deletions(-)\n rename Documentation/{environment_variables.rst => runtime_configuration.rst} (58%)\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%)"}