From ca4edafa149011010b1943edafc3993a99c8df7c Mon Sep 17 00:00:00 2001 From: Ankit Nautiyal Date: Thu, 16 Oct 2025 11:24:08 +0530 Subject: drm/i915/vblank: Add helper to get correct vblank length MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently crtc_vblank_start is assumed to be the vblank_start for the fixed refresh rate case. That value can be different from the variable refresh rate case whenever always_use_vrr_tg()==false. On icl/tgl it's always different due to the extra vblank delay, and also on adl+ it could be different if we were to use an optimized guardband. So places where crtc_vblank_start is used to compute vblank length needs change so as to account for cases where vrr is enabled. Specifically with vrr.enable the effective vblank length is actually guardband. Add a helper to get the correct vblank length for both vrr and fixed refresh rate cases. Use this helper where vblank_start is used to compute the vblank length. Signed-off-by: Ankit Nautiyal Reviewed-by: Ville Syrjälä Link: https://lore.kernel.org/r/20251016055415.2101347-5-ankit.k.nautiyal@intel.com --- drivers/gpu/drm/i915/display/intel_vblank.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'drivers/gpu/drm/i915/display/intel_vblank.c') diff --git a/drivers/gpu/drm/i915/display/intel_vblank.c b/drivers/gpu/drm/i915/display/intel_vblank.c index 0b7fcc05e64c..2fc0c1c0bb87 100644 --- a/drivers/gpu/drm/i915/display/intel_vblank.c +++ b/drivers/gpu/drm/i915/display/intel_vblank.c @@ -767,3 +767,13 @@ int intel_vblank_evade(struct intel_vblank_evade_ctx *evade) return scanline; } + +int intel_crtc_vblank_length(const struct intel_crtc_state *crtc_state) +{ + const struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode; + + if (crtc_state->vrr.enable) + return crtc_state->vrr.guardband; + else + return adjusted_mode->crtc_vtotal - adjusted_mode->crtc_vblank_start; +} -- cgit v1.2.3