Skip to content

Commit fa9a58e

Browse files
tbaldenGtrCraft
authored andcommittedNov 25, 2021
Implement KCAL color calibration
kcal: sde_hw: color proc v4: add RGB bias Implement the RGB control part of kcal in new sde driver. Color mask bias can be applied at the points identified. Add internal values to be hooked for sysfs or other means of control. original concept: @savoca kernel 4.9 / sde_hw: @tbalden drm: msm: kcal: export rgb to userspace and clean it up Signed-off-by: Francisco Franco <[email protected]> drm: msm: kcal: hue, saturation, value and contrast adjustments drm: msm: kcal: make the userspace module param vars static and use short instead of integers Same reasoning as franciscofranco/enchilada@20461e4 There's no point in using integers where a short is big enough. Signed-off-by: Francisco Franco <[email protected]> Signed-off-by: Nathan Chancellor <[email protected]> kcal: pie: fix used pcc setup for sde path Signed-off-by: Carlos Ayrton Lopez Arroyo <[email protected]>
1 parent b433c0f commit fa9a58e

File tree

2 files changed

+65
-6
lines changed

2 files changed

+65
-6
lines changed
 

‎techpack/display/msm/sde/sde_hw_color_proc_v4.c

+64-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22
/*
3-
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
3+
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
4+
* Copyright (c) 2018, Pal Zoltan Illes (tbalden) - kcal rgb
45
*/
6+
#include <linux/moduleparam.h>
57
#include <drm/msm_drm_pp.h>
68
#include "sde_hw_color_proc_common_v4.h"
79
#include "sde_hw_color_proc_v4.h"
810

11+
static unsigned short kcal_red = 256;
12+
static unsigned short kcal_green = 256;
13+
static unsigned short kcal_blue = 256;
14+
static unsigned short kcal_hue = 0;
15+
static unsigned short kcal_sat = 255;
16+
static unsigned short kcal_val = 255;
17+
static unsigned short kcal_cont = 255;
18+
19+
module_param(kcal_red, short, 0644);
20+
module_param(kcal_green, short, 0644);
21+
module_param(kcal_blue, short, 0644);
22+
module_param(kcal_hue, short, 0644);
23+
module_param(kcal_sat, short, 0644);
24+
module_param(kcal_val, short, 0644);
25+
module_param(kcal_cont, short, 0644);
26+
927
static int sde_write_3d_gamut(struct sde_hw_blk_reg_map *hw,
1028
struct drm_msm_3d_gamut *payload, u32 base,
1129
u32 *opcode, u32 pipe, u32 scale_tbl_a_len,
@@ -203,13 +221,22 @@ void sde_setup_dspp_pccv4(struct sde_hw_dspp *ctx, void *cfg)
203221
struct drm_msm_pcc *pcc_cfg;
204222
struct drm_msm_pcc_coeff *coeffs = NULL;
205223
int i = 0;
224+
int kcal_min = 20;
206225
u32 base = 0;
226+
u32 opcode = 0, local_opcode = 0;
207227

208228
if (!ctx || !cfg) {
209229
DRM_ERROR("invalid param ctx %pK cfg %pK\n", ctx, cfg);
210230
return;
211231
}
212232

233+
if (kcal_red < kcal_min)
234+
kcal_red = kcal_min;
235+
if (kcal_green < kcal_min)
236+
kcal_green = kcal_min;
237+
if (kcal_blue < kcal_min)
238+
kcal_blue = kcal_min;
239+
213240
if (!hw_cfg->payload) {
214241
DRM_DEBUG_DRIVER("disable pcc feature\n");
215242
SDE_REG_WRITE(&ctx->hw, ctx->cap->sblk->pcc.base, 0);
@@ -223,7 +250,6 @@ void sde_setup_dspp_pccv4(struct sde_hw_dspp *ctx, void *cfg)
223250
}
224251

225252
pcc_cfg = hw_cfg->payload;
226-
227253
for (i = 0; i < PCC_NUM_PLANES; i++) {
228254
base = ctx->cap->sblk->pcc.base + (i * sizeof(u32));
229255
switch (i) {
@@ -260,15 +286,48 @@ void sde_setup_dspp_pccv4(struct sde_hw_dspp *ctx, void *cfg)
260286
}
261287

262288
SDE_REG_WRITE(&ctx->hw, base + PCC_C_OFF, coeffs->c);
263-
SDE_REG_WRITE(&ctx->hw, base + PCC_R_OFF, coeffs->r);
264-
SDE_REG_WRITE(&ctx->hw, base + PCC_G_OFF, coeffs->g);
265-
SDE_REG_WRITE(&ctx->hw, base + PCC_B_OFF, coeffs->b);
289+
290+
// RED
291+
SDE_REG_WRITE(&ctx->hw, base + PCC_R_OFF,
292+
i == 0 ? (coeffs->r * kcal_red) / 256 : coeffs->r);
293+
// GREEN
294+
SDE_REG_WRITE(&ctx->hw, base + PCC_G_OFF,
295+
i == 1 ? (coeffs->g * kcal_green) / 256 : coeffs->g);
296+
// BLUE
297+
SDE_REG_WRITE(&ctx->hw, base + PCC_B_OFF,
298+
i == 2 ? (coeffs->b * kcal_blue) / 256 : coeffs->b);
299+
266300
SDE_REG_WRITE(&ctx->hw, base + PCC_RG_OFF, coeffs->rg);
267301
SDE_REG_WRITE(&ctx->hw, base + PCC_RB_OFF, coeffs->rb);
268302
SDE_REG_WRITE(&ctx->hw, base + PCC_GB_OFF, coeffs->gb);
269303
SDE_REG_WRITE(&ctx->hw, base + PCC_RGB_OFF, coeffs->rgb);
270304
}
271305

306+
opcode = SDE_REG_READ(&ctx->hw, ctx->cap->sblk->hsic.base);
307+
308+
// HUE
309+
SDE_REG_WRITE(&ctx->hw, ctx->cap->sblk->hsic.base + PA_HUE_OFF,
310+
kcal_hue & PA_HUE_MASK);
311+
local_opcode |= PA_HUE_EN;
312+
313+
// SATURATION
314+
SDE_REG_WRITE(&ctx->hw, ctx->cap->sblk->hsic.base + PA_SAT_OFF,
315+
kcal_sat & PA_SAT_MASK);
316+
local_opcode |= PA_SAT_EN;
317+
318+
// VALUE
319+
SDE_REG_WRITE(&ctx->hw, ctx->cap->sblk->hsic.base + PA_VAL_OFF,
320+
kcal_val & PA_VAL_MASK);
321+
local_opcode |= PA_VAL_EN;
322+
323+
// CONTRAST
324+
SDE_REG_WRITE(&ctx->hw, ctx->cap->sblk->hsic.base + PA_CONT_OFF,
325+
kcal_cont & PA_CONT_MASK);
326+
local_opcode |= PA_CONT_EN;
327+
328+
opcode |= (local_opcode | PA_EN);
329+
SDE_REG_WRITE(&ctx->hw, ctx->cap->sblk->hsic.base, opcode);
330+
272331
SDE_REG_WRITE(&ctx->hw, ctx->cap->sblk->pcc.base, PCC_EN);
273332
}
274333

‎techpack/display/msm/sde/sde_hw_dspp.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static void dspp_pcc(struct sde_hw_dspp *c)
5959
c->ops.setup_pcc = sde_setup_dspp_pcc_v1_7;
6060
else if (c->cap->sblk->pcc.version ==
6161
(SDE_COLOR_PROCESS_VER(0x4, 0x0))) {
62-
ret = reg_dmav1_init_dspp_op_v4(SDE_DSPP_PCC, c->idx);
62+
ret = 1; // reg_dmav1_init_dspp_op_v4(SDE_DSPP_PCC, c->idx); use the sde one instead, with correct hsic settings possibilities
6363
if (!ret)
6464
c->ops.setup_pcc = reg_dmav1_setup_dspp_pccv4;
6565
else

0 commit comments

Comments
 (0)
Please sign in to comment.