[libcamera-devel,v2,1/1] libcamera: set ControlInfo for Span Controls
diff mbox series

Message ID 20220816191752.109151-2-Rauch.Christian@gmx.de
State New
Headers show
Series
  • libcamera: set ControlInfo for Span Controls
Related show

Commit Message

Christian Rauch Aug. 16, 2022, 7:17 p.m. UTC
Some control properties are typed with a Span to store an array of values.
Currently those are ColourGains, SensorBlackLevels, ColourCorrectionMatrix
and FrameDurationLimits. The value range and defaults in the ControlInfo of
those Controls is currently defined as scalar. This prevents accessing the
ControlInfo via the native Span type.

By defining the ControlInfo in terms of Spans, we can avoid this issue.

Signed-off-by: Christian Rauch <Rauch.Christian@gmx.de>
---
 src/ipa/ipu3/ipu3.cpp                           |  6 +++---
 src/ipa/raspberrypi/raspberrypi.cpp             | 14 +++++++++++---
 test/serialization/ipa_data_serializer_test.cpp |  2 +-
 3 files changed, 15 insertions(+), 7 deletions(-)

--
2.34.1

Patch
diff mbox series

diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp
index e37b2fa0..0439cd9d 100644
--- a/src/ipa/ipu3/ipu3.cpp
+++ b/src/ipa/ipu3/ipu3.cpp
@@ -273,9 +273,9 @@  void IPAIPU3::updateControls(const IPACameraSensorInfo &sensorInfo,
 		frameDurations[i] = frameSize / (sensorInfo.pixelRate / 1000000U);
 	}

-	controls[&controls::FrameDurationLimits] = ControlInfo(frameDurations[0],
-							       frameDurations[1],
-							       frameDurations[2]);
+	controls[&controls::FrameDurationLimits] = ControlInfo{ Span<const int64_t>({ frameDurations[0], frameDurations[0] }),
+								Span<const int64_t>({ frameDurations[1], frameDurations[1] }),
+								Span<const int64_t>({ frameDurations[2], frameDurations[2] }) };

 	*ipaControls = ControlInfoMap(std::move(controls), controls::controls);
 }
diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp
index 69c73f8c..175b6b88 100644
--- a/src/ipa/raspberrypi/raspberrypi.cpp
+++ b/src/ipa/raspberrypi/raspberrypi.cpp
@@ -82,15 +82,23 @@  static const ControlInfoMap::Map ipaControls{
 	{ &controls::AeExposureMode, ControlInfo(controls::AeExposureModeValues) },
 	{ &controls::ExposureValue, ControlInfo(-8.0f, 8.0f, 0.0f) },
 	{ &controls::AwbEnable, ControlInfo(false, true) },
-	{ &controls::ColourGains, ControlInfo(0.0f, 32.0f) },
+	{ &controls::ColourGains, ControlInfo{ Span<const float>({ 0, 0 }), Span<const float>({ 32, 32 }), Span<const float>({ 0, 0 }) } },
 	{ &controls::AwbMode, ControlInfo(controls::AwbModeValues) },
 	{ &controls::Brightness, ControlInfo(-1.0f, 1.0f, 0.0f) },
 	{ &controls::Contrast, ControlInfo(0.0f, 32.0f, 1.0f) },
 	{ &controls::Saturation, ControlInfo(0.0f, 32.0f, 1.0f) },
 	{ &controls::Sharpness, ControlInfo(0.0f, 16.0f, 1.0f) },
-	{ &controls::ColourCorrectionMatrix, ControlInfo(-16.0f, 16.0f) },
+	{ &controls::ColourCorrectionMatrix, ControlInfo{
+						     Span<const float>({ -16, -16, -16, -16, -16, -16, -16, -16, -16 }),
+						     Span<const float>({ 16, 16, 16, 16, 16, 16, 16, 16, 16 }),
+						     Span<const float>({ 1, 0, 0, 0, 1, 0, 0, 0, 1 }),
+					     } },
 	{ &controls::ScalerCrop, ControlInfo(Rectangle{}, Rectangle(65535, 65535, 65535, 65535), Rectangle{}) },
-	{ &controls::FrameDurationLimits, ControlInfo(INT64_C(33333), INT64_C(120000)) },
+	{ &controls::FrameDurationLimits, ControlInfo{
+						  Span<const int64_t>({ 33333, 33333 }),
+						  Span<const int64_t>({ 120000, 120000 }),
+						  Span<const int64_t>({ 33333, 33333 }),
+					  } },
 	{ &controls::draft::NoiseReductionMode, ControlInfo(controls::draft::NoiseReductionModeValues) }
 };

diff --git a/test/serialization/ipa_data_serializer_test.cpp b/test/serialization/ipa_data_serializer_test.cpp
index d2050a86..e9e29bd5 100644
--- a/test/serialization/ipa_data_serializer_test.cpp
+++ b/test/serialization/ipa_data_serializer_test.cpp
@@ -36,7 +36,7 @@  static const ControlInfoMap Controls = ControlInfoMap({
 		{ &controls::AeEnable, ControlInfo(false, true) },
 		{ &controls::ExposureTime, ControlInfo(0, 999999) },
 		{ &controls::AnalogueGain, ControlInfo(1.0f, 32.0f) },
-		{ &controls::ColourGains, ControlInfo(0.0f, 32.0f) },
+		{ &controls::ColourGains, ControlInfo{ Span<const float>({ 0, 0 }), Span<const float>({ 32, 32 }), Span<const float>({ 0, 0 }) } },
 		{ &controls::Brightness, ControlInfo(-1.0f, 1.0f) },
 	}, controls::controls);