Commit 9677dd01 authored by Ville Syrjälä's avatar Ville Syrjälä

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: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240528185647.7765-4-ville.syrjala@linux.intel.comReviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
parent 1fea2978
...@@ -207,9 +207,7 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc) ...@@ -207,9 +207,7 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc)
if (crtc->mode_flags & I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP) if (crtc->mode_flags & I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP)
return __intel_get_crtc_scanline_from_timestamp(crtc); return __intel_get_crtc_scanline_from_timestamp(crtc);
vtotal = mode->crtc_vtotal; vtotal = intel_mode_vtotal(mode);
if (mode->flags & DRM_MODE_FLAG_INTERLACE)
vtotal /= 2;
position = intel_de_read_fw(dev_priv, PIPEDSL(pipe)) & PIPEDSL_LINE_MASK; position = intel_de_read_fw(dev_priv, PIPEDSL(pipe)) & PIPEDSL_LINE_MASK;
...@@ -249,11 +247,7 @@ int intel_crtc_scanline_to_hw(struct intel_crtc *crtc, int scanline) ...@@ -249,11 +247,7 @@ int intel_crtc_scanline_to_hw(struct intel_crtc *crtc, int scanline)
{ {
const struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(&crtc->base); const struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(&crtc->base);
const struct drm_display_mode *mode = &vblank->hwmode; const struct drm_display_mode *mode = &vblank->hwmode;
int vtotal; int vtotal = intel_mode_vtotal(mode);
vtotal = mode->crtc_vtotal;
if (mode->flags & DRM_MODE_FLAG_INTERLACE)
vtotal /= 2;
return (scanline + vtotal - crtc->scanline_offset) % vtotal; return (scanline + vtotal - crtc->scanline_offset) % vtotal;
} }
...@@ -310,13 +304,10 @@ static bool i915_get_crtc_scanoutpos(struct drm_crtc *_crtc, ...@@ -310,13 +304,10 @@ static bool i915_get_crtc_scanoutpos(struct drm_crtc *_crtc,
htotal = mode->crtc_htotal; htotal = mode->crtc_htotal;
hsync_start = mode->crtc_hsync_start; hsync_start = mode->crtc_hsync_start;
vtotal = mode->crtc_vtotal; vtotal = intel_mode_vtotal(mode);
vbl_start = intel_mode_vblank_start(mode); vbl_start = intel_mode_vblank_start(mode);
vbl_end = intel_mode_vblank_end(mode); vbl_end = intel_mode_vblank_end(mode);
if (mode->flags & DRM_MODE_FLAG_INTERLACE)
vtotal /= 2;
/* /*
* Enter vblank critical section, as we will do multiple * Enter vblank critical section, as we will do multiple
* timing critical raw register reads, potentially with * timing critical raw register reads, potentially with
...@@ -508,19 +499,12 @@ static int intel_crtc_scanline_offset(const struct intel_crtc_state *crtc_state) ...@@ -508,19 +499,12 @@ static int intel_crtc_scanline_offset(const struct intel_crtc_state *crtc_state)
* However if queried just before the start of vblank we'll get an * However if queried just before the start of vblank we'll get an
* answer that's slightly in the future. * answer that's slightly in the future.
*/ */
if (DISPLAY_VER(i915) == 2) { if (DISPLAY_VER(i915) == 2)
int vtotal; return intel_mode_vtotal(adjusted_mode) - 1;
else if (HAS_DDI(i915) && intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI))
vtotal = adjusted_mode->crtc_vtotal;
if (adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE)
vtotal /= 2;
return vtotal - 1;
} else if (HAS_DDI(i915) && intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) {
return 2; return 2;
} else { else
return 1; return 1;
}
} }
void intel_crtc_update_active_timings(const struct intel_crtc_state *crtc_state, void intel_crtc_update_active_timings(const struct intel_crtc_state *crtc_state,
...@@ -592,6 +576,16 @@ int intel_mode_vblank_end(const struct drm_display_mode *mode) ...@@ -592,6 +576,16 @@ int intel_mode_vblank_end(const struct drm_display_mode *mode)
return vblank_end; return vblank_end;
} }
int intel_mode_vtotal(const struct drm_display_mode *mode)
{
int vtotal = mode->crtc_vtotal;
if (mode->flags & DRM_MODE_FLAG_INTERLACE)
vtotal /= 2;
return vtotal;
}
void intel_vblank_evade_init(const struct intel_crtc_state *old_crtc_state, void intel_vblank_evade_init(const struct intel_crtc_state *old_crtc_state,
const struct intel_crtc_state *new_crtc_state, const struct intel_crtc_state *new_crtc_state,
struct intel_vblank_evade_ctx *evade) struct intel_vblank_evade_ctx *evade)
......
...@@ -22,6 +22,7 @@ struct intel_vblank_evade_ctx { ...@@ -22,6 +22,7 @@ struct intel_vblank_evade_ctx {
int intel_mode_vblank_start(const struct drm_display_mode *mode); int intel_mode_vblank_start(const struct drm_display_mode *mode);
int intel_mode_vblank_end(const struct drm_display_mode *mode); int intel_mode_vblank_end(const struct drm_display_mode *mode);
int intel_mode_vtotal(const struct drm_display_mode *mode);
void intel_vblank_evade_init(const struct intel_crtc_state *old_crtc_state, void intel_vblank_evade_init(const struct intel_crtc_state *old_crtc_state,
const struct intel_crtc_state *new_crtc_state, const struct intel_crtc_state *new_crtc_state,
......
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