Show a patch.

GET /api/patches/17664/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 17664,
    "url": "https://patchwork.libcamera.org/api/patches/17664/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/17664/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20221024000356.29521-2-laurent.pinchart@ideasonboard.com>",
    "date": "2022-10-24T00:03:44",
    "name": "[libcamera-devel,v3,01/13] ipa: Sort algorithm operations based on calling order",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "632a1e3c68d65edaab988ff11a2c47a13281f590",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/17664/mbox/",
    "series": [
        {
            "id": 3574,
            "url": "https://patchwork.libcamera.org/api/series/3574/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3574",
            "date": "2022-10-24T00:03:43",
            "name": "Add Bayer format support for RkISP1",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/3574/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/17664/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/17664/checks/",
    "tags": {},
    "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 CDF7CBDB16\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 24 Oct 2022 00:04:26 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A30C062ED4;\n\tMon, 24 Oct 2022 02:04:24 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2309D62EA6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 24 Oct 2022 02:04:23 +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 99E24471;\n\tMon, 24 Oct 2022 02:04:22 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1666569864;\n\tbh=vgw+hsZqZ1Sox8PqtwxEJBX1S5VSzB6m7IptRVqtDbg=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=Er3RzuO99oPSDiTF2DMso8UVo/S9RGYHG8OHtJZn9AA579OBTl6nTqmIQ0AQM4Zp9\n\tbW0EWLJ8rBGpaLfL2OcHgp4v3hJJzdu4SeKv0uJkZ6EHFIppNgH2GHQ2gmTqht+yJf\n\t7RbkxFkPuZlMHGYqWiZQqp60weSODND13B/3gMK9rB5Za0WiLnM131SFt4zyuN9KWW\n\tmN7QrGpwMYkTUBiQPWSzxF6r0/fSkyUGkNGPBl25/mSMFJtcoTy6T/GHfUmDMjdF3/\n\tPEmdQxu52JTjBzyvkWBAgCl4Vb2kb/zimwamHG4DOwMDu+62eHFIocD31L0culPO4T\n\tKGWxekRv1dkVQ==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1666569862;\n\tbh=vgw+hsZqZ1Sox8PqtwxEJBX1S5VSzB6m7IptRVqtDbg=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=Uv+st2HSKwaPsQmKLQgex1lPXmkahm+h5sTUqlRUNFdLcGD0DGIAwYTV+jNAOExKu\n\t9ctGo8x4pV4sAUrtQNXB2sJUnfaLHjJo3SCBd0k6+GShu4doxSLoEjyS+eonlXfycO\n\tCCJeBkiMKmOTORqK7I2BMlEabeJZARGuUJdKnCzw="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"Uv+st2HS\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 24 Oct 2022 03:03:44 +0300",
        "Message-Id": "<20221024000356.29521-2-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.37.4",
        "In-Reply-To": "<20221024000356.29521-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20221024000356.29521-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 01/13] ipa: Sort algorithm operations\n\tbased on calling order",
        "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>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Reorder functions in the base ipa::Algorithm and its derived classes to\nmatch the calling order: queueRequest(), prepare() and process(). This\nmakes the code flow easier to read. No functional change intended.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/ipu3/algorithms/af.cpp    |  32 +++---\n src/ipa/ipu3/algorithms/awb.cpp   | 166 +++++++++++++++---------------\n src/ipa/libipa/algorithm.cpp      |  34 +++---\n src/ipa/libipa/algorithm.h        |  14 +--\n src/ipa/rkisp1/algorithms/agc.cpp |  80 +++++++-------\n src/ipa/rkisp1/algorithms/awb.cpp |  94 ++++++++---------\n src/ipa/rkisp1/algorithms/awb.h   |   6 +-\n 7 files changed, 213 insertions(+), 213 deletions(-)",
    "diff": "diff --git a/src/ipa/ipu3/algorithms/af.cpp b/src/ipa/ipu3/algorithms/af.cpp\nindex 5a0452a5719b..12927eecf613 100644\n--- a/src/ipa/ipu3/algorithms/af.cpp\n+++ b/src/ipa/ipu3/algorithms/af.cpp\n@@ -113,22 +113,6 @@ Af::Af()\n {\n }\n \n-/**\n- * \\copydoc libcamera::ipa::Algorithm::prepare\n- */\n-void Af::prepare(IPAContext &context,\n-\t\t [[maybe_unused]] const uint32_t frame,\n-\t\t [[maybe_unused]] IPAFrameContext &frameContext,\n-\t\t ipu3_uapi_params *params)\n-{\n-\tconst struct ipu3_uapi_grid_config &grid = context.configuration.af.afGrid;\n-\tparams->acc_param.af.grid_cfg = grid;\n-\tparams->acc_param.af.filter_config = afFilterConfigDefault;\n-\n-\t/* Enable AF processing block */\n-\tparams->use.acc_af = 1;\n-}\n-\n /**\n  * \\brief Configure the Af given a configInfo\n  * \\param[in] context The shared IPA context\n@@ -197,6 +181,22 @@ int Af::configure(IPAContext &context, const IPAConfigInfo &configInfo)\n \treturn 0;\n }\n \n+/**\n+ * \\copydoc libcamera::ipa::Algorithm::prepare\n+ */\n+void Af::prepare(IPAContext &context,\n+\t\t [[maybe_unused]] const uint32_t frame,\n+\t\t [[maybe_unused]] IPAFrameContext &frameContext,\n+\t\t ipu3_uapi_params *params)\n+{\n+\tconst struct ipu3_uapi_grid_config &grid = context.configuration.af.afGrid;\n+\tparams->acc_param.af.grid_cfg = grid;\n+\tparams->acc_param.af.filter_config = afFilterConfigDefault;\n+\n+\t/* Enable AF processing block */\n+\tparams->use.acc_af = 1;\n+}\n+\n /**\n  * \\brief AF coarse scan\n  * \\param[in] context The shared IPA context\ndiff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp\nindex dd7ebc07c534..5abd46215833 100644\n--- a/src/ipa/ipu3/algorithms/awb.cpp\n+++ b/src/ipa/ipu3/algorithms/awb.cpp\n@@ -218,6 +218,89 @@ int Awb::configure(IPAContext &context,\n \treturn 0;\n }\n \n+constexpr uint16_t Awb::threshold(float value)\n+{\n+\t/* AWB thresholds are in the range [0, 8191] */\n+\treturn value * 8191;\n+}\n+\n+constexpr uint16_t Awb::gainValue(double gain)\n+{\n+\t/*\n+\t * The colour gains applied by the BNR for the four channels (Gr, R, B\n+\t * and Gb) are expressed in the parameters structure as 16-bit integers\n+\t * that store a fixed-point U3.13 value in the range [0, 8[.\n+\t *\n+\t * The real gain value is equal to the gain parameter plus one, i.e.\n+\t *\n+\t * Pout = Pin * (1 + gain / 8192)\n+\t *\n+\t * where 'Pin' is the input pixel value, 'Pout' the output pixel value,\n+\t * and 'gain' the gain in the parameters structure as a 16-bit integer.\n+\t */\n+\treturn std::clamp((gain - 1.0) * 8192, 0.0, 65535.0);\n+}\n+\n+/**\n+ * \\copydoc libcamera::ipa::Algorithm::prepare\n+ */\n+void Awb::prepare(IPAContext &context,\n+\t\t  [[maybe_unused]] const uint32_t frame,\n+\t\t  [[maybe_unused]] IPAFrameContext &frameContext,\n+\t\t  ipu3_uapi_params *params)\n+{\n+\t/*\n+\t * Green saturation thresholds are reduced because we are using the\n+\t * green channel only in the exposure computation.\n+\t */\n+\tparams->acc_param.awb.config.rgbs_thr_r = threshold(1.0);\n+\tparams->acc_param.awb.config.rgbs_thr_gr = threshold(0.9);\n+\tparams->acc_param.awb.config.rgbs_thr_gb = threshold(0.9);\n+\tparams->acc_param.awb.config.rgbs_thr_b = threshold(1.0);\n+\n+\t/*\n+\t * Enable saturation inclusion on thr_b for ImgU to update the\n+\t * ipu3_uapi_awb_set_item->sat_ratio field.\n+\t */\n+\tparams->acc_param.awb.config.rgbs_thr_b |= IPU3_UAPI_AWB_RGBS_THR_B_INCL_SAT |\n+\t\t\t\t\t\t   IPU3_UAPI_AWB_RGBS_THR_B_EN;\n+\n+\tconst ipu3_uapi_grid_config &grid = context.configuration.grid.bdsGrid;\n+\n+\tparams->acc_param.awb.config.grid = context.configuration.grid.bdsGrid;\n+\n+\t/*\n+\t * Optical center is column start (respectively row start) of the\n+\t * cell of interest minus its X center (respectively Y center).\n+\t *\n+\t * For the moment use BDS as a first approximation, but it should\n+\t * be calculated based on Shading (SHD) parameters.\n+\t */\n+\tparams->acc_param.bnr = imguCssBnrDefaults;\n+\tSize &bdsOutputSize = context.configuration.grid.bdsOutputSize;\n+\tparams->acc_param.bnr.column_size = bdsOutputSize.width;\n+\tparams->acc_param.bnr.opt_center.x_reset = grid.x_start - (bdsOutputSize.width / 2);\n+\tparams->acc_param.bnr.opt_center.y_reset = grid.y_start - (bdsOutputSize.height / 2);\n+\tparams->acc_param.bnr.opt_center_sqr.x_sqr_reset = params->acc_param.bnr.opt_center.x_reset\n+\t\t\t\t\t\t\t* params->acc_param.bnr.opt_center.x_reset;\n+\tparams->acc_param.bnr.opt_center_sqr.y_sqr_reset = params->acc_param.bnr.opt_center.y_reset\n+\t\t\t\t\t\t\t* params->acc_param.bnr.opt_center.y_reset;\n+\n+\tparams->acc_param.bnr.wb_gains.gr = gainValue(context.activeState.awb.gains.green);\n+\tparams->acc_param.bnr.wb_gains.r  = gainValue(context.activeState.awb.gains.red);\n+\tparams->acc_param.bnr.wb_gains.b  = gainValue(context.activeState.awb.gains.blue);\n+\tparams->acc_param.bnr.wb_gains.gb = gainValue(context.activeState.awb.gains.green);\n+\n+\tLOG(IPU3Awb, Debug) << \"Color temperature estimated: \" << asyncResults_.temperatureK;\n+\n+\t/* The CCM matrix may change when color temperature will be used */\n+\tparams->acc_param.ccm = imguCssCcmDefault;\n+\n+\tparams->use.acc_awb = 1;\n+\tparams->use.acc_bnr = 1;\n+\tparams->use.acc_ccm = 1;\n+}\n+\n /**\n  * The function estimates the correlated color temperature using\n  * from RGB color space input.\n@@ -415,89 +498,6 @@ void Awb::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n \t\t     context.activeState.awb.temperatureK);\n }\n \n-constexpr uint16_t Awb::threshold(float value)\n-{\n-\t/* AWB thresholds are in the range [0, 8191] */\n-\treturn value * 8191;\n-}\n-\n-constexpr uint16_t Awb::gainValue(double gain)\n-{\n-\t/*\n-\t * The colour gains applied by the BNR for the four channels (Gr, R, B\n-\t * and Gb) are expressed in the parameters structure as 16-bit integers\n-\t * that store a fixed-point U3.13 value in the range [0, 8[.\n-\t *\n-\t * The real gain value is equal to the gain parameter plus one, i.e.\n-\t *\n-\t * Pout = Pin * (1 + gain / 8192)\n-\t *\n-\t * where 'Pin' is the input pixel value, 'Pout' the output pixel value,\n-\t * and 'gain' the gain in the parameters structure as a 16-bit integer.\n-\t */\n-\treturn std::clamp((gain - 1.0) * 8192, 0.0, 65535.0);\n-}\n-\n-/**\n- * \\copydoc libcamera::ipa::Algorithm::prepare\n- */\n-void Awb::prepare(IPAContext &context,\n-\t\t  [[maybe_unused]] const uint32_t frame,\n-\t\t  [[maybe_unused]] IPAFrameContext &frameContext,\n-\t\t  ipu3_uapi_params *params)\n-{\n-\t/*\n-\t * Green saturation thresholds are reduced because we are using the\n-\t * green channel only in the exposure computation.\n-\t */\n-\tparams->acc_param.awb.config.rgbs_thr_r = threshold(1.0);\n-\tparams->acc_param.awb.config.rgbs_thr_gr = threshold(0.9);\n-\tparams->acc_param.awb.config.rgbs_thr_gb = threshold(0.9);\n-\tparams->acc_param.awb.config.rgbs_thr_b = threshold(1.0);\n-\n-\t/*\n-\t * Enable saturation inclusion on thr_b for ImgU to update the\n-\t * ipu3_uapi_awb_set_item->sat_ratio field.\n-\t */\n-\tparams->acc_param.awb.config.rgbs_thr_b |= IPU3_UAPI_AWB_RGBS_THR_B_INCL_SAT |\n-\t\t\t\t\t\t   IPU3_UAPI_AWB_RGBS_THR_B_EN;\n-\n-\tconst ipu3_uapi_grid_config &grid = context.configuration.grid.bdsGrid;\n-\n-\tparams->acc_param.awb.config.grid = context.configuration.grid.bdsGrid;\n-\n-\t/*\n-\t * Optical center is column start (respectively row start) of the\n-\t * cell of interest minus its X center (respectively Y center).\n-\t *\n-\t * For the moment use BDS as a first approximation, but it should\n-\t * be calculated based on Shading (SHD) parameters.\n-\t */\n-\tparams->acc_param.bnr = imguCssBnrDefaults;\n-\tSize &bdsOutputSize = context.configuration.grid.bdsOutputSize;\n-\tparams->acc_param.bnr.column_size = bdsOutputSize.width;\n-\tparams->acc_param.bnr.opt_center.x_reset = grid.x_start - (bdsOutputSize.width / 2);\n-\tparams->acc_param.bnr.opt_center.y_reset = grid.y_start - (bdsOutputSize.height / 2);\n-\tparams->acc_param.bnr.opt_center_sqr.x_sqr_reset = params->acc_param.bnr.opt_center.x_reset\n-\t\t\t\t\t\t\t* params->acc_param.bnr.opt_center.x_reset;\n-\tparams->acc_param.bnr.opt_center_sqr.y_sqr_reset = params->acc_param.bnr.opt_center.y_reset\n-\t\t\t\t\t\t\t* params->acc_param.bnr.opt_center.y_reset;\n-\n-\tparams->acc_param.bnr.wb_gains.gr = gainValue(context.activeState.awb.gains.green);\n-\tparams->acc_param.bnr.wb_gains.r  = gainValue(context.activeState.awb.gains.red);\n-\tparams->acc_param.bnr.wb_gains.b  = gainValue(context.activeState.awb.gains.blue);\n-\tparams->acc_param.bnr.wb_gains.gb = gainValue(context.activeState.awb.gains.green);\n-\n-\tLOG(IPU3Awb, Debug) << \"Color temperature estimated: \" << asyncResults_.temperatureK;\n-\n-\t/* The CCM matrix may change when color temperature will be used */\n-\tparams->acc_param.ccm = imguCssCcmDefault;\n-\n-\tparams->use.acc_awb = 1;\n-\tparams->use.acc_bnr = 1;\n-\tparams->use.acc_ccm = 1;\n-}\n-\n REGISTER_IPA_ALGORITHM(Awb, \"Awb\")\n \n } /* namespace ipa::ipu3::algorithms */\ndiff --git a/src/ipa/libipa/algorithm.cpp b/src/ipa/libipa/algorithm.cpp\nindex 71f583840a5a..bc1c29a6dbcc 100644\n--- a/src/ipa/libipa/algorithm.cpp\n+++ b/src/ipa/libipa/algorithm.cpp\n@@ -66,23 +66,6 @@ namespace ipa {\n  * \\return 0 if successful, an error code otherwise\n  */\n \n-/**\n- * \\fn Algorithm::prepare()\n- * \\brief Fill the \\a params buffer with ISP processing parameters for a frame\n- * \\param[in] context The shared IPA context\n- * \\param[in] frame The frame context sequence number\n- * \\param[in] frameContext The FrameContext for this frame\n- * \\param[out] params The ISP specific parameters\n- *\n- * This function is called for every frame when the camera is running before it\n- * is processed by the ISP to prepare the ISP processing parameters for that\n- * frame.\n- *\n- * Algorithms shall fill in the parameter structure fields appropriately to\n- * configure the ISP processing blocks that they are responsible for. This\n- * includes setting fields and flags that enable those processing blocks.\n- */\n-\n /**\n  * \\fn Algorithm::queueRequest()\n  * \\brief Provide control values to the algorithm\n@@ -100,6 +83,23 @@ namespace ipa {\n  * use during frame processing.\n  */\n \n+/**\n+ * \\fn Algorithm::prepare()\n+ * \\brief Fill the \\a params buffer with ISP processing parameters for a frame\n+ * \\param[in] context The shared IPA context\n+ * \\param[in] frame The frame context sequence number\n+ * \\param[in] frameContext The FrameContext for this frame\n+ * \\param[out] params The ISP specific parameters\n+ *\n+ * This function is called for every frame when the camera is running before it\n+ * is processed by the ISP to prepare the ISP processing parameters for that\n+ * frame.\n+ *\n+ * Algorithms shall fill in the parameter structure fields appropriately to\n+ * configure the ISP processing blocks that they are responsible for. This\n+ * includes setting fields and flags that enable those processing blocks.\n+ */\n+\n /**\n  * \\fn Algorithm::process()\n  * \\brief Process ISP statistics, and run algorithm operations\ndiff --git a/src/ipa/libipa/algorithm.h b/src/ipa/libipa/algorithm.h\nindex 38b3231c5d0e..987e3e4ce777 100644\n--- a/src/ipa/libipa/algorithm.h\n+++ b/src/ipa/libipa/algorithm.h\n@@ -38,13 +38,6 @@ public:\n \t\treturn 0;\n \t}\n \n-\tvirtual void prepare([[maybe_unused]] typename Module::Context &context,\n-\t\t\t     [[maybe_unused]] const uint32_t frame,\n-\t\t\t     [[maybe_unused]] typename Module::FrameContext &frameContext,\n-\t\t\t     [[maybe_unused]] typename Module::Params *params)\n-\t{\n-\t}\n-\n \tvirtual void queueRequest([[maybe_unused]] typename Module::Context &context,\n \t\t\t\t  [[maybe_unused]] const uint32_t frame,\n \t\t\t\t  [[maybe_unused]] typename Module::FrameContext &frameContext,\n@@ -52,6 +45,13 @@ public:\n \t{\n \t}\n \n+\tvirtual void prepare([[maybe_unused]] typename Module::Context &context,\n+\t\t\t     [[maybe_unused]] const uint32_t frame,\n+\t\t\t     [[maybe_unused]] typename Module::FrameContext &frameContext,\n+\t\t\t     [[maybe_unused]] typename Module::Params *params)\n+\t{\n+\t}\n+\n \tvirtual void process([[maybe_unused]] typename Module::Context &context,\n \t\t\t     [[maybe_unused]] const uint32_t frame,\n \t\t\t     [[maybe_unused]] typename Module::FrameContext &frameContext,\ndiff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\nindex a06e9f732a8f..3fcbfa608467 100644\n--- a/src/ipa/rkisp1/algorithms/agc.cpp\n+++ b/src/ipa/rkisp1/algorithms/agc.cpp\n@@ -107,6 +107,46 @@ int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo)\n \treturn 0;\n }\n \n+/**\n+ * \\copydoc libcamera::ipa::Algorithm::prepare\n+ */\n+void Agc::prepare(IPAContext &context, const uint32_t frame,\n+\t\t  IPAFrameContext &frameContext, rkisp1_params_cfg *params)\n+{\n+\tframeContext.agc.exposure = context.activeState.agc.exposure;\n+\tframeContext.agc.gain = context.activeState.agc.gain;\n+\n+\tif (frame > 0)\n+\t\treturn;\n+\n+\t/* Configure the measurement window. */\n+\tparams->meas.aec_config.meas_window = context.configuration.agc.measureWindow;\n+\t/* Use a continuous method for measure. */\n+\tparams->meas.aec_config.autostop = RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_0;\n+\t/* Estimate Y as (R + G + B) x (85/256). */\n+\tparams->meas.aec_config.mode = RKISP1_CIF_ISP_EXP_MEASURING_MODE_1;\n+\n+\tparams->module_cfg_update |= RKISP1_CIF_ISP_MODULE_AEC;\n+\tparams->module_ens |= RKISP1_CIF_ISP_MODULE_AEC;\n+\tparams->module_en_update |= RKISP1_CIF_ISP_MODULE_AEC;\n+\n+\t/* Configure histogram. */\n+\tparams->meas.hst_config.meas_window = context.configuration.agc.measureWindow;\n+\t/* Produce the luminance histogram. */\n+\tparams->meas.hst_config.mode = RKISP1_CIF_ISP_HISTOGRAM_MODE_Y_HISTOGRAM;\n+\t/* Set an average weighted histogram. */\n+\tfor (unsigned int histBin = 0; histBin < numHistBins_; histBin++)\n+\t\tparams->meas.hst_config.hist_weight[histBin] = 1;\n+\t/* Step size can't be less than 3. */\n+\tparams->meas.hst_config.histogram_predivider = 4;\n+\n+\t/* Update the configuration for histogram. */\n+\tparams->module_cfg_update |= RKISP1_CIF_ISP_MODULE_HST;\n+\t/* Enable the histogram measure unit. */\n+\tparams->module_ens |= RKISP1_CIF_ISP_MODULE_HST;\n+\tparams->module_en_update |= RKISP1_CIF_ISP_MODULE_HST;\n+}\n+\n /**\n  * \\brief Apply a filter on the exposure value to limit the speed of changes\n  * \\param[in] exposureValue The target exposure from the AGC algorithm\n@@ -348,46 +388,6 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n \tmetadata.set(controls::FrameDuration, frameDuration.get<std::micro>());\n }\n \n-/**\n- * \\copydoc libcamera::ipa::Algorithm::prepare\n- */\n-void Agc::prepare(IPAContext &context, const uint32_t frame,\n-\t\t  IPAFrameContext &frameContext, rkisp1_params_cfg *params)\n-{\n-\tframeContext.agc.exposure = context.activeState.agc.exposure;\n-\tframeContext.agc.gain = context.activeState.agc.gain;\n-\n-\tif (frame > 0)\n-\t\treturn;\n-\n-\t/* Configure the measurement window. */\n-\tparams->meas.aec_config.meas_window = context.configuration.agc.measureWindow;\n-\t/* Use a continuous method for measure. */\n-\tparams->meas.aec_config.autostop = RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_0;\n-\t/* Estimate Y as (R + G + B) x (85/256). */\n-\tparams->meas.aec_config.mode = RKISP1_CIF_ISP_EXP_MEASURING_MODE_1;\n-\n-\tparams->module_cfg_update |= RKISP1_CIF_ISP_MODULE_AEC;\n-\tparams->module_ens |= RKISP1_CIF_ISP_MODULE_AEC;\n-\tparams->module_en_update |= RKISP1_CIF_ISP_MODULE_AEC;\n-\n-\t/* Configure histogram. */\n-\tparams->meas.hst_config.meas_window = context.configuration.agc.measureWindow;\n-\t/* Produce the luminance histogram. */\n-\tparams->meas.hst_config.mode = RKISP1_CIF_ISP_HISTOGRAM_MODE_Y_HISTOGRAM;\n-\t/* Set an average weighted histogram. */\n-\tfor (unsigned int histBin = 0; histBin < numHistBins_; histBin++)\n-\t\tparams->meas.hst_config.hist_weight[histBin] = 1;\n-\t/* Step size can't be less than 3. */\n-\tparams->meas.hst_config.histogram_predivider = 4;\n-\n-\t/* Update the configuration for histogram. */\n-\tparams->module_cfg_update |= RKISP1_CIF_ISP_MODULE_HST;\n-\t/* Enable the histogram measure unit. */\n-\tparams->module_ens |= RKISP1_CIF_ISP_MODULE_HST;\n-\tparams->module_en_update |= RKISP1_CIF_ISP_MODULE_HST;\n-}\n-\n REGISTER_IPA_ALGORITHM(Agc, \"Agc\")\n \n } /* namespace ipa::rkisp1::algorithms */\ndiff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\nindex 083c2d982c52..744f4a386c1a 100644\n--- a/src/ipa/rkisp1/algorithms/awb.cpp\n+++ b/src/ipa/rkisp1/algorithms/awb.cpp\n@@ -67,20 +67,41 @@ int Awb::configure(IPAContext &context,\n \treturn 0;\n }\n \n-uint32_t Awb::estimateCCT(double red, double green, double blue)\n+/**\n+ * \\copydoc libcamera::ipa::Algorithm::queueRequest\n+ */\n+void Awb::queueRequest(IPAContext &context,\n+\t\t       [[maybe_unused]] const uint32_t frame,\n+\t\t       IPAFrameContext &frameContext,\n+\t\t       const ControlList &controls)\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-\tdouble Y = (-0.32466) * (red) + (1.57837) * (green) + (-0.73191) * (blue);\n-\tdouble Z = (-0.68202) * (red) + (0.77073) * (green) + (0.56332) * (blue);\n-\n-\t/* Calculate the normalized chromaticity values */\n-\tdouble x = X / (X + Y + Z);\n-\tdouble y = Y / (X + Y + Z);\n-\n-\t/* Calculate CCT */\n-\tdouble n = (x - 0.3320) / (0.1858 - y);\n-\treturn 449 * n * n * n + 3525 * n * n + 6823.3 * n + 5520.33;\n+\tauto &awb = context.activeState.awb;\n+\n+\tconst auto &awbEnable = controls.get(controls::AwbEnable);\n+\tif (awbEnable && *awbEnable != awb.autoEnabled) {\n+\t\tawb.autoEnabled = *awbEnable;\n+\n+\t\tLOG(RkISP1Awb, Debug)\n+\t\t\t<< (*awbEnable ? \"Enabling\" : \"Disabling\") << \" AWB\";\n+\t}\n+\n+\tconst auto &colourGains = controls.get(controls::ColourGains);\n+\tif (colourGains && !awb.autoEnabled) {\n+\t\tawb.gains.manual.red = (*colourGains)[0];\n+\t\tawb.gains.manual.blue = (*colourGains)[1];\n+\n+\t\tLOG(RkISP1Awb, Debug)\n+\t\t\t<< \"Set colour gains to red: \" << awb.gains.manual.red\n+\t\t\t<< \", blue: \" << awb.gains.manual.blue;\n+\t}\n+\n+\tframeContext.awb.autoEnabled = awb.autoEnabled;\n+\n+\tif (!awb.autoEnabled) {\n+\t\tframeContext.awb.gains.red = awb.gains.manual.red;\n+\t\tframeContext.awb.gains.green = 1.0;\n+\t\tframeContext.awb.gains.blue = awb.gains.manual.blue;\n+\t}\n }\n \n /**\n@@ -165,41 +186,20 @@ void Awb::prepare(IPAContext &context, const uint32_t frame,\n \tparams->module_ens |= RKISP1_CIF_ISP_MODULE_AWB;\n }\n \n-/**\n- * \\copydoc libcamera::ipa::Algorithm::queueRequest\n- */\n-void Awb::queueRequest(IPAContext &context,\n-\t\t       [[maybe_unused]] const uint32_t frame,\n-\t\t       IPAFrameContext &frameContext,\n-\t\t       const ControlList &controls)\n+uint32_t Awb::estimateCCT(double red, double green, double blue)\n {\n-\tauto &awb = context.activeState.awb;\n-\n-\tconst auto &awbEnable = controls.get(controls::AwbEnable);\n-\tif (awbEnable && *awbEnable != awb.autoEnabled) {\n-\t\tawb.autoEnabled = *awbEnable;\n-\n-\t\tLOG(RkISP1Awb, Debug)\n-\t\t\t<< (*awbEnable ? \"Enabling\" : \"Disabling\") << \" AWB\";\n-\t}\n-\n-\tconst auto &colourGains = controls.get(controls::ColourGains);\n-\tif (colourGains && !awb.autoEnabled) {\n-\t\tawb.gains.manual.red = (*colourGains)[0];\n-\t\tawb.gains.manual.blue = (*colourGains)[1];\n-\n-\t\tLOG(RkISP1Awb, Debug)\n-\t\t\t<< \"Set colour gains to red: \" << awb.gains.manual.red\n-\t\t\t<< \", blue: \" << awb.gains.manual.blue;\n-\t}\n-\n-\tframeContext.awb.autoEnabled = awb.autoEnabled;\n-\n-\tif (!awb.autoEnabled) {\n-\t\tframeContext.awb.gains.red = awb.gains.manual.red;\n-\t\tframeContext.awb.gains.green = 1.0;\n-\t\tframeContext.awb.gains.blue = awb.gains.manual.blue;\n-\t}\n+\t/* Convert the RGB values to CIE tristimulus values (XYZ) */\n+\tdouble X = (-0.14282) * (red) + (1.54924) * (green) + (-0.95641) * (blue);\n+\tdouble Y = (-0.32466) * (red) + (1.57837) * (green) + (-0.73191) * (blue);\n+\tdouble Z = (-0.68202) * (red) + (0.77073) * (green) + (0.56332) * (blue);\n+\n+\t/* Calculate the normalized chromaticity values */\n+\tdouble x = X / (X + Y + Z);\n+\tdouble y = Y / (X + Y + Z);\n+\n+\t/* Calculate CCT */\n+\tdouble n = (x - 0.3320) / (0.1858 - y);\n+\treturn 449 * n * n * n + 3525 * n * n + 6823.3 * n + 5520.33;\n }\n \n /**\ndiff --git a/src/ipa/rkisp1/algorithms/awb.h b/src/ipa/rkisp1/algorithms/awb.h\nindex f5633b1171a0..9d45a442339c 100644\n--- a/src/ipa/rkisp1/algorithms/awb.h\n+++ b/src/ipa/rkisp1/algorithms/awb.h\n@@ -20,12 +20,12 @@ public:\n \t~Awb() = default;\n \n \tint configure(IPAContext &context, const IPACameraSensorInfo &configInfo) override;\n-\tvoid prepare(IPAContext &context, const uint32_t frame,\n-\t\t     IPAFrameContext &frameContext,\n-\t\t     rkisp1_params_cfg *params) override;\n \tvoid queueRequest(IPAContext &context, const uint32_t frame,\n \t\t\t  IPAFrameContext &frameContext,\n \t\t\t  const ControlList &controls) override;\n+\tvoid prepare(IPAContext &context, const uint32_t frame,\n+\t\t     IPAFrameContext &frameContext,\n+\t\t     rkisp1_params_cfg *params) override;\n \tvoid process(IPAContext &context, const uint32_t frame,\n \t\t     IPAFrameContext &frameContext,\n \t\t     const rkisp1_stat_buffer *stats,\n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "01/13"
    ]
}