mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
To: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
Cc: Jacopo Mondi <jacopo.mondi@ideasonboard.com>,
	 Jai Luthra <jai.luthra+renesas@ideasonboard.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	 linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	 Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
Subject: Re: [PATCH v9 06/13] media: rppx1: awbg: Add support for white balance gain settings
Date: Wed, 3 Jun 2026 15:38:42 +0200	[thread overview]
Message-ID: <aiAuUs0Q_1zI0iZW@zed> (raw)
In-Reply-To: <20260516211320.3041412-7-niklas.soderlund+renesas@ragnatech.se>

Hi Niklas

On Sat, May 16, 2026 at 11:13:13PM +0200, Niklas Söderlund wrote:
> Extend the RPPX1 driver to allow setting the white balance gain
> configuration parameters. 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@ragnatech.se>
> Co-developed-by: Jai Luthra <jai.luthra+renesas@ideasonboard.com>
> Signed-off-by: Jai Luthra <jai.luthra+renesas@ideasonboard.com>
> Co-developed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
> Signed-off-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>

Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

Thanks
  j

> ---
>  .../platform/dreamchip/rppx1/rpp_module.h     |  1 +
>  .../platform/dreamchip/rppx1/rpp_params.c     |  5 +++
>  .../platform/dreamchip/rppx1/rppx1_awbg.c     | 32 +++++++++++++++
>  .../uapi/linux/media/dreamchip/rppx1-config.h | 40 ++++++++++++++++++-
>  4 files changed, 77 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/dreamchip/rppx1/rpp_module.h b/drivers/media/platform/dreamchip/rppx1/rpp_module.h
> index 64a1b848f1ea..0e36b717b4ef 100644
> --- a/drivers/media/platform/dreamchip/rppx1/rpp_module.h
> +++ b/drivers/media/platform/dreamchip/rppx1/rpp_module.h
> @@ -47,6 +47,7 @@ void rpp_module_clrset(struct rpp_module *mod, u32 offset, u32 mask, u32 value);
>
>  union rppx1_params_block {
>  	struct v4l2_isp_block_header header;
> +	struct rppx1_awbg_params awbg;
>  	struct rppx1_wbmeas_params wbmeas;
>  };
>
> diff --git a/drivers/media/platform/dreamchip/rppx1/rpp_params.c b/drivers/media/platform/dreamchip/rppx1/rpp_params.c
> index 7325abeba92a..17bbcf366970 100644
> --- a/drivers/media/platform/dreamchip/rppx1/rpp_params.c
> +++ b/drivers/media/platform/dreamchip/rppx1/rpp_params.c
> @@ -17,6 +17,8 @@
>
>  static const struct v4l2_isp_params_block_type_info
>  rppx1_ext_params_blocks_info[] = {
> +	RPPX1_PARAMS_BLOCK_INFO(AWBG_PRE1, awbg),
> +	RPPX1_PARAMS_BLOCK_INFO(AWBG_PRE2, awbg),
>  	RPPX1_PARAMS_BLOCK_INFO(WBMEAS_POST, wbmeas),
>  };
>
> @@ -51,6 +53,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_AWBG_PRE1:
> +			module = &rpp->pre1.awbg;
> +			break;
>  		case RPPX1_PARAMS_BLOCK_TYPE_WBMEAS_POST:
>  			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 4a242b41142b..f30e12d6f880 100644
> --- a/drivers/media/platform/dreamchip/rppx1/rppx1_awbg.c
> +++ b/drivers/media/platform/dreamchip/rppx1/rppx1_awbg.c
> @@ -26,6 +26,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_awbg_params *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,
>  };
> diff --git a/include/uapi/linux/media/dreamchip/rppx1-config.h b/include/uapi/linux/media/dreamchip/rppx1-config.h
> index 938f8f258f9e..5ed8a335c9de 100644
> --- a/include/uapi/linux/media/dreamchip/rppx1-config.h
> +++ b/include/uapi/linux/media/dreamchip/rppx1-config.h
> @@ -48,9 +48,15 @@ struct rppx1_window {
>   * NOTE: Only append to the enumeration as the numbers are uAPI.
>   *
>   * @RPPX1_PARAMS_BLOCK_TYPE_WBMEAS_POST: AWB Measurement Configuration
> + * @RPPX1_PARAMS_BLOCK_TYPE_AWBG_PRE1: PRE1 pipe White Balance Gains
> + * @RPPX1_PARAMS_BLOCK_TYPE_AWBG_PRE2: PRE2 White Balance Gains
> + * @RPPX1_PARAMS_BLOCK_TYPE_AWBG_POST: MAIN_POST White Balance Gains
>   */
>  enum rppx1_params_block_type {
>  	RPPX1_PARAMS_BLOCK_TYPE_WBMEAS_POST,
> +	RPPX1_PARAMS_BLOCK_TYPE_AWBG_PRE1,
> +	RPPX1_PARAMS_BLOCK_TYPE_AWBG_PRE2,
> +	RPPX1_PARAMS_BLOCK_TYPE_AWBG_POST,
>  };
>
>  /**
> @@ -109,6 +115,35 @@ struct rppx1_wbmeas_params {
>  	__u32 ccor_offs[3];
>  };
>
> +/**
> + * struct rppx1_awbg_params  - WB gain configuration
> + *
> + * The RPP-X1 White Balance Gain module is available in the PRE1 and PRE2
> + * pre-fusion pipes and in the MAIN_POST post-fusion pipe. Userspace selects
> + * which pipe to operate by setting the @header.type field to
> + * RPPX1_PARAMS_BLOCK_TYPE_AWBG_PRE1, RPPX1_PARAMS_BLOCK_TYPE_AWBG_PRE2
> + * or RPPX1_PARAMS_BLOCK_TYPE_AWBG_POST.
> + *
> + * The White Balance module allows to specify per-color channel gains, expressed
> + * as unsigned fixed-point values as 18 bits unsigned integers in Q6.12 format
> + * with a maximum of 63.999.
> + *
> + * @header: block header (type = RPPX1_PARAMS_BLOCK_TYPE_AWBG_PRE1 or
> + *	    type = RPPX1_PARAMS_BLOCK_TYPE_AWBG_PRE2 or
> + *	    type = RPPX1_PARAMS_BLOCK_TYPE_AWBG_POST)
> + * @gain_red: gain for red component, 18-bit (unsigned Q6.12)
> + * @gain_green_r: gain for green component in red lines, 18-bit (unsigned Q6.12)
> + * @gain_blue: gain for blue component, 18-bit (unsigned Q6.12)
> + * @gain_green_b: gain for green component in blue lines, 18-bit (unsigned Q6.12)
> + */
> +struct rppx1_awbg_params {
> +	struct v4l2_isp_params_block_header header;
> +	__u32 gain_red;
> +	__u32 gain_green_r;
> +	__u32 gain_blue;
> +	__u32 gain_green_b;
> +};
> +
>  /**
>   * RPPX1_PARAMS_MAX_SIZE - Maximum size of all RPP-X1 parameter blocks
>   *
> @@ -116,7 +151,10 @@ struct rppx1_wbmeas_params {
>   * multiple pipes.
>   */
>  #define RPPX1_PARAMS_MAX_SIZE						\
> -	(sizeof(struct rppx1_wbmeas_params))
> +	(sizeof(struct rppx1_wbmeas_params)			+	\
> +	sizeof(struct rppx1_awbg_params)			+	\
> +	sizeof(struct rppx1_awbg_params)			+	\
> +	sizeof(struct rppx1_awbg_params))
>
>  /* ---------------------------------------------------------------------------
>   * Statistics Structures
> --
> 2.54.0
>

  reply	other threads:[~2026-06-03 13:38 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-16 21:13 [PATCH v9 00/13] media: Add support for R-Car ISP using Dreamchip RPPX1 ISP Niklas Söderlund
2026-05-16 21:13 ` [PATCH v9 01/13] media: Add RPP_X1_PARAMS and RPP_X1_STATS meta formats Niklas Söderlund
2026-06-03 10:49   ` Jacopo Mondi
2026-06-03 12:48     ` Niklas Söderlund
2026-05-16 21:13 ` [PATCH v9 02/13] media: uapi: Add extensible param and stats blocks for RPPX1 Niklas Söderlund
2026-06-03 10:50   ` Jacopo Mondi
2026-06-03 12:55     ` Niklas Söderlund
2026-05-16 21:13 ` [PATCH v9 03/13] media: rppx1: Add framework to support Dreamchip RPPX1 ISP Niklas Söderlund
2026-06-03 10:56   ` Jacopo Mondi
2026-06-03 12:24   ` Jacopo Mondi
2026-06-03 13:47     ` Niklas Söderlund
2026-06-03 14:26       ` Jacopo Mondi
2026-06-03 15:17         ` Niklas Söderlund
2026-06-03 15:33           ` Jacopo Mondi
2026-05-16 21:13 ` [PATCH v9 04/13] media: rcar-isp: Add support for ISPCORE Niklas Söderlund
2026-06-03 13:15   ` Jacopo Mondi
2026-06-11 11:53     ` Niklas Söderlund
2026-05-16 21:13 ` [PATCH v9 05/13] media: rppx1: wbmeas: Add support for white balance measurement Niklas Söderlund
2026-06-03 13:35   ` Jacopo Mondi
2026-05-16 21:13 ` [PATCH v9 06/13] media: rppx1: awbg: Add support for white balance gain settings Niklas Söderlund
2026-06-03 13:38   ` Jacopo Mondi [this message]
2026-05-16 21:13 ` [PATCH v9 07/13] media: rppx1: exm: Add support for exposure measurement Niklas Söderlund
2026-06-03 13:57   ` Jacopo Mondi
2026-06-11 12:04     ` Niklas Söderlund
2026-05-16 21:13 ` [PATCH v9 08/13] media: rppx1: hist: Add support histogram measurement Niklas Söderlund
2026-06-03 14:11   ` Jacopo Mondi
2026-06-11 12:14     ` Niklas Söderlund
2026-05-16 21:13 ` [PATCH v9 09/13] media: rppx1: bls: Add support for black level compensation Niklas Söderlund
2026-05-16 21:13 ` [PATCH v9 10/13] media: rppx1: ccor: Add support for color correction matrix Niklas Söderlund
2026-05-16 21:13 ` [PATCH v9 11/13] media: rppx1: lsc: Add support for lens shade correction Niklas Söderlund
2026-06-03 14:32   ` Jacopo Mondi
2026-05-16 21:13 ` [PATCH v9 12/13] media: rppx1: ga: Add support for gamma out correction Niklas Söderlund
2026-06-03 14:33   ` Jacopo Mondi
2026-05-16 21:13 ` [PATCH v9 13/13] media: rppx1: lin: Add support for gamma sensor linearization Niklas Söderlund
2026-06-03 14:36   ` Jacopo Mondi
2026-06-11 12:19     ` 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=aiAuUs0Q_1zI0iZW@zed \
    --to=jacopo.mondi@ideasonboard.com \
    --cc=jacopo.mondi+renesas@ideasonboard.com \
    --cc=jai.luthra+renesas@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=mchehab@kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    /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®