drm: rcar-du: Switch page flip to atomic helpers
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Sun, 22 Feb 2015 23:04:21 +0000 (01:04 +0200)
committerLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Tue, 3 Mar 2015 14:16:22 +0000 (16:16 +0200)
The atomic page flip helper implements the page flip operation using
asynchronous commits.

As the legacy page flip was the last CRTC operation that needed direct
access to plane setup, the plane setup functions can now become private
to the plane implementation.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
drivers/gpu/drm/rcar-du/rcar_du_crtc.c
drivers/gpu/drm/rcar-du/rcar_du_plane.c
drivers/gpu/drm/rcar-du/rcar_du_plane.h

index 8a44d37f17168701702ef7eca322d7b01fc14d0b..2a1119b52c2aff86b11c8da5ebf8d8b3c9e7d5ee 100644 (file)
@@ -436,14 +436,6 @@ void rcar_du_crtc_resume(struct rcar_du_crtc *rcrtc)
        rcar_du_crtc_start(rcrtc);
 }
 
-static void rcar_du_crtc_update_base(struct rcar_du_crtc *rcrtc)
-{
-       struct drm_crtc *crtc = &rcrtc->crtc;
-
-       rcar_du_plane_compute_base(rcrtc->plane, crtc->primary->fb);
-       rcar_du_plane_update_base(rcrtc->plane);
-}
-
 /* -----------------------------------------------------------------------------
  * CRTC Functions
  */
@@ -485,12 +477,25 @@ static bool rcar_du_crtc_mode_fixup(struct drm_crtc *crtc,
 
 static void rcar_du_crtc_atomic_begin(struct drm_crtc *crtc)
 {
+       struct drm_pending_vblank_event *event = crtc->state->event;
        struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
+       struct drm_device *dev = rcrtc->crtc.dev;
+       unsigned long flags;
 
        /* We need to access the hardware during atomic update, acquire a
         * reference to the CRTC.
         */
        rcar_du_crtc_get(rcrtc);
+
+       if (event) {
+               event->pipe = rcrtc->index;
+
+               WARN_ON(drm_crtc_vblank_get(crtc) != 0);
+
+               spin_lock_irqsave(&dev->event_lock, flags);
+               rcrtc->event = event;
+               spin_unlock_irqrestore(&dev->event_lock, flags);
+       }
 }
 
 static void rcar_du_crtc_atomic_flush(struct drm_crtc *crtc)
@@ -515,43 +520,11 @@ static const struct drm_crtc_helper_funcs crtc_helper_funcs = {
        .atomic_flush = rcar_du_crtc_atomic_flush,
 };
 
-static int rcar_du_crtc_page_flip(struct drm_crtc *crtc,
-                                 struct drm_framebuffer *fb,
-                                 struct drm_pending_vblank_event *event,
-                                 uint32_t page_flip_flags)
-{
-       struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
-       struct drm_device *dev = rcrtc->crtc.dev;
-       unsigned long flags;
-
-       spin_lock_irqsave(&dev->event_lock, flags);
-       if (rcrtc->event != NULL) {
-               spin_unlock_irqrestore(&dev->event_lock, flags);
-               return -EBUSY;
-       }
-       spin_unlock_irqrestore(&dev->event_lock, flags);
-
-       drm_atomic_set_fb_for_plane(crtc->primary->state, fb);
-
-       crtc->primary->fb = fb;
-       rcar_du_crtc_update_base(rcrtc);
-
-       if (event) {
-               event->pipe = rcrtc->index;
-               drm_crtc_vblank_get(crtc);
-               spin_lock_irqsave(&dev->event_lock, flags);
-               rcrtc->event = event;
-               spin_unlock_irqrestore(&dev->event_lock, flags);
-       }
-
-       return 0;
-}
-
 static const struct drm_crtc_funcs crtc_funcs = {
        .reset = drm_atomic_helper_crtc_reset,
        .destroy = drm_crtc_cleanup,
        .set_config = drm_atomic_helper_set_config,
-       .page_flip = rcar_du_crtc_page_flip,
+       .page_flip = drm_atomic_helper_page_flip,
        .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
        .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
 };
index ff087f7de88eb2133648853d18d9b8e3dcf1a04a..9176ac451438cbd430d8ee004cca386ee872a315 100644 (file)
@@ -129,7 +129,7 @@ static void rcar_du_plane_release(struct rcar_du_plane *plane)
        plane->hwindex = -1;
 }
 
-void rcar_du_plane_update_base(struct rcar_du_plane *plane)
+static void rcar_du_plane_update_base(struct rcar_du_plane *plane)
 {
        struct rcar_du_group *rgrp = plane->group;
        unsigned int src_x = plane->plane.state->src_x >> 16;
@@ -182,8 +182,8 @@ void rcar_du_plane_update_base(struct rcar_du_plane *plane)
        }
 }
 
-void rcar_du_plane_compute_base(struct rcar_du_plane *plane,
-                               struct drm_framebuffer *fb)
+static void rcar_du_plane_compute_base(struct rcar_du_plane *plane,
+                                      struct drm_framebuffer *fb)
 {
        struct drm_gem_cma_object *gem;
 
index 3420ff07f2c699755c1b7a24b81ba6da60023021..9b77a638863f732a5d18e2e0654c52412828524c 100644 (file)
@@ -62,8 +62,5 @@ struct rcar_du_planes {
 int rcar_du_planes_init(struct rcar_du_group *rgrp);
 
 void rcar_du_plane_setup(struct rcar_du_plane *plane);
-void rcar_du_plane_update_base(struct rcar_du_plane *plane);
-void rcar_du_plane_compute_base(struct rcar_du_plane *plane,
-                               struct drm_framebuffer *fb);
 
 #endif /* __RCAR_DU_PLANE_H__ */