Patch Detail
Show a patch.
GET /api/patches/20547/?format=api
{ "id": 20547, "url": "https://patchwork.libcamera.org/api/patches/20547/?format=api", "web_url": "https://patchwork.libcamera.org/patch/20547/", "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": "<20240703175119.1872585-7-mzamazal@redhat.com>", "date": "2024-07-03T17:51:06", "name": "[v2,06/19] libcamera: software_isp: Make stats frame and buffer aware", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "5366bafbe88dc03ec5b17afd0ae3279726b38b73", "submitter": { "id": 177, "url": "https://patchwork.libcamera.org/api/people/177/?format=api", "name": "Milan Zamazal", "email": "mzamazal@redhat.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/20547/mbox/", "series": [ { "id": 4440, "url": "https://patchwork.libcamera.org/api/series/4440/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4440", "date": "2024-07-03T17:51:00", "name": "Software ISP refactoring", "version": 2, "mbox": "https://patchwork.libcamera.org/series/4440/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/20547/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/20547/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 609B1C3240\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 3 Jul 2024 17:51:54 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5E25463361;\n\tWed, 3 Jul 2024 19:51:53 +0200 (CEST)", "from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4FD8062E22\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 3 Jul 2024 19:51:42 +0200 (CEST)", "from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com\n\t(ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63])\n\tby relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n\tcipher=TLS_AES_256_GCM_SHA384) id us-mta-446-div3Gz8uNyagqLnHs4zE0Q-1;\n\tWed, 03 Jul 2024 13:51:39 -0400", "from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com\n\t(mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com\n\t[10.30.177.12])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (2048 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS id D182119560AE; Wed, 3 Jul 2024 17:51:38 +0000 (UTC)", "from nuthatch.redhat.com (unknown [10.45.224.13])\n\tby mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id 4FA971954B0D; Wed, 3 Jul 2024 17:51:37 +0000 (UTC)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"W+CzzgkF\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1720029101;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=T3xgEn9AJJROtO74ZJAWDhFBjvjV/zHnxs+zv+Cm6t8=;\n\tb=W+CzzgkF1an3p/KWP5uEqHJGyTLBUy/pnD5xOmpOYVt3HKuhEZUJqBG4zP61ayZwrgLvZt\n\tvkQYgM+1o7ssF66rVdOh+jsQe3qqB3NKrCK5QoXA0qOo8Rckipsaq/wCrg9BqXsBzfdG6l\n\tUCQnB53JWXBWWagcCkUi2gtPek0qO9w=", "X-MC-Unique": "div3Gz8uNyagqLnHs4zE0Q-1", "From": "Milan Zamazal <mzamazal@redhat.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Milan Zamazal <mzamazal@redhat.com>,\n\tUmang Jain <umang.jain@ideasonboard.com>", "Subject": "[PATCH v2 06/19] libcamera: software_isp: Make stats frame and\n\tbuffer aware", "Date": "Wed, 3 Jul 2024 19:51:06 +0200", "Message-ID": "<20240703175119.1872585-7-mzamazal@redhat.com>", "In-Reply-To": "<20240703175119.1872585-1-mzamazal@redhat.com>", "References": "<20240703175119.1872585-1-mzamazal@redhat.com>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 3.0 on 10.30.177.12", "X-Mimecast-Spam-Score": "0", "X-Mimecast-Originator": "redhat.com", "Content-Transfer-Encoding": "8bit", "Content-Type": "text/plain; charset=\"US-ASCII\"; x-default=true", "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>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "This patch adds frame and bufferId arguments to stats related calls.\nAlthough the parameters are currently unused, because frame ids are not\ntracked and used and the stats buffer is passed around directly rather\nthan being referred by its id, they bring the internal APIs closer to\ntheir counterparts in hardware pipelines.\n\nIt serves as a preparation for followup patches that will introduce:\n\n- Frame number tracking in order to switch to DelayedControls\n (software ISP TODO #11 + #12).\n- A ring buffer for stats in order to improve passing the stats\n (software ISP TODO #2).\n\nFrame and buffer ids are unrelated for the given purposes but since they\nare passed together at the same places, the change is implemented as a\nsingle patch rather than two, basically the same, patches.\n\nSigned-off-by: Milan Zamazal <mzamazal@redhat.com>\n---\n .../libcamera/internal/software_isp/software_isp.h | 8 +++++---\n include/libcamera/ipa/soft.mojom | 2 +-\n src/ipa/simple/soft_simple.cpp | 8 ++++++--\n src/libcamera/pipeline/simple/simple.cpp | 11 +++++++----\n src/libcamera/software_isp/debayer_cpu.cpp | 8 +++++++-\n src/libcamera/software_isp/software_isp.cpp | 11 +++++++----\n src/libcamera/software_isp/swstats_cpu.cpp | 4 ++--\n src/libcamera/software_isp/swstats_cpu.h | 4 ++--\n 8 files changed, 37 insertions(+), 19 deletions(-)", "diff": "diff --git a/include/libcamera/internal/software_isp/software_isp.h b/include/libcamera/internal/software_isp/software_isp.h\nindex c5338c05..6a03b17f 100644\n--- a/include/libcamera/internal/software_isp/software_isp.h\n+++ b/include/libcamera/internal/software_isp/software_isp.h\n@@ -11,6 +11,7 @@\n #include <initializer_list>\n #include <map>\n #include <memory>\n+#include <stdint.h>\n #include <string>\n #include <tuple>\n #include <vector>\n@@ -65,7 +66,8 @@ public:\n \tint exportBuffers(unsigned int output, unsigned int count,\n \t\t\t std::vector<std::unique_ptr<FrameBuffer>> *buffers);\n \n-\tvoid processStats(const ControlList &sensorControls);\n+\tvoid processStats(const uint32_t frame, const uint32_t bufferId,\n+\t\t\t const ControlList &sensorControls);\n \n \tint start();\n \tvoid stop();\n@@ -77,13 +79,13 @@ public:\n \n \tSignal<FrameBuffer *> inputBufferReady;\n \tSignal<FrameBuffer *> outputBufferReady;\n-\tSignal<> ispStatsReady;\n+\tSignal<uint32_t, uint32_t> ispStatsReady;\n \tSignal<const ControlList &> setSensorControls;\n \n private:\n \tvoid saveIspParams();\n \tvoid setSensorCtrls(const ControlList &sensorControls);\n-\tvoid statsReady();\n+\tvoid statsReady(uint32_t frame, uint32_t bufferId);\n \tvoid inputReady(FrameBuffer *input);\n \tvoid outputReady(FrameBuffer *output);\n \ndiff --git a/include/libcamera/ipa/soft.mojom b/include/libcamera/ipa/soft.mojom\nindex 3aa2066e..bd48ece9 100644\n--- a/include/libcamera/ipa/soft.mojom\n+++ b/include/libcamera/ipa/soft.mojom\n@@ -19,7 +19,7 @@ interface IPASoftInterface {\n \tconfigure(libcamera.ControlInfoMap sensorCtrlInfoMap)\n \t\t=> (int32 ret);\n \n-\t[async] processStats(libcamera.ControlList sensorControls);\n+\t[async] processStats(uint32 frame, uint32 bufferId, libcamera.ControlList sensorControls);\n };\n \n interface IPASoftEventInterface {\ndiff --git a/src/ipa/simple/soft_simple.cpp b/src/ipa/simple/soft_simple.cpp\nindex b41b24c6..09e3c8f6 100644\n--- a/src/ipa/simple/soft_simple.cpp\n+++ b/src/ipa/simple/soft_simple.cpp\n@@ -74,7 +74,8 @@ public:\n \tint start() override;\n \tvoid stop() override;\n \n-\tvoid processStats(const ControlList &sensorControls) override;\n+\tvoid processStats(const uint32_t frame, const uint32_t bufferId,\n+\t\t\t const ControlList &sensorControls) override;\n \n protected:\n \tstd::string logPrefix() const override;\n@@ -248,7 +249,10 @@ void IPASoftSimple::stop()\n {\n }\n \n-void IPASoftSimple::processStats(const ControlList &sensorControls)\n+void IPASoftSimple::processStats(\n+\t[[maybe_unused]] const uint32_t frame,\n+\t[[maybe_unused]] const uint32_t bufferId,\n+\tconst ControlList &sensorControls)\n {\n \tSwIspStats::Histogram histogram = stats_->yHistogram;\n \tif (ignoreUpdates_ > 0)\ndiff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\nindex 7abe1d1d..b1bf0d16 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -13,6 +13,7 @@\n #include <memory>\n #include <queue>\n #include <set>\n+#include <stdint.h>\n #include <string.h>\n #include <string>\n #include <unordered_map>\n@@ -290,7 +291,7 @@ private:\n \tvoid conversionInputDone(FrameBuffer *buffer);\n \tvoid conversionOutputDone(FrameBuffer *buffer);\n \n-\tvoid ispStatsReady();\n+\tvoid ispStatsReady(uint32_t frame, uint32_t bufferId);\n \tvoid setSensorControls(const ControlList &sensorControls);\n };\n \n@@ -890,11 +891,13 @@ void SimpleCameraData::conversionOutputDone(FrameBuffer *buffer)\n \t\tpipe->completeRequest(request);\n }\n \n-void SimpleCameraData::ispStatsReady()\n+void SimpleCameraData::ispStatsReady(uint32_t frame, uint32_t bufferId)\n {\n \t/* \\todo Use the DelayedControls class */\n-\tswIsp_->processStats(sensor_->getControls({ V4L2_CID_ANALOGUE_GAIN,\n-\t\t\t\t\t\t V4L2_CID_EXPOSURE }));\n+\tswIsp_->processStats(\n+\t\tframe, bufferId,\n+\t\tsensor_->getControls({ V4L2_CID_ANALOGUE_GAIN,\n+\t\t\t\t V4L2_CID_EXPOSURE }));\n }\n \n void SimpleCameraData::setSensorControls(const ControlList &sensorControls)\ndiff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp\nindex f8d2677d..1575cedb 100644\n--- a/src/libcamera/software_isp/debayer_cpu.cpp\n+++ b/src/libcamera/software_isp/debayer_cpu.cpp\n@@ -784,7 +784,13 @@ void DebayerCpu::process(FrameBuffer *input, FrameBuffer *output, DebayerParams\n \t\t}\n \t}\n \n-\tstats_->finishFrame();\n+\t/*\n+\t * Frame and buffer ids are currently not used, so pass zeros as parameters.\n+\t *\n+\t * \\todo Pass real values once frame is passed here and stats buffer passing\n+\t * is changed.\n+\t */\n+\tstats_->finishFrame(0, 0);\n \toutputBufferReady.emit(output);\n \tinputBufferReady.emit(input);\n }\ndiff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp\nindex 08a1afcc..3fc4a64b 100644\n--- a/src/libcamera/software_isp/software_isp.cpp\n+++ b/src/libcamera/software_isp/software_isp.cpp\n@@ -156,15 +156,18 @@ SoftwareIsp::~SoftwareIsp()\n \n /**\n * \\brief Process the statistics gathered\n+ * \\param[in] frame The frame number\n+ * \\param[in] bufferId ID of the statistics buffer\n * \\param[in] sensorControls The sensor controls\n *\n * Requests the IPA to calculate new parameters for ISP and new control\n * values for the sensor.\n */\n-void SoftwareIsp::processStats(const ControlList &sensorControls)\n+void SoftwareIsp::processStats(const uint32_t frame, const uint32_t bufferId,\n+\t\t\t const ControlList &sensorControls)\n {\n \tASSERT(ipa_);\n-\tipa_->processStats(sensorControls);\n+\tipa_->processStats(frame, bufferId, sensorControls);\n }\n \n /**\n@@ -356,9 +359,9 @@ void SoftwareIsp::setSensorCtrls(const ControlList &sensorControls)\n \tsetSensorControls.emit(sensorControls);\n }\n \n-void SoftwareIsp::statsReady()\n+void SoftwareIsp::statsReady(uint32_t frame, uint32_t bufferId)\n {\n-\tispStatsReady.emit();\n+\tispStatsReady.emit(frame, bufferId);\n }\n \n void SoftwareIsp::inputReady(FrameBuffer *input)\ndiff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp\nindex 815c4d4f..a9b1f35a 100644\n--- a/src/libcamera/software_isp/swstats_cpu.cpp\n+++ b/src/libcamera/software_isp/swstats_cpu.cpp\n@@ -314,10 +314,10 @@ void SwStatsCpu::startFrame(void)\n *\n * This may only be called after a successful setWindow() call.\n */\n-void SwStatsCpu::finishFrame(void)\n+void SwStatsCpu::finishFrame(uint32_t frame, uint32_t bufferId)\n {\n \t*sharedStats_ = stats_;\n-\tstatsReady.emit();\n+\tstatsReady.emit(frame, bufferId);\n }\n \n /**\ndiff --git a/src/libcamera/software_isp/swstats_cpu.h b/src/libcamera/software_isp/swstats_cpu.h\nindex 363e326f..26a2f462 100644\n--- a/src/libcamera/software_isp/swstats_cpu.h\n+++ b/src/libcamera/software_isp/swstats_cpu.h\n@@ -41,7 +41,7 @@ public:\n \tint configure(const StreamConfiguration &inputCfg);\n \tvoid setWindow(const Rectangle &window);\n \tvoid startFrame();\n-\tvoid finishFrame();\n+\tvoid finishFrame(uint32_t frame, uint32_t bufferId);\n \n \tvoid processLine0(unsigned int y, const uint8_t *src[])\n \t{\n@@ -61,7 +61,7 @@ public:\n \t\t(this->*stats2_)(src);\n \t}\n \n-\tSignal<> statsReady;\n+\tSignal<uint32_t, uint32_t> statsReady;\n \n private:\n \tusing statsProcessFn = void (SwStatsCpu::*)(const uint8_t *src[]);\n", "prefixes": [ "v2", "06/19" ] }