Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/i915: Extract intel_mode_vtotal()

We have several copies of code calculating the hardware's
idea of vtotal. Pull that to a helper, similar to
intel_mode_vblank_{start,end}().

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240528185647.7765-4-ville.syrjala@linux.intel.com
Reviewed-by: Jani Nikula <jani.nikula@intel.com>

+18 -23
+17 -23
drivers/gpu/drm/i915/display/intel_vblank.c
··· 207 207 if (crtc->mode_flags & I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP) 208 208 return __intel_get_crtc_scanline_from_timestamp(crtc); 209 209 210 - vtotal = mode->crtc_vtotal; 211 - if (mode->flags & DRM_MODE_FLAG_INTERLACE) 212 - vtotal /= 2; 210 + vtotal = intel_mode_vtotal(mode); 213 211 214 212 position = intel_de_read_fw(dev_priv, PIPEDSL(pipe)) & PIPEDSL_LINE_MASK; 215 213 ··· 247 249 { 248 250 const struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(&crtc->base); 249 251 const struct drm_display_mode *mode = &vblank->hwmode; 250 - int vtotal; 251 - 252 - vtotal = mode->crtc_vtotal; 253 - if (mode->flags & DRM_MODE_FLAG_INTERLACE) 254 - vtotal /= 2; 252 + int vtotal = intel_mode_vtotal(mode); 255 253 256 254 return (scanline + vtotal - crtc->scanline_offset) % vtotal; 257 255 } ··· 304 310 305 311 htotal = mode->crtc_htotal; 306 312 hsync_start = mode->crtc_hsync_start; 307 - vtotal = mode->crtc_vtotal; 313 + vtotal = intel_mode_vtotal(mode); 308 314 vbl_start = intel_mode_vblank_start(mode); 309 315 vbl_end = intel_mode_vblank_end(mode); 310 - 311 - if (mode->flags & DRM_MODE_FLAG_INTERLACE) 312 - vtotal /= 2; 313 316 314 317 /* 315 318 * Enter vblank critical section, as we will do multiple ··· 499 508 * However if queried just before the start of vblank we'll get an 500 509 * answer that's slightly in the future. 501 510 */ 502 - if (DISPLAY_VER(i915) == 2) { 503 - int vtotal; 504 - 505 - vtotal = adjusted_mode->crtc_vtotal; 506 - if (adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE) 507 - vtotal /= 2; 508 - 509 - return vtotal - 1; 510 - } else if (HAS_DDI(i915) && intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) { 511 + if (DISPLAY_VER(i915) == 2) 512 + return intel_mode_vtotal(adjusted_mode) - 1; 513 + else if (HAS_DDI(i915) && intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) 511 514 return 2; 512 - } else { 515 + else 513 516 return 1; 514 - } 515 517 } 516 518 517 519 void intel_crtc_update_active_timings(const struct intel_crtc_state *crtc_state, ··· 574 590 vblank_end /= 2; 575 591 576 592 return vblank_end; 593 + } 594 + 595 + int intel_mode_vtotal(const struct drm_display_mode *mode) 596 + { 597 + int vtotal = mode->crtc_vtotal; 598 + 599 + if (mode->flags & DRM_MODE_FLAG_INTERLACE) 600 + vtotal /= 2; 601 + 602 + return vtotal; 577 603 } 578 604 579 605 void intel_vblank_evade_init(const struct intel_crtc_state *old_crtc_state,
+1
drivers/gpu/drm/i915/display/intel_vblank.h
··· 22 22 23 23 int intel_mode_vblank_start(const struct drm_display_mode *mode); 24 24 int intel_mode_vblank_end(const struct drm_display_mode *mode); 25 + int intel_mode_vtotal(const struct drm_display_mode *mode); 25 26 26 27 void intel_vblank_evade_init(const struct intel_crtc_state *old_crtc_state, 27 28 const struct intel_crtc_state *new_crtc_state,