[libcamera-devel,2/2] libcamera: Switch internal YAML files to YAML 1.1
diff mbox series

Message ID 20220804132112.17604-3-laurent.pinchart@ideasonboard.com
State Accepted
Commit 73570c06371306fe3e75d04149626b6827751854
Headers show
Series
  • Use YAML 1.1 for the time being
Related show

Commit Message

Laurent Pinchart Aug. 4, 2022, 1:21 p.m. UTC
The python3-yaml package shipped by Debian is based on libyaml 0.2.2,
which doesn't support YAML 1.2. It is documented as such:

    Python3-yaml is a complete YAML 1.1 parser and emitter for Python3.

For some reasons the internal YAML files used to generate format- and
control-related source files still parse correctly, despite the YAML 1.2
directive at the beginning. Still, given that we don't use any feature
of YAML 1.2, and that the tuning data files now use YAML 1.1, switch the
internal YAML files to version 1.1 as well for consistency.

The main drawback of YAML 1.1 is that the unquoted literal strings Yes,
No, On and Off will be parsed as booleans. We need to be careful to
avoid those values in YAML files, until libcamera can switch to YAML 1.2
once more recent versions of libyaml get shipped by the distributions we
want to support.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/control_ids.yaml  | 2 +-
 src/libcamera/formats.yaml      | 2 +-
 src/libcamera/property_ids.yaml | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

Comments

Florian Sylvestre Aug. 4, 2022, 2:14 p.m. UTC | #1
On Thu, 4 Aug 2022 at 15:21, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> The python3-yaml package shipped by Debian is based on libyaml 0.2.2,
> which doesn't support YAML 1.2. It is documented as such:
>
>     Python3-yaml is a complete YAML 1.1 parser and emitter for Python3.
>
> For some reasons the internal YAML files used to generate format- and
> control-related source files still parse correctly, despite the YAML 1.2
> directive at the beginning. Still, given that we don't use any feature
> of YAML 1.2, and that the tuning data files now use YAML 1.1, switch the
> internal YAML files to version 1.1 as well for consistency.
>
> The main drawback of YAML 1.1 is that the unquoted literal strings Yes,
> No, On and Off will be parsed as booleans. We need to be careful to
> avoid those values in YAML files, until libcamera can switch to YAML 1.2
> once more recent versions of libyaml get shipped by the distributions we
> want to support.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/libcamera/control_ids.yaml  | 2 +-
>  src/libcamera/formats.yaml      | 2 +-
>  src/libcamera/property_ids.yaml | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml
> index ecab3ae97260..5510feefdfeb 100644
> --- a/src/libcamera/control_ids.yaml
> +++ b/src/libcamera/control_ids.yaml
> @@ -2,7 +2,7 @@
>  #
>  # Copyright (C) 2019, Google Inc.
>  #
> -%YAML 1.2
> +%YAML 1.1
>  ---
>  # Unless otherwise stated, all controls are bi-directional, i.e. they can be
>  # set through Request::controls() and returned out through Request::metadata().
> diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml
> index d3fbf5f47211..e586cde1d705 100644
> --- a/src/libcamera/formats.yaml
> +++ b/src/libcamera/formats.yaml
> @@ -2,7 +2,7 @@
>  #
>  # Copyright (C) 2020, Google Inc.
>  #
> -%YAML 1.2
> +%YAML 1.1
>  ---
>  formats:
>    - R8:
> diff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml
> index 11b7ebdc3105..cb55e0ed2283 100644
> --- a/src/libcamera/property_ids.yaml
> +++ b/src/libcamera/property_ids.yaml
> @@ -2,7 +2,7 @@
>  #
>  # Copyright (C) 2019, Google Inc.
>  #
> -%YAML 1.2
> +%YAML 1.1
>  ---
>  controls:
>    - Location:
> --
> Regards,
>
> Laurent Pinchart
>
Reviewed-by: Florian Sylvestre <fsylvestre@baylibre.com>
Kieran Bingham Aug. 4, 2022, 2:59 p.m. UTC | #2
Quoting Laurent Pinchart via libcamera-devel (2022-08-04 14:21:12)
> The python3-yaml package shipped by Debian is based on libyaml 0.2.2,
> which doesn't support YAML 1.2. It is documented as such:
> 
>     Python3-yaml is a complete YAML 1.1 parser and emitter for Python3.
> 
> For some reasons the internal YAML files used to generate format- and
> control-related source files still parse correctly, despite the YAML 1.2
> directive at the beginning. Still, given that we don't use any feature
> of YAML 1.2, and that the tuning data files now use YAML 1.1, switch the
> internal YAML files to version 1.1 as well for consistency.
> 
> The main drawback of YAML 1.1 is that the unquoted literal strings Yes,
> No, On and Off will be parsed as booleans. We need to be careful to
> avoid those values in YAML files, until libcamera can switch to YAML 1.2
> once more recent versions of libyaml get shipped by the distributions we
> want to support.
> 

I wonder if this also potentially explains why I saw quite a lot of odd
pixel format issues the other day.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/libcamera/control_ids.yaml  | 2 +-
>  src/libcamera/formats.yaml      | 2 +-
>  src/libcamera/property_ids.yaml | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml
> index ecab3ae97260..5510feefdfeb 100644
> --- a/src/libcamera/control_ids.yaml
> +++ b/src/libcamera/control_ids.yaml
> @@ -2,7 +2,7 @@
>  #
>  # Copyright (C) 2019, Google Inc.
>  #
> -%YAML 1.2
> +%YAML 1.1
>  ---
>  # Unless otherwise stated, all controls are bi-directional, i.e. they can be
>  # set through Request::controls() and returned out through Request::metadata().
> diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml
> index d3fbf5f47211..e586cde1d705 100644
> --- a/src/libcamera/formats.yaml
> +++ b/src/libcamera/formats.yaml
> @@ -2,7 +2,7 @@
>  #
>  # Copyright (C) 2020, Google Inc.
>  #
> -%YAML 1.2
> +%YAML 1.1
>  ---
>  formats:
>    - R8:
> diff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml
> index 11b7ebdc3105..cb55e0ed2283 100644
> --- a/src/libcamera/property_ids.yaml
> +++ b/src/libcamera/property_ids.yaml
> @@ -2,7 +2,7 @@
>  #
>  # Copyright (C) 2019, Google Inc.
>  #
> -%YAML 1.2
> +%YAML 1.1
>  ---
>  controls:
>    - Location:
> -- 
> Regards,
> 
> Laurent Pinchart
>
Laurent Pinchart Aug. 4, 2022, 4 p.m. UTC | #3
On Thu, Aug 04, 2022 at 03:59:36PM +0100, Kieran Bingham wrote:
> Quoting Laurent Pinchart via libcamera-devel (2022-08-04 14:21:12)
> > The python3-yaml package shipped by Debian is based on libyaml 0.2.2,
> > which doesn't support YAML 1.2. It is documented as such:
> > 
> >     Python3-yaml is a complete YAML 1.1 parser and emitter for Python3.
> > 
> > For some reasons the internal YAML files used to generate format- and
> > control-related source files still parse correctly, despite the YAML 1.2
> > directive at the beginning. Still, given that we don't use any feature
> > of YAML 1.2, and that the tuning data files now use YAML 1.1, switch the
> > internal YAML files to version 1.1 as well for consistency.
> > 
> > The main drawback of YAML 1.1 is that the unquoted literal strings Yes,
> > No, On and Off will be parsed as booleans. We need to be careful to
> > avoid those values in YAML files, until libcamera can switch to YAML 1.2
> > once more recent versions of libyaml get shipped by the distributions we
> > want to support.
> 
> I wonder if this also potentially explains why I saw quite a lot of odd
> pixel format issues the other day.

I'd be surprised, as this is related to build time, not run time.

I've looked at the pyyaml implementation, and it only checks that the
major version is 1, it ignores the minor version. I'll update the commit
message to

libcamera: Switch internal YAML files to YAML 1.1

The python3-yaml package (containing the PyYAML Python package) shipped
by Debian stable is documented as a YAML 1.1 parser:

    Python3-yaml is a complete YAML 1.1 parser and emitter for Python3.

PyYAML doesn't implement YAML 1.2 support, but ignores the minor number
of the YAML directive, and thus doesn't choke on the libcamera internal
files used to generate format- and control-related source code that
explicitly state conformance with YAML 1.2. Still, given that we don't
use any feature of YAML 1.2, and that the tuning data files now use YAML
1.1, switch the internal YAML files to version 1.1 as well for
consistency.

The main drawback of YAML 1.1 is that the unquoted literal strings Yes,
No, On and Off will be parsed as booleans. We need to be careful to
avoid those values in YAML files, until libcamera can switch to YAML 1.2
once more recent versions of libyaml get shipped by the distributions we
want to support. This is however not an issue introduced by this change,
as the existing YAML 1.2 files were parsed with the YAML 1.1 string
literal parsing rules anyway.

> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >  src/libcamera/control_ids.yaml  | 2 +-
> >  src/libcamera/formats.yaml      | 2 +-
> >  src/libcamera/property_ids.yaml | 2 +-
> >  3 files changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml
> > index ecab3ae97260..5510feefdfeb 100644
> > --- a/src/libcamera/control_ids.yaml
> > +++ b/src/libcamera/control_ids.yaml
> > @@ -2,7 +2,7 @@
> >  #
> >  # Copyright (C) 2019, Google Inc.
> >  #
> > -%YAML 1.2
> > +%YAML 1.1
> >  ---
> >  # Unless otherwise stated, all controls are bi-directional, i.e. they can be
> >  # set through Request::controls() and returned out through Request::metadata().
> > diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml
> > index d3fbf5f47211..e586cde1d705 100644
> > --- a/src/libcamera/formats.yaml
> > +++ b/src/libcamera/formats.yaml
> > @@ -2,7 +2,7 @@
> >  #
> >  # Copyright (C) 2020, Google Inc.
> >  #
> > -%YAML 1.2
> > +%YAML 1.1
> >  ---
> >  formats:
> >    - R8:
> > diff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml
> > index 11b7ebdc3105..cb55e0ed2283 100644
> > --- a/src/libcamera/property_ids.yaml
> > +++ b/src/libcamera/property_ids.yaml
> > @@ -2,7 +2,7 @@
> >  #
> >  # Copyright (C) 2019, Google Inc.
> >  #
> > -%YAML 1.2
> > +%YAML 1.1
> >  ---
> >  controls:
> >    - Location:

Patch
diff mbox series

diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml
index ecab3ae97260..5510feefdfeb 100644
--- a/src/libcamera/control_ids.yaml
+++ b/src/libcamera/control_ids.yaml
@@ -2,7 +2,7 @@ 
 #
 # Copyright (C) 2019, Google Inc.
 #
-%YAML 1.2
+%YAML 1.1
 ---
 # Unless otherwise stated, all controls are bi-directional, i.e. they can be
 # set through Request::controls() and returned out through Request::metadata().
diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml
index d3fbf5f47211..e586cde1d705 100644
--- a/src/libcamera/formats.yaml
+++ b/src/libcamera/formats.yaml
@@ -2,7 +2,7 @@ 
 #
 # Copyright (C) 2020, Google Inc.
 #
-%YAML 1.2
+%YAML 1.1
 ---
 formats:
   - R8:
diff --git a/src/libcamera/property_ids.yaml b/src/libcamera/property_ids.yaml
index 11b7ebdc3105..cb55e0ed2283 100644
--- a/src/libcamera/property_ids.yaml
+++ b/src/libcamera/property_ids.yaml
@@ -2,7 +2,7 @@ 
 #
 # Copyright (C) 2019, Google Inc.
 #
-%YAML 1.2
+%YAML 1.1
 ---
 controls:
   - Location: