[{"id":23152,"web_url":"https://patchwork.libcamera.org/comment/23152/","msgid":"<Yo66aueP57ctSyxL@pendragon.ideasonboard.com>","date":"2022-05-25T23:23:22","subject":"Re: [libcamera-devel] [libcamera-devel 3/5] ipa: rkisp1: Add Yaml\n\tconfiguration file support","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Florian,\n\nThank you for the patch.\n\nOn Mon, May 23, 2022 at 11:24:33AM +0200, Florian Sylvestre via libcamera-devel wrote:\n> Retrieve root node in Yaml configuration file and provide to\n> each algorithm this YamlObject to allow them to grab their default\n> parameters by calling init() function.\n> \n> Signed-off-by: Florian Sylvestre <fsylvestre@baylibre.com>\n> ---\n>  src/ipa/rkisp1/algorithms/algorithm.h |  4 ++-\n>  src/ipa/rkisp1/rkisp1.cpp             | 36 +++++++++++++++++++++++++++\n>  2 files changed, 39 insertions(+), 1 deletion(-)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/algorithm.h b/src/ipa/rkisp1/algorithms/algorithm.h\n> index d46c3188..5b95fd30 100644\n> --- a/src/ipa/rkisp1/algorithms/algorithm.h\n> +++ b/src/ipa/rkisp1/algorithms/algorithm.h\n> @@ -17,9 +17,11 @@\n>  \n>  namespace libcamera {\n>  \n> +class YamlObject;\n> +\n>  namespace ipa::rkisp1 {\n>  \n> -using Algorithm = libcamera::ipa::Algorithm<IPAContext, IPACameraSensorInfo, rkisp1_params_cfg, rkisp1_stat_buffer>;\n> +using Algorithm = libcamera::ipa::Algorithm<IPAContext, YamlObject, IPACameraSensorInfo, rkisp1_params_cfg, rkisp1_stat_buffer>;\n>  \n>  } /* namespace ipa::rkisp1 */\n>  \n> diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\n> index 23cb95b5..c44514c2 100644\n> --- a/src/ipa/rkisp1/rkisp1.cpp\n> +++ b/src/ipa/rkisp1/rkisp1.cpp\n> @@ -24,6 +24,7 @@\n>  #include <libcamera/request.h>\n>  \n>  #include <libcamera/internal/mapped_framebuffer.h>\n> +#include <libcamera/internal/yaml_parser.h>\n>  \n>  #include \"algorithms/agc.h\"\n>  #include \"algorithms/algorithm.h\"\n> @@ -61,6 +62,7 @@ public:\n>  private:\n>  \tvoid setControls(unsigned int frame);\n>  \tvoid prepareMetadata(unsigned int frame, unsigned int aeState);\n> +\tint parseConfigurationFile(FILE *fh);\n>  \n>  \tstd::map<unsigned int, FrameBuffer> buffers_;\n>  \tstd::map<unsigned int, MappedFrameBuffer> mappedBuffers_;\n> @@ -126,6 +128,40 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision)\n>  \talgorithms_.push_back(std::make_unique<algorithms::Awb>());\n>  \talgorithms_.push_back(std::make_unique<algorithms::BlackLevelCorrection>());\n>  \n> +\t/* Load the tuning file for this sensor. */\n> +\tFILE *fh = fopen(settings.configurationFile.c_str(), \"r\");\n> +\tif (!fh) {\n> +\t\tint ret = -errno;\n> +\t\tLOG(IPARkISP1, Error) << \"Failed to open configuration file \"\n\n\"tuning file\" here too, as in patch 1/5 ?\n\n> +\t\t\t\t      << settings.configurationFile << \": \" << strerror(-ret);\n> +\t\treturn ret;\n> +\t}\n> +\n> +\tint ret = parseConfigurationFile(fh);\n> +\n> +\tfclose(fh);\n\nI've submitted a patch series that switches from FILE to File,\nsimplyfing error handling and cleanup. Could you rebase this series on\ntop of it for a v2 ?\n\n> +\tif (ret)\n> +\t\treturn -EINVAL;\n> +\n> +\treturn 0;\n> +}\n> +\n> +int IPARkISP1::parseConfigurationFile(FILE *fh)\n> +{\n> +\tstd::unique_ptr<libcamera::YamlObject> root = YamlParser::parse(fh);\n> +\tif (!root)\n> +\t\treturn -EINVAL;\n> +\n> +\tif (!root->isDictionary())\n> +\t\treturn -EINVAL;\n> +\n> +\t/* Allow each algo to get parameters from configuration file. */\n> +\tfor (auto const &algo : algorithms_) {\n> +\t\tint ret = algo->init(context_, root.get());\n> +\t\tif (ret)\n> +\t\t\treturn ret;\n> +\t}\n> +\n>  \treturn 0;\n>  }\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 47086BD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 25 May 2022 23:23:30 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5473A65663;\n\tThu, 26 May 2022 01:23:29 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 07B9460422\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 May 2022 01:23:28 +0200 (CEST)","from pendragon.ideasonboard.com (ip-109-40-242-63.web.vodafone.de\n\t[109.40.242.63])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6BF5D496;\n\tThu, 26 May 2022 01:23:27 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1653521009;\n\tbh=6DWB7gxA0qU2b8s0dpS4bQtRBuFWITbEi29vBFHdoTQ=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=qTUCsUQFI8wegB8sn8BxYH7cZoQv1slol+/pN3xDmy8txNikdutro8L3x16LP3MIq\n\tPPmwVEO+2froKm0f0zc7xz519g8j9+H4DrEhGLBvA+GN8N9rYly7da+YJnyzpwZsek\n\tl3BQkVaUfeQcnw1PfYwC9znCIXaHAv7ahrlJof+vv4JLb0QNynw8LWMELcFuk8c2Dw\n\tLij+XvHPzd5O4khtJ8xN9VRKeCViBEH/K4yULrRRPbvVw1O3HG/6Ilm3tXBKRJiImo\n\tERUm8ZjbSuefwaX/qEa3RklPKVVAYQyACCUHDVg6qEmD2rLIuvNfXy1UiRVpuoiRyp\n\tWgYLcNDuxXtGA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1653521007;\n\tbh=6DWB7gxA0qU2b8s0dpS4bQtRBuFWITbEi29vBFHdoTQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=uEIAGSRbsyr8mnvCJYnq86pLJGizIJ++1wuhUKXMnOWqBFAwWYlKMMcO81dvm7zOs\n\tApWI8Ptn7ui8ltwJ1v9CEoKgYxqxNhuO0yT7R+13xFb9MN1Cei6370pr3pssfGu78X\n\t6LStGy9KdXMxF2WqHl3b5GQv066sAjt6nZwg/mjU="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"uEIAGSRb\"; dkim-atps=neutral","Date":"Thu, 26 May 2022 02:23:22 +0300","To":"Florian Sylvestre <fsylvestre@baylibre.com>","Message-ID":"<Yo66aueP57ctSyxL@pendragon.ideasonboard.com>","References":"<20220523092435.475510-1-fsylvestre@baylibre.com>\n\t<20220523092435.475510-4-fsylvestre@baylibre.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220523092435.475510-4-fsylvestre@baylibre.com>","Subject":"Re: [libcamera-devel] [libcamera-devel 3/5] ipa: rkisp1: Add Yaml\n\tconfiguration file support","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23276,"web_url":"https://patchwork.libcamera.org/comment/23276/","msgid":"<CALzBHU7+mFPxHnn1dAG-a0AKTaPVR7wzJOGL7v=Wx4H1EGacHg@mail.gmail.com>","date":"2022-06-01T08:13:09","subject":"Re: [libcamera-devel] [libcamera-devel 3/5] ipa: rkisp1: Add Yaml\n\tconfiguration file support","submitter":{"id":123,"url":"https://patchwork.libcamera.org/api/people/123/","name":"Florian Sylvestre","email":"fsylvestre@baylibre.com"},"content":">> +                                   << settings.configurationFile << \":\n\" << strerror(-ret);\n>> +             return ret;\n>> +     }\n>> +\n>> +     int ret = parseConfigurationFile(fh);\n>> +\n>> +     fclose(fh);\n>I've submitted a patch series that switches from FILE to File,\n>simplyfing error handling and cleanup. Could you rebase this series on\n>top of it for a v2 ?\nThe issue that I have with that is YamlParser is consuming std::FILE\nheader, and if I did not see how to retrieve the file header while using\nFile Class (I suppose it's expected). So, do you have a hint (other than\nupdating YamlParser Class)?\n\nRegards,\nFlorian.\n\nLe jeu. 26 mai 2022 à 01:23, Laurent Pinchart <\nlaurent.pinchart@ideasonboard.com> a écrit :\n\n> Hi Florian,\n>\n> Thank you for the patch.\n>\n> On Mon, May 23, 2022 at 11:24:33AM +0200, Florian Sylvestre via\n> libcamera-devel wrote:\n> > Retrieve root node in Yaml configuration file and provide to\n> > each algorithm this YamlObject to allow them to grab their default\n> > parameters by calling init() function.\n> >\n> > Signed-off-by: Florian Sylvestre <fsylvestre@baylibre.com>\n> > ---\n> >  src/ipa/rkisp1/algorithms/algorithm.h |  4 ++-\n> >  src/ipa/rkisp1/rkisp1.cpp             | 36 +++++++++++++++++++++++++++\n> >  2 files changed, 39 insertions(+), 1 deletion(-)\n> >\n> > diff --git a/src/ipa/rkisp1/algorithms/algorithm.h\n> b/src/ipa/rkisp1/algorithms/algorithm.h\n> > index d46c3188..5b95fd30 100644\n> > --- a/src/ipa/rkisp1/algorithms/algorithm.h\n> > +++ b/src/ipa/rkisp1/algorithms/algorithm.h\n> > @@ -17,9 +17,11 @@\n> >\n> >  namespace libcamera {\n> >\n> > +class YamlObject;\n> > +\n> >  namespace ipa::rkisp1 {\n> >\n> > -using Algorithm = libcamera::ipa::Algorithm<IPAContext,\n> IPACameraSensorInfo, rkisp1_params_cfg, rkisp1_stat_buffer>;\n> > +using Algorithm = libcamera::ipa::Algorithm<IPAContext, YamlObject,\n> IPACameraSensorInfo, rkisp1_params_cfg, rkisp1_stat_buffer>;\n> >\n> >  } /* namespace ipa::rkisp1 */\n> >\n> > diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\n> > index 23cb95b5..c44514c2 100644\n> > --- a/src/ipa/rkisp1/rkisp1.cpp\n> > +++ b/src/ipa/rkisp1/rkisp1.cpp\n> > @@ -24,6 +24,7 @@\n> >  #include <libcamera/request.h>\n> >\n> >  #include <libcamera/internal/mapped_framebuffer.h>\n> > +#include <libcamera/internal/yaml_parser.h>\n> >\n> >  #include \"algorithms/agc.h\"\n> >  #include \"algorithms/algorithm.h\"\n> > @@ -61,6 +62,7 @@ public:\n> >  private:\n> >       void setControls(unsigned int frame);\n> >       void prepareMetadata(unsigned int frame, unsigned int aeState);\n> > +     int parseConfigurationFile(FILE *fh);\n> >\n> >       std::map<unsigned int, FrameBuffer> buffers_;\n> >       std::map<unsigned int, MappedFrameBuffer> mappedBuffers_;\n> > @@ -126,6 +128,40 @@ int IPARkISP1::init(const IPASettings &settings,\n> unsigned int hwRevision)\n> >       algorithms_.push_back(std::make_unique<algorithms::Awb>());\n> >\n>  algorithms_.push_back(std::make_unique<algorithms::BlackLevelCorrection>());\n> >\n> > +     /* Load the tuning file for this sensor. */\n> > +     FILE *fh = fopen(settings.configurationFile.c_str(), \"r\");\n> > +     if (!fh) {\n> > +             int ret = -errno;\n> > +             LOG(IPARkISP1, Error) << \"Failed to open configuration\n> file \"\n>\n> \"tuning file\" here too, as in patch 1/5 ?\n>\n> > +                                   << settings.configurationFile << \":\n> \" << strerror(-ret);\n> > +             return ret;\n> > +     }\n> > +\n> > +     int ret = parseConfigurationFile(fh);\n> > +\n> > +     fclose(fh);\n>\n> I've submitted a patch series that switches from FILE to File,\n> simplyfing error handling and cleanup. Could you rebase this series on\n> top of it for a v2 ?\n>\n> > +     if (ret)\n> > +             return -EINVAL;\n> > +\n> > +     return 0;\n> > +}\n> > +\n> > +int IPARkISP1::parseConfigurationFile(FILE *fh)\n> > +{\n> > +     std::unique_ptr<libcamera::YamlObject> root =\n> YamlParser::parse(fh);\n> > +     if (!root)\n> > +             return -EINVAL;\n> > +\n> > +     if (!root->isDictionary())\n> > +             return -EINVAL;\n> > +\n> > +     /* Allow each algo to get parameters from configuration file. */\n> > +     for (auto const &algo : algorithms_) {\n> > +             int ret = algo->init(context_, root.get());\n> > +             if (ret)\n> > +                     return ret;\n> > +     }\n> > +\n> >       return 0;\n> >  }\n> >\n>\n> --\n> Regards,\n>\n> Laurent Pinchart\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 7C675BD161\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  1 Jun 2022 08:13:25 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 32E5665632;\n\tWed,  1 Jun 2022 10:13:25 +0200 (CEST)","from mail-pg1-x532.google.com (mail-pg1-x532.google.com\n\t[IPv6:2607:f8b0:4864:20::532])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4FA7E60414\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  1 Jun 2022 10:13:23 +0200 (CEST)","by mail-pg1-x532.google.com with SMTP id e66so1207118pgc.8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 01 Jun 2022 01:13:23 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1654071205;\n\tbh=Lv0BSUU8O67EEfOE2jp//mWqGIly8Kkc0PBuqjM3w1U=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=QYHbb05j703/hDhzTREeQsQUmlvPdewsnSJd2R600SjcflnO9oZeWg3Dm/05OhSWx\n\t0ho+XBqRkeZi5N7/ukhhnIiClFgbdFAZKnzrnu4tIovDvPJqqwMPNTcrn8eGkWIGA6\n\tLD3mAmxuzQ5JG9r5b5TP1WtBqSP33SxfHK/luSGm3hXcNSlsV3emzmxYC3bQ9NBZt2\n\tsLibSpE0xNfPsNjetxmKCBAvRVc8t9NYMaVxvmiOKgCC+d7fEzO01qxS7zPgioXnW8\n\tATNY98aFSDwyLGfh9H/VjuD5DBeqVuosRxECNh/zJmwKrd+lp2OjjIw4PLScIHYt5m\n\tMFeCaJ7ImI8zQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=baylibre-com.20210112.gappssmtp.com; s=20210112;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=f+THE0GfryxoSIcbFbkeXTmRFWjQQJ5n1V1huWvwDUE=;\n\tb=i0bKrNfoVcli2ZtTc/zTH4lFsm8gvwTiityJ9DQ051yVTNAkrL4iKlSe6k2BsR1V5B\n\t0DdwlyIb0x/kYbL+MaVNXoa5KsgBeN1h6NAtkyzebYhLgY1UOCMz29y1n0HazHLQiVpW\n\tx9KG0orlXIjZ0noTJEW/asVGQlbghJRG91alH/RlkJgmN5houcCrbhBMgvkpzrUpK3iA\n\tiQ/vTYyzzhL+viQqYodiqhSedLWrD5w+p43APCNF0qLlxPJHbw2mKwZjHIUtizu2Do+R\n\t57yBL8b2RppuX+SCKnQ/tPcL6mAafj9zbRoEQwv7jGJV9QHEedYVL1Tw7PLtvjkXSnL6\n\tGBQQ=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=baylibre-com.20210112.gappssmtp.com\n\theader.i=@baylibre-com.20210112.gappssmtp.com header.b=\"i0bKrNfo\"; \n\tdkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=f+THE0GfryxoSIcbFbkeXTmRFWjQQJ5n1V1huWvwDUE=;\n\tb=xy2LNOZ+OgVVsE1wsFXQNcHeOxSyYtkZkvVq7G/+hcLCitRSHDlpcte8IRrjb8ytAG\n\tx2J1BnZR/NwvIfc5oVr6LlN2jO77CIt6t58saRd6PZcu+8/JKbcOFg8jZHf/Xj3eLa7H\n\tY/6a6K/ozCQt2gk7NIv+Q97wNF/NPilrzKe2f7KwjsOU53ygaIDmSS8VFjPrx8E0Qyv7\n\tLj0495mkykRy1uhXaSt04OoNvsn7VqDjotUofxp0t9D+ujZCUOyiaylKIBWs/HHBcn89\n\tWd41SGTcnAimTd/wHidU2n6Yfxh59amLL2Sju1PRrjpiVVfmJ+hgX+om9L80Le9z8LQD\n\tdmsw==","X-Gm-Message-State":"AOAM533ZE3jqtfihV2JPAqkUcliMKwgRoenz3PG6faYrriHqbrj6N+PP\n\tdKUwrMs+HxtK0TXoVrOLYFHKf1tajO0u9cKqmRooAhyp4KR7oQ==","X-Google-Smtp-Source":"ABdhPJwaM9yerJj3J74nyGjzV0WkXaOxS22fmBebHsFeM0MrPPnAkOtQr8w5QbLNemdZ0APRTJne9lltyKdpS8x5OLY=","X-Received":"by 2002:a05:6a00:451a:b0:51b:680d:2199 with SMTP id\n\tcw26-20020a056a00451a00b0051b680d2199mr8230795pfb.25.1654071201701;\n\tWed, 01 Jun 2022 01:13:21 -0700 (PDT)","MIME-Version":"1.0","References":"<20220523092435.475510-1-fsylvestre@baylibre.com>\n\t<20220523092435.475510-4-fsylvestre@baylibre.com>\n\t<Yo66aueP57ctSyxL@pendragon.ideasonboard.com>","In-Reply-To":"<Yo66aueP57ctSyxL@pendragon.ideasonboard.com>","Date":"Wed, 1 Jun 2022 10:13:09 +0200","Message-ID":"<CALzBHU7+mFPxHnn1dAG-a0AKTaPVR7wzJOGL7v=Wx4H1EGacHg@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"multipart/alternative; boundary=\"00000000000069336005e05e76ed\"","Subject":"Re: [libcamera-devel] [libcamera-devel 3/5] ipa: rkisp1: Add Yaml\n\tconfiguration file support","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Florian Sylvestre via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Florian Sylvestre <fsylvestre@baylibre.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23359,"web_url":"https://patchwork.libcamera.org/comment/23359/","msgid":"<YqEaiy21sYv8Hcch@pendragon.ideasonboard.com>","date":"2022-06-08T21:54:19","subject":"Re: [libcamera-devel] [libcamera-devel 3/5] ipa: rkisp1: Add Yaml\n\tconfiguration file support","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Florian,\n\nOn Wed, Jun 01, 2022 at 10:13:09AM +0200, Florian Sylvestre wrote:\n> >> +                                   << settings.configurationFile << \": \" << strerror(-ret);\n> >> +             return ret;\n> >> +     }\n> >> +\n> >> +     int ret = parseConfigurationFile(fh);\n> >> +\n> >> +     fclose(fh);\n> > \n> > I've submitted a patch series that switches from FILE to File,\n> > simplyfing error handling and cleanup. Could you rebase this series on\n> > top of it for a v2 ?\n> \n> The issue that I have with that is YamlParser is consuming std::FILE\n> header, and if I did not see how to retrieve the file header while using\n> File Class (I suppose it's expected). So, do you have a hint (other than\n> updating YamlParser Class)?\n\nYou can use the\nhttps://gitlab.com/ideasonboard/nxp/libcamera/-/tree/pinchartl/yaml\nbranch which contains a rework of the YamlParser class. In particular,\nhttps://gitlab.com/ideasonboard/nxp/libcamera/-/commit/40ec4b367c74252bb8a8ac4d81fed8068cac0b6f\nswitches from FILE to File. I expect the series to get merged soon.\n\n> Le jeu. 26 mai 2022 à 01:23, Laurent Pinchart a écrit :\n> > On Mon, May 23, 2022 at 11:24:33AM +0200, Florian Sylvestre wrote:\n> > > Retrieve root node in Yaml configuration file and provide to\n> > > each algorithm this YamlObject to allow them to grab their default\n> > > parameters by calling init() function.\n> > >\n> > > Signed-off-by: Florian Sylvestre <fsylvestre@baylibre.com>\n> > > ---\n> > >  src/ipa/rkisp1/algorithms/algorithm.h |  4 ++-\n> > >  src/ipa/rkisp1/rkisp1.cpp             | 36 +++++++++++++++++++++++++++\n> > >  2 files changed, 39 insertions(+), 1 deletion(-)\n> > >\n> > > diff --git a/src/ipa/rkisp1/algorithms/algorithm.h b/src/ipa/rkisp1/algorithms/algorithm.h\n> > > index d46c3188..5b95fd30 100644\n> > > --- a/src/ipa/rkisp1/algorithms/algorithm.h\n> > > +++ b/src/ipa/rkisp1/algorithms/algorithm.h\n> > > @@ -17,9 +17,11 @@\n> > >\n> > >  namespace libcamera {\n> > >\n> > > +class YamlObject;\n> > > +\n> > >  namespace ipa::rkisp1 {\n> > >\n> > > -using Algorithm = libcamera::ipa::Algorithm<IPAContext, IPACameraSensorInfo, rkisp1_params_cfg, rkisp1_stat_buffer>;\n> > > +using Algorithm = libcamera::ipa::Algorithm<IPAContext, YamlObject, IPACameraSensorInfo, rkisp1_params_cfg, rkisp1_stat_buffer>;\n> > >\n> > >  } /* namespace ipa::rkisp1 */\n> > >\n> > > diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\n> > > index 23cb95b5..c44514c2 100644\n> > > --- a/src/ipa/rkisp1/rkisp1.cpp\n> > > +++ b/src/ipa/rkisp1/rkisp1.cpp\n> > > @@ -24,6 +24,7 @@\n> > >  #include <libcamera/request.h>\n> > >\n> > >  #include <libcamera/internal/mapped_framebuffer.h>\n> > > +#include <libcamera/internal/yaml_parser.h>\n> > >\n> > >  #include \"algorithms/agc.h\"\n> > >  #include \"algorithms/algorithm.h\"\n> > > @@ -61,6 +62,7 @@ public:\n> > >  private:\n> > >       void setControls(unsigned int frame);\n> > >       void prepareMetadata(unsigned int frame, unsigned int aeState);\n> > > +     int parseConfigurationFile(FILE *fh);\n> > >\n> > >       std::map<unsigned int, FrameBuffer> buffers_;\n> > >       std::map<unsigned int, MappedFrameBuffer> mappedBuffers_;\n> > > @@ -126,6 +128,40 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision)\n> > >       algorithms_.push_back(std::make_unique<algorithms::Awb>());\n> > >\n> >  algorithms_.push_back(std::make_unique<algorithms::BlackLevelCorrection>());\n> > >\n> > > +     /* Load the tuning file for this sensor. */\n> > > +     FILE *fh = fopen(settings.configurationFile.c_str(), \"r\");\n> > > +     if (!fh) {\n> > > +             int ret = -errno;\n> > > +             LOG(IPARkISP1, Error) << \"Failed to open configuration file \"\n> >\n> > \"tuning file\" here too, as in patch 1/5 ?\n> >\n> > > +                                   << settings.configurationFile << \":\n> > \" << strerror(-ret);\n> > > +             return ret;\n> > > +     }\n> > > +\n> > > +     int ret = parseConfigurationFile(fh);\n> > > +\n> > > +     fclose(fh);\n> >\n> > I've submitted a patch series that switches from FILE to File,\n> > simplyfing error handling and cleanup. Could you rebase this series on\n> > top of it for a v2 ?\n> >\n> > > +     if (ret)\n> > > +             return -EINVAL;\n> > > +\n> > > +     return 0;\n> > > +}\n> > > +\n> > > +int IPARkISP1::parseConfigurationFile(FILE *fh)\n> > > +{\n> > > +     std::unique_ptr<libcamera::YamlObject> root = YamlParser::parse(fh);\n> > > +     if (!root)\n> > > +             return -EINVAL;\n> > > +\n> > > +     if (!root->isDictionary())\n> > > +             return -EINVAL;\n> > > +\n> > > +     /* Allow each algo to get parameters from configuration file. */\n> > > +     for (auto const &algo : algorithms_) {\n> > > +             int ret = algo->init(context_, root.get());\n> > > +             if (ret)\n> > > +                     return ret;\n> > > +     }\n> > > +\n> > >       return 0;\n> > >  }\n> > >","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 90642BD161\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  8 Jun 2022 21:54:27 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B83F165635;\n\tWed,  8 Jun 2022 23:54:26 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 048FF65632\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Jun 2022 23:54:25 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 794606CF;\n\tWed,  8 Jun 2022 23:54:24 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1654725266;\n\tbh=0PCOHHhLM2422iQot/EiSfKMN7P2A/vPCf/LDGoqeB4=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=b6iksGiehdKWxlAWgMdVM91bW6avuedeLJLa0fHSBJubP9sHOSn55IfvSPNz82ELC\n\tIrq5jVAEXhCLiVLD+NaN1W51WdKkEQ7VdBu0YWuFXCMqCg2FvXlOm7x/aPXUkGUGCn\n\t+9lPy4tBNJal2huHhxTHrdz3W2ANRjI2Tcid1KfHGunshukKf+7A/hei2gpFxC/f0p\n\tdqmPZpOqpDrS8H2sishwOnoMdqZJLTSU9fV9LSG+fPF+vl0/WvdDTKk+rkMeRLqmTK\n\t4mLIowvOR0y5gs834YYyM0YvAHtk7ZkG1ZZHWSzGydKgTFNQ7W0e2FkO2oqGjnhOkp\n\tjJo6eV4Ey3xrw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1654725264;\n\tbh=0PCOHHhLM2422iQot/EiSfKMN7P2A/vPCf/LDGoqeB4=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=cQ/wbZts9By9hC2PLcB0z3y0d5FvuO+pmU4JcNnhHWKK0Y2+YFhbqYtmLcPBJN4hS\n\t2to7WGnEkuQL+DnuLzy6bdWbmQX3nNlpyfkPLkYwtjI2Ly7wFavEp83HZDh0Vx/XI9\n\thkShJHgyj7F6oe71mlYJo6yQ7+etwSYdn98GoScY="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"cQ/wbZts\"; dkim-atps=neutral","Date":"Thu, 9 Jun 2022 00:54:19 +0300","To":"Florian Sylvestre <fsylvestre@baylibre.com>","Message-ID":"<YqEaiy21sYv8Hcch@pendragon.ideasonboard.com>","References":"<20220523092435.475510-1-fsylvestre@baylibre.com>\n\t<20220523092435.475510-4-fsylvestre@baylibre.com>\n\t<Yo66aueP57ctSyxL@pendragon.ideasonboard.com>\n\t<CALzBHU7+mFPxHnn1dAG-a0AKTaPVR7wzJOGL7v=Wx4H1EGacHg@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<CALzBHU7+mFPxHnn1dAG-a0AKTaPVR7wzJOGL7v=Wx4H1EGacHg@mail.gmail.com>","Subject":"Re: [libcamera-devel] [libcamera-devel 3/5] ipa: rkisp1: Add Yaml\n\tconfiguration file support","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]