Show a patch.

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

{
    "id": 17796,
    "url": "https://patchwork.libcamera.org/api/patches/17796/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/17796/",
    "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": "<20221115090755.2921-5-naush@raspberrypi.com>",
    "date": "2022-11-15T09:07:51",
    "name": "[libcamera-devel,v6,4/8] pipeline: raspberrypi: delayed_controls: Add user cookie to DelayedControls",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "dadac3988c2cff8884deb54c9a3cfa75d8b3ac6c",
    "submitter": {
        "id": 34,
        "url": "https://patchwork.libcamera.org/api/people/34/?format=api",
        "name": "Naushir Patuck",
        "email": "naush@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/17796/mbox/",
    "series": [
        {
            "id": 3609,
            "url": "https://patchwork.libcamera.org/api/series/3609/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3609",
            "date": "2022-11-15T09:07:47",
            "name": "Raspberry Pi AGC digital gain fixes",
            "version": 6,
            "mbox": "https://patchwork.libcamera.org/series/3609/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/17796/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/17796/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 DD54EC3285\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 15 Nov 2022 09:08:07 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BB0AE63079;\n\tTue, 15 Nov 2022 10:08:06 +0100 (CET)",
            "from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com\n\t[IPv6:2a00:1450:4864:20::42c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C69726307F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 15 Nov 2022 10:08:03 +0100 (CET)",
            "by mail-wr1-x42c.google.com with SMTP id j15so23120810wrq.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 15 Nov 2022 01:08:03 -0800 (PST)",
            "from naush-laptop.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tp25-20020a05600c1d9900b003c64c186206sm15143696wms.16.2022.11.15.01.08.02\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 15 Nov 2022 01:08:02 -0800 (PST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1668503286;\n\tbh=J6cFEdUNUolwDllVMsFx8kpijHwSyHWPGi/UH1SmfYc=;\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=VdyriAh3jmQ+xXDmyTW3AgLE9BKC3E/d8baelRuGPaZzWH8dzJVJW+IZJ55cp0nhA\n\tIK9Uaumh2OPOEgSU2RB5lZKmnHXd2vZ2z0U+9x/BaVtY2bHuNk37pbEc1VwW9U2lmX\n\tjvfjngL+17Qq9TdwrRIk4/6+88hm8nT73vO5t88NKRRBPGIvFfNBlujGn6HVImGAYn\n\tmxMdm93pGpmBpEW/mN5kytdOWCdGL61+LwtVVJQlrFqLgrf6OH56Ji7wyBGDA155ew\n\tQkD51c/0UoUzPhyxMwr751K/3icDgJYZmuX+ZI37/J/toEPaz6ozuBk3hPxueeCVMJ\n\tuwCh7CEItlO2Q==",
            "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=g4e6aCLgztXw7aLK8j8CpH1wz8V389BXNzUdmUAx/Uc=;\n\tb=p1fT+sUheMGfIcnAhb/GLseNdTIb/BAU3YFN4b3+O8vhHXl1+P0O6+7YbzFyi6/lW3\n\te8rrTnwfhROiWCZdDjfE9eyV6qfQ3rbCVouli5mkVaVSAZ6dAFfztW+B/wBnKZioVtV3\n\tBbEoPJCNkRAF/cBQjMC2OlilhiU3u7pem4VcBwBHr7tKh5GZuvSwmSQQGSBCVMq2Ggi2\n\tqr78HJMQgSmSLTWSdqUw04qYm7HwIQaLVpZ8qrv/DqSEMRhdDLc8IvlEyLf1Uc3GDI+O\n\tTXqxdjTWQ2jpVThAIWRWMpLw6dOifAvrA6/QW5aFOGQI68W/HxQRy7S2IIvtVY/Aynsi\n\tGn1w=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"p1fT+sUh\"; 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=g4e6aCLgztXw7aLK8j8CpH1wz8V389BXNzUdmUAx/Uc=;\n\tb=crSqkokpVF5kv983a8uPyAFeIrvM1Sx9Kl2Aydfw2deDkTJOwhc+VZKEucm0LlvklC\n\to8BpH9gz+WM1N66Jxty/KFqavdCii3i7GCKuBLw+GtmZLTqu4hg3hPAN58y7CPE57JyF\n\tgGVcfQk8lUtfiANoxxlezdz5o20jPBUhS1ZTdBO0gq+XhQEuFZK01Hdz54SGBjVq92RD\n\tv0fxs6NBNQIpjwEx5QBgto5X0KmRBRkiFjlU2xdFIim0X6Y73yaSbtPYPKNucLEyTLDW\n\tjsSqWJbA1VVGPrAn79LQ4yKsXzj8B4avUVgu4otdhxiLk3MQtlZJw6IzKES4np+TKwrd\n\tR6Eg==",
        "X-Gm-Message-State": "ANoB5pnVJa/4KhFsewhBUVjfp5zOnrOIcD1lrnTZJdsuUT8QhbA76qlk\n\tegHStDxlQs/2G+16jN0eOByRGbgNlc4Rhg==",
        "X-Google-Smtp-Source": "AA0mqf6ZYqbkIJk5ZZrmR2pjvprAbUPtQ8LKypPIy98Ri6o5erjlK0iSv9jX6F+Ej5FilvqyoGo3QQ==",
        "X-Received": "by 2002:adf:ff85:0:b0:235:c5de:75c3 with SMTP id\n\tj5-20020adfff85000000b00235c5de75c3mr9782712wrr.285.1668503283260; \n\tTue, 15 Nov 2022 01:08:03 -0800 (PST)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 15 Nov 2022 09:07:51 +0000",
        "Message-Id": "<20221115090755.2921-5-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20221115090755.2921-1-naush@raspberrypi.com>",
        "References": "<20221115090755.2921-1-naush@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v6 4/8] pipeline: raspberrypi:\n\tdelayed_controls: Add user cookie to 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 .../pipeline/raspberrypi/delayed_controls.cpp      | 14 ++++++++------\n .../pipeline/raspberrypi/delayed_controls.h        |  8 +++++---\n src/libcamera/pipeline/raspberrypi/raspberrypi.cpp |  6 +++---\n 3 files changed, 16 insertions(+), 12 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/raspberrypi/delayed_controls.cpp b/src/libcamera/pipeline/raspberrypi/delayed_controls.cpp\nindex 867e3866cc46..3db92e7d24fb 100644\n--- a/src/libcamera/pipeline/raspberrypi/delayed_controls.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/delayed_controls.cpp\n@@ -108,7 +108,7 @@ DelayedControls::DelayedControls(V4L2Device *device,\n \t\tmaxDelay_ = std::max(maxDelay_, controlParams_[id].delay);\n \t}\n \n-\treset();\n+\treset(0);\n }\n \n /**\n@@ -117,10 +117,11 @@ DelayedControls::DelayedControls(V4L2Device *device,\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@@ -150,7 +151,7 @@ void DelayedControls::reset()\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@@ -184,6 +185,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@@ -204,7 +206,7 @@ bool DelayedControls::push(const ControlList &controls)\n  *\n  * \\return The controls at \\a sequence number\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@@ -221,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@@ -280,7 +282,7 @@ void DelayedControls::applyControls(uint32_t sequence)\n \twhile (writeCount_ > queueCount_) {\n \t\tLOG(RPiDelayedControls, 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/raspberrypi/delayed_controls.h b/src/libcamera/pipeline/raspberrypi/delayed_controls.h\nindex 238b86ab6cb4..61f755f0fddd 100644\n--- a/src/libcamera/pipeline/raspberrypi/delayed_controls.h\n+++ b/src/libcamera/pipeline/raspberrypi/delayed_controls.h\n@@ -11,6 +11,7 @@\n \n #include <stdint.h>\n #include <unordered_map>\n+#include <utility>\n \n #include <libcamera/controls.h>\n \n@@ -31,10 +32,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);\n \n-\tbool push(const ControlList &controls);\n-\tControlList get(uint32_t sequence);\n+\tbool push(const ControlList &controls, unsigned int cookie);\n+\tstd::pair<ControlList, unsigned int> get(uint32_t sequence);\n \n \tvoid applyControls(uint32_t sequence);\n \n@@ -78,6 +79,7 @@ private:\n \tuint32_t queueCount_;\n \tuint32_t writeCount_;\n \tstd::unordered_map<const ControlId *, RingBuffer<Info>> values_;\n+\tRingBuffer<unsigned int> cookies_;\n };\n \n } /* namespace RPi */\ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex f3be4ee3b730..2c12ed1fba95 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -1064,7 +1064,7 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls)\n \t * Reset the delayed controls with the gain and exposure values set by\n \t * the IPA.\n \t */\n-\tdata->delayedCtrls_->reset();\n+\tdata->delayedCtrls_->reset(0);\n \n \tdata->state_ = RPiCameraData::State::Idle;\n \n@@ -1794,7 +1794,7 @@ void RPiCameraData::setIspControls(const ControlList &controls)\n \n void RPiCameraData::setDelayedControls(const ControlList &controls)\n {\n-\tif (!delayedCtrls_->push(controls))\n+\tif (!delayedCtrls_->push(controls, 0))\n \t\tLOG(RPI, Error) << \"V4L2 DelayedControl set failed\";\n \thandleState();\n }\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.\n",
    "prefixes": [
        "libcamera-devel",
        "v6",
        "4/8"
    ]
}