]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/i915:vrr: Separate out functions to compute vmin and vmax
authorAnkit Nautiyal <ankit.k.nautiyal@intel.com>
Tue, 11 Mar 2025 09:37:45 +0000 (15:07 +0530)
committerAnkit Nautiyal <ankit.k.nautiyal@intel.com>
Thu, 13 Mar 2025 12:15:25 +0000 (17:45 +0530)
Make helpers to compute vmin and vmax.

v2: Make the adjusted mode const (Ville)
Use reverse xmas tree order of declarations. (Ville)

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

index 106bfaf6649bd8af9de7af21745eb3a0c815be75..a88b77114867c1ed0c1c45941297a3f377b3c51c 100644 (file)
@@ -222,6 +222,34 @@ cmrr_get_vtotal(struct intel_crtc_state *crtc_state, bool video_mode_required)
        return vtotal;
 }
 
+static
+int intel_vrr_compute_vmin(struct intel_connector *connector,
+                          const struct drm_display_mode *adjusted_mode)
+{
+       const struct drm_display_info *info = &connector->base.display_info;
+       int vmin;
+
+       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,
+                          const struct drm_display_mode *adjusted_mode)
+{
+       const struct drm_display_info *info = &connector->base.display_info;
+       int vmax;
+
+       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;
+}
+
 void
 intel_vrr_compute_config(struct intel_crtc_state *crtc_state,
                         struct drm_connector_state *conn_state)
@@ -232,7 +260,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;
 
        /*
@@ -253,13 +280,8 @@ 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;