{"id":20877,"url":"https://patchwork.libcamera.org/api/patches/20877/?format=json","web_url":"https://patchwork.libcamera.org/patch/20877/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","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-4-mzamazal@redhat.com>","date":"2024-08-12T11:49:52","name":"[03/16] libcamera: software_isp: Separate allocation of the parameters buffer","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"d1a09b00ba77dc5cf5d4df38d274d7ee8628478f","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/?format=json","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/20877/mbox/","series":[{"id":4511,"url":"https://patchwork.libcamera.org/api/series/4511/?format=json","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/20877/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/20877/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 45233C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 12 Aug 2024 11:50:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D4462633B5;\n\tMon, 12 Aug 2024 13:50:30 +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 96BF763398\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 Aug 2024 13:50:27 +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-486-AKJ3hmxbOse8QyuKb_ExaQ-1;\n\tMon, 12 Aug 2024 07:50:25 -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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS\n\tid 985FE1918166 for <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 Aug 2024 11:50:24 +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 4CB7E19772C4; Mon, 12 Aug 2024 11:50:22 +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=\"F3wdGEDp\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1723463426;\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=JOfNXZhsJOwjlwrExudQJC5YRNJ5y6fUPZY+0WyjHOM=;\n\tb=F3wdGEDpMhHAj/Kzm9aCli3zklt5YloxhRDyIfPIItLwNjjpeIxQX/ix9OAJ5lm/GnR/tJ\n\tl0h0o61n54jqOZ6eCR6moEYezzyCuo2n3TpfnNgzPtpOPwlcAw0P5vAfIDno9OoloOaM2z\n\tnRq0xPhSVG2pD+2Zhmd8o3oLkJr/sDE=","X-MC-Unique":"AKJ3hmxbOse8QyuKb_ExaQ-1","From":"Milan Zamazal <mzamazal@redhat.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Milan Zamazal <mzamazal@redhat.com>","Subject":"[PATCH 03/16] libcamera: software_isp: Separate allocation of the\n\tparameters buffer","Date":"Mon, 12 Aug 2024 13:49:52 +0200","Message-ID":"<20240812115009.946036-4-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":"There will be some additions to that code in followup patches and let's\nnot blow the code in SoftwareIsp constructor even more.\n\nSigned-off-by: Milan Zamazal <mzamazal@redhat.com>\n---\n .../internal/software_isp/software_isp.h      |  1 +\n src/libcamera/software_isp/software_isp.cpp   | 51 +++++++++++--------\n 2 files changed, 30 insertions(+), 22 deletions(-)","diff":"diff --git a/include/libcamera/internal/software_isp/software_isp.h b/include/libcamera/internal/software_isp/software_isp.h\nindex d2b47ecc..fc9200dd 100644\n--- a/include/libcamera/internal/software_isp/software_isp.h\n+++ b/include/libcamera/internal/software_isp/software_isp.h\n@@ -95,6 +95,7 @@ private:\n \tThread ispWorkerThread_;\n \tSharedMemObject<DebayerParams> sharedParams_;\n \tDebayerParams debayerParams_;\n+\tbool allocateParamsBuffers();\n \tDmaBufAllocator dmaHeap_;\n \n \tstd::unique_ptr<ipa::soft::IPAProxySoft> ipa_;\ndiff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp\nindex 0412b401..3f41b71d 100644\n--- a/src/libcamera/software_isp/software_isp.cpp\n+++ b/src/libcamera/software_isp/software_isp.cpp\n@@ -68,33 +68,12 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor)\n \t\t   DmaBufAllocator::DmaBufAllocatorFlag::SystemHeap |\n \t\t   DmaBufAllocator::DmaBufAllocatorFlag::UDmaBuf)\n {\n-\t/*\n-\t * debayerParams_ must be initialized because the initial value is used for\n-\t * the first two frames, i.e. until stats processing starts providing its\n-\t * own parameters.\n-\t *\n-\t * \\todo This should be handled in the same place as the related\n-\t * operations, in the IPA module.\n-\t */\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-\tfor (unsigned int i = 0; i < DebayerParams::kRGBLookupSize; i++) {\n-\t\tdebayerParams_.red[i] = gammaTable[i];\n-\t\tdebayerParams_.green[i] = gammaTable[i];\n-\t\tdebayerParams_.blue[i] = gammaTable[i];\n-\t}\n-\n \tif (!dmaHeap_.isValid()) {\n \t\tLOG(SoftwareIsp, Error) << \"Failed to create DmaBufAllocator object\";\n \t\treturn;\n \t}\n-\n-\tsharedParams_ = SharedMemObject<DebayerParams>(\"softIsp_params\");\n-\tif (!sharedParams_) {\n-\t\tLOG(SoftwareIsp, Error) << \"Failed to create shared memory for parameters\";\n+\tif (!allocateParamsBuffers())\n \t\treturn;\n-\t}\n \n \tauto stats = std::make_unique<SwStatsCpu>();\n \tif (!stats->isValid()) {\n@@ -145,6 +124,34 @@ SoftwareIsp::~SoftwareIsp()\n \tdebayer_.reset();\n }\n \n+bool SoftwareIsp::allocateParamsBuffers()\n+{\n+\t/*\n+\t * DebayerParams must be initialized because the initial value is used for\n+\t * the first two frames, i.e. until stats processing starts providing its\n+\t * own parameters.\n+\t *\n+\t * \\todo This should be handled in the same place as the related\n+\t * operations, in the IPA module.\n+\t */\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+\tfor (unsigned int j = 0; j < DebayerParams::kRGBLookupSize; j++) {\n+\t\tdebayerParams_.red[j] = gammaTable[j];\n+\t\tdebayerParams_.green[j] = gammaTable[j];\n+\t\tdebayerParams_.blue[j] = gammaTable[j];\n+\t}\n+\n+\tsharedParams_ = SharedMemObject<DebayerParams>(\"softIsp_params\");\n+\tif (!sharedParams_) {\n+\t\tLOG(SoftwareIsp, Error) << \"Failed to create shared memory for parameters\";\n+\t\treturn false;\n+\t}\n+\n+\treturn true;\n+}\n+\n /**\n  * \\fn int SoftwareIsp::loadConfiguration([[maybe_unused]] const std::string &filename)\n  * \\brief Load a configuration from a file\n","prefixes":["03/16"]}