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

Extract the code for staging the vblank event for the
flip done interrupt handler. We'll reuse this for DSB
stuff later.

Reviewed-by: Animesh Manna <animesh.ma...@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrj...@linux.intel.com>
---
 drivers/gpu/drm/i915/display/intel_crtc.c | 21 +++++++++++++++------
 drivers/gpu/drm/i915/display/intel_crtc.h |  3 +++
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_crtc.c 
b/drivers/gpu/drm/i915/display/intel_crtc.c
index 8ed8dd5fe458..4c653e9076d5 100644
--- a/drivers/gpu/drm/i915/display/intel_crtc.c
+++ b/drivers/gpu/drm/i915/display/intel_crtc.c
@@ -521,12 +521,8 @@ void intel_pipe_update_start(struct intel_atomic_state 
*state,
        intel_psr_lock(new_crtc_state);
 
        if (new_crtc_state->do_async_flip) {
-               spin_lock_irq(&crtc->base.dev->event_lock);
-               /* arm the event for the flip done irq handler */
-               crtc->flip_done_event = new_crtc_state->uapi.event;
-               spin_unlock_irq(&crtc->base.dev->event_lock);
-
-               new_crtc_state->uapi.event = NULL;
+               intel_crtc_prepare_vblank_event(new_crtc_state,
+                                               &crtc->flip_done_event);
                return;
        }
 
@@ -626,6 +622,19 @@ void intel_crtc_arm_vblank_event(struct intel_crtc_state 
*crtc_state)
        crtc_state->uapi.event = NULL;
 }
 
+void intel_crtc_prepare_vblank_event(struct intel_crtc_state *crtc_state,
+                                    struct drm_pending_vblank_event **event)
+{
+       struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
+       unsigned long irqflags;
+
+       spin_lock_irqsave(&crtc->base.dev->event_lock, irqflags);
+       *event = 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
diff --git a/drivers/gpu/drm/i915/display/intel_crtc.h 
b/drivers/gpu/drm/i915/display/intel_crtc.h
index 34ffbd2ee1b7..de54ae1deedf 100644
--- a/drivers/gpu/drm/i915/display/intel_crtc.h
+++ b/drivers/gpu/drm/i915/display/intel_crtc.h
@@ -14,6 +14,7 @@ struct drm_device;
 struct drm_display_mode;
 struct drm_file;
 struct drm_i915_private;
+struct drm_pending_vblank_event;
 struct intel_atomic_state;
 struct intel_crtc;
 struct intel_crtc_state;
@@ -34,6 +35,8 @@ int intel_usecs_to_scanlines(const struct drm_display_mode 
*adjusted_mode,
 int intel_scanlines_to_usecs(const struct drm_display_mode *adjusted_mode,
                             int scanlines);
 void intel_crtc_arm_vblank_event(struct intel_crtc_state *crtc_state);
+void intel_crtc_prepare_vblank_event(struct intel_crtc_state *crtc_state,
+                                    struct drm_pending_vblank_event **event);
 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);
 int intel_crtc_get_pipe_from_crtc_id_ioctl(struct drm_device *dev, void *data,
-- 
2.45.2

Reply via email to