summaryrefslogtreecommitdiff
path: root/include/android
diff options
context:
space:
mode:
Diffstat (limited to 'include/android')
0 files changed, 0 insertions, 0 deletions
' href='#n60'>60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2021, Google Inc.
 *
 * Helper class that performs sensor-specific parameter computations
 */

#pragma once

#include <stdint.h>

#include <memory>
#include <optional>
#include <string>
#include <vector>

#include <libcamera/base/class.h>

namespace libcamera {

namespace ipa {

class CameraSensorHelper
{
public:
	CameraSensorHelper() = default;
	virtual ~CameraSensorHelper() = default;

	std::optional<int16_t> blackLevel() const { return blackLevel_; }
	virtual uint32_t gainCode(double gain) const;
	virtual double gain(uint32_t gainCode) const;

protected:
	enum AnalogueGainType {
		AnalogueGainLinear,
		AnalogueGainExponential,
	};

	struct AnalogueGainLinearConstants {
		int16_t m0;
		int16_t c0;
		int16_t m1;
		int16_t c1;
	};

	struct AnalogueGainExpConstants {
		double a;
		double m;
	};

	union AnalogueGainConstants {
		AnalogueGainLinearConstants linear;
		AnalogueGainExpConstants exp;
	};

	std::optional<int16_t> blackLevel_;
	AnalogueGainType gainType_;
	AnalogueGainConstants gainConstants_;

private:
	LIBCAMERA_DISABLE_COPY_AND_MOVE(CameraSensorHelper)
};

class CameraSensorHelperFactoryBase
{
public:
	CameraSensorHelperFactoryBase(const std::string name);
	virtual ~CameraSensorHelperFactoryBase() = default;

	static std::unique_ptr<CameraSensorHelper> create(const std::string &name);

	static std::vector<CameraSensorHelperFactoryBase *> &factories();

private:
	LIBCAMERA_DISABLE_COPY_AND_MOVE(CameraSensorHelperFactoryBase)

	static void registerType(CameraSensorHelperFactoryBase *factory);

	virtual std::unique_ptr<CameraSensorHelper> createInstance() const = 0;

	std::string name_;
};

template<typename _Helper>