]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
drm/i915: Extract chv_color_check()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 27 Mar 2019 15:50:39 +0000 (17:50 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Thu, 28 Mar 2019 19:29:53 +0000 (21:29 +0200)
Since CHV has the CGM unit we require a custom implementation
of .color_check().

This fixes the computation of gamma_enable as previously we
left it enabled even when were using the CGM gamma instead.
Now we turn off the legacy LUT unless it's actually required.

v2: Add some comment explaining the color pipeline (Matt)

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190327155045.28446-5-ville.syrjala@linux.intel.com
drivers/gpu/drm/i915/intel_color.c

index cdd5eccb767b8709405ec4efe48a11181cb8492b..87cc204a1dbfcb6d7af5e9cae9d4c5849f73e747 100644 (file)
@@ -848,6 +848,41 @@ static u32 chv_cgm_mode(const struct intel_crtc_state *crtc_state)
        return cgm_mode;
 }
 
+/*
+ * CHV color pipeline:
+ * u0.10 -> CGM degamma -> u0.14 -> CGM csc -> u0.14 -> CGM gamma ->
+ * u0.10 -> WGC csc -> u0.10 -> pipe gamma -> u0.10
+ *
+ * We always bypass the WGC csc and use the CGM csc
+ * instead since it has degamma and better precision.
+ */
+static int chv_color_check(struct intel_crtc_state *crtc_state)
+{
+       int ret;
+
+       ret = check_luts(crtc_state);
+       if (ret)
+               return ret;
+
+       /*
+        * Pipe gamma will be used only for the legacy LUT.
+        * Otherwise we bypass it and use the CGM gamma instead.
+        */
+       crtc_state->gamma_enable =
+               crtc_state_is_legacy_gamma(crtc_state) &&
+               !crtc_state->c8_planes;
+
+       crtc_state->gamma_mode = GAMMA_MODE_MODE_8BIT;
+
+       crtc_state->cgm_mode = chv_cgm_mode(crtc_state);
+
+       ret = intel_color_add_affected_planes(crtc_state);
+       if (ret)
+               return ret;
+
+       return 0;
+}
+
 static int _intel_color_check(struct intel_crtc_state *crtc_state)
 {
        struct drm_i915_private *dev_priv = to_i915(crtc_state->base.crtc->dev);
@@ -877,9 +912,6 @@ static int _intel_color_check(struct intel_crtc_state *crtc_state)
 
        crtc_state->csc_mode = 0;
 
-       if (IS_CHERRYVIEW(dev_priv))
-               crtc_state->cgm_mode = chv_cgm_mode(crtc_state);
-
        if (!crtc_state->gamma_enable ||
            crtc_state_is_legacy_gamma(crtc_state))
                crtc_state->gamma_mode = GAMMA_MODE_MODE_8BIT;
@@ -917,7 +949,7 @@ void intel_color_init(struct intel_crtc *crtc)
 
        if (HAS_GMCH(dev_priv)) {
                if (IS_CHERRYVIEW(dev_priv)) {
-                       dev_priv->display.color_check = _intel_color_check;
+                       dev_priv->display.color_check = chv_color_check;
                        dev_priv->display.color_commit = i9xx_color_commit;
                        dev_priv->display.load_luts = cherryview_load_luts;
                } else {