diff --git a/libweston/backend-drm/drm-internal.h b/libweston/backend-drm/drm-internal.h index cf588674..21bece8d 100644 --- a/libweston/backend-drm/drm-internal.h +++ b/libweston/backend-drm/drm-internal.h @@ -682,12 +682,21 @@ drm_fb_get_from_bo(struct gbm_bo *bo, struct drm_backend *backend, #ifdef BUILD_DRM_GBM extern struct drm_fb * drm_fb_get_from_view(struct drm_output_state *state, struct weston_view *ev); +extern bool +drm_can_scanout_dmabuf(struct weston_compositor *ec, + struct linux_dmabuf_buffer *dmabuf); #else static inline struct drm_fb * drm_fb_get_from_view(struct drm_output_state *state, struct weston_view *ev) { return NULL; } +static inline bool +drm_can_scanout_dmabuf(struct weston_compositor *ec, + struct linux_dmabuf_buffer *dmabuf) +{ + return false; +} #endif struct drm_pending_state * diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c index 6e1169c6..89508a8d 100644 --- a/libweston/backend-drm/drm.c +++ b/libweston/backend-drm/drm.c @@ -2893,6 +2893,7 @@ drm_backend_create(struct weston_compositor *compositor, b->base.repaint_cancel = drm_repaint_cancel; b->base.create_output = drm_output_create; b->base.device_changed = drm_device_changed; + b->base.can_scanout_dmabuf = drm_can_scanout_dmabuf; weston_setup_vt_switch_bindings(compositor); diff --git a/libweston/backend-drm/fb.c b/libweston/backend-drm/fb.c index e978b088..fcbabbea 100644 --- a/libweston/backend-drm/fb.c +++ b/libweston/backend-drm/fb.c @@ -509,6 +509,24 @@ drm_fb_unref(struct drm_fb *fb) } #ifdef BUILD_DRM_GBM +bool +drm_can_scanout_dmabuf(struct weston_compositor *ec, + struct linux_dmabuf_buffer *dmabuf) +{ + struct drm_fb *fb; + struct drm_backend *b = to_drm_backend(ec); + bool ret = false; + + fb = drm_fb_get_from_dmabuf(dmabuf, b, true); + if (fb) + ret = true; + + drm_fb_unref(fb); + drm_debug(b, "[dmabuf] dmabuf %p, import test %s\n", dmabuf, + ret ? "succeeded" : "failed"); + return ret; +} + struct drm_fb * drm_fb_get_from_view(struct drm_output_state *state, struct weston_view *ev) {