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: Simplify scanline_offset handling for gen2

Currently intel_crtc_scanline_offset() is careful to always
return a positive offset. That is not actually necessary
as long as we take care of negative values when applying the
offset in __intel_get_crtc_scanline().

This simplifies intel_crtc_scanline_offset(), and makes
the scanline_offfset arithmetic more symmetric between
the forward (__intel_get_crtc_scanline()) and reverse
(intel_crtc_scanline_to_hw()) directions.

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

+3 -5
+3 -5
drivers/gpu/drm/i915/display/intel_vblank.c
··· 240 240 * See update_scanline_offset() for the details on the 241 241 * scanline_offset adjustment. 242 242 */ 243 - return (position + crtc->scanline_offset) % vtotal; 243 + return (position + vtotal + crtc->scanline_offset) % vtotal; 244 244 } 245 245 246 246 int intel_crtc_scanline_to_hw(struct intel_crtc *crtc, int scanline) ··· 470 470 static int intel_crtc_scanline_offset(const struct intel_crtc_state *crtc_state) 471 471 { 472 472 struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev); 473 - const struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode; 474 473 475 474 /* 476 475 * The scanline counter increments at the leading edge of hsync. ··· 481 482 * last active line), the scanline counter will read vblank_start-1. 482 483 * 483 484 * On gen2 the scanline counter starts counting from 1 instead 484 - * of vtotal-1, so we have to subtract one (or rather add vtotal-1 485 - * to keep the value positive), instead of adding one. 485 + * of vtotal-1, so we have to subtract one. 486 486 * 487 487 * On HSW+ the behaviour of the scanline counter depends on the output 488 488 * type. For DP ports it behaves like most other platforms, but on HDMI ··· 498 500 * answer that's slightly in the future. 499 501 */ 500 502 if (DISPLAY_VER(i915) == 2) 501 - return intel_mode_vtotal(adjusted_mode) - 1; 503 + return -1; 502 504 else if (HAS_DDI(i915) && intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) 503 505 return 2; 504 506 else