Skip to content

Commit 77d8285

Browse files
committed
drm/i915: Introduce intel_crtc_scanline_to_hw()
Add a helper to convert our idea of a scanline to the hw's idea of the same scanline (ie. apply crtc->scanline_offset in reverse). We'll need this to tell the DSB do stuff on a specific scanline. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230606191504.18099-17-ville.syrjala@linux.intel.com Reviewed-by: Uma Shankar <uma.shankar@intel.com>
1 parent b428328 commit 77d8285

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

drivers/gpu/drm/i915/display/intel_vblank.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,20 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc)
251251
return (position + crtc->scanline_offset) % vtotal;
252252
}
253253

254+
int intel_crtc_scanline_to_hw(struct intel_crtc *crtc, int scanline)
255+
{
256+
const struct drm_vblank_crtc *vblank =
257+
&crtc->base.dev->vblank[drm_crtc_index(&crtc->base)];
258+
const struct drm_display_mode *mode = &vblank->hwmode;
259+
int vtotal;
260+
261+
vtotal = mode->crtc_vtotal;
262+
if (mode->flags & DRM_MODE_FLAG_INTERLACE)
263+
vtotal /= 2;
264+
265+
return (scanline + vtotal - crtc->scanline_offset) % vtotal;
266+
}
267+
254268
static bool i915_get_crtc_scanoutpos(struct drm_crtc *_crtc,
255269
bool in_vblank_irq,
256270
int *vpos, int *hpos,

drivers/gpu/drm/i915/display/intel_vblank.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ void intel_wait_for_pipe_scanline_stopped(struct intel_crtc *crtc);
2222
void intel_wait_for_pipe_scanline_moving(struct intel_crtc *crtc);
2323
void intel_crtc_update_active_timings(const struct intel_crtc_state *crtc_state,
2424
bool vrr_enable);
25+
int intel_crtc_scanline_to_hw(struct intel_crtc *crtc, int scanline);
2526

2627
#endif /* __INTEL_VBLANK_H__ */

0 commit comments

Comments
 (0)