[libcamera-devel] [PATCH v4 3/6] libcamera: CameraSensorProperties: Adds table of v4l2 index and test pattern

Hirokazu Honda hiroh at chromium.org
Thu May 6 09:54:46 CEST 2021


In V4L2 API, a driver returns an index (also with a name) to
represent a test pattern, but it is a driver specific what test
pattern is represented by the index. Therefore, this adds a
mapping table from the index and a test pattern into a static
configuration of a sensor.

Signed-off-by: Hirokazu Honda <hiroh at chromium.org>
---
 .../internal/camera_sensor_properties.h       |  2 ++
 src/libcamera/camera_sensor_properties.cpp    | 20 +++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/include/libcamera/internal/camera_sensor_properties.h b/include/libcamera/internal/camera_sensor_properties.h
index f5e242cb..f52890b4 100644
--- a/include/libcamera/internal/camera_sensor_properties.h
+++ b/include/libcamera/internal/camera_sensor_properties.h
@@ -7,6 +7,7 @@
 #ifndef __LIBCAMERA_SENSOR_CAMERA_SENSOR_PROPERTIES_H__
 #define __LIBCAMERA_SENSOR_CAMERA_SENSOR_PROPERTIES_H__
 
+#include <map>
 #include <string>
 
 #include <libcamera/geometry.h>
@@ -17,6 +18,7 @@ struct CameraSensorProperties {
 	static const CameraSensorProperties *get(const std::string &sensor);
 
 	Size unitCellSize;
+	std::map<int32_t, int32_t> testPatternModeMap;
 };
 
 } /* namespace libcamera */
diff --git a/src/libcamera/camera_sensor_properties.cpp b/src/libcamera/camera_sensor_properties.cpp
index 6ded31dc..89eaf9f8 100644
--- a/src/libcamera/camera_sensor_properties.cpp
+++ b/src/libcamera/camera_sensor_properties.cpp
@@ -9,6 +9,8 @@
 
 #include <map>
 
+#include <libcamera/control_ids.h>
+
 #include "libcamera/internal/log.h"
 
 /**
@@ -44,15 +46,33 @@ LOG_DEFINE_CATEGORY(CameraSensorProperties)
  */
 const CameraSensorProperties *CameraSensorProperties::get(const std::string &sensor)
 {
+
 	static const std::map<std::string, const CameraSensorProperties> sensorProps = {
 		{ "imx219", {
 			.unitCellSize = { 1120, 1120 },
+			.testPatternModeMap = {
+				{ 0, controls::draft::TestPatternModeOff },
+				{ 1, controls::draft::TestPatternModeColorBars },
+				{ 2, controls::draft::TestPatternModeSolidColor },
+				{ 3, controls::draft::TestPatternModeColorBarsFadeToGray },
+				{ 4, controls::draft::TestPatternModePn9 },
+			},
 		} },
 		{ "ov5670", {
 			.unitCellSize = { 1120, 1120 },
+			.testPatternModeMap = {
+				{ 0, controls::draft::TestPatternModeOff },
+				{ 1, controls::draft::TestPatternModeColorBars },
+			},
+
 		} },
 		{ "ov13858", {
 			.unitCellSize = { 1120, 1120 },
+			.testPatternModeMap =  {
+				{ 0, controls::draft::TestPatternModeOff },
+				{ 1, controls::draft::TestPatternModeColorBars },
+				{ 2, controls::draft::TestPatternModeColorBarsFadeToGray },
+			},
 		} },
 	};
 
-- 
2.31.1.607.g51e8a6a459-goog



More information about the libcamera-devel mailing list