[PATCH v7 06/18] media: rppx1: Add support for AWB gain settings

From: Jai Luthra

Date: Fri Apr 10 2026 - 05:13:22 EST


From: Niklas Söderlund <niklas.soderlund+renesas@xxxxxxxxxxxx>

Extend the RPPX1 driver to allow setting the AWB gains using the
parameter buffer format. This is the second function block inside the
RPPX1 to be enabled and it uses the RPPX1 framework for parameters and
its writer abstraction to allow the user to control how (and when)
configuration is applied to the RPPX1.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@xxxxxxxxxxxx>
Signed-off-by: Jai Luthra <jai.luthra+renesas@xxxxxxxxxxxxxxxx>
---
.../media/platform/dreamchip/rppx1/rpp_params.c | 4 +++
.../media/platform/dreamchip/rppx1/rppx1_awbg.c | 32 ++++++++++++++++++++++
2 files changed, 36 insertions(+)

diff --git a/drivers/media/platform/dreamchip/rppx1/rpp_params.c b/drivers/media/platform/dreamchip/rppx1/rpp_params.c
index 868a5ce1620e185174b8fade8a9a697826b3fed5..de47be81133d067a85f63ba0eb3f8f5e1f0ba2d3 100644
--- a/drivers/media/platform/dreamchip/rppx1/rpp_params.c
+++ b/drivers/media/platform/dreamchip/rppx1/rpp_params.c
@@ -16,6 +16,7 @@

static const struct v4l2_isp_params_block_type_info
rppx1_ext_params_blocks_info[] = {
+ RPPX1_PARAMS_BLOCK_INFO(AWB_GAIN, awb_gain),
RPPX1_PARAMS_BLOCK_INFO(AWB_MEAS, awb_meas),
};

@@ -51,6 +52,9 @@ int rppx1_params(struct rppx1 *rpp, struct vb2_buffer *vb, size_t max_size,
block_offset += block->header.size;

switch (block->header.type) {
+ case RPPX1_PARAMS_BLOCK_TYPE_AWB_GAIN:
+ module = &rpp->pre1.awbg;
+ break;
case RPPX1_PARAMS_BLOCK_TYPE_AWB_MEAS:
module = &rpp->post.wbmeas;
break;
diff --git a/drivers/media/platform/dreamchip/rppx1/rppx1_awbg.c b/drivers/media/platform/dreamchip/rppx1/rppx1_awbg.c
index e20bc369ca8c6db3781ed95381024f0fa4c48dff..0be63cc8dfbec573da8dec921f08f7bcc1b95a82 100644
--- a/drivers/media/platform/dreamchip/rppx1/rppx1_awbg.c
+++ b/drivers/media/platform/dreamchip/rppx1/rppx1_awbg.c
@@ -25,6 +25,38 @@ static int rppx1_awbg_probe(struct rpp_module *mod)
return 0;
}

+static int
+rppx1_awbg_fill_params(struct rpp_module *mod,
+ const union rppx1_params_block *block,
+ rppx1_reg_write write, void *priv)
+{
+ const struct rppx1_params_awb_gain_config *cfg = &block->awbg;
+
+ /* If the modules is disabled, simply bypass it. */
+ if (cfg->header.flags & V4L2_ISP_PARAMS_FL_BLOCK_DISABLE) {
+ write(priv, mod->base + AWB_ENABLE_REG, 0);
+ return 0;
+ }
+
+ /*
+ * RPP gains are 18-bit with 12 bit fractional part and 0x1000 = 1.0,
+ * giving a possible range of 0.0 to 64.0. NOTE: RPP documentation is
+ * contradictory this is the register definition, the function
+ * description states 0x400 = 1.0 AND 18-bit with 12 fractional bits,
+ * which is not possible...
+ */
+
+ write(priv, mod->base + AWB_GAIN_GR_REG, cfg->gain_green_r);
+ write(priv, mod->base + AWB_GAIN_GB_REG, cfg->gain_green_b);
+ write(priv, mod->base + AWB_GAIN_R_REG, cfg->gain_red);
+ write(priv, mod->base + AWB_GAIN_B_REG, cfg->gain_blue);
+
+ write(priv, mod->base + AWB_ENABLE_REG, AWB_ENABLE_AWB_GAIN_EN);
+
+ return 0;
+}
+
const struct rpp_module_ops rppx1_awbg_ops = {
.probe = rppx1_awbg_probe,
+ .fill_params = rppx1_awbg_fill_params,
};

--
2.53.0