[PATCH] ipa: rpi: Add tuning files for OV7251
Kieran Bingham
kieran.bingham at ideasonboard.com
Sat Oct 19 23:43:59 CEST 2024
Quoting Kieran Bingham (2024-10-10 14:41:48)
> From: Dave Stevenson <dave.stevenson at raspberrypi.com>
>
> OV7251 is a mono VGA global shutter sensor that has a mainline
> driver and works with libcamera.
> Add the supporting files for it. The tuning is copied from OV9281.
>
> Signed-off-by: Dave Stevenson <dave.stevenson at raspberrypi.com>
> Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
Naush / David, Are you happy for this to be merged ?
--
Kieran
> ---
> src/ipa/rpi/cam_helper/cam_helper_ov7251.cpp | 66 +++++++++
> src/ipa/rpi/cam_helper/meson.build | 1 +
> src/ipa/rpi/vc4/data/meson.build | 1 +
> src/ipa/rpi/vc4/data/ov7251_mono.json | 136 +++++++++++++++++++
> 4 files changed, 204 insertions(+)
> create mode 100644 src/ipa/rpi/cam_helper/cam_helper_ov7251.cpp
> create mode 100644 src/ipa/rpi/vc4/data/ov7251_mono.json
>
> diff --git a/src/ipa/rpi/cam_helper/cam_helper_ov7251.cpp b/src/ipa/rpi/cam_helper/cam_helper_ov7251.cpp
> new file mode 100644
> index 000000000000..7b12c44508a4
> --- /dev/null
> +++ b/src/ipa/rpi/cam_helper/cam_helper_ov7251.cpp
> @@ -0,0 +1,66 @@
> +/* SPDX-License-Identifier: BSD-2-Clause */
> +/*
> + * Copyright (C) 2021, Raspberry Pi Ltd
> + *
> + * camera information for ov7251 sensor
> + */
> +
> +#include <assert.h>
> +
> +#include "cam_helper.h"
> +
> +using namespace RPiController;
> +
> +class CamHelperOv7251 : public CamHelper
> +{
> +public:
> + CamHelperOv7251();
> + uint32_t gainCode(double gain) const override;
> + double gain(uint32_t gainCode) const override;
> + void getDelays(int &exposureDelay, int &gainDelay,
> + int &vblankDelay, int &hblankDelay) const override;
> +
> +private:
> + /*
> + * Smallest difference between the frame length and integration time,
> + * in units of lines.
> + */
> + static constexpr int frameIntegrationDiff = 4;
> +};
> +
> +/*
> + * OV7251 doesn't output metadata, so we have to use the "unicam parser" which
> + * works by counting frames.
> + */
> +
> +CamHelperOv7251::CamHelperOv7251()
> + : CamHelper({}, frameIntegrationDiff)
> +{
> +}
> +
> +uint32_t CamHelperOv7251::gainCode(double gain) const
> +{
> + return static_cast<uint32_t>(gain * 16.0);
> +}
> +
> +double CamHelperOv7251::gain(uint32_t gainCode) const
> +{
> + return static_cast<double>(gainCode) / 16.0;
> +}
> +
> +void CamHelperOv7251::getDelays(int &exposureDelay, int &gainDelay,
> + int &vblankDelay, int &hblankDelay) const
> +{
> + /* The driver appears to behave as follows: */
> + exposureDelay = 2;
> + gainDelay = 2;
> + vblankDelay = 2;
> + hblankDelay = 2;
> +}
> +
> +static CamHelper *create()
> +{
> + return new CamHelperOv7251();
> +}
> +
> +static RegisterCamHelper reg("ov7251", &create);
> diff --git a/src/ipa/rpi/cam_helper/meson.build b/src/ipa/rpi/cam_helper/meson.build
> index 1e43f1da29cd..03e88fe082e2 100644
> --- a/src/ipa/rpi/cam_helper/meson.build
> +++ b/src/ipa/rpi/cam_helper/meson.build
> @@ -11,6 +11,7 @@ rpi_ipa_cam_helper_sources = files([
> 'cam_helper_imx519.cpp',
> 'cam_helper_imx708.cpp',
> 'cam_helper_ov64a40.cpp',
> + 'cam_helper_ov7251.cpp',
> 'cam_helper_ov9281.cpp',
> 'md_parser_smia.cpp',
> ])
> diff --git a/src/ipa/rpi/vc4/data/meson.build b/src/ipa/rpi/vc4/data/meson.build
> index 60477c112196..8c34a1a5faa2 100644
> --- a/src/ipa/rpi/vc4/data/meson.build
> +++ b/src/ipa/rpi/vc4/data/meson.build
> @@ -19,6 +19,7 @@ conf_files = files([
> 'ov5647.json',
> 'ov5647_noir.json',
> 'ov64a40.json',
> + 'ov7251_mono.json',
> 'ov9281_mono.json',
> 'se327m12.json',
> 'uncalibrated.json',
> diff --git a/src/ipa/rpi/vc4/data/ov7251_mono.json b/src/ipa/rpi/vc4/data/ov7251_mono.json
> new file mode 100644
> index 000000000000..a9d05a01b53f
> --- /dev/null
> +++ b/src/ipa/rpi/vc4/data/ov7251_mono.json
> @@ -0,0 +1,136 @@
> +{
> + "version": 2.0,
> + "target": "bcm2835",
> + "algorithms": [
> + {
> + "rpi.black_level":
> + {
> + "black_level": 4096
> + }
> + },
> + {
> + "rpi.lux":
> + {
> + "reference_shutter_speed": 2000,
> + "reference_gain": 1.0,
> + "reference_aperture": 1.0,
> + "reference_lux": 800,
> + "reference_Y": 20000
> + }
> + },
> + {
> + "rpi.noise":
> + {
> + "reference_constant": 0,
> + "reference_slope": 2.5
> + }
> + },
> + {
> + "rpi.sdn": { }
> + },
> + {
> + "rpi.agc":
> + {
> + "metering_modes":
> + {
> + "centre-weighted":
> + {
> + "weights":
> + [
> + 4, 4, 4, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0
> + ]
> + }
> + },
> + "exposure_modes":
> + {
> + "normal":
> + {
> + "shutter": [ 100, 15000, 30000, 60000, 120000 ],
> + "gain": [ 1.0, 2.0, 3.0, 4.0, 8.0 ]
> + },
> + "short":
> + {
> + "shutter": [ 100, 5000, 10000, 20000, 30000 ],
> + "gain": [ 1.0, 2.0, 4.0, 6.0, 8.0 ]
> + },
> + "long":
> + {
> + "shutter": [ 1000, 30000, 60000, 90000, 120000 ],
> + "gain": [ 1.0, 2.0, 4.0, 6.0, 12.0 ]
> + }
> + },
> + "constraint_modes":
> + {
> + "normal": [
> + {
> + "bound": "LOWER",
> + "q_lo": 0.98,
> + "q_hi": 1.0,
> + "y_target":
> + [
> + 0, 0.4,
> + 1000, 0.4
> + ]
> + }
> + ]
> + },
> + "y_target":
> + [
> + 0, 0.16,
> + 1000, 0.165,
> + 10000, 0.17
> + ]
> + }
> + },
> + {
> + "rpi.alsc":
> + {
> + "n_iter": 0,
> + "luminance_strength": 1.0,
> + "corner_strength": 1.5
> + }
> + },
> + {
> + "rpi.contrast":
> + {
> + "ce_enable": 0,
> + "gamma_curve":
> + [
> + 0, 0,
> + 1024, 5040,
> + 2048, 9338,
> + 3072, 12356,
> + 4096, 15312,
> + 5120, 18051,
> + 6144, 20790,
> + 7168, 23193,
> + 8192, 25744,
> + 9216, 27942,
> + 10240, 30035,
> + 11264, 32005,
> + 12288, 33975,
> + 13312, 35815,
> + 14336, 37600,
> + 15360, 39168,
> + 16384, 40642,
> + 18432, 43379,
> + 20480, 45749,
> + 22528, 47753,
> + 24576, 49621,
> + 26624, 51253,
> + 28672, 52698,
> + 30720, 53796,
> + 32768, 54876,
> + 36864, 57012,
> + 40960, 58656,
> + 45056, 59954,
> + 49152, 61183,
> + 53248, 62355,
> + 57344, 63419,
> + 61440, 64476,
> + 65535, 65535
> + ]
> + }
> + }
> + ]
> +}
> \ No newline at end of file
> --
> 2.34.1
>
More information about the libcamera-devel
mailing list