Patch Detail
Show a patch.
GET /api/patches/17741/?format=api
{ "id": 17741, "url": "https://patchwork.libcamera.org/api/patches/17741/?format=api", "web_url": "https://patchwork.libcamera.org/patch/17741/", "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": "<20221031114522.14215-7-naush@raspberrypi.com>", "date": "2022-10-31T11:45:21", "name": "[libcamera-devel,v5,6/7] pipeline: ipa: raspberrypi: Use IPA cookies", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "90758f38ba50600c4d6705bafc84d93a78c8b04b", "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/17741/mbox/", "series": [ { "id": 3590, "url": "https://patchwork.libcamera.org/api/series/3590/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3590", "date": "2022-10-31T11:45:15", "name": "Raspberry Pi AGC digital gain fixes", "version": 5, "mbox": "https://patchwork.libcamera.org/series/3590/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/17741/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/17741/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 41694C3288\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 31 Oct 2022 11:45:41 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9C8A56304C;\n\tMon, 31 Oct 2022 12:45:40 +0100 (CET)", "from mail-wr1-x432.google.com (mail-wr1-x432.google.com\n\t[IPv6:2a00:1450:4864:20::432])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7A85863044\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 31 Oct 2022 12:45:33 +0100 (CET)", "by mail-wr1-x432.google.com with SMTP id bk15so15536335wrb.13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 31 Oct 2022 04:45:33 -0700 (PDT)", "from naush-laptop.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\th11-20020adff18b000000b0023677e1157fsm6936354wro.56.2022.10.31.04.45.31\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 31 Oct 2022 04:45:31 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1667216740;\n\tbh=3Jo1qVg3Sfuw1vzQ2V5aXJtvy5yWBNhAi4JDuOuniPU=;\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=is+Eb1tkuOVY6GNp5NJbmsBCGPiEYlQphMJv2jv+cDQhMCNsIdIka5+rQOSjtKO/x\n\tmut+xA+g9K3E4QCW7Xlirp/oqU+cKZKw4/KDoOWEuqvY44fxu8DeEt9Kd+EJcCZW8b\n\tPgdpXwk99jXVITUXLZwGMpipw0zFa1hUt0tW6RtSQnu5Q5T7kFfeXPOzkLniNoJMSw\n\tZZUNNxj2gZraNLbUP0Sq6Cg/eUkz2FRDUhUcr0TpaQQe51eWkWafluDccAEgw8PlMp\n\tHZyZSQRNQED42tMYX7ZLSvzmXIuCNw2x3aHCVoi1AcFrPSEbz0BdHVqfJvd4+FjhbK\n\tBKaKIbMLEtH3w==", "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=5snii4aeFSeyDQEkTWsmNtv8fYZz92tBHLMau6EEI/s=;\n\tb=AhDeLbUUBigs5jAZeLKHfapt/5wozo1N4I5Ct2dW5+ieDW+vCORkC3f0pgbKX8Fskn\n\tmV9PPDuGPy1PuO3bDGzlhEiIOjjkzQv3BrXfG7SZcMaEtHevtm8807b/3yMeHeWEONKy\n\td7eXgJZNqZyxQMkcRC4oOjExt1RGz8QsI5yHprF8Klaasdr//TPoD3BR5RLaVnm2wnSk\n\tYuMe5r4KsvSC2qjYDF9wx16piBtHTBwOmUDyvg1mmJTjSU0AaPsBgm/n0WCSTlNYAuO1\n\t+DASMyNWOZ11LhAWIfF9tVyLLBHF2gDiPEpYWTBY/Lu1QTutoPlTM3b+SoAwXaA1sZcC\n\tUTOw==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"AhDeLbUU\"; 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=5snii4aeFSeyDQEkTWsmNtv8fYZz92tBHLMau6EEI/s=;\n\tb=MKKbbFLJrMINDIv6x+OD6k08s0xpoyt5Knf3AfT/vVqY2TB+cGFo3qv7t4RH9i4zI7\n\t+lgNx9TBaRWVtaP6d/vkXOk4565qln/vZ2yQeAksbx1o8ZRiHnXgXsxMMXuNOdljnQ3y\n\tA79VG4nY1ND5CQfvvYnnnrMntEVGYSEQMcfS/3DxGeQ+NX57KgohOJ437+eU9/kouOOZ\n\tDjOouiCIz1ECBbkg/r1nLoryyzTHAJmehwrlgNsi3KDCy4qsPP6yo40UQthrojEVsyRf\n\tZhJTlqbAEjrPLdoUqDIpy7hsHM/x23JI+fmRrmo/MtDc53gImiug2ZaC3ipT+q5iqLV3\n\ttdUw==", "X-Gm-Message-State": "ACrzQf3QHEeh5UP3NTBTp4WxjJwCwiw/Vxa6kMF+owKgVOAE7tONUEIi\n\tKV8Ci+FrUgB6ybEfGftko1z8NYv4e+mGOg==", "X-Google-Smtp-Source": "AMsMyM4oPcnPpkg7PGNAWFCC6EONDNp95A37W9JDinmGEwdNQDS2yXsN2hMOLRJlWV80kFAknjxhQQ==", "X-Received": "by 2002:adf:c082:0:b0:236:d057:3fff with SMTP id\n\td2-20020adfc082000000b00236d0573fffmr1979121wrf.206.1667216732784; \n\tMon, 31 Oct 2022 04:45:32 -0700 (PDT)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 31 Oct 2022 11:45:21 +0000", "Message-Id": "<20221031114522.14215-7-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20221031114522.14215-1-naush@raspberrypi.com>", "References": "<20221031114522.14215-1-naush@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v5 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 | 6 ++-\n src/ipa/raspberrypi/raspberrypi.cpp | 42 ++++++++++---------\n .../pipeline/raspberrypi/raspberrypi.cpp | 16 ++++---\n 3 files changed, 37 insertions(+), 27 deletions(-)", "diff": "diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom\nindex 40f78d9e3b3f..325d2d855bc0 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 ipaContext;\n+\tuint32 delayContext;\n };\n \n struct IPAConfig {\n@@ -127,7 +129,7 @@ interface IPARPiInterface {\n \t */\n \tunmapBuffers(array<uint32> ids);\n \n-\t[async] signalStatReady(uint32 bufferId);\n+\t[async] signalStatReady(uint32 bufferId, uint32 ipaContext);\n \t[async] signalQueueRequest(libcamera.ControlList controls);\n \t[async] signalIspPrepare(ISPConfig data);\n };\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 delayContext);\n };\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 799a4fe70000..194171a8bc96 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -126,7 +126,7 @@ public:\n \t\t ControlList *controls, IPAConfigResult *result) override;\n \tvoid mapBuffers(const std::vector<IPABuffer> &buffers) override;\n \tvoid unmapBuffers(const std::vector<unsigned int> &ids) override;\n-\tvoid signalStatReady(const uint32_t bufferId) override;\n+\tvoid signalStatReady(const uint32_t bufferId, uint32_t ipaContext) override;\n \tvoid signalQueueRequest(const ControlList &controls) override;\n \tvoid signalIspPrepare(const ISPConfig &data) override;\n \n@@ -137,9 +137,9 @@ private:\n \tvoid queueRequest(const ControlList &controls);\n \tvoid returnEmbeddedBuffer(unsigned int bufferId);\n \tvoid prepareISP(const ISPConfig &data);\n-\tvoid reportMetadata();\n-\tvoid fillDeviceStatus(const ControlList &sensorControls);\n-\tvoid processStats(unsigned int bufferId);\n+\tvoid reportMetadata(unsigned int ipaContext);\n+\tvoid fillDeviceStatus(const ControlList &sensorControls, unsigned int ipaContext);\n+\tvoid processStats(unsigned int bufferId, unsigned int ipaContext);\n \tvoid applyFrameDurations(Duration minFrameDuration, Duration maxFrameDuration);\n \tvoid applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls);\n \tvoid applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls);\n@@ -509,14 +509,16 @@ void IPARPi::unmapBuffers(const std::vector<unsigned int> &ids)\n \t}\n }\n \n-void IPARPi::signalStatReady(uint32_t bufferId)\n+void IPARPi::signalStatReady(uint32_t bufferId, uint32_t ipaContext)\n {\n+\tunsigned int context = ipaContext % rpiMetadata_.size();\n+\n \tif (++checkCount_ != frameCount_) /* assert here? */\n \t\tLOG(IPARPI, Error) << \"WARNING: Prepare/Process mismatch!!!\";\n \tif (processPending_ && frameCount_ > mistrustCount_)\n-\t\tprocessStats(bufferId);\n+\t\tprocessStats(bufferId, context);\n \n-\treportMetadata();\n+\treportMetadata(context);\n \n \tstatsMetadataComplete.emit(bufferId & MaskID, libcameraMetadata_);\n }\n@@ -540,9 +542,9 @@ void IPARPi::signalIspPrepare(const ISPConfig &data)\n \trunIsp.emit(data.bayerBufferId & MaskID);\n }\n \n-void IPARPi::reportMetadata()\n+void IPARPi::reportMetadata(unsigned int ipaContext)\n {\n-\tRPiController::Metadata &rpiMetadata = rpiMetadata_[0];\n+\tRPiController::Metadata &rpiMetadata = rpiMetadata_[ipaContext];\n \tstd::unique_lock<RPiController::Metadata> lock(rpiMetadata);\n \n \t/*\n@@ -1009,12 +1011,12 @@ 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_[0];\n+\tunsigned int ipaContext = data.ipaContext % rpiMetadata_.size();\n+\tRPiController::Metadata &rpiMetadata = rpiMetadata_[ipaContext];\n \tSpan<uint8_t> embeddedBuffer;\n \n-\tlastMetadata = std::move(rpiMetadata);\n-\tfillDeviceStatus(data.controls);\n+\trpiMetadata.clear();\n+\tfillDeviceStatus(data.controls, ipaContext);\n \n \tif (data.embeddedBufferPresent) {\n \t\t/*\n@@ -1046,7 +1048,9 @@ 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 =\n+\t\t\trpiMetadata_[ipaContext ? ipaContext : rpiMetadata_.size()];\n+\t\trpiMetadata.mergeCopy(lastMetadata);\n \t\tprocessPending_ = false;\n \t\treturn;\n \t}\n@@ -1105,7 +1109,7 @@ void IPARPi::prepareISP(const ISPConfig &data)\n \t\tsetIspControls.emit(ctrls);\n }\n \n-void IPARPi::fillDeviceStatus(const ControlList &sensorControls)\n+void IPARPi::fillDeviceStatus(const ControlList &sensorControls, unsigned int ipaContext)\n {\n \tDeviceStatus deviceStatus = {};\n \n@@ -1121,12 +1125,12 @@ void IPARPi::fillDeviceStatus(const ControlList &sensorControls)\n \n \tLOG(IPARPI, Debug) << \"Metadata - \" << deviceStatus;\n \n-\trpiMetadata_[0].set(\"device.status\", deviceStatus);\n+\trpiMetadata_[ipaContext].set(\"device.status\", deviceStatus);\n }\n \n-void IPARPi::processStats(unsigned int bufferId)\n+void IPARPi::processStats(unsigned int bufferId, unsigned int ipaContext)\n {\n-\tRPiController::Metadata &rpiMetadata = rpiMetadata_[0];\n+\tRPiController::Metadata &rpiMetadata = rpiMetadata_[ipaContext];\n \n \tauto it = buffers_.find(bufferId);\n \tif (it == buffers_.end()) {\n@@ -1145,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, ipaContext);\n \t}\n }\n \ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 29626c0ef14e..cae1f7b9aea3 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 delayContext);\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 delayContext;\n \t};\n \n \tstd::queue<BayerFrame> bayerQueue_;\n@@ -1792,9 +1793,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 delayContext)\n {\n-\tif (!delayedCtrls_->push(controls, 0))\n+\tif (!delayedCtrls_->push(controls, delayContext))\n \t\tLOG(RPI, Error) << \"V4L2 DelayedControl set failed\";\n \thandleState();\n }\n@@ -1867,13 +1868,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, delayContext] = 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), delayContext });\n \t} else {\n \t\tembeddedQueue_.push(buffer);\n \t}\n@@ -1923,7 +1924,8 @@ void RPiCameraData::ispOutputDequeue(FrameBuffer *buffer)\n \t * application until after the IPA signals so.\n \t */\n \tif (stream == &isp_[Isp::Stats]) {\n-\t\tipa_->signalStatReady(ipa::RPi::MaskStats | static_cast<unsigned int>(index));\n+\t\tipa_->signalStatReady(ipa::RPi::MaskStats | static_cast<unsigned int>(index),\n+\t\t\t\t requestQueue_.front()->sequence());\n \t} else {\n \t\t/* Any other ISP output can be handed back to the application now. */\n \t\thandleStreamBuffer(buffer, stream);\n@@ -2168,6 +2170,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.ipaContext = request->sequence();\n+\tispPrepare.delayContext = bayerFrame.delayContext;\n \n \tif (embeddedBuffer) {\n \t\tunsigned int embeddedId = unicam_[Unicam::Embedded].getBufferId(embeddedBuffer);\n", "prefixes": [ "libcamera-devel", "v5", "6/7" ] }