{"id":2008,"url":"https://patchwork.libcamera.org/api/patches/2008/?format=json","web_url":"https://patchwork.libcamera.org/patch/2008/","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":"<20190924172503.30864-10-jacopo@jmondi.org>","date":"2019-09-24T17:24:51","name":"[libcamera-devel,09/21] libcamera: v4l2_controls: Make V4L2ControlInfoMap a class","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"e3ec336dc34fd11ddbf55a4a79780aa78dcffa92","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/2008/mbox/","series":[{"id":506,"url":"https://patchwork.libcamera.org/api/series/506/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=506","date":"2019-09-24T17:24:42","name":"Implement control serialization","version":1,"mbox":"https://patchwork.libcamera.org/series/506/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/2008/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/2008/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net\n\t[217.70.183.195])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4A9BE62379\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 24 Sep 2019 19:23:34 +0200 (CEST)","from uno.homenet.telecomitalia.it\n\t(host89-248-dynamic.45-213-r.retail.telecomitalia.it [213.45.248.89])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay3-d.mail.gandi.net (Postfix) with ESMTPSA id D546960006\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 24 Sep 2019 17:23:33 +0000 (UTC)"],"X-Originating-IP":"213.45.248.89","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 24 Sep 2019 19:24:51 +0200","Message-Id":"<20190924172503.30864-10-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.23.0","In-Reply-To":"<20190924172503.30864-1-jacopo@jmondi.org>","References":"<20190924172503.30864-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 09/21] libcamera: v4l2_controls: Make\n\tV4L2ControlInfoMap a class","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Tue, 24 Sep 2019 17:23:34 -0000"},"content":"Make V4L2ControlInfoMap a class to be able to serialize its content.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/include/v4l2_controls.h | 25 ++++++++-\n src/libcamera/v4l2_controls.cpp       | 79 ++++++++++++++++++++++++++-\n src/libcamera/v4l2_device.cpp         |  3 +-\n 3 files changed, 103 insertions(+), 4 deletions(-)","diff":"diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h\nindex 739f9f131923..5b583b9dfda6 100644\n--- a/src/libcamera/include/v4l2_controls.h\n+++ b/src/libcamera/include/v4l2_controls.h\n@@ -24,6 +24,8 @@ namespace libcamera {\n class V4L2ControlInfo : public DataInfo\n {\n public:\n+\tV4L2ControlInfo(unsigned int id, const DataValue &min = 0,\n+\t\t\tconst DataValue &max = 0);\n \tV4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl);\n \tunsigned int id() const { return id_; }\n \n@@ -31,7 +33,28 @@ private:\n \tunsigned int id_;\n };\n \n-using V4L2ControlInfoMap = std::map<unsigned int, V4L2ControlInfo>;\n+class V4L2ControlInfoMap\n+{\n+private:\n+\tusing InfoMap = std::map<unsigned int, V4L2ControlInfo>;\n+\n+public:\n+\tusing iterator = InfoMap::iterator;\n+\tusing const_iterator = InfoMap::const_iterator;\n+\n+\titerator begin() { return map_.begin(); }\n+\titerator end() { return map_.end(); }\n+\tconst_iterator begin() const { return map_.begin(); }\n+\tconst_iterator end() const { return map_.end(); }\n+\n+\titerator find(unsigned int id) { return map_.find(id); }\n+\tconst_iterator find(unsigned int id) const { return map_.find(id); }\n+\n+\tvoid emplace(unsigned int id, const struct v4l2_query_ext_ctrl &ctrl);\n+\n+private:\n+\tInfoMap map_;\n+};\n \n class V4L2Control : public DataValue\n {\ndiff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp\nindex b386d313bc4a..c046f88bc7d3 100644\n--- a/src/libcamera/v4l2_controls.cpp\n+++ b/src/libcamera/v4l2_controls.cpp\n@@ -68,6 +68,18 @@ namespace libcamera {\n  * the first time the control information is accessed.\n  */\n \n+/**\n+ * \\brief Contruct a V4L2ControlInfo from with a min and max values\n+ * \\param[in] id The v4l2 control id\n+ * \\param[in] min The v4l2 control minimum value\n+ * \\param[in] max The v4l2 control maximum value\n+ */\n+V4L2ControlInfo::V4L2ControlInfo(unsigned int id, const DataValue &min,\n+\t\t\t\t const DataValue &max)\n+\t: DataInfo(min, max), id_(id)\n+{\n+}\n+\n /**\n  * \\brief Construct a V4L2ControlInfo from a struct v4l2_query_ext_ctrl\n  * \\param ctrl The struct v4l2_query_ext_ctrl as returned by the kernel\n@@ -86,10 +98,75 @@ V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl)\n  */\n \n /**\n- * \\typedef V4L2ControlInfoMap\n+ * \\class V4L2ControlInfoMap\n  * \\brief A map of control ID to V4L2ControlInfo\n  */\n \n+/**\n+ * \\typedef V4L2ControlInfoMap::iterator\n+ * \\brief Iterator for the controls contained within the list\n+ */\n+\n+/**\n+ * \\typedef V4L2ControlInfoMap::const_iterator\n+ * \\brief Const iterator for the controls contained within the list\n+ */\n+\n+/**\n+ * \\fn iterator V4L2ControlInfoMap::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 const_iterator V4L2ControlInfoMap::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 iterator V4L2ControlInfoMap::end()\n+ * \\brief Retrieve an iterator pointing to the past-the-end control in the list\n+ * \\return An iterator to the element following the last control in the list\n+ */\n+\n+/**\n+ * \\fn const_iterator V4L2ControlInfoMap::end() const\n+ * \\brief Retrieve a const iterator pointing to the past-the-end control in the\n+ * list\n+ * \\return A const iterator to the element following the last control in the\n+ * list\n+ */\n+\n+/**\n+ * \\fn iterator V4L2ControlInfoMap::find(unsigned int id)\n+ * \\brief Find V4L2ControlInfo with \\a id\n+ * \\param id The control identifier\n+ * \\return An interator to the V4L2ControlInfo with key \\a id or the\n+ * past-the-end iterator if no element with key \\a id exists\n+ */\n+\n+/**\n+ * \\fn const_iterator V4L2ControlInfoMap::find(unsigned int id) const\n+ * \\brief Find V4L2ControlInfo with \\a id\n+ * \\param id The control identifier\n+ * \\return A const interator to the V4L2ControlInfo with key \\a id or the\n+ * past-the-end iterator if no element with key \\a id exists\n+ */\n+\n+/**\n+ * \\brief Insert a new element in the map constructed in-place\n+ * \\param[in] id The control identifier\n+ * \\param[in] ctrl The v4l2_query_ext_ctrl containing info on the control\n+ */\n+void V4L2ControlInfoMap::emplace(unsigned int id,\n+\t\t\t\t const struct v4l2_query_ext_ctrl &ctrl)\n+{\n+\tmap_.emplace(std::piecewise_construct,\n+\t\t     std::forward_as_tuple(id),\n+\t\t     std::forward_as_tuple(ctrl));\n+}\n+\n /**\n  * \\class V4L2Control\n  * \\brief A V4L2 control value\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex e1a715edec13..f89f4cd6c505 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -364,8 +364,7 @@ void V4L2Device::listControls()\n \t\t\tcontinue;\n \t\t}\n \n-\t\tV4L2ControlInfo info(ctrl);\n-\t\tcontrols_.emplace(ctrl.id, info);\n+\t\tcontrols_.emplace(ctrl.id, ctrl);\n \t}\n }\n \n","prefixes":["libcamera-devel","09/21"]}