Show a patch.

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

{
    "id": 13413,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/13413/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/13413/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/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": "<20210820065316.44343-10-jeanmichel.hautbois@ideasonboard.com>",
    "date": "2021-08-20T06:53:16",
    "name": "[libcamera-devel,v5,9/9] ipa: ipu3: Move IPU3 agc into algorithms",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "87d54948bed76e734b0aa92559693c5621b53e3c",
    "submitter": {
        "id": 75,
        "url": "https://patchwork.libcamera.org/api/1.1/people/75/?format=api",
        "name": "Jean-Michel Hautbois",
        "email": "jeanmichel.hautbois@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/13413/mbox/",
    "series": [
        {
            "id": 2374,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2374/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2374",
            "date": "2021-08-20T06:53:07",
            "name": "IPU3: Introduce modularity for algorithms",
            "version": 5,
            "mbox": "https://patchwork.libcamera.org/series/2374/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/13413/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/13413/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 B972DC3245\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 20 Aug 2021 06:53:31 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D560F688A2;\n\tFri, 20 Aug 2021 08:53:30 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DFDEC68919\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 20 Aug 2021 08:53:22 +0200 (CEST)",
            "from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:e43b:edb2:932:6b0a])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8B69118EE;\n\tFri, 20 Aug 2021 08:53:22 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"I4YOhEl2\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1629442402;\n\tbh=9YS54Lj9B9mRrvwh0wl/yeWopRzugic0IomrM2dj9gA=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=I4YOhEl2fiM5lACCx0Hr1LwRd6ILiPO1p9Uz2C6AF7lrwZvSkP2nEjgoX1LSqCLDe\n\t9MHCl+UTiVIjT98t5RvVn5mx6RPsdmQgtDe7hTboCtw11kmP2OpaNAcA0g6w3Pyb4I\n\tieDzwpBvLweU2l1NcujHzJLq8gOY+fwrBGeEfm3Q=",
        "From": "Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 20 Aug 2021 08:53:16 +0200",
        "Message-Id": "<20210820065316.44343-10-jeanmichel.hautbois@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.30.2",
        "In-Reply-To": "<20210820065316.44343-1-jeanmichel.hautbois@ideasonboard.com>",
        "References": "<20210820065316.44343-1-jeanmichel.hautbois@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v5 9/9] ipa: ipu3: Move IPU3 agc into\n\talgorithms",
        "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>"
    },
    "content": "Now that the interface is properly used by the AGC class, move it into\nipa::ipu3::algorithms and let the loops do the calls.\nAs we need to exchange the exposure_ and gain_ by passing them through the\nFrameContext, use the calculated values in setControls() function to\nease the reading.\n\nSigned-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n .../ipu3/{ipu3_agc.cpp => algorithms/agc.cpp} | 18 ++++++++---------\n src/ipa/ipu3/{ipu3_agc.h => algorithms/agc.h} | 20 +++++++++----------\n src/ipa/ipu3/algorithms/meson.build           |  1 +\n src/ipa/ipu3/ipu3.cpp                         | 20 ++++++++-----------\n src/ipa/ipu3/meson.build                      |  1 -\n 5 files changed, 28 insertions(+), 32 deletions(-)\n rename src/ipa/ipu3/{ipu3_agc.cpp => algorithms/agc.cpp} (94%)\n rename src/ipa/ipu3/{ipu3_agc.h => algorithms/agc.h} (73%)",
    "diff": "diff --git a/src/ipa/ipu3/ipu3_agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\nsimilarity index 94%\nrename from src/ipa/ipu3/ipu3_agc.cpp\nrename to src/ipa/ipu3/algorithms/agc.cpp\nindex 1c156b89..e4598b2e 100644\n--- a/src/ipa/ipu3/ipu3_agc.cpp\n+++ b/src/ipa/ipu3/algorithms/agc.cpp\n@@ -5,7 +5,7 @@\n  * ipu3_agc.cpp - AGC/AEC control algorithm\n  */\n \n-#include \"ipu3_agc.h\"\n+#include \"agc.h\"\n \n #include <algorithm>\n #include <chrono>\n@@ -21,7 +21,7 @@ namespace libcamera {\n \n using namespace std::literals::chrono_literals;\n \n-namespace ipa::ipu3 {\n+namespace ipa::ipu3::algorithms {\n \n LOG_DEFINE_CATEGORY(IPU3Agc)\n \n@@ -50,14 +50,14 @@ static constexpr double kEvGainTarget = 0.5;\n /* A cell is 8 bytes and contains averages for RGB values and saturation ratio */\n static constexpr uint8_t kCellSize = 8;\n \n-IPU3Agc::IPU3Agc()\n+Agc::Agc()\n \t: frameCount_(0), lastFrame_(0), iqMean_(0.0), lineDuration_(0s),\n \t  maxExposureTime_(0s), prevExposure_(0s), prevExposureNoDg_(0s),\n \t  currentExposure_(0s), currentExposureNoDg_(0s)\n {\n }\n \n-int IPU3Agc::configure(IPAContext &context, const IPAConfigInfo &configInfo)\n+int Agc::configure(IPAContext &context, const IPAConfigInfo &configInfo)\n {\n \taeGrid_ = context.configuration.grid.bdsGrid;\n \n@@ -68,7 +68,7 @@ int IPU3Agc::configure(IPAContext &context, const IPAConfigInfo &configInfo)\n \treturn 0;\n }\n \n-void IPU3Agc::processBrightness(const ipu3_uapi_stats_3a *stats)\n+void Agc::processBrightness(const ipu3_uapi_stats_3a *stats)\n {\n \tconst struct ipu3_uapi_grid_config statsAeGrid = stats->stats_4a_config.awb_config.grid;\n \tRectangle aeRegion = { statsAeGrid.x_start,\n@@ -109,7 +109,7 @@ void IPU3Agc::processBrightness(const ipu3_uapi_stats_3a *stats)\n \tiqMean_ = Histogram(Span<uint32_t>(hist)).interQuantileMean(0.98, 1.0);\n }\n \n-void IPU3Agc::filterExposure()\n+void Agc::filterExposure()\n {\n \tdouble speed = 0.2;\n \tif (prevExposure_ == 0s) {\n@@ -143,7 +143,7 @@ void IPU3Agc::filterExposure()\n \tLOG(IPU3Agc, Debug) << \"After filtering, total_exposure \" << prevExposure_;\n }\n \n-void IPU3Agc::lockExposureGain(uint32_t &exposure, double &gain)\n+void Agc::lockExposureGain(uint32_t &exposure, double &gain)\n {\n \t/* Algorithm initialization should wait for first valid frames */\n \t/* \\todo - have a number of frames given by DelayedControls ?\n@@ -186,7 +186,7 @@ void IPU3Agc::lockExposureGain(uint32_t &exposure, double &gain)\n \tlastFrame_ = frameCount_;\n }\n \n-void IPU3Agc::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)\n+void Agc::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)\n {\n \tuint32_t &exposure = context.frameContext.agc.exposure;\n \tdouble &gain = context.frameContext.agc.gain;\n@@ -195,6 +195,6 @@ void IPU3Agc::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)\n \tframeCount_++;\n }\n \n-} /* namespace ipa::ipu3 */\n+} /* namespace ipa::ipu3::algorithms */\n \n } /* namespace libcamera */\ndiff --git a/src/ipa/ipu3/ipu3_agc.h b/src/ipa/ipu3/algorithms/agc.h\nsimilarity index 73%\nrename from src/ipa/ipu3/ipu3_agc.h\nrename to src/ipa/ipu3/algorithms/agc.h\nindex 0e922664..1739d2fd 100644\n--- a/src/ipa/ipu3/ipu3_agc.h\n+++ b/src/ipa/ipu3/algorithms/agc.h\n@@ -2,10 +2,10 @@\n /*\n  * Copyright (C) 2021, Ideas On Board\n  *\n- * ipu3_agc.h - IPU3 AGC/AEC control algorithm\n+ * agc.h - IPU3 AGC/AEC control algorithm\n  */\n-#ifndef __LIBCAMERA_IPU3_AGC_H__\n-#define __LIBCAMERA_IPU3_AGC_H__\n+#ifndef __LIBCAMERA_IPU3_ALGORITHMS_AGC_H__\n+#define __LIBCAMERA_IPU3_ALGORITHMS_AGC_H__\n \n #include <linux/intel-ipu3.h>\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 struct IPACameraSensorInfo;\n \n-namespace ipa::ipu3 {\n+namespace ipa::ipu3::algorithms {\n \n using utils::Duration;\n \n-class IPU3Agc : public Algorithm\n+class Agc : public Algorithm\n {\n public:\n-\tIPU3Agc();\n-\t~IPU3Agc() = default;\n+\tAgc();\n+\t~Agc() = default;\n \n \tint configure(IPAContext &context, const IPAConfigInfo &configInfo) override;\n \tvoid process(IPAContext &context, const ipu3_uapi_stats_3a *stats) override;\n@@ -53,8 +53,8 @@ private:\n \tDuration currentExposureNoDg_;\n };\n \n-} /* namespace ipa::ipu3 */\n+} /* namespace ipa::ipu3::algorithms */\n \n } /* namespace libcamera */\n \n-#endif /* __LIBCAMERA_IPU3_AGC_H__ */\n+#endif /* __LIBCAMERA_IPU3_ALGORITHMS_AGC_H__ */\ndiff --git a/src/ipa/ipu3/algorithms/meson.build b/src/ipa/ipu3/algorithms/meson.build\nindex fa004df4..deae225b 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+    'agc.cpp',\n     'algorithm.cpp',\n     'awb.cpp',\n     'tone_mapping.cpp',\ndiff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\nindex 5fc358fa..0ed0a6f1 100644\n--- a/src/ipa/ipu3/ipu3.cpp\n+++ b/src/ipa/ipu3/ipu3.cpp\n@@ -29,10 +29,10 @@\n \n #include \"libcamera/internal/mapped_framebuffer.h\"\n \n+#include \"algorithms/agc.h\"\n #include \"algorithms/algorithm.h\"\n #include \"algorithms/awb.h\"\n #include \"algorithms/tone_mapping.h\"\n-#include \"ipu3_agc.h\"\n #include \"libipa/camera_sensor_helper.h\"\n \n /**\n@@ -187,8 +187,6 @@ private:\n \tuint32_t minGain_;\n \tuint32_t maxGain_;\n \n-\t/* Interface to the AEC/AGC algorithm */\n-\tstd::unique_ptr<IPU3Agc> agcAlgo_;\n \t/* Interface to the Camera Helper */\n \tstd::unique_ptr<CameraSensorHelper> camHelper_;\n \n@@ -268,6 +266,7 @@ int IPAIPU3::init(const IPASettings &settings,\n \t*ipaControls = ControlInfoMap(std::move(controls), controls::controls);\n \n \t/* Construct our Algorithms */\n+\talgorithms_.push_back(std::make_unique<algorithms::Agc>());\n \talgorithms_.push_back(std::make_unique<algorithms::Awb>());\n \talgorithms_.push_back(std::make_unique<algorithms::ToneMapping>());\n \n@@ -386,9 +385,6 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo)\n \t\t\treturn ret;\n \t}\n \n-\tagcAlgo_ = std::make_unique<IPU3Agc>();\n-\tagcAlgo_->configure(context_, configInfo);\n-\n \treturn 0;\n }\n \n@@ -476,15 +472,12 @@ void IPAIPU3::parseStatistics(unsigned int frame,\n {\n \tControlList ctrls(controls::controls);\n \n-\tfor (auto const &algo : algorithms_)\n-\t\talgo->process(context_, stats);\n-\n \t/* \\todo These fields should not be written by the IPAIPU3 layer */\n \tcontext_.frameContext.agc.gain = camHelper_->gain(gain_);\n \tcontext_.frameContext.agc.exposure = exposure_;\n-\tagcAlgo_->process(context_, stats);\n-\texposure_ = context_.frameContext.agc.exposure;\n-\tgain_ = camHelper_->gainCode(context_.frameContext.agc.gain);\n+\n+\tfor (auto const &algo : algorithms_)\n+\t\talgo->process(context_, stats);\n \n \tsetControls(frame);\n \n@@ -505,6 +498,9 @@ void IPAIPU3::setControls(unsigned int frame)\n \tIPU3Action op;\n \top.op = ActionSetSensorControls;\n \n+\texposure_ = context_.frameContext.agc.exposure;\n+\tgain_ = camHelper_->gainCode(context_.frameContext.agc.gain);\n+\n \tControlList ctrls(ctrls_);\n \tctrls.set(V4L2_CID_EXPOSURE, static_cast<int32_t>(exposure_));\n \tctrls.set(V4L2_CID_ANALOGUE_GAIN, static_cast<int32_t>(gain_));\ndiff --git a/src/ipa/ipu3/meson.build b/src/ipa/ipu3/meson.build\nindex d1126947..39320980 100644\n--- a/src/ipa/ipu3/meson.build\n+++ b/src/ipa/ipu3/meson.build\n@@ -6,7 +6,6 @@ ipa_name = 'ipa_ipu3'\n \n ipu3_ipa_sources = files([\n     'ipu3.cpp',\n-    'ipu3_agc.cpp',\n ])\n \n ipu3_ipa_sources += ipu3_ipa_algorithms\n",
    "prefixes": [
        "libcamera-devel",
        "v5",
        "9/9"
    ]
}