[PATCH weston v2 6/8] compositor-drm: init linux_dmabuf support

Pekka Paalanen ppaalanen at gmail.com
Wed Jul 1 07:56:18 PDT 2015


From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

v2 changes:
- only initialize linux_dmabuf if renderer supports it

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

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index f24fa0b..59d869c 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -55,6 +55,7 @@
 #include "launcher-util.h"
 #include "vaapi-recorder.h"
 #include "presentation_timing-server-protocol.h"
+#include "linux-dmabuf.h"
 
 #ifndef DRM_CAP_TIMESTAMP_MONOTONIC
 #define DRM_CAP_TIMESTAMP_MONOTONIC 0x6
@@ -2789,10 +2790,13 @@ static void
 switch_to_gl_renderer(struct drm_compositor *c)
 {
 	struct drm_output *output;
+	bool dmabuf_support_inited;
 
 	if (!c->use_pixman)
 		return;
 
+	dmabuf_support_inited = !!c->base.renderer->import_dmabuf;
+
 	weston_log("Switching to GL renderer\n");
 
 	c->gbm = create_gbm_device(c->drm.fd);
@@ -2818,6 +2822,12 @@ switch_to_gl_renderer(struct drm_compositor *c)
 		drm_output_init_egl(output, c);
 
 	c->use_pixman = 0;
+
+	if (!dmabuf_support_inited && c->base.renderer->import_dmabuf) {
+		if (linux_dmabuf_setup(&c->base) < 0)
+			weston_log("Error: initializing dmabuf "
+				   "support failed.\n");
+	}
 }
 
 static void
@@ -2983,6 +2993,12 @@ drm_compositor_create(struct wl_display *display,
 	weston_compositor_add_debug_binding(&ec->base, KEY_W,
 					    renderer_switch_binding, ec);
 
+	if (ec->base.renderer->import_dmabuf) {
+		if (linux_dmabuf_setup(&ec->base) < 0)
+			weston_log("Error: initializing dmabuf "
+				   "support failed.\n");
+	}
+
 	return &ec->base;
 
 err_udev_monitor:
-- 
2.3.6



More information about the wayland-devel mailing list