[libcamera-devel] [PATCH 14/23] libcamera: controls: Parse 'compound' yaml property

Jacopo Mondi jacopo at jmondi.org
Mon Jan 13 17:42:36 CET 2020


Parse the 'compound' yaml property and create Control<> instances with
the opportune type accordingly.

Controls defined in the yaml source file as 'compound' will be
instantiated with 'Span<T>' type, while non-compound controls retain the
'T' type.

Example
controls_ids.yaml:

  - CompoundControl:
    type: int32_t
    description: A fictional compound control
    compound: true

Will be parsed by gen-control.py to generate a Control<Span<int32_t>>
instance.

Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
 src/libcamera/gen-controls.py | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/libcamera/gen-controls.py b/src/libcamera/gen-controls.py
index 7369ab4b0fdb..53ac66483bf6 100755
--- a/src/libcamera/gen-controls.py
+++ b/src/libcamera/gen-controls.py
@@ -42,9 +42,14 @@ ${description}
         name, ctrl = ctrl.popitem()
         id_name = snake_case(name).upper()
 
+        if ctrl.get('compound'):
+            ctrl_type = 'Span<%s>' % ctrl['type']
+        else:
+            ctrl_type = ctrl['type']
+
         info = {
             'name': name,
-            'type': ctrl['type'],
+            'type': ctrl_type,
             'description': format_description(ctrl['description']),
             'id_name': id_name,
         }
@@ -92,9 +97,14 @@ def generate_h(controls):
 
         ids.append('\t' + id_name + ' = ' + str(id_value) + ',')
 
+        if ctrl.get('compound'):
+            ctrl_type = 'Span<%s>' % ctrl['type']
+        else:
+            ctrl_type = ctrl['type']
+
         info = {
             'name': name,
-            'type': ctrl['type'],
+            'type': ctrl_type,
         }
 
         enum = ctrl.get('enum')
-- 
2.24.0



More information about the libcamera-devel mailing list