From patchwork Wed Aug 6 12:30:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 24062 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 9F8EDBDCC1 for ; Wed, 6 Aug 2025 12:31:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0B9D66921B; Wed, 6 Aug 2025 14:31:05 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="LTddZYAc"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E610D6921B for ; Wed, 6 Aug 2025 14:31:00 +0200 (CEST) Received: from [192.168.0.172] (mob-5-90-59-79.net.vodafone.it [5.90.59.79]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 17DA3CF; Wed, 6 Aug 2025 14:30:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1754483412; bh=vSKqXi1EP2wo4ONMUCkZUR6ZmgF5KV06Oyc0Qqv09so=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=LTddZYAcX8gfURbsilGFLAZsUCQkXe+SYgQZ0dnAVLgJ5E7DyYTrZLAR4Eeeys66Y GEGqWHPfv92MUbutCgAt3UU2KB2uV80x4akkywxogCJrhZzSfNNF74hTIsD/AK2807 6CmUBalTTorBUIq+Id73orqTSjPVEGbwYUVHF5X0= From: Jacopo Mondi Date: Wed, 06 Aug 2025 14:30:46 +0200 Subject: [PATCH 2/3] libcamera: Rename ControlValue to ControlStorage MIME-Version: 1.0 Message-Id: <20250806-control_storage-v1-2-2ec8424f6f7d@ideasonboard.com> References: <20250806-control_storage-v1-0-2ec8424f6f7d@ideasonboard.com> In-Reply-To: <20250806-control_storage-v1-0-2ec8424f6f7d@ideasonboard.com> To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=64772; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=vSKqXi1EP2wo4ONMUCkZUR6ZmgF5KV06Oyc0Qqv09so=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBok0sCZK7jdTEc+HdjEqo4CiCnS2FrRrEgkUA5V wG3JqA0guGJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaJNLAgAKCRByNAaPFqFW PLSFD/9EbvaRHvco0E1CNF0G8w7tsoSYHmlfjcVRuKeMaumYb1FSb172hSTuoujuwCTKRyyZ8JS sQnaARSSafPne5dULmGeOfG0VxSv6fQ0P+dfnUdeWOGYtHd04Tw+z7FX+fbONUPVZ8Q5JQvDK+3 Eub1gWQ8GZLgapsemcklzHaAPNyOJifE+Nv2GwdpvkcKMk9obihgcB+4Z+ntNIwoa1p3EZcZcqL Ifgnry4RkAbUUBnmwWEP+3DPzLa0kKuzrT+bSU40vOa0BufOLoLbD4/r9jbCQRJ7L4U3A/wqzUd rj0ZK2S2WPGw2Y6/RmB6Uh0BJeOCcBaJjYkihXcmltZHBLYwUaGwr3m2aUj8CW107c4CwoI+Tct V+Pb7cdwersWbxM7zUyPExU5s+Ff+efbh04GOh8vj/kDBTOT8/DN13/gURYzoAXiiSh9e0LMgIi IoBP8LlvLHKmLEm9JYJcRhVqxlR6DN51n2SQcq4qYeg9b2UWpTxE1OAXwyM8TQSffFSxjyPdqZB JWQmo2uMKPaMTNRnxCxYdqP+zLatMUz4eWtVTsvxMutCeXBHv9vZn9r9d3M4h1t8zRj3aQtHVgM 1iTpJuT2BH5hRXQxOdB9uN7seCekID+ECUNPFZiXg8NWDgtFNNZorjaqYVCQP7VmbqB8dM+Wxis c18wAyERZqJnhHQ== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B 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" The ControlValue class in libcamera represents the storage location of the values a Control represents. When a ControlValue is constructed, assigned or set() the values received as parameters are mem-copied inside the storage space allocated inside the ControlValue. This implies that creating ControlValue effectively mem-copies a Control creating multiple storages from the same information. To prepare to use wherever possible the newly introduced ControlValueView in the libcamera API, rename the ControlValue to ControlStorage. Signed-off-by: Jacopo Mondi --- include/libcamera/control_ids.h.in | 2 +- include/libcamera/controls.h | 64 ++++---- include/libcamera/internal/control_serializer.h | 6 +- include/libcamera/internal/debug_controls.h | 2 +- include/libcamera/internal/delayed_controls.h | 6 +- src/apps/cam/capture_script.cpp | 16 +- src/apps/cam/capture_script.h | 8 +- src/gstreamer/gstlibcamera-controls.cpp.in | 4 +- src/ipa/libipa/agc_mean_luminance.cpp | 4 +- src/ipa/libipa/awb.cpp | 4 +- src/ipa/libipa/awb.h | 2 +- src/ipa/rkisp1/algorithms/agc.cpp | 16 +- src/ipa/rkisp1/algorithms/ccm.cpp | 6 +- src/ipa/rpi/common/ipa_base.cpp | 18 +-- src/ipa/rpi/pisp/pisp.cpp | 2 +- src/ipa/rpi/vc4/vc4.cpp | 20 +-- src/libcamera/control_ids.cpp.in | 2 +- src/libcamera/control_serializer.cpp | 18 +-- src/libcamera/controls.cpp | 162 ++++++++++----------- src/libcamera/debug_controls.cpp | 4 +- src/libcamera/ipa_controls.cpp | 2 +- src/libcamera/pipeline/ipu3/ipu3.cpp | 4 +- .../pipeline/rpi/common/delayed_controls.h | 6 +- .../pipeline/rpi/common/pipeline_base.cpp | 2 +- src/libcamera/pipeline/rpi/vc4/vc4.cpp | 4 +- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 12 +- src/libcamera/pipeline/virtual/config_parser.cpp | 2 +- src/libcamera/sensor/camera_sensor_legacy.cpp | 2 +- src/libcamera/sensor/camera_sensor_raw.cpp | 2 +- src/libcamera/v4l2_device.cpp | 12 +- src/py/libcamera/py_helpers.cpp | 22 +-- src/py/libcamera/py_helpers.h | 4 +- test/controls/control_value.cpp | 8 +- test/serialization/serialization_test.cpp | 8 +- 34 files changed, 228 insertions(+), 228 deletions(-) diff --git a/include/libcamera/control_ids.h.in b/include/libcamera/control_ids.h.in index 6b5712339a3a1633700cc4d9741ccb8d284cffbe..bd2cb0878a8158b7d0bf2e6070539fa06c11504e 100644 --- a/include/libcamera/control_ids.h.in +++ b/include/libcamera/control_ids.h.in @@ -45,7 +45,7 @@ enum {{ctrl.name}}Enum { {{enum.name}} = {{enum.value}}, {%- endfor %} }; -extern const std::array {{ctrl.name}}Values; +extern const std::array {{ctrl.name}}Values; extern const std::map {{ctrl.name}}NameValueMap; {% endif -%} extern const Control<{{ctrl.type}}> {{ctrl.name}}; diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 3b691804fce18909fccdb420c212413a97d33be7..8c531cca25538edadd08b8e1662227ba56065e40 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -132,17 +132,17 @@ struct control_type && sizeof(T) == sizeof } /* namespace details */ -class ControlValue +class ControlStorage { public: - ControlValue(); + ControlStorage(); #ifndef __DOXYGEN__ template::value && details::control_type::value && !std::is_same>::value, std::nullptr_t> = nullptr> - ControlValue(const T &value) + ControlStorage(const T &value) : type_(ControlTypeNone), numElements_(0) { set(details::control_type>::value, false, @@ -155,19 +155,19 @@ public: #else template #endif - ControlValue(const T &value) + ControlStorage(const T &value) : type_(ControlTypeNone), numElements_(0) { set(details::control_type>::value, true, value.data(), value.size(), sizeof(typename T::value_type)); } - explicit ControlValue(const ControlValueView &cvv); + explicit ControlStorage(const ControlValueView &cvv); - ~ControlValue(); + ~ControlStorage(); - ControlValue(const ControlValue &other); - ControlValue &operator=(const ControlValue &other); + ControlStorage(const ControlStorage &other); + ControlStorage &operator=(const ControlStorage &other); ControlType type() const { return type_; } bool isNone() const { return type_ == ControlTypeNone; } @@ -178,8 +178,8 @@ public: std::string toString() const; - bool operator==(const ControlValue &other) const; - bool operator!=(const ControlValue &other) const + bool operator==(const ControlStorage &other) const; + bool operator!=(const ControlStorage &other) const { return !(*this == other); } @@ -259,7 +259,7 @@ public: { } - ControlValueView(const ControlValue &cv) noexcept + ControlValueView(const ControlStorage &cv) noexcept : ControlValueView(cv.type(), cv.isArray(), cv.numElements(), reinterpret_cast(cv.data().data())) { @@ -397,18 +397,18 @@ private: class ControlInfo { public: - explicit ControlInfo(const ControlValue &min = {}, - const ControlValue &max = {}, - const ControlValue &def = {}); - explicit ControlInfo(Span values, - const ControlValue &def = {}); + explicit ControlInfo(const ControlStorage &min = {}, + const ControlStorage &max = {}, + const ControlStorage &def = {}); + explicit ControlInfo(Span values, + const ControlStorage &def = {}); explicit ControlInfo(std::set values, bool def); explicit ControlInfo(bool value); - const ControlValue &min() const { return min_; } - const ControlValue &max() const { return max_; } - const ControlValue &def() const { return def_; } - const std::vector &values() const { return values_; } + const ControlStorage &min() const { return min_; } + const ControlStorage &max() const { return max_; } + const ControlStorage &def() const { return def_; } + const std::vector &values() const { return values_; } std::string toString() const; @@ -423,10 +423,10 @@ public: } private: - ControlValue min_; - ControlValue max_; - ControlValue def_; - std::vector values_; + ControlStorage min_; + ControlStorage max_; + ControlStorage def_; + std::vector values_; }; using ControlIdMap = std::unordered_map; @@ -478,7 +478,7 @@ private: class ControlList { private: - using ControlListMap = std::unordered_map; + using ControlListMap = std::unordered_map; public: enum class MergePolicy { @@ -513,14 +513,14 @@ public: if (entry == controls_.end()) return std::nullopt; - const ControlValue &val = entry->second; + const ControlStorage &val = entry->second; return val.get(); } template void set(const Control &ctrl, const V &value) { - ControlValue *val = find(ctrl.id()); + ControlStorage *val = find(ctrl.id()); if (!val) return; @@ -530,22 +530,22 @@ public: template void set(const Control> &ctrl, const std::initializer_list &value) { - ControlValue *val = find(ctrl.id()); + ControlStorage *val = find(ctrl.id()); if (!val) return; val->set(Span, Size>{ value.begin(), value.size() }); } - const ControlValue &get(unsigned int id) const; - void set(unsigned int id, const ControlValue &value); + const ControlStorage &get(unsigned int id) const; + void set(unsigned int id, const ControlStorage &value); const ControlInfoMap *infoMap() const { return infoMap_; } const ControlIdMap *idMap() const { return idmap_; } private: - const ControlValue *find(unsigned int id) const; - ControlValue *find(unsigned int id); + const ControlStorage *find(unsigned int id) const; + ControlStorage *find(unsigned int id); const ControlValidator *validator_; const ControlIdMap *idmap_; diff --git a/include/libcamera/internal/control_serializer.h b/include/libcamera/internal/control_serializer.h index 8a63ae44a13ed6f9b8162d86eef96bbc5fa82b30..a63f8675e3076eddfdda8c7b684499237451596b 100644 --- a/include/libcamera/internal/control_serializer.h +++ b/include/libcamera/internal/control_serializer.h @@ -41,13 +41,13 @@ public: bool isCached(const ControlInfoMap &infoMap); private: - static size_t binarySize(const ControlValue &value); + static size_t binarySize(const ControlStorage &value); static size_t binarySize(const ControlInfo &info); - static void store(const ControlValue &value, ByteStreamBuffer &buffer); + static void store(const ControlStorage &value, ByteStreamBuffer &buffer); static void store(const ControlInfo &info, ByteStreamBuffer &buffer); - ControlValue loadControlValue(ByteStreamBuffer &buffer, + ControlStorage loadControlValue(ByteStreamBuffer &buffer, bool isArray = false, unsigned int count = 1); ControlInfo loadControlInfo(ByteStreamBuffer &buffer); diff --git a/include/libcamera/internal/debug_controls.h b/include/libcamera/internal/debug_controls.h index 0b049f48e246f0f857abbddfa25018e9dc3e58d1..efb5f5acb98ce39d933458e4f698029d68b9a531 100644 --- a/include/libcamera/internal/debug_controls.h +++ b/include/libcamera/internal/debug_controls.h @@ -35,7 +35,7 @@ public: cache_.set(ctrl, value); } - void set(unsigned int id, const ControlValue &value); + void set(unsigned int id, const ControlStorage &value); private: bool enabled_ = false; diff --git a/include/libcamera/internal/delayed_controls.h b/include/libcamera/internal/delayed_controls.h index b64d8bba7cf73e10491d13d64bb4b3f7db80681b..edb3ef8eba0a10fa2e083a8831ee820dac1628d2 100644 --- a/include/libcamera/internal/delayed_controls.h +++ b/include/libcamera/internal/delayed_controls.h @@ -37,7 +37,7 @@ public: void applyControls(uint32_t sequence); private: - class Info : public ControlValue + class Info : public ControlStorage { public: Info() @@ -45,8 +45,8 @@ private: { } - Info(const ControlValue &v, bool updated_ = true) - : ControlValue(v), updated(updated_) + Info(const ControlStorage &v, bool updated_ = true) + : ControlStorage(v), updated(updated_) { } diff --git a/src/apps/cam/capture_script.cpp b/src/apps/cam/capture_script.cpp index fdf82efc06332b5f04f1e8cd3071bd2ec75cddde..8f713cd3c4d70ec66aedb17a8515023f3e428aac 100644 --- a/src/apps/cam/capture_script.cpp +++ b/src/apps/cam/capture_script.cpp @@ -311,7 +311,7 @@ int CaptureScript::parseControl(EventPtr event, ControlList &controls) const ControlId *controlId = it->second; - ControlValue val = unpackControl(controlId); + ControlStorage val = unpackControl(controlId); if (val.isNone()) { std::cerr << "Error unpacking control '" << name << "'" << std::endl; @@ -332,7 +332,7 @@ std::string CaptureScript::parseScalar() return eventScalarValue(event); } -ControlValue CaptureScript::parseRectangles() +ControlStorage CaptureScript::parseRectangles() { std::vector rectangles; @@ -351,7 +351,7 @@ ControlValue CaptureScript::parseRectangles() rectangles.push_back(rect); } - ControlValue controlValue; + ControlStorage controlValue; if (rectangles.size() == 1) controlValue.set(rectangles.at(0)); else @@ -458,10 +458,10 @@ void CaptureScript::unpackFailure(const ControlId *id, const std::string &repr) << typeName << " control " << id->name() << std::endl; } -ControlValue CaptureScript::parseScalarControl(const ControlId *id, +ControlStorage CaptureScript::parseScalarControl(const ControlId *id, const std::string repr) { - ControlValue value{}; + ControlStorage value{}; switch (id->type()) { case ControlTypeNone: @@ -513,10 +513,10 @@ ControlValue CaptureScript::parseScalarControl(const ControlId *id, return value; } -ControlValue CaptureScript::parseArrayControl(const ControlId *id, +ControlStorage CaptureScript::parseArrayControl(const ControlId *id, const std::vector &repr) { - ControlValue value{}; + ControlStorage value{}; switch (id->type()) { case ControlTypeNone: @@ -586,7 +586,7 @@ ControlValue CaptureScript::parseArrayControl(const ControlId *id, return value; } -ControlValue CaptureScript::unpackControl(const ControlId *id) +ControlStorage CaptureScript::unpackControl(const ControlId *id) { /* Parse complex types. */ switch (id->type()) { diff --git a/src/apps/cam/capture_script.h b/src/apps/cam/capture_script.h index 294b920363bae01b55bd91343f94a71e31168b3b..8b7aeb1ca79f192d33e7f6a70a8a79494711fe37 100644 --- a/src/apps/cam/capture_script.h +++ b/src/apps/cam/capture_script.h @@ -56,18 +56,18 @@ private: int parseFrame(EventPtr event); int parseControl(EventPtr event, libcamera::ControlList &controls); - libcamera::ControlValue parseScalarControl(const libcamera::ControlId *id, + libcamera::ControlStorage parseScalarControl(const libcamera::ControlId *id, const std::string repr); - libcamera::ControlValue parseArrayControl(const libcamera::ControlId *id, + libcamera::ControlStorage parseArrayControl(const libcamera::ControlId *id, const std::vector &repr); std::string parseScalar(); - libcamera::ControlValue parseRectangles(); + libcamera::ControlStorage parseRectangles(); std::vector> parseArrays(); std::vector parseSingleArray(); void unpackFailure(const libcamera::ControlId *id, const std::string &repr); - libcamera::ControlValue unpackControl(const libcamera::ControlId *id); + libcamera::ControlStorage unpackControl(const libcamera::ControlId *id); libcamera::Rectangle unpackRectangle(const std::vector &strVec); }; diff --git a/src/gstreamer/gstlibcamera-controls.cpp.in b/src/gstreamer/gstlibcamera-controls.cpp.in index 2a16b39a93d95938022b38c57aab74efa10678cf..346bf83fac076c8fa7c7d6f8a9b281626849aaa1 100644 --- a/src/gstreamer/gstlibcamera-controls.cpp.in +++ b/src/gstreamer/gstlibcamera-controls.cpp.in @@ -159,7 +159,7 @@ bool GstCameraControls::getProperty(guint propId, GValue *value, controls::controls.at(propId)->name().c_str()); return true; } - const ControlValue &cv = controls_acc_.get(propId); + const ControlStorage &cv = controls_acc_.get(propId); switch (propId) { {%- for vendor, ctrls in controls %} @@ -296,7 +296,7 @@ void GstCameraControls::setCamera(const std::shared_ptr &cam) control != controls_acc_.end(); ++control) { unsigned int id = control->first; - ControlValue value = control->second; + ControlStorage value = control->second; const ControlId *cid = capabilities_.idmap().at(id); auto info = capabilities_.find(cid); diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp index ff96a381ffce9fe67a259a60e0382d61cf423bc6..29d679d7d3bdd4fbbb9b2759c5dff3ad70ca664c 100644 --- a/src/ipa/libipa/agc_mean_luminance.cpp +++ b/src/ipa/libipa/agc_mean_luminance.cpp @@ -186,7 +186,7 @@ void AgcMeanLuminance::parseConstraint(const YamlObject &modeDict, int32_t id) int AgcMeanLuminance::parseConstraintModes(const YamlObject &tuningData) { - std::vector availableConstraintModes; + std::vector availableConstraintModes; const YamlObject &yamlConstraintModes = tuningData[controls::AeConstraintMode.name()]; if (yamlConstraintModes.isDictionary()) { @@ -238,7 +238,7 @@ int AgcMeanLuminance::parseConstraintModes(const YamlObject &tuningData) int AgcMeanLuminance::parseExposureModes(const YamlObject &tuningData) { - std::vector availableExposureModes; + std::vector availableExposureModes; const YamlObject &yamlExposureModes = tuningData[controls::AeExposureMode.name()]; if (yamlExposureModes.isDictionary()) { diff --git a/src/ipa/libipa/awb.cpp b/src/ipa/libipa/awb.cpp index 214bac8b56a6ca7b0ac9954f0aa742cd613e6141..5e0defd8badbc9a559d8fe31f3e7080c982bde99 100644 --- a/src/ipa/libipa/awb.cpp +++ b/src/ipa/libipa/awb.cpp @@ -163,9 +163,9 @@ namespace ipa { * \return Zero on success, negative error code otherwise */ int AwbAlgorithm::parseModeConfigs(const YamlObject &tuningData, - const ControlValue &def) + const ControlStorage &def) { - std::vector availableModes; + std::vector availableModes; const YamlObject &yamlModes = tuningData[controls::AwbMode.name()]; if (!yamlModes.isDictionary()) { diff --git a/src/ipa/libipa/awb.h b/src/ipa/libipa/awb.h index f4a86038635f984ac03b1e466c0fcd4e6d5e22bd..8d126242859b4a9296ec412a2681537d73223118 100644 --- a/src/ipa/libipa/awb.h +++ b/src/ipa/libipa/awb.h @@ -51,7 +51,7 @@ public: protected: int parseModeConfigs(const YamlObject &tuningData, - const ControlValue &def = {}); + const ControlStorage &def = {}); struct ModeConfig { double ctHi; diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index 35440b67e999b7a307c9ca7cc32fffd6cafb168b..284f83f5256b2a275451f94a38d9142e422e7a1c 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -73,11 +73,11 @@ int Agc::parseMeteringModes(IPAContext &context, const YamlObject &tuningData) meteringModes_[controls::MeteringMatrix] = weights; } - std::vector meteringModes; + std::vector meteringModes; std::vector meteringModeKeys = utils::map_keys(meteringModes_); std::transform(meteringModeKeys.begin(), meteringModeKeys.end(), std::back_inserter(meteringModes), - [](int x) { return ControlValue(x); }); + [](int x) { return ControlStorage(x); }); context.ctrlMap[&controls::AeMeteringMode] = ControlInfo(meteringModes); return 0; @@ -148,13 +148,13 @@ int Agc::init(IPAContext &context, const YamlObject &tuningData) return ret; context.ctrlMap[&controls::ExposureTimeMode] = - ControlInfo({ { ControlValue(controls::ExposureTimeModeAuto), - ControlValue(controls::ExposureTimeModeManual) } }, - ControlValue(controls::ExposureTimeModeAuto)); + ControlInfo({ { ControlStorage(controls::ExposureTimeModeAuto), + ControlStorage(controls::ExposureTimeModeManual) } }, + ControlStorage(controls::ExposureTimeModeAuto)); context.ctrlMap[&controls::AnalogueGainMode] = - ControlInfo({ { ControlValue(controls::AnalogueGainModeAuto), - ControlValue(controls::AnalogueGainModeManual) } }, - ControlValue(controls::AnalogueGainModeAuto)); + ControlInfo({ { ControlStorage(controls::AnalogueGainModeAuto), + ControlStorage(controls::AnalogueGainModeManual) } }, + ControlStorage(controls::AnalogueGainModeAuto)); /* \todo Move this to the Camera class */ context.ctrlMap[&controls::AeEnable] = ControlInfo(false, true, true); context.ctrlMap[&controls::ExposureValue] = ControlInfo(-8.0f, 8.0f, 0.0f); diff --git a/src/ipa/rkisp1/algorithms/ccm.cpp b/src/ipa/rkisp1/algorithms/ccm.cpp index de2b6fe775aa7cb3a9a9d73f1c56ca58fde22e64..f709adad2bd85c88fc57aa801c60764dcb628b64 100644 --- a/src/ipa/rkisp1/algorithms/ccm.cpp +++ b/src/ipa/rkisp1/algorithms/ccm.cpp @@ -45,9 +45,9 @@ int Ccm::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData { auto &cmap = context.ctrlMap; cmap[&controls::ColourCorrectionMatrix] = ControlInfo( - ControlValue(-8.0f), - ControlValue(7.993f), - ControlValue(kIdentity3x3.data())); + ControlStorage(-8.0f), + ControlStorage(7.993f), + ControlStorage(kIdentity3x3.data())); int ret = ccm_.readYaml(tuningData["ccms"], "ct", "ccm"); if (ret < 0) { diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp index ce2343e91cdee92776f7d4a36de6d107c47ce0ac..532cc3f89463775943c389bd70b1cd9a491c2f53 100644 --- a/src/ipa/rpi/common/ipa_base.cpp +++ b/src/ipa/rpi/common/ipa_base.cpp @@ -58,24 +58,24 @@ const ControlInfoMap::Map ipaControls{ /* \todo Move this to the Camera class */ { &controls::AeEnable, ControlInfo(false, true, true) }, { &controls::ExposureTimeMode, - ControlInfo({ { ControlValue(controls::ExposureTimeModeAuto), - ControlValue(controls::ExposureTimeModeManual) } }, - ControlValue(controls::ExposureTimeModeAuto)) }, + ControlInfo({ { ControlStorage(controls::ExposureTimeModeAuto), + ControlStorage(controls::ExposureTimeModeManual) } }, + ControlStorage(controls::ExposureTimeModeAuto)) }, { &controls::ExposureTime, ControlInfo(1, 66666, static_cast(defaultExposureTime.get())) }, { &controls::AnalogueGainMode, - ControlInfo({ { ControlValue(controls::AnalogueGainModeAuto), - ControlValue(controls::AnalogueGainModeManual) } }, - ControlValue(controls::AnalogueGainModeAuto)) }, + ControlInfo({ { ControlStorage(controls::AnalogueGainModeAuto), + ControlStorage(controls::AnalogueGainModeManual) } }, + ControlStorage(controls::AnalogueGainModeAuto)) }, { &controls::AnalogueGain, ControlInfo(1.0f, 16.0f, 1.0f) }, { &controls::AeMeteringMode, ControlInfo(controls::AeMeteringModeValues) }, { &controls::AeConstraintMode, ControlInfo(controls::AeConstraintModeValues) }, { &controls::AeExposureMode, ControlInfo(controls::AeExposureModeValues) }, { &controls::ExposureValue, ControlInfo(-8.0f, 8.0f, 0.0f) }, { &controls::AeFlickerMode, - ControlInfo({ { ControlValue(controls::FlickerOff), - ControlValue(controls::FlickerManual) } }, - ControlValue(controls::FlickerOff)) }, + ControlInfo({ { ControlStorage(controls::FlickerOff), + ControlStorage(controls::FlickerManual) } }, + ControlStorage(controls::FlickerOff)) }, { &controls::AeFlickerPeriod, ControlInfo(100, 1000000) }, { &controls::Brightness, ControlInfo(-1.0f, 1.0f, 0.0f) }, { &controls::Contrast, ControlInfo(0.0f, 32.0f, 1.0f) }, diff --git a/src/ipa/rpi/pisp/pisp.cpp b/src/ipa/rpi/pisp/pisp.cpp index 829b912585223a0296a9709aca433d5240caea1b..e793998cbee506af437ebe283853ecc5e7fd3924 100644 --- a/src/ipa/rpi/pisp/pisp.cpp +++ b/src/ipa/rpi/pisp/pisp.cpp @@ -927,7 +927,7 @@ void IpaPiSP::applyFocusStats(const NoiseStatus *noiseStatus) void IpaPiSP::applyAF(const struct AfStatus *afStatus, ControlList &lensCtrls) { if (afStatus->lensSetting) { - ControlValue v(afStatus->lensSetting.value()); + ControlStorage v(afStatus->lensSetting.value()); lensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE, v); } } diff --git a/src/ipa/rpi/vc4/vc4.cpp b/src/ipa/rpi/vc4/vc4.cpp index b2fec934480487c0c0566d510afd7a72129e441c..250426a3bae2e3ec89349f73490c9d859bfeaaa0 100644 --- a/src/ipa/rpi/vc4/vc4.cpp +++ b/src/ipa/rpi/vc4/vc4.cpp @@ -369,7 +369,7 @@ void IpaVc4::applyCCM(const struct CcmStatus *ccmStatus, ControlList &ctrls) ccm.enabled = 1; ccm.ccm.offsets[0] = ccm.ccm.offsets[1] = ccm.ccm.offsets[2] = 0; - ControlValue c(Span{ reinterpret_cast(&ccm), + ControlStorage c(Span{ reinterpret_cast(&ccm), sizeof(ccm) }); ctrls.set(V4L2_CID_USER_BCM2835_ISP_CC_MATRIX, c); } @@ -383,7 +383,7 @@ void IpaVc4::applyBlackLevel(const struct BlackLevelStatus *blackLevelStatus, Co blackLevel.black_level_g = blackLevelStatus->blackLevelG; blackLevel.black_level_b = blackLevelStatus->blackLevelB; - ControlValue c(Span{ reinterpret_cast(&blackLevel), + ControlStorage c(Span{ reinterpret_cast(&blackLevel), sizeof(blackLevel) }); ctrls.set(V4L2_CID_USER_BCM2835_ISP_BLACK_LEVEL, c); } @@ -405,7 +405,7 @@ void IpaVc4::applyGamma(const struct ContrastStatus *contrastStatus, ControlList gamma.y[numGammaPoints - 1] = 65535; gamma.enabled = 1; - ControlValue c(Span{ reinterpret_cast(&gamma), + ControlStorage c(Span{ reinterpret_cast(&gamma), sizeof(gamma) }); ctrls.set(V4L2_CID_USER_BCM2835_ISP_GAMMA, c); } @@ -419,7 +419,7 @@ void IpaVc4::applyGEQ(const struct GeqStatus *geqStatus, ControlList &ctrls) geq.slope.den = 1000; geq.slope.num = 1000 * geqStatus->slope; - ControlValue c(Span{ reinterpret_cast(&geq), + ControlStorage c(Span{ reinterpret_cast(&geq), sizeof(geq) }); ctrls.set(V4L2_CID_USER_BCM2835_ISP_GEQ, c); } @@ -453,11 +453,11 @@ void IpaVc4::applyDenoise(const struct DenoiseStatus *denoiseStatus, ControlList cdn.enabled = 0; } - ControlValue c(Span{ reinterpret_cast(&denoise), + ControlStorage c(Span{ reinterpret_cast(&denoise), sizeof(denoise) }); ctrls.set(V4L2_CID_USER_BCM2835_ISP_DENOISE, c); - c = ControlValue(Span{ reinterpret_cast(&cdn), + c = ControlStorage(Span{ reinterpret_cast(&cdn), sizeof(cdn) }); ctrls.set(V4L2_CID_USER_BCM2835_ISP_CDN, c); } @@ -474,7 +474,7 @@ void IpaVc4::applySharpen(const struct SharpenStatus *sharpenStatus, ControlList sharpen.limit.num = 1000 * sharpenStatus->limit; sharpen.limit.den = 1000; - ControlValue c(Span{ reinterpret_cast(&sharpen), + ControlStorage c(Span{ reinterpret_cast(&sharpen), sizeof(sharpen) }); ctrls.set(V4L2_CID_USER_BCM2835_ISP_SHARPEN, c); } @@ -486,7 +486,7 @@ void IpaVc4::applyDPC(const struct DpcStatus *dpcStatus, ControlList &ctrls) dpc.enabled = 1; dpc.strength = dpcStatus->strength; - ControlValue c(Span{ reinterpret_cast(&dpc), + ControlStorage c(Span{ reinterpret_cast(&dpc), sizeof(dpc) }); ctrls.set(V4L2_CID_USER_BCM2835_ISP_DPC, c); } @@ -543,7 +543,7 @@ void IpaVc4::applyLS(const struct AlscStatus *lsStatus, ControlList &ctrls) resampleTable(grid + 3 * w * h, lsStatus->b, w, h); } - ControlValue c(Span{ reinterpret_cast(&ls), + ControlStorage c(Span{ reinterpret_cast(&ls), sizeof(ls) }); ctrls.set(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING, c); } @@ -551,7 +551,7 @@ void IpaVc4::applyLS(const struct AlscStatus *lsStatus, ControlList &ctrls) void IpaVc4::applyAF(const struct AfStatus *afStatus, ControlList &lensCtrls) { if (afStatus->lensSetting) { - ControlValue v(afStatus->lensSetting.value()); + ControlStorage v(afStatus->lensSetting.value()); lensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE, v); } } diff --git a/src/libcamera/control_ids.cpp.in b/src/libcamera/control_ids.cpp.in index 65668d486dbc1be5f8af241dc6dc2f6d963bd29c..dcfd8ba240189dcc52e36d3d567fde13ae374dd4 100644 --- a/src/libcamera/control_ids.cpp.in +++ b/src/libcamera/control_ids.cpp.in @@ -79,7 +79,7 @@ namespace {{vendor}} { {%- for ctrl in ctrls %} {% if ctrl.is_enum -%} -extern const std::array {{ctrl.name}}Values = { +extern const std::array {{ctrl.name}}Values = { {%- for enum in ctrl.enum_values %} static_cast<{{ctrl.type}}>({{enum.name}}), {%- endfor %} diff --git a/src/libcamera/control_serializer.cpp b/src/libcamera/control_serializer.cpp index 050f8512bd5285609da6cc12a989e1ea1bac418d..df8bcd8a938c6fd3db252ae56673483fa9923b7d 100644 --- a/src/libcamera/control_serializer.cpp +++ b/src/libcamera/control_serializer.cpp @@ -36,7 +36,7 @@ LOG_DEFINE_CATEGORY(Serializer) * \brief Serializer and deserializer for control-related classes * * The control serializer is a helper to serialize and deserialize - * ControlInfoMap and ControlValue instances for the purpose of communication + * ControlInfoMap and ControlStorage instances for the purpose of communication * with IPA modules. * * Neither the ControlInfoMap nor the ControlList are self-contained data @@ -142,7 +142,7 @@ void ControlSerializer::reset() controlIdMaps_.clear(); } -size_t ControlSerializer::binarySize(const ControlValue &value) +size_t ControlSerializer::binarySize(const ControlStorage &value) { return sizeof(ControlType) + value.data().size_bytes(); } @@ -192,7 +192,7 @@ size_t ControlSerializer::binarySize(const ControlList &list) return size; } -void ControlSerializer::store(const ControlValue &value, +void ControlSerializer::store(const ControlStorage &value, ByteStreamBuffer &buffer) { const ControlType type = value.type(); @@ -363,7 +363,7 @@ int ControlSerializer::serialize(const ControlList &list, /* Serialize all entries. */ for (const auto &ctrl : list) { unsigned int id = ctrl.first; - const ControlValue &value = ctrl.second; + const ControlStorage &value = ctrl.second; struct ipa_control_value_entry entry; entry.id = id; @@ -382,14 +382,14 @@ int ControlSerializer::serialize(const ControlList &list, return 0; } -ControlValue ControlSerializer::loadControlValue(ByteStreamBuffer &buffer, +ControlStorage ControlSerializer::loadControlValue(ByteStreamBuffer &buffer, bool isArray, unsigned int count) { ControlType type; buffer.read(&type); - ControlValue value; + ControlStorage value; value.reserve(type, isArray, count); buffer.read(value.data()); @@ -399,9 +399,9 @@ ControlValue ControlSerializer::loadControlValue(ByteStreamBuffer &buffer, ControlInfo ControlSerializer::loadControlInfo(ByteStreamBuffer &b) { - ControlValue min = loadControlValue(b); - ControlValue max = loadControlValue(b); - ControlValue def = loadControlValue(b); + ControlStorage min = loadControlValue(b); + ControlStorage max = loadControlValue(b); + ControlStorage def = loadControlValue(b); return ControlInfo(min, max, def); } diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index a238141a5c34856242bed7f76e938e706d49f1ff..cdc4f12d1048d58c558feaa8a17b25814d2dae13 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -91,44 +91,44 @@ static constexpr size_t ControlValueSize[] = { */ /** - * \class ControlValue + * \class ControlStorage * \brief Abstract type representing the value of a control */ -/** \todo Revisit the ControlValue layout when stabilizing the ABI */ -static_assert(sizeof(ControlValue) == 16, "Invalid size of ControlValue class"); +/** \todo Revisit the ControlStorage layout when stabilizing the ABI */ +static_assert(sizeof(ControlStorage) == 16, "Invalid size of ControlStorage class"); /** - * \brief Construct an empty ControlValue. + * \brief Construct an empty ControlStorage */ -ControlValue::ControlValue() +ControlStorage::ControlStorage() : type_(ControlTypeNone), isArray_(false), numElements_(0) { } /** - * \brief Construct a ControlValue from a ControlValueView + * \brief Construct a ControlStorage from a ControlValueView */ -ControlValue::ControlValue(const ControlValueView &cvv) - : ControlValue() +ControlStorage::ControlStorage(const ControlValueView &cvv) + : ControlStorage() { set(cvv.type(), cvv.isArray(), cvv.data().data(), cvv.numElements(), ControlValueSize[cvv.type()]); } /** - * \fn template T ControlValue::ControlValue(const T &value) - * \brief Construct a ControlValue of type T + * \fn template T ControlStorage::ControlStorage(const T &value) + * \brief Construct a ControlStorage of type T * \param[in] value Initial value * - * This function constructs a new instance of ControlValue and stores the \a + * This function constructs a new instance of ControlStorage and stores the \a * value inside it. If the type \a T is equivalent to Span, the instance * stores an array of values of type \a R. Otherwise the instance stores a * single value of type \a T. The numElements() and type() are updated to * reflect the stored value. */ -void ControlValue::release() +void ControlStorage::release() { std::size_t size = numElements_ * ControlValueSize[type_]; @@ -138,28 +138,28 @@ void ControlValue::release() } } -ControlValue::~ControlValue() +ControlStorage::~ControlStorage() { release(); } /** - * \brief Construct a ControlValue with the content of \a other - * \param[in] other The ControlValue to copy content from + * \brief Construct a ControlStorage with the content of \a other + * \param[in] other The ControlStorage to copy content from */ -ControlValue::ControlValue(const ControlValue &other) +ControlStorage::ControlStorage(const ControlStorage &other) : type_(ControlTypeNone), numElements_(0) { *this = other; } /** - * \brief Replace the content of the ControlValue with a copy of the content + * \brief Replace the content of the ControlStorage with a copy of the content * of \a other - * \param[in] other The ControlValue to copy content from - * \return The ControlValue with its content replaced with the one of \a other + * \param[in] other The ControlStorage to copy content from + * \return The ControlStorage with its content replaced with the one of \a other */ -ControlValue &ControlValue::operator=(const ControlValue &other) +ControlStorage &ControlStorage::operator=(const ControlStorage &other) { set(other.type_, other.isArray_, other.data().data(), other.numElements_, ControlValueSize[other.type_]); @@ -167,39 +167,39 @@ ControlValue &ControlValue::operator=(const ControlValue &other) } /** - * \fn ControlValue::type() + * \fn ControlStorage::type() * \brief Retrieve the data type of the value * \return The value data type */ /** - * \fn ControlValue::isNone() + * \fn ControlStorage::isNone() * \brief Determine if the value is not initialised * \return True if the value type is ControlTypeNone, false otherwise */ /** - * \fn ControlValue::isArray() + * \fn ControlStorage::isArray() * \brief Determine if the value stores an array * \return True if the value stores an array, false otherwise */ /** - * \fn ControlValue::numElements() - * \brief Retrieve the number of elements stored in the ControlValue + * \fn ControlStorage::numElements() + * \brief Retrieve the number of elements stored in the ControlStorage * * For instances storing an array, this function returns the number of elements * in the array. For instances storing a string, it returns the length of the * string, not counting the terminating '\0'. Otherwise, it returns 1. * - * \return The number of elements stored in the ControlValue + * \return The number of elements stored in the ControlStorage */ /** * \brief Retrieve the raw data of a control value * \return The raw data of the control value as a span of uint8_t */ -Span ControlValue::data() const +Span ControlStorage::data() const { std::size_t size = numElements_ * ControlValueSize[type_]; const uint8_t *data = size > sizeof(value_) @@ -209,28 +209,28 @@ Span ControlValue::data() const } /** - * \copydoc ControlValue::data() const + * \copydoc ControlStorage::data() const */ -Span ControlValue::data() +Span ControlStorage::data() { - Span data = const_cast(this)->data(); + Span data = const_cast(this)->data(); return { const_cast(data.data()), data.size() }; } /** * \brief Assemble and return a string describing the value - * \return A string describing the ControlValue + * \return A string describing the ControlStorage */ -std::string ControlValue::toString() const +std::string ControlStorage::toString() const { return static_cast(std::ostringstream{} << ControlValueView(*this)).str(); } /** - * \brief Compare ControlValue instances for equality + * \brief Compare ControlStorage instances for equality * \return True if the values have identical types and values, false otherwise */ -bool ControlValue::operator==(const ControlValue &other) const +bool ControlStorage::operator==(const ControlStorage &other) const { if (type_ != other.type_) return false; @@ -245,22 +245,22 @@ bool ControlValue::operator==(const ControlValue &other) const } /** - * \fn bool ControlValue::operator!=() - * \brief Compare ControlValue instances for non equality + * \fn bool ControlStorage::operator!=() + * \brief Compare ControlStorage instances for non equality * \return False if the values have identical types and values, true otherwise */ /** - * \fn template T ControlValue::get() const + * \fn template T ControlStorage::get() const * \brief Get the control value * * This function returns the contained value as an instance of \a T. If the - * ControlValue instance stores a single value, the type \a T shall match the + * ControlStorage instance stores a single value, the type \a T shall match the * stored value type(). If the instance stores an array of values, the type * \a T should be equal to Span, and the type \a R shall match the * stored value type(). The behaviour is undefined otherwise. * - * Note that a ControlValue instance that stores a non-array value is not + * Note that a ControlStorage instance that stores a non-array value is not * equivalent to an instance that stores an array value containing a single * element. The latter shall be accessed through a Span type, while * the former shall be accessed through a type \a T corresponding to type(). @@ -269,7 +269,7 @@ bool ControlValue::operator==(const ControlValue &other) const */ /** - * \fn template void ControlValue::set(const T &value) + * \fn template void ControlStorage::set(const T &value) * \brief Set the control value to \a value * \param[in] value The control value * @@ -283,14 +283,14 @@ bool ControlValue::operator==(const ControlValue &other) const * operation for Span<> values that refer to large arrays. */ -void ControlValue::set(ControlType type, bool isArray, const void *data, +void ControlStorage::set(ControlType type, bool isArray, const void *data, std::size_t numElements, std::size_t elementSize) { ASSERT(elementSize == ControlValueSize[type]); reserve(type, isArray, numElements); - Span storage = ControlValue::data(); + Span storage = ControlStorage::data(); memcpy(storage.data(), data, storage.size()); } @@ -306,7 +306,7 @@ void ControlValue::set(ControlType type, bool isArray, const void *data, * Otherwise the instance becomes a simple control, numElements is ignored, and * storage for the single element is reserved. */ -void ControlValue::reserve(ControlType type, bool isArray, std::size_t numElements) +void ControlStorage::reserve(ControlType type, bool isArray, std::size_t numElements) { if (!isArray) numElements = 1; @@ -336,17 +336,17 @@ void ControlValue::reserve(ControlType type, bool isArray, std::size_t numElemen /** * \fn ControlValueView::ControlValueView() * \brief Construct an empty view - * \sa ControlValue::ControlValue() + * \sa ControlStorage::ControlStorage() */ /** - * \fn ControlValueView::ControlValueView(const ControlValue &v) + * \fn ControlValueView::ControlValueView(const ControlStorage &v) * \brief Construct a view referring to \a v * * The constructed view will refer to the value stored by \a v, and * thus \a v must not be modified or destroyed before the view. * - * \sa ControlValue::ControlValue() + * \sa ControlStorage::ControlStorage() */ /** @@ -357,31 +357,31 @@ void ControlValue::reserve(ControlType type, bool isArray, std::size_t numElemen /** * \fn ControlType ControlValueView::type() const - * \copydoc ControlValue::type() - * \sa ControlValue::type() + * \copydoc ControlStorage::type() + * \sa ControlStorage::type() */ /** * \fn ControlValueView::isNone() const - * \copydoc ControlValue::isNone() - * \sa ControlValue::isNone() + * \copydoc ControlStorage::isNone() + * \sa ControlStorage::isNone() */ /** * \fn ControlValueView::isArray() const - * \copydoc ControlValue::isArray() - * \sa ControlValue::isArray() + * \copydoc ControlStorage::isArray() + * \sa ControlStorage::isArray() */ /** * \fn ControlValueView::numElements() const - * \copydoc ControlValue::numElements() - * \sa ControlValue::numElements() + * \copydoc ControlStorage::numElements() + * \sa ControlStorage::numElements() */ /** - * \copydoc ControlValue::data() - * \sa ControlValue::data() + * \copydoc ControlStorage::data() + * \sa ControlStorage::data() */ Span ControlValueView::data() const { @@ -389,8 +389,8 @@ Span ControlValueView::data() const } /** - * \copydoc ControlValue::operator==() - * \sa ControlValue::operator==() + * \copydoc ControlStorage::operator==() + * \sa ControlStorage::operator==() * \sa ControlValueView::operator!=() */ bool ControlValueView::operator==(const ControlValueView &other) const @@ -411,20 +411,20 @@ bool ControlValueView::operator==(const ControlValueView &other) const /** * \fn ControlValueView::operator!=() const - * \copydoc ControlValue::operator!=() - * \sa ControlValue::operator!=() + * \copydoc ControlStorage::operator!=() + * \sa ControlStorage::operator!=() * \sa ControlValueView::operator==() */ /** * \fn template T ControlValueView::get() const - * \copydoc ControlValue::get() - * \sa ControlValue::get() + * \copydoc ControlStorage::get() + * \sa ControlStorage::get() */ /** * \brief Insert a text representation of a value into an output stream - * \sa ControlValue::toString() + * \sa ControlStorage::toString() */ std::ostream &operator<<(std::ostream &s, const ControlValueView &v) { @@ -713,9 +713,9 @@ ControlId::ControlId(unsigned int id, const std::string &name, * \param[in] max The control maximum value * \param[in] def The control default value */ -ControlInfo::ControlInfo(const ControlValue &min, - const ControlValue &max, - const ControlValue &def) +ControlInfo::ControlInfo(const ControlStorage &min, + const ControlStorage &max, + const ControlStorage &def) : min_(min), max_(max), def_(def) { } @@ -730,15 +730,15 @@ ControlInfo::ControlInfo(const ControlValue &min, * values list respectively. The default value is set to \a def if provided, or * to the minimum value otherwise. */ -ControlInfo::ControlInfo(Span values, - const ControlValue &def) +ControlInfo::ControlInfo(Span values, + const ControlStorage &def) { min_ = values.front(); max_ = values.back(); def_ = !def.isNone() ? def : values.front(); values_.reserve(values.size()); - for (const ControlValue &value : values) + for (const ControlStorage &value : values) values_.push_back(value); } @@ -779,7 +779,7 @@ ControlInfo::ControlInfo(bool value) * the terminating '\0'. For all other control types, this is the minimum value * of each element. * - * \return A ControlValue with the minimum value for the control + * \return A ControlStorage with the minimum value for the control */ /** @@ -790,13 +790,13 @@ ControlInfo::ControlInfo(bool value) * the terminating '\0'. For all other control types, this is the maximum value * of each element. * - * \return A ControlValue with the maximum value for the control + * \return A ControlStorage with the maximum value for the control */ /** * \fn ControlInfo::def() * \brief Retrieve the default value of the control - * \return A ControlValue with the default value for the control + * \return A ControlStorage with the default value for the control */ /** @@ -804,10 +804,10 @@ ControlInfo::ControlInfo(bool value) * \brief Retrieve the list of valid values * * For controls that support a pre-defined number of values, the enumeration of - * those is reported through a vector of ControlValue instances accessible with + * those is reported through a vector of ControlStorage instances accessible with * this function. * - * \return A vector of ControlValue representing the control valid values + * \return A vector of ControlStorage representing the control valid values */ /** @@ -1234,11 +1234,11 @@ bool ControlList::contains(unsigned int id) const * * \return The control value */ -const ControlValue &ControlList::get(unsigned int id) const +const ControlStorage &ControlList::get(unsigned int id) const { - static const ControlValue zero; + static const ControlStorage zero; - const ControlValue *val = find(id); + const ControlStorage *val = find(id); if (!val) return zero; @@ -1257,9 +1257,9 @@ const ControlValue &ControlList::get(unsigned int id) const * The behaviour is undefined if the control \a id is not supported by the * object that the list refers to. */ -void ControlList::set(unsigned int id, const ControlValue &value) +void ControlList::set(unsigned int id, const ControlStorage &value) { - ControlValue *val = find(id); + ControlStorage *val = find(id); if (!val) return; @@ -1284,7 +1284,7 @@ void ControlList::set(unsigned int id, const ControlValue &value) * nullptr is returned in that case. */ -const ControlValue *ControlList::find(unsigned int id) const +const ControlStorage *ControlList::find(unsigned int id) const { const auto iter = controls_.find(id); if (iter == controls_.end()) { @@ -1297,7 +1297,7 @@ const ControlValue *ControlList::find(unsigned int id) const return &iter->second; } -ControlValue *ControlList::find(unsigned int id) +ControlStorage *ControlList::find(unsigned int id) { if (validator_ && !validator_->validate(id)) { LOG(Controls, Error) diff --git a/src/libcamera/debug_controls.cpp b/src/libcamera/debug_controls.cpp index 339602313facbb14f408d38f3998d9bfc80b1dea..d5046a221c3b201e9cc59a27ea8d3f40bf045167 100644 --- a/src/libcamera/debug_controls.cpp +++ b/src/libcamera/debug_controls.cpp @@ -138,7 +138,7 @@ void DebugMetadata::moveEntries(ControlList &list) */ /** - * \fn DebugMetadata::set(unsigned int id, const ControlValue &value) + * \fn DebugMetadata::set(unsigned int id, const ControlStorage &value) * \brief Set the value of control \a id to \a value * \param[in] id The id of the control * \param[in] value The control value @@ -148,7 +148,7 @@ void DebugMetadata::moveEntries(ControlList &list) * * \sa enable() */ -void DebugMetadata::set(unsigned int id, const ControlValue &value) +void DebugMetadata::set(unsigned int id, const ControlStorage &value) { if (parent_) { parent_->set(id, value); diff --git a/src/libcamera/ipa_controls.cpp b/src/libcamera/ipa_controls.cpp index 12d92ebe894d6616733bf45035cf2838065123d9..e9d655b35e0cc82450499fc8eedf8f47002f76da 100644 --- a/src/libcamera/ipa_controls.cpp +++ b/src/libcamera/ipa_controls.cpp @@ -191,7 +191,7 @@ static_assert(sizeof(ipa_controls_header) == 32, /** * \struct ipa_control_value_entry - * \brief Description of a serialized ControlValue entry + * \brief Description of a serialized ControlStorage entry * \var ipa_control_value_entry::id * The numerical ID of the control * \var ipa_control_value_entry::type diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index e31e3879dcc9f59425aac18c81492c9f68b4642b..2e7b9f094621d2f39198fc966fb5d4d42928027a 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -955,7 +955,7 @@ int PipelineHandlerIPU3::updateControls(IPU3CameraData *data) const std::vector &testPatternModes = sensor->testPatternModes(); if (!testPatternModes.empty()) { - std::vector values; + std::vector values; values.reserve(testPatternModes.size()); for (auto pattern : testPatternModes) @@ -1209,7 +1209,7 @@ void IPU3CameraData::setSensorControls([[maybe_unused]] unsigned int id, if (!lensControls.contains(V4L2_CID_FOCUS_ABSOLUTE)) return; - const ControlValue &focusValue = lensControls.get(V4L2_CID_FOCUS_ABSOLUTE); + const ControlStorage &focusValue = lensControls.get(V4L2_CID_FOCUS_ABSOLUTE); focusLens->setFocusPosition(focusValue.get()); } diff --git a/src/libcamera/pipeline/rpi/common/delayed_controls.h b/src/libcamera/pipeline/rpi/common/delayed_controls.h index 487b0057b2f58e6ec1506fb5bc17fa42aa52daca..2d5fa6678b507b54c7d28466ebb48f63fa33635b 100644 --- a/src/libcamera/pipeline/rpi/common/delayed_controls.h +++ b/src/libcamera/pipeline/rpi/common/delayed_controls.h @@ -40,7 +40,7 @@ public: void applyControls(uint32_t sequence); private: - class Info : public ControlValue + class Info : public ControlStorage { public: Info() @@ -48,8 +48,8 @@ private: { } - Info(const ControlValue &v, bool updated_ = true) - : ControlValue(v), updated(updated_) + Info(const ControlStorage &v, bool updated_ = true) + : ControlStorage(v), updated(updated_) { } diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index 563df198e6e45698115bfe6c3c84279f6672771d..2999b71afa643dee15c304737b0d64f6c0382af9 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -1250,7 +1250,7 @@ void CameraData::setLensControls(const ControlList &controls) CameraLens *lens = sensor_->focusLens(); if (lens && controls.contains(V4L2_CID_FOCUS_ABSOLUTE)) { - ControlValue const &focusValue = controls.get(V4L2_CID_FOCUS_ABSOLUTE); + ControlStorage const &focusValue = controls.get(V4L2_CID_FOCUS_ABSOLUTE); lens->setFocusPosition(focusValue.get()); } } diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp index 99d43bd0a2f544039f8634fc2d6493d88c04a20c..3cfc8497455d56c9b3f42f3292c97e58381aca6d 100644 --- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp +++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp @@ -886,8 +886,8 @@ void Vc4CameraData::setIspControls(const ControlList &controls) ControlList ctrls = controls; if (ctrls.contains(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING)) { - ControlValue &value = - const_cast(ctrls.get(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING)); + ControlStorage &value = + const_cast(ctrls.get(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING)); Span s = value.data(); bcm2835_isp_lens_shading *ls = reinterpret_cast(s.data()); diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index 4b5816dfdde08c44f23f5b0ea55de228a59c39d8..627aa69be294d89f796cfac148c315b29d6de633 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -99,7 +99,7 @@ public: private: int processControl(const UVCCameraData *data, ControlList *controls, - unsigned int id, const ControlValue &value); + unsigned int id, const ControlStorage &value); int processControls(UVCCameraData *data, const ControlList &reqControls); bool acquireDevice(Camera *camera) override; @@ -322,7 +322,7 @@ void PipelineHandlerUVC::stopDevice(Camera *camera) } int PipelineHandlerUVC::processControl(const UVCCameraData *data, ControlList *controls, - unsigned int id, const ControlValue &value) + unsigned int id, const ControlStorage &value) { uint32_t cid; @@ -721,7 +721,7 @@ void UVCCameraData::addControl(uint32_t cid, const ControlInfo &v4l2Info, } /* Map the control info. */ - const std::vector &v4l2Values = v4l2Info.values(); + const std::vector &v4l2Values = v4l2Info.values(); int32_t min = v4l2Info.min().get(); int32_t max = v4l2Info.max().get(); int32_t def = v4l2Info.def().get(); @@ -793,7 +793,7 @@ void UVCCameraData::addControl(uint32_t cid, const ControlInfo &v4l2Info, > exposureModes; std::optional lcDef; - for (const ControlValue &value : v4l2Values) { + for (const ControlStorage &value : v4l2Values) { const auto x = value.get(); if (0 <= x && static_cast(x) < exposureModes.size()) { @@ -814,7 +814,7 @@ void UVCCameraData::addControl(uint32_t cid, const ControlInfo &v4l2Info, else if (exposureModes[V4L2_EXPOSURE_MANUAL]) manualExposureMode_ = V4L2_EXPOSURE_MANUAL; - std::array values; + std::array values; std::size_t count = 0; if (autoExposureMode_) @@ -827,7 +827,7 @@ void UVCCameraData::addControl(uint32_t cid, const ControlInfo &v4l2Info, return; info = ControlInfo{ - Span{ values.data(), count }, + Span{ values.data(), count }, !lcDef ? values.front() : *lcDef, }; break; diff --git a/src/libcamera/pipeline/virtual/config_parser.cpp b/src/libcamera/pipeline/virtual/config_parser.cpp index 1d3d9ba87ec0991c5a1bd08d3a177a320cd4c182..47448533f98e38dcdd517446f2cb0a4563a52c8d 100644 --- a/src/libcamera/pipeline/virtual/config_parser.cpp +++ b/src/libcamera/pipeline/virtual/config_parser.cpp @@ -59,7 +59,7 @@ ConfigParser::parseConfigFile(File &file, PipelineHandler *pipe) ControlInfo(1000000 / data->config_.resolutions[0].frameRates[1], 1000000 / data->config_.resolutions[0].frameRates[0]); - std::vector supportedFaceDetectModes{ + std::vector supportedFaceDetectModes{ static_cast(controls::draft::FaceDetectModeOff), }; controls[&controls::draft::FaceDetectMode] = ControlInfo(supportedFaceDetectModes); diff --git a/src/libcamera/sensor/camera_sensor_legacy.cpp b/src/libcamera/sensor/camera_sensor_legacy.cpp index ba0a5c331d066a4010400620715234729705c349..366a66880ff0525b8198acccdaca946da538faad 100644 --- a/src/libcamera/sensor/camera_sensor_legacy.cpp +++ b/src/libcamera/sensor/camera_sensor_legacy.cpp @@ -538,7 +538,7 @@ void CameraSensorLegacy::initTestPatternModes() for (const auto &it : testPatternModes) indexToTestPatternMode[it.second] = it.first; - for (const ControlValue &value : v4l2TestPattern->second.values()) { + for (const ControlStorage &value : v4l2TestPattern->second.values()) { const int32_t index = value.get(); const auto it = indexToTestPatternMode.find(index); diff --git a/src/libcamera/sensor/camera_sensor_raw.cpp b/src/libcamera/sensor/camera_sensor_raw.cpp index f9aef054e6779fe122b5a83d32eee1678904608d..fc41ee1b71c360c7e1b2ac1aed15a44c277ad7a1 100644 --- a/src/libcamera/sensor/camera_sensor_raw.cpp +++ b/src/libcamera/sensor/camera_sensor_raw.cpp @@ -720,7 +720,7 @@ void CameraSensorRaw::initTestPatternModes() for (const auto &it : testPatternModes) indexToTestPatternMode[it.second] = it.first; - for (const ControlValue &value : v4l2TestPattern->second.values()) { + for (const ControlStorage &value : v4l2TestPattern->second.values()) { const int32_t index = value.get(); const auto it = indexToTestPatternMode.find(index); diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 0db92c19ca4a5f1d0e4b4f4973f36a98e6401ec5..9be9df78416d8a5a4c6891b2926fcea41f808233 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -205,7 +205,7 @@ ControlList V4L2Device::getControls(const std::vector &ids) if (info.flags & V4L2_CTRL_FLAG_HAS_PAYLOAD) { ControlType type; - ControlValue &value = ctrl.second; + ControlStorage &value = ctrl.second; Span data; switch (info.type) { @@ -312,7 +312,7 @@ int V4L2Device::setControls(ControlList *ctrls) v4l2Ctrl.id = id; /* Set the v4l2_ext_control value for the write operation. */ - ControlValue &value = ctrl->second; + ControlStorage &value = ctrl->second; switch (iter->first->type()) { case ControlTypeUnsigned16: { if (value.isArray()) { @@ -652,7 +652,7 @@ std::optional V4L2Device::v4l2ControlInfo(const v4l2_query_ext_ctrl */ std::optional V4L2Device::v4l2MenuControlInfo(const struct v4l2_query_ext_ctrl &ctrl) { - std::vector indices; + std::vector indices; struct v4l2_querymenu menu = {}; menu.id = ctrl.id; @@ -676,7 +676,7 @@ std::optional V4L2Device::v4l2MenuControlInfo(const struct v4l2_que return std::nullopt; return ControlInfo(indices, - ControlValue(static_cast(ctrl.default_value))); + ControlStorage(static_cast(ctrl.default_value))); } /* @@ -790,11 +790,11 @@ void V4L2Device::updateControls(ControlList *ctrls, for (const v4l2_ext_control &v4l2Ctrl : v4l2Ctrls) { const unsigned int id = v4l2Ctrl.id; - ControlValue value = ctrls->get(id); + ControlStorage value = ctrls->get(id); if (value.isArray()) { /* * No action required, the VIDIOC_[GS]_EXT_CTRLS ioctl - * accessed the ControlValue storage directly for array + * accessed the ControlStorage storage directly for array * controls. */ continue; diff --git a/src/py/libcamera/py_helpers.cpp b/src/py/libcamera/py_helpers.cpp index 1ad1d4c1a1cd45d50d0a731a4d69b14998b613f2..75283396b1dca7b5e16695e11630496cf1104e3a 100644 --- a/src/py/libcamera/py_helpers.cpp +++ b/src/py/libcamera/py_helpers.cpp @@ -16,7 +16,7 @@ namespace py = pybind11; using namespace libcamera; template -static py::object valueOrTuple(const ControlValue &cv) +static py::object valueOrTuple(const ControlStorage &cv) { if (cv.isArray()) { const T *v = reinterpret_cast(cv.data().data()); @@ -31,7 +31,7 @@ static py::object valueOrTuple(const ControlValue &cv) return py::cast(cv.get()); } -py::object controlValueToPy(const ControlValue &cv) +py::object controlValueToPy(const ControlStorage &cv) { switch (cv.type()) { case ControlTypeNone: @@ -57,28 +57,28 @@ py::object controlValueToPy(const ControlValue &cv) case ControlTypePoint: return valueOrTuple(cv); default: - throw std::runtime_error("Unsupported ControlValue type"); + throw std::runtime_error("Unsupported ControlStorage type"); } } template -static ControlValue controlValueMaybeArray(const py::object &ob) +static ControlStorage controlValueMaybeArray(const py::object &ob) { if (py::isinstance(ob) || py::isinstance(ob)) { std::vector vec = ob.cast>(); - return ControlValue(Span(vec)); + return ControlStorage(Span(vec)); } - return ControlValue(ob.cast()); + return ControlStorage(ob.cast()); } -ControlValue pyToControlValue(const py::object &ob, ControlType type) +ControlStorage pyToControlValue(const py::object &ob, ControlType type) { switch (type) { case ControlTypeNone: - return ControlValue(); + return ControlStorage(); case ControlTypeBool: - return ControlValue(ob.cast()); + return ControlStorage(ob.cast()); case ControlTypeByte: return controlValueMaybeArray(ob); case ControlTypeInteger32: @@ -88,11 +88,11 @@ ControlValue pyToControlValue(const py::object &ob, ControlType type) case ControlTypeFloat: return controlValueMaybeArray(ob); case ControlTypeString: - return ControlValue(ob.cast()); + return ControlStorage(ob.cast()); case ControlTypeRectangle: return controlValueMaybeArray(ob); case ControlTypeSize: - return ControlValue(ob.cast()); + return ControlStorage(ob.cast()); case ControlTypePoint: return controlValueMaybeArray(ob); default: diff --git a/src/py/libcamera/py_helpers.h b/src/py/libcamera/py_helpers.h index 983969dfff0373b14bc87f082a4de10888d0dd7b..47a0ee462c3c3396504c22a99173d83b0d549366 100644 --- a/src/py/libcamera/py_helpers.h +++ b/src/py/libcamera/py_helpers.h @@ -9,5 +9,5 @@ #include -pybind11::object controlValueToPy(const libcamera::ControlValue &cv); -libcamera::ControlValue pyToControlValue(const pybind11::object &ob, libcamera::ControlType type); +pybind11::object controlValueToPy(const libcamera::ControlStorage &cv); +libcamera::ControlStorage pyToControlValue(const pybind11::object &ob, libcamera::ControlType type); diff --git a/test/controls/control_value.cpp b/test/controls/control_value.cpp index 5084fd0cf47087395873fa75b496d37c3f9307a2..17cfe547d617cc9e2de7173d025b2e99bf27b105 100644 --- a/test/controls/control_value.cpp +++ b/test/controls/control_value.cpp @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Google Inc. * - * ControlValue tests + * ControlStorage tests */ #include @@ -15,7 +15,7 @@ using namespace std; using namespace libcamera; -class ControlValueTest : public Test +class ControlStorageTest : public Test { protected: int run() @@ -23,7 +23,7 @@ protected: /* * None type. */ - ControlValue value; + ControlStorage value; if (!value.isNone() || value.isArray()) { cerr << "Empty value is non-null" << endl; return TestFail; @@ -341,4 +341,4 @@ protected: } }; -TEST_REGISTER(ControlValueTest) +TEST_REGISTER(ControlStorageTest) diff --git a/test/serialization/serialization_test.cpp b/test/serialization/serialization_test.cpp index af9969fdd11ff821de104b98b013acb891d2a8c8..4b5188972deed3f473f75527fb279148a1d52c40 100644 --- a/test/serialization/serialization_test.cpp +++ b/test/serialization/serialization_test.cpp @@ -56,17 +56,17 @@ bool SerializationTest::equals(const ControlInfoMap &lhs, const ControlInfoMap & bool SerializationTest::equals(const ControlList &lhs, const ControlList &rhs) { - std::map rlhs; + std::map rlhs; std::transform(lhs.begin(), lhs.end(), std::inserter(rlhs, rlhs.end()), - [](const std::pair &v) + [](const std::pair &v) -> decltype(rlhs)::value_type { return { v.first, v.second }; }); - std::map rrhs; + std::map rrhs; std::transform(rhs.begin(), rhs.end(), std::inserter(rrhs, rrhs.end()), - [](const std::pair &v) + [](const std::pair &v) -> decltype(rrhs)::value_type { return { v.first, v.second };