Skip to content

Commit 435cbb0

Browse files
ckborahaknautiyal
authored andcommitted
drm/i915/color: Upscale degamma values for MTL
MTL onwards Degamma LUT/PRE-CSC LUT precision has been increased from 16 bits to 24 bits. Currently, drm framework only supports LUTs up to 16 bit precision. Until a new uapi comes along to support higher bitdepth, upscale the values sent from userland to 24 bit before writing into the HW to continue supporting degamma on MTL. Add helper function to upscale or downscale lut values. Parameters 'to' and 'from' needs to be less than 32. This should be sufficient as currently there are no lut values exceeding 32 bit. v2: (Jani) - Reuse glk_load_degamma_lut() - Create a helper function for upscaling values v3: Fix multi line comment style (Uma) v4: Remove extra line(Ankit) Signed-off-by: Chaitanya Kumar Borah <[email protected]> Reviewed-by: Uma Shankar <[email protected]> Signed-off-by: Ankit Nautiyal <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 4948738 commit 435cbb0

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

drivers/gpu/drm/i915/display/intel_color.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,16 @@ static int glk_degamma_lut_size(struct drm_i915_private *i915)
14531453
return 35;
14541454
}
14551455

1456+
/*
1457+
* change_lut_val_precision: helper function to upscale or downscale lut values.
1458+
* Parameters 'to' and 'from' needs to be less than 32. This should be sufficient
1459+
* as currently there are no lut values exceeding 32 bit.
1460+
*/
1461+
static u32 change_lut_val_precision(u32 lut_val, int to, int from)
1462+
{
1463+
return mul_u32_u32(lut_val, (1 << to)) / (1 << from);
1464+
}
1465+
14561466
static void glk_load_degamma_lut(const struct intel_crtc_state *crtc_state,
14571467
const struct drm_property_blob *blob)
14581468
{
@@ -1487,8 +1497,15 @@ static void glk_load_degamma_lut(const struct intel_crtc_state *crtc_state,
14871497
* ToDo: Extend to max 7.0. Enable 32 bit input value
14881498
* as compared to just 16 to achieve this.
14891499
*/
1500+
u32 lut_val;
1501+
1502+
if (DISPLAY_VER(i915) >= 14)
1503+
lut_val = change_lut_val_precision(lut[i].green, 24, 16);
1504+
else
1505+
lut_val = lut[i].green;
1506+
14901507
ilk_lut_write(crtc_state, PRE_CSC_GAMC_DATA(pipe),
1491-
lut[i].green);
1508+
lut_val);
14921509
}
14931510

14941511
/* Clamp values > 1.0. */

0 commit comments

Comments
 (0)