Show a patch.

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

{
    "id": 17275,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/17275/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/17275/",
    "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": "<20220902120808.842-3-naush@raspberrypi.com>",
    "date": "2022-09-02T12:08:04",
    "name": "[libcamera-devel,v1,2/6] delayed_controls: Add user cookie to DelayedControls",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "5f175fbfd60f3ea772c2d75255b303124893b203",
    "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/17275/mbox/",
    "series": [
        {
            "id": 3459,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3459/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3459",
            "date": "2022-09-02T12:08:02",
            "name": "Raspberry Pi AGC digial gain fixes",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3459/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/17275/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/17275/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 C22E1C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  2 Sep 2022 12:08:20 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E7DDD61FE3;\n\tFri,  2 Sep 2022 14:08:19 +0200 (CEST)",
            "from mail-wm1-x334.google.com (mail-wm1-x334.google.com\n\t[IPv6:2a00:1450:4864:20::334])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BCCD461FDE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  2 Sep 2022 14:08:17 +0200 (CEST)",
            "by mail-wm1-x334.google.com with SMTP id\n\ti188-20020a1c3bc5000000b003a7b6ae4eb2so3207218wma.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 02 Sep 2022 05:08:17 -0700 (PDT)",
            "from naush-laptop.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\th2-20020a5d4302000000b0021e51c039c5sm1397809wrq.80.2022.09.02.05.08.16\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 02 Sep 2022 05:08:16 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1662120500;\n\tbh=g+yojow+QSITK4eB7dyNWvdns/J7/9ZmNwJ1ghjHEIY=;\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=pnKmR74Yk5lNZrXafAVXsIPJ+fh49TdOz5bBwXEzRgb9FaHgVFKafAQ0HjIg/FXwv\n\tOUPDK8k5YFTodMgdZiWEduCO/CT2IuE0sf3yF+QFhLF4TAEGfkrYApIXIcCcAhL53H\n\tJg0X3GtFJRtPx/Xh45TzRWXHNb6WkBMpb11aANrDKXYvo3Se3EsgyXHtjENXwmfq+f\n\tOckPGpPCIF9DgOQO1CueFG4V8M7uVpveybVeB8mumGmHArwgwkraOXAoIYCMuu5oIu\n\tCs2RjlVSmLsxL4PEk2l0IUZdQT+yUpiVqyl9SIQYMhxrfs57e9DYxRDMUtgCu/aWLV\n\tzQx1Jejrp2DPw==",
            "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\tbh=TLd3IVP2iO3I4bZNxOYJauQGUqiKFviOy3ElyLrY/78=;\n\tb=h13YdhOhNKnO856Arbhty28zkJO5AUbbf53EukhhS57hpxaXE16yWnIKiF9enTuWbf\n\tS5PaGP5iJui7iKsa2cHymW9dA0RgcS/t8mQvOm3Ys5nipE3ZIr6Pu2hUs3WunXl/c/8u\n\tug8a66gO2A5sgWm1SdxlqbqPCAeplySoplXuA2LYPjebEFTqLm9z1WBBCZonAvqL2peV\n\tsq9d8qrNymO44vjD9LTQsW+WTat0/N62qB+h+4yrbBdBu1oBhU5exWnJRRQsZM8g+BOq\n\tOlqfAQgzjJGqchhyaKxioI7WJ7hU6Y565bJga2ufCkI/wLdo7XPloueLafSFVNJ/sd9L\n\tJF2g=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"h13YdhOh\"; 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;\n\tbh=TLd3IVP2iO3I4bZNxOYJauQGUqiKFviOy3ElyLrY/78=;\n\tb=pgYFBzwwrFK81zWdOZn3esoi/K4FUehoOVLxvqL9JnQS0C5zPjLiJAELztxp2KU+J7\n\tHigcGj9s73nTMTQRChycMx3X24Ik3Sq2W8MUUPRTUJWmztDcvzz8ao0A7a+TvbhfNQWf\n\t0Kziv5YGHs30Pcp68HaccZcl1r2UNXckuxTjUglsaFwPLWiOLo9z7ud17YhLyL4ExTLL\n\tG7Qxu5gYBr294r++0NPBzsHPck30SUvraPevyXNty3/ex990Q0mO3fNnmjuiLDNQnfdA\n\tuhSAQVEyz8ATCDKDhg/hbkZdyuCCJyg23x+9pzb991w4DVtD+7O9TejDlkyl2BEPcF/e\n\tPFBA==",
        "X-Gm-Message-State": "ACgBeo3g8z56gdbf7HwezcwkNxf0ZOTRjA4tTYqoXvkcsIsgKPHgeoDY\n\tGTg8RE0lMc7y6leoMLRmuVgcyUnWnKGL1AZG",
        "X-Google-Smtp-Source": "AA6agR7wxSdKAqwMPJGx1UqSLHCZs7BuRGGZ3AWdcvbFIRox8BGIUltDh5CIXT6C3x5CQAcxafK4oA==",
        "X-Received": "by 2002:a05:600c:3ac9:b0:3a5:f114:1f8 with SMTP id\n\td9-20020a05600c3ac900b003a5f11401f8mr2557143wms.204.1662120497174; \n\tFri, 02 Sep 2022 05:08:17 -0700 (PDT)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri,  2 Sep 2022 13:08:04 +0100",
        "Message-Id": "<20220902120808.842-3-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20220902120808.842-1-naush@raspberrypi.com>",
        "References": "<20220902120808.842-1-naush@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v1 2/6] 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>\n---\n include/libcamera/internal/delayed_controls.h   |  8 +++++---\n src/libcamera/delayed_controls.cpp              | 17 +++++++++++------\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, 25 insertions(+), 16 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/delayed_controls.h b/include/libcamera/internal/delayed_controls.h\nindex f6e622f1dfba..fa222bb17d23 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 *, ControlRingBuffer<Info>> values_;\n+\tControlRingBuffer<unsigned int> cookies_;\n };\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/delayed_controls.cpp b/src/libcamera/delayed_controls.cpp\nindex 777441e8222a..c2198d0e8d77 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,14 @@ 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  *\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 +183,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 +202,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 +222,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 +281,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 93219a6c1134..b0f0b22c5298 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -1385,7 +1385,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 b4094898ca6c..d34a906c3cea 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -1848,7 +1848,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 03bbe6b467ae..cec90810ff95 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -1159,8 +1159,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, cooke] = 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",
        "v1",
        "2/6"
    ]
}