{"id":2129,"url":"https://patchwork.libcamera.org/api/patches/2129/?format=json","web_url":"https://patchwork.libcamera.org/patch/2129/","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":"<20191007224642.6597-2-laurent.pinchart@ideasonboard.com>","date":"2019-10-07T22:46:34","name":"[libcamera-devel,1/9] libcamera: control_ids: Generate map of all supported controls","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"24542a3a3483374b05e0a939182d4223969f7732","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/2129/mbox/","series":[{"id":526,"url":"https://patchwork.libcamera.org/api/series/526/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=526","date":"2019-10-07T22:46:33","name":"Use ControlList for both libcamera and V4L2 controls","version":1,"mbox":"https://patchwork.libcamera.org/series/526/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/2129/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/2129/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 B5E2961966\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  8 Oct 2019 00:46:51 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(modemcable118.64-20-96.mc.videotron.ca [96.20.64.118])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D44FEB2E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  8 Oct 2019 00:46:50 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1570488411;\n\tbh=IxLRHr79EuWaBR9GOp4FgtsR3K5J2Sj37RJ+4GRv4Is=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=mHJdgOBvmY6tHmn68B0T2UrBgtU2ZH684A4nqyL1lKaFzOrAPWLKCpE+sb/tSuSl1\n\t02Zv0KIzXHyxI5cbpYWJG6VZiKLPg2qDAOhyCStkgxk37SJoexyH1frwyl1TlRG7b7\n\tPjvOTcKZPummzGFtYSk9BzC91jFPFtp2XYnj+S8o=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue,  8 Oct 2019 01:46:34 +0300","Message-Id":"<20191007224642.6597-2-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.21.0","In-Reply-To":"<20191007224642.6597-1-laurent.pinchart@ideasonboard.com>","References":"<20191007224642.6597-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 1/9] libcamera: control_ids: Generate map\n\tof all supported controls","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":"Mon, 07 Oct 2019 22:46:51 -0000"},"content":"In order to deserialise a ControlList, we will need to lookup ControlId\ninstances based on their numerical ID. Generate a global map from the\ncontrols definitions to support such a lookup.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/control_ids.h.in | 3 +++\n src/libcamera/control_ids.cpp.in   | 7 +++++++\n src/libcamera/gen-controls.py      | 7 ++++++-\n 3 files changed, 16 insertions(+), 1 deletion(-)","diff":"diff --git a/include/libcamera/control_ids.h.in b/include/libcamera/control_ids.h.in\nindex 1d0bc791e559..30b2bae8a9ae 100644\n--- a/include/libcamera/control_ids.h.in\n+++ b/include/libcamera/control_ids.h.in\n@@ -10,6 +10,7 @@\n #ifndef __LIBCAMERA_CONTROL_IDS_H__\n #define __LIBCAMERA_CONTROL_IDS_H__\n \n+#include <map>\n #include <stdint.h>\n \n #include <libcamera/controls.h>\n@@ -24,6 +25,8 @@ ${ids}\n \n ${controls}\n \n+extern const std::map<unsigned int, const ControlId *> controls;\n+\n } /* namespace controls */\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/control_ids.cpp.in b/src/libcamera/control_ids.cpp.in\nindex f699ac9eea54..f0656d3147b1 100644\n--- a/src/libcamera/control_ids.cpp.in\n+++ b/src/libcamera/control_ids.cpp.in\n@@ -20,6 +20,13 @@ namespace controls {\n \n ${controls}\n \n+/**\n+ * \\brief List of all supported libcamera controls\n+ */\n+extern const std::map<unsigned int, const ControlId *> controls {\n+${controls_map}\n+};\n+\n } /* namespace controls */\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/gen-controls.py b/src/libcamera/gen-controls.py\nindex 0899e40b4080..0c4bd79eee5b 100755\n--- a/src/libcamera/gen-controls.py\n+++ b/src/libcamera/gen-controls.py\n@@ -23,6 +23,7 @@ ${description}\n extern const Control<${type}> ${name}(${id_name}, \"${name}\");''')\n \n     ctrls = []\n+    ctrls_map = []\n \n     for ctrl in controls:\n         name, ctrl = ctrl.popitem()\n@@ -40,8 +41,12 @@ extern const Control<${type}> ${name}(${id_name}, \"${name}\");''')\n         }\n \n         ctrls.append(template.substitute(info))\n+        ctrls_map.append('\\t{ ' + id_name + ', &' + name + ' },')\n \n-    return {'controls': '\\n\\n'.join(ctrls)}\n+    return {\n+        'controls': '\\n\\n'.join(ctrls),\n+        'controls_map': '\\n'.join(ctrls_map),\n+    }\n \n \n def generate_h(controls):\n","prefixes":["libcamera-devel","1/9"]}