[{"id":23419,"web_url":"https://patchwork.libcamera.org/comment/23419/","msgid":"<YqrwFelnNICs7cTY@pendragon.ideasonboard.com>","date":"2022-06-16T08:55:49","subject":"Re: [libcamera-devel] [PATCH v2 2/5] ipa: libipa: Add init()\n\tfunction to the Algorithm class","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 Thu, Jun 16, 2022 at 10:07:41AM +0200, Florian Sylvestre via libcamera-devel wrote:\n> Add the init() function that will be called during algorithm initialization\n> to provide each algorithm the list of algorithms tuning data.\n> Each algorithm will be responsible to grab their corresponding parameters.\n> \n> Signed-off-by: Florian Sylvestre <fsylvestre@baylibre.com>\n> ---\n>  src/ipa/ipu3/algorithms/algorithm.h |  4 +++-\n>  src/ipa/libipa/algorithm.cpp        | 16 ++++++++++++++++\n>  src/ipa/libipa/algorithm.h          | 10 +++++++++-\n>  3 files changed, 28 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/ipa/ipu3/algorithms/algorithm.h b/src/ipa/ipu3/algorithms/algorithm.h\n> index d2eecc78..32cdfe52 100644\n> --- a/src/ipa/ipu3/algorithms/algorithm.h\n> +++ b/src/ipa/ipu3/algorithms/algorithm.h\n> @@ -15,9 +15,11 @@\n>  \n>  namespace libcamera {\n>  \n> +class YamlObject;\n> +\n>  namespace ipa::ipu3 {\n>  \n> -using Algorithm = libcamera::ipa::Algorithm<IPAContext, IPAConfigInfo, ipu3_uapi_params, ipu3_uapi_stats_3a>;\n> +using Algorithm = libcamera::ipa::Algorithm<IPAContext, YamlObject, IPAConfigInfo, ipu3_uapi_params, ipu3_uapi_stats_3a>;\n\nThis is getting long, I'd wrap it as\n\nusing Algorithm = libcamera::ipa::Algorithm<IPAContext, YamlObject, IPAConfigInfo,\n\t\t\t\t\t    ipu3_uapi_params, ipu3_uapi_stats_3a>;\n\n>  \n>  } /* namespace ipa::ipu3 */\n>  \n> diff --git a/src/ipa/libipa/algorithm.cpp b/src/ipa/libipa/algorithm.cpp\n> index 398d5372..3424610b 100644\n> --- a/src/ipa/libipa/algorithm.cpp\n> +++ b/src/ipa/libipa/algorithm.cpp\n> @@ -29,6 +29,22 @@ namespace ipa {\n>   * to manage algorithms regardless of their specific type.\n>   */\n>  \n> +/**\n> + * \\fn Algorithm::init()\n> + * \\brief Configure the Algorithm with default parameters\n> + * \\param[in] context The shared IPA context\n> + * \\param[in] params The initial parameters used to tune algorithms\n> + *\n> + * This function is called once before the camera is running to get default\n> + * algorithm parameters.\n\nI think this sentence is a leftover of v1, it can be dropped.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> + * This function is called once, when the IPA module is initialized, to\n> + * initialize the algorithm. The \\a params YamlObject contains IPA module\n> + * parameters, typically tuning data for all algorithms. The Algorithm is\n> + * responsible for reading the parameters relevant to its configuration.\n> + *\n> + * \\return 0 if successful, an error code otherwise\n> + */\n> +\n>  /**\n>   * \\fn Algorithm::configure()\n>   * \\brief Configure the Algorithm given an IPAConfigInfo\n> diff --git a/src/ipa/libipa/algorithm.h b/src/ipa/libipa/algorithm.h\n> index 766aee5d..f5be1caf 100644\n> --- a/src/ipa/libipa/algorithm.h\n> +++ b/src/ipa/libipa/algorithm.h\n> @@ -10,12 +10,20 @@ namespace libcamera {\n>  \n>  namespace ipa {\n>  \n> -template<typename Context, typename Config, typename Params, typename Stats>\n> +template<typename Context, typename TuningData,\n> +\t typename Config, typename Params, typename Stats>\n> +\n>  class Algorithm\n>  {\n>  public:\n>  \tvirtual ~Algorithm() {}\n>  \n> +\tvirtual int init([[maybe_unused]] Context &context,\n> +\t\t\t [[maybe_unused]] const TuningData *params)\n> +\t{\n> +\t\treturn 0;\n> +\t}\n> +\n>  \tvirtual int configure([[maybe_unused]] Context &context,\n>  \t\t\t      [[maybe_unused]] const Config &configInfo)\n>  \t{","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 B7786BD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 16 Jun 2022 08:56:01 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6C83F65635;\n\tThu, 16 Jun 2022 10:56:01 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6899D601F1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 16 Jun 2022 10:56:00 +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 EEE4B415;\n\tThu, 16 Jun 2022 10:55:59 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1655369761;\n\tbh=/rx/Aa2tauRTPNagJAIB9rj0G6XipDunW9HDM/Kci8g=;\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=IXb53QgWSv0cm0XjE7fl3rIkIQiA0g8y7JVIgNDS6zF5/gGEmaoAa1T2X4El/fst9\n\tR+Lh/qut7PUEV2VljtuScsQJaY1r1DHrShgh4HUlwyvOa7R9pOmAmE2Lut7G9sxH/B\n\tL2TLskrB8LmFr81h5nx1dzFZWCEumC+vS1BsV6TryN4tlwqtsNQf8REqEW07TdGurf\n\tFzcWpGxWKaE+NHjxFOExiAXVWV3t5yWlPmvX34qUf3UkpT4hAwLbX7wJGB08Jb5CDg\n\tXYt68//80tCatJ/jciHuIS2Iz1CHsHRbsehBkR8EPWXc5Oa6GEYkDDevMI6phU1r4r\n\t6fZ7tW8o+WyjA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1655369760;\n\tbh=/rx/Aa2tauRTPNagJAIB9rj0G6XipDunW9HDM/Kci8g=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=JzDdIgBKGGuIuC+Mi8ecZRKPl3Gxe03cfWNB5Inf1pUni0XRAGD/zMqKVvy+fR1h6\n\tPgqV896vU1GzQBIJhBDgGooE9WgtOaClO65ZhVXX29iCsSmLXXar3dJHSMRp/T0hK7\n\trAIUBb/p6biDugXksXDUUNK6zcZKuDBGUSB6gPtE="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"JzDdIgBK\"; dkim-atps=neutral","Date":"Thu, 16 Jun 2022 11:55:49 +0300","To":"Florian Sylvestre <fsylvestre@baylibre.com>","Message-ID":"<YqrwFelnNICs7cTY@pendragon.ideasonboard.com>","References":"<20220616080744.548995-1-fsylvestre@baylibre.com>\n\t<20220616080744.548995-3-fsylvestre@baylibre.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220616080744.548995-3-fsylvestre@baylibre.com>","Subject":"Re: [libcamera-devel] [PATCH v2 2/5] ipa: libipa: Add init()\n\tfunction to the Algorithm class","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>"}}]