drm/i915: Introduce intel_crtc_scanline_to_hw()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 6 Jun 2023 19:15:01 +0000 (22:15 +0300)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 27 Sep 2023 15:47:08 +0000 (18:47 +0300)
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>
drivers/gpu/drm/i915/display/intel_vblank.c
drivers/gpu/drm/i915/display/intel_vblank.h

index f5659ebd08eb291eeb705383bd8d115a8acfd623..2cec2abf97466ca1600fd9f6404920e2f5bf9bda 100644 (file)
@@ -251,6 +251,20 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc)
        return (position + crtc->scanline_offset) % vtotal;
 }
 
+int intel_crtc_scanline_to_hw(struct intel_crtc *crtc, int scanline)
+{
+       const struct drm_vblank_crtc *vblank =
+               &crtc->base.dev->vblank[drm_crtc_index(&crtc->base)];
+       const struct drm_display_mode *mode = &vblank->hwmode;
+       int vtotal;
+
+       vtotal = mode->crtc_vtotal;
+       if (mode->flags & DRM_MODE_FLAG_INTERLACE)
+               vtotal /= 2;
+
+       return (scanline + vtotal - crtc->scanline_offset) % vtotal;
+}
+
 static bool i915_get_crtc_scanoutpos(struct drm_crtc *_crtc,
                                     bool in_vblank_irq,
                                     int *vpos, int *hpos,
index 08e706b29149518ed122ec644a2ebb2196f11dc2..17636f140c71dbaaac06547edd1724bdf2c369e9 100644 (file)
@@ -22,5 +22,6 @@ void intel_wait_for_pipe_scanline_stopped(struct intel_crtc *crtc);
 void intel_wait_for_pipe_scanline_moving(struct intel_crtc *crtc);
 void intel_crtc_update_active_timings(const struct intel_crtc_state *crtc_state,
                                      bool vrr_enable);
+int intel_crtc_scanline_to_hw(struct intel_crtc *crtc, int scanline);
 
 #endif /* __INTEL_VBLANK_H__ */