From 7313f046a23af37bbe52ed75355d312971a8122b Mon Sep 17 00:00:00 2001 From: Stefan Klug Date: Tue, 25 Nov 2025 17:28:38 +0100 Subject: [PATCH] libcamera: Add and implement LensDewarpEnable control Add a LensDewarpEnable control to enable or disable lens dewarping if it is configured. Implement it inside the dw100 converter module. Signed-off-by: Stefan Klug Reviewed-by: Paul Elder Reviewed-by: Kieran Bingham --- src/libcamera/control_ids_core.yaml | 7 +++++++ src/libcamera/converter/converter_dw100.cpp | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/libcamera/control_ids_core.yaml b/src/libcamera/control_ids_core.yaml index f7818658..3bcb475f 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/converter/converter_dw100.cpp b/src/libcamera/converter/converter_dw100.cpp index 16bbc417..df5155cf 100644 --- a/src/libcamera/converter/converter_dw100.cpp +++ b/src/libcamera/converter/converter_dw100.cpp @@ -343,6 +343,9 @@ void ConverterDW100Module::updateControlInfos(const Stream *stream, ControlInfoM controls[&controls::ScalerCrop] = ControlInfo(Rectangle(sensorCrop_.x, sensorCrop_.y, 1, 1), sensorCrop_, sensorCrop_); + if (dewarpParams_.has_value()) + controls[&controls::LensDewarpEnable] = ControlInfo(false, true, true); + if (!converter_.supportsRequests()) LOG(Converter, Warning) << "dw100 kernel driver has no requests support." @@ -366,6 +369,12 @@ void ConverterDW100Module::setControls(const Stream *stream, const ControlList & auto &info = vertexMaps_[stream]; auto &vertexMap = info.map; + const auto &lensDewarpEnable = controls.get(controls::LensDewarpEnable); + if (lensDewarpEnable) { + vertexMap.setLensDewarpEnable(*lensDewarpEnable); + info.update = true; + } + const auto &crop = controls.get(controls::ScalerCrop); if (crop) { vertexMap.setScalerCrop(*crop); @@ -394,6 +403,9 @@ void ConverterDW100Module::populateMetadata(const Stream *stream, ControlList &m auto &vertexMap = vertexMaps_[stream].map; meta.set(controls::ScalerCrop, vertexMap.effectiveScalerCrop()); + + if (dewarpParams_.has_value()) + meta.set(controls::LensDewarpEnable, vertexMap.lensDewarpEnable()); } /**