From e4d231ecdf9d039be138908d01ce638722774df7 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Thu, 12 Jun 2014 15:12:48 +0300 Subject: [PATCH] compositor-drm: init linux_dmabuf support v2 changes: - only initialize linux_dmabuf if renderer supports it Signed-off-by: Pekka Paalanen Reviewed-by: Daniel Stone --- src/compositor-drm.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/compositor-drm.c b/src/compositor-drm.c index 585169e8..33421329 100644 --- a/src/compositor-drm.c +++ b/src/compositor-drm.c @@ -56,6 +56,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 @@ -2965,10 +2966,13 @@ static void switch_to_gl_renderer(struct drm_backend *b) { struct drm_output *output; + bool dmabuf_support_inited; if (!b->use_pixman) return; + dmabuf_support_inited = !!b->compositor->renderer->import_dmabuf; + weston_log("Switching to GL renderer\n"); b->gbm = create_gbm_device(b->drm.fd); @@ -2994,6 +2998,12 @@ switch_to_gl_renderer(struct drm_backend *b) drm_output_init_egl(output, b); b->use_pixman = 0; + + if (!dmabuf_support_inited && b->compositor->renderer->import_dmabuf) { + if (linux_dmabuf_setup(b->compositor) < 0) + weston_log("Error: initializing dmabuf " + "support failed.\n"); + } } static void @@ -3154,7 +3164,14 @@ drm_backend_create(struct weston_compositor *compositor, weston_compositor_add_debug_binding(compositor, KEY_W, renderer_switch_binding, b); + if (compositor->renderer->import_dmabuf) { + if (linux_dmabuf_setup(compositor) < 0) + weston_log("Error: initializing dmabuf " + "support failed.\n"); + } + compositor->backend = &b->base; + return b; err_udev_monitor: