From patchwork Thu Oct 23 14:48:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 24759 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 D4E7AC3346 for ; Thu, 23 Oct 2025 14:50:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 15BE560861; Thu, 23 Oct 2025 16:50:25 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="XDi+9YIC"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id ACDFF607ED for ; Thu, 23 Oct 2025 16:50:22 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:7328:357b:4ce1:72b6]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id BA53A1D2B; Thu, 23 Oct 2025 16:48:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1761230917; bh=9UZZaXIngu5Dle1/LCtUV/S6Q1vKVbwh4WpHag52gY0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XDi+9YICZg/R3BeX9Md8+S4EX5EVbm3h5oAANFpDNvGDRZB+x76PtmJ5PGX2bfs0g is2b2FhVu6773JSRHoiCsxo0ygoNgM1dG3frCsCAt+Mz4ZEfWtWPH+9k/xQHkOCCDy tp9nFG1cZf8B0ITQ/zXGfniIzxCp90TLXlstJjKg= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v2 32/35] libcamera: Add and implement LensDewarpEnable control Date: Thu, 23 Oct 2025 16:48:33 +0200 Message-ID: <20251023144841.403689-33-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251023144841.403689-1-stefan.klug@ideasonboard.com> References: <20251023144841.403689-1-stefan.klug@ideasonboard.com> 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" Add a LensDewarpEnable control to enable or disable lens dewarping if it is configured. Implement it for the dw100 converter. Signed-off-by: Stefan Klug --- Changes in v2: - Merged control definition and usage into one patch - Improved control description - Fixed actual handling of LensDewarpEnable control that got lost in a previous rebase --- src/libcamera/control_ids_core.yaml | 7 +++++++ src/libcamera/pipeline/rkisp1/rkisp1.cpp | 26 ++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/libcamera/control_ids_core.yaml b/src/libcamera/control_ids_core.yaml index f781865859ac..3bcb475fd102 100644 --- a/src/libcamera/control_ids_core.yaml +++ b/src/libcamera/control_ids_core.yaml @@ -1346,4 +1346,11 @@ controls: reduces the WdrExposureValue until the amount of pixels that are close to saturation is lower than this value. + - LensDewarpEnable: + type: bool + direction: inout + description: | + Enable or disable lens dewarping. This control is only available if lens + dewarp parameters are configured in the tuning file. + ... diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 2280a5554f5a..da3cfc0ffdeb 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -1492,6 +1492,14 @@ int PipelineHandlerRkISP1::updateControls(RkISP1CameraData *data) maxCrop); } + if (data->dewarpParams_.has_value()) { + if (dewarper_->supportsRequests()) + controls[&controls::LensDewarpEnable] = ControlInfo(false, true, true); + else + LOG(RkISP1, Warning) + << "dw100 kernel driver has no requests support." + " No dynamic configuration possible."; + } } /* Add the IPA registered controls to list of camera controls. */ @@ -1765,8 +1773,15 @@ void PipelineHandlerRkISP1::imageBufferReady(FrameBuffer *buffer) availableDewarpRequests_.pop(); } + bool update = false; auto &vertexMap = dewarper_->vertexMap(&data->mainPathStream_); + const auto &lensDewarpEnable = request->controls().get(controls::LensDewarpEnable); + if (lensDewarpEnable) { + vertexMap.setLensDewarpEnable(*lensDewarpEnable); + update = true; + } + /* Handle scaler crop control. */ const auto &crop = request->controls().get(controls::ScalerCrop); if (crop) { @@ -1775,9 +1790,12 @@ void PipelineHandlerRkISP1::imageBufferReady(FrameBuffer *buffer) << "Dynamically setting ScalerCrop requires a " "dw100 driver with requests support"; vertexMap.setScalerCrop(*crop); - dewarper_->applyVertexMap(&data->mainPathStream_, dewarpRequest); + update = true; } + if (update) + dewarper_->applyVertexMap(&data->mainPathStream_, dewarpRequest); + /* * Queue input and output buffers to the dewarper. The output * buffers for the dewarper are the buffers of the request, supplied @@ -1809,7 +1827,11 @@ void PipelineHandlerRkISP1::imageBufferReady(FrameBuffer *buffer) } } - request->metadata().set(controls::ScalerCrop, vertexMap.effectiveScalerCrop()); + auto &meta = request->metadata(); + meta.set(controls::ScalerCrop, vertexMap.effectiveScalerCrop()); + + if (vertexMap.dewarpParamsValid()) + meta.set(controls::LensDewarpEnable, vertexMap.lensDewarpEnable()); } void PipelineHandlerRkISP1::dewarpRequestReady(V4L2Request *request)