libcamera: CameraSensorProperties: Add table of v4l2 index and test pattern

The V4L2 specification defines the sensor test pattern modes
through a menu control, where a numerical index is associated to
a string that describes the test pattern. The index-to-pattern
mapping is driver specific and requires a corresponding representation
in the library.

Add to the static list of CameraSensorProperties a map of indexes to
libcamera::controls::TestPatternModes values to be able to map the
indexes returned by the driver to the corresponding test pattern mode.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
Hirokazu Honda 2021-06-10 17:25:36 +09:00 committed by Jacopo Mondi
parent c520531884
commit 0b312cb4ac
2 changed files with 35 additions and 0 deletions

View file

@ -7,6 +7,7 @@
#ifndef __LIBCAMERA_SENSOR_CAMERA_SENSOR_PROPERTIES_H__ #ifndef __LIBCAMERA_SENSOR_CAMERA_SENSOR_PROPERTIES_H__
#define __LIBCAMERA_SENSOR_CAMERA_SENSOR_PROPERTIES_H__ #define __LIBCAMERA_SENSOR_CAMERA_SENSOR_PROPERTIES_H__
#include <map>
#include <string> #include <string>
#include <libcamera/geometry.h> #include <libcamera/geometry.h>
@ -17,6 +18,7 @@ struct CameraSensorProperties {
static const CameraSensorProperties *get(const std::string &sensor); static const CameraSensorProperties *get(const std::string &sensor);
Size unitCellSize; Size unitCellSize;
std::map<int32_t, int32_t> testPatternModes;
}; };
} /* namespace libcamera */ } /* namespace libcamera */

View file

@ -9,6 +9,8 @@
#include <map> #include <map>
#include <libcamera/control_ids.h>
#include "libcamera/internal/log.h" #include "libcamera/internal/log.h"
/** /**
@ -34,6 +36,11 @@ LOG_DEFINE_CATEGORY(CameraSensorProperties)
* *
* \var CameraSensorProperties::unitCellSize * \var CameraSensorProperties::unitCellSize
* \brief The physical size of a pixel, including pixel edges, in nanometers. * \brief The physical size of a pixel, including pixel edges, in nanometers.
*
* \var CameraSensorProperties::testPatternModes
* \brief Map that associates the indexes of the sensor test pattern modes as
* returned by V4L2_CID_TEST_PATTERN with the corresponding TestPattern
* control value
*/ */
/** /**
@ -47,18 +54,44 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen
static const std::map<std::string, const CameraSensorProperties> sensorProps = { static const std::map<std::string, const CameraSensorProperties> sensorProps = {
{ "imx219", { { "imx219", {
.unitCellSize = { 1120, 1120 }, .unitCellSize = { 1120, 1120 },
.testPatternModes = {
{ 0, controls::draft::TestPatternModeOff },
{ 1, controls::draft::TestPatternModeColorBars },
{ 2, controls::draft::TestPatternModeSolidColor },
{ 3, controls::draft::TestPatternModeColorBarsFadeToGray },
{ 4, controls::draft::TestPatternModePn9 },
},
} }, } },
{ "imx258", { { "imx258", {
.unitCellSize = { 1120, 1120 }, .unitCellSize = { 1120, 1120 },
/* \todo fill test pattern modes for imx258. */
.testPatternModes = {},
} }, } },
{ "ov5670", { { "ov5670", {
.unitCellSize = { 1120, 1120 }, .unitCellSize = { 1120, 1120 },
.testPatternModes = {
{ 0, controls::draft::TestPatternModeOff },
{ 1, controls::draft::TestPatternModeColorBars },
},
} }, } },
{ "ov13858", { { "ov13858", {
.unitCellSize = { 1120, 1120 }, .unitCellSize = { 1120, 1120 },
.testPatternModes = {
{ 0, controls::draft::TestPatternModeOff },
{ 1, controls::draft::TestPatternModeColorBars },
},
} }, } },
{ "ov5693", { { "ov5693", {
.unitCellSize = { 1400, 1400 }, .unitCellSize = { 1400, 1400 },
.testPatternModes = {
{ 0, controls::draft::TestPatternModeOff },
{ 2, controls::draft::TestPatternModeColorBars },
/*
* No corresponding test pattern mode for
* 1: "Random data" and 3: "Colour Bars with
* Rolling Bar".
*/
},
} }, } },
}; };