libcamera v0.0.0
Supporting cameras in Linux since 2019
Loading...
Searching...
No Matches
camera_sensor_helper.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2/*
3 * Copyright (C) 2021, Google Inc.
4 *
5 * camera_sensor_helper.h - Helper class that performs sensor-specific parameter computations
6 */
7
8#pragma once
9
10#include <stdint.h>
11
12#include <memory>
13#include <string>
14#include <vector>
15
17
18namespace libcamera {
19
20namespace ipa {
21
23{
24public:
25 CameraSensorHelper() = default;
26 virtual ~CameraSensorHelper() = default;
27
28 virtual uint32_t gainCode(double gain) const;
29 virtual double gain(uint32_t gainCode) const;
30
31protected:
35 };
36
38 int16_t m0;
39 int16_t c0;
40 int16_t m1;
41 int16_t c1;
42 };
43
45 double a;
46 double m;
47 };
48
52 };
53
56
57private:
59};
60
62{
63public:
64 CameraSensorHelperFactory(const std::string name);
65 virtual ~CameraSensorHelperFactory() = default;
66
67 static std::unique_ptr<CameraSensorHelper> create(const std::string &name);
68
69 static void registerType(CameraSensorHelperFactory *factory);
70 static std::vector<CameraSensorHelperFactory *> &factories();
71
72protected:
74
75private:
77
78 std::string name_;
79};
80
81#define REGISTER_CAMERA_SENSOR_HELPER(name, helper) \
82class helper##Factory final : public CameraSensorHelperFactory \
83{ \
84public: \
85 helper##Factory() : CameraSensorHelperFactory(name) {} \
86 \
87private: \
88 CameraSensorHelper *createInstance() \
89 { \
90 return new helper(); \
91 } \
92}; \
93static helper##Factory global_##helper##Factory;
94
95} /* namespace ipa */
96
97} /* namespace libcamera */
Utilities to help constructing class interfaces.
#define LIBCAMERA_DISABLE_COPY_AND_MOVE(klass)
Disable copy and move construction and assignment of the klass.
Registration of CameraSensorHelperFactory classes and creation of instances.
Definition: camera_sensor_helper.h:62
static std::unique_ptr< CameraSensorHelper > create(const std::string &name)
Create an instance of the CameraSensorHelper corresponding to a named factory.
Definition: camera_sensor_helper.cpp:255
static std::vector< CameraSensorHelperFactory * > & factories()
Retrieve the list of all camera sensor helper factories.
Definition: camera_sensor_helper.cpp:290
static void registerType(CameraSensorHelperFactory *factory)
Add a camera sensor helper class to the registry.
Definition: camera_sensor_helper.cpp:278
virtual CameraSensorHelper * createInstance()=0
Create an instance of the CameraSensorHelper corresponding to the factory.
Base class for computing sensor tuning parameters using sensor-specific constants.
Definition: camera_sensor_helper.h:23
virtual uint32_t gainCode(double gain) const
Construct a CameraSensorHelper instance.
Definition: camera_sensor_helper.cpp:58
AnalogueGainType
The gain calculation modes as defined by the MIPI CCS.
Definition: camera_sensor_helper.h:32
@ AnalogueGainLinear
Gain is computed using linear gain estimation.
Definition: camera_sensor_helper.h:33
@ AnalogueGainExponential
Gain is expressed using an exponential model.
Definition: camera_sensor_helper.h:34
virtual double gain(uint32_t gainCode) const
Compute the real gain from the V4L2 subdev control gain code.
Definition: camera_sensor_helper.cpp:90
AnalogueGainType gainType_
The analogue gain model type.
Definition: camera_sensor_helper.h:54
AnalogueGainConstants gainConstants_
The analogue gain parameters used for calculation.
Definition: camera_sensor_helper.h:55
Top-level libcamera namespace.
Definition: backtrace.h:17
Analogue gain constants for the exponential gain model.
Definition: camera_sensor_helper.h:44
double m
Constant used in the exponential gain coding/decoding.
Definition: camera_sensor_helper.h:46
double a
Constant used in the exponential gain coding/decoding.
Definition: camera_sensor_helper.h:45
Analogue gain constants for the linear gain model.
Definition: camera_sensor_helper.h:37
int16_t m0
Constant used in the linear gain coding/decoding.
Definition: camera_sensor_helper.h:38
int16_t c1
Constant used in the linear gain coding/decoding.
Definition: camera_sensor_helper.h:41
int16_t m1
Constant used in the linear gain coding/decoding.
Definition: camera_sensor_helper.h:40
int16_t c0
Constant used in the linear gain coding/decoding.
Definition: camera_sensor_helper.h:39
Analogue gain model constants.
Definition: camera_sensor_helper.h:49
AnalogueGainExpConstants exp
Constants for the exponential gain model.
Definition: camera_sensor_helper.h:51
AnalogueGainLinearConstants linear
Constants for the linear gain model.
Definition: camera_sensor_helper.h:50