[10/14] ipa: rppx1: Add RppX1Params and RppX1Stats
diff mbox series

Message ID 20260618-rppx1-ipa-v1-10-32337264cfcd@ideasonboard.com
State New
Headers show
Series
  • libcamera: Add support for R-Car Gen4 and RPP-X1 ISP
Related show

Commit Message

Jacopo Mondi June 18, 2026, 10:18 a.m. UTC
Add RppX1Params and RppX1Stats classes that implement V4L2Params and
V4L2Stats for the RPP-X1 ISP.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
 src/ipa/rppx1/params.h | 108 +++++++++++++++++++++++++++++++++++++++++++++++++
 src/ipa/rppx1/stats.h  |  62 ++++++++++++++++++++++++++++
 2 files changed, 170 insertions(+)

Comments

Niklas Söderlund June 18, 2026, 8:31 p.m. UTC | #1
Hi Jacopo,

Thanks for your patch.

On 2026-06-18 12:18:49 +0200, Jacopo Mondi wrote:
> Add RppX1Params and RppX1Stats classes that implement V4L2Params and
> V4L2Stats for the RPP-X1 ISP.
> 
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

> ---
>  src/ipa/rppx1/params.h | 108 +++++++++++++++++++++++++++++++++++++++++++++++++
>  src/ipa/rppx1/stats.h  |  62 ++++++++++++++++++++++++++++
>  2 files changed, 170 insertions(+)
> 
> diff --git a/src/ipa/rppx1/params.h b/src/ipa/rppx1/params.h
> new file mode 100644
> index 000000000000..a7f927372c1d
> --- /dev/null
> +++ b/src/ipa/rppx1/params.h
> @@ -0,0 +1,108 @@
> +/* SPDX-License-Identifier: LGPL-2.1-or-later */
> +/*
> + * Copyright (C) 2026, Ideas On Board
> + *
> + * RPP-X1 ISP Parameters
> + */
> +
> +#pragma once
> +
> +#include <linux/media/dreamchip/rppx1-config.h>
> +
> +#include <libipa/v4l2_params.h>
> +
> +namespace libcamera {
> +
> +namespace ipa::rppx1 {
> +
> +enum class BlockType : uint16_t {
> +	BlsPre1,
> +	LinPre1,
> +	LscPre1,
> +	AwbgPre1,
> +	CcorPost,
> +	GaHv,
> +	WbmeasPost,
> +	HistPost,
> +	ExmPre1,
> +};
> +
> +namespace details {
> +
> +template<BlockType B>
> +struct block_type {
> +};
> +
> +#define RPPX1_DEFINE_BLOCK_TYPE(blkType, cfgType, id)		\
> +template<>							\
> +struct block_type<BlockType::blkType> {			\
> +	using type = struct rppx1_##cfgType##_params;	\
> +	static constexpr rppx1_params_block_type blockType =	\
> +		RPPX1_PARAMS_BLOCK_TYPE_##id;			\
> +};
> +
> +RPPX1_DEFINE_BLOCK_TYPE(BlsPre1, bls, BLS_PRE1)
> +RPPX1_DEFINE_BLOCK_TYPE(LinPre1, lin, LIN_PRE1)
> +RPPX1_DEFINE_BLOCK_TYPE(LscPre1, lsc, LSC_PRE1)
> +RPPX1_DEFINE_BLOCK_TYPE(AwbgPre1, awbg, AWBG_PRE1)
> +RPPX1_DEFINE_BLOCK_TYPE(CcorPost, ccor, CCOR_POST)
> +RPPX1_DEFINE_BLOCK_TYPE(GaHv, ga, GA_HV)
> +RPPX1_DEFINE_BLOCK_TYPE(WbmeasPost, wbmeas, WBMEAS_POST)
> +RPPX1_DEFINE_BLOCK_TYPE(HistPost, hist, HIST_POST)
> +RPPX1_DEFINE_BLOCK_TYPE(ExmPre1, exm, EXM_PRE1)
> +
> +struct params_traits {
> +	using id_type = BlockType;
> +
> +	template<id_type Id>
> +	using id_to_details = block_type<Id>;
> +};
> +
> +} /* namespace details */
> +
> +template<typename T>
> +class RppX1ParamsBlock final : public V4L2ParamsBlock<T>
> +{
> +public:
> +	RppX1ParamsBlock(const Span<uint8_t> data)
> +		: V4L2ParamsBlock<T>(data),
> +		  configData_(data.subspan(sizeof(v4l2_isp_block_header)))
> +	{
> +	}
> +
> +	const T *operator->() const override
> +	{
> +		return reinterpret_cast<const T *>(configData_.data());
> +	}
> +
> +	T *operator->() override
> +	{
> +		return reinterpret_cast<T *>(configData_.data());
> +	}
> +
> +	const T &operator*() const override
> +	{
> +		return *reinterpret_cast<const T *>(configData_.data());
> +	}
> +
> +	T &operator*() override
> +	{
> +		return *reinterpret_cast<T *>(configData_.data());
> +	}
> +
> +private:
> +	Span<uint8_t> configData_;
> +};
> +
> +class RppX1Params : public V4L2Params<details::params_traits>
> +{
> +public:
> +	RppX1Params(Span<uint8_t> data)
> +		: V4L2Params(data, V4L2_ISP_PARAMS_VERSION_V1)
> +	{
> +	}
> +};
> +
> +} /* namespace ipa::rppx1 */
> +
> +} /* namespace libcamera */
> diff --git a/src/ipa/rppx1/stats.h b/src/ipa/rppx1/stats.h
> new file mode 100644
> index 000000000000..71a3e1da505c
> --- /dev/null
> +++ b/src/ipa/rppx1/stats.h
> @@ -0,0 +1,62 @@
> +/* SPDX-License-Identifier: LGPL-2.1-or-later */
> +/*
> + * Copyright (C) 2026, Ideas On Board
> + *
> + * RPP-X1 ISP Statistics
> + */
> +
> +#pragma once
> +
> +#include <linux/media/dreamchip/rppx1-config.h>
> +
> +#include <libipa/v4l2_stats.h>
> +
> +namespace libcamera {
> +
> +namespace ipa::rppx1 {
> +
> +enum class StatsType : uint16_t {
> +	HistPost,
> +	ExmPre1,
> +	WbmeasPost,
> +};
> +
> +namespace details {
> +
> +template<StatsType B>
> +struct stats_type {
> +};
> +
> +#define RPPX1_DEFINE_STATS_TYPE(blkType, cfgType, id)		\
> +template<>							\
> +struct stats_type<StatsType::blkType> {				\
> +	using type = struct rppx1_##cfgType##_stats;		\
> +	static constexpr rppx1_stats_block_type blockType =	\
> +		RPPX1_STATS_BLOCK_TYPE_##id;			\
> +};
> +
> +RPPX1_DEFINE_STATS_TYPE(HistPost, hist, HIST_POST)
> +RPPX1_DEFINE_STATS_TYPE(ExmPre1, exm, EXM_PRE1)
> +RPPX1_DEFINE_STATS_TYPE(WbmeasPost, wbmeas, WBMEAS_POST)
> +
> +struct stats_traits {
> +	using id_type = StatsType;
> +
> +	template<id_type Id>
> +	using id_to_details = stats_type<Id>;
> +};
> +
> +} /* namespace details */
> +
> +class RppX1Stats : public V4L2Stats<details::stats_traits>
> +{
> +public:
> +	RppX1Stats(Span<uint8_t> data)
> +		: V4L2Stats(data, V4L2_ISP_VERSION_V1)
> +	{
> +	}
> +};
> +
> +} /* namespace ipa::rppx1 */
> +
> +} /* namespace libcamera */
> 
> -- 
> 2.54.0
>

