From patchwork Wed Oct 15 01:22:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24654 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id DED39BF415 for ; Wed, 15 Oct 2025 01:23:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 480CB60622; Wed, 15 Oct 2025 03:23:13 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Lm7RcUaU"; dkim-atps=neutral Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4D71D60618 for ; Wed, 15 Oct 2025 03:23:04 +0200 (CEST) Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-b40f11a1027so1073899066b.2 for ; Tue, 14 Oct 2025 18:23:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491383; x=1761096183; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3ome6wJLZjqhmaYsCAuXqPUDJjo8qNs2C5lFy+zKkTE=; b=Lm7RcUaUwvpmuNB+o7/ZuQiNuiiXUzftaQ4LIDuXjdvh5z6o488Yai98btBfEDYU2L EdDEiSwitUWuVYYscBArXRAKB1Mp7jyZ7Uwl7fZDB9GwI7sNCu4LDVV6cXgHldrb1sad ih5uuzigH9ntvdrKW5PMaltZ4X7NQPU/+MXGLunibAvAmxMifRaJt64+Ah3XDJ1rgGw1 qdJdVmVVB9u4NtDaqQNktKvZ6COnM4Ys1uanRcn32dUWXhsy8/oiGHxaBvMU7bjpgJdT DPQh+1Z4aLR++r7h4Z8GpeEkGuw59GpsQQi9ykFTfsN5gV/xLe2MWZP8zFAsZwhkNBJ6 VV1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491383; x=1761096183; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3ome6wJLZjqhmaYsCAuXqPUDJjo8qNs2C5lFy+zKkTE=; b=xSuFSdSSDG4ex3I/XiXEryBD3MNMx9TapmfyNHzYv4pA1rfGvNIKMSMZEPbns59IAd rLHxiMSqS1TOXQDcazeBeqqGjaRAsvcCdwgn76Di59TMcoco2PwW2nO5bE+zBCYUcdXX 0hxerUJQi/kkv3lS4CC1rEkgtBgE9w3yQdGVDI4d9uD8gaeNlXfX1kApv2dpl1KQSRJ3 9NDBE8Ovexi7PwTWhj8QtSR2/p6zlE5nhbP/Gga2Bsd8R06sXxQf7zzixptsnfJ9fC7j u1P7qh93IZRAE3aCDmbv2uYHXmzf5VRL+tTB60qjpin5a4fyjk7nrXrv/uJFe9sjfjiq Fdpw== X-Gm-Message-State: AOJu0YytI/uZHKDzXSj/CsgC5NlmZ6HdLQgL+FsrA7r6Ds4i4SANpLN5 UP+x31iBhiPFOwmJ+TP09LG8aBVQf3Wb4FBEjiIm2wRJtIcs8tCZK7RdX1yNIEZtyqvh9kx9IMa ScuPD X-Gm-Gg: ASbGncsYYMeoGzbmtV5MGBApauDR3dtOFKXu/PmtruaTlIIlERmnn+cZTnWrUz+3zcA pt0/lg4mXxr+QMKTfT1fFfv0WvWdv5sh0zog5FzzX6YJw6wLXqIU4Qxp2dB1TFGZmrhSYILIFjX jRIdkzWrTbT6yDg/TDVCnRZYKi9NQMpy2jsIMxV2S9w+WjwvB+Fd7So3JqTd8wxkF25k3HGjVtf nzaFkkKic+Lh0Ol8YXYbrE/Vbb9/4NnVPLT21SlQgJr2AwxnYcxYWaekV4/j94Gs2zRWmCXPlNp GYxoWO8rYwJ0+h9l/srLQRIykB5rh4nt8jIiu6xDcbsLS65kAL88yeib4Bq7JsCZ6nBB5qtfyuj XXlipQXjJJ7KL8k7wK/0qEIl/NpsrM26egiN7ka59/yyWXdraD+SqZxRA/id3PhOFhg9JiFeaFq 0eGTXXsGGg3Jy2bhVJszEmD3aOR/QAfe6d80KthSlj X-Google-Smtp-Source: AGHT+IFmbV75YWgYP1Snbyr6pOFAXRm/0v9qTOz/dXXNUUtfTCfRYD9tOCS1lhudIxriMMetwv88Bw== X-Received: by 2002:a17:907:7292:b0:b50:891f:66b3 with SMTP id a640c23a62f3a-b50aca0b669mr2544259966b.64.1760491383451; Tue, 14 Oct 2025 18:23:03 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:03 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 09/39] libcamera: software_isp: Move useful items from DebayerCpu to Debayer base class Date: Wed, 15 Oct 2025 02:22:21 +0100 Message-ID: <20251015012251.17508-10-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The DebayerCpu class has a number of variables, embedded structures and methods which are useful to DebayerGpu implementation. Move relevant variables and methods to base class. Since we want to call setParams() from the GPUISP and reuse the code in the existing CPUISP as a first step, we need to move all of the dependent variables in DebayerCPU to the Debayer base class including LookupTable and redCcm_. The DebayerEGL class will ultimately be able to consume both the CCM and non-CCM data. Signed-off-by: Bryan O'Donoghue Reviewed-by: Kieran Bingham --- src/libcamera/software_isp/debayer.h | 45 +++++++++++++++++++++- src/libcamera/software_isp/debayer_cpu.cpp | 2 +- src/libcamera/software_isp/debayer_cpu.h | 35 +---------------- 3 files changed, 46 insertions(+), 36 deletions(-) diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h index ba033d44..1b195d29 100644 --- a/src/libcamera/software_isp/debayer.h +++ b/src/libcamera/software_isp/debayer.h @@ -14,11 +14,14 @@ #include #include +#include #include #include #include +#include "libcamera/internal/global_configuration.h" +#include "libcamera/internal/software_isp/benchmark.h" #include "libcamera/internal/software_isp/debayer_params.h" namespace libcamera { @@ -27,9 +30,10 @@ class FrameBuffer; LOG_DECLARE_CATEGORY(Debayer) -class Debayer +class Debayer : public Object { public: + Debayer (const GlobalConfiguration &configuration) : bench_(configuration) {}; virtual ~Debayer() = 0; virtual int configure(const StreamConfiguration &inputCfg, @@ -45,8 +49,47 @@ public: virtual SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) = 0; + virtual const SharedFD &getStatsFD() = 0; + + unsigned int frameSize() { return outputConfig_.frameSize; } + Signal inputBufferReady; Signal outputBufferReady; + + /** + * struct DebayerInputConfig + * + * Structure to describe the incoming Bayer parameters. + */ + struct DebayerInputConfig { + Size patternSize; + unsigned int bpp; /* Memory used per pixel, not precision */ + unsigned int stride; + std::vector outputFormats; + }; + + /** + * struct DebayerOutputConfig + * + * Structure to describe the output pattern requested to the Debayer logic. + */ + struct DebayerOutputConfig { + unsigned int bpp; /* Memory used per pixel, not precision */ + unsigned int stride; + unsigned int frameSize; + }; + + DebayerInputConfig inputConfig_; + DebayerOutputConfig outputConfig_; + DebayerParams::LookupTable red_; + DebayerParams::LookupTable green_; + DebayerParams::LookupTable blue_; + DebayerParams::CcmLookupTable redCcm_; + DebayerParams::CcmLookupTable greenCcm_; + DebayerParams::CcmLookupTable blueCcm_; + DebayerParams::LookupTable gammaLut_; + bool swapRedBlueGains_; + Benchmark bench_; private: virtual Size patternSize(PixelFormat inputFormat) = 0; diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp index df77deb6..612f01a6 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/debayer_cpu.cpp @@ -42,7 +42,7 @@ namespace libcamera { * \param[in] configuration The global configuration */ DebayerCpu::DebayerCpu(std::unique_ptr stats, const GlobalConfiguration &configuration) - : stats_(std::move(stats)), bench_(configuration) + : Debayer(configuration), stats_(std::move(stats)) { /* * Reading from uncached buffers may be very slow. diff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h index aff32491..ff72eaba 100644 --- a/src/libcamera/software_isp/debayer_cpu.h +++ b/src/libcamera/software_isp/debayer_cpu.h @@ -17,16 +17,14 @@ #include -#include "libcamera/internal/software_isp/benchmark.h" #include "libcamera/internal/bayer_format.h" -#include "libcamera/internal/global_configuration.h" #include "libcamera/internal/software_isp/swstats_cpu.h" #include "debayer.h" namespace libcamera { -class DebayerCpu : public Debayer, public Object +class DebayerCpu : public Debayer { public: DebayerCpu(std::unique_ptr stats, const GlobalConfiguration &configuration); @@ -49,13 +47,6 @@ public: */ const SharedFD &getStatsFD() { return stats_->getStatsFD(); } - /** - * \brief Get the output frame size - * - * \return The output frame size - */ - unsigned int frameSize() { return outputConfig_.frameSize; } - private: /** * \brief Called to debayer 1 line of Bayer input data to output format @@ -112,19 +103,6 @@ private: template void debayer10P_RGRG_BGR888(uint8_t *dst, const uint8_t *src[]); - struct DebayerInputConfig { - Size patternSize; - unsigned int bpp; /* Memory used per pixel, not precision */ - unsigned int stride; - std::vector outputFormats; - }; - - struct DebayerOutputConfig { - unsigned int bpp; /* Memory used per pixel, not precision */ - unsigned int stride; - unsigned int frameSize; - }; - int getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config); int getOutputConfig(PixelFormat outputFormat, DebayerOutputConfig &config); int setupStandardBayerOrder(BayerFormat::Order order); @@ -140,20 +118,11 @@ private: /* Max. supported Bayer pattern height is 4, debayering this requires 5 lines */ static constexpr unsigned int kMaxLineBuffers = 5; - DebayerParams::LookupTable red_; - DebayerParams::LookupTable green_; - DebayerParams::LookupTable blue_; - DebayerParams::CcmLookupTable redCcm_; - DebayerParams::CcmLookupTable greenCcm_; - DebayerParams::CcmLookupTable blueCcm_; - DebayerParams::LookupTable gammaLut_; debayerFn debayer0_; debayerFn debayer1_; debayerFn debayer2_; debayerFn debayer3_; Rectangle window_; - DebayerInputConfig inputConfig_; - DebayerOutputConfig outputConfig_; std::unique_ptr stats_; std::vector lineBuffers_[kMaxLineBuffers]; unsigned int lineBufferLength_; @@ -161,8 +130,6 @@ private: unsigned int lineBufferIndex_; unsigned int xShift_; /* Offset of 0/1 applied to window_.x */ bool enableInputMemcpy_; - bool swapRedBlueGains_; - Benchmark bench_; }; } /* namespace libcamera */