From: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
To: Mauro Carvalho Chehab <mchehab@kernel.org>,
Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>,
Jacopo Mondi <jacopo.mondi@ideasonboard.com>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>,
"Marek Vasut" <marek.vasut+renesas@mailbox.org>
Subject: [PATCH v6 10/12] media: rppx1: Add support for Gamma Correction
Date: Sat, 14 Mar 2026 22:59:42 +0100 [thread overview]
Message-ID: <20260314215944.3674865-11-niklas.soderlund+renesas@ragnatech.se> (raw)
In-Reply-To: <20260314215944.3674865-1-niklas.soderlund+renesas@ragnatech.se>
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@ragnatech.se>
Tested-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
---
.../platform/dreamchip/rppx1/rpp_params.c | 4 +++
.../media/platform/dreamchip/rppx1/rppx1_ga.c | 34 +++++++++++++++++++
2 files changed, 38 insertions(+)
diff --git a/drivers/media/platform/dreamchip/rppx1/rpp_params.c b/drivers/media/platform/dreamchip/rppx1/rpp_params.c
index 0314cb732844..a2f6c85893e3 100644
--- a/drivers/media/platform/dreamchip/rppx1/rpp_params.c
+++ b/drivers/media/platform/dreamchip/rppx1/rpp_params.c
@@ -19,6 +19,7 @@ rkisp1_ext_params_blocks_info[] = {
RKISP1_PARAMS_BLOCK_INFO(BLS, bls),
RKISP1_PARAMS_BLOCK_INFO(AWB_GAIN, awb_gain),
RKISP1_PARAMS_BLOCK_INFO(CTK, ctk),
+ RKISP1_PARAMS_BLOCK_INFO(GOC, goc),
RKISP1_PARAMS_BLOCK_INFO(LSC, lsc),
RKISP1_PARAMS_BLOCK_INFO(AWB_MEAS, awb_meas),
RKISP1_PARAMS_BLOCK_INFO(HST_MEAS, hst),
@@ -66,6 +67,9 @@ int rppx1_params(struct rppx1 *rpp, struct vb2_buffer *vb, size_t max_size,
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.53.0
next prev parent reply other threads:[~2026-03-14 22:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-14 21:59 [PATCH v6 00/12] media: Add support for R-Car ISP using Dreamchip RPPX1 ISP Niklas Söderlund
2026-03-14 21:59 ` [PATCH v6 01/12] media: rppx1: Add framework to support " Niklas Söderlund
2026-03-14 21:59 ` [PATCH v6 02/12] media: rcar-isp: Add support for ISPCORE Niklas Söderlund
2026-03-14 21:59 ` [PATCH v6 03/12] media: rppx1: Add support for AWB measurement parameters and statistics Niklas Söderlund
2026-03-14 21:59 ` [PATCH v6 04/12] media: rppx1: Add support for AWB gain settings Niklas Söderlund
2026-03-14 21:59 ` [PATCH v6 05/12] media: rppx1: Add support for Auto Exposure Measurement Niklas Söderlund
2026-03-14 21:59 ` [PATCH v6 06/12] media: rppx1: Add support for Histogram Measurement Niklas Söderlund
2026-03-14 21:59 ` [PATCH v6 07/12] media: rppx1: Add support for Black Level Subtraction Niklas Söderlund
2026-03-14 21:59 ` [PATCH v6 08/12] media: rppx1: Add support for Color Correction Matrix Niklas Söderlund
2026-03-14 21:59 ` [PATCH v6 09/12] media: rppx1: Add support for Lens Shade Correction Niklas Söderlund
2026-03-14 21:59 ` Niklas Söderlund [this message]
2026-03-14 21:59 ` [PATCH v6 11/12] media: rppx1: Add support for Bayer Demosaicing Niklas Söderlund
2026-03-14 21:59 ` [PATCH v6 12/12] media: rppx1: Add support for Bilateral Denoising Niklas Söderlund
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260314215944.3674865-11-niklas.soderlund+renesas@ragnatech.se \
--to=niklas.soderlund+renesas@ragnatech.se \
--cc=jacopo.mondi@ideasonboard.com \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=marek.vasut+renesas@mailbox.org \
--cc=mchehab@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®