Commit 5316dd0d authored by Ville Syrjälä's avatar Ville Syrjälä

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: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240528185647.7765-5-ville.syrjala@linux.intel.comReviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
parent 9677dd01
...@@ -240,7 +240,7 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc) ...@@ -240,7 +240,7 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc)
* See update_scanline_offset() for the details on the * See update_scanline_offset() for the details on the
* scanline_offset adjustment. * scanline_offset adjustment.
*/ */
return (position + crtc->scanline_offset) % vtotal; return (position + vtotal + crtc->scanline_offset) % vtotal;
} }
int intel_crtc_scanline_to_hw(struct intel_crtc *crtc, int scanline) int intel_crtc_scanline_to_hw(struct intel_crtc *crtc, int scanline)
...@@ -470,7 +470,6 @@ void intel_wait_for_pipe_scanline_moving(struct intel_crtc *crtc) ...@@ -470,7 +470,6 @@ void intel_wait_for_pipe_scanline_moving(struct intel_crtc *crtc)
static int intel_crtc_scanline_offset(const struct intel_crtc_state *crtc_state) static int intel_crtc_scanline_offset(const struct intel_crtc_state *crtc_state)
{ {
struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev); struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev);
const struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode;
/* /*
* The scanline counter increments at the leading edge of hsync. * The scanline counter increments at the leading edge of hsync.
...@@ -482,8 +481,7 @@ static int intel_crtc_scanline_offset(const struct intel_crtc_state *crtc_state) ...@@ -482,8 +481,7 @@ static int intel_crtc_scanline_offset(const struct intel_crtc_state *crtc_state)
* last active line), the scanline counter will read vblank_start-1. * last active line), the scanline counter will read vblank_start-1.
* *
* On gen2 the scanline counter starts counting from 1 instead * On gen2 the scanline counter starts counting from 1 instead
* of vtotal-1, so we have to subtract one (or rather add vtotal-1 * of vtotal-1, so we have to subtract one.
* to keep the value positive), instead of adding one.
* *
* On HSW+ the behaviour of the scanline counter depends on the output * On HSW+ the behaviour of the scanline counter depends on the output
* type. For DP ports it behaves like most other platforms, but on HDMI * type. For DP ports it behaves like most other platforms, but on HDMI
...@@ -500,7 +498,7 @@ static int intel_crtc_scanline_offset(const struct intel_crtc_state *crtc_state) ...@@ -500,7 +498,7 @@ static int intel_crtc_scanline_offset(const struct intel_crtc_state *crtc_state)
* answer that's slightly in the future. * answer that's slightly in the future.
*/ */
if (DISPLAY_VER(i915) == 2) if (DISPLAY_VER(i915) == 2)
return intel_mode_vtotal(adjusted_mode) - 1; return -1;
else if (HAS_DDI(i915) && intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) else if (HAS_DDI(i915) && intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI))
return 2; return 2;
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment