[libcamera-devel,RFC,v2,3/5] libcamera: SensorDatabase: Adds table of v4l2 name and test pattern
diff mbox series

Message ID 20210413075013.3069213-4-hiroh@chromium.org
State Superseded
Headers show
Series
  • Report available test pattern modes
Related show

Commit Message

Hirokazu Honda April 13, 2021, 7:50 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            | 37 ++++++++++++++++++--
 2 files changed, 36 insertions(+), 3 deletions(-)

Patch
diff mbox series

diff --git a/include/libcamera/internal/sensor_database.h b/include/libcamera/internal/sensor_database.h
index 7d743e46..c0b181f8 100644
--- a/include/libcamera/internal/sensor_database.h
+++ b/include/libcamera/internal/sensor_database.h
@@ -10,11 +10,13 @@ 
 #include <string>
 
 #include <libcamera/geometry.h>
+#include <libcamera/span.h>
 
 namespace libcamera {
 
 struct SensorInfo {
 	Size unitCellSize;
+	Span<const std::pair<const char *, int32_t>> testPatternModeMap;
 };
 
 class SensorDatabase
diff --git a/src/libcamera/sensor_database.cpp b/src/libcamera/sensor_database.cpp
index 68e69e8b..a71e8958 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,54 @@  namespace libcamera {
 
 namespace {
 
+constexpr std::pair<const char *, int32_t> imx219TestPatternModeMap[] = {
+	{ "Disabled", controls::draft::SensorTestPatternModeOff },
+	{ "Color Bars", controls::draft::SensorTestPatternModeColorBars },
+	{ "Solid Color", controls::draft::SensorTestPatternModeSolidColor },
+	{ "Grey Color Bars", controls::draft::SensorTestPatternModeColorBarsFadeToGray },
+	{ "PN9", controls::draft::SensorTestPatternModePn9 },
+};
+
+constexpr std::pair<const char *, int32_t> ov5670TestPatternModeMap[] = {
+	{ "Disabled", controls::draft::SensorTestPatternModeOff },
+	{ "Vertical Color Bar Type 1", controls::draft::SensorTestPatternModeColorBars },
+};
+
+constexpr std::pair<const char *, int32_t> ov13858TestPatternModeMap[] = {
+	{ "Disabled", controls::draft::SensorTestPatternModeOff },
+	{ "Vertical Color Bar Type 1", controls::draft::SensorTestPatternModeColorBars },
+	{ "Vertical Color Bar Type 2", controls::draft::SensorTestPatternModeColorBarsFadeToGray },
+};
+
 /**
  * \brief Sony IMX219 sensor properties
  */
 constexpr SensorInfo imx219Info = {
-	.unitCellSize = { 1120, 1120 }
+	.unitCellSize = { 1120, 1120 },
+	.testPatternModeMap =
+		libcamera::Span<const std::pair<const char *, int32_t>>(
+			imx219TestPatternModeMap),
 };
 
 /**
  * \brief Omnivision ov5670 sensor properties
  */
 constexpr SensorInfo ov5670Info = {
-	.unitCellSize = { 1120, 1120 }
+	.unitCellSize = { 1120, 1120 },
+	.testPatternModeMap =
+		libcamera::Span<const std::pair<const char *, int32_t>>(
+			ov5670TestPatternModeMap),
 };
 
 /**
  * \brief Omnivision 13858 sensor properties
  */
 constexpr SensorInfo ov13858Info = {
-	.unitCellSize = { 1120, 1120 }
+	.unitCellSize = { 1120, 1120 },
+	.testPatternModeMap =
+		libcamera::Span<const std::pair<const char *, int32_t>>(
+			ov13858TestPatternModeMap),
+
 };
 
 #define SENSOR_INFO(_sensor) \