[{"id":37065,"web_url":"https://patchwork.libcamera.org/comment/37065/","msgid":"<176409347031.567526.11324554554160127966@ping.linuxembedded.co.uk>","date":"2025-11-25T17:57:50","subject":"Re: [PATCH v3 28/29] DNI libcamera: rkisp1: Implement dw100 specific\n\tfeatures","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Stefan Klug (2025-11-25 16:28:40)\n> The dw100 allows more features implemented in the dw100 vertex map.\n> Implement these features for the rkisp1 pipeline.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> \n> ---\n> \n> Changes in v3:\n> - Move control handling from pipeline handler to the converter\n>   class\n> - Moved controls into core namespace\n\nNow that these are managed entirely in the dw100 component, I would\nwonder if these can have a dw100 control namespace.\n\nUnless we can generalise them for core...\n\nBut if they were in controls::dw100:: I'd think this patch could lose\nit's DNI and be merged ....\n\n\n> \n> Changes in v2:\n> - Marked as DoNotIntegrate because the puplic interface needs further\n>   discussions\n> - Added Dw100EffectiveScale metadata\n> ---\n>  .../converter/converter_dw100_vertexmap.h     |  2 +-\n>  src/libcamera/control_ids_core.yaml           | 50 +++++++++++++++++++\n>  src/libcamera/converter/converter_dw100.cpp   | 36 +++++++++++++\n>  3 files changed, 87 insertions(+), 1 deletion(-)\n> \n> diff --git a/include/libcamera/internal/converter/converter_dw100_vertexmap.h b/include/libcamera/internal/converter/converter_dw100_vertexmap.h\n> index 49ecc81678a0..f79274a6098a 100644\n> --- a/include/libcamera/internal/converter/converter_dw100_vertexmap.h\n> +++ b/include/libcamera/internal/converter/converter_dw100_vertexmap.h\n> @@ -42,7 +42,7 @@ public:\n>         const Transform &transform() const { return transform_; }\n>  \n>         void setScale(const float scale) { scale_ = scale; }\n> -       float effectiveScale() const { return (effectiveScaleX_ + effectiveScaleY_) * 0.5; }\n> +       std::array<float, 2> effectiveScale() const { return { static_cast<float>(effectiveScaleX_), static_cast<float>(effectiveScaleY_) }; }\n>  \n>         void setRotation(const float rotation) { rotation_ = rotation; }\n>         float rotation() const { return rotation_; }\n> diff --git a/src/libcamera/control_ids_core.yaml b/src/libcamera/control_ids_core.yaml\n> index 3bcb475fd102..e03b570282ba 100644\n> --- a/src/libcamera/control_ids_core.yaml\n> +++ b/src/libcamera/control_ids_core.yaml\n> @@ -1353,4 +1353,54 @@ controls:\n>          Enable or disable lens dewarping. This control is only available if lens\n>          dewarp parameters are configured in the tuning file.\n>  \n> +  - Dw100ScaleMode:\n> +      type: int32_t\n> +      direction: inout\n> +      description: |\n> +        Scale mode of the dewarper.\n> +      enum:\n> +        - name: Dw100ScaleModeFill\n> +          value: 0\n> +          description: |\n> +            Fills the given output size with the largest rectangle possible.\n> +            Aspect ratio is not preserved. Dw100Scale is ignored.\n> +        - name: Dw100ScaleModeCrop\n> +          value: 1\n> +          description: |\n> +            Crops to the given output size. The scale factor can be specified\n> +            using Dw100Scale. Aspect ratio is preserved.\n> +\n> +  - Dw100Scale:\n> +      type: float\n> +      direction: inout\n> +      description: |\n> +        Scale factor applied to the image when Dw100ScaleMode is set to Crop.\n> +        This value is clamped, so that all pixels have valid input data.\n> +        Therefore a value of 0 always provides the largest possible field of\n> +        view. Scaling happens centered around the center of the ScalerCrop +\n> +        Dw10Offset.\n> +\n> +  - Dw100Rotation:\n> +      type: float\n> +      direction: inout\n> +      description: |\n> +        Rotates the image by the given angle in degrees in clockwise direction\n> +        around the center of ScalerCrop + Dw100Offset\n> +\n> +  - Dw100Offset:\n> +      type: Point\n> +      direction: inout\n> +      description: |\n> +        Moves the image by the given values in x and y direction in sensor\n> +        coordinate space. This is clamped, so that all output pixels contain\n> +        valid data. The offset is therefore ignored when the Dw100Scale value is\n> +        too small.\n> +\n> +  - Dw100EffectiveScale:\n> +      type: float\n> +      direction: out\n> +      description: |\n> +        Effective scale\n> +      size: [2]\n> +\n>  ...\n> diff --git a/src/libcamera/converter/converter_dw100.cpp b/src/libcamera/converter/converter_dw100.cpp\n> index 7adad1b502f0..b39e4ab23cd6 100644\n> --- a/src/libcamera/converter/converter_dw100.cpp\n> +++ b/src/libcamera/converter/converter_dw100.cpp\n> @@ -346,6 +346,13 @@ void ConverterDW100Module::updateControlInfos(const Stream *stream, ControlInfoM\n>         if (dewarpParams_.has_value())\n>                 controls[&controls::LensDewarpEnable] = ControlInfo(false, true, true);\n>  \n> +       controls[&controls::Dw100Scale] = ControlInfo(0.2f, 8.0f, 1.0f);\n> +       controls[&controls::Dw100Rotation] = ControlInfo(-180.0f, 180.0f, 0.0f);\n> +       controls[&controls::Dw100Offset] =\n> +               ControlInfo(Point(-10000, -10000), Point(10000, 10000), Point(0, 0));\n> +       controls[&controls::Dw100ScaleMode] =\n> +               ControlInfo(controls::Dw100ScaleModeValues, controls::Dw100ScaleModeFill);\n> +\n>         if (!converter_.supportsRequests())\n>                 LOG(Converter, Warning)\n>                         << \"dw100 kernel driver has no requests support.\"\n> @@ -369,6 +376,30 @@ void ConverterDW100Module::setControls(const Stream *stream, const ControlList &\n>         auto &info = vertexMaps_[stream];\n>         auto &vertexMap = info.map;\n>  \n> +       const auto &scale = controls.get(controls::Dw100Scale);\n> +       if (scale) {\n> +               vertexMap.setScale(*scale);\n> +               info.update = true;\n> +       }\n> +\n> +       const auto &rotation = controls.get(controls::Dw100Rotation);\n> +       if (rotation) {\n> +               vertexMap.setRotation(*rotation);\n> +               info.update = true;\n> +       }\n> +\n> +       const auto &offset = controls.get(controls::Dw100Offset);\n> +       if (offset) {\n> +               vertexMap.setOffset(*offset);\n> +               info.update = true;\n> +       }\n> +\n> +       const auto &scaleMode = controls.get(controls::Dw100ScaleMode);\n> +       if (scaleMode) {\n> +               vertexMap.setMode(static_cast<Dw100VertexMap::ScaleMode>(*scaleMode));\n> +               info.update = true;\n> +       }\n> +\n>         const auto &lensDewarpEnable = controls.get(controls::LensDewarpEnable);\n>         if (lensDewarpEnable) {\n>                 vertexMap.setLensDewarpEnable(*lensDewarpEnable);\n> @@ -402,6 +433,11 @@ void ConverterDW100Module::populateMetadata(const Stream *stream, ControlList &m\n>  \n>         auto &vertexMap = vertexMaps_[stream].map;\n>  \n> +       std::array<float, 2> effectiveScale = vertexMap.effectiveScale();\n> +       meta.set(controls::Dw100EffectiveScale, effectiveScale);\n> +       meta.set(controls::Dw100Scale, (effectiveScale[0] + effectiveScale[1]) / 2.0);\n> +       meta.set(controls::Dw100Rotation, vertexMap.rotation());\n> +       meta.set(controls::Dw100Offset, vertexMap.effectiveOffset());\n>         meta.set(controls::ScalerCrop, vertexMap.effectiveScalerCrop());\n>  \n>         if (dewarpParams_.has_value())\n> -- \n> 2.51.0\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 8AEB7C3334\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 Nov 2025 17:57:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7BCF260A8A;\n\tTue, 25 Nov 2025 18:57:54 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 47161609D8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 Nov 2025 18:57:53 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 39C6B236;\n\tTue, 25 Nov 2025 18:55:44 +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=\"r1Nm4l9n\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1764093344;\n\tbh=gjWR5Yq7+hOP28FaS9U7BzIWz33AqrWmCY0kn8c1GTA=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=r1Nm4l9n7JsygL39cDipxicBa0ZhpnBHdOI84E+00vge70xX7nudUz6jeOMY/Pr8Y\n\toQ0drMjBxR7auMhZJ267L/D7nJ0/hRx+/IraWy+liZHDHucySnR2udopmRTgdidwG/\n\tI+5D6G6+bIdRt4VJbtihIjIfgL6EB3xJVRu40+es=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20251125162851.2301793-29-stefan.klug@ideasonboard.com>","References":"<20251125162851.2301793-1-stefan.klug@ideasonboard.com>\n\t<20251125162851.2301793-29-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH v3 28/29] DNI libcamera: rkisp1: Implement dw100 specific\n\tfeatures","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Tue, 25 Nov 2025 17:57:50 +0000","Message-ID":"<176409347031.567526.11324554554160127966@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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>"}}]