[{"id":36747,"web_url":"https://patchwork.libcamera.org/comment/36747/","msgid":"<176250972552.2116251.16132671036922600217@neptunite.rasen.tech>","date":"2025-11-07T10:02:05","subject":"Re: [PATCH v2 32/35] libcamera: Add and implement LensDewarpEnable\n\tcontrol","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Quoting Stefan Klug (2025-10-23 23:48:33)\n> Add a LensDewarpEnable control to enable or disable lens dewarping if it\n> is configured. Implement it for the dw100 converter.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> \n> ---\n> \n> Changes in v2:\n> - Merged control definition and usage into one patch\n> - Improved control description\n> - Fixed actual handling of LensDewarpEnable control that got lost in a\n>   previous rebase\n> ---\n>  src/libcamera/control_ids_core.yaml      |  7 +++++++\n>  src/libcamera/pipeline/rkisp1/rkisp1.cpp | 26 ++++++++++++++++++++++--\n>  2 files changed, 31 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/libcamera/control_ids_core.yaml b/src/libcamera/control_ids_core.yaml\n> index f781865859ac..3bcb475fd102 100644\n> --- a/src/libcamera/control_ids_core.yaml\n> +++ b/src/libcamera/control_ids_core.yaml\n> @@ -1346,4 +1346,11 @@ controls:\n>          reduces the WdrExposureValue until the amount of pixels that are close\n>          to saturation is lower than this value.\n>  \n> +  - LensDewarpEnable:\n> +      type: bool\n> +      direction: inout\n> +      description: |\n> +        Enable or disable lens dewarping. This control is only available if lens\n> +        dewarp parameters are configured in the tuning file.\n> +\n>  ...\n> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> index 2280a5554f5a..da3cfc0ffdeb 100644\n> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> @@ -1492,6 +1492,14 @@ int PipelineHandlerRkISP1::updateControls(RkISP1CameraData *data)\n>                                                                       maxCrop);\n>                 }\n>  \n> +               if (data->dewarpParams_.has_value()) {\n> +                       if (dewarper_->supportsRequests())\n> +                               controls[&controls::LensDewarpEnable] = ControlInfo(false, true, true);\n> +                       else\n> +                               LOG(RkISP1, Warning)\n> +                                       << \"dw100 kernel driver has no requests support.\"\n> +                                          \" No dynamic configuration possible.\";\n> +               }\n>         }\n>  \n>         /* Add the IPA registered controls to list of camera controls. */\n> @@ -1765,8 +1773,15 @@ void PipelineHandlerRkISP1::imageBufferReady(FrameBuffer *buffer)\n>                 availableDewarpRequests_.pop();\n>         }\n>  \n> +       bool update = false;\n>         auto &vertexMap = dewarper_->vertexMap(&data->mainPathStream_);\n>  \n> +       const auto &lensDewarpEnable = request->controls().get(controls::LensDewarpEnable);\n> +       if (lensDewarpEnable) {\n> +               vertexMap.setLensDewarpEnable(*lensDewarpEnable);\n> +               update = true;\n> +       }\n> +\n>         /* Handle scaler crop control. */\n>         const auto &crop = request->controls().get(controls::ScalerCrop);\n>         if (crop) {\n> @@ -1775,9 +1790,12 @@ void PipelineHandlerRkISP1::imageBufferReady(FrameBuffer *buffer)\n>                                 << \"Dynamically setting ScalerCrop requires a \"\n>                                    \"dw100 driver with requests support\";\n>                 vertexMap.setScalerCrop(*crop);\n> -               dewarper_->applyVertexMap(&data->mainPathStream_, dewarpRequest);\n> +               update = true;\n>         }\n>  \n> +       if (update)\n> +               dewarper_->applyVertexMap(&data->mainPathStream_, dewarpRequest);\n> +\n>         /*\n>          * Queue input and output buffers to the dewarper. The output\n>          * buffers for the dewarper are the buffers of the request, supplied\n> @@ -1809,7 +1827,11 @@ void PipelineHandlerRkISP1::imageBufferReady(FrameBuffer *buffer)\n>                 }\n>         }\n>  \n> -       request->metadata().set(controls::ScalerCrop, vertexMap.effectiveScalerCrop());\n> +       auto &meta = request->metadata();\n> +       meta.set(controls::ScalerCrop, vertexMap.effectiveScalerCrop());\n> +\n> +       if (vertexMap.dewarpParamsValid())\n> +               meta.set(controls::LensDewarpEnable, vertexMap.lensDewarpEnable());\n>  }\n>  \n>  void PipelineHandlerRkISP1::dewarpRequestReady(V4L2Request *request)\n> -- \n> 2.48.1\n>","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 EAD00C3241\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  7 Nov 2025 10:02:14 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0089460A80;\n\tFri,  7 Nov 2025 11:02:13 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7E86F606D5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  7 Nov 2025 11:02:12 +0100 (CET)","from neptunite.rasen.tech (unknown\n\t[IPv6:2404:7a81:160:2100:8ce5:1b8c:5343:a04e])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id D9C98161;\n\tFri,  7 Nov 2025 11:00:15 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"mipiPWcI\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1762509616;\n\tbh=MactC/djACXp6q+XVmCdX4SLRg5yAqyPH2OKN8Kgll0=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=mipiPWcIQu8E3sFVh6cxwonT3zF+rfnjVBuM9qurDGNUOT8X6ypZVYPc+iAbczT19\n\t8tQD7vtOVz9BJ9F0Pz35oF9su6kB6BB2Q0W8pfmXvSBs7Y7OnR/FHav7b00Q7ZfXGc\n\tBp6/aWSTIuQgPUy4yWBujDjttACcK8zwhMVQiik0=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20251023144841.403689-33-stefan.klug@ideasonboard.com>","References":"<20251023144841.403689-1-stefan.klug@ideasonboard.com>\n\t<20251023144841.403689-33-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH v2 32/35] libcamera: Add and implement LensDewarpEnable\n\tcontrol","From":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Fri, 07 Nov 2025 19:02:05 +0900","Message-ID":"<176250972552.2116251.16132671036922600217@neptunite.rasen.tech>","User-Agent":"alot/0.0.0","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>"}}]