summaryrefslogtreecommitdiff
path: root/utils/codegen
diff options
context:
space:
mode:
authorPaul Elder <paul.elder@ideasonboard.com>2024-11-26 00:13:57 +0900
committerPaul Elder <paul.elder@ideasonboard.com>2024-12-18 17:26:52 +0900
commit39fe4ad96803f4dd97f034c3e4c05c55757bce11 (patch)
treeee154c25987962fd12d321f6710040c6305a79d7 /utils/codegen
parent9bd9d25a8297441d6cd8934cc3df2a8bbb497251 (diff)
utils: codegen: controls.py: Parse direction information
In preparation for adding support for querying direction information from controls, parse the direction information from control ID definitions. This can later be plugged in directly to the IPA code generators simply by using ctrl.direction. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
Diffstat (limited to 'utils/codegen')
-rw-r--r--utils/codegen/controls.py24
-rwxr-xr-xutils/codegen/gen-controls.py2
-rwxr-xr-xutils/codegen/gen-gst-controls.py2
3 files changed, 25 insertions, 3 deletions
diff --git a/utils/codegen/controls.py b/utils/codegen/controls.py
index 03c77cc6..602f15b2 100644
--- a/utils/codegen/controls.py
+++ b/utils/codegen/controls.py
@@ -28,7 +28,7 @@ class ControlEnum(object):
class Control(object):
- def __init__(self, name, data, vendor):
+ def __init__(self, name, data, vendor, mode):
self.__name = name
self.__data = data
self.__enum_values = None
@@ -60,6 +60,16 @@ class Control(object):
self.__size = num_elems
+ if mode == 'properties':
+ self.__direction = 'out'
+ else:
+ direction = self.__data.get('direction')
+ if direction is None:
+ raise RuntimeError(f'Control `{self.__name}` missing required field `{direction}`')
+ if direction not in ['in', 'out', 'inout']:
+ raise RuntimeError(f'Control `{self.__name}` direction `{direction}` is invalid; must be one of `in`, `out`, or `inout`')
+ self.__direction = direction
+
@property
def description(self):
"""The control description"""
@@ -112,6 +122,18 @@ class Control(object):
return f"Span<const {typ}>"
@property
+ def direction(self):
+ in_flag = 'ControlId::Direction::In'
+ out_flag = 'ControlId::Direction::Out'
+
+ if self.__direction == 'inout':
+ return f'{in_flag} | {out_flag}'
+ if self.__direction == 'in':
+ return in_flag
+ if self.__direction == 'out':
+ return out_flag
+
+ @property
def element_type(self):
return self.__data.get('type')
diff --git a/utils/codegen/gen-controls.py b/utils/codegen/gen-controls.py
index 3034e9a5..59b716c1 100755
--- a/utils/codegen/gen-controls.py
+++ b/utils/codegen/gen-controls.py
@@ -71,7 +71,7 @@ def main(argv):
ctrls = controls.setdefault(vendor, [])
for i, ctrl in enumerate(data['controls']):
- ctrl = Control(*ctrl.popitem(), vendor)
+ ctrl = Control(*ctrl.popitem(), vendor, args.mode)
ctrls.append(extend_control(ctrl, i, ranges))
# Sort the vendors by range numerical value
diff --git a/utils/codegen/gen-gst-controls.py b/utils/codegen/gen-gst-controls.py
index 2601a675..df098826 100755
--- a/utils/codegen/gen-gst-controls.py
+++ b/utils/codegen/gen-gst-controls.py
@@ -154,7 +154,7 @@ def main(argv):
ctrls = controls.setdefault(vendor, [])
for ctrl in data['controls']:
- ctrl = Control(*ctrl.popitem(), vendor)
+ ctrl = Control(*ctrl.popitem(), vendor, mode='controls')
if ctrl.name in exposed_controls:
ctrls.append(extend_control(ctrl))