[libcamera-devel,2/3] libcamera: control_ids: Separate the id numerical space
diff mbox series

Message ID 20220621150337.47839-3-jacopo@jmondi.org
State New
Headers show
Series
  • libcamera: Introduce internal controls
Related show

Commit Message

Jacopo Mondi June 21, 2022, 3:03 p.m. UTC
Separate the internal and public control id numerical space by
placing the internal controls at offset 0x1000.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 utils/gen-controls.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

Jean-Michel Hautbois June 21, 2022, 6:22 p.m. UTC | #1
Hi Jacopo,

On 21/06/2022 17:03, Jacopo Mondi via libcamera-devel wrote:
> Separate the internal and public control id numerical space by
> placing the internal controls at offset 0x1000.

I don't expect we will have more than 4096 controls in the public part:
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org>

> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> ---
>   utils/gen-controls.py | 10 +++++++---
>   1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/utils/gen-controls.py b/utils/gen-controls.py
> index 978179f63858..63e888546277 100755
> --- a/utils/gen-controls.py
> +++ b/utils/gen-controls.py
> @@ -118,7 +118,7 @@ ${description}
>       }
>   
>   
> -def generate_h(controls):
> +def generate_h(internal, controls):
>       enum_template_start = string.Template('''enum ${name}Enum {''')
>       enum_value_template = string.Template('''\t${name} = ${value},''')
>       enum_values_template = string.Template('''extern const std::array<const ControlValue, ${size}> ${name}Values;''')
> @@ -133,7 +133,11 @@ def generate_h(controls):
>           name, ctrl = ctrl.popitem()
>           id_name = snake_case(name).upper()
>   
> -        ids.append('\t' + id_name + ' = ' + str(id_value) + ',')
> +        # Separate the internal and public controls id space
> +        if internal:
> +            ids.append('\t' + id_name + ' = ' + "0x1000 | " + str(id_value) + ',')
> +        else:
> +            ids.append('\t' + id_name + ' = ' + str(id_value) + ',')
>   
>           ctrl_type = ctrl['type']
>           if ctrl_type == 'string':
> @@ -218,7 +222,7 @@ def main(argv):
>       if args.template.endswith('.cpp.in'):
>           data = generate_cpp(controls)
>       elif args.template.endswith('.h.in'):
> -        data = generate_h(controls)
> +        data = generate_h(args.internal, controls)
>       else:
>           raise RuntimeError('Unknown template type')
>

Patch
diff mbox series

diff --git a/utils/gen-controls.py b/utils/gen-controls.py
index 978179f63858..63e888546277 100755
--- a/utils/gen-controls.py
+++ b/utils/gen-controls.py
@@ -118,7 +118,7 @@  ${description}
     }
 
 
-def generate_h(controls):
+def generate_h(internal, controls):
     enum_template_start = string.Template('''enum ${name}Enum {''')
     enum_value_template = string.Template('''\t${name} = ${value},''')
     enum_values_template = string.Template('''extern const std::array<const ControlValue, ${size}> ${name}Values;''')
@@ -133,7 +133,11 @@  def generate_h(controls):
         name, ctrl = ctrl.popitem()
         id_name = snake_case(name).upper()
 
-        ids.append('\t' + id_name + ' = ' + str(id_value) + ',')
+        # Separate the internal and public controls id space
+        if internal:
+            ids.append('\t' + id_name + ' = ' + "0x1000 | " + str(id_value) + ',')
+        else:
+            ids.append('\t' + id_name + ' = ' + str(id_value) + ',')
 
         ctrl_type = ctrl['type']
         if ctrl_type == 'string':
@@ -218,7 +222,7 @@  def main(argv):
     if args.template.endswith('.cpp.in'):
         data = generate_cpp(controls)
     elif args.template.endswith('.h.in'):
-        data = generate_h(controls)
+        data = generate_h(args.internal, controls)
     else:
         raise RuntimeError('Unknown template type')