libcamera v0.0.0+1-ab0bf965
Supporting cameras in Linux since 2019
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#ifndef __LIBCAMERA_IPA_LIBIPA_CAMERA_SENSOR_HELPER_H__
8#define __LIBCAMERA_IPA_LIBIPA_CAMERA_SENSOR_HELPER_H__
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
39 int16_t m0;
40 int16_t c0;
41 int16_t m1;
42 int16_t c1;
43 };
44
46
47private:
49};
50
52{
53public:
54 CameraSensorHelperFactory(const std::string name);
55 virtual ~CameraSensorHelperFactory() = default;
56
57 static std::unique_ptr<CameraSensorHelper> create(const std::string &name);
58
59 static void registerType(CameraSensorHelperFactory *factory);
60 static std::vector<CameraSensorHelperFactory *> &factories();
61
62protected:
64
65private:
67
68 std::string name_;
69};
70
71#define REGISTER_CAMERA_SENSOR_HELPER(name, helper) \
72class helper##Factory final : public CameraSensorHelperFactory \
73{ \
74public: \
75 helper##Factory() : CameraSensorHelperFactory(name) {} \
76 \
77private: \
78 CameraSensorHelper *createInstance() \
79 { \
80 return new helper(); \
81 } \
82}; \
83static helper##Factory global_##helper##Factory;
84
85} /* namespace ipa */
86
87} /* namespace libcamera */
88
89#endif /* __LIBCAMERA_IPA_LIBIPA_CAMERA_SENSOR_HELPER_H__ */
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:52
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:208
CameraSensorHelperFactory(const std::string name)
Construct a camera sensor helper factory.
Definition: camera_sensor_helper.cpp:193
static std::vector< CameraSensorHelperFactory * > & factories()
Retrieve the list of all camera sensor helper factories.
Definition: camera_sensor_helper.cpp:243
static void registerType(CameraSensorHelperFactory *factory)
Add a camera sensor helper class to the registry.
Definition: camera_sensor_helper.cpp:231
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
AnalogueGainConstants analogueGainConstants_
The analogue gain parameters used for calculation.
Definition: camera_sensor_helper.h:45
virtual uint32_t gainCode(double gain) const
Construct a CameraSensorHelper instance.
Definition: camera_sensor_helper.cpp:59
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 computed using exponential gain estimation (introduced in CCS v1.1)
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:81
Top-level libcamera namespace.
Definition: bound_method.h:15
Analogue gain constants used for gain calculation.
Definition: camera_sensor_helper.h:37
AnalogueGainType type
Analogue gain calculation mode.
Definition: camera_sensor_helper.h:38
int16_t c0
Constant used in the analogue gain coding/decoding.
Definition: camera_sensor_helper.h:40
int16_t c1
Constant used in the analogue gain coding/decoding.
Definition: camera_sensor_helper.h:42
int16_t m1
Constant used in the analogue gain coding/decoding.
Definition: camera_sensor_helper.h:41
int16_t m0
Constant used in the analogue Gain coding/decoding.
Definition: camera_sensor_helper.h:39