@@ -10,6 +10,7 @@
#ifndef __LIBCAMERA_CONTROL_IDS_H__
#define __LIBCAMERA_CONTROL_IDS_H__
+#include <map>
#include <stdint.h>
#include <libcamera/controls.h>
@@ -24,6 +25,8 @@ ${ids}
${controls}
+extern const std::map<unsigned int, const ControlId *> controls;
+
} /* namespace controls */
} /* namespace libcamera */
@@ -20,6 +20,13 @@ namespace controls {
${controls}
+/**
+ * \brief List of all supported libcamera controls
+ */
+extern const std::map<unsigned int, const ControlId *> controls {
+${controls_map}
+};
+
} /* namespace controls */
} /* namespace libcamera */
@@ -23,6 +23,7 @@ ${description}
extern const Control<${type}> ${name}(${id_name}, "${name}");''')
ctrls = []
+ ctrls_map = []
for ctrl in controls:
name, ctrl = ctrl.popitem()
@@ -40,8 +41,12 @@ extern const Control<${type}> ${name}(${id_name}, "${name}");''')
}
ctrls.append(template.substitute(info))
+ ctrls_map.append('\t{ ' + id_name + ', &' + name + ' },')
- return {'controls': '\n\n'.join(ctrls)}
+ return {
+ 'controls': '\n\n'.join(ctrls),
+ 'controls_map': '\n'.join(ctrls_map),
+ }
def generate_h(controls):
In order to deserialise a ControlList, we will need to lookup ControlId instances based on their numerical ID. Generate a global map from the controls definitions to support such a lookup. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- include/libcamera/control_ids.h.in | 3 +++ src/libcamera/control_ids.cpp.in | 7 +++++++ src/libcamera/gen-controls.py | 7 ++++++- 3 files changed, 16 insertions(+), 1 deletion(-)