Skip to contentSkip to conversation

staging: drm/omap: avoid multiple planes having same z-order

PATCH New Rob Clark 1 participant 3 messages Mar 12, 2012 Staging

lore
Share & tools
lore

Rob Clark

author
#0 lore raw

PATCH 1/3 staging: drm/omap: avoid multiple planes having same z-order

From: Rob Clark <[email protected]>

Multiple video pipes on same output with same z-order is an undefined behavior. Set a unique z-order value based on overlay number/id.

---
 drivers/staging/omapdrm/omap_plane.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/omapdrm/omap_plane.c +1 -1
index 55ddc58..9b3bfa0 100644
@@ -439,7 +439,7 @@ struct drm_plane *omap_plane_init(struct drm_device *dev,
 	if (priv)
 		omap_plane->info.zorder = 0;
 	else
-		omap_plane->info.zorder = 1;
+		omap_plane->info.zorder = ovl->id;
 
 	update_manager(plane);
 
Signature · 1 line
1.7.5.4
author
#1 lore raw

PATCH 2/3 staging: drm/omap: send page-flip event after endwin

From: Rob Clark <[email protected]>

The endwin irq indicates that DSS has finished scanning out a buffer. Use this to trigger page-flip event to userspace, so this happens only *after* the previous buffer is finished.

---
 drivers/staging/omapdrm/omap_crtc.c  |   27 ++++++++++++----
 drivers/staging/omapdrm/omap_drv.h   |    2 +
 drivers/staging/omapdrm/omap_plane.c |   56 +++++++++++++++++++++++++++-------
 3 files changed, 67 insertions(+), 18 deletions(-)
drivers/staging/omapdrm/omap_crtc.c +20 -7
index 17ca163..13e3c7f 100644
@@ -118,25 +118,21 @@ static void omap_crtc_load_lut(struct drm_crtc *crtc)
 {
 }
 
-static void page_flip_cb(void *arg)
+static void vblank_cb(void *arg)
 {
+	static uint32_t sequence = 0;
 	struct drm_crtc *crtc = arg;
 	struct drm_device *dev = crtc->dev;
 	struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
 	struct drm_pending_vblank_event *event = omap_crtc->event;
-	struct drm_framebuffer *old_fb = omap_crtc->old_fb;
-	struct timeval now;
 	unsigned long flags;
+	struct timeval now;
 
 	WARN_ON(!event);
 
 	omap_crtc->event = NULL;
-	omap_crtc->old_fb = NULL;
-
-	omap_crtc_mode_set_base(crtc, crtc->x, crtc->y, old_fb);
 
 	/* wakeup userspace */
-	/* TODO: this should happen *after* flip in vsync IRQ handler */
 	if (event) {
 		spin_lock_irqsave(&dev->event_lock, flags);
 		event->event.sequence = drm_vblank_count_and_time(
@@ -150,6 +146,23 @@ static void page_flip_cb(void *arg)
 	}
 }
 
+static void page_flip_cb(void *arg)
+{
+	struct drm_crtc *crtc = arg;
+	struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
+	struct drm_framebuffer *old_fb = omap_crtc->old_fb;
+
+	omap_crtc->old_fb = NULL;
+
+	omap_crtc_mode_set_base(crtc, crtc->x, crtc->y, old_fb);
+
+	/* really we'd like to setup the callback atomically w/ setting the
+	 * new scanout buffer to avoid getting stuck waiting an extra vblank
+	 * cycle.. for now go for correctness and later figure out speed..
+	 */
+	omap_plane_on_endwin(omap_crtc->plane, vblank_cb, crtc);
+}
+
 static int omap_crtc_page_flip_locked(struct drm_crtc *crtc,
 		 struct drm_framebuffer *fb,
 		 struct drm_pending_vblank_event *event)
drivers/staging/omapdrm/omap_drv.h +2 -0
index 21e48cf..b7e0f07 100644
@@ -85,6 +85,8 @@ int omap_plane_mode_set(struct drm_plane *plane,
 		unsigned int crtc_w, unsigned int crtc_h,
 		uint32_t src_x, uint32_t src_y,
 		uint32_t src_w, uint32_t src_h);
+void omap_plane_on_endwin(struct drm_plane *plane,
+		void (*fxn)(void *), void *arg);
 
 struct drm_encoder *omap_encoder_init(struct drm_device *dev,
 		struct omap_overlay_manager *mgr);
drivers/staging/omapdrm/omap_plane.c +45 -11

93 lines not on this page · raw message

Signature · 1 line
1.7.5.4
author
#2 lore raw

PATCH 3/3 staging: drm/omap: use current time for page-flip event

In reply to Rob Clark

From: Rob Clark <[email protected]>

Because we don't have vblank hooked up via drm_irq (which is a bit awkward due to separation between omapdss (which knows the irq #) and omapdrm, for now use gettimeofday to have a semi-sane timestamp in the page-flip event. Otherwise apps like weston drm compositor, which use the timestamp in it's animations, get highly confused.

---
 drivers/staging/omapdrm/omap_crtc.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
drivers/staging/omapdrm/omap_crtc.c +10 -0
index 13e3c7f..490a7f1 100644
@@ -134,9 +134,19 @@ static void vblank_cb(void *arg)
 
 	/* wakeup userspace */
 	if (event) {
+		do_gettimeofday(&now);
+
 		spin_lock_irqsave(&dev->event_lock, flags);
+		/* TODO: we can't yet use the vblank time accounting,
+		 * because omapdss lower layer is the one that knows
+		 * the irq # and registers the handler, which more or
+		 * less defeats how drm_irq works.. for now just fake
+		 * the sequence number and use gettimeofday..
+		 *
 		event->event.sequence = drm_vblank_count_and_time(
 				dev, omap_crtc->id, &now);
+		 */
+		event->event.sequence = sequence++;
 		event->event.tv_sec = now.tv_sec;
 		event->event.tv_usec = now.tv_usec;
 		list_add_tail(&event->base.link,
Signature · 1 line
1.7.5.4