[libcamera-devel,v3,4/7] libcamera: SensorDatabase: Adds table of v4l2 name and test pattern
diff mbox series

Message ID 20210428073617.373422-5-hiroh@chromium.org
State Superseded
Headers show
Series
  • Report Android HAL client test pattern modes
Related show

Commit Message

Hirokazu Honda April 28, 2021, 7:36 a.m. UTC
In V4L2 API, a driver returns a name to represent a test pattern,
but it is a driver specific what test pattern is represented by
the name. Therefore, this adds a mapping table from the name to
a test pattern into a static configuration of a sensor.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
---
 include/libcamera/internal/sensor_database.h |  2 +
 src/libcamera/sensor_database.cpp            | 39 ++++++++++++++++----
 2 files changed, 34 insertions(+), 7 deletions(-)

Patch
diff mbox series

diff --git a/include/libcamera/internal/sensor_database.h b/include/libcamera/internal/sensor_database.h
index 7d743e46..04a5783c 100644
--- a/include/libcamera/internal/sensor_database.h
+++ b/include/libcamera/internal/sensor_database.h
@@ -7,6 +7,7 @@ 
 #ifndef __LIBCAMERA_SENSOR_DATABASE_H__
 #define __LIBCAMERA_SENSOR_DATABASE_H__
 
+#include <map>
 #include <string>
 
 #include <libcamera/geometry.h>
@@ -15,6 +16,7 @@  namespace libcamera {
 
 struct SensorInfo {
 	Size unitCellSize;
+	std::map<std::string, int32_t> testPatternModeMap;
 };
 
 class SensorDatabase
diff --git a/src/libcamera/sensor_database.cpp b/src/libcamera/sensor_database.cpp
index 68e69e8b..a4d4f686 100644
--- a/src/libcamera/sensor_database.cpp
+++ b/src/libcamera/sensor_database.cpp
@@ -9,6 +9,8 @@ 
 
 #include <algorithm>
 
+#include "libcamera/control_ids.h"
+
 namespace libcamera {
 
 /**
@@ -43,25 +45,48 @@  namespace libcamera {
 
 namespace {
 
+const std::map<std::string, int32_t> imx219TestPatternModeMap = {
+	{ "Disabled", controls::draft::TestPatternModeOff },
+	{ "Color Bars", controls::draft::TestPatternModeColorBars },
+	{ "Solid Color", controls::draft::TestPatternModeSolidColor },
+	{ "Grey Color Bars", controls::draft::TestPatternModeColorBarsFadeToGray },
+	{ "PN9", controls::draft::TestPatternModePn9 },
+};
+
+const std::map<std::string, int32_t> ov5670TestPatternModeMap = {
+	{ "Disabled", controls::draft::TestPatternModeOff },
+	{ "Vertical Color Bar Type 1", controls::draft::TestPatternModeColorBars },
+};
+
+const std::map<std::string, int32_t> ov13858TestPatternModeMap = {
+	{ "Disabled", controls::draft::TestPatternModeOff },
+	{ "Vertical Color Bar Type 1", controls::draft::TestPatternModeColorBars },
+	{ "Vertical Color Bar Type 2", controls::draft::TestPatternModeColorBarsFadeToGray },
+};
+
 /**
  * \brief Sony IMX219 sensor properties
  */
-constexpr SensorInfo imx219Info = {
-	.unitCellSize = { 1120, 1120 }
+const SensorInfo imx219Info = {
+	.unitCellSize = { 1120, 1120 },
+	.testPatternModeMap = imx219TestPatternModeMap,
 };
 
 /**
  * \brief Omnivision ov5670 sensor properties
  */
-constexpr SensorInfo ov5670Info = {
-	.unitCellSize = { 1120, 1120 }
+const SensorInfo ov5670Info = {
+	.unitCellSize = { 1120, 1120 },
+	.testPatternModeMap = ov5670TestPatternModeMap,
 };
 
 /**
  * \brief Omnivision 13858 sensor properties
  */
-constexpr SensorInfo ov13858Info = {
-	.unitCellSize = { 1120, 1120 }
+const SensorInfo ov13858Info = {
+	.unitCellSize = { 1120, 1120 },
+	.testPatternModeMap = ov13858TestPatternModeMap,
+
 };
 
 #define SENSOR_INFO(_sensor) \
@@ -70,7 +95,7 @@  constexpr SensorInfo ov13858Info = {
 /*
  * \brief The database of sensor properties
  */
-constexpr std::pair<const char *const, const SensorInfo *> sensorDatabase__[] = {
+const std::pair<const char *const, const SensorInfo *> sensorDatabase__[] = {
 	SENSOR_INFO(imx219),
 	SENSOR_INFO(ov5670),
 	SENSOR_INFO(ov13858),