From patchwork Wed Jun 11 01:32:20 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: 23516 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 60CD1C3327 for ; Wed, 11 Jun 2025 01:33:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CED3A68DCE; Wed, 11 Jun 2025 03:33:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="v+pfrmHa"; dkim-atps=neutral Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 06FAF68DD0 for ; Wed, 11 Jun 2025 03:33:30 +0200 (CEST) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-450ccda1a6eso56809745e9.2 for ; Tue, 10 Jun 2025 18:33:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605609; x=1750210409; 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=9PVu7x00JvXUNXl45gheWNt7X7t7eecspR+1Or+mgZ8=; b=v+pfrmHa0yl8WJ0hwuUFpkHITr9LfGcDU+Ninvz90xjdbDaBAmgi3VGSzM5FJx+8iu 6SascQO0M84HEQnJOvLGBR2hYqIRbmX2VZgTwu2ZhJOef9ESFxg136Gp+Ep1CMoKU/FR tgrYUzxuk5zV+TmXpbEjnuWHllUvcIODPzumr4r0gbqv2v+RMmH8e68YdWQX7NaXkaLy sRZ93/fL63JOBV6GntEl18DNJ8Givny1e7pqCou//nQc41PFBfwfdqheVircDQ0xmHQl hTcgs31CFhMjvI2lkyAlNKpruQoccK3qLtcliIirbWkI/HJm/RcXI5xfuX7/tu2bmbYA 2KOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605609; x=1750210409; 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=9PVu7x00JvXUNXl45gheWNt7X7t7eecspR+1Or+mgZ8=; b=g9KlqQ0gkt6QPXkxXb3hTmb5SvOHY2aUV7mLTYnD/pGRZpg1vadZEvDHEYFFbhNOMi 8oV2zMKDdq7wLaM4uImEQvDep1Qo6he+JjWl+EaDoqjsg8U4UvKImFJxGX7nkM4jzu0F lBRUqA66PB/6+p6JK5q0G2Maf2VNoMQzcNOPG8BXRCW3ng4l8fww2XxBqOlz2LzkZxde z2o5pMsW0+Imyfw1Gv5UdcKuRzMYoV7bhX72P/INomY4wHqgnz8yWwcWwR4Am1JYdmS4 sXIDcNi+9YyJQfc7PfluTZCLrd7J4IIynX+tXilnPxHAo/rWX92j3dzTje8JX0zqKiYl FBFw== X-Gm-Message-State: AOJu0YxoEtgpNSdWLPOKo0Gyj9YN3L0gmA5zoJ8IFwZ7AbVMN7PpHHC1 BHThuUKIY43t0Qg+Dk4MkGWRDRysu/p0zVmgk/MhGPkA7rFJdMV8yZcPI2A99janNCCgWfoHiha 2gXIi+oE= X-Gm-Gg: ASbGncs51d654lEl8xUUmTgjpfZyE9D1l/WmdvLob+RxXAlmUmjYiEyDH/ueLc5vLEt 0JWzZGAbUNC3hf6Debu9C1uy1MmTYeYpdpPdGxUNDLuckY26KYc0EOuejxupA9JrJwapEpkLkrI vAQKVbA/PhM+34RsrSV8XvxgEvLAawV6vl0mbLaA6SrWqOKZWtZIaBc4NXIX7Irhj3Yzg4CXu3n xv3wupff72i+x+4EUZ5Hyz3AxF283fEvEn8m+R1FYoEzIgY2qJTvN7H2M6BWvnE+Hi++/+s81zI W1YJzUw+GddeYj5In4FF2fcEOoZWfQN6qJ2I8GHN0ZYE2dRPzMuO1qOhxCaExjBt6tRp7KqqxUC ARf8Wj5t+aBIYnav/jZu275pvyQCwduYAAXRRL6pawg== X-Google-Smtp-Source: AGHT+IH1pjZUNAWQum5V8DLvmjxoGKt/RBAENA6acO4UcvGrZYV0esNj4/K6d9O75I0FJ7DNEV12RQ== X-Received: by 2002:a05:600c:6986:b0:439:9424:1b70 with SMTP id 5b1f17b1804b1-45324f6a144mr6240575e9.30.1749605609353; Tue, 10 Jun 2025 18:33:29 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.33.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:33:28 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 10/35] libcamera: software_isp: Move param select code to Debayer base class Date: Wed, 11 Jun 2025 02:32:20 +0100 Message-ID: <20250611013245.133785-11-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-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" Move the parameter selection code into the Debayer base class in-order to facilitate reuse of the lookup tables in the eGL shaders. Signed-off-by: Bryan O'Donoghue --- src/libcamera/software_isp/debayer.cpp | 40 ++++++++++++++++++++++ src/libcamera/software_isp/debayer.h | 5 +++ src/libcamera/software_isp/debayer_cpu.cpp | 29 +++------------- 3 files changed, 49 insertions(+), 25 deletions(-) diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index 29fdcbbf..75e4bffa 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -187,4 +187,44 @@ Debayer::~Debayer() * \brief Signals when the output buffer is ready */ +/** + * \fn void Debayer::setParams(DebayerParams ¶ms) + * \brief Select the bayer params to use for the next frame debayer + * \param[in] params The parameters to be used in debayering + */ +void Debayer::setParams(DebayerParams ¶ms) +{ + green_ = params.green; + greenCcm_ = params.greenCcm; + if (swapRedBlueGains_) { + red_ = params.blue; + blue_ = params.red; + redCcm_ = params.blueCcm; + blueCcm_ = params.redCcm; + for (unsigned int i = 0; i < 256; i++) { + std::swap(redCcm_[i].r, redCcm_[i].b); + std::swap(blueCcm_[i].r, blueCcm_[i].b); + } + } else { + red_ = params.red; + blue_ = params.blue; + redCcm_ = params.redCcm; + blueCcm_ = params.blueCcm; + } + gammaLut_ = params.gammaLut; +} + +/** + * \fn void Debayer::dmaSyncBegin(DebayerParams ¶ms) + * \brief Common CPU/GPU Dma Sync Buffer begin + */ +void Debayer::dmaSyncBegin(std::vector &dmaSyncers, FrameBuffer *input, FrameBuffer *output) +{ + for (const FrameBuffer::Plane &plane : input->planes()) + dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Read); + + for (const FrameBuffer::Plane &plane : output->planes()) + dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Write); +} + } /* namespace libcamera */ diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h index 01b6e916..0af66b55 100644 --- a/src/libcamera/software_isp/debayer.h +++ b/src/libcamera/software_isp/debayer.h @@ -20,6 +20,7 @@ #include #include +#include "libcamera/internal/dma_buf_allocator.h" #include "libcamera/internal/software_isp/benchmark.h" #include "libcamera/internal/software_isp/debayer_params.h" @@ -82,6 +83,10 @@ public: private: virtual Size patternSize(PixelFormat inputFormat) = 0; + +protected: + void setParams(DebayerParams ¶ms); + void dmaSyncBegin(std::vector &dmaSyncers, FrameBuffer *input, FrameBuffer *output); }; } /* namespace libcamera */ diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp index 13db8a8c..4ef573a3 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/debayer_cpu.cpp @@ -22,7 +22,6 @@ #include #include "libcamera/internal/bayer_format.h" -#include "libcamera/internal/dma_buf_allocator.h" #include "libcamera/internal/framebuffer.h" #include "libcamera/internal/mapped_framebuffer.h" @@ -740,30 +739,10 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output bench_.startFrame(); std::vector dmaSyncers; - for (const FrameBuffer::Plane &plane : input->planes()) - dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Read); - - for (const FrameBuffer::Plane &plane : output->planes()) - dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Write); - - green_ = params.green; - greenCcm_ = params.greenCcm; - if (swapRedBlueGains_) { - red_ = params.blue; - blue_ = params.red; - redCcm_ = params.blueCcm; - blueCcm_ = params.redCcm; - for (unsigned int i = 0; i < 256; i++) { - std::swap(redCcm_[i].r, redCcm_[i].b); - std::swap(blueCcm_[i].r, blueCcm_[i].b); - } - } else { - red_ = params.red; - blue_ = params.blue; - redCcm_ = params.redCcm; - blueCcm_ = params.blueCcm; - } - gammaLut_ = params.gammaLut; + + dmaSyncBegin(dmaSyncers, input, output); + + setParams(params); /* Copy metadata from the input buffer */ FrameMetadata &metadata = output->_d()->metadata();