{"id":24924,"url":"https://patchwork.libcamera.org/api/1.1/patches/24924/?format=json","web_url":"https://patchwork.libcamera.org/patch/24924/","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":"<20251030165816.1095180-20-barnabas.pocze@ideasonboard.com>","date":"2025-10-30T16:58:13","name":"[RFC,v3,19/22] libcamera: pipeline_handler: Inject \"debug\" metadata","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"ea58f5101c3df5ce71aa43e5f29a56d079df4fe7","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/1.1/people/216/?format=json","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/24924/mbox/","series":[{"id":5545,"url":"https://patchwork.libcamera.org/api/1.1/series/5545/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5545","date":"2025-10-30T16:57:54","name":"libcamera: Add `MetadataList`","version":3,"mbox":"https://patchwork.libcamera.org/series/5545/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/24924/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/24924/checks/","tags":{},"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 2E8D0C3336\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 30 Oct 2025 16:58:53 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A44ED609B3;\n\tThu, 30 Oct 2025 17:58:52 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0A2EF6097B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 30 Oct 2025 17:58:27 +0100 (CET)","from pb-laptop.local (185.221.140.239.nat.pool.zt.hu\n\t[185.221.140.239])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6957F4E5B;\n\tThu, 30 Oct 2025 17:56:36 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"P+MLy6S9\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1761843397;\n\tbh=9QB9kHA1zUZ+FIzDCzw0hB32seKsXL9zKorcZNi8fBA=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=P+MLy6S9al4FoM80e5QVxRlUYvFbjqP8I7jWKfpttBnyr8wHPvGZ7wc/EUgxP/VXY\n\tL5ucpf6oUlyI1/8IuD6pXDO+lFicYldtIvSlGTp53XcM7JzJJy/k4XzjYSKhHmfsm0\n\tDLghoA8C7CSjwrPaFU/7AA2ztpnGMpNO/LfXEv/I=","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>","Subject":"[RFC PATCH v3 19/22] libcamera: pipeline_handler: Inject \"debug\"\n\tmetadata","Date":"Thu, 30 Oct 2025 17:58:13 +0100","Message-ID":"<20251030165816.1095180-20-barnabas.pocze@ideasonboard.com>","X-Mailer":"git-send-email 2.51.1","In-Reply-To":"<20251030165816.1095180-1-barnabas.pocze@ideasonboard.com>","References":"<20251030165816.1095180-1-barnabas.pocze@ideasonboard.com>","MIME-Version":"1.0","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":"Inject all metadata controls in the \"debug\" namespace into\nthe metadata plan of each camera so that they can be used\nseamlessly. Dynamically sized array-like controls have a\nhard-coded size of 32 elements.\n\nAdditionally, a new type is added for inspecting properties of\na control type at runtime since that was not available previously.\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n---\n include/libcamera/internal/controls.h | 39 +++++++++++++++++++++++\n src/libcamera/controls.cpp            |  2 +-\n src/libcamera/pipeline_handler.cpp    | 45 +++++++++++++++++++++++++++\n 3 files changed, 85 insertions(+), 1 deletion(-)\n create mode 100644 include/libcamera/internal/controls.h","diff":"diff --git a/include/libcamera/internal/controls.h b/include/libcamera/internal/controls.h\nnew file mode 100644\nindex 0000000000..be3f93e43c\n--- /dev/null\n+++ b/include/libcamera/internal/controls.h\n@@ -0,0 +1,39 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2025, Ideas on Board Oy\n+ */\n+\n+#pragma once\n+\n+#include <libcamera/controls.h>\n+\n+namespace libcamera::controls::details {\n+\n+struct TypeInfo {\n+\tstd::size_t size = 0;\n+\tstd::size_t alignment = 0;\n+\n+\texplicit operator bool() const { return alignment != 0; }\n+\n+\tstatic constexpr TypeInfo get(ControlType t)\n+\t{\n+\t\tswitch (t) {\n+\t\tcase ControlTypeNone: return {};\n+\t\tcase ControlTypeBool: return { sizeof(bool), alignof(bool) };\n+\t\tcase ControlTypeByte: return { sizeof(uint8_t), alignof(uint8_t) };\n+\t\tcase ControlTypeUnsigned16: return { sizeof(uint16_t), alignof(uint16_t) };\n+\t\tcase ControlTypeUnsigned32: return { sizeof(uint32_t), alignof(uint32_t) };\n+\t\tcase ControlTypeInteger32: return { sizeof(int32_t), alignof(int32_t) };\n+\t\tcase ControlTypeInteger64: return { sizeof(int64_t), alignof(int64_t) };\n+\t\tcase ControlTypeFloat: return { sizeof(float), alignof(float) };\n+\t\tcase ControlTypeString: return { sizeof(char), alignof(char) };\n+\t\tcase ControlTypeRectangle: return { sizeof(Rectangle), alignof(Rectangle) };\n+\t\tcase ControlTypeSize: return { sizeof(Size), alignof(Size) };\n+\t\tcase ControlTypePoint: return { sizeof(Point), alignof(Point) };\n+\t\t}\n+\n+\t\treturn {};\n+\t}\n+};\n+\n+} /* libcamera::controls::details */\ndiff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex 222030c434..d51e6c882f 100644\n--- a/src/libcamera/controls.cpp\n+++ b/src/libcamera/controls.cpp\n@@ -17,7 +17,7 @@\n #include \"libcamera/internal/control_validator.h\"\n \n /**\n- * \\file controls.h\n+ * \\file libcamera/controls.h\n  * \\brief Framework to manage controls related to an object\n  *\n  * A control is a mean to govern or influence the operation of an object, and in\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex de98a93306..a3a37de873 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -16,11 +16,13 @@\n #include <libcamera/base/utils.h>\n \n #include <libcamera/camera.h>\n+#include <libcamera/control_ids.h>\n #include <libcamera/framebuffer.h>\n #include <libcamera/property_ids.h>\n \n #include \"libcamera/internal/camera.h\"\n #include \"libcamera/internal/camera_manager.h\"\n+#include \"libcamera/internal/controls.h\"\n #include \"libcamera/internal/device_enumerator.h\"\n #include \"libcamera/internal/media_device.h\"\n #include \"libcamera/internal/request.h\"\n@@ -755,6 +757,47 @@ std::string PipelineHandler::configurationFile(const std::string &subdir,\n \treturn std::string();\n }\n \n+namespace {\n+\n+/*\n+ * This is kind of hack. The metadata controls in the \"debug\" namespace\n+ * are forcefully injected into each Camera's MetadataListPlan so that\n+ * they work seamlessly without any additional setup.\n+ *\n+ * The dynamically-sized array-like controls have a maximum capacity\n+ * determined by the magic number below.\n+ */\n+void extendMetadataPlanWithDebugMetadata(MetadataListPlan& mlp)\n+{\n+\tconstexpr std::size_t kDynamicArrayCapacity = 32;\n+\n+\tfor (const auto &[id, ctrl] : controls::controls) {\n+\t\tif (!ctrl->isOutput())\n+\t\t\tcontinue;\n+\t\tif (ctrl->vendor() != \"debug\")\n+\t\t\tcontinue;\n+\t\tif (mlp.get(id))\n+\t\t\tcontinue;\n+\n+\t\tstd::size_t count = ctrl->size();\n+\t\tif (count == 0) /* Non-array controls have a static size of 0. */\n+\t\t\tcount = 1;\n+\t\telse if (ctrl->size() == libcamera::dynamic_extent)\n+\t\t\tcount = kDynamicArrayCapacity;\n+\n+\t\tconst auto info = controls::details::TypeInfo::get(ctrl->type());\n+\t\tif (!info)\n+\t\t\tcontinue;\n+\n+\t\t[[maybe_unused]] bool ok = mlp.set(id,\n+\t\t\t\t\t\t   info.size, info.alignment,\n+\t\t\t\t\t\t   count, ctrl->type(), ctrl->isArray());\n+\t\tASSERT(ok);\n+\t}\n+}\n+\n+} /* namespace */\n+\n /**\n  * \\brief Register a camera to the camera manager and pipeline handler\n  * \\param[in] camera The camera to be added\n@@ -800,6 +843,8 @@ void PipelineHandler::registerCamera(std::shared_ptr<Camera> camera)\n \tCamera::Private *data = camera->_d();\n \tdata->properties_.set(properties::SystemDevices, devnums);\n \n+\textendMetadataPlanWithDebugMetadata(data->metadataPlan_);\n+\n \tmanager_->_d()->addCamera(std::move(camera));\n }\n \n","prefixes":["RFC","v3","19/22"]}