[v2,10/25] libtuning: Implement a minimal yaml parser
diff mbox series

Message ID 20240628104828.2928109-11-stefan.klug@ideasonboard.com
State Superseded
Headers show
Series
  • Add ccm calibration to libtuning
Related show

Commit Message

Stefan Klug June 28, 2024, 10:47 a.m. UTC
At the moment this just reads the yaml file and returns it verbatim.
This needs to evolve further in the near future.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
---
 utils/tuning/config-example.yaml              | 12 ++++++++++++
 utils/tuning/libtuning/parsers/yaml_parser.py |  9 ++++++---
 2 files changed, 18 insertions(+), 3 deletions(-)
 create mode 100644 utils/tuning/config-example.yaml

Comments

Laurent Pinchart June 28, 2024, 11:07 p.m. UTC | #1
Hi Stefan,

Thank you for the patch.

On Fri, Jun 28, 2024 at 12:47:03PM +0200, Stefan Klug wrote:
> At the moment this just reads the yaml file and returns it verbatim.
> This needs to evolve further in the near future.
> 
> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
> ---
>  utils/tuning/config-example.yaml              | 12 ++++++++++++
>  utils/tuning/libtuning/parsers/yaml_parser.py |  9 ++++++---
>  2 files changed, 18 insertions(+), 3 deletions(-)
>  create mode 100644 utils/tuning/config-example.yaml
> 
> diff --git a/utils/tuning/config-example.yaml b/utils/tuning/config-example.yaml
> new file mode 100644
> index 000000000000..1b7f52cd2fff
> --- /dev/null
> +++ b/utils/tuning/config-example.yaml
> @@ -0,0 +1,12 @@
> +general:
> +  disable: []
> +  plot: []
> +  alsc:
> +    do_alsc_colour: 1
> +    luminance_strength: 0.5
> +  awb:
> +    greyworld: 0
> +  macbeth:
> +    small: 1
> +    show: 0
> +#  blacklevel: 32
> \ No newline at end of file

This will need to be documented. I suppose it will come later.

> diff --git a/utils/tuning/libtuning/parsers/yaml_parser.py b/utils/tuning/libtuning/parsers/yaml_parser.py
> index 244db24daeb1..71c30180d29f 100644
> --- a/utils/tuning/libtuning/parsers/yaml_parser.py
> +++ b/utils/tuning/libtuning/parsers/yaml_parser.py
> @@ -5,13 +5,16 @@
>  # Parser for YAML format config file
>  
>  from .parser import Parser
> +import yaml
>  
>  
>  class YamlParser(Parser):
>      def __init__(self):
>          super().__init__()
>  
> -    # \todo Implement this (it's fine for now as we don't need a config for
> -    # rkisp1 LSC, which is the only user of this so far)
>      def parse(self, config_file: str, modules: list) -> (dict, list):
> -        return {}, []
> +        # dummy implementation that just reads the file

s/dummy/Dummy/

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> +        with open(config_file, 'r') as f:
> +            config = yaml.safe_load(f)
> +
> +        return config, []

Patch
diff mbox series

diff --git a/utils/tuning/config-example.yaml b/utils/tuning/config-example.yaml
new file mode 100644
index 000000000000..1b7f52cd2fff
--- /dev/null
+++ b/utils/tuning/config-example.yaml
@@ -0,0 +1,12 @@ 
+general:
+  disable: []
+  plot: []
+  alsc:
+    do_alsc_colour: 1
+    luminance_strength: 0.5
+  awb:
+    greyworld: 0
+  macbeth:
+    small: 1
+    show: 0
+#  blacklevel: 32
\ No newline at end of file
diff --git a/utils/tuning/libtuning/parsers/yaml_parser.py b/utils/tuning/libtuning/parsers/yaml_parser.py
index 244db24daeb1..71c30180d29f 100644
--- a/utils/tuning/libtuning/parsers/yaml_parser.py
+++ b/utils/tuning/libtuning/parsers/yaml_parser.py
@@ -5,13 +5,16 @@ 
 # Parser for YAML format config file
 
 from .parser import Parser
+import yaml
 
 
 class YamlParser(Parser):
     def __init__(self):
         super().__init__()
 
-    # \todo Implement this (it's fine for now as we don't need a config for
-    # rkisp1 LSC, which is the only user of this so far)
     def parse(self, config_file: str, modules: list) -> (dict, list):
-        return {}, []
+        # dummy implementation that just reads the file
+        with open(config_file, 'r') as f:
+            config = yaml.safe_load(f)
+
+        return config, []