From: Pranay Samala <[email protected]>

Move HDR plane post-CSC LUT programming to improve code organization.

Also removes the segment 0 index register writes as it is not currently
programmed.

Signed-off-by: Pranay Samala <[email protected]>
Signed-off-by: Chaitanya Kumar Borah <[email protected]>
---
 drivers/gpu/drm/i915/display/intel_color.c | 92 +++++++++++-----------
 1 file changed, 48 insertions(+), 44 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_color.c 
b/drivers/gpu/drm/i915/display/intel_color.c
index 9f7c2a328868..3578606e0ed4 100644
--- a/drivers/gpu/drm/i915/display/intel_color.c
+++ b/drivers/gpu/drm/i915/display/intel_color.c
@@ -4061,6 +4061,52 @@ xelpd_program_plane_pre_csc_lut(struct intel_dsb *dsb,
                xelpd_load_sdr_pre_csc_lut(display, dsb, pipe, plane, 
pre_csc_lut);
 }
 
+static void
+xelpd_load_hdr_post_csc_lut(struct intel_display *display,
+                           struct intel_dsb *dsb,
+                           enum pipe pipe,
+                           enum plane_id plane,
+                           const struct drm_color_lut32 *post_csc_lut)
+{
+       u32 lut_size = 32;
+       u32 lut_val;
+       int i;
+
+       intel_de_write_dsb(display, dsb, PLANE_POST_CSC_GAMC_INDEX_ENH(pipe, 
plane, 0),
+                          PLANE_PAL_PREC_AUTO_INCREMENT);
+
+       if (post_csc_lut) {
+               for (i = 0; i < lut_size; i++) {
+                       lut_val = 
drm_color_lut32_extract(post_csc_lut[i].green, 24);
+
+                       intel_de_write_dsb(display, dsb,
+                                          PLANE_POST_CSC_GAMC_DATA_ENH(pipe, 
plane, 0),
+                                          lut_val);
+               }
+
+               do {
+                       intel_de_write_dsb(display, dsb,
+                                          PLANE_POST_CSC_GAMC_DATA_ENH(pipe, 
plane, 0),
+                                          (1 << 24));
+               } while (i++ < 34);
+       } else {
+               for (i = 0; i < lut_size; i++) {
+                       lut_val = (i * ((1 << 24) - 1)) / (lut_size - 1);
+
+                       intel_de_write_dsb(display, dsb,
+                                          PLANE_POST_CSC_GAMC_DATA_ENH(pipe, 
plane, 0), lut_val);
+               }
+
+               do {
+                       intel_de_write_dsb(display, dsb,
+                                          PLANE_POST_CSC_GAMC_DATA_ENH(pipe, 
plane, 0),
+                                          1 << 24);
+               } while (i++ < 34);
+       }
+
+       intel_de_write_dsb(display, dsb, PLANE_POST_CSC_GAMC_INDEX_ENH(pipe, 
plane, 0), 0);
+}
+
 static void
 xelpd_program_plane_post_csc_lut(struct intel_dsb *dsb,
                                 const struct intel_plane_state *plane_state)
@@ -4070,51 +4116,9 @@ xelpd_program_plane_post_csc_lut(struct intel_dsb *dsb,
        enum pipe pipe = to_intel_plane(state->plane)->pipe;
        enum plane_id plane = to_intel_plane(state->plane)->id;
        const struct drm_color_lut32 *post_csc_lut = 
plane_state->hw.gamma_lut->data;
-       u32 i, lut_size, lut_val;
-
-       if (icl_is_hdr_plane(display, plane)) {
-               intel_de_write_dsb(display, dsb, 
PLANE_POST_CSC_GAMC_INDEX_ENH(pipe, plane, 0),
-                                  PLANE_PAL_PREC_AUTO_INCREMENT);
-               /* 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) {
-                       lut_size = 32;
-                       for (i = 0; i < lut_size; i++) {
-                               lut_val = 
drm_color_lut32_extract(post_csc_lut[i].green, 24);
-
-                               intel_de_write_dsb(display, dsb,
-                                                  
PLANE_POST_CSC_GAMC_DATA_ENH(pipe, plane, 0),
-                                                  lut_val);
-                       }
-
-                       /* Segment 2 */
-                       do {
-                               intel_de_write_dsb(display, dsb,
-                                                  
PLANE_POST_CSC_GAMC_DATA_ENH(pipe, plane, 0),
-                                                  (1 << 24));
-                       } while (i++ < 34);
-               } else {
-                       /*TODO: Add for segment 0 */
-                       lut_size = 32;
-                       for (i = 0; i < lut_size; i++) {
-                               u32 v = (i * ((1 << 24) - 1)) / (lut_size - 1);
-
-                               intel_de_write_dsb(display, dsb,
-                                                  
PLANE_POST_CSC_GAMC_DATA_ENH(pipe, plane, 0), v);
-                       }
-
-                       do {
-                               intel_de_write_dsb(display, dsb,
-                                                  
PLANE_POST_CSC_GAMC_DATA_ENH(pipe, plane, 0),
-                                                  1 << 24);
-                       } while (i++ < 34);
-               }
 
-               intel_de_write_dsb(display, dsb, 
PLANE_POST_CSC_GAMC_INDEX_ENH(pipe, plane, 0), 0);
-               intel_de_write_dsb(display, dsb,
-                                  PLANE_POST_CSC_GAMC_SEG0_INDEX_ENH(pipe, 
plane, 0), 0);
-       }
+       if (icl_is_hdr_plane(display, plane))
+               xelpd_load_hdr_post_csc_lut(display, dsb, pipe, plane, 
post_csc_lut);
 }
 
 static void
-- 
2.25.1

Reply via email to