Add to ControlId information about the names and values of enum, in the event that the ControlId is an enum type. This allows applications to query the ControlId for the names of the enum values, so that they can be displayed on a UI, for example. Without this, it was necessary to use macros of NameOfControlNameValueMap, which is difficult to use and is very inflexible. There already exists a map from name -> value in generated code. Reuse this and pass it to the ControlId constructor, which in turn generates the reverse map. The reverse map is then exposed to applications. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
124 lines
2.7 KiB
C++
124 lines
2.7 KiB
C++
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
/*
|
|
* Copyright (C) 2019, Google Inc.
|
|
*
|
|
* {{mode}} ID list
|
|
*
|
|
* This file is auto-generated. Do not edit.
|
|
*/
|
|
|
|
#include <libcamera/{{filename}}.h>
|
|
#include <libcamera/controls.h>
|
|
|
|
/**
|
|
* \file {{filename}}.h
|
|
* \brief Camera {{mode}} identifiers
|
|
*/
|
|
|
|
namespace libcamera {
|
|
|
|
/**
|
|
* \brief Namespace for libcamera {{mode}}
|
|
*/
|
|
namespace {{mode}} {
|
|
|
|
{%- for vendor, ctrls in controls -%}
|
|
|
|
{%- if vendor != 'libcamera' %}
|
|
/**
|
|
* \brief Namespace for {{vendor}} {{mode}}
|
|
*/
|
|
namespace {{vendor}} {
|
|
{%- endif -%}
|
|
|
|
{% for ctrl in ctrls %}
|
|
|
|
{% if ctrl.is_enum -%}
|
|
/**
|
|
* \enum {{ctrl.name}}Enum
|
|
* \brief Supported {{ctrl.name}} values
|
|
{%- for enum in ctrl.enum_values %}
|
|
*
|
|
* \var {{enum.name}}
|
|
* \brief {{enum.description|format_description}}
|
|
{%- endfor %}
|
|
*/
|
|
|
|
/**
|
|
* \var {{ctrl.name}}Values
|
|
* \brief List of all {{ctrl.name}} supported values
|
|
*/
|
|
|
|
/**
|
|
* \var {{ctrl.name}}NameValueMap
|
|
* \brief Map of all {{ctrl.name}} supported value names (in std::string format) to value
|
|
*/
|
|
|
|
{% endif -%}
|
|
/**
|
|
* \var {{ctrl.name}}
|
|
* \brief {{ctrl.description|format_description}}
|
|
*/
|
|
{%- endfor %}
|
|
{% if vendor != 'libcamera' %}
|
|
} /* namespace {{vendor}} */
|
|
{% endif -%}
|
|
|
|
{%- endfor %}
|
|
|
|
#ifndef __DOXYGEN__
|
|
/*
|
|
* Keep the {{mode}} definitions hidden from doxygen as it incorrectly parses
|
|
* them as functions.
|
|
*/
|
|
{% for vendor, ctrls in controls -%}
|
|
|
|
{% if vendor != 'libcamera' %}
|
|
namespace {{vendor}} {
|
|
{% endif %}
|
|
|
|
{%- for ctrl in ctrls %}
|
|
{% if ctrl.is_enum -%}
|
|
extern const std::array<const ControlValue, {{ctrl.enum_values_count}}> {{ctrl.name}}Values = {
|
|
{%- for enum in ctrl.enum_values %}
|
|
static_cast<{{ctrl.type}}>({{enum.name}}),
|
|
{%- endfor %}
|
|
};
|
|
extern const std::map<std::string, {{ctrl.type}}> {{ctrl.name}}NameValueMap = {
|
|
{%- for enum in ctrl.enum_values %}
|
|
{ "{{enum.name}}", {{enum.name}} },
|
|
{%- endfor %}
|
|
};
|
|
extern const Control<{{ctrl.type}}> {{ctrl.name}}({{ctrl.name|snake_case|upper}}, "{{ctrl.name}}", {{ctrl.name}}NameValueMap);
|
|
{% else -%}
|
|
extern const Control<{{ctrl.type}}> {{ctrl.name}}({{ctrl.name|snake_case|upper}}, "{{ctrl.name}}");
|
|
{% endif -%}
|
|
{%- endfor %}
|
|
|
|
{% if vendor != 'libcamera' %}
|
|
} /* namespace {{vendor}} */
|
|
{% endif -%}
|
|
|
|
{%- endfor %}
|
|
#endif /* __DOXYGEN__ */
|
|
|
|
/**
|
|
* \brief List of all supported libcamera {{mode}}
|
|
{%- if mode == 'controls' %}
|
|
*
|
|
* Unless otherwise stated, all controls are bi-directional, i.e. they can be
|
|
* set through Request::controls() and returned out through Request::metadata().
|
|
{%- endif %}
|
|
*/
|
|
extern const ControlIdMap {{mode}} {
|
|
{%- for vendor, ctrls in controls -%}
|
|
{%- for ctrl in ctrls %}
|
|
{ {{ctrl.namespace}}{{ctrl.name|snake_case|upper}}, &{{ctrl.namespace}}{{ctrl.name}} },
|
|
{%- endfor -%}
|
|
{%- endfor %}
|
|
};
|
|
|
|
} /* namespace {{mode}} */
|
|
|
|
} /* namespace libcamera */
|