drm/i915: Extract intel_crtc_vblank_delay()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 10 Dec 2024 21:09:50 +0000 (23:09 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 15 Jan 2025 17:12:30 +0000 (19:12 +0200)
Pull the vblank delay computation into a separate function.
We'll need more logic here soon and we don't want to pollute
intel_crtc_compute_config() with low level details.

We'll use HAS_DSB() to determine if any delay might be required
or not because delayed vblank only really exists for the
purposes of the DSB. It also doesn't event exists on any pre-tgl
platforms, which also don't have DSB. I was midly tempted
to check for the enable_dsb modparam here actually, but as
that can be changed dynamically via debugfs we'd need to either
reconfigure it on the fly or force a modeset. Neither will happen
currently, so we'll just assume DSB may be used of the platform
supports it.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20241210211007.5976-2-ville.syrjala@linux.intel.com
Reviewed-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
drivers/gpu/drm/i915/display/intel_display.c

index 4271da219b4105630106a2bc7e1fa42015ede1e1..5530bcf32b87a3ed75c2f33ae58b4286d4208f79 100644 (file)
@@ -2610,16 +2610,29 @@ static int intel_crtc_compute_pipe_mode(struct intel_crtc_state *crtc_state)
        return 0;
 }
 
-static bool intel_crtc_needs_wa_14015401596(struct intel_crtc_state *crtc_state)
+static bool intel_crtc_needs_wa_14015401596(const struct intel_crtc_state *crtc_state)
 {
        struct intel_display *display = to_intel_display(crtc_state);
-       const struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode;
 
        return intel_vrr_possible(crtc_state) && crtc_state->has_psr &&
-               adjusted_mode->crtc_vblank_start == adjusted_mode->crtc_vdisplay &&
                IS_DISPLAY_VER(display, 13, 14);
 }
 
+static int intel_crtc_vblank_delay(const struct intel_crtc_state *crtc_state)
+{
+       struct intel_display *display = to_intel_display(crtc_state);
+       int vblank_delay = 0;
+
+       if (!HAS_DSB(display))
+               return 0;
+
+       /* Wa_14015401596 */
+       if (intel_crtc_needs_wa_14015401596(crtc_state))
+               vblank_delay = max(vblank_delay, 1);
+
+       return vblank_delay;
+}
+
 static int intel_crtc_compute_config(struct intel_atomic_state *state,
                                     struct intel_crtc *crtc)
 {
@@ -2629,9 +2642,8 @@ static int intel_crtc_compute_config(struct intel_atomic_state *state,
                &crtc_state->hw.adjusted_mode;
        int ret;
 
-       /* Wa_14015401596 */
-       if (intel_crtc_needs_wa_14015401596(crtc_state))
-               adjusted_mode->crtc_vblank_start += 1;
+       adjusted_mode->crtc_vblank_start +=
+               intel_crtc_vblank_delay(crtc_state);
 
        ret = intel_dpll_crtc_compute_clock(state, crtc);
        if (ret)