drm/i915: Stop loading linear degamma LUT on glk needlessly
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Mon, 24 Oct 2022 16:15:14 +0000 (19:15 +0300)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 25 Oct 2022 22:38:52 +0000 (01:38 +0300)
Make glk_load_luts() a bit lighter for the common case
where neither the degamma LUT nor pipe CSC are enabled
by not loading the linear degamma LUT. Making .load_luts()
as lightweight as possible is a good idea since it may need
to execute from a vblank worker under tight deadlines.

My earlier reasoning for always loading the linear degamma LUT
was to avoid an extra LUT load when just enabling/disabling the
pipe CSC, but that is nonsense since we load the LUTs on every
flagged color management change/modeset anyway (either of which
is needed for a pipe CSC toggle).

We can also get rid of the glk_can_preload_luts() special
case since the presence of the degamma LUT will now always
match csc_enable.

v2: Fix typos (Uma)

Reviewed-by: Uma Shankar <uma.shankar@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221024161514.5340-6-ville.syrjala@linux.intel.com
drivers/gpu/drm/i915/display/intel_color.c

index 66d9eef92c45b12b39478423205d2d15b4fe581c..4bb113c39f4b1b0e3b12a6d0a7ab0f9378ab70a4 100644 (file)
@@ -1198,24 +1198,6 @@ static bool chv_can_preload_luts(const struct intel_crtc_state *new_crtc_state)
        return !old_crtc_state->post_csc_lut;
 }
 
-static bool glk_can_preload_luts(const struct intel_crtc_state *new_crtc_state)
-{
-       struct intel_crtc *crtc = to_intel_crtc(new_crtc_state->uapi.crtc);
-       struct intel_atomic_state *state =
-               to_intel_atomic_state(new_crtc_state->uapi.state);
-       const struct intel_crtc_state *old_crtc_state =
-               intel_atomic_get_old_crtc_state(state, crtc);
-
-       /*
-        * The hardware degamma is active whenever the pipe
-        * CSC is active. Thus even if the old state has no
-        * software degamma we need to avoid clobbering the
-        * linear hardware degamma mid scanout.
-        */
-       return !old_crtc_state->csc_enable &&
-               !old_crtc_state->post_csc_lut;
-}
-
 int intel_color_check(struct intel_crtc_state *crtc_state)
 {
        struct drm_i915_private *dev_priv = to_i915(crtc_state->uapi.crtc->dev);
@@ -1626,11 +1608,9 @@ static void glk_assign_luts(struct intel_crtc_state *crtc_state)
         * On GLK+ both pipe CSC and degamma LUT are controlled
         * by csc_enable. Hence for the cases where the CSC is
         * needed but degamma LUT is not we need to load a
-        * linear degamma LUT. In fact we'll just always load
-        * the degama LUT so that we don't have to reload
-        * it every time the pipe CSC is being enabled.
+        * linear degamma LUT.
         */
-       if (!crtc_state->pre_csc_lut)
+       if (crtc_state->csc_enable && !crtc_state->pre_csc_lut)
                drm_property_replace_blob(&crtc_state->pre_csc_lut,
                                          i915->display.color.glk_linear_degamma_lut);
 }
@@ -1671,7 +1651,7 @@ static int glk_color_check(struct intel_crtc_state *crtc_state)
 
        glk_assign_luts(crtc_state);
 
-       crtc_state->preload_luts = glk_can_preload_luts(crtc_state);
+       crtc_state->preload_luts = intel_can_preload_luts(crtc_state);
 
        return 0;
 }