Patch Detail
Show a patch.
GET /api/1.1/patches/17631/?format=api
{ "id": 17631, "url": "https://patchwork.libcamera.org/api/1.1/patches/17631/?format=api", "web_url": "https://patchwork.libcamera.org/patch/17631/", "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-7-naush@raspberrypi.com>", "date": "2022-10-19T09:01:06", "name": "[libcamera-devel,v4,6/7] pipeline: ipa: raspberrypi: Use IPA cookies", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "5dc51a7696f4001ac4f416cd48db248af1be1bdf", "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/17631/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/17631/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/17631/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 4E671C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 19 Oct 2022 09:01:27 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DC4B762E4C;\n\tWed, 19 Oct 2022 11:01:26 +0200 (CEST)", "from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com\n\t[IPv6:2a00:1450:4864:20::42f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 34E8962E46\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 19 Oct 2022 11:01:23 +0200 (CEST)", "by mail-wr1-x42f.google.com with SMTP id n12so27810880wrp.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 19 Oct 2022 02:01:23 -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.21\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 19 Oct 2022 02:01:21 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1666170086;\n\tbh=njQ9gW5DKOXOyMQ0F7GWvUGNhge0VpeeJz1MElUPrg4=;\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=D4sJfp623TCg/D0eoGQHDcvHAmQ4Ftms9TfHdg4Eoe7bq9p8S+O7t6dwRc9wmkej8\n\t5BTgOiDM4QZViCVN7Zoh40LsWL5MdlQMniNGOPu5WtNTp3TEqIgeOvZKHyZ2VpwbPU\n\tNLpWIsD6Yf31jy8UPOVUvCQzgz4P5js6ghth1qu1RvQw0RoNYFVYnBC307bfZUjcLQ\n\tniHv3AZTTbd+YLTWfwoCUp7rP78UIbROaEq79H77AOBTGeoKpmpDFfIuOLQTAMQozt\n\tfND4IaoB9c+aqkmpZotz2hxLDAW86elo+ZISduEJ9IHqBQIkuJuLzAdd545bhh/spC\n\tDF4F1bJeyClyg==", "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=W917K/nmtTKhwmLkk3bJj7stCIhhxNruF7ozW1jiSAU=;\n\tb=OctBth4TcIHemxsXPy9Nfwhu5mj2oO/9ikehYJ4WGn+B1VntgndrBEuPm07PMZ/dkn\n\tz0Assm2OE1qzRzhZG2BOIHuK1EvNehax3t2i7wIm9ZsrcEdhlOdXLF+DsvmadoG+se+7\n\tLlzrqaXZqrWKvbroFdlLAZSh/Kpi0NMZeTgPcLg/r68v2gzR8RoSHwxzOykt/5tR5i/g\n\tfL1weqSzu1dMRXkj/L5wCdclcdGsIC6Ww8JjcwmhmFzLypdrsq2JB06ziLnZ2JljbzSX\n\t9bPi201VTrv2Q0Kogd1oJHcIlVN/O1dPgThk0dGXWkH3i1XAjP/OStjJMxirmRnj8UCA\n\tiDaA==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"OctBth4T\"; 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=W917K/nmtTKhwmLkk3bJj7stCIhhxNruF7ozW1jiSAU=;\n\tb=op/m9eJUYibXR+gqr+crqI/ZFLmj0PhqWLnmjRB4YMObf0+GylUE5r9kQ7t2H//xZU\n\tJotbvTnyB074pAeS4+BDVZq/SH6Qi937ax1gaux7cFlDHhoNha9OcuNmS6h0JBmMsiDk\n\tvAtxtX+44O+AfKuk4oeX2GQBXh2FfFIMVSj2dq7J5FB1TBDhDrhuP5ZgYdTL4I+kMkxy\n\tAY6k4xm0Kb0wJLZxP6F830uH6X7pWwxrCPj620JKXYaZfDDRY3ktTeewOlaOX2UNE/V9\n\tNjtcjxRqwWqq9rv21cNRDar61hW6wec2ievtyehqH2fAwPxsk2NG+P0M1dWpwfVo8rJY\n\tjgsQ==", "X-Gm-Message-State": "ACrzQf36trnHUtgB66+L1FgNSceqHDF2Xw0yed9sMO5NW10e3SYHYUO0\n\tJQuL0WAr1yMcuVqiubJtWECmaXPkcVfAPg==", "X-Google-Smtp-Source": "AMsMyM6lviXBBuajoqIJUHRmMAhYLL7aQI/AR3GjbTNl+vNt1asBU+XNufmRvGVh0G3PtfXJb6mkJA==", "X-Received": "by 2002:a05:6000:1051:b0:22e:5d8a:d3d5 with SMTP id\n\tc17-20020a056000105100b0022e5d8ad3d5mr4309112wrx.476.1666170082582; \n\tWed, 19 Oct 2022 02:01:22 -0700 (PDT)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 19 Oct 2022 10:01:06 +0100", "Message-Id": "<20221019090107.19975-7-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 6/7] pipeline: ipa: raspberrypi: Use\n\tIPA cookies", "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": "Pass an IPA cookie from the pipeline handler to the IPA and eventually back to\nthe pipeline handler through the setDelayedControls signal. This cookie is used\nto index the RPiController::Metadata object to be used for the frame.\n\nThe IPA cookie is then returned from DelayedControls when the frame with the\napplied controls has been returned from the sensor, and eventually passed back\nto the IPA from the signalIspPrepare signal.\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/ipa/raspberrypi.mojom | 4 +++-\n src/ipa/raspberrypi/raspberrypi.cpp | 12 +++++++-----\n .../pipeline/raspberrypi/raspberrypi.cpp | 19 +++++++++++++------\n 3 files changed, 23 insertions(+), 12 deletions(-)", "diff": "diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom\nindex 40f78d9e3b3f..bb5abd895262 100644\n--- a/include/libcamera/ipa/raspberrypi.mojom\n+++ b/include/libcamera/ipa/raspberrypi.mojom\n@@ -37,6 +37,8 @@ struct ISPConfig {\n \tuint32 bayerBufferId;\n \tbool embeddedBufferPresent;\n \tlibcamera.ControlList controls;\n+\tuint32 ipaCookie;\n+\tuint32 delayCookie;\n };\n \n struct IPAConfig {\n@@ -137,5 +139,5 @@ interface IPARPiEventInterface {\n \trunIsp(uint32 bufferId);\n \tembeddedComplete(uint32 bufferId);\n \tsetIspControls(libcamera.ControlList controls);\n-\tsetDelayedControls(libcamera.ControlList controls);\n+\tsetDelayedControls(libcamera.ControlList controls, uint32 delayCookie);\n };\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 9e7792f5dfbe..aed8f68aded9 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -168,6 +168,7 @@ private:\n \tRPiController::Controller controller_;\n \tstd::array<RPiController::Metadata, numMetadataContexts> rpiMetadata_;\n \tunsigned int metadataIdx_;\n+\tunsigned int lastMetadataIdx_;\n \n \t/*\n \t * We count frames to decide if the frame must be hidden (e.g. from\n@@ -324,7 +325,6 @@ void IPARPi::start(const ControlList &controls, StartConfig *startConfig)\n \n \tfirstStart_ = false;\n \tlastRunTimestamp_ = 0;\n-\tmetadataIdx_ = 0;\n }\n \n void IPARPi::setMode(const IPACameraSensorInfo &sensorInfo)\n@@ -535,6 +535,8 @@ void IPARPi::signalIspPrepare(const ISPConfig &data)\n \t * avoid running the control algos for a few frames in case\n \t * they are \"unreliable\".\n \t */\n+\tlastMetadataIdx_ = metadataIdx_;\n+\tmetadataIdx_ = data.ipaCookie % rpiMetadata_.size();\n \tprepareISP(data);\n \tframeCount_++;\n \n@@ -1011,11 +1013,10 @@ void IPARPi::returnEmbeddedBuffer(unsigned int bufferId)\n void IPARPi::prepareISP(const ISPConfig &data)\n {\n \tint64_t frameTimestamp = data.controls.get(controls::SensorTimestamp).value_or(0);\n-\tRPiController::Metadata lastMetadata;\n \tRPiController::Metadata &rpiMetadata = rpiMetadata_[metadataIdx_];\n \tSpan<uint8_t> embeddedBuffer;\n \n-\tlastMetadata = std::move(rpiMetadata);\n+\trpiMetadata.clear();\n \tfillDeviceStatus(data.controls);\n \n \tif (data.embeddedBufferPresent) {\n@@ -1048,7 +1049,8 @@ void IPARPi::prepareISP(const ISPConfig &data)\n \t\t * current frame, or any other bits of metadata that were added\n \t\t * in helper_->Prepare().\n \t\t */\n-\t\trpiMetadata.merge(lastMetadata);\n+\t\tRPiController::Metadata &lastMetadata = rpiMetadata_[lastMetadataIdx_];\n+\t\trpiMetadata.mergeCopy(lastMetadata);\n \t\tprocessPending_ = false;\n \t\treturn;\n \t}\n@@ -1147,7 +1149,7 @@ void IPARPi::processStats(unsigned int bufferId)\n \t\tControlList ctrls(sensorCtrls_);\n \t\tapplyAGC(&agcStatus, ctrls);\n \n-\t\tsetDelayedControls.emit(ctrls);\n+\t\tsetDelayedControls.emit(ctrls, metadataIdx_);\n \t}\n }\n \ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 23f2460190f4..8f6c6c0ce89f 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -206,7 +206,7 @@ public:\n \tvoid runIsp(uint32_t bufferId);\n \tvoid embeddedComplete(uint32_t bufferId);\n \tvoid setIspControls(const ControlList &controls);\n-\tvoid setDelayedControls(const ControlList &controls);\n+\tvoid setDelayedControls(const ControlList &controls, uint32_t delayCookie);\n \tvoid setSensorControls(ControlList &controls);\n \tvoid unicamTimeout();\n \n@@ -262,6 +262,7 @@ public:\n \tstruct BayerFrame {\n \t\tFrameBuffer *buffer;\n \t\tControlList controls;\n+\t\tunsigned int delayCookie;\n \t};\n \n \tstd::queue<BayerFrame> bayerQueue_;\n@@ -294,6 +295,9 @@ public:\n \t/* Have internal buffers been allocated? */\n \tbool buffersAllocated_;\n \n+\t/* Frame cookie to pass to the IPA */\n+\tunsigned int ipaCookie_;\n+\n private:\n \tvoid checkRequestCompleted();\n \tvoid fillRequestMetadata(const ControlList &bufferControls,\n@@ -1064,7 +1068,8 @@ 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->ipaCookie_ = 0;\n+\tdata->delayedCtrls_->reset(data->ipaCookie_);\n \n \tdata->state_ = RPiCameraData::State::Idle;\n \n@@ -1792,9 +1797,9 @@ void RPiCameraData::setIspControls(const ControlList &controls)\n \thandleState();\n }\n \n-void RPiCameraData::setDelayedControls(const ControlList &controls)\n+void RPiCameraData::setDelayedControls(const ControlList &controls, uint32_t delayCookie)\n {\n-\tif (!delayedCtrls_->push(controls))\n+\tif (!delayedCtrls_->push(controls, delayCookie))\n \t\tLOG(RPI, Error) << \"V4L2 DelayedControl set failed\";\n \thandleState();\n }\n@@ -1867,13 +1872,13 @@ 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\tauto [ctrl, cookie] = delayedCtrls_->get(buffer->metadata().sequence);\n+\t\tauto [ctrl, delayCookie] = 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 \t\t */\n \t\tctrl.set(controls::SensorTimestamp, buffer->metadata().timestamp);\n-\t\tbayerQueue_.push({ buffer, std::move(ctrl) });\n+\t\tbayerQueue_.push({ buffer, std::move(ctrl), delayCookie });\n \t} else {\n \t\tembeddedQueue_.push(buffer);\n \t}\n@@ -2168,6 +2173,8 @@ void RPiCameraData::tryRunPipeline()\n \tipa::RPi::ISPConfig ispPrepare;\n \tispPrepare.bayerBufferId = ipa::RPi::MaskBayerData | bayerId;\n \tispPrepare.controls = std::move(bayerFrame.controls);\n+\tispPrepare.ipaCookie = ipaCookie_++;\n+\tispPrepare.delayCookie = bayerFrame.delayCookie;\n \n \tif (embeddedBuffer) {\n \t\tunsigned int embeddedId = unicam_[Unicam::Embedded].getBufferId(embeddedBuffer);\n", "prefixes": [ "libcamera-devel", "v4", "6/7" ] }