ipa: libipa: Handle missing YAML nodes in Interpolator
diff mbox series

Message ID 20260528071909.547179-1-shaunakkdatar@gmail.com
State Accepted
Headers show
Series
  • ipa: libipa: Handle missing YAML nodes in Interpolator
Related show

Commit Message

Shaunak Datar May 28, 2026, 7:19 a.m. UTC
Interpolator::readYaml() currently logs an error when passed an empty
YAML object because it expects the node to always be a list.

Optional tuning parameters such as colourGains in the AWB Grey algorithm
may be absent from the tuning files. rkisp1 uses tuning files without a
colourGains section.

Return -ENOENT for empty YAML nodes before validating the node to avoid
ERROR logs while still reporting a warning to the caller.

Fixes: #323

Signed-off-by: Shaunak Datar <shaunakkdatar@gmail.com>
---
 src/ipa/libipa/interpolator.h | 3 +++
 1 file changed, 3 insertions(+)

Comments

Kieran Bingham June 3, 2026, 11:42 a.m. UTC | #1
Quoting Shaunak Datar (2026-05-28 08:19:09)
> Interpolator::readYaml() currently logs an error when passed an empty
> YAML object because it expects the node to always be a list.
> 
> Optional tuning parameters such as colourGains in the AWB Grey algorithm
> may be absent from the tuning files. rkisp1 uses tuning files without a
> colourGains section.
> 
> Return -ENOENT for empty YAML nodes before validating the node to avoid
> ERROR logs while still reporting a warning to the caller.

This sounds quite reasonable to me so far, but it's hard for me to
visualise if this means we'll ignore different errors.

Though - now I see issue #323 shows me what I was missing!

> Fixes: #323



This should be:

Closes: https://gitlab.freedesktop.org/camera/libcamera/-/work_items/323

But we can update that while applying.


So this works for me, I'd be happy to hear if anyone who dabbles more in
the IPA has any concerns about this ... Stefan ?


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

> 
> Signed-off-by: Shaunak Datar <shaunakkdatar@gmail.com>
> ---
>  src/ipa/libipa/interpolator.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/src/ipa/libipa/interpolator.h b/src/ipa/libipa/interpolator.h
> index cc4b27b5..01bd8140 100644
> --- a/src/ipa/libipa/interpolator.h
> +++ b/src/ipa/libipa/interpolator.h
> @@ -46,6 +46,9 @@ public:
>                 data_.clear();
>                 lastInterpolatedKey_.reset();
>  
> +               if (yaml.isEmpty())
> +                       return -ENOENT;
> +
>                 if (!yaml.isList()) {
>                         LOG(Interpolator, Error) << "yaml object must be a list";
>                         return -EINVAL;
> -- 
> 2.54.0
>
Laurent Pinchart June 11, 2026, 1:20 a.m. UTC | #2
On Wed, Jun 03, 2026 at 12:42:02PM +0100, Kieran Bingham wrote:
> Quoting Shaunak Datar (2026-05-28 08:19:09)
> > Interpolator::readYaml() currently logs an error when passed an empty
> > YAML object because it expects the node to always be a list.
> > 
> > Optional tuning parameters such as colourGains in the AWB Grey algorithm
> > may be absent from the tuning files. rkisp1 uses tuning files without a
> > colourGains section.
> > 
> > Return -ENOENT for empty YAML nodes before validating the node to avoid
> > ERROR logs while still reporting a warning to the caller.
> 
> This sounds quite reasonable to me so far, but it's hard for me to
> visualise if this means we'll ignore different errors.
> 
> Though - now I see issue #323 shows me what I was missing!
> 
> > Fixes: #323
> 
> This should be:
> 
> Closes: https://gitlab.freedesktop.org/camera/libcamera/-/work_items/323
> 
> But we can update that while applying.
> 
> So this works for me, I'd be happy to hear if anyone who dabbles more in
> the IPA has any concerns about this ... Stefan ?
> 
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

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

> > Signed-off-by: Shaunak Datar <shaunakkdatar@gmail.com>
> > ---
> >  src/ipa/libipa/interpolator.h | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/src/ipa/libipa/interpolator.h b/src/ipa/libipa/interpolator.h
> > index cc4b27b5..01bd8140 100644
> > --- a/src/ipa/libipa/interpolator.h
> > +++ b/src/ipa/libipa/interpolator.h
> > @@ -46,6 +46,9 @@ public:
> >                 data_.clear();
> >                 lastInterpolatedKey_.reset();
> >  
> > +               if (yaml.isEmpty())
> > +                       return -ENOENT;
> > +
> >                 if (!yaml.isList()) {
> >                         LOG(Interpolator, Error) << "yaml object must be a list";
> >                         return -EINVAL;

Patch
diff mbox series

diff --git a/src/ipa/libipa/interpolator.h b/src/ipa/libipa/interpolator.h
index cc4b27b5..01bd8140 100644
--- a/src/ipa/libipa/interpolator.h
+++ b/src/ipa/libipa/interpolator.h
@@ -46,6 +46,9 @@  public:
 		data_.clear();
 		lastInterpolatedKey_.reset();
 
+		if (yaml.isEmpty())
+			return -ENOENT;
+
 		if (!yaml.isList()) {
 			LOG(Interpolator, Error) << "yaml object must be a list";
 			return -EINVAL;