[PATCH 39/45] media: qcom: camss: sa8775p: add white balance parameters
From: Gjorgji . Rosikopulos . gjorgji . rosikopulos
Date: Tue Oct 06 2026 - 18:50:49 EST
From: Gjorgji Rosikopulos <gjorgji.rosikopulos@xxxxxxxxxxxxxxxx>
Program the red, green, and blue white balance gains from IFE parameter
buffers. Enable or disable the gain block as requested.
Signed-off-by: Gjorgji Rosikopulos <gjorgji.rosikopulos@xxxxxxxxxxxxxxxx>
Signed-off-by: Atanas Filipov <atanas.filipov@xxxxxxxxxxxxxxxx>
---
.../platform/qcom/camss/camss-ife-mod-v41x.c | 42 +++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/drivers/media/platform/qcom/camss/camss-ife-mod-v41x.c b/drivers/media/platform/qcom/camss/camss-ife-mod-v41x.c
index 77d33c05cc6e..3c53f585133c 100644
--- a/drivers/media/platform/qcom/camss/camss-ife-mod-v41x.c
+++ b/drivers/media/platform/qcom/camss/camss-ife-mod-v41x.c
@@ -179,6 +179,36 @@ static void mod_v41x_wb_gain_config(struct ife_pp_ctx *ctx)
writel_relaxed(value, base + IFE_MOD_V41X_WB_GAIN_CFG_2);
}
+static void mod_v41x_wb_gain_set(struct ife_pp_ctx *ctx,
+ const struct camss_ife_params_wb_gain *cfg)
+{
+ void __iomem *base = ctx->base + IFE_MOD_V41X_WB_GAIN_OFFSET;
+
+ writel_relaxed(FIELD_PREP(IFE_MOD_V41X_WB_GAIN_VALUE, cfg->g),
+ base + IFE_MOD_V41X_WB_GAIN_CFG_0);
+ writel_relaxed(FIELD_PREP(IFE_MOD_V41X_WB_GAIN_VALUE, cfg->b),
+ base + IFE_MOD_V41X_WB_GAIN_CFG_1);
+ writel_relaxed(FIELD_PREP(IFE_MOD_V41X_WB_GAIN_VALUE, cfg->r),
+ base + IFE_MOD_V41X_WB_GAIN_CFG_2);
+}
+
+static void mod_v41x_wb_gain_apply(struct ife_pp_ctx *ctx,
+ const struct camss_ife_params_wb_gain *cfg,
+ bool enable)
+{
+ void __iomem *base = ctx->base + IFE_MOD_V41X_WB_GAIN_OFFSET;
+ u32 value;
+
+ value = readl_relaxed(base + IFE_MOD_V41X_WB_GAIN_MODULE_CFG);
+ if (enable) {
+ mod_v41x_wb_gain_set(ctx, cfg);
+ value |= IFE_MOD_V41X_WB_GAIN_CFG_EN;
+ } else {
+ value &= ~IFE_MOD_V41X_WB_GAIN_CFG_EN;
+ }
+ writel_relaxed(value, base + IFE_MOD_V41X_WB_GAIN_MODULE_CFG);
+}
+
static void mod_v41x_demosaic_config(struct ife_pp_ctx *ctx)
{
void __iomem *base = ctx->base + IFE_MOD_V41X_DEMOSAIC_OFFSET;
@@ -632,6 +662,14 @@ static void mod_v41x_params_apply_lsc(void *priv, const union camss_ife_params_b
mod_v41x_lsc_apply(ctx, &block->lsc, enable);
}
+static void mod_v41x_params_apply_wb(void *priv, const union camss_ife_params_block *block)
+{
+ struct ife_pp_ctx *ctx = priv;
+ bool enable = block->header.flags & V4L2_ISP_PARAMS_FL_BLOCK_ENABLE;
+
+ mod_v41x_wb_gain_apply(ctx, &block->wb_gain, enable);
+}
+
static void mod_v41x_params_apply_gamma(void *priv, const union camss_ife_params_block *block)
{
struct ife_pp_ctx *ctx = priv;
@@ -650,12 +688,16 @@ static const struct v4l2_isp_params_block_type_info mod_v41x_params_type_info[]
[CAMSS_IFE_PARAMS_GAMMA_256] = {
.size = sizeof(struct camss_ife_params_gamma_256),
},
+ [CAMSS_IFE_PARAMS_WB_GAIN] = {
+ .size = sizeof(struct camss_ife_params_wb_gain),
+ },
};
static const camss_ife_params_handler_fn mod_v41x_params_handlers[] = {
[CAMSS_IFE_PARAMS_COLOR_CORRECT] = mod_v41x_params_apply_ccm,
[CAMSS_IFE_PARAMS_LSC] = mod_v41x_params_apply_lsc,
[CAMSS_IFE_PARAMS_GAMMA_256] = mod_v41x_params_apply_gamma,
+ [CAMSS_IFE_PARAMS_WB_GAIN] = mod_v41x_params_apply_wb,
};
static_assert(ARRAY_SIZE(mod_v41x_params_handlers) ==
--
2.34.1