[Libva] [PATCH] wayland: Add basic support for creating RGB Wayland buffers
Rob Bradford
robert.bradford at intel.com
Fri Apr 12 11:52:23 PDT 2013
From: Rob Bradford <rob at linux.intel.com>
This is a necessary step towards being able to decode to a buffer that the
Wayland compositor can directly scan out from.
---
src/i965_output_wayland.c | 71 +++++++++++++++++++++++++++++++++++++++++------
1 file changed, 62 insertions(+), 9 deletions(-)
diff --git a/src/i965_output_wayland.c b/src/i965_output_wayland.c
index fb07b0a..ac86431 100644
--- a/src/i965_output_wayland.c
+++ b/src/i965_output_wayland.c
@@ -205,6 +205,38 @@ create_planar_buffer(
return (struct wl_buffer *)id;
}
+static struct wl_buffer *
+create_packed_buffer(
+ struct va_wl_output *wl_output,
+ uint32_t name,
+ int32_t width,
+ int32_t height,
+ uint32_t format,
+ int32_t pitch
+)
+{
+ struct wl_vtable * const wl_vtable = &wl_output->vtable;
+ struct wl_proxy *id;
+
+ id = wl_vtable->proxy_create(
+ (struct wl_proxy *)wl_output->wl_drm,
+ wl_vtable->buffer_interface
+ );
+ if (!id)
+ return NULL;
+
+ wl_vtable->proxy_marshal(
+ (struct wl_proxy *)wl_output->wl_drm,
+ WL_DRM_CREATE_BUFFER,
+ id,
+ name,
+ width, height,
+ pitch,
+ format
+ );
+ return (struct wl_buffer *)id;
+}
+
/* Hook to return Wayland buffer associated with the VA surface */
static VAStatus
va_GetSurfaceBufferWl(
@@ -237,6 +269,15 @@ va_GetSurfaceBufferWl(
return VA_STATUS_ERROR_INVALID_SURFACE;
switch (obj_surface->fourcc) {
+ case VA_FOURCC_RGB:
+ drm_format = WL_DRM_FORMAT_RGBX8888;
+ offsets[0] = 0;
+ pitches[0] = obj_surface->width * 4;
+ offsets[1] = 0;
+ pitches[1] = 0;
+ offsets[2] = 0;
+ pitches[2] = 0;
+ break;
case VA_FOURCC('N','V','1','2'):
drm_format = WL_DRM_FORMAT_NV12;
offsets[0] = 0;
@@ -279,15 +320,27 @@ va_GetSurfaceBufferWl(
return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT;
}
- buffer = create_planar_buffer(
- i965->wl_output,
- name,
- obj_surface->orig_width,
- obj_surface->orig_height,
- drm_format,
- offsets,
- pitches
- );
+ if (offsets[1] > 0) {
+ buffer = create_planar_buffer(
+ i965->wl_output,
+ name,
+ obj_surface->orig_width,
+ obj_surface->orig_height,
+ drm_format,
+ offsets,
+ pitches
+ );
+ } else {
+ buffer = create_packed_buffer(
+ i965->wl_output,
+ name,
+ obj_surface->orig_width,
+ obj_surface->orig_height,
+ drm_format,
+ pitches[0]
+ );
+ }
+
if (!buffer)
return VA_STATUS_ERROR_ALLOCATION_FAILED;
--
1.8.1.4
More information about the Libva
mailing list