Skip to content
This repository has been archived by the owner on Nov 14, 2021. It is now read-only.

Commit

Permalink
drm: msm: kcal: hue, saturation, value and contrast adjustments
Browse files Browse the repository at this point in the history
Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
  • Loading branch information
flar2 authored and 0ctobot committed Sep 3, 2021
1 parent 2959485 commit ac4ffdc
Showing 1 changed file with 39 additions and 5 deletions.
44 changes: 39 additions & 5 deletions techpack/display/msm/sde/sde_hw_color_proc_v4.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@
unsigned int kcal_red = 256;
unsigned int kcal_green = 256;
unsigned int kcal_blue = 256;
unsigned int kcal_hue = 0;
unsigned int kcal_sat = 255;
unsigned int kcal_val = 255;
unsigned int kcal_cont = 255;

module_param(kcal_red, uint, 0644);
module_param(kcal_green, uint, 0644);
module_param(kcal_blue, uint, 0644);
module_param(kcal_hue, uint, 0644);
module_param(kcal_sat, uint, 0644);
module_param(kcal_val, uint, 0644);
module_param(kcal_cont, uint, 0644);

static int sde_write_3d_gamut(struct sde_hw_blk_reg_map *hw,
struct drm_msm_3d_gamut *payload, u32 base,
Expand Down Expand Up @@ -214,6 +222,7 @@ void sde_setup_dspp_pccv4(struct sde_hw_dspp *ctx, void *cfg)
int i = 0;
int kcal_min = 20;
u32 base = 0;
u32 opcode = 0, local_opcode = 0;

if (!ctx || !cfg) {
DRM_ERROR("invalid param ctx %pK cfg %pK\n", ctx, cfg);
Expand Down Expand Up @@ -276,23 +285,48 @@ void sde_setup_dspp_pccv4(struct sde_hw_dspp *ctx, void *cfg)
}

SDE_REG_WRITE(&ctx->hw, base + PCC_C_OFF, coeffs->c);
// ====
// RED

// RED
SDE_REG_WRITE(&ctx->hw, base + PCC_R_OFF,
i == 0 ? (coeffs->r * kcal_red) / 256 : coeffs->r);
// GREEN
// GREEN
SDE_REG_WRITE(&ctx->hw, base + PCC_G_OFF,
i == 1 ? (coeffs->g * kcal_green) / 256 : coeffs->g);
// BLUE
// BLUE
SDE_REG_WRITE(&ctx->hw, base + PCC_B_OFF,
i == 2 ? (coeffs->b * kcal_blue) / 256 : coeffs->b);
// =====

SDE_REG_WRITE(&ctx->hw, base + PCC_RG_OFF, coeffs->rg);
SDE_REG_WRITE(&ctx->hw, base + PCC_RB_OFF, coeffs->rb);
SDE_REG_WRITE(&ctx->hw, base + PCC_GB_OFF, coeffs->gb);
SDE_REG_WRITE(&ctx->hw, base + PCC_RGB_OFF, coeffs->rgb);
}

opcode = SDE_REG_READ(&ctx->hw, ctx->cap->sblk->hsic.base);

// HUE
SDE_REG_WRITE(&ctx->hw, ctx->cap->sblk->hsic.base + PA_HUE_OFF,
kcal_hue & PA_HUE_MASK);
local_opcode |= PA_HUE_EN;

// SATURATION
SDE_REG_WRITE(&ctx->hw, ctx->cap->sblk->hsic.base + PA_SAT_OFF,
kcal_sat & PA_SAT_MASK);
local_opcode |= PA_SAT_EN;

// VALUE
SDE_REG_WRITE(&ctx->hw, ctx->cap->sblk->hsic.base + PA_VAL_OFF,
kcal_val & PA_VAL_MASK);
local_opcode |= PA_VAL_EN;

// CONTRAST
SDE_REG_WRITE(&ctx->hw, ctx->cap->sblk->hsic.base + PA_CONT_OFF,
kcal_cont & PA_CONT_MASK);
local_opcode |= PA_CONT_EN;

opcode |= (local_opcode | PA_EN);
SDE_REG_WRITE(&ctx->hw, ctx->cap->sblk->hsic.base, opcode);

SDE_REG_WRITE(&ctx->hw, ctx->cap->sblk->pcc.base, PCC_EN);
}

Expand Down

0 comments on commit ac4ffdc

Please sign in to comment.