[Libva] [Driver PATCH 5/5] add vaGetImageBufferWl support
Zhao Halley
halley.zhao at intel.com
Tue Jun 5 02:12:12 PDT 2012
From: Zhao halley <halley.zhao at intel.com>
---
src/i965_render_wayland.c | 49 +++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/src/i965_render_wayland.c b/src/i965_render_wayland.c
index 7d09a77..9d338b2 100755
--- a/src/i965_render_wayland.c
+++ b/src/i965_render_wayland.c
@@ -197,7 +197,7 @@ i965_wayland_get_buffer_unlocked(
}
static VAStatus
-i965_wayland_get_buffer(
+i965_wayland_get_surface_buffer(
VADriverContextP ctx,
VASurfaceID va_surface,
struct wl_buffer **out_buffer
@@ -225,6 +225,50 @@ i965_wayland_get_buffer(
return va_status;
}
+static VAStatus
+i965_wayland_get_image_buffer(
+ VADriverContextP ctx,
+ VAImageID va_image,
+ struct wl_buffer **out_buffer
+)
+{
+ struct i965_driver_data * const i965 = i965_driver_data(ctx);
+ struct VADriverVTableWayland * const vtable = ctx->vtable_wayland;
+ struct object_image *obj_image;
+ VAStatus va_status=VA_STATUS_SUCCESS;
+ int name;
+ int format; // WL_DRM format mapped from obj_image.image.format
+
+ if (ctx->display_type != VA_DISPLAY_WAYLAND)
+ return VA_STATUS_ERROR_INVALID_DISPLAY;
+
+ obj_image = IMAGE(va_image);
+ if (!obj_image)
+ return VA_STATUS_ERROR_INVALID_IMAGE;
+ assert(obj_image->bo);
+
+ if (dri_bo_flink(obj_image->bo, &name) != 0) {
+ fprintf(stderr, "libva: error: flink failed for bo %p\n", obj_image->bo);
+ return VA_STATUS_ERROR_INVALID_BUFFER;
+ }
+
+ // XXXX, todo. update format, consider YUV planar image
+ struct wl_buffer *buffer;
+ buffer = wl_drm_create_buffer(
+ vtable->wl_drm,
+ name,
+ obj_image->image.width,
+ obj_image->image.height,
+ obj_image->image.pitches[0],
+ format
+ );
+ if (!buffer) {
+ return VA_STATUS_ERROR_ALLOCATION_FAILED;
+ }
+ *out_buffer = buffer;
+
+ return va_status;
+}
bool
i965_render_wayland_init(VADriverContextP ctx)
@@ -240,7 +284,8 @@ i965_render_wayland_init(VADriverContextP ctx)
vtable->wl_drm = NULL;
vtable->name = 0;
- vtable->vaGetSurfaceBufferWl = i965_wayland_get_buffer;
+ vtable->vaGetSurfaceBufferWl = i965_wayland_get_surface_buffer;
+ vtable->vaGetImageBufferWl = i965_wayland_get_image_buffer;
id = wl_display_get_global(ctx->native_dpy, "wl_drm", 1);
if (!id) {
--
1.7.5.4
More information about the Libva
mailing list