[PATCH 2/4] utils: codegen: controls.py: Parse direction information
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Tue Nov 26 00:06:56 CET 2024
Hi Paul,
Thank you for the patch.
On Tue, Nov 26, 2024 at 12:30:01AM +0900, Paul Elder wrote:
> 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 at ideasonboard.com>
> ---
> utils/codegen/controls.py | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/utils/codegen/controls.py b/utils/codegen/controls.py
> index 03c77cc64abe..bc1c655f1b9b 100644
> --- a/utils/codegen/controls.py
> +++ b/utils/codegen/controls.py
> @@ -60,6 +60,15 @@ class Control(object):
>
> self.__size = num_elems
>
> + direction = self.__data.get('direction')
> + if direction is not None:
> + valid_values = ['in', 'out', 'inout']
> + if direction not in valid_values:
You can also write
if direction not in ['in', 'out', 'inout']:
Up to you. With the changes proposed in a response to the cover letter,
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> + raise RuntimeError(f'Control `{self.__name}` direction `{direction}` is invalid; must be one of `in`, `out`, or `inout`')
> + self.__direction = direction
> + else:
> + self.__direction = 'inout'
> +
> @property
> def description(self):
> """The control description"""
> @@ -111,6 +120,18 @@ class Control(object):
> else:
> return f"Span<const {typ}>"
>
> + @property
> + def direction(self):
> + in_flag = 'static_cast<ControlId::DirectionFlags>(ControlId::Direction::In)'
> + out_flag = 'static_cast<ControlId::DirectionFlags>(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')
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list