backend-drm: Add dmabuf scan-out check for DRM-backend

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This commit is contained in:
Marius Vlad 2019-11-11 00:27:17 +02:00
parent 5a701547a4
commit 81bada58db
3 changed files with 28 additions and 0 deletions

View File

@ -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 *

View File

@ -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);

View File

@ -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)
{