[{"id":18763,"web_url":"https://patchwork.libcamera.org/comment/18763/","msgid":"<de02df31-8c23-d59c-a6cf-8b5aef6b31fd@ideasonboard.com>","date":"2021-08-13T10:11:53","subject":"Re: [libcamera-devel] [PATCH v2 09/10] ipa: ipu3: Move IPU3 awb\n\tinto algorithms","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"On 12/08/2021 17:52, Jean-Michel Hautbois wrote:\n> Now that the interface is properly used by the AWB class, move it into\n> ipa::ipu3::algorithms and let the loops do the calls.\n> \n> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> ---\n>  .../ipu3/{ipu3_awb.cpp => algorithms/awb.cpp} | 28 +++++++++----------\n>  src/ipa/ipu3/{ipu3_awb.h => algorithms/awb.h} | 20 ++++++-------\n>  src/ipa/ipu3/algorithms/meson.build           |  1 +\n>  src/ipa/ipu3/ipu3.cpp                         | 12 ++------\n>  src/ipa/ipu3/meson.build                      |  1 -\n>  5 files changed, 28 insertions(+), 34 deletions(-)\n>  rename src/ipa/ipu3/{ipu3_awb.cpp => algorithms/awb.cpp} (94%)\n>  rename src/ipa/ipu3/{ipu3_awb.h => algorithms/awb.h} (84%)\n> \n> diff --git a/src/ipa/ipu3/ipu3_awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp\n> similarity index 94%\n> rename from src/ipa/ipu3/ipu3_awb.cpp\n> rename to src/ipa/ipu3/algorithms/awb.cpp\n> index b422b095..0f401d6d 100644\n> --- a/src/ipa/ipu3/ipu3_awb.cpp\n> +++ b/src/ipa/ipu3/algorithms/awb.cpp\n> @@ -2,9 +2,9 @@\n>  /*\n>   * Copyright (C) 2021, Ideas On Board\n>   *\n> - * ipu3_awb.cpp - AWB control algorithm\n> + * awb.cpp - AWB control algorithm\n>   */\n> -#include \"ipu3_awb.h\"\n> +#include \"awb.h\"\n>  \n>  #include <algorithm>\n>  #include <cmath>\n> @@ -13,7 +13,7 @@\n>  \n>  namespace libcamera {\n>  \n> -namespace ipa::ipu3 {\n> +namespace ipa::ipu3::algorithms {\n>  \n>  LOG_DEFINE_CATEGORY(IPU3Awb)\n>  \n> @@ -114,7 +114,7 @@ static const struct ipu3_uapi_ccm_mat_config imguCssCcmDefault = {\n>  \t0, 0, 8191, 0\n>  };\n>  \n> -IPU3Awb::IPU3Awb()\n> +Awb::Awb()\n>  \t: Algorithm()\n>  {\n>  \tasyncResults_.blueGain = 1.0;\n> @@ -125,7 +125,7 @@ IPU3Awb::IPU3Awb()\n>  \tzones_.reserve(kAwbStatsSizeX * kAwbStatsSizeY);\n>  }\n>  \n> -IPU3Awb::~IPU3Awb()\n> +Awb::~Awb()\n>  {\n>  }\n>  \n> @@ -143,7 +143,7 @@ IPU3Awb::~IPU3Awb()\n>   * More detailed information can be found in:\n>   * https://en.wikipedia.org/wiki/Color_temperature#Approximation\n>   */\n> -uint32_t IPU3Awb::estimateCCT(double red, double green, double blue)\n> +uint32_t Awb::estimateCCT(double red, double green, double blue)\n>  {\n>  \t/* Convert the RGB values to CIE tristimulus values (XYZ) */\n>  \tdouble X = (-0.14282) * (red) + (1.54924) * (green) + (-0.95641) * (blue);\n> @@ -160,7 +160,7 @@ uint32_t IPU3Awb::estimateCCT(double red, double green, double blue)\n>  }\n>  \n>  /* Generate an RGB vector with the average values for each region */\n> -void IPU3Awb::generateZones(std::vector<RGB> &zones)\n> +void Awb::generateZones(std::vector<RGB> &zones)\n>  {\n>  \tfor (unsigned int i = 0; i < kAwbStatsSizeX * kAwbStatsSizeY; i++) {\n>  \t\tRGB zone;\n> @@ -177,7 +177,7 @@ void IPU3Awb::generateZones(std::vector<RGB> &zones)\n>  }\n>  \n>  /* Translate the IPU3 statistics into the default statistics region array */\n> -void IPU3Awb::generateAwbStats(const ipu3_uapi_stats_3a *stats)\n> +void Awb::generateAwbStats(const ipu3_uapi_stats_3a *stats)\n>  {\n>  \tuint32_t regionWidth = round(awbGrid_.width / static_cast<double>(kAwbStatsSizeX));\n>  \tuint32_t regionHeight = round(awbGrid_.height / static_cast<double>(kAwbStatsSizeY));\n> @@ -209,7 +209,7 @@ void IPU3Awb::generateAwbStats(const ipu3_uapi_stats_3a *stats)\n>  \t}\n>  }\n>  \n> -void IPU3Awb::clearAwbStats()\n> +void Awb::clearAwbStats()\n>  {\n>  \tfor (unsigned int i = 0; i < kAwbStatsSizeX * kAwbStatsSizeY; i++) {\n>  \t\tawbStats_[i].bSum = 0;\n> @@ -220,7 +220,7 @@ void IPU3Awb::clearAwbStats()\n>  \t}\n>  }\n>  \n> -void IPU3Awb::awbGreyWorld()\n> +void Awb::awbGreyWorld()\n>  {\n>  \tLOG(IPU3Awb, Debug) << \"Grey world AWB\";\n>  \t/*\n> @@ -260,7 +260,7 @@ void IPU3Awb::awbGreyWorld()\n>  \tasyncResults_.blueGain = blueGain;\n>  }\n>  \n> -void IPU3Awb::calculateWBGains(const ipu3_uapi_stats_3a *stats)\n> +void Awb::calculateWBGains(const ipu3_uapi_stats_3a *stats)\n>  {\n>  \tASSERT(stats->stats_3a_status.awb_en);\n>  \tzones_.clear();\n> @@ -275,7 +275,7 @@ void IPU3Awb::calculateWBGains(const ipu3_uapi_stats_3a *stats)\n>  \t}\n>  }\n>  \n> -void IPU3Awb::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)\n> +void Awb::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)\n>  {\n>  \tcalculateWBGains(stats);\n>  \tcontext.frameContext.awb.gains.blueGain = asyncResults_.blueGain;\n> @@ -283,7 +283,7 @@ void IPU3Awb::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)\n>  \tcontext.frameContext.awb.gains.redGain = asyncResults_.redGain;\n>  }\n>  \n> -void IPU3Awb::prepare(IPAContext &context, ipu3_uapi_params &params)\n> +void Awb::prepare(IPAContext &context, ipu3_uapi_params &params)\n>  {\n>  \tparams.use.acc_awb = 1;\n>  \tparams.acc_param.awb.config.rgbs_thr_gr = 8191;\n> @@ -327,6 +327,6 @@ void IPU3Awb::prepare(IPAContext &context, ipu3_uapi_params &params)\n>  \tparams.acc_param.ccm = imguCssCcmDefault;\n>  }\n>  \n> -} /* namespace ipa::ipu3 */\n> +} /* namespace ipa::ipu3::algorithms */\n>  \n>  } /* namespace libcamera */\n> diff --git a/src/ipa/ipu3/ipu3_awb.h b/src/ipa/ipu3/algorithms/awb.h\n> similarity index 84%\n> rename from src/ipa/ipu3/ipu3_awb.h\n> rename to src/ipa/ipu3/algorithms/awb.h\n> index 4de3fae2..ad640521 100644\n> --- a/src/ipa/ipu3/ipu3_awb.h\n> +++ b/src/ipa/ipu3/algorithms/awb.h\n> @@ -2,10 +2,10 @@\n>  /*\n>   * Copyright (C) 2021, Ideas On Board\n>   *\n> - * ipu3_awb.h - IPU3 AWB control algorithm\n> + * awb.h - IPU3 AWB control algorithm\n>   */\n> -#ifndef __LIBCAMERA_IPU3_AWB_H__\n> -#define __LIBCAMERA_IPU3_AWB_H__\n> +#ifndef __LIBCAMERA_IPU3_ALGORITHMS_AWB_H__\n> +#define __LIBCAMERA_IPU3_ALGORITHMS_AWB_H__\n>  \n>  #include <vector>\n>  \n> @@ -13,21 +13,21 @@\n>  \n>  #include <libcamera/geometry.h>\n>  \n> -#include \"algorithms/algorithm.h\"\n> +#include \"algorithm.h\"\n>  \n>  namespace libcamera {\n>  \n> -namespace ipa::ipu3 {\n> +namespace ipa::ipu3::algorithms {\n>  \n>  /* Region size for the statistics generation algorithm */\n>  static constexpr uint32_t kAwbStatsSizeX = 16;\n>  static constexpr uint32_t kAwbStatsSizeY = 12;\n>  \n> -class IPU3Awb : public Algorithm\n> +class Awb : public Algorithm\n>  {\n>  public:\n> -\tIPU3Awb();\n> -\t~IPU3Awb();\n> +\tAwb();\n> +\t~Awb();\n>  \n>  \tvoid prepare(IPAContext &context, ipu3_uapi_params &params) override;\n>  \tvoid process(IPAContext &context, const ipu3_uapi_stats_3a *stats) override;\n> @@ -85,7 +85,7 @@ private:\n>  \tAwbStatus asyncResults_;\n>  };\n>  \n> -} /* namespace ipa::ipu3 */\n> +} /* namespace ipa::ipu3::algorithms */\n>  \n>  } /* namespace libcamera*/\n> -#endif /* __LIBCAMERA_IPU3_AWB_H__ */\n> +#endif /* __LIBCAMERA_IPU3_ALGORITHMS_AWB_H__ */\n> diff --git a/src/ipa/ipu3/algorithms/meson.build b/src/ipa/ipu3/algorithms/meson.build\n> index 69a59096..9ef2dd41 100644\n> --- a/src/ipa/ipu3/algorithms/meson.build\n> +++ b/src/ipa/ipu3/algorithms/meson.build\n> @@ -1,6 +1,7 @@\n>  # SPDX-License-Identifier: CC0-1.0\n>  \n>  ipu3_ipa_algorithms = files([\n> +    'awb.cpp',\n>      'contrast.cpp',\n>      'grid.cpp',\n>  ])\n> diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\n> index 27765aa6..bea2a372 100644\n> --- a/src/ipa/ipu3/ipu3.cpp\n> +++ b/src/ipa/ipu3/ipu3.cpp\n> @@ -30,10 +30,10 @@\n>  #include \"libcamera/internal/mapped_framebuffer.h\"\n>  \n>  #include \"algorithms/algorithm.h\"\n> +#include \"algorithms/awb.h\"\n>  #include \"algorithms/contrast.h\"\n>  #include \"algorithms/grid.h\"\n>  #include \"ipu3_agc.h\"\n> -#include \"ipu3_awb.h\"\n>  #include \"libipa/camera_sensor_helper.h\"\n>  \n>  namespace libcamera {\n> @@ -84,8 +84,6 @@ private:\n>  \tuint32_t minGain_;\n>  \tuint32_t maxGain_;\n>  \n> -\t/* Interface to the AWB algorithm */\n> -\tstd::unique_ptr<IPU3Awb> awbAlgo_;\n>  \t/* Interface to the AEC/AGC algorithm */\n>  \tstd::unique_ptr<IPU3Agc> agcAlgo_;\n>  \t/* Interface to the Camera Helper */\n> @@ -168,6 +166,8 @@ int IPAIPU3::init(const IPASettings &settings,\n>  \t*ipaControls = ControlInfoMap(std::move(controls), controls::controls);\n>  \t/* Construct our Algorithms */\n>  \talgorithms_.emplace_back(new algorithms::Grid());\n> +\t/* Grid needs to be prepared before AWB */\n\nIn the next patch, you add AGC in between grid and Awb ...\n\nHow about saying 'Grid configuration must be processed before other\nalgorithms' as a comment above Grid, ... (when Grid is added, in the\ngrid patch).\n\n\nWith that,\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\n> +\talgorithms_.emplace_back(new algorithms::Awb());\n>  \talgorithms_.emplace_back(new algorithms::Contrast());\n>  \n>  \treturn 0;\n> @@ -229,8 +229,6 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo)\n>  \t\t\treturn ret;\n>  \t}\n>  \n> -\tawbAlgo_ = std::make_unique<IPU3Awb>();\n> -\n>  \tagcAlgo_ = std::make_unique<IPU3Agc>();\n>  \tagcAlgo_->configure(context_, configInfo);\n>  \n> @@ -309,8 +307,6 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)\n>  \tfor (auto const &algo : algorithms_)\n>  \t\talgo->prepare(context_, params_);\n>  \n> -\tawbAlgo_->prepare(context_, params_);\n> -\n>  \t*params = params_;\n>  \n>  \tIPU3Action op;\n> @@ -335,8 +331,6 @@ void IPAIPU3::parseStatistics(unsigned int frame,\n>  \tgain = context_.frameContext.agc.gain;\n>  \tgain_ = camHelper_->gainCode(gain);\n>  \n> -\tawbAlgo_->process(context_, stats);\n> -\n>  \tsetControls(frame);\n>  \n>  \t/* \\todo Use VBlank value calculated from each frame exposure. */\n> diff --git a/src/ipa/ipu3/meson.build b/src/ipa/ipu3/meson.build\n> index fcb27d68..d1126947 100644\n> --- a/src/ipa/ipu3/meson.build\n> +++ b/src/ipa/ipu3/meson.build\n> @@ -7,7 +7,6 @@ ipa_name = 'ipa_ipu3'\n>  ipu3_ipa_sources = files([\n>      'ipu3.cpp',\n>      'ipu3_agc.cpp',\n> -    'ipu3_awb.cpp',\n>  ])\n>  \n>  ipu3_ipa_sources += ipu3_ipa_algorithms\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 5DCFFC3240\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 13 Aug 2021 10:12:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B24AB68891;\n\tFri, 13 Aug 2021 12:12:02 +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 A9D00687FA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 13 Aug 2021 12:11:58 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2E739EE;\n\tFri, 13 Aug 2021 12:11:58 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"eWQuqWwV\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1628849518;\n\tbh=1JTBNH6z/Dizpc2++xPs8v6u30B7fXszoXlucEwOEjo=;\n\th=To:References:From:Subject:Date:In-Reply-To:From;\n\tb=eWQuqWwV5gXHYaEvsS9re2z1GQTs1B98FtuxTI17UBKzYNj78kNjYyc3mo6byRV5N\n\tCtfB+s+wwEejuAr488OGFh12DGZ3NVEwpOVkDkyeGgn2hTAB9c2kCCSeoU35E7/Awr\n\tSdDVH2rq8jAF9SnuwVbVGnaPCSzcw1axQcaibPwA=","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210812165243.276977-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20210812165243.276977-10-jeanmichel.hautbois@ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<de02df31-8c23-d59c-a6cf-8b5aef6b31fd@ideasonboard.com>","Date":"Fri, 13 Aug 2021 11:11:53 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.11.0","MIME-Version":"1.0","In-Reply-To":"<20210812165243.276977-10-jeanmichel.hautbois@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH v2 09/10] ipa: ipu3: Move IPU3 awb\n\tinto algorithms","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":18810,"web_url":"https://patchwork.libcamera.org/comment/18810/","msgid":"<YRmr1RQ5ZWNUJXY4@pendragon.ideasonboard.com>","date":"2021-08-16T00:05:41","subject":"Re: [libcamera-devel] [PATCH v2 09/10] ipa: ipu3: Move IPU3 awb\n\tinto algorithms","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jean-Michel,\n\nThank you for the patch.\n\nOn Thu, Aug 12, 2021 at 06:52:42PM +0200, Jean-Michel Hautbois wrote:\n> Now that the interface is properly used by the AWB class, move it into\n> ipa::ipu3::algorithms and let the loops do the calls.\n> \n> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  .../ipu3/{ipu3_awb.cpp => algorithms/awb.cpp} | 28 +++++++++----------\n>  src/ipa/ipu3/{ipu3_awb.h => algorithms/awb.h} | 20 ++++++-------\n>  src/ipa/ipu3/algorithms/meson.build           |  1 +\n>  src/ipa/ipu3/ipu3.cpp                         | 12 ++------\n>  src/ipa/ipu3/meson.build                      |  1 -\n>  5 files changed, 28 insertions(+), 34 deletions(-)\n>  rename src/ipa/ipu3/{ipu3_awb.cpp => algorithms/awb.cpp} (94%)\n>  rename src/ipa/ipu3/{ipu3_awb.h => algorithms/awb.h} (84%)\n> \n> diff --git a/src/ipa/ipu3/ipu3_awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp\n> similarity index 94%\n> rename from src/ipa/ipu3/ipu3_awb.cpp\n> rename to src/ipa/ipu3/algorithms/awb.cpp\n> index b422b095..0f401d6d 100644\n> --- a/src/ipa/ipu3/ipu3_awb.cpp\n> +++ b/src/ipa/ipu3/algorithms/awb.cpp\n> @@ -2,9 +2,9 @@\n>  /*\n>   * Copyright (C) 2021, Ideas On Board\n>   *\n> - * ipu3_awb.cpp - AWB control algorithm\n> + * awb.cpp - AWB control algorithm\n>   */\n> -#include \"ipu3_awb.h\"\n> +#include \"awb.h\"\n>  \n>  #include <algorithm>\n>  #include <cmath>\n> @@ -13,7 +13,7 @@\n>  \n>  namespace libcamera {\n>  \n> -namespace ipa::ipu3 {\n> +namespace ipa::ipu3::algorithms {\n>  \n>  LOG_DEFINE_CATEGORY(IPU3Awb)\n>  \n> @@ -114,7 +114,7 @@ static const struct ipu3_uapi_ccm_mat_config imguCssCcmDefault = {\n>  \t0, 0, 8191, 0\n>  };\n>  \n> -IPU3Awb::IPU3Awb()\n> +Awb::Awb()\n>  \t: Algorithm()\n>  {\n>  \tasyncResults_.blueGain = 1.0;\n> @@ -125,7 +125,7 @@ IPU3Awb::IPU3Awb()\n>  \tzones_.reserve(kAwbStatsSizeX * kAwbStatsSizeY);\n>  }\n>  \n> -IPU3Awb::~IPU3Awb()\n> +Awb::~Awb()\n>  {\n>  }\n>  \n> @@ -143,7 +143,7 @@ IPU3Awb::~IPU3Awb()\n>   * More detailed information can be found in:\n>   * https://en.wikipedia.org/wiki/Color_temperature#Approximation\n>   */\n> -uint32_t IPU3Awb::estimateCCT(double red, double green, double blue)\n> +uint32_t Awb::estimateCCT(double red, double green, double blue)\n>  {\n>  \t/* Convert the RGB values to CIE tristimulus values (XYZ) */\n>  \tdouble X = (-0.14282) * (red) + (1.54924) * (green) + (-0.95641) * (blue);\n> @@ -160,7 +160,7 @@ uint32_t IPU3Awb::estimateCCT(double red, double green, double blue)\n>  }\n>  \n>  /* Generate an RGB vector with the average values for each region */\n> -void IPU3Awb::generateZones(std::vector<RGB> &zones)\n> +void Awb::generateZones(std::vector<RGB> &zones)\n>  {\n>  \tfor (unsigned int i = 0; i < kAwbStatsSizeX * kAwbStatsSizeY; i++) {\n>  \t\tRGB zone;\n> @@ -177,7 +177,7 @@ void IPU3Awb::generateZones(std::vector<RGB> &zones)\n>  }\n>  \n>  /* Translate the IPU3 statistics into the default statistics region array */\n> -void IPU3Awb::generateAwbStats(const ipu3_uapi_stats_3a *stats)\n> +void Awb::generateAwbStats(const ipu3_uapi_stats_3a *stats)\n>  {\n>  \tuint32_t regionWidth = round(awbGrid_.width / static_cast<double>(kAwbStatsSizeX));\n>  \tuint32_t regionHeight = round(awbGrid_.height / static_cast<double>(kAwbStatsSizeY));\n> @@ -209,7 +209,7 @@ void IPU3Awb::generateAwbStats(const ipu3_uapi_stats_3a *stats)\n>  \t}\n>  }\n>  \n> -void IPU3Awb::clearAwbStats()\n> +void Awb::clearAwbStats()\n>  {\n>  \tfor (unsigned int i = 0; i < kAwbStatsSizeX * kAwbStatsSizeY; i++) {\n>  \t\tawbStats_[i].bSum = 0;\n> @@ -220,7 +220,7 @@ void IPU3Awb::clearAwbStats()\n>  \t}\n>  }\n>  \n> -void IPU3Awb::awbGreyWorld()\n> +void Awb::awbGreyWorld()\n>  {\n>  \tLOG(IPU3Awb, Debug) << \"Grey world AWB\";\n>  \t/*\n> @@ -260,7 +260,7 @@ void IPU3Awb::awbGreyWorld()\n>  \tasyncResults_.blueGain = blueGain;\n>  }\n>  \n> -void IPU3Awb::calculateWBGains(const ipu3_uapi_stats_3a *stats)\n> +void Awb::calculateWBGains(const ipu3_uapi_stats_3a *stats)\n>  {\n>  \tASSERT(stats->stats_3a_status.awb_en);\n>  \tzones_.clear();\n> @@ -275,7 +275,7 @@ void IPU3Awb::calculateWBGains(const ipu3_uapi_stats_3a *stats)\n>  \t}\n>  }\n>  \n> -void IPU3Awb::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)\n> +void Awb::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)\n>  {\n>  \tcalculateWBGains(stats);\n>  \tcontext.frameContext.awb.gains.blueGain = asyncResults_.blueGain;\n> @@ -283,7 +283,7 @@ void IPU3Awb::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)\n>  \tcontext.frameContext.awb.gains.redGain = asyncResults_.redGain;\n>  }\n>  \n> -void IPU3Awb::prepare(IPAContext &context, ipu3_uapi_params &params)\n> +void Awb::prepare(IPAContext &context, ipu3_uapi_params &params)\n>  {\n>  \tparams.use.acc_awb = 1;\n>  \tparams.acc_param.awb.config.rgbs_thr_gr = 8191;\n> @@ -327,6 +327,6 @@ void IPU3Awb::prepare(IPAContext &context, ipu3_uapi_params &params)\n>  \tparams.acc_param.ccm = imguCssCcmDefault;\n>  }\n>  \n> -} /* namespace ipa::ipu3 */\n> +} /* namespace ipa::ipu3::algorithms */\n>  \n>  } /* namespace libcamera */\n> diff --git a/src/ipa/ipu3/ipu3_awb.h b/src/ipa/ipu3/algorithms/awb.h\n> similarity index 84%\n> rename from src/ipa/ipu3/ipu3_awb.h\n> rename to src/ipa/ipu3/algorithms/awb.h\n> index 4de3fae2..ad640521 100644\n> --- a/src/ipa/ipu3/ipu3_awb.h\n> +++ b/src/ipa/ipu3/algorithms/awb.h\n> @@ -2,10 +2,10 @@\n>  /*\n>   * Copyright (C) 2021, Ideas On Board\n>   *\n> - * ipu3_awb.h - IPU3 AWB control algorithm\n> + * awb.h - IPU3 AWB control algorithm\n>   */\n> -#ifndef __LIBCAMERA_IPU3_AWB_H__\n> -#define __LIBCAMERA_IPU3_AWB_H__\n> +#ifndef __LIBCAMERA_IPU3_ALGORITHMS_AWB_H__\n> +#define __LIBCAMERA_IPU3_ALGORITHMS_AWB_H__\n>  \n>  #include <vector>\n>  \n> @@ -13,21 +13,21 @@\n>  \n>  #include <libcamera/geometry.h>\n>  \n> -#include \"algorithms/algorithm.h\"\n> +#include \"algorithm.h\"\n>  \n>  namespace libcamera {\n>  \n> -namespace ipa::ipu3 {\n> +namespace ipa::ipu3::algorithms {\n>  \n>  /* Region size for the statistics generation algorithm */\n>  static constexpr uint32_t kAwbStatsSizeX = 16;\n>  static constexpr uint32_t kAwbStatsSizeY = 12;\n>  \n> -class IPU3Awb : public Algorithm\n> +class Awb : public Algorithm\n>  {\n>  public:\n> -\tIPU3Awb();\n> -\t~IPU3Awb();\n> +\tAwb();\n> +\t~Awb();\n>  \n>  \tvoid prepare(IPAContext &context, ipu3_uapi_params &params) override;\n>  \tvoid process(IPAContext &context, const ipu3_uapi_stats_3a *stats) override;\n> @@ -85,7 +85,7 @@ private:\n>  \tAwbStatus asyncResults_;\n>  };\n>  \n> -} /* namespace ipa::ipu3 */\n> +} /* namespace ipa::ipu3::algorithms */\n>  \n>  } /* namespace libcamera*/\n> -#endif /* __LIBCAMERA_IPU3_AWB_H__ */\n> +#endif /* __LIBCAMERA_IPU3_ALGORITHMS_AWB_H__ */\n> diff --git a/src/ipa/ipu3/algorithms/meson.build b/src/ipa/ipu3/algorithms/meson.build\n> index 69a59096..9ef2dd41 100644\n> --- a/src/ipa/ipu3/algorithms/meson.build\n> +++ b/src/ipa/ipu3/algorithms/meson.build\n> @@ -1,6 +1,7 @@\n>  # SPDX-License-Identifier: CC0-1.0\n>  \n>  ipu3_ipa_algorithms = files([\n> +    'awb.cpp',\n>      'contrast.cpp',\n>      'grid.cpp',\n>  ])\n> diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\n> index 27765aa6..bea2a372 100644\n> --- a/src/ipa/ipu3/ipu3.cpp\n> +++ b/src/ipa/ipu3/ipu3.cpp\n> @@ -30,10 +30,10 @@\n>  #include \"libcamera/internal/mapped_framebuffer.h\"\n>  \n>  #include \"algorithms/algorithm.h\"\n> +#include \"algorithms/awb.h\"\n>  #include \"algorithms/contrast.h\"\n>  #include \"algorithms/grid.h\"\n>  #include \"ipu3_agc.h\"\n> -#include \"ipu3_awb.h\"\n>  #include \"libipa/camera_sensor_helper.h\"\n>  \n>  namespace libcamera {\n> @@ -84,8 +84,6 @@ private:\n>  \tuint32_t minGain_;\n>  \tuint32_t maxGain_;\n>  \n> -\t/* Interface to the AWB algorithm */\n> -\tstd::unique_ptr<IPU3Awb> awbAlgo_;\n>  \t/* Interface to the AEC/AGC algorithm */\n>  \tstd::unique_ptr<IPU3Agc> agcAlgo_;\n>  \t/* Interface to the Camera Helper */\n> @@ -168,6 +166,8 @@ int IPAIPU3::init(const IPASettings &settings,\n>  \t*ipaControls = ControlInfoMap(std::move(controls), controls::controls);\n>  \t/* Construct our Algorithms */\n>  \talgorithms_.emplace_back(new algorithms::Grid());\n> +\t/* Grid needs to be prepared before AWB */\n> +\talgorithms_.emplace_back(new algorithms::Awb());\n>  \talgorithms_.emplace_back(new algorithms::Contrast());\n>  \n>  \treturn 0;\n> @@ -229,8 +229,6 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo)\n>  \t\t\treturn ret;\n>  \t}\n>  \n> -\tawbAlgo_ = std::make_unique<IPU3Awb>();\n> -\n>  \tagcAlgo_ = std::make_unique<IPU3Agc>();\n>  \tagcAlgo_->configure(context_, configInfo);\n>  \n> @@ -309,8 +307,6 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)\n>  \tfor (auto const &algo : algorithms_)\n>  \t\talgo->prepare(context_, params_);\n>  \n> -\tawbAlgo_->prepare(context_, params_);\n> -\n>  \t*params = params_;\n>  \n>  \tIPU3Action op;\n> @@ -335,8 +331,6 @@ void IPAIPU3::parseStatistics(unsigned int frame,\n>  \tgain = context_.frameContext.agc.gain;\n>  \tgain_ = camHelper_->gainCode(gain);\n>  \n> -\tawbAlgo_->process(context_, stats);\n> -\n>  \tsetControls(frame);\n>  \n>  \t/* \\todo Use VBlank value calculated from each frame exposure. */\n> diff --git a/src/ipa/ipu3/meson.build b/src/ipa/ipu3/meson.build\n> index fcb27d68..d1126947 100644\n> --- a/src/ipa/ipu3/meson.build\n> +++ b/src/ipa/ipu3/meson.build\n> @@ -7,7 +7,6 @@ ipa_name = 'ipa_ipu3'\n>  ipu3_ipa_sources = files([\n>      'ipu3.cpp',\n>      'ipu3_agc.cpp',\n> -    'ipu3_awb.cpp',\n>  ])\n>  \n>  ipu3_ipa_sources += ipu3_ipa_algorithms","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 7D731BD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 16 Aug 2021 00:05:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E9B6968893;\n\tMon, 16 Aug 2021 02:05:48 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A782B60261\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 16 Aug 2021 02:05:47 +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 25ADE2C5;\n\tMon, 16 Aug 2021 02:05:47 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"sU1jEH/W\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1629072347;\n\tbh=F50UIIkv1FH2kgm790YW5m6zKeWHCuvy2cixF4VAsi4=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=sU1jEH/WGy/W+i0EmnP2if8B1kHbPq3KxLUrRvIqUSrMlYlF5QnX4K+OpcNM3KAJY\n\tFuQNYdJ16paH8HE6J+G6rTxv+li0NQQWx1/oGS5o/oWG0+uLc1jKXj6lo0qrwH8pp7\n\txl3h/oI1Ry0YtRAJykWKoQQOM0P7cWtYqnpHqPM4=","Date":"Mon, 16 Aug 2021 03:05:41 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<YRmr1RQ5ZWNUJXY4@pendragon.ideasonboard.com>","References":"<20210812165243.276977-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20210812165243.276977-10-jeanmichel.hautbois@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210812165243.276977-10-jeanmichel.hautbois@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 09/10] ipa: ipu3: Move IPU3 awb\n\tinto algorithms","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]