[libcamera-devel] [PATCH v2 4/7] libcamera: SensorDatabase: Adds table of v4l2 name and test pattern

Laurent Pinchart laurent.pinchart at ideasonboard.com
Tue Apr 27 05:59:26 CEST 2021


Hi Hiro,

Thank you for the patch.

On Wed, Apr 21, 2021 at 01:23:43PM +0900, Hirokazu Honda wrote:
> 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 at chromium.org>
> ---
>  include/libcamera/internal/sensor_database.h |  2 ++
>  src/libcamera/sensor_database.cpp            | 37 ++++++++++++++++++--
>  2 files changed, 36 insertions(+), 3 deletions(-)
> 
> 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..da469b67 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::TestPatternModeOff },
> +	{ "Color Bars", controls::draft::TestPatternModeColorBars },
> +	{ "Solid Color", controls::draft::TestPatternModeSolidColor },
> +	{ "Grey Color Bars", controls::draft::TestPatternModeColorBarsFadeToGray },
> +	{ "PN9", controls::draft::TestPatternModePn9 },
> +};

You can make those maps. I know they can't be constexpr, and they will
be global variables of non-trivial types, but for this kind of use case
I really don't see a real problem.

> +
> +constexpr std::pair<const char *, int32_t> ov5670TestPatternModeMap[] = {
> +	{ "Disabled", controls::draft::TestPatternModeOff },
> +	{ "Vertical Color Bar Type 1", controls::draft::TestPatternModeColorBars },
> +};
> +
> +constexpr std::pair<const char *, 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 }
> +	.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) \

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list