[libcamera-devel,RFC,5/5] android: CameraDevice: Report queried test pattern modes
diff mbox series

Message ID 20210409043208.1823330-6-hiroh@chromium.org
State RFC
Headers show
Series
  • Report available test pattern modes
Related show

Commit Message

Hirokazu Honda April 9, 2021, 4:32 a.m. UTC
Report test pattern modes obtained by Camera::controls().

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
---
 src/android/camera_device.cpp | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

Patch
diff mbox series

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 89044efa..8701cc69 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -1075,12 +1075,22 @@  const camera_metadata_t *CameraDevice::getStaticMetadata()
 
 	staticMetadata_->addEntry(ANDROID_SENSOR_ORIENTATION, &orientation_, 1);
 
-	std::vector<int32_t> testPatterModes = {
-		ANDROID_SENSOR_TEST_PATTERN_MODE_OFF,
+	const auto &sensorTestPatternsInfo =
+		controlsInfo.find(&controls::draft::SensorTestPatternMode);
+	std::vector<int32_t> testPatternModes = {
+		ANDROID_SENSOR_TEST_PATTERN_MODE_OFF
 	};
+	if (sensorTestPatternsInfo != controlsInfo.end()) {
+		const auto &values = sensorTestPatternsInfo->second.values();
+		if (!values.empty()) {
+			testPatternModes.clear();
+			for (const auto &value : values)
+				testPatternModes.push_back(value.get<int32_t>());
+		}
+	}
 	staticMetadata_->addEntry(ANDROID_SENSOR_AVAILABLE_TEST_PATTERN_MODES,
-				  testPatterModes.data(),
-				  testPatterModes.size());
+				  testPatternModes.data(),
+				  testPatternModes.size());
 
 	std::vector<float> physicalSize = {
 		2592, 1944,