From 9cacf4e42086abe57b3998a0d909b49b97a1a7a5 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 1 Jul 2024 18:26:32 +0300 Subject: ipa: rkisp1: Add ISP parameters abstraction class Individual algorithms of the rkisp1 IPA module access their corresponding ISP parameters through the top-level structure rkisp1_params_cfg. This will not work anymore with the new parameters format. In order to ease the transition to the new format, abstract the ISP parameters in a new RkISP1Params class that offers the same interface regardless of the format. Signed-off-by: Laurent Pinchart Reviewed-by: Paul Elder Reviewed-by: Stefan Klug --- src/ipa/rkisp1/params.h | 157 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 src/ipa/rkisp1/params.h (limited to 'src/ipa/rkisp1/params.h') diff --git a/src/ipa/rkisp1/params.h b/src/ipa/rkisp1/params.h new file mode 100644 index 00000000..28a781bc --- /dev/null +++ b/src/ipa/rkisp1/params.h @@ -0,0 +1,157 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2024, Ideas On Board + * + * RkISP1 ISP Parameters + */ + +#pragma once + +#include +#include + +#include + +#include +#include + +namespace libcamera { + +namespace ipa::rkisp1 { + +enum class BlockType { + Bls, + Dpcc, + Sdg, + AwbGain, + Flt, + Bdm, + Ctk, + Goc, + Dpf, + DpfStrength, + Cproc, + Ie, + Lsc, + Awb, + Hst, + Aec, + Afc, +}; + +namespace details { + +template +struct block_type { +}; + +#define RKISP1_DEFINE_BLOCK_TYPE(blockType, blockStruct) \ +template<> \ +struct block_type { \ + using type = struct rkisp1_cif_isp_##blockStruct##_config; \ +}; + +RKISP1_DEFINE_BLOCK_TYPE(Bls, bls) +RKISP1_DEFINE_BLOCK_TYPE(Dpcc, dpcc) +RKISP1_DEFINE_BLOCK_TYPE(Sdg, sdg) +RKISP1_DEFINE_BLOCK_TYPE(AwbGain, awb_gain) +RKISP1_DEFINE_BLOCK_TYPE(Flt, flt) +RKISP1_DEFINE_BLOCK_TYPE(Bdm, bdm) +RKISP1_DEFINE_BLOCK_TYPE(Ctk, ctk) +RKISP1_DEFINE_BLOCK_TYPE(Goc, goc) +RKISP1_DEFINE_BLOCK_TYPE(Dpf, dpf) +RKISP1_DEFINE_BLOCK_TYPE(DpfStrength, dpf_strength) +RKISP1_DEFINE_BLOCK_TYPE(Cproc, cproc) +RKISP1_DEFINE_BLOCK_TYPE(Ie, ie) +RKISP1_DEFINE_BLOCK_TYPE(Lsc, lsc) +RKISP1_DEFINE_BLOCK_TYPE(Awb, awb_meas) +RKISP1_DEFINE_BLOCK_TYPE(Hst, hst) +RKISP1_DEFINE_BLOCK_TYPE(Aec, aec) +RKISP1_DEFINE_BLOCK_TYPE(Afc, afc) + +} /* namespace details */ + +class RkISP1Params; + +class RkISP1ParamsBlockBase +{ +public: + RkISP1ParamsBlockBase(RkISP1Params *params, BlockType type, + const Span &data); + + Span data() const { return data_; } + + void setEnabled(bool enabled); + +private: + LIBCAMERA_DISABLE_COPY(RkISP1ParamsBlockBase) + + RkISP1Params *params_; + BlockType type_; + Span header_; + Span data_; +}; + +template +class RkISP1ParamsBlock : public RkISP1ParamsBlockBase +{ +public: + using Type = typename details::block_type::type; + + RkISP1ParamsBlock(RkISP1Params *params, const Span &data) + : RkISP1ParamsBlockBase(params, B, data) + { + } + + const Type *operator->() const + { + return reinterpret_cast(data().data()); + } + + Type *operator->() + { + return reinterpret_cast(data().data()); + } + + const Type &operator*() const & + { + return *reinterpret_cast(data().data()); + } + + Type &operator*() & + { + return *reinterpret_cast(data().data()); + } +}; + +class RkISP1Params +{ +public: + RkISP1Params(uint32_t format, Span data); + + template + RkISP1ParamsBlock block() + { + return RkISP1ParamsBlock(this, block(B)); + } + + uint32_t format() const { return format_; } + size_t size() const { return used_; } + +private: + friend class RkISP1ParamsBlockBase; + + Span block(BlockType type); + void setBlockEnabled(BlockType type, bool enabled); + + uint32_t format_; + + Span data_; + size_t used_; + + std::map> blocks_; +}; + +} /* namespace ipa::rkisp1 */ + +} /* namespace libcamera*/ -- cgit v1.2.1