1212#include "intel_vrr_regs.h"
1313#include "intel_dp.h"
1414
15- #define FIXED_POINT_PRECISION 100
16- #define CMRR_PRECISION_TOLERANCE 10
17-
1815bool intel_vrr_is_capable (struct intel_connector * connector )
1916{
2017 const struct drm_display_info * info = & connector -> base .display_info ;
@@ -110,52 +107,6 @@ int intel_vrr_vmax_vblank_start(const struct intel_crtc_state *crtc_state)
110107 return crtc_state -> vrr .vmax - intel_vrr_vblank_exit_length (crtc_state );
111108}
112109
113- static bool
114- is_cmrr_frac_required (struct intel_crtc_state * crtc_state )
115- {
116- int calculated_refresh_k , actual_refresh_k , pixel_clock_per_line ;
117- struct drm_display_mode * adjusted_mode = & crtc_state -> hw .adjusted_mode ;
118- struct drm_i915_private * i915 = to_i915 (crtc_state -> uapi .crtc -> dev );
119-
120- if (!HAS_CMRR (i915 ))
121- return false;
122-
123- actual_refresh_k =
124- drm_mode_vrefresh (adjusted_mode ) * FIXED_POINT_PRECISION ;
125- pixel_clock_per_line =
126- adjusted_mode -> crtc_clock * 1000 / adjusted_mode -> crtc_htotal ;
127- calculated_refresh_k =
128- pixel_clock_per_line * FIXED_POINT_PRECISION / adjusted_mode -> crtc_vtotal ;
129-
130- if ((actual_refresh_k - calculated_refresh_k ) < CMRR_PRECISION_TOLERANCE )
131- return false;
132-
133- return true;
134- }
135-
136- static unsigned int
137- cmrr_get_vtotal (struct intel_crtc_state * crtc_state , bool video_mode_required )
138- {
139- int multiplier_m = 1 , multiplier_n = 1 , vtotal , desired_refresh_rate ;
140- long long adjusted_pixel_rate ;
141- struct drm_display_mode * adjusted_mode = & crtc_state -> hw .adjusted_mode ;
142-
143- desired_refresh_rate = drm_mode_vrefresh (adjusted_mode );
144-
145- if (video_mode_required ) {
146- multiplier_m = 1001 ;
147- multiplier_n = 1000 ;
148- }
149-
150- crtc_state -> cmrr .cmrr_n =
151- desired_refresh_rate * adjusted_mode -> crtc_htotal * multiplier_n ;
152- vtotal = (adjusted_mode -> crtc_clock * 1000 * multiplier_n ) / crtc_state -> cmrr .cmrr_n ;
153- adjusted_pixel_rate = adjusted_mode -> crtc_clock * 1000 * multiplier_m ;
154- crtc_state -> cmrr .cmrr_m = do_div (adjusted_pixel_rate , crtc_state -> cmrr .cmrr_n );
155-
156- return vtotal ;
157- }
158-
159110void
160111intel_vrr_compute_config (struct intel_crtc_state * crtc_state ,
161112 struct drm_connector_state * conn_state )
@@ -165,7 +116,6 @@ intel_vrr_compute_config(struct intel_crtc_state *crtc_state,
165116 struct intel_connector * connector =
166117 to_intel_connector (conn_state -> connector );
167118 struct intel_dp * intel_dp = intel_attached_dp (connector );
168- bool is_edp = intel_dp_is_edp (intel_dp );
169119 struct drm_display_mode * adjusted_mode = & crtc_state -> hw .adjusted_mode ;
170120 const struct drm_display_info * info = & connector -> base .display_info ;
171121 int vmin , vmax ;
@@ -210,26 +160,21 @@ intel_vrr_compute_config(struct intel_crtc_state *crtc_state,
210160 crtc_state -> vrr .flipline = crtc_state -> vrr .vmin + 1 ;
211161
212162 /*
213- * When panel is VRR capable and userspace has
214- * not enabled adaptive sync mode then Fixed Average
215- * Vtotal mode should be enabled.
163+ * For XE_LPD+, we use guardband and pipeline override
164+ * is deprecated.
216165 */
166+ if (DISPLAY_VER (i915 ) >= 13 ) {
167+ crtc_state -> vrr .guardband =
168+ crtc_state -> vrr .vmin + 1 - adjusted_mode -> crtc_vblank_start ;
169+ } else {
170+ crtc_state -> vrr .pipeline_full =
171+ min (255 , crtc_state -> vrr .vmin - adjusted_mode -> crtc_vblank_start -
172+ crtc_state -> framestart_delay - 1 );
173+ }
174+
217175 if (crtc_state -> uapi .vrr_enabled ) {
218176 crtc_state -> vrr .enable = true;
219177 crtc_state -> mode_flags |= I915_MODE_FLAG_VRR ;
220- } else if (is_cmrr_frac_required (crtc_state ) && is_edp ) {
221- crtc_state -> vrr .enable = true;
222- crtc_state -> cmrr .enable = true;
223- /*
224- * TODO: Compute precise target refresh rate to determine
225- * if video_mode_required should be true. Currently set to
226- * false due to uncertainty about the precise target
227- * refresh Rate.
228- */
229- crtc_state -> vrr .vmax = cmrr_get_vtotal (crtc_state , false);
230- crtc_state -> vrr .vmin = crtc_state -> vrr .vmax ;
231- crtc_state -> vrr .flipline = crtc_state -> vrr .vmin ;
232- crtc_state -> mode_flags |= I915_MODE_FLAG_VRR ;
233178 }
234179
235180 if (intel_dp_as_sdp_supported (intel_dp )) {
@@ -240,19 +185,6 @@ intel_vrr_compute_config(struct intel_crtc_state *crtc_state,
240185 (crtc_state -> hw .adjusted_mode .crtc_vtotal -
241186 crtc_state -> hw .adjusted_mode .vsync_end );
242187 }
243-
244- /*
245- * For XE_LPD+, we use guardband and pipeline override
246- * is deprecated.
247- */
248- if (DISPLAY_VER (i915 ) >= 13 ) {
249- crtc_state -> vrr .guardband =
250- crtc_state -> vrr .vmin + 1 - adjusted_mode -> crtc_vblank_start ;
251- } else {
252- crtc_state -> vrr .pipeline_full =
253- min (255 , crtc_state -> vrr .vmin - adjusted_mode -> crtc_vblank_start -
254- crtc_state -> framestart_delay - 1 );
255- }
256188}
257189
258190static u32 trans_vrr_ctl (const struct intel_crtc_state * crtc_state )
@@ -392,8 +324,6 @@ void intel_vrr_get_config(struct intel_crtc_state *crtc_state)
392324 TRANS_VRR_CTL (dev_priv , cpu_transcoder ));
393325
394326 crtc_state -> vrr .enable = trans_vrr_ctl & VRR_CTL_VRR_ENABLE ;
395- if (HAS_CMRR (dev_priv ))
396- crtc_state -> cmrr .enable = (trans_vrr_ctl & VRR_CTL_CMRR_ENABLE );
397327
398328 if (crtc_state -> cmrr .enable ) {
399329 crtc_state -> cmrr .cmrr_n =
0 commit comments