Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: intel-xe@lists.freedesktop.org, jani.nikula@linux.intel.com,
	ville.syrjala@linux.intel.com,
	mitulkumar.ajitkumar.golani@intel.com
Subject: [PATCH 01/23] drm/i915/vrr: Refactor VRR Timing Computation
Date: Mon, 11 Nov 2024 14:41:59 +0530	[thread overview]
Message-ID: <20241111091221.2992818-2-ankit.k.nautiyal@intel.com> (raw)
In-Reply-To: <20241111091221.2992818-1-ankit.k.nautiyal@intel.com>

Introduce helper functions to compute timins gfor different mode of
operation of VRR timing generator.

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
---
 drivers/gpu/drm/i915/display/intel_vrr.c | 115 +++++++++++++++--------
 1 file changed, 75 insertions(+), 40 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_vrr.c b/drivers/gpu/drm/i915/display/intel_vrr.c
index 19a5d0076bb8..defe346b0261 100644
--- a/drivers/gpu/drm/i915/display/intel_vrr.c
+++ b/drivers/gpu/drm/i915/display/intel_vrr.c
@@ -161,6 +161,73 @@ cmrr_get_vtotal(struct intel_crtc_state *crtc_state, bool video_mode_required)
 	return vtotal;
 }
 
+static
+void intel_vrr_compute_cmrr_timings(struct intel_crtc_state *crtc_state)
+{
+	crtc_state->vrr.enable = true;
+	crtc_state->cmrr.enable = true;
+	/*
+	 * TODO: Compute precise target refresh rate to determine
+	 * if video_mode_required should be true. Currently set to
+	 * false due to uncertainty about the precise target
+	 * refresh Rate.
+	 */
+	crtc_state->vrr.vmax = cmrr_get_vtotal(crtc_state, false);
+	crtc_state->vrr.vmin = crtc_state->vrr.vmax;
+	crtc_state->vrr.flipline = crtc_state->vrr.vmin;
+	crtc_state->mode_flags |= I915_MODE_FLAG_VRR;
+}
+
+static
+int intel_vrr_compute_vmin(struct intel_connector *connector,
+			   struct drm_display_mode *adjusted_mode)
+{
+	int vmin;
+	const struct drm_display_info *info = &connector->base.display_info;
+
+	vmin = DIV_ROUND_UP(adjusted_mode->crtc_clock * 1000,
+			    adjusted_mode->crtc_htotal * info->monitor_range.max_vfreq);
+	vmin = max_t(int, vmin, adjusted_mode->crtc_vtotal);
+
+	return vmin;
+}
+
+static
+int intel_vrr_compute_vmax(struct intel_connector *connector,
+			   struct drm_display_mode *adjusted_mode)
+{
+	int vmax;
+	const struct drm_display_info *info = &connector->base.display_info;
+
+	vmax = adjusted_mode->crtc_clock * 1000 /
+		(adjusted_mode->crtc_htotal * info->monitor_range.min_vfreq);
+
+	vmax = max_t(int, vmax, adjusted_mode->crtc_vtotal);
+
+	return vmax;
+}
+
+static
+void intel_vrr_prepare_vrr_timings(struct intel_crtc_state *crtc_state, int vmin, int vmax)
+{
+	/*
+	 * flipline determines the min vblank length the hardware will
+	 * generate, and flipline>=vmin+1, hence we reduce vmin by one
+	 * to make sure we can get the actual min vblank length.
+	 */
+	crtc_state->vrr.vmin = vmin - 1;
+	crtc_state->vrr.vmax = vmax;
+	crtc_state->vrr.flipline = crtc_state->vrr.vmin + 1;
+}
+
+static
+void intel_vrr_compute_vrr_timings(struct intel_crtc_state *crtc_state, int vmin, int vmax)
+{
+	intel_vrr_prepare_vrr_timings(crtc_state, vmin, vmax);
+	crtc_state->vrr.enable = true;
+	crtc_state->mode_flags |= I915_MODE_FLAG_VRR;
+}
+
 void
 intel_vrr_compute_config(struct intel_crtc_state *crtc_state,
 			 struct drm_connector_state *conn_state)
@@ -171,7 +238,6 @@ intel_vrr_compute_config(struct intel_crtc_state *crtc_state,
 	struct intel_dp *intel_dp = intel_attached_dp(connector);
 	bool is_edp = intel_dp_is_edp(intel_dp);
 	struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode;
-	const struct drm_display_info *info = &connector->base.display_info;
 	int vmin, vmax;
 
 	/*
@@ -192,49 +258,18 @@ intel_vrr_compute_config(struct intel_crtc_state *crtc_state,
 	if (HAS_LRR(display))
 		crtc_state->update_lrr = true;
 
-	vmin = DIV_ROUND_UP(adjusted_mode->crtc_clock * 1000,
-			    adjusted_mode->crtc_htotal * info->monitor_range.max_vfreq);
-	vmax = adjusted_mode->crtc_clock * 1000 /
-		(adjusted_mode->crtc_htotal * info->monitor_range.min_vfreq);
-
-	vmin = max_t(int, vmin, adjusted_mode->crtc_vtotal);
-	vmax = max_t(int, vmax, adjusted_mode->crtc_vtotal);
+	vmin = intel_vrr_compute_vmin(connector, adjusted_mode);
+	vmax = intel_vrr_compute_vmax(connector, adjusted_mode);
 
 	if (vmin >= vmax)
 		return;
 
-	/*
-	 * flipline determines the min vblank length the hardware will
-	 * generate, and flipline>=vmin+1, hence we reduce vmin by one
-	 * to make sure we can get the actual min vblank length.
-	 */
-	crtc_state->vrr.vmin = vmin - 1;
-	crtc_state->vrr.vmax = vmax;
-
-	crtc_state->vrr.flipline = crtc_state->vrr.vmin + 1;
-
-	/*
-	 * When panel is VRR capable and userspace has
-	 * not enabled adaptive sync mode then Fixed Average
-	 * Vtotal mode should be enabled.
-	 */
-	if (crtc_state->uapi.vrr_enabled) {
-		crtc_state->vrr.enable = true;
-		crtc_state->mode_flags |= I915_MODE_FLAG_VRR;
-	} else if (is_cmrr_frac_required(crtc_state) && is_edp) {
-		crtc_state->vrr.enable = true;
-		crtc_state->cmrr.enable = true;
-		/*
-		 * TODO: Compute precise target refresh rate to determine
-		 * if video_mode_required should be true. Currently set to
-		 * false due to uncertainty about the precise target
-		 * refresh Rate.
-		 */
-		crtc_state->vrr.vmax = cmrr_get_vtotal(crtc_state, false);
-		crtc_state->vrr.vmin = crtc_state->vrr.vmax;
-		crtc_state->vrr.flipline = crtc_state->vrr.vmin;
-		crtc_state->mode_flags |= I915_MODE_FLAG_VRR;
-	}
+	if (crtc_state->uapi.vrr_enabled)
+		intel_vrr_compute_vrr_timings(crtc_state, vmin, vmax);
+	else if (is_cmrr_frac_required(crtc_state) && is_edp)
+		intel_vrr_compute_cmrr_timings(crtc_state);
+	else
+		intel_vrr_prepare_vrr_timings(crtc_state, vmin, vmax);
 
 	if (intel_dp->as_sdp_supported && crtc_state->vrr.enable) {
 		crtc_state->vrr.vsync_start =
-- 
2.45.2


  reply	other threads:[~2024-11-11  9:09 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-11  9:11 [PATCH 00/23] Use VRR timing generator for fixed refresh rate modes Ankit Nautiyal
2024-11-11  9:11 ` Ankit Nautiyal [this message]
2024-11-11 17:48   ` [PATCH 01/23] drm/i915/vrr: Refactor VRR Timing Computation Garg, Nemesa
2024-11-11 17:49     ` Garg, Nemesa
2024-11-12  3:54     ` Nautiyal, Ankit K
2024-11-11  9:12 ` [PATCH 02/23] drm/i915/vrr: Simplify CMRR Enable Check in intel_vrr_get_config Ankit Nautiyal
2024-11-11  9:12 ` [PATCH 03/23] drm/i915/vrr: Introduce new field for VRR mode Ankit Nautiyal
2024-11-11 17:33   ` Garg, Nemesa
2024-11-12  3:51     ` Nautiyal, Ankit K
2024-11-12 11:32   ` Jani Nikula
2024-11-12 11:33     ` Jani Nikula
2024-11-12 12:51       ` Nautiyal, Ankit K
2024-11-11  9:12 ` [PATCH 04/23] drm/i915/vrr: Fill VRR mode for CMRR and dynamic VRR Ankit Nautiyal
2024-11-11  9:12 ` [PATCH 05/23] drm/i915/vrr: Rename vrr.enable to vrr.tg_enable Ankit Nautiyal
2024-11-11  9:12 ` [PATCH 06/23] drm/i915/display: Absorb cmrr attributes into vrr Ankit Nautiyal
2024-11-11  9:12 ` [PATCH 07/23] drm/i915/display: Add vrr mode to crtc_state dump Ankit Nautiyal
2024-11-12 11:29   ` Jani Nikula
2024-11-11  9:12 ` [PATCH 08/23] drm/i915/vrr: Remove condition flipline > vmin for LNL Ankit Nautiyal
2024-11-11  9:12 ` [PATCH 09/23] drm/i915/vrr: Compute vrr vsync if platforms support it Ankit Nautiyal
2024-11-11  9:12 ` [PATCH 10/23] drm/i915/dp: Avoid vrr compute config for HDMI sink Ankit Nautiyal
2024-11-11  9:12 ` [PATCH 11/23] drm/i915/dp: fix the Adaptive sync Operation mode for SDP Ankit Nautiyal
2024-11-11  9:12 ` [PATCH 12/23] drm/i915/hdmi: Use VRR Timing generator for HDMI Ankit Nautiyal
2024-11-11  9:12 ` [PATCH 13/23] drm/i915/vrr: Handle joiner with vrr Ankit Nautiyal
2024-11-11  9:12 ` [PATCH 14/23] drm/i915/display: Handle transcoder timings for joiner Ankit Nautiyal
2024-11-11  9:12 ` [PATCH 15/23] drm/i915/vrr: Introduce VRR mode Fixed RR Ankit Nautiyal
2024-11-11  9:12 ` [PATCH 16/23] drm/i915/vrr: Fill fixed refresh mode in vrr_get_compute_config Ankit Nautiyal
2024-11-11  9:12 ` [PATCH 17/23] drm/i915/display: Enable MSA Ignore Timing PAR only when in not fixed_rr mode Ankit Nautiyal
2024-11-11  9:12 ` [PATCH 18/23] drm/i915/dp: Set FAVT mode in DP SDP with fixed refresh rate Ankit Nautiyal
2024-11-11  9:12 ` [PATCH 19/23] drm/i915/vrr: Avoid sending PUSH when VRR TG is used with Fixed " Ankit Nautiyal
2024-11-11  9:12 ` [PATCH 20/23] drm/i915/display: Disable PSR before disabling VRR Ankit Nautiyal
2024-11-11  9:12 ` [PATCH 21/23] drm/i915/psr: Allow PSR for fixed refrsh rate with VRR TG Ankit Nautiyal
2024-11-11  9:12 ` [PATCH 22/23] drm/i915/vrr: Always use VRR timing generator for XE2LPD+ Ankit Nautiyal
2024-11-11  9:12 ` [PATCH 23/23] drm/i915/display: Use VRR timings for XE2LPD+ in modeset sequence Ankit Nautiyal
2024-11-11  9:17 ` ✓ CI.Patch_applied: success for Use VRR timing generator for fixed refresh rate modes Patchwork
2024-11-11  9:18 ` ✓ CI.checkpatch: " Patchwork
2024-11-11  9:19 ` ✓ CI.KUnit: " Patchwork
2024-11-11  9:30 ` ✓ CI.Build: " Patchwork
2024-11-11  9:33 ` ✓ CI.Hooks: " Patchwork
2024-11-11  9:35 ` ✗ CI.checksparse: warning " Patchwork
2024-11-11  9:56 ` ✗ CI.BAT: failure " Patchwork
2024-11-11 10:15 ` ✗ CI.FULL: " Patchwork
2024-12-13 17:31 ` [PATCH 00/23] " Ville Syrjälä
2025-01-22 10:38   ` Nautiyal, Ankit K
2025-01-22 13:08     ` Ville Syrjälä
2025-01-22 13:27       ` Nautiyal, Ankit K

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241111091221.2992818-2-ankit.k.nautiyal@intel.com \
    --to=ankit.k.nautiyal@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=mitulkumar.ajitkumar.golani@intel.com \
    --cc=ville.syrjala@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox