From: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
To: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Cc: 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
Subject: Re: [v8 12/14] media: rppx1: db: Add support for debayering filters
Date: Sat, 16 May 2026 22:47:36 +0200 [thread overview]
Message-ID: <20260516204736.GA332351@ragnatech.se> (raw)
In-Reply-To: <aftj3lgMSyVIvFda@zed>
On 2026-05-06 17:54:36 +0200, Jacopo Mondi wrote:
> Hi Niklas
>
> On Mon, May 04, 2026 at 03:05:54AM +0200, Niklas Söderlund wrote:
> > Extend the RPPX1 driver to allow setting the debayering filters
> > 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>
> > ---
> > .../platform/dreamchip/rppx1/rpp_module.h | 2 +
> > .../platform/dreamchip/rppx1/rpp_params.c | 7 ++
> > .../media/platform/dreamchip/rppx1/rppx1_db.c | 82 +++++++++++++++++++
> > .../uapi/linux/media/dreamchip/rppx1-config.h | 58 ++++++++++++-
>
> As this block still doesn't have a user in libcamera, but I understand
> there might be value in having the module upstream, what if we
> upstream rppx1_db.c but we don't commit to a uAPI yet ? We can keep
> the types you have defined in the uAPI internal to the driver for now?
I will drop the parameters and uAPI from this series. I will however
keep the rppx1_db.c file for the probe and verification of the version
register.
I will do the same for rppx1_bd.c which also don't have a libcamera user
ATM, only in my test suite.
Once this series is merged we can add this to libcamera and revisit
these modules here.
>
> > 4 files changed, 148 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/media/platform/dreamchip/rppx1/rpp_module.h b/drivers/media/platform/dreamchip/rppx1/rpp_module.h
> > index 830ef0df7228..064da13082fe 100644
> > --- a/drivers/media/platform/dreamchip/rppx1/rpp_module.h
> > +++ b/drivers/media/platform/dreamchip/rppx1/rpp_module.h
> > @@ -88,6 +88,8 @@ union rppx1_params_block {
> > struct rppx1_bls_params bls;
> > struct rppx1_lsc_params lsc;
> > struct rppx1_awbg_params awbg;
> > + struct rppx1_db_demosaic_params db_demosaic;
> > + struct rppx1_db_filter_params db_filter;
> > struct rppx1_ccor_params ccor;
> > struct rppx1_hist_params hist;
> > struct rppx1_exm_params exm;
> > diff --git a/drivers/media/platform/dreamchip/rppx1/rpp_params.c b/drivers/media/platform/dreamchip/rppx1/rpp_params.c
> > index 317ed715f1de..3320ca3998bd 100644
> > --- a/drivers/media/platform/dreamchip/rppx1/rpp_params.c
> > +++ b/drivers/media/platform/dreamchip/rppx1/rpp_params.c
> > @@ -22,6 +22,8 @@ rppx1_ext_params_blocks_info[] = {
> > RPPX1_PARAMS_BLOCK_INFO(LSC_PRE2, lsc),
> > RPPX1_PARAMS_BLOCK_INFO(AWBG_PRE1, awbg),
> > RPPX1_PARAMS_BLOCK_INFO(AWBG_PRE2, awbg),
> > + RPPX1_PARAMS_BLOCK_INFO(DB_DEMOSAIC_POST, db_demosaic),
> > + RPPX1_PARAMS_BLOCK_INFO(DB_FILTER_POST, db_filter),
> > RPPX1_PARAMS_BLOCK_INFO(CCOR_POST, ccor),
> > RPPX1_PARAMS_BLOCK_INFO(HIST_PRE1, hist),
> > RPPX1_PARAMS_BLOCK_INFO(HIST_PRE2, hist),
> > @@ -74,6 +76,11 @@ int rppx1_params(struct rppx1 *rpp, struct vb2_buffer *vb, size_t max_size,
> > case RPPX1_PARAMS_BLOCK_TYPE_AWBG_PRE1:
> > module = &rpp->pre1.awbg;
> > break;
> > + case RPPX1_PARAMS_BLOCK_TYPE_DB_DEMOSAIC_POST:
> > + case RPPX1_PARAMS_BLOCK_TYPE_DB_FILTER_POST:
> > + /* Both types handled by the same block. */
> > + module = &rpp->post.db;
> > + break;
> > case RPPX1_PARAMS_BLOCK_TYPE_CCOR_POST:
> > module = &rpp->post.ccor;
> > break;
> > diff --git a/drivers/media/platform/dreamchip/rppx1/rppx1_db.c b/drivers/media/platform/dreamchip/rppx1/rppx1_db.c
> > index 5e233896cfc8..5571b3a9562d 100644
> > --- a/drivers/media/platform/dreamchip/rppx1/rppx1_db.c
> > +++ b/drivers/media/platform/dreamchip/rppx1/rppx1_db.c
> > @@ -39,6 +39,88 @@ static int rppx1_db_probe(struct rpp_module *mod)
> > return 0;
> > }
> >
> > +static int
> > +rppx1_db_fill_params_demosaic(struct rpp_module *mod,
> > + const union rppx1_params_block *block,
> > + rppx1_reg_write write, void *priv)
> > +{
> > + const struct rppx1_db_demosaic_params *cfg = &block->db_demosaic;
> > +
> > + /* If the modules is disabled, simply bypass it. */
> > + if (cfg->header.flags & V4L2_ISP_PARAMS_FL_BLOCK_DISABLE) {
> > + write(priv, mod->base + DEMOSAIC_REG, 0x400);
> > + return 0;
> > + }
> > +
> > + /* Native threshold is at RPP 16-bit precision. */
> > + write(priv, mod->base + DEMOSAIC_REG, cfg->demosaic_th);
> > +
> > + return 0;
> > +}
> > +
> > +static int
> > +rppx1_db_fill_params_filter(struct rpp_module *mod,
> > + const union rppx1_params_block *block,
> > + rppx1_reg_write write, void *priv)
> > +{
> > + const struct rppx1_db_filter_params *cfg = &block->db_filter;
> > +
> > + /* If the modules is disabled, simply bypass it. */
> > + if (cfg->header.flags & V4L2_ISP_PARAMS_FL_BLOCK_DISABLE) {
> > + write(priv, mod->base + FILT_MODE_REG, 0);
> > + return 0;
> > + }
> > +
> > + /* Native values are at RPP 18-bit precision. */
> > + write(priv, mod->base + FILT_THRESH_BL0_REG, cfg->thresh_bl0);
> > + write(priv, mod->base + FILT_THRESH_BL0_REG, cfg->thresh_bl1);
> > + write(priv, mod->base + FILT_THRESH_SH0_REG, cfg->thresh_sh0);
> > + write(priv, mod->base + FILT_THRESH_SH1_REG, cfg->thresh_sh1);
> > +
> > + /* Native values are at RPP 8-bit precision. */
> > + write(priv, mod->base + FILT_FAC_BL0_REG, cfg->fac_bl0);
> > + write(priv, mod->base + FILT_FAC_BL1_REG, cfg->fac_bl1);
> > + write(priv, mod->base + FILT_FAC_MID_REG, cfg->fac_mid);
> > + write(priv, mod->base + FILT_FAC_SH0_REG, cfg->fac_sh0);
> > + write(priv, mod->base + FILT_FAC_SH1_REG, cfg->fac_sh1);
> > +
> > + /*
> > + * The lum_weight field is provided in RPP register format:
> > + *
> > + * 31 unused
> > + * 30:28 lum_weight_gain
> > + * 27:24 unused
> > + * 23:12 lum_weight_kink
> > + * 11:0 lum_weight_min
> > + */
> > + write(priv, mod->base + FILT_LUM_WEIGHT_REG, cfg->lum_weight);
> > +
> > + write(priv, mod->base + FILT_MODE_REG,
> > + (cfg->chr_v_mode << 4) |
> > + (cfg->chr_h_mode << 6) |
> > + (cfg->grn_stage1 << 8) |
> > + (cfg->mode ? FILT_MODE_FILT_MODE : 0) |
> > + FILT_MODE_FILT_ENABLE);
> > +
> > + return 0;
> > +}
> > +
> > +static int
> > +rppx1_db_fill_params(struct rpp_module *mod,
> > + const union rppx1_params_block *block,
> > + rppx1_reg_write write, void *priv)
> > +{
> > + switch (block->header.type) {
> > + case RPPX1_PARAMS_BLOCK_TYPE_DB_DEMOSAIC_POST:
> > + return rppx1_db_fill_params_demosaic(mod, block, write, priv);
> > + case RPPX1_PARAMS_BLOCK_TYPE_DB_FILTER_POST:
> > + return rppx1_db_fill_params_filter(mod, block, write, priv);
> > + }
> > +
> > + return -EINVAL;
> > +}
> > +
> > const struct rpp_module_ops rppx1_db_ops = {
> > .probe = rppx1_db_probe,
> > + .fill_params = rppx1_db_fill_params,
> > };
> > diff --git a/include/uapi/linux/media/dreamchip/rppx1-config.h b/include/uapi/linux/media/dreamchip/rppx1-config.h
> > index d173c0c1bfc0..378b18dbc48d 100644
> > --- a/include/uapi/linux/media/dreamchip/rppx1-config.h
> > +++ b/include/uapi/linux/media/dreamchip/rppx1-config.h
> > @@ -91,6 +91,8 @@ enum rppx1_meas_chan {
> > * @RPPX1_PARAMS_BLOCK_TYPE_LSC_PRE2: PRE2 Lens Shading Correction
> > * @RPPX1_PARAMS_BLOCK_TYPE_GA_HV: Human Vision Pipe Gamma Out Correction
> > * @RPPX1_PARAMS_BLOCK_TYPE_GA_MV: Machine Vision Gamma Out Correction
> > + * @RPPX1_PARAMS_BLOCK_TYPE_DB_DEMOSAIC_POST: Debayer demosaicing
> > + * @RPPX1_PARAMS_BLOCK_TYPE_DB_FILTER_POST: Debayer filtering
> > */
> > enum rppx1_params_block_type {
> > RPPX1_PARAMS_BLOCK_TYPE_WBMEAS_POST,
> > @@ -109,6 +111,8 @@ enum rppx1_params_block_type {
> > RPPX1_PARAMS_BLOCK_TYPE_LSC_PRE2,
> > RPPX1_PARAMS_BLOCK_TYPE_GA_HV,
> > RPPX1_PARAMS_BLOCK_TYPE_GA_MV,
> > + RPPX1_PARAMS_BLOCK_TYPE_DB_DEMOSAIC_POST,
> > + RPPX1_PARAMS_BLOCK_TYPE_DB_FILTER_POST,
> > };
> >
> > /**
> > @@ -544,6 +548,56 @@ struct rppx1_ga_params {
> > __u32 gamma_y[RPPX1_GA_MAX_SAMPLES];
> > };
> >
> > +/**
> > + * struct rppx1_db_demosaic_params - Debayer demosaic configuration
> > + *
> > + * @header: block header (type = RPPX1_PARAMS_BLOCK_TYPE_DB_DEMOSAIC_POST)
> > + * @demosaic_th: threshold for texture detection, 16-bit
> > + */
> > +struct rppx1_db_demosaic_params {
> > + struct v4l2_isp_params_block_header header;
> > + __u16 demosaic_th;
> > +};
> > +
> > +/**
> > + * struct rppx1_db_filter_params - Debayer filter (denoise) configuration
> > + *
> > + * RPP-X1 thresholds are 18-bit and factors are 8-bit.
> > + *
> > + * @header: block header (type = RPPX1_PARAMS_BLOCK_TYPE_DB_FILTER_POST)
> > + * @mode: filter mode
> > + * @grn_stage1: green filter stage 1 select (range 0x0...0x8)
> > + * @chr_h_mode: chroma filter horizontal mode
> > + * @chr_v_mode: chroma filter vertical mode
> > + * @thresh_bl0: If thresh_bl1 < sum_grad < thresh_bl0 then fac_bl0 is selected (blurring th)
> > + * @thresh_bl1: If sum_grad < thresh_bl1 then fac_bl1 is selected (blurring th)
> > + * @thresh_sh0: If thresh_sh0 < sum_grad < thresh_sh1 then thresh_sh0 is selected (sharpening th)
> > + * @thresh_sh1: If thresh_sh1 < sum_grad then thresh_sh1 is selected (sharpening th)
> > + * @lum_weight: luminance weight, min (bits 0:11), kink (bits 12:23), gain (bits 28:30)
> > + * @fac_sh1: filter factor for sharp1 level
> > + * @fac_sh0: filter factor for sharp0 level
> > + * @fac_mid: filter factor for mid level and for static filter mode
> > + * @fac_bl0: filter factor for blur0 level
> > + * @fac_bl1: filter factor for blur1 level (max blur)
> > + */
> > +struct rppx1_db_filter_params {
> > + struct v4l2_isp_params_block_header header;
> > + __u32 mode;
> > + __u8 grn_stage1;
> > + __u8 chr_h_mode;
> > + __u8 chr_v_mode;
> > + __u32 thresh_bl0;
> > + __u32 thresh_bl1;
> > + __u32 thresh_sh0;
> > + __u32 thresh_sh1;
> > + __u32 lum_weight;
> > + __u32 fac_sh1;
> > + __u32 fac_sh0;
> > + __u32 fac_mid;
> > + __u32 fac_bl0;
> > + __u32 fac_bl1;
> > +};
> > +
> > /**
> > * RPPX1_PARAMS_MAX_SIZE - Maximum size of all RPP-X1 parameter blocks
> > *
> > @@ -566,7 +620,9 @@ struct rppx1_ga_params {
> > sizeof(struct rppx1_lsc_params) + \
> > sizeof(struct rppx1_lsc_params) + \
> > sizeof(struct rppx1_ga_params) + \
> > - sizeof(struct rppx1_ga_params))
> > + sizeof(struct rppx1_ga_params) + \
> > + sizeof(struct rppx1_db_demosaic_params) + \
> > + sizeof(struct rppx1_db_filter_params))
> >
> > /* ---------------------------------------------------------------------------
> > * Statistics Structures
> > --
> > 2.54.0
> >
> >
--
Kind Regards,
Niklas Söderlund
next prev parent reply other threads:[~2026-05-16 20:47 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-04 1:05 [v8 00/14] media: Add support for R-Car ISP using Dreamchip RPPX1 ISP Niklas Söderlund
2026-05-04 1:05 ` [v8 01/14] media: Add RPP_X1_PARAMS and RPP_X1_STATS meta formats Niklas Söderlund
2026-05-06 7:45 ` Jacopo Mondi
2026-05-04 1:05 ` [v8 02/14] media: rppx1: Add framework to support Dreamchip RPPX1 ISP Niklas Söderlund
2026-05-06 8:53 ` Jacopo Mondi
2026-05-16 15:17 ` Niklas Söderlund
2026-06-03 8:27 ` Jacopo Mondi
2026-05-04 1:05 ` [v8 03/14] media: rcar-isp: Add support for ISPCORE Niklas Söderlund
2026-05-06 15:02 ` Jacopo Mondi
2026-05-16 20:16 ` Niklas Söderlund
2026-06-03 9:11 ` Jacopo Mondi
2026-06-03 12:45 ` Niklas Söderlund
2026-05-04 1:05 ` [v8 04/14] media: rppx1: wbmeas: Add support for white balance measurement Niklas Söderlund
2026-05-06 13:58 ` Antoine Bouyer
2026-05-06 14:22 ` Jacopo Mondi
2026-05-16 20:27 ` Niklas Söderlund
2026-05-04 1:05 ` [v8 05/14] media: rppx1: awbg: Add support for white balance gain settings Niklas Söderlund
2026-05-04 1:05 ` [v8 06/14] media: rppx1: exm: Add support for exposure measurement Niklas Söderlund
2026-05-04 1:05 ` [v8 07/14] media: rppx1: hist: Add support histogram measurement Niklas Söderlund
2026-05-06 15:51 ` Jacopo Mondi
2026-05-16 20:31 ` Niklas Söderlund
2026-05-04 1:05 ` [v8 08/14] media: rppx1: bls: Add support for black level compensation Niklas Söderlund
2026-05-06 15:25 ` Jacopo Mondi
2026-05-16 20:44 ` Niklas Söderlund
2026-06-03 9:35 ` Jacopo Mondi
2026-05-04 1:05 ` [v8 09/14] media: rppx1: ccor: Add support for color correction matrix Niklas Söderlund
2026-05-04 1:05 ` [v8 10/14] media: rppx1: lsc: Add support for lens shade correction Niklas Söderlund
2026-05-04 1:05 ` [v8 11/14] media: rppx1: ga: Add support for gamma out correction Niklas Söderlund
2026-05-04 1:05 ` [v8 12/14] media: rppx1: db: Add support for debayering filters Niklas Söderlund
2026-05-06 15:54 ` Jacopo Mondi
2026-05-16 20:47 ` Niklas Söderlund [this message]
2026-05-04 1:05 ` [v8 13/14] media: rppx1: bd: Add support for bilateral denoising Niklas Söderlund
2026-05-04 1:05 ` [v8 14/14] media: rppx1: lin: Add support for gamma sensor linearization Niklas Söderlund
2026-05-06 15:57 ` Jacopo Mondi
2026-05-16 20:56 ` Niklas Söderlund
2026-05-06 12:19 ` [v8 00/14] media: Add support for R-Car ISP using Dreamchip RPPX1 ISP Geert Uytterhoeven
2026-05-06 12:29 ` Niklas Söderlund
2026-05-06 12:49 ` Jacopo Mondi
2026-05-06 12:56 ` Geert Uytterhoeven
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=20260516204736.GA332351@ragnatech.se \
--to=niklas.soderlund+renesas@ragnatech.se \
--cc=jacopo.mondi@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 \
/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
Powered by JetHome