[RFC,03/19] ipa: rkisp2: params: Add rkisp2 extensible parameters wrapper
diff mbox series

Message ID 20260703122543.1991189-4-paul.elder@ideasonboard.com
State New
Headers show
Series
  • Add support for rkisp2
Related show

Commit Message

Paul Elder July 3, 2026, 12:25 p.m. UTC
Add the libipa wrapper for extensible parameters for the rkisp2. This
wraps the extensible parameters in the rkisp2 uapi to make them easier
to use within libcamera.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

---
This is in a separate patch to reduce the size of the other patches to
make them easier to review.
---
 src/ipa/rkisp2/algorithms/algorithm.h | 42 ++++++++++++++
 src/ipa/rkisp2/params.h               | 83 +++++++++++++++++++++++++++
 2 files changed, 125 insertions(+)
 create mode 100644 src/ipa/rkisp2/algorithms/algorithm.h
 create mode 100644 src/ipa/rkisp2/params.h

Patch
diff mbox series

diff --git a/src/ipa/rkisp2/algorithms/algorithm.h b/src/ipa/rkisp2/algorithms/algorithm.h
new file mode 100644
index 000000000000..c30596e3299b
--- /dev/null
+++ b/src/ipa/rkisp2/algorithms/algorithm.h
@@ -0,0 +1,42 @@ 
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2026, Ideas On Board
+ *
+ * RkISP2 control algorithm interface
+ */
+
+#pragma once
+
+#include <linux/rkisp2-config.h>
+
+#include <libipa/algorithm.h>
+
+#include "module.h"
+
+namespace libcamera {
+
+namespace ipa::rkisp2 {
+
+class Algorithm : public libcamera::ipa::Algorithm<Module>
+{
+};
+
+union rkisp2_params_block {
+	const struct v4l2_isp_params_block_header *header;
+	const struct rkisp2_params_bls *bls;
+	const struct rkisp2_params_awb_gains *awb_gains;
+	const struct rkisp2_params_csm *csm;
+	const struct rkisp2_params_ccm *ccm;
+	const struct rkisp2_params_goc *goc;
+	const struct rkisp2_params_lsc *lsc;
+	const struct rkisp2_params_ae_lite *ae_lite;
+	const struct rkisp2_params_hist_lite *hist_lite;
+	const struct rkisp2_params_hist_big *hist_big;
+	const struct rkisp2_params_awb_meas *awb_meas;
+	const __u8 *data;
+};
+
+} /* namespace ipa::rkisp2 */
+
+} /* namespace libcamera */
+
diff --git a/src/ipa/rkisp2/params.h b/src/ipa/rkisp2/params.h
new file mode 100644
index 000000000000..c7c15483ee11
--- /dev/null
+++ b/src/ipa/rkisp2/params.h
@@ -0,0 +1,83 @@ 
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2026, Ideas On Board
+ *
+ * RkISP2 ISP Parameters
+ */
+
+#pragma once
+
+#include <stdint.h>
+
+#include <linux/rkisp2-config.h>
+#include <linux/videodev2.h>
+
+#include <libipa/v4l2_params.h>
+
+namespace libcamera {
+
+namespace ipa::rkisp2 {
+
+enum class RkISP2Blocks : uint16_t {
+	Bls,
+	AwbGains,
+	Csm,
+	Ccm,
+	Goc,
+	Lsc,
+	AeLite,
+	HistLite,
+	HistBig0,
+	HistBig1,
+	HistBig2,
+	AwbMeas,
+};
+
+namespace details {
+
+template<RkISP2Blocks B>
+struct block_type {
+};
+
+#define RKISP2_DEFINE_BLOCK_TYPE(id, cfgType, blkType)		\
+template<>								\
+struct block_type<RkISP2Blocks::id> {					\
+	using type = struct rkisp2_params_##cfgType;			\
+	static constexpr rkisp2_params_block_type blockType = 		\
+		rkisp2_params_block_type::RKISP2_PARAMS_##blkType;	\
+}
+
+RKISP2_DEFINE_BLOCK_TYPE(Bls,			bls,		BLOCK_BLS);
+RKISP2_DEFINE_BLOCK_TYPE(AwbGains,		awb_gains,	BLOCK_AWB_GAINS);
+RKISP2_DEFINE_BLOCK_TYPE(Csm,			csm,		BLOCK_CSM);
+RKISP2_DEFINE_BLOCK_TYPE(Ccm,			ccm,		BLOCK_CCM);
+RKISP2_DEFINE_BLOCK_TYPE(Goc,			goc,		BLOCK_GOC);
+RKISP2_DEFINE_BLOCK_TYPE(Lsc,			lsc,		BLOCK_LSC);
+RKISP2_DEFINE_BLOCK_TYPE(AeLite,		ae_lite,	BLOCK_AE_LITE);
+RKISP2_DEFINE_BLOCK_TYPE(HistLite,		hist_lite,	BLOCK_HIST_LITE);
+RKISP2_DEFINE_BLOCK_TYPE(HistBig0,		hist_big,	BLOCK_HIST_BIG0);
+RKISP2_DEFINE_BLOCK_TYPE(HistBig1,		hist_big,	BLOCK_HIST_BIG1);
+RKISP2_DEFINE_BLOCK_TYPE(HistBig2,		hist_big,	BLOCK_HIST_BIG2);
+RKISP2_DEFINE_BLOCK_TYPE(AwbMeas,		awb_meas,	BLOCK_AWB_MEAS);
+
+struct param_traits {
+	using id_type = RkISP2Blocks;
+
+	template<id_type Id>
+	using id_to_details = block_type<Id>;
+};
+
+} /* namespace details */
+
+class RkISP2Params : public V4L2Params<details::param_traits>
+{
+public:
+	RkISP2Params(Span<uint8_t> data)
+		: V4L2Params(data, V4L2_ISP_PARAMS_VERSION_V1)
+	{
+	}
+};
+
+} /* namespace ipa::rkisp2 */
+
+} /* namespace libcamera */