libcamera: controls: Generate an array of valid values
For each Control that supports enumerated values generate an array of ControlValue which contains the full list of valid values. At the expense of a slight increase in memory occupation this change allows the construction of the ControlInfo associated with a Control from the values list, defaulting the minimum and maximum values reported by the ControlInfo. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
parent
7a307fa647
commit
ef7a07dd8a
3 changed files with 32 additions and 0 deletions
|
@ -10,6 +10,7 @@
|
||||||
#ifndef __LIBCAMERA_CONTROL_IDS_H__
|
#ifndef __LIBCAMERA_CONTROL_IDS_H__
|
||||||
#define __LIBCAMERA_CONTROL_IDS_H__
|
#define __LIBCAMERA_CONTROL_IDS_H__
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <libcamera/controls.h>
|
#include <libcamera/controls.h>
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <libcamera/control_ids.h>
|
#include <libcamera/control_ids.h>
|
||||||
|
#include <libcamera/controls.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file control_ids.h
|
* \file control_ids.h
|
||||||
|
|
|
@ -33,6 +33,12 @@ ${description}''')
|
||||||
${description}
|
${description}
|
||||||
*/''')
|
*/''')
|
||||||
def_template = string.Template('extern const Control<${type}> ${name}(${id_name}, "${name}");')
|
def_template = string.Template('extern const Control<${type}> ${name}(${id_name}, "${name}");')
|
||||||
|
enum_values_doc = string.Template('''/**
|
||||||
|
* \\var ${name}Values
|
||||||
|
* \\brief List of all $name supported values
|
||||||
|
*/''')
|
||||||
|
enum_values_start = string.Template('''extern const std::array<const ControlValue, ${size}> ${name}Values = {''')
|
||||||
|
enum_values_values = string.Template('''\tstatic_cast<int32_t>(${name}),''')
|
||||||
|
|
||||||
ctrls_doc = []
|
ctrls_doc = []
|
||||||
ctrls_def = []
|
ctrls_def = []
|
||||||
|
@ -68,6 +74,7 @@ ${description}
|
||||||
enum_doc = []
|
enum_doc = []
|
||||||
enum_doc.append(enum_doc_start_template.substitute(info))
|
enum_doc.append(enum_doc_start_template.substitute(info))
|
||||||
|
|
||||||
|
num_entries = 0
|
||||||
for entry in enum:
|
for entry in enum:
|
||||||
value_info = {
|
value_info = {
|
||||||
'name' : name,
|
'name' : name,
|
||||||
|
@ -75,11 +82,25 @@ ${description}
|
||||||
'description': format_description(entry['description']),
|
'description': format_description(entry['description']),
|
||||||
}
|
}
|
||||||
enum_doc.append(enum_doc_value_template.substitute(value_info))
|
enum_doc.append(enum_doc_value_template.substitute(value_info))
|
||||||
|
num_entries += 1
|
||||||
|
|
||||||
enum_doc = '\n *\n'.join(enum_doc)
|
enum_doc = '\n *\n'.join(enum_doc)
|
||||||
enum_doc += '\n */'
|
enum_doc += '\n */'
|
||||||
target_doc.append(enum_doc)
|
target_doc.append(enum_doc)
|
||||||
|
|
||||||
|
values_info = {
|
||||||
|
'name': info['name'],
|
||||||
|
'size': num_entries,
|
||||||
|
}
|
||||||
|
target_doc.append(enum_values_doc.substitute(values_info))
|
||||||
|
target_def.append(enum_values_start.substitute(values_info))
|
||||||
|
for entry in enum:
|
||||||
|
value_info = {
|
||||||
|
'name': entry['name']
|
||||||
|
}
|
||||||
|
target_def.append(enum_values_values.substitute(value_info))
|
||||||
|
target_def.append("};")
|
||||||
|
|
||||||
target_doc.append(doc_template.substitute(info))
|
target_doc.append(doc_template.substitute(info))
|
||||||
target_def.append(def_template.substitute(info))
|
target_def.append(def_template.substitute(info))
|
||||||
|
|
||||||
|
@ -100,6 +121,7 @@ ${description}
|
||||||
def generate_h(controls):
|
def generate_h(controls):
|
||||||
enum_template_start = string.Template('''enum ${name}Enum {''')
|
enum_template_start = string.Template('''enum ${name}Enum {''')
|
||||||
enum_value_template = string.Template('''\t${name} = ${value},''')
|
enum_value_template = string.Template('''\t${name} = ${value},''')
|
||||||
|
enum_values_template = string.Template('''extern const std::array<const ControlValue, ${size}> ${name}Values;''')
|
||||||
template = string.Template('''extern const Control<${type}> ${name};''')
|
template = string.Template('''extern const Control<${type}> ${name};''')
|
||||||
|
|
||||||
ctrls = []
|
ctrls = []
|
||||||
|
@ -132,14 +154,22 @@ def generate_h(controls):
|
||||||
if enum:
|
if enum:
|
||||||
target_ctrls.append(enum_template_start.substitute(info))
|
target_ctrls.append(enum_template_start.substitute(info))
|
||||||
|
|
||||||
|
num_entries = 0
|
||||||
for entry in enum:
|
for entry in enum:
|
||||||
value_info = {
|
value_info = {
|
||||||
'name': entry['name'],
|
'name': entry['name'],
|
||||||
'value': entry['value'],
|
'value': entry['value'],
|
||||||
}
|
}
|
||||||
target_ctrls.append(enum_value_template.substitute(value_info))
|
target_ctrls.append(enum_value_template.substitute(value_info))
|
||||||
|
num_entries += 1
|
||||||
target_ctrls.append("};")
|
target_ctrls.append("};")
|
||||||
|
|
||||||
|
values_info = {
|
||||||
|
'name': info['name'],
|
||||||
|
'size': num_entries,
|
||||||
|
}
|
||||||
|
target_ctrls.append(enum_values_template.substitute(values_info))
|
||||||
|
|
||||||
target_ctrls.append(template.substitute(info))
|
target_ctrls.append(template.substitute(info))
|
||||||
id_value += 1
|
id_value += 1
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue