<div dir="ltr"><span class="gmail-im">>> +                                   << settings.configurationFile << ": " << strerror(-ret);<br>
>> +             return ret;<br>
>> +     }<br>
>> +<br>
>> +     int ret = parseConfigurationFile(fh);<br>
>> +<br>
>> +     fclose(fh);<br></span>>I've submitted a patch series that switches from FILE to File,<br>
>simplyfing error handling and cleanup. Could you rebase this series on<br><div>
>top of it for a v2 ?</div><div>The issue that I have with that is YamlParser is consuming std::FILE</div><div>header, and if I did not see how to retrieve the file header while using</div><div>File Class (I suppose it's expected). So, do you have a hint (other than</div><div>updating YamlParser Class)?</div><div><br></div><div>Regards,</div><div>Florian.<br></div><div><span class="gmail-im"></span></div><div><span class="gmail-im"></span></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le jeu. 26 mai 2022 à 01:23, Laurent Pinchart <<a href="mailto:laurent.pinchart@ideasonboard.com">laurent.pinchart@ideasonboard.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Florian,<br>
<br>
Thank you for the patch.<br>
<br>
On Mon, May 23, 2022 at 11:24:33AM +0200, Florian Sylvestre via libcamera-devel wrote:<br>
> Retrieve root node in Yaml configuration file and provide to<br>
> each algorithm this YamlObject to allow them to grab their default<br>
> parameters by calling init() function.<br>
> <br>
> Signed-off-by: Florian Sylvestre <<a href="mailto:fsylvestre@baylibre.com" target="_blank">fsylvestre@baylibre.com</a>><br>
> ---<br>
>  src/ipa/rkisp1/algorithms/algorithm.h |  4 ++-<br>
>  src/ipa/rkisp1/rkisp1.cpp             | 36 +++++++++++++++++++++++++++<br>
>  2 files changed, 39 insertions(+), 1 deletion(-)<br>
> <br>
> diff --git a/src/ipa/rkisp1/algorithms/algorithm.h b/src/ipa/rkisp1/algorithms/algorithm.h<br>
> index d46c3188..5b95fd30 100644<br>
> --- a/src/ipa/rkisp1/algorithms/algorithm.h<br>
> +++ b/src/ipa/rkisp1/algorithms/algorithm.h<br>
> @@ -17,9 +17,11 @@<br>
>  <br>
>  namespace libcamera {<br>
>  <br>
> +class YamlObject;<br>
> +<br>
>  namespace ipa::rkisp1 {<br>
>  <br>
> -using Algorithm = libcamera::ipa::Algorithm<IPAContext, IPACameraSensorInfo, rkisp1_params_cfg, rkisp1_stat_buffer>;<br>
> +using Algorithm = libcamera::ipa::Algorithm<IPAContext, YamlObject, IPACameraSensorInfo, rkisp1_params_cfg, rkisp1_stat_buffer>;<br>
>  <br>
>  } /* namespace ipa::rkisp1 */<br>
>  <br>
> diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp<br>
> index 23cb95b5..c44514c2 100644<br>
> --- a/src/ipa/rkisp1/rkisp1.cpp<br>
> +++ b/src/ipa/rkisp1/rkisp1.cpp<br>
> @@ -24,6 +24,7 @@<br>
>  #include <libcamera/request.h><br>
>  <br>
>  #include <libcamera/internal/mapped_framebuffer.h><br>
> +#include <libcamera/internal/yaml_parser.h><br>
>  <br>
>  #include "algorithms/agc.h"<br>
>  #include "algorithms/algorithm.h"<br>
> @@ -61,6 +62,7 @@ public:<br>
>  private:<br>
>       void setControls(unsigned int frame);<br>
>       void prepareMetadata(unsigned int frame, unsigned int aeState);<br>
> +     int parseConfigurationFile(FILE *fh);<br>
>  <br>
>       std::map<unsigned int, FrameBuffer> buffers_;<br>
>       std::map<unsigned int, MappedFrameBuffer> mappedBuffers_;<br>
> @@ -126,6 +128,40 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision)<br>
>       algorithms_.push_back(std::make_unique<algorithms::Awb>());<br>
>       algorithms_.push_back(std::make_unique<algorithms::BlackLevelCorrection>());<br>
>  <br>
> +     /* Load the tuning file for this sensor. */<br>
> +     FILE *fh = fopen(settings.configurationFile.c_str(), "r");<br>
> +     if (!fh) {<br>
> +             int ret = -errno;<br>
> +             LOG(IPARkISP1, Error) << "Failed to open configuration file "<br>
<br>
"tuning file" here too, as in patch 1/5 ?<br>
<br>
> +                                   << settings.configurationFile << ": " << strerror(-ret);<br>
> +             return ret;<br>
> +     }<br>
> +<br>
> +     int ret = parseConfigurationFile(fh);<br>
> +<br>
> +     fclose(fh);<br>
<br>
I've submitted a patch series that switches from FILE to File,<br>
simplyfing error handling and cleanup. Could you rebase this series on<br>
top of it for a v2 ?<br>
<br>
> +     if (ret)<br>
> +             return -EINVAL;<br>
> +<br>
> +     return 0;<br>
> +}<br>
> +<br>
> +int IPARkISP1::parseConfigurationFile(FILE *fh)<br>
> +{<br>
> +     std::unique_ptr<libcamera::YamlObject> root = YamlParser::parse(fh);<br>
> +     if (!root)<br>
> +             return -EINVAL;<br>
> +<br>
> +     if (!root->isDictionary())<br>
> +             return -EINVAL;<br>
> +<br>
> +     /* Allow each algo to get parameters from configuration file. */<br>
> +     for (auto const &algo : algorithms_) {<br>
> +             int ret = algo->init(context_, root.get());<br>
> +             if (ret)<br>
> +                     return ret;<br>
> +     }<br>
> +<br>
>       return 0;<br>
>  }<br>
>  <br>
<br>
-- <br>
Regards,<br>
<br>
Laurent Pinchart<br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr">Florian Sylvestre<br></div></div>