Add color .get_config hook to read config other than LUTs and CSCs, and
start off with CHV CGM pipe mode to abstract the platform specific
register access better.

Signed-off-by: Jani Nikula <[email protected]>
---
 drivers/gpu/drm/i915/display/intel_color.c   | 16 ++++++++++++++++
 drivers/gpu/drm/i915/display/intel_display.c |  4 ----
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_color.c 
b/drivers/gpu/drm/i915/display/intel_color.c
index f458b136e6a8..0a6d5ff494eb 100644
--- a/drivers/gpu/drm/i915/display/intel_color.c
+++ b/drivers/gpu/drm/i915/display/intel_color.c
@@ -76,6 +76,10 @@ struct intel_color_funcs {
         * software state. Used by eg. the hardware state checker.
         */
        void (*read_csc)(struct intel_crtc_state *crtc_state);
+       /*
+        * Read config other than LUTs and CSCs, before them. Optional.
+        */
+       void (*get_config)(struct intel_crtc_state *crtc_state);
 };
 
 #define CTM_COEFF_SIGN (1ULL << 63)
@@ -1737,6 +1741,9 @@ void intel_color_get_config(struct intel_crtc_state 
*crtc_state)
 {
        struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev);
 
+       if (i915->display.funcs.color->get_config)
+               i915->display.funcs.color->get_config(crtc_state);
+
        i915->display.funcs.color->read_luts(crtc_state);
 
        if (i915->display.funcs.color->read_csc)
@@ -3004,6 +3011,14 @@ static struct drm_property_blob 
*chv_read_cgm_gamma(struct intel_crtc *crtc)
        return blob;
 }
 
+static void chv_get_config(struct intel_crtc_state *crtc_state)
+{
+       struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
+       struct drm_i915_private *i915 = to_i915(crtc->base.dev);
+
+       crtc_state->cgm_mode = intel_de_read(i915, CGM_PIPE_MODE(crtc->pipe));
+}
+
 static void chv_read_luts(struct intel_crtc_state *crtc_state)
 {
        struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
@@ -3365,6 +3380,7 @@ static const struct intel_color_funcs chv_color_funcs = {
        .read_luts = chv_read_luts,
        .lut_equal = chv_lut_equal,
        .read_csc = chv_read_csc,
+       .get_config = chv_get_config,
 };
 
 static const struct intel_color_funcs i965_color_funcs = {
diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
b/drivers/gpu/drm/i915/display/intel_display.c
index bca7664d1ffc..9b9b885db8d4 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -2935,10 +2935,6 @@ static bool i9xx_get_pipe_config(struct intel_crtc *crtc,
 
        pipe_config->framestart_delay = 
REG_FIELD_GET(TRANSCONF_FRAME_START_DELAY_MASK, tmp) + 1;
 
-       if (IS_CHERRYVIEW(dev_priv))
-               pipe_config->cgm_mode = intel_de_read(dev_priv,
-                                                     
CGM_PIPE_MODE(crtc->pipe));
-
        i9xx_get_pipe_color_config(pipe_config);
        intel_color_get_config(pipe_config);
 
-- 
2.39.2

Reply via email to