[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250915170743.106249-11-niklas.soderlund+renesas@ragnatech.se>
Date: Mon, 15 Sep 2025 19:07:41 +0200
From: Niklas Söderlund <niklas.soderlund+renesas@...natech.se>
To: Mauro Carvalho Chehab <mchehab@...nel.org>,
Jacopo Mondi <jacopo.mondi@...asonboard.com>,
Laurent Pinchart <laurent.pinchart@...asonboard.com>,
linux-media@...r.kernel.org,
linux-renesas-soc@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Niklas Söderlund <niklas.soderlund+renesas@...natech.se>
Subject: [PATCH v2 10/12] media: rppx1: Add support for Gamma Correction
Extend the RPPX1 driver to allow setting the Gamma Correction
configuration using the RkISP1 parameter buffer format. 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.
As the RkISP1 parameters are all 10-bit while RPP can be either 12- or
24-bit, the driver corrects for this allowing the RkISP1 parameters to
be used.
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@...natech.se>
---
.../platform/dreamchip/rppx1/rpp_params.c | 3 ++
.../media/platform/dreamchip/rppx1/rppx1_ga.c | 34 +++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/drivers/media/platform/dreamchip/rppx1/rpp_params.c b/drivers/media/platform/dreamchip/rppx1/rpp_params.c
index 8491ce88ab90..323ee792426e 100644
--- a/drivers/media/platform/dreamchip/rppx1/rpp_params.c
+++ b/drivers/media/platform/dreamchip/rppx1/rpp_params.c
@@ -33,6 +33,9 @@ int rppx1_params_rkisp1(struct rppx1 *rpp, struct rkisp1_ext_params_cfg *cfg,
case RKISP1_EXT_PARAMS_BLOCK_TYPE_CTK:
module = &rpp->post.ccor;
break;
+ case RKISP1_EXT_PARAMS_BLOCK_TYPE_GOC:
+ module = &rpp->hv.ga;
+ break;
case RKISP1_EXT_PARAMS_BLOCK_TYPE_LSC:
module = &rpp->pre1.lsc;
break;
diff --git a/drivers/media/platform/dreamchip/rppx1/rppx1_ga.c b/drivers/media/platform/dreamchip/rppx1/rppx1_ga.c
index d6c7f951cf29..a748190ef2dc 100644
--- a/drivers/media/platform/dreamchip/rppx1/rppx1_ga.c
+++ b/drivers/media/platform/dreamchip/rppx1/rppx1_ga.c
@@ -43,7 +43,41 @@ static int rppx1_ga_start(struct rpp_module *mod,
return 0;
}
+static int
+rppx1_ga_param_rkisp1(struct rpp_module *mod,
+ const union rppx1_params_rkisp1_config *block,
+ rppx1_reg_write write, void *priv)
+{
+ const struct rkisp1_ext_params_goc_config *cfg = &block->goc;
+
+ /* If the modules is disabled, simply bypass it. */
+ if (cfg->header.flags & RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE) {
+ write(priv, mod->base + GAMMA_OUT_ENABLE_REG, 0);
+ return 0;
+ }
+
+ write(priv, mod->base + GAMMA_OUT_MODE_REG,
+ cfg->config.mode ? GAMMA_OUT_ENABLE_GAMMA_OUT_EN : 0);
+
+ /*
+ * The RkISP mean values are 10-bit while the RPP can be 12 or 24 bit.
+ * Figure out how much we need to adjust the output values.
+ */
+ const unsigned int shift = mod->info.ga.colorbits - 10;
+
+ for (unsigned int i = 0; i < RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10; i++)
+ write(priv, mod->base + GAMMA_OUT_Y_REG(i),
+ cfg->config.gamma_y[i] << shift);
+
+ /* Enable module. */
+ write(priv, mod->base + GAMMA_OUT_ENABLE_REG,
+ GAMMA_OUT_ENABLE_GAMMA_OUT_EN);
+
+ return 0;
+}
+
const struct rpp_module_ops rppx1_ga_ops = {
.probe = rppx1_ga_probe,
.start = rppx1_ga_start,
+ .param_rkisp1 = rppx1_ga_param_rkisp1,
};
--
2.51.0
Powered by blists - more mailing lists