[PATCH v2] libcamera: controls: Generate macro for each control

Barnabás Pőcze barnabas.pocze at ideasonboard.com
Tue Mar 25 14:42:31 CET 2025


Generate a macro in the form of LIBCAMERA_HAS_$VENDOR_VENDOR_$MODE_$NAME
for each control so that its existence can be checked easily and without
extra version checks.

Signed-off-by: Barnabás Pőcze <barnabas.pocze at ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
changes in v2:
  * rename macro from `LIBCAMERA_HAS_$VENDOR_$MODE_$NAME` to
    `LIBCAMERA_HAS_$VENDOR_VENDOR_$MODE_$NAME` so that has the
                          ^^^^^^^
    name of the macro already generated for the control namespaces
    as prefix

v1: https://patchwork.libcamera.org/patch/22972/
---
 include/libcamera/control_ids.h.in | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/libcamera/control_ids.h.in b/include/libcamera/control_ids.h.in
index 5d0594c68..6b5712339 100644
--- a/include/libcamera/control_ids.h.in
+++ b/include/libcamera/control_ids.h.in
@@ -49,6 +49,7 @@ extern const std::array<const ControlValue, {{ctrl.enum_values_count}}> {{ctrl.n
 extern const std::map<std::string, {{ctrl.type}}> {{ctrl.name}}NameValueMap;
 {% endif -%}
 extern const Control<{{ctrl.type}}> {{ctrl.name}};
+#define LIBCAMERA_HAS_{{vendor|upper}}_VENDOR_{{mode|upper}}_{{ctrl.name|snake_case|upper}}
 {% endfor -%}

 {% if vendor != 'libcamera' %}
--
2.49.0


More information about the libcamera-devel mailing list