From: Ville Syrjälä <ville.syrj...@linux.intel.com>

Extract a few helpers to check whether the hw degamma or
gamma LUT is enabled.

Signed-off-by: Ville Syrjälä <ville.syrj...@linux.intel.com>
---
 drivers/gpu/drm/i915/display/intel_color.c | 27 ++++++++++++++++------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_color.c 
b/drivers/gpu/drm/i915/display/intel_color.c
index acf3d152edfe..f714c87d8e42 100644
--- a/drivers/gpu/drm/i915/display/intel_color.c
+++ b/drivers/gpu/drm/i915/display/intel_color.c
@@ -1628,12 +1628,15 @@ static int i9xx_gamma_precision(const struct 
intel_crtc_state *crtc_state)
        }
 }
 
+static bool ilk_crtc_has_gamma(const struct intel_crtc_state *crtc_state)
+{
+       return crtc_state->gamma_enable &&
+               (crtc_state->csc_mode & CSC_POSITION_BEFORE_GAMMA) != 0;
+}
+
 static int ilk_gamma_precision(const struct intel_crtc_state *crtc_state)
 {
-       if (!crtc_state->gamma_enable)
-               return 0;
-
-       if ((crtc_state->csc_mode & CSC_POSITION_BEFORE_GAMMA) == 0)
+       if (!ilk_crtc_has_gamma(crtc_state))
                return 0;
 
        switch (crtc_state->gamma_mode) {
@@ -1671,9 +1674,19 @@ static int glk_gamma_precision(const struct 
intel_crtc_state *crtc_state)
        }
 }
 
+static bool icl_crtc_has_degamma(const struct intel_crtc_state *crtc_state)
+{
+       return crtc_state->gamma_mode & PRE_CSC_GAMMA_ENABLE;
+}
+
+static bool icl_crtc_has_gamma(const struct intel_crtc_state *crtc_state)
+{
+       return crtc_state->gamma_mode & POST_CSC_GAMMA_ENABLE;
+}
+
 static int icl_gamma_precision(const struct intel_crtc_state *crtc_state)
 {
-       if ((crtc_state->gamma_mode & POST_CSC_GAMMA_ENABLE) == 0)
+       if (!icl_crtc_has_gamma(crtc_state))
                return 0;
 
        switch (crtc_state->gamma_mode & GAMMA_MODE_MODE_MASK) {
@@ -2241,10 +2254,10 @@ static void icl_read_luts(struct intel_crtc_state 
*crtc_state)
 {
        struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
 
-       if (crtc_state->gamma_mode & PRE_CSC_GAMMA_ENABLE)
+       if (icl_crtc_has_degamma(crtc_state))
                crtc_state->hw.degamma_lut = glk_read_degamma_lut(crtc);
 
-       if ((crtc_state->gamma_mode & POST_CSC_GAMMA_ENABLE) == 0)
+       if (!icl_crtc_has_gamma(crtc_state))
                return;
 
        switch (crtc_state->gamma_mode & GAMMA_MODE_MODE_MASK) {
-- 
2.26.2

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to