Patch Detail
Show a patch.
GET /api/1.1/patches/20881/?format=api
{ "id": 20881, "url": "https://patchwork.libcamera.org/api/1.1/patches/20881/?format=api", "web_url": "https://patchwork.libcamera.org/patch/20881/", "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": "<20240812115009.946036-8-mzamazal@redhat.com>", "date": "2024-08-12T11:49:56", "name": "[07/16] libcamera: software_isp: Use multiple parameters buffers in IPA", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "ee432376f214a2844cb6a4a2941bf928d013a486", "submitter": { "id": 177, "url": "https://patchwork.libcamera.org/api/1.1/people/177/?format=api", "name": "Milan Zamazal", "email": "mzamazal@redhat.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/20881/mbox/", "series": [ { "id": 4511, "url": "https://patchwork.libcamera.org/api/1.1/series/4511/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4511", "date": "2024-08-12T11:49:49", "name": "Software ISP: Share params and stats buffers", "version": 1, "mbox": "https://patchwork.libcamera.org/series/4511/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/20881/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/20881/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 84722C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 12 Aug 2024 11:50:39 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 34E2F633D0;\n\tMon, 12 Aug 2024 13:50:39 +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 76387633C9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 Aug 2024 13:50:33 +0200 (CEST)", "from mx-prod-mc-02.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-66-Pr4eGMrwNKWFgBcavFyrcw-1;\n\tMon, 12 Aug 2024 07:50:31 -0400", "from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com\n\t(mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com\n\t[10.30.177.15])\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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS\n\tid 6881F18EB226 for <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 Aug 2024 11:50:30 +0000 (UTC)", "from nuthatch.redhat.com (unknown [10.45.225.57])\n\tby mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id 4CE0819772C7; Mon, 12 Aug 2024 11:50:29 +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=\"aWl/8jIm\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1723463432;\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=0VH6w5H5H/h2H5c+QEbIYYLm9AFq2VBsC+KuYmpCxZ0=;\n\tb=aWl/8jImTNFAHNwnSr2paIAr420P5mLl/xFuOa7Sw9ADOL6r9Zb7ZyGP/S55Wd3e8yAdce\n\tlzLiToDIn3qMgP+BV+k6SS/vV1Zoe4tKyjR3g0DACfuzUKoqR7O++iTo9ulE+yaQbOyDKW\n\txppflaLtDN45ghFpn0AZd+f+S0puBtg=", "X-MC-Unique": "Pr4eGMrwNKWFgBcavFyrcw-1", "From": "Milan Zamazal <mzamazal@redhat.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Milan Zamazal <mzamazal@redhat.com>", "Subject": "[PATCH 07/16] libcamera: software_isp: Use multiple parameters\n\tbuffers in IPA", "Date": "Mon, 12 Aug 2024 13:49:56 +0200", "Message-ID": "<20240812115009.946036-8-mzamazal@redhat.com>", "In-Reply-To": "<20240812115009.946036-1-mzamazal@redhat.com>", "References": "<20240812115009.946036-1-mzamazal@redhat.com>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 3.0 on 10.30.177.15", "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": "Instead of the single parameters buffer file descriptor, pass the file\ndescriptors of all the parameters buffers to the IPA and let it use them\naccording to the passed buffer id.\n\nThis means:\n\n- The file descriptors of all the buffers must be passed to the IPA.\n\n- The IPA must store mappings of the buffer ids to the corresponding\n buffers.\n\n- The current buffer id is passed to/from the IPA.\n\nThe parameters buffers are still copied for debayering, this will be\naddressed in the next patch.\n\nSigned-off-by: Milan Zamazal <mzamazal@redhat.com>\n---\n include/libcamera/ipa/soft.mojom | 2 +-\n src/ipa/simple/soft_simple.cpp | 29 +++++++++++----------\n src/libcamera/software_isp/software_isp.cpp | 12 ++++++---\n 3 files changed, 25 insertions(+), 18 deletions(-)", "diff": "diff --git a/include/libcamera/ipa/soft.mojom b/include/libcamera/ipa/soft.mojom\nindex 1498aedf..86dd988f 100644\n--- a/include/libcamera/ipa/soft.mojom\n+++ b/include/libcamera/ipa/soft.mojom\n@@ -15,7 +15,7 @@ struct IPAConfigInfo {\n interface IPASoftInterface {\n \tinit(libcamera.IPASettings settings,\n \t libcamera.SharedFD fdStats,\n-\t libcamera.SharedFD fdParams,\n+\t array<libcamera.SharedFD> fdParams,\n \t libcamera.ControlInfoMap sensorCtrlInfoMap)\n \t\t=> (int32 ret);\n \tstart() => (int32 ret);\ndiff --git a/src/ipa/simple/soft_simple.cpp b/src/ipa/simple/soft_simple.cpp\nindex 9d5fe923..50f8f194 100644\n--- a/src/ipa/simple/soft_simple.cpp\n+++ b/src/ipa/simple/soft_simple.cpp\n@@ -48,7 +48,7 @@ public:\n \n \tint init(const IPASettings &settings,\n \t\t const SharedFD &fdStats,\n-\t\t const SharedFD &fdParams,\n+\t\t const std::vector<SharedFD> &fdParams,\n \t\t const ControlInfoMap &sensorInfoMap) override;\n \tint configure(const IPAConfigInfo &configInfo) override;\n \n@@ -66,7 +66,7 @@ protected:\n private:\n \tvoid updateExposure(double exposureMSV);\n \n-\tDebayerParams *params_;\n+\tstd::map<unsigned int, DebayerParams *> paramsBuffers_;\n \tSwIspStats *stats_;\n \tstd::unique_ptr<CameraSensorHelper> camHelper_;\n \tControlInfoMap sensorInfoMap_;\n@@ -79,13 +79,13 @@ IPASoftSimple::~IPASoftSimple()\n {\n \tif (stats_)\n \t\tmunmap(stats_, sizeof(SwIspStats));\n-\tif (params_)\n-\t\tmunmap(params_, sizeof(DebayerParams));\n+\tfor (auto &item : paramsBuffers_)\n+\t\tmunmap(item.second, sizeof(DebayerParams));\n }\n \n int IPASoftSimple::init(const IPASettings &settings,\n \t\t\tconst SharedFD &fdStats,\n-\t\t\tconst SharedFD &fdParams,\n+\t\t\tconst std::vector<SharedFD> &fdParams,\n \t\t\tconst ControlInfoMap &sensorInfoMap)\n {\n \tcamHelper_ = CameraSensorHelperFactoryBase::create(settings.sensorModel);\n@@ -122,7 +122,6 @@ int IPASoftSimple::init(const IPASettings &settings,\n \tif (ret)\n \t\treturn ret;\n \n-\tparams_ = nullptr;\n \tstats_ = nullptr;\n \n \tif (!fdStats.isValid()) {\n@@ -130,20 +129,21 @@ int IPASoftSimple::init(const IPASettings &settings,\n \t\treturn -ENODEV;\n \t}\n \n-\tif (!fdParams.isValid()) {\n-\t\tLOG(IPASoft, Error) << \"Invalid Parameters handle\";\n-\t\treturn -ENODEV;\n-\t}\n+\tfor (auto &sharedFd : fdParams) {\n+\t\tif (!sharedFd.isValid()) {\n+\t\t\tLOG(IPASoft, Error) << \"Invalid Parameters handle\";\n+\t\t\treturn -ENODEV;\n+\t\t}\n \n-\t{\n \t\tvoid *mem = mmap(nullptr, sizeof(DebayerParams), PROT_WRITE,\n-\t\t\t\t MAP_SHARED, fdParams.get(), 0);\n+\t\t\t\t MAP_SHARED, sharedFd.get(), 0);\n \t\tif (mem == MAP_FAILED) {\n \t\t\tLOG(IPASoft, Error) << \"Unable to map Parameters\";\n \t\t\treturn -errno;\n \t\t}\n \n-\t\tparams_ = static_cast<DebayerParams *>(mem);\n+\t\tASSERT(sharedFd.get() >= 0);\n+\t\tparamsBuffers_[sharedFd.get()] = static_cast<DebayerParams *>(mem);\n \t}\n \n \t{\n@@ -258,8 +258,9 @@ void IPASoftSimple::prepare(const uint32_t frame,\n \t\t\t const uint32_t paramsBufferId)\n {\n \tIPAFrameContext &frameContext = context_.frameContexts.get(frame);\n+\tDebayerParams *params = paramsBuffers_.at(paramsBufferId);\n \tfor (auto const &algo : algorithms())\n-\t\talgo->prepare(context_, frame, frameContext, params_);\n+\t\talgo->prepare(context_, frame, frameContext, params);\n \tsetIspParams.emit(paramsBufferId);\n }\n \ndiff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp\nindex d48be2d2..480ecf6e 100644\n--- a/src/libcamera/software_isp/software_isp.cpp\n+++ b/src/libcamera/software_isp/software_isp.cpp\n@@ -13,6 +13,8 @@\n #include <sys/types.h>\n #include <unistd.h>\n \n+#include <libcamera/base/shared_fd.h>\n+\n #include <libcamera/formats.h>\n #include <libcamera/request.h>\n #include <libcamera/stream.h>\n@@ -85,6 +87,9 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor,\n \tstats->statsReady.connect(this, &SoftwareIsp::statsReady);\n \n \tdebayer_ = std::make_unique<DebayerCpu>(std::move(stats));\n+\tstd::vector<SharedFD> fdParams;\n+\tfor (auto &item : sharedParams_)\n+\t\tfdParams.emplace_back(item.second.fd());\n \tdebayer_->inputBufferReady.connect(this, &SoftwareIsp::inputReady);\n \tdebayer_->outputBufferReady.connect(this, &SoftwareIsp::outputReady);\n \tdebayer_->releaseIspParams.connect(this, &SoftwareIsp::releaseIspParams);\n@@ -106,7 +111,7 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor,\n \n \tint ret = ipa_->init(IPASettings{ ipaTuningFile, sensor->model() },\n \t\t\t debayer_->getStatsFD(),\n-\t\t\t sharedParams_.begin()->second.fd(),\n+\t\t\t fdParams,\n \t\t\t sensor->controls());\n \tif (ret) {\n \t\tLOG(SoftwareIsp, Error) << \"IPA init failed\";\n@@ -380,13 +385,14 @@ void SoftwareIsp::process(uint32_t frame, FrameBuffer *input, FrameBuffer *outpu\n \tconst uint32_t paramsBufferId = availableParams_.front();\n \tavailableParams_.pop();\n \tipa_->prepare(frame, paramsBufferId);\n+\tdebayerParams_ = *sharedParams_.at(paramsBufferId);\n \tdebayer_->invokeMethod(&DebayerCpu::process,\n \t\t\t ConnectionTypeQueued, frame, paramsBufferId, input, output, debayerParams_);\n }\n \n-void SoftwareIsp::saveIspParams([[maybe_unused]] uint32_t paramsBufferId)\n+void SoftwareIsp::saveIspParams(uint32_t paramsBufferId)\n {\n-\tdebayerParams_ = *sharedParams_.begin()->second;\n+\tdebayerParams_ = *sharedParams_.at(paramsBufferId);\n }\n \n void SoftwareIsp::releaseIspParams(uint32_t paramsBufferId)\n", "prefixes": [ "07/16" ] }