Show a patch.

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

{
    "id": 17627,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/17627/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/17627/",
    "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": "<20221019090107.19975-3-naush@raspberrypi.com>",
    "date": "2022-10-19T09:01:02",
    "name": "[libcamera-devel,v4,2/7] delayed_controls: Add user cookie to DelayedControls",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "68c8bc825b3224c91d21f34f48ffbe732a1e6c22",
    "submitter": {
        "id": 34,
        "url": "https://patchwork.libcamera.org/api/1.1/people/34/?format=api",
        "name": "Naushir Patuck",
        "email": "naush@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/17627/mbox/",
    "series": [
        {
            "id": 3566,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3566/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3566",
            "date": "2022-10-19T09:01:00",
            "name": "Raspberry Pi AGC digital gain fixes",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/3566/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/17627/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/17627/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 1C851C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 19 Oct 2022 09:01:22 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D380762E37;\n\tWed, 19 Oct 2022 11:01:21 +0200 (CEST)",
            "from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com\n\t[IPv6:2a00:1450:4864:20::42a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 517F162E44\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 19 Oct 2022 11:01:18 +0200 (CEST)",
            "by mail-wr1-x42a.google.com with SMTP id bu30so27997396wrb.8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 19 Oct 2022 02:01:18 -0700 (PDT)",
            "from naush-laptop.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tr9-20020a05600c458900b003b47b913901sm1017595wmo.1.2022.10.19.02.01.17\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 19 Oct 2022 02:01:17 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1666170081;\n\tbh=UntYsoOmCryGyWKA+wnI7n3tSkGOrY5INPDdjnLUPFs=;\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=Z0PRE/Rh9QASKUlKV+5ugnLWOgCuxp75Jbq57lANLMSX1d7eKEYjmz6OPMKxnvcjT\n\tR1WRj1y1P/gjtmOjtFTt9n0wEFzIZn5lXsWHuzOt6vFurzGiLtuDQMNh8etntiZKgx\n\tMFbk7mL1h6IT3zByoblCLt0Q+1s7psxW74+ig/WJe31AT/BUlTmgYWHDt5BmeK5aqx\n\tOYwWxGqzDbUcDpyC9kxpGF8WFT2JlJis4VrmOOxgEEzrvyaPMbOZmkHZS3I6+pFknn\n\tqL07bOiAPTZdn2zDq9zVluYPkUFDISR4PQmyTzBguy/kJLrI7eNMKZa7AMfVKFRCX/\n\tuT1/oxqv2OWxQ==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=yESThd+2Y5C1Vw4cwozsKb3HqyWcTJnJ+yXPhzqbGXI=;\n\tb=PIyDYPOjz46EkNMNZ79pkoUe4l2qFhzih9BzSILJaAm1In3lLL2D3cxlEaQNg4cyKT\n\t+0YFgGmE0Uo6gcOpUHL5VNFg8E+4ERu8vZyTajIEzUzB7yH7pS/GtWHL31vyPya8D7lG\n\tWtN/yUb5Gh9ZGT934VHPTYf/RXG7dmrQvvJPcmOUTUTG8FYa9cz16j5R837Gad3CBpSw\n\tQEKOhyMTe4Bi+j7/LyLaqzdA99DE4C+KzaKHSP2DK6MQpFwF5323hBXajlNuOfDbUwSu\n\ti1e6bM9tGQVNeIdu7RJejE5jJPG25A3owOiM4eN8JG8vRcd7kzk57rSV4i1THiBuRafB\n\tdWHA=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"PIyDYPOj\"; dkim-atps=neutral",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=yESThd+2Y5C1Vw4cwozsKb3HqyWcTJnJ+yXPhzqbGXI=;\n\tb=3CXBg4ikzGkrqNQrAFJ8FoJcsyKnZ8Jxcgk2qD+b85VwHm7IXJaR9Bkzh5ytsv1LT7\n\tDRG3WMjfE+2OOXZxenTriaVBNgqqewPCqi5ZywgYKo0mcQ0j0p1dNEIsX1TMjAWx3CQI\n\tTlkdt2rWTSOJMSZCWRgCIIJn/lm/SVfXtNDvGe5Gl0YXMrhDDgAclosKmBrLi08I6GtN\n\tpBPpcmc8CYN2UwIppN8dstzQEb/wMhOZi9npRLygvGPsFSKXiO/U7Kd2DRQBXfUxKVcs\n\trIpKN15Ws2Y3dMN9khppxij0oTaBsVV+x4xv5cp+vY5fOpgbKe/gQMKgWhLyRyQVGnjU\n\ttXUA==",
        "X-Gm-Message-State": "ACrzQf2ybTzMCeIRBU9Q79PkZ65j552t0nT4WGwLSVsxX0M3d20aildo\n\tl+faahfIVCpJUIoHghq4Ka+pVJEJ7HYEDg==",
        "X-Google-Smtp-Source": "AMsMyM4UX5lI1VWj6vGrUV1FbXxYxHOlDzcorbz/u0CfIzCEiaQKzus3k5e4KSTi3iuLfgaAPSu5Tg==",
        "X-Received": "by 2002:adf:9d8a:0:b0:230:5212:d358 with SMTP id\n\tp10-20020adf9d8a000000b002305212d358mr4363764wre.405.1666170078114; \n\tWed, 19 Oct 2022 02:01:18 -0700 (PDT)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed, 19 Oct 2022 10:01:02 +0100",
        "Message-Id": "<20221019090107.19975-3-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20221019090107.19975-1-naush@raspberrypi.com>",
        "References": "<20221019090107.19975-1-naush@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v4 2/7] delayed_controls: Add user cookie\n\tto DelayedControls",
        "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": "Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Naushir Patuck <naush@raspberrypi.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Allow the caller to provide a cookie value to DelayedControls::reset and\nDelayedControls::push. This cookie value is returned from DelayedControls::get\nfor the frame that has the control values applied to it.\n\nThe cookie value is useful in tracking when a set of controls has been applied\nto a frame. In a subsequent commit, it will be used by the Raspberry Pi IPA to\ntrack the IPA context used when setting the control values.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\nTested-by: David Plowman <david.plowman@raspberrypi.com>\n---\n include/libcamera/internal/delayed_controls.h |  8 +++++---\n src/libcamera/delayed_controls.cpp            | 20 ++++++++++++-------\n src/libcamera/pipeline/ipu3/ipu3.cpp          |  3 ++-\n .../pipeline/raspberrypi/raspberrypi.cpp      |  2 +-\n src/libcamera/pipeline/rkisp1/rkisp1.cpp      |  3 ++-\n test/delayed_controls.cpp                     |  8 ++++----\n 6 files changed, 27 insertions(+), 17 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/delayed_controls.h b/include/libcamera/internal/delayed_controls.h\nindex de8026e3e4f0..c7e79150afb8 100644\n--- a/include/libcamera/internal/delayed_controls.h\n+++ b/include/libcamera/internal/delayed_controls.h\n@@ -9,6 +9,7 @@\n \n #include <stdint.h>\n #include <unordered_map>\n+#include <utility>\n \n #include <libcamera/controls.h>\n \n@@ -27,10 +28,10 @@ public:\n \tDelayedControls(V4L2Device *device,\n \t\t\tconst std::unordered_map<uint32_t, ControlParams> &controlParams);\n \n-\tvoid reset();\n+\tvoid reset(unsigned int cookie = 0);\n \n-\tbool push(const ControlList &controls);\n-\tControlList get(uint32_t sequence);\n+\tbool push(const ControlList &controls, unsigned int cookie = 0);\n+\tstd::pair<ControlList, unsigned int> get(uint32_t sequence);\n \n \tvoid applyControls(uint32_t sequence);\n \n@@ -77,6 +78,7 @@ private:\n \tuint32_t writeCount_;\n \t/* \\todo Evaluate if we should index on ControlId * or unsigned int */\n \tstd::unordered_map<const ControlId *, RingBuffer<Info>> values_;\n+\tRingBuffer<unsigned int> cookies_;\n };\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/delayed_controls.cpp b/src/libcamera/delayed_controls.cpp\nindex 777441e8222a..3e7f60f9c421 100644\n--- a/src/libcamera/delayed_controls.cpp\n+++ b/src/libcamera/delayed_controls.cpp\n@@ -109,14 +109,16 @@ DelayedControls::DelayedControls(V4L2Device *device,\n \n /**\n  * \\brief Reset state machine\n+ * \\param[in] cookie User supplied reset cookie value\n  *\n  * Resets the state machine to a starting position based on control values\n  * retrieved from the device.\n  */\n-void DelayedControls::reset()\n+void DelayedControls::reset(unsigned int cookie)\n {\n \tqueueCount_ = 1;\n \twriteCount_ = 0;\n+\tcookies_[0] = cookie;\n \n \t/* Retrieve control as reported by the device. */\n \tstd::vector<uint32_t> ids;\n@@ -140,13 +142,15 @@ void DelayedControls::reset()\n /**\n  * \\brief Push a set of controls on the queue\n  * \\param[in] controls List of controls to add to the device queue\n+ * \\param[in] cookie User supplied cookie value for \\a controls\n  *\n  * Push a set of controls to the control queue. This increases the control queue\n- * depth by one.\n+ * depth by one. The \\a cookie value will be subsequently returned from\n+ * \\a get() for the frame with all controls applied.\n  *\n  * \\returns true if \\a controls are accepted, or false otherwise\n  */\n-bool DelayedControls::push(const ControlList &controls)\n+bool DelayedControls::push(const ControlList &controls, const unsigned int cookie)\n {\n \t/* Copy state from previous frame. */\n \tfor (auto &ctrl : values_) {\n@@ -180,6 +184,7 @@ bool DelayedControls::push(const ControlList &controls)\n \t\t\t<< \" at index \" << queueCount_;\n \t}\n \n+\tcookies_[queueCount_] = cookie;\n \tqueueCount_++;\n \n \treturn true;\n@@ -198,9 +203,10 @@ bool DelayedControls::push(const ControlList &controls)\n  * push(). The max history from the current sequence number that yields valid\n  * values are thus 16 minus number of controls pushed.\n  *\n- * \\return The controls at \\a sequence number\n+ * \\return The controls at \\a sequence number and associated user supplied\n+ * cookie value.\n  */\n-ControlList DelayedControls::get(uint32_t sequence)\n+std::pair<ControlList, unsigned int> DelayedControls::get(uint32_t sequence)\n {\n \tunsigned int index = std::max<int>(0, sequence - maxDelay_);\n \n@@ -217,7 +223,7 @@ ControlList DelayedControls::get(uint32_t sequence)\n \t\t\t<< \" at index \" << index;\n \t}\n \n-\treturn out;\n+\treturn { out, cookies_[index] };\n }\n \n /**\n@@ -276,7 +282,7 @@ void DelayedControls::applyControls(uint32_t sequence)\n \twhile (writeCount_ > queueCount_) {\n \t\tLOG(DelayedControls, Debug)\n \t\t\t<< \"Queue is empty, auto queue no-op.\";\n-\t\tpush({});\n+\t\tpush({}, cookies_[queueCount_ - 1]);\n \t}\n \n \tdevice_->setControls(&out);\ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 3b892d9671c5..bf612089fdcb 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -1389,7 +1389,8 @@ void IPU3CameraData::cio2BufferReady(FrameBuffer *buffer)\n \trequest->metadata().set(controls::SensorTimestamp,\n \t\t\t\tbuffer->metadata().timestamp);\n \n-\tinfo->effectiveSensorControls = delayedCtrls_->get(buffer->metadata().sequence);\n+\tauto [controls, cookie] = delayedCtrls_->get(buffer->metadata().sequence);\n+\tinfo->effectiveSensorControls = std::move(controls);\n \n \tif (request->findBuffer(&rawStream_))\n \t\tpipe()->completeBuffer(request, buffer);\ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 343f8cb2c7ed..23f2460190f4 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -1867,7 +1867,7 @@ void RPiCameraData::unicamBufferDequeue(FrameBuffer *buffer)\n \t\t * Lookup the sensor controls used for this frame sequence from\n \t\t * DelayedControl and queue them along with the frame buffer.\n \t\t */\n-\t\tControlList ctrl = delayedCtrls_->get(buffer->metadata().sequence);\n+\t\tauto [ctrl, cookie] = delayedCtrls_->get(buffer->metadata().sequence);\n \t\t/*\n \t\t * Add the frame timestamp to the ControlList for the IPA to use\n \t\t * as it does not receive the FrameBuffer object.\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex 455ee2a0a711..20049d089472 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -1191,8 +1191,9 @@ void PipelineHandlerRkISP1::statReady(FrameBuffer *buffer)\n \tif (data->frame_ <= buffer->metadata().sequence)\n \t\tdata->frame_ = buffer->metadata().sequence + 1;\n \n+\tauto [controls, cookie] = data->delayedCtrls_->get(buffer->metadata().sequence);\n \tdata->ipa_->processStatsBuffer(info->frame, info->statBuffer->cookie(),\n-\t\t\t\t       data->delayedCtrls_->get(buffer->metadata().sequence));\n+\t\t\t\t       controls);\n }\n \n REGISTER_PIPELINE_HANDLER(PipelineHandlerRkISP1)\ndiff --git a/test/delayed_controls.cpp b/test/delayed_controls.cpp\nindex a8ce9828d73d..322c545998b2 100644\n--- a/test/delayed_controls.cpp\n+++ b/test/delayed_controls.cpp\n@@ -96,7 +96,7 @@ protected:\n \n \t\t\tdelayed->applyControls(i);\n \n-\t\t\tControlList result = delayed->get(i);\n+\t\t\tauto [result, cookie] = delayed->get(i);\n \t\t\tint32_t brightness = result.get(V4L2_CID_BRIGHTNESS).get<int32_t>();\n \t\t\tif (brightness != value) {\n \t\t\t\tcerr << \"Failed single control without delay\"\n@@ -138,7 +138,7 @@ protected:\n \n \t\t\tdelayed->applyControls(i);\n \n-\t\t\tControlList result = delayed->get(i);\n+\t\t\tauto [result, cookie] = delayed->get(i);\n \t\t\tint32_t brightness = result.get(V4L2_CID_BRIGHTNESS).get<int32_t>();\n \t\t\tif (brightness != expected) {\n \t\t\t\tcerr << \"Failed single control with delay\"\n@@ -187,7 +187,7 @@ protected:\n \n \t\t\tdelayed->applyControls(i);\n \n-\t\t\tControlList result = delayed->get(i);\n+\t\t\tauto [result, cookie] = delayed->get(i);\n \t\t\tint32_t brightness = result.get(V4L2_CID_BRIGHTNESS).get<int32_t>();\n \t\t\tint32_t contrast = result.get(V4L2_CID_CONTRAST).get<int32_t>();\n \t\t\tif (brightness != expected || contrast != expected + 1) {\n@@ -247,7 +247,7 @@ protected:\n \n \t\t\tdelayed->applyControls(i);\n \n-\t\t\tControlList result = delayed->get(i);\n+\t\t\tauto [result, cookie] = delayed->get(i);\n \n \t\t\tint32_t brightness = result.get(V4L2_CID_BRIGHTNESS).get<int32_t>();\n \t\t\tint32_t contrast = result.get(V4L2_CID_CONTRAST).get<int32_t>();\n",
    "prefixes": [
        "libcamera-devel",
        "v4",
        "2/7"
    ]
}