Now that the pre_csc_lut and non-pre_csc_lut paths look similar, deduplicate the loops and just determine the value based on pre_csc_lut vs. not.
Signed-off-by: Jani Nikula <[email protected]> --- 'git show -w' for easy review --- drivers/gpu/drm/i915/display/intel_color.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_color.c b/drivers/gpu/drm/i915/display/intel_color.c index 9f9ba0cf58a1..3eb42c2ae635 100644 --- a/drivers/gpu/drm/i915/display/intel_color.c +++ b/drivers/gpu/drm/i915/display/intel_color.c @@ -4018,28 +4018,22 @@ xelpd_program_plane_post_csc_lut(struct intel_dsb *dsb, /* TODO: Add macro */ intel_de_write_dsb(display, dsb, PLANE_POST_CSC_GAMC_SEG0_INDEX_ENH(pipe, plane, 0), PLANE_PAL_PREC_AUTO_INCREMENT); - if (post_csc_lut) { - for (i = 0; i < lut_size + 3; i++) { + + for (i = 0; i < lut_size + 3; i++) { + if (post_csc_lut) { if (i < lut_size) lut_val = drm_color_lut32_extract(post_csc_lut[i].green, 24); /* else clamp to the last LUT value to prevent step discontinuity */ - - intel_de_write_dsb(display, dsb, - PLANE_POST_CSC_GAMC_DATA_ENH(pipe, plane, 0), - lut_val); - } - } else { - /*TODO: Add for segment 0 */ - for (i = 0; i < lut_size + 3; i++) { + } else { if (i < lut_size) lut_val = (i * ((1 << 24) - 1)) / (lut_size - 1); else lut_val = 1 << 24; - - intel_de_write_dsb(display, dsb, - PLANE_POST_CSC_GAMC_DATA_ENH(pipe, plane, 0), - lut_val); } + + intel_de_write_dsb(display, dsb, + PLANE_POST_CSC_GAMC_DATA_ENH(pipe, plane, 0), + lut_val); } intel_de_write_dsb(display, dsb, PLANE_POST_CSC_GAMC_INDEX_ENH(pipe, plane, 0), 0); -- 2.47.3
