{"id":1546,"url":"https://patchwork.libcamera.org/api/1.1/patches/1546/?format=json","web_url":"https://patchwork.libcamera.org/patch/1546/","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":"<20190630233817.10130-5-laurent.pinchart@ideasonboard.com>","date":"2019-06-30T23:38:07","name":"[libcamera-devel,v3,04/14] libcamera: controls: Introduce control-related data types","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"f76d70d478b7da28b8289883b899d2e8e663a0ab","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/1546/mbox/","series":[{"id":384,"url":"https://patchwork.libcamera.org/api/1.1/series/384/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=384","date":"2019-06-30T23:38:03","name":"libcamera Controls","version":3,"mbox":"https://patchwork.libcamera.org/series/384/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/1546/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/1546/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DA99161E16\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  1 Jul 2019 01:38:43 +0200 (CEST)","from pendragon.bb.dnainternet.fi\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6C21E255\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  1 Jul 2019 01:38:43 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1561937923;\n\tbh=UytlxKPf/z4l6FpOS9kG7e0+YnoIwOqNDYmxAqnvVZk=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=M4zjZSxuZFDxDzFpKigzWlVWz4ziNwk2RRCN2cUX72D7ioKCZSjLQLuOam0TL+0Eq\n\tSJ+KNdA3QOWbFMn2Ea+1r2LNsJPVdQ5ynCyBuh5uauayytlonLaeESje4ECiQpHlFR\n\t37XRFFvT1yE3bnAcYZHqloiYExrg+GopjYNyfVtI=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon,  1 Jul 2019 02:38:07 +0300","Message-Id":"<20190630233817.10130-5-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.21.0","In-Reply-To":"<20190630233817.10130-1-laurent.pinchart@ideasonboard.com>","References":"<20190630233817.10130-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 04/14] libcamera: controls: Introduce\n\tcontrol-related data types","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Sun, 30 Jun 2019 23:38:44 -0000"},"content":"From: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nAdd a set of data types to support controls:\n\n- ControlValue stores a control type and value in a generic way\n- ControlId enumerates all the control identifies\n- ControlIdentier declares the types of a control and map their names\n- ControlInfo stores runtime information for controls\n- ControlList contains a set of control info and value pairs\n\nThe control definitions map is generated from the controls documentation\nto ensure that the two will always be synchronised.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\nChanges since v2:\n\n- Squashed \"Provide ControlValue class\"\n- Renamed Value to ControlValue\n- Removed operator<<()\n- Added control table generation\n- Moved control definitions to control_definitions.h\n- Renamed ControlTypes to controlsTypes and make it const\n- Moved the initial controls list to a separate patch\n- Renamed control_definitions.h to control_ids.h and\n  control_definitions.cpp to control_types.cpp to match the contained\n  enum and variable name respectively\n- Indexed ControlList by ControlInfo pointer instead of value\n- Replaced ControlInfoHash with std::hash specialisation\n- Added automatic conversion between 32- and 64-bit integer values\n\nThe automatic conversion between integer types was prompted by an\nassertion failure due to the use of getInt() on the min() and max()\nvalue of an Integer control. The min and max ControlValue instances are\ncreate as Integer64, due to the V4L2ControlInfo class returning the\nrange as int64_t. This may need to be reworked.\n---\n Documentation/Doxyfile.in       |   3 +-\n include/libcamera/control_ids.h |  35 +++\n include/libcamera/controls.h    | 134 ++++++++++\n include/libcamera/meson.build   |   2 +\n src/libcamera/controls.cpp      | 428 ++++++++++++++++++++++++++++++++\n src/libcamera/gen-controls.awk  | 106 ++++++++\n src/libcamera/meson.build       |  11 +\n 7 files changed, 718 insertions(+), 1 deletion(-)\n create mode 100644 include/libcamera/control_ids.h\n create mode 100644 include/libcamera/controls.h\n create mode 100644 src/libcamera/controls.cpp\n create mode 100755 src/libcamera/gen-controls.awk","diff":"diff --git a/Documentation/Doxyfile.in b/Documentation/Doxyfile.in\nindex c58631200dd5..9ca32241b895 100644\n--- a/Documentation/Doxyfile.in\n+++ b/Documentation/Doxyfile.in\n@@ -868,7 +868,8 @@ EXCLUDE_SYMBOLS        = libcamera::SignalBase \\\n                          libcamera::SlotArgs \\\n                          libcamera::SlotBase \\\n                          libcamera::SlotMember \\\n-                         libcamera::SlotStatic\n+                         libcamera::SlotStatic \\\n+                         std::*\n \n # The EXAMPLE_PATH tag can be used to specify one or more files or directories\n # that contain example code fragments that are included (see the \\include\ndiff --git a/include/libcamera/control_ids.h b/include/libcamera/control_ids.h\nnew file mode 100644\nindex 000000000000..d0e700da9844\n--- /dev/null\n+++ b/include/libcamera/control_ids.h\n@@ -0,0 +1,35 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * control_ids.h : Control ID list\n+ */\n+\n+#ifndef __LIBCAMERA_CONTROL_IDS_H__\n+#define __LIBCAMERA_CONTROL_IDS_H__\n+\n+#include <functional>\n+\n+namespace libcamera {\n+\n+enum ControlId {\n+};\n+\n+} /* namespace libcamera */\n+\n+namespace std {\n+\n+template<>\n+struct hash<libcamera::ControlId> {\n+\tusing argument_type = libcamera::ControlId;\n+\tusing result_type = std::size_t;\n+\n+\tresult_type operator()(const argument_type &key) const noexcept\n+\t{\n+\t\treturn std::hash<std::underlying_type<argument_type>::type>()(key);\n+\t}\n+};\n+\n+} /* namespace std */\n+\n+#endif // __LIBCAMERA_CONTROL_IDS_H__\ndiff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nnew file mode 100644\nindex 000000000000..ad2d49d522c5\n--- /dev/null\n+++ b/include/libcamera/controls.h\n@@ -0,0 +1,134 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * controls.h - Control handling\n+ */\n+\n+#ifndef __LIBCAMERA_CONTROLS_H__\n+#define __LIBCAMERA_CONTROLS_H__\n+\n+#include <stdint.h>\n+#include <string>\n+#include <unordered_map>\n+\n+#include <libcamera/control_ids.h>\n+\n+namespace libcamera {\n+\n+class Camera;\n+\n+enum ControlValueType {\n+\tControlValueNone,\n+\tControlValueBool,\n+\tControlValueInteger,\n+\tControlValueInteger64,\n+};\n+\n+class ControlValue\n+{\n+public:\n+\tControlValue();\n+\tControlValue(bool value);\n+\tControlValue(int value);\n+\tControlValue(int64_t value);\n+\n+\tControlValueType type() const { return type_; };\n+\tbool isNone() const { return type_ == ControlValueNone; };\n+\n+\tvoid set(bool value);\n+\tvoid set(int value);\n+\tvoid set(int64_t value);\n+\n+\tbool getBool() const;\n+\tint getInt() const;\n+\tint64_t getInt64() const;\n+\n+\tstd::string toString() const;\n+\n+private:\n+\tControlValueType type_;\n+\n+\tunion {\n+\t\tbool bool_;\n+\t\tint integer_;\n+\t\tint64_t integer64_;\n+\t};\n+};\n+\n+struct ControlIdentifier {\n+\tControlId id;\n+\tconst char *name;\n+\tControlValueType type;\n+};\n+\n+class ControlInfo\n+{\n+public:\n+\texplicit ControlInfo(ControlId id, const ControlValue &min = 0,\n+\t\t\t     const ControlValue &max = 0);\n+\n+\tControlId id() const { return ident_->id; }\n+\tconst char *name() const { return ident_->name; }\n+\tControlValueType type() const { return ident_->type; }\n+\n+\tconst ControlValue &min() const { return min_; }\n+\tconst ControlValue &max() const { return max_; }\n+\n+\tstd::string toString() const;\n+\n+private:\n+\tconst struct ControlIdentifier *ident_;\n+\tControlValue min_;\n+\tControlValue max_;\n+};\n+\n+bool operator==(const ControlInfo &lhs, const ControlInfo &rhs);\n+bool operator==(const ControlId &lhs, const ControlInfo &rhs);\n+bool operator==(const ControlInfo &lhs, const ControlId &rhs);\n+static inline bool operator!=(const ControlInfo &lhs, const ControlInfo &rhs)\n+{\n+\treturn !(lhs == rhs);\n+}\n+static inline bool operator!=(const ControlId &lhs, const ControlInfo &rhs)\n+{\n+\treturn !(lhs == rhs);\n+}\n+static inline bool operator!=(const ControlInfo &lhs, const ControlId &rhs)\n+{\n+\treturn !(lhs == rhs);\n+}\n+\n+class ControlList\n+{\n+private:\n+\tusing ControlListMap = std::unordered_map<const ControlInfo *, ControlValue>;\n+\n+public:\n+\tControlList(Camera *camera);\n+\n+\tusing iterator = ControlListMap::iterator;\n+\tusing const_iterator = ControlListMap::const_iterator;\n+\n+\titerator begin() { return controls_.begin(); }\n+\titerator end() { return controls_.end(); }\n+\tconst_iterator begin() const { return controls_.begin(); }\n+\tconst_iterator end() const { return controls_.end(); }\n+\n+\tbool contains(const ControlInfo *info) const { return controls_.count(info); };\n+\tbool empty() const { return controls_.empty(); }\n+\tstd::size_t size() const { return controls_.size(); }\n+\tvoid clear() { controls_.clear(); }\n+\n+\tControlValue &operator[](const ControlInfo *info) { return controls_[info]; }\n+\n+\tvoid update(const ControlList &list);\n+\n+private:\n+\tCamera *camera_;\n+\tControlListMap controls_;\n+};\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_CONTROLS_H__ */\ndiff --git a/include/libcamera/meson.build b/include/libcamera/meson.build\nindex 15484724df01..3067120a1598 100644\n--- a/include/libcamera/meson.build\n+++ b/include/libcamera/meson.build\n@@ -2,6 +2,8 @@ libcamera_api = files([\n     'buffer.h',\n     'camera.h',\n     'camera_manager.h',\n+    'control_ids.h',\n+    'controls.h',\n     'event_dispatcher.h',\n     'event_notifier.h',\n     'geometry.h',\ndiff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nnew file mode 100644\nindex 000000000000..22db2b93eff2\n--- /dev/null\n+++ b/src/libcamera/controls.cpp\n@@ -0,0 +1,428 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * controls.cpp - Control handling\n+ */\n+\n+#include <libcamera/controls.h>\n+\n+#include <sstream>\n+#include <string>\n+\n+#include \"log.h\"\n+#include \"utils.h\"\n+\n+/**\n+ * \\file controls.h\n+ * \\brief Describes control framework and controls supported by a camera\n+ */\n+\n+namespace libcamera {\n+\n+LOG_DEFINE_CATEGORY(Controls)\n+\n+/**\n+ * \\enum ControlValueType\n+ * Determines the type of value represented by a ControlValue\n+ * \\var ControlValueNone\n+ * Identifies an unset control value\n+ * \\var ControlValueBool\n+ * Identifies controls storing a boolean value\n+ * \\var ControlValueInteger\n+ * Identifies controls storing an integer value\n+ * \\var ControlValueInteger64\n+ * Identifies controls storing a 64-bit integer value\n+ */\n+\n+/**\n+ * \\class ControlValue\n+ * \\brief Abstract type for values in a control\n+ */\n+\n+/**\n+ * \\brief Construct an empty ControlValue.\n+ */\n+ControlValue::ControlValue()\n+\t: type_(ControlValueNone)\n+{\n+}\n+\n+/**\n+ * \\brief Construct a Boolean ControlValue\n+ * \\param[in] value Boolean value to store\n+ */\n+ControlValue::ControlValue(bool value)\n+\t: type_(ControlValueBool), bool_(value)\n+{\n+}\n+\n+/**\n+ * \\brief Construct an integer ControlValue\n+ * \\param[in] value Integer value to store\n+ */\n+ControlValue::ControlValue(int value)\n+\t: type_(ControlValueInteger), integer_(value)\n+{\n+}\n+\n+/**\n+ * \\brief Construct a 64 bit integer ControlValue\n+ * \\param[in] value String representation to store\n+ */\n+ControlValue::ControlValue(int64_t value)\n+\t: type_(ControlValueInteger64), integer64_(value)\n+{\n+}\n+\n+/**\n+ * \\fn ControlValue::type\n+ * \\brief Return the type of value represented by the object\n+ */\n+\n+/**\n+ * \\fn ControlValue::isNone\n+ * \\brief Determine if the value is initialised\n+ * \\return True if the value type is ControlValueNone, false otherwise\n+ */\n+\n+/**\n+ * \\brief Set the value with a boolean\n+ * \\param[in] value Boolean value to store\n+ */\n+void ControlValue::set(bool value)\n+{\n+\ttype_ = ControlValueBool;\n+\tbool_ = value;\n+}\n+\n+/**\n+ * \\brief Set the value with an integer\n+ * \\param[in] value Integer value to store\n+ */\n+void ControlValue::set(int value)\n+{\n+\ttype_ = ControlValueInteger;\n+\tinteger_ = value;\n+}\n+\n+/**\n+ * \\brief Set the value with a 64 bit integer\n+ * \\param[in] value 64 bit integer value to store\n+ */\n+void ControlValue::set(int64_t value)\n+{\n+\ttype_ = ControlValueInteger64;\n+\tinteger64_ = value;\n+}\n+\n+/**\n+ * \\brief Get the boolean value.\n+ *\n+ * The value type must be Boolean.\n+ */\n+bool ControlValue::getBool() const\n+{\n+\tASSERT(type_ == ControlValueBool);\n+\n+\treturn bool_;\n+}\n+\n+/**\n+ * \\brief Get the integer value.\n+ *\n+ * The value type must be Integer or Integer64\n+ */\n+int ControlValue::getInt() const\n+{\n+\tASSERT(type_ == ControlValueInteger || type_ == ControlValueInteger64);\n+\n+\treturn integer_;\n+}\n+\n+/**\n+ * \\brief Get the 64 bit integer value.\n+ *\n+ * The value type must be Integer or Integer64\n+ */\n+int64_t ControlValue::getInt64() const\n+{\n+\tASSERT(type_ == ControlValueInteger || type_ == ControlValueInteger64);\n+\n+\treturn integer64_;\n+}\n+\n+/**\n+ * \\brief Assemble and return a string describing the value\n+ * \\return A string describing the ControlValue\n+ */\n+std::string ControlValue::toString() const\n+{\n+\tswitch (type_) {\n+\tcase ControlValueNone:\n+\t\treturn \"<None>\";\n+\tcase ControlValueBool:\n+\t\treturn bool_ ? \"True\" : \"False\";\n+\tcase ControlValueInteger:\n+\t\treturn std::to_string(integer_);\n+\tcase ControlValueInteger64:\n+\t\treturn std::to_string(integer64_);\n+\t}\n+\n+\treturn \"<ValueType Error>\";\n+}\n+\n+/**\n+ * \\enum ControlId\n+ * Control Identifiers\n+ */\n+\n+/**\n+ * \\struct ControlIdentifier\n+ * \\brief Describes a ControlId with control specific constant meta-data.\n+ *\n+ * Defines a Control with a unique ID, a name, and a type.\n+ * This structure is used as static part of the autogenerated control\n+ * definitions, which are generated from the ControlId documentation.\n+ *\n+ * \\var ControlIdentifier::id\n+ * The unique ID for a control\n+ * \\var ControlIdentifier::name\n+ * The string representation of the control\n+ * \\var ControlIdentifier::type\n+ * The ValueType required to represent the control value\n+ */\n+\n+/*\n+ * The controlTypes are automatically generated to produce a control_types.cpp\n+ * output. This file is not for public use, and so no suitable header exists\n+ * for this sole usage of the controlTypes reference. As such the extern is\n+ * only defined here for use during the ControlInfo constructor and should not\n+ * be referenced directly elsewhere.\n+ */\n+extern const std::unordered_map<ControlId, ControlIdentifier> controlTypes;\n+\n+/**\n+ * \\class ControlInfo\n+ * \\brief Describe the information and capabilities of a Control\n+ *\n+ * The ControlInfo represents control specific meta-data which is constant on a\n+ * per camera basis. ControlInfo classes are constructed by pipeline handlers\n+ * to expose the controls they support and the metadata needed to utilise those\n+ * controls.\n+ */\n+\n+/**\n+ * \\brief Construct a ControlInfo with minimum and maximum range parameters.\n+ */\n+ControlInfo::ControlInfo(ControlId id, const ControlValue &min,\n+\t\t\t const ControlValue &max)\n+\t: min_(min), max_(max)\n+{\n+\tauto iter = controlTypes.find(id);\n+\tif (iter == controlTypes.end()) {\n+\t\tLOG(Controls, Fatal) << \"Attempt to create invalid ControlInfo\";\n+\t\treturn;\n+\t}\n+\n+\tident_ = &iter->second;\n+}\n+\n+/**\n+ * \\fn ControlInfo::id()\n+ * \\brief Retrieve the ID of the control information descriptor\n+ * \\return the ControlId\n+ */\n+\n+/**\n+ * \\fn ControlInfo::name()\n+ * \\brief Retrieve the string name of the control information descriptor\n+ * \\return A string name for the Control\n+ */\n+\n+/**\n+ * \\fn ControlInfo::type()\n+ * \\brief Retrieve the ValueType of the control information descriptor\n+ * \\return The control type\n+ */\n+\n+/**\n+ * \\fn ControlInfo::min()\n+ * \\brief Reports the minimum value of the control\n+ * \\return a COntrolValue with the minimum setting for the control\n+ */\n+\n+/**\n+ * \\fn ControlInfo::max()\n+ * \\brief Reports the maximum value of the control\n+ * \\return a ControlValue with the maximum setting for the control\n+ */\n+\n+/**\n+ * \\brief Provide a string representation of the ControlInfo\n+ */\n+std::string ControlInfo::toString() const\n+{\n+\tstd::stringstream ss;\n+\n+\tss << name() << \"[\" << min_.toString() << \"..\" << max_.toString() << \"]\";\n+\n+\treturn ss.str();\n+}\n+\n+/**\n+ * \\brief Compare control information for equality\n+ * \\param[in] lhs Left-hand side control information\n+ * \\param[in] rhs Right-hand side control information\n+ *\n+ * Control information are compared based on their ID only, as a camera may not\n+ * have two separate controls with the same ID.\n+ *\n+ * \\return True if \\a lhs and \\a rhs are equal, false otherwise\n+ */\n+bool operator==(const ControlInfo &lhs, const ControlInfo &rhs)\n+{\n+\treturn lhs.id() == rhs.id();\n+}\n+\n+/**\n+ * \\brief Compare control ID and information for equality\n+ * \\param[in] lhs Left-hand side control identifier\n+ * \\param[in] rhs Right-hand side control information\n+ *\n+ * Control information are compared based on their ID only, as a camera may not\n+ * have two separate controls with the same ID.\n+ *\n+ * \\return True if \\a lhs and \\a rhs are equal, false otherwise\n+ */\n+bool operator==(const ControlId &lhs, const ControlInfo &rhs)\n+{\n+\treturn lhs == rhs.id();\n+}\n+\n+/**\n+ * \\brief Compare control information and ID for equality\n+ * \\param[in] lhs Left-hand side control information\n+ * \\param[in] rhs Right-hand side control identifier\n+ *\n+ * Control information are compared based on their ID only, as a camera may not\n+ * have two separate controls with the same ID.\n+ *\n+ * \\return True if \\a lhs and \\a rhs are equal, false otherwise\n+ */\n+bool operator==(const ControlInfo &lhs, const ControlId &rhs)\n+{\n+\treturn lhs.id() == rhs;\n+}\n+\n+/**\n+ * \\class ControlList\n+ * \\brief Associates a list of ControlIds with their values for a Camera.\n+ *\n+ * A ControlList specifies a map of ControlIds and Values and associated\n+ * validation against the ControlInfo for the related Camera device.\n+ */\n+\n+/**\n+ * \\brief Construct a ControlList with a reference to the Camera it applies on\n+ */\n+ControlList::ControlList(Camera *camera)\n+\t: camera_(camera)\n+{\n+}\n+\n+/**\n+ * \\typedef ControlList::iterator\n+ * \\brief Iterator for the controls contained within the list.\n+ */\n+\n+/**\n+ * \\typedef ControlList::const_iterator\n+ * \\brief Const iterator for the controls contained within the list.\n+ */\n+\n+/**\n+ * \\fn iterator ControlList::begin()\n+ * \\brief Retrieve an iterator to the first Control in the list\n+ * \\return An iterator to the first Control in the list\n+ */\n+\n+/**\n+ * \\fn iterator ControlList::end()\n+ * \\brief Retrieve an iterator to the next element after the last controls in\n+ * the instance.\n+ * \\return An iterator to the element following the last control in the instance\n+ */\n+\n+/**\n+ * \\fn const_iterator ControlList::begin() const\n+ * \\brief Retrieve a const_iterator to the first Control in the list\n+ * \\return A const_iterator to the first Control in the list\n+ */\n+\n+/**\n+ * \\fn const_iterator ControlList::end() const\n+ * \\brief Retrieve a constant iterator pointing to an empty element after the\n+ * \\return A const iterator to the element following the last control in the\n+ * instance\n+ */\n+\n+/**\n+ * \\fn ControlList::contains(const ControlInfo *info) const\n+ * \\brief Check if the ist contains a control with the specified \\a info\n+ * \\param[in] info The control info\n+ * \\return True if the list contains a matching control, false otherwise\n+ */\n+\n+/**\n+ * \\fn ControlList::empty()\n+ * \\brief Identify if the list is empty\n+ * \\return True if the list does not contain any control, false otherwise\n+ */\n+\n+/**\n+ * \\fn ControlList::size()\n+ * \\brief Retrieve the number of controls in the list\n+ * \\return The number of Control entries stored in the list\n+ */\n+\n+/**\n+ * \\fn ControlList::clear()\n+ * \\brief Removes all controls from the list\n+ */\n+\n+/**\n+ * \\fn ControlList::operator[](const ControlInfo *info)\n+ * \\brief Access or insert the control specified by \\a info\n+ * \\param[in] info The control info\n+ *\n+ * This method returns a reference to the control identified by \\a info,\n+ * inserting it in the list if the info is not already present.\n+ *\n+ * \\return A reference to the value of the control identified by \\a info\n+ */\n+\n+/**\n+ * \\brief Update all Control values with the value from the given \\a list\n+ * \\param list The list of controls to update or append to this list\n+ *\n+ * Update all controls in the ControlList, by the values given by \\a list\n+ * If the list already contains a control of this ID then it will be overwritten\n+ */\n+void ControlList::update(const ControlList &list)\n+{\n+\tif (list.camera_ != camera_) {\n+\t\tLOG(Controls, Error)\n+\t\t\t<< \"ControlLists can not be translated between cameras\";\n+\t\treturn;\n+\t}\n+\n+\tfor (auto it : list) {\n+\t\tconst ControlInfo *info = it.first;\n+\t\tconst ControlValue &value = it.second;\n+\n+\t\tcontrols_[info] = value;\n+\t}\n+}\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/gen-controls.awk b/src/libcamera/gen-controls.awk\nnew file mode 100755\nindex 000000000000..a91529b575db\n--- /dev/null\n+++ b/src/libcamera/gen-controls.awk\n@@ -0,0 +1,106 @@\n+#!/usr/bin/awk -f\n+\n+# SPDX-License-Identifier: LGPL-2.1-or-later\n+\n+# Controls are documented using Doxygen in the main control.cpp source.\n+#\n+# Generate control tables directly from the documentation, creating enumerations\n+# to support the IDs and static type information regarding each control.\n+\n+BEGIN {\n+\tid=0\n+\tinput=ARGV[1]\n+\tmode=ARGV[2]\n+\toutput=ARGV[3]\n+}\n+\n+# Detect Doxygen style comment blocks and ignore other lines\n+/^\\/\\*\\*$/ { in_doxygen=1; first_line=1; next }\n+// { if (!in_doxygen) next }\n+\n+# Entry point for the Control Documentation\n+/ * \\\\enum ControlId$/ { in_controls=1; first_line=0; next }\n+// { if (!in_controls) next }\n+\n+# Extract control information\n+/ \\* \\\\var/ { names[++id]=$3; first_line=0; next }\n+/ \\* ControlType:/ { types[id] = $3 }\n+\n+# End of comment blocks\n+/^ \\*\\// { in_doxygen=0 }\n+\n+# Identify the end of controls\n+/^ \\* \\\\/ { if (first_line) exit }\n+// { first_line=0 }\n+\n+################################\n+# Support output file generation\n+\n+function basename(file) {\n+\tsub(\".*/\", \"\", file)\n+\treturn file\n+}\n+\n+function Header(file, description) {\n+\tprint \"/* SPDX-License-Identifier: LGPL-2.1-or-later */\" > file\n+\tprint \"/*\" > file\n+\tprint \" * Copyright (C) 2019, Google Inc.\" > file\n+\tprint \" *\" > file\n+\tprint \" * \" basename(file) \" - \" description > file\n+\tprint \" *\" > file\n+\tprint \" * This file is autogenerated. Do not edit.\" > file\n+\tprint \" */\" > file\n+\tprint \"\" > file\n+}\n+\n+function EnterNameSpace(file) {\n+\tprint \"namespace libcamera {\" > file\n+\tprint \"\" > file\n+}\n+\n+function ExitNameSpace(file) {\n+\tprint \"\" > file\n+\tprint \"} /* namespace libcamera */\" > file\n+}\n+\n+function GenerateHeader(file) {\n+\tHeader(file, \"Control ID list\")\n+\n+\tprint \"#ifndef __LIBCAMERA_CONTROL_IDS_H__\" > file\n+\tprint \"#define __LIBCAMERA_CONTROL_IDS_H__\" > file\n+\tprint \"\" > file\n+\n+\tEnterNameSpace(file)\n+\tprint \"enum ControlId {\" > file\n+\tfor (i=1; i <= id; ++i) {\n+\t\tprintf \"\\t%s,\\n\", names[i] > file\n+\t}\n+\tprint \"};\" > file\n+\tExitNameSpace(file)\n+\n+\tprint \"\" > file\n+\tprint \"#endif // __LIBCAMERA_CONTROL_IDS_H__\" > file\n+}\n+\n+function GenerateTable(file) {\n+\tHeader(file, \"Control types\")\n+\tprint \"#include <libcamera/controls.h>\" > file\n+\tprint \"\" > file\n+\n+\tEnterNameSpace(file)\n+\n+\tprint \"extern const std::unordered_map<ControlId, ControlIdentifier>\" > file\n+\tprint \"controlTypes {\" > file\n+\tfor (i=1; i <= id; ++i) {\n+\t\tprintf \"\\t{ %s, { %s, \\\"%s\\\", ControlValue%s } },\\n\", names[i], names[i], names[i], types[i] > file\n+\t}\n+\tprint \"};\" > file\n+\tExitNameSpace(file)\n+}\n+\n+END {\n+\tif (mode == \"--header\")\n+\t\tGenerateHeader(output)\n+\telse\n+\t\tGenerateTable(output)\n+}\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex 985aa7e8ab0e..b1ee92735e41 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -3,6 +3,7 @@ libcamera_sources = files([\n     'camera.cpp',\n     'camera_manager.cpp',\n     'camera_sensor.cpp',\n+    'controls.cpp',\n     'device_enumerator.cpp',\n     'device_enumerator_sysfs.cpp',\n     'event_dispatcher.cpp',\n@@ -66,6 +67,16 @@ if libudev.found()\n     ])\n endif\n \n+gen_controls = files('gen-controls.awk')\n+\n+control_types_cpp = custom_target('control_types_cpp',\n+                                  input : files('controls.cpp'),\n+                                  output : 'control_types.cpp',\n+                                  depend_files : gen_controls,\n+                                  command : [gen_controls, '@INPUT@', '--code', '@OUTPUT@'])\n+\n+libcamera_sources += control_types_cpp\n+\n libcamera_deps = [\n     cc.find_library('dl'),\n     libudev,\n","prefixes":["libcamera-devel","v3","04/14"]}