From patchwork Thu Oct 23 14:48:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 24761 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 C0BEFC3347 for ; Thu, 23 Oct 2025 14:50:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4C7D260865; Thu, 23 Oct 2025 16:50:29 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="R8QkNssV"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8C648607ED for ; Thu, 23 Oct 2025 16:50:28 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:7328:357b:4ce1:72b6]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 91B42192B; Thu, 23 Oct 2025 16:48:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1761230923; bh=jNkATD4IVKZDk3Nr2jeaeEoD0w69FOUxdlyhHGDPwO0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R8QkNssVKikSvpXWkrqqtmvJr8iwFzOXea/+WXHv5lxNxCh+EWj+iIQSeZDu9rnAl f1GGvs4l6tZBRbh6iqgKiQxGuZT64dm1utGmAIB7GexyYJPxlAlIs9xmoHyWIjMf5C 9RfFvbegOx3TLcMq1rzH/sLiKrqHWi5SZwkdOeiY= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v2 34/35] DNI libcamera: rkisp1: Implement dw100 specific features Date: Thu, 23 Oct 2025 16:48:35 +0200 Message-ID: <20251023144841.403689-35-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" The dw100 allows more features implemented in the dw100 vertex map. Implement these features for the rkisp1 pipeline. Signed-off-by: Stefan Klug --- Changes in v2: - Marked as DoNotIntegrate because the puplic interface needs further discussions - Added Dw100EffectiveScale metadata --- .../converter/converter_dw100_vertexmap.h | 2 +- src/libcamera/control_ids_draft.yaml | 45 ++++++++++++++++++ src/libcamera/pipeline/rkisp1/rkisp1.cpp | 46 ++++++++++++++++--- 3 files changed, 86 insertions(+), 7 deletions(-) diff --git a/include/libcamera/internal/converter/converter_dw100_vertexmap.h b/include/libcamera/internal/converter/converter_dw100_vertexmap.h index b05ed8338a23..5fa46452f9ef 100644 --- a/include/libcamera/internal/converter/converter_dw100_vertexmap.h +++ b/include/libcamera/internal/converter/converter_dw100_vertexmap.h @@ -47,7 +47,7 @@ public: const Transform &transform() const { return transform_; } void setScale(const float scale) { scale_ = scale; } - float effectiveScale() const { return (effectiveScaleX_ + effectiveScaleY_) * 0.5; } + std::array effectiveScale() const { return { static_cast(effectiveScaleX_), static_cast(effectiveScaleY_) }; } void setRotation(const float rotation) { rotation_ = rotation; } float rotation() const { return rotation_; } diff --git a/src/libcamera/control_ids_draft.yaml b/src/libcamera/control_ids_draft.yaml index 03309eeac34f..30c832e32159 100644 --- a/src/libcamera/control_ids_draft.yaml +++ b/src/libcamera/control_ids_draft.yaml @@ -206,6 +206,51 @@ controls: available only on this camera device are at least this numeric value. All of the custom test patterns will be static (that is the raw image must not vary from frame to frame). + - Dw100ScaleMode: + type: int32_t + direction: inout + description: | + Scale mode of the dewarper. + enum: + - name: Fill + value: 0 + description: | + Fills the given output size with the largest rectangle possible. + Aspect ratio is not preserved. Dw100Scale is ignored. + - name: Crop + value: 1 + description: | + Crops to the given output size. The scale factor can be specified + using Dw100Scale. Aspect ratio is preserved. + - Dw100Scale: + type: float + direction: inout + description: | + Scale factor applied to the image when Dw100ScaleMode is set to Crop. + This value is clamped, so that all pixels have valid input data. + Therefore a value of 0 always provides the largest possible field of + view. Scaling happens centered around the center of the ScalerCrop + + Dw10Offset. + - Dw100Rotation: + type: float + direction: inout + description: | + Rotates the image by the given angle in degrees in clockwise direction + around the center of ScalerCrop + Dw100Offset + - Dw100Offset: + type: Point + direction: inout + description: | + Moves the image by the given values in x and y direction in sensor + coordinate space. This is clamped, so that all output pixels contain + valid data. The offset is therefore ignored when the Dw100Scale value is + too small. + - Dw100EffectiveScale: + type: float + direction: out + description: | + Effective scale + size: [2] - FaceDetectMode: type: int32_t diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 9a156d4a01f2..6538fbcc9698 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -1500,13 +1500,18 @@ int PipelineHandlerRkISP1::updateControls(RkISP1CameraData *data) maxCrop); } - if (data->dewarpParams_.has_value()) { - if (dewarper_->supportsRequests()) + if (dewarper_->supportsRequests()) { + controls[&controls::draft::Dw100Scale] = ControlInfo(0.2f, 8.0f, 1.0f); + controls[&controls::draft::Dw100Rotation] = ControlInfo(-180.0f, 180.0f, 0.0f); + controls[&controls::draft::Dw100Offset] = ControlInfo(Point(-10000, -10000), Point(10000, 10000), Point(0, 0)); + controls[&controls::draft::Dw100ScaleMode] = ControlInfo(controls::draft::Dw100ScaleModeValues, controls::draft::Fill); + + if (data->dewarpParams_.has_value()) controls[&controls::LensDewarpEnable] = ControlInfo(false, true, true); - else - LOG(RkISP1, Warning) - << "dw100 kernel driver has no requests support." - " No dynamic configuration possible."; + } else { + LOG(RkISP1, Warning) + << "dw100 kernel driver has no requests support." + " No dynamic configuration possible."; } } @@ -1784,6 +1789,30 @@ void PipelineHandlerRkISP1::imageBufferReady(FrameBuffer *buffer) bool update = false; auto &vertexMap = dewarper_->vertexMap(&data->mainPathStream_); + const auto &scale = request->controls().get(controls::draft::Dw100Scale); + if (scale) { + vertexMap.setScale(*scale); + update = true; + } + + const auto &rotation = request->controls().get(controls::draft::Dw100Rotation); + if (rotation) { + vertexMap.setRotation(*rotation); + update = true; + } + + const auto &offset = request->controls().get(controls::draft::Dw100Offset); + if (offset) { + vertexMap.setOffset(*offset); + update = true; + } + + const auto &scaleMode = request->controls().get(controls::draft::Dw100ScaleMode); + if (scaleMode) { + vertexMap.setMode(static_cast(*scaleMode)); + update = true; + } + const auto &lensDewarpEnable = request->controls().get(controls::LensDewarpEnable); if (lensDewarpEnable) { vertexMap.setLensDewarpEnable(*lensDewarpEnable); @@ -1836,6 +1865,11 @@ void PipelineHandlerRkISP1::imageBufferReady(FrameBuffer *buffer) } auto &meta = request->metadata(); + std::array effectiveScale = vertexMap.effectiveScale(); + meta.set(controls::draft::Dw100EffectiveScale, effectiveScale); + meta.set(controls::draft::Dw100Scale, (effectiveScale[0] + effectiveScale[1]) / 2.0); + meta.set(controls::draft::Dw100Rotation, vertexMap.rotation()); + meta.set(controls::draft::Dw100Offset, vertexMap.effectiveOffset()); meta.set(controls::ScalerCrop, vertexMap.effectiveScalerCrop()); if (vertexMap.dewarpParamsValid())