Patch Detail
Show a patch.
GET /api/1.1/patches/20880/?format=api
{ "id": 20880, "url": "https://patchwork.libcamera.org/api/1.1/patches/20880/?format=api", "web_url": "https://patchwork.libcamera.org/patch/20880/", "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-7-mzamazal@redhat.com>", "date": "2024-08-12T11:49:55", "name": "[06/16] libcamera: software_isp: Allocate multiple parameters buffers", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "2e028687f558fffc6a5a137c7f698ce652a4189e", "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/20880/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/20880/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/20880/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 82AC7C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 12 Aug 2024 11:50:37 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D44D7633CB;\n\tMon, 12 Aug 2024 13:50:36 +0200 (CEST)", "from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4AD33633BF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 Aug 2024 13:50:32 +0200 (CEST)", "from mx-prod-mc-01.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-449-gpeJGR9kOxG7vOOvz4-bKg-1;\n\tMon, 12 Aug 2024 07:50:29 -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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS\n\tid CCAC61953942 for <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 Aug 2024 11:50:28 +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 CBD9519772C4; Mon, 12 Aug 2024 11:50:27 +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=\"KlyqG98r\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1723463431;\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=OF9/rB2Yo1/21SBoGbiRvv4x8gx7d18lkjE7VG1i1OQ=;\n\tb=KlyqG98rbvVUF34lfzihapCvYiBVGWzV7eVNFsVEpPWzoGn8lzAuzMtt/hCw3xSZeRQ25/\n\tQ8TCScAVu9Rbz+54L83VjVEjOtDQTUJuofvqBI//vByamnLa5TVeGZvP34oyHGUN+XFzZB\n\tgkwkKkLwcRjDnfU4Z7d/8aHziyfapq0=", "X-MC-Unique": "gpeJGR9kOxG7vOOvz4-bKg-1", "From": "Milan Zamazal <mzamazal@redhat.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Milan Zamazal <mzamazal@redhat.com>", "Subject": "[PATCH 06/16] libcamera: software_isp: Allocate multiple parameters\n\tbuffers", "Date": "Mon, 12 Aug 2024 13:49:55 +0200", "Message-ID": "<20240812115009.946036-7-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": "We want to use more than one parameters buffer. Processing statistics\n(and setting the corresponding parameters) is asynchronous and may work\nwith a parameters buffer while the last parameters buffer may be in or\nwait for use in debayering.\n\nThe question is how many buffer we need. A starting idea might be to\nuse the same number as for input and output buffers. This may not be\nnecessarily the best or even correct idea, but if the number of those\nbuffers is sufficient now then perhaps the same number of the parameters\nbuffers (and later statistics buffers) would work. Unless multiple\nstreams are used...\n\nNevertheless, the number of the input and output buffers is currently\nfixed, which makes it possible to use in init, before configure, where\nthe current single buffer is allocated. It just requires to make the\ngiven constant public in SimplePipelineHandler so that it can be passed\nto the SoftwareIsp constructor.\n\nAnother alternative would be to determine the right number of buffers in\nSoftwareIsp::configure. This would be more complicated as it would\nrequire some more refactoring, allocating the buffers in configure and\npassing their file descriptors to the IPA and debayering on demand.\n\nOnly the first allocated buffer is actually used at the moment. This\nwill be changed in the followup patches once support for multiple\nbuffers is added to the IPA and debayering.\n\nSigned-off-by: Milan Zamazal <mzamazal@redhat.com>\n---\n .../internal/software_isp/software_isp.h | 6 +++---\n src/libcamera/pipeline/simple/simple.cpp | 6 +++---\n src/libcamera/software_isp/software_isp.cpp | 15 ++++++---------\n 3 files changed, 12 insertions(+), 15 deletions(-)", "diff": "diff --git a/include/libcamera/internal/software_isp/software_isp.h b/include/libcamera/internal/software_isp/software_isp.h\nindex c2fcc307..8956978c 100644\n--- a/include/libcamera/internal/software_isp/software_isp.h\n+++ b/include/libcamera/internal/software_isp/software_isp.h\n@@ -46,7 +46,8 @@ LOG_DECLARE_CATEGORY(SoftwareIsp)\n class SoftwareIsp\n {\n public:\n-\tSoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor);\n+\tSoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor,\n+\t\t const unsigned int bufferCount);\n \t~SoftwareIsp();\n \n \tint loadConfiguration([[maybe_unused]] const std::string &filename) { return 0; }\n@@ -94,11 +95,10 @@ private:\n \n \tstd::unique_ptr<DebayerCpu> debayer_;\n \tThread ispWorkerThread_;\n-\tstatic constexpr unsigned int kParamStatBufferCount = 1;\n \tstd::map<uint32_t, SharedMemObject<DebayerParams>> sharedParams_;\n \tDebayerParams debayerParams_;\n \tstd::queue<uint32_t> availableParams_;\n-\tbool allocateParamsBuffers();\n+\tbool allocateParamsBuffers(const unsigned int bufferCount);\n \tDmaBufAllocator dmaHeap_;\n \n \tstd::unique_ptr<ipa::soft::IPAProxySoft> ipa_;\ndiff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\nindex f0bcafba..459f617b 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -349,13 +349,12 @@ public:\n \tV4L2Subdevice *subdev(const MediaEntity *entity);\n \tMediaDevice *converter() { return converter_; }\n \tbool swIspEnabled() const { return swIspEnabled_; }\n+\tstatic constexpr unsigned int kNumInternalBuffers = 3;\n \n protected:\n \tint queueRequestDevice(Camera *camera, Request *request) override;\n \n private:\n-\tstatic constexpr unsigned int kNumInternalBuffers = 3;\n-\n \tstruct EntityData {\n \t\tstd::unique_ptr<V4L2VideoDevice> video;\n \t\tstd::unique_ptr<V4L2Subdevice> subdev;\n@@ -531,7 +530,8 @@ int SimpleCameraData::init()\n \t * Instantiate Soft ISP if this is enabled for the given driver and no converter is used.\n \t */\n \tif (!converter_ && pipe->swIspEnabled()) {\n-\t\tswIsp_ = std::make_unique<SoftwareIsp>(pipe, sensor_.get());\n+\t\tswIsp_ = std::make_unique<SoftwareIsp>(pipe, sensor_.get(),\n+\t\t\t\t\t\t pipe->kNumInternalBuffers);\n \t\tif (!swIsp_->isValid()) {\n \t\t\tLOG(SimplePipeline, Warning)\n \t\t\t\t<< \"Failed to create software ISP, disabling software debayering\";\ndiff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp\nindex d78537fc..d48be2d2 100644\n--- a/src/libcamera/software_isp/software_isp.cpp\n+++ b/src/libcamera/software_isp/software_isp.cpp\n@@ -57,18 +57,15 @@ LOG_DEFINE_CATEGORY(SoftwareIsp)\n * ready\n */\n \n-/**\n- * \\var SoftwareIsp::kParamStatBufferCount\n- * \\brief The number of stats and params buffers (each of them)\n- */\n-\n /**\n * \\brief Constructs SoftwareIsp object\n * \\param[in] pipe The pipeline handler in use\n * \\param[in] sensor Pointer to the CameraSensor instance owned by the pipeline\n+ * \\param[in] bufferCount Number of parameters buffers and stats buffers to allocate\n * handler\n */\n-SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor)\n+SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor,\n+\t\t\t const unsigned bufferCount)\n \t: dmaHeap_(DmaBufAllocator::DmaBufAllocatorFlag::CmaHeap |\n \t\t DmaBufAllocator::DmaBufAllocatorFlag::SystemHeap |\n \t\t DmaBufAllocator::DmaBufAllocatorFlag::UDmaBuf)\n@@ -77,7 +74,7 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor)\n \t\tLOG(SoftwareIsp, Error) << \"Failed to create DmaBufAllocator object\";\n \t\treturn;\n \t}\n-\tif (!allocateParamsBuffers())\n+\tif (!allocateParamsBuffers(bufferCount))\n \t\treturn;\n \n \tauto stats = std::make_unique<SwStatsCpu>();\n@@ -129,13 +126,13 @@ SoftwareIsp::~SoftwareIsp()\n \tdebayer_.reset();\n }\n \n-bool SoftwareIsp::allocateParamsBuffers()\n+bool SoftwareIsp::allocateParamsBuffers(const unsigned int bufferCount)\n {\n \tstd::array<uint8_t, 256> gammaTable;\n \tfor (unsigned int i = 0; i < 256; i++)\n \t\tgammaTable[i] = UINT8_MAX * std::pow(i / 256.0, 0.5);\n \n-\tfor (unsigned int i = 0; i < kParamStatBufferCount; i++) {\n+\tfor (unsigned int i = 0; i < bufferCount; i++) {\n \t\tauto params = SharedMemObject<DebayerParams>(\"softIsp_params\");\n \t\tif (!params) {\n \t\t\tLOG(SoftwareIsp, Error) << \"Failed to create shared memory for parameters\";\n", "prefixes": [ "06/16" ] }