[PATCH weston v11 05/13] compositor-drm: Track all plane types

Daniel Stone daniels at collabora.com
Tue Jul 18 13:14:27 UTC 2017


Retain drm_plane tracking objects for all actual DRM planes when using
universal planes, not just overlay planes. Rename uses of 'sprite' to
'plane' to make it clear that it can now be any kind of plane, not just
an overlay/sprite.

These are currently unused.

Signed-off-by: Daniel Stone <daniels at collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
 libweston/compositor-drm.c | 74 ++++++++++++++++++++++++----------------------
 1 file changed, 39 insertions(+), 35 deletions(-)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index c680c2cf..d1ac3855 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -166,7 +166,7 @@ struct drm_backend {
 	int min_height, max_height;
 	int no_addfb2;
 
-	struct wl_list sprite_list;
+	struct wl_list plane_list;
 	int sprites_are_broken;
 	int sprites_hidden;
 
@@ -1131,7 +1131,7 @@ drm_output_repaint(struct weston_output *output_base,
 	struct drm_output *output = to_drm_output(output_base);
 	struct drm_backend *backend =
 		to_drm_backend(output->base.compositor);
-	struct drm_plane *s;
+	struct drm_plane *p;
 	struct drm_mode *mode;
 	int ret = 0;
 
@@ -1191,28 +1191,29 @@ drm_output_repaint(struct weston_output *output_base,
 	/*
 	 * Now, update all the sprite surfaces
 	 */
-	wl_list_for_each(s, &backend->sprite_list, link) {
+	wl_list_for_each(p, &backend->plane_list, link) {
 		uint32_t flags = 0, fb_id = 0;
 		drmVBlank vbl = {
 			.request.type = DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT,
 			.request.sequence = 1,
 		};
 
-		/* XXX: Set output much earlier, so we don't attempt to place
-		 *      planes on entirely the wrong output. */
-		if ((!s->fb_current && !s->fb_pending) ||
-		    !drm_plane_crtc_supported(output, s))
+		if (p->type != WDRM_PLANE_TYPE_OVERLAY)
+			continue;
+
+		if ((!p->fb_current && !p->fb_pending) ||
+		    !drm_plane_crtc_supported(output, p))
 			continue;
 
-		if (s->fb_pending && !backend->sprites_hidden)
-			fb_id = s->fb_pending->fb_id;
+		if (p->fb_pending && !backend->sprites_hidden)
+			fb_id = p->fb_pending->fb_id;
 
-		ret = drmModeSetPlane(backend->drm.fd, s->plane_id,
+		ret = drmModeSetPlane(backend->drm.fd, p->plane_id,
 				      output->crtc_id, fb_id, flags,
-				      s->dest_x, s->dest_y,
-				      s->dest_w, s->dest_h,
-				      s->src_x, s->src_y,
-				      s->src_w, s->src_h);
+				      p->dest_x, p->dest_y,
+				      p->dest_w, p->dest_h,
+				      p->src_x, p->src_y,
+				      p->src_w, p->src_h);
 		if (ret)
 			weston_log("setplane failed: %d: %s\n",
 				ret, strerror(errno));
@@ -1223,17 +1224,17 @@ drm_output_repaint(struct weston_output *output_base,
 		 * Queue a vblank signal so we know when the surface
 		 * becomes active on the display or has been replaced.
 		 */
-		vbl.request.signal = (unsigned long)s;
+		vbl.request.signal = (unsigned long) p;
 		ret = drmWaitVBlank(backend->drm.fd, &vbl);
 		if (ret) {
 			weston_log("vblank event request failed: %d: %s\n",
 				ret, strerror(errno));
 		}
 
-		s->output = output;
-		s->fb_last = s->fb_current;
-		s->fb_current = s->fb_pending;
-		s->fb_pending = NULL;
+		p->output = output;
+		p->fb_last = p->fb_current;
+		p->fb_current = p->fb_pending;
+		p->fb_pending = NULL;
 		output->vblank_pending++;
 	}
 
@@ -1483,7 +1484,10 @@ drm_output_prepare_overlay_view(struct drm_output *output,
 	if (ev->alpha != 1.0f)
 		return NULL;
 
-	wl_list_for_each(p, &b->sprite_list, link) {
+	wl_list_for_each(p, &b->plane_list, link) {
+		if (p->type != WDRM_PLANE_TYPE_OVERLAY)
+			continue;
+
 		if (!drm_plane_crtc_supported(output, p))
 			continue;
 
@@ -2165,7 +2169,7 @@ drm_plane_create(struct drm_backend *b, const drmModePlane *kplane)
 	drmModeFreeObjectProperties(props);
 
 	weston_plane_init(&plane->base, b->compositor, 0, 0);
-	wl_list_insert(&b->sprite_list, &plane->link);
+	wl_list_insert(&b->plane_list, &plane->link);
 
 	return plane;
 }
@@ -2226,14 +2230,10 @@ create_sprites(struct drm_backend *b)
 		if (!drm_plane)
 			continue;
 
-		/* Ignore non-overlay planes for now. */
-		if (drm_plane->type != WDRM_PLANE_TYPE_OVERLAY) {
-			drm_plane_destroy(drm_plane);
-			continue;
-		}
-
-		weston_compositor_stack_plane(b->compositor, &drm_plane->base,
-					      &b->compositor->primary_plane);
+		if (drm_plane->type == WDRM_PLANE_TYPE_OVERLAY)
+			weston_compositor_stack_plane(b->compositor,
+						      &drm_plane->base,
+						      &b->compositor->primary_plane);
 	}
 
 	drmModeFreePlaneResources(kplane_res);
@@ -2251,7 +2251,7 @@ destroy_sprites(struct drm_backend *b)
 {
 	struct drm_plane *plane, *next;
 
-	wl_list_for_each_safe(plane, next, &b->sprite_list, link)
+	wl_list_for_each_safe(plane, next, &b->plane_list, link)
 		drm_plane_destroy(plane);
 }
 
@@ -3482,7 +3482,7 @@ session_notify(struct wl_listener *listener, void *data)
 {
 	struct weston_compositor *compositor = data;
 	struct drm_backend *b = to_drm_backend(compositor);
-	struct drm_plane *sprite;
+	struct drm_plane *plane;
 	struct drm_output *output;
 
 	if (compositor->session_active) {
@@ -3512,12 +3512,16 @@ session_notify(struct wl_listener *listener, void *data)
 		output = container_of(compositor->output_list.next,
 				      struct drm_output, base.link);
 
-		wl_list_for_each(sprite, &b->sprite_list, link)
+		wl_list_for_each(plane, &b->plane_list, link) {
+			if (plane->type != WDRM_PLANE_TYPE_OVERLAY)
+				continue;
+
 			drmModeSetPlane(b->drm.fd,
-					sprite->plane_id,
+					plane->plane_id,
 					output->crtc_id, 0, 0,
 					0, 0, 0, 0, 0, 0, 0, 0);
-	};
+		}
+	}
 }
 
 /**
@@ -3938,7 +3942,7 @@ drm_backend_create(struct weston_compositor *compositor,
 
 	weston_setup_vt_switch_bindings(compositor);
 
-	wl_list_init(&b->sprite_list);
+	wl_list_init(&b->plane_list);
 	create_sprites(b);
 
 	if (udev_input_init(&b->input,
-- 
2.13.3



More information about the wayland-devel mailing list