{"id":1498,"url":"https://patchwork.libcamera.org/api/patches/1498/?format=json","web_url":"https://patchwork.libcamera.org/patch/1498/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20190621161401.28337-6-kieran.bingham@ideasonboard.com>","date":"2019-06-21T16:13:57","name":"[libcamera-devel,RFC,v2,5/9] libcamera: Implement a ControlList","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"ae0b84940ff7d309fb31ae8fc6b436ca2860c76d","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/1498/mbox/","series":[{"id":370,"url":"https://patchwork.libcamera.org/api/series/370/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=370","date":"2019-06-21T16:13:52","name":"Libcamera Controls","version":2,"mbox":"https://patchwork.libcamera.org/series/370/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/1498/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/1498/checks/","tags":{},"headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C9D41615BC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 21 Jun 2019 18:14:07 +0200 (CEST)","from localhost.localdomain\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6BB3AF81;\n\tFri, 21 Jun 2019 18:14:07 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1561133647;\n\tbh=0Bt6+LQA9Hoznez1ludzlC5gnVMhR5h+d8cIS0UFoSE=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=YhTuT8EKbAlExdV440W74GYea345X+5G/S8hULdfLYGfu39iDzSIMPtc2Zl11Luao\n\txVeU5J0XQbd6YVC8/adguRmaoW9mYKX5dvlp3+bJID0HiKJy1aMqrMBMPGfMhOweMj\n\tWAcgWiPa/NCmvTj5VBOWVShwmVH9qVRpkA7j+HVg=","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"LibCamera Devel <libcamera-devel@lists.libcamera.org>","Date":"Fri, 21 Jun 2019 17:13:57 +0100","Message-Id":"<20190621161401.28337-6-kieran.bingham@ideasonboard.com>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20190621161401.28337-1-kieran.bingham@ideasonboard.com>","References":"<20190621161401.28337-1-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC PATCH v2 5/9] libcamera: Implement a\n\tControlList","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":"Fri, 21 Jun 2019 16:14:08 -0000"},"content":"Define a ControlList which wraps the STL std::unordered_map to contain\na list of associative pairs of ControlInfo and Value items.\n\nA ControlInfo (or represented by its ControlId) together with a Value\nprovide a control item which can be interpreted by the internal IPA and\nPipelineHandler components.\n\nTo pass a set of controls around, a ControlList  can be added to a\nRequest or stored locally to establish a set of default values for later\nreuse.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n include/libcamera/controls.h |  41 +++++++++++\n src/libcamera/controls.cpp   | 128 +++++++++++++++++++++++++++++++++++\n 2 files changed, 169 insertions(+)","diff":"diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nindex 95198d41c4cf..5835b840a31b 100644\n--- a/include/libcamera/controls.h\n+++ b/include/libcamera/controls.h\n@@ -4,6 +4,9 @@\n  *\n  * controls.h - Control handling\n  */\n+\n+#include <unordered_map>\n+\n #ifndef __LIBCAMERA_CONTROLS_H__\n #define __LIBCAMERA_CONTROLS_H__\n \n@@ -53,6 +56,44 @@ private:\n \n std::ostream &operator<<(std::ostream &stream, const ControlInfo &value);\n \n+class ControlList\n+{\n+private:\n+\tstruct ControlInfoHasher {\n+\t\tstd::size_t operator()(const ControlInfo &ci) const\n+\t\t{\n+\t\t\treturn std::hash<int>()(ci.id());\n+\t\t}\n+\t};\n+\n+\ttypedef std::unordered_map<ControlInfo, Value, ControlInfoHasher> ControlListMap;\n+\n+public:\n+\tControlList();\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(ControlId id) const { return controls_.count(id); };\n+\tbool empty() const { return controls_.empty(); }\n+\tsize_t size() const { return controls_.size(); }\n+\tvoid reset() { controls_.clear(); }\n+\n+\tValue &operator[](ControlId id) { return controls_[id]; }\n+\n+\tvoid update(const ControlList &list);\n+\tvoid update(enum ControlId id, const Value &value);\n+\tvoid update(const ControlInfo &info, const Value &value);\n+\n+private:\n+\tControlListMap controls_;\n+};\n+\n } /* namespace libcamera */\n \n #endif /* __LIBCAMERA_CONTROLS_H__ */\ndiff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex b1be46ddb55e..7c55afffe4ca 100644\n--- a/src/libcamera/controls.cpp\n+++ b/src/libcamera/controls.cpp\n@@ -157,4 +157,132 @@ std::ostream &operator<<(std::ostream &stream, const ControlInfo &info)\n \treturn stream << info.toString();\n }\n \n+/**\n+ * \\class ControlList\n+ * \\brief Associates a list of ControlIds with their values.\n+ *\n+ * The ControlList stores a pair of ControlInfo and Value classes as an\n+ * unordered map. Entries can be updated using array syntax such as\n+ *   myControlList[MyControlId] = myValue;\n+ * or\n+ *   myNewValue = myControlList[MyControlId];\n+ */\n+\n+/**\n+ * \\brief Construct a ControlList\n+ */\n+ControlList::ControlList()\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()\n+ * \\brief Identify if the List contains a control with the specified ControlId\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::reset()\n+ * \\brief Removes all controls from the list\n+ */\n+\n+/**\n+ * \\fn ControlList::operator[]()\n+ * \\brief Access the control with the given Id\n+ * \\param id The id of the control to access\n+ * \\return The Value of the control with a ControlId of \\a Id\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+\tfor (auto it : list) {\n+\t\tconst ControlInfo &info = it.first;\n+\t\tconst Value &value = it.second;\n+\n+\t\tcontrols_[info] = value;\n+\t}\n+}\n+\n+/**\n+ * \\brief Update a control value in the list\n+ * \\param id The ControlId of the control to update\n+ * \\param value The new value for the updated control\n+ *\n+ * Set the Control value in the list to the appropriate value\n+ * If the list already contains a control of this ID then it will be overwritten\n+ */\n+void ControlList::update(enum ControlId id, const Value &value)\n+{\n+\tcontrols_[id] = value;\n+}\n+\n+/**\n+ * \\brief Update a control value in the list.\n+ * \\param info The ControlInfo of the control to update\n+ * \\param value The new value for the updated control\n+ *\n+ * Set the Control value in the list to the appropriate value.\n+ * If the list already contains a control of the Id matching the ControlInfo\n+ * then it will be overwritten.\n+ */\n+void ControlList::update(const ControlInfo &info, const Value &value)\n+{\n+\tcontrols_[info] = value;\n+}\n+\n } /* namespace libcamera */\n","prefixes":["libcamera-devel","RFC","v2","5/9"]}