Patch
diff mbox series

diff --git a/src/ipa/rppx1/params.h b/src/ipa/rppx1/params.h
new file mode 100644
index 000000000000..a7f927372c1d
--- /dev/null
+++ b/src/ipa/rppx1/params.h
@@ -0,0 +1,108 @@ 
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2026, Ideas On Board
+ *
+ * RPP-X1 ISP Parameters
+ */
+
+#pragma once
+
+#include <linux/media/dreamchip/rppx1-config.h>
+
+#include <libipa/v4l2_params.h>
+
+namespace libcamera {
+
+namespace ipa::rppx1 {
+
+enum class BlockType : uint16_t {
+	BlsPre1,
+	LinPre1,
+	LscPre1,
+	AwbgPre1,
+	CcorPost,
+	GaHv,
+	WbmeasPost,
+	HistPost,
+	ExmPre1,
+};
+
+namespace details {
+
+template<BlockType B>
+struct block_type {
+};
+
+#define RPPX1_DEFINE_BLOCK_TYPE(blkType, cfgType, id)		\
+template<>							\
+struct block_type<BlockType::blkType> {			\
+	using type = struct rppx1_##cfgType##_params;	\
+	static constexpr rppx1_params_block_type blockType =	\
+		RPPX1_PARAMS_BLOCK_TYPE_##id;			\
+};
+
+RPPX1_DEFINE_BLOCK_TYPE(BlsPre1, bls, BLS_PRE1)
+RPPX1_DEFINE_BLOCK_TYPE(LinPre1, lin, LIN_PRE1)
+RPPX1_DEFINE_BLOCK_TYPE(LscPre1, lsc, LSC_PRE1)
+RPPX1_DEFINE_BLOCK_TYPE(AwbgPre1, awbg, AWBG_PRE1)
+RPPX1_DEFINE_BLOCK_TYPE(CcorPost, ccor, CCOR_POST)
+RPPX1_DEFINE_BLOCK_TYPE(GaHv, ga, GA_HV)
+RPPX1_DEFINE_BLOCK_TYPE(WbmeasPost, wbmeas, WBMEAS_POST)
+RPPX1_DEFINE_BLOCK_TYPE(HistPost, hist, HIST_POST)
+RPPX1_DEFINE_BLOCK_TYPE(ExmPre1, exm, EXM_PRE1)
+
+struct params_traits {
+	using id_type = BlockType;
+
+	template<id_type Id>
+	using id_to_details = block_type<Id>;
+};
+
+} /* namespace details */
+
+template<typename T>
+class RppX1ParamsBlock final : public V4L2ParamsBlock<T>
+{
+public:
+	RppX1ParamsBlock(const Span<uint8_t> data)
+		: V4L2ParamsBlock<T>(data),
+		  configData_(data.subspan(sizeof(v4l2_isp_block_header)))
+	{
+	}
+
+	const T *operator->() const override
+	{
+		return reinterpret_cast<const T *>(configData_.data());
+	}
+
+	T *operator->() override
+	{
+		return reinterpret_cast<T *>(configData_.data());
+	}
+
+	const T &operator*() const override
+	{
+		return *reinterpret_cast<const T *>(configData_.data());
+	}
+
+	T &operator*() override
+	{
+		return *reinterpret_cast<T *>(configData_.data());
+	}
+
+private:
+	Span<uint8_t> configData_;
+};
+
+class RppX1Params : public V4L2Params<details::params_traits>
+{
+public:
+	RppX1Params(Span<uint8_t> data)
+		: V4L2Params(data, V4L2_ISP_PARAMS_VERSION_V1)
+	{
+	}
+};
+
+} /* namespace ipa::rppx1 */
+
+} /* namespace libcamera */
diff --git a/src/ipa/rppx1/stats.h b/src/ipa/rppx1/stats.h
new file mode 100644
index 000000000000..71a3e1da505c
--- /dev/null
+++ b/src/ipa/rppx1/stats.h
@@ -0,0 +1,62 @@ 
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2026, Ideas On Board
+ *
+ * RPP-X1 ISP Statistics
+ */
+
+#pragma once
+
+#include <linux/media/dreamchip/rppx1-config.h>
+
+#include <libipa/v4l2_stats.h>
+
+namespace libcamera {
+
+namespace ipa::rppx1 {
+
+enum class StatsType : uint16_t {
+	HistPost,
+	ExmPre1,
+	WbmeasPost,
+};
+
+namespace details {
+
+template<StatsType B>
+struct stats_type {
+};
+
+#define RPPX1_DEFINE_STATS_TYPE(blkType, cfgType, id)		\
+template<>							\
+struct stats_type<StatsType::blkType> {				\
+	using type = struct rppx1_##cfgType##_stats;		\
+	static constexpr rppx1_stats_block_type blockType =	\
+		RPPX1_STATS_BLOCK_TYPE_##id;			\
+};
+
+RPPX1_DEFINE_STATS_TYPE(HistPost, hist, HIST_POST)
+RPPX1_DEFINE_STATS_TYPE(ExmPre1, exm, EXM_PRE1)
+RPPX1_DEFINE_STATS_TYPE(WbmeasPost, wbmeas, WBMEAS_POST)
+
+struct stats_traits {
+	using id_type = StatsType;
+
+	template<id_type Id>
+	using id_to_details = stats_type<Id>;
+};
+
+} /* namespace details */
+
+class RppX1Stats : public V4L2Stats<details::stats_traits>
+{
+public:
+	RppX1Stats(Span<uint8_t> data)
+		: V4L2Stats(data, V4L2_ISP_VERSION_V1)
+	{
+	}
+};
+
+} /* namespace ipa::rppx1 */
+
+} /* namespace libcamera */