Show a patch.

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

{
    "id": 13411,
    "url": "https://patchwork.libcamera.org/api/patches/13411/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/13411/",
    "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": "<20210820065316.44343-5-jeanmichel.hautbois@ideasonboard.com>",
    "date": "2021-08-20T06:53:11",
    "name": "[libcamera-devel,v5,4/9] ipa: ipu3: Introduce modular algorithm",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "d77841ccf9af451be6ff1459021dcb765829e6c3",
    "submitter": {
        "id": 75,
        "url": "https://patchwork.libcamera.org/api/people/75/?format=api",
        "name": "Jean-Michel Hautbois",
        "email": "jeanmichel.hautbois@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/13411/mbox/",
    "series": [
        {
            "id": 2374,
            "url": "https://patchwork.libcamera.org/api/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/13411/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/13411/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 EA2F5C3242\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 20 Aug 2021 06:53:27 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 487E868921;\n\tFri, 20 Aug 2021 08:53: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 B5459605A9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 20 Aug 2021 08:53:21 +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 71C9B18EE;\n\tFri, 20 Aug 2021 08:53:21 +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=\"sP9zdJU4\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1629442401;\n\tbh=55VDxdprmNyI+WSM6bQpcxugiCnPww7K5wbzTVZ7Pyg=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=sP9zdJU4QrtRUCdcOeaU67nDCSj2gfwjZTVT/LLyH6rGM2SnMGbr06t9hyRHXdHEp\n\tm2YQigimJAh4Ri+ULIUwz1V75UOBaMHOxCbI7HZ7NmCtRrAUXkWNiGFVSBUz3dHaqf\n\tUYY0GRmThR5xTfl+NyGz0VwOcLMtQ+EwvHEdE6/M=",
        "From": "Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 20 Aug 2021 08:53:11 +0200",
        "Message-Id": "<20210820065316.44343-5-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 4/9] ipa: ipu3: Introduce modular\n\talgorithm",
        "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": "Implement a new modular framework for algorithms with a common context\nstructure that is passed to each algorithm through a common API.\n\nThis patch:\n- removes all the local references from IPAIPU3 and uses IPAContext\n- implements the list of pointers and the loop at configure call on each\n  algorithm\n- loops in fillParams on each prepare() call on the algorithm list\n- loops in prepareStats on each process() call on the algorithm list\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 src/ipa/ipu3/ipa_context.h |  6 ++++\n src/ipa/ipu3/ipu3.cpp      | 57 ++++++++++++++++++++++++++++++--------\n 2 files changed, 51 insertions(+), 12 deletions(-)",
    "diff": "diff --git a/src/ipa/ipu3/ipa_context.h b/src/ipa/ipu3/ipa_context.h\nindex 2706d3ca..a031ab83 100644\n--- a/src/ipa/ipu3/ipa_context.h\n+++ b/src/ipa/ipu3/ipa_context.h\n@@ -10,11 +10,17 @@\n \n #include <linux/intel-ipu3.h>\n \n+#include <libcamera/geometry.h>\n+\n namespace libcamera {\n \n namespace ipa::ipu3 {\n \n struct IPASessionConfiguration {\n+\tstruct {\n+\t\tipu3_uapi_grid_config bdsGrid;\n+\t\tSize bdsOutputSize;\n+\t} grid;\n };\n \n struct IPAFrameContext {\ndiff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\nindex d9be37e9..4d5b0af1 100644\n--- a/src/ipa/ipu3/ipu3.cpp\n+++ b/src/ipa/ipu3/ipu3.cpp\n@@ -29,6 +29,7 @@\n \n #include \"libcamera/internal/mapped_framebuffer.h\"\n \n+#include \"algorithms/algorithm.h\"\n #include \"ipu3_agc.h\"\n #include \"ipu3_awb.h\"\n #include \"libipa/camera_sensor_helper.h\"\n@@ -79,6 +80,17 @@\n  * are run. This needs to be turned into real per-frame data storage.\n  */\n \n+/**\n+ * \\struct IPASessionConfiguration::grid\n+ * \\brief Grid configuration of the IPA\n+ *\n+ * \\var IPASessionConfiguration::grid::bdsGrid\n+ * \\brief Bayer Down Scaler grid plane config used by the kernel\n+ *\n+ * \\var IPASessionConfiguration::grid::bdsOutputSize\n+ * \\brief BDS output size configured by the pipeline handler\n+ */\n+\n static constexpr uint32_t kMaxCellWidthPerSet = 160;\n static constexpr uint32_t kMaxCellHeightPerSet = 56;\n \n@@ -137,10 +149,12 @@ private:\n \t/* Interface to the Camera Helper */\n \tstd::unique_ptr<CameraSensorHelper> camHelper_;\n \n+\t/* Maintain the algorithms used by the IPA */\n+\tstd::list<std::unique_ptr<ipa::ipu3::Algorithm>> algorithms_;\n+\n \t/* Local parameter storage */\n+\tstruct IPAContext context_;\n \tstruct ipu3_uapi_params params_;\n-\n-\tstruct ipu3_uapi_grid_config bdsGrid_;\n };\n \n /**\n@@ -237,7 +251,9 @@ void IPAIPU3::calculateBdsGrid(const Size &bdsOutputSize)\n \tuint32_t minError = std::numeric_limits<uint32_t>::max();\n \tSize best;\n \tSize bestLog2;\n-\tbdsGrid_ = {};\n+\n+\t/* Set the BDS output size in the IPAConfiguration structure */\n+\tcontext_.configuration.grid.bdsOutputSize = bdsOutputSize;\n \n \tfor (uint32_t widthShift = 3; widthShift <= 7; ++widthShift) {\n \t\tuint32_t width = std::min(kMaxCellWidthPerSet,\n@@ -261,14 +277,17 @@ void IPAIPU3::calculateBdsGrid(const Size &bdsOutputSize)\n \t\t}\n \t}\n \n-\tbdsGrid_.width = best.width >> bestLog2.width;\n-\tbdsGrid_.block_width_log2 = bestLog2.width;\n-\tbdsGrid_.height = best.height >> bestLog2.height;\n-\tbdsGrid_.block_height_log2 = bestLog2.height;\n+\tstruct ipu3_uapi_grid_config &bdsGrid = context_.configuration.grid.bdsGrid;\n+\tbdsGrid.x_start = 0;\n+\tbdsGrid.y_start = 0;\n+\tbdsGrid.width = best.width >> bestLog2.width;\n+\tbdsGrid.block_width_log2 = bestLog2.width;\n+\tbdsGrid.height = best.height >> bestLog2.height;\n+\tbdsGrid.block_height_log2 = bestLog2.height;\n \n \tLOG(IPAIPU3, Debug) << \"Best grid found is: (\"\n-\t\t\t    << (int)bdsGrid_.width << \" << \" << (int)bdsGrid_.block_width_log2 << \") x (\"\n-\t\t\t    << (int)bdsGrid_.height << \" << \" << (int)bdsGrid_.block_height_log2 << \")\";\n+\t\t\t    << (int)bdsGrid.width << \" << \" << (int)bdsGrid.block_width_log2 << \") x (\"\n+\t\t\t    << (int)bdsGrid.height << \" << \" << (int)bdsGrid.block_height_log2 << \")\";\n }\n \n int IPAIPU3::configure(const IPAConfigInfo &configInfo)\n@@ -310,15 +329,23 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo)\n \n \tdefVBlank_ = itVBlank->second.def().get<int32_t>();\n \n+\t/* Clean context and IPU3 parameters at configuration */\n \tparams_ = {};\n+\tcontext_ = {};\n \n \tcalculateBdsGrid(configInfo.bdsOutputSize);\n \n-\tawbAlgo_ = std::make_unique<IPU3Awb>();\n-\tawbAlgo_->initialise(params_, configInfo.bdsOutputSize, bdsGrid_);\n+\tfor (auto const &algo : algorithms_) {\n+\t\tint ret = algo->configure(context_, configInfo);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\n \n+\tawbAlgo_ = std::make_unique<IPU3Awb>();\n+\tawbAlgo_->initialise(params_, context_.configuration.grid.bdsOutputSize,\n+\t\t\t     context_.configuration.grid.bdsGrid);\n \tagcAlgo_ = std::make_unique<IPU3Agc>();\n-\tagcAlgo_->initialise(bdsGrid_, sensorInfo_);\n+\tagcAlgo_->initialise(context_.configuration.grid.bdsGrid, sensorInfo_);\n \n \treturn 0;\n }\n@@ -392,6 +419,9 @@ void IPAIPU3::processControls([[maybe_unused]] unsigned int frame,\n \n void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)\n {\n+\tfor (auto const &algo : algorithms_)\n+\t\talgo->prepare(context_, &params_);\n+\n \tif (agcAlgo_->updateControls())\n \t\tawbAlgo_->updateWbParameters(params_, agcAlgo_->gamma());\n \n@@ -409,6 +439,9 @@ 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 \tdouble gain = camHelper_->gain(gain_);\n \tagcAlgo_->process(stats, exposure_, gain);\n \tgain_ = camHelper_->gainCode(gain);\n",
    "prefixes": [
        "libcamera-devel",
        "v5",
        "4/9"
    ]
}