[libcamera-devel] android: Hardcode black level lock
diff mbox series

Message ID 20211221053458.2711409-1-paul.elder@ideasonboard.com
State New
Delegated to: Paul Elder
Headers show
Series
  • [libcamera-devel] android: Hardcode black level lock
Related show

Commit Message

Paul Elder Dec. 21, 2021, 5:34 a.m. UTC
Hardcode black level lock in request and result metadata. Also add it to
the template.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
---
 src/android/camera_capabilities.cpp | 7 +++++++
 src/android/camera_device.cpp       | 9 +++++++++
 src/android/camera_request.h        | 1 +
 3 files changed, 17 insertions(+)

Patch
diff mbox series

diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
index c52b22be..3f3b7303 100644
--- a/src/android/camera_capabilities.cpp
+++ b/src/android/camera_capabilities.cpp
@@ -492,6 +492,8 @@  void CameraCapabilities::computeHwLevel(
 		hwLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED;
 	}
 
+	/* Black level lock doesn't need to be checked as we hardcode it */
+
 	found = availableResultKeys_.count(ANDROID_HOT_PIXEL_MODE);
 	if (!found) {
 		LOG(HAL, Info) << noFull << "missing hot pixel mode";
@@ -940,6 +942,7 @@  int CameraCapabilities::initializeStaticMetadata()
 	};
 
 	availableRequestKeys_ = {
+		ANDROID_BLACK_LEVEL_LOCK,
 		ANDROID_COLOR_CORRECTION_ABERRATION_MODE,
 		ANDROID_CONTROL_AE_ANTIBANDING_MODE,
 		ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION,
@@ -972,6 +975,7 @@  int CameraCapabilities::initializeStaticMetadata()
 	};
 
 	availableResultKeys_ = {
+		ANDROID_BLACK_LEVEL_LOCK,
 		ANDROID_COLOR_CORRECTION_ABERRATION_MODE,
 		ANDROID_CONTROL_AE_ANTIBANDING_MODE,
 		ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION,
@@ -2032,6 +2036,9 @@  std::unique_ptr<CameraMetadata> CameraCapabilities::requestTemplatePreview() con
 		requestTemplate->addEntry(ANDROID_TONEMAP_MODE, tonemapMode);
 	}
 
+	uint8_t blackLevelLock = ANDROID_BLACK_LEVEL_LOCK_OFF;
+	requestTemplate->addEntry(ANDROID_BLACK_LEVEL_LOCK, blackLevelLock);
+
 	if (staticMetadata_->entryContains<uint8_t>(ANDROID_HOT_PIXEL_AVAILABLE_HOT_PIXEL_MODES,
 						    ANDROID_HOT_PIXEL_MODE_FAST)) {
 		uint8_t hotPixelMode = ANDROID_HOT_PIXEL_MODE_FAST;
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 7cab878c..a097d384 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -973,6 +973,9 @@  int CameraDevice::processControls(Camera3RequestDescriptor *descriptor)
 		}
 	}
 
+	if (settings.getEntry(ANDROID_BLACK_LEVEL_LOCK, &entry))
+		descriptor->blackLevelLock_ = *entry.data.u8;
+
 	if (settings.getEntry(ANDROID_HOT_PIXEL_MODE, &entry)) {
 		const int32_t data = static_cast<int32_t>(*entry.data.u8);
 		int32_t hotPixelMode;
@@ -1814,6 +1817,12 @@  CameraDevice::getResultMetadata(const Camera3RequestDescriptor &descriptor) cons
 		resultMetadata->addEntry(ANDROID_EDGE_MODE, descriptor.edgeMode_);
 	}
 
+	/*
+	 * \todo Hardcode the black level lock for now, as simply reporting
+	 * what the request asked for satsifies CTS.
+	 */
+	resultMetadata->addEntry(ANDROID_BLACK_LEVEL_LOCK, descriptor.blackLevelLock_);
+
 	if (metadata.contains(controls::draft::HotPixelMode)) {
 		bool valid;
 		switch (metadata.get(controls::draft::HotPixelMode)) {
diff --git a/src/android/camera_request.h b/src/android/camera_request.h
index 69b6c8fc..1e53ceb0 100644
--- a/src/android/camera_request.h
+++ b/src/android/camera_request.h
@@ -90,6 +90,7 @@  public:
 	/* The android edge mode associated with this request */
 	/* \todo Wrap all such controls? */
 	int32_t edgeMode_;
+	uint8_t blackLevelLock_;
 
 private:
 	LIBCAMERA_DISABLE_COPY(Camera3RequestDescriptor)