[libcamera-devel] [PATCH v2 15/19] py: Re-implement controls geneneration
Tomi Valkeinen
tomi.valkeinen at ideasonboard.com
Fri May 27 12:10:26 CEST 2022
On 27/05/2022 11:05, Laurent Pinchart wrote:
> Hi Tomi,
>
> Thank you for the patch.
>
> On Tue, May 24, 2022 at 02:46:06PM +0300, Tomi Valkeinen wrote:
>> The Python bindings controls generation was not very good. It only
>> covered the enums and they were in the main namespace.
>>
>> This adds the controls somewhat similarly to the C++ side. We will have
>> e.g.:
>>
>> libcamera.controls.Brightness
>> libcamera.controls.AeMeteringModeEnum.CentreWeighted
>>
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen at ideasonboard.com>
>> ---
>> ...py-control-enums.py => gen-py-controls.py} | 20 +++++++++++--------
>> src/py/libcamera/meson.build | 16 +++++++++------
>> ...ed.cpp.in => py_controls_generated.cpp.in} | 17 +++++++++++++---
>> src/py/libcamera/py_main.cpp | 4 ++--
>> 4 files changed, 38 insertions(+), 19 deletions(-)
>> rename src/py/libcamera/{gen-py-control-enums.py => gen-py-controls.py} (85%)
>> rename src/py/libcamera/{py_control_enums_generated.cpp.in => py_controls_generated.cpp.in} (50%)
>>
>> diff --git a/src/py/libcamera/gen-py-control-enums.py b/src/py/libcamera/gen-py-controls.py
>> similarity index 85%
>> rename from src/py/libcamera/gen-py-control-enums.py
>> rename to src/py/libcamera/gen-py-controls.py
>> index 6b2b5362..e3e1e178 100755
>> --- a/src/py/libcamera/gen-py-control-enums.py
>> +++ b/src/py/libcamera/gen-py-controls.py
>> @@ -1,7 +1,7 @@
>> #!/usr/bin/env python3
>> # SPDX-License-Identifier: GPL-2.0-or-later
>> #
>> -# Generate Python bindings enums for controls from YAML
>> +# Generate Python bindings controls from YAML
>>
>> import argparse
>> import string
>> @@ -27,18 +27,22 @@ def generate_py(controls):
>> for ctrl in controls:
>> name, ctrl = ctrl.popitem()
>>
>> - enum = ctrl.get('enum')
>> - if not enum:
>> - continue
>> -
>> if ctrl.get('draft'):
>> ns = 'libcamera::controls::draft::'
>> + container = "draft"
>> else:
>> ns = 'libcamera::controls::'
>> + container = "controls"
>>
>> cpp_enum = name + 'Enum'
>
> I'd move this line after the enum check below.
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Thanks, makes sense.
Tomi
More information about the libcamera-devel
mailing list