Show a patch.

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

{
    "id": 16138,
    "url": "https://patchwork.libcamera.org/api/patches/16138/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/16138/",
    "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": "<20220603132259.188845-2-umang.jain@ideasonboard.com>",
    "date": "2022-06-03T13:22:56",
    "name": "[libcamera-devel,v1,1/4] ipa: ipu3: Separate out frame context queue as a distinct class",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "8ab258e2c411e81222a87c73d43b1e0f40f6b3bd",
    "submitter": {
        "id": 86,
        "url": "https://patchwork.libcamera.org/api/people/86/?format=api",
        "name": "Umang Jain",
        "email": "umang.jain@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/16138/mbox/",
    "series": [
        {
            "id": 3157,
            "url": "https://patchwork.libcamera.org/api/series/3157/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3157",
            "date": "2022-06-03T13:22:55",
            "name": "Move frame contexts queue to separate class",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3157/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/16138/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/16138/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 AA7E2C3256\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  3 Jun 2022 13:23:08 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F019F65639;\n\tFri,  3 Jun 2022 15:23:07 +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 4368360105\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  3 Jun 2022 15:23:05 +0200 (CEST)",
            "from perceval.ideasonboard.com\n\t(static-127-186-62-95.ipcom.comunitel.net [95.62.186.127])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C750710DD;\n\tFri,  3 Jun 2022 15:23:04 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1654262588;\n\tbh=vzOxlCkU1d8zf16gF6O0d6hz2qGWA70wddX4Y8mdK54=;\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=F3wYiOx5ukRq2GAVfcJtxUJ8uxWvXYuye+DgyqvFwzL7ZnXiNROyFDlOcWTupXQ4H\n\toExrW+t5JuvmHh/vwEI7kqO6D9Sedpv9DQicDZWdazI0yW1zcd2mweHroVzNI2DlQM\n\tdbo7KPwyBFeXkigMcKq0HJkff+UaM4Vo6cXYarKb+nT0hdWl5dRFK9SYw4HLjhCXSw\n\tAh/cb7OY8ZCvV8EhBiNdIfMvVLQKzqcgbS5zNlzfi6MDy/1lfcrmbKzt3Kr4Wvqd+B\n\tIe5ttIXoR7Ik3Wiu1lHdiTAe14pWERO7q6AC21vwqJvDyj/yY65fNhv2gWtB/S8E03\n\tscScmKmn/2l3g==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1654262585;\n\tbh=vzOxlCkU1d8zf16gF6O0d6hz2qGWA70wddX4Y8mdK54=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=vk9bYQvwRvqvlOok8v2WiYH+VSNbjmY5zo6ZqX3/z8JdQ/k8714uhNEytZJf2gmac\n\tt76f+fL15REQqEJkbb0fZ38L/2RGgNafWAPcQoGBP92N2wuoeeJ4eZPMLUSubPP/Cg\n\tqh1DF7De6qAwb0PkXT0wym7guukZ8zapSd9QKcko="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"vk9bYQvw\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri,  3 Jun 2022 15:22:56 +0200",
        "Message-Id": "<20220603132259.188845-2-umang.jain@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.31.1",
        "In-Reply-To": "<20220603132259.188845-1-umang.jain@ideasonboard.com>",
        "References": "<20220603132259.188845-1-umang.jain@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v1 1/4] ipa: ipu3: Separate out frame\n\tcontext queue as a distinct 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": "Umang Jain via libcamera-devel <libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Umang Jain <umang.jain@ideasonboard.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "There are cases where we need more checks and balance to be carried out\nby the frame context queue class. For that, separate it out as a\ndistinct class on which we can build upon.\n\nFor now, a minimialistic implementation is provided with .get(frame)\nhelper which returns a IPAFrameContext pointer for the required frame.\nGoing ahead more such helpers can be provided to access/modify the\nframe context queue.\n\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n---\n src/ipa/ipu3/ipa_context.cpp | 57 ++++++++++++++++++++++++++++++++++--\n src/ipa/ipu3/ipa_context.h   | 11 ++++++-\n src/ipa/ipu3/ipu3.cpp        | 18 ++++++------\n 3 files changed, 74 insertions(+), 12 deletions(-)",
    "diff": "diff --git a/src/ipa/ipu3/ipa_context.cpp b/src/ipa/ipu3/ipa_context.cpp\nindex 13cdb835..9f95a61c 100644\n--- a/src/ipa/ipu3/ipa_context.cpp\n+++ b/src/ipa/ipu3/ipa_context.cpp\n@@ -7,12 +7,18 @@\n \n #include \"ipa_context.h\"\n \n+#include <libcamera/base/log.h>\n+\n /**\n  * \\file ipa_context.h\n  * \\brief Context and state information shared between the algorithms\n  */\n \n-namespace libcamera::ipa::ipu3 {\n+namespace libcamera {\n+\n+LOG_DECLARE_CATEGORY(IPAIPU3)\n+\n+namespace ipa::ipu3 {\n \n /**\n  * \\struct IPASessionConfiguration\n@@ -211,4 +217,51 @@ IPAFrameContext::IPAFrameContext(uint32_t id, const ControlList &reqControls)\n  * \\brief Analogue gain multiplier\n  */\n \n-} /* namespace libcamera::ipa::ipu3 */\n+/**\n+ * \\class FCQueue\n+ * \\brief A FIFO circular queue holding IPAFrameContext(s)\n+ *\n+ * FCQueue holds all the IPAFrameContext(s) related to frames required\n+ * to be processed by the IPA at a given point.\n+ */\n+\n+/**\n+ * \\brief FCQueue constructor\n+ */\n+FCQueue::FCQueue()\n+{\n+\tclear();\n+}\n+\n+/**\n+ * \\brief Retrieve the IPAFrameContext for the frame\n+ * \\param[in] frame Frame number for which the IPAFrameContext needs to\n+ * retrieved\n+ *\n+ * \\return Pointer to the IPAFrameContext\n+ */\n+IPAFrameContext *FCQueue::get(uint32_t frame)\n+{\n+\tIPAFrameContext &frameContext = this->at(frame % kMaxFrameContexts);\n+\n+\tif (frame != frameContext.frame) {\n+\t\tLOG(IPAIPU3, Warning)\n+\t\t\t<< \"Got wrong frame context for frame\" << frame\n+\t\t\t<< \" or frame context doesn't exist yet\";\n+\t}\n+\n+\treturn &frameContext;\n+}\n+\n+/**\n+ * \\brief Clear the FCQueue by resetting all the entries in the ring-buffer\n+ */\n+void FCQueue::clear()\n+{\n+\tIPAFrameContext initFrameContext;\n+\tthis->fill(initFrameContext);\n+}\n+\n+} /* namespace ipa::ipu3 */\n+\n+} /* namespace libcamera */\ndiff --git a/src/ipa/ipu3/ipa_context.h b/src/ipa/ipu3/ipa_context.h\nindex 42e11141..56d281f6 100644\n--- a/src/ipa/ipu3/ipa_context.h\n+++ b/src/ipa/ipu3/ipa_context.h\n@@ -89,11 +89,20 @@ struct IPAFrameContext {\n \tControlList frameControls;\n };\n \n+class FCQueue : public std::array<IPAFrameContext, kMaxFrameContexts>\n+{\n+public:\n+\tFCQueue();\n+\n+\tvoid clear();\n+\tIPAFrameContext *get(uint32_t frame);\n+};\n+\n struct IPAContext {\n \tIPASessionConfiguration configuration;\n \tIPAActiveState activeState;\n \n-\tstd::array<IPAFrameContext, kMaxFrameContexts> frameContexts;\n+\tFCQueue frameContexts;\n };\n \n } /* namespace ipa::ipu3 */\ndiff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\nindex 2f6bb672..0843d882 100644\n--- a/src/ipa/ipu3/ipu3.cpp\n+++ b/src/ipa/ipu3/ipu3.cpp\n@@ -456,8 +456,8 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo,\n \n \t/* Clean IPAActiveState at each reconfiguration. */\n \tcontext_.activeState = {};\n-\tIPAFrameContext initFrameContext;\n-\tcontext_.frameContexts.fill(initFrameContext);\n+\tcontext_.frameContexts.clear();\n+\n \n \tif (!validateSensorControls()) {\n \t\tLOG(IPAIPU3, Error) << \"Sensor control validation failed.\";\n@@ -569,20 +569,20 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame,\n \tconst ipu3_uapi_stats_3a *stats =\n \t\treinterpret_cast<ipu3_uapi_stats_3a *>(mem.data());\n \n-\tIPAFrameContext &frameContext = context_.frameContexts[frame % kMaxFrameContexts];\n+\tIPAFrameContext *frameContext = context_.frameContexts.get(frame);\n \n-\tif (frameContext.frame != frame)\n+\tif (frameContext->frame != frame)\n \t\tLOG(IPAIPU3, Warning) << \"Frame \" << frame << \" does not match its frame context\";\n \n-\tframeContext.sensor.exposure = sensorControls.get(V4L2_CID_EXPOSURE).get<int32_t>();\n-\tframeContext.sensor.gain = camHelper_->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>());\n+\tframeContext->sensor.exposure = sensorControls.get(V4L2_CID_EXPOSURE).get<int32_t>();\n+\tframeContext->sensor.gain = camHelper_->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>());\n \n \tdouble lineDuration = context_.configuration.sensor.lineDuration.get<std::micro>();\n \tint32_t vBlank = context_.configuration.sensor.defVBlank;\n \tControlList ctrls(controls::controls);\n \n \tfor (auto const &algo : algorithms_)\n-\t\talgo->process(context_, &frameContext, stats);\n+\t\talgo->process(context_, frameContext, stats);\n \n \tsetControls(frame);\n \n@@ -590,11 +590,11 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame,\n \tint64_t frameDuration = (vBlank + sensorInfo_.outputSize.height) * lineDuration;\n \tctrls.set(controls::FrameDuration, frameDuration);\n \n-\tctrls.set(controls::AnalogueGain, frameContext.sensor.gain);\n+\tctrls.set(controls::AnalogueGain, frameContext->sensor.gain);\n \n \tctrls.set(controls::ColourTemperature, context_.activeState.awb.temperatureK);\n \n-\tctrls.set(controls::ExposureTime, frameContext.sensor.exposure * lineDuration);\n+\tctrls.set(controls::ExposureTime, frameContext->sensor.exposure * lineDuration);\n \n \t/*\n \t * \\todo The Metadata provides a path to getting extended data\n",
    "prefixes": [
        "libcamera-devel",
        "v1",
        "1/4"
    ]
}