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

Message ID 20200113164245.52535-15-jacopo@jmondi.org
State Superseded
Delegated to: Jacopo Mondi
Headers show
Series
  • Properties and compound controls
Related show

Commit Message

Jacopo Mondi Jan. 13, 2020, 4:42 p.m. UTC
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@jmondi.org>
---
 src/libcamera/gen-controls.py | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

Patch

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')