A lot of drivers need to fire pageflip completion event at very next vblank interrupt. The patch adds helper to perform this operation. drm_crtc_arm_completion_event checks if there is an event to handle, if vblank reference get succeeds it arms the event, otherwise it sends the event immediately. Signed-off-by: Andrzej Hajda <a.hajda@xxxxxxxxxxx> --- drivers/gpu/drm/drm_irq.c | 25 +++++++++++++++++++++++++ include/drm/drm_irq.h | 1 + 2 files changed, 26 insertions(+) diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index 77f357b..313d323 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c @@ -1053,6 +1053,31 @@ void drm_crtc_send_vblank_event(struct drm_crtc *crtc, EXPORT_SYMBOL(drm_crtc_send_vblank_event); /** + * drm_crtc_arm_completion_event - conditionally arm crtc completion event + * @crtc: the source CRTC of the completion event + * + * A lot of drivers need to fire pageflip completion event at very next vblank + * interrupt. This helper tries to arm the event in case of successful vblank + * get otherwise it sends the event immediately. + */ +void drm_crtc_arm_completion_event(struct drm_crtc *crtc) +{ + struct drm_pending_vblank_event *event = crtc->state->event; + + if (event) { + crtc->state->event = NULL; + + spin_lock_irq(&crtc->dev->event_lock); + if (drm_crtc_vblank_get(crtc) == 0) + drm_crtc_arm_vblank_event(crtc, event); + else + drm_crtc_send_vblank_event(crtc, event); + spin_unlock_irq(&crtc->dev->event_lock); + } +} +EXPORT_SYMBOL(drm_crtc_arm_completion_event); + +/** * drm_vblank_enable - enable the vblank interrupt on a CRTC * @dev: DRM device * @pipe: CRTC index diff --git a/include/drm/drm_irq.h b/include/drm/drm_irq.h index 2401b14..7bd9690 100644 --- a/include/drm/drm_irq.h +++ b/include/drm/drm_irq.h @@ -144,6 +144,7 @@ extern void drm_crtc_send_vblank_event(struct drm_crtc *crtc, struct drm_pending_vblank_event *e); extern void drm_crtc_arm_vblank_event(struct drm_crtc *crtc, struct drm_pending_vblank_event *e); +extern void drm_crtc_arm_completion_event(struct drm_crtc *crtc); extern bool drm_handle_vblank(struct drm_device *dev, unsigned int pipe); extern bool drm_crtc_handle_vblank(struct drm_crtc *crtc); extern int drm_crtc_vblank_get(struct drm_crtc *crtc); -- 2.7.4 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel