From fa6ef9d5bef88f0319922670ad0424fa2ddfb194 Mon Sep 17 00:00:00 2001 From: Stephan Raue Date: Wed, 16 Dec 2009 03:50:09 +0100 Subject: [PATCH] libva: - cleanup libva-sds patch --- .../libva/patches/libva-0.31.0-1+sds9.diff | 3787 ----------------- 1 file changed, 3787 deletions(-) diff --git a/packages/multimedia/libva/patches/libva-0.31.0-1+sds9.diff b/packages/multimedia/libva/patches/libva-0.31.0-1+sds9.diff index 30f717362b..ae764859ec 100644 --- a/packages/multimedia/libva/patches/libva-0.31.0-1+sds9.diff +++ b/packages/multimedia/libva/patches/libva-0.31.0-1+sds9.diff @@ -38718,1610 +38718,6 @@ diff -Naur libva-0.31.0/i965_drv_video/i965_drv_video.c libva-0.31.0.patch/i965_ } diff -Naur libva-0.31.0/i965_drv_video/i965_drv_video.c.orig libva-0.31.0.patch/i965_drv_video/i965_drv_video.c.orig ---- libva-0.31.0/i965_drv_video/i965_drv_video.c.orig 1970-01-01 01:00:00.000000000 +0100 -+++ libva-0.31.0.patch/i965_drv_video/i965_drv_video.c.orig 2009-12-15 13:43:55.261448287 +0100 -@@ -0,0 +1,1601 @@ -+/* -+ * Copyright © 2009 Intel Corporation -+ * -+ * Permission is hereby granted, free of charge, to any person obtaining a -+ * copy of this software and associated documentation files (the -+ * "Software"), to deal in the Software without restriction, including -+ * without limitation the rights to use, copy, modify, merge, publish, -+ * distribute, sub license, and/or sell copies of the Software, and to -+ * permit persons to whom the Software is furnished to do so, subject to -+ * the following conditions: -+ * -+ * The above copyright notice and this permission notice (including the -+ * next paragraph) shall be included in all copies or substantial portions -+ * of the Software. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -+ * -+ * Authors: -+ * Xiang Haihao -+ * Zou Nan hai -+ * -+ */ -+ -+#include -+#include -+ -+#include "va_backend.h" -+#include "va_dricommon.h" -+ -+#include "intel_driver.h" -+#include "intel_memman.h" -+#include "intel_batchbuffer.h" -+ -+#include "i965_media.h" -+#include "i965_drv_video.h" -+#include "i965_defines.h" -+ -+#define CONFIG_ID_OFFSET 0x01000000 -+#define CONTEXT_ID_OFFSET 0x02000000 -+#define SURFACE_ID_OFFSET 0x04000000 -+#define BUFFER_ID_OFFSET 0x08000000 -+#define IMAGE_ID_OFFSET 0x0a000000 -+#define SUBPIC_ID_OFFSET 0x10000000 -+ -+enum { -+ I965_SURFACETYPE_RGBA = 1, -+ I965_SURFACETYPE_YUV, -+ I965_SURFACETYPE_INDEXED -+}; -+ -+/* List of supported image formats */ -+typedef struct { -+ unsigned int type; -+ VAImageFormat va_format; -+} i965_image_format_map_t; -+ -+static const i965_image_format_map_t -+i965_image_formats_map[I965_MAX_IMAGE_FORMATS + 1] = { -+ { I965_SURFACETYPE_YUV, -+ { VA_FOURCC('Y','V','1','2'), VA_LSB_FIRST, 12, } }, -+}; -+ -+static const i965_image_format_map_t * -+get_image_format(const VAImageFormat *va_format) -+{ -+ unsigned int i; -+ for (i = 0; i965_image_formats_map[i].type != 0; i++) { -+ const i965_image_format_map_t * const m = &i965_image_formats_map[i]; -+ if (m->va_format.fourcc == va_format->fourcc && -+ (m->type == I965_SURFACETYPE_RGBA ? -+ (m->va_format.byte_order == va_format->byte_order && -+ m->va_format.red_mask == va_format->red_mask && -+ m->va_format.green_mask == va_format->green_mask && -+ m->va_format.blue_mask == va_format->blue_mask && -+ m->va_format.alpha_mask == va_format->alpha_mask) : 1)) -+ return m; -+ } -+ return NULL; -+} -+ -+/* List of supported subpicture formats */ -+typedef struct { -+ unsigned int type; -+ unsigned int format; -+ VAImageFormat va_format; -+ unsigned int va_flags; -+} i965_subpic_format_map_t; -+ -+static const i965_subpic_format_map_t -+i965_subpic_formats_map[I965_MAX_SUBPIC_FORMATS + 1] = { -+ { I965_SURFACETYPE_INDEXED, I965_SURFACEFORMAT_P4A4_UNORM, -+ { VA_FOURCC('I','A','4','4'), VA_MSB_FIRST, 8, }, -+ 0 }, -+ { I965_SURFACETYPE_INDEXED, I965_SURFACEFORMAT_A4P4_UNORM, -+ { VA_FOURCC('A','I','4','4'), VA_MSB_FIRST, 8, }, -+ 0 }, -+ { I965_SURFACETYPE_RGBA, I965_SURFACEFORMAT_B8G8R8A8_UNORM, -+ { VA_FOURCC('B','G','R','A'), VA_LSB_FIRST, 32, -+ 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 }, -+ 0 }, -+ { I965_SURFACETYPE_RGBA, I965_SURFACEFORMAT_R8G8B8A8_UNORM, -+ { VA_FOURCC('R','G','B','A'), VA_LSB_FIRST, 32, -+ 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 }, -+ 0 }, -+}; -+ -+static const i965_subpic_format_map_t * -+get_subpic_format(const VAImageFormat *va_format) -+{ -+ unsigned int i; -+ for (i = 0; i < sizeof(i965_subpic_formats_map)/sizeof(i965_subpic_formats_map[0]); i++) { -+ const i965_subpic_format_map_t * const m = &i965_subpic_formats_map[i]; -+ if (m->va_format.fourcc == va_format->fourcc && -+ (m->type == I965_SURFACETYPE_RGBA ? -+ (m->va_format.byte_order == va_format->byte_order && -+ m->va_format.red_mask == va_format->red_mask && -+ m->va_format.green_mask == va_format->green_mask && -+ m->va_format.blue_mask == va_format->blue_mask && -+ m->va_format.alpha_mask == va_format->alpha_mask) : 1)) -+ return m; -+ } -+ return NULL; -+} -+ -+VAStatus -+i965_QueryConfigProfiles(VADriverContextP ctx, -+ VAProfile *profile_list, /* out */ -+ int *num_profiles) /* out */ -+{ -+ int i = 0; -+ -+ profile_list[i++] = VAProfileMPEG2Simple; -+ profile_list[i++] = VAProfileMPEG2Main; -+ -+ /* If the assert fails then I965_MAX_PROFILES needs to be bigger */ -+ assert(i <= I965_MAX_PROFILES); -+ *num_profiles = i; -+ -+ return VA_STATUS_SUCCESS; -+} -+ -+VAStatus -+i965_QueryConfigEntrypoints(VADriverContextP ctx, -+ VAProfile profile, -+ VAEntrypoint *entrypoint_list, /* out */ -+ int *num_entrypoints) /* out */ -+{ -+ VAStatus vaStatus = VA_STATUS_SUCCESS; -+ -+ switch (profile) { -+ case VAProfileMPEG2Simple: -+ case VAProfileMPEG2Main: -+ *num_entrypoints = 1; -+ entrypoint_list[0] = VAEntrypointVLD; -+ break; -+ -+ default: -+ vaStatus = VA_STATUS_ERROR_UNSUPPORTED_PROFILE; -+ *num_entrypoints = 0; -+ break; -+ } -+ -+ /* If the assert fails then I965_MAX_ENTRYPOINTS needs to be bigger */ -+ assert(*num_entrypoints <= I965_MAX_ENTRYPOINTS); -+ -+ return vaStatus; -+} -+ -+VAStatus -+i965_GetConfigAttributes(VADriverContextP ctx, -+ VAProfile profile, -+ VAEntrypoint entrypoint, -+ VAConfigAttrib *attrib_list, /* in/out */ -+ int num_attribs) -+{ -+ int i; -+ -+ /* Other attributes don't seem to be defined */ -+ /* What to do if we don't know the attribute? */ -+ for (i = 0; i < num_attribs; i++) { -+ switch (attrib_list[i].type) { -+ case VAConfigAttribRTFormat: -+ attrib_list[i].value = VA_RT_FORMAT_YUV420; -+ break; -+ -+ default: -+ /* Do nothing */ -+ attrib_list[i].value = VA_ATTRIB_NOT_SUPPORTED; -+ break; -+ } -+ } -+ -+ return VA_STATUS_SUCCESS; -+} -+ -+static void -+i965_destroy_config(struct object_heap *heap, struct object_base *obj) -+{ -+ object_heap_free(heap, obj); -+} -+ -+static VAStatus -+i965_update_attribute(struct object_config *obj_config, VAConfigAttrib *attrib) -+{ -+ int i; -+ -+ /* Check existing attrbiutes */ -+ for (i = 0; obj_config->num_attribs < i; i++) { -+ if (obj_config->attrib_list[i].type == attrib->type) { -+ /* Update existing attribute */ -+ obj_config->attrib_list[i].value = attrib->value; -+ return VA_STATUS_SUCCESS; -+ } -+ } -+ -+ if (obj_config->num_attribs < I965_MAX_CONFIG_ATTRIBUTES) { -+ i = obj_config->num_attribs; -+ obj_config->attrib_list[i].type = attrib->type; -+ obj_config->attrib_list[i].value = attrib->value; -+ obj_config->num_attribs++; -+ return VA_STATUS_SUCCESS; -+ } -+ -+ return VA_STATUS_ERROR_MAX_NUM_EXCEEDED; -+} -+ -+VAStatus -+i965_CreateConfig(VADriverContextP ctx, -+ VAProfile profile, -+ VAEntrypoint entrypoint, -+ VAConfigAttrib *attrib_list, -+ int num_attribs, -+ VAConfigID *config_id) /* out */ -+{ -+ struct i965_driver_data *i965 = i965_driver_data(ctx); -+ struct object_config *obj_config; -+ int configID; -+ int i; -+ VAStatus vaStatus; -+ -+ /* Validate profile & entrypoint */ -+ switch (profile) { -+ case VAProfileMPEG2Simple: -+ case VAProfileMPEG2Main: -+ if (VAEntrypointVLD == entrypoint) { -+ vaStatus = VA_STATUS_SUCCESS; -+ } else { -+ vaStatus = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT; -+ } -+ break; -+ -+ default: -+ vaStatus = VA_STATUS_ERROR_UNSUPPORTED_PROFILE; -+ break; -+ } -+ -+ if (VA_STATUS_SUCCESS != vaStatus) { -+ return vaStatus; -+ } -+ -+ configID = NEW_CONFIG_ID(); -+ obj_config = CONFIG(configID); -+ -+ if (NULL == obj_config) { -+ vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; -+ return vaStatus; -+ } -+ -+ obj_config->profile = profile; -+ obj_config->entrypoint = entrypoint; -+ obj_config->attrib_list[0].type = VAConfigAttribRTFormat; -+ obj_config->attrib_list[0].value = VA_RT_FORMAT_YUV420; -+ obj_config->num_attribs = 1; -+ -+ for(i = 0; i < num_attribs; i++) { -+ vaStatus = i965_update_attribute(obj_config, &(attrib_list[i])); -+ -+ if (VA_STATUS_SUCCESS != vaStatus) { -+ break; -+ } -+ } -+ -+ /* Error recovery */ -+ if (VA_STATUS_SUCCESS != vaStatus) { -+ i965_destroy_config(&i965->config_heap, (struct object_base *)obj_config); -+ } else { -+ *config_id = configID; -+ } -+ -+ return vaStatus; -+} -+ -+VAStatus -+i965_DestroyConfig(VADriverContextP ctx, VAConfigID config_id) -+{ -+ struct i965_driver_data *i965 = i965_driver_data(ctx); -+ struct object_config *obj_config = CONFIG(config_id); -+ VAStatus vaStatus; -+ -+ if (NULL == obj_config) { -+ vaStatus = VA_STATUS_ERROR_INVALID_CONFIG; -+ return vaStatus; -+ } -+ -+ i965_destroy_config(&i965->config_heap, (struct object_base *)obj_config); -+ return VA_STATUS_SUCCESS; -+} -+ -+VAStatus i965_QueryConfigAttributes(VADriverContextP ctx, -+ VAConfigID config_id, -+ VAProfile *profile, /* out */ -+ VAEntrypoint *entrypoint, /* out */ -+ VAConfigAttrib *attrib_list, /* out */ -+ int *num_attribs) /* out */ -+{ -+ struct i965_driver_data *i965 = i965_driver_data(ctx); -+ struct object_config *obj_config = CONFIG(config_id); -+ VAStatus vaStatus = VA_STATUS_SUCCESS; -+ int i; -+ -+ assert(obj_config); -+ *profile = obj_config->profile; -+ *entrypoint = obj_config->entrypoint; -+ *num_attribs = obj_config->num_attribs; -+ -+ for(i = 0; i < obj_config->num_attribs; i++) { -+ attrib_list[i] = obj_config->attrib_list[i]; -+ } -+ -+ return vaStatus; -+} -+ -+static void -+i965_destroy_surface(struct object_heap *heap, struct object_base *obj) -+{ -+ struct object_surface *obj_surface = (struct object_surface *)obj; -+ -+ dri_bo_unreference(obj_surface->bo); -+ obj_surface->bo = NULL; -+ object_heap_free(heap, obj); -+} -+ -+VAStatus -+i965_CreateSurfaces(VADriverContextP ctx, -+ int width, -+ int height, -+ int format, -+ int num_surfaces, -+ VASurfaceID *surfaces) /* out */ -+{ -+ struct i965_driver_data *i965 = i965_driver_data(ctx); -+ int i; -+ VAStatus vaStatus = VA_STATUS_SUCCESS; -+ -+ /* We only support one format */ -+ if (VA_RT_FORMAT_YUV420 != format) { -+ return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT; -+ } -+ -+ for (i = 0; i < num_surfaces; i++) { -+ int surfaceID = NEW_SURFACE_ID(); -+ struct object_surface *obj_surface = SURFACE(surfaceID); -+ -+ if (NULL == obj_surface) { -+ vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; -+ break; -+ } -+ -+ surfaces[i] = surfaceID; -+ obj_surface->status = VASurfaceReady; -+ obj_surface->subpic = VA_INVALID_ID; -+ obj_surface->width = width; -+ obj_surface->height = height; -+ obj_surface->size = SIZE_YUV420(width, height); -+ obj_surface->bo = dri_bo_alloc(i965->intel.bufmgr, -+ "vaapi surface", -+ obj_surface->size, -+ 64); -+ -+ assert(obj_surface->bo); -+ if (NULL == obj_surface->bo) { -+ vaStatus = VA_STATUS_ERROR_UNKNOWN; -+ break; -+ } -+ } -+ -+ /* Error recovery */ -+ if (VA_STATUS_SUCCESS != vaStatus) { -+ /* surfaces[i-1] was the last successful allocation */ -+ for (; i--; ) { -+ struct object_surface *obj_surface = SURFACE(surfaces[i]); -+ -+ surfaces[i] = VA_INVALID_SURFACE; -+ assert(obj_surface); -+ i965_destroy_surface(&i965->surface_heap, (struct object_base *)obj_surface); -+ } -+ } -+ -+ return vaStatus; -+} -+ -+VAStatus -+i965_DestroySurfaces(VADriverContextP ctx, -+ VASurfaceID *surface_list, -+ int num_surfaces) -+{ -+ struct i965_driver_data *i965 = i965_driver_data(ctx); -+ int i; -+ -+ for (i = num_surfaces; i--; ) { -+ struct object_surface *obj_surface = SURFACE(surface_list[i]); -+ -+ assert(obj_surface); -+ i965_destroy_surface(&i965->surface_heap, (struct object_base *)obj_surface); -+ } -+ -+ return VA_STATUS_SUCCESS; -+} -+ -+VAStatus -+i965_QueryImageFormats(VADriverContextP ctx, -+ VAImageFormat *format_list, /* out */ -+ int *num_formats) /* out */ -+{ -+ int n; -+ -+ for (n = 0; i965_image_formats_map[n].va_format.fourcc != 0; n++) { -+ const i965_image_format_map_t * const m = &i965_image_formats_map[n]; -+ if (format_list) -+ format_list[n] = m->va_format; -+ } -+ -+ if (num_formats) -+ *num_formats = n; -+ -+ return VA_STATUS_SUCCESS; -+} -+ -+VAStatus -+i965_PutImage(VADriverContextP ctx, -+ VASurfaceID surface, -+ VAImageID image, -+ int src_x, -+ int src_y, -+ unsigned int src_width, -+ unsigned int src_height, -+ int dest_x, -+ int dest_y, -+ unsigned int dest_width, -+ unsigned int dest_height) -+{ -+ return VA_STATUS_SUCCESS; -+} -+ -+VAStatus -+i965_QuerySubpictureFormats(VADriverContextP ctx, -+ VAImageFormat *format_list, /* out */ -+ unsigned int *flags, /* out */ -+ unsigned int *num_formats) /* out */ -+{ -+ int n; -+ -+ for (n = 0; i965_subpic_formats_map[n].va_format.fourcc != 0; n++) { -+ const i965_subpic_format_map_t * const m = &i965_subpic_formats_map[n]; -+ if (format_list) -+ format_list[n] = m->va_format; -+ if (flags) -+ flags[n] = m->va_flags; -+ } -+ -+ if (num_formats) -+ *num_formats = n; -+ -+ return VA_STATUS_SUCCESS; -+} -+ -+static void -+i965_destroy_subpic(struct object_heap *heap, struct object_base *obj) -+{ -+// struct object_subpic *obj_subpic = (struct object_subpic *)obj; -+ -+ object_heap_free(heap, obj); -+} -+ -+VAStatus -+i965_CreateSubpicture(VADriverContextP ctx, -+ VAImageID image, -+ VASubpictureID *subpicture) /* out */ -+{ -+ struct i965_driver_data *i965 = i965_driver_data(ctx); -+ VASubpictureID subpicID = NEW_SUBPIC_ID() -+ -+ struct object_subpic *obj_subpic = SUBPIC(subpicID); -+ if (!obj_subpic) -+ return VA_STATUS_ERROR_ALLOCATION_FAILED; -+ -+ struct object_image *obj_image = IMAGE(image); -+ if (!obj_image) -+ return VA_STATUS_ERROR_INVALID_IMAGE; -+ -+ const i965_subpic_format_map_t * const m = get_subpic_format(&obj_image->image.format); -+ if (!m) -+ return VA_STATUS_ERROR_UNKNOWN; /* XXX: VA_STATUS_ERROR_UNSUPPORTED_FORMAT? */ -+ -+ *subpicture = subpicID; -+ obj_subpic->image = image; -+ obj_subpic->format = m->format; -+ obj_subpic->width = obj_image->image.width; -+ obj_subpic->height = obj_image->image.height; -+ obj_subpic->pitch = obj_image->image.pitches[0]; -+ obj_subpic->bo = obj_image->bo; -+ return VA_STATUS_SUCCESS; -+} -+ -+VAStatus -+i965_DestroySubpicture(VADriverContextP ctx, -+ VASubpictureID subpicture) -+{ -+ -+ struct i965_driver_data *i965 = i965_driver_data(ctx); -+ struct object_subpic *obj_subpic = SUBPIC(subpicture); -+ i965_destroy_subpic(&i965->subpic_heap, (struct object_base *)obj_subpic); -+ return VA_STATUS_SUCCESS; -+} -+ -+VAStatus -+i965_SetSubpictureImage(VADriverContextP ctx, -+ VASubpictureID subpicture, -+ VAImageID image) -+{ -+ /* TODO */ -+ return VA_STATUS_ERROR_UNIMPLEMENTED; -+} -+ -+VAStatus -+i965_SetSubpictureChromakey(VADriverContextP ctx, -+ VASubpictureID subpicture, -+ unsigned int chromakey_min, -+ unsigned int chromakey_max, -+ unsigned int chromakey_mask) -+{ -+ /* TODO */ -+ return VA_STATUS_ERROR_UNIMPLEMENTED; -+} -+ -+VAStatus -+i965_SetSubpictureGlobalAlpha(VADriverContextP ctx, -+ VASubpictureID subpicture, -+ float global_alpha) -+{ -+ /* TODO */ -+ return VA_STATUS_ERROR_UNIMPLEMENTED; -+} -+ -+VAStatus -+i965_AssociateSubpicture(VADriverContextP ctx, -+ VASubpictureID subpicture, -+ VASurfaceID *target_surfaces, -+ int num_surfaces, -+ short src_x, /* upper left offset in subpicture */ -+ short src_y, -+ unsigned short src_width, -+ unsigned short src_height, -+ short dest_x, /* upper left offset in surface */ -+ short dest_y, -+ unsigned short dest_width, -+ unsigned short dest_height, -+ /* -+ * whether to enable chroma-keying or global-alpha -+ * see VA_SUBPICTURE_XXX values -+ */ -+ unsigned int flags) -+{ -+ struct i965_driver_data *i965 = i965_driver_data(ctx); -+ struct object_subpic *obj_subpic = SUBPIC(subpicture); -+ int i; -+ -+ obj_subpic->src_rect.x = src_x; -+ obj_subpic->src_rect.y = src_y; -+ obj_subpic->src_rect.width = src_width; -+ obj_subpic->src_rect.height = src_height; -+ obj_subpic->dst_rect.x = dest_x; -+ obj_subpic->dst_rect.y = dest_y; -+ obj_subpic->dst_rect.width = dest_width; -+ obj_subpic->dst_rect.height = dest_height; -+ -+ for (i = 0; i < num_surfaces; i++) { -+ struct object_surface *obj_surface = SURFACE(target_surfaces[i]); -+ if (!obj_surface) -+ return VA_STATUS_ERROR_INVALID_SURFACE; -+ obj_surface->subpic = subpicture; -+ } -+ return VA_STATUS_SUCCESS; -+} -+ -+ -+VAStatus -+i965_DeassociateSubpicture(VADriverContextP ctx, -+ VASubpictureID subpicture, -+ VASurfaceID *target_surfaces, -+ int num_surfaces) -+{ -+ struct i965_driver_data *i965 = i965_driver_data(ctx); -+ int i; -+ -+ for (i = 0; i < num_surfaces; i++) { -+ struct object_surface *obj_surface = SURFACE(target_surfaces[i]); -+ if (!obj_surface) -+ return VA_STATUS_ERROR_INVALID_SURFACE; -+ if (obj_surface->subpic == subpicture) -+ obj_surface->subpic = VA_INVALID_ID; -+ } -+ return VA_STATUS_SUCCESS; -+} -+ -+static void -+i965_reference_buffer_store(struct buffer_store **ptr, -+ struct buffer_store *buffer_store) -+{ -+ assert(*ptr == NULL); -+ -+ if (buffer_store) { -+ buffer_store->ref_count++; -+ *ptr = buffer_store; -+ } -+} -+ -+static void -+i965_release_buffer_store(struct buffer_store **ptr) -+{ -+ struct buffer_store *buffer_store = *ptr; -+ -+ if (buffer_store == NULL) -+ return; -+ -+ assert(buffer_store->bo || buffer_store->buffer); -+ assert(!(buffer_store->bo && buffer_store->buffer)); -+ buffer_store->ref_count--; -+ -+ if (buffer_store->ref_count == 0) { -+ dri_bo_unreference(buffer_store->bo); -+ free(buffer_store->buffer); -+ buffer_store->bo = NULL; -+ buffer_store->buffer = NULL; -+ free(buffer_store); -+ } -+ -+ *ptr = NULL; -+} -+ -+static void -+i965_destroy_context(struct object_heap *heap, struct object_base *obj) -+{ -+ struct object_context *obj_context = (struct object_context *)obj; -+ -+ i965_release_buffer_store(&obj_context->decode_state.pic_param); -+ i965_release_buffer_store(&obj_context->decode_state.slice_param); -+ i965_release_buffer_store(&obj_context->decode_state.iq_matrix); -+ i965_release_buffer_store(&obj_context->decode_state.bit_plane); -+ i965_release_buffer_store(&obj_context->decode_state.slice_data); -+ free(obj_context->render_targets); -+ object_heap_free(heap, obj); -+} -+ -+VAStatus -+i965_CreateContext(VADriverContextP ctx, -+ VAConfigID config_id, -+ int picture_width, -+ int picture_height, -+ int flag, -+ VASurfaceID *render_targets, -+ int num_render_targets, -+ VAContextID *context) /* out */ -+{ -+ struct i965_driver_data *i965 = i965_driver_data(ctx); -+ struct object_config *obj_config = CONFIG(config_id); -+ struct object_context *obj_context = NULL; -+ VAStatus vaStatus = VA_STATUS_SUCCESS; -+ int contextID; -+ int i; -+ -+ if (NULL == obj_config) { -+ vaStatus = VA_STATUS_ERROR_INVALID_CONFIG; -+ return vaStatus; -+ } -+ -+ /* Validate flag */ -+ /* Validate picture dimensions */ -+ contextID = NEW_CONTEXT_ID(); -+ obj_context = CONTEXT(contextID); -+ -+ if (NULL == obj_context) { -+ vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; -+ return vaStatus; -+ } -+ -+ obj_context->context_id = contextID; -+ *context = contextID; -+ memset(&obj_context->decode_state, 0, sizeof(obj_context->decode_state)); -+ obj_context->decode_state.current_render_target = -1; -+ obj_context->config_id = config_id; -+ obj_context->picture_width = picture_width; -+ obj_context->picture_height = picture_height; -+ obj_context->num_render_targets = num_render_targets; -+ obj_context->render_targets = -+ (VASurfaceID *)calloc(num_render_targets, sizeof(VASurfaceID)); -+ -+ for(i = 0; i < num_render_targets; i++) { -+ if (NULL == SURFACE(render_targets[i])) { -+ vaStatus = VA_STATUS_ERROR_INVALID_SURFACE; -+ break; -+ } -+ -+ obj_context->render_targets[i] = render_targets[i]; -+ } -+ -+ obj_context->flags = flag; -+ -+ /* Error recovery */ -+ if (VA_STATUS_SUCCESS != vaStatus) { -+ i965_destroy_context(&i965->context_heap, (struct object_base *)obj_context); -+ } -+ -+ return vaStatus; -+} -+ -+VAStatus -+i965_DestroyContext(VADriverContextP ctx, VAContextID context) -+{ -+ struct i965_driver_data *i965 = i965_driver_data(ctx); -+ struct object_context *obj_context = CONTEXT(context); -+ -+ assert(obj_context); -+ i965_destroy_context(&i965->context_heap, (struct object_base *)obj_context); -+ -+ return VA_STATUS_SUCCESS; -+} -+ -+static void -+i965_destroy_buffer(struct object_heap *heap, struct object_base *obj) -+{ -+ struct object_buffer *obj_buffer = (struct object_buffer *)obj; -+ -+ assert(obj_buffer->buffer_store); -+ i965_release_buffer_store(&obj_buffer->buffer_store); -+ object_heap_free(heap, obj); -+} -+ -+VAStatus -+i965_CreateBuffer(VADriverContextP ctx, -+ VAContextID context, /* in */ -+ VABufferType type, /* in */ -+ unsigned int size, /* in */ -+ unsigned int num_elements, /* in */ -+ void *data, /* in */ -+ VABufferID *buf_id) /* out */ -+{ -+ struct i965_driver_data *i965 = i965_driver_data(ctx); -+ struct object_buffer *obj_buffer = NULL; -+ struct buffer_store *buffer_store = NULL; -+ int bufferID; -+ -+ /* Validate type */ -+ switch (type) { -+ case VAPictureParameterBufferType: -+ case VAIQMatrixBufferType: -+ case VABitPlaneBufferType: -+ case VASliceGroupMapBufferType: -+ case VASliceParameterBufferType: -+ case VASliceDataBufferType: -+ case VAMacroblockParameterBufferType: -+ case VAResidualDataBufferType: -+ case VADeblockingParameterBufferType: -+ case VAImageBufferType: -+ /* Ok */ -+ break; -+ -+ default: -+ return VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE; -+ } -+ -+ bufferID = NEW_BUFFER_ID(); -+ obj_buffer = BUFFER(bufferID); -+ -+ if (NULL == obj_buffer) { -+ return VA_STATUS_ERROR_ALLOCATION_FAILED; -+ } -+ -+ obj_buffer->max_num_elements = num_elements; -+ obj_buffer->num_elements = num_elements; -+ obj_buffer->size_element = size; -+ obj_buffer->type = type; -+ obj_buffer->buffer_store = NULL; -+ buffer_store = calloc(1, sizeof(struct buffer_store)); -+ assert(buffer_store); -+ buffer_store->ref_count = 1; -+ -+ if (type == VASliceDataBufferType || type == VAImageBufferType) { -+ buffer_store->bo = dri_bo_alloc(i965->intel.bufmgr, -+ "Buffer", -+ size * num_elements, 64); -+ assert(buffer_store->bo); -+ -+ if (data) -+ dri_bo_subdata(buffer_store->bo, 0, size * num_elements, data); -+ } else { -+ buffer_store->buffer = malloc(size * num_elements); -+ assert(buffer_store->buffer); -+ -+ if (data) -+ memcpy(buffer_store->buffer, data, size * num_elements); -+ } -+ -+ i965_reference_buffer_store(&obj_buffer->buffer_store, buffer_store); -+ i965_release_buffer_store(&buffer_store); -+ *buf_id = bufferID; -+ -+ return VA_STATUS_SUCCESS; -+} -+ -+ -+VAStatus -+i965_BufferSetNumElements(VADriverContextP ctx, -+ VABufferID buf_id, /* in */ -+ unsigned int num_elements) /* in */ -+{ -+ struct i965_driver_data *i965 = i965_driver_data(ctx); -+ struct object_buffer *obj_buffer = BUFFER(buf_id); -+ VAStatus vaStatus = VA_STATUS_SUCCESS; -+ -+ assert(obj_buffer); -+ -+ if ((num_elements < 0) || -+ (num_elements > obj_buffer->max_num_elements)) { -+ vaStatus = VA_STATUS_ERROR_UNKNOWN; -+ } else { -+ obj_buffer->num_elements = num_elements; -+ } -+ -+ return vaStatus; -+} -+ -+VAStatus -+i965_MapBuffer(VADriverContextP ctx, -+ VABufferID buf_id, /* in */ -+ void **pbuf) /* out */ -+{ -+ struct i965_driver_data *i965 = i965_driver_data(ctx); -+ struct object_buffer *obj_buffer = BUFFER(buf_id); -+ VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN; -+ -+ assert(obj_buffer && obj_buffer->buffer_store); -+ assert(obj_buffer->buffer_store->bo || obj_buffer->buffer_store->buffer); -+ assert(!(obj_buffer->buffer_store->bo && obj_buffer->buffer_store->buffer)); -+ -+ if (NULL != obj_buffer->buffer_store->bo) { -+ dri_bo_map(obj_buffer->buffer_store->bo, 1); -+ assert(obj_buffer->buffer_store->bo->virtual); -+ *pbuf = obj_buffer->buffer_store->bo->virtual; -+ vaStatus = VA_STATUS_SUCCESS; -+ } else if (NULL != obj_buffer->buffer_store->buffer) { -+ *pbuf = obj_buffer->buffer_store->buffer; -+ vaStatus = VA_STATUS_SUCCESS; -+ } -+ -+ return vaStatus; -+} -+ -+VAStatus -+i965_UnmapBuffer(VADriverContextP ctx, VABufferID buf_id) -+{ -+ struct i965_driver_data *i965 = i965_driver_data(ctx); -+ struct object_buffer *obj_buffer = BUFFER(buf_id); -+ VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN; -+ -+ assert(obj_buffer && obj_buffer->buffer_store); -+ assert(obj_buffer->buffer_store->bo || obj_buffer->buffer_store->buffer); -+ assert(!(obj_buffer->buffer_store->bo && obj_buffer->buffer_store->buffer)); -+ -+ if (NULL != obj_buffer->buffer_store->bo) { -+ dri_bo_unmap(obj_buffer->buffer_store->bo); -+ vaStatus = VA_STATUS_SUCCESS; -+ } else if (NULL != obj_buffer->buffer_store->buffer) { -+ /* Do nothing */ -+ vaStatus = VA_STATUS_SUCCESS; -+ } -+ -+ return vaStatus; -+} -+ -+VAStatus -+i965_DestroyBuffer(VADriverContextP ctx, VABufferID buffer_id) -+{ -+ struct i965_driver_data *i965 = i965_driver_data(ctx); -+ struct object_buffer *obj_buffer = BUFFER(buffer_id); -+ -+ assert(obj_buffer); -+ i965_destroy_buffer(&i965->buffer_heap, (struct object_base *)obj_buffer); -+ -+ return VA_STATUS_SUCCESS; -+} -+ -+VAStatus -+i965_BeginPicture(VADriverContextP ctx, -+ VAContextID context, -+ VASurfaceID render_target) -+{ -+ struct i965_driver_data *i965 = i965_driver_data(ctx); -+ struct object_context *obj_context = CONTEXT(context); -+ struct object_surface *obj_surface = SURFACE(render_target); -+ struct object_config *obj_config; -+ VAContextID config; -+ VAStatus vaStatus; -+ -+ assert(obj_context); -+ assert(obj_surface); -+ -+ config = obj_context->config_id; -+ obj_config = CONFIG(config); -+ assert(obj_config); -+ -+ switch (obj_config->profile) { -+ case VAProfileMPEG2Simple: -+ case VAProfileMPEG2Main: -+ vaStatus = VA_STATUS_SUCCESS; -+ break; -+ -+ default: -+ assert(0); -+ vaStatus = VA_STATUS_ERROR_UNSUPPORTED_PROFILE; -+ break; -+ } -+ -+ obj_context->decode_state.current_render_target = render_target; -+ -+ return vaStatus; -+} -+ -+static VAStatus -+i965_render_picture_parameter_buffer(VADriverContextP ctx, -+ struct object_context *obj_context, -+ struct object_buffer *obj_buffer) -+{ -+ assert(obj_buffer->buffer_store->bo == NULL); -+ assert(obj_buffer->buffer_store->buffer); -+ i965_release_buffer_store(&obj_context->decode_state.pic_param); -+ i965_reference_buffer_store(&obj_context->decode_state.pic_param, -+ obj_buffer->buffer_store); -+ -+ return VA_STATUS_SUCCESS; -+} -+ -+static VAStatus -+i965_render_iq_matrix_buffer(VADriverContextP ctx, -+ struct object_context *obj_context, -+ struct object_buffer *obj_buffer) -+{ -+ assert(obj_buffer->buffer_store->bo == NULL); -+ assert(obj_buffer->buffer_store->buffer); -+ i965_release_buffer_store(&obj_context->decode_state.iq_matrix); -+ i965_reference_buffer_store(&obj_context->decode_state.iq_matrix, -+ obj_buffer->buffer_store); -+ -+ return VA_STATUS_SUCCESS; -+} -+ -+static VAStatus -+i965_render_bit_plane_buffer(VADriverContextP ctx, -+ struct object_context *obj_context, -+ struct object_buffer *obj_buffer) -+{ -+ assert(obj_buffer->buffer_store->bo == NULL); -+ assert(obj_buffer->buffer_store->buffer); -+ i965_release_buffer_store(&obj_context->decode_state.bit_plane); -+ i965_reference_buffer_store(&obj_context->decode_state.bit_plane, -+ obj_buffer->buffer_store); -+ -+ return VA_STATUS_SUCCESS; -+} -+ -+static VAStatus -+i965_render_slice_parameter_buffer(VADriverContextP ctx, -+ struct object_context *obj_context, -+ struct object_buffer *obj_buffer) -+{ -+ assert(obj_buffer->buffer_store->bo == NULL); -+ assert(obj_buffer->buffer_store->buffer); -+ i965_release_buffer_store(&obj_context->decode_state.slice_param); -+ i965_reference_buffer_store(&obj_context->decode_state.slice_param, -+ obj_buffer->buffer_store); -+ obj_context->decode_state.num_slices = obj_buffer->num_elements; -+ -+ return VA_STATUS_SUCCESS; -+} -+ -+static VAStatus -+i965_render_slice_data_buffer(VADriverContextP ctx, -+ struct object_context *obj_context, -+ struct object_buffer *obj_buffer) -+{ -+ assert(obj_buffer->buffer_store->buffer == NULL); -+ assert(obj_buffer->buffer_store->bo); -+ i965_release_buffer_store(&obj_context->decode_state.slice_data); -+ i965_reference_buffer_store(&obj_context->decode_state.slice_data, -+ obj_buffer->buffer_store); -+ -+ return VA_STATUS_SUCCESS; -+} -+ -+VAStatus -+i965_RenderPicture(VADriverContextP ctx, -+ VAContextID context, -+ VABufferID *buffers, -+ int num_buffers) -+{ -+ struct i965_driver_data *i965 = i965_driver_data(ctx); -+ struct object_context *obj_context; -+ int i; -+ VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN; -+ -+ obj_context = CONTEXT(context); -+ assert(obj_context); -+ -+ for (i = 0; i < num_buffers; i++) { -+ struct object_buffer *obj_buffer = BUFFER(buffers[i]); -+ assert(obj_buffer); -+ -+ switch (obj_buffer->type) { -+ case VAPictureParameterBufferType: -+ vaStatus = i965_render_picture_parameter_buffer(ctx, obj_context, obj_buffer); -+ break; -+ -+ case VAIQMatrixBufferType: -+ vaStatus = i965_render_iq_matrix_buffer(ctx, obj_context, obj_buffer); -+ break; -+ -+ case VABitPlaneBufferType: -+ vaStatus = i965_render_bit_plane_buffer(ctx, obj_context, obj_buffer); -+ break; -+ -+ case VASliceParameterBufferType: -+ vaStatus = i965_render_slice_parameter_buffer(ctx, obj_context, obj_buffer); -+ break; -+ -+ case VASliceDataBufferType: -+ vaStatus = i965_render_slice_data_buffer(ctx, obj_context, obj_buffer); -+ break; -+ -+ default: -+ break; -+ } -+ } -+ -+ return vaStatus; -+} -+ -+VAStatus -+i965_EndPicture(VADriverContextP ctx, VAContextID context) -+{ -+ struct i965_driver_data *i965 = i965_driver_data(ctx); -+ struct object_context *obj_context = CONTEXT(context); -+ struct object_config *obj_config; -+ VAContextID config; -+ -+ assert(obj_context); -+ assert(obj_context->decode_state.pic_param); -+ assert(obj_context->decode_state.slice_param); -+ assert(obj_context->decode_state.slice_data); -+ -+ config = obj_context->config_id; -+ obj_config = CONFIG(config); -+ assert(obj_config); -+ i965_media_decode_picture(ctx, obj_config->profile, &obj_context->decode_state); -+ obj_context->decode_state.current_render_target = -1; -+ obj_context->decode_state.num_slices = 0; -+ i965_release_buffer_store(&obj_context->decode_state.pic_param); -+ i965_release_buffer_store(&obj_context->decode_state.slice_param); -+ i965_release_buffer_store(&obj_context->decode_state.iq_matrix); -+ i965_release_buffer_store(&obj_context->decode_state.bit_plane); -+ i965_release_buffer_store(&obj_context->decode_state.slice_data); -+ -+ return VA_STATUS_SUCCESS; -+} -+ -+VAStatus -+i965_SyncSurface(VADriverContextP ctx, -+ VASurfaceID render_target) -+{ -+ struct i965_driver_data *i965 = i965_driver_data(ctx); -+ struct object_surface *obj_surface = SURFACE(render_target); -+ -+ assert(obj_surface); -+ -+ return VA_STATUS_SUCCESS; -+} -+ -+VAStatus -+i965_QuerySurfaceStatus(VADriverContextP ctx, -+ VASurfaceID render_target, -+ VASurfaceStatus *status) /* out */ -+{ -+ struct i965_driver_data *i965 = i965_driver_data(ctx); -+ struct object_surface *obj_surface = SURFACE(render_target); -+ -+ assert(obj_surface); -+ *status = obj_surface->status; -+ -+ return VA_STATUS_SUCCESS; -+} -+ -+ -+/* -+ * Query display attributes -+ * The caller must provide a "attr_list" array that can hold at -+ * least vaMaxNumDisplayAttributes() entries. The actual number of attributes -+ * returned in "attr_list" is returned in "num_attributes". -+ */ -+VAStatus -+i965_QueryDisplayAttributes(VADriverContextP ctx, -+ VADisplayAttribute *attr_list, /* out */ -+ int *num_attributes) /* out */ -+{ -+ if (num_attributes) -+ *num_attributes = 0; -+ -+ return VA_STATUS_SUCCESS; -+} -+ -+/* -+ * Get display attributes -+ * This function returns the current attribute values in "attr_list". -+ * Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field -+ * from vaQueryDisplayAttributes() can have their values retrieved. -+ */ -+VAStatus -+i965_GetDisplayAttributes(VADriverContextP ctx, -+ VADisplayAttribute *attr_list, /* in/out */ -+ int num_attributes) -+{ -+ /* TODO */ -+ return VA_STATUS_ERROR_UNIMPLEMENTED; -+} -+ -+/* -+ * Set display attributes -+ * Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field -+ * from vaQueryDisplayAttributes() can be set. If the attribute is not settable or -+ * the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED -+ */ -+VAStatus -+i965_SetDisplayAttributes(VADriverContextP ctx, -+ VADisplayAttribute *attr_list, -+ int num_attributes) -+{ -+ /* TODO */ -+ return VA_STATUS_ERROR_UNIMPLEMENTED; -+} -+ -+VAStatus -+i965_DbgCopySurfaceToBuffer(VADriverContextP ctx, -+ VASurfaceID surface, -+ void **buffer, /* out */ -+ unsigned int *stride) /* out */ -+{ -+ /* TODO */ -+ return VA_STATUS_ERROR_UNIMPLEMENTED; -+} -+ -+static VAStatus -+i965_Init(VADriverContextP ctx) -+{ -+ struct i965_driver_data *i965 = i965_driver_data(ctx); -+ -+ if (intel_driver_init(ctx) == False) -+ return VA_STATUS_ERROR_UNKNOWN; -+ -+ if (!IS_G4X(i965->intel.device_id) && -+ !IS_IGDNG(i965->intel.device_id)) -+ return VA_STATUS_ERROR_UNKNOWN; -+ -+ if (i965_media_init(ctx) == False) -+ return VA_STATUS_ERROR_UNKNOWN; -+ -+ if (i965_render_init(ctx) == False) -+ return VA_STATUS_ERROR_UNKNOWN; -+ -+ return VA_STATUS_SUCCESS; -+} -+ -+static void -+i965_destroy_heap(struct object_heap *heap, -+ void (*func)(struct object_heap *heap, struct object_base *object)) -+{ -+ struct object_base *object; -+ object_heap_iterator iter; -+ -+ object = object_heap_first(heap, &iter); -+ -+ while (object) { -+ if (func) -+ func(heap, object); -+ -+ object = object_heap_next(heap, &iter); -+ } -+ -+ object_heap_destroy(heap); -+} -+ -+ -+VAStatus -+i965_DestroyImage(VADriverContextP ctx, VAImageID image); -+ -+VAStatus -+i965_CreateImage(VADriverContextP ctx, -+ VAImageFormat *format, -+ int width, -+ int height, -+ VAImage *out_image) /* out */ -+{ -+ struct i965_driver_data *i965 = i965_driver_data(ctx); -+ struct object_image *obj_image; -+ VAStatus va_status = VA_STATUS_ERROR_OPERATION_FAILED; -+ VAImageID image_id; -+ unsigned int width2, height2, size2, size; -+ -+ out_image->image_id = VA_INVALID_ID; -+ out_image->buf = VA_INVALID_ID; -+ -+ image_id = NEW_IMAGE_ID(); -+ if (image_id == VA_INVALID_ID) -+ return VA_STATUS_ERROR_ALLOCATION_FAILED; -+ -+ obj_image = IMAGE(image_id); -+ if (!obj_image) -+ return VA_STATUS_ERROR_ALLOCATION_FAILED; -+ obj_image->bo = NULL; -+ obj_image->palette = NULL; -+ -+ VAImage * const image = &obj_image->image; -+ image->image_id = image_id; -+ image->buf = VA_INVALID_ID; -+ -+ size = width * height; -+ width2 = (width + 1) / 2; -+ height2 = (height + 1) / 2; -+ size2 = width2 * height2; -+ -+ image->num_palette_entries = 0; -+ image->entry_bytes = 0; -+ memset(image->component_order, 0, sizeof(image->component_order)); -+ -+ switch (format->fourcc) { -+ case VA_FOURCC('I','A','4','4'): -+ case VA_FOURCC('A','I','4','4'): -+ image->num_planes = 1; -+ image->pitches[0] = width; -+ image->offsets[0] = 0; -+ image->data_size = image->offsets[0] + image->pitches[0] * height; -+ image->num_palette_entries = 16; -+ image->entry_bytes = 3; -+ image->component_order[0] = 'R'; -+ image->component_order[1] = 'G'; -+ image->component_order[2] = 'B'; -+ break; -+ case VA_FOURCC('A','R','G','B'): -+ case VA_FOURCC('A','B','G','R'): -+ case VA_FOURCC('B','G','R','A'): -+ case VA_FOURCC('R','G','B','A'): -+ image->num_planes = 1; -+ image->pitches[0] = width * 4; -+ image->offsets[0] = 0; -+ image->data_size = image->offsets[0] + image->pitches[0] * height; -+ break; -+ case VA_FOURCC('Y','V','1','2'): -+ image->num_planes = 3; -+ image->pitches[0] = width; -+ image->offsets[0] = 0; -+ image->pitches[1] = width2; -+ image->offsets[1] = size; -+ image->pitches[2] = width2; -+ image->offsets[2] = size + size2; -+ image->data_size = size + 2 * size2; -+ break; -+ default: -+ goto error; -+ } -+ -+ va_status = i965_CreateBuffer(ctx, 0, VAImageBufferType, -+ image->data_size, 1, NULL, &image->buf); -+ if (va_status != VA_STATUS_SUCCESS) -+ goto error; -+ -+ obj_image->bo = BUFFER(image->buf)->buffer_store->bo; -+ -+ if (image->num_palette_entries > 0 && image->entry_bytes > 0) { -+ obj_image->palette = malloc(image->num_palette_entries * sizeof(obj_image->palette)); -+ if (!obj_image->palette) -+ goto error; -+ } -+ -+ image->image_id = image_id; -+ image->format = *format; -+ image->width = width; -+ image->height = height; -+ -+ *out_image = *image; -+ return VA_STATUS_SUCCESS; -+ -+ error: -+ i965_DestroyImage(ctx, image_id); -+ return va_status; -+} -+ -+VAStatus i965_DeriveImage(VADriverContextP ctx, -+ VASurfaceID surface, -+ VAImage *image) /* out */ -+{ -+ /* TODO */ -+ return VA_STATUS_ERROR_OPERATION_FAILED; -+} -+ -+static void -+i965_destroy_image(struct object_heap *heap, struct object_base *obj) -+{ -+ object_heap_free(heap, obj); -+} -+ -+ -+VAStatus -+i965_DestroyImage(VADriverContextP ctx, VAImageID image) -+{ -+ struct i965_driver_data *i965 = i965_driver_data(ctx); -+ struct object_image *obj_image = IMAGE(image); -+ -+ if (!obj_image) -+ return VA_STATUS_SUCCESS; -+ -+ if (obj_image->image.buf != VA_INVALID_ID) { -+ i965_DestroyBuffer(ctx, obj_image->image.buf); -+ obj_image->image.buf = VA_INVALID_ID; -+ } -+ -+ if (obj_image->palette) { -+ free(obj_image->palette); -+ obj_image->palette = NULL; -+ } -+ -+ i965_destroy_image(&i965->image_heap, (struct object_base *)obj_image); -+ -+ return VA_STATUS_SUCCESS; -+} -+ -+/* -+ * pointer to an array holding the palette data. The size of the array is -+ * num_palette_entries * entry_bytes in size. The order of the components -+ * in the palette is described by the component_order in VASubpicture struct -+ */ -+VAStatus -+i965_SetImagePalette(VADriverContextP ctx, -+ VAImageID image, -+ unsigned char *palette) -+{ -+ struct i965_driver_data *i965 = i965_driver_data(ctx); -+ unsigned int i; -+ -+ struct object_image *obj_image = IMAGE(image); -+ if (!obj_image) -+ return VA_STATUS_ERROR_INVALID_IMAGE; -+ -+ if (!obj_image->palette) -+ return VA_STATUS_ERROR_ALLOCATION_FAILED; /* XXX: unpaletted/error */ -+ -+ for (i = 0; i < obj_image->image.num_palette_entries; i++) -+ obj_image->palette[i] = (((unsigned int)palette[3*i + 0] << 16) | -+ ((unsigned int)palette[3*i + 1] << 8) | -+ (unsigned int)palette[3*i + 2]); -+ return VA_STATUS_SUCCESS; -+} -+ -+VAStatus -+i965_GetImage(VADriverContextP ctx, -+ VASurfaceID surface, -+ int x, /* coordinates of the upper left source pixel */ -+ int y, -+ unsigned int width, /* width and height of the region */ -+ unsigned int height, -+ VAImageID image) -+{ -+ return VA_STATUS_SUCCESS; -+} -+ -+VAStatus -+i965_PutSurface(VADriverContextP ctx, -+ VASurfaceID surface, -+ Drawable draw, /* X Drawable */ -+ short srcx, -+ short srcy, -+ unsigned short srcw, -+ unsigned short srch, -+ short destx, -+ short desty, -+ unsigned short destw, -+ unsigned short desth, -+ VARectangle *cliprects, /* client supplied clip list */ -+ unsigned int number_cliprects, /* number of clip rects in the clip list */ -+ unsigned int flags) /* de-interlacing flags */ -+{ -+ struct i965_driver_data *i965 = i965_driver_data(ctx); -+ struct dri_state *dri_state = (struct dri_state *)ctx->dri_state; -+ struct i965_render_state *render_state = &i965->render_state; -+ struct dri_drawable *dri_drawable; -+ union dri_buffer *buffer; -+ struct intel_region *dest_region; -+ struct object_surface *obj_surface; -+ int ret; -+ uint32_t name; -+ Bool new_region = False; -+ /* Currently don't support DRI1 */ -+ if (dri_state->driConnectedFlag != VA_DRI2) -+ return VA_STATUS_ERROR_UNKNOWN; -+ -+ dri_drawable = dri_get_drawable(ctx, draw); -+ assert(dri_drawable); -+ -+ buffer = dri_get_rendering_buffer(ctx, dri_drawable); -+ assert(buffer); -+ -+ dest_region = render_state->draw_region; -+ -+ if (dest_region) { -+ assert(dest_region->bo); -+ dri_bo_flink(dest_region->bo, &name); -+ -+ if (buffer->dri2.name != name) { -+ new_region = True; -+ dri_bo_unreference(dest_region->bo); -+ } -+ } else { -+ dest_region = (struct intel_region *)calloc(1, sizeof(*dest_region)); -+ assert(dest_region); -+ render_state->draw_region = dest_region; -+ new_region = True; -+ } -+ -+ if (new_region) { -+ dest_region->x = dri_drawable->x; -+ dest_region->y = dri_drawable->y; -+ dest_region->width = dri_drawable->width; -+ dest_region->height = dri_drawable->height; -+ dest_region->cpp = buffer->dri2.cpp; -+ dest_region->pitch = buffer->dri2.pitch; -+ -+ dest_region->bo = intel_bo_gem_create_from_name(i965->intel.bufmgr, "rendering buffer", buffer->dri2.name); -+ assert(dest_region->bo); -+ -+ ret = dri_bo_get_tiling(dest_region->bo, &(dest_region->tiling), &(dest_region->swizzle)); -+ assert(ret == 0); -+ } -+ -+ i965_render_put_surface(ctx, surface, -+ srcx, srcy, srcw, srch, -+ destx, desty, destw, desth); -+ obj_surface = SURFACE(surface); -+ if(obj_surface->subpic != VA_INVALID_ID) { -+ i965_render_put_subpic(ctx, surface, -+ srcx, srcy, srcw, srch, -+ destx, desty, destw, desth); -+ } -+ dri_swap_buffer(ctx, dri_drawable); -+ -+ return VA_STATUS_SUCCESS; -+} -+ -+VAStatus -+i965_Terminate(VADriverContextP ctx) -+{ -+ struct i965_driver_data *i965 = i965_driver_data(ctx); -+ -+ if (i965_render_terminate(ctx) == False) -+ return VA_STATUS_ERROR_UNKNOWN; -+ -+ if (i965_media_terminate(ctx) == False) -+ return VA_STATUS_ERROR_UNKNOWN; -+ -+ if (intel_driver_terminate(ctx) == False) -+ return VA_STATUS_ERROR_UNKNOWN; -+ -+ i965_destroy_heap(&i965->buffer_heap, i965_destroy_buffer); -+ i965_destroy_heap(&i965->image_heap, i965_destroy_image); -+ i965_destroy_heap(&i965->subpic_heap, i965_destroy_subpic); -+ i965_destroy_heap(&i965->surface_heap, i965_destroy_surface); -+ i965_destroy_heap(&i965->context_heap, i965_destroy_context); -+ i965_destroy_heap(&i965->config_heap, i965_destroy_config); -+ -+ free(ctx->pDriverData); -+ ctx->pDriverData = NULL; -+ -+ return VA_STATUS_SUCCESS; -+} -+ -+VAStatus -+__vaDriverInit_0_31( VADriverContextP ctx ) -+{ -+ struct i965_driver_data *i965; -+ int result; -+ -+ ctx->version_major = VA_MAJOR_VERSION; -+ ctx->version_minor = VA_MINOR_VERSION; -+ ctx->max_profiles = I965_MAX_PROFILES; -+ ctx->max_entrypoints = I965_MAX_ENTRYPOINTS; -+ ctx->max_attributes = I965_MAX_CONFIG_ATTRIBUTES; -+ ctx->max_image_formats = I965_MAX_IMAGE_FORMATS; -+ ctx->max_subpic_formats = I965_MAX_SUBPIC_FORMATS; -+ ctx->max_display_attributes = I965_MAX_DISPLAY_ATTRIBUTES; -+ ctx->str_vendor = I965_STR_VENDOR; -+ -+ ctx->vtable.vaTerminate = i965_Terminate; -+ ctx->vtable.vaQueryConfigEntrypoints = i965_QueryConfigEntrypoints; -+ ctx->vtable.vaQueryConfigProfiles = i965_QueryConfigProfiles; -+ ctx->vtable.vaQueryConfigEntrypoints = i965_QueryConfigEntrypoints; -+ ctx->vtable.vaQueryConfigAttributes = i965_QueryConfigAttributes; -+ ctx->vtable.vaCreateConfig = i965_CreateConfig; -+ ctx->vtable.vaDestroyConfig = i965_DestroyConfig; -+ ctx->vtable.vaGetConfigAttributes = i965_GetConfigAttributes; -+ ctx->vtable.vaCreateSurfaces = i965_CreateSurfaces; -+ ctx->vtable.vaDestroySurfaces = i965_DestroySurfaces; -+ ctx->vtable.vaCreateContext = i965_CreateContext; -+ ctx->vtable.vaDestroyContext = i965_DestroyContext; -+ ctx->vtable.vaCreateBuffer = i965_CreateBuffer; -+ ctx->vtable.vaBufferSetNumElements = i965_BufferSetNumElements; -+ ctx->vtable.vaMapBuffer = i965_MapBuffer; -+ ctx->vtable.vaUnmapBuffer = i965_UnmapBuffer; -+ ctx->vtable.vaDestroyBuffer = i965_DestroyBuffer; -+ ctx->vtable.vaBeginPicture = i965_BeginPicture; -+ ctx->vtable.vaRenderPicture = i965_RenderPicture; -+ ctx->vtable.vaEndPicture = i965_EndPicture; -+ ctx->vtable.vaSyncSurface = i965_SyncSurface; -+ ctx->vtable.vaQuerySurfaceStatus = i965_QuerySurfaceStatus; -+ ctx->vtable.vaPutSurface = i965_PutSurface; -+ ctx->vtable.vaQueryImageFormats = i965_QueryImageFormats; -+ ctx->vtable.vaCreateImage = i965_CreateImage; -+ ctx->vtable.vaDeriveImage = i965_DeriveImage; -+ ctx->vtable.vaDestroyImage = i965_DestroyImage; -+ ctx->vtable.vaSetImagePalette = i965_SetImagePalette; -+ ctx->vtable.vaGetImage = i965_GetImage; -+ ctx->vtable.vaPutImage = i965_PutImage; -+ ctx->vtable.vaQuerySubpictureFormats = i965_QuerySubpictureFormats; -+ ctx->vtable.vaCreateSubpicture = i965_CreateSubpicture; -+ ctx->vtable.vaDestroySubpicture = i965_DestroySubpicture; -+ ctx->vtable.vaSetSubpictureImage = i965_SetSubpictureImage; -+ ctx->vtable.vaSetSubpictureChromakey = i965_SetSubpictureChromakey; -+ ctx->vtable.vaSetSubpictureGlobalAlpha = i965_SetSubpictureGlobalAlpha; -+ ctx->vtable.vaAssociateSubpicture = i965_AssociateSubpicture; -+ ctx->vtable.vaDeassociateSubpicture = i965_DeassociateSubpicture; -+ ctx->vtable.vaQueryDisplayAttributes = i965_QueryDisplayAttributes; -+ ctx->vtable.vaGetDisplayAttributes = i965_GetDisplayAttributes; -+ ctx->vtable.vaSetDisplayAttributes = i965_SetDisplayAttributes; -+// ctx->vtable.vaDbgCopySurfaceToBuffer = i965_DbgCopySurfaceToBuffer; -+ -+ i965 = (struct i965_driver_data *)calloc(1, sizeof(*i965)); -+ assert(i965); -+ ctx->pDriverData = (void *)i965; -+ -+ result = object_heap_init(&i965->config_heap, -+ sizeof(struct object_config), -+ CONFIG_ID_OFFSET); -+ assert(result == 0); -+ -+ result = object_heap_init(&i965->context_heap, -+ sizeof(struct object_context), -+ CONTEXT_ID_OFFSET); -+ assert(result == 0); -+ -+ result = object_heap_init(&i965->surface_heap, -+ sizeof(struct object_surface), -+ SURFACE_ID_OFFSET); -+ assert(result == 0); -+ -+ result = object_heap_init(&i965->buffer_heap, -+ sizeof(struct object_buffer), -+ BUFFER_ID_OFFSET); -+ assert(result == 0); -+ -+ result = object_heap_init(&i965->image_heap, -+ sizeof(struct object_image), -+ IMAGE_ID_OFFSET); -+ assert(result == 0); -+ -+ result = object_heap_init(&i965->subpic_heap, -+ sizeof(struct object_subpic), -+ SUBPIC_ID_OFFSET); -+ assert(result == 0); -+ -+ return i965_Init(ctx); -+} diff -Naur libva-0.31.0/i965_drv_video/i965_drv_video.h libva-0.31.0.patch/i965_drv_video/i965_drv_video.h --- libva-0.31.0/i965_drv_video/i965_drv_video.h 2009-11-20 17:12:42.000000000 +0100 +++ libva-0.31.0.patch/i965_drv_video/i965_drv_video.h 2009-12-15 13:43:55.262448685 +0100 @@ -68207,79 +66603,6 @@ diff -Naur libva-0.31.0/src/Makefile.am libva-0.31.0.patch/src/Makefile.am +libva_compat_la_LIBADD = libva-x11.la -ldl +libva_compat_la_DEPENDENCIES = libva-x11.la diff -Naur libva-0.31.0/src/Makefile.am.orig libva-0.31.0.patch/src/Makefile.am.orig ---- libva-0.31.0/src/Makefile.am.orig 1970-01-01 01:00:00.000000000 +0100 -+++ libva-0.31.0.patch/src/Makefile.am.orig 2009-12-15 13:45:17.333446938 +0100 -@@ -0,0 +1,70 @@ -+# Copyright (c) 2007 Intel Corporation. All Rights Reserved. -+# -+# Permission is hereby granted, free of charge, to any person obtaining a -+# copy of this software and associated documentation files (the -+# "Software"), to deal in the Software without restriction, including -+# without limitation the rights to use, copy, modify, merge, publish, -+# distribute, sub license, and/or sell copies of the Software, and to -+# permit persons to whom the Software is furnished to do so, subject to -+# the following conditions: -+# -+# The above copyright notice and this permission notice (including the -+# next paragraph) shall be included in all copies or substantial portions -+# of the Software. -+# -+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -+# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -+ -+INCLUDES = \ -+ $(LIBVA_CFLAGS) -I$(top_srcdir)/src/x11 \ -+ -DIN_LIBVA \ -+ -DVA_DRIVERS_PATH="\"$(LIBVA_DRIVERS_PATH)\"" -+ -+LDADD = \ -+ $(LIBVA_LT_LDFLAGS) -+ -+libva_x11_backend = libva-x11.la -+libva_x11_backenddir = x11 -+if USE_GLX -+libva_glx_backend = libva-glx.la -+libva_glx_backenddir = glx -+else -+libva_glx_backend = -+libva_glx_backenddir = -+endif -+ -+lib_LTLIBRARIES = libva.la $(libva_x11_backend) $(libva_glx_backend) -+ -+libva_ladir = $(libdir) -+libva_la_LDFLAGS = $(LDADD) -no-undefined -+libva_la_LIBADD = $(LIBVA_LIBS) -ldl -+ -+libva_x11_la_SOURCES = -+libva_x11_la_LIBADD = $(libvacorelib) x11/libva_x11.la $(LIBVA_LIBS) $(X11_LIBS) $(XEXT_LIBS) $(XFIXES_LIBS) -ldl -+libva_x11_la_LDFLAGS = $(LDADD) -+libva_x11_la_DEPENDENCIES = $(libvacorelib) x11/libva_x11.la -+ -+libva_glx_la_SOURCES = -+libva_glx_la_LIBADD = $(libvacorelib) glx/libva_glx.la libva-x11.la $(GL_DEPS_LIBS) -ldl -+libva_glx_la_LDFLAGS = $(LDADD) -+libva_glx_la_DEPENDENCIES = $(libvacorelib) glx/libva_glx.la libva-x11.la -+ -+SUBDIRS = $(libva_x11_backenddir) $(libva_glx_backenddir) -+ -+DIST_SUBDIRS = x11 glx -+ -+libva_la_SOURCES = va.c -+ -+libvaincludedir = ${includedir}/va -+libvainclude_HEADERS = va.h va_backend.h va_version.h -+ -+DISTCLEANFILES = \ -+ va_version.h -+ -+EXTRA_DIST = \ -+ va_version.h.in diff -Naur libva-0.31.0/src/Makefile.in libva-0.31.0.patch/src/Makefile.in --- libva-0.31.0/src/Makefile.in 2009-09-10 17:18:49.000000000 +0200 +++ libva-0.31.0.patch/src/Makefile.in 2009-12-15 13:51:56.104446602 +0100 @@ -68970,440 +67293,6 @@ diff -Naur libva-0.31.0/src/va_backend.h libva-0.31.0.patch/src/va_backend.h typedef VAStatus (*VADriverInit) ( diff -Naur libva-0.31.0/src/va_backend.h.orig libva-0.31.0.patch/src/va_backend.h.orig ---- libva-0.31.0/src/va_backend.h.orig 1970-01-01 01:00:00.000000000 +0100 -+++ libva-0.31.0.patch/src/va_backend.h.orig 2009-12-15 13:45:17.333446938 +0100 -@@ -0,0 +1,431 @@ -+/* -+ * Copyright (c) 2007 Intel Corporation. All Rights Reserved. -+ * -+ * Permission is hereby granted, free of charge, to any person obtaining a -+ * copy of this software and associated documentation files (the -+ * "Software"), to deal in the Software without restriction, including -+ * without limitation the rights to use, copy, modify, merge, publish, -+ * distribute, sub license, and/or sell copies of the Software, and to -+ * permit persons to whom the Software is furnished to do so, subject to -+ * the following conditions: -+ * -+ * The above copyright notice and this permission notice (including the -+ * next paragraph) shall be included in all copies or substantial portions -+ * of the Software. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -+ */ -+ -+/* -+ * Video Decode Acceleration -Backend API -+ */ -+ -+#ifndef _VA_BACKEND_H_ -+#define _VA_BACKEND_H_ -+ -+#ifdef IN_LIBVA -+#include "va.h" -+#include "x11/va_x11.h" -+#include "glx/va_backend_glx.h" -+#else -+#include -+#include -+#include -+#endif -+ -+#include -+#include -+ -+ -+typedef struct VADriverContext *VADriverContextP; -+typedef struct VADisplayContext *VADisplayContextP; -+ -+struct VADriverVTable -+{ -+ VAStatus (*vaTerminate) ( VADriverContextP ctx ); -+ -+ VAStatus (*vaQueryConfigProfiles) ( -+ VADriverContextP ctx, -+ VAProfile *profile_list, /* out */ -+ int *num_profiles /* out */ -+ ); -+ -+ VAStatus (*vaQueryConfigEntrypoints) ( -+ VADriverContextP ctx, -+ VAProfile profile, -+ VAEntrypoint *entrypoint_list, /* out */ -+ int *num_entrypoints /* out */ -+ ); -+ -+ VAStatus (*vaGetConfigAttributes) ( -+ VADriverContextP ctx, -+ VAProfile profile, -+ VAEntrypoint entrypoint, -+ VAConfigAttrib *attrib_list, /* in/out */ -+ int num_attribs -+ ); -+ -+ VAStatus (*vaCreateConfig) ( -+ VADriverContextP ctx, -+ VAProfile profile, -+ VAEntrypoint entrypoint, -+ VAConfigAttrib *attrib_list, -+ int num_attribs, -+ VAConfigID *config_id /* out */ -+ ); -+ -+ VAStatus (*vaDestroyConfig) ( -+ VADriverContextP ctx, -+ VAConfigID config_id -+ ); -+ -+ VAStatus (*vaQueryConfigAttributes) ( -+ VADriverContextP ctx, -+ VAConfigID config_id, -+ VAProfile *profile, /* out */ -+ VAEntrypoint *entrypoint, /* out */ -+ VAConfigAttrib *attrib_list, /* out */ -+ int *num_attribs /* out */ -+ ); -+ -+ VAStatus (*vaCreateSurfaces) ( -+ VADriverContextP ctx, -+ int width, -+ int height, -+ int format, -+ int num_surfaces, -+ VASurfaceID *surfaces /* out */ -+ ); -+ -+ VAStatus (*vaDestroySurfaces) ( -+ VADriverContextP ctx, -+ VASurfaceID *surface_list, -+ int num_surfaces -+ ); -+ -+ VAStatus (*vaCreateContext) ( -+ VADriverContextP ctx, -+ VAConfigID config_id, -+ int picture_width, -+ int picture_height, -+ int flag, -+ VASurfaceID *render_targets, -+ int num_render_targets, -+ VAContextID *context /* out */ -+ ); -+ -+ VAStatus (*vaDestroyContext) ( -+ VADriverContextP ctx, -+ VAContextID context -+ ); -+ -+ VAStatus (*vaCreateBuffer) ( -+ VADriverContextP ctx, -+ VAContextID context, /* in */ -+ VABufferType type, /* in */ -+ unsigned int size, /* in */ -+ unsigned int num_elements, /* in */ -+ void *data, /* in */ -+ VABufferID *buf_id /* out */ -+ ); -+ -+ VAStatus (*vaBufferSetNumElements) ( -+ VADriverContextP ctx, -+ VABufferID buf_id, /* in */ -+ unsigned int num_elements /* in */ -+ ); -+ -+ VAStatus (*vaMapBuffer) ( -+ VADriverContextP ctx, -+ VABufferID buf_id, /* in */ -+ void **pbuf /* out */ -+ ); -+ -+ VAStatus (*vaUnmapBuffer) ( -+ VADriverContextP ctx, -+ VABufferID buf_id /* in */ -+ ); -+ -+ VAStatus (*vaDestroyBuffer) ( -+ VADriverContextP ctx, -+ VABufferID buffer_id -+ ); -+ -+ VAStatus (*vaBeginPicture) ( -+ VADriverContextP ctx, -+ VAContextID context, -+ VASurfaceID render_target -+ ); -+ -+ VAStatus (*vaRenderPicture) ( -+ VADriverContextP ctx, -+ VAContextID context, -+ VABufferID *buffers, -+ int num_buffers -+ ); -+ -+ VAStatus (*vaEndPicture) ( -+ VADriverContextP ctx, -+ VAContextID context -+ ); -+ -+ VAStatus (*vaSyncSurface) ( -+ VADriverContextP ctx, -+ VASurfaceID render_target -+ ); -+ -+ VAStatus (*vaQuerySurfaceStatus) ( -+ VADriverContextP ctx, -+ VASurfaceID render_target, -+ VASurfaceStatus *status /* out */ -+ ); -+ -+ VAStatus (*vaPutSurface) ( -+ VADriverContextP ctx, -+ VASurfaceID surface, -+ Drawable draw, /* X Drawable */ -+ short srcx, -+ short srcy, -+ unsigned short srcw, -+ unsigned short srch, -+ short destx, -+ short desty, -+ unsigned short destw, -+ unsigned short desth, -+ VARectangle *cliprects, /* client supplied clip list */ -+ unsigned int number_cliprects, /* number of clip rects in the clip list */ -+ unsigned int flags /* de-interlacing flags */ -+ ); -+ -+ VAStatus (*vaQueryImageFormats) ( -+ VADriverContextP ctx, -+ VAImageFormat *format_list, /* out */ -+ int *num_formats /* out */ -+ ); -+ -+ VAStatus (*vaCreateImage) ( -+ VADriverContextP ctx, -+ VAImageFormat *format, -+ int width, -+ int height, -+ VAImage *image /* out */ -+ ); -+ -+ VAStatus (*vaDeriveImage) ( -+ VADriverContextP ctx, -+ VASurfaceID surface, -+ VAImage *image /* out */ -+ ); -+ -+ VAStatus (*vaDestroyImage) ( -+ VADriverContextP ctx, -+ VAImageID image -+ ); -+ -+ VAStatus (*vaSetImagePalette) ( -+ VADriverContextP ctx, -+ VAImageID image, -+ /* -+ * pointer to an array holding the palette data. The size of the array is -+ * num_palette_entries * entry_bytes in size. The order of the components -+ * in the palette is described by the component_order in VAImage struct -+ */ -+ unsigned char *palette -+ ); -+ -+ VAStatus (*vaGetImage) ( -+ VADriverContextP ctx, -+ VASurfaceID surface, -+ int x, /* coordinates of the upper left source pixel */ -+ int y, -+ unsigned int width, /* width and height of the region */ -+ unsigned int height, -+ VAImageID image -+ ); -+ -+ VAStatus (*vaPutImage) ( -+ VADriverContextP ctx, -+ VASurfaceID surface, -+ VAImageID image, -+ int src_x, -+ int src_y, -+ unsigned int src_width, -+ unsigned int src_height, -+ int dest_x, -+ int dest_y, -+ unsigned int dest_width, -+ unsigned int dest_height -+ ); -+ -+ VAStatus (*vaQuerySubpictureFormats) ( -+ VADriverContextP ctx, -+ VAImageFormat *format_list, /* out */ -+ unsigned int *flags, /* out */ -+ unsigned int *num_formats /* out */ -+ ); -+ -+ VAStatus (*vaCreateSubpicture) ( -+ VADriverContextP ctx, -+ VAImageID image, -+ VASubpictureID *subpicture /* out */ -+ ); -+ -+ VAStatus (*vaDestroySubpicture) ( -+ VADriverContextP ctx, -+ VASubpictureID subpicture -+ ); -+ -+ VAStatus (*vaSetSubpictureImage) ( -+ VADriverContextP ctx, -+ VASubpictureID subpicture, -+ VAImageID image -+ ); -+ -+ VAStatus (*vaSetSubpictureChromakey) ( -+ VADriverContextP ctx, -+ VASubpictureID subpicture, -+ unsigned int chromakey_min, -+ unsigned int chromakey_max, -+ unsigned int chromakey_mask -+ ); -+ -+ VAStatus (*vaSetSubpictureGlobalAlpha) ( -+ VADriverContextP ctx, -+ VASubpictureID subpicture, -+ float global_alpha -+ ); -+ -+ VAStatus (*vaAssociateSubpicture) ( -+ VADriverContextP ctx, -+ VASubpictureID subpicture, -+ VASurfaceID *target_surfaces, -+ int num_surfaces, -+ short src_x, /* upper left offset in subpicture */ -+ short src_y, -+ unsigned short src_width, -+ unsigned short src_height, -+ short dest_x, /* upper left offset in surface */ -+ short dest_y, -+ unsigned short dest_width, -+ unsigned short dest_height, -+ /* -+ * whether to enable chroma-keying or global-alpha -+ * see VA_SUBPICTURE_XXX values -+ */ -+ unsigned int flags -+ ); -+ -+ VAStatus (*vaDeassociateSubpicture) ( -+ VADriverContextP ctx, -+ VASubpictureID subpicture, -+ VASurfaceID *target_surfaces, -+ int num_surfaces -+ ); -+ -+ VAStatus (*vaQueryDisplayAttributes) ( -+ VADriverContextP ctx, -+ VADisplayAttribute *attr_list, /* out */ -+ int *num_attributes /* out */ -+ ); -+ -+ VAStatus (*vaGetDisplayAttributes) ( -+ VADriverContextP ctx, -+ VADisplayAttribute *attr_list, /* in/out */ -+ int num_attributes -+ ); -+ -+ VAStatus (*vaSetDisplayAttributes) ( -+ VADriverContextP ctx, -+ VADisplayAttribute *attr_list, -+ int num_attributes -+ ); -+ -+ /* device specific */ -+ VAStatus (*vaCreateSurfaceFromCIFrame) ( -+ VADriverContextP ctx, -+ unsigned long frame_id, -+ VASurfaceID *surface /* out */ -+ ); -+ -+ -+ VAStatus (*vaCreateSurfaceFromV4L2Buf) ( -+ VADriverContextP ctx, -+ int v4l2_fd, /* file descriptor of V4L2 device */ -+ struct v4l2_format *v4l2_fmt, /* format of V4L2 */ -+ struct v4l2_buffer *v4l2_buf, /* V4L2 buffer */ -+ VASurfaceID *surface /* out */ -+ ); -+ -+ VAStatus (*vaCopySurfaceToBuffer) ( -+ VADriverContextP ctx, -+ VASurfaceID surface, -+ unsigned int *fourcc, /* out for follow argument */ -+ unsigned int *luma_stride, -+ unsigned int *chroma_u_stride, -+ unsigned int *chroma_v_stride, -+ unsigned int *luma_offset, -+ unsigned int *chroma_u_offset, -+ unsigned int *chroma_v_offset, -+ void **buffer -+ ); -+ -+ /* Optional: GLX support hooks */ -+ struct VADriverVTableGLX glx; -+}; -+ -+struct VADriverContext -+{ -+ void *pDriverData; -+ struct VADriverVTable vtable; -+ -+ Display *x11_dpy; -+ int x11_screen; -+ int version_major; -+ int version_minor; -+ int max_profiles; -+ int max_entrypoints; -+ int max_attributes; -+ int max_image_formats; -+ int max_subpic_formats; -+ int max_display_attributes; -+ const char *str_vendor; -+ -+ void *handle; /* dlopen handle */ -+ -+ void *dri_state; -+ void *glx; /* opaque for GLX code */ -+}; -+ -+struct VADisplayContext -+{ -+ VADisplayContextP pNext; -+ VADriverContextP pDriverContext; -+ -+ int (*vaIsValid) ( -+ VADisplayContextP ctx -+ ); -+ -+ void (*vaDestroy) ( -+ VADisplayContextP ctx -+ ); -+ -+ VAStatus (*vaGetDriverName) ( -+ VADisplayContextP ctx, -+ char **driver_name -+ ); -+ -+ void *opaque; /* opaque for display extensions (e.g. GLX) */ -+}; -+ -+typedef VAStatus (*VADriverInit) ( -+ VADriverContextP driver_context -+); -+ -+ -+#endif /* _VA_BACKEND_H_ */ diff -Naur libva-0.31.0/src/va.c libva-0.31.0.patch/src/va.c --- libva-0.31.0/src/va.c 2009-11-20 17:12:42.000000000 +0100 +++ libva-0.31.0.patch/src/va.c 2009-12-15 13:45:26.817448431 +0100 @@ -72860,1277 +70749,6 @@ diff -Naur libva-0.31.0/src/va_compat_template.h libva-0.31.0.patch/src/va_compa +#undef COMPAT_MAJOR +#undef COMPAT_MINOR diff -Naur libva-0.31.0/src/va.c.orig libva-0.31.0.patch/src/va.c.orig ---- libva-0.31.0/src/va.c.orig 1970-01-01 01:00:00.000000000 +0100 -+++ libva-0.31.0.patch/src/va.c.orig 2009-12-15 13:44:59.070448743 +0100 -@@ -0,0 +1,1268 @@ -+/* -+ * Copyright (c) 2007 Intel Corporation. All Rights Reserved. -+ * -+ * Permission is hereby granted, free of charge, to any person obtaining a -+ * copy of this software and associated documentation files (the -+ * "Software"), to deal in the Software without restriction, including -+ * without limitation the rights to use, copy, modify, merge, publish, -+ * distribute, sub license, and/or sell copies of the Software, and to -+ * permit persons to whom the Software is furnished to do so, subject to -+ * the following conditions: -+ * -+ * The above copyright notice and this permission notice (including the -+ * next paragraph) shall be included in all copies or substantial portions -+ * of the Software. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -+ */ -+ -+#define _GNU_SOURCE 1 -+#include "va.h" -+#include "va_backend.h" -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include -+#include "va_dri.h" -+#include "va_dri2.h" -+#include "va_dricommon.h" -+ -+ -+#define DRIVER_INIT_FUNC "__vaDriverInit_0_31" -+#define DRIVER_INIT_FUNC_SDS "__vaDriverInit_0_31_sds" -+ -+#define DRIVER_EXTENSION "_drv_video.so" -+ -+#define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext) -+#define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; } -+ -+#define ASSERT assert -+#define CHECK_VTABLE(s, ctx, func) if (!va_checkVtable(ctx->vtable.va##func, #func)) s = VA_STATUS_ERROR_UNKNOWN; -+#define CHECK_MAXIMUM(s, ctx, var) if (!va_checkMaximum(ctx->max_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN; -+#define CHECK_STRING(s, ctx, var) if (!va_checkString(ctx->str_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN; -+ -+#define TRACE(func) if (va_debug_trace) va_infoMessage("[TR] %s\n", #func); -+ -+static int va_debug_trace = 0; -+ -+static int vaDisplayIsValid(VADisplay dpy) -+{ -+ VADisplayContextP pDisplayContext = (VADisplayContextP)dpy; -+ return pDisplayContext && pDisplayContext->vaIsValid(pDisplayContext); -+} -+ -+static void va_errorMessage(const char *msg, ...) -+{ -+ va_list args; -+ -+ fprintf(stderr, "libva error: "); -+ va_start(args, msg); -+ vfprintf(stderr, msg, args); -+ va_end(args); -+} -+ -+static void va_infoMessage(const char *msg, ...) -+{ -+ va_list args; -+ -+ fprintf(stderr, "libva: "); -+ va_start(args, msg); -+ vfprintf(stderr, msg, args); -+ va_end(args); -+} -+ -+static Bool va_checkVtable(void *ptr, char *function) -+{ -+ if (!ptr) -+ { -+ va_errorMessage("No valid vtable entry for va%s\n", function); -+ return False; -+ } -+ return True; -+} -+ -+static Bool va_checkMaximum(int value, char *variable) -+{ -+ if (!value) -+ { -+ va_errorMessage("Failed to define max_%s in init\n", variable); -+ return False; -+ } -+ return True; -+} -+ -+static Bool va_checkString(const char* value, char *variable) -+{ -+ if (!value) -+ { -+ va_errorMessage("Failed to define str_%s in init\n", variable); -+ return False; -+ } -+ return True; -+} -+ -+static VAStatus va_getDriverName(VADisplay dpy, char **driver_name) -+{ -+ VADisplayContextP pDisplayContext = (VADisplayContextP)dpy; -+ -+ return pDisplayContext->vaGetDriverName(pDisplayContext, driver_name); -+} -+ -+static VAStatus va_openDriver(VADisplay dpy, char *driver_name) -+{ -+ VADriverContextP ctx = CTX(dpy); -+ VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN; -+ char *search_path = NULL; -+ char *saveptr; -+ char *driver_dir; -+ -+ if (geteuid() == getuid()) -+ { -+ /* don't allow setuid apps to use LIBVA_DRIVERS_PATH */ -+ search_path = getenv("LIBVA_DRIVERS_PATH"); -+ } -+ if (!search_path) -+ { -+ search_path = VA_DRIVERS_PATH; -+ } -+ -+ search_path = strdup((const char *)search_path); -+ driver_dir = strtok_r((const char *)search_path, ":", &saveptr); -+ while(driver_dir) -+ { -+ void *handle = NULL; -+ char *driver_path = (char *) malloc( strlen(driver_dir) + -+ strlen(driver_name) + -+ strlen(DRIVER_EXTENSION) + 2 ); -+ strncpy( driver_path, driver_dir, strlen(driver_dir) + 1); -+ strncat( driver_path, "/", strlen("/") ); -+ strncat( driver_path, driver_name, strlen(driver_name) ); -+ strncat( driver_path, DRIVER_EXTENSION, strlen(DRIVER_EXTENSION) ); -+ -+ va_infoMessage("Trying to open %s\n", driver_path); -+ -+ handle = dlopen( driver_path, RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE ); -+ if (!handle) -+ { -+ /* Don't give errors for non-existing files */ -+ if (0 == access( driver_path, F_OK)) -+ { -+ va_errorMessage("dlopen of %s failed: %s\n", driver_path, dlerror()); -+ } -+ } -+ else -+ { -+ VADriverInit init_func; -+ init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC); -+ if (!init_func) -+ { -+ /* Then try SDS extensions (VDPAU and XvBA backends) */ -+ init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC_SDS); -+ } -+ if (!init_func) -+ { -+ va_errorMessage("%s has no function %s\n", driver_path, DRIVER_INIT_FUNC); -+ dlclose(handle); -+ } -+ else -+ { -+ vaStatus = (*init_func)(ctx); -+ -+ if (VA_STATUS_SUCCESS == vaStatus) -+ { -+ CHECK_MAXIMUM(vaStatus, ctx, profiles); -+ CHECK_MAXIMUM(vaStatus, ctx, entrypoints); -+ CHECK_MAXIMUM(vaStatus, ctx, attributes); -+ CHECK_MAXIMUM(vaStatus, ctx, image_formats); -+ CHECK_MAXIMUM(vaStatus, ctx, subpic_formats); -+ CHECK_MAXIMUM(vaStatus, ctx, display_attributes); -+ CHECK_STRING(vaStatus, ctx, vendor); -+ CHECK_VTABLE(vaStatus, ctx, Terminate); -+ CHECK_VTABLE(vaStatus, ctx, QueryConfigProfiles); -+ CHECK_VTABLE(vaStatus, ctx, QueryConfigEntrypoints); -+ CHECK_VTABLE(vaStatus, ctx, QueryConfigAttributes); -+ CHECK_VTABLE(vaStatus, ctx, CreateConfig); -+ CHECK_VTABLE(vaStatus, ctx, DestroyConfig); -+ CHECK_VTABLE(vaStatus, ctx, GetConfigAttributes); -+ CHECK_VTABLE(vaStatus, ctx, CreateSurfaces); -+ CHECK_VTABLE(vaStatus, ctx, DestroySurfaces); -+ CHECK_VTABLE(vaStatus, ctx, CreateContext); -+ CHECK_VTABLE(vaStatus, ctx, DestroyContext); -+ CHECK_VTABLE(vaStatus, ctx, CreateBuffer); -+ CHECK_VTABLE(vaStatus, ctx, BufferSetNumElements); -+ CHECK_VTABLE(vaStatus, ctx, MapBuffer); -+ CHECK_VTABLE(vaStatus, ctx, UnmapBuffer); -+ CHECK_VTABLE(vaStatus, ctx, DestroyBuffer); -+ CHECK_VTABLE(vaStatus, ctx, BeginPicture); -+ CHECK_VTABLE(vaStatus, ctx, RenderPicture); -+ CHECK_VTABLE(vaStatus, ctx, EndPicture); -+ CHECK_VTABLE(vaStatus, ctx, SyncSurface); -+ CHECK_VTABLE(vaStatus, ctx, QuerySurfaceStatus); -+ CHECK_VTABLE(vaStatus, ctx, PutSurface); -+ CHECK_VTABLE(vaStatus, ctx, QueryImageFormats); -+ CHECK_VTABLE(vaStatus, ctx, CreateImage); -+ CHECK_VTABLE(vaStatus, ctx, DeriveImage); -+ CHECK_VTABLE(vaStatus, ctx, DestroyImage); -+ CHECK_VTABLE(vaStatus, ctx, SetImagePalette); -+ CHECK_VTABLE(vaStatus, ctx, GetImage); -+ CHECK_VTABLE(vaStatus, ctx, PutImage); -+ CHECK_VTABLE(vaStatus, ctx, QuerySubpictureFormats); -+ CHECK_VTABLE(vaStatus, ctx, CreateSubpicture); -+ CHECK_VTABLE(vaStatus, ctx, DestroySubpicture); -+ CHECK_VTABLE(vaStatus, ctx, SetSubpictureImage); -+ CHECK_VTABLE(vaStatus, ctx, SetSubpictureChromakey); -+ CHECK_VTABLE(vaStatus, ctx, SetSubpictureGlobalAlpha); -+ CHECK_VTABLE(vaStatus, ctx, AssociateSubpicture); -+ CHECK_VTABLE(vaStatus, ctx, DeassociateSubpicture); -+ CHECK_VTABLE(vaStatus, ctx, QueryDisplayAttributes); -+ CHECK_VTABLE(vaStatus, ctx, GetDisplayAttributes); -+ CHECK_VTABLE(vaStatus, ctx, SetDisplayAttributes); -+ } -+ if (VA_STATUS_SUCCESS != vaStatus) -+ { -+ va_errorMessage("%s init failed\n", driver_path); -+ dlclose(handle); -+ } -+ if (VA_STATUS_SUCCESS == vaStatus) -+ { -+ ctx->handle = handle; -+ } -+ free(driver_path); -+ break; -+ } -+ } -+ free(driver_path); -+ -+ driver_dir = strtok_r(NULL, ":", &saveptr); -+ } -+ -+ free(search_path); -+ -+ return vaStatus; -+} -+ -+VAPrivFunc vaGetLibFunc(VADisplay dpy, const char *func) -+{ -+ VADriverContextP ctx; -+ if( !vaDisplayIsValid(dpy) ) -+ return NULL; -+ ctx = CTX(dpy); -+ -+ if (NULL == ctx->handle) -+ return NULL; -+ -+ return (VAPrivFunc) dlsym(ctx->handle, func); -+} -+ -+ -+/* -+ * Returns a short english description of error_status -+ */ -+const char *vaErrorStr(VAStatus error_status) -+{ -+ switch(error_status) -+ { -+ case VA_STATUS_SUCCESS: -+ return "success (no error)"; -+ case VA_STATUS_ERROR_OPERATION_FAILED: -+ return "operation failed"; -+ case VA_STATUS_ERROR_ALLOCATION_FAILED: -+ return "resource allocation failed"; -+ case VA_STATUS_ERROR_INVALID_DISPLAY: -+ return "invalid VADisplay"; -+ case VA_STATUS_ERROR_INVALID_CONFIG: -+ return "invalid VAConfigID"; -+ case VA_STATUS_ERROR_INVALID_CONTEXT: -+ return "invalid VAContextID"; -+ case VA_STATUS_ERROR_INVALID_SURFACE: -+ return "invalid VASurfaceID"; -+ case VA_STATUS_ERROR_INVALID_BUFFER: -+ return "invalid VABufferID"; -+ case VA_STATUS_ERROR_INVALID_IMAGE: -+ return "invalid VAImageID"; -+ case VA_STATUS_ERROR_INVALID_SUBPICTURE: -+ return "invalid VASubpictureID"; -+ case VA_STATUS_ERROR_ATTR_NOT_SUPPORTED: -+ return "attribute not supported"; -+ case VA_STATUS_ERROR_MAX_NUM_EXCEEDED: -+ return "list argument exceeds maximum number"; -+ case VA_STATUS_ERROR_UNSUPPORTED_PROFILE: -+ return "the requested VAProfile is not supported"; -+ case VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT: -+ return "the requested VAEntryPoint is not supported"; -+ case VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT: -+ return "the requested RT Format is not supported"; -+ case VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE: -+ return "the requested VABufferType is not supported"; -+ case VA_STATUS_ERROR_SURFACE_BUSY: -+ return "surface is in use"; -+ case VA_STATUS_ERROR_FLAG_NOT_SUPPORTED: -+ return "flag not supported"; -+ case VA_STATUS_ERROR_INVALID_PARAMETER: -+ return "invalid parameter"; -+ case VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED: -+ return "resolution not supported"; -+ case VA_STATUS_ERROR_UNIMPLEMENTED: -+ return "the requested function is not implemented"; -+ case VA_STATUS_ERROR_SURFACE_IN_DISPLAYING: -+ return "surface is in displaying (may by overlay)" ; -+ case VA_STATUS_ERROR_UNKNOWN: -+ return "unknown libva error"; -+ } -+ return "unknown libva error / description missing"; -+} -+ -+VAStatus vaInitialize ( -+ VADisplay dpy, -+ int *major_version, /* out */ -+ int *minor_version /* out */ -+) -+{ -+ char *driver_name = NULL; -+ VAStatus vaStatus; -+ -+ CHECK_DISPLAY(dpy); -+ -+ va_debug_trace = (getenv("LIBVA_DEBUG_TRACE") != NULL); -+ -+ va_infoMessage("libva version %s\n", VA_VERSION_S); -+ -+ vaStatus = va_getDriverName(dpy, &driver_name); -+ va_infoMessage("va_getDriverName() returns %d\n", vaStatus); -+ -+ if (VA_STATUS_SUCCESS == vaStatus) -+ { -+ vaStatus = va_openDriver(dpy, driver_name); -+ va_infoMessage("va_openDriver() returns %d\n", vaStatus); -+ -+ *major_version = VA_MAJOR_VERSION; -+ *minor_version = VA_MINOR_VERSION; -+ } -+ -+ if (driver_name) -+ free(driver_name); -+ return vaStatus; -+} -+ -+ -+/* -+ * After this call, all library internal resources will be cleaned up -+ */ -+VAStatus vaTerminate ( -+ VADisplay dpy -+) -+{ -+ VAStatus vaStatus = VA_STATUS_SUCCESS; -+ VADisplayContextP pDisplayContext = (VADisplayContextP)dpy; -+ VADriverContextP old_ctx; -+ -+ CHECK_DISPLAY(dpy); -+ old_ctx = CTX(dpy); -+ -+ if (old_ctx->handle) -+ { -+ vaStatus = old_ctx->vtable.vaTerminate(old_ctx); -+ dlclose(old_ctx->handle); -+ old_ctx->handle = NULL; -+ } -+ -+ if (VA_STATUS_SUCCESS == vaStatus) -+ pDisplayContext->vaDestroy(pDisplayContext); -+ return vaStatus; -+} -+ -+/* -+ * vaQueryVendorString returns a pointer to a zero-terminated string -+ * describing some aspects of the VA implemenation on a specific -+ * hardware accelerator. The format of the returned string is: -+ * --- -+ * e.g. for the Intel GMA500 implementation, an example would be: -+ * "IntelGMA500-1.0-0.2-patch3 -+ */ -+const char *vaQueryVendorString ( -+ VADisplay dpy -+) -+{ -+ if( !vaDisplayIsValid(dpy) ) -+ return NULL; -+ -+ return CTX(dpy)->str_vendor; -+} -+ -+ -+/* Get maximum number of profiles supported by the implementation */ -+int vaMaxNumProfiles ( -+ VADisplay dpy -+) -+{ -+ if( !vaDisplayIsValid(dpy) ) -+ return 0; -+ -+ return CTX(dpy)->max_profiles; -+} -+ -+/* Get maximum number of entrypoints supported by the implementation */ -+int vaMaxNumEntrypoints ( -+ VADisplay dpy -+) -+{ -+ if( !vaDisplayIsValid(dpy) ) -+ return 0; -+ -+ return CTX(dpy)->max_entrypoints; -+} -+ -+ -+/* Get maximum number of attributs supported by the implementation */ -+int vaMaxNumConfigAttributes ( -+ VADisplay dpy -+) -+{ -+ if( !vaDisplayIsValid(dpy) ) -+ return 0; -+ -+ return CTX(dpy)->max_attributes; -+} -+ -+VAStatus vaQueryConfigEntrypoints ( -+ VADisplay dpy, -+ VAProfile profile, -+ VAEntrypoint *entrypoints, /* out */ -+ int *num_entrypoints /* out */ -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaQueryConfigEntrypoints); -+ return ctx->vtable.vaQueryConfigEntrypoints ( ctx, profile, entrypoints, num_entrypoints); -+} -+ -+VAStatus vaGetConfigAttributes ( -+ VADisplay dpy, -+ VAProfile profile, -+ VAEntrypoint entrypoint, -+ VAConfigAttrib *attrib_list, /* in/out */ -+ int num_attribs -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaGetConfigAttributes); -+ return ctx->vtable.vaGetConfigAttributes ( ctx, profile, entrypoint, attrib_list, num_attribs ); -+} -+ -+VAStatus vaQueryConfigProfiles ( -+ VADisplay dpy, -+ VAProfile *profile_list, /* out */ -+ int *num_profiles /* out */ -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaQueryConfigProfiles); -+ return ctx->vtable.vaQueryConfigProfiles ( ctx, profile_list, num_profiles ); -+} -+ -+VAStatus vaCreateConfig ( -+ VADisplay dpy, -+ VAProfile profile, -+ VAEntrypoint entrypoint, -+ VAConfigAttrib *attrib_list, -+ int num_attribs, -+ VAConfigID *config_id /* out */ -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaCreateConfig); -+ return ctx->vtable.vaCreateConfig ( ctx, profile, entrypoint, attrib_list, num_attribs, config_id ); -+} -+ -+VAStatus vaDestroyConfig ( -+ VADisplay dpy, -+ VAConfigID config_id -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaDestroyConfig); -+ return ctx->vtable.vaDestroyConfig ( ctx, config_id ); -+} -+ -+VAStatus vaQueryConfigAttributes ( -+ VADisplay dpy, -+ VAConfigID config_id, -+ VAProfile *profile, /* out */ -+ VAEntrypoint *entrypoint, /* out */ -+ VAConfigAttrib *attrib_list,/* out */ -+ int *num_attribs /* out */ -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaQueryConfigAttributes); -+ return ctx->vtable.vaQueryConfigAttributes( ctx, config_id, profile, entrypoint, attrib_list, num_attribs); -+} -+ -+VAStatus vaCreateSurfaces ( -+ VADisplay dpy, -+ int width, -+ int height, -+ int format, -+ int num_surfaces, -+ VASurfaceID *surfaces /* out */ -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaCreateSurfaces); -+ return ctx->vtable.vaCreateSurfaces( ctx, width, height, format, num_surfaces, surfaces ); -+} -+ -+ -+VAStatus vaDestroySurfaces ( -+ VADisplay dpy, -+ VASurfaceID *surface_list, -+ int num_surfaces -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaDestroySurfaces); -+ return ctx->vtable.vaDestroySurfaces( ctx, surface_list, num_surfaces ); -+} -+ -+VAStatus vaCreateContext ( -+ VADisplay dpy, -+ VAConfigID config_id, -+ int picture_width, -+ int picture_height, -+ int flag, -+ VASurfaceID *render_targets, -+ int num_render_targets, -+ VAContextID *context /* out */ -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaCreateContext); -+ return ctx->vtable.vaCreateContext( ctx, config_id, picture_width, picture_height, -+ flag, render_targets, num_render_targets, context ); -+} -+ -+VAStatus vaDestroyContext ( -+ VADisplay dpy, -+ VAContextID context -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaDestroyContext); -+ return ctx->vtable.vaDestroyContext( ctx, context ); -+} -+ -+VAStatus vaCreateBuffer ( -+ VADisplay dpy, -+ VAContextID context, /* in */ -+ VABufferType type, /* in */ -+ unsigned int size, /* in */ -+ unsigned int num_elements, /* in */ -+ void *data, /* in */ -+ VABufferID *buf_id /* out */ -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaCreateBuffer); -+ return ctx->vtable.vaCreateBuffer( ctx, context, type, size, num_elements, data, buf_id); -+} -+ -+VAStatus vaBufferSetNumElements ( -+ VADisplay dpy, -+ VABufferID buf_id, /* in */ -+ unsigned int num_elements /* in */ -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaBufferSetNumElements); -+ return ctx->vtable.vaBufferSetNumElements( ctx, buf_id, num_elements ); -+} -+ -+ -+VAStatus vaMapBuffer ( -+ VADisplay dpy, -+ VABufferID buf_id, /* in */ -+ void **pbuf /* out */ -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaMapBuffer); -+ return ctx->vtable.vaMapBuffer( ctx, buf_id, pbuf ); -+} -+ -+VAStatus vaUnmapBuffer ( -+ VADisplay dpy, -+ VABufferID buf_id /* in */ -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaUnmapBuffer); -+ return ctx->vtable.vaUnmapBuffer( ctx, buf_id ); -+} -+ -+VAStatus vaDestroyBuffer ( -+ VADisplay dpy, -+ VABufferID buffer_id -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaDestroyBuffer); -+ return ctx->vtable.vaDestroyBuffer( ctx, buffer_id ); -+} -+ -+VAStatus vaBeginPicture ( -+ VADisplay dpy, -+ VAContextID context, -+ VASurfaceID render_target -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaBeginPicture); -+ return ctx->vtable.vaBeginPicture( ctx, context, render_target ); -+} -+ -+VAStatus vaRenderPicture ( -+ VADisplay dpy, -+ VAContextID context, -+ VABufferID *buffers, -+ int num_buffers -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaRenderPicture); -+ return ctx->vtable.vaRenderPicture( ctx, context, buffers, num_buffers ); -+} -+ -+VAStatus vaEndPicture ( -+ VADisplay dpy, -+ VAContextID context -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaEndPicture); -+ return ctx->vtable.vaEndPicture( ctx, context ); -+} -+ -+VAStatus vaSyncSurface ( -+ VADisplay dpy, -+ VASurfaceID render_target -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaSyncSurface); -+ return ctx->vtable.vaSyncSurface( ctx, render_target ); -+} -+ -+VAStatus vaQuerySurfaceStatus ( -+ VADisplay dpy, -+ VASurfaceID render_target, -+ VASurfaceStatus *status /* out */ -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaQuerySurfaceStatus); -+ return ctx->vtable.vaQuerySurfaceStatus( ctx, render_target, status ); -+} -+ -+VAStatus vaPutSurface ( -+ VADisplay dpy, -+ VASurfaceID surface, -+ Drawable draw, /* X Drawable */ -+ short srcx, -+ short srcy, -+ unsigned short srcw, -+ unsigned short srch, -+ short destx, -+ short desty, -+ unsigned short destw, -+ unsigned short desth, -+ VARectangle *cliprects, /* client supplied clip list */ -+ unsigned int number_cliprects, /* number of clip rects in the clip list */ -+ unsigned int flags /* de-interlacing flags */ -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaPutSurface); -+ return ctx->vtable.vaPutSurface( ctx, surface, draw, srcx, srcy, srcw, srch, -+ destx, desty, destw, desth, -+ cliprects, number_cliprects, flags ); -+} -+ -+/* Get maximum number of image formats supported by the implementation */ -+int vaMaxNumImageFormats ( -+ VADisplay dpy -+) -+{ -+ if( !vaDisplayIsValid(dpy) ) -+ return 0; -+ -+ return CTX(dpy)->max_image_formats; -+} -+ -+VAStatus vaQueryImageFormats ( -+ VADisplay dpy, -+ VAImageFormat *format_list, /* out */ -+ int *num_formats /* out */ -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaQueryImageFormats); -+ return ctx->vtable.vaQueryImageFormats ( ctx, format_list, num_formats); -+} -+ -+/* -+ * The width and height fields returned in the VAImage structure may get -+ * enlarged for some YUV formats. The size of the data buffer that needs -+ * to be allocated will be given in the "data_size" field in VAImage. -+ * Image data is not allocated by this function. The client should -+ * allocate the memory and fill in the VAImage structure's data field -+ * after looking at "data_size" returned from the library. -+ */ -+VAStatus vaCreateImage ( -+ VADisplay dpy, -+ VAImageFormat *format, -+ int width, -+ int height, -+ VAImage *image /* out */ -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaCreateImage); -+ return ctx->vtable.vaCreateImage ( ctx, format, width, height, image); -+} -+ -+/* -+ * Should call DestroyImage before destroying the surface it is bound to -+ */ -+VAStatus vaDestroyImage ( -+ VADisplay dpy, -+ VAImageID image -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaDestroyImage); -+ return ctx->vtable.vaDestroyImage ( ctx, image); -+} -+ -+VAStatus vaSetImagePalette ( -+ VADisplay dpy, -+ VAImageID image, -+ unsigned char *palette -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaSetImagePalette); -+ return ctx->vtable.vaSetImagePalette ( ctx, image, palette); -+} -+ -+/* -+ * Retrieve surface data into a VAImage -+ * Image must be in a format supported by the implementation -+ */ -+VAStatus vaGetImage ( -+ VADisplay dpy, -+ VASurfaceID surface, -+ int x, /* coordinates of the upper left source pixel */ -+ int y, -+ unsigned int width, /* width and height of the region */ -+ unsigned int height, -+ VAImageID image -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaGetImage); -+ return ctx->vtable.vaGetImage ( ctx, surface, x, y, width, height, image); -+} -+ -+/* -+ * Copy data from a VAImage to a surface -+ * Image must be in a format supported by the implementation -+ */ -+VAStatus vaPutImage ( -+ VADisplay dpy, -+ VASurfaceID surface, -+ VAImageID image, -+ int src_x, -+ int src_y, -+ unsigned int src_width, -+ unsigned int src_height, -+ int dest_x, -+ int dest_y, -+ unsigned int dest_width, -+ unsigned int dest_height -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaPutImage); -+ return ctx->vtable.vaPutImage ( ctx, surface, image, src_x, src_y, src_width, src_height, dest_x, dest_y, dest_width, dest_height ); -+} -+ -+/* -+ * Derive an VAImage from an existing surface. -+ * This interface will derive a VAImage and corresponding image buffer from -+ * an existing VA Surface. The image buffer can then be mapped/unmapped for -+ * direct CPU access. This operation is only possible on implementations with -+ * direct rendering capabilities and internal surface formats that can be -+ * represented with a VAImage. When the operation is not possible this interface -+ * will return VA_STATUS_ERROR_OPERATION_FAILED. Clients should then fall back -+ * to using vaCreateImage + vaPutImage to accomplish the same task in an -+ * indirect manner. -+ * -+ * Implementations should only return success when the resulting image buffer -+ * would be useable with vaMap/Unmap. -+ * -+ * When directly accessing a surface special care must be taken to insure -+ * proper synchronization with the graphics hardware. Clients should call -+ * vaQuerySurfaceStatus to insure that a surface is not the target of concurrent -+ * rendering or currently being displayed by an overlay. -+ * -+ * Additionally nothing about the contents of a surface should be assumed -+ * following a vaPutSurface. Implementations are free to modify the surface for -+ * scaling or subpicture blending within a call to vaPutImage. -+ * -+ * Calls to vaPutImage or vaGetImage using the same surface from which the image -+ * has been derived will return VA_STATUS_ERROR_SURFACE_BUSY. vaPutImage or -+ * vaGetImage with other surfaces is supported. -+ * -+ * An image created with vaDeriveImage should be freed with vaDestroyImage. The -+ * image and image buffer structures will be destroyed; however, the underlying -+ * surface will remain unchanged until freed with vaDestroySurfaces. -+ */ -+VAStatus vaDeriveImage ( -+ VADisplay dpy, -+ VASurfaceID surface, -+ VAImage *image /* out */ -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaDeriveImage); -+ return ctx->vtable.vaDeriveImage ( ctx, surface, image ); -+} -+ -+ -+/* Get maximum number of subpicture formats supported by the implementation */ -+int vaMaxNumSubpictureFormats ( -+ VADisplay dpy -+) -+{ -+ if( !vaDisplayIsValid(dpy) ) -+ return 0; -+ -+ return CTX(dpy)->max_subpic_formats; -+} -+ -+/* -+ * Query supported subpicture formats -+ * The caller must provide a "format_list" array that can hold at -+ * least vaMaxNumSubpictureFormats() entries. The flags arrary holds the flag -+ * for each format to indicate additional capabilities for that format. The actual -+ * number of formats returned in "format_list" is returned in "num_formats". -+ */ -+VAStatus vaQuerySubpictureFormats ( -+ VADisplay dpy, -+ VAImageFormat *format_list, /* out */ -+ unsigned int *flags, /* out */ -+ unsigned int *num_formats /* out */ -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaQuerySubpictureFormats); -+ return ctx->vtable.vaQuerySubpictureFormats ( ctx, format_list, flags, num_formats); -+} -+ -+/* -+ * Subpictures are created with an image associated. -+ */ -+VAStatus vaCreateSubpicture ( -+ VADisplay dpy, -+ VAImageID image, -+ VASubpictureID *subpicture /* out */ -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaCreateSubpicture); -+ return ctx->vtable.vaCreateSubpicture ( ctx, image, subpicture ); -+} -+ -+/* -+ * Destroy the subpicture before destroying the image it is assocated to -+ */ -+VAStatus vaDestroySubpicture ( -+ VADisplay dpy, -+ VASubpictureID subpicture -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaDestroySubpicture); -+ return ctx->vtable.vaDestroySubpicture ( ctx, subpicture); -+} -+ -+VAStatus vaSetSubpictureImage ( -+ VADisplay dpy, -+ VASubpictureID subpicture, -+ VAImageID image -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaSetSubpictureImage); -+ return ctx->vtable.vaSetSubpictureImage ( ctx, subpicture, image); -+} -+ -+ -+/* -+ * If chromakey is enabled, then the area where the source value falls within -+ * the chromakey [min, max] range is transparent -+ */ -+VAStatus vaSetSubpictureChromakey ( -+ VADisplay dpy, -+ VASubpictureID subpicture, -+ unsigned int chromakey_min, -+ unsigned int chromakey_max, -+ unsigned int chromakey_mask -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaSetSubpictureChromakey); -+ return ctx->vtable.vaSetSubpictureChromakey ( ctx, subpicture, chromakey_min, chromakey_max, chromakey_mask ); -+} -+ -+ -+/* -+ * Global alpha value is between 0 and 1. A value of 1 means fully opaque and -+ * a value of 0 means fully transparent. If per-pixel alpha is also specified then -+ * the overall alpha is per-pixel alpha multiplied by the global alpha -+ */ -+VAStatus vaSetSubpictureGlobalAlpha ( -+ VADisplay dpy, -+ VASubpictureID subpicture, -+ float global_alpha -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaSetSubpictureGlobalAlpha); -+ return ctx->vtable.vaSetSubpictureGlobalAlpha ( ctx, subpicture, global_alpha ); -+} -+ -+/* -+ vaAssociateSubpicture associates the subpicture with the target_surface. -+ It defines the region mapping between the subpicture and the target -+ surface through source and destination rectangles (with the same width and height). -+ Both will be displayed at the next call to vaPutSurface. Additional -+ associations before the call to vaPutSurface simply overrides the association. -+*/ -+VAStatus vaAssociateSubpicture ( -+ VADisplay dpy, -+ VASubpictureID subpicture, -+ VASurfaceID *target_surfaces, -+ int num_surfaces, -+ short src_x, /* upper left offset in subpicture */ -+ short src_y, -+ unsigned short src_width, -+ unsigned short src_height, -+ short dest_x, /* upper left offset in surface */ -+ short dest_y, -+ unsigned short dest_width, -+ unsigned short dest_height, -+ /* -+ * whether to enable chroma-keying or global-alpha -+ * see VA_SUBPICTURE_XXX values -+ */ -+ unsigned int flags -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaAssociateSubpicture); -+ return ctx->vtable.vaAssociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces, src_x, src_y, src_width, src_height, dest_x, dest_y, dest_width, dest_height, flags ); -+} -+ -+/* -+ * vaDeassociateSubpicture removes the association of the subpicture with target_surfaces. -+ */ -+VAStatus vaDeassociateSubpicture ( -+ VADisplay dpy, -+ VASubpictureID subpicture, -+ VASurfaceID *target_surfaces, -+ int num_surfaces -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaDeassociateSubpicture); -+ return ctx->vtable.vaDeassociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces ); -+} -+ -+ -+/* Get maximum number of display attributes supported by the implementation */ -+int vaMaxNumDisplayAttributes ( -+ VADisplay dpy -+) -+{ -+ if( !vaDisplayIsValid(dpy) ) -+ return 0; -+ -+ return CTX(dpy)->max_display_attributes; -+} -+ -+/* -+ * Query display attributes -+ * The caller must provide a "attr_list" array that can hold at -+ * least vaMaxNumDisplayAttributes() entries. The actual number of attributes -+ * returned in "attr_list" is returned in "num_attributes". -+ */ -+VAStatus vaQueryDisplayAttributes ( -+ VADisplay dpy, -+ VADisplayAttribute *attr_list, /* out */ -+ int *num_attributes /* out */ -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaQueryDisplayAttributes); -+ return ctx->vtable.vaQueryDisplayAttributes ( ctx, attr_list, num_attributes ); -+} -+ -+/* -+ * Get display attributes -+ * This function returns the current attribute values in "attr_list". -+ * Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field -+ * from vaQueryDisplayAttributes() can have their values retrieved. -+ */ -+VAStatus vaGetDisplayAttributes ( -+ VADisplay dpy, -+ VADisplayAttribute *attr_list, /* in/out */ -+ int num_attributes -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaGetDisplayAttributes); -+ return ctx->vtable.vaGetDisplayAttributes ( ctx, attr_list, num_attributes ); -+} -+ -+/* -+ * Set display attributes -+ * Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field -+ * from vaQueryDisplayAttributes() can be set. If the attribute is not settable or -+ * the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED -+ */ -+VAStatus vaSetDisplayAttributes ( -+ VADisplay dpy, -+ VADisplayAttribute *attr_list, -+ int num_attributes -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaSetDisplayAttributes); -+ return ctx->vtable.vaSetDisplayAttributes ( ctx, attr_list, num_attributes ); -+} -+ -+/* Wrap a CI (camera imaging) frame as a VA surface to share captured video between camear -+ * and VA encode. With frame_id, VA driver need to call CI interfaces to get the information -+ * of the frame, and to determine if the frame can be wrapped as a VA surface -+ * -+ * Application should make sure the frame is idle before the frame is passed into VA stack -+ * and also a vaSyncSurface should be called before application tries to access the frame -+ * from CI stack -+ */ -+VAStatus vaCreateSurfaceFromCIFrame ( -+ VADisplay dpy, -+ unsigned long frame_id, -+ VASurfaceID *surface /* out */ -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaCreateSurfacesFromCIFrame); -+ -+ if (ctx->vtable.vaCreateSurfaceFromCIFrame) -+ return ctx->vtable.vaCreateSurfaceFromCIFrame( ctx, frame_id, surface ); -+ else -+ return VA_STATUS_ERROR_UNKNOWN; -+} -+ -+ -+/* Wrap a V4L2 buffer as a VA surface, so that V4L2 camera, VA encode -+ * can share the data without copy -+ * The VA driver should query the camera device from v4l2_fd to see -+ * if camera device memory/buffer can be wrapped into a VA surface -+ * Buffer information is passed in by v4l2_fmt and v4l2_buf structure, -+ * VA driver also needs do further check if the buffer can meet encode -+ * hardware requirement, such as dimension, fourcc, stride, etc -+ * -+ * Application should make sure the buffer is idle before the frame into VA stack -+ * and also a vaSyncSurface should be called before application tries to access the frame -+ * from V4L2 stack -+ */ -+VAStatus vaCreateSurfaceFromV4L2Buf( -+ VADisplay dpy, -+ int v4l2_fd, /* file descriptor of V4L2 device */ -+ struct v4l2_format *v4l2_fmt, /* format of V4L2 */ -+ struct v4l2_buffer *v4l2_buf, /* V4L2 buffer */ -+ VASurfaceID *surface /* out */ -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vtable.vaCreateSurfaceFromV4L2Buf); -+ -+ if (ctx->vtable.vaCreateSurfaceFromV4L2Buf) -+ return ctx->vtable.vaCreateSurfaceFromV4L2Buf( ctx, v4l2_fd, v4l2_fmt, v4l2_buf, surface ); -+ else -+ return VA_STATUS_ERROR_UNKNOWN; -+} -+ -+/* It is a debug interface, and isn't exported in core VAAPI -+ * It is used to dump surface data into system memory -+ * Application should explicitly call free to release the buffer memory -+ */ -+ -+VAStatus vaCopySurfaceToBuffer(VADisplay dpy, -+ VASurfaceID surface, -+ unsigned int *fourcc, /* following are output argument */ -+ unsigned int *luma_stride, -+ unsigned int *chroma_u_stride, -+ unsigned int *chroma_v_stride, -+ unsigned int *luma_offset, -+ unsigned int *chroma_u_offset, -+ unsigned int *chroma_v_offset, -+ void **buffer -+) -+{ -+ VADriverContextP ctx; -+ CHECK_DISPLAY(dpy); -+ ctx = CTX(dpy); -+ -+ TRACE(vaCopySurfaceToBuffer); -+ if (ctx->vtable.vaCopySurfaceToBuffer) -+ return ctx->vtable.vaCopySurfaceToBuffer( ctx, surface, fourcc, luma_stride, chroma_u_stride, chroma_v_stride, luma_offset, chroma_u_offset, chroma_v_offset, buffer); -+ else -+ return VA_STATUS_ERROR_UNKNOWN; -+} diff -Naur libva-0.31.0/src/va.h libva-0.31.0.patch/src/va.h --- libva-0.31.0/src/va.h 2009-11-20 17:12:42.000000000 +0100 +++ libva-0.31.0.patch/src/va.h 2009-12-15 13:45:13.207447712 +0100 @@ -76074,166 +72692,6 @@ diff -Naur libva-0.31.0/src/x11/dri1_util.c libva-0.31.0.patch/src/x11/dri1_util VA_DRICloseConnection(ctx->x11_dpy, ctx->x11_screen); diff -Naur libva-0.31.0/src/x11/dri1_util.c.orig libva-0.31.0.patch/src/x11/dri1_util.c.orig ---- libva-0.31.0/src/x11/dri1_util.c.orig 1970-01-01 01:00:00.000000000 +0100 -+++ libva-0.31.0.patch/src/x11/dri1_util.c.orig 2009-09-22 15:17:03.000000000 +0200 -@@ -0,0 +1,157 @@ -+#include -+#include -+#include -+#include -+#include -+ -+#include -+ -+#include "X11/Xlib.h" -+#include "va.h" -+#include "va_backend.h" -+ -+#include "va_dri.h" -+#include "va_dricommon.h" -+ -+struct dri1_drawable -+{ -+ struct dri_drawable base; -+ union dri_buffer buffer; -+ int width; -+ int height; -+}; -+ -+static struct dri_drawable * -+dri1CreateDrawable(VADriverContextP ctx, XID x_drawable) -+{ -+ struct dri1_drawable *dri1_drawable; -+ -+ dri1_drawable = calloc(1, sizeof(*dri1_drawable)); -+ -+ if (!dri1_drawable) -+ return NULL; -+ -+ dri1_drawable->base.x_drawable = x_drawable; -+ -+ return &dri1_drawable->base; -+} -+ -+static void -+dri1DestroyDrawable(VADriverContextP ctx, struct dri_drawable *dri_drawable) -+{ -+ free(dri_drawable); -+} -+ -+static void -+dri1SwapBuffer(VADriverContextP ctx, struct dri_drawable *dri_drawable) -+{ -+ -+} -+ -+static union dri_buffer * -+dri1GetRenderingBuffer(VADriverContextP ctx, struct dri_drawable *dri_drawable) -+{ -+ struct dri1_drawable *dri1_drawable = (struct dri1_drawable *)dri_drawable; -+ -+ return &dri1_drawable->buffer; -+} -+ -+static void -+dri1Close(VADriverContextP ctx) -+{ -+ struct dri_state *dri_state = (struct dri_state *)ctx->dri_state; -+ -+ free_drawable_hashtable(ctx); -+ VA_DRIDestroyContext(ctx->x11_dpy, ctx->x11_screen, dri_state->hwContextID); -+ assert(dri_state->pSAREA != MAP_FAILED); -+ drmUnmap(dri_state->pSAREA, SAREA_MAX); -+ assert(dri_state->fd >= 0); -+ drmCloseOnce(dri_state->fd); -+ VA_DRICloseConnection(ctx->x11_dpy, ctx->x11_screen); -+} -+ -+Bool -+isDRI1Connected(VADriverContextP ctx, char **driver_name) -+{ -+ struct dri_state *dri_state = (struct dri_state *)ctx->dri_state; -+ int direct_capable; -+ int driver_major; -+ int driver_minor; -+ int driver_patch; -+ int newlyopened; -+ char *BusID; -+ drm_magic_t magic; -+ -+ *driver_name = NULL; -+ dri_state->fd = -1; -+ dri_state->pSAREA = MAP_FAILED; -+ dri_state->driConnectedFlag = VA_NONE; -+ -+ if (!VA_DRIQueryDirectRenderingCapable(ctx->x11_dpy, -+ ctx->x11_screen, -+ &direct_capable)) -+ goto err_out0; -+ -+ if (!direct_capable) -+ goto err_out0; -+ -+ if (!VA_DRIGetClientDriverName(ctx->x11_dpy, ctx->x11_screen, -+ &driver_major, &driver_minor, -+ &driver_patch, driver_name)) -+ goto err_out0; -+ -+ if (!VA_DRIOpenConnection(ctx->x11_dpy, ctx->x11_screen, -+ &dri_state->hSAREA, &BusID)) -+ goto err_out0; -+ -+ -+ dri_state->fd = drmOpenOnce(NULL, BusID, &newlyopened); -+ XFree(BusID); -+ -+ if (dri_state->fd < 0) -+ goto err_out1; -+ -+ -+ if (drmGetMagic(dri_state->fd, &magic)) -+ goto err_out1; -+ -+ if (newlyopened && !VA_DRIAuthConnection(ctx->x11_dpy, ctx->x11_screen, magic)) -+ goto err_out1; -+ -+ if (drmMap(dri_state->fd, dri_state->hSAREA, SAREA_MAX, &dri_state->pSAREA)) -+ goto err_out1; -+ -+ if (!VA_DRICreateContext(ctx->x11_dpy, ctx->x11_screen, -+ DefaultVisual(ctx->x11_dpy, ctx->x11_screen), -+ &dri_state->hwContextID, &dri_state->hwContext)) -+ goto err_out1; -+ -+ dri_state->driConnectedFlag = VA_DRI1; -+ dri_state->createDrawable = dri1CreateDrawable; -+ dri_state->destroyDrawable = dri1DestroyDrawable; -+ dri_state->swapBuffer = dri1SwapBuffer; -+ dri_state->getRenderingBuffer = dri1GetRenderingBuffer; -+ dri_state->close = dri1Close; -+ -+ return True; -+ -+err_out1: -+ if (dri_state->pSAREA != MAP_FAILED) -+ drmUnmap(dri_state->pSAREA, SAREA_MAX); -+ -+ if (dri_state->fd >= 0) -+ drmCloseOnce(dri_state->fd); -+ -+ VA_DRICloseConnection(ctx->x11_dpy, ctx->x11_screen); -+ -+err_out0: -+ if (*driver_name) -+ XFree(*driver_name); -+ -+ dri_state->pSAREA = MAP_FAILED; -+ dri_state->fd = -1; -+ *driver_name = NULL; -+ -+ return False; -+} -+ diff -Naur libva-0.31.0/src/x11/dri2_util.c libva-0.31.0.patch/src/x11/dri2_util.c --- libva-0.31.0/src/x11/dri2_util.c 2009-09-10 17:18:49.000000000 +0200 +++ libva-0.31.0.patch/src/x11/dri2_util.c 2009-12-15 13:44:45.454354628 +0100 @@ -77308,251 +73766,6 @@ diff -Naur libva-0.31.0/src/x11/va_x11.c libva-0.31.0.patch/src/x11/va_x11.c pDriverContext->dri_state = dri_state; dpy = (VADisplay)pDisplayContext; diff -Naur libva-0.31.0/src/x11/va_x11.c.orig libva-0.31.0.patch/src/x11/va_x11.c.orig ---- libva-0.31.0/src/x11/va_x11.c.orig 1970-01-01 01:00:00.000000000 +0100 -+++ libva-0.31.0.patch/src/x11/va_x11.c.orig 2009-12-15 13:44:52.004448213 +0100 -@@ -0,0 +1,242 @@ -+/* -+ * Copyright (c) 2007 Intel Corporation. All Rights Reserved. -+ * -+ * Permission is hereby granted, free of charge, to any person obtaining a -+ * copy of this software and associated documentation files (the -+ * "Software"), to deal in the Software without restriction, including -+ * without limitation the rights to use, copy, modify, merge, publish, -+ * distribute, sub license, and/or sell copies of the Software, and to -+ * permit persons to whom the Software is furnished to do so, subject to -+ * the following conditions: -+ * -+ * The above copyright notice and this permission notice (including the -+ * next paragraph) shall be included in all copies or substantial portions -+ * of the Software. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -+ */ -+ -+#define _GNU_SOURCE 1 -+#include "config.h" -+#include "va.h" -+#include "va_backend.h" -+#include "va_x11.h" -+#include "va_dri.h" -+#include "va_dri2.h" -+#include "va_dricommon.h" -+#include "va_nvctrl.h" -+#include "va_fglext.h" -+#include "libdrm_glue.h" -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+static VADisplayContextP pDisplayContexts = NULL; -+ -+static int va_DisplayContextIsValid ( -+ VADisplayContextP pDisplayContext -+) -+{ -+ VADisplayContextP ctx = pDisplayContexts; -+ -+ while (ctx) -+ { -+ if (ctx == pDisplayContext && pDisplayContext->pDriverContext) -+ return 1; -+ ctx = ctx->pNext; -+ } -+ return 0; -+} -+ -+static void va_DisplayContextDestroy ( -+ VADisplayContextP pDisplayContext -+) -+{ -+ VADisplayContextP *ctx = &pDisplayContexts; -+ -+ /* Throw away pDisplayContext */ -+ while (*ctx) -+ { -+ if (*ctx == pDisplayContext) -+ { -+ *ctx = pDisplayContext->pNext; -+ pDisplayContext->pNext = NULL; -+ break; -+ } -+ ctx = &((*ctx)->pNext); -+ } -+ -+ libdrm_close(); -+ free(pDisplayContext->pDriverContext->dri_state); -+ free(pDisplayContext->pDriverContext); -+ free(pDisplayContext); -+} -+ -+ -+static VAStatus va_DRI2GetDriverName ( -+ VADisplayContextP pDisplayContext, -+ char **driver_name -+) -+{ -+ VADriverContextP ctx = pDisplayContext->pDriverContext; -+ -+ if (!isDRI2Connected(ctx, driver_name)) -+ return VA_STATUS_ERROR_UNKNOWN; -+ -+ return VA_STATUS_SUCCESS; -+} -+ -+static VAStatus va_DRIGetDriverName ( -+ VADisplayContextP pDisplayContext, -+ char **driver_name -+) -+{ -+ VADriverContextP ctx = pDisplayContext->pDriverContext; -+ -+ if (!isDRI1Connected(ctx, driver_name)) -+ return VA_STATUS_ERROR_UNKNOWN; -+ -+ return VA_STATUS_SUCCESS; -+} -+ -+static VAStatus va_NVCTRL_GetDriverName ( -+ VADisplayContextP pDisplayContext, -+ char **driver_name -+) -+{ -+ VADriverContextP ctx = pDisplayContext->pDriverContext; -+ int direct_capable, driver_major, driver_minor, driver_patch; -+ Bool result; -+ -+ result = VA_NVCTRLQueryDirectRenderingCapable(ctx->x11_dpy, ctx->x11_screen, -+ &direct_capable); -+ if (!result || !direct_capable) -+ return VA_STATUS_ERROR_UNKNOWN; -+ -+ result = VA_NVCTRLGetClientDriverName(ctx->x11_dpy, ctx->x11_screen, -+ &driver_major, &driver_minor, -+ &driver_patch, driver_name); -+ if (!result) -+ return VA_STATUS_ERROR_UNKNOWN; -+ -+ return VA_STATUS_SUCCESS; -+} -+ -+static VAStatus va_FGLEXT_GetDriverName( -+ VADisplayContextP pDisplayContext, -+ char **driver_name -+) -+{ -+ VADriverContextP ctx = pDisplayContext->pDriverContext; -+ int direct_capable, driver_major, driver_minor, driver_patch; -+ Bool result; -+ -+ result = VA_FGLEXTQueryDirectRenderingCapable(ctx->x11_dpy, ctx->x11_screen, -+ &direct_capable); -+ if (!result || !direct_capable) -+ return VA_STATUS_ERROR_UNKNOWN; -+ -+ result = VA_FGLEXTGetClientDriverName(ctx->x11_dpy, ctx->x11_screen, -+ &driver_major, &driver_minor, -+ &driver_patch, driver_name); -+ if (!result) -+ return VA_STATUS_ERROR_UNKNOWN; -+ -+ return VA_STATUS_SUCCESS; -+} -+ -+static VAStatus va_DisplayContextGetDriverName ( -+ VADisplayContextP pDisplayContext, -+ char **driver_name -+) -+{ -+ VAStatus vaStatus; -+ char *driver_name_env; -+ -+ if (driver_name) -+ *driver_name = NULL; -+ -+ if ((driver_name_env = getenv("LIBVA_DRIVER_NAME")) != NULL -+ && geteuid() == getuid()) -+ { -+ /* don't allow setuid apps to use LIBVA_DRIVER_NAME */ -+ *driver_name = strdup(driver_name_env); -+ return VA_STATUS_SUCCESS; -+ } -+ -+ vaStatus = va_DRI2GetDriverName(pDisplayContext, driver_name); -+ if (vaStatus != VA_STATUS_SUCCESS) -+ vaStatus = va_DRIGetDriverName(pDisplayContext, driver_name); -+ if (vaStatus != VA_STATUS_SUCCESS) -+ vaStatus = va_NVCTRL_GetDriverName(pDisplayContext, driver_name); -+ if (vaStatus != VA_STATUS_SUCCESS) -+ vaStatus = va_FGLEXT_GetDriverName(pDisplayContext, driver_name); -+ return vaStatus; -+} -+ -+ -+VADisplay vaGetDisplay ( -+ Display *native_dpy /* implementation specific */ -+) -+{ -+ VADisplay dpy = NULL; -+ VADisplayContextP pDisplayContext = pDisplayContexts; -+ -+ if (!native_dpy) -+ return NULL; -+ -+ while (pDisplayContext) -+ { -+ if (pDisplayContext->pDriverContext && -+ pDisplayContext->pDriverContext->x11_dpy == native_dpy) -+ { -+ dpy = (VADisplay)pDisplayContext; -+ break; -+ } -+ pDisplayContext = pDisplayContext->pNext; -+ } -+ -+ if (!dpy) -+ { -+ /* create new entry */ -+ VADriverContextP pDriverContext; -+ struct dri_state *dri_state; -+ pDisplayContext = calloc(1, sizeof(*pDisplayContext)); -+ pDriverContext = calloc(1, sizeof(*pDriverContext)); -+ dri_state = calloc(1, sizeof(*dri_state)); -+ if (pDisplayContext && pDriverContext && dri_state) -+ { -+ pDriverContext->x11_dpy = native_dpy; -+ pDisplayContext->pNext = pDisplayContexts; -+ pDisplayContext->pDriverContext = pDriverContext; -+ pDisplayContext->vaIsValid = va_DisplayContextIsValid; -+ pDisplayContext->vaDestroy = va_DisplayContextDestroy; -+ pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName; -+ pDisplayContexts = pDisplayContext; -+ pDriverContext->dri_state = dri_state; -+ dpy = (VADisplay)pDisplayContext; -+ } -+ else -+ { -+ if (pDisplayContext) -+ free(pDisplayContext); -+ if (pDriverContext) -+ free(pDriverContext); -+ if (dri_state) -+ free(dri_state); -+ } -+ } -+ -+ return dpy; -+} diff -Naur libva-0.31.0/src/x11/va_x11.h libva-0.31.0.patch/src/x11/va_x11.h --- libva-0.31.0/src/x11/va_x11.h 2009-07-06 12:44:10.000000000 +0200 +++ libva-0.31.0.patch/src/x11/va_x11.h 2009-12-15 13:45:13.207447712 +0100