As we move towards using a shorter, optimized guardband, we need to adjust
how the delayed vblank start is computed.

Adjust the crtc_vblank_start using Vtotal - guardband only when
intel_vrr_always_use_vrr_tg() is true.

Also update allow_vblank_delay_fastset() to permit vblank delay adjustments
while switching to lower refresh rate mode (LRR), when VRR TG is always
active. This avoids full modeset due to change in vblank start, while
maintaining consistent guardband.

These changes pave the way for future guardband optimization, by handling
the movement of the crtc_vblank_start for platforms that have VRR TG always
active.

v2: Drop the helper and add the adjustment directly to
intel_vrr_compute_guardband(). (Ville)

v3: Use adjusted_mode.crtc_vtotal instead of vmin and include the readout
logic to keep the compute and readout paths in sync. (Ville)

Signed-off-by: Ankit Nautiyal <[email protected]>
---
 drivers/gpu/drm/i915/display/intel_display.c | 10 ++++++++--
 drivers/gpu/drm/i915/display/intel_vrr.c     |  6 +++++-
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
b/drivers/gpu/drm/i915/display/intel_display.c
index ceee5ae99c2c..65a7da694ef6 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -4958,9 +4958,15 @@ static bool allow_vblank_delay_fastset(const struct 
intel_crtc_state *old_crtc_s
         * Allow fastboot to fix up vblank delay (handled via LRR
         * codepaths), a bit dodgy as the registers aren't
         * double buffered but seems to be working more or less...
+        *
+        * Also allow this when the VRR timing generator is always on,
+        * and optimized guardband is used. In such cases,
+        * vblank delay may vary even without inherited state, but it's
+        * still safe as VRR guardband is still same.
         */
-       return HAS_LRR(display) && old_crtc_state->inherited &&
-               !intel_crtc_has_type(old_crtc_state, INTEL_OUTPUT_DSI);
+       return HAS_LRR(display) &&
+              (old_crtc_state->inherited || 
intel_vrr_always_use_vrr_tg(display)) &&
+              !intel_crtc_has_type(old_crtc_state, INTEL_OUTPUT_DSI);
 }
 
 bool
diff --git a/drivers/gpu/drm/i915/display/intel_vrr.c 
b/drivers/gpu/drm/i915/display/intel_vrr.c
index 221b25832e56..a4b416da53f4 100644
--- a/drivers/gpu/drm/i915/display/intel_vrr.c
+++ b/drivers/gpu/drm/i915/display/intel_vrr.c
@@ -436,7 +436,7 @@ intel_vrr_max_guardband(struct intel_crtc_state *crtc_state)
 void intel_vrr_compute_guardband(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;
+       struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode;
 
        if (!intel_vrr_possible(crtc_state))
                return;
@@ -444,6 +444,10 @@ void intel_vrr_compute_guardband(struct intel_crtc_state 
*crtc_state)
        crtc_state->vrr.guardband = min(crtc_state->vrr.vmin - 
adjusted_mode->crtc_vdisplay,
                                        intel_vrr_max_guardband(crtc_state));
 
+       if (intel_vrr_always_use_vrr_tg(display))
+               adjusted_mode->crtc_vblank_start  =
+                       adjusted_mode->crtc_vtotal - crtc_state->vrr.guardband;
+
        if (DISPLAY_VER(display) < 13)
                crtc_state->vrr.pipeline_full =
                        intel_vrr_guardband_to_pipeline_full(crtc_state,
-- 
2.45.2

Reply via email to