From: Ville Syrjälä <ville.syrj...@linux.intel.com>

We'll need to arm the vblank event also from the future
DSB based codepath. Extract the function that does the
whold dance for us.

Signed-off-by: Ville Syrjälä <ville.syrj...@linux.intel.com>
---
 drivers/gpu/drm/i915/display/intel_crtc.c | 29 +++++++++++++++--------
 drivers/gpu/drm/i915/display/intel_crtc.h |  1 +
 2 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_crtc.c 
b/drivers/gpu/drm/i915/display/intel_crtc.c
index 54b529bfc935..6831060a792a 100644
--- a/drivers/gpu/drm/i915/display/intel_crtc.c
+++ b/drivers/gpu/drm/i915/display/intel_crtc.c
@@ -560,6 +560,23 @@ static void dbg_vblank_evade(struct intel_crtc *crtc, 
ktime_t end)
 static void dbg_vblank_evade(struct intel_crtc *crtc, ktime_t end) {}
 #endif
 
+void intel_crtc_arm_vblank_event(struct intel_crtc_state *crtc_state)
+{
+       struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
+       unsigned long irqflags;
+
+       if (!crtc_state->uapi.event)
+               return;
+
+       drm_WARN_ON(crtc->base.dev, drm_crtc_vblank_get(&crtc->base) != 0);
+
+       spin_lock_irqsave(&crtc->base.dev->event_lock, irqflags);
+       drm_crtc_arm_vblank_event(&crtc->base, crtc_state->uapi.event);
+       spin_unlock_irqrestore(&crtc->base.dev->event_lock, irqflags);
+
+       crtc_state->uapi.event = NULL;
+}
+
 /**
  * intel_pipe_update_end() - end update of a set of display registers
  * @state: the atomic state
@@ -601,16 +618,8 @@ void intel_pipe_update_end(struct intel_atomic_state 
*state,
                drm_vblank_work_schedule(&new_crtc_state->vblank_work,
                                         
drm_crtc_accurate_vblank_count(&crtc->base) + 1,
                                         false);
-       } else if (new_crtc_state->uapi.event) {
-               drm_WARN_ON(&dev_priv->drm,
-                           drm_crtc_vblank_get(&crtc->base) != 0);
-
-               spin_lock(&crtc->base.dev->event_lock);
-               drm_crtc_arm_vblank_event(&crtc->base,
-                                         new_crtc_state->uapi.event);
-               spin_unlock(&crtc->base.dev->event_lock);
-
-               new_crtc_state->uapi.event = NULL;
+       } else {
+               intel_crtc_arm_vblank_event(new_crtc_state);
        }
 
        /*
diff --git a/drivers/gpu/drm/i915/display/intel_crtc.h 
b/drivers/gpu/drm/i915/display/intel_crtc.h
index 22d7993d1f0b..b615b7ab5ccd 100644
--- a/drivers/gpu/drm/i915/display/intel_crtc.h
+++ b/drivers/gpu/drm/i915/display/intel_crtc.h
@@ -28,6 +28,7 @@ struct intel_crtc_state;
 
 int intel_usecs_to_scanlines(const struct drm_display_mode *adjusted_mode,
                             int usecs);
+void intel_crtc_arm_vblank_event(struct intel_crtc_state *crtc_state);
 u32 intel_crtc_max_vblank_count(const struct intel_crtc_state *crtc_state);
 int intel_crtc_init(struct drm_i915_private *dev_priv, enum pipe pipe);
 struct intel_crtc_state *intel_crtc_state_alloc(struct intel_crtc *crtc);
-- 
2.44.2

Reply via email to