[libcamera-devel,v2,2/3] libcamera: raspberrypi: Add ColourCorrectionMatrix control

Message ID 20200724145618.26304-3-david.plowman@raspberrypi.com
State Accepted
Headers show
Series
  • ColourCorrectionMatrix control
Related show

Commit Message

David Plowman July 24, 2020, 2:56 p.m. UTC
Implements, for the Raspberry Pi platform, the returning of the CCM
(Colour Correction Matrix) used by the pipeline in the libcamera
metadata.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
---
 include/libcamera/ipa/raspberrypi.h | 1 +
 src/ipa/raspberrypi/raspberrypi.cpp | 8 ++++++++
 2 files changed, 9 insertions(+)

Patch

diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h
index a493776..ca62990 100644
--- a/include/libcamera/ipa/raspberrypi.h
+++ b/include/libcamera/ipa/raspberrypi.h
@@ -56,6 +56,7 @@  static const ControlInfoMap RPiControls = {
 	{ &controls::Contrast, ControlInfo(0.0f, 32.0f) },
 	{ &controls::Saturation, ControlInfo(0.0f, 32.0f) },
 	{ &controls::Sharpness, ControlInfo(0.0f, 16.0f, 1.0f) },
+	{ &controls::ColourCorrectionMatrix, ControlInfo(-16.0f, 16.0f) },
 };
 
 } /* namespace libcamera */
diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp
index 7bd0488..3747208 100644
--- a/src/ipa/raspberrypi/raspberrypi.cpp
+++ b/src/ipa/raspberrypi/raspberrypi.cpp
@@ -438,6 +438,14 @@  void IPARPi::reportMetadata()
 		int32_t focusFoM = (focusStatus->focus_measures[5] + focusStatus->focus_measures[6]) / 2;
 		libcameraMetadata_.set(controls::FocusFoM, focusFoM);
 	}
+
+	CcmStatus *ccmStatus = rpiMetadata_.GetLocked<CcmStatus>("ccm.status");
+	if (ccmStatus) {
+		float m[9];
+		for (unsigned int i = 0; i < 9; i++)
+			m[i] = ccmStatus->matrix[i];
+		libcameraMetadata_.set(controls::ColourCorrectionMatrix, m);
+	}
 }
 
 /*