[libcamera-devel] [PATCH v2 02/10] libcamera: controls: Parse 'values' in gen-controls.py
Jacopo Mondi
jacopo at jmondi.org
Thu Dec 5 21:43:42 CET 2019
In preparation to add libcamera Camera definition by re-using the
control generation framework, augment the gen_controls.py script to
support parsing the 'values' yaml tag and generate documentation and
definition of possible values associated with a Control or a Property.
Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
src/libcamera/gen-controls.py | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/src/libcamera/gen-controls.py b/src/libcamera/gen-controls.py
index 940386cc68c8..f86f01f6759b 100755
--- a/src/libcamera/gen-controls.py
+++ b/src/libcamera/gen-controls.py
@@ -17,10 +17,15 @@ def snake_case(s):
def generate_cpp(controls):
+ value_doc_template = string.Template('''/**
+ * \\def ${name}
+ * \\brief ${description} */''')
+
doc_template = string.Template('''/**
* \\var extern const Control<${type}> ${name}
${description}
*/''')
+
def_template = string.Template('extern const Control<${type}> ${name}(${id_name}, "${name}");')
ctrls_doc = []
@@ -35,13 +40,27 @@ ${description}
description[0] = '\\brief ' + description[0]
description = '\n'.join([(line and ' * ' or ' *') + line for line in description])
+ try:
+ values = ctrl['values']
+ except KeyError:
+ values = ""
+
info = {
'name': name,
'type': ctrl['type'],
'description': description,
'id_name': id_name,
+ 'values' : values,
}
+ for value in values:
+ value_info = {
+ 'name': list(value.keys())[0],
+ 'value': value['value'],
+ 'description': value['description']
+ }
+ ctrls_doc.append(value_doc_template.substitute(value_info))
+
ctrls_doc.append(doc_template.substitute(info))
ctrls_def.append(def_template.substitute(info))
ctrls_map.append('\t{ ' + id_name + ', &' + name + ' },')
@@ -54,6 +73,7 @@ ${description}
def generate_h(controls):
+ value_template = string.Template('''#define ${name} ${value}''')
template = string.Template('''extern const Control<${type}> ${name};''')
ctrls = []
@@ -66,11 +86,25 @@ def generate_h(controls):
ids.append('\t' + id_name + ' = ' + str(id_value) + ',')
+ try:
+ values = ctrl['values']
+ except KeyError:
+ values = ""
+
info = {
'name': name,
'type': ctrl['type'],
+ 'values' : values,
}
+ for value in values:
+ value_info = {
+ 'name': list(value.keys())[0],
+ 'value': value['value'],
+ 'description': value['description']
+ }
+ ctrls.append(value_template.substitute(value_info))
+
ctrls.append(template.substitute(info))
id_value += 1
--
2.23.0
More information about the libcamera-devel
mailing list