[PATCH 2/5] drm: use page-flip for sprites, in case no vblank event

Rob Clark rob.clark at linaro.org
Sun Mar 11 17:48:42 PDT 2012


From: Rob Clark <rob at ti.com>

If the output does not support vblank events (possibly the case with
USB or DSI command mode displays which do not have a traditional
vsync), use instead the page_flip handler to know when the display
is finished scanning out a sprite.
---
 src/compositor-drm.c |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 67fa500..500ec15 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -117,6 +117,12 @@ struct drm_sprite {
 	uint32_t dest_x, dest_y;
 	uint32_t dest_w, dest_h;
 
+	/*
+	 * for displays that don't have a vblank (dsi command-mode displays,
+	 * usb displays, etc), it can be simulated from the page-flip event
+	 */
+	int simulate_vblank;
+
 	uint32_t formats[];
 };
 
@@ -286,8 +292,7 @@ drm_output_repaint(struct weston_output *output_base,
 		vbl.request.signal = (unsigned long)s;
 		ret = drmWaitVBlank(compositor->drm.fd, &vbl);
 		if (ret) {
-			fprintf(stderr, "vblank event request failed: %d: %s\n",
-				ret, strerror(errno));
+			s->simulate_vblank = 1;
 		}
 	}
 
@@ -327,6 +332,7 @@ page_flip_handler(int fd, unsigned int frame,
 	struct drm_output *output = (struct drm_output *) data;
 	struct drm_compositor *c =
 		(struct drm_compositor *) output->base.compositor;
+	struct drm_sprite *s;
 	uint32_t msecs;
 
 	if (output->scanout_buffer) {
@@ -349,6 +355,13 @@ page_flip_handler(int fd, unsigned int frame,
 
 	msecs = sec * 1000 + usec / 1000;
 	weston_output_finish_frame(&output->base, msecs);
+
+	wl_list_for_each(s, &c->sprite_list, link) {
+		if (s->simulate_vblank) {
+			vblank_handler(fd, frame, sec, usec, s);
+			s->simulate_vblank = 0;
+		}
+	}
 }
 
 static int
-- 
1.7.5.4



More information about the wayland-devel mailing list