summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiang, Haihao <haihao.xiang@intel.com>2016-07-19 16:19:58 +0800
committerXiang, Haihao <haihao.xiang@intel.com>2016-09-19 14:03:30 +0800
commita55ea7cb3143d57c8dba1b76ccea3511ea69adf2 (patch)
tree8033e0b16a5b803b9ceb49f9d2fdf399488b2d2c
parentd8719fb8b2d999c3de64def3a801778021c71f84 (diff)
downloadlibva-a55ea7cb3143d57c8dba1b76ccea3511ea69adf2.tar.gz
wayland: Check whether prime fd can be used in buffer sharing mechanism
Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
-rw-r--r--va/wayland/va_backend_wayland.h3
-rw-r--r--va/wayland/va_wayland_drm.c20
2 files changed, 21 insertions, 2 deletions
diff --git a/va/wayland/va_backend_wayland.h b/va/wayland/va_backend_wayland.h
index b33e3a1..67d0004 100644
--- a/va/wayland/va_backend_wayland.h
+++ b/va/wayland/va_backend_wayland.h
@@ -60,6 +60,9 @@ struct VADriverVTableWayland {
unsigned int flags,
struct wl_buffer **out_buffer
);
+
+ /** \brief Indicate whether buffer sharing with prime fd is supported. */
+ unsigned int has_prime_sharing;
};
#endif /* VA_BACKEND_WAYLAND_H */
diff --git a/va/wayland/va_wayland_drm.c b/va/wayland/va_wayland_drm.c
index 94abe5c..958ea85 100644
--- a/va/wayland/va_wayland_drm.c
+++ b/va/wayland/va_wayland_drm.c
@@ -98,10 +98,21 @@ drm_handle_authenticated(void *data, struct wl_drm *drm)
drm_state->auth_type = VA_DRM_AUTH_CUSTOM;
}
+static void
+drm_handle_capabilities(void *data, struct wl_drm *wl_drm, uint32_t value)
+{
+ VADisplayContextP const pDisplayContext = data;
+ VADriverContextP const ctx = pDisplayContext->pDriverContext;
+ struct VADriverVTableWayland *vtable = ctx->vtable_wayland;
+
+ vtable->has_prime_sharing = !!(value & WL_DRM_CAPABILITY_PRIME);
+}
+
static const struct wl_drm_listener drm_listener = {
drm_handle_device,
drm_handle_format,
- drm_handle_authenticated
+ drm_handle_authenticated,
+ drm_handle_capabilities,
};
static VAStatus
@@ -121,6 +132,9 @@ va_wayland_drm_destroy(VADisplayContextP pDisplayContext)
VADriverContextP const ctx = pDisplayContext->pDriverContext;
struct va_wayland_drm_context * const wl_drm_ctx = pDisplayContext->opaque;
struct drm_state * const drm_state = ctx->drm_state;
+ struct VADriverVTableWayland *vtable = ctx->vtable_wayland;
+
+ vtable->has_prime_sharing = 0;
if (wl_drm_ctx->drm) {
wl_drm_destroy(wl_drm_ctx->drm);
@@ -156,7 +170,7 @@ registry_handle_global(
if (strcmp(interface, "wl_drm") == 0) {
wl_drm_ctx->drm =
- wl_registry_bind(wl_drm_ctx->registry, id, wl_drm_ctx->drm_interface, 1);
+ wl_registry_bind(wl_drm_ctx->registry, id, wl_drm_ctx->drm_interface, 2);
}
}
@@ -171,6 +185,7 @@ va_wayland_drm_create(VADisplayContextP pDisplayContext)
VADriverContextP const ctx = pDisplayContext->pDriverContext;
struct va_wayland_drm_context *wl_drm_ctx;
struct drm_state *drm_state;
+ struct VADriverVTableWayland *vtable = ctx->vtable_wayland;
wl_drm_ctx = malloc(sizeof(*wl_drm_ctx));
if (!wl_drm_ctx)
@@ -189,6 +204,7 @@ va_wayland_drm_create(VADisplayContextP pDisplayContext)
drm_state->fd = -1;
drm_state->auth_type = 0;
ctx->drm_state = drm_state;
+ vtable->has_prime_sharing = 0;
wl_drm_ctx->handle = dlopen(LIBWAYLAND_DRM_NAME, RTLD_LAZY|RTLD_LOCAL);
if (!wl_drm_ctx->handle)