diff -Nru libva-0.31.0+latest2/configure.ac libva-0.31.0+latest3/configure.ac --- libva-0.31.0+latest2/configure.ac 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/configure.ac 2010-03-18 08:39:39.000000000 +0000 @@ -28,9 +28,6 @@ m4_define([libva_version], [libva_major_version.libva_minor_version.libva_micro_version]) -# increase this number for each API change -m4_define([libva_sds_version], [6]) - # if the library source code has changed, increment revision m4_define([libva_lt_revision], [1]) # if any interface was added/removed/changed, then inc current, reset revision @@ -55,22 +52,14 @@ AC_SUBST(LIBVA_MICRO_VERSION) AC_SUBST(LIBVA_VERSION) -LIBVA_SDS_VERSION=libva_sds_version -AC_SUBST(LIBVA_SDS_VERSION) - LIBVA_LT_CURRENT=libva_lt_current LIBVA_LT_REV=libva_lt_revision LIBVA_LT_AGE=libva_lt_age LIBVA_LT_VERSION="$LIBVA_LT_CURRENT:$LIBVA_LT_REV:$LIBVA_LT_AGE" -LIBVA_LT_LDFLAGS="-version-info $LIBVA_LT_VERSION -release $LIBVA_VERSION.$LIBVA_SDS_VERSION" +LIBVA_LT_LDFLAGS="-version-info $LIBVA_LT_VERSION" AC_SUBST(LIBVA_LT_VERSION) AC_SUBST(LIBVA_LT_LDFLAGS) -AC_ARG_ENABLE(glx, - [AC_HELP_STRING([--enable-glx], - [build with OpenGL for X11 support])], - [], [enable_glx=yes]) - AC_ARG_ENABLE(dummy-driver, [AC_HELP_STRING([--enable-dummy-driver], [build dummy video driver])], @@ -84,7 +73,7 @@ AC_ARG_WITH(drivers-path, [AC_HELP_STRING([--with-drivers-path=[[path]]], [drivers path])],, - [with_drivers_path="$libdir/va/drivers"]) + [with_drivers_path="$libdir/dri"]) LIBVA_DRIVERS_PATH="$with_drivers_path" AC_SUBST(LIBVA_DRIVERS_PATH) @@ -111,46 +100,6 @@ fi AM_CONDITIONAL(BUILD_I965_DRIVER, test x$enable_i965_driver = xyes) -dnl Check for __attribute__((visibility())) -AC_CACHE_CHECK([whether __attribute__((visibility())) is supported], - libva_cv_visibility_attribute, - [cat > conftest.c </dev/null 2>&1; then - if grep '\.hidden.*foo' conftest.s >/dev/null; then - if grep '\.protected.*bar' conftest.s >/dev/null; then - libva_cv_visibility_attribute=yes - fi - fi - fi - rm -f conftest.[cs] -]) -ATTRIBUTE_HIDDEN="" -if test $libva_cv_visibility_attribute = yes; then - ATTRIBUTE_HIDDEN="__attribute__((visibility(\"hidden\")))" -fi -AC_DEFINE_UNQUOTED([ATTRIBUTE_HIDDEN], [$ATTRIBUTE_HIDDEN], - [Defined to __attribute__((visibility("hidden"))) when available]) - -# Check for OpenGL (X11) -USE_GLX="no" -GL_DEPS_CFLAGS="" -GL_DEPS_LIBS="" -if test x$enable_glx = xyes; then - AC_CHECK_HEADERS([GL/gl.h]) - AC_CHECK_HEADERS([GL/glx.h]) - AC_CHECK_LIB(GL, glXCreateContext, [ - USE_GLX="yes" - GL_DEPS_LIBS="-lX11 -lGL" - ]) -fi -AC_SUBST(GL_DEPS_CFLAGS) -AC_SUBST(GL_DEPS_LIBS) -AM_CONDITIONAL(USE_GLX, test "$USE_GLX" = "yes") - # We only need the headers, we don't link against the DRM libraries LIBVA_CFLAGS="$DRM_CFLAGS" AC_SUBST(LIBVA_CFLAGS) @@ -170,7 +119,6 @@ va/Makefile va/va_version.h va/x11/Makefile - va/glx/Makefile dummy_drv_video/Makefile i965_drv_video/Makefile i965_drv_video/shaders/Makefile @@ -184,6 +132,5 @@ test/encode/Makefile libva.pc libva-x11.pc - libva-glx.pc ]) diff -Nru libva-0.31.0+latest2/debian/changelog libva-0.31.0+latest3/debian/changelog --- libva-0.31.0+latest2/debian/changelog 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/debian/changelog 2010-04-18 14:36:16.000000000 +0100 @@ -1,9 +1,20 @@ -libva (0.31.0+latest2-1+sds11~multimediappa2) lucid; urgency=low +libva (0.31.0+latest3-1+sds12~multimediappa1) lucid; urgency=low - * New upstream release. Altered packaging scripts once again to enable - Intel i965_drv_video.so. + * New upstream release. - -- Brandon Snider Tue, 23 Mar 2010 21:44:57 -0400 + -- Brandon Snider Sun, 18 Apr 2010 09:14:58 -0400 + +libva (0.31.0-1+sds12) hardy; urgency=low + + * G45 updates: + - Add I420 image format. + - Fix destruction of image created by vaDeriveImage(). + * OpenGL extensions updates: + - Fix vaCopySurfaceGLX() to handle the postprocessing flags. + - Fix default implementation with TFP + FBO. Requires GLX 1.3. + - Fix vaCreateSurfaceGLX() to handle GL_RGBA8 internal formats. + + -- Gwenole Beauchesne Sun, 04 Apr 2010 07:56:59 +0200 libva (0.31.0-1+sds11) hardy; urgency=low diff -Nru libva-0.31.0+latest2/debian/control libva-0.31.0+latest3/debian/control --- libva-0.31.0+latest2/debian/control 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/debian/control 2010-04-18 14:36:16.000000000 +0100 @@ -5,7 +5,6 @@ debhelper (>= 5), autotools-dev, libdrm-dev, - libdrm-intel1, x11proto-xext-dev, libxext-dev, libxfixes-dev, diff -Nru libva-0.31.0+latest2/debian/patches/032_g45_fix_subpic_formats.patch libva-0.31.0+latest3/debian/patches/032_g45_fix_subpic_formats.patch --- libva-0.31.0+latest2/debian/patches/032_g45_fix_subpic_formats.patch 1970-01-01 01:00:00.000000000 +0100 +++ libva-0.31.0+latest3/debian/patches/032_g45_fix_subpic_formats.patch 2010-04-18 14:36:16.000000000 +0100 @@ -0,0 +1,19 @@ +commit d6e726b80766c669dffe846fcd31fcfe5dc89847 +Author: Gwenole Beauchesne +Date: Wed Nov 4 12:13:41 2009 +0000 + + [G45] Fix subpictures formats array terminator. + +diff --git a/i965_drv_video/i965_drv_video.c b/i965_drv_video/i965_drv_video.c +index 6a60ecc..e476ca2 100644 +--- a/i965_drv_video/i965_drv_video.c ++++ b/i965_drv_video/i965_drv_video.c +@@ -76,7 +76,7 @@ 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++) { ++ for (i = 0; i965_subpic_formats_map[i].type != 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 ? diff -Nru libva-0.31.0+latest2/debian/patches/033_g45_add_rgba_subpic.patch libva-0.31.0+latest3/debian/patches/033_g45_add_rgba_subpic.patch --- libva-0.31.0+latest2/debian/patches/033_g45_add_rgba_subpic.patch 1970-01-01 01:00:00.000000000 +0100 +++ libva-0.31.0+latest3/debian/patches/033_g45_add_rgba_subpic.patch 2010-04-18 14:36:16.000000000 +0100 @@ -0,0 +1,103 @@ +commit 98edda85a2d734763a5f40478a063d3e289e1389 +Author: Gwenole Beauchesne +Date: Wed Nov 4 10:56:54 2009 +0000 + + [G45] Add RGBA subpictures. + +diff --git a/i965_drv_video/i965_drv_video.c b/i965_drv_video/i965_drv_video.c +index e476ca2..637e304 100644 +--- a/i965_drv_video/i965_drv_video.c ++++ b/i965_drv_video/i965_drv_video.c +@@ -70,6 +70,14 @@ i965_subpic_formats_map[I965_MAX_SUBPIC_FORMATS + 1] = { + { 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 * +@@ -467,6 +475,7 @@ i965_CreateSubpicture(VADriverContextP ctx, + 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; + } +@@ -1218,6 +1227,15 @@ i965_CreateImage(VADriverContextP ctx, + 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; + default: + goto error; + } +diff --git a/i965_drv_video/i965_drv_video.h b/i965_drv_video/i965_drv_video.h +index fa09869..2f538c2 100644 +--- a/i965_drv_video/i965_drv_video.h ++++ b/i965_drv_video/i965_drv_video.h +@@ -44,7 +44,7 @@ + #define I965_MAX_ENTRYPOINTS 5 + #define I965_MAX_CONFIG_ATTRIBUTES 10 + #define I965_MAX_IMAGE_FORMATS 10 +-#define I965_MAX_SUBPIC_FORMATS 2 ++#define I965_MAX_SUBPIC_FORMATS 4 + #define I965_MAX_DISPLAY_ATTRIBUTES 4 + #define I965_STR_VENDOR "i965 Driver 0.1" + +@@ -126,6 +126,7 @@ struct object_subpic + unsigned int format; + int width; + int height; ++ int pitch; + dri_bo *bo; + }; + +diff --git a/i965_drv_video/i965_render.c b/i965_drv_video/i965_render.c +index 4a4f041..c738d22 100644 +--- a/i965_drv_video/i965_render.c ++++ b/i965_drv_video/i965_render.c +@@ -587,7 +587,7 @@ i965_subpic_render_src_surface_state(VADriverContextP ctx, + int index, + dri_bo *region, + unsigned long offset, +- int w, int h, int format) ++ int w, int h, int p, int format) + { + struct i965_driver_data *i965 = i965_driver_data(ctx); + struct i965_render_state *render_state = &i965->render_state; +@@ -621,7 +621,7 @@ i965_subpic_render_src_surface_state(VADriverContextP ctx, + ss->ss2.mip_count = 0; + ss->ss2.render_target_rotation = 0; + +- ss->ss3.pitch = w - 1; ++ ss->ss3.pitch = p - 1; + + dri_bo_emit_reloc(ss_bo, + I915_GEM_DOMAIN_SAMPLER, 0, +@@ -679,8 +679,8 @@ i965_subpic_render_src_surfaces_state(VADriverContextP ctx, + region = obj_surface->bo; + subpic_region = obj_image->bo; + /*subpicture surface*/ +- i965_subpic_render_src_surface_state(ctx, 1, subpic_region, 0, obj_subpic->width, obj_subpic->height, obj_subpic->format); +- i965_subpic_render_src_surface_state(ctx, 2, subpic_region, 0, obj_subpic->width, obj_subpic->height, obj_subpic->format); ++ i965_subpic_render_src_surface_state(ctx, 1, subpic_region, 0, obj_subpic->width, obj_subpic->height, obj_subpic->pitch, obj_subpic->format); ++ i965_subpic_render_src_surface_state(ctx, 2, subpic_region, 0, obj_subpic->width, obj_subpic->height, obj_subpic->pitch, obj_subpic->format); + } + + static void diff -Nru libva-0.31.0+latest2/debian/patches/034_g45_fix_return_for_unimpl.patch libva-0.31.0+latest3/debian/patches/034_g45_fix_return_for_unimpl.patch --- libva-0.31.0+latest2/debian/patches/034_g45_fix_return_for_unimpl.patch 1970-01-01 01:00:00.000000000 +0100 +++ libva-0.31.0+latest3/debian/patches/034_g45_fix_return_for_unimpl.patch 2010-04-18 14:36:16.000000000 +0100 @@ -0,0 +1,77 @@ +commit ff263433c32aac08574b58b26f3f4be7abe05bdf +Author: Gwenole Beauchesne +Date: Wed Nov 4 13:23:40 2009 +0000 + + [G45] Don't return VA_STATUS_SUCCESS for unimplemented functions. + +diff --git a/i965_drv_video/i965_drv_video.c b/i965_drv_video/i965_drv_video.c +index 637e304..9e8502a 100644 +--- a/i965_drv_video/i965_drv_video.c ++++ b/i965_drv_video/i965_drv_video.c +@@ -496,7 +496,8 @@ i965_SetSubpictureImage(VADriverContextP ctx, + VASubpictureID subpicture, + VAImageID image) + { +- return VA_STATUS_SUCCESS; ++ /* TODO */ ++ return VA_STATUS_ERROR_UNIMPLEMENTED; + } + + VAStatus +@@ -506,7 +507,8 @@ i965_SetSubpictureChromakey(VADriverContextP ctx, + unsigned int chromakey_max, + unsigned int chromakey_mask) + { +- return VA_STATUS_SUCCESS; ++ /* TODO */ ++ return VA_STATUS_ERROR_UNIMPLEMENTED; + } + + VAStatus +@@ -514,7 +516,8 @@ i965_SetSubpictureGlobalAlpha(VADriverContextP ctx, + VASubpictureID subpicture, + float global_alpha) + { +- return VA_STATUS_SUCCESS; ++ /* TODO */ ++ return VA_STATUS_ERROR_UNIMPLEMENTED; + } + + VAStatus +@@ -1103,7 +1106,7 @@ i965_GetDisplayAttributes(VADriverContextP ctx, + int num_attributes) + { + /* TODO */ +- return VA_STATUS_ERROR_UNKNOWN; ++ return VA_STATUS_ERROR_UNIMPLEMENTED; + } + + /* +@@ -1118,7 +1121,7 @@ i965_SetDisplayAttributes(VADriverContextP ctx, + int num_attributes) + { + /* TODO */ +- return VA_STATUS_ERROR_UNKNOWN; ++ return VA_STATUS_ERROR_UNIMPLEMENTED; + } + + VAStatus +@@ -1128,7 +1131,7 @@ i965_DbgCopySurfaceToBuffer(VADriverContextP ctx, + unsigned int *stride) /* out */ + { + /* TODO */ +- return VA_STATUS_ERROR_UNKNOWN; ++ return VA_STATUS_ERROR_UNIMPLEMENTED; + } + + static VAStatus +@@ -1270,7 +1273,8 @@ VAStatus i965_DeriveImage(VADriverContextP ctx, + VASurfaceID surface, + VAImage *image) /* out */ + { +- return VA_STATUS_SUCCESS; ++ /* TODO */ ++ return VA_STATUS_ERROR_OPERATION_FAILED; + } + + static void diff -Nru libva-0.31.0+latest2/debian/patches/035_g45_add_yv12_image_format.patch libva-0.31.0+latest3/debian/patches/035_g45_add_yv12_image_format.patch --- libva-0.31.0+latest2/debian/patches/035_g45_add_yv12_image_format.patch 1970-01-01 01:00:00.000000000 +0100 +++ libva-0.31.0+latest3/debian/patches/035_g45_add_yv12_image_format.patch 2010-04-18 14:36:16.000000000 +0100 @@ -0,0 +1,95 @@ +commit c5cb995d6cd49f5f2988b1721cb6b5da8a9b2c09 +Author: Gwenole Beauchesne +Date: Wed Nov 4 13:01:44 2009 +0000 + + [G45] Add YV12 image format. + +diff --git a/i965_drv_video/i965_drv_video.c b/i965_drv_video/i965_drv_video.c +index 9e8502a..6488570 100644 +--- a/i965_drv_video/i965_drv_video.c ++++ b/i965_drv_video/i965_drv_video.c +@@ -54,6 +54,36 @@ enum { + 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; +@@ -398,8 +428,16 @@ 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 = 0; ++ *num_formats = n; + + return VA_STATUS_SUCCESS; + } +@@ -1239,6 +1277,16 @@ i965_CreateImage(VADriverContextP ctx, + 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 + size2; ++ image->pitches[2] = width2; ++ image->offsets[2] = size; ++ image->data_size = size + 2 * size2; ++ break; + default: + goto error; + } +diff --git a/i965_drv_video/i965_drv_video.h b/i965_drv_video/i965_drv_video.h +index 2f538c2..be253ed 100644 +--- a/i965_drv_video/i965_drv_video.h ++++ b/i965_drv_video/i965_drv_video.h +@@ -43,7 +43,7 @@ + #define I965_MAX_PROFILES 11 + #define I965_MAX_ENTRYPOINTS 5 + #define I965_MAX_CONFIG_ATTRIBUTES 10 +-#define I965_MAX_IMAGE_FORMATS 10 ++#define I965_MAX_IMAGE_FORMATS 1 + #define I965_MAX_SUBPIC_FORMATS 4 + #define I965_MAX_DISPLAY_ATTRIBUTES 4 + #define I965_STR_VENDOR "i965 Driver 0.1" diff -Nru libva-0.31.0+latest2/debian/patches/036_g45_add_vaGetImage.patch libva-0.31.0+latest3/debian/patches/036_g45_add_vaGetImage.patch --- libva-0.31.0+latest2/debian/patches/036_g45_add_vaGetImage.patch 1970-01-01 01:00:00.000000000 +0100 +++ libva-0.31.0+latest3/debian/patches/036_g45_add_vaGetImage.patch 2010-04-18 14:36:16.000000000 +0100 @@ -0,0 +1,62 @@ +commit c833a4ef4efa20ab8df18d13bdab1e5c5e4671a8 +Author: Gwenole Beauchesne +Date: Wed Nov 4 13:16:34 2009 +0000 + + [G45] Implement vaGetImage() for full-sized surface readback. + +diff --git a/i965_drv_video/i965_drv_video.c b/i965_drv_video/i965_drv_video.c +index ebaf1ae..59ebdd7 100644 +--- a/i965_drv_video/i965_drv_video.c ++++ b/i965_drv_video/i965_drv_video.c +@@ -1392,7 +1392,50 @@ i965_GetImage(VADriverContextP ctx, + unsigned int height, + VAImageID image) + { +- return VA_STATUS_SUCCESS; ++ struct i965_driver_data *i965 = i965_driver_data(ctx); ++ ++ struct object_surface *obj_surface = SURFACE(surface); ++ if (!obj_surface) ++ return VA_STATUS_ERROR_INVALID_SURFACE; ++ ++ struct object_image *obj_image = IMAGE(image); ++ if (!obj_image) ++ return VA_STATUS_ERROR_INVALID_IMAGE; ++ ++ /* XXX: we only support full-size surface readback */ ++ if (x != 0 || ++ y != 0 || ++ width != obj_surface->width || ++ height != obj_surface->height) ++ return VA_STATUS_ERROR_INVALID_PARAMETER; ++ ++ /* XXX: we only support 1:1 image copies */ ++ if (width != obj_image->image.width || ++ height != obj_image->image.height) ++ return VA_STATUS_ERROR_INVALID_PARAMETER; ++ ++ VAStatus va_status; ++ void *image_data = NULL; ++ ++ va_status = i965_MapBuffer(ctx, obj_image->image.buf, &image_data); ++ if (va_status != VA_STATUS_SUCCESS) ++ return va_status; ++ ++ dri_bo_map(obj_surface->bo, 0); ++ ++ switch (obj_image->image.format.fourcc) { ++ case VA_FOURCC('Y','V','1','2'): /* YV12 is native format here */ ++ memcpy(image_data, obj_surface->bo->virtual, obj_surface->bo->size); ++ break; ++ default: ++ va_status = VA_STATUS_ERROR_OPERATION_FAILED; ++ break; ++ } ++ ++ dri_bo_unmap(obj_surface->bo); ++ ++ i965_UnmapBuffer(ctx, obj_image->image.buf); ++ return va_status; + } + + VAStatus diff -Nru libva-0.31.0+latest2/debian/patches/037_g45_add_vaPutImage.patch libva-0.31.0+latest3/debian/patches/037_g45_add_vaPutImage.patch --- libva-0.31.0+latest2/debian/patches/037_g45_add_vaPutImage.patch 1970-01-01 01:00:00.000000000 +0100 +++ libva-0.31.0+latest3/debian/patches/037_g45_add_vaPutImage.patch 2010-04-18 14:36:16.000000000 +0100 @@ -0,0 +1,102 @@ +commit c00ac73b0fa1f5c4ff9cdc76b7556c5db03c5335 +Author: Gwenole Beauchesne +Date: Wed Nov 4 13:36:39 2009 +0000 + + [G45] Implement vaPutImage() for full-sized surface uploads. + +diff --git a/i965_drv_video/i965_drv_video.c b/i965_drv_video/i965_drv_video.c +index 59ebdd7..5c15439 100644 +--- a/i965_drv_video/i965_drv_video.c ++++ b/i965_drv_video/i965_drv_video.c +@@ -443,22 +443,6 @@ i965_QueryImageFormats(VADriverContextP ctx, + } + + 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 */ +@@ -1439,6 +1423,68 @@ i965_GetImage(VADriverContextP ctx, + } + + 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) ++{ ++ struct i965_driver_data *i965 = i965_driver_data(ctx); ++ ++ struct object_surface *obj_surface = SURFACE(surface); ++ if (!obj_surface) ++ return VA_STATUS_ERROR_INVALID_SURFACE; ++ ++ struct object_image *obj_image = IMAGE(image); ++ if (!obj_image) ++ return VA_STATUS_ERROR_INVALID_IMAGE; ++ ++ /* XXX: we don't support partial video surface updates */ ++ if (src_x != 0 || ++ src_y != 0 || ++ src_width != obj_image->image.width || ++ src_height != obj_image->image.height) ++ return VA_STATUS_ERROR_OPERATION_FAILED; ++ if (dest_x != 0 || ++ dest_y != 0 || ++ dest_width != obj_surface->width || ++ dest_height != obj_surface->height) ++ return VA_STATUS_ERROR_OPERATION_FAILED; ++ if (src_width != dest_width || ++ src_height != dest_height) ++ return VA_STATUS_ERROR_OPERATION_FAILED; ++ ++ VAStatus va_status; ++ void *image_data = NULL; ++ ++ va_status = i965_MapBuffer(ctx, obj_image->image.buf, &image_data); ++ if (va_status != VA_STATUS_SUCCESS) ++ return va_status; ++ ++ dri_bo_map(obj_surface->bo, 1); ++ ++ switch (obj_image->image.format.fourcc) { ++ case VA_FOURCC('Y','V','1','2'): /* YV12 is native format here */ ++ memcpy(obj_surface->bo->virtual, image_data, obj_surface->bo->size); ++ break; ++ default: ++ va_status = VA_STATUS_ERROR_OPERATION_FAILED; ++ break; ++ } ++ ++ dri_bo_unmap(obj_surface->bo); ++ ++ i965_UnmapBuffer(ctx, obj_image->image.buf); ++ return va_status; ++} ++ ++VAStatus + i965_PutSurface(VADriverContextP ctx, + VASurfaceID surface, + Drawable draw, /* X Drawable */ diff -Nru libva-0.31.0+latest2/debian/patches/038_g45_vaPutSurface_cliprects.patch libva-0.31.0+latest3/debian/patches/038_g45_vaPutSurface_cliprects.patch --- libva-0.31.0+latest2/debian/patches/038_g45_vaPutSurface_cliprects.patch 1970-01-01 01:00:00.000000000 +0100 +++ libva-0.31.0+latest3/debian/patches/038_g45_vaPutSurface_cliprects.patch 2010-04-18 14:36:16.000000000 +0100 @@ -0,0 +1,523 @@ +commit ab248483d89c6cf7beb7a3a87c9b9a55464023cc +Author: Gwenole Beauchesne +Date: Wed Nov 4 17:34:53 2009 +0000 + + [G45] Handle cliprects in vaPutSurface(). + +diff --git a/i965_drv_video/i965_drv_video.c b/i965_drv_video/i965_drv_video.c +index 5c15439..d4ad6e1 100644 +--- a/i965_drv_video/i965_drv_video.c ++++ b/i965_drv_video/i965_drv_video.c +@@ -1507,13 +1507,23 @@ i965_PutSurface(VADriverContextP ctx, + union dri_buffer *buffer; + struct intel_region *dest_region; + struct object_surface *obj_surface; +- int ret; ++ int ret; + uint32_t name; ++ VARectangle src_rect, dst_rect; + Bool new_region = False; ++ + /* Currently don't support DRI1 */ + if (dri_state->driConnectedFlag != VA_DRI2) + return VA_STATUS_ERROR_UNKNOWN; + ++ /* XXX: we currently only support up to 64 cliprects */ ++ if (number_cliprects > MAX_CLIP_RECTS) ++ return VA_STATUS_ERROR_OPERATION_FAILED; ++ ++ obj_surface = SURFACE(surface); ++ if (!obj_surface) ++ return VA_STATUS_ERROR_INVALID_SURFACE; ++ + dri_drawable = dri_get_drawable(ctx, draw); + assert(dri_drawable); + +@@ -1552,17 +1562,24 @@ i965_PutSurface(VADriverContextP ctx, + 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); ++ src_rect.x = srcx; ++ src_rect.y = srcy; ++ src_rect.width = srcw; ++ src_rect.height = srch; ++ ++ dst_rect.x = destx; ++ dst_rect.y = desty; ++ dst_rect.width = destw; ++ dst_rect.height = desth; + ++ i965_render_put_surface(ctx, surface, &src_rect, &dst_rect, ++ cliprects, number_cliprects); ++ ++ if (obj_surface->subpic != VA_INVALID_ID) ++ i965_render_put_subpic(ctx, surface, &src_rect, &dst_rect, ++ cliprects, number_cliprects); ++ ++ dri_swap_buffer(ctx, dri_drawable); + return VA_STATUS_SUCCESS; + } + +diff --git a/i965_drv_video/i965_render.c b/i965_drv_video/i965_render.c +index c738d22..301d51d 100644 +--- a/i965_drv_video/i965_render.c ++++ b/i965_drv_video/i965_render.c +@@ -788,13 +788,81 @@ i965_render_binding_table(VADriverContextP ctx) + dri_bo_unmap(render_state->wm.binding_table); + } + +-static void ++static unsigned int ++i965_render_do_upload_vertex(VADriverContextP ctx, ++ unsigned int width, ++ unsigned int height, ++ const VARectangle *src_rect, ++ const VARectangle *dst_rect, ++ const VARectangle *cliprects, ++ unsigned int num_cliprects) ++{ ++ struct i965_driver_data *i965 = i965_driver_data(ctx); ++ struct i965_render_state *render_state = &i965->render_state; ++ struct intel_region *dest_region = render_state->draw_region; ++ float *vb, tx1, tx2, ty1, ty2; ++ int x1, x2, y1, y2; ++ unsigned int i, n; ++ ++ if (!cliprects || num_cliprects == 0) { ++ cliprects = dst_rect; ++ num_cliprects = 1; ++ } ++ ++ dri_bo_map(render_state->vb.vertex_buffer, 1); ++ assert(render_state->vb.vertex_buffer->virtual); ++ vb = render_state->vb.vertex_buffer->virtual; ++ ++ for (n = 0, i = 0; i < num_cliprects; i++) { ++ x1 = dest_region->x + cliprects[i].x; ++ y1 = dest_region->y + cliprects[i].y; ++ x2 = x1 + cliprects[i].width; ++ y2 = y1 + cliprects[i].height; ++ x1 = MAX(x1, dst_rect->x); ++ y1 = MAX(y1, dst_rect->y); ++ x2 = MIN(x2, dst_rect->x + dst_rect->width); ++ y2 = MIN(y2, dst_rect->y + dst_rect->height); ++ ++ if (x2 <= x1 || y2 <= y1) ++ continue; ++ ++ const float sx1 = (float)(x1 - dst_rect->x) / (float)dst_rect->width; ++ const float sy1 = (float)(y1 - dst_rect->y) / (float)dst_rect->height; ++ const float sx2 = (float)(x2 - dst_rect->x) / (float)dst_rect->width; ++ const float sy2 = (float)(y2 - dst_rect->y) / (float)dst_rect->height; ++ tx1 = ((float)src_rect->x + sx1 * (float)src_rect->width) / width; ++ ty1 = ((float)src_rect->y + sy1 * (float)src_rect->height) / height; ++ tx2 = ((float)src_rect->x + sx2 * (float)src_rect->width) / width; ++ ty2 = ((float)src_rect->y + sy2 * (float)src_rect->height) / height; ++ ++ vb[n++] = tx2; ++ vb[n++] = ty2; ++ vb[n++] = x2; ++ vb[n++] = y2; ++ ++ vb[n++] = tx1; ++ vb[n++] = ty2; ++ vb[n++] = x1; ++ vb[n++] = y2; ++ ++ vb[n++] = tx1; ++ vb[n++] = ty1; ++ vb[n++] = x1; ++ vb[n++] = y1; ++ } ++ ++ dri_bo_unmap(render_state->vb.vertex_buffer); ++ return n / 12; ++} ++ ++static unsigned int + i965_subpic_render_upload_vertex(VADriverContextP ctx, + VASurfaceID surface, +- const VARectangle *output_rect) +-{ ++ const VARectangle *output_rect, ++ const VARectangle *cliprects, ++ unsigned int num_cliprects) ++{ + struct i965_driver_data *i965 = i965_driver_data(ctx); +- struct i965_render_state *render_state = &i965->render_state; + struct object_surface *obj_surface = SURFACE(surface); + struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic); + +@@ -804,8 +872,6 @@ i965_subpic_render_upload_vertex(VADriverContextP ctx, + const float ssy = (float)output_rect->height / (float)obj_surface->height; + const float sx = psx * ssx; + const float sy = psy * ssy; +- float *vb, tx1, tx2, ty1, ty2, x1, x2, y1, y2; +- int i = 0; + + VARectangle dst_rect; + dst_rect.x = output_rect->x + sx * (float)obj_subpic->dst_rect.x; +@@ -813,106 +879,38 @@ i965_subpic_render_upload_vertex(VADriverContextP ctx, + dst_rect.width = sx * (float)obj_subpic->dst_rect.width; + dst_rect.height = sy * (float)obj_subpic->dst_rect.height; + +- dri_bo_map(render_state->vb.vertex_buffer, 1); +- assert(render_state->vb.vertex_buffer->virtual); +- vb = render_state->vb.vertex_buffer->virtual; +- +- tx1 = (float)obj_subpic->src_rect.x / (float)obj_subpic->width; +- ty1 = (float)obj_subpic->src_rect.y / (float)obj_subpic->height; +- tx2 = (float)(obj_subpic->src_rect.x + obj_subpic->src_rect.width) / (float)obj_subpic->width; +- ty2 = (float)(obj_subpic->src_rect.y + obj_subpic->src_rect.height) / (float)obj_subpic->height; +- +- x1 = (float)dst_rect.x; +- y1 = (float)dst_rect.y; +- x2 = (float)(dst_rect.x + dst_rect.width); +- y2 = (float)(dst_rect.y + dst_rect.height); +- +- vb[i++] = tx2; +- vb[i++] = ty2; +- vb[i++] = x2; +- vb[i++] = y2; +- +- vb[i++] = tx1; +- vb[i++] = ty2; +- vb[i++] = x1; +- vb[i++] = y2; +- +- vb[i++] = tx1; +- vb[i++] = ty1; +- vb[i++] = x1; +- vb[i++] = y1; +- dri_bo_unmap(render_state->vb.vertex_buffer); ++ return i965_render_do_upload_vertex(ctx, ++ obj_subpic->width, obj_subpic->height, ++ &obj_subpic->src_rect, &dst_rect, ++ cliprects, num_cliprects); + } + +-static void ++static unsigned int + i965_render_upload_vertex(VADriverContextP ctx, + VASurfaceID surface, +- short srcx, +- short srcy, +- unsigned short srcw, +- unsigned short srch, +- short destx, +- short desty, +- unsigned short destw, +- unsigned short desth) ++ const VARectangle *src_rect, ++ const VARectangle *dst_rect, ++ const VARectangle *cliprects, ++ unsigned int num_cliprects) + { + struct i965_driver_data *i965 = i965_driver_data(ctx); +- struct i965_render_state *render_state = &i965->render_state; +- struct intel_region *dest_region = render_state->draw_region; +- struct object_surface *obj_surface; +- float *vb; +- +- float u1, v1, u2, v2; +- int i, width, height; +- int box_x1 = dest_region->x + destx; +- int box_y1 = dest_region->y + desty; +- int box_x2 = box_x1 + destw; +- int box_y2 = box_y1 + desth; +- +- obj_surface = SURFACE(surface); +- assert(surface); +- width = obj_surface->width; +- height = obj_surface->height; +- +- u1 = (float)srcx / width; +- v1 = (float)srcy / height; +- u2 = (float)(srcx + srcw) / width; +- v2 = (float)(srcy + srch) / height; +- +- dri_bo_map(render_state->vb.vertex_buffer, 1); +- assert(render_state->vb.vertex_buffer->virtual); +- vb = render_state->vb.vertex_buffer->virtual; +- +- i = 0; +- vb[i++] = u2; +- vb[i++] = v2; +- vb[i++] = (float)box_x2; +- vb[i++] = (float)box_y2; +- +- vb[i++] = u1; +- vb[i++] = v2; +- vb[i++] = (float)box_x1; +- vb[i++] = (float)box_y2; +- +- vb[i++] = u1; +- vb[i++] = v1; +- vb[i++] = (float)box_x1; +- vb[i++] = (float)box_y1; ++ struct object_surface *obj_surface = SURFACE(surface); ++ assert(obj_surface); + +- dri_bo_unmap(render_state->vb.vertex_buffer); ++ return i965_render_do_upload_vertex(ctx, ++ obj_surface->width, obj_surface->height, ++ src_rect, ++ dst_rect, ++ cliprects, num_cliprects); + } + +-static void ++static unsigned int + i965_surface_render_state_setup(VADriverContextP ctx, +- VASurfaceID surface, +- short srcx, +- short srcy, +- unsigned short srcw, +- unsigned short srch, +- short destx, +- short desty, +- unsigned short destw, +- unsigned short desth) ++ VASurfaceID surface, ++ const VARectangle *src_rect, ++ const VARectangle *dst_rect, ++ const VARectangle *cliprects, ++ unsigned int num_cliprects) + { + i965_render_vs_unit(ctx); + i965_render_sf_unit(ctx); +@@ -923,21 +921,17 @@ i965_surface_render_state_setup(VADriverContextP ctx, + i965_render_cc_viewport(ctx); + i965_render_cc_unit(ctx); + i965_render_binding_table(ctx); +- i965_render_upload_vertex(ctx, surface, +- srcx, srcy, srcw, srch, +- destx, desty, destw, desth); ++ return i965_render_upload_vertex(ctx, surface, src_rect, dst_rect, ++ cliprects, num_cliprects); + } +-static void ++ ++static unsigned int + i965_subpic_render_state_setup(VADriverContextP ctx, +- VASurfaceID surface, +- short srcx, +- short srcy, +- unsigned short srcw, +- unsigned short srch, +- short destx, +- short desty, +- unsigned short destw, +- unsigned short desth) ++ VASurfaceID surface, ++ const VARectangle *src_rect, ++ const VARectangle *dst_rect, ++ const VARectangle *cliprects, ++ unsigned int num_cliprects) + { + i965_render_vs_unit(ctx); + i965_render_sf_unit(ctx); +@@ -948,16 +942,10 @@ i965_subpic_render_state_setup(VADriverContextP ctx, + i965_render_cc_viewport(ctx); + i965_subpic_render_cc_unit(ctx); + i965_render_binding_table(ctx); +- +- VARectangle output_rect; +- output_rect.x = destx; +- output_rect.y = desty; +- output_rect.width = destw; +- output_rect.height = desth; +- i965_subpic_render_upload_vertex(ctx, surface, &output_rect); ++ return i965_subpic_render_upload_vertex(ctx, surface, dst_rect, ++ cliprects, num_cliprects); + } + +- + static void + i965_render_pipeline_select(VADriverContextP ctx) + { +@@ -1193,7 +1181,7 @@ i965_render_upload_image_palette( + } + + static void +-i965_render_startup(VADriverContextP ctx) ++i965_render_startup(VADriverContextP ctx, unsigned int vb_offset) + { + struct i965_driver_data *i965 = i965_driver_data(ctx); + struct i965_render_state *render_state = &i965->render_state; +@@ -1204,7 +1192,7 @@ i965_render_startup(VADriverContextP ctx) + (0 << VB0_BUFFER_INDEX_SHIFT) | + VB0_VERTEXDATA | + ((4 * 4) << VB0_BUFFER_PITCH_SHIFT)); +- OUT_RELOC(ctx, render_state->vb.vertex_buffer, I915_GEM_DOMAIN_VERTEX, 0, 0); ++ OUT_RELOC(ctx, render_state->vb.vertex_buffer, I915_GEM_DOMAIN_VERTEX, 0, vb_offset); + + if (IS_IGDNG(i965->intel.device_id)) + OUT_RELOC(ctx, render_state->vb.vertex_buffer, I915_GEM_DOMAIN_VERTEX, 0, 12 * 4); +@@ -1269,8 +1257,10 @@ i965_clear_dest_region(VADriverContextP ctx) + } + + static void +-i965_surface_render_pipeline_setup(VADriverContextP ctx) ++i965_surface_render_pipeline_setup(VADriverContextP ctx, unsigned int n_rects) + { ++ unsigned int i; ++ + intel_batchbuffer_start_atomic(ctx, 0x1000); + intel_batchbuffer_emit_mi_flush(ctx); + i965_clear_dest_region(ctx); +@@ -1284,13 +1274,16 @@ i965_surface_render_pipeline_setup(VADriverContextP ctx) + i965_render_cs_urb_layout(ctx); + i965_render_drawing_rectangle(ctx); + i965_render_vertex_elements(ctx); +- i965_render_startup(ctx); ++ for (i = 0; i < n_rects; i++) ++ i965_render_startup(ctx, 48 * i); + intel_batchbuffer_end_atomic(ctx); + } + + static void +-i965_subpic_render_pipeline_setup(VADriverContextP ctx) ++i965_subpic_render_pipeline_setup(VADriverContextP ctx, unsigned int n_rects) + { ++ unsigned int i; ++ + intel_batchbuffer_start_atomic(ctx, 0x1000); + intel_batchbuffer_emit_mi_flush(ctx); + i965_render_pipeline_select(ctx); +@@ -1303,7 +1296,8 @@ i965_subpic_render_pipeline_setup(VADriverContextP ctx) + i965_render_cs_urb_layout(ctx); + i965_render_drawing_rectangle(ctx); + i965_render_vertex_elements(ctx); +- i965_render_startup(ctx); ++ for (i = 0; i < n_rects; i++) ++ i965_render_startup(ctx, 48 * i); + intel_batchbuffer_end_atomic(ctx); + } + +@@ -1397,45 +1391,39 @@ i965_render_initialize(VADriverContextP ctx) + void + i965_render_put_surface(VADriverContextP ctx, + VASurfaceID surface, +- short srcx, +- short srcy, +- unsigned short srcw, +- unsigned short srch, +- short destx, +- short desty, +- unsigned short destw, +- unsigned short desth) ++ const VARectangle *src_rect, ++ const VARectangle *dst_rect, ++ const VARectangle *cliprects, ++ unsigned int num_cliprects) + { ++ unsigned int n_rects; ++ + i965_render_initialize(ctx); +- i965_surface_render_state_setup(ctx, surface, +- srcx, srcy, srcw, srch, +- destx, desty, destw, desth); +- i965_surface_render_pipeline_setup(ctx); ++ n_rects = i965_surface_render_state_setup(ctx, surface, ++ src_rect, dst_rect, ++ cliprects, num_cliprects); ++ i965_surface_render_pipeline_setup(ctx, n_rects); + intel_batchbuffer_flush(ctx); + } + + void + i965_render_put_subpic(VADriverContextP ctx, +- VASurfaceID surface, +- short srcx, +- short srcy, +- unsigned short srcw, +- unsigned short srch, +- short destx, +- short desty, +- unsigned short destw, +- unsigned short desth) ++ VASurfaceID surface, ++ const VARectangle *src_rect, ++ const VARectangle *dst_rect, ++ const VARectangle *cliprects, ++ unsigned int num_cliprects) + { + struct i965_driver_data *i965 = i965_driver_data(ctx); + struct object_surface *obj_surface = SURFACE(surface); + struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic); ++ unsigned int n_rects; + assert(obj_subpic); + + i965_render_initialize(ctx); +- i965_subpic_render_state_setup(ctx, surface, +- srcx, srcy, srcw, srch, +- destx, desty, destw, desth); +- i965_subpic_render_pipeline_setup(ctx); ++ n_rects = i965_subpic_render_state_setup(ctx, surface, src_rect, dst_rect, ++ cliprects, num_cliprects); ++ i965_subpic_render_pipeline_setup(ctx, n_rects); + i965_render_upload_image_palette(ctx, obj_subpic->image, 0xff); + intel_batchbuffer_flush(ctx); + } +diff --git a/i965_drv_video/i965_render.h b/i965_drv_video/i965_render.h +index e3dce02..d2e23f1 100644 +--- a/i965_drv_video/i965_render.h ++++ b/i965_drv_video/i965_render.h +@@ -28,6 +28,7 @@ + #ifndef _I965_RENDER_H_ + #define _I965_RENDER_H_ + ++#define MAX_CLIP_RECTS 80 /* vb_bo:4096 / vb:(3*4*4) */ + #define MAX_RENDER_SURFACES 16 + #define MAX_SAMPLERS 16 + +@@ -65,27 +66,20 @@ struct i965_render_state + + Bool i965_render_init(VADriverContextP ctx); + Bool i965_render_terminate(VADriverContextP ctx); ++ + void i965_render_put_surface(VADriverContextP ctx, + VASurfaceID surface, +- short srcx, +- short srcy, +- unsigned short srcw, +- unsigned short srch, +- short destx, +- short desty, +- unsigned short destw, +- unsigned short desth); +- ++ const VARectangle *src_rect, ++ const VARectangle *dst_rect, ++ const VARectangle *cliprects, ++ unsigned int num_cliprects); + + void + i965_render_put_subpic(VADriverContextP ctx, +- VASurfaceID surface, +- short srcx, +- short srcy, +- unsigned short srcw, +- unsigned short srch, +- short destx, +- short desty, +- unsigned short destw, +- unsigned short desth); ++ VASurfaceID surface, ++ const VARectangle *src_rect, ++ const VARectangle *dst_rect, ++ const VARectangle *cliprects, ++ unsigned int num_cliprects); ++ + #endif /* _I965_RENDER_H_ */ diff -Nru libva-0.31.0+latest2/debian/patches/039_g45_add_vaDeriveImage.patch libva-0.31.0+latest3/debian/patches/039_g45_add_vaDeriveImage.patch --- libva-0.31.0+latest2/debian/patches/039_g45_add_vaDeriveImage.patch 1970-01-01 01:00:00.000000000 +0100 +++ libva-0.31.0+latest3/debian/patches/039_g45_add_vaDeriveImage.patch 2010-04-18 14:36:16.000000000 +0100 @@ -0,0 +1,305 @@ +commit 1eb1e3e56d3c7a83aea7361a02167d382619fea8 +Author: Gwenole Beauchesne +Date: Mon Mar 8 17:22:06 2010 +0100 + + [G45] Implement vaDeriveImage(). + +diff --git a/i965_drv_video/i965_drv_video.c b/i965_drv_video/i965_drv_video.c +index eb3b49d..98a824f 100644 +--- a/i965_drv_video/i965_drv_video.c ++++ b/i965_drv_video/i965_drv_video.c +@@ -336,12 +336,27 @@ VAStatus i965_QueryConfigAttributes(VADriverContextP ctx, + return vaStatus; + } + ++static struct object_image * ++i965_CreateImage_impl( ++ VADriverContextP ctx, ++ const VAImageFormat *format, ++ unsigned int width, ++ unsigned int height, ++ VASurfaceID surface ++); ++ ++static void ++i965_DestroyImage_impl( ++ VADriverContextP ctx, ++ struct object_image *obj_image, ++ int from_surface ++); ++ + 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); + } +@@ -358,6 +373,13 @@ i965_CreateSurfaces(VADriverContextP ctx, + int i; + VAStatus vaStatus = VA_STATUS_SUCCESS; + ++ /* Internal format: linear I420 (compatible with YV12 VA image) */ ++ static const VAImageFormat vaFormat = { ++ .fourcc = VA_FOURCC('Y','V','1','2'), ++ .byte_order = VA_LSB_FIRST, ++ .bits_per_pixel = 12 ++ }; ++ + /* We only support one format */ + if (VA_RT_FORMAT_YUV420 != format) { + return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT; +@@ -366,28 +388,36 @@ i965_CreateSurfaces(VADriverContextP ctx, + for (i = 0; i < num_surfaces; i++) { + int surfaceID = NEW_SURFACE_ID(); + struct object_surface *obj_surface = SURFACE(surfaceID); ++ struct object_image *obj_image; ++ struct object_buffer *obj_buffer; + + if (NULL == obj_surface) { + vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; + break; + } + ++ obj_image = i965_CreateImage_impl(ctx, &vaFormat, width, height, surfaceID); ++ if (!obj_image) { ++ vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; ++ break; ++ } ++ ++ obj_buffer = BUFFER(obj_image->image.buf); ++ if (!obj_buffer) { ++ vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; ++ break; ++ } ++ assert(obj_buffer->buffer_store); ++ + 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; +- } ++ obj_surface->image = obj_image->image; ++ obj_surface->is_derived = 0; ++ obj_surface->bo = obj_buffer->buffer_store->bo; + } + + /* Error recovery */ +@@ -417,6 +447,7 @@ i965_DestroySurfaces(VADriverContextP ctx, + struct object_surface *obj_surface = SURFACE(surface_list[i]); + + assert(obj_surface); ++ i965_DestroyImage_impl(ctx, IMAGE(obj_surface->image.image_id), 1); + i965_destroy_surface(&i965->surface_heap, (struct object_base *)obj_surface); + } + +@@ -1200,29 +1231,28 @@ i965_destroy_heap(struct object_heap *heap, + VAStatus + i965_DestroyImage(VADriverContextP ctx, VAImageID image); + +-VAStatus +-i965_CreateImage(VADriverContextP ctx, +- VAImageFormat *format, +- int width, +- int height, +- VAImage *out_image) /* out */ ++static struct object_image * ++i965_CreateImage_impl( ++ VADriverContextP ctx, ++ const VAImageFormat *format, ++ unsigned int width, ++ unsigned int height, ++ VASurfaceID surface ++) + { + 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; ++ return NULL; + + obj_image = IMAGE(image_id); + if (!obj_image) +- return VA_STATUS_ERROR_ALLOCATION_FAILED; ++ return NULL; ++ obj_image->surface = surface; + obj_image->bo = NULL; + obj_image->palette = NULL; + +@@ -1275,9 +1305,9 @@ i965_CreateImage(VADriverContextP ctx, + goto error; + } + +- va_status = i965_CreateBuffer(ctx, 0, VAImageBufferType, +- image->data_size, 1, NULL, &image->buf); +- if (va_status != VA_STATUS_SUCCESS) ++ if (i965_CreateBuffer(ctx, 0, VAImageBufferType, ++ image->data_size, 1, NULL, ++ &image->buf) != VA_STATUS_SUCCESS) + goto error; + + obj_image->bo = BUFFER(image->buf)->buffer_store->bo; +@@ -1292,21 +1322,47 @@ i965_CreateImage(VADriverContextP ctx, + image->format = *format; + image->width = width; + image->height = height; +- +- *out_image = *image; +- return VA_STATUS_SUCCESS; ++ return obj_image; + + error: +- i965_DestroyImage(ctx, image_id); +- return va_status; ++ i965_DestroyImage_impl(ctx, obj_image, 0); ++ return NULL; ++} ++ ++VAStatus ++i965_CreateImage(VADriverContextP ctx, ++ VAImageFormat *format, ++ int width, ++ int height, ++ VAImage *out_image) /* out */ ++{ ++ struct object_image *obj_image; ++ ++ obj_image = i965_CreateImage_impl(ctx, format, width, height, VA_INVALID_ID); ++ if (!obj_image) ++ return VA_STATUS_ERROR_ALLOCATION_FAILED; ++ ++ *out_image = obj_image->image; ++ return VA_STATUS_SUCCESS; + } + + VAStatus i965_DeriveImage(VADriverContextP ctx, + VASurfaceID surface, + VAImage *image) /* out */ + { +- /* TODO */ +- return VA_STATUS_ERROR_OPERATION_FAILED; ++ struct i965_driver_data *i965 = i965_driver_data(ctx); ++ ++ struct object_surface *obj_surface = SURFACE(surface); ++ if (!obj_surface) ++ return VA_STATUS_ERROR_INVALID_SURFACE; ++ ++ struct object_image *obj_image = IMAGE(obj_surface->image.image_id); ++ if (!obj_image) ++ return VA_STATUS_ERROR_INVALID_IMAGE; ++ ++ obj_surface->is_derived = 1; ++ *image = obj_surface->image; ++ return VA_STATUS_SUCCESS; + } + + static void +@@ -1315,15 +1371,24 @@ i965_destroy_image(struct object_heap *heap, struct object_base *obj) + object_heap_free(heap, obj); + } + +- +-VAStatus +-i965_DestroyImage(VADriverContextP ctx, VAImageID image) ++static void ++i965_DestroyImage_impl( ++ VADriverContextP ctx, ++ struct object_image *obj_image, ++ int from_surface ++) + { +- struct i965_driver_data *i965 = i965_driver_data(ctx); +- struct object_image *obj_image = IMAGE(image); ++ struct i965_driver_data * const i965 = i965_driver_data(ctx); + + if (!obj_image) +- return VA_STATUS_SUCCESS; ++ return; ++ ++ if (!from_surface && obj_image->surface != VA_INVALID_ID) { ++ /* only destroy when called from vaDestroySurfaces() */ ++ struct object_surface *obj_surface = SURFACE(obj_image->surface); ++ obj_surface->is_derived = 0; ++ return; ++ } + + if (obj_image->image.buf != VA_INVALID_ID) { + i965_DestroyBuffer(ctx, obj_image->image.buf); +@@ -1336,6 +1401,15 @@ i965_DestroyImage(VADriverContextP ctx, VAImageID image) + } + + i965_destroy_image(&i965->image_heap, (struct object_base *)obj_image); ++} ++ ++VAStatus ++i965_DestroyImage(VADriverContextP ctx, VAImageID image) ++{ ++ struct i965_driver_data *i965 = i965_driver_data(ctx); ++ struct object_image *obj_image = IMAGE(image); ++ ++ i965_DestroyImage_impl(ctx, obj_image, 0); + + return VA_STATUS_SUCCESS; + } +@@ -1382,6 +1456,9 @@ i965_GetImage(VADriverContextP ctx, + if (!obj_surface) + return VA_STATUS_ERROR_INVALID_SURFACE; + ++ if (obj_surface->is_derived) ++ return VA_STATUS_ERROR_SURFACE_BUSY; ++ + struct object_image *obj_image = IMAGE(image); + if (!obj_image) + return VA_STATUS_ERROR_INVALID_IMAGE; +@@ -1441,6 +1518,9 @@ i965_PutImage(VADriverContextP ctx, + if (!obj_surface) + return VA_STATUS_ERROR_INVALID_SURFACE; + ++ if (obj_surface->is_derived) ++ return VA_STATUS_ERROR_SURFACE_BUSY; ++ + struct object_image *obj_image = IMAGE(image); + if (!obj_image) + return VA_STATUS_ERROR_INVALID_IMAGE; +diff --git a/i965_drv_video/i965_drv_video.h b/i965_drv_video/i965_drv_video.h +index be253ed..7f410ab 100644 +--- a/i965_drv_video/i965_drv_video.h ++++ b/i965_drv_video/i965_drv_video.h +@@ -96,6 +96,8 @@ struct object_surface + int width; + int height; + int size; ++ VAImage image; ++ int is_derived; + dri_bo *bo; + }; + +@@ -113,6 +115,7 @@ struct object_image + { + struct object_base base; + VAImage image; ++ VASurfaceID surface; + dri_bo *bo; + unsigned int *palette; + }; diff -Nru libva-0.31.0+latest2/debian/patches/040_g45_add_i420_image_format.patch libva-0.31.0+latest3/debian/patches/040_g45_add_i420_image_format.patch --- libva-0.31.0+latest2/debian/patches/040_g45_add_i420_image_format.patch 1970-01-01 01:00:00.000000000 +0100 +++ libva-0.31.0+latest3/debian/patches/040_g45_add_i420_image_format.patch 2010-04-18 14:36:16.000000000 +0100 @@ -0,0 +1,69 @@ +commit 0b18b60ccc4df5e2dc30ad301451c3bd8b55b49d +Author: Gwenole Beauchesne +Date: Thu Mar 18 12:25:20 2010 +0100 + + [G45] Add I420 image format. + +diff --git a/i965_drv_video/i965_drv_video.c b/i965_drv_video/i965_drv_video.c +index 98a824f..7b3a206 100644 +--- a/i965_drv_video/i965_drv_video.c ++++ b/i965_drv_video/i965_drv_video.c +@@ -64,6 +64,8 @@ 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, } }, ++ { I965_SURFACETYPE_YUV, ++ { VA_FOURCC('I','4','2','0'), VA_LSB_FIRST, 12, } }, + }; + + static const i965_image_format_map_t * +@@ -1301,6 +1303,16 @@ i965_CreateImage_impl( + image->offsets[2] = size; + image->data_size = size + 2 * size2; + break; ++ case VA_FOURCC('I','4','2','0'): ++ 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; + } +@@ -1485,7 +1497,8 @@ i965_GetImage(VADriverContextP ctx, + dri_bo_map(obj_surface->bo, 0); + + switch (obj_image->image.format.fourcc) { +- case VA_FOURCC('Y','V','1','2'): /* YV12 is native format here */ ++ case VA_FOURCC('Y','V','1','2'): ++ case VA_FOURCC('I','4','2','0'): /* I420 is native format here */ + memcpy(image_data, obj_surface->bo->virtual, obj_surface->bo->size); + break; + default: +@@ -1550,7 +1563,8 @@ i965_PutImage(VADriverContextP ctx, + dri_bo_map(obj_surface->bo, 1); + + switch (obj_image->image.format.fourcc) { +- case VA_FOURCC('Y','V','1','2'): /* YV12 is native format here */ ++ case VA_FOURCC('Y','V','1','2'): ++ case VA_FOURCC('I','4','2','0'): /* I420 is native format here */ + memcpy(obj_surface->bo->virtual, image_data, obj_surface->bo->size); + break; + default: +diff --git a/i965_drv_video/i965_drv_video.h b/i965_drv_video/i965_drv_video.h +index 7f410ab..9e5707b 100644 +--- a/i965_drv_video/i965_drv_video.h ++++ b/i965_drv_video/i965_drv_video.h +@@ -43,7 +43,7 @@ + #define I965_MAX_PROFILES 11 + #define I965_MAX_ENTRYPOINTS 5 + #define I965_MAX_CONFIG_ATTRIBUTES 10 +-#define I965_MAX_IMAGE_FORMATS 1 ++#define I965_MAX_IMAGE_FORMATS 2 + #define I965_MAX_SUBPIC_FORMATS 4 + #define I965_MAX_DISPLAY_ATTRIBUTES 4 + #define I965_STR_VENDOR "i965 Driver 0.1" diff -Nru libva-0.31.0+latest2/debian/patches/103_fix_vainfo_deps.patch libva-0.31.0+latest3/debian/patches/103_fix_vainfo_deps.patch --- libva-0.31.0+latest2/debian/patches/103_fix_vainfo_deps.patch 1970-01-01 01:00:00.000000000 +0100 +++ libva-0.31.0+latest3/debian/patches/103_fix_vainfo_deps.patch 2010-04-18 14:36:16.000000000 +0100 @@ -0,0 +1,22 @@ +commit a07468c4f0e30b5f207a2bdf1b362f5584d748a7 +Author: Gwenole Beauchesne +Date: Tue Sep 22 12:29:56 2009 +0000 + + Fix vainfo dependencies (Konstantin Pavlov). + +diff --git a/test/Makefile.am b/test/Makefile.am +index d7e1b1f..8785259 100644 +--- a/test/Makefile.am ++++ b/test/Makefile.am +@@ -25,9 +25,8 @@ bin_PROGRAMS = vainfo + + AM_CFLAGS = -I$(top_srcdir)/va -I$(top_srcdir)/test/basic -I$(top_srcdir)/src/x11 + +- +-vainfo_LDADD = $(top_srcdir)/va/$(libvabackendlib) +-vainfo_DEPENDENCIES = $(top_srcdir)/va/$(libvabackendlib) ++vainfo_LDADD = $(top_srcdir)/va/libva.la $(top_srcdir)/va/$(libvabackendlib) ++vainfo_DEPENDENCIES = $(top_srcdir)/va/libva.la $(top_srcdir)/va/$(libvabackendlib) + vainfo_SOURCES = vainfo.c + + SUBDIRS = basic decode encode putsurface diff -Nru libva-0.31.0+latest2/debian/patches/104_fix_libva_pkgconfig_deps.patch libva-0.31.0+latest3/debian/patches/104_fix_libva_pkgconfig_deps.patch --- libva-0.31.0+latest2/debian/patches/104_fix_libva_pkgconfig_deps.patch 1970-01-01 01:00:00.000000000 +0100 +++ libva-0.31.0+latest3/debian/patches/104_fix_libva_pkgconfig_deps.patch 2010-04-18 14:36:16.000000000 +0100 @@ -0,0 +1,18 @@ +commit 5f1314d188c4ecc2e0d5be54bcd663013e8b0077 +Author: Gwenole Beauchesne +Date: Tue Sep 22 13:00:34 2009 +0000 + + Fix libva-x11 dependencies. Ensure this grabs libva so that people don't have to check for that themselves. + +diff --git a/libva-x11.pc.in b/libva-x11.pc.in +index 75e4f0b..6dde07f 100644 +--- a/libva-x11.pc.in ++++ b/libva-x11.pc.in +@@ -6,6 +6,7 @@ display=x11 + + Name: libva-${display} + Description: Userspace Video Acceleration (VA) ${display} interface ++Requires: libva + Version: @PACKAGE_VERSION@ + Libs: -L${libdir} -lva-${display} + Cflags: -I${includedir} diff -Nru libva-0.31.0+latest2/debian/patches/105_dont_search_LIBGL_DRIVERS_PATH.patch libva-0.31.0+latest3/debian/patches/105_dont_search_LIBGL_DRIVERS_PATH.patch --- libva-0.31.0+latest2/debian/patches/105_dont_search_LIBGL_DRIVERS_PATH.patch 1970-01-01 01:00:00.000000000 +0100 +++ libva-0.31.0+latest3/debian/patches/105_dont_search_LIBGL_DRIVERS_PATH.patch 2010-04-18 14:36:16.000000000 +0100 @@ -0,0 +1,21 @@ +commit ecc7b5f332674ee57ad11a0d6bb58a252549c762 +Author: Gwenole Beauchesne +Date: Tue Sep 22 13:03:23 2009 +0000 + + Don't search LIBGL_DRIVERS_PATH, stick to LIBVA_DRIVERS_PATH only or the default path. + +diff --git a/va/va.c b/va/va.c +index c8e036e..ada70ce 100644 +--- a/va/va.c ++++ b/va/va.c +@@ -127,10 +127,6 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name) + { + /* don't allow setuid apps to use LIBVA_DRIVERS_PATH */ + search_path = getenv("LIBVA_DRIVERS_PATH"); +- if (!search_path) +- { +- search_path = getenv("LIBGL_DRIVERS_PATH"); +- } + } + if (!search_path) + { diff -Nru libva-0.31.0+latest2/debian/patches/108_drivers_path.patch libva-0.31.0+latest3/debian/patches/108_drivers_path.patch --- libva-0.31.0+latest2/debian/patches/108_drivers_path.patch 1970-01-01 01:00:00.000000000 +0100 +++ libva-0.31.0+latest3/debian/patches/108_drivers_path.patch 2010-04-18 14:36:16.000000000 +0100 @@ -0,0 +1,19 @@ +commit 43becedcfa2b9b040006868a63c686a131c9ba74 +Author: Gwenole Beauchesne +Date: Wed Jun 24 08:12:13 2009 +0000 + + Install drivers into pkglibdir/va/. + +diff --git a/configure.ac b/configure.ac +index f2d0ea4..ebe5df6 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -73,7 +73,7 @@ AC_ARG_ENABLE(i965-driver, + + AC_ARG_WITH(drivers-path, + [AC_HELP_STRING([--with-drivers-path=[[path]]], [drivers path])],, +- [with_drivers_path="$libdir/dri"]) ++ [with_drivers_path="$libdir/va/drivers"]) + + LIBVA_DRIVERS_PATH="$with_drivers_path" + AC_SUBST(LIBVA_DRIVERS_PATH) diff -Nru libva-0.31.0+latest2/debian/patches/201_libva_LIBVA_DRIVER_NAME.patch libva-0.31.0+latest3/debian/patches/201_libva_LIBVA_DRIVER_NAME.patch --- libva-0.31.0+latest2/debian/patches/201_libva_LIBVA_DRIVER_NAME.patch 1970-01-01 01:00:00.000000000 +0100 +++ libva-0.31.0+latest3/debian/patches/201_libva_LIBVA_DRIVER_NAME.patch 2010-04-18 14:36:16.000000000 +0100 @@ -0,0 +1,97 @@ +commit 1f9ee94ab4ac60459048bef5a2aa348cdf88c390 +Author: Gwenole Beauchesne +Date: Tue Feb 23 09:11:22 2010 +0000 + + Move LIBVA_DRIVER_NAME check in vaInitialize(). + +diff --git a/va/va.c b/va/va.c +index ada70ce..b5940e5 100644 +--- a/va/va.c ++++ b/va/va.c +@@ -320,30 +320,42 @@ VAStatus vaInitialize ( + int *minor_version /* out */ + ) + { +- char *driver_name = NULL; +- VAStatus vaStatus; +- +- CHECK_DISPLAY(dpy); ++ const char *driver_name_env = NULL; ++ char *driver_name = NULL; ++ VAStatus vaStatus; + +- va_debug_trace = (getenv("LIBVA_DEBUG_TRACE") != NULL); ++ CHECK_DISPLAY(dpy); + +- va_infoMessage("libva version %s\n", VA_VERSION_S); ++ va_debug_trace = (getenv("LIBVA_DEBUG_TRACE") != NULL); + +- 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; +- } ++ va_infoMessage("libva version %s\n", VA_VERSION_S); + +- if (driver_name) +- free(driver_name); +- return vaStatus; ++ driver_name_env = getenv("LIBVA_DRIVER_NAME"); ++ if (driver_name_env && geteuid() == getuid()) ++ { ++ /* Don't allow setuid apps to use LIBVA_DRIVER_NAME */ ++ driver_name = strdup(driver_name_env); ++ vaStatus = VA_STATUS_SUCCESS; ++ va_infoMessage("User requested driver '%s'\n", driver_name); ++ } ++ else ++ { ++ 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; + } + + +diff --git a/va/x11/va_x11.c b/va/x11/va_x11.c +index 29e81c8..78e38de 100644 +--- a/va/x11/va_x11.c ++++ b/va/x11/va_x11.c +@@ -136,19 +136,10 @@ static VAStatus va_DisplayContextGetDriverName ( + ) + { + 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); diff -Nru libva-0.31.0+latest2/debian/patches/202_check_crystalhd.patch libva-0.31.0+latest3/debian/patches/202_check_crystalhd.patch --- libva-0.31.0+latest2/debian/patches/202_check_crystalhd.patch 1970-01-01 01:00:00.000000000 +0100 +++ libva-0.31.0+latest3/debian/patches/202_check_crystalhd.patch 2010-04-18 14:36:16.000000000 +0100 @@ -0,0 +1,155 @@ +commit 0eeee71bcd334512a6b86702ee612b35feb644b2 +Author: Gwenole Beauchesne +Date: Tue Feb 23 10:05:25 2010 +0000 + + Detect Broadcom Crystal HD chip. + +diff --git a/va/Makefile.am b/va/Makefile.am +index aeaf82f..f382c0e 100644 +--- a/va/Makefile.am ++++ b/va/Makefile.am +@@ -42,7 +42,7 @@ libva_x11_la_DEPENDENCIES = $(libvacorelib) x11/libva_x11.la + + SUBDIRS = x11 + +-libva_la_SOURCES = va.c ++libva_la_SOURCES = va.c va_crystalhd.c + + libvaincludedir = ${includedir}/va + libvainclude_HEADERS = va.h va_x11.h va_backend.h va_version.h +@@ -51,4 +51,5 @@ DISTCLEANFILES = \ + va_version.h + + EXTRA_DIST = \ +- va_version.h.in ++ va_version.h.in \ ++ va_crystalhd.h +diff --git a/va/va.c b/va/va.c +index b5940e5..fd68481 100644 +--- a/va/va.c ++++ b/va/va.c +@@ -24,8 +24,10 @@ + + #define _GNU_SOURCE 1 + ++#include "config.h" + #include "va.h" + #include "va_backend.h" ++#include "va_crystalhd.h" + + #include + #include +@@ -349,6 +351,15 @@ VAStatus vaInitialize ( + vaStatus = va_openDriver(dpy, driver_name); + va_infoMessage("va_openDriver() returns %d\n", vaStatus); + ++ if (vaStatus != VA_STATUS_SUCCESS && !driver_name_env) ++ { ++ if (va_hasCrystalHD()) ++ { ++ vaStatus = va_openDriver(dpy, "crystalhd"); ++ va_infoMessage("va_openDriver() returns %d\n", vaStatus); ++ } ++ } ++ + *major_version = VA_MAJOR_VERSION; + *minor_version = VA_MINOR_VERSION; + } +diff --git a/va/va_crystalhd.c b/va/va_crystalhd.c +new file mode 100644 +index 0000000..1ddd4fe +--- /dev/null ++++ b/va/va_crystalhd.c +@@ -0,0 +1,54 @@ ++/* ++ * Copyright (C) 2010 Splitted-Desktop Systems. 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. ++ */ ++ ++#include ++#include ++#include ++#include "config.h" ++#include "va_crystalhd.h" ++ ++/* Checks if the Broadcom Crystal HD decoder is available */ ++int va_hasCrystalHD(void) ++{ ++ char line[1024]; ++ int len, vendor, device, dummy, found = 0; ++ FILE *fp; ++ ++ fp = fopen("/proc/bus/pci/devices", "r"); ++ if (!fp) ++ return 0; ++ ++ while (!found && fgets(line, sizeof(line), fp)) { ++ len = strlen(line); ++ if (len == 0) ++ continue; ++ line[len - 1] = 0; ++ if (sscanf(line, "%x %04x%04x", &dummy, &vendor, &device) == 3) { ++ if (vendor == 0x14e4 && device == 0x1612) /* BCM70012 */ ++ found = 1; ++ } ++ } ++ fclose(fp); ++ return found; ++} +diff --git a/va/va_crystalhd.h b/va/va_crystalhd.h +new file mode 100644 +index 0000000..44a39d9 +--- /dev/null ++++ b/va/va_crystalhd.h +@@ -0,0 +1,32 @@ ++/* ++ * Copyright (C) 2010 Splitted-Desktop Systems. 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. ++ */ ++ ++#ifndef VA_CRYSTALHD_H ++#define VA_CRYSTALHD_H ++ ++/** Checks if the Broadcom Crystal HD decoder is available */ ++int va_hasCrystalHD(void) ++ ATTRIBUTE_HIDDEN; ++ ++#endif /* VA_CRYSTALHD_H */ diff -Nru libva-0.31.0+latest2/debian/patches/203_fix_fglrx_detection.patch libva-0.31.0+latest3/debian/patches/203_fix_fglrx_detection.patch --- libva-0.31.0+latest2/debian/patches/203_fix_fglrx_detection.patch 1970-01-01 01:00:00.000000000 +0100 +++ libva-0.31.0+latest3/debian/patches/203_fix_fglrx_detection.patch 2010-04-18 14:36:16.000000000 +0100 @@ -0,0 +1,538 @@ +commit 02c2bb46ae11a1674927e6e65f990df1dc9ed1ce +Author: Gwenole Beauchesne +Date: Mon Mar 8 09:17:09 2010 +0100 + + Don't link against libdrm to workaround XvBA / fglrx >= 8.66-RC1 bugs. + +diff --git a/va/Makefile.am b/va/Makefile.am +index f382c0e..3b9ccfc 100644 +--- a/va/Makefile.am ++++ b/va/Makefile.am +@@ -36,7 +36,7 @@ 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) $(DRM_LIBS) $(XFIXES_LIBS) ++libva_x11_la_LIBADD = $(libvacorelib) x11/libva_x11.la $(LIBVA_LIBS) $(X11_LIBS) $(XEXT_LIBS) $(XFIXES_LIBS) + libva_x11_la_LDFLAGS = $(LDADD) + libva_x11_la_DEPENDENCIES = $(libvacorelib) x11/libva_x11.la + +diff --git a/va/x11/Makefile.am b/va/x11/Makefile.am +index 40346f1..7466fda 100644 +--- a/va/x11/Makefile.am ++++ b/va/x11/Makefile.am +@@ -25,6 +25,6 @@ noinst_LTLIBRARIES = libva_x11.la + libva_x11includedir = ${includedir}/va + libva_x11include_HEADERS = va_dri.h va_dri2.h va_dricommon.h + +-libva_x11_la_SOURCES = va_x11.c va_dri.c va_dri2.c va_dricommon.c dri2_util.c dri1_util.c va_nvctrl.c ++libva_x11_la_SOURCES = va_x11.c va_dri.c va_dri2.c va_dricommon.c dri2_util.c dri1_util.c va_nvctrl.c libdrm_glue.c + +-EXTRA_DIST = va_dristr.h va_dri2str.h va_dri2tokens.h va_nvctrl.h ++EXTRA_DIST = va_dristr.h va_dri2str.h va_dri2tokens.h va_nvctrl.h libdrm_glue.h +diff --git a/va/x11/dri1_util.c b/va/x11/dri1_util.c +index 3e67e2a..f6ce1ba 100644 +--- a/va/x11/dri1_util.c ++++ b/va/x11/dri1_util.c +@@ -1,10 +1,13 @@ ++#include "config.h" ++#include + #include ++#include /* strcasecmp() */ + #include + #include + #include + #include + +-#include ++#include "libdrm_glue.h" + + #include "X11/Xlib.h" + #include "va.h" +@@ -21,6 +24,75 @@ struct dri1_drawable + int height; + }; + ++static int ++firegl_drmOpenMinor(int minor) ++{ ++ char buf[64]; ++ int fd; ++ ++ sprintf(buf, "/dev/ati/card%d", minor); ++ if ((fd = open(buf, O_RDWR, 0)) >= 0) ++ return fd; ++ return -1; ++} ++ ++static int ++firegl_drmOpenByBusID(const char *busid) ++{ ++ int i, fd; ++ drmSetVersion sv; ++ const char *buf; ++ ++ for (i = 0; i < DRM_MAX_MINOR; i++) { ++ if ((fd = firegl_drmOpenMinor(i)) < 0) ++ continue; ++ sv.drm_di_major = 1; ++ sv.drm_di_minor = 1; ++ sv.drm_dd_major = -1; ++ sv.drm_dd_minor = -1; ++ libdrm_drmSetInterfaceVersion(fd, &sv); ++ buf = libdrm_drmGetBusid(fd); ++ if (buf && strcasecmp(buf, busid) == 0) { /* XXX: drmMatchBusID() */ ++ libdrm_drmFreeBusid(buf); ++ return fd; ++ } ++ if (buf) ++ libdrm_drmFreeBusid(buf); ++ close(fd); ++ } ++ return -1; ++} ++ ++static int ++drm_open_once(struct dri_state *dri_state, const char *BusID, int *newlyopened) ++{ ++ dri_state->driConnectedFlag = VA_NONE; ++ dri_state->fd = libdrm_drmOpenOnce(NULL, BusID, newlyopened); ++ if (dri_state->fd < 0) { ++ dri_state->fd = firegl_drmOpenByBusID(BusID); ++ if (dri_state->fd >= 0) { ++ *newlyopened = 1; ++ dri_state->driConnectedFlag |= VA_DRI_AMD; ++ } ++ } ++ return dri_state->fd; ++} ++ ++static void ++drm_close_once(struct dri_state *dri_state) ++{ ++ /* XXX: dri_state->close() doesn't seem to be called, thus this ++ function is never called either */ ++ if (dri_state->fd < 0) ++ return; ++ if (dri_state->driConnectedFlag & VA_DRI_AMD) ++ close(dri_state->fd); ++ else ++ libdrm_drmCloseOnce(dri_state->fd); ++ dri_state->fd = -1; ++ dri_state->driConnectedFlag = VA_NONE; ++} ++ + static struct dri_drawable * + dri1CreateDrawable(VADriverContextP ctx, XID x_drawable) + { +@@ -64,9 +136,9 @@ dri1Close(VADriverContextP ctx) + 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); ++ libdrm_drmUnmap(dri_state->pSAREA, SAREA_MAX); + assert(dri_state->fd >= 0); +- drmCloseOnce(dri_state->fd); ++ drm_close_once(dri_state); + VA_DRICloseConnection(ctx->x11_dpy, ctx->x11_screen); + } + +@@ -104,21 +176,20 @@ isDRI1Connected(VADriverContextP ctx, char **driver_name) + &dri_state->hSAREA, &BusID)) + goto err_out0; + +- +- dri_state->fd = drmOpenOnce(NULL, BusID, &newlyopened); ++ drm_open_once(dri_state, BusID, &newlyopened); + XFree(BusID); + + if (dri_state->fd < 0) + goto err_out1; + + +- if (drmGetMagic(dri_state->fd, &magic)) ++ if (libdrm_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)) ++ if (libdrm_drmMap(dri_state->fd, dri_state->hSAREA, SAREA_MAX, &dri_state->pSAREA)) + goto err_out1; + + if (!VA_DRICreateContext(ctx->x11_dpy, ctx->x11_screen, +@@ -126,7 +197,8 @@ isDRI1Connected(VADriverContextP ctx, char **driver_name) + &dri_state->hwContextID, &dri_state->hwContext)) + goto err_out1; + +- dri_state->driConnectedFlag = VA_DRI1; ++ dri_state->driConnectedFlag &= VA_DRI_AMD; /* clear flags but AMD bit */ ++ dri_state->driConnectedFlag |= VA_DRI1; + dri_state->createDrawable = dri1CreateDrawable; + dri_state->destroyDrawable = dri1DestroyDrawable; + dri_state->swapBuffer = dri1SwapBuffer; +@@ -137,10 +209,10 @@ isDRI1Connected(VADriverContextP ctx, char **driver_name) + + err_out1: + if (dri_state->pSAREA != MAP_FAILED) +- drmUnmap(dri_state->pSAREA, SAREA_MAX); ++ libdrm_drmUnmap(dri_state->pSAREA, SAREA_MAX); + + if (dri_state->fd >= 0) +- drmCloseOnce(dri_state->fd); ++ drm_close_once(dri_state); + + VA_DRICloseConnection(ctx->x11_dpy, ctx->x11_screen); + +diff --git a/va/x11/dri2_util.c b/va/x11/dri2_util.c +index ebe7a2c..b727e97 100644 +--- a/va/x11/dri2_util.c ++++ b/va/x11/dri2_util.c +@@ -3,7 +3,7 @@ + #include + #include + +-#include ++#include "libdrm_glue.h" + + #include + #include +@@ -166,7 +166,7 @@ isDRI2Connected(VADriverContextP ctx, char **driver_name) + if (dri_state->fd < 0) + goto err_out; + +- if (drmGetMagic(dri_state->fd, &magic)) ++ if (libdrm_drmGetMagic(dri_state->fd, &magic)) + goto err_out; + + if (!VA_DRI2Authenticate(ctx->x11_dpy, RootWindow(ctx->x11_dpy, ctx->x11_screen), +diff --git a/va/x11/libdrm_glue.c b/va/x11/libdrm_glue.c +new file mode 100644 +index 0000000..92c7d60 +--- /dev/null ++++ b/va/x11/libdrm_glue.c +@@ -0,0 +1,209 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. 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 "libdrm_glue.h" ++#include ++#include ++#include ++#include ++#include ++ ++#define LOAD_FUNC_(NAME, RET, ARGS, FALLBACK) \ ++ static RET (*lib_##NAME) ARGS; \ ++ if (lib_##NAME == NULL) { \ ++ lib_##NAME = libdrm_symbol(#NAME); \ ++ if (!lib_##NAME) \ ++ lib_##NAME = FALLBACK; \ ++ } \ ++ assert(lib_##NAME != NULL) ++ ++#define LOAD_FUNC(NAME, RET, ARGS) \ ++ LOAD_FUNC_(NAME, RET, ARGS, NULL) ++ ++static void *libdrm_handle; ++static int libdrm_handle_ok = -1; ++ ++static inline void *libdrm_symbol(const char *name) ++{ ++ if (!libdrm_open()) ++ return NULL; ++ return dlsym(libdrm_handle, name); ++} ++ ++int libdrm_open(void) ++{ ++ if (libdrm_handle_ok < 0) { ++ libdrm_handle = dlopen("libdrm.so.2", RTLD_LOCAL|RTLD_LAZY); ++ libdrm_handle_ok = libdrm_handle != NULL; ++ } ++ assert(libdrm_handle); ++ return libdrm_handle_ok; ++} ++ ++void libdrm_close(void) ++{ ++ if (libdrm_handle) ++ dlclose(libdrm_handle); ++} ++ ++// Default drmOpenOnce() and drmCloseOnce() implementations based on current GIT ++#define DRM_MAX_FDS 16 ++static struct { ++ char *BusID; ++ int fd; ++ int refcount; ++} connection[DRM_MAX_FDS]; ++ ++static int nr_fds = 0; ++ ++// Default implementation for drmOpenOnce() if none exists in the library ++static int ++libdrm_default_drmOpenOnce(void *unused, const char *BusID, int *newlyopened) ++{ ++ int i; ++ int fd; ++ ++ for (i = 0; i < nr_fds; i++) ++ if (strcmp(BusID, connection[i].BusID) == 0) { ++ connection[i].refcount++; ++ *newlyopened = 0; ++ return connection[i].fd; ++ } ++ ++ fd = libdrm_drmOpen(unused, BusID); ++ if (fd <= 0 || nr_fds == DRM_MAX_FDS) ++ return fd; ++ ++ connection[nr_fds].BusID = strdup(BusID); ++ connection[nr_fds].fd = fd; ++ connection[nr_fds].refcount = 1; ++ *newlyopened = 1; ++ ++ if (0) ++ fprintf(stderr, "saved connection %d for %s %d\n", ++ nr_fds, connection[nr_fds].BusID, ++ strcmp(BusID, connection[nr_fds].BusID)); ++ nr_fds++; ++ return fd; ++} ++ ++// Default implementation for drmCloseOnce() if none exists in the library ++static void libdrm_default_drmCloseOnce(int fd) ++{ ++ int i; ++ ++ for (i = 0; i < nr_fds; i++) { ++ if (fd == connection[i].fd) { ++ if (--connection[i].refcount == 0) { ++ libdrm_drmClose(connection[i].fd); ++ free(connection[i].BusID); ++ if (i < --nr_fds) ++ connection[i] = connection[nr_fds]; ++ return; ++ } ++ } ++ } ++} ++ ++// Determine whether the DRM kernel driver has been loaded ++int libdrm_drmAvailable(void) ++{ ++ LOAD_FUNC(drmAvailable, int, (void)); ++ return lib_drmAvailable(); ++} ++ ++// Open the DRM device ++int libdrm_drmOpen(const char *name, const char *busid) ++{ ++ LOAD_FUNC(drmOpen, int, (const char *, const char *)); ++ return lib_drmOpen(name, busid); ++} ++ ++// Close the device ++int libdrm_drmClose(int fd) ++{ ++ LOAD_FUNC(drmClose, int, (int)); ++ return lib_drmClose(fd); ++} ++ ++// Open the DRM device (re-use an existing connection) ++int libdrm_drmOpenOnce(void *unused, const char *BusID, int *newlyopened) ++{ ++ LOAD_FUNC_(drmOpenOnce, int, (void *, const char *, int *), ++ libdrm_default_drmOpenOnce); ++ return lib_drmOpenOnce(unused, BusID, newlyopened); ++} ++ ++// Close the device (unref an existing connection prior to actually closing it) ++void libdrm_drmCloseOnce(int fd) ++{ ++ LOAD_FUNC_(drmCloseOnce, void, (int), libdrm_default_drmCloseOnce); ++ lib_drmCloseOnce(fd); ++} ++ ++// DRM connection cookie ++int libdrm_drmGetMagic(int fd, drm_magic_t * magic) ++{ ++ LOAD_FUNC(drmGetMagic, int, (int, drm_magic_t *)); ++ return lib_drmGetMagic(fd, magic); ++} ++ ++// Issue a set-version ioctl ++int libdrm_drmSetInterfaceVersion(int fd, drmSetVersion *version) ++{ ++ LOAD_FUNC(drmSetInterfaceVersion, int, (int, drmSetVersion *)); ++ return lib_drmSetInterfaceVersion(fd, version); ++} ++ ++// Get the bus ID of the device ++char *libdrm_drmGetBusid(int fd) ++{ ++ LOAD_FUNC(drmGetBusid, char *, (int)); ++ return lib_drmGetBusid(fd); ++} ++ ++// Free the bus ID information ++void libdrm_drmFreeBusid(const char *busid) ++{ ++ LOAD_FUNC(drmFreeBusid, void, (const char *)); ++ lib_drmFreeBusid(busid); ++} ++ ++// Map a region of memory ++int libdrm_drmMap(int fd, ++ drm_handle_t handle, ++ drmSize size, ++ drmAddressPtr address) ++{ ++ LOAD_FUNC(drmMap, int, (int, drm_handle_t, drmSize, drmAddressPtr)); ++ return lib_drmMap(fd, handle, size, address); ++} ++ ++// Unmap mappings obtained with drmMap() ++int libdrm_drmUnmap(drmAddress address, drmSize size) ++{ ++ LOAD_FUNC(drmUnmap, int, (drmAddress, drmSize)); ++ return lib_drmUnmap(address, size); ++} +diff --git a/va/x11/libdrm_glue.h b/va/x11/libdrm_glue.h +new file mode 100644 +index 0000000..878470b +--- /dev/null ++++ b/va/x11/libdrm_glue.h +@@ -0,0 +1,73 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. 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. ++ */ ++ ++#ifndef LIBDRM_GLUE_H ++#define LIBDRM_GLUE_H ++ ++#include "config.h" ++#include ++ ++int libdrm_open(void) ++ ATTRIBUTE_HIDDEN; ++ ++void libdrm_close(void) ++ ATTRIBUTE_HIDDEN; ++ ++int libdrm_drmAvailable(void) ++ ATTRIBUTE_HIDDEN; ++ ++int libdrm_drmOpen(const char *name, const char *busid) ++ ATTRIBUTE_HIDDEN; ++ ++int libdrm_drmClose(int fd) ++ ATTRIBUTE_HIDDEN; ++ ++int libdrm_drmOpenOnce(void *unused, const char *BusID, int *newlyopened) ++ ATTRIBUTE_HIDDEN; ++ ++void libdrm_drmCloseOnce(int fd) ++ ATTRIBUTE_HIDDEN; ++ ++int libdrm_drmGetMagic(int fd, drm_magic_t * magic) ++ ATTRIBUTE_HIDDEN; ++ ++int libdrm_drmSetInterfaceVersion(int fd, drmSetVersion *version) ++ ATTRIBUTE_HIDDEN; ++ ++char *libdrm_drmGetBusid(int fd) ++ ATTRIBUTE_HIDDEN; ++ ++void libdrm_drmFreeBusid(const char *busid) ++ ATTRIBUTE_HIDDEN; ++ ++int libdrm_drmMap(int fd, ++ drm_handle_t handle, ++ drmSize size, ++ drmAddressPtr address) ++ ATTRIBUTE_HIDDEN; ++ ++int libdrm_drmUnmap(drmAddress address, drmSize size) ++ ATTRIBUTE_HIDDEN; ++ ++#endif /* LIBDRM_GLUE_H */ +diff --git a/va/x11/va_dricommon.h b/va/x11/va_dricommon.h +index b762bd0..5ed7a6a 100644 +--- a/va/x11/va_dricommon.h ++++ b/va/x11/va_dricommon.h +@@ -13,7 +13,8 @@ enum + { + VA_NONE = 0, + VA_DRI1 = 1, +- VA_DRI2 = 2 ++ VA_DRI2 = 2, ++ VA_DRI_AMD = 4 /* AMD DRI implementation */ + }; + + union dri_buffer +diff --git a/va/x11/va_x11.c b/va/x11/va_x11.c +index 78e38de..1216093 100644 +--- a/va/x11/va_x11.c ++++ b/va/x11/va_x11.c +@@ -31,6 +31,7 @@ + #include "va_dri2.h" + #include "va_dricommon.h" + #include "va_nvctrl.h" ++#include "libdrm_glue.h" + #include + #include + #include +@@ -75,6 +76,8 @@ static void va_DisplayContextDestroy ( + } + ctx = &((*ctx)->pNext); + } ++ ++ libdrm_close(); + free(pDisplayContext->pDriverContext->dri_state); + free(pDisplayContext->pDriverContext); + free(pDisplayContext); diff -Nru libva-0.31.0+latest2/debian/patches/204_check_ATIFGLEXTENSION.patch libva-0.31.0+latest3/debian/patches/204_check_ATIFGLEXTENSION.patch --- libva-0.31.0+latest2/debian/patches/204_check_ATIFGLEXTENSION.patch 1970-01-01 01:00:00.000000000 +0100 +++ libva-0.31.0+latest3/debian/patches/204_check_ATIFGLEXTENSION.patch 2010-04-18 14:36:16.000000000 +0100 @@ -0,0 +1,325 @@ +commit 595a044901ee32acc3212100966f5a1a9e181515 +Author: Gwenole Beauchesne +Date: Fri Nov 20 15:51:22 2009 +0000 + + Fix detection of fglrx. + +diff --git a/va/Makefile.am b/va/Makefile.am +index 3b9ccfc..99f6bbf 100644 +--- a/va/Makefile.am ++++ b/va/Makefile.am +@@ -36,7 +36,7 @@ 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) ++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 + +diff --git a/va/x11/Makefile.am b/va/x11/Makefile.am +index 7466fda..a6d9323 100644 +--- a/va/x11/Makefile.am ++++ b/va/x11/Makefile.am +@@ -25,6 +25,23 @@ noinst_LTLIBRARIES = libva_x11.la + libva_x11includedir = ${includedir}/va + libva_x11include_HEADERS = va_dri.h va_dri2.h va_dricommon.h + +-libva_x11_la_SOURCES = va_x11.c va_dri.c va_dri2.c va_dricommon.c dri2_util.c dri1_util.c va_nvctrl.c libdrm_glue.c ++libva_x11_la_SOURCES = \ ++ dri1_util.c \ ++ dri2_util.c \ ++ libdrm_glue.c \ ++ va_dri.c \ ++ va_dri2.c \ ++ va_dricommon.c \ ++ va_fglext.c \ ++ va_nvctrl.c \ ++ va_x11.c \ ++ $(NULL) + +-EXTRA_DIST = va_dristr.h va_dri2str.h va_dri2tokens.h va_nvctrl.h libdrm_glue.h ++EXTRA_DIST = \ ++ libdrm_glue.h \ ++ va_dri2str.h \ ++ va_dri2tokens.h \ ++ va_dristr.h \ ++ va_fglext.h \ ++ va_nvctrl.h \ ++ $(NULL) +diff --git a/va/x11/va_fglext.c b/va/x11/va_fglext.c +new file mode 100644 +index 0000000..add1f28 +--- /dev/null ++++ b/va/x11/va_fglext.c +@@ -0,0 +1,175 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. 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 ++ ++#define NEED_REPLIES ++#include ++#include ++#include ++#include ++#include ++#include "va_fglext.h" ++ ++#define ATIFGL_EXTENSION_NAME "ATIFGLEXTENSION" ++#define ATIFGL_EXTENSION_EVENTS 0 ++ ++typedef struct _FGLGetDriverData { ++ CARD8 reqType; ++ CARD8 fireglReqType; ++ CARD16 length B16; ++ CARD32 screen B32; ++ CARD16 size B16; ++ CARD16 pad1; ++} xFGLGetDriverDataReq; ++#define sz_xFGLGetDriverDataReq sizeof(xFGLGetDriverDataReq) ++ ++typedef struct { ++ BYTE type; ++ BYTE pad1; ++ CARD16 sequenceNumber B16; ++ CARD32 length B32; ++ CARD8 majorVersion; ++ CARD8 minorVersion; ++ CARD8 patchlevel B16; ++ CARD8 BIOSVersionMajor; ++ CARD8 BIOSVersionMinor; ++ CARD8 HasSecondary; ++ CARD16 pad3 B16; ++ CARD32 pad4 B32; ++ CARD32 pad5 B32; ++ CARD32 pad6 B32; ++ CARD32 pad7 B32; ++ // ... there are more fields ++} xFGLGetDriverDataReply; ++#define sz_xFGLGetDriverDataReply sizeof(xFGLGetDriverDataReply) ++ ++#define X_FGLGetDriverData 0 ++ ++static XExtensionInfo _fglext_ext_info_data; ++static XExtensionInfo *fglext_ext_info = &_fglext_ext_info_data; ++static /* const */ char *fglext_extension_name = ATIFGL_EXTENSION_NAME; ++ ++#define xFGLCheckExtension(dpy,i,val) \ ++ XextCheckExtension (dpy, i, fglext_extension_name, val) ++ ++static int close_display(); ++static /* const */ XExtensionHooks fglext_extension_hooks = { ++ NULL, /* create_gc */ ++ NULL, /* copy_gc */ ++ NULL, /* flush_gc */ ++ NULL, /* free_gc */ ++ NULL, /* create_font */ ++ NULL, /* free_font */ ++ close_display, /* close_display */ ++ NULL, /* wire_to_event */ ++ NULL, /* event_to_wire */ ++ NULL, /* error */ ++ NULL, /* error_string */ ++}; ++ ++static XEXT_GENERATE_FIND_DISPLAY (find_display, fglext_ext_info, ++ fglext_extension_name, ++ &fglext_extension_hooks, ++ ATIFGL_EXTENSION_EVENTS, NULL) ++ ++static XEXT_GENERATE_CLOSE_DISPLAY (close_display, fglext_ext_info) ++ ++Bool VA_FGLEXTQueryDirectRenderingCapable( Display *dpy, int screen, ++ Bool *isCapable ) ++{ ++ char **extensions; ++ int i, n_extensions, has_fglext = 0, has_fglrxdri = 0; ++ ++ if (isCapable) ++ *isCapable = False; ++ ++ extensions = XListExtensions(dpy, &n_extensions); ++ if (!extensions) ++ return False; ++ ++ for (i = 0; i < n_extensions; i++) { ++ if (strcmp(extensions[i], ATIFGL_EXTENSION_NAME) == 0) ++ has_fglext = 1; ++ if (strcmp(extensions[i], "ATIFGLRXDRI") == 0) ++ has_fglrxdri = 1; ++ } ++ XFreeExtensionList(extensions); ++ ++ if (!has_fglext) ++ return False; ++ ++ if (isCapable) ++ *isCapable = has_fglrxdri; ++ ++ return True; ++} ++ ++Bool VA_FGLEXTGetClientDriverName( Display *dpy, int screen, ++ int *ddxDriverMajorVersion, int *ddxDriverMinorVersion, ++ int *ddxDriverPatchVersion, char **clientDriverName ) ++{ ++ XExtDisplayInfo *info = find_display (dpy); ++ xFGLGetDriverDataReply rep; ++ xFGLGetDriverDataReq *req; ++ ++ if (ddxDriverMajorVersion) ++ *ddxDriverMajorVersion = 0; ++ if (ddxDriverMinorVersion) ++ *ddxDriverMinorVersion = 0; ++ if (ddxDriverPatchVersion) ++ *ddxDriverPatchVersion = 0; ++ if (clientDriverName) ++ *clientDriverName = NULL; ++ ++ if(!XextHasExtension(info)) ++ return False; ++ ++ xFGLCheckExtension (dpy, info, False); ++ ++ LockDisplay (dpy); ++ GetReq (FGLGetDriverData, req); ++ req->reqType = info->codes->major_opcode; ++ req->fireglReqType = X_FGLGetDriverData; ++ req->screen = screen; ++ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { ++ UnlockDisplay (dpy); ++ SyncHandle (); ++ return False; ++ } ++ UnlockDisplay (dpy); ++ SyncHandle (); ++ ++ if (ddxDriverMajorVersion) ++ *ddxDriverMajorVersion = rep.majorVersion; ++ if (ddxDriverMinorVersion) ++ *ddxDriverMinorVersion = rep.minorVersion; ++ if (ddxDriverPatchVersion) ++ *ddxDriverPatchVersion = rep.patchlevel; ++ if (clientDriverName) ++ *clientDriverName = strdup("fglrx"); ++ ++ return True; ++} +diff --git a/va/x11/va_fglext.h b/va/x11/va_fglext.h +new file mode 100644 +index 0000000..f2d87c3 +--- /dev/null ++++ b/va/x11/va_fglext.h +@@ -0,0 +1,37 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. 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. ++ */ ++ ++#ifndef VA_FGLEXTLIB_H ++#define VA_FGLEXTLIB_H ++ ++#include ++ ++Bool VA_FGLEXTQueryDirectRenderingCapable( Display *dpy, int screen, ++ Bool *isCapable ); ++ ++Bool VA_FGLEXTGetClientDriverName( Display *dpy, int screen, ++ int *ddxDriverMajorVersion, int *ddxDriverMinorVersion, ++ int *ddxDriverPatchVersion, char **clientDriverName ); ++ ++#endif /* VA_FGLEXTLIB_H */ +diff --git a/va/x11/va_x11.c b/va/x11/va_x11.c +index 1216093..71cc36f 100644 +--- a/va/x11/va_x11.c ++++ b/va/x11/va_x11.c +@@ -31,6 +31,7 @@ + #include "va_dri2.h" + #include "va_dricommon.h" + #include "va_nvctrl.h" ++#include "va_fglext.h" + #include "libdrm_glue.h" + #include + #include +@@ -133,6 +134,29 @@ static VAStatus va_NVCTRL_GetDriverName ( + 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 +@@ -148,7 +172,8 @@ static VAStatus va_DisplayContextGetDriverName ( + 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; + } + diff -Nru libva-0.31.0+latest2/debian/patches/300_sds_version.patch libva-0.31.0+latest3/debian/patches/300_sds_version.patch --- libva-0.31.0+latest2/debian/patches/300_sds_version.patch 1970-01-01 01:00:00.000000000 +0100 +++ libva-0.31.0+latest3/debian/patches/300_sds_version.patch 2010-04-18 14:36:16.000000000 +0100 @@ -0,0 +1,96 @@ +commit 1821919f68487c5e4fec33bd242208f49cb58c1e +Author: Gwenole Beauchesne +Date: Wed Jun 24 11:32:40 2009 +0000 + + Explicit API extensions from SDS. + +diff --git a/configure.ac b/configure.ac +index ebe5df6..95cf992 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -28,6 +28,9 @@ m4_define([libva_micro_version], [0]) + m4_define([libva_version], + [libva_major_version.libva_minor_version.libva_micro_version]) + ++# increase this number for each API change ++m4_define([libva_sds_version], [6]) ++ + # if the library source code has changed, increment revision + m4_define([libva_lt_revision], [1]) + # if any interface was added/removed/changed, then inc current, reset revision +@@ -52,11 +55,14 @@ AC_SUBST(LIBVA_MINOR_VERSION) + AC_SUBST(LIBVA_MICRO_VERSION) + AC_SUBST(LIBVA_VERSION) + ++LIBVA_SDS_VERSION=libva_sds_version ++AC_SUBST(LIBVA_SDS_VERSION) ++ + LIBVA_LT_CURRENT=libva_lt_current + LIBVA_LT_REV=libva_lt_revision + LIBVA_LT_AGE=libva_lt_age + LIBVA_LT_VERSION="$LIBVA_LT_CURRENT:$LIBVA_LT_REV:$LIBVA_LT_AGE" +-LIBVA_LT_LDFLAGS="-version-info $LIBVA_LT_VERSION" ++LIBVA_LT_LDFLAGS="-version-info $LIBVA_LT_VERSION -release $LIBVA_VERSION.$LIBVA_SDS_VERSION" + AC_SUBST(LIBVA_LT_VERSION) + AC_SUBST(LIBVA_LT_LDFLAGS) + +diff --git a/libva.pc.in b/libva.pc.in +index 60f1483..0b37945 100644 +--- a/libva.pc.in ++++ b/libva.pc.in +@@ -3,6 +3,7 @@ exec_prefix=@exec_prefix@ + libdir=@libdir@ + includedir=@includedir@ + driverdir=@LIBVA_DRIVERS_PATH@ ++sdsversion=@LIBVA_SDS_VERSION@ + + Name: libva + Description: Userspace Video Acceleration (VA) core interface +diff --git a/va/va.c b/va/va.c +index fd68481..0d208d8 100644 +--- a/va/va.c ++++ b/va/va.c +@@ -162,7 +162,15 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name) + else + { + VADriverInit init_func; +- init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC); ++ char driver_init_func_sds[32]; ++ /* First, try SDS extensions (VDPAU and XvBA backends) */ ++ sprintf(driver_init_func_sds, "%s_%d_sds%d", ++ DRIVER_INIT_FUNC, VA_MICRO_VERSION, VA_SDS_VERSION); ++ init_func = (VADriverInit) dlsym(handle, driver_init_func_sds); ++ if (!init_func) ++ { ++ init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC); ++ } + if (!init_func) + { + va_errorMessage("%s has no function %s\n", driver_path, DRIVER_INIT_FUNC); +diff --git a/va/va_version.h.in b/va/va_version.h.in +index c9ea97a..197c482 100644 +--- a/va/va_version.h.in ++++ b/va/va_version.h.in +@@ -47,6 +47,13 @@ + #define VA_MICRO_VERSION (@LIBVA_MICRO_VERSION@) + + /** ++ * VA_SDS_VERSION: ++ * ++ * The version of the SDS API extensions to the VA library ++ */ ++#define VA_SDS_VERSION (@LIBVA_SDS_VERSION@) ++ ++/** + * VA_VERSION: + * + * The full version of the VA library, like 1.2.3 +@@ -59,7 +66,7 @@ + * The full version of the VA library, in string form (suited for + * string concatenation) + */ +-#define VA_VERSION_S "@LIBVA_VERSION@" ++#define VA_VERSION_S "@LIBVA_VERSION@-sds@LIBVA_SDS_VERSION@" + + /** + * VA_VERSION_HEX: diff -Nru libva-0.31.0+latest2/debian/patches/321_libva_glx.base.patch libva-0.31.0+latest3/debian/patches/321_libva_glx.base.patch --- libva-0.31.0+latest2/debian/patches/321_libva_glx.base.patch 1970-01-01 01:00:00.000000000 +0100 +++ libva-0.31.0+latest3/debian/patches/321_libva_glx.base.patch 2010-04-18 14:36:16.000000000 +0100 @@ -0,0 +1,202 @@ +commit e69075435675d356c7c9b4ff734a60e8cd031604 +Author: Gwenole Beauchesne +Date: Mon Mar 8 09:44:25 2010 +0100 + + Add OpenGL extensions (v3) and generic implementation with TFP and FBO. + +diff --git a/Makefile.am b/Makefile.am +index 459660b..e75a2db 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -32,10 +32,13 @@ endif + + pcfiles = libva.pc + pcfiles += libva-x11.pc ++if USE_GLX ++pcfiles += libva-glx.pc ++endif + + pkgconfigdir = @pkgconfigdir@ + pkgconfig_DATA = $(pcfiles) + +-EXTRA_DIST = libva.pc.in libva-x11.pc.in ++EXTRA_DIST = libva.pc.in libva-x11.pc.in libva-glx.pc.in + + CLEANFILES = $(pcfiles) +diff --git a/configure.ac b/configure.ac +index 95cf992..86366e9 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -66,6 +66,11 @@ LIBVA_LT_LDFLAGS="-version-info $LIBVA_LT_VERSION -release $LIBVA_VERSION.$LIBVA + AC_SUBST(LIBVA_LT_VERSION) + AC_SUBST(LIBVA_LT_LDFLAGS) + ++AC_ARG_ENABLE(glx, ++ [AC_HELP_STRING([--enable-glx], ++ [build with OpenGL for X11 support])], ++ [], [enable_glx=yes]) ++ + AC_ARG_ENABLE(dummy-driver, + [AC_HELP_STRING([--enable-dummy-driver], + [build dummy video driver])], +@@ -130,6 +135,22 @@ fi + AC_DEFINE_UNQUOTED([ATTRIBUTE_HIDDEN], [$ATTRIBUTE_HIDDEN], + [Defined to __attribute__((visibility("hidden"))) when available]) + ++# Check for OpenGL (X11) ++USE_GLX="no" ++GL_DEPS_CFLAGS="" ++GL_DEPS_LIBS="" ++if test x$enable_glx = xyes; then ++ AC_CHECK_HEADERS([GL/gl.h]) ++ AC_CHECK_HEADERS([GL/glx.h]) ++ AC_CHECK_LIB(GL, glXCreateContext, [ ++ USE_GLX="yes" ++ GL_DEPS_LIBS="-lX11 -lGL" ++ ]) ++fi ++AC_SUBST(GL_DEPS_CFLAGS) ++AC_SUBST(GL_DEPS_LIBS) ++AM_CONDITIONAL(USE_GLX, test "$USE_GLX" = "yes") ++ + # We only need the headers, we don't link against the DRM libraries + LIBVA_CFLAGS="$DRM_CFLAGS" + AC_SUBST(LIBVA_CFLAGS) +@@ -149,6 +170,7 @@ AC_OUTPUT([ + va/Makefile + va/va_version.h + va/x11/Makefile ++ va/glx/Makefile + dummy_drv_video/Makefile + i965_drv_video/Makefile + i965_drv_video/shaders/Makefile +@@ -162,5 +184,6 @@ AC_OUTPUT([ + test/encode/Makefile + libva.pc + libva-x11.pc ++ libva-glx.pc + ]) + +diff --git a/libva-glx.pc.in b/libva-glx.pc.in +new file mode 100644 +index 0000000..2019915 +--- /dev/null ++++ b/libva-glx.pc.in +@@ -0,0 +1,12 @@ ++prefix=@prefix@ ++exec_prefix=@exec_prefix@ ++libdir=@libdir@ ++includedir=@includedir@ ++display=glx ++ ++Name: libva-${display} ++Description: Userspace Video Acceleration (VA) ${display} interface ++Requires: libva ++Version: @PACKAGE_VERSION@ ++Libs: -L${libdir} -lva-${display} ++Cflags: -I${includedir} +diff --git a/va/Makefile.am b/va/Makefile.am +index 99f6bbf..ebff3d5 100644 +--- a/va/Makefile.am ++++ b/va/Makefile.am +@@ -27,9 +27,17 @@ INCLUDES = \ + LDADD = \ + $(LIBVA_LT_LDFLAGS) + +-lib_LTLIBRARIES = \ +- libva.la \ +- libva-x11.la ++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 +@@ -40,7 +48,14 @@ libva_x11_la_LIBADD = $(libvacorelib) x11/libva_x11.la $(LIBVA_LIBS) $(X11_LIBS + libva_x11_la_LDFLAGS = $(LDADD) + libva_x11_la_DEPENDENCIES = $(libvacorelib) x11/libva_x11.la + +-SUBDIRS = x11 ++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 va_crystalhd.c + +diff --git a/va/glx/Makefile.am b/va/glx/Makefile.am +new file mode 100644 +index 0000000..337f34e +diff --git a/va/glx/va_backend_glx.h b/va/glx/va_backend_glx.h +new file mode 100644 +index 0000000..d110485 +diff --git a/va/glx/va_glx.c b/va/glx/va_glx.c +new file mode 100644 +index 0000000..ec50a0e +diff --git a/va/glx/va_glx.h b/va/glx/va_glx.h +new file mode 100644 +index 0000000..1a0624d +diff --git a/va/glx/va_glx_impl.c b/va/glx/va_glx_impl.c +new file mode 100644 +index 0000000..b0f24bb +diff --git a/va/glx/va_glx_impl.h b/va/glx/va_glx_impl.h +new file mode 100644 +index 0000000..977bfcc +diff --git a/va/glx/va_glx_private.h b/va/glx/va_glx_private.h +new file mode 100644 +index 0000000..d416729 +diff --git a/va/va_backend.h b/va/va_backend.h +index ff86744..06fef7f 100644 +--- a/va/va_backend.h ++++ b/va/va_backend.h +@@ -365,6 +365,9 @@ struct VADriverVTable + unsigned int *chroma_v_offset, + void **buffer + ); ++ ++ /* Optional: GLX support hooks */ ++ struct VADriverVTableGLX *glx; + }; + + struct VADriverContext +@@ -387,6 +390,7 @@ struct VADriverContext + void *handle; /* dlopen handle */ + + void *dri_state; ++ void *glx; /* opaque for GLX code */ + }; + + #define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */ +@@ -409,6 +413,8 @@ struct VADisplayContext + VADisplayContextP ctx, + char **driver_name + ); ++ ++ void *opaque; /* opaque for display extensions (e.g. GLX) */ + }; + + typedef VAStatus (*VADriverInit) ( +diff --git a/va/x11/va_x11.c b/va/x11/va_x11.c +index 71cc36f..6826b31 100644 +--- a/va/x11/va_x11.c ++++ b/va/x11/va_x11.c +@@ -217,6 +217,7 @@ VADisplay vaGetDisplay ( + pDisplayContext->vaIsValid = va_DisplayContextIsValid; + pDisplayContext->vaDestroy = va_DisplayContextDestroy; + pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName; ++ pDisplayContext->opaque = NULL; + pDisplayContexts = pDisplayContext; + pDriverContext->dri_state = dri_state; + dpy = (VADisplay)pDisplayContext; diff -Nru libva-0.31.0+latest2/debian/patches/322_libva_glx.patch libva-0.31.0+latest3/debian/patches/322_libva_glx.patch --- libva-0.31.0+latest2/debian/patches/322_libva_glx.patch 1970-01-01 01:00:00.000000000 +0100 +++ libva-0.31.0+latest3/debian/patches/322_libva_glx.patch 2010-04-18 14:36:16.000000000 +0100 @@ -0,0 +1,1602 @@ +commit acf3ec6b5176bf4cd09136a1d8c9bc3ff63f9d4e +Author: Gwenole Beauchesne +Date: Sun Apr 4 08:06:59 2010 +0200 + + Add OpenGL extensions (v3) and generic implementation with TFP and FBO. + +diff --git a/Makefile.am b/Makefile.am +index 459660b..e75a2db 100644 +diff --git a/configure.ac b/configure.ac +index 95cf992..86366e9 100644 +diff --git a/libva-glx.pc.in b/libva-glx.pc.in +new file mode 100644 +index 0000000..2019915 +diff --git a/va/Makefile.am b/va/Makefile.am +index 99f6bbf..ebff3d5 100644 +diff --git a/va/glx/Makefile.am b/va/glx/Makefile.am +new file mode 100644 +index 0000000..337f34e +--- /dev/null ++++ b/va/glx/Makefile.am +@@ -0,0 +1,41 @@ ++# Copyright (C) 2009 Splitted-Desktop Systems. 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. ++ ++AM_CFLAGS = -DLINUX -I$(top_srcdir)/va -I$(top_srcdir)/va/x11 ++ ++source_c = \ ++ va_glx.c \ ++ va_glx_impl.c ++ ++source_h = \ ++ va_glx.h \ ++ va_backend_glx.h ++ ++source_h_priv = \ ++ va_glx_impl.h \ ++ va_glx_private.h ++ ++noinst_LTLIBRARIES = libva_glx.la ++libva_glxincludedir = ${includedir}/va ++libva_glxinclude_HEADERS = $(source_h) ++libva_glx_la_SOURCES = $(source_c) ++noinst_HEADERS = $(source_h_priv) +diff --git a/va/glx/va_backend_glx.h b/va/glx/va_backend_glx.h +new file mode 100644 +index 0000000..d110485 +--- /dev/null ++++ b/va/glx/va_backend_glx.h +@@ -0,0 +1,54 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. 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. ++ */ ++ ++#ifndef VA_BACKEND_GLX_H ++#define VA_BACKEND_GLX_H ++ ++struct VADriverContext; ++ ++struct VADriverVTableGLX { ++ /* Optional: create a surface used for display to OpenGL */ ++ VAStatus (*vaCreateSurfaceGLX)( ++ struct VADriverContext *ctx, ++ unsigned int gl_target, ++ unsigned int gl_texture, ++ void **gl_surface ++ ); ++ ++ /* Optional: destroy a VA/GLX surface */ ++ VAStatus (*vaDestroySurfaceGLX)( ++ struct VADriverContext *ctx, ++ void *gl_surface ++ ); ++ ++ /* Optional: copy a VA surface to a VA/GLX surface */ ++ VAStatus (*vaCopySurfaceGLX)( ++ struct VADriverContext *ctx, ++ void *gl_surface, ++ VASurfaceID surface, ++ unsigned int flags ++ ); ++}; ++ ++#endif /* VA_BACKEND_GLX_H */ +diff --git a/va/glx/va_glx.c b/va/glx/va_glx.c +new file mode 100644 +index 0000000..27145ce +--- /dev/null ++++ b/va/glx/va_glx.c +@@ -0,0 +1,174 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. 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. ++ */ ++ ++#include ++#include "va_glx_private.h" ++#include "va_glx_impl.h" ++ ++#define INIT_CONTEXT(ctx, dpy) do { \ ++ if (!vaDisplayIsValid(dpy)) \ ++ return VA_STATUS_ERROR_INVALID_DISPLAY; \ ++ \ ++ ctx = ((VADisplayContextP)(dpy))->pDriverContext; \ ++ if (!(ctx)) \ ++ return VA_STATUS_ERROR_INVALID_DISPLAY; \ ++ \ ++ VAStatus status = va_glx_init_context(ctx); \ ++ if (status != VA_STATUS_SUCCESS) \ ++ return status; \ ++ } while (0) ++ ++#define INVOKE(ctx, func, args) do { \ ++ VADriverVTableGLXP vtable; \ ++ vtable = &VA_DRIVER_CONTEXT_GLX(ctx)->vtable; \ ++ if (!vtable->va##func##GLX) \ ++ return VA_STATUS_ERROR_UNIMPLEMENTED; \ ++ status = vtable->va##func##GLX args; \ ++ } while (0) ++ ++// Check VADisplay is valid ++static inline int vaDisplayIsValid(VADisplay dpy) ++{ ++ VADisplayContextP pDisplayContext = (VADisplayContextP)dpy; ++ ++ return (pDisplayContext && ++ pDisplayContext->vaIsValid && ++ pDisplayContext->vaIsValid(pDisplayContext)); ++} ++ ++// Destroy VA/GLX display context ++static void va_DisplayContextDestroy(VADisplayContextP pDisplayContext) ++{ ++ VADisplayContextGLXP pDisplayContextGLX; ++ VADriverContextP pDriverContext; ++ VADriverContextGLXP pDriverContextGLX; ++ ++ if (!pDisplayContext) ++ return; ++ ++ pDriverContext = pDisplayContext->pDriverContext; ++ pDriverContextGLX = pDriverContext->glx; ++ if (pDriverContextGLX) { ++ free(pDriverContextGLX); ++ pDriverContext->glx = NULL; ++ } ++ ++ pDisplayContextGLX = pDisplayContext->opaque; ++ if (pDisplayContextGLX) { ++ vaDestroyFunc vaDestroy = pDisplayContextGLX->vaDestroy; ++ free(pDisplayContextGLX); ++ pDisplayContext->opaque = NULL; ++ if (vaDestroy) ++ vaDestroy(pDisplayContext); ++ } ++} ++ ++// Return a suitable VADisplay for VA API ++VADisplay vaGetDisplayGLX(Display *native_dpy) ++{ ++ VADisplay dpy = NULL; ++ VADisplayContextP pDisplayContext = NULL; ++ VADisplayContextGLXP pDisplayContextGLX = NULL; ++ VADriverContextP pDriverContext; ++ VADriverContextGLXP pDriverContextGLX = NULL; ++ ++ dpy = vaGetDisplay(native_dpy); ++ if (!dpy) ++ return NULL; ++ pDisplayContext = (VADisplayContextP)dpy; ++ pDriverContext = pDisplayContext->pDriverContext; ++ ++ pDisplayContextGLX = calloc(1, sizeof(*pDisplayContextGLX)); ++ if (!pDisplayContextGLX) ++ goto error; ++ ++ pDriverContextGLX = calloc(1, sizeof(*pDriverContextGLX)); ++ if (!pDriverContextGLX) ++ goto error; ++ ++ pDisplayContextGLX->vaDestroy = pDisplayContext->vaDestroy; ++ pDisplayContext->vaDestroy = va_DisplayContextDestroy; ++ pDisplayContext->opaque = pDisplayContextGLX; ++ pDriverContext->glx = pDriverContextGLX; ++ return dpy; ++ ++error: ++ free(pDriverContextGLX); ++ free(pDisplayContextGLX); ++ pDisplayContext->vaDestroy(pDisplayContext); ++ return NULL; ++} ++ ++// Create a surface used for display to OpenGL ++VAStatus vaCreateSurfaceGLX( ++ VADisplay dpy, ++ GLenum target, ++ GLuint texture, ++ void **gl_surface ++) ++{ ++ VADriverContextP ctx; ++ VAStatus status; ++ ++ /* Make sure it is a valid GL texture object */ ++ if (!glIsTexture(texture)) ++ return VA_STATUS_ERROR_INVALID_PARAMETER; ++ ++ INIT_CONTEXT(ctx, dpy); ++ ++ INVOKE(ctx, CreateSurface, (ctx, target, texture, gl_surface)); ++ return status; ++} ++ ++// Destroy a VA/GLX surface ++VAStatus vaDestroySurfaceGLX( ++ VADisplay dpy, ++ void *gl_surface ++) ++{ ++ VADriverContextP ctx; ++ VAStatus status; ++ ++ INIT_CONTEXT(ctx, dpy); ++ ++ INVOKE(ctx, DestroySurface, (ctx, gl_surface)); ++ return status; ++} ++ ++// Copy a VA surface to a VA/GLX surface ++VAStatus vaCopySurfaceGLX( ++ VADisplay dpy, ++ void *gl_surface, ++ VASurfaceID surface, ++ unsigned int flags ++) ++{ ++ VADriverContextP ctx; ++ VAStatus status; ++ ++ INIT_CONTEXT(ctx, dpy); ++ ++ INVOKE(ctx, CopySurface, (ctx, gl_surface, surface, flags)); ++ return status; ++} +diff --git a/va/glx/va_glx.h b/va/glx/va_glx.h +new file mode 100644 +index 0000000..1a0624d +--- /dev/null ++++ b/va/glx/va_glx.h +@@ -0,0 +1,109 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. 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. ++ */ ++ ++#ifndef VA_GLX_H ++#define VA_GLX_H ++ ++#include ++#include ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++/** ++ * Return a suitable VADisplay for VA API ++ * ++ * @param[in] dpy the X11 display ++ * @return a VADisplay ++ */ ++VADisplay vaGetDisplayGLX( ++ Display *dpy ++); ++ ++/** ++ * Create a surface used for display to OpenGL ++ * ++ * The application shall maintain the live GLX context itself. ++ * Implementations are free to use glXGetCurrentContext() and ++ * glXGetCurrentDrawable() functions for internal purposes. ++ * ++ * @param[in] dpy the VA display ++ * @param[in] target the GL target to which the texture needs to be bound ++ * @param[in] texture the GL texture ++ * @param[out] gl_surface the VA/GLX surface ++ * @return VA_STATUS_SUCCESS if successful ++ */ ++VAStatus vaCreateSurfaceGLX( ++ VADisplay dpy, ++ GLenum target, ++ GLuint texture, ++ void **gl_surface ++); ++ ++/** ++ * Destroy a VA/GLX surface ++ * ++ * The application shall maintain the live GLX context itself. ++ * Implementations are free to use glXGetCurrentContext() and ++ * glXGetCurrentDrawable() functions for internal purposes. ++ * ++ * @param[in] dpy the VA display ++ * @param[in] gl_surface the VA surface ++ * @return VA_STATUS_SUCCESS if successful ++ */ ++VAStatus vaDestroySurfaceGLX( ++ VADisplay dpy, ++ void *gl_surface ++); ++ ++/** ++ * Copy a VA surface to a VA/GLX surface ++ * ++ * This function will not return until the copy is completed. At this ++ * point, the underlying GL texture will contain the surface pixels ++ * in an RGB format defined by the user. ++ * ++ * The application shall maintain the live GLX context itself. ++ * Implementations are free to use glXGetCurrentContext() and ++ * glXGetCurrentDrawable() functions for internal purposes. ++ * ++ * @param[in] dpy the VA display ++ * @param[in] gl_surface the VA/GLX destination surface ++ * @param[in] surface the VA source surface ++ * @param[in] flags the PutSurface flags ++ * @return VA_STATUS_SUCCESS if successful ++ */ ++VAStatus vaCopySurfaceGLX( ++ VADisplay dpy, ++ void *gl_surface, ++ VASurfaceID surface, ++ unsigned int flags ++); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* VA_GLX_H */ +diff --git a/va/glx/va_glx_impl.c b/va/glx/va_glx_impl.c +new file mode 100644 +index 0000000..7c26648 +--- /dev/null ++++ b/va/glx/va_glx_impl.c +@@ -0,0 +1,1050 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. 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_glx_private.h" ++#include "va_glx_impl.h" ++#include ++#include ++#include ++#include ++#include ++#include ++ ++static void va_glx_error_message(const char *format, ...) ++{ ++ va_list args; ++ va_start(args, format); ++ fprintf(stderr, "[%s] ", PACKAGE_NAME); ++ vfprintf(stderr, format, args); ++ va_end(args); ++} ++ ++// X error trap ++static int x11_error_code = 0; ++static int (*old_error_handler)(Display *, XErrorEvent *); ++ ++static int error_handler(Display *dpy, XErrorEvent *error) ++{ ++ x11_error_code = error->error_code; ++ return 0; ++} ++ ++static void x11_trap_errors(void) ++{ ++ x11_error_code = 0; ++ old_error_handler = XSetErrorHandler(error_handler); ++} ++ ++static int x11_untrap_errors(void) ++{ ++ XSetErrorHandler(old_error_handler); ++ return x11_error_code; ++} ++ ++// Returns a string representation of an OpenGL error ++static const char *gl_get_error_string(GLenum error) ++{ ++ static const struct { ++ GLenum val; ++ const char *str; ++ } ++ gl_errors[] = { ++ { GL_NO_ERROR, "no error" }, ++ { GL_INVALID_ENUM, "invalid enumerant" }, ++ { GL_INVALID_VALUE, "invalid value" }, ++ { GL_INVALID_OPERATION, "invalid operation" }, ++ { GL_STACK_OVERFLOW, "stack overflow" }, ++ { GL_STACK_UNDERFLOW, "stack underflow" }, ++ { GL_OUT_OF_MEMORY, "out of memory" }, ++#ifdef GL_INVALID_FRAMEBUFFER_OPERATION_EXT ++ { GL_INVALID_FRAMEBUFFER_OPERATION_EXT, "invalid framebuffer operation" }, ++#endif ++ { ~0, NULL } ++ }; ++ ++ int i; ++ for (i = 0; gl_errors[i].str; i++) { ++ if (gl_errors[i].val == error) ++ return gl_errors[i].str; ++ } ++ return "unknown"; ++} ++ ++static inline int gl_do_check_error(int report) ++{ ++ GLenum error; ++ int is_error = 0; ++ while ((error = glGetError()) != GL_NO_ERROR) { ++ if (report) ++ va_glx_error_message("glError: %s caught\n", ++ gl_get_error_string(error)); ++ is_error = 1; ++ } ++ return is_error; ++} ++ ++static inline void gl_purge_errors(void) ++{ ++ gl_do_check_error(0); ++} ++ ++static inline int gl_check_error(void) ++{ ++ return gl_do_check_error(1); ++} ++ ++// glGetTexLevelParameteriv() wrapper ++static int gl_get_texture_param(GLenum param, unsigned int *pval) ++{ ++ GLint val; ++ ++ gl_purge_errors(); ++ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, param, &val); ++ if (gl_check_error()) ++ return 0; ++ if (pval) ++ *pval = val; ++ return 1; ++} ++ ++// Returns the OpenGL VTable ++static inline VAOpenGLVTableP gl_get_vtable(VADriverContextP ctx) ++{ ++ return &VA_DRIVER_CONTEXT_GLX(ctx)->gl_vtable; ++} ++ ++// Lookup for a GLX function ++typedef void (*GLFuncPtr)(void); ++typedef GLFuncPtr (*GLXGetProcAddressProc)(const char *); ++ ++static GLFuncPtr get_proc_address_default(const char *name) ++{ ++ return NULL; ++} ++ ++static GLXGetProcAddressProc get_proc_address_func(void) ++{ ++ GLXGetProcAddressProc get_proc_func; ++ ++ dlerror(); ++ get_proc_func = (GLXGetProcAddressProc) ++ dlsym(RTLD_DEFAULT, "glXGetProcAddress"); ++ if (!dlerror()) ++ return get_proc_func; ++ ++ get_proc_func = (GLXGetProcAddressProc) ++ dlsym(RTLD_DEFAULT, "glXGetProcAddressARB"); ++ if (!dlerror()) ++ return get_proc_func; ++ ++ return get_proc_address_default; ++} ++ ++static inline GLFuncPtr get_proc_address(const char *name) ++{ ++ static GLXGetProcAddressProc get_proc_func = NULL; ++ if (!get_proc_func) ++ get_proc_func = get_proc_address_func(); ++ return get_proc_func(name); ++} ++ ++// Check for GLX extensions (TFP, FBO) ++static int check_extension(const char *name, const char *ext) ++{ ++ const char *end; ++ int name_len, n; ++ ++ if (!name || !ext) ++ return 0; ++ ++ end = ext + strlen(ext); ++ name_len = strlen(name); ++ while (ext < end) { ++ n = strcspn(ext, " "); ++ if (n == name_len && strncmp(name, ext, n) == 0) ++ return 1; ++ ext += (n + 1); ++ } ++ return 0; ++} ++ ++static int check_tfp_extensions(VADriverContextP ctx) ++{ ++ const char *gl_extensions; ++ const char *glx_extensions; ++ ++ gl_extensions = (const char *)glGetString(GL_EXTENSIONS); ++ if (!check_extension("GL_ARB_texture_non_power_of_two", gl_extensions)) ++ return 0; ++ ++ glx_extensions = glXQueryExtensionsString(ctx->x11_dpy, ctx->x11_screen); ++ if (!check_extension("GLX_EXT_texture_from_pixmap", glx_extensions)) ++ return 0; ++ return 1; ++} ++ ++static int check_fbo_extensions(VADriverContextP ctx) ++{ ++ const char *gl_extensions; ++ ++ gl_extensions = (const char *)glGetString(GL_EXTENSIONS); ++ if (check_extension("GL_ARB_framebuffer_object", gl_extensions)) ++ return 1; ++ if (check_extension("GL_EXT_framebuffer_object", gl_extensions)) ++ return 1; ++ return 0; ++} ++ ++// Load GLX extensions ++static int load_tfp_extensions(VADriverContextP ctx) ++{ ++ VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); ++ ++ pOpenGLVTable->glx_bind_tex_image = (PFNGLXBINDTEXIMAGEEXTPROC) ++ get_proc_address("glXBindTexImageEXT"); ++ if (!pOpenGLVTable->glx_bind_tex_image) ++ return 0; ++ pOpenGLVTable->glx_release_tex_image = (PFNGLXRELEASETEXIMAGEEXTPROC) ++ get_proc_address("glXReleaseTexImageEXT"); ++ if (!pOpenGLVTable->glx_release_tex_image) ++ return 0; ++ return 1; ++} ++ ++static int load_fbo_extensions(VADriverContextP ctx) ++{ ++ VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); ++ ++ pOpenGLVTable->gl_gen_framebuffers = (PFNGLGENFRAMEBUFFERSEXTPROC) ++ get_proc_address("glGenFramebuffersEXT"); ++ if (!pOpenGLVTable->gl_gen_framebuffers) ++ return 0; ++ pOpenGLVTable->gl_delete_framebuffers = (PFNGLDELETEFRAMEBUFFERSEXTPROC) ++ get_proc_address("glDeleteFramebuffersEXT"); ++ if (!pOpenGLVTable->gl_delete_framebuffers) ++ return 0; ++ pOpenGLVTable->gl_bind_framebuffer = (PFNGLBINDFRAMEBUFFEREXTPROC) ++ get_proc_address("glBindFramebufferEXT"); ++ if (!pOpenGLVTable->gl_bind_framebuffer) ++ return 0; ++ pOpenGLVTable->gl_gen_renderbuffers = (PFNGLGENRENDERBUFFERSEXTPROC) ++ get_proc_address("glGenRenderbuffersEXT"); ++ if (!pOpenGLVTable->gl_gen_renderbuffers) ++ return 0; ++ pOpenGLVTable->gl_delete_renderbuffers = (PFNGLDELETERENDERBUFFERSEXTPROC) ++ get_proc_address("glDeleteRenderbuffersEXT"); ++ if (!pOpenGLVTable->gl_delete_renderbuffers) ++ return 0; ++ pOpenGLVTable->gl_bind_renderbuffer = (PFNGLBINDRENDERBUFFEREXTPROC) ++ get_proc_address("glBindRenderbufferEXT"); ++ if (!pOpenGLVTable->gl_bind_renderbuffer) ++ return 0; ++ pOpenGLVTable->gl_renderbuffer_storage = (PFNGLRENDERBUFFERSTORAGEEXTPROC) ++ get_proc_address("glRenderbufferStorageEXT"); ++ if (!pOpenGLVTable->gl_renderbuffer_storage) ++ return 0; ++ pOpenGLVTable->gl_framebuffer_renderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) ++ get_proc_address("glFramebufferRenderbufferEXT"); ++ if (!pOpenGLVTable->gl_framebuffer_renderbuffer) ++ return 0; ++ pOpenGLVTable->gl_framebuffer_texture_2d = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) ++ get_proc_address("glFramebufferTexture2DEXT"); ++ if (!pOpenGLVTable->gl_framebuffer_texture_2d) ++ return 0; ++ pOpenGLVTable->gl_check_framebuffer_status = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) ++ get_proc_address("glCheckFramebufferStatusEXT"); ++ if (!pOpenGLVTable->gl_check_framebuffer_status) ++ return 0; ++ return 1; ++} ++ ++ ++/* ========================================================================= */ ++/* === VA/GLX helpers === */ ++/* ========================================================================= */ ++ ++// OpenGL context state ++typedef struct OpenGLContextState *OpenGLContextStateP; ++ ++struct OpenGLContextState { ++ Display *display; ++ Window window; ++ XVisualInfo *visual; ++ GLXContext context; ++}; ++ ++static void ++gl_destroy_context(OpenGLContextStateP cs) ++{ ++ if (!cs) ++ return; ++ ++ if (cs->visual) { ++ XFree(cs->visual); ++ cs->visual = NULL; ++ } ++ ++ if (cs->display && cs->context) { ++ if (glXGetCurrentContext() == cs->context) ++ glXMakeCurrent(cs->display, None, NULL); ++ glXDestroyContext(cs->display, cs->context); ++ cs->display = NULL; ++ cs->context = NULL; ++ } ++ free(cs); ++} ++ ++static OpenGLContextStateP ++gl_create_context(VADriverContextP ctx, OpenGLContextStateP parent) ++{ ++ OpenGLContextStateP cs; ++ GLXFBConfig *fbconfigs = NULL; ++ int n_fbconfigs; ++ ++ static GLint fbconfig_attrs[] = { ++ GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, ++ GLX_RENDER_TYPE, GLX_RGBA_BIT, ++ GLX_DOUBLEBUFFER, True, ++ GLX_RED_SIZE, 1, ++ GLX_GREEN_SIZE, 1, ++ GLX_BLUE_SIZE, 1, ++ None ++ }; ++ ++ cs = malloc(sizeof(*cs)); ++ if (!cs) ++ goto error; ++ ++ cs->display = ctx->x11_dpy; ++ cs->window = parent ? parent->window : None; ++ cs->visual = NULL; ++ cs->context = NULL; ++ ++ fbconfigs = glXChooseFBConfig( ++ ctx->x11_dpy, ++ ctx->x11_screen, ++ fbconfig_attrs, ++ &n_fbconfigs ++ ); ++ if (!fbconfigs) ++ goto error; ++ ++ cs->visual = glXGetVisualFromFBConfig(ctx->x11_dpy, fbconfigs[0]); ++ if (!cs->visual) ++ goto error; ++ ++ cs->context = glXCreateNewContext( ++ ctx->x11_dpy, ++ fbconfigs[0], ++ GLX_RGBA_TYPE, ++ parent ? parent->context : NULL, ++ True ++ ); ++ if (cs->context) ++ goto end; ++ ++error: ++ gl_destroy_context(cs); ++ cs = NULL; ++end: ++ if (fbconfigs) ++ XFree(fbconfigs); ++ return cs; ++} ++ ++static void gl_get_current_context(OpenGLContextStateP cs) ++{ ++ cs->display = glXGetCurrentDisplay(); ++ cs->window = glXGetCurrentDrawable(); ++ cs->context = glXGetCurrentContext(); ++} ++ ++static int ++gl_set_current_context(OpenGLContextStateP new_cs, OpenGLContextStateP old_cs) ++{ ++ /* If display is NULL, this could be that new_cs was retrieved from ++ gl_get_current_context() with none set previously. If that case, ++ the other fields are also NULL and we don't return an error */ ++ if (!new_cs->display) ++ return !new_cs->window && !new_cs->context; ++ ++ if (old_cs) { ++ if (old_cs == new_cs) ++ return 1; ++ gl_get_current_context(old_cs); ++ if (old_cs->display == new_cs->display && ++ old_cs->window == new_cs->window && ++ old_cs->context == new_cs->context) ++ return 1; ++ } ++ return glXMakeCurrent(new_cs->display, new_cs->window, new_cs->context); ++} ++ ++/** Unique VASurfaceGLX identifier */ ++#define VA_SURFACE_GLX_MAGIC VA_FOURCC('V','A','G','L') ++ ++struct VASurfaceGLX { ++ uint32_t magic; ///< Magic number identifying a VASurfaceGLX ++ GLenum target; ///< GL target to which the texture is bound ++ GLuint texture; ///< GL texture ++ VASurfaceID surface; ///< Associated VA surface ++ unsigned int width; ++ unsigned int height; ++ OpenGLContextStateP gl_context; ++ int is_bound; ++ Pixmap pixmap; ++ GLuint pix_texture; ++ GLXPixmap glx_pixmap; ++ GLuint fbo; ++}; ++ ++// Create Pixmaps for GLX texture-from-pixmap extension ++static int create_tfp_surface(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) ++{ ++ const unsigned int width = pSurfaceGLX->width; ++ const unsigned int height = pSurfaceGLX->height; ++ Pixmap pixmap = None; ++ GLXFBConfig *fbconfig = NULL; ++ GLXPixmap glx_pixmap = None; ++ Window root_window; ++ XWindowAttributes wattr; ++ int *attrib; ++ int n_fbconfig_attrs; ++ ++ root_window = RootWindow(ctx->x11_dpy, ctx->x11_screen); ++ XGetWindowAttributes(ctx->x11_dpy, root_window, &wattr); ++ if (wattr.depth != 24 && wattr.depth != 32) ++ return 0; ++ pixmap = XCreatePixmap( ++ ctx->x11_dpy, ++ root_window, ++ width, ++ height, ++ wattr.depth ++ ); ++ if (!pixmap) ++ return 0; ++ pSurfaceGLX->pixmap = pixmap; ++ ++ int fbconfig_attrs[32] = { ++ GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT, ++ GLX_DOUBLEBUFFER, GL_TRUE, ++ GLX_RENDER_TYPE, GLX_RGBA_BIT, ++ GLX_X_RENDERABLE, GL_TRUE, ++ GLX_Y_INVERTED_EXT, GL_TRUE, ++ GLX_RED_SIZE, 8, ++ GLX_GREEN_SIZE, 8, ++ GLX_BLUE_SIZE, 8, ++ GL_NONE, ++ }; ++ for (attrib = fbconfig_attrs; *attrib != GL_NONE; attrib += 2) ++ ; ++ *attrib++ = GLX_DEPTH_SIZE; *attrib++ = wattr.depth; ++ if (wattr.depth == 32) { ++ *attrib++ = GLX_ALPHA_SIZE; *attrib++ = 8; ++ *attrib++ = GLX_BIND_TO_TEXTURE_RGBA_EXT; *attrib++ = GL_TRUE; ++ } ++ else { ++ *attrib++ = GLX_BIND_TO_TEXTURE_RGB_EXT; *attrib++ = GL_TRUE; ++ } ++ *attrib++ = GL_NONE; ++ ++ fbconfig = glXChooseFBConfig( ++ ctx->x11_dpy, ++ ctx->x11_screen, ++ fbconfig_attrs, ++ &n_fbconfig_attrs ++ ); ++ if (!fbconfig) ++ return 0; ++ ++ int pixmap_attrs[10] = { ++ GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT, ++ GLX_MIPMAP_TEXTURE_EXT, GL_FALSE, ++ GL_NONE, ++ }; ++ for (attrib = pixmap_attrs; *attrib != GL_NONE; attrib += 2) ++ ; ++ *attrib++ = GLX_TEXTURE_FORMAT_EXT; ++ if (wattr.depth == 32) ++ *attrib++ = GLX_TEXTURE_FORMAT_RGBA_EXT; ++ else ++ *attrib++ = GLX_TEXTURE_FORMAT_RGB_EXT; ++ *attrib++ = GL_NONE; ++ ++ x11_trap_errors(); ++ glx_pixmap = glXCreatePixmap( ++ ctx->x11_dpy, ++ fbconfig[0], ++ pixmap, ++ pixmap_attrs ++ ); ++ free(fbconfig); ++ if (x11_untrap_errors() != 0) ++ return 0; ++ pSurfaceGLX->glx_pixmap = glx_pixmap; ++ ++ glGenTextures(1, &pSurfaceGLX->pix_texture); ++ glBindTexture(GL_TEXTURE_2D, pSurfaceGLX->pix_texture); ++ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); ++ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); ++ return 1; ++} ++ ++// Destroy Pixmaps used for TFP ++static void destroy_tfp_surface(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) ++{ ++ if (pSurfaceGLX->pix_texture) { ++ glDeleteTextures(1, &pSurfaceGLX->pix_texture); ++ pSurfaceGLX->pix_texture = 0; ++ } ++ ++ if (pSurfaceGLX->glx_pixmap) { ++ glXDestroyPixmap(ctx->x11_dpy, pSurfaceGLX->glx_pixmap); ++ pSurfaceGLX->glx_pixmap = None; ++ } ++ ++ if (pSurfaceGLX->pixmap) { ++ XFreePixmap(ctx->x11_dpy, pSurfaceGLX->pixmap); ++ pSurfaceGLX->pixmap = None; ++ } ++} ++ ++// Bind GLX Pixmap to texture ++static int bind_pixmap(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) ++{ ++ VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); ++ ++ if (pSurfaceGLX->is_bound) ++ return 1; ++ ++ glBindTexture(GL_TEXTURE_2D, pSurfaceGLX->pix_texture); ++ ++ x11_trap_errors(); ++ pOpenGLVTable->glx_bind_tex_image( ++ ctx->x11_dpy, ++ pSurfaceGLX->glx_pixmap, ++ GLX_FRONT_LEFT_EXT, ++ NULL ++ ); ++ XSync(ctx->x11_dpy, False); ++ if (x11_untrap_errors() != 0) { ++ va_glx_error_message("failed to bind pixmap\n"); ++ return 0; ++ } ++ ++ pSurfaceGLX->is_bound = 1; ++ return 1; ++} ++ ++// Release GLX Pixmap from texture ++static int unbind_pixmap(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) ++{ ++ VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); ++ ++ if (!pSurfaceGLX->is_bound) ++ return 1; ++ ++ x11_trap_errors(); ++ pOpenGLVTable->glx_release_tex_image( ++ ctx->x11_dpy, ++ pSurfaceGLX->glx_pixmap, ++ GLX_FRONT_LEFT_EXT ++ ); ++ XSync(ctx->x11_dpy, False); ++ if (x11_untrap_errors() != 0) { ++ va_glx_error_message("failed to release pixmap\n"); ++ return 0; ++ } ++ ++ glBindTexture(GL_TEXTURE_2D, 0); ++ ++ pSurfaceGLX->is_bound = 0; ++ return 1; ++} ++ ++// Render GLX Pixmap to texture ++static void render_pixmap(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) ++{ ++ const unsigned int w = pSurfaceGLX->width; ++ const unsigned int h = pSurfaceGLX->height; ++ ++ glColor4f(1.0f, 1.0f, 1.0f, 1.0f); ++ glBegin(GL_QUADS); ++ { ++ glTexCoord2f(0.0f, 0.0f); glVertex2i(0, 0); ++ glTexCoord2f(0.0f, 1.0f); glVertex2i(0, h); ++ glTexCoord2f(1.0f, 1.0f); glVertex2i(w, h); ++ glTexCoord2f(1.0f, 0.0f); glVertex2i(w, 0); ++ } ++ glEnd(); ++} ++ ++// Create offscreen surface ++static int create_fbo_surface(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) ++{ ++ VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); ++ GLuint fbo; ++ GLenum status; ++ ++ pOpenGLVTable->gl_gen_framebuffers(1, &fbo); ++ pOpenGLVTable->gl_bind_framebuffer(GL_FRAMEBUFFER_EXT, fbo); ++ pOpenGLVTable->gl_framebuffer_texture_2d( ++ GL_FRAMEBUFFER_EXT, ++ GL_COLOR_ATTACHMENT0_EXT, ++ GL_TEXTURE_2D, ++ pSurfaceGLX->texture, ++ 0 ++ ); ++ ++ status = pOpenGLVTable->gl_check_framebuffer_status(GL_DRAW_FRAMEBUFFER_EXT); ++ pOpenGLVTable->gl_bind_framebuffer(GL_FRAMEBUFFER_EXT, 0); ++ if (status != GL_FRAMEBUFFER_COMPLETE_EXT) ++ return 0; ++ ++ pSurfaceGLX->fbo = fbo; ++ return 1; ++} ++ ++// Destroy offscreen surface ++static void destroy_fbo_surface(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) ++{ ++ VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); ++ ++ if (pSurfaceGLX->fbo) { ++ pOpenGLVTable->gl_delete_framebuffers(1, &pSurfaceGLX->fbo); ++ pSurfaceGLX->fbo = 0; ++ } ++} ++ ++// Setup matrices to match the FBO texture dimensions ++static void fbo_enter(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) ++{ ++ VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); ++ const unsigned int width = pSurfaceGLX->width; ++ const unsigned int height = pSurfaceGLX->height; ++ ++ pOpenGLVTable->gl_bind_framebuffer(GL_FRAMEBUFFER_EXT, pSurfaceGLX->fbo); ++ glPushAttrib(GL_VIEWPORT_BIT); ++ glMatrixMode(GL_PROJECTION); ++ glPushMatrix(); ++ glLoadIdentity(); ++ glMatrixMode(GL_MODELVIEW); ++ glPushMatrix(); ++ glLoadIdentity(); ++ glViewport(0, 0, width, height); ++ glTranslatef(-1.0f, -1.0f, 0.0f); ++ glScalef(2.0f / width, 2.0f / height, 1.0f); ++} ++ ++// Restore original OpenGL matrices ++static void fbo_leave(VADriverContextP ctx) ++{ ++ VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); ++ ++ glPopAttrib(); ++ glMatrixMode(GL_PROJECTION); ++ glPopMatrix(); ++ glMatrixMode(GL_MODELVIEW); ++ glPopMatrix(); ++ pOpenGLVTable->gl_bind_framebuffer(GL_FRAMEBUFFER_EXT, 0); ++} ++ ++// Check internal texture format is supported ++static int is_supported_internal_format(GLenum format) ++{ ++ /* XXX: we don't support other textures than RGBA */ ++ switch (format) { ++ case 4: ++ case GL_RGBA: ++ case GL_RGBA8: ++ return 1; ++ } ++ return 0; ++} ++ ++// Destroy VA/GLX surface ++static void ++destroy_surface(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) ++{ ++ unbind_pixmap(ctx, pSurfaceGLX); ++ destroy_fbo_surface(ctx, pSurfaceGLX); ++ destroy_tfp_surface(ctx, pSurfaceGLX); ++ free(pSurfaceGLX); ++} ++ ++// Create VA/GLX surface ++static VASurfaceGLXP ++create_surface(VADriverContextP ctx, GLenum target, GLuint texture) ++{ ++ VASurfaceGLXP pSurfaceGLX = NULL; ++ unsigned int internal_format, border_width, width, height; ++ int is_error = 1; ++ ++ pSurfaceGLX = malloc(sizeof(*pSurfaceGLX)); ++ if (!pSurfaceGLX) ++ goto end; ++ ++ pSurfaceGLX->magic = VA_SURFACE_GLX_MAGIC; ++ pSurfaceGLX->target = target; ++ pSurfaceGLX->texture = texture; ++ pSurfaceGLX->surface = VA_INVALID_SURFACE; ++ pSurfaceGLX->gl_context = NULL; ++ pSurfaceGLX->is_bound = 0; ++ pSurfaceGLX->pixmap = None; ++ pSurfaceGLX->pix_texture = 0; ++ pSurfaceGLX->glx_pixmap = None; ++ pSurfaceGLX->fbo = 0; ++ ++ glEnable(target); ++ glBindTexture(target, texture); ++ if (!gl_get_texture_param(GL_TEXTURE_INTERNAL_FORMAT, &internal_format)) ++ goto end; ++ if (!is_supported_internal_format(internal_format)) ++ goto end; ++ ++ /* Check texture dimensions */ ++ if (!gl_get_texture_param(GL_TEXTURE_BORDER, &border_width)) ++ goto end; ++ if (!gl_get_texture_param(GL_TEXTURE_WIDTH, &width)) ++ goto end; ++ if (!gl_get_texture_param(GL_TEXTURE_HEIGHT, &height)) ++ goto end; ++ ++ width -= 2 * border_width; ++ height -= 2 * border_width; ++ if (width == 0 || height == 0) ++ goto end; ++ ++ pSurfaceGLX->width = width; ++ pSurfaceGLX->height = height; ++ ++ /* Create TFP objects */ ++ if (!create_tfp_surface(ctx, pSurfaceGLX)) ++ goto end; ++ ++ /* Create FBO objects */ ++ if (!create_fbo_surface(ctx, pSurfaceGLX)) ++ goto end; ++ ++ is_error = 0; ++end: ++ if (is_error && pSurfaceGLX) { ++ destroy_surface(ctx, pSurfaceGLX); ++ pSurfaceGLX = NULL; ++ } ++ return pSurfaceGLX; ++} ++ ++ ++/* ========================================================================= */ ++/* === VA/GLX implementation from the driver (fordward calls) === */ ++/* ========================================================================= */ ++ ++#define INVOKE(ctx, func, args) do { \ ++ VADriverVTableGLXP vtable = (ctx)->vtable.glx; \ ++ if (!vtable->va##func##GLX) \ ++ return VA_STATUS_ERROR_UNIMPLEMENTED; \ ++ \ ++ VAStatus status = vtable->va##func##GLX args; \ ++ if (status != VA_STATUS_SUCCESS) \ ++ return status; \ ++ } while (0) ++ ++static VAStatus ++vaCreateSurfaceGLX_impl_driver( ++ VADriverContextP ctx, ++ GLenum target, ++ GLuint texture, ++ void **gl_surface ++) ++{ ++ INVOKE(ctx, CreateSurface, (ctx, target, texture, gl_surface)); ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus ++vaDestroySurfaceGLX_impl_driver(VADriverContextP ctx, void *gl_surface) ++{ ++ INVOKE(ctx, DestroySurface, (ctx, gl_surface)); ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus ++vaCopySurfaceGLX_impl_driver( ++ VADriverContextP ctx, ++ void *gl_surface, ++ VASurfaceID surface, ++ unsigned int flags ++) ++{ ++ INVOKE(ctx, CopySurface, (ctx, gl_surface, surface, flags)); ++ return VA_STATUS_SUCCESS; ++} ++ ++#undef INVOKE ++ ++ ++/* ========================================================================= */ ++/* === VA/GLX implementation from libVA (generic and suboptimal path) === */ ++/* ========================================================================= */ ++ ++#define INIT_SURFACE(surface, surface_arg) do { \ ++ surface = (VASurfaceGLXP)(surface_arg); \ ++ if (!check_surface(surface)) \ ++ return VA_STATUS_ERROR_INVALID_SURFACE; \ ++ } while (0) ++ ++// Check VASurfaceGLX is valid ++static inline int check_surface(VASurfaceGLXP pSurfaceGLX) ++{ ++ return pSurfaceGLX && pSurfaceGLX->magic == VA_SURFACE_GLX_MAGIC; ++} ++ ++static VAStatus ++vaCreateSurfaceGLX_impl_libva( ++ VADriverContextP ctx, ++ GLenum target, ++ GLuint texture, ++ void **gl_surface ++) ++{ ++ VASurfaceGLXP pSurfaceGLX; ++ struct OpenGLContextState old_cs, *new_cs; ++ ++ gl_get_current_context(&old_cs); ++ new_cs = gl_create_context(ctx, &old_cs); ++ if (!new_cs) ++ return VA_STATUS_ERROR_ALLOCATION_FAILED; ++ if (!gl_set_current_context(new_cs, NULL)) ++ return VA_STATUS_ERROR_OPERATION_FAILED; ++ ++ pSurfaceGLX = create_surface(ctx, target, texture); ++ if (!pSurfaceGLX) ++ return VA_STATUS_ERROR_ALLOCATION_FAILED; ++ ++ pSurfaceGLX->gl_context = new_cs; ++ *gl_surface = pSurfaceGLX; ++ ++ gl_set_current_context(&old_cs, NULL); ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus ++vaDestroySurfaceGLX_impl_libva(VADriverContextP ctx, void *gl_surface) ++{ ++ VASurfaceGLXP pSurfaceGLX; ++ struct OpenGLContextState old_cs, *new_cs; ++ ++ INIT_SURFACE(pSurfaceGLX, gl_surface); ++ ++ new_cs = pSurfaceGLX->gl_context; ++ if (!gl_set_current_context(new_cs, &old_cs)) ++ return VA_STATUS_ERROR_OPERATION_FAILED; ++ ++ destroy_surface(ctx, pSurfaceGLX); ++ ++ gl_destroy_context(new_cs); ++ gl_set_current_context(&old_cs, NULL); ++ return VA_STATUS_SUCCESS; ++} ++ ++static inline VAStatus ++deassociate_surface(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) ++{ ++ if (!unbind_pixmap(ctx, pSurfaceGLX)) ++ return VA_STATUS_ERROR_OPERATION_FAILED; ++ ++ pSurfaceGLX->surface = VA_INVALID_SURFACE; ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus ++associate_surface( ++ VADriverContextP ctx, ++ VASurfaceGLXP pSurfaceGLX, ++ VASurfaceID surface, ++ unsigned int flags ++) ++{ ++ VAStatus status; ++ ++ /* XXX: optimise case where we are associating the same VA surface ++ as before an no changed occurred to it */ ++ status = deassociate_surface(ctx, pSurfaceGLX); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ ++ x11_trap_errors(); ++ status = ctx->vtable.vaPutSurface( ++ ctx, ++ surface, ++ pSurfaceGLX->pixmap, ++ 0, 0, pSurfaceGLX->width, pSurfaceGLX->height, ++ 0, 0, pSurfaceGLX->width, pSurfaceGLX->height, ++ NULL, 0, ++ flags ++ ); ++ XSync(ctx->x11_dpy, False); ++ if (x11_untrap_errors() != 0) ++ return VA_STATUS_ERROR_OPERATION_FAILED; ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ ++ pSurfaceGLX->surface = surface; ++ return VA_STATUS_SUCCESS; ++} ++ ++static inline VAStatus ++sync_surface(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) ++{ ++ if (pSurfaceGLX->surface == VA_INVALID_SURFACE) ++ return VA_STATUS_ERROR_INVALID_SURFACE; ++ ++ return ctx->vtable.vaSyncSurface(ctx, pSurfaceGLX->surface); ++} ++ ++static inline VAStatus ++begin_render_surface(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) ++{ ++ VAStatus status; ++ ++ status = sync_surface(ctx, pSurfaceGLX); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ ++ if (!bind_pixmap(ctx, pSurfaceGLX)) ++ return VA_STATUS_ERROR_OPERATION_FAILED; ++ ++ return VA_STATUS_SUCCESS; ++} ++ ++static inline VAStatus ++end_render_surface(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) ++{ ++ if (!unbind_pixmap(ctx, pSurfaceGLX)) ++ return VA_STATUS_ERROR_OPERATION_FAILED; ++ ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus ++copy_surface( ++ VADriverContextP ctx, ++ VASurfaceGLXP pSurfaceGLX, ++ VASurfaceID surface, ++ unsigned int flags ++) ++{ ++ VAStatus status; ++ ++ /* Associate VA surface */ ++ status = associate_surface(ctx, pSurfaceGLX, surface, flags); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ ++ /* Render to FBO */ ++ fbo_enter(ctx, pSurfaceGLX); ++ status = begin_render_surface(ctx, pSurfaceGLX); ++ if (status == VA_STATUS_SUCCESS) { ++ render_pixmap(ctx, pSurfaceGLX); ++ status = end_render_surface(ctx, pSurfaceGLX); ++ } ++ fbo_leave(ctx); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ ++ return deassociate_surface(ctx, pSurfaceGLX); ++} ++ ++static VAStatus ++vaCopySurfaceGLX_impl_libva( ++ VADriverContextP ctx, ++ void *gl_surface, ++ VASurfaceID surface, ++ unsigned int flags ++) ++{ ++ VASurfaceGLXP pSurfaceGLX; ++ VAStatus status; ++ struct OpenGLContextState old_cs; ++ ++ INIT_SURFACE(pSurfaceGLX, gl_surface); ++ ++ if (!gl_set_current_context(pSurfaceGLX->gl_context, &old_cs)) ++ return VA_STATUS_ERROR_OPERATION_FAILED; ++ ++ status = copy_surface(ctx, pSurfaceGLX, surface, flags); ++ ++ gl_set_current_context(&old_cs, NULL); ++ return status; ++} ++ ++#undef INIT_SURFACE ++ ++ ++/* ========================================================================= */ ++/* === Private VA/GLX vtable initialization === */ ++/* ========================================================================= */ ++ ++// Initialize GLX driver context ++VAStatus va_glx_init_context(VADriverContextP ctx) ++{ ++ VADriverContextGLXP glx_ctx = VA_DRIVER_CONTEXT_GLX(ctx); ++ VADriverVTableGLXP vtable = &glx_ctx->vtable; ++ int glx_major, glx_minor; ++ ++ if (glx_ctx->is_initialized) ++ return VA_STATUS_SUCCESS; ++ ++ if (ctx->vtable.glx && ctx->vtable.glx->vaCopySurfaceGLX) { ++ vtable->vaCreateSurfaceGLX = vaCreateSurfaceGLX_impl_driver; ++ vtable->vaDestroySurfaceGLX = vaDestroySurfaceGLX_impl_driver; ++ vtable->vaCopySurfaceGLX = vaCopySurfaceGLX_impl_driver; ++ } ++ else { ++ vtable->vaCreateSurfaceGLX = vaCreateSurfaceGLX_impl_libva; ++ vtable->vaDestroySurfaceGLX = vaDestroySurfaceGLX_impl_libva; ++ vtable->vaCopySurfaceGLX = vaCopySurfaceGLX_impl_libva; ++ ++ if (!glXQueryVersion(ctx->x11_dpy, &glx_major, &glx_minor)) ++ return VA_STATUS_ERROR_UNIMPLEMENTED; ++ if (glx_major < 1 || (glx_major == 1 && glx_minor < 3)) { /* GLX 1.3 */ ++ va_glx_error_message("GLX version 1.3 expected but only " ++ "version %d.%d is available\n", ++ glx_major, glx_minor); ++ return VA_STATUS_ERROR_UNIMPLEMENTED; ++ } ++ ++ if (!check_tfp_extensions(ctx) || !load_tfp_extensions(ctx)) ++ return VA_STATUS_ERROR_UNIMPLEMENTED; ++ ++ if (!check_fbo_extensions(ctx) || !load_fbo_extensions(ctx)) ++ return VA_STATUS_ERROR_UNIMPLEMENTED; ++ } ++ ++ glx_ctx->is_initialized = 1; ++ return VA_STATUS_SUCCESS; ++} +diff --git a/va/glx/va_glx_impl.h b/va/glx/va_glx_impl.h +new file mode 100644 +index 0000000..ca1095e +--- /dev/null ++++ b/va/glx/va_glx_impl.h +@@ -0,0 +1,37 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. 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. ++ */ ++ ++#ifndef VA_GLX_IMPL_H ++#define VA_GLX_IMPL_H ++ ++/** ++ * Initialize GLX driver context ++ * ++ * @param[in] ctx the VA driver context ++ * @return VA_STATUS_SUCCESS if successful ++ */ ++VAStatus va_glx_init_context(VADriverContextP ctx) ++ ATTRIBUTE_HIDDEN; ++ ++#endif /* VA_GLX_IMPL_H */ +diff --git a/va/glx/va_glx_private.h b/va/glx/va_glx_private.h +new file mode 100644 +index 0000000..6667de9 +--- /dev/null ++++ b/va/glx/va_glx_private.h +@@ -0,0 +1,76 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. 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. ++ */ ++ ++#ifndef VA_GLX_PRIVATE_H ++#define VA_GLX_PRIVATE_H ++ ++#include "config.h" ++#include "va.h" ++#include "va_backend.h" ++#include "va_x11.h" ++#include "va_glx.h" ++#include "va_backend_glx.h" ++ ++#if GLX_GLXEXT_VERSION < 18 ++typedef void (*PFNGLXBINDTEXIMAGEEXTPROC)(Display *, GLXDrawable, int, const int *); ++typedef void (*PFNGLXRELEASETEXIMAGEEXTPROC)(Display *, GLXDrawable, int); ++#endif ++ ++typedef struct VAOpenGLVTable *VAOpenGLVTableP; ++ ++struct VAOpenGLVTable { ++ PFNGLXBINDTEXIMAGEEXTPROC glx_bind_tex_image; ++ PFNGLXRELEASETEXIMAGEEXTPROC glx_release_tex_image; ++ PFNGLGENFRAMEBUFFERSEXTPROC gl_gen_framebuffers; ++ PFNGLDELETEFRAMEBUFFERSEXTPROC gl_delete_framebuffers; ++ PFNGLBINDFRAMEBUFFEREXTPROC gl_bind_framebuffer; ++ PFNGLGENRENDERBUFFERSEXTPROC gl_gen_renderbuffers; ++ PFNGLDELETERENDERBUFFERSEXTPROC gl_delete_renderbuffers; ++ PFNGLBINDRENDERBUFFEREXTPROC gl_bind_renderbuffer; ++ PFNGLRENDERBUFFERSTORAGEEXTPROC gl_renderbuffer_storage; ++ PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC gl_framebuffer_renderbuffer; ++ PFNGLFRAMEBUFFERTEXTURE2DEXTPROC gl_framebuffer_texture_2d; ++ PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC gl_check_framebuffer_status; ++}; ++ ++typedef struct VADisplayContextGLX *VADisplayContextGLXP; ++typedef struct VADriverContextGLX *VADriverContextGLXP; ++typedef struct VASurfaceGLX *VASurfaceGLXP; ++typedef struct VADriverVTableGLX *VADriverVTableGLXP; ++ ++typedef void (*vaDestroyFunc)(VADisplayContextP); ++ ++struct VADisplayContextGLX { ++ vaDestroyFunc vaDestroy; ++}; ++ ++#define VA_DRIVER_CONTEXT_GLX(ctx) ((VADriverContextGLXP)((ctx)->glx)) ++ ++struct VADriverContextGLX { ++ struct VADriverVTableGLX vtable; ++ struct VAOpenGLVTable gl_vtable; ++ unsigned int is_initialized : 1; ++}; ++ ++#endif /* VA_GLX_PRIVATE_H */ +diff --git a/va/va_backend.h b/va/va_backend.h +index ff86744..06fef7f 100644 +diff --git a/va/x11/va_x11.c b/va/x11/va_x11.c +index 71cc36f..6826b31 100644 diff -Nru libva-0.31.0+latest2/debian/patches/390_compat.base.patch libva-0.31.0+latest3/debian/patches/390_compat.base.patch --- libva-0.31.0+latest2/debian/patches/390_compat.base.patch 1970-01-01 01:00:00.000000000 +0100 +++ libva-0.31.0+latest3/debian/patches/390_compat.base.patch 2010-04-18 14:36:16.000000000 +0100 @@ -0,0 +1,143 @@ +commit 94db34ae392a7787afac9087799bb0421c844b83 +Author: Gwenole Beauchesne +Date: Wed Jun 24 11:40:56 2009 +0000 + + Add compatibility layer with original VA-API 0.29 to 0.31. + +diff --git a/va/Makefile.am b/va/Makefile.am +index ebff3d5..1752526 100644 +--- a/va/Makefile.am ++++ b/va/Makefile.am +@@ -57,7 +57,7 @@ SUBDIRS = $(libva_x11_backenddir) $(libva_glx_backenddir) + + DIST_SUBDIRS = x11 glx + +-libva_la_SOURCES = va.c va_crystalhd.c ++libva_la_SOURCES = va.c va_crystalhd.c va_compat.c + + libvaincludedir = ${includedir}/va + libvainclude_HEADERS = va.h va_x11.h va_backend.h va_version.h +@@ -67,4 +67,8 @@ DISTCLEANFILES = \ + + EXTRA_DIST = \ + va_version.h.in \ +- va_crystalhd.h ++ va_crystalhd.h \ ++ va_compat.h \ ++ va_compat_template.h ++ ++va_compat.c: va_compat_template.h +diff --git a/va/va.c b/va/va.c +index 0d208d8..ad201fa 100644 +--- a/va/va.c ++++ b/va/va.c +@@ -28,6 +28,7 @@ + #include "va.h" + #include "va_backend.h" + #include "va_crystalhd.h" ++#include "va_compat.h" + + #include + #include +@@ -39,6 +40,8 @@ + + + #define DRIVER_INIT_FUNC "__vaDriverInit_0_31" ++#define DRIVER_INIT_FUNC_0_29 "__vaDriverInit_0_29" ++#define DRIVER_INIT_FUNC_0_30 "__vaDriverInit_0_30" + + #define DRIVER_EXTENSION "_drv_video.so" + +@@ -163,13 +166,24 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name) + { + VADriverInit init_func; + char driver_init_func_sds[32]; ++ int compat_version = 0; + /* First, try SDS extensions (VDPAU and XvBA backends) */ + sprintf(driver_init_func_sds, "%s_%d_sds%d", + DRIVER_INIT_FUNC, VA_MICRO_VERSION, VA_SDS_VERSION); + init_func = (VADriverInit) dlsym(handle, driver_init_func_sds); + if (!init_func) + { ++ /* Otherwise, we need the compatibility layer for some buffers */ + init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC); ++ compat_version = VA_MINOR_VERSION; ++ if (!init_func) { ++ init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC_0_29); ++ compat_version = 29; ++ } ++ if (!init_func) { ++ init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC_0_30); ++ compat_version = 30; ++ } + } + if (!init_func) + { +@@ -178,7 +192,36 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name) + } + else + { +- vaStatus = (*init_func)(ctx); ++ struct VADriverContext_0_29 ctx_0_29; ++ struct VADriverContext_0_30 ctx_0_30; ++ void *compat_ctx = NULL; ++ ++ switch (compat_version) { ++ case 29: ++ compat_ctx = &ctx_0_29; ++ ctx_0_29.pDriverData = NULL; ++ ctx_0_29.x11_dpy = ctx->x11_dpy; ++ ctx_0_29.x11_screen = ctx->x11_screen; ++ break; ++ case 30: ++ compat_ctx = &ctx_0_30; ++ ctx_0_30.pDriverData = NULL; ++ ctx_0_30.x11_dpy = ctx->x11_dpy; ++ ctx_0_30.x11_screen = ctx->x11_screen; ++ break; ++ case VA_MINOR_VERSION: ++ compat_ctx = ctx; ++ break; ++ default: ++ ASSERT(compat_version == 0); ++ vaStatus = VA_STATUS_ERROR_UNKNOWN; ++ break; ++ } ++ ++ vaStatus = (*init_func)(compat_ctx ? compat_ctx : ctx); ++ ++ if (VA_STATUS_SUCCESS == vaStatus) ++ vaStatus = va_compat_init(dpy, compat_version, compat_ctx); + + if (VA_STATUS_SUCCESS == vaStatus) + { +@@ -399,6 +442,8 @@ VAStatus vaTerminate ( + old_ctx->handle = NULL; + } + ++ va_compat_fini(dpy); ++ + if (VA_STATUS_SUCCESS == vaStatus) + pDisplayContext->vaDestroy(pDisplayContext); + return vaStatus; +diff --git a/va/va_backend.h b/va/va_backend.h +index 06fef7f..9cf8911 100644 +--- a/va/va_backend.h ++++ b/va/va_backend.h +@@ -391,6 +391,7 @@ struct VADriverContext + + void *dri_state; + void *glx; /* opaque for GLX code */ ++ void *compat; /* opaque for compat code */ + }; + + #define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */ +diff --git a/va/va_compat.c b/va/va_compat.c +new file mode 100644 +index 0000000..af43188 +diff --git a/va/va_compat.h b/va/va_compat.h +new file mode 100644 +index 0000000..2c9d801 +diff --git a/va/va_compat_template.h b/va/va_compat_template.h +new file mode 100644 +index 0000000..18349de diff -Nru libva-0.31.0+latest2/debian/patches/391_compat.patch libva-0.31.0+latest3/debian/patches/391_compat.patch --- libva-0.31.0+latest2/debian/patches/391_compat.patch 1970-01-01 01:00:00.000000000 +0100 +++ libva-0.31.0+latest3/debian/patches/391_compat.patch 2010-04-18 14:36:16.000000000 +0100 @@ -0,0 +1,3214 @@ +commit 94db34ae392a7787afac9087799bb0421c844b83 +Author: Gwenole Beauchesne +Date: Wed Jun 24 11:40:56 2009 +0000 + + Add compatibility layer with original VA-API 0.29 to 0.31. + +diff --git a/va/Makefile.am b/va/Makefile.am +index ebff3d5..1752526 100644 +diff --git a/va/va.c b/va/va.c +index 0d208d8..ad201fa 100644 +diff --git a/va/va_backend.h b/va/va_backend.h +index 06fef7f..9cf8911 100644 +diff --git a/va/va_compat.c b/va/va_compat.c +new file mode 100644 +index 0000000..af43188 +--- /dev/null ++++ b/va/va_compat.c +@@ -0,0 +1,1178 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. 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. ++ */ ++ ++#include "config.h" ++#include "va.h" ++#include "va_compat.h" ++#include "va_backend.h" ++#include ++#include ++#include ++#include ++ ++#define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext) ++#define COMPAT_CTX(ctx) ((VACompatContextP)(ctx)->compat) ++#define ASSERT assert ++ ++/* Invoke the normal VA API entry-point. This one can be replaced with ++ one of the va_compat_*() functions */ ++#define VA_INVOKE(FUNC, CTX, ...) \ ++ (CTX)->vtable.FUNC(CTX, __VA_ARGS__) ++ ++/* Invoke the real VA API entry-point. That is, the driver's function */ ++#define VA_INVOKE_COMPAT_ARGS(CTX, ...) \ ++ (COMPAT_CTX(CTX)->compat_ctx, __VA_ARGS__) ++#define VA_INVOKE_COMPAT(FUNC, CTX, ...) \ ++ COMPAT_CTX(CTX)->vtable.FUNC VA_INVOKE_COMPAT_ARGS(CTX, __VA_ARGS__) ++ ++typedef struct VACompatContext *VACompatContextP; ++ ++typedef VAStatus (*VABufferTranslateFunc)(VACompatContextP ctx, void *dest, const void *src); ++ ++typedef enum { ++ VA_DRIVER_ID_UNKNOWN, ++ VA_DRIVER_ID_POULSBO, ++ VA_DRIVER_ID_IEGD ++} VADriverID; ++ ++typedef struct { ++ VABufferID id; ++ VABufferType type; ++ unsigned int size; ++ unsigned int num_elements; ++ unsigned char *data; ++ VABufferTranslateFunc translate; ++ VABufferID compat_id; ++ unsigned int compat_size; ++ unsigned char *compat_data; ++ unsigned int map_count; ++} VABufferCompat; ++ ++typedef struct VAContextMap *VAContextMapP; ++typedef struct VAContextMap { ++ VASurfaceID surface; ++ VAContextID context; ++ VAContextMapP next; ++} VAContextMap; ++ ++typedef struct { ++ VAStatus (*vaTerminate)(void *); ++ VAStatus (*vaQueryConfigProfiles)(void *, VAProfile *, int *); ++ VAStatus (*vaQueryConfigEntrypoints)(void *, VAProfile, VAEntrypoint *, int *); ++ VAStatus (*vaGetConfigAttributes)(void *, VAProfile, VAEntrypoint, VAConfigAttrib *, int); ++ VAStatus (*vaCreateConfig)(void *, VAProfile, VAEntrypoint, VAConfigAttrib *, int, VAConfigID *); ++ VAStatus (*vaDestroyConfig)(void *, VAConfigID); ++ VAStatus (*vaQueryConfigAttributes)(void *, VAConfigID, VAProfile *, VAEntrypoint *, VAConfigAttrib *, int *); ++ VAStatus (*vaCreateSurfaces)(void *, int, int, int, int, VASurfaceID *); ++ VAStatus (*vaDestroySurfaces)(void *, VASurfaceID *, int); ++ VAStatus (*vaCreateContext)(void *, VAConfigID, int, int, int, VASurfaceID *, int, VAContextID *); ++ VAStatus (*vaDestroyContext)(void *, VAContextID); ++ VAStatus (*vaCreateBuffer)(void *, VAContextID, VABufferType, unsigned int, unsigned int, void *, VABufferID *); ++ VAStatus (*vaBufferSetNumElements)(void *, VABufferID, unsigned int); ++ VAStatus (*vaMapBuffer)(void *, VABufferID, void **); ++ VAStatus (*vaUnmapBuffer)(void *, VABufferID); ++ VAStatus (*vaDestroyBuffer)(void *, VABufferID); ++ VAStatus (*vaBeginPicture)(void *, VAContextID, VASurfaceID); ++ VAStatus (*vaRenderPicture)(void *, VAContextID, VABufferID *, int); ++ VAStatus (*vaEndPicture)(void *, VAContextID); ++ VAStatus (*vaSyncSurface_pre31)(void *, VAContextID, VASurfaceID); ++ VAStatus (*vaQuerySurfaceStatus)(void *, VASurfaceID, VASurfaceStatus *); ++ VAStatus (*vaPutSurface)(void *, VASurfaceID, unsigned long, short, short, unsigned short, unsigned short, short, short, unsigned short, unsigned short, VARectangle *, unsigned int, unsigned int); ++ VAStatus (*vaQueryImageFormats)(void *, VAImageFormat *, int *); ++ VAStatus (*vaCreateImage)(void *, VAImageFormat *, int, int, VAImage *); ++ VAStatus (*vaDeriveImage)(void *, VASurfaceID, VAImage *); ++ VAStatus (*vaDestroyImage)(void *, VAImageID); ++ VAStatus (*vaSetImagePalette)(void *, VAImageID, unsigned char *); ++ VAStatus (*vaGetImage)(void *, VASurfaceID, int, int, unsigned int, unsigned int, VAImageID); ++ VAStatus (*vaPutImage_pre31)(void *, VASurfaceID, VAImageID, int, int, unsigned int, unsigned int, int, int); ++ VAStatus (*vaPutImage2_pre31)(void *, VASurfaceID, VAImageID, int, int, unsigned int, unsigned int, int, int, unsigned int, unsigned int); ++ VAStatus (*vaQuerySubpictureFormats)(void *, VAImageFormat *, unsigned int *, unsigned int *); ++ VAStatus (*vaCreateSubpicture)(void *, VAImageID, VASubpictureID *); ++ VAStatus (*vaDestroySubpicture)(void *, VASubpictureID); ++ VAStatus (*vaSetSubpictureImage)(void *, VASubpictureID, VAImageID); ++ VAStatus (*vaSetSubpictureChromakey)(void *, VASubpictureID, unsigned int, unsigned int, unsigned int); ++ VAStatus (*vaSetSubpictureGlobalAlpha)(void *, VASubpictureID, float); ++ VAStatus (*vaAssociateSubpicture_pre31)(void *, VASubpictureID, VASurfaceID *, int, short, short, short, short, unsigned short, unsigned short, unsigned int); ++ VAStatus (*vaAssociateSubpicture2_pre31)(void *, VASubpictureID, VASurfaceID *, int, short, short, unsigned short, unsigned short, short, short, unsigned short, unsigned short, unsigned int); ++ VAStatus (*vaDeassociateSubpicture)(void *, VASubpictureID, VASurfaceID *, int); ++ VAStatus (*vaQueryDisplayAttributes)(void *, VADisplayAttribute *, int *); ++ VAStatus (*vaGetDisplayAttributes)(void *, VADisplayAttribute *, int); ++ VAStatus (*vaSetDisplayAttributes)(void *, VADisplayAttribute *, int); ++ ++ /* 0.29 hooks */ ++ VAStatus (*vaSetSubpicturePalette)(void *, VASubpictureID, unsigned char *); ++ VAStatus (*vaDbgCopySurfaceToBuffer)(void *, VASurfaceID, void **, unsigned int *); ++ ++ /* 0.30 hooks */ ++ VAStatus (*vaCreateSurfaceFromCIFrame)(void *, unsigned long, VASurfaceID *); ++ VAStatus (*vaCreateSurfaceFromV4L2Buf)(void *, int, struct v4l2_format *, struct v4l2_buffer *, VASurfaceID *); ++ VAStatus (*vaCopySurfaceToBuffer)(void *, VASurfaceID, unsigned int *, unsigned int *, unsigned int *, unsigned int *, unsigned int *, unsigned int *, unsigned int *, void **); ++ ++ /* 0.31 hooks */ ++ VAStatus (*vaPutImage)(void *, VASurfaceID, VAImageID, int, int, unsigned int, unsigned int, int, int, unsigned int, unsigned int); ++ VAStatus (*vaAssociateSubpicture)(void *, VASubpictureID, VASurfaceID *, int, short, short, unsigned short, unsigned short, short, short, unsigned short, unsigned short, unsigned int); ++ VAStatus (*vaSyncSurface)(void *, VASurfaceID); ++} VACompatDriverVTable; ++ ++typedef struct VACompatContext { ++ VABufferCompat *buffers; ++ unsigned int buffers_count_max; ++ unsigned int compat_version; ++ void *compat_ctx; ++ VACompatDriverVTable vtable; /* original vtable */ ++ VADriverID driver_id; ++ char *driver_name; ++ VAContextMapP context_map; ++ VAContextMapP last_context_map_match; ++ unsigned int skip_frame : 1; ++} VACompatContext; ++ ++#define COMPAT_MAJOR 0 ++#define COMPAT_MINOR 29 ++#include "va_compat_template.h" ++ ++#define COMPAT_MAJOR 0 ++#define COMPAT_MINOR 30 ++#include "va_compat_template.h" ++ ++#define COMPAT_MAJOR 0 ++#define COMPAT_MINOR 31 ++#include "va_compat_template.h" ++ ++static inline int va_IsIntelBuffer(VADriverContextP ctx, VABufferID id) ++{ ++ VACompatContextP compat = ctx->compat; ++ ++ if (compat->driver_id == VA_DRIVER_ID_POULSBO) { ++ /* There were only Intel implementations for VA API. Besides, the ++ returned buffer IDs had the following format [ 0 BASE ID ] where ++ BASE is the 7-bit value 0x04 and ID an index into the heap of ++ objects */ ++ return (id & 0x7f000000) == 0x04000000; ++ } ++ ++ if (compat->driver_id == VA_DRIVER_ID_IEGD) { ++ /* XXX: there is no means to differentiate the buffers, they ++ are linearly generated (IEGD 10.0 build 1335) */ ++ return 1; ++ } ++ ++ return 0; ++} ++ ++static VAContextMapP va_context_map_lookup_p( ++ VACompatContextP ctx, ++ VASurfaceID surface ++) ++{ ++ VAContextMapP m = ctx->context_map; ++ ++ while (m) { ++ if (m->surface == surface) ++ return m; ++ m = m->next; ++ } ++ return NULL; ++} ++ ++static VAContextID va_context_map_lookup( ++ VACompatContextP ctx, ++ VASurfaceID surface ++) ++{ ++ VAContextMapP m; ++ ++ /* Lookup in cached */ ++ m = ctx->last_context_map_match; ++ if (m && m->surface == surface) ++ return m->context; ++ ++ /* Full (slow) lookup */ ++ m = va_context_map_lookup_p(ctx, surface); ++ if (m) { ++ ctx->last_context_map_match = m; ++ return m->context; ++ } ++ return VA_INVALID_ID; ++} ++ ++static void va_context_map_add( ++ VACompatContextP ctx, ++ VAContextID context, ++ VASurfaceID surface ++) ++{ ++ VAContextMapP m; ++ ++ /* Update existing entry */ ++ m = va_context_map_lookup_p(ctx, surface); ++ if (m) { ++ m->context = context; ++ return; ++ } ++ ++ /* Create new mapping */ ++ m = malloc(sizeof(*m)); ++ ASSERT(m); ++ if (m) { ++ m->surface = surface; ++ m->context = context; ++ m->next = ctx->context_map; ++ ctx->context_map = m; ++ } ++} ++ ++static void va_context_map_remove( ++ VACompatContextP ctx, ++ VAContextID context ++) ++{ ++ VAContextMapP p = NULL; ++ VAContextMapP m = ctx->context_map; ++ VAContextMapP d; ++ ++ while (m) { ++ if (m->context == context) { ++ d = m; ++ ++ /* Unlink current node */ ++ if (p) ++ p->next = m->next; ++ else ++ ctx->context_map = m->next; ++ m = m->next; ++ ++ /* Reset cache */ ++ if (ctx->last_context_map_match == d) ++ ctx->last_context_map_match = NULL; ++ ++ free(d); ++ } ++ else { ++ p = m; ++ m = m->next; ++ } ++ } ++} ++ ++static VABufferCompat *va_GetBufferCompat ( ++ VADriverContextP ctx, ++ VABufferID id ++) ++{ ++ VACompatContextP compat = ctx->compat; ++ int index; ++ ++ if (!va_IsIntelBuffer(ctx, id)) ++ return NULL; ++ ++ index = id & 0x00ffffff; ++ if (index >= compat->buffers_count_max) ++ return NULL; ++ ++ if (compat->buffers[index].id != id) ++ return NULL; ++ ++ return &compat->buffers[index]; ++} ++ ++static VAStatus va_TranslateBufferCompat ( ++ VADriverContextP ctx, ++ VABufferCompat *compat_buffer ++) ++{ ++ VAStatus status; ++ unsigned char *src, *dest; ++ int i; ++ ++ status = VA_INVOKE(vaMapBuffer, ctx, compat_buffer->id, (void **)&src); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ ++ ASSERT(compat_buffer->data); ++ ASSERT(src == compat_buffer->data); ++ ASSERT(compat_buffer->compat_data); ++ dest = compat_buffer->compat_data; ++ for (i = 0; i < compat_buffer->num_elements; i++) ++ { ++ /* XXX: check errors */ ++ status = compat_buffer->translate(ctx->compat, dest, src); ++ ++ src += compat_buffer->size; ++ dest += compat_buffer->compat_size; ++ } ++ ++ return VA_INVOKE(vaUnmapBuffer, ctx, compat_buffer->id); ++} ++ ++static VAStatus va_CreateBufferCompat ( ++ VADriverContextP ctx, ++ VAContextID context, ++ VABufferID id, ++ VABufferType type, ++ unsigned int size, ++ unsigned int num_elements, ++ unsigned int compat_size, ++ VABufferTranslateFunc translate_func ++) ++{ ++ VACompatContextP compat = ctx->compat; ++ VABufferCompat *compat_buffer; ++ int index; ++ ++ if (!va_IsIntelBuffer(ctx, id)) ++ return VA_STATUS_ERROR_INVALID_BUFFER; ++ index = id & 0x00ffffff; ++ ++ /* XXX: this allocation strategy is not really space efficient... */ ++ if (index >= compat->buffers_count_max) ++ { ++ compat->buffers_count_max = index + 1; ++ compat->buffers = realloc(compat->buffers, ++ (compat->buffers_count_max * ++ sizeof(VABufferCompat))); ++ if (compat->buffers == NULL) ++ return VA_STATUS_ERROR_ALLOCATION_FAILED; ++ } ++ ++ compat_buffer = &compat->buffers[index]; ++ compat_buffer->id = id; ++ compat_buffer->type = type; ++ compat_buffer->size = size; ++ compat_buffer->num_elements = num_elements; ++ compat_buffer->data = NULL; ++ compat_buffer->translate = translate_func; ++ compat_buffer->compat_size = compat_size; ++ compat_buffer->compat_data = NULL; ++ compat_buffer->map_count = 0; ++ ++ return VA_INVOKE_COMPAT(vaCreateBuffer, ++ ctx, ++ context, ++ type, ++ compat_size, ++ num_elements, ++ NULL, ++ &compat_buffer->compat_id); ++} ++ ++static VAStatus va_DestroyBufferCompat ( ++ VADriverContextP ctx, ++ VABufferID id ++) ++{ ++ VABufferCompat *compat_buffer; ++ VAStatus status; ++ ++ if ((compat_buffer = va_GetBufferCompat(ctx, id)) == NULL) ++ return VA_STATUS_SUCCESS; ++ ++ /* Force unmap if there were more maps than unmaps */ ++ if (compat_buffer->map_count > 1) ++ compat_buffer->map_count = 1; ++ if (compat_buffer->map_count > 1) ++ { ++ if ((status = VA_INVOKE(vaUnmapBuffer, ctx, id)) != VA_STATUS_SUCCESS) ++ return status; ++ } ++ ++ compat_buffer->id = 0; ++ return VA_INVOKE_COMPAT(vaDestroyBuffer, ctx, compat_buffer->compat_id); ++} ++ ++static VAStatus va_compat_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 */ ++) ++{ ++ VABufferTranslateFunc translate_func = NULL; ++ unsigned int compat_size = 0; ++ VAStatus status; ++ ++ status = VA_INVOKE_COMPAT(vaCreateBuffer, ++ ctx, ++ context, ++ type, ++ size, ++ num_elements, ++ data, ++ buf_id); ++ ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ ++#define INIT_TRANSLATE_FUNC_(STRUCT, MAJOR, MINOR) do { \ ++ translate_func = va_compat_translate_VA##STRUCT##_##MAJOR##_##MINOR; \ ++ compat_size = sizeof(VA##STRUCT##_##MAJOR##_##MINOR); \ ++} while (0) ++#define INIT_TRANSLATE_FUNC(BUFFER, CODEC, MAJOR, MINOR) \ ++ INIT_TRANSLATE_FUNC_(BUFFER##Buffer##CODEC, MAJOR, MINOR) ++ ++ /* XXX: this assumes all structures have different sizes from each other */ ++ switch (size) { ++ case sizeof(VAPictureParameterBufferH264): ++ if (type == VAPictureParameterBufferType && ctx->version_major == 0) ++ { ++ switch (ctx->version_minor) { ++ case 29: INIT_TRANSLATE_FUNC(PictureParameter,H264, 0,29); break; ++ case 30: INIT_TRANSLATE_FUNC(PictureParameter,H264, 0,30); break; ++ } ++ } ++ break; ++ case sizeof(VASliceParameterBufferH264): ++ if (type == VASliceParameterBufferType && ctx->version_major == 0) ++ { ++ switch (ctx->version_minor) { ++ case 29: INIT_TRANSLATE_FUNC(SliceParameter,H264, 0,29); break; ++ case 30: INIT_TRANSLATE_FUNC(SliceParameter,H264, 0,30); break; ++ } ++ } ++ break; ++ case sizeof(VAPictureParameterBufferVC1): ++ if (type == VAPictureParameterBufferType && ctx->version_major == 0) ++ { ++ switch (ctx->version_minor) { ++ case 29: INIT_TRANSLATE_FUNC(PictureParameter,VC1, 0,29); break; ++ case 30: INIT_TRANSLATE_FUNC(PictureParameter,VC1, 0,30); break; ++ } ++ } ++ break; ++ case sizeof(VAPictureParameterBufferMPEG2): ++ if (type == VAPictureParameterBufferType && ctx->version_major == 0) ++ { ++ switch (ctx->version_minor) { ++ case 29: INIT_TRANSLATE_FUNC(PictureParameter,MPEG2, 0,29); break; ++ case 30: INIT_TRANSLATE_FUNC(PictureParameter,MPEG2, 0,30); break; ++ } ++ } ++ break; ++ case sizeof(VASliceParameterBufferMPEG2): ++ if (type == VASliceParameterBufferType && ctx->version_major == 0) ++ { ++ switch (ctx->version_minor) { ++ case 29: INIT_TRANSLATE_FUNC(SliceParameter,MPEG2, 0,29); break; ++ case 30: INIT_TRANSLATE_FUNC(SliceParameter,MPEG2, 0,30); break; ++ } ++ } ++ break; ++ case sizeof(VAPictureParameterBufferMPEG4): ++ if (type == VAPictureParameterBufferType && ctx->version_major == 0) ++ { ++ switch (ctx->version_minor) { ++ case 29: INIT_TRANSLATE_FUNC(PictureParameter,MPEG4, 0,29); break; ++ case 30: INIT_TRANSLATE_FUNC(PictureParameter,MPEG4, 0,30); break; ++ case 31: INIT_TRANSLATE_FUNC(PictureParameter,MPEG4, 0,31); break; ++ } ++ } ++ break; ++ case sizeof(VAEncSliceParameterBuffer): ++ if (type == VAEncSliceParameterBufferType && ctx->version_major == 0) ++ { ++ switch (ctx->version_minor) { ++ case 30: INIT_TRANSLATE_FUNC_(EncSliceParameterBuffer, 0,30); break; ++ } ++ } ++ break; ++ } ++ ++#undef INIT_TRANSLATE_FUNC ++ ++ /* Create thunk */ ++ if (buf_id && translate_func) ++ { ++ ASSERT(compat_size > 0); ++ ++ status = va_CreateBufferCompat(ctx, ++ context, ++ *buf_id, ++ type, ++ size, ++ num_elements, ++ compat_size, ++ translate_func); ++ } ++ ++ return status; ++} ++ ++static VAStatus va_compat_BufferSetNumElements ( ++ VADriverContextP ctx, ++ VABufferID buf_id, /* in */ ++ unsigned int num_elements /* in */ ++) ++{ ++ VABufferCompat *compat_buffer; ++ VAStatus status; ++ ++ status = VA_INVOKE_COMPAT(vaBufferSetNumElements, ctx, buf_id, num_elements); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ ++ if ((compat_buffer = va_GetBufferCompat(ctx, buf_id)) != NULL) ++ { ++ compat_buffer->num_elements = num_elements; ++ status = VA_INVOKE_COMPAT(vaBufferSetNumElements, ++ ctx, ++ compat_buffer->compat_id, ++ num_elements); ++ } ++ ++ return status; ++} ++ ++static VAStatus va_compat_DestroyBuffer ( ++ VADriverContextP ctx, ++ VABufferID buffer_id ++) ++{ ++ VAStatus status; ++ if ((status = va_DestroyBufferCompat(ctx, buffer_id)) != VA_STATUS_SUCCESS) ++ return status; ++ ++ return VA_INVOKE_COMPAT(vaDestroyBuffer, ctx, buffer_id); ++} ++ ++static VAStatus va_compat_MapBuffer ( ++ VADriverContextP ctx, ++ VABufferID buf_id, /* in */ ++ void **pbuf /* out */ ++) ++{ ++ VABufferCompat *compat_buffer; ++ VAStatus status; ++ ++ if ((compat_buffer = va_GetBufferCompat(ctx, buf_id)) == NULL) ++ return VA_INVOKE_COMPAT(vaMapBuffer, ctx, buf_id, pbuf); ++ ++ if (compat_buffer->map_count++ == 0) ++ { ++ status = VA_INVOKE_COMPAT(vaMapBuffer, ctx, buf_id, (void **)&compat_buffer->data); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ ++ status = VA_INVOKE_COMPAT(vaMapBuffer, ctx, compat_buffer->compat_id, (void **)&compat_buffer->compat_data); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ } ++ ++ if (pbuf) ++ *pbuf = compat_buffer->data; ++ ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus va_compat_UnmapBuffer ( ++ VADriverContextP ctx, ++ VABufferID buf_id /* in */ ++) ++{ ++ VABufferCompat *compat_buffer; ++ VAStatus status; ++ ++ if ((compat_buffer = va_GetBufferCompat(ctx, buf_id)) == NULL) ++ return VA_INVOKE_COMPAT(vaUnmapBuffer, ctx, buf_id); ++ ++ if (--compat_buffer->map_count == 0) ++ { ++ status = VA_INVOKE_COMPAT(vaUnmapBuffer, ctx, compat_buffer->compat_id); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ compat_buffer->compat_data = NULL; ++ ++ status = VA_INVOKE_COMPAT(vaUnmapBuffer, ctx, compat_buffer->id); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ compat_buffer->data = NULL; ++ } ++ ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus va_compat_BeginPicture ( ++ VADriverContextP ctx, ++ VAContextID context, ++ VASurfaceID render_target ++) ++{ ++ VACompatContextP compat = ctx->compat; ++ compat->skip_frame = 0; ++ return VA_INVOKE_COMPAT(vaBeginPicture, ctx, context, render_target); ++} ++ ++static VAStatus va_compat_EndPicture ( ++ VADriverContextP ctx, ++ VAContextID context ++) ++{ ++ VACompatContextP compat = ctx->compat; ++ VAStatus status = VA_INVOKE_COMPAT(vaEndPicture, ctx, context); ++ ++ /* Ignore errors if the HW decoder did not handle VC-1 skipped P-frames */ ++ if (compat->skip_frame && status == VA_STATUS_ERROR_UNKNOWN) ++ status = VA_STATUS_SUCCESS; ++ ++ return status; ++} ++ ++static VAStatus va_compat_RenderPicture ( ++ VADriverContextP ctx, ++ VAContextID context, ++ VABufferID *buffers, ++ int num_buffers ++) ++{ ++ VACompatContextP compat = ctx->compat; ++ VABufferCompat *compat_buffer; ++ VABufferID *compat_buffer_ids; ++ VAStatus status; ++ int i, n; ++ ++ if ((n = num_buffers) < 1) ++ n = 1; ++ compat_buffer_ids = alloca(n * sizeof(compat_buffer_ids[0])); ++ ++ for (i = 0; i < num_buffers; i++) ++ { ++ if ((compat_buffer = va_GetBufferCompat(ctx, buffers[i])) == NULL) ++ compat_buffer_ids[i] = buffers[i]; ++ else ++ { ++ status = va_TranslateBufferCompat(ctx, compat_buffer); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ compat_buffer_ids[i] = compat_buffer->compat_id; ++ } ++ } ++ ++ if (!compat->skip_frame) ++ { ++ status = VA_INVOKE_COMPAT(vaRenderPicture, ctx, context, compat_buffer_ids, num_buffers); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ } ++ ++ /* Buffers are automatically destroyed afterwards */ ++ for (i = 0; i < num_buffers; i++) ++ { ++ if ((compat_buffer = va_GetBufferCompat(ctx, buffers[i])) != NULL) ++ { ++ status = VA_INVOKE_COMPAT(vaDestroyBuffer, ctx, compat_buffer->id); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ } ++ } ++ ++ return VA_STATUS_SUCCESS; ++} ++ ++#define DEFINE_VTABLE_ENTRY_(RETVAL, PROC, ARGS, COMPAT_PROC, COMPAT_ARGS, COMPAT_PRE, COMPAT_POST) \ ++static RETVAL va_compat_##PROC ARGS \ ++{ \ ++ if (COMPAT_CTX(ctx)->vtable.va##COMPAT_PROC == NULL) \ ++ return VA_STATUS_ERROR_OPERATION_FAILED; \ ++ COMPAT_PRE; \ ++ RETVAL ret = COMPAT_CTX(ctx)->vtable.va##COMPAT_PROC VA_INVOKE_COMPAT_ARGS COMPAT_ARGS; \ ++ COMPAT_POST; \ ++ return ret; \ ++} ++ ++#define DEFINE_VTABLE_ENTRY(RETVAL, PROC, DECL_ARGS, CALL_ARGS) \ ++DEFINE_VTABLE_ENTRY_(RETVAL, PROC, DECL_ARGS, PROC, CALL_ARGS, {}, {}) ++ ++static VAStatus va_compat_Terminate(VADriverContextP ctx) ++{ ++ if (COMPAT_CTX(ctx)->vtable.vaTerminate == NULL) ++ return VA_STATUS_ERROR_OPERATION_FAILED; ++ return COMPAT_CTX(ctx)->vtable.vaTerminate(COMPAT_CTX(ctx)->compat_ctx); ++} ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, QueryConfigProfiles, ++ (VADriverContextP ctx, VAProfile *profile_list, int *num_profiles), ++ (ctx, profile_list, num_profiles)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, QueryConfigEntrypoints, ++ (VADriverContextP ctx, VAProfile profile, ++ VAEntrypoint *entrypoint_list, int *num_entrypoints), ++ (ctx, profile, entrypoint_list, num_entrypoints)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, GetConfigAttributes, ++ (VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, ++ VAConfigAttrib *attrib_list, int num_attribs), ++ (ctx, profile, entrypoint, attrib_list, num_attribs)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, CreateConfig, ++ (VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, ++ VAConfigAttrib *attrib_list, int num_attribs, VAConfigID *config_id), ++ (ctx, profile, entrypoint, attrib_list, num_attribs, config_id)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, DestroyConfig, ++ (VADriverContextP ctx, VAConfigID config_id), ++ (ctx, config_id)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, QueryConfigAttributes, ++ (VADriverContextP ctx, VAConfigID config_id, VAProfile *profile, ++ VAEntrypoint *entrypoint, VAConfigAttrib *attrib_list, int *num_attribs), ++ (ctx, config_id, profile, entrypoint, attrib_list, num_attribs)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, CreateSurfaces, ++ (VADriverContextP ctx, int width, int height, int format, ++ int num_surfaces, VASurfaceID *surfaces), ++ (ctx, width, height, format, num_surfaces, surfaces)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, DestroySurfaces, ++ (VADriverContextP ctx, VASurfaceID *surface_list, int num_surfaces), ++ (ctx, surface_list, num_surfaces)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, CreateContext, ++ (VADriverContextP ctx, VAConfigID config_id, ++ int picture_width, int picture_height, int flag, ++ VASurfaceID *render_targets, int num_render_targets, VAContextID *context), ++ (ctx, config_id, picture_width, picture_height, flag, ++ render_targets, num_render_targets, context)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, DestroyContext, ++ (VADriverContextP ctx, VAContextID context), ++ (ctx, context)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, SyncSurface, ++ (VADriverContextP ctx, VASurfaceID render_target), ++ (ctx, render_target)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, QuerySurfaceStatus, ++ (VADriverContextP ctx, VASurfaceID render_target, VASurfaceStatus *status), ++ (ctx, render_target, status)) ++ ++DEFINE_VTABLE_ENTRY_( ++ VAStatus, PutSurface, ++ (VADriverContextP ctx, VASurfaceID surface, Drawable draw, ++ short srcx, short srcy, unsigned short srcw, unsigned short srch, ++ short destx, short desty, unsigned short destw, unsigned short desth, ++ VARectangle *cliprects, unsigned int number_cliprects, unsigned int flags), ++ PutSurface, ++ (ctx, surface, draw, srcx, srcy, srcw, srch, destx, desty, destw, desth, ++ cliprects, number_cliprects, flags), ++ { ++ if (COMPAT_CTX(ctx)->compat_version < 30) /* 0.30 */ ++ flags &= (VA_TOP_FIELD|VA_BOTTOM_FIELD|VA_CLEAR_DRAWABLE); ++ }, ++ {}) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, QueryImageFormats, ++ (VADriverContextP ctx, VAImageFormat *format_list, int *num_formats), ++ (ctx, format_list, num_formats)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, CreateImage, ++ (VADriverContextP ctx, VAImageFormat *format, ++ int width, int height, VAImage *image), ++ (ctx, format, width, height, image)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, DeriveImage, ++ (VADriverContextP ctx, VASurfaceID surface, VAImage *image), ++ (ctx, surface, image)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, DestroyImage, ++ (VADriverContextP ctx, VAImageID image), ++ (ctx, image)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, SetImagePalette, ++ (VADriverContextP ctx, VAImageID image, unsigned char *palette), ++ (ctx, image, palette)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, GetImage, ++ (VADriverContextP ctx, VASurfaceID surface, ++ int x, int y, unsigned int width, unsigned int height, VAImageID image), ++ (ctx, surface, x, y, width, height, image)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, PutImage, ++ (VADriverContextP ctx, VASurfaceID surface, VAImageID image, ++ int srcx, int srcy, unsigned int srcw, unsigned int srch, ++ int destx, int desty, unsigned int destw, unsigned int desth), ++ (ctx, surface, image, srcx, srcy, srcw, srch, destx, desty, destw, desth)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, QuerySubpictureFormats, ++ (VADriverContextP ctx, VAImageFormat *format_list, ++ unsigned int *flags, unsigned int *num_formats), ++ (ctx, format_list, flags, num_formats)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, CreateSubpicture, ++ (VADriverContextP ctx, VAImageID image, VASubpictureID *subpicture), ++ (ctx, image, subpicture)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, DestroySubpicture, ++ (VADriverContextP ctx, VASubpictureID subpicture), ++ (ctx, subpicture)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, SetSubpictureImage, ++ (VADriverContextP ctx, VASubpictureID subpicture, VAImageID image), ++ (ctx, subpicture, image)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, SetSubpictureChromakey, ++ (VADriverContextP ctx, VASubpictureID subpicture, ++ unsigned int chromakey_min, ++ unsigned int chromakey_max, ++ unsigned int chromakey_mask), ++ (ctx, subpicture, chromakey_min, chromakey_max, chromakey_mask)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, SetSubpictureGlobalAlpha, ++ (VADriverContextP ctx, VASubpictureID subpicture, float global_alpha), ++ (ctx, subpicture, global_alpha)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, AssociateSubpicture, ++ (VADriverContextP ctx, VASubpictureID subpicture, ++ VASurfaceID *target_surfaces, int num_surfaces, ++ short srcx, short srcy, unsigned short srcw, unsigned short srch, ++ short destx, short desty, unsigned short destw, unsigned short desth, ++ unsigned int flags), ++ (ctx, subpicture, target_surfaces, num_surfaces, ++ srcx, srcy, srcw, srch, destx, desty, destw, desth, flags)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, DeassociateSubpicture, ++ (VADriverContextP ctx, VASubpictureID subpicture, ++ VASurfaceID *target_surfaces, int num_surfaces), ++ (ctx, subpicture, target_surfaces, num_surfaces)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, QueryDisplayAttributes, ++ (VADriverContextP ctx, VADisplayAttribute *attr_list, int *num_attributes), ++ (ctx, attr_list, num_attributes)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, GetDisplayAttributes, ++ (VADriverContextP ctx, VADisplayAttribute *attr_list, int num_attributes), ++ (ctx, attr_list, num_attributes)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, SetDisplayAttributes, ++ (VADriverContextP ctx, VADisplayAttribute *attr_list, int num_attributes), ++ (ctx, attr_list, num_attributes)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, CreateSurfaceFromCIFrame, ++ (VADriverContextP ctx, unsigned long frame_id, VASurfaceID *surface), ++ (ctx, frame_id, surface)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, CreateSurfaceFromV4L2Buf, ++ (VADriverContextP ctx, int v4l2_fd, ++ struct v4l2_format *v4l2_fmt, struct v4l2_buffer *v4l2_buf, ++ VASurfaceID *surface), ++ (ctx, v4l2_fd, v4l2_fmt, v4l2_buf, surface)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, CopySurfaceToBuffer, ++ (VADriverContextP ctx, VASurfaceID surface, unsigned int *fourcc, ++ 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), ++ (ctx, surface, fourcc, ++ luma_stride, chroma_u_stride, chroma_v_stride, ++ luma_offset, chroma_u_offset, chroma_v_offset, ++ buffer)) ++ ++DEFINE_VTABLE_ENTRY_( ++ VAStatus, SyncSurface_pre31, ++ (VADriverContextP ctx, VASurfaceID render_target), ++ SyncSurface_pre31, ++ (ctx, va_context_map_lookup(COMPAT_CTX(ctx), render_target), render_target), ++ {}, {}) ++ ++DEFINE_VTABLE_ENTRY_( ++ VAStatus, PutImage_pre31, ++ (VADriverContextP ctx, VASurfaceID surface, VAImageID image, ++ int srcx, int srcy, unsigned int srcw, unsigned int srch, ++ int destx, int desty, unsigned int destw, unsigned int desth), ++ PutImage2_pre31, ++ (ctx, surface, image, srcx, srcy, srcw, srch, destx, desty, destw, desth), ++ {}, {}) ++ ++DEFINE_VTABLE_ENTRY_( ++ VAStatus, AssociateSubpicture_pre31, ++ (VADriverContextP ctx, VASubpictureID subpicture, ++ VASurfaceID *target_surfaces, int num_surfaces, ++ short srcx, short srcy, unsigned short srcw, unsigned short srch, ++ short destx, short desty, unsigned short destw, unsigned short desth, ++ unsigned int flags), ++ AssociateSubpicture2_pre31, ++ (ctx, subpicture, target_surfaces, num_surfaces, ++ srcx, srcy, srcw, srch, destx, desty, destw, desth, flags), ++ {}, {}) ++ ++DEFINE_VTABLE_ENTRY_( ++ VAStatus, CreateContext_pre31, ++ (VADriverContextP ctx, VAConfigID config_id, ++ int picture_width, int picture_height, int flag, ++ VASurfaceID *render_targets, int num_render_targets, VAContextID *context), ++ CreateContext, ++ (ctx, config_id, picture_width, picture_height, flag, ++ render_targets, num_render_targets, context), ++ {}, { ++ VACompatContextP const compat_ctx = COMPAT_CTX(ctx); ++ int i; ++ for (i = 0; i < num_render_targets; i++) ++ va_context_map_add(compat_ctx, *context, render_targets[i]); ++ }) ++ ++DEFINE_VTABLE_ENTRY_( ++ VAStatus, DestroyContext_pre31, ++ (VADriverContextP ctx, VAContextID context), ++ DestroyContext, ++ (ctx, context), ++ {}, { va_context_map_remove(COMPAT_CTX(ctx), context); }) ++ ++#undef DEFINE_VTABLE_ENTRY ++#undef DEFINE_VTABLE_ENTRY_ ++ ++static void va_compat_init_VADriverVTable(VADriverContextP ctx, int compat_version) ++{ ++#define INIT_VTABLE_(CTX, DST_PROC, SRC_PROC) \ ++ (CTX)->vtable.va##DST_PROC = va_compat_##SRC_PROC ++#define INIT_VTABLE(CTX, PROC) \ ++ INIT_VTABLE_(CTX, PROC, PROC) ++ ++ INIT_VTABLE(ctx, Terminate); ++ INIT_VTABLE(ctx, QueryConfigProfiles); ++ INIT_VTABLE(ctx, QueryConfigEntrypoints); ++ INIT_VTABLE(ctx, GetConfigAttributes); ++ INIT_VTABLE(ctx, CreateConfig); ++ INIT_VTABLE(ctx, DestroyConfig); ++ INIT_VTABLE(ctx, QueryConfigAttributes); ++ INIT_VTABLE(ctx, CreateSurfaces); ++ INIT_VTABLE(ctx, DestroySurfaces); ++ INIT_VTABLE(ctx, CreateContext); ++ INIT_VTABLE(ctx, DestroyContext); ++ INIT_VTABLE(ctx, CreateBuffer); ++ INIT_VTABLE(ctx, BufferSetNumElements); ++ INIT_VTABLE(ctx, MapBuffer); ++ INIT_VTABLE(ctx, UnmapBuffer); ++ INIT_VTABLE(ctx, DestroyBuffer); ++ INIT_VTABLE(ctx, BeginPicture); ++ INIT_VTABLE(ctx, RenderPicture); ++ INIT_VTABLE(ctx, EndPicture); ++ INIT_VTABLE(ctx, SyncSurface); ++ INIT_VTABLE(ctx, QuerySurfaceStatus); ++ INIT_VTABLE(ctx, PutSurface); ++ INIT_VTABLE(ctx, QueryImageFormats); ++ INIT_VTABLE(ctx, CreateImage); ++ INIT_VTABLE(ctx, DeriveImage); ++ INIT_VTABLE(ctx, DestroyImage); ++ INIT_VTABLE(ctx, SetImagePalette); ++ INIT_VTABLE(ctx, GetImage); ++ INIT_VTABLE(ctx, PutImage); ++ INIT_VTABLE(ctx, QuerySubpictureFormats); ++ INIT_VTABLE(ctx, CreateSubpicture); ++ INIT_VTABLE(ctx, DestroySubpicture); ++ INIT_VTABLE(ctx, SetSubpictureImage); ++ INIT_VTABLE(ctx, SetSubpictureChromakey); ++ INIT_VTABLE(ctx, SetSubpictureGlobalAlpha); ++ INIT_VTABLE(ctx, AssociateSubpicture); ++ INIT_VTABLE(ctx, DeassociateSubpicture); ++ INIT_VTABLE(ctx, QueryDisplayAttributes); ++ INIT_VTABLE(ctx, GetDisplayAttributes); ++ INIT_VTABLE(ctx, SetDisplayAttributes); ++ INIT_VTABLE(ctx, CreateSurfaceFromCIFrame); ++ INIT_VTABLE(ctx, CreateSurfaceFromV4L2Buf); ++ INIT_VTABLE(ctx, CopySurfaceToBuffer); ++ ++ if (compat_version && compat_version < 31) { ++ INIT_VTABLE_(ctx, CreateContext, CreateContext_pre31); ++ INIT_VTABLE_(ctx, DestroyContext, DestroyContext_pre31); ++ INIT_VTABLE_(ctx, SyncSurface, SyncSurface_pre31); ++ INIT_VTABLE_(ctx, PutImage, PutImage_pre31); ++ INIT_VTABLE_(ctx, AssociateSubpicture, AssociateSubpicture_pre31); ++ } ++ ++#undef INIT_VTABLE ++#undef INIT_VTABLE__ ++} ++ ++VAStatus va_compat_init(VADisplay dpy, int compat_version, void *compat_ctx) ++{ ++ VADisplayContextP pDisplayContext = (VADisplayContextP)dpy; ++ VADriverContextP ctx = CTX(dpy); ++ VADriverContextP_0_29 ctx_0_29; ++ VADriverContextP_0_30 ctx_0_30; ++ VACompatContextP compat; ++ VAStatus status; ++ char *driver_name; ++ ++ ctx->compat = NULL; ++ ++ if (compat_version == 0) ++ return VA_STATUS_SUCCESS; ++ ++ ASSERT(compat_ctx); ++ if (compat_ctx == NULL) ++ return VA_STATUS_ERROR_UNKNOWN; ++ ++ driver_name = NULL; ++ status = pDisplayContext->vaGetDriverName(pDisplayContext, &driver_name); ++ ASSERT(status == VA_STATUS_SUCCESS); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ ++ if ((compat = malloc(sizeof(*compat))) == NULL) ++ return VA_STATUS_ERROR_ALLOCATION_FAILED; ++ compat->buffers = NULL; ++ compat->buffers_count_max = 0; ++ compat->compat_version = compat_version; ++ compat->compat_ctx = NULL; ++ compat->driver_name = driver_name; ++ compat->context_map = NULL; ++ compat->last_context_map_match = NULL; ++ ctx->compat = compat; ++ ++ if (strcmp(driver_name, "psb") == 0) ++ compat->driver_id = VA_DRIVER_ID_POULSBO; ++ else if (strcmp(driver_name, "iegd") == 0) ++ compat->driver_id = VA_DRIVER_ID_IEGD; ++ else ++ compat->driver_id = VA_DRIVER_ID_UNKNOWN; ++ ++ switch (compat_version) { ++ case 29: ++ if ((ctx_0_29 = malloc(sizeof(*ctx_0_29))) == NULL) ++ return VA_STATUS_ERROR_ALLOCATION_FAILED; ++ memcpy(ctx_0_29, compat_ctx, sizeof(*ctx_0_29)); ++ va_compat_translate_VADriverContext_0_29(compat, ctx_0_29); ++ compat->compat_ctx = ctx_0_29; ++ COPY_FIELD(ctx, ctx_0_29, version_major); ++ COPY_FIELD(ctx, ctx_0_29, version_minor); ++ COPY_FIELD(ctx, ctx_0_29, max_profiles); ++ COPY_FIELD(ctx, ctx_0_29, max_entrypoints); ++ COPY_FIELD(ctx, ctx_0_29, max_attributes); ++ COPY_FIELD(ctx, ctx_0_29, max_image_formats); ++ COPY_FIELD(ctx, ctx_0_29, max_subpic_formats); ++ COPY_FIELD(ctx, ctx_0_29, max_display_attributes); ++ COPY_FIELD(ctx, ctx_0_29, str_vendor); ++ break; ++ case 30: ++ if ((ctx_0_30 = malloc(sizeof(*ctx_0_30))) == NULL) ++ return VA_STATUS_ERROR_ALLOCATION_FAILED; ++ memcpy(ctx_0_30, compat_ctx, sizeof(*ctx_0_30)); ++ va_compat_translate_VADriverContext_0_30(compat, ctx_0_30); ++ compat->compat_ctx = ctx_0_30; ++ COPY_FIELD(ctx, ctx_0_30, version_major); ++ COPY_FIELD(ctx, ctx_0_30, version_minor); ++ COPY_FIELD(ctx, ctx_0_30, max_profiles); ++ COPY_FIELD(ctx, ctx_0_30, max_entrypoints); ++ COPY_FIELD(ctx, ctx_0_30, max_attributes); ++ COPY_FIELD(ctx, ctx_0_30, max_image_formats); ++ COPY_FIELD(ctx, ctx_0_30, max_subpic_formats); ++ COPY_FIELD(ctx, ctx_0_30, max_display_attributes); ++ COPY_FIELD(ctx, ctx_0_30, str_vendor); ++ break; ++ case VA_MINOR_VERSION: ++ va_compat_translate_VADriverContext(compat, compat_ctx); ++ compat->compat_ctx = compat_ctx; ++ break; ++ default: ++ ASSERT(compat_version == 0); ++ return VA_STATUS_ERROR_UNKNOWN; ++ } ++ ++ va_compat_init_VADriverVTable(ctx, compat_version); ++ return VA_STATUS_SUCCESS; ++} ++ ++VAStatus va_compat_fini(VADisplay dpy) ++{ ++ VADriverContextP ctx = CTX(dpy); ++ VACompatContextP compat = ctx->compat; ++ int i; ++ ++ if (compat == NULL) ++ return VA_STATUS_SUCCESS; ++ ++ if (compat->driver_name) ++ { ++ free(compat->driver_name); ++ compat->driver_name = NULL; ++ } ++ ++ if (compat->buffers) ++ { ++ for (i = 0; i < compat->buffers_count_max; i++) ++ { ++ if (compat->buffers[i].id) ++ va_DestroyBufferCompat(ctx, compat->buffers[i].id); ++ } ++ free(compat->buffers); ++ compat->buffers = NULL; ++ } ++ ++ if (compat->compat_ctx && compat->compat_version != VA_MINOR_VERSION) ++ { ++ free(compat->compat_ctx); ++ compat->compat_ctx = NULL; ++ } ++ ++ if (compat->context_map) ++ { ++ VAContextMapP d, m = compat->context_map; ++ while (m) { ++ d = m; ++ m = m->next; ++ free(d); ++ } ++ } ++ compat->last_context_map_match = NULL; ++ ++ free(compat); ++ ctx->compat = NULL; ++ return VA_STATUS_SUCCESS; ++} +diff --git a/va/va_compat.h b/va/va_compat.h +new file mode 100644 +index 0000000..2c9d801 +--- /dev/null ++++ b/va/va_compat.h +@@ -0,0 +1,1467 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. 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. ++ */ ++ ++#ifndef VA_COMPAT_H ++#define VA_COMPAT_H ++ ++VAStatus va_compat_init(VADisplay dpy, int compat_version, void *compat_ctx); ++VAStatus va_compat_fini(VADisplay dpy); ++ ++/* H.264 Picture (0.29) */ ++typedef struct _VAPictureH264_0_29 ++{ ++ VASurfaceID picture_id; ++ unsigned int flags; ++ unsigned int TopFieldOrderCnt; ++ unsigned int BottomFieldOrderCnt; ++} VAPictureH264_0_29; ++ ++/* H.264 Picture Parameter Buffer (0.29) */ ++typedef struct _VAPictureParameterBufferH264_0_29 ++{ ++ VAPictureH264_0_29 CurrPic; ++ VAPictureH264_0_29 ReferenceFrames[16]; /* in DPB */ ++ unsigned short picture_width_in_mbs_minus1; ++ unsigned short picture_height_in_mbs_minus1; ++ unsigned char bit_depth_luma_minus8; ++ unsigned char bit_depth_chroma_minus8; ++ unsigned char num_ref_frames; ++ union { ++ struct { ++ unsigned char chroma_format_idc : 2; ++ unsigned char residual_colour_transform_flag : 1; ++ unsigned char frame_mbs_only_flag : 1; ++ unsigned char mb_adaptive_frame_field_flag : 1; ++ unsigned char direct_8x8_inference_flag : 1; ++ unsigned char MinLumaBiPredSize8x8 : 1; /* see A.3.3.2 */ ++ }; ++ unsigned char seq_fields; ++ }; ++ unsigned char num_slice_groups_minus1; ++ unsigned char slice_group_map_type; ++ signed char pic_init_qp_minus26; ++ signed char chroma_qp_index_offset; ++ signed char second_chroma_qp_index_offset; ++ union { ++ struct { ++ unsigned char entropy_coding_mode_flag : 1; ++ unsigned char weighted_pred_flag : 1; ++ unsigned char weighted_bipred_idc : 2; ++ unsigned char transform_8x8_mode_flag : 1; ++ unsigned char field_pic_flag : 1; ++ unsigned char constrained_intra_pred_flag : 1; ++ }; ++ unsigned char pic_fields; ++ }; ++ unsigned short frame_num; ++} VAPictureParameterBufferH264_0_29; ++ ++/* H.264 Slice Parameter Buffer (0.29) */ ++typedef struct _VASliceParameterBufferH264_0_29 ++{ ++ unsigned int slice_data_size;/* number of bytes in the slice data buffer for this slice */ ++ unsigned int slice_data_offset;/* the offset to the NAL start code for this slice */ ++ unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */ ++ unsigned short slice_data_bit_offset; /* bit offset from NAL start code to the beginning of slice data */ ++ unsigned short first_mb_in_slice; ++ unsigned char slice_type; ++ unsigned char direct_spatial_mv_pred_flag; ++ unsigned char num_ref_idx_l0_active_minus1; ++ unsigned char num_ref_idx_l1_active_minus1; ++ unsigned char cabac_init_idc; ++ char slice_qp_delta; ++ unsigned char disable_deblocking_filter_idc; ++ char slice_alpha_c0_offset_div2; ++ char slice_beta_offset_div2; ++ VAPictureH264_0_29 RefPicList0[32]; /* See 8.2.4.2 */ ++ VAPictureH264_0_29 RefPicList1[32]; /* See 8.2.4.2 */ ++ unsigned char luma_log2_weight_denom; ++ unsigned char chroma_log2_weight_denom; ++ unsigned char luma_weight_l0_flag; ++ short luma_weight_l0[32]; ++ short luma_offset_l0[32]; ++ unsigned char chroma_weight_l0_flag; ++ short chroma_weight_l0[32][2]; ++ short chroma_offset_l0[32][2]; ++ unsigned char luma_weight_l1_flag; ++ short luma_weight_l1[32]; ++ short luma_offset_l1[32]; ++ unsigned char chroma_weight_l1_flag; ++ short chroma_weight_l1[32][2]; ++ short chroma_offset_l1[32][2]; ++} VASliceParameterBufferH264_0_29; ++ ++/* VC-1 Picture Parameter Buffer (0.29) */ ++typedef struct _VAPictureParameterBufferVC1_0_29 ++{ ++ VASurfaceID forward_reference_picture; ++ VASurfaceID backward_reference_picture; ++ /* if out-of-loop post-processing is done on the render ++ target, then we need to keep the in-loop decoded ++ picture as a reference picture */ ++ VASurfaceID inloop_decoded_picture; ++ ++ /* sequence layer for AP or meta data for SP and MP */ ++ union { ++ struct { ++ unsigned char interlace : 1; /* SEQUENCE_LAYER::INTERLACE */ ++ unsigned char syncmarker : 1;/* METADATA::SYNCMARKER */ ++ unsigned char overlap : 1;/* METADATA::OVERLAP */ ++ }; ++ unsigned char sequence_fields; ++ }; ++ ++ unsigned short coded_width; /* ENTRY_POINT_LAYER::CODED_WIDTH */ ++ unsigned short coded_height; /* ENTRY_POINT_LAYER::CODED_HEIGHT */ ++ unsigned char closed_entry; /* ENTRY_POINT_LAYER::CLOSED_ENTRY */ ++ unsigned char broken_link; /* ENTRY_POINT_LAYER::BROKEN_LINK */ ++ unsigned char loopfilter; /* ENTRY_POINT_LAYER::LOOPFILTER */ ++ unsigned char conditional_overlap_flag; /* ENTRY_POINT_LAYER::CONDOVER */ ++ unsigned char fast_uvmc_flag; /* ENTRY_POINT_LAYER::FASTUVMC */ ++ union { ++ struct { ++ unsigned char range_mapping_luma_flag: 1; /* ENTRY_POINT_LAYER::RANGE_MAPY_FLAG */ ++ unsigned char range_mapping_luma: 3; /* ENTRY_POINT_LAYER::RANGE_MAPY */ ++ unsigned char range_mapping_chroma_flag: 1; /* ENTRY_POINT_LAYER::RANGE_MAPUV_FLAG */ ++ unsigned char range_mapping_chroma: 3; /* ENTRY_POINT_LAYER::RANGE_MAPUV */ ++ }; ++ unsigned char range_mapping_fields; ++ }; ++ ++ unsigned char b_picture_fraction; /* PICTURE_LAYER::BFRACTION */ ++ unsigned char cbp_table; /* PICTURE_LAYER::CBPTAB/ICBPTAB */ ++ unsigned char mb_mode_table; /* PICTURE_LAYER::MBMODETAB */ ++ unsigned char range_reduction_frame;/* PICTURE_LAYER::RANGEREDFRM */ ++ unsigned char rounding_control; /* PICTURE_LAYER::RNDCTRL */ ++ unsigned char post_processing; /* PICTURE_LAYER::POSTPROC */ ++ unsigned char picture_resolution_index; /* PICTURE_LAYER::RESPIC */ ++ unsigned char luma_scale; /* PICTURE_LAYER::LUMSCALE */ ++ unsigned char luma_shift; /* PICTURE_LAYER::LUMSHIFT */ ++ union { ++ struct { ++ unsigned char picture_type : 2; /* PICTURE_LAYER::PTYPE */ ++ unsigned char frame_coding_mode : 3;/* PICTURE_LAYER::FCM */ ++ unsigned char top_field_first : 1;/* PICTURE_LAYER::TFF */ ++ unsigned char is_first_field : 1; /* set to 1 if it is the first field */ ++ unsigned char intensity_compensation: 1;/* PICTURE_LAYER::INTCOMP */ ++ }; ++ unsigned char picture_fields; ++ }; ++ union { ++ struct { ++ unsigned char mv_type_mb : 1; /* PICTURE::MVTYPEMB */ ++ unsigned char direct_mb : 1; /* PICTURE::DIRECTMB */ ++ unsigned char skip_mb : 1; /* PICTURE::SKIPMB */ ++ unsigned char field_tx : 1; /* PICTURE::FIELDTX */ ++ unsigned char forward_mb : 1; /* PICTURE::FORWARDMB */ ++ unsigned char ac_pred : 1; /* PICTURE::ACPRED */ ++ unsigned char overflags : 1; /* PICTURE::OVERFLAGS */ ++ }; ++ unsigned char raw_coding_flag; ++ }; ++ union { ++ struct { ++ unsigned char bp_mv_type_mb : 1; /* PICTURE::MVTYPEMB */ ++ unsigned char bp_direct_mb : 1; /* PICTURE::DIRECTMB */ ++ unsigned char bp_skip_mb : 1; /* PICTURE::SKIPMB */ ++ unsigned char bp_field_tx : 1; /* PICTURE::FIELDTX */ ++ unsigned char bp_forward_mb : 1; /* PICTURE::FORWARDMB */ ++ unsigned char bp_ac_pred : 1; /* PICTURE::ACPRED */ ++ unsigned char bp_overflags : 1; /* PICTURE::OVERFLAGS */ ++ }; ++ unsigned char bitplane_present_flag; /* signal what bitplane is being passed via the bitplane buffer */ ++ }; ++ union { ++ struct { ++ unsigned char reference_distance_flag : 1;/* PICTURE_LAYER::REFDIST_FLAG */ ++ unsigned char reference_distance : 5;/* PICTURE_LAYER::REFDIST */ ++ unsigned char num_reference_pictures: 1;/* PICTURE_LAYER::NUMREF */ ++ unsigned char reference_field_pic_indicator : 1;/* PICTURE_LAYER::REFFIELD */ ++ }; ++ unsigned short reference_fields; ++ }; ++ union { ++ struct { ++ VAMvModeVC1 mv_mode : 3; /* PICTURE_LAYER::MVMODE */ ++ VAMvModeVC1 mv_mode2 : 3; /* PICTURE_LAYER::MVMODE2 */ ++ unsigned char mv_table : 3; /* PICTURE_LAYER::MVTAB/IMVTAB */ ++ unsigned char two_mv_block_pattern_table: 2; /* PICTURE_LAYER::2MVBPTAB */ ++ unsigned char four_mv_switch : 1; /* PICTURE_LAYER::4MVSWITCH */ ++ unsigned char four_mv_block_pattern_table : 2; /* PICTURE_LAYER::4MVBPTAB */ ++ unsigned char extended_mv_flag : 1; /* ENTRY_POINT_LAYER::EXTENDED_MV */ ++ unsigned char extended_mv_range : 2; /* PICTURE_LAYER::MVRANGE */ ++ unsigned char extended_dmv_flag : 1; /* ENTRY_POINT_LAYER::EXTENDED_DMV */ ++ unsigned char extended_dmv_range : 2; /* PICTURE_LAYER::DMVRANGE */ ++ }; ++ unsigned int mv_fields; ++ }; ++ union { ++ struct { ++ unsigned char dquant : 2; /* ENTRY_POINT_LAYER::DQUANT */ ++ unsigned char quantizer : 2; /* ENTRY_POINT_LAYER::QUANTIZER */ ++ unsigned char half_qp : 1; /* PICTURE_LAYER::HALFQP */ ++ unsigned char pic_quantizer_scale : 5;/* PICTURE_LAYER::PQUANT */ ++ unsigned char pic_quantizer_type : 1;/* PICTURE_LAYER::PQUANTIZER */ ++ unsigned char dq_frame : 1; /* VOPDQUANT::DQUANTFRM */ ++ unsigned char dq_profile : 2; /* VOPDQUANT::DQPROFILE */ ++ unsigned char dq_sb_edge : 2; /* VOPDQUANT::DQSBEDGE */ ++ unsigned char dq_db_edge : 2; /* VOPDQUANT::DQDBEDGE */ ++ unsigned char dq_binary_level : 1; /* VOPDQUANT::DQBILEVEL */ ++ unsigned char alt_pic_quantizer : 5;/* VOPDQUANT::ALTPQUANT */ ++ }; ++ unsigned long pic_quantizer_fields; ++ }; ++ union { ++ struct { ++ unsigned char variable_sized_transform_flag : 1;/* ENTRY_POINT_LAYER::VSTRANSFORM */ ++ unsigned char mb_level_transform_type_flag : 1;/* PICTURE_LAYER::TTMBF */ ++ unsigned char frame_level_transform_type : 2;/* PICTURE_LAYER::TTFRM */ ++ unsigned char transform_ac_codingset_idx1 : 2;/* PICTURE_LAYER::TRANSACFRM */ ++ unsigned char transform_ac_codingset_idx2 : 2;/* PICTURE_LAYER::TRANSACFRM2 */ ++ unsigned char intra_transform_dc_table : 1;/* PICTURE_LAYER::TRANSDCTAB */ ++ }; ++ unsigned short transform_fields; ++ }; ++} VAPictureParameterBufferVC1_0_29; ++ ++/* MPEG-2 Picture Parameter Buffer (0.29) */ ++typedef struct _VAPictureParameterBufferMPEG2_0_29 ++{ ++ unsigned short horizontal_size; ++ unsigned short vertical_size; ++ VASurfaceID forward_reference_picture; ++ VASurfaceID backward_reference_picture; ++ /* meanings of the following fields are the same as in the standard */ ++ int picture_coding_type; ++ int f_code; /* pack all four fcode into this */ ++ union { ++ struct { ++ unsigned char intra_dc_precision : 2; ++ unsigned char picture_structure : 2; ++ unsigned char top_field_first : 1; ++ unsigned char frame_pred_frame_dct : 1; ++ unsigned char concealment_motion_vectors : 1; ++ unsigned char q_scale_type : 1; ++ unsigned char intra_vlc_format : 1; ++ unsigned char alternate_scan : 1; ++ unsigned char repeat_first_field : 1; ++ unsigned char progressive_frame : 1; ++ unsigned char is_first_field : 1; /* indicate whether the current field ++ * is the first field for field picture ++ */ ++ }; ++ unsigned int picture_coding_extension; ++ }; ++} VAPictureParameterBufferMPEG2_0_29; ++ ++/* MPEG-2 Slice Parameter Buffer (0.29) */ ++typedef struct _VASliceParameterBufferMPEG2_0_29 ++{ ++ unsigned int slice_data_size;/* number of bytes in the slice data buffer for this slice */ ++ unsigned int slice_data_offset;/* the offset to the first byte of slice data */ ++ unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */ ++ unsigned int macroblock_offset;/* the offset to the first bit of MB from the first byte of slice data */ ++ unsigned int slice_vertical_position; ++ int quantiser_scale_code; ++ int intra_slice_flag; ++} VASliceParameterBufferMPEG2_0_29; ++ ++/* MPEG-4 Picture Parameter Buffer (0.29) */ ++typedef struct _VAPictureParameterBufferMPEG4_0_29 ++{ ++ unsigned short vop_width; ++ unsigned short vop_height; ++ VASurfaceID forward_reference_picture; ++ VASurfaceID backward_reference_picture; ++ union { ++ struct { ++ unsigned char short_video_header : 1; ++ unsigned char chroma_format : 2; ++ unsigned char interlaced : 1; ++ unsigned char obmc_disable : 1; ++ unsigned char sprite_enable : 2; ++ unsigned char sprite_warping_accuracy : 2; ++ unsigned char quant_type : 1; ++ unsigned char quarter_sample : 1; ++ unsigned char data_partitioned : 1; ++ unsigned char reversible_vlc : 1; ++ }; ++ unsigned short vol_fields; ++ }; ++ unsigned char no_of_sprite_warping_points; ++ short sprite_trajectory_du[3]; ++ short sprite_trajectory_dv[3]; ++ unsigned char quant_precision; ++ union { ++ struct { ++ unsigned char vop_coding_type : 2; ++ unsigned char backward_reference_vop_coding_type : 2; ++ unsigned char vop_rounding_type : 1; ++ unsigned char intra_dc_vlc_thr : 3; ++ unsigned char top_field_first : 1; ++ unsigned char alternate_vertical_scan_flag : 1; ++ }; ++ unsigned short vop_fields; ++ }; ++ unsigned char vop_fcode_forward; ++ unsigned char vop_fcode_backward; ++ /* short header related */ ++ unsigned char num_gobs_in_vop; ++ unsigned char num_macroblocks_in_gob; ++ /* for direct mode prediction */ ++ short TRB; ++ short TRD; ++} VAPictureParameterBufferMPEG4_0_29; ++ ++/* H.264 Picture (0.30) */ ++typedef struct _VAPictureH264_0_30 ++{ ++ VASurfaceID picture_id; ++ unsigned int flags; ++ unsigned int TopFieldOrderCnt; ++ unsigned int BottomFieldOrderCnt; ++} VAPictureH264_0_30; ++ ++/* H.264 Picture Parameter Buffer (0.30) */ ++typedef struct _VAPictureParameterBufferH264_0_30 ++{ ++ VAPictureH264 CurrPic; ++ VAPictureH264 ReferenceFrames[16]; /* in DPB */ ++ unsigned short picture_width_in_mbs_minus1; ++ unsigned short picture_height_in_mbs_minus1; ++ unsigned char bit_depth_luma_minus8; ++ unsigned char bit_depth_chroma_minus8; ++ unsigned char num_ref_frames; ++ union { ++ struct { ++ unsigned char chroma_format_idc : 2; ++ unsigned char residual_colour_transform_flag : 1; ++ unsigned char frame_mbs_only_flag : 1; ++ unsigned char mb_adaptive_frame_field_flag : 1; ++ unsigned char direct_8x8_inference_flag : 1; ++ unsigned char MinLumaBiPredSize8x8 : 1; /* see A.3.3.2 */ ++ } bits; ++ unsigned char value; ++ } seq_fields; ++ unsigned char num_slice_groups_minus1; ++ unsigned char slice_group_map_type; ++ signed char pic_init_qp_minus26; ++ signed char chroma_qp_index_offset; ++ signed char second_chroma_qp_index_offset; ++ union { ++ struct { ++ unsigned char entropy_coding_mode_flag : 1; ++ unsigned char weighted_pred_flag : 1; ++ unsigned char weighted_bipred_idc : 2; ++ unsigned char transform_8x8_mode_flag : 1; ++ unsigned char field_pic_flag : 1; ++ unsigned char constrained_intra_pred_flag : 1; ++ } bits; ++ unsigned char value; ++ } pic_fields; ++ unsigned short frame_num; ++} VAPictureParameterBufferH264_0_30; ++ ++/* H.264 Slice Parameter Buffer (0.30) */ ++typedef struct _VASliceParameterBufferH264_0_30 ++{ ++ unsigned int slice_data_size;/* number of bytes in the slice data buffer for this slice */ ++ unsigned int slice_data_offset;/* the offset to the NAL start code for this slice */ ++ unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */ ++ unsigned short slice_data_bit_offset; /* bit offset from NAL start code to the beginning of slice data */ ++ unsigned short first_mb_in_slice; ++ unsigned char slice_type; ++ unsigned char direct_spatial_mv_pred_flag; ++ unsigned char num_ref_idx_l0_active_minus1; ++ unsigned char num_ref_idx_l1_active_minus1; ++ unsigned char cabac_init_idc; ++ char slice_qp_delta; ++ unsigned char disable_deblocking_filter_idc; ++ char slice_alpha_c0_offset_div2; ++ char slice_beta_offset_div2; ++ VAPictureH264 RefPicList0[32]; /* See 8.2.4.2 */ ++ VAPictureH264 RefPicList1[32]; /* See 8.2.4.2 */ ++ unsigned char luma_log2_weight_denom; ++ unsigned char chroma_log2_weight_denom; ++ unsigned char luma_weight_l0_flag; ++ short luma_weight_l0[32]; ++ short luma_offset_l0[32]; ++ unsigned char chroma_weight_l0_flag; ++ short chroma_weight_l0[32][2]; ++ short chroma_offset_l0[32][2]; ++ unsigned char luma_weight_l1_flag; ++ short luma_weight_l1[32]; ++ short luma_offset_l1[32]; ++ unsigned char chroma_weight_l1_flag; ++ short chroma_weight_l1[32][2]; ++ short chroma_offset_l1[32][2]; ++} VASliceParameterBufferH264_0_30; ++ ++/* VC-1 Picture Parameter Buffer (0.30) */ ++typedef struct _VAPictureParameterBufferVC1_0_30 ++{ ++ VASurfaceID forward_reference_picture; ++ VASurfaceID backward_reference_picture; ++ /* if out-of-loop post-processing is done on the render ++ target, then we need to keep the in-loop decoded ++ picture as a reference picture */ ++ VASurfaceID inloop_decoded_picture; ++ ++ /* sequence layer for AP or meta data for SP and MP */ ++ union { ++ struct { ++ unsigned char interlace : 1; /* SEQUENCE_LAYER::INTERLACE */ ++ unsigned char syncmarker : 1;/* METADATA::SYNCMARKER */ ++ unsigned char overlap : 1;/* METADATA::OVERLAP */ ++ } bits; ++ unsigned char value; ++ } sequence_fields; ++ ++ unsigned short coded_width; /* ENTRY_POINT_LAYER::CODED_WIDTH */ ++ unsigned short coded_height; /* ENTRY_POINT_LAYER::CODED_HEIGHT */ ++ unsigned char closed_entry; /* ENTRY_POINT_LAYER::CLOSED_ENTRY */ ++ unsigned char broken_link; /* ENTRY_POINT_LAYER::BROKEN_LINK */ ++ unsigned char loopfilter; /* ENTRY_POINT_LAYER::LOOPFILTER */ ++ unsigned char conditional_overlap_flag; /* ENTRY_POINT_LAYER::CONDOVER */ ++ unsigned char fast_uvmc_flag; /* ENTRY_POINT_LAYER::FASTUVMC */ ++ union { ++ struct { ++ unsigned char luma_flag : 1; /* ENTRY_POINT_LAYER::RANGE_MAPY_FLAG */ ++ unsigned char luma : 3; /* ENTRY_POINT_LAYER::RANGE_MAPY */ ++ unsigned char chroma_flag : 1; /* ENTRY_POINT_LAYER::RANGE_MAPUV_FLAG */ ++ unsigned char chroma : 3; /* ENTRY_POINT_LAYER::RANGE_MAPUV */ ++ } bits; ++ unsigned char value; ++ } range_mapping_fields; ++ ++ unsigned char b_picture_fraction; /* PICTURE_LAYER::BFRACTION */ ++ unsigned char cbp_table; /* PICTURE_LAYER::CBPTAB/ICBPTAB */ ++ unsigned char mb_mode_table; /* PICTURE_LAYER::MBMODETAB */ ++ unsigned char range_reduction_frame;/* PICTURE_LAYER::RANGEREDFRM */ ++ unsigned char rounding_control; /* PICTURE_LAYER::RNDCTRL */ ++ unsigned char post_processing; /* PICTURE_LAYER::POSTPROC */ ++ unsigned char picture_resolution_index; /* PICTURE_LAYER::RESPIC */ ++ unsigned char luma_scale; /* PICTURE_LAYER::LUMSCALE */ ++ unsigned char luma_shift; /* PICTURE_LAYER::LUMSHIFT */ ++ union { ++ struct { ++ unsigned char picture_type : 2; /* PICTURE_LAYER::PTYPE */ ++ unsigned char frame_coding_mode : 3; /* PICTURE_LAYER::FCM */ ++ unsigned char top_field_first : 1; /* PICTURE_LAYER::TFF */ ++ unsigned char is_first_field : 1; /* set to 1 if it is the first field */ ++ unsigned char intensity_compensation : 1; /* PICTURE_LAYER::INTCOMP */ ++ } bits; ++ unsigned char value; ++ } picture_fields; ++ union { ++ struct { ++ unsigned char mv_type_mb : 1; /* PICTURE::MVTYPEMB */ ++ unsigned char direct_mb : 1; /* PICTURE::DIRECTMB */ ++ unsigned char skip_mb : 1; /* PICTURE::SKIPMB */ ++ unsigned char field_tx : 1; /* PICTURE::FIELDTX */ ++ unsigned char forward_mb : 1; /* PICTURE::FORWARDMB */ ++ unsigned char ac_pred : 1; /* PICTURE::ACPRED */ ++ unsigned char overflags : 1; /* PICTURE::OVERFLAGS */ ++ } flags; ++ unsigned char value; ++ } raw_coding; ++ union { ++ struct { ++ unsigned char bp_mv_type_mb : 1; /* PICTURE::MVTYPEMB */ ++ unsigned char bp_direct_mb : 1; /* PICTURE::DIRECTMB */ ++ unsigned char bp_skip_mb : 1; /* PICTURE::SKIPMB */ ++ unsigned char bp_field_tx : 1; /* PICTURE::FIELDTX */ ++ unsigned char bp_forward_mb : 1; /* PICTURE::FORWARDMB */ ++ unsigned char bp_ac_pred : 1; /* PICTURE::ACPRED */ ++ unsigned char bp_overflags : 1; /* PICTURE::OVERFLAGS */ ++ } flags; ++ unsigned char value; ++ } bitplane_present; /* signal what bitplane is being passed via the bitplane buffer */ ++ union { ++ struct { ++ unsigned char reference_distance_flag : 1;/* PICTURE_LAYER::REFDIST_FLAG */ ++ unsigned char reference_distance : 5;/* PICTURE_LAYER::REFDIST */ ++ unsigned char num_reference_pictures: 1;/* PICTURE_LAYER::NUMREF */ ++ unsigned char reference_field_pic_indicator : 1;/* PICTURE_LAYER::REFFIELD */ ++ } bits; ++ unsigned short value; ++ } reference_fields; ++ union { ++ struct { ++ unsigned char mv_mode : 3; /* PICTURE_LAYER::MVMODE */ ++ unsigned char mv_mode2 : 3; /* PICTURE_LAYER::MVMODE2 */ ++ unsigned char mv_table : 3; /* PICTURE_LAYER::MVTAB/IMVTAB */ ++ unsigned char two_mv_block_pattern_table: 2; /* PICTURE_LAYER::2MVBPTAB */ ++ unsigned char four_mv_switch : 1; /* PICTURE_LAYER::4MVSWITCH */ ++ unsigned char four_mv_block_pattern_table : 2; /* PICTURE_LAYER::4MVBPTAB */ ++ unsigned char extended_mv_flag : 1; /* ENTRY_POINT_LAYER::EXTENDED_MV */ ++ unsigned char extended_mv_range : 2; /* PICTURE_LAYER::MVRANGE */ ++ unsigned char extended_dmv_flag : 1; /* ENTRY_POCHAR_LAYER::EXTENDED_DMV */ ++ unsigned char extended_dmv_range : 2; /* PICTURE_LAYER::DMVRANGE */ ++ } bits; ++ unsigned int value; ++ } mv_fields; ++ union { ++ struct { ++ unsigned char dquant : 2; /* ENTRY_POINT_LAYER::DQUANT */ ++ unsigned char quantizer : 2; /* ENTRY_POINT_LAYER::QUANTIZER */ ++ unsigned char half_qp : 1; /* PICTURE_LAYER::HALFQP */ ++ unsigned char pic_quantizer_scale : 5;/* PICTURE_LAYER::PQUANT */ ++ unsigned char pic_quantizer_type : 1;/* PICTURE_LAYER::PQUANTIZER */ ++ unsigned char dq_frame : 1; /* VOPDQUANT::DQUANTFRM */ ++ unsigned char dq_profile : 2; /* VOPDQUANT::DQPROFILE */ ++ unsigned char dq_sb_edge : 2; /* VOPDQUANT::DQSBEDGE */ ++ unsigned char dq_db_edge : 2; /* VOPDQUANT::DQDBEDGE */ ++ unsigned char dq_binary_level : 1; /* VOPDQUANT::DQBILEVEL */ ++ unsigned char alt_pic_quantizer : 5;/* VOPDQUANT::ALTPQUANT */ ++ } bits; ++ unsigned long value; ++ } pic_quantizer_fields; ++ union { ++ struct { ++ unsigned char variable_sized_transform_flag : 1;/* ENTRY_POINT_LAYER::VSTRANSFORM */ ++ unsigned char mb_level_transform_type_flag : 1;/* PICTURE_LAYER::TTMBF */ ++ unsigned char frame_level_transform_type : 2;/* PICTURE_LAYER::TTFRM */ ++ unsigned char transform_ac_codingset_idx1 : 2;/* PICTURE_LAYER::TRANSACFRM */ ++ unsigned char transform_ac_codingset_idx2 : 2;/* PICTURE_LAYER::TRANSACFRM2 */ ++ unsigned char intra_transform_dc_table : 1;/* PICTURE_LAYER::TRANSDCTAB */ ++ } bits; ++ unsigned short value; ++ } transform_fields; ++} VAPictureParameterBufferVC1_0_30; ++ ++/* MPEG-2 Picture Parameter Buffer (0.30) */ ++typedef struct _VAPictureParameterBufferMPEG2_0_30 ++{ ++ unsigned short horizontal_size; ++ unsigned short vertical_size; ++ VASurfaceID forward_reference_picture; ++ VASurfaceID backward_reference_picture; ++ /* meanings of the following fields are the same as in the standard */ ++ int picture_coding_type; ++ int f_code; /* pack all four fcode into this */ ++ union { ++ struct { ++ unsigned int intra_dc_precision : 2; ++ unsigned int picture_structure : 2; ++ unsigned int top_field_first : 1; ++ unsigned int frame_pred_frame_dct : 1; ++ unsigned int concealment_motion_vectors : 1; ++ unsigned int q_scale_type : 1; ++ unsigned int intra_vlc_format : 1; ++ unsigned int alternate_scan : 1; ++ unsigned int repeat_first_field : 1; ++ unsigned int progressive_frame : 1; ++ unsigned int is_first_field : 1; /* indicate whether the current field ++ * is the first field for field picture ++ */ ++ } bits; ++ unsigned int value; ++ } picture_coding_extension; ++} VAPictureParameterBufferMPEG2_0_30; ++ ++/* MPEG-2 Slice Parameter Buffer (0.29) */ ++typedef VASliceParameterBufferMPEG2_0_29 VASliceParameterBufferMPEG2_0_30; ++ ++/* MPEG-4 Picture Parameter Buffer (0.30) */ ++typedef struct _VAPictureParameterBufferMPEG4_0_30 ++{ ++ unsigned short vop_width; ++ unsigned short vop_height; ++ VASurfaceID forward_reference_picture; ++ VASurfaceID backward_reference_picture; ++ union { ++ struct { ++ unsigned char short_video_header : 1; ++ unsigned char chroma_format : 2; ++ unsigned char interlaced : 1; ++ unsigned char obmc_disable : 1; ++ unsigned char sprite_enable : 2; ++ unsigned char sprite_warping_accuracy : 2; ++ unsigned char quant_type : 1; ++ unsigned char quarter_sample : 1; ++ unsigned char data_partitioned : 1; ++ unsigned char reversible_vlc : 1; ++ } bits; ++ unsigned short value; ++ } vol_fields; ++ unsigned char no_of_sprite_warping_points; ++ short sprite_trajectory_du[3]; ++ short sprite_trajectory_dv[3]; ++ unsigned char quant_precision; ++ union { ++ struct { ++ unsigned char vop_coding_type : 2; ++ unsigned char backward_reference_vop_coding_type : 2; ++ unsigned char vop_rounding_type : 1; ++ unsigned char intra_dc_vlc_thr : 3; ++ unsigned char top_field_first : 1; ++ unsigned char alternate_vertical_scan_flag : 1; ++ } bits; ++ unsigned short value; ++ } vop_fields; ++ unsigned char vop_fcode_forward; ++ unsigned char vop_fcode_backward; ++ /* short header related */ ++ unsigned char num_gobs_in_vop; ++ unsigned char num_macroblocks_in_gob; ++ /* for direct mode prediction */ ++ short TRB; ++ short TRD; ++} VAPictureParameterBufferMPEG4_0_30; ++ ++/* Encode Slice Parameter Buffer (0.30) */ ++typedef struct _VAEncSliceParameterBuffer_0_30 ++{ ++ unsigned int start_row_number; /* starting MB row number for this slice */ ++ unsigned int slice_height; /* slice height measured in MB */ ++ union { ++ struct { ++ unsigned char is_intra : 1; ++ unsigned char disable_deblocking_filter_idc : 2; ++ } bits; ++ unsigned char value; ++ } slice_flags; ++} VAEncSliceParameterBuffer_0_30; ++ ++/* MPEG-4 Picture Parameter Buffer (0.31) */ ++typedef struct _VAPictureParameterBufferMPEG4_0_31 ++{ ++ unsigned short vop_width; ++ unsigned short vop_height; ++ VASurfaceID forward_reference_picture; ++ VASurfaceID backward_reference_picture; ++ union { ++ struct { ++ unsigned int short_video_header : 1; ++ unsigned int chroma_format : 2; ++ unsigned int interlaced : 1; ++ unsigned int obmc_disable : 1; ++ unsigned int sprite_enable : 2; ++ unsigned int sprite_warping_accuracy : 2; ++ unsigned int quant_type : 1; ++ unsigned int quarter_sample : 1; ++ unsigned int data_partitioned : 1; ++ unsigned int reversible_vlc : 1; ++ } bits; ++ unsigned int value; ++ } vol_fields; ++ unsigned char no_of_sprite_warping_points; ++ short sprite_trajectory_du[3]; ++ short sprite_trajectory_dv[3]; ++ unsigned char quant_precision; ++ union { ++ struct { ++ unsigned int vop_coding_type : 2; ++ unsigned int backward_reference_vop_coding_type : 2; ++ unsigned int vop_rounding_type : 1; ++ unsigned int intra_dc_vlc_thr : 3; ++ unsigned int top_field_first : 1; ++ unsigned int alternate_vertical_scan_flag : 1; ++ } bits; ++ unsigned int value; ++ } vop_fields; ++ unsigned char vop_fcode_forward; ++ unsigned char vop_fcode_backward; ++ /* short header related */ ++ unsigned char num_gobs_in_vop; ++ unsigned char num_macroblocks_in_gob; ++ /* for direct mode prediction */ ++ short TRB; ++ short TRD; ++} VAPictureParameterBufferMPEG4_0_31; ++ ++typedef struct VADriverContext_0_29 *VADriverContextP_0_29; ++ ++/* Driver VTable (0.29) */ ++struct VADriverVTable_0_29 ++{ ++ VAStatus (*vaTerminate) ( VADriverContextP_0_29 ctx ); ++ ++ VAStatus (*vaQueryConfigProfiles) ( ++ VADriverContextP_0_29 ctx, ++ VAProfile *profile_list, /* out */ ++ int *num_profiles /* out */ ++ ); ++ ++ VAStatus (*vaQueryConfigEntrypoints) ( ++ VADriverContextP_0_29 ctx, ++ VAProfile profile, ++ VAEntrypoint *entrypoint_list, /* out */ ++ int *num_entrypoints /* out */ ++ ); ++ ++ VAStatus (*vaGetConfigAttributes) ( ++ VADriverContextP_0_29 ctx, ++ VAProfile profile, ++ VAEntrypoint entrypoint, ++ VAConfigAttrib *attrib_list, /* in/out */ ++ int num_attribs ++ ); ++ ++ VAStatus (*vaCreateConfig) ( ++ VADriverContextP_0_29 ctx, ++ VAProfile profile, ++ VAEntrypoint entrypoint, ++ VAConfigAttrib *attrib_list, ++ int num_attribs, ++ VAConfigID *config_id /* out */ ++ ); ++ ++ VAStatus (*vaDestroyConfig) ( ++ VADriverContextP_0_29 ctx, ++ VAConfigID config_id ++ ); ++ ++ VAStatus (*vaQueryConfigAttributes) ( ++ VADriverContextP_0_29 ctx, ++ VAConfigID config_id, ++ VAProfile *profile, /* out */ ++ VAEntrypoint *entrypoint, /* out */ ++ VAConfigAttrib *attrib_list, /* out */ ++ int *num_attribs /* out */ ++ ); ++ ++ VAStatus (*vaCreateSurfaces) ( ++ VADriverContextP_0_29 ctx, ++ int width, ++ int height, ++ int format, ++ int num_surfaces, ++ VASurfaceID *surfaces /* out */ ++ ); ++ ++ VAStatus (*vaDestroySurfaces) ( ++ VADriverContextP_0_29 ctx, ++ VASurfaceID *surface_list, ++ int num_surfaces ++ ); ++ ++ VAStatus (*vaCreateContext) ( ++ VADriverContextP_0_29 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_0_29 ctx, ++ VAContextID context ++ ); ++ ++ VAStatus (*vaCreateBuffer) ( ++ VADriverContextP_0_29 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_0_29 ctx, ++ VABufferID buf_id, /* in */ ++ unsigned int num_elements /* in */ ++ ); ++ ++ VAStatus (*vaMapBuffer) ( ++ VADriverContextP_0_29 ctx, ++ VABufferID buf_id, /* in */ ++ void **pbuf /* out */ ++ ); ++ ++ VAStatus (*vaUnmapBuffer) ( ++ VADriverContextP_0_29 ctx, ++ VABufferID buf_id /* in */ ++ ); ++ ++ VAStatus (*vaDestroyBuffer) ( ++ VADriverContextP_0_29 ctx, ++ VABufferID buffer_id ++ ); ++ ++ VAStatus (*vaBeginPicture) ( ++ VADriverContextP_0_29 ctx, ++ VAContextID context, ++ VASurfaceID render_target ++ ); ++ ++ VAStatus (*vaRenderPicture) ( ++ VADriverContextP_0_29 ctx, ++ VAContextID context, ++ VABufferID *buffers, ++ int num_buffers ++ ); ++ ++ VAStatus (*vaEndPicture) ( ++ VADriverContextP_0_29 ctx, ++ VAContextID context ++ ); ++ ++ VAStatus (*vaSyncSurface) ( ++ VADriverContextP_0_29 ctx, ++ VAContextID context, ++ VASurfaceID render_target ++ ); ++ ++ VAStatus (*vaQuerySurfaceStatus) ( ++ VADriverContextP_0_29 ctx, ++ VASurfaceID render_target, ++ VASurfaceStatus *status /* out */ ++ ); ++ ++ VAStatus (*vaPutSurface) ( ++ VADriverContextP_0_29 ctx, ++ VASurfaceID surface, ++ unsigned long 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_0_29 ctx, ++ VAImageFormat *format_list, /* out */ ++ int *num_formats /* out */ ++ ); ++ ++ VAStatus (*vaCreateImage) ( ++ VADriverContextP_0_29 ctx, ++ VAImageFormat *format, ++ int width, ++ int height, ++ VAImage *image /* out */ ++ ); ++ ++ VAStatus (*vaDeriveImage) ( ++ VADriverContextP_0_29 ctx, ++ VASurfaceID surface, ++ VAImage *image /* out */ ++ ); ++ ++ VAStatus (*vaDestroyImage) ( ++ VADriverContextP_0_29 ctx, ++ VAImageID image ++ ); ++ ++ VAStatus (*vaSetImagePalette) ( ++ VADriverContextP_0_29 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_0_29 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_0_29 ctx, ++ VASurfaceID surface, ++ VAImageID image, ++ int src_x, ++ int src_y, ++ unsigned int width, ++ unsigned int height, ++ int dest_x, ++ int dest_y ++ ); ++ ++ VAStatus (*vaPutImage2) ( ++ VADriverContextP_0_29 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_0_29 ctx, ++ VAImageFormat *format_list, /* out */ ++ unsigned int *flags, /* out */ ++ unsigned int *num_formats /* out */ ++ ); ++ ++ VAStatus (*vaCreateSubpicture) ( ++ VADriverContextP_0_29 ctx, ++ VAImageID image, ++ VASubpictureID *subpicture /* out */ ++ ); ++ ++ VAStatus (*vaDestroySubpicture) ( ++ VADriverContextP_0_29 ctx, ++ VASubpictureID subpicture ++ ); ++ ++ VAStatus (*vaSetSubpictureImage) ( ++ VADriverContextP_0_29 ctx, ++ VASubpictureID subpicture, ++ VAImageID image ++ ); ++ ++ VAStatus (*vaSetSubpicturePalette) ( ++ VADriverContextP_0_29 ctx, ++ VASubpictureID subpicture, ++ /* ++ * 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 ++ */ ++ unsigned char *palette ++ ); ++ ++ VAStatus (*vaSetSubpictureChromakey) ( ++ VADriverContextP_0_29 ctx, ++ VASubpictureID subpicture, ++ unsigned int chromakey_min, ++ unsigned int chromakey_max, ++ unsigned int chromakey_mask ++ ); ++ ++ VAStatus (*vaSetSubpictureGlobalAlpha) ( ++ VADriverContextP_0_29 ctx, ++ VASubpictureID subpicture, ++ float global_alpha ++ ); ++ ++ VAStatus (*vaAssociateSubpicture) ( ++ VADriverContextP_0_29 ctx, ++ VASubpictureID subpicture, ++ VASurfaceID *target_surfaces, ++ int num_surfaces, ++ short src_x, /* upper left offset in subpicture */ ++ short src_y, ++ short dest_x, /* upper left offset in surface */ ++ short dest_y, ++ unsigned short width, ++ unsigned short height, ++ /* ++ * whether to enable chroma-keying or global-alpha ++ * see VA_SUBPICTURE_XXX values ++ */ ++ unsigned int flags ++ ); ++ ++ VAStatus (*vaAssociateSubpicture2) ( ++ VADriverContextP_0_29 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_0_29 ctx, ++ VASubpictureID subpicture, ++ VASurfaceID *target_surfaces, ++ int num_surfaces ++ ); ++ ++ VAStatus (*vaQueryDisplayAttributes) ( ++ VADriverContextP_0_29 ctx, ++ VADisplayAttribute *attr_list, /* out */ ++ int *num_attributes /* out */ ++ ); ++ ++ VAStatus (*vaGetDisplayAttributes) ( ++ VADriverContextP_0_29 ctx, ++ VADisplayAttribute *attr_list, /* in/out */ ++ int num_attributes ++ ); ++ ++ VAStatus (*vaSetDisplayAttributes) ( ++ VADriverContextP_0_29 ctx, ++ VADisplayAttribute *attr_list, ++ int num_attributes ++ ); ++ ++ ++ VAStatus (*vaDbgCopySurfaceToBuffer) ( ++ VADriverContextP_0_29 ctx, ++ VASurfaceID surface, ++ void **buffer, /* out */ ++ unsigned int *stride /* out */ ++ ); ++}; ++ ++/* Driver context (0.29) */ ++struct VADriverContext_0_29 ++{ ++ void *old_pNext; /* preserved for binary compatibility */ ++ ++ void *pDriverData; ++ struct VADriverVTable_0_29 vtable; ++ ++ void *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 */ ++}; ++ ++/* Forward declarations for VA API 0.30 */ ++struct v4l2_format; ++struct v4l2_buffer; ++typedef struct VADriverContext_0_30 *VADriverContextP_0_30; ++ ++/* Driver VTable (0.30) */ ++struct VADriverVTable_0_30 ++{ ++ VAStatus (*vaTerminate) ( VADriverContextP_0_30 ctx ); ++ ++ VAStatus (*vaQueryConfigProfiles) ( ++ VADriverContextP_0_30 ctx, ++ VAProfile *profile_list, /* out */ ++ int *num_profiles /* out */ ++ ); ++ ++ VAStatus (*vaQueryConfigEntrypoints) ( ++ VADriverContextP_0_30 ctx, ++ VAProfile profile, ++ VAEntrypoint *entrypoint_list, /* out */ ++ int *num_entrypoints /* out */ ++ ); ++ ++ VAStatus (*vaGetConfigAttributes) ( ++ VADriverContextP_0_30 ctx, ++ VAProfile profile, ++ VAEntrypoint entrypoint, ++ VAConfigAttrib *attrib_list, /* in/out */ ++ int num_attribs ++ ); ++ ++ VAStatus (*vaCreateConfig) ( ++ VADriverContextP_0_30 ctx, ++ VAProfile profile, ++ VAEntrypoint entrypoint, ++ VAConfigAttrib *attrib_list, ++ int num_attribs, ++ VAConfigID *config_id /* out */ ++ ); ++ ++ VAStatus (*vaDestroyConfig) ( ++ VADriverContextP_0_30 ctx, ++ VAConfigID config_id ++ ); ++ ++ VAStatus (*vaQueryConfigAttributes) ( ++ VADriverContextP_0_30 ctx, ++ VAConfigID config_id, ++ VAProfile *profile, /* out */ ++ VAEntrypoint *entrypoint, /* out */ ++ VAConfigAttrib *attrib_list, /* out */ ++ int *num_attribs /* out */ ++ ); ++ ++ VAStatus (*vaCreateSurfaces) ( ++ VADriverContextP_0_30 ctx, ++ int width, ++ int height, ++ int format, ++ int num_surfaces, ++ VASurfaceID *surfaces /* out */ ++ ); ++ ++ VAStatus (*vaDestroySurfaces) ( ++ VADriverContextP_0_30 ctx, ++ VASurfaceID *surface_list, ++ int num_surfaces ++ ); ++ ++ VAStatus (*vaCreateContext) ( ++ VADriverContextP_0_30 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_0_30 ctx, ++ VAContextID context ++ ); ++ ++ VAStatus (*vaCreateBuffer) ( ++ VADriverContextP_0_30 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_0_30 ctx, ++ VABufferID buf_id, /* in */ ++ unsigned int num_elements /* in */ ++ ); ++ ++ VAStatus (*vaMapBuffer) ( ++ VADriverContextP_0_30 ctx, ++ VABufferID buf_id, /* in */ ++ void **pbuf /* out */ ++ ); ++ ++ VAStatus (*vaUnmapBuffer) ( ++ VADriverContextP_0_30 ctx, ++ VABufferID buf_id /* in */ ++ ); ++ ++ VAStatus (*vaDestroyBuffer) ( ++ VADriverContextP_0_30 ctx, ++ VABufferID buffer_id ++ ); ++ ++ VAStatus (*vaBeginPicture) ( ++ VADriverContextP_0_30 ctx, ++ VAContextID context, ++ VASurfaceID render_target ++ ); ++ ++ VAStatus (*vaRenderPicture) ( ++ VADriverContextP_0_30 ctx, ++ VAContextID context, ++ VABufferID *buffers, ++ int num_buffers ++ ); ++ ++ VAStatus (*vaEndPicture) ( ++ VADriverContextP_0_30 ctx, ++ VAContextID context ++ ); ++ ++ VAStatus (*vaSyncSurface) ( ++ VADriverContextP_0_30 ctx, ++ VAContextID context, ++ VASurfaceID render_target ++ ); ++ ++ VAStatus (*vaQuerySurfaceStatus) ( ++ VADriverContextP_0_30 ctx, ++ VASurfaceID render_target, ++ VASurfaceStatus *status /* out */ ++ ); ++ ++ VAStatus (*vaPutSurface) ( ++ VADriverContextP_0_30 ctx, ++ VASurfaceID surface, ++ unsigned long 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_0_30 ctx, ++ VAImageFormat *format_list, /* out */ ++ int *num_formats /* out */ ++ ); ++ ++ VAStatus (*vaCreateImage) ( ++ VADriverContextP_0_30 ctx, ++ VAImageFormat *format, ++ int width, ++ int height, ++ VAImage *image /* out */ ++ ); ++ ++ VAStatus (*vaDeriveImage) ( ++ VADriverContextP_0_30 ctx, ++ VASurfaceID surface, ++ VAImage *image /* out */ ++ ); ++ ++ VAStatus (*vaDestroyImage) ( ++ VADriverContextP_0_30 ctx, ++ VAImageID image ++ ); ++ ++ VAStatus (*vaSetImagePalette) ( ++ VADriverContextP_0_30 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_0_30 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_0_30 ctx, ++ VASurfaceID surface, ++ VAImageID image, ++ int src_x, ++ int src_y, ++ unsigned int width, ++ unsigned int height, ++ int dest_x, ++ int dest_y ++ ); ++ ++ VAStatus (*vaPutImage2) ( ++ VADriverContextP_0_30 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_0_30 ctx, ++ VAImageFormat *format_list, /* out */ ++ unsigned int *flags, /* out */ ++ unsigned int *num_formats /* out */ ++ ); ++ ++ VAStatus (*vaCreateSubpicture) ( ++ VADriverContextP_0_30 ctx, ++ VAImageID image, ++ VASubpictureID *subpicture /* out */ ++ ); ++ ++ VAStatus (*vaDestroySubpicture) ( ++ VADriverContextP_0_30 ctx, ++ VASubpictureID subpicture ++ ); ++ ++ VAStatus (*vaSetSubpictureImage) ( ++ VADriverContextP_0_30 ctx, ++ VASubpictureID subpicture, ++ VAImageID image ++ ); ++ ++ VAStatus (*vaSetSubpictureChromakey) ( ++ VADriverContextP_0_30 ctx, ++ VASubpictureID subpicture, ++ unsigned int chromakey_min, ++ unsigned int chromakey_max, ++ unsigned int chromakey_mask ++ ); ++ ++ VAStatus (*vaSetSubpictureGlobalAlpha) ( ++ VADriverContextP_0_30 ctx, ++ VASubpictureID subpicture, ++ float global_alpha ++ ); ++ ++ VAStatus (*vaAssociateSubpicture) ( ++ VADriverContextP_0_30 ctx, ++ VASubpictureID subpicture, ++ VASurfaceID *target_surfaces, ++ int num_surfaces, ++ short src_x, /* upper left offset in subpicture */ ++ short src_y, ++ short dest_x, /* upper left offset in surface */ ++ short dest_y, ++ unsigned short width, ++ unsigned short height, ++ /* ++ * whether to enable chroma-keying or global-alpha ++ * see VA_SUBPICTURE_XXX values ++ */ ++ unsigned int flags ++ ); ++ ++ VAStatus (*vaAssociateSubpicture2) ( ++ VADriverContextP_0_30 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_0_30 ctx, ++ VASubpictureID subpicture, ++ VASurfaceID *target_surfaces, ++ int num_surfaces ++ ); ++ ++ VAStatus (*vaQueryDisplayAttributes) ( ++ VADriverContextP_0_30 ctx, ++ VADisplayAttribute *attr_list, /* out */ ++ int *num_attributes /* out */ ++ ); ++ ++ VAStatus (*vaGetDisplayAttributes) ( ++ VADriverContextP_0_30 ctx, ++ VADisplayAttribute *attr_list, /* in/out */ ++ int num_attributes ++ ); ++ ++ VAStatus (*vaSetDisplayAttributes) ( ++ VADriverContextP_0_30 ctx, ++ VADisplayAttribute *attr_list, ++ int num_attributes ++ ); ++ ++ /* device specific */ ++ VAStatus (*vaCreateSurfaceFromCIFrame) ( ++ VADriverContextP_0_30 ctx, ++ unsigned long frame_id, ++ VASurfaceID *surface /* out */ ++ ); ++ ++ ++ VAStatus (*vaCreateSurfaceFromV4L2Buf) ( ++ VADriverContextP_0_30 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_0_30 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 ++ ); ++}; ++ ++/* Driver context (0.30) */ ++struct VADriverContext_0_30 ++{ ++ void *pDriverData; ++ struct VADriverVTable_0_30 vtable; ++ ++ void *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; ++}; ++ ++/* Driver VTable and context (0.31) */ ++#define VADriverVTable_0_31 VADriverVTable ++#define VADriverContext_0_31 VADriverContext ++ ++#endif /* VA_COMPAT_H */ +diff --git a/va/va_compat_template.h b/va/va_compat_template.h +new file mode 100644 +index 0000000..18349de +--- /dev/null ++++ b/va/va_compat_template.h +@@ -0,0 +1,539 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. 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. ++ */ ++ ++#undef CONCAT_ ++#define CONCAT_(x, y) x##y ++#undef CONCAT ++#define CONCAT(x, y) CONCAT_(x, y) ++#undef MKCOMPAT_ ++#define MKCOMPAT_(NAME,MINOR) CONCAT(CONCAT(NAME,_0_),MINOR) ++#undef MKCOMPAT ++#define MKCOMPAT(NAME) MKCOMPAT_(NAME,COMPAT_MINOR) ++#undef STRUCT ++#define STRUCT(BUFFER, CODEC) MKCOMPAT(VA##BUFFER##Buffer##CODEC) ++#undef TRANSLATE_1 ++#define TRANSLATE_1(NAME) CONCAT(va_compat_translate_,NAME) ++#undef TRANSLATE_ ++#define TRANSLATE_(NAME) TRANSLATE_1(MKCOMPAT(NAME)) ++#undef TRANSLATE ++#define TRANSLATE(BUFFER, CODEC) TRANSLATE_1(STRUCT(BUFFER,CODEC)) ++ ++#undef COPY_ARRAY ++#define COPY_ARRAY(DST, SRC, ARRAY) \ ++ memcpy((DST)->ARRAY, (SRC)->ARRAY, sizeof((DST)->ARRAY)) ++ ++#undef COPY_FIELD ++#define COPY_FIELD(DST, SRC, MEMBER) \ ++ (DST)->MEMBER = (SRC)->MEMBER ++ ++#undef COPY_VTABLE__ ++#define COPY_VTABLE__(DST, DST_MEMBER, SRC, SRC_MEMBER) \ ++ (DST##_vtable)->DST_MEMBER = (SRC##_vtable)->SRC_MEMBER ++ ++#undef COPY_VTABLE_ ++#define COPY_VTABLE_(DST, DST_SUFFIX, SRC, MEMBER) \ ++ COPY_VTABLE__(DST, MEMBER##_##DST_SUFFIX, SRC, MEMBER) ++ ++#undef COPY_VTABLE ++#define COPY_VTABLE(DST, SRC, MEMBER) \ ++ COPY_VTABLE__(DST, MEMBER, SRC, MEMBER) ++ ++/* 0.29 */ ++#if COMPAT_MAJOR == 0 && COMPAT_MINOR == 29 ++#undef BFV ++#define BFV(a, b) a ++#undef BFM ++#define BFM(a, b, c) c ++#undef COPY_BIT_FIELD ++#define COPY_BIT_FIELD(DST, SRC, FIELD, MEMBER) \ ++ (DST)->MEMBER = (SRC)->FIELD.bits.MEMBER ++#undef COPY_BIT_FLAG ++#define COPY_BIT_FLAG(DST, SRC, FIELD, MEMBER) \ ++ (DST)->MEMBER = (SRC)->FIELD.flags.MEMBER ++#endif ++ ++/* 0.29 glue to match 0.30 names */ ++#undef M_raw_coding ++#undef M_bitplane_present ++#undef M_luma_flag ++#undef M_luma ++#undef M_chroma_flag ++#undef M_chroma ++ ++#if COMPAT_MAJOR == 0 && COMPAT_MINOR == 29 ++#define M_raw_coding raw_coding_flag ++#define M_bitplane_present bitplane_present_flag ++#define M_luma_flag range_mapping_luma_flag ++#define M_luma range_mapping_luma ++#define M_chroma_flag range_mapping_chroma_flag ++#define M_chroma range_mapping_chroma ++#else ++#define M_raw_coding raw_coding ++#define M_bitplane_present bitplane_present ++#define M_luma_flag luma_flag ++#define M_luma luma ++#define M_chroma_flag chroma_flag ++#define M_chroma chroma ++#endif ++ ++/* 0.30 */ ++#if COMPAT_MAJOR == 0 && COMPAT_MINOR == 30 ++#undef BFV ++#define BFV(a, b) a.b ++#undef BFM ++#define BFM(a, b, c) a.b.c ++#undef COPY_BIT_FIELD ++#define COPY_BIT_FIELD(DST, SRC, FIELD, MEMBER) \ ++ (DST)->FIELD.bits.MEMBER = (SRC)->FIELD.bits.MEMBER ++#undef COPY_BIT_FLAG ++#define COPY_BIT_FLAG(DST, SRC, FIELD, MEMBER) \ ++ (DST)->FIELD.flags.MEMBER = (SRC)->FIELD.flags.MEMBER ++#endif ++ ++#if COMPAT_MAJOR == 0 && COMPAT_MINOR < 31 ++static VAStatus TRANSLATE_(VAPictureH264)( ++ VACompatContextP ctx, ++ void *dest_pic, ++ const void *src_pic ++) ++{ ++ MKCOMPAT(VAPictureH264) *dest = dest_pic; ++ const VAPictureH264 *src = src_pic; ++ ++ COPY_FIELD(dest, src, picture_id); ++ COPY_FIELD(dest, src, flags); ++ COPY_FIELD(dest, src, TopFieldOrderCnt); ++ COPY_FIELD(dest, src, BottomFieldOrderCnt); ++ ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus TRANSLATE(PictureParameter,H264)( ++ VACompatContextP ctx, ++ void *dest_buffer, ++ const void *src_buffer ++) ++{ ++ STRUCT(PictureParameter,H264) *dest = dest_buffer; ++ const VAPictureParameterBufferH264 *src = src_buffer; ++ VAStatus status; ++ int i; ++ ++ status = TRANSLATE_(VAPictureH264)(ctx, ++ &dest->CurrPic, &src->CurrPic); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ ++ for (i = 0; i < 16; i++) { ++ status = TRANSLATE_(VAPictureH264)(ctx, ++ &dest->ReferenceFrames[i], ++ &src->ReferenceFrames[i]); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ } ++ ++ COPY_FIELD(dest, src, picture_width_in_mbs_minus1); ++ COPY_FIELD(dest, src, picture_height_in_mbs_minus1); ++ COPY_FIELD(dest, src, bit_depth_luma_minus8); ++ COPY_FIELD(dest, src, bit_depth_chroma_minus8); ++ COPY_FIELD(dest, src, num_ref_frames); ++ dest->BFV(seq_fields, value) = 0; /* reset all bits */ ++ COPY_BIT_FIELD(dest, src, seq_fields, chroma_format_idc); ++ COPY_BIT_FIELD(dest, src, seq_fields, residual_colour_transform_flag); ++ COPY_BIT_FIELD(dest, src, seq_fields, frame_mbs_only_flag); ++ COPY_BIT_FIELD(dest, src, seq_fields, mb_adaptive_frame_field_flag); ++ COPY_BIT_FIELD(dest, src, seq_fields, direct_8x8_inference_flag); ++ COPY_BIT_FIELD(dest, src, seq_fields, MinLumaBiPredSize8x8); ++ COPY_FIELD(dest, src, num_slice_groups_minus1); ++ COPY_FIELD(dest, src, slice_group_map_type); ++ COPY_FIELD(dest, src, pic_init_qp_minus26); ++ COPY_FIELD(dest, src, chroma_qp_index_offset); ++ COPY_FIELD(dest, src, second_chroma_qp_index_offset); ++ dest->BFV(pic_fields, value) = 0; /* reset all bits */ ++ COPY_BIT_FIELD(dest, src, pic_fields, entropy_coding_mode_flag); ++ COPY_BIT_FIELD(dest, src, pic_fields, weighted_pred_flag); ++ COPY_BIT_FIELD(dest, src, pic_fields, weighted_bipred_idc); ++ COPY_BIT_FIELD(dest, src, pic_fields, transform_8x8_mode_flag); ++ COPY_BIT_FIELD(dest, src, pic_fields, field_pic_flag); ++ COPY_BIT_FIELD(dest, src, pic_fields, constrained_intra_pred_flag); ++ COPY_FIELD(dest, src, frame_num); ++ ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus TRANSLATE(SliceParameter,H264)( ++ VACompatContextP ctx, ++ void *dest_buffer, ++ const void *src_buffer ++) ++{ ++ STRUCT(SliceParameter,H264) *dest = dest_buffer; ++ const VASliceParameterBufferH264 *src = src_buffer; ++ VAStatus status; ++ int i; ++ ++ COPY_FIELD(dest, src, slice_data_size); ++ COPY_FIELD(dest, src, slice_data_offset); ++ COPY_FIELD(dest, src, slice_data_flag); ++ COPY_FIELD(dest, src, slice_data_bit_offset); ++ COPY_FIELD(dest, src, first_mb_in_slice); ++ COPY_FIELD(dest, src, slice_type); ++ COPY_FIELD(dest, src, direct_spatial_mv_pred_flag); ++ COPY_FIELD(dest, src, num_ref_idx_l0_active_minus1); ++ COPY_FIELD(dest, src, num_ref_idx_l1_active_minus1); ++ COPY_FIELD(dest, src, cabac_init_idc); ++ COPY_FIELD(dest, src, slice_qp_delta); ++ COPY_FIELD(dest, src, disable_deblocking_filter_idc); ++ COPY_FIELD(dest, src, slice_alpha_c0_offset_div2); ++ COPY_FIELD(dest, src, slice_beta_offset_div2); ++ for (i = 0; i < 32; i++) { ++ status = TRANSLATE_(VAPictureH264)(ctx, ++ &dest->RefPicList0[i], ++ &src->RefPicList0[i]); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ status = TRANSLATE_(VAPictureH264)(ctx, ++ &dest->RefPicList1[i], ++ &src->RefPicList1[i]); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ } ++ COPY_FIELD(dest, src, luma_log2_weight_denom); ++ COPY_FIELD(dest, src, chroma_log2_weight_denom); ++ COPY_FIELD(dest, src, luma_weight_l0_flag); ++ COPY_ARRAY(dest, src, luma_weight_l0); ++ COPY_ARRAY(dest, src, luma_offset_l0); ++ COPY_FIELD(dest, src, chroma_weight_l0_flag); ++ COPY_ARRAY(dest, src, chroma_weight_l0); ++ COPY_ARRAY(dest, src, chroma_offset_l0); ++ COPY_FIELD(dest, src, luma_weight_l1_flag); ++ COPY_ARRAY(dest, src, luma_weight_l1); ++ COPY_ARRAY(dest, src, luma_offset_l1); ++ COPY_FIELD(dest, src, chroma_weight_l1_flag); ++ COPY_ARRAY(dest, src, chroma_weight_l1); ++ COPY_ARRAY(dest, src, chroma_offset_l1); ++ ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus TRANSLATE(PictureParameter,VC1)( ++ VACompatContextP ctx, ++ void *dest_buffer, ++ const void *src_buffer ++) ++{ ++ STRUCT(PictureParameter,VC1) *dest = dest_buffer; ++ const VAPictureParameterBufferVC1 *src = src_buffer; ++ ++ COPY_FIELD(dest, src, forward_reference_picture); ++ COPY_FIELD(dest, src, backward_reference_picture); ++ COPY_FIELD(dest, src, inloop_decoded_picture); ++ dest->BFV(sequence_fields, value) = 0; /* reset all bits */ ++ COPY_BIT_FIELD(dest, src, sequence_fields, interlace); ++ COPY_BIT_FIELD(dest, src, sequence_fields, syncmarker); ++ COPY_BIT_FIELD(dest, src, sequence_fields, overlap); ++ COPY_FIELD(dest, src, coded_width); ++ COPY_FIELD(dest, src, coded_height); ++#if COMPAT_MAJOR == 0 && COMPAT_MINOR == 30 ++ dest->closed_entry = src->entrypoint_fields.bits.closed_entry; ++ dest->broken_link = src->entrypoint_fields.bits.broken_link; ++ dest->loopfilter = src->entrypoint_fields.bits.loopfilter; ++#else ++ COPY_BIT_FIELD(dest, src, entrypoint_fields, closed_entry); ++ COPY_BIT_FIELD(dest, src, entrypoint_fields, broken_link); ++ COPY_BIT_FIELD(dest, src, entrypoint_fields, loopfilter); ++#endif ++ COPY_FIELD(dest, src, conditional_overlap_flag); ++ COPY_FIELD(dest, src, fast_uvmc_flag); ++ dest->BFV(range_mapping_fields, value) = 0; /* reset all bits */ ++ dest->BFM(range_mapping_fields, bits, M_luma_flag) = ++ src->range_mapping_fields.bits.luma_flag; ++ dest->BFM(range_mapping_fields, bits, M_luma) = ++ src->range_mapping_fields.bits.luma; ++ dest->BFM(range_mapping_fields, bits, M_chroma_flag) = ++ src->range_mapping_fields.bits.chroma_flag; ++ dest->BFM(range_mapping_fields, bits, M_chroma) = ++ src->range_mapping_fields.bits.chroma; ++ COPY_FIELD(dest, src, b_picture_fraction); ++ COPY_FIELD(dest, src, cbp_table); ++ COPY_FIELD(dest, src, mb_mode_table); ++ COPY_FIELD(dest, src, range_reduction_frame); ++ COPY_FIELD(dest, src, rounding_control); ++ COPY_FIELD(dest, src, post_processing); ++ COPY_FIELD(dest, src, picture_resolution_index); ++ COPY_FIELD(dest, src, luma_scale); ++ COPY_FIELD(dest, src, luma_shift); ++ dest->BFV(picture_fields, value) = 0; /* reset all bits */ ++ COPY_BIT_FIELD(dest, src, picture_fields, picture_type); ++ COPY_BIT_FIELD(dest, src, picture_fields, frame_coding_mode); ++ COPY_BIT_FIELD(dest, src, picture_fields, top_field_first); ++ COPY_BIT_FIELD(dest, src, picture_fields, is_first_field); ++ COPY_BIT_FIELD(dest, src, picture_fields, intensity_compensation); ++ dest->BFV(M_raw_coding, value) = 0; /* reset all bits */ ++ COPY_BIT_FLAG(dest, src, raw_coding, mv_type_mb); ++ COPY_BIT_FLAG(dest, src, raw_coding, direct_mb); ++ COPY_BIT_FLAG(dest, src, raw_coding, skip_mb); ++ COPY_BIT_FLAG(dest, src, raw_coding, field_tx); ++ COPY_BIT_FLAG(dest, src, raw_coding, forward_mb); ++ COPY_BIT_FLAG(dest, src, raw_coding, ac_pred); ++ COPY_BIT_FLAG(dest, src, raw_coding, overflags); ++ dest->BFV(M_bitplane_present, value) = 0; /* reset all bits */ ++ COPY_BIT_FLAG(dest, src, bitplane_present, bp_mv_type_mb); ++ COPY_BIT_FLAG(dest, src, bitplane_present, bp_direct_mb); ++ COPY_BIT_FLAG(dest, src, bitplane_present, bp_skip_mb); ++ COPY_BIT_FLAG(dest, src, bitplane_present, bp_field_tx); ++ COPY_BIT_FLAG(dest, src, bitplane_present, bp_forward_mb); ++ COPY_BIT_FLAG(dest, src, bitplane_present, bp_ac_pred); ++ COPY_BIT_FLAG(dest, src, bitplane_present, bp_overflags); ++ dest->BFV(reference_fields, value) = 0; /* reset all bits */ ++ COPY_BIT_FIELD(dest, src, reference_fields, reference_distance_flag); ++ COPY_BIT_FIELD(dest, src, reference_fields, reference_distance); ++ COPY_BIT_FIELD(dest, src, reference_fields, num_reference_pictures); ++ COPY_BIT_FIELD(dest, src, reference_fields, reference_field_pic_indicator); ++ dest->BFV(mv_fields, value) = 0; /* reset all bits */ ++ COPY_BIT_FIELD(dest, src, mv_fields, mv_mode); ++ COPY_BIT_FIELD(dest, src, mv_fields, mv_mode2); ++ COPY_BIT_FIELD(dest, src, mv_fields, mv_table); ++ COPY_BIT_FIELD(dest, src, mv_fields, two_mv_block_pattern_table); ++ COPY_BIT_FIELD(dest, src, mv_fields, four_mv_switch); ++ COPY_BIT_FIELD(dest, src, mv_fields, four_mv_block_pattern_table); ++ COPY_BIT_FIELD(dest, src, mv_fields, extended_mv_flag); ++ COPY_BIT_FIELD(dest, src, mv_fields, extended_mv_range); ++ COPY_BIT_FIELD(dest, src, mv_fields, extended_dmv_flag); ++ COPY_BIT_FIELD(dest, src, mv_fields, extended_dmv_range); ++ dest->BFV(pic_quantizer_fields, value) = 0; /* reset all bits */ ++ COPY_BIT_FIELD(dest, src, pic_quantizer_fields, dquant); ++ COPY_BIT_FIELD(dest, src, pic_quantizer_fields, quantizer); ++ COPY_BIT_FIELD(dest, src, pic_quantizer_fields, half_qp); ++ COPY_BIT_FIELD(dest, src, pic_quantizer_fields, pic_quantizer_scale); ++ COPY_BIT_FIELD(dest, src, pic_quantizer_fields, pic_quantizer_type); ++ COPY_BIT_FIELD(dest, src, pic_quantizer_fields, dq_frame); ++ COPY_BIT_FIELD(dest, src, pic_quantizer_fields, dq_profile); ++ COPY_BIT_FIELD(dest, src, pic_quantizer_fields, dq_sb_edge); ++ COPY_BIT_FIELD(dest, src, pic_quantizer_fields, dq_db_edge); ++ COPY_BIT_FIELD(dest, src, pic_quantizer_fields, dq_binary_level); ++ COPY_BIT_FIELD(dest, src, pic_quantizer_fields, alt_pic_quantizer); ++ dest->BFV(transform_fields, value) = 0; /* reset all bits */ ++ COPY_BIT_FIELD(dest, src, transform_fields, variable_sized_transform_flag); ++ COPY_BIT_FIELD(dest, src, transform_fields, mb_level_transform_type_flag); ++ COPY_BIT_FIELD(dest, src, transform_fields, frame_level_transform_type); ++ COPY_BIT_FIELD(dest, src, transform_fields, transform_ac_codingset_idx1); ++ COPY_BIT_FIELD(dest, src, transform_fields, transform_ac_codingset_idx2); ++ COPY_BIT_FIELD(dest, src, transform_fields, intra_transform_dc_table); ++ ++ if (src->picture_fields.bits.picture_type == 4) { ++ dest->BFM(picture_fields, bits, picture_type) = 1; /* P-frame */ ++ ctx->skip_frame = 1; ++ } ++ ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus TRANSLATE(PictureParameter,MPEG2)( ++ VACompatContextP ctx, ++ void *dest_buffer, ++ const void *src_buffer ++) ++{ ++ STRUCT(PictureParameter,MPEG2) *dest = dest_buffer; ++ const VAPictureParameterBufferMPEG2 *src = src_buffer; ++ ++ COPY_FIELD(dest, src, horizontal_size); ++ COPY_FIELD(dest, src, vertical_size); ++ COPY_FIELD(dest, src, forward_reference_picture); ++ COPY_FIELD(dest, src, backward_reference_picture); ++ COPY_FIELD(dest, src, picture_coding_type); ++ COPY_FIELD(dest, src, f_code); ++ dest->BFV(picture_coding_extension, value) = 0; /* reset all bits */ ++ COPY_BIT_FIELD(dest, src, picture_coding_extension, intra_dc_precision); ++ COPY_BIT_FIELD(dest, src, picture_coding_extension, picture_structure); ++ COPY_BIT_FIELD(dest, src, picture_coding_extension, top_field_first); ++ COPY_BIT_FIELD(dest, src, picture_coding_extension, frame_pred_frame_dct); ++ COPY_BIT_FIELD(dest, src, picture_coding_extension, concealment_motion_vectors); ++ COPY_BIT_FIELD(dest, src, picture_coding_extension, q_scale_type); ++ COPY_BIT_FIELD(dest, src, picture_coding_extension, intra_vlc_format); ++ COPY_BIT_FIELD(dest, src, picture_coding_extension, alternate_scan); ++ COPY_BIT_FIELD(dest, src, picture_coding_extension, repeat_first_field); ++ COPY_BIT_FIELD(dest, src, picture_coding_extension, progressive_frame); ++ COPY_BIT_FIELD(dest, src, picture_coding_extension, is_first_field); ++ ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus TRANSLATE(SliceParameter,MPEG2)( ++ VACompatContextP ctx, ++ void *dest_buffer, ++ const void *src_buffer ++) ++{ ++ STRUCT(SliceParameter,MPEG2) *dest = dest_buffer; ++ const VASliceParameterBufferMPEG2 *src = src_buffer; ++ ++ COPY_FIELD(dest, src, slice_data_size); ++ COPY_FIELD(dest, src, slice_data_offset); ++ COPY_FIELD(dest, src, slice_data_flag); ++ COPY_FIELD(dest, src, macroblock_offset); ++ COPY_FIELD(dest, src, slice_vertical_position); ++ COPY_FIELD(dest, src, quantiser_scale_code); ++ COPY_FIELD(dest, src, intra_slice_flag); ++ ++ return VA_STATUS_SUCCESS; ++} ++#endif ++ ++static VAStatus TRANSLATE(PictureParameter,MPEG4)( ++ VACompatContextP ctx, ++ void *dest_buffer, ++ const void *src_buffer ++) ++{ ++ STRUCT(PictureParameter,MPEG4) *dest = dest_buffer; ++ const VAPictureParameterBufferMPEG4 *src = src_buffer; ++ ++ COPY_FIELD(dest, src, vop_width); ++ COPY_FIELD(dest, src, vop_height); ++ COPY_FIELD(dest, src, forward_reference_picture); ++ COPY_FIELD(dest, src, backward_reference_picture); ++ dest->BFV(vol_fields, value) = 0; /* reset all bits */ ++ COPY_BIT_FIELD(dest, src, vol_fields, short_video_header); ++ COPY_BIT_FIELD(dest, src, vol_fields, chroma_format); ++ COPY_BIT_FIELD(dest, src, vol_fields, interlaced); ++ COPY_BIT_FIELD(dest, src, vol_fields, obmc_disable); ++ COPY_BIT_FIELD(dest, src, vol_fields, sprite_enable); ++ COPY_BIT_FIELD(dest, src, vol_fields, sprite_warping_accuracy); ++ COPY_BIT_FIELD(dest, src, vol_fields, quant_type); ++ COPY_BIT_FIELD(dest, src, vol_fields, quarter_sample); ++ COPY_BIT_FIELD(dest, src, vol_fields, data_partitioned); ++ COPY_BIT_FIELD(dest, src, vol_fields, reversible_vlc); ++ COPY_FIELD(dest, src, no_of_sprite_warping_points); ++ COPY_ARRAY(dest, src, sprite_trajectory_du); ++ COPY_ARRAY(dest, src, sprite_trajectory_dv); ++ COPY_FIELD(dest, src, quant_precision); ++ dest->BFV(vop_fields, value) = 0; /* reset all bits */ ++ COPY_BIT_FIELD(dest, src, vop_fields, vop_coding_type); ++ COPY_BIT_FIELD(dest, src, vop_fields, backward_reference_vop_coding_type); ++ COPY_BIT_FIELD(dest, src, vop_fields, vop_rounding_type); ++ COPY_BIT_FIELD(dest, src, vop_fields, intra_dc_vlc_thr); ++ COPY_BIT_FIELD(dest, src, vop_fields, top_field_first); ++ COPY_BIT_FIELD(dest, src, vop_fields, alternate_vertical_scan_flag); ++ COPY_FIELD(dest, src, vop_fcode_forward); ++ COPY_FIELD(dest, src, vop_fcode_backward); ++ COPY_FIELD(dest, src, num_gobs_in_vop); ++ COPY_FIELD(dest, src, num_macroblocks_in_gob); ++ COPY_FIELD(dest, src, TRB); ++ COPY_FIELD(dest, src, TRD); ++ ++ return VA_STATUS_SUCCESS; ++} ++ ++#if COMPAT_MAJOR == 0 && COMPAT_MINOR == 30 ++static VAStatus TRANSLATE_(VAEncSliceParameterBuffer)( ++ VACompatContextP ctx, ++ void *dest_buffer, ++ const void *src_buffer ++) ++{ ++ MKCOMPAT(VAEncSliceParameterBuffer) * const dest = dest_buffer; ++ const VAEncSliceParameterBuffer * const src = src_buffer; ++ ++ COPY_FIELD(dest, src, start_row_number); ++ COPY_FIELD(dest, src, slice_height); ++ dest->BFV(slice_flags, value) = 0; /* reset all bits */ ++ COPY_BIT_FIELD(dest, src, slice_flags, is_intra); ++ COPY_BIT_FIELD(dest, src, slice_flags, disable_deblocking_filter_idc); ++ ++ return VA_STATUS_SUCCESS; ++} ++#endif ++ ++static void TRANSLATE_(VADriverContext)( ++ VACompatContext *dest, ++ const struct MKCOMPAT(VADriverContext) *src ++) ++{ ++ VACompatDriverVTable *dest_vtable = &dest->vtable; ++ const struct MKCOMPAT(VADriverVTable) *src_vtable = &src->vtable; ++ ++ memset(dest_vtable, 0, sizeof(*dest_vtable)); ++ COPY_VTABLE(dest, src, vaTerminate); ++ COPY_VTABLE(dest, src, vaQueryConfigProfiles); ++ COPY_VTABLE(dest, src, vaQueryConfigEntrypoints); ++ COPY_VTABLE(dest, src, vaGetConfigAttributes); ++ COPY_VTABLE(dest, src, vaCreateConfig); ++ COPY_VTABLE(dest, src, vaDestroyConfig); ++ COPY_VTABLE(dest, src, vaQueryConfigAttributes); ++ COPY_VTABLE(dest, src, vaCreateSurfaces); ++ COPY_VTABLE(dest, src, vaDestroySurfaces); ++ COPY_VTABLE(dest, src, vaCreateContext); ++ COPY_VTABLE(dest, src, vaDestroyContext); ++ COPY_VTABLE(dest, src, vaCreateBuffer); ++ COPY_VTABLE(dest, src, vaBufferSetNumElements); ++ COPY_VTABLE(dest, src, vaMapBuffer); ++ COPY_VTABLE(dest, src, vaUnmapBuffer); ++ COPY_VTABLE(dest, src, vaDestroyBuffer); ++ COPY_VTABLE(dest, src, vaBeginPicture); ++ COPY_VTABLE(dest, src, vaRenderPicture); ++ COPY_VTABLE(dest, src, vaEndPicture); ++ COPY_VTABLE(dest, src, vaQuerySurfaceStatus); ++ COPY_VTABLE(dest, src, vaPutSurface); ++ COPY_VTABLE(dest, src, vaQueryImageFormats); ++ COPY_VTABLE(dest, src, vaCreateImage); ++ COPY_VTABLE(dest, src, vaDeriveImage); ++ COPY_VTABLE(dest, src, vaDestroyImage); ++ COPY_VTABLE(dest, src, vaSetImagePalette); ++ COPY_VTABLE(dest, src, vaGetImage); ++ COPY_VTABLE(dest, src, vaQuerySubpictureFormats); ++ COPY_VTABLE(dest, src, vaCreateSubpicture); ++ COPY_VTABLE(dest, src, vaDestroySubpicture); ++ COPY_VTABLE(dest, src, vaSetSubpictureImage); ++ COPY_VTABLE(dest, src, vaSetSubpictureChromakey); ++ COPY_VTABLE(dest, src, vaSetSubpictureGlobalAlpha); ++ COPY_VTABLE(dest, src, vaDeassociateSubpicture); ++ COPY_VTABLE(dest, src, vaQueryDisplayAttributes); ++ COPY_VTABLE(dest, src, vaGetDisplayAttributes); ++ COPY_VTABLE(dest, src, vaSetDisplayAttributes); ++#if COMPAT_MAJOR == 0 && COMPAT_MINOR <= 29 ++ COPY_VTABLE(dest, src, vaSetSubpicturePalette); ++ COPY_VTABLE(dest, src, vaDbgCopySurfaceToBuffer); ++#endif ++#if COMPAT_MAJOR == 0 && COMPAT_MINOR >= 30 ++ COPY_VTABLE(dest, src, vaCreateSurfaceFromCIFrame); ++ COPY_VTABLE(dest, src, vaCreateSurfaceFromV4L2Buf); ++ COPY_VTABLE(dest, src, vaCopySurfaceToBuffer); ++#endif ++#if COMPAT_MAJOR == 0 && COMPAT_MINOR >= 31 ++ COPY_VTABLE(dest, src, vaSyncSurface); ++ COPY_VTABLE(dest, src, vaPutImage); ++ COPY_VTABLE(dest, src, vaAssociateSubpicture); ++#else ++ COPY_VTABLE_(dest, pre31, src, vaSyncSurface); ++ COPY_VTABLE_(dest, pre31, src, vaPutImage); ++ COPY_VTABLE_(dest, pre31, src, vaPutImage2); ++ COPY_VTABLE_(dest, pre31, src, vaAssociateSubpicture); ++ COPY_VTABLE_(dest, pre31, src, vaAssociateSubpicture2); ++#endif ++} ++ ++#undef COMPAT_MAJOR ++#undef COMPAT_MINOR diff -Nru libva-0.31.0+latest2/debian/patches/392_compat.dso.patch libva-0.31.0+latest3/debian/patches/392_compat.dso.patch --- libva-0.31.0+latest2/debian/patches/392_compat.dso.patch 1970-01-01 01:00:00.000000000 +0100 +++ libva-0.31.0+latest3/debian/patches/392_compat.dso.patch 2010-04-18 14:36:16.000000000 +0100 @@ -0,0 +1,183 @@ +commit 23dc87f7a37ea245e9797b947df6fbd3c911dd76 +Author: Gwenole Beauchesne +Date: Fri Oct 16 12:39:06 2009 +0000 + + Fix compatibility with older programs linked against libva.so.0. + +diff --git a/va/Makefile.am b/va/Makefile.am +index 1752526..f92ba8a 100644 +--- a/va/Makefile.am ++++ b/va/Makefile.am +@@ -72,3 +72,8 @@ EXTRA_DIST = \ + va_compat_template.h + + va_compat.c: va_compat_template.h ++ ++lib_LTLIBRARIES += libva-compat.la ++libva_compat_la_SOURCES = va_compat_lib.c ++libva_compat_la_LIBADD = libva-x11.la -ldl ++libva_compat_la_DEPENDENCIES = libva-x11.la +diff --git a/va/va_compat_lib.c b/va/va_compat_lib.c +new file mode 100644 +index 0000000..b7e9ea5 +--- /dev/null ++++ b/va/va_compat_lib.c +@@ -0,0 +1,158 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. 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 ++#include ++#include ++ ++typedef void *VADisplay; ++typedef int VAStatus; ++typedef unsigned int VAGenericID; ++typedef VAGenericID VAContextID; ++typedef VAGenericID VASurfaceID; ++typedef VAGenericID VAImageID; ++typedef VAGenericID VASubpictureID; ++ ++#define PREPARE_FUNC(NAME, RET, ARGS) \ ++ static RET (*lib_##NAME) ARGS; \ ++ if (lib_##NAME == NULL) \ ++ lib_##NAME = dlsym(RTLD_NEXT, #NAME); \ ++ assert(lib_##NAME != NULL) ++ ++VAStatus ++vaSyncSurface( ++ VADisplay dpy, ++ VAContextID context, ++ VASurfaceID render_target ++) ++{ ++ PREPARE_FUNC(vaSyncSurface, VAStatus, (VADisplay, VASurfaceID)); ++ ++ return lib_vaSyncSurface(dpy, render_target); ++} ++ ++VAStatus ++vaPutImage( ++ VADisplay dpy, ++ VASurfaceID surface, ++ VAImageID image, ++ int src_x, ++ int src_y, ++ unsigned int width, ++ unsigned int height, ++ int dest_x, ++ int dest_y ++) ++{ ++ PREPARE_FUNC(vaPutImage, VAStatus, (VADisplay, VASurfaceID, VAImageID, ++ int, int, unsigned int, unsigned int, ++ int, int, unsigned int, unsigned int)); ++ ++ return lib_vaPutImage(dpy, surface, image, ++ src_x, src_y, width, height, ++ dest_x, dest_y, width, height); ++} ++ ++VAStatus ++vaPutImage2( ++ 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 ++) ++{ ++ PREPARE_FUNC(vaPutImage, VAStatus, (VADisplay, VASurfaceID, VAImageID, ++ int, int, unsigned int, unsigned int, ++ int, int, unsigned int, unsigned int)); ++ ++ return lib_vaPutImage(dpy, surface, image, ++ src_x, src_y, src_width, src_height, ++ dest_x, dest_y, dest_width, dest_height); ++} ++ ++VAStatus ++vaAssociateSubpicture( ++ VADisplay dpy, ++ VASubpictureID subpicture, ++ VASurfaceID *target_surfaces, ++ int num_surfaces, ++ short src_x, ++ short src_y, ++ short dest_x, ++ short dest_y, ++ unsigned short width, ++ unsigned short height, ++ unsigned int flags ++) ++{ ++ PREPARE_FUNC(vaAssociateSubpicture, ++ VAStatus, (VADisplay, VASubpictureID, VASurfaceID *, int, ++ short, short, unsigned short, unsigned short, ++ short, short, unsigned short, unsigned short, ++ unsigned int)); ++ ++ return lib_vaAssociateSubpicture(dpy, subpicture, ++ target_surfaces, num_surfaces, ++ src_x, src_y, width, height, ++ dest_x, dest_y, width, height, ++ flags); ++} ++ ++VAStatus ++vaAssociateSubpicture2( ++ VADisplay dpy, ++ VASubpictureID subpicture, ++ VASurfaceID *target_surfaces, ++ int num_surfaces, ++ short src_x, ++ short src_y, ++ unsigned short src_width, ++ unsigned short src_height, ++ short dest_x, ++ short dest_y, ++ unsigned short dest_width, ++ unsigned short dest_height, ++ unsigned int flags ++) ++{ ++ PREPARE_FUNC(vaAssociateSubpicture, ++ VAStatus, (VADisplay, VASubpictureID, VASurfaceID *, int, ++ short, short, unsigned short, unsigned short, ++ short, short, unsigned short, unsigned short, ++ unsigned int)); ++ ++ return lib_vaAssociateSubpicture(dpy, subpicture, ++ target_surfaces, num_surfaces, ++ src_x, src_y, src_width, src_height, ++ dest_x, dest_y, dest_width, dest_height, ++ flags); ++} diff -Nru libva-0.31.0+latest2/i965_drv_video/i965_drv_video.c libva-0.31.0+latest3/i965_drv_video/i965_drv_video.c --- libva-0.31.0+latest2/i965_drv_video/i965_drv_video.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/i965_drv_video/i965_drv_video.c 2010-03-18 08:39:38.000000000 +0000 @@ -54,36 +54,6 @@ 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; @@ -100,21 +70,13 @@ { 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; i965_subpic_formats_map[i].type != 0; 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 ? @@ -336,27 +298,12 @@ return vaStatus; } -static struct object_image * -i965_CreateImage_impl( - VADriverContextP ctx, - const VAImageFormat *format, - unsigned int width, - unsigned int height, - VASurfaceID surface -); - -static void -i965_DestroyImage_impl( - VADriverContextP ctx, - struct object_image *obj_image, - int from_surface -); - 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); } @@ -373,13 +320,6 @@ int i; VAStatus vaStatus = VA_STATUS_SUCCESS; - /* Internal format: linear I420 (compatible with YV12 VA image) */ - static const VAImageFormat vaFormat = { - .fourcc = VA_FOURCC('Y','V','1','2'), - .byte_order = VA_LSB_FIRST, - .bits_per_pixel = 12 - }; - /* We only support one format */ if (VA_RT_FORMAT_YUV420 != format) { return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT; @@ -388,36 +328,28 @@ for (i = 0; i < num_surfaces; i++) { int surfaceID = NEW_SURFACE_ID(); struct object_surface *obj_surface = SURFACE(surfaceID); - struct object_image *obj_image; - struct object_buffer *obj_buffer; if (NULL == obj_surface) { vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; break; } - obj_image = i965_CreateImage_impl(ctx, &vaFormat, width, height, surfaceID); - if (!obj_image) { - vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; - break; - } - - obj_buffer = BUFFER(obj_image->image.buf); - if (!obj_buffer) { - vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; - break; - } - assert(obj_buffer->buffer_store); - 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->image = obj_image->image; - obj_surface->is_derived = 0; - obj_surface->bo = obj_buffer->buffer_store->bo; + 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 */ @@ -447,7 +379,6 @@ struct object_surface *obj_surface = SURFACE(surface_list[i]); assert(obj_surface); - i965_DestroyImage_impl(ctx, IMAGE(obj_surface->image.image_id), 1); i965_destroy_surface(&i965->surface_heap, (struct object_base *)obj_surface); } @@ -459,21 +390,29 @@ 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; + *num_formats = 0; 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 */ @@ -528,7 +467,6 @@ 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; } @@ -549,8 +487,7 @@ VASubpictureID subpicture, VAImageID image) { - /* TODO */ - return VA_STATUS_ERROR_UNIMPLEMENTED; + return VA_STATUS_SUCCESS; } VAStatus @@ -560,8 +497,7 @@ unsigned int chromakey_max, unsigned int chromakey_mask) { - /* TODO */ - return VA_STATUS_ERROR_UNIMPLEMENTED; + return VA_STATUS_SUCCESS; } VAStatus @@ -569,8 +505,7 @@ VASubpictureID subpicture, float global_alpha) { - /* TODO */ - return VA_STATUS_ERROR_UNIMPLEMENTED; + return VA_STATUS_SUCCESS; } VAStatus @@ -1159,7 +1094,7 @@ int num_attributes) { /* TODO */ - return VA_STATUS_ERROR_UNIMPLEMENTED; + return VA_STATUS_ERROR_UNKNOWN; } /* @@ -1174,7 +1109,7 @@ int num_attributes) { /* TODO */ - return VA_STATUS_ERROR_UNIMPLEMENTED; + return VA_STATUS_ERROR_UNKNOWN; } VAStatus @@ -1184,7 +1119,7 @@ unsigned int *stride) /* out */ { /* TODO */ - return VA_STATUS_ERROR_UNIMPLEMENTED; + return VA_STATUS_ERROR_UNKNOWN; } static VAStatus @@ -1231,28 +1166,29 @@ VAStatus i965_DestroyImage(VADriverContextP ctx, VAImageID image); -static struct object_image * -i965_CreateImage_impl( - VADriverContextP ctx, - const VAImageFormat *format, - unsigned int width, - unsigned int height, - VASurfaceID surface -) +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 NULL; + return VA_STATUS_ERROR_ALLOCATION_FAILED; obj_image = IMAGE(image_id); if (!obj_image) - return NULL; - obj_image->surface = VA_INVALID_ID; + return VA_STATUS_ERROR_ALLOCATION_FAILED; obj_image->bo = NULL; obj_image->palette = NULL; @@ -1282,32 +1218,13 @@ 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 + size2; - image->pitches[2] = width2; - image->offsets[2] = size; - image->data_size = size + 2 * size2; - break; default: goto error; } - if (i965_CreateBuffer(ctx, 0, VAImageBufferType, - image->data_size, 1, NULL, - &image->buf) != VA_STATUS_SUCCESS) + 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; @@ -1322,46 +1239,19 @@ image->format = *format; image->width = width; image->height = height; - return obj_image; - - error: - i965_DestroyImage_impl(ctx, obj_image, 0); - return NULL; -} - -VAStatus -i965_CreateImage(VADriverContextP ctx, - VAImageFormat *format, - int width, - int height, - VAImage *out_image) /* out */ -{ - struct object_image *obj_image; - obj_image = i965_CreateImage_impl(ctx, format, width, height, VA_INVALID_ID); - if (!obj_image) - return VA_STATUS_ERROR_ALLOCATION_FAILED; - - *out_image = obj_image->image; + *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 */ { - struct i965_driver_data *i965 = i965_driver_data(ctx); - - struct object_surface *obj_surface = SURFACE(surface); - if (!obj_surface) - return VA_STATUS_ERROR_INVALID_SURFACE; - - struct object_image *obj_image = IMAGE(obj_surface->image.image_id); - if (!obj_image) - return VA_STATUS_ERROR_INVALID_IMAGE; - - obj_surface->is_derived = 1; - *image = obj_surface->image; return VA_STATUS_SUCCESS; } @@ -1371,24 +1261,15 @@ object_heap_free(heap, obj); } -static void -i965_DestroyImage_impl( - VADriverContextP ctx, - struct object_image *obj_image, - int from_surface -) + +VAStatus +i965_DestroyImage(VADriverContextP ctx, VAImageID image) { - struct i965_driver_data * const i965 = i965_driver_data(ctx); + struct i965_driver_data *i965 = i965_driver_data(ctx); + struct object_image *obj_image = IMAGE(image); if (!obj_image) - return; - - if (!from_surface && obj_image->surface != VA_INVALID_ID) { - /* only destroy when called from vaDestroySurfaces() */ - struct object_surface *obj_surface = SURFACE(obj_image->surface); - obj_surface->is_derived = 0; - return; - } + return VA_STATUS_SUCCESS; if (obj_image->image.buf != VA_INVALID_ID) { i965_DestroyBuffer(ctx, obj_image->image.buf); @@ -1401,15 +1282,6 @@ } i965_destroy_image(&i965->image_heap, (struct object_base *)obj_image); -} - -VAStatus -i965_DestroyImage(VADriverContextP ctx, VAImageID image) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct object_image *obj_image = IMAGE(image); - - i965_DestroyImage_impl(ctx, obj_image, 0); return VA_STATUS_SUCCESS; } @@ -1450,118 +1322,7 @@ unsigned int height, VAImageID image) { - struct i965_driver_data *i965 = i965_driver_data(ctx); - - struct object_surface *obj_surface = SURFACE(surface); - if (!obj_surface) - return VA_STATUS_ERROR_INVALID_SURFACE; - - if (obj_surface->is_derived) - return VA_STATUS_ERROR_SURFACE_BUSY; - - struct object_image *obj_image = IMAGE(image); - if (!obj_image) - return VA_STATUS_ERROR_INVALID_IMAGE; - - /* XXX: we only support full-size surface readback */ - if (x != 0 || - y != 0 || - width != obj_surface->width || - height != obj_surface->height) - return VA_STATUS_ERROR_INVALID_PARAMETER; - - /* XXX: we only support 1:1 image copies */ - if (width != obj_image->image.width || - height != obj_image->image.height) - return VA_STATUS_ERROR_INVALID_PARAMETER; - - VAStatus va_status; - void *image_data = NULL; - - va_status = i965_MapBuffer(ctx, obj_image->image.buf, &image_data); - if (va_status != VA_STATUS_SUCCESS) - return va_status; - - dri_bo_map(obj_surface->bo, 0); - - switch (obj_image->image.format.fourcc) { - case VA_FOURCC('Y','V','1','2'): /* YV12 is native format here */ - memcpy(image_data, obj_surface->bo->virtual, obj_surface->bo->size); - break; - default: - va_status = VA_STATUS_ERROR_OPERATION_FAILED; - break; - } - - dri_bo_unmap(obj_surface->bo); - - i965_UnmapBuffer(ctx, obj_image->image.buf); - return va_status; -} - -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) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - - struct object_surface *obj_surface = SURFACE(surface); - if (!obj_surface) - return VA_STATUS_ERROR_INVALID_SURFACE; - - if (obj_surface->is_derived) - return VA_STATUS_ERROR_SURFACE_BUSY; - - struct object_image *obj_image = IMAGE(image); - if (!obj_image) - return VA_STATUS_ERROR_INVALID_IMAGE; - - /* XXX: we don't support partial video surface updates */ - if (src_x != 0 || - src_y != 0 || - src_width != obj_image->image.width || - src_height != obj_image->image.height) - return VA_STATUS_ERROR_OPERATION_FAILED; - if (dest_x != 0 || - dest_y != 0 || - dest_width != obj_surface->width || - dest_height != obj_surface->height) - return VA_STATUS_ERROR_OPERATION_FAILED; - if (src_width != dest_width || - src_height != dest_height) - return VA_STATUS_ERROR_OPERATION_FAILED; - - VAStatus va_status; - void *image_data = NULL; - - va_status = i965_MapBuffer(ctx, obj_image->image.buf, &image_data); - if (va_status != VA_STATUS_SUCCESS) - return va_status; - - dri_bo_map(obj_surface->bo, 1); - - switch (obj_image->image.format.fourcc) { - case VA_FOURCC('Y','V','1','2'): /* YV12 is native format here */ - memcpy(obj_surface->bo->virtual, image_data, obj_surface->bo->size); - break; - default: - va_status = VA_STATUS_ERROR_OPERATION_FAILED; - break; - } - - dri_bo_unmap(obj_surface->bo); - - i965_UnmapBuffer(ctx, obj_image->image.buf); - return va_status; + return VA_STATUS_SUCCESS; } VAStatus @@ -1587,23 +1348,13 @@ union dri_buffer *buffer; struct intel_region *dest_region; struct object_surface *obj_surface; - int ret; + int ret; uint32_t name; - VARectangle src_rect, dst_rect; Bool new_region = False; - /* Currently don't support DRI1 */ if (dri_state->driConnectedFlag != VA_DRI2) return VA_STATUS_ERROR_UNKNOWN; - /* XXX: we currently only support up to 64 cliprects */ - if (number_cliprects > MAX_CLIP_RECTS) - return VA_STATUS_ERROR_OPERATION_FAILED; - - obj_surface = SURFACE(surface); - if (!obj_surface) - return VA_STATUS_ERROR_INVALID_SURFACE; - dri_drawable = dri_get_drawable(ctx, draw); assert(dri_drawable); @@ -1642,24 +1393,17 @@ assert(ret == 0); } - src_rect.x = srcx; - src_rect.y = srcy; - src_rect.width = srcw; - src_rect.height = srch; - - dst_rect.x = destx; - dst_rect.y = desty; - dst_rect.width = destw; - dst_rect.height = desth; - - i965_render_put_surface(ctx, surface, &src_rect, &dst_rect, - cliprects, number_cliprects); - - if (obj_surface->subpic != VA_INVALID_ID) - i965_render_put_subpic(ctx, surface, &src_rect, &dst_rect, - cliprects, number_cliprects); - + 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; } diff -Nru libva-0.31.0+latest2/i965_drv_video/i965_drv_video.h libva-0.31.0+latest3/i965_drv_video/i965_drv_video.h --- libva-0.31.0+latest2/i965_drv_video/i965_drv_video.h 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/i965_drv_video/i965_drv_video.h 2010-03-18 08:39:38.000000000 +0000 @@ -43,8 +43,8 @@ #define I965_MAX_PROFILES 11 #define I965_MAX_ENTRYPOINTS 5 #define I965_MAX_CONFIG_ATTRIBUTES 10 -#define I965_MAX_IMAGE_FORMATS 1 -#define I965_MAX_SUBPIC_FORMATS 4 +#define I965_MAX_IMAGE_FORMATS 10 +#define I965_MAX_SUBPIC_FORMATS 2 #define I965_MAX_DISPLAY_ATTRIBUTES 4 #define I965_STR_VENDOR "i965 Driver 0.1" @@ -96,8 +96,6 @@ int width; int height; int size; - VAImage image; - int is_derived; dri_bo *bo; }; @@ -115,7 +113,6 @@ { struct object_base base; VAImage image; - VASurfaceID surface; dri_bo *bo; unsigned int *palette; }; @@ -129,7 +126,6 @@ unsigned int format; int width; int height; - int pitch; dri_bo *bo; }; diff -Nru libva-0.31.0+latest2/i965_drv_video/i965_render.c libva-0.31.0+latest3/i965_drv_video/i965_render.c --- libva-0.31.0+latest2/i965_drv_video/i965_render.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/i965_drv_video/i965_render.c 2010-03-18 08:39:38.000000000 +0000 @@ -587,7 +587,7 @@ int index, dri_bo *region, unsigned long offset, - int w, int h, int p, int format) + int w, int h, int format) { struct i965_driver_data *i965 = i965_driver_data(ctx); struct i965_render_state *render_state = &i965->render_state; @@ -621,7 +621,7 @@ ss->ss2.mip_count = 0; ss->ss2.render_target_rotation = 0; - ss->ss3.pitch = p - 1; + ss->ss3.pitch = w - 1; dri_bo_emit_reloc(ss_bo, I915_GEM_DOMAIN_SAMPLER, 0, @@ -679,8 +679,8 @@ region = obj_surface->bo; subpic_region = obj_image->bo; /*subpicture surface*/ - i965_subpic_render_src_surface_state(ctx, 1, subpic_region, 0, obj_subpic->width, obj_subpic->height, obj_subpic->pitch, obj_subpic->format); - i965_subpic_render_src_surface_state(ctx, 2, subpic_region, 0, obj_subpic->width, obj_subpic->height, obj_subpic->pitch, obj_subpic->format); + i965_subpic_render_src_surface_state(ctx, 1, subpic_region, 0, obj_subpic->width, obj_subpic->height, obj_subpic->format); + i965_subpic_render_src_surface_state(ctx, 2, subpic_region, 0, obj_subpic->width, obj_subpic->height, obj_subpic->format); } static void @@ -788,81 +788,13 @@ dri_bo_unmap(render_state->wm.binding_table); } -static unsigned int -i965_render_do_upload_vertex(VADriverContextP ctx, - unsigned int width, - unsigned int height, - const VARectangle *src_rect, - const VARectangle *dst_rect, - const VARectangle *cliprects, - unsigned int num_cliprects) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct intel_region *dest_region = render_state->draw_region; - float *vb, tx1, tx2, ty1, ty2; - int x1, x2, y1, y2; - unsigned int i, n; - - if (!cliprects || num_cliprects == 0) { - cliprects = dst_rect; - num_cliprects = 1; - } - - dri_bo_map(render_state->vb.vertex_buffer, 1); - assert(render_state->vb.vertex_buffer->virtual); - vb = render_state->vb.vertex_buffer->virtual; - - for (n = 0, i = 0; i < num_cliprects; i++) { - x1 = dest_region->x + cliprects[i].x; - y1 = dest_region->y + cliprects[i].y; - x2 = x1 + cliprects[i].width; - y2 = y1 + cliprects[i].height; - x1 = MAX(x1, dst_rect->x); - y1 = MAX(y1, dst_rect->y); - x2 = MIN(x2, dst_rect->x + dst_rect->width); - y2 = MIN(y2, dst_rect->y + dst_rect->height); - - if (x2 <= x1 || y2 <= y1) - continue; - - const float sx1 = (float)(x1 - dst_rect->x) / (float)dst_rect->width; - const float sy1 = (float)(y1 - dst_rect->y) / (float)dst_rect->height; - const float sx2 = (float)(x2 - dst_rect->x) / (float)dst_rect->width; - const float sy2 = (float)(y2 - dst_rect->y) / (float)dst_rect->height; - tx1 = ((float)src_rect->x + sx1 * (float)src_rect->width) / width; - ty1 = ((float)src_rect->y + sy1 * (float)src_rect->height) / height; - tx2 = ((float)src_rect->x + sx2 * (float)src_rect->width) / width; - ty2 = ((float)src_rect->y + sy2 * (float)src_rect->height) / height; - - vb[n++] = tx2; - vb[n++] = ty2; - vb[n++] = x2; - vb[n++] = y2; - - vb[n++] = tx1; - vb[n++] = ty2; - vb[n++] = x1; - vb[n++] = y2; - - vb[n++] = tx1; - vb[n++] = ty1; - vb[n++] = x1; - vb[n++] = y1; - } - - dri_bo_unmap(render_state->vb.vertex_buffer); - return n / 12; -} - -static unsigned int +static void i965_subpic_render_upload_vertex(VADriverContextP ctx, VASurfaceID surface, - const VARectangle *output_rect, - const VARectangle *cliprects, - unsigned int num_cliprects) -{ + const VARectangle *output_rect) +{ struct i965_driver_data *i965 = i965_driver_data(ctx); + struct i965_render_state *render_state = &i965->render_state; struct object_surface *obj_surface = SURFACE(surface); struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic); @@ -872,6 +804,8 @@ const float ssy = (float)output_rect->height / (float)obj_surface->height; const float sx = psx * ssx; const float sy = psy * ssy; + float *vb, tx1, tx2, ty1, ty2, x1, x2, y1, y2; + int i = 0; VARectangle dst_rect; dst_rect.x = output_rect->x + sx * (float)obj_subpic->dst_rect.x; @@ -879,38 +813,106 @@ dst_rect.width = sx * (float)obj_subpic->dst_rect.width; dst_rect.height = sy * (float)obj_subpic->dst_rect.height; - return i965_render_do_upload_vertex(ctx, - obj_subpic->width, obj_subpic->height, - &obj_subpic->src_rect, &dst_rect, - cliprects, num_cliprects); + dri_bo_map(render_state->vb.vertex_buffer, 1); + assert(render_state->vb.vertex_buffer->virtual); + vb = render_state->vb.vertex_buffer->virtual; + + tx1 = (float)obj_subpic->src_rect.x / (float)obj_subpic->width; + ty1 = (float)obj_subpic->src_rect.y / (float)obj_subpic->height; + tx2 = (float)(obj_subpic->src_rect.x + obj_subpic->src_rect.width) / (float)obj_subpic->width; + ty2 = (float)(obj_subpic->src_rect.y + obj_subpic->src_rect.height) / (float)obj_subpic->height; + + x1 = (float)dst_rect.x; + y1 = (float)dst_rect.y; + x2 = (float)(dst_rect.x + dst_rect.width); + y2 = (float)(dst_rect.y + dst_rect.height); + + vb[i++] = tx2; + vb[i++] = ty2; + vb[i++] = x2; + vb[i++] = y2; + + vb[i++] = tx1; + vb[i++] = ty2; + vb[i++] = x1; + vb[i++] = y2; + + vb[i++] = tx1; + vb[i++] = ty1; + vb[i++] = x1; + vb[i++] = y1; + dri_bo_unmap(render_state->vb.vertex_buffer); } -static unsigned int +static void i965_render_upload_vertex(VADriverContextP ctx, VASurfaceID surface, - const VARectangle *src_rect, - const VARectangle *dst_rect, - const VARectangle *cliprects, - unsigned int num_cliprects) + short srcx, + short srcy, + unsigned short srcw, + unsigned short srch, + short destx, + short desty, + unsigned short destw, + unsigned short desth) { struct i965_driver_data *i965 = i965_driver_data(ctx); - struct object_surface *obj_surface = SURFACE(surface); - assert(obj_surface); + struct i965_render_state *render_state = &i965->render_state; + struct intel_region *dest_region = render_state->draw_region; + struct object_surface *obj_surface; + float *vb; + + float u1, v1, u2, v2; + int i, width, height; + int box_x1 = dest_region->x + destx; + int box_y1 = dest_region->y + desty; + int box_x2 = box_x1 + destw; + int box_y2 = box_y1 + desth; - return i965_render_do_upload_vertex(ctx, - obj_surface->width, obj_surface->height, - src_rect, - dst_rect, - cliprects, num_cliprects); + obj_surface = SURFACE(surface); + assert(surface); + width = obj_surface->width; + height = obj_surface->height; + + u1 = (float)srcx / width; + v1 = (float)srcy / height; + u2 = (float)(srcx + srcw) / width; + v2 = (float)(srcy + srch) / height; + + dri_bo_map(render_state->vb.vertex_buffer, 1); + assert(render_state->vb.vertex_buffer->virtual); + vb = render_state->vb.vertex_buffer->virtual; + + i = 0; + vb[i++] = u2; + vb[i++] = v2; + vb[i++] = (float)box_x2; + vb[i++] = (float)box_y2; + + vb[i++] = u1; + vb[i++] = v2; + vb[i++] = (float)box_x1; + vb[i++] = (float)box_y2; + + vb[i++] = u1; + vb[i++] = v1; + vb[i++] = (float)box_x1; + vb[i++] = (float)box_y1; + + dri_bo_unmap(render_state->vb.vertex_buffer); } -static unsigned int +static void i965_surface_render_state_setup(VADriverContextP ctx, - VASurfaceID surface, - const VARectangle *src_rect, - const VARectangle *dst_rect, - const VARectangle *cliprects, - unsigned int num_cliprects) + VASurfaceID surface, + short srcx, + short srcy, + unsigned short srcw, + unsigned short srch, + short destx, + short desty, + unsigned short destw, + unsigned short desth) { i965_render_vs_unit(ctx); i965_render_sf_unit(ctx); @@ -921,17 +923,21 @@ i965_render_cc_viewport(ctx); i965_render_cc_unit(ctx); i965_render_binding_table(ctx); - return i965_render_upload_vertex(ctx, surface, src_rect, dst_rect, - cliprects, num_cliprects); + i965_render_upload_vertex(ctx, surface, + srcx, srcy, srcw, srch, + destx, desty, destw, desth); } - -static unsigned int +static void i965_subpic_render_state_setup(VADriverContextP ctx, - VASurfaceID surface, - const VARectangle *src_rect, - const VARectangle *dst_rect, - const VARectangle *cliprects, - unsigned int num_cliprects) + VASurfaceID surface, + short srcx, + short srcy, + unsigned short srcw, + unsigned short srch, + short destx, + short desty, + unsigned short destw, + unsigned short desth) { i965_render_vs_unit(ctx); i965_render_sf_unit(ctx); @@ -942,10 +948,16 @@ i965_render_cc_viewport(ctx); i965_subpic_render_cc_unit(ctx); i965_render_binding_table(ctx); - return i965_subpic_render_upload_vertex(ctx, surface, dst_rect, - cliprects, num_cliprects); + + VARectangle output_rect; + output_rect.x = destx; + output_rect.y = desty; + output_rect.width = destw; + output_rect.height = desth; + i965_subpic_render_upload_vertex(ctx, surface, &output_rect); } + static void i965_render_pipeline_select(VADriverContextP ctx) { @@ -1181,7 +1193,7 @@ } static void -i965_render_startup(VADriverContextP ctx, unsigned int vb_offset) +i965_render_startup(VADriverContextP ctx) { struct i965_driver_data *i965 = i965_driver_data(ctx); struct i965_render_state *render_state = &i965->render_state; @@ -1192,7 +1204,7 @@ (0 << VB0_BUFFER_INDEX_SHIFT) | VB0_VERTEXDATA | ((4 * 4) << VB0_BUFFER_PITCH_SHIFT)); - OUT_RELOC(ctx, render_state->vb.vertex_buffer, I915_GEM_DOMAIN_VERTEX, 0, vb_offset); + OUT_RELOC(ctx, render_state->vb.vertex_buffer, I915_GEM_DOMAIN_VERTEX, 0, 0); if (IS_IGDNG(i965->intel.device_id)) OUT_RELOC(ctx, render_state->vb.vertex_buffer, I915_GEM_DOMAIN_VERTEX, 0, 12 * 4); @@ -1257,10 +1269,8 @@ } static void -i965_surface_render_pipeline_setup(VADriverContextP ctx, unsigned int n_rects) +i965_surface_render_pipeline_setup(VADriverContextP ctx) { - unsigned int i; - intel_batchbuffer_start_atomic(ctx, 0x1000); intel_batchbuffer_emit_mi_flush(ctx); i965_clear_dest_region(ctx); @@ -1274,16 +1284,13 @@ i965_render_cs_urb_layout(ctx); i965_render_drawing_rectangle(ctx); i965_render_vertex_elements(ctx); - for (i = 0; i < n_rects; i++) - i965_render_startup(ctx, 48 * i); + i965_render_startup(ctx); intel_batchbuffer_end_atomic(ctx); } static void -i965_subpic_render_pipeline_setup(VADriverContextP ctx, unsigned int n_rects) +i965_subpic_render_pipeline_setup(VADriverContextP ctx) { - unsigned int i; - intel_batchbuffer_start_atomic(ctx, 0x1000); intel_batchbuffer_emit_mi_flush(ctx); i965_render_pipeline_select(ctx); @@ -1296,8 +1303,7 @@ i965_render_cs_urb_layout(ctx); i965_render_drawing_rectangle(ctx); i965_render_vertex_elements(ctx); - for (i = 0; i < n_rects; i++) - i965_render_startup(ctx, 48 * i); + i965_render_startup(ctx); intel_batchbuffer_end_atomic(ctx); } @@ -1391,39 +1397,45 @@ void i965_render_put_surface(VADriverContextP ctx, VASurfaceID surface, - const VARectangle *src_rect, - const VARectangle *dst_rect, - const VARectangle *cliprects, - unsigned int num_cliprects) + short srcx, + short srcy, + unsigned short srcw, + unsigned short srch, + short destx, + short desty, + unsigned short destw, + unsigned short desth) { - unsigned int n_rects; - i965_render_initialize(ctx); - n_rects = i965_surface_render_state_setup(ctx, surface, - src_rect, dst_rect, - cliprects, num_cliprects); - i965_surface_render_pipeline_setup(ctx, n_rects); + i965_surface_render_state_setup(ctx, surface, + srcx, srcy, srcw, srch, + destx, desty, destw, desth); + i965_surface_render_pipeline_setup(ctx); intel_batchbuffer_flush(ctx); } void i965_render_put_subpic(VADriverContextP ctx, - VASurfaceID surface, - const VARectangle *src_rect, - const VARectangle *dst_rect, - const VARectangle *cliprects, - unsigned int num_cliprects) + VASurfaceID surface, + short srcx, + short srcy, + unsigned short srcw, + unsigned short srch, + short destx, + short desty, + unsigned short destw, + unsigned short desth) { struct i965_driver_data *i965 = i965_driver_data(ctx); struct object_surface *obj_surface = SURFACE(surface); struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic); - unsigned int n_rects; assert(obj_subpic); i965_render_initialize(ctx); - n_rects = i965_subpic_render_state_setup(ctx, surface, src_rect, dst_rect, - cliprects, num_cliprects); - i965_subpic_render_pipeline_setup(ctx, n_rects); + i965_subpic_render_state_setup(ctx, surface, + srcx, srcy, srcw, srch, + destx, desty, destw, desth); + i965_subpic_render_pipeline_setup(ctx); i965_render_upload_image_palette(ctx, obj_subpic->image, 0xff); intel_batchbuffer_flush(ctx); } diff -Nru libva-0.31.0+latest2/i965_drv_video/i965_render.h libva-0.31.0+latest3/i965_drv_video/i965_render.h --- libva-0.31.0+latest2/i965_drv_video/i965_render.h 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/i965_drv_video/i965_render.h 2009-07-03 17:32:12.000000000 +0100 @@ -28,7 +28,6 @@ #ifndef _I965_RENDER_H_ #define _I965_RENDER_H_ -#define MAX_CLIP_RECTS 80 /* vb_bo:4096 / vb:(3*4*4) */ #define MAX_RENDER_SURFACES 16 #define MAX_SAMPLERS 16 @@ -66,20 +65,27 @@ Bool i965_render_init(VADriverContextP ctx); Bool i965_render_terminate(VADriverContextP ctx); - void i965_render_put_surface(VADriverContextP ctx, VASurfaceID surface, - const VARectangle *src_rect, - const VARectangle *dst_rect, - const VARectangle *cliprects, - unsigned int num_cliprects); + short srcx, + short srcy, + unsigned short srcw, + unsigned short srch, + short destx, + short desty, + unsigned short destw, + unsigned short desth); + void i965_render_put_subpic(VADriverContextP ctx, - VASurfaceID surface, - const VARectangle *src_rect, - const VARectangle *dst_rect, - const VARectangle *cliprects, - unsigned int num_cliprects); - + VASurfaceID surface, + short srcx, + short srcy, + unsigned short srcw, + unsigned short srch, + short destx, + short desty, + unsigned short destw, + unsigned short desth); #endif /* _I965_RENDER_H_ */ diff -Nru libva-0.31.0+latest2/libva-glx.pc.in libva-0.31.0+latest3/libva-glx.pc.in --- libva-0.31.0+latest2/libva-glx.pc.in 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/libva-glx.pc.in 1970-01-01 01:00:00.000000000 +0100 @@ -1,12 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ -display=glx - -Name: libva-${display} -Description: Userspace Video Acceleration (VA) ${display} interface -Requires: libva -Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -lva-${display} -Cflags: -I${includedir} diff -Nru libva-0.31.0+latest2/libva.pc.in libva-0.31.0+latest3/libva.pc.in --- libva-0.31.0+latest2/libva.pc.in 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/libva.pc.in 2009-09-10 16:18:49.000000000 +0100 @@ -3,7 +3,6 @@ libdir=@libdir@ includedir=@includedir@ driverdir=@LIBVA_DRIVERS_PATH@ -sdsversion=@LIBVA_SDS_VERSION@ Name: libva Description: Userspace Video Acceleration (VA) core interface diff -Nru libva-0.31.0+latest2/libva-x11.pc.in libva-0.31.0+latest3/libva-x11.pc.in --- libva-0.31.0+latest2/libva-x11.pc.in 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/libva-x11.pc.in 2009-09-10 16:18:49.000000000 +0100 @@ -6,7 +6,6 @@ Name: libva-${display} Description: Userspace Video Acceleration (VA) ${display} interface -Requires: libva Version: @PACKAGE_VERSION@ Libs: -L${libdir} -lva-${display} Cflags: -I${includedir} diff -Nru libva-0.31.0+latest2/Makefile.am libva-0.31.0+latest3/Makefile.am --- libva-0.31.0+latest2/Makefile.am 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/Makefile.am 2010-03-18 08:39:39.000000000 +0000 @@ -32,13 +32,10 @@ pcfiles = libva.pc pcfiles += libva-x11.pc -if USE_GLX -pcfiles += libva-glx.pc -endif pkgconfigdir = @pkgconfigdir@ pkgconfig_DATA = $(pcfiles) -EXTRA_DIST = libva.pc.in libva-x11.pc.in libva-glx.pc.in +EXTRA_DIST = libva.pc.in libva-x11.pc.in CLEANFILES = $(pcfiles) diff -Nru libva-0.31.0+latest2/.pc/032_g45_fix_subpic_formats.patch/i965_drv_video/i965_drv_video.c libva-0.31.0+latest3/.pc/032_g45_fix_subpic_formats.patch/i965_drv_video/i965_drv_video.c --- libva-0.31.0+latest2/.pc/032_g45_fix_subpic_formats.patch/i965_drv_video/i965_drv_video.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/032_g45_fix_subpic_formats.patch/i965_drv_video/i965_drv_video.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,1531 +0,0 @@ -/* - * 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 - -#include "va/x11/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 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 }, -}; - -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 */ -{ - if (num_formats) - *num_formats = 0; - - 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->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) -{ - return VA_STATUS_SUCCESS; -} - -VAStatus -i965_SetSubpictureChromakey(VADriverContextP ctx, - VASubpictureID subpicture, - unsigned int chromakey_min, - unsigned int chromakey_max, - unsigned int chromakey_mask) -{ - return VA_STATUS_SUCCESS; -} - -VAStatus -i965_SetSubpictureGlobalAlpha(VADriverContextP ctx, - VASubpictureID subpicture, - float global_alpha) -{ - return VA_STATUS_SUCCESS; -} - -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_UNKNOWN; -} - -/* - * 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_UNKNOWN; -} - -VAStatus -i965_DbgCopySurfaceToBuffer(VADriverContextP ctx, - VASurfaceID surface, - void **buffer, /* out */ - unsigned int *stride) /* out */ -{ - /* TODO */ - return VA_STATUS_ERROR_UNKNOWN; -} - -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; - 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 */ -{ - return VA_STATUS_SUCCESS; -} - -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 -Nru libva-0.31.0+latest2/.pc/033_g45_add_rgba_subpic.patch/i965_drv_video/i965_drv_video.c libva-0.31.0+latest3/.pc/033_g45_add_rgba_subpic.patch/i965_drv_video/i965_drv_video.c --- libva-0.31.0+latest2/.pc/033_g45_add_rgba_subpic.patch/i965_drv_video/i965_drv_video.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/033_g45_add_rgba_subpic.patch/i965_drv_video/i965_drv_video.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,1531 +0,0 @@ -/* - * 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 - -#include "va/x11/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 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 }, -}; - -static const i965_subpic_format_map_t * -get_subpic_format(const VAImageFormat *va_format) -{ - unsigned int i; - for (i = 0; i965_subpic_formats_map[i].type != 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 */ -{ - if (num_formats) - *num_formats = 0; - - 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->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) -{ - return VA_STATUS_SUCCESS; -} - -VAStatus -i965_SetSubpictureChromakey(VADriverContextP ctx, - VASubpictureID subpicture, - unsigned int chromakey_min, - unsigned int chromakey_max, - unsigned int chromakey_mask) -{ - return VA_STATUS_SUCCESS; -} - -VAStatus -i965_SetSubpictureGlobalAlpha(VADriverContextP ctx, - VASubpictureID subpicture, - float global_alpha) -{ - return VA_STATUS_SUCCESS; -} - -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_UNKNOWN; -} - -/* - * 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_UNKNOWN; -} - -VAStatus -i965_DbgCopySurfaceToBuffer(VADriverContextP ctx, - VASurfaceID surface, - void **buffer, /* out */ - unsigned int *stride) /* out */ -{ - /* TODO */ - return VA_STATUS_ERROR_UNKNOWN; -} - -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; - 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 */ -{ - return VA_STATUS_SUCCESS; -} - -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 -Nru libva-0.31.0+latest2/.pc/033_g45_add_rgba_subpic.patch/i965_drv_video/i965_drv_video.h libva-0.31.0+latest3/.pc/033_g45_add_rgba_subpic.patch/i965_drv_video/i965_drv_video.h --- libva-0.31.0+latest2/.pc/033_g45_add_rgba_subpic.patch/i965_drv_video/i965_drv_video.h 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/033_g45_add_rgba_subpic.patch/i965_drv_video/i965_drv_video.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,173 +0,0 @@ -/* - * 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 - * - */ - -#ifndef _I965_DRV_VIDEO_H_ -#define _I965_DRV_VIDEO_H_ - -#include -#include - -#include "object_heap.h" - -#include "intel_driver.h" - -#include "i965_media.h" -#include "i965_render.h" - -#define I965_MAX_PROFILES 11 -#define I965_MAX_ENTRYPOINTS 5 -#define I965_MAX_CONFIG_ATTRIBUTES 10 -#define I965_MAX_IMAGE_FORMATS 10 -#define I965_MAX_SUBPIC_FORMATS 2 -#define I965_MAX_DISPLAY_ATTRIBUTES 4 -#define I965_STR_VENDOR "i965 Driver 0.1" - -struct buffer_store -{ - unsigned char *buffer; - dri_bo *bo; - int ref_count; -}; - -struct object_config -{ - struct object_base base; - VAProfile profile; - VAEntrypoint entrypoint; - VAConfigAttrib attrib_list[I965_MAX_CONFIG_ATTRIBUTES]; - int num_attribs; -}; - -struct decode_state -{ - struct buffer_store *pic_param; - struct buffer_store *slice_param; - struct buffer_store *iq_matrix; - struct buffer_store *bit_plane; - struct buffer_store *slice_data; - VASurfaceID current_render_target; - int num_slices; -}; - -struct object_context -{ - struct object_base base; - VAContextID context_id; - VAConfigID config_id; - VASurfaceID *render_targets; - int num_render_targets; - int picture_width; - int picture_height; - int flags; - struct decode_state decode_state; -}; - -struct object_surface -{ - struct object_base base; - VASurfaceStatus status; - VASubpictureID subpic; - int width; - int height; - int size; - dri_bo *bo; -}; - -struct object_buffer -{ - struct object_base base; - struct buffer_store *buffer_store; - int max_num_elements; - int num_elements; - int size_element; - VABufferType type; -}; - -struct object_image -{ - struct object_base base; - VAImage image; - dri_bo *bo; - unsigned int *palette; -}; - -struct object_subpic -{ - struct object_base base; - VAImageID image; - VARectangle src_rect; - VARectangle dst_rect; - unsigned int format; - int width; - int height; - dri_bo *bo; -}; - - - -struct i965_driver_data -{ - struct intel_driver_data intel; - struct object_heap config_heap; - struct object_heap context_heap; - struct object_heap surface_heap; - struct object_heap buffer_heap; - struct object_heap image_heap; - struct object_heap subpic_heap; - struct i965_media_state media_state; - struct i965_render_state render_state; -}; - -#define NEW_CONFIG_ID() object_heap_allocate(&i965->config_heap); -#define NEW_CONTEXT_ID() object_heap_allocate(&i965->context_heap); -#define NEW_SURFACE_ID() object_heap_allocate(&i965->surface_heap); -#define NEW_BUFFER_ID() object_heap_allocate(&i965->buffer_heap); -#define NEW_IMAGE_ID() object_heap_allocate(&i965->image_heap); -#define NEW_SUBPIC_ID() object_heap_allocate(&i965->subpic_heap); - -#define CONFIG(id) ((struct object_config *)object_heap_lookup(&i965->config_heap, id)) -#define CONTEXT(id) ((struct object_context *)object_heap_lookup(&i965->context_heap, id)) -#define SURFACE(id) ((struct object_surface *)object_heap_lookup(&i965->surface_heap, id)) -#define BUFFER(id) ((struct object_buffer *)object_heap_lookup(&i965->buffer_heap, id)) -#define IMAGE(id) ((struct object_image *)object_heap_lookup(&i965->image_heap, id)) -#define SUBPIC(id) ((struct object_subpic *)object_heap_lookup(&i965->subpic_heap, id)) - -#define FOURCC_IA44 0x34344149 -#define FOURCC_AI44 0x34344941 - -#define STRIDE(w) (((w) + 0xf) & ~0xf) -#define SIZE_YUV420(w, h) (h * (STRIDE(w) + STRIDE(w >> 1))) - -static INLINE struct i965_driver_data * -i965_driver_data(VADriverContextP ctx) -{ - return (struct i965_driver_data *)(ctx->pDriverData); -} - -#endif /* _I965_DRV_VIDEO_H_ */ diff -Nru libva-0.31.0+latest2/.pc/033_g45_add_rgba_subpic.patch/i965_drv_video/i965_render.c libva-0.31.0+latest3/.pc/033_g45_add_rgba_subpic.patch/i965_drv_video/i965_render.c --- libva-0.31.0+latest2/.pc/033_g45_add_rgba_subpic.patch/i965_drv_video/i965_render.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/033_g45_add_rgba_subpic.patch/i965_drv_video/i965_render.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,1516 +0,0 @@ -/* - * Copyright © 2006 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, sublicense, - * 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 NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS 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: - * Eric Anholt - * Keith Packard - * Xiang Haihao - * - */ - -/* - * Most of rendering codes are ported from xf86-video-intel/src/i965_video.c - */ - -#include -#include -#include -#include - -#include -#include "va/x11/va_dricommon.h" - -#include "intel_batchbuffer.h" -#include "intel_driver.h" - -#include "i965_defines.h" -#include "i965_render.h" -#include "i965_drv_video.h" - -#define SF_KERNEL_NUM_GRF 16 -#define SF_MAX_THREADS 1 - -static const unsigned int sf_kernel_static[][4] = -{ -#include "shaders/render/exa_sf.g4b" -}; - -#define PS_KERNEL_NUM_GRF 32 -#define PS_MAX_THREADS 32 - -#define I965_GRF_BLOCKS(nreg) ((nreg + 15) / 16 - 1) - -static const unsigned int ps_kernel_static[][4] = -{ -#include "shaders/render/exa_wm_xy.g4b" -#include "shaders/render/exa_wm_src_affine.g4b" -#include "shaders/render/exa_wm_src_sample_planar.g4b" -#include "shaders/render/exa_wm_yuv_rgb.g4b" -#include "shaders/render/exa_wm_write.g4b" -}; -static const unsigned int ps_subpic_kernel_static[][4] = -{ -#include "shaders/render/exa_wm_xy.g4b" -#include "shaders/render/exa_wm_src_affine.g4b" -#include "shaders/render/exa_wm_src_sample_argb.g4b" -#include "shaders/render/exa_wm_write.g4b" -}; - -/* On IGDNG */ -static const unsigned int sf_kernel_static_gen5[][4] = -{ -#include "shaders/render/exa_sf.g4b.gen5" -}; - -static const unsigned int ps_kernel_static_gen5[][4] = -{ -#include "shaders/render/exa_wm_xy.g4b.gen5" -#include "shaders/render/exa_wm_src_affine.g4b.gen5" -#include "shaders/render/exa_wm_src_sample_planar.g4b.gen5" -#include "shaders/render/exa_wm_yuv_rgb.g4b.gen5" -#include "shaders/render/exa_wm_write.g4b.gen5" -}; -static const unsigned int ps_subpic_kernel_static_gen5[][4] = -{ -#include "shaders/render/exa_wm_xy.g4b.gen5" -#include "shaders/render/exa_wm_src_affine.g4b.gen5" -#include "shaders/render/exa_wm_src_sample_argb.g4b.gen5" -#include "shaders/render/exa_wm_write.g4b.gen5" -}; - -static uint32_t float_to_uint (float f) -{ - union { - uint32_t i; - float f; - } x; - - x.f = f; - return x.i; -} - -enum -{ - SF_KERNEL = 0, - PS_KERNEL, - PS_SUBPIC_KERNEL -}; - -struct render_kernel -{ - char *name; - const unsigned int (*bin)[4]; - int size; - dri_bo *bo; -}; - -static struct render_kernel render_kernels_gen4[] = { - { - "SF", - sf_kernel_static, - sizeof(sf_kernel_static), - NULL - }, - { - "PS", - ps_kernel_static, - sizeof(ps_kernel_static), - NULL - }, - - { - "PS_SUBPIC", - ps_subpic_kernel_static, - sizeof(ps_subpic_kernel_static), - NULL - } -}; - -static struct render_kernel render_kernels_gen5[] = { - { - "SF", - sf_kernel_static_gen5, - sizeof(sf_kernel_static_gen5), - NULL - }, - { - "PS", - ps_kernel_static_gen5, - sizeof(ps_kernel_static_gen5), - NULL - }, - - { - "PS_SUBPIC", - ps_subpic_kernel_static_gen5, - sizeof(ps_subpic_kernel_static_gen5), - NULL - } -}; - -static struct render_kernel *render_kernels = NULL; - -#define NUM_RENDER_KERNEL (sizeof(render_kernels_gen4)/sizeof(render_kernels_gen4[0])) - -#define URB_VS_ENTRIES 8 -#define URB_VS_ENTRY_SIZE 1 - -#define URB_GS_ENTRIES 0 -#define URB_GS_ENTRY_SIZE 0 - -#define URB_CLIP_ENTRIES 0 -#define URB_CLIP_ENTRY_SIZE 0 - -#define URB_SF_ENTRIES 1 -#define URB_SF_ENTRY_SIZE 2 - -#define URB_CS_ENTRIES 0 -#define URB_CS_ENTRY_SIZE 0 - -static void -i965_render_vs_unit(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct i965_vs_unit_state *vs_state; - - dri_bo_map(render_state->vs.state, 1); - assert(render_state->vs.state->virtual); - vs_state = render_state->vs.state->virtual; - memset(vs_state, 0, sizeof(*vs_state)); - - if (IS_IGDNG(i965->intel.device_id)) - vs_state->thread4.nr_urb_entries = URB_VS_ENTRIES >> 2; - else - vs_state->thread4.nr_urb_entries = URB_VS_ENTRIES; - - vs_state->thread4.urb_entry_allocation_size = URB_VS_ENTRY_SIZE - 1; - vs_state->vs6.vs_enable = 0; - vs_state->vs6.vert_cache_disable = 1; - - dri_bo_unmap(render_state->vs.state); -} - -static void -i965_render_sf_unit(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct i965_sf_unit_state *sf_state; - - dri_bo_map(render_state->sf.state, 1); - assert(render_state->sf.state->virtual); - sf_state = render_state->sf.state->virtual; - memset(sf_state, 0, sizeof(*sf_state)); - - sf_state->thread0.grf_reg_count = I965_GRF_BLOCKS(SF_KERNEL_NUM_GRF); - sf_state->thread0.kernel_start_pointer = render_kernels[SF_KERNEL].bo->offset >> 6; - - sf_state->sf1.single_program_flow = 1; /* XXX */ - sf_state->sf1.binding_table_entry_count = 0; - sf_state->sf1.thread_priority = 0; - sf_state->sf1.floating_point_mode = 0; /* Mesa does this */ - sf_state->sf1.illegal_op_exception_enable = 1; - sf_state->sf1.mask_stack_exception_enable = 1; - sf_state->sf1.sw_exception_enable = 1; - - /* scratch space is not used in our kernel */ - sf_state->thread2.per_thread_scratch_space = 0; - sf_state->thread2.scratch_space_base_pointer = 0; - - sf_state->thread3.const_urb_entry_read_length = 0; /* no const URBs */ - sf_state->thread3.const_urb_entry_read_offset = 0; /* no const URBs */ - sf_state->thread3.urb_entry_read_length = 1; /* 1 URB per vertex */ - sf_state->thread3.urb_entry_read_offset = 0; - sf_state->thread3.dispatch_grf_start_reg = 3; - - sf_state->thread4.max_threads = SF_MAX_THREADS - 1; - sf_state->thread4.urb_entry_allocation_size = URB_SF_ENTRY_SIZE - 1; - sf_state->thread4.nr_urb_entries = URB_SF_ENTRIES; - sf_state->thread4.stats_enable = 1; - - sf_state->sf5.viewport_transform = 0; /* skip viewport */ - - sf_state->sf6.cull_mode = I965_CULLMODE_NONE; - sf_state->sf6.scissor = 0; - - sf_state->sf7.trifan_pv = 2; - - sf_state->sf6.dest_org_vbias = 0x8; - sf_state->sf6.dest_org_hbias = 0x8; - - dri_bo_emit_reloc(render_state->sf.state, - I915_GEM_DOMAIN_INSTRUCTION, 0, - sf_state->thread0.grf_reg_count << 1, - offsetof(struct i965_sf_unit_state, thread0), - render_kernels[SF_KERNEL].bo); - - dri_bo_unmap(render_state->sf.state); -} - -static void -i965_render_sampler(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct i965_sampler_state *sampler_state; - int i; - - assert(render_state->wm.sampler_count > 0); - assert(render_state->wm.sampler_count <= MAX_SAMPLERS); - - dri_bo_map(render_state->wm.sampler, 1); - assert(render_state->wm.sampler->virtual); - sampler_state = render_state->wm.sampler->virtual; - for (i = 0; i < render_state->wm.sampler_count; i++) { - memset(sampler_state, 0, sizeof(*sampler_state)); - sampler_state->ss0.min_filter = I965_MAPFILTER_LINEAR; - sampler_state->ss0.mag_filter = I965_MAPFILTER_LINEAR; - sampler_state->ss1.r_wrap_mode = I965_TEXCOORDMODE_CLAMP; - sampler_state->ss1.s_wrap_mode = I965_TEXCOORDMODE_CLAMP; - sampler_state->ss1.t_wrap_mode = I965_TEXCOORDMODE_CLAMP; - sampler_state++; - } - - dri_bo_unmap(render_state->wm.sampler); -} -static void -i965_subpic_render_wm_unit(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct i965_wm_unit_state *wm_state; - - assert(render_state->wm.sampler); - - dri_bo_map(render_state->wm.state, 1); - assert(render_state->wm.state->virtual); - wm_state = render_state->wm.state->virtual; - memset(wm_state, 0, sizeof(*wm_state)); - - wm_state->thread0.grf_reg_count = I965_GRF_BLOCKS(PS_KERNEL_NUM_GRF); - wm_state->thread0.kernel_start_pointer = render_kernels[PS_SUBPIC_KERNEL].bo->offset >> 6; - - wm_state->thread1.single_program_flow = 1; /* XXX */ - - if (IS_IGDNG(i965->intel.device_id)) - wm_state->thread1.binding_table_entry_count = 0; /* hardware requirement */ - else - wm_state->thread1.binding_table_entry_count = 7; - - wm_state->thread2.scratch_space_base_pointer = 0; - wm_state->thread2.per_thread_scratch_space = 0; /* 1024 bytes */ - - wm_state->thread3.dispatch_grf_start_reg = 3; /* XXX */ - wm_state->thread3.const_urb_entry_read_length = 0; - wm_state->thread3.const_urb_entry_read_offset = 0; - wm_state->thread3.urb_entry_read_length = 1; /* XXX */ - wm_state->thread3.urb_entry_read_offset = 0; /* XXX */ - - wm_state->wm4.stats_enable = 0; - wm_state->wm4.sampler_state_pointer = render_state->wm.sampler->offset >> 5; - - if (IS_IGDNG(i965->intel.device_id)) - wm_state->wm4.sampler_count = 0; /* hardware requirement */ - else - wm_state->wm4.sampler_count = (render_state->wm.sampler_count + 3) / 4; - - wm_state->wm5.max_threads = PS_MAX_THREADS - 1; - wm_state->wm5.thread_dispatch_enable = 1; - wm_state->wm5.enable_16_pix = 1; - wm_state->wm5.enable_8_pix = 0; - wm_state->wm5.early_depth_test = 1; - - dri_bo_emit_reloc(render_state->wm.state, - I915_GEM_DOMAIN_INSTRUCTION, 0, - wm_state->thread0.grf_reg_count << 1, - offsetof(struct i965_wm_unit_state, thread0), - render_kernels[PS_SUBPIC_KERNEL].bo); - - dri_bo_emit_reloc(render_state->wm.state, - I915_GEM_DOMAIN_INSTRUCTION, 0, - wm_state->wm4.sampler_count << 2, - offsetof(struct i965_wm_unit_state, wm4), - render_state->wm.sampler); - - dri_bo_unmap(render_state->wm.state); -} - - -static void -i965_render_wm_unit(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct i965_wm_unit_state *wm_state; - - assert(render_state->wm.sampler); - - dri_bo_map(render_state->wm.state, 1); - assert(render_state->wm.state->virtual); - wm_state = render_state->wm.state->virtual; - memset(wm_state, 0, sizeof(*wm_state)); - - wm_state->thread0.grf_reg_count = I965_GRF_BLOCKS(PS_KERNEL_NUM_GRF); - wm_state->thread0.kernel_start_pointer = render_kernels[PS_KERNEL].bo->offset >> 6; - - wm_state->thread1.single_program_flow = 1; /* XXX */ - - if (IS_IGDNG(i965->intel.device_id)) - wm_state->thread1.binding_table_entry_count = 0; /* hardware requirement */ - else - wm_state->thread1.binding_table_entry_count = 7; - - wm_state->thread2.scratch_space_base_pointer = 0; - wm_state->thread2.per_thread_scratch_space = 0; /* 1024 bytes */ - - wm_state->thread3.dispatch_grf_start_reg = 3; /* XXX */ - wm_state->thread3.const_urb_entry_read_length = 0; - wm_state->thread3.const_urb_entry_read_offset = 0; - wm_state->thread3.urb_entry_read_length = 1; /* XXX */ - wm_state->thread3.urb_entry_read_offset = 0; /* XXX */ - - wm_state->wm4.stats_enable = 0; - wm_state->wm4.sampler_state_pointer = render_state->wm.sampler->offset >> 5; - - if (IS_IGDNG(i965->intel.device_id)) - wm_state->wm4.sampler_count = 0; /* hardware requirement */ - else - wm_state->wm4.sampler_count = (render_state->wm.sampler_count + 3) / 4; - - wm_state->wm5.max_threads = PS_MAX_THREADS - 1; - wm_state->wm5.thread_dispatch_enable = 1; - wm_state->wm5.enable_16_pix = 1; - wm_state->wm5.enable_8_pix = 0; - wm_state->wm5.early_depth_test = 1; - - dri_bo_emit_reloc(render_state->wm.state, - I915_GEM_DOMAIN_INSTRUCTION, 0, - wm_state->thread0.grf_reg_count << 1, - offsetof(struct i965_wm_unit_state, thread0), - render_kernels[PS_KERNEL].bo); - - dri_bo_emit_reloc(render_state->wm.state, - I915_GEM_DOMAIN_INSTRUCTION, 0, - wm_state->wm4.sampler_count << 2, - offsetof(struct i965_wm_unit_state, wm4), - render_state->wm.sampler); - - dri_bo_unmap(render_state->wm.state); -} - -static void -i965_render_cc_viewport(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct i965_cc_viewport *cc_viewport; - - dri_bo_map(render_state->cc.viewport, 1); - assert(render_state->cc.viewport->virtual); - cc_viewport = render_state->cc.viewport->virtual; - memset(cc_viewport, 0, sizeof(*cc_viewport)); - - cc_viewport->min_depth = -1.e35; - cc_viewport->max_depth = 1.e35; - - dri_bo_unmap(render_state->cc.viewport); -} - -static void -i965_subpic_render_cc_unit(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct i965_cc_unit_state *cc_state; - - assert(render_state->cc.viewport); - - dri_bo_map(render_state->cc.state, 1); - assert(render_state->cc.state->virtual); - cc_state = render_state->cc.state->virtual; - memset(cc_state, 0, sizeof(*cc_state)); - - cc_state->cc0.stencil_enable = 0; /* disable stencil */ - cc_state->cc2.depth_test = 0; /* disable depth test */ - cc_state->cc2.logicop_enable = 0; /* disable logic op */ - cc_state->cc3.ia_blend_enable = 0 ; /* blend alpha just like colors */ - cc_state->cc3.blend_enable = 1; /* enable color blend */ - cc_state->cc3.alpha_test = 0; /* disable alpha test */ - cc_state->cc3.alpha_test_format = 0;//0:ALPHATEST_UNORM8; /*store alpha value with UNORM8 */ - cc_state->cc3.alpha_test_func = 5;//COMPAREFUNCTION_LESS; /*pass if less than the reference */ - cc_state->cc4.cc_viewport_state_offset = render_state->cc.viewport->offset >> 5; - - cc_state->cc5.dither_enable = 0; /* disable dither */ - cc_state->cc5.logicop_func = 0xc; /* WHITE */ - cc_state->cc5.statistics_enable = 1; - cc_state->cc5.ia_blend_function = I965_BLENDFUNCTION_ADD; - cc_state->cc5.ia_src_blend_factor = I965_BLENDFACTOR_DST_ALPHA; - cc_state->cc5.ia_dest_blend_factor = I965_BLENDFACTOR_DST_ALPHA; - - cc_state->cc6.clamp_post_alpha_blend = 0; - cc_state->cc6.clamp_pre_alpha_blend =0; - - /*final color = src_color*src_blend_factor +/- dst_color*dest_color_blend_factor*/ - cc_state->cc6.blend_function = I965_BLENDFUNCTION_ADD; - cc_state->cc6.src_blend_factor = I965_BLENDFACTOR_SRC_ALPHA; - cc_state->cc6.dest_blend_factor = I965_BLENDFACTOR_INV_SRC_ALPHA; - - /*alpha test reference*/ - cc_state->cc7.alpha_ref.f =0.0 ; - - - dri_bo_emit_reloc(render_state->cc.state, - I915_GEM_DOMAIN_INSTRUCTION, 0, - 0, - offsetof(struct i965_cc_unit_state, cc4), - render_state->cc.viewport); - - dri_bo_unmap(render_state->cc.state); -} - - -static void -i965_render_cc_unit(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct i965_cc_unit_state *cc_state; - - assert(render_state->cc.viewport); - - dri_bo_map(render_state->cc.state, 1); - assert(render_state->cc.state->virtual); - cc_state = render_state->cc.state->virtual; - memset(cc_state, 0, sizeof(*cc_state)); - - cc_state->cc0.stencil_enable = 0; /* disable stencil */ - cc_state->cc2.depth_test = 0; /* disable depth test */ - cc_state->cc2.logicop_enable = 1; /* enable logic op */ - cc_state->cc3.ia_blend_enable = 0; /* blend alpha just like colors */ - cc_state->cc3.blend_enable = 0; /* disable color blend */ - cc_state->cc3.alpha_test = 0; /* disable alpha test */ - cc_state->cc4.cc_viewport_state_offset = render_state->cc.viewport->offset >> 5; - - cc_state->cc5.dither_enable = 0; /* disable dither */ - cc_state->cc5.logicop_func = 0xc; /* WHITE */ - cc_state->cc5.statistics_enable = 1; - cc_state->cc5.ia_blend_function = I965_BLENDFUNCTION_ADD; - cc_state->cc5.ia_src_blend_factor = I965_BLENDFACTOR_ONE; - cc_state->cc5.ia_dest_blend_factor = I965_BLENDFACTOR_ONE; - - dri_bo_emit_reloc(render_state->cc.state, - I915_GEM_DOMAIN_INSTRUCTION, 0, - 0, - offsetof(struct i965_cc_unit_state, cc4), - render_state->cc.viewport); - - dri_bo_unmap(render_state->cc.state); -} - -static void -i965_render_src_surface_state(VADriverContextP ctx, - int index, - dri_bo *region, - unsigned long offset, - int w, int h) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct i965_surface_state *ss; - dri_bo *ss_bo; - - ss_bo = dri_bo_alloc(i965->intel.bufmgr, - "surface state", - sizeof(struct i965_surface_state), 32); - assert(ss_bo); - dri_bo_map(ss_bo, 1); - assert(ss_bo->virtual); - ss = ss_bo->virtual; - memset(ss, 0, sizeof(*ss)); - ss->ss0.surface_type = I965_SURFACE_2D; - ss->ss0.surface_format = I965_SURFACEFORMAT_R8_UNORM; - ss->ss0.writedisable_alpha = 0; - ss->ss0.writedisable_red = 0; - ss->ss0.writedisable_green = 0; - ss->ss0.writedisable_blue = 0; - ss->ss0.color_blend = 1; - ss->ss0.vert_line_stride = 0; - ss->ss0.vert_line_stride_ofs = 0; - ss->ss0.mipmap_layout_mode = 0; - ss->ss0.render_cache_read_mode = 0; - - ss->ss1.base_addr = region->offset + offset; - - ss->ss2.width = w - 1; - ss->ss2.height = h - 1; - ss->ss2.mip_count = 0; - ss->ss2.render_target_rotation = 0; - - ss->ss3.pitch = w - 1; - - dri_bo_emit_reloc(ss_bo, - I915_GEM_DOMAIN_SAMPLER, 0, - offset, - offsetof(struct i965_surface_state, ss1), - region); - - dri_bo_unmap(ss_bo); - - assert(index < MAX_RENDER_SURFACES); - assert(render_state->wm.surface[index] == NULL); - render_state->wm.surface[index] = ss_bo; - render_state->wm.sampler_count++; -} - -static void -i965_subpic_render_src_surface_state(VADriverContextP ctx, - int index, - dri_bo *region, - unsigned long offset, - int w, int h, int format) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct i965_surface_state *ss; - dri_bo *ss_bo; - - ss_bo = dri_bo_alloc(i965->intel.bufmgr, - "surface state", - sizeof(struct i965_surface_state), 32); - assert(ss_bo); - dri_bo_map(ss_bo, 1); - assert(ss_bo->virtual); - ss = ss_bo->virtual; - memset(ss, 0, sizeof(*ss)); - ss->ss0.surface_type = I965_SURFACE_2D; - ss->ss0.surface_format = format; - ss->ss0.writedisable_alpha = 0; - ss->ss0.writedisable_red = 0; - ss->ss0.writedisable_green = 0; - ss->ss0.writedisable_blue = 0; - ss->ss0.color_blend = 1; - ss->ss0.vert_line_stride = 0; - ss->ss0.vert_line_stride_ofs = 0; - ss->ss0.mipmap_layout_mode = 0; - ss->ss0.render_cache_read_mode = 0; - - ss->ss1.base_addr = region->offset + offset; - - ss->ss2.width = w - 1; - ss->ss2.height = h - 1; - ss->ss2.mip_count = 0; - ss->ss2.render_target_rotation = 0; - - ss->ss3.pitch = w - 1; - - dri_bo_emit_reloc(ss_bo, - I915_GEM_DOMAIN_SAMPLER, 0, - offset, - offsetof(struct i965_surface_state, ss1), - region); - - dri_bo_unmap(ss_bo); - - assert(index < MAX_RENDER_SURFACES); - assert(render_state->wm.surface[index] == NULL); - render_state->wm.surface[index] = ss_bo; - render_state->wm.sampler_count++; -} - -static void -i965_render_src_surfaces_state(VADriverContextP ctx, - VASurfaceID surface) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct object_surface *obj_surface; - int w, h; - dri_bo *region; - - obj_surface = SURFACE(surface); - assert(obj_surface); - assert(obj_surface->bo); - w = obj_surface->width; - h = obj_surface->height; - region = obj_surface->bo; - - i965_render_src_surface_state(ctx, 1, region, 0, w, h); /* Y */ - i965_render_src_surface_state(ctx, 2, region, 0, w, h); - i965_render_src_surface_state(ctx, 3, region, w * h + w * h / 4, w / 2, h / 2); /* V */ - i965_render_src_surface_state(ctx, 4, region, w * h + w * h / 4, w / 2, h / 2); - i965_render_src_surface_state(ctx, 5, region, w * h, w / 2, h / 2); /* U */ - i965_render_src_surface_state(ctx, 6, region, w * h, w / 2, h / 2); -} - -static void -i965_subpic_render_src_surfaces_state(VADriverContextP ctx, - VASurfaceID surface) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct object_surface *obj_surface = SURFACE(surface); - int w, h; - dri_bo *region; - dri_bo *subpic_region; - struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic); - struct object_image *obj_image = IMAGE(obj_subpic->image); - assert(obj_surface); - assert(obj_surface->bo); - w = obj_surface->width; - h = obj_surface->height; - region = obj_surface->bo; - subpic_region = obj_image->bo; - /*subpicture surface*/ - i965_subpic_render_src_surface_state(ctx, 1, subpic_region, 0, obj_subpic->width, obj_subpic->height, obj_subpic->format); - i965_subpic_render_src_surface_state(ctx, 2, subpic_region, 0, obj_subpic->width, obj_subpic->height, obj_subpic->format); -} - -static void -i965_render_set_surface_tiling(struct i965_surface_state *ss, unsigned int tiling) -{ - switch (tiling) { - case I915_TILING_NONE: - ss->ss3.tiled_surface = 0; - ss->ss3.tile_walk = 0; - break; - case I915_TILING_X: - ss->ss3.tiled_surface = 1; - ss->ss3.tile_walk = I965_TILEWALK_XMAJOR; - break; - case I915_TILING_Y: - ss->ss3.tiled_surface = 1; - ss->ss3.tile_walk = I965_TILEWALK_YMAJOR; - break; - } -} - -static void -i965_render_dest_surface_state(VADriverContextP ctx, int index) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct intel_region *dest_region = render_state->draw_region; - struct i965_surface_state *ss; - dri_bo *ss_bo; - - ss_bo = dri_bo_alloc(i965->intel.bufmgr, - "surface state", - sizeof(struct i965_surface_state), 32); - assert(ss_bo); - dri_bo_map(ss_bo, 1); - assert(ss_bo->virtual); - ss = ss_bo->virtual; - memset(ss, 0, sizeof(*ss)); - - ss->ss0.surface_type = I965_SURFACE_2D; - ss->ss0.data_return_format = I965_SURFACERETURNFORMAT_FLOAT32; - - if (dest_region->cpp == 2) { - ss->ss0.surface_format = I965_SURFACEFORMAT_B5G6R5_UNORM; - } else { - ss->ss0.surface_format = I965_SURFACEFORMAT_B8G8R8A8_UNORM; - } - - ss->ss0.writedisable_alpha = 0; - ss->ss0.writedisable_red = 0; - ss->ss0.writedisable_green = 0; - ss->ss0.writedisable_blue = 0; - ss->ss0.color_blend = 1; - ss->ss0.vert_line_stride = 0; - ss->ss0.vert_line_stride_ofs = 0; - ss->ss0.mipmap_layout_mode = 0; - ss->ss0.render_cache_read_mode = 0; - - ss->ss1.base_addr = dest_region->bo->offset; - - ss->ss2.width = dest_region->width - 1; - ss->ss2.height = dest_region->height - 1; - ss->ss2.mip_count = 0; - ss->ss2.render_target_rotation = 0; - ss->ss3.pitch = dest_region->pitch - 1; - i965_render_set_surface_tiling(ss, dest_region->tiling); - - dri_bo_emit_reloc(ss_bo, - I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, - 0, - offsetof(struct i965_surface_state, ss1), - dest_region->bo); - - dri_bo_unmap(ss_bo); - - assert(index < MAX_RENDER_SURFACES); - assert(render_state->wm.surface[index] == NULL); - render_state->wm.surface[index] = ss_bo; -} - -static void -i965_render_binding_table(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - int i; - unsigned int *binding_table; - - dri_bo_map(render_state->wm.binding_table, 1); - assert(render_state->wm.binding_table->virtual); - binding_table = render_state->wm.binding_table->virtual; - memset(binding_table, 0, render_state->wm.binding_table->size); - - for (i = 0; i < MAX_RENDER_SURFACES; i++) { - if (render_state->wm.surface[i]) { - binding_table[i] = render_state->wm.surface[i]->offset; - dri_bo_emit_reloc(render_state->wm.binding_table, - I915_GEM_DOMAIN_INSTRUCTION, 0, - 0, - i * sizeof(*binding_table), - render_state->wm.surface[i]); - } - } - - dri_bo_unmap(render_state->wm.binding_table); -} - -static void -i965_subpic_render_upload_vertex(VADriverContextP ctx, - VASurfaceID surface, - const VARectangle *output_rect) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct object_surface *obj_surface = SURFACE(surface); - struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic); - - const float psx = (float)obj_surface->width / (float)obj_subpic->width; - const float psy = (float)obj_surface->height / (float)obj_subpic->height; - const float ssx = (float)output_rect->width / (float)obj_surface->width; - const float ssy = (float)output_rect->height / (float)obj_surface->height; - const float sx = psx * ssx; - const float sy = psy * ssy; - float *vb, tx1, tx2, ty1, ty2, x1, x2, y1, y2; - int i = 0; - - VARectangle dst_rect; - dst_rect.x = output_rect->x + sx * (float)obj_subpic->dst_rect.x; - dst_rect.y = output_rect->y + sx * (float)obj_subpic->dst_rect.y; - dst_rect.width = sx * (float)obj_subpic->dst_rect.width; - dst_rect.height = sy * (float)obj_subpic->dst_rect.height; - - dri_bo_map(render_state->vb.vertex_buffer, 1); - assert(render_state->vb.vertex_buffer->virtual); - vb = render_state->vb.vertex_buffer->virtual; - - tx1 = (float)obj_subpic->src_rect.x / (float)obj_subpic->width; - ty1 = (float)obj_subpic->src_rect.y / (float)obj_subpic->height; - tx2 = (float)(obj_subpic->src_rect.x + obj_subpic->src_rect.width) / (float)obj_subpic->width; - ty2 = (float)(obj_subpic->src_rect.y + obj_subpic->src_rect.height) / (float)obj_subpic->height; - - x1 = (float)dst_rect.x; - y1 = (float)dst_rect.y; - x2 = (float)(dst_rect.x + dst_rect.width); - y2 = (float)(dst_rect.y + dst_rect.height); - - vb[i++] = tx2; - vb[i++] = ty2; - vb[i++] = x2; - vb[i++] = y2; - - vb[i++] = tx1; - vb[i++] = ty2; - vb[i++] = x1; - vb[i++] = y2; - - vb[i++] = tx1; - vb[i++] = ty1; - vb[i++] = x1; - vb[i++] = y1; - dri_bo_unmap(render_state->vb.vertex_buffer); -} - -static void -i965_render_upload_vertex(VADriverContextP ctx, - VASurfaceID surface, - short srcx, - short srcy, - unsigned short srcw, - unsigned short srch, - short destx, - short desty, - unsigned short destw, - unsigned short desth) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct intel_region *dest_region = render_state->draw_region; - struct object_surface *obj_surface; - float *vb; - - float u1, v1, u2, v2; - int i, width, height; - int box_x1 = dest_region->x + destx; - int box_y1 = dest_region->y + desty; - int box_x2 = box_x1 + destw; - int box_y2 = box_y1 + desth; - - obj_surface = SURFACE(surface); - assert(surface); - width = obj_surface->width; - height = obj_surface->height; - - u1 = (float)srcx / width; - v1 = (float)srcy / height; - u2 = (float)(srcx + srcw) / width; - v2 = (float)(srcy + srch) / height; - - dri_bo_map(render_state->vb.vertex_buffer, 1); - assert(render_state->vb.vertex_buffer->virtual); - vb = render_state->vb.vertex_buffer->virtual; - - i = 0; - vb[i++] = u2; - vb[i++] = v2; - vb[i++] = (float)box_x2; - vb[i++] = (float)box_y2; - - vb[i++] = u1; - vb[i++] = v2; - vb[i++] = (float)box_x1; - vb[i++] = (float)box_y2; - - vb[i++] = u1; - vb[i++] = v1; - vb[i++] = (float)box_x1; - vb[i++] = (float)box_y1; - - dri_bo_unmap(render_state->vb.vertex_buffer); -} - -static void -i965_surface_render_state_setup(VADriverContextP ctx, - VASurfaceID surface, - short srcx, - short srcy, - unsigned short srcw, - unsigned short srch, - short destx, - short desty, - unsigned short destw, - unsigned short desth) -{ - i965_render_vs_unit(ctx); - i965_render_sf_unit(ctx); - i965_render_dest_surface_state(ctx, 0); - i965_render_src_surfaces_state(ctx, surface); - i965_render_sampler(ctx); - i965_render_wm_unit(ctx); - i965_render_cc_viewport(ctx); - i965_render_cc_unit(ctx); - i965_render_binding_table(ctx); - i965_render_upload_vertex(ctx, surface, - srcx, srcy, srcw, srch, - destx, desty, destw, desth); -} -static void -i965_subpic_render_state_setup(VADriverContextP ctx, - VASurfaceID surface, - short srcx, - short srcy, - unsigned short srcw, - unsigned short srch, - short destx, - short desty, - unsigned short destw, - unsigned short desth) -{ - i965_render_vs_unit(ctx); - i965_render_sf_unit(ctx); - i965_render_dest_surface_state(ctx, 0); - i965_subpic_render_src_surfaces_state(ctx, surface); - i965_render_sampler(ctx); - i965_subpic_render_wm_unit(ctx); - i965_render_cc_viewport(ctx); - i965_subpic_render_cc_unit(ctx); - i965_render_binding_table(ctx); - - VARectangle output_rect; - output_rect.x = destx; - output_rect.y = desty; - output_rect.width = destw; - output_rect.height = desth; - i965_subpic_render_upload_vertex(ctx, surface, &output_rect); -} - - -static void -i965_render_pipeline_select(VADriverContextP ctx) -{ - BEGIN_BATCH(ctx, 1); - OUT_BATCH(ctx, CMD_PIPELINE_SELECT | PIPELINE_SELECT_3D); - ADVANCE_BATCH(ctx); -} - -static void -i965_render_state_sip(VADriverContextP ctx) -{ - BEGIN_BATCH(ctx, 2); - OUT_BATCH(ctx, CMD_STATE_SIP | 0); - OUT_BATCH(ctx, 0); - ADVANCE_BATCH(ctx); -} - -static void -i965_render_state_base_address(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - - if (IS_IGDNG(i965->intel.device_id)) { - BEGIN_BATCH(ctx, 8); - OUT_BATCH(ctx, CMD_STATE_BASE_ADDRESS | 6); - OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); - ADVANCE_BATCH(ctx); - } else { - BEGIN_BATCH(ctx, 6); - OUT_BATCH(ctx, CMD_STATE_BASE_ADDRESS | 4); - OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); - ADVANCE_BATCH(ctx); - } -} - -static void -i965_render_binding_table_pointers(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - - BEGIN_BATCH(ctx, 6); - OUT_BATCH(ctx, CMD_BINDING_TABLE_POINTERS | 4); - OUT_BATCH(ctx, 0); /* vs */ - OUT_BATCH(ctx, 0); /* gs */ - OUT_BATCH(ctx, 0); /* clip */ - OUT_BATCH(ctx, 0); /* sf */ - OUT_RELOC(ctx, render_state->wm.binding_table, I915_GEM_DOMAIN_INSTRUCTION, 0, 0); /* wm */ - ADVANCE_BATCH(ctx); -} - -static void -i965_render_constant_color(VADriverContextP ctx) -{ - BEGIN_BATCH(ctx, 5); - OUT_BATCH(ctx, CMD_CONSTANT_COLOR | 3); - OUT_BATCH(ctx, float_to_uint(1.0)); - OUT_BATCH(ctx, float_to_uint(0.0)); - OUT_BATCH(ctx, float_to_uint(1.0)); - OUT_BATCH(ctx, float_to_uint(1.0)); - ADVANCE_BATCH(ctx); -} - -static void -i965_render_pipelined_pointers(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - - BEGIN_BATCH(ctx, 7); - OUT_BATCH(ctx, CMD_PIPELINED_POINTERS | 5); - OUT_RELOC(ctx, render_state->vs.state, I915_GEM_DOMAIN_INSTRUCTION, 0, 0); - OUT_BATCH(ctx, 0); /* disable GS */ - OUT_BATCH(ctx, 0); /* disable CLIP */ - OUT_RELOC(ctx, render_state->sf.state, I915_GEM_DOMAIN_INSTRUCTION, 0, 0); - OUT_RELOC(ctx, render_state->wm.state, I915_GEM_DOMAIN_INSTRUCTION, 0, 0); - OUT_RELOC(ctx, render_state->cc.state, I915_GEM_DOMAIN_INSTRUCTION, 0, 0); - ADVANCE_BATCH(ctx); -} - -static void -i965_render_urb_layout(VADriverContextP ctx) -{ - int urb_vs_start, urb_vs_size; - int urb_gs_start, urb_gs_size; - int urb_clip_start, urb_clip_size; - int urb_sf_start, urb_sf_size; - int urb_cs_start, urb_cs_size; - - urb_vs_start = 0; - urb_vs_size = URB_VS_ENTRIES * URB_VS_ENTRY_SIZE; - urb_gs_start = urb_vs_start + urb_vs_size; - urb_gs_size = URB_GS_ENTRIES * URB_GS_ENTRY_SIZE; - urb_clip_start = urb_gs_start + urb_gs_size; - urb_clip_size = URB_CLIP_ENTRIES * URB_CLIP_ENTRY_SIZE; - urb_sf_start = urb_clip_start + urb_clip_size; - urb_sf_size = URB_SF_ENTRIES * URB_SF_ENTRY_SIZE; - urb_cs_start = urb_sf_start + urb_sf_size; - urb_cs_size = URB_CS_ENTRIES * URB_CS_ENTRY_SIZE; - - BEGIN_BATCH(ctx, 3); - OUT_BATCH(ctx, - CMD_URB_FENCE | - UF0_CS_REALLOC | - UF0_SF_REALLOC | - UF0_CLIP_REALLOC | - UF0_GS_REALLOC | - UF0_VS_REALLOC | - 1); - OUT_BATCH(ctx, - ((urb_clip_start + urb_clip_size) << UF1_CLIP_FENCE_SHIFT) | - ((urb_gs_start + urb_gs_size) << UF1_GS_FENCE_SHIFT) | - ((urb_vs_start + urb_vs_size) << UF1_VS_FENCE_SHIFT)); - OUT_BATCH(ctx, - ((urb_cs_start + urb_cs_size) << UF2_CS_FENCE_SHIFT) | - ((urb_sf_start + urb_sf_size) << UF2_SF_FENCE_SHIFT)); - ADVANCE_BATCH(ctx); -} - -static void -i965_render_cs_urb_layout(VADriverContextP ctx) -{ - BEGIN_BATCH(ctx, 2); - OUT_BATCH(ctx, CMD_CS_URB_STATE | 0); - OUT_BATCH(ctx, - ((URB_CS_ENTRY_SIZE - 1) << 4) | /* URB Entry Allocation Size */ - (URB_CS_ENTRIES << 0)); /* Number of URB Entries */ - ADVANCE_BATCH(ctx); -} - -static void -i965_render_drawing_rectangle(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct intel_region *dest_region = render_state->draw_region; - - BEGIN_BATCH(ctx, 4); - OUT_BATCH(ctx, CMD_DRAWING_RECTANGLE | 2); - OUT_BATCH(ctx, 0x00000000); - OUT_BATCH(ctx, (dest_region->width - 1) | (dest_region->height - 1) << 16); - OUT_BATCH(ctx, 0x00000000); - ADVANCE_BATCH(ctx); -} - -static void -i965_render_vertex_elements(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - - if (IS_IGDNG(i965->intel.device_id)) { - BEGIN_BATCH(ctx, 5); - OUT_BATCH(ctx, CMD_VERTEX_ELEMENTS | 3); - /* offset 0: X,Y -> {X, Y, 1.0, 1.0} */ - OUT_BATCH(ctx, (0 << VE0_VERTEX_BUFFER_INDEX_SHIFT) | - VE0_VALID | - (I965_SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT) | - (0 << VE0_OFFSET_SHIFT)); - OUT_BATCH(ctx, (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) | - (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) | - (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_2_SHIFT) | - (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT)); - /* offset 8: S0, T0 -> {S0, T0, 1.0, 1.0} */ - OUT_BATCH(ctx, (0 << VE0_VERTEX_BUFFER_INDEX_SHIFT) | - VE0_VALID | - (I965_SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT) | - (8 << VE0_OFFSET_SHIFT)); - OUT_BATCH(ctx, (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) | - (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) | - (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_2_SHIFT) | - (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT)); - ADVANCE_BATCH(ctx); - } else { - BEGIN_BATCH(ctx, 5); - OUT_BATCH(ctx, CMD_VERTEX_ELEMENTS | 3); - /* offset 0: X,Y -> {X, Y, 1.0, 1.0} */ - OUT_BATCH(ctx, (0 << VE0_VERTEX_BUFFER_INDEX_SHIFT) | - VE0_VALID | - (I965_SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT) | - (0 << VE0_OFFSET_SHIFT)); - OUT_BATCH(ctx, (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) | - (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) | - (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_2_SHIFT) | - (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT) | - (0 << VE1_DESTINATION_ELEMENT_OFFSET_SHIFT)); - /* offset 8: S0, T0 -> {S0, T0, 1.0, 1.0} */ - OUT_BATCH(ctx, (0 << VE0_VERTEX_BUFFER_INDEX_SHIFT) | - VE0_VALID | - (I965_SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT) | - (8 << VE0_OFFSET_SHIFT)); - OUT_BATCH(ctx, (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) | - (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) | - (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_2_SHIFT) | - (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT) | - (4 << VE1_DESTINATION_ELEMENT_OFFSET_SHIFT)); - ADVANCE_BATCH(ctx); - } -} - -static void -i965_render_upload_image_palette( - VADriverContextP ctx, - VAImageID image_id, - unsigned int alpha -) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - unsigned int i; - - struct object_image *obj_image = IMAGE(image_id); - assert(obj_image); - - if (obj_image->image.num_palette_entries == 0) - return; - - BEGIN_BATCH(ctx, 1 + obj_image->image.num_palette_entries); - OUT_BATCH(ctx, CMD_SAMPLER_PALETTE_LOAD | (obj_image->image.num_palette_entries - 1)); - /*fill palette*/ - //int32_t out[16]; //0-23:color 23-31:alpha - for (i = 0; i < obj_image->image.num_palette_entries; i++) - OUT_BATCH(ctx, (alpha << 24) | obj_image->palette[i]); - ADVANCE_BATCH(ctx); -} - -static void -i965_render_startup(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - - BEGIN_BATCH(ctx, 11); - OUT_BATCH(ctx, CMD_VERTEX_BUFFERS | 3); - OUT_BATCH(ctx, - (0 << VB0_BUFFER_INDEX_SHIFT) | - VB0_VERTEXDATA | - ((4 * 4) << VB0_BUFFER_PITCH_SHIFT)); - OUT_RELOC(ctx, render_state->vb.vertex_buffer, I915_GEM_DOMAIN_VERTEX, 0, 0); - - if (IS_IGDNG(i965->intel.device_id)) - OUT_RELOC(ctx, render_state->vb.vertex_buffer, I915_GEM_DOMAIN_VERTEX, 0, 12 * 4); - else - OUT_BATCH(ctx, 3); - - OUT_BATCH(ctx, 0); - - OUT_BATCH(ctx, - CMD_3DPRIMITIVE | - _3DPRIMITIVE_VERTEX_SEQUENTIAL | - (_3DPRIM_RECTLIST << _3DPRIMITIVE_TOPOLOGY_SHIFT) | - (0 << 9) | - 4); - OUT_BATCH(ctx, 3); /* vertex count per instance */ - OUT_BATCH(ctx, 0); /* start vertex offset */ - OUT_BATCH(ctx, 1); /* single instance */ - OUT_BATCH(ctx, 0); /* start instance location */ - OUT_BATCH(ctx, 0); /* index buffer offset, ignored */ - ADVANCE_BATCH(ctx); -} - -static void -i965_clear_dest_region(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct intel_region *dest_region = render_state->draw_region; - unsigned int blt_cmd, br13; - int pitch; - - blt_cmd = XY_COLOR_BLT_CMD; - br13 = 0xf0 << 16; - pitch = dest_region->pitch; - - if (dest_region->cpp == 4) { - br13 |= BR13_8888; - blt_cmd |= (XY_COLOR_BLT_WRITE_RGB | XY_COLOR_BLT_WRITE_ALPHA); - } else { - assert(dest_region->cpp == 2); - br13 |= BR13_565; - } - - if (dest_region->tiling != I915_TILING_NONE) { - blt_cmd |= XY_COLOR_BLT_DST_TILED; - pitch /= 4; - } - - br13 |= pitch; - - BEGIN_BATCH(ctx, 6); - OUT_BATCH(ctx, blt_cmd); - OUT_BATCH(ctx, br13); - OUT_BATCH(ctx, (dest_region->y << 16) | (dest_region->x)); - OUT_BATCH(ctx, ((dest_region->y + dest_region->height) << 16) | - (dest_region->x + dest_region->width)); - OUT_RELOC(ctx, dest_region->bo, - I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, - 0); - OUT_BATCH(ctx, 0x0); - ADVANCE_BATCH(ctx); -} - -static void -i965_surface_render_pipeline_setup(VADriverContextP ctx) -{ - intel_batchbuffer_start_atomic(ctx, 0x1000); - intel_batchbuffer_emit_mi_flush(ctx); - i965_clear_dest_region(ctx); - i965_render_pipeline_select(ctx); - i965_render_state_sip(ctx); - i965_render_state_base_address(ctx); - i965_render_binding_table_pointers(ctx); - i965_render_constant_color(ctx); - i965_render_pipelined_pointers(ctx); - i965_render_urb_layout(ctx); - i965_render_cs_urb_layout(ctx); - i965_render_drawing_rectangle(ctx); - i965_render_vertex_elements(ctx); - i965_render_startup(ctx); - intel_batchbuffer_end_atomic(ctx); -} - -static void -i965_subpic_render_pipeline_setup(VADriverContextP ctx) -{ - intel_batchbuffer_start_atomic(ctx, 0x1000); - intel_batchbuffer_emit_mi_flush(ctx); - i965_render_pipeline_select(ctx); - i965_render_state_sip(ctx); - i965_render_state_base_address(ctx); - i965_render_binding_table_pointers(ctx); - i965_render_constant_color(ctx); - i965_render_pipelined_pointers(ctx); - i965_render_urb_layout(ctx); - i965_render_cs_urb_layout(ctx); - i965_render_drawing_rectangle(ctx); - i965_render_vertex_elements(ctx); - i965_render_startup(ctx); - intel_batchbuffer_end_atomic(ctx); -} - - -static void -i965_render_initialize(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - int i; - dri_bo *bo; - - /* VERTEX BUFFER */ - dri_bo_unreference(render_state->vb.vertex_buffer); - bo = dri_bo_alloc(i965->intel.bufmgr, - "vertex buffer", - 4096, - 4096); - assert(bo); - render_state->vb.vertex_buffer = bo; - - /* VS */ - dri_bo_unreference(render_state->vs.state); - bo = dri_bo_alloc(i965->intel.bufmgr, - "vs state", - sizeof(struct i965_vs_unit_state), - 64); - assert(bo); - render_state->vs.state = bo; - - /* GS */ - /* CLIP */ - /* SF */ - dri_bo_unreference(render_state->sf.state); - bo = dri_bo_alloc(i965->intel.bufmgr, - "sf state", - sizeof(struct i965_sf_unit_state), - 64); - assert(bo); - render_state->sf.state = bo; - - /* WM */ - for (i = 0; i < MAX_RENDER_SURFACES; i++) { - dri_bo_unreference(render_state->wm.surface[i]); - render_state->wm.surface[i] = NULL; - } - - dri_bo_unreference(render_state->wm.binding_table); - bo = dri_bo_alloc(i965->intel.bufmgr, - "binding table", - MAX_RENDER_SURFACES * sizeof(unsigned int), - 64); - assert(bo); - render_state->wm.binding_table = bo; - - dri_bo_unreference(render_state->wm.sampler); - bo = dri_bo_alloc(i965->intel.bufmgr, - "sampler state", - MAX_SAMPLERS * sizeof(struct i965_sampler_state), - 64); - assert(bo); - render_state->wm.sampler = bo; - render_state->wm.sampler_count = 0; - - dri_bo_unreference(render_state->wm.state); - bo = dri_bo_alloc(i965->intel.bufmgr, - "wm state", - sizeof(struct i965_wm_unit_state), - 64); - assert(bo); - render_state->wm.state = bo; - - /* COLOR CALCULATOR */ - dri_bo_unreference(render_state->cc.state); - bo = dri_bo_alloc(i965->intel.bufmgr, - "color calc state", - sizeof(struct i965_cc_unit_state), - 64); - assert(bo); - render_state->cc.state = bo; - - dri_bo_unreference(render_state->cc.viewport); - bo = dri_bo_alloc(i965->intel.bufmgr, - "cc viewport", - sizeof(struct i965_cc_viewport), - 64); - assert(bo); - render_state->cc.viewport = bo; -} - -void -i965_render_put_surface(VADriverContextP ctx, - VASurfaceID surface, - short srcx, - short srcy, - unsigned short srcw, - unsigned short srch, - short destx, - short desty, - unsigned short destw, - unsigned short desth) -{ - i965_render_initialize(ctx); - i965_surface_render_state_setup(ctx, surface, - srcx, srcy, srcw, srch, - destx, desty, destw, desth); - i965_surface_render_pipeline_setup(ctx); - intel_batchbuffer_flush(ctx); -} - -void -i965_render_put_subpic(VADriverContextP ctx, - VASurfaceID surface, - short srcx, - short srcy, - unsigned short srcw, - unsigned short srch, - short destx, - short desty, - unsigned short destw, - unsigned short desth) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct object_surface *obj_surface = SURFACE(surface); - struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic); - assert(obj_subpic); - - i965_render_initialize(ctx); - i965_subpic_render_state_setup(ctx, surface, - srcx, srcy, srcw, srch, - destx, desty, destw, desth); - i965_subpic_render_pipeline_setup(ctx); - i965_render_upload_image_palette(ctx, obj_subpic->image, 0xff); - intel_batchbuffer_flush(ctx); -} - - -Bool -i965_render_init(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - int i; - - /* kernel */ - assert(NUM_RENDER_KERNEL == (sizeof(render_kernels_gen5) / - sizeof(render_kernels_gen5[0]))); - - if (IS_IGDNG(i965->intel.device_id)) - render_kernels = render_kernels_gen5; - else - render_kernels = render_kernels_gen4; - - for (i = 0; i < NUM_RENDER_KERNEL; i++) { - struct render_kernel *kernel = &render_kernels[i]; - kernel->bo = dri_bo_alloc(i965->intel.bufmgr, - kernel->name, - kernel->size, 64); - assert(kernel->bo); - dri_bo_subdata(kernel->bo, 0, kernel->size, kernel->bin); - } - - return True; -} - -Bool -i965_render_terminate(VADriverContextP ctx) -{ - int i; - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - - for (i = 0; i < NUM_RENDER_KERNEL; i++) { - struct render_kernel *kernel = &render_kernels[i]; - - dri_bo_unreference(kernel->bo); - kernel->bo = NULL; - } - - dri_bo_unreference(render_state->vb.vertex_buffer); - render_state->vb.vertex_buffer = NULL; - dri_bo_unreference(render_state->vs.state); - render_state->vs.state = NULL; - dri_bo_unreference(render_state->sf.state); - render_state->sf.state = NULL; - dri_bo_unreference(render_state->wm.binding_table); - render_state->wm.binding_table = NULL; - dri_bo_unreference(render_state->wm.sampler); - render_state->wm.sampler = NULL; - dri_bo_unreference(render_state->wm.state); - render_state->wm.state = NULL; - - for (i = 0; i < MAX_RENDER_SURFACES; i++) { - dri_bo_unreference(render_state->wm.surface[i]); - render_state->wm.surface[i] = NULL; - } - - dri_bo_unreference(render_state->cc.viewport); - render_state->cc.viewport = NULL; - dri_bo_unreference(render_state->cc.state); - render_state->cc.state = NULL; - - if (render_state->draw_region) { - dri_bo_unreference(render_state->draw_region->bo); - free(render_state->draw_region); - render_state->draw_region = NULL; - } - - return True; -} - diff -Nru libva-0.31.0+latest2/.pc/034_g45_fix_return_for_unimpl.patch/i965_drv_video/i965_drv_video.c libva-0.31.0+latest3/.pc/034_g45_fix_return_for_unimpl.patch/i965_drv_video/i965_drv_video.c --- libva-0.31.0+latest2/.pc/034_g45_fix_return_for_unimpl.patch/i965_drv_video/i965_drv_video.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/034_g45_fix_return_for_unimpl.patch/i965_drv_video/i965_drv_video.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,1549 +0,0 @@ -/* - * 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 - -#include "va/x11/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 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; i965_subpic_formats_map[i].type != 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 */ -{ - if (num_formats) - *num_formats = 0; - - 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) -{ - return VA_STATUS_SUCCESS; -} - -VAStatus -i965_SetSubpictureChromakey(VADriverContextP ctx, - VASubpictureID subpicture, - unsigned int chromakey_min, - unsigned int chromakey_max, - unsigned int chromakey_mask) -{ - return VA_STATUS_SUCCESS; -} - -VAStatus -i965_SetSubpictureGlobalAlpha(VADriverContextP ctx, - VASubpictureID subpicture, - float global_alpha) -{ - return VA_STATUS_SUCCESS; -} - -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_UNKNOWN; -} - -/* - * 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_UNKNOWN; -} - -VAStatus -i965_DbgCopySurfaceToBuffer(VADriverContextP ctx, - VASurfaceID surface, - void **buffer, /* out */ - unsigned int *stride) /* out */ -{ - /* TODO */ - return VA_STATUS_ERROR_UNKNOWN; -} - -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; - 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 */ -{ - return VA_STATUS_SUCCESS; -} - -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 -Nru libva-0.31.0+latest2/.pc/035_g45_add_yv12_image_format.patch/i965_drv_video/i965_drv_video.c libva-0.31.0+latest3/.pc/035_g45_add_yv12_image_format.patch/i965_drv_video/i965_drv_video.c --- libva-0.31.0+latest2/.pc/035_g45_add_yv12_image_format.patch/i965_drv_video/i965_drv_video.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/035_g45_add_yv12_image_format.patch/i965_drv_video/i965_drv_video.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,1553 +0,0 @@ -/* - * 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 - -#include "va/x11/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 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; i965_subpic_formats_map[i].type != 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 */ -{ - if (num_formats) - *num_formats = 0; - - 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; - 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 -Nru libva-0.31.0+latest2/.pc/035_g45_add_yv12_image_format.patch/i965_drv_video/i965_drv_video.h libva-0.31.0+latest3/.pc/035_g45_add_yv12_image_format.patch/i965_drv_video/i965_drv_video.h --- libva-0.31.0+latest2/.pc/035_g45_add_yv12_image_format.patch/i965_drv_video/i965_drv_video.h 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/035_g45_add_yv12_image_format.patch/i965_drv_video/i965_drv_video.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,174 +0,0 @@ -/* - * 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 - * - */ - -#ifndef _I965_DRV_VIDEO_H_ -#define _I965_DRV_VIDEO_H_ - -#include -#include - -#include "object_heap.h" - -#include "intel_driver.h" - -#include "i965_media.h" -#include "i965_render.h" - -#define I965_MAX_PROFILES 11 -#define I965_MAX_ENTRYPOINTS 5 -#define I965_MAX_CONFIG_ATTRIBUTES 10 -#define I965_MAX_IMAGE_FORMATS 10 -#define I965_MAX_SUBPIC_FORMATS 4 -#define I965_MAX_DISPLAY_ATTRIBUTES 4 -#define I965_STR_VENDOR "i965 Driver 0.1" - -struct buffer_store -{ - unsigned char *buffer; - dri_bo *bo; - int ref_count; -}; - -struct object_config -{ - struct object_base base; - VAProfile profile; - VAEntrypoint entrypoint; - VAConfigAttrib attrib_list[I965_MAX_CONFIG_ATTRIBUTES]; - int num_attribs; -}; - -struct decode_state -{ - struct buffer_store *pic_param; - struct buffer_store *slice_param; - struct buffer_store *iq_matrix; - struct buffer_store *bit_plane; - struct buffer_store *slice_data; - VASurfaceID current_render_target; - int num_slices; -}; - -struct object_context -{ - struct object_base base; - VAContextID context_id; - VAConfigID config_id; - VASurfaceID *render_targets; - int num_render_targets; - int picture_width; - int picture_height; - int flags; - struct decode_state decode_state; -}; - -struct object_surface -{ - struct object_base base; - VASurfaceStatus status; - VASubpictureID subpic; - int width; - int height; - int size; - dri_bo *bo; -}; - -struct object_buffer -{ - struct object_base base; - struct buffer_store *buffer_store; - int max_num_elements; - int num_elements; - int size_element; - VABufferType type; -}; - -struct object_image -{ - struct object_base base; - VAImage image; - dri_bo *bo; - unsigned int *palette; -}; - -struct object_subpic -{ - struct object_base base; - VAImageID image; - VARectangle src_rect; - VARectangle dst_rect; - unsigned int format; - int width; - int height; - int pitch; - dri_bo *bo; -}; - - - -struct i965_driver_data -{ - struct intel_driver_data intel; - struct object_heap config_heap; - struct object_heap context_heap; - struct object_heap surface_heap; - struct object_heap buffer_heap; - struct object_heap image_heap; - struct object_heap subpic_heap; - struct i965_media_state media_state; - struct i965_render_state render_state; -}; - -#define NEW_CONFIG_ID() object_heap_allocate(&i965->config_heap); -#define NEW_CONTEXT_ID() object_heap_allocate(&i965->context_heap); -#define NEW_SURFACE_ID() object_heap_allocate(&i965->surface_heap); -#define NEW_BUFFER_ID() object_heap_allocate(&i965->buffer_heap); -#define NEW_IMAGE_ID() object_heap_allocate(&i965->image_heap); -#define NEW_SUBPIC_ID() object_heap_allocate(&i965->subpic_heap); - -#define CONFIG(id) ((struct object_config *)object_heap_lookup(&i965->config_heap, id)) -#define CONTEXT(id) ((struct object_context *)object_heap_lookup(&i965->context_heap, id)) -#define SURFACE(id) ((struct object_surface *)object_heap_lookup(&i965->surface_heap, id)) -#define BUFFER(id) ((struct object_buffer *)object_heap_lookup(&i965->buffer_heap, id)) -#define IMAGE(id) ((struct object_image *)object_heap_lookup(&i965->image_heap, id)) -#define SUBPIC(id) ((struct object_subpic *)object_heap_lookup(&i965->subpic_heap, id)) - -#define FOURCC_IA44 0x34344149 -#define FOURCC_AI44 0x34344941 - -#define STRIDE(w) (((w) + 0xf) & ~0xf) -#define SIZE_YUV420(w, h) (h * (STRIDE(w) + STRIDE(w >> 1))) - -static INLINE struct i965_driver_data * -i965_driver_data(VADriverContextP ctx) -{ - return (struct i965_driver_data *)(ctx->pDriverData); -} - -#endif /* _I965_DRV_VIDEO_H_ */ diff -Nru libva-0.31.0+latest2/.pc/036_g45_add_vaGetImage.patch/i965_drv_video/i965_drv_video.c libva-0.31.0+latest3/.pc/036_g45_add_vaGetImage.patch/i965_drv_video/i965_drv_video.c --- libva-0.31.0+latest2/.pc/036_g45_add_vaGetImage.patch/i965_drv_video/i965_drv_video.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/036_g45_add_vaGetImage.patch/i965_drv_video/i965_drv_video.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,1601 +0,0 @@ -/* - * 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 - -#include "va/x11/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; i965_subpic_formats_map[i].type != 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 + size2; - image->pitches[2] = width2; - image->offsets[2] = size; - 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 -Nru libva-0.31.0+latest2/.pc/037_g45_add_vaPutImage.patch/i965_drv_video/i965_drv_video.c libva-0.31.0+latest3/.pc/037_g45_add_vaPutImage.patch/i965_drv_video/i965_drv_video.c --- libva-0.31.0+latest2/.pc/037_g45_add_vaPutImage.patch/i965_drv_video/i965_drv_video.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/037_g45_add_vaPutImage.patch/i965_drv_video/i965_drv_video.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,1644 +0,0 @@ -/* - * 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 - -#include "va/x11/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; i965_subpic_formats_map[i].type != 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 + size2; - image->pitches[2] = width2; - image->offsets[2] = size; - 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) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - - struct object_surface *obj_surface = SURFACE(surface); - if (!obj_surface) - return VA_STATUS_ERROR_INVALID_SURFACE; - - struct object_image *obj_image = IMAGE(image); - if (!obj_image) - return VA_STATUS_ERROR_INVALID_IMAGE; - - /* XXX: we only support full-size surface readback */ - if (x != 0 || - y != 0 || - width != obj_surface->width || - height != obj_surface->height) - return VA_STATUS_ERROR_INVALID_PARAMETER; - - /* XXX: we only support 1:1 image copies */ - if (width != obj_image->image.width || - height != obj_image->image.height) - return VA_STATUS_ERROR_INVALID_PARAMETER; - - VAStatus va_status; - void *image_data = NULL; - - va_status = i965_MapBuffer(ctx, obj_image->image.buf, &image_data); - if (va_status != VA_STATUS_SUCCESS) - return va_status; - - dri_bo_map(obj_surface->bo, 0); - - switch (obj_image->image.format.fourcc) { - case VA_FOURCC('Y','V','1','2'): /* YV12 is native format here */ - memcpy(image_data, obj_surface->bo->virtual, obj_surface->bo->size); - break; - default: - va_status = VA_STATUS_ERROR_OPERATION_FAILED; - break; - } - - dri_bo_unmap(obj_surface->bo); - - i965_UnmapBuffer(ctx, obj_image->image.buf); - return va_status; -} - -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 -Nru libva-0.31.0+latest2/.pc/038_g45_vaPutSurface_cliprects.patch/i965_drv_video/i965_drv_video.c libva-0.31.0+latest3/.pc/038_g45_vaPutSurface_cliprects.patch/i965_drv_video/i965_drv_video.c --- libva-0.31.0+latest2/.pc/038_g45_vaPutSurface_cliprects.patch/i965_drv_video/i965_drv_video.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/038_g45_vaPutSurface_cliprects.patch/i965_drv_video/i965_drv_video.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,1690 +0,0 @@ -/* - * 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 - -#include "va/x11/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; i965_subpic_formats_map[i].type != 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_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 + size2; - image->pitches[2] = width2; - image->offsets[2] = size; - 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) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - - struct object_surface *obj_surface = SURFACE(surface); - if (!obj_surface) - return VA_STATUS_ERROR_INVALID_SURFACE; - - struct object_image *obj_image = IMAGE(image); - if (!obj_image) - return VA_STATUS_ERROR_INVALID_IMAGE; - - /* XXX: we only support full-size surface readback */ - if (x != 0 || - y != 0 || - width != obj_surface->width || - height != obj_surface->height) - return VA_STATUS_ERROR_INVALID_PARAMETER; - - /* XXX: we only support 1:1 image copies */ - if (width != obj_image->image.width || - height != obj_image->image.height) - return VA_STATUS_ERROR_INVALID_PARAMETER; - - VAStatus va_status; - void *image_data = NULL; - - va_status = i965_MapBuffer(ctx, obj_image->image.buf, &image_data); - if (va_status != VA_STATUS_SUCCESS) - return va_status; - - dri_bo_map(obj_surface->bo, 0); - - switch (obj_image->image.format.fourcc) { - case VA_FOURCC('Y','V','1','2'): /* YV12 is native format here */ - memcpy(image_data, obj_surface->bo->virtual, obj_surface->bo->size); - break; - default: - va_status = VA_STATUS_ERROR_OPERATION_FAILED; - break; - } - - dri_bo_unmap(obj_surface->bo); - - i965_UnmapBuffer(ctx, obj_image->image.buf); - return va_status; -} - -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) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - - struct object_surface *obj_surface = SURFACE(surface); - if (!obj_surface) - return VA_STATUS_ERROR_INVALID_SURFACE; - - struct object_image *obj_image = IMAGE(image); - if (!obj_image) - return VA_STATUS_ERROR_INVALID_IMAGE; - - /* XXX: we don't support partial video surface updates */ - if (src_x != 0 || - src_y != 0 || - src_width != obj_image->image.width || - src_height != obj_image->image.height) - return VA_STATUS_ERROR_OPERATION_FAILED; - if (dest_x != 0 || - dest_y != 0 || - dest_width != obj_surface->width || - dest_height != obj_surface->height) - return VA_STATUS_ERROR_OPERATION_FAILED; - if (src_width != dest_width || - src_height != dest_height) - return VA_STATUS_ERROR_OPERATION_FAILED; - - VAStatus va_status; - void *image_data = NULL; - - va_status = i965_MapBuffer(ctx, obj_image->image.buf, &image_data); - if (va_status != VA_STATUS_SUCCESS) - return va_status; - - dri_bo_map(obj_surface->bo, 1); - - switch (obj_image->image.format.fourcc) { - case VA_FOURCC('Y','V','1','2'): /* YV12 is native format here */ - memcpy(obj_surface->bo->virtual, image_data, obj_surface->bo->size); - break; - default: - va_status = VA_STATUS_ERROR_OPERATION_FAILED; - break; - } - - dri_bo_unmap(obj_surface->bo); - - i965_UnmapBuffer(ctx, obj_image->image.buf); - return va_status; -} - -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 -Nru libva-0.31.0+latest2/.pc/038_g45_vaPutSurface_cliprects.patch/i965_drv_video/i965_render.c libva-0.31.0+latest3/.pc/038_g45_vaPutSurface_cliprects.patch/i965_drv_video/i965_render.c --- libva-0.31.0+latest2/.pc/038_g45_vaPutSurface_cliprects.patch/i965_drv_video/i965_render.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/038_g45_vaPutSurface_cliprects.patch/i965_drv_video/i965_render.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,1516 +0,0 @@ -/* - * Copyright © 2006 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, sublicense, - * 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 NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS 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: - * Eric Anholt - * Keith Packard - * Xiang Haihao - * - */ - -/* - * Most of rendering codes are ported from xf86-video-intel/src/i965_video.c - */ - -#include -#include -#include -#include - -#include -#include "va/x11/va_dricommon.h" - -#include "intel_batchbuffer.h" -#include "intel_driver.h" - -#include "i965_defines.h" -#include "i965_render.h" -#include "i965_drv_video.h" - -#define SF_KERNEL_NUM_GRF 16 -#define SF_MAX_THREADS 1 - -static const unsigned int sf_kernel_static[][4] = -{ -#include "shaders/render/exa_sf.g4b" -}; - -#define PS_KERNEL_NUM_GRF 32 -#define PS_MAX_THREADS 32 - -#define I965_GRF_BLOCKS(nreg) ((nreg + 15) / 16 - 1) - -static const unsigned int ps_kernel_static[][4] = -{ -#include "shaders/render/exa_wm_xy.g4b" -#include "shaders/render/exa_wm_src_affine.g4b" -#include "shaders/render/exa_wm_src_sample_planar.g4b" -#include "shaders/render/exa_wm_yuv_rgb.g4b" -#include "shaders/render/exa_wm_write.g4b" -}; -static const unsigned int ps_subpic_kernel_static[][4] = -{ -#include "shaders/render/exa_wm_xy.g4b" -#include "shaders/render/exa_wm_src_affine.g4b" -#include "shaders/render/exa_wm_src_sample_argb.g4b" -#include "shaders/render/exa_wm_write.g4b" -}; - -/* On IGDNG */ -static const unsigned int sf_kernel_static_gen5[][4] = -{ -#include "shaders/render/exa_sf.g4b.gen5" -}; - -static const unsigned int ps_kernel_static_gen5[][4] = -{ -#include "shaders/render/exa_wm_xy.g4b.gen5" -#include "shaders/render/exa_wm_src_affine.g4b.gen5" -#include "shaders/render/exa_wm_src_sample_planar.g4b.gen5" -#include "shaders/render/exa_wm_yuv_rgb.g4b.gen5" -#include "shaders/render/exa_wm_write.g4b.gen5" -}; -static const unsigned int ps_subpic_kernel_static_gen5[][4] = -{ -#include "shaders/render/exa_wm_xy.g4b.gen5" -#include "shaders/render/exa_wm_src_affine.g4b.gen5" -#include "shaders/render/exa_wm_src_sample_argb.g4b.gen5" -#include "shaders/render/exa_wm_write.g4b.gen5" -}; - -static uint32_t float_to_uint (float f) -{ - union { - uint32_t i; - float f; - } x; - - x.f = f; - return x.i; -} - -enum -{ - SF_KERNEL = 0, - PS_KERNEL, - PS_SUBPIC_KERNEL -}; - -struct render_kernel -{ - char *name; - const unsigned int (*bin)[4]; - int size; - dri_bo *bo; -}; - -static struct render_kernel render_kernels_gen4[] = { - { - "SF", - sf_kernel_static, - sizeof(sf_kernel_static), - NULL - }, - { - "PS", - ps_kernel_static, - sizeof(ps_kernel_static), - NULL - }, - - { - "PS_SUBPIC", - ps_subpic_kernel_static, - sizeof(ps_subpic_kernel_static), - NULL - } -}; - -static struct render_kernel render_kernels_gen5[] = { - { - "SF", - sf_kernel_static_gen5, - sizeof(sf_kernel_static_gen5), - NULL - }, - { - "PS", - ps_kernel_static_gen5, - sizeof(ps_kernel_static_gen5), - NULL - }, - - { - "PS_SUBPIC", - ps_subpic_kernel_static_gen5, - sizeof(ps_subpic_kernel_static_gen5), - NULL - } -}; - -static struct render_kernel *render_kernels = NULL; - -#define NUM_RENDER_KERNEL (sizeof(render_kernels_gen4)/sizeof(render_kernels_gen4[0])) - -#define URB_VS_ENTRIES 8 -#define URB_VS_ENTRY_SIZE 1 - -#define URB_GS_ENTRIES 0 -#define URB_GS_ENTRY_SIZE 0 - -#define URB_CLIP_ENTRIES 0 -#define URB_CLIP_ENTRY_SIZE 0 - -#define URB_SF_ENTRIES 1 -#define URB_SF_ENTRY_SIZE 2 - -#define URB_CS_ENTRIES 0 -#define URB_CS_ENTRY_SIZE 0 - -static void -i965_render_vs_unit(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct i965_vs_unit_state *vs_state; - - dri_bo_map(render_state->vs.state, 1); - assert(render_state->vs.state->virtual); - vs_state = render_state->vs.state->virtual; - memset(vs_state, 0, sizeof(*vs_state)); - - if (IS_IGDNG(i965->intel.device_id)) - vs_state->thread4.nr_urb_entries = URB_VS_ENTRIES >> 2; - else - vs_state->thread4.nr_urb_entries = URB_VS_ENTRIES; - - vs_state->thread4.urb_entry_allocation_size = URB_VS_ENTRY_SIZE - 1; - vs_state->vs6.vs_enable = 0; - vs_state->vs6.vert_cache_disable = 1; - - dri_bo_unmap(render_state->vs.state); -} - -static void -i965_render_sf_unit(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct i965_sf_unit_state *sf_state; - - dri_bo_map(render_state->sf.state, 1); - assert(render_state->sf.state->virtual); - sf_state = render_state->sf.state->virtual; - memset(sf_state, 0, sizeof(*sf_state)); - - sf_state->thread0.grf_reg_count = I965_GRF_BLOCKS(SF_KERNEL_NUM_GRF); - sf_state->thread0.kernel_start_pointer = render_kernels[SF_KERNEL].bo->offset >> 6; - - sf_state->sf1.single_program_flow = 1; /* XXX */ - sf_state->sf1.binding_table_entry_count = 0; - sf_state->sf1.thread_priority = 0; - sf_state->sf1.floating_point_mode = 0; /* Mesa does this */ - sf_state->sf1.illegal_op_exception_enable = 1; - sf_state->sf1.mask_stack_exception_enable = 1; - sf_state->sf1.sw_exception_enable = 1; - - /* scratch space is not used in our kernel */ - sf_state->thread2.per_thread_scratch_space = 0; - sf_state->thread2.scratch_space_base_pointer = 0; - - sf_state->thread3.const_urb_entry_read_length = 0; /* no const URBs */ - sf_state->thread3.const_urb_entry_read_offset = 0; /* no const URBs */ - sf_state->thread3.urb_entry_read_length = 1; /* 1 URB per vertex */ - sf_state->thread3.urb_entry_read_offset = 0; - sf_state->thread3.dispatch_grf_start_reg = 3; - - sf_state->thread4.max_threads = SF_MAX_THREADS - 1; - sf_state->thread4.urb_entry_allocation_size = URB_SF_ENTRY_SIZE - 1; - sf_state->thread4.nr_urb_entries = URB_SF_ENTRIES; - sf_state->thread4.stats_enable = 1; - - sf_state->sf5.viewport_transform = 0; /* skip viewport */ - - sf_state->sf6.cull_mode = I965_CULLMODE_NONE; - sf_state->sf6.scissor = 0; - - sf_state->sf7.trifan_pv = 2; - - sf_state->sf6.dest_org_vbias = 0x8; - sf_state->sf6.dest_org_hbias = 0x8; - - dri_bo_emit_reloc(render_state->sf.state, - I915_GEM_DOMAIN_INSTRUCTION, 0, - sf_state->thread0.grf_reg_count << 1, - offsetof(struct i965_sf_unit_state, thread0), - render_kernels[SF_KERNEL].bo); - - dri_bo_unmap(render_state->sf.state); -} - -static void -i965_render_sampler(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct i965_sampler_state *sampler_state; - int i; - - assert(render_state->wm.sampler_count > 0); - assert(render_state->wm.sampler_count <= MAX_SAMPLERS); - - dri_bo_map(render_state->wm.sampler, 1); - assert(render_state->wm.sampler->virtual); - sampler_state = render_state->wm.sampler->virtual; - for (i = 0; i < render_state->wm.sampler_count; i++) { - memset(sampler_state, 0, sizeof(*sampler_state)); - sampler_state->ss0.min_filter = I965_MAPFILTER_LINEAR; - sampler_state->ss0.mag_filter = I965_MAPFILTER_LINEAR; - sampler_state->ss1.r_wrap_mode = I965_TEXCOORDMODE_CLAMP; - sampler_state->ss1.s_wrap_mode = I965_TEXCOORDMODE_CLAMP; - sampler_state->ss1.t_wrap_mode = I965_TEXCOORDMODE_CLAMP; - sampler_state++; - } - - dri_bo_unmap(render_state->wm.sampler); -} -static void -i965_subpic_render_wm_unit(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct i965_wm_unit_state *wm_state; - - assert(render_state->wm.sampler); - - dri_bo_map(render_state->wm.state, 1); - assert(render_state->wm.state->virtual); - wm_state = render_state->wm.state->virtual; - memset(wm_state, 0, sizeof(*wm_state)); - - wm_state->thread0.grf_reg_count = I965_GRF_BLOCKS(PS_KERNEL_NUM_GRF); - wm_state->thread0.kernel_start_pointer = render_kernels[PS_SUBPIC_KERNEL].bo->offset >> 6; - - wm_state->thread1.single_program_flow = 1; /* XXX */ - - if (IS_IGDNG(i965->intel.device_id)) - wm_state->thread1.binding_table_entry_count = 0; /* hardware requirement */ - else - wm_state->thread1.binding_table_entry_count = 7; - - wm_state->thread2.scratch_space_base_pointer = 0; - wm_state->thread2.per_thread_scratch_space = 0; /* 1024 bytes */ - - wm_state->thread3.dispatch_grf_start_reg = 3; /* XXX */ - wm_state->thread3.const_urb_entry_read_length = 0; - wm_state->thread3.const_urb_entry_read_offset = 0; - wm_state->thread3.urb_entry_read_length = 1; /* XXX */ - wm_state->thread3.urb_entry_read_offset = 0; /* XXX */ - - wm_state->wm4.stats_enable = 0; - wm_state->wm4.sampler_state_pointer = render_state->wm.sampler->offset >> 5; - - if (IS_IGDNG(i965->intel.device_id)) - wm_state->wm4.sampler_count = 0; /* hardware requirement */ - else - wm_state->wm4.sampler_count = (render_state->wm.sampler_count + 3) / 4; - - wm_state->wm5.max_threads = PS_MAX_THREADS - 1; - wm_state->wm5.thread_dispatch_enable = 1; - wm_state->wm5.enable_16_pix = 1; - wm_state->wm5.enable_8_pix = 0; - wm_state->wm5.early_depth_test = 1; - - dri_bo_emit_reloc(render_state->wm.state, - I915_GEM_DOMAIN_INSTRUCTION, 0, - wm_state->thread0.grf_reg_count << 1, - offsetof(struct i965_wm_unit_state, thread0), - render_kernels[PS_SUBPIC_KERNEL].bo); - - dri_bo_emit_reloc(render_state->wm.state, - I915_GEM_DOMAIN_INSTRUCTION, 0, - wm_state->wm4.sampler_count << 2, - offsetof(struct i965_wm_unit_state, wm4), - render_state->wm.sampler); - - dri_bo_unmap(render_state->wm.state); -} - - -static void -i965_render_wm_unit(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct i965_wm_unit_state *wm_state; - - assert(render_state->wm.sampler); - - dri_bo_map(render_state->wm.state, 1); - assert(render_state->wm.state->virtual); - wm_state = render_state->wm.state->virtual; - memset(wm_state, 0, sizeof(*wm_state)); - - wm_state->thread0.grf_reg_count = I965_GRF_BLOCKS(PS_KERNEL_NUM_GRF); - wm_state->thread0.kernel_start_pointer = render_kernels[PS_KERNEL].bo->offset >> 6; - - wm_state->thread1.single_program_flow = 1; /* XXX */ - - if (IS_IGDNG(i965->intel.device_id)) - wm_state->thread1.binding_table_entry_count = 0; /* hardware requirement */ - else - wm_state->thread1.binding_table_entry_count = 7; - - wm_state->thread2.scratch_space_base_pointer = 0; - wm_state->thread2.per_thread_scratch_space = 0; /* 1024 bytes */ - - wm_state->thread3.dispatch_grf_start_reg = 3; /* XXX */ - wm_state->thread3.const_urb_entry_read_length = 0; - wm_state->thread3.const_urb_entry_read_offset = 0; - wm_state->thread3.urb_entry_read_length = 1; /* XXX */ - wm_state->thread3.urb_entry_read_offset = 0; /* XXX */ - - wm_state->wm4.stats_enable = 0; - wm_state->wm4.sampler_state_pointer = render_state->wm.sampler->offset >> 5; - - if (IS_IGDNG(i965->intel.device_id)) - wm_state->wm4.sampler_count = 0; /* hardware requirement */ - else - wm_state->wm4.sampler_count = (render_state->wm.sampler_count + 3) / 4; - - wm_state->wm5.max_threads = PS_MAX_THREADS - 1; - wm_state->wm5.thread_dispatch_enable = 1; - wm_state->wm5.enable_16_pix = 1; - wm_state->wm5.enable_8_pix = 0; - wm_state->wm5.early_depth_test = 1; - - dri_bo_emit_reloc(render_state->wm.state, - I915_GEM_DOMAIN_INSTRUCTION, 0, - wm_state->thread0.grf_reg_count << 1, - offsetof(struct i965_wm_unit_state, thread0), - render_kernels[PS_KERNEL].bo); - - dri_bo_emit_reloc(render_state->wm.state, - I915_GEM_DOMAIN_INSTRUCTION, 0, - wm_state->wm4.sampler_count << 2, - offsetof(struct i965_wm_unit_state, wm4), - render_state->wm.sampler); - - dri_bo_unmap(render_state->wm.state); -} - -static void -i965_render_cc_viewport(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct i965_cc_viewport *cc_viewport; - - dri_bo_map(render_state->cc.viewport, 1); - assert(render_state->cc.viewport->virtual); - cc_viewport = render_state->cc.viewport->virtual; - memset(cc_viewport, 0, sizeof(*cc_viewport)); - - cc_viewport->min_depth = -1.e35; - cc_viewport->max_depth = 1.e35; - - dri_bo_unmap(render_state->cc.viewport); -} - -static void -i965_subpic_render_cc_unit(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct i965_cc_unit_state *cc_state; - - assert(render_state->cc.viewport); - - dri_bo_map(render_state->cc.state, 1); - assert(render_state->cc.state->virtual); - cc_state = render_state->cc.state->virtual; - memset(cc_state, 0, sizeof(*cc_state)); - - cc_state->cc0.stencil_enable = 0; /* disable stencil */ - cc_state->cc2.depth_test = 0; /* disable depth test */ - cc_state->cc2.logicop_enable = 0; /* disable logic op */ - cc_state->cc3.ia_blend_enable = 0 ; /* blend alpha just like colors */ - cc_state->cc3.blend_enable = 1; /* enable color blend */ - cc_state->cc3.alpha_test = 0; /* disable alpha test */ - cc_state->cc3.alpha_test_format = 0;//0:ALPHATEST_UNORM8; /*store alpha value with UNORM8 */ - cc_state->cc3.alpha_test_func = 5;//COMPAREFUNCTION_LESS; /*pass if less than the reference */ - cc_state->cc4.cc_viewport_state_offset = render_state->cc.viewport->offset >> 5; - - cc_state->cc5.dither_enable = 0; /* disable dither */ - cc_state->cc5.logicop_func = 0xc; /* WHITE */ - cc_state->cc5.statistics_enable = 1; - cc_state->cc5.ia_blend_function = I965_BLENDFUNCTION_ADD; - cc_state->cc5.ia_src_blend_factor = I965_BLENDFACTOR_DST_ALPHA; - cc_state->cc5.ia_dest_blend_factor = I965_BLENDFACTOR_DST_ALPHA; - - cc_state->cc6.clamp_post_alpha_blend = 0; - cc_state->cc6.clamp_pre_alpha_blend =0; - - /*final color = src_color*src_blend_factor +/- dst_color*dest_color_blend_factor*/ - cc_state->cc6.blend_function = I965_BLENDFUNCTION_ADD; - cc_state->cc6.src_blend_factor = I965_BLENDFACTOR_SRC_ALPHA; - cc_state->cc6.dest_blend_factor = I965_BLENDFACTOR_INV_SRC_ALPHA; - - /*alpha test reference*/ - cc_state->cc7.alpha_ref.f =0.0 ; - - - dri_bo_emit_reloc(render_state->cc.state, - I915_GEM_DOMAIN_INSTRUCTION, 0, - 0, - offsetof(struct i965_cc_unit_state, cc4), - render_state->cc.viewport); - - dri_bo_unmap(render_state->cc.state); -} - - -static void -i965_render_cc_unit(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct i965_cc_unit_state *cc_state; - - assert(render_state->cc.viewport); - - dri_bo_map(render_state->cc.state, 1); - assert(render_state->cc.state->virtual); - cc_state = render_state->cc.state->virtual; - memset(cc_state, 0, sizeof(*cc_state)); - - cc_state->cc0.stencil_enable = 0; /* disable stencil */ - cc_state->cc2.depth_test = 0; /* disable depth test */ - cc_state->cc2.logicop_enable = 1; /* enable logic op */ - cc_state->cc3.ia_blend_enable = 0; /* blend alpha just like colors */ - cc_state->cc3.blend_enable = 0; /* disable color blend */ - cc_state->cc3.alpha_test = 0; /* disable alpha test */ - cc_state->cc4.cc_viewport_state_offset = render_state->cc.viewport->offset >> 5; - - cc_state->cc5.dither_enable = 0; /* disable dither */ - cc_state->cc5.logicop_func = 0xc; /* WHITE */ - cc_state->cc5.statistics_enable = 1; - cc_state->cc5.ia_blend_function = I965_BLENDFUNCTION_ADD; - cc_state->cc5.ia_src_blend_factor = I965_BLENDFACTOR_ONE; - cc_state->cc5.ia_dest_blend_factor = I965_BLENDFACTOR_ONE; - - dri_bo_emit_reloc(render_state->cc.state, - I915_GEM_DOMAIN_INSTRUCTION, 0, - 0, - offsetof(struct i965_cc_unit_state, cc4), - render_state->cc.viewport); - - dri_bo_unmap(render_state->cc.state); -} - -static void -i965_render_src_surface_state(VADriverContextP ctx, - int index, - dri_bo *region, - unsigned long offset, - int w, int h) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct i965_surface_state *ss; - dri_bo *ss_bo; - - ss_bo = dri_bo_alloc(i965->intel.bufmgr, - "surface state", - sizeof(struct i965_surface_state), 32); - assert(ss_bo); - dri_bo_map(ss_bo, 1); - assert(ss_bo->virtual); - ss = ss_bo->virtual; - memset(ss, 0, sizeof(*ss)); - ss->ss0.surface_type = I965_SURFACE_2D; - ss->ss0.surface_format = I965_SURFACEFORMAT_R8_UNORM; - ss->ss0.writedisable_alpha = 0; - ss->ss0.writedisable_red = 0; - ss->ss0.writedisable_green = 0; - ss->ss0.writedisable_blue = 0; - ss->ss0.color_blend = 1; - ss->ss0.vert_line_stride = 0; - ss->ss0.vert_line_stride_ofs = 0; - ss->ss0.mipmap_layout_mode = 0; - ss->ss0.render_cache_read_mode = 0; - - ss->ss1.base_addr = region->offset + offset; - - ss->ss2.width = w - 1; - ss->ss2.height = h - 1; - ss->ss2.mip_count = 0; - ss->ss2.render_target_rotation = 0; - - ss->ss3.pitch = w - 1; - - dri_bo_emit_reloc(ss_bo, - I915_GEM_DOMAIN_SAMPLER, 0, - offset, - offsetof(struct i965_surface_state, ss1), - region); - - dri_bo_unmap(ss_bo); - - assert(index < MAX_RENDER_SURFACES); - assert(render_state->wm.surface[index] == NULL); - render_state->wm.surface[index] = ss_bo; - render_state->wm.sampler_count++; -} - -static void -i965_subpic_render_src_surface_state(VADriverContextP ctx, - int index, - dri_bo *region, - unsigned long offset, - int w, int h, int p, int format) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct i965_surface_state *ss; - dri_bo *ss_bo; - - ss_bo = dri_bo_alloc(i965->intel.bufmgr, - "surface state", - sizeof(struct i965_surface_state), 32); - assert(ss_bo); - dri_bo_map(ss_bo, 1); - assert(ss_bo->virtual); - ss = ss_bo->virtual; - memset(ss, 0, sizeof(*ss)); - ss->ss0.surface_type = I965_SURFACE_2D; - ss->ss0.surface_format = format; - ss->ss0.writedisable_alpha = 0; - ss->ss0.writedisable_red = 0; - ss->ss0.writedisable_green = 0; - ss->ss0.writedisable_blue = 0; - ss->ss0.color_blend = 1; - ss->ss0.vert_line_stride = 0; - ss->ss0.vert_line_stride_ofs = 0; - ss->ss0.mipmap_layout_mode = 0; - ss->ss0.render_cache_read_mode = 0; - - ss->ss1.base_addr = region->offset + offset; - - ss->ss2.width = w - 1; - ss->ss2.height = h - 1; - ss->ss2.mip_count = 0; - ss->ss2.render_target_rotation = 0; - - ss->ss3.pitch = p - 1; - - dri_bo_emit_reloc(ss_bo, - I915_GEM_DOMAIN_SAMPLER, 0, - offset, - offsetof(struct i965_surface_state, ss1), - region); - - dri_bo_unmap(ss_bo); - - assert(index < MAX_RENDER_SURFACES); - assert(render_state->wm.surface[index] == NULL); - render_state->wm.surface[index] = ss_bo; - render_state->wm.sampler_count++; -} - -static void -i965_render_src_surfaces_state(VADriverContextP ctx, - VASurfaceID surface) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct object_surface *obj_surface; - int w, h; - dri_bo *region; - - obj_surface = SURFACE(surface); - assert(obj_surface); - assert(obj_surface->bo); - w = obj_surface->width; - h = obj_surface->height; - region = obj_surface->bo; - - i965_render_src_surface_state(ctx, 1, region, 0, w, h); /* Y */ - i965_render_src_surface_state(ctx, 2, region, 0, w, h); - i965_render_src_surface_state(ctx, 3, region, w * h + w * h / 4, w / 2, h / 2); /* V */ - i965_render_src_surface_state(ctx, 4, region, w * h + w * h / 4, w / 2, h / 2); - i965_render_src_surface_state(ctx, 5, region, w * h, w / 2, h / 2); /* U */ - i965_render_src_surface_state(ctx, 6, region, w * h, w / 2, h / 2); -} - -static void -i965_subpic_render_src_surfaces_state(VADriverContextP ctx, - VASurfaceID surface) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct object_surface *obj_surface = SURFACE(surface); - int w, h; - dri_bo *region; - dri_bo *subpic_region; - struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic); - struct object_image *obj_image = IMAGE(obj_subpic->image); - assert(obj_surface); - assert(obj_surface->bo); - w = obj_surface->width; - h = obj_surface->height; - region = obj_surface->bo; - subpic_region = obj_image->bo; - /*subpicture surface*/ - i965_subpic_render_src_surface_state(ctx, 1, subpic_region, 0, obj_subpic->width, obj_subpic->height, obj_subpic->pitch, obj_subpic->format); - i965_subpic_render_src_surface_state(ctx, 2, subpic_region, 0, obj_subpic->width, obj_subpic->height, obj_subpic->pitch, obj_subpic->format); -} - -static void -i965_render_set_surface_tiling(struct i965_surface_state *ss, unsigned int tiling) -{ - switch (tiling) { - case I915_TILING_NONE: - ss->ss3.tiled_surface = 0; - ss->ss3.tile_walk = 0; - break; - case I915_TILING_X: - ss->ss3.tiled_surface = 1; - ss->ss3.tile_walk = I965_TILEWALK_XMAJOR; - break; - case I915_TILING_Y: - ss->ss3.tiled_surface = 1; - ss->ss3.tile_walk = I965_TILEWALK_YMAJOR; - break; - } -} - -static void -i965_render_dest_surface_state(VADriverContextP ctx, int index) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct intel_region *dest_region = render_state->draw_region; - struct i965_surface_state *ss; - dri_bo *ss_bo; - - ss_bo = dri_bo_alloc(i965->intel.bufmgr, - "surface state", - sizeof(struct i965_surface_state), 32); - assert(ss_bo); - dri_bo_map(ss_bo, 1); - assert(ss_bo->virtual); - ss = ss_bo->virtual; - memset(ss, 0, sizeof(*ss)); - - ss->ss0.surface_type = I965_SURFACE_2D; - ss->ss0.data_return_format = I965_SURFACERETURNFORMAT_FLOAT32; - - if (dest_region->cpp == 2) { - ss->ss0.surface_format = I965_SURFACEFORMAT_B5G6R5_UNORM; - } else { - ss->ss0.surface_format = I965_SURFACEFORMAT_B8G8R8A8_UNORM; - } - - ss->ss0.writedisable_alpha = 0; - ss->ss0.writedisable_red = 0; - ss->ss0.writedisable_green = 0; - ss->ss0.writedisable_blue = 0; - ss->ss0.color_blend = 1; - ss->ss0.vert_line_stride = 0; - ss->ss0.vert_line_stride_ofs = 0; - ss->ss0.mipmap_layout_mode = 0; - ss->ss0.render_cache_read_mode = 0; - - ss->ss1.base_addr = dest_region->bo->offset; - - ss->ss2.width = dest_region->width - 1; - ss->ss2.height = dest_region->height - 1; - ss->ss2.mip_count = 0; - ss->ss2.render_target_rotation = 0; - ss->ss3.pitch = dest_region->pitch - 1; - i965_render_set_surface_tiling(ss, dest_region->tiling); - - dri_bo_emit_reloc(ss_bo, - I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, - 0, - offsetof(struct i965_surface_state, ss1), - dest_region->bo); - - dri_bo_unmap(ss_bo); - - assert(index < MAX_RENDER_SURFACES); - assert(render_state->wm.surface[index] == NULL); - render_state->wm.surface[index] = ss_bo; -} - -static void -i965_render_binding_table(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - int i; - unsigned int *binding_table; - - dri_bo_map(render_state->wm.binding_table, 1); - assert(render_state->wm.binding_table->virtual); - binding_table = render_state->wm.binding_table->virtual; - memset(binding_table, 0, render_state->wm.binding_table->size); - - for (i = 0; i < MAX_RENDER_SURFACES; i++) { - if (render_state->wm.surface[i]) { - binding_table[i] = render_state->wm.surface[i]->offset; - dri_bo_emit_reloc(render_state->wm.binding_table, - I915_GEM_DOMAIN_INSTRUCTION, 0, - 0, - i * sizeof(*binding_table), - render_state->wm.surface[i]); - } - } - - dri_bo_unmap(render_state->wm.binding_table); -} - -static void -i965_subpic_render_upload_vertex(VADriverContextP ctx, - VASurfaceID surface, - const VARectangle *output_rect) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct object_surface *obj_surface = SURFACE(surface); - struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic); - - const float psx = (float)obj_surface->width / (float)obj_subpic->width; - const float psy = (float)obj_surface->height / (float)obj_subpic->height; - const float ssx = (float)output_rect->width / (float)obj_surface->width; - const float ssy = (float)output_rect->height / (float)obj_surface->height; - const float sx = psx * ssx; - const float sy = psy * ssy; - float *vb, tx1, tx2, ty1, ty2, x1, x2, y1, y2; - int i = 0; - - VARectangle dst_rect; - dst_rect.x = output_rect->x + sx * (float)obj_subpic->dst_rect.x; - dst_rect.y = output_rect->y + sx * (float)obj_subpic->dst_rect.y; - dst_rect.width = sx * (float)obj_subpic->dst_rect.width; - dst_rect.height = sy * (float)obj_subpic->dst_rect.height; - - dri_bo_map(render_state->vb.vertex_buffer, 1); - assert(render_state->vb.vertex_buffer->virtual); - vb = render_state->vb.vertex_buffer->virtual; - - tx1 = (float)obj_subpic->src_rect.x / (float)obj_subpic->width; - ty1 = (float)obj_subpic->src_rect.y / (float)obj_subpic->height; - tx2 = (float)(obj_subpic->src_rect.x + obj_subpic->src_rect.width) / (float)obj_subpic->width; - ty2 = (float)(obj_subpic->src_rect.y + obj_subpic->src_rect.height) / (float)obj_subpic->height; - - x1 = (float)dst_rect.x; - y1 = (float)dst_rect.y; - x2 = (float)(dst_rect.x + dst_rect.width); - y2 = (float)(dst_rect.y + dst_rect.height); - - vb[i++] = tx2; - vb[i++] = ty2; - vb[i++] = x2; - vb[i++] = y2; - - vb[i++] = tx1; - vb[i++] = ty2; - vb[i++] = x1; - vb[i++] = y2; - - vb[i++] = tx1; - vb[i++] = ty1; - vb[i++] = x1; - vb[i++] = y1; - dri_bo_unmap(render_state->vb.vertex_buffer); -} - -static void -i965_render_upload_vertex(VADriverContextP ctx, - VASurfaceID surface, - short srcx, - short srcy, - unsigned short srcw, - unsigned short srch, - short destx, - short desty, - unsigned short destw, - unsigned short desth) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct intel_region *dest_region = render_state->draw_region; - struct object_surface *obj_surface; - float *vb; - - float u1, v1, u2, v2; - int i, width, height; - int box_x1 = dest_region->x + destx; - int box_y1 = dest_region->y + desty; - int box_x2 = box_x1 + destw; - int box_y2 = box_y1 + desth; - - obj_surface = SURFACE(surface); - assert(surface); - width = obj_surface->width; - height = obj_surface->height; - - u1 = (float)srcx / width; - v1 = (float)srcy / height; - u2 = (float)(srcx + srcw) / width; - v2 = (float)(srcy + srch) / height; - - dri_bo_map(render_state->vb.vertex_buffer, 1); - assert(render_state->vb.vertex_buffer->virtual); - vb = render_state->vb.vertex_buffer->virtual; - - i = 0; - vb[i++] = u2; - vb[i++] = v2; - vb[i++] = (float)box_x2; - vb[i++] = (float)box_y2; - - vb[i++] = u1; - vb[i++] = v2; - vb[i++] = (float)box_x1; - vb[i++] = (float)box_y2; - - vb[i++] = u1; - vb[i++] = v1; - vb[i++] = (float)box_x1; - vb[i++] = (float)box_y1; - - dri_bo_unmap(render_state->vb.vertex_buffer); -} - -static void -i965_surface_render_state_setup(VADriverContextP ctx, - VASurfaceID surface, - short srcx, - short srcy, - unsigned short srcw, - unsigned short srch, - short destx, - short desty, - unsigned short destw, - unsigned short desth) -{ - i965_render_vs_unit(ctx); - i965_render_sf_unit(ctx); - i965_render_dest_surface_state(ctx, 0); - i965_render_src_surfaces_state(ctx, surface); - i965_render_sampler(ctx); - i965_render_wm_unit(ctx); - i965_render_cc_viewport(ctx); - i965_render_cc_unit(ctx); - i965_render_binding_table(ctx); - i965_render_upload_vertex(ctx, surface, - srcx, srcy, srcw, srch, - destx, desty, destw, desth); -} -static void -i965_subpic_render_state_setup(VADriverContextP ctx, - VASurfaceID surface, - short srcx, - short srcy, - unsigned short srcw, - unsigned short srch, - short destx, - short desty, - unsigned short destw, - unsigned short desth) -{ - i965_render_vs_unit(ctx); - i965_render_sf_unit(ctx); - i965_render_dest_surface_state(ctx, 0); - i965_subpic_render_src_surfaces_state(ctx, surface); - i965_render_sampler(ctx); - i965_subpic_render_wm_unit(ctx); - i965_render_cc_viewport(ctx); - i965_subpic_render_cc_unit(ctx); - i965_render_binding_table(ctx); - - VARectangle output_rect; - output_rect.x = destx; - output_rect.y = desty; - output_rect.width = destw; - output_rect.height = desth; - i965_subpic_render_upload_vertex(ctx, surface, &output_rect); -} - - -static void -i965_render_pipeline_select(VADriverContextP ctx) -{ - BEGIN_BATCH(ctx, 1); - OUT_BATCH(ctx, CMD_PIPELINE_SELECT | PIPELINE_SELECT_3D); - ADVANCE_BATCH(ctx); -} - -static void -i965_render_state_sip(VADriverContextP ctx) -{ - BEGIN_BATCH(ctx, 2); - OUT_BATCH(ctx, CMD_STATE_SIP | 0); - OUT_BATCH(ctx, 0); - ADVANCE_BATCH(ctx); -} - -static void -i965_render_state_base_address(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - - if (IS_IGDNG(i965->intel.device_id)) { - BEGIN_BATCH(ctx, 8); - OUT_BATCH(ctx, CMD_STATE_BASE_ADDRESS | 6); - OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); - ADVANCE_BATCH(ctx); - } else { - BEGIN_BATCH(ctx, 6); - OUT_BATCH(ctx, CMD_STATE_BASE_ADDRESS | 4); - OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); - OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY); - ADVANCE_BATCH(ctx); - } -} - -static void -i965_render_binding_table_pointers(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - - BEGIN_BATCH(ctx, 6); - OUT_BATCH(ctx, CMD_BINDING_TABLE_POINTERS | 4); - OUT_BATCH(ctx, 0); /* vs */ - OUT_BATCH(ctx, 0); /* gs */ - OUT_BATCH(ctx, 0); /* clip */ - OUT_BATCH(ctx, 0); /* sf */ - OUT_RELOC(ctx, render_state->wm.binding_table, I915_GEM_DOMAIN_INSTRUCTION, 0, 0); /* wm */ - ADVANCE_BATCH(ctx); -} - -static void -i965_render_constant_color(VADriverContextP ctx) -{ - BEGIN_BATCH(ctx, 5); - OUT_BATCH(ctx, CMD_CONSTANT_COLOR | 3); - OUT_BATCH(ctx, float_to_uint(1.0)); - OUT_BATCH(ctx, float_to_uint(0.0)); - OUT_BATCH(ctx, float_to_uint(1.0)); - OUT_BATCH(ctx, float_to_uint(1.0)); - ADVANCE_BATCH(ctx); -} - -static void -i965_render_pipelined_pointers(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - - BEGIN_BATCH(ctx, 7); - OUT_BATCH(ctx, CMD_PIPELINED_POINTERS | 5); - OUT_RELOC(ctx, render_state->vs.state, I915_GEM_DOMAIN_INSTRUCTION, 0, 0); - OUT_BATCH(ctx, 0); /* disable GS */ - OUT_BATCH(ctx, 0); /* disable CLIP */ - OUT_RELOC(ctx, render_state->sf.state, I915_GEM_DOMAIN_INSTRUCTION, 0, 0); - OUT_RELOC(ctx, render_state->wm.state, I915_GEM_DOMAIN_INSTRUCTION, 0, 0); - OUT_RELOC(ctx, render_state->cc.state, I915_GEM_DOMAIN_INSTRUCTION, 0, 0); - ADVANCE_BATCH(ctx); -} - -static void -i965_render_urb_layout(VADriverContextP ctx) -{ - int urb_vs_start, urb_vs_size; - int urb_gs_start, urb_gs_size; - int urb_clip_start, urb_clip_size; - int urb_sf_start, urb_sf_size; - int urb_cs_start, urb_cs_size; - - urb_vs_start = 0; - urb_vs_size = URB_VS_ENTRIES * URB_VS_ENTRY_SIZE; - urb_gs_start = urb_vs_start + urb_vs_size; - urb_gs_size = URB_GS_ENTRIES * URB_GS_ENTRY_SIZE; - urb_clip_start = urb_gs_start + urb_gs_size; - urb_clip_size = URB_CLIP_ENTRIES * URB_CLIP_ENTRY_SIZE; - urb_sf_start = urb_clip_start + urb_clip_size; - urb_sf_size = URB_SF_ENTRIES * URB_SF_ENTRY_SIZE; - urb_cs_start = urb_sf_start + urb_sf_size; - urb_cs_size = URB_CS_ENTRIES * URB_CS_ENTRY_SIZE; - - BEGIN_BATCH(ctx, 3); - OUT_BATCH(ctx, - CMD_URB_FENCE | - UF0_CS_REALLOC | - UF0_SF_REALLOC | - UF0_CLIP_REALLOC | - UF0_GS_REALLOC | - UF0_VS_REALLOC | - 1); - OUT_BATCH(ctx, - ((urb_clip_start + urb_clip_size) << UF1_CLIP_FENCE_SHIFT) | - ((urb_gs_start + urb_gs_size) << UF1_GS_FENCE_SHIFT) | - ((urb_vs_start + urb_vs_size) << UF1_VS_FENCE_SHIFT)); - OUT_BATCH(ctx, - ((urb_cs_start + urb_cs_size) << UF2_CS_FENCE_SHIFT) | - ((urb_sf_start + urb_sf_size) << UF2_SF_FENCE_SHIFT)); - ADVANCE_BATCH(ctx); -} - -static void -i965_render_cs_urb_layout(VADriverContextP ctx) -{ - BEGIN_BATCH(ctx, 2); - OUT_BATCH(ctx, CMD_CS_URB_STATE | 0); - OUT_BATCH(ctx, - ((URB_CS_ENTRY_SIZE - 1) << 4) | /* URB Entry Allocation Size */ - (URB_CS_ENTRIES << 0)); /* Number of URB Entries */ - ADVANCE_BATCH(ctx); -} - -static void -i965_render_drawing_rectangle(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct intel_region *dest_region = render_state->draw_region; - - BEGIN_BATCH(ctx, 4); - OUT_BATCH(ctx, CMD_DRAWING_RECTANGLE | 2); - OUT_BATCH(ctx, 0x00000000); - OUT_BATCH(ctx, (dest_region->width - 1) | (dest_region->height - 1) << 16); - OUT_BATCH(ctx, 0x00000000); - ADVANCE_BATCH(ctx); -} - -static void -i965_render_vertex_elements(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - - if (IS_IGDNG(i965->intel.device_id)) { - BEGIN_BATCH(ctx, 5); - OUT_BATCH(ctx, CMD_VERTEX_ELEMENTS | 3); - /* offset 0: X,Y -> {X, Y, 1.0, 1.0} */ - OUT_BATCH(ctx, (0 << VE0_VERTEX_BUFFER_INDEX_SHIFT) | - VE0_VALID | - (I965_SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT) | - (0 << VE0_OFFSET_SHIFT)); - OUT_BATCH(ctx, (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) | - (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) | - (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_2_SHIFT) | - (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT)); - /* offset 8: S0, T0 -> {S0, T0, 1.0, 1.0} */ - OUT_BATCH(ctx, (0 << VE0_VERTEX_BUFFER_INDEX_SHIFT) | - VE0_VALID | - (I965_SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT) | - (8 << VE0_OFFSET_SHIFT)); - OUT_BATCH(ctx, (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) | - (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) | - (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_2_SHIFT) | - (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT)); - ADVANCE_BATCH(ctx); - } else { - BEGIN_BATCH(ctx, 5); - OUT_BATCH(ctx, CMD_VERTEX_ELEMENTS | 3); - /* offset 0: X,Y -> {X, Y, 1.0, 1.0} */ - OUT_BATCH(ctx, (0 << VE0_VERTEX_BUFFER_INDEX_SHIFT) | - VE0_VALID | - (I965_SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT) | - (0 << VE0_OFFSET_SHIFT)); - OUT_BATCH(ctx, (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) | - (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) | - (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_2_SHIFT) | - (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT) | - (0 << VE1_DESTINATION_ELEMENT_OFFSET_SHIFT)); - /* offset 8: S0, T0 -> {S0, T0, 1.0, 1.0} */ - OUT_BATCH(ctx, (0 << VE0_VERTEX_BUFFER_INDEX_SHIFT) | - VE0_VALID | - (I965_SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT) | - (8 << VE0_OFFSET_SHIFT)); - OUT_BATCH(ctx, (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT) | - (I965_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT) | - (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_2_SHIFT) | - (I965_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT) | - (4 << VE1_DESTINATION_ELEMENT_OFFSET_SHIFT)); - ADVANCE_BATCH(ctx); - } -} - -static void -i965_render_upload_image_palette( - VADriverContextP ctx, - VAImageID image_id, - unsigned int alpha -) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - unsigned int i; - - struct object_image *obj_image = IMAGE(image_id); - assert(obj_image); - - if (obj_image->image.num_palette_entries == 0) - return; - - BEGIN_BATCH(ctx, 1 + obj_image->image.num_palette_entries); - OUT_BATCH(ctx, CMD_SAMPLER_PALETTE_LOAD | (obj_image->image.num_palette_entries - 1)); - /*fill palette*/ - //int32_t out[16]; //0-23:color 23-31:alpha - for (i = 0; i < obj_image->image.num_palette_entries; i++) - OUT_BATCH(ctx, (alpha << 24) | obj_image->palette[i]); - ADVANCE_BATCH(ctx); -} - -static void -i965_render_startup(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - - BEGIN_BATCH(ctx, 11); - OUT_BATCH(ctx, CMD_VERTEX_BUFFERS | 3); - OUT_BATCH(ctx, - (0 << VB0_BUFFER_INDEX_SHIFT) | - VB0_VERTEXDATA | - ((4 * 4) << VB0_BUFFER_PITCH_SHIFT)); - OUT_RELOC(ctx, render_state->vb.vertex_buffer, I915_GEM_DOMAIN_VERTEX, 0, 0); - - if (IS_IGDNG(i965->intel.device_id)) - OUT_RELOC(ctx, render_state->vb.vertex_buffer, I915_GEM_DOMAIN_VERTEX, 0, 12 * 4); - else - OUT_BATCH(ctx, 3); - - OUT_BATCH(ctx, 0); - - OUT_BATCH(ctx, - CMD_3DPRIMITIVE | - _3DPRIMITIVE_VERTEX_SEQUENTIAL | - (_3DPRIM_RECTLIST << _3DPRIMITIVE_TOPOLOGY_SHIFT) | - (0 << 9) | - 4); - OUT_BATCH(ctx, 3); /* vertex count per instance */ - OUT_BATCH(ctx, 0); /* start vertex offset */ - OUT_BATCH(ctx, 1); /* single instance */ - OUT_BATCH(ctx, 0); /* start instance location */ - OUT_BATCH(ctx, 0); /* index buffer offset, ignored */ - ADVANCE_BATCH(ctx); -} - -static void -i965_clear_dest_region(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - struct intel_region *dest_region = render_state->draw_region; - unsigned int blt_cmd, br13; - int pitch; - - blt_cmd = XY_COLOR_BLT_CMD; - br13 = 0xf0 << 16; - pitch = dest_region->pitch; - - if (dest_region->cpp == 4) { - br13 |= BR13_8888; - blt_cmd |= (XY_COLOR_BLT_WRITE_RGB | XY_COLOR_BLT_WRITE_ALPHA); - } else { - assert(dest_region->cpp == 2); - br13 |= BR13_565; - } - - if (dest_region->tiling != I915_TILING_NONE) { - blt_cmd |= XY_COLOR_BLT_DST_TILED; - pitch /= 4; - } - - br13 |= pitch; - - BEGIN_BATCH(ctx, 6); - OUT_BATCH(ctx, blt_cmd); - OUT_BATCH(ctx, br13); - OUT_BATCH(ctx, (dest_region->y << 16) | (dest_region->x)); - OUT_BATCH(ctx, ((dest_region->y + dest_region->height) << 16) | - (dest_region->x + dest_region->width)); - OUT_RELOC(ctx, dest_region->bo, - I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, - 0); - OUT_BATCH(ctx, 0x0); - ADVANCE_BATCH(ctx); -} - -static void -i965_surface_render_pipeline_setup(VADriverContextP ctx) -{ - intel_batchbuffer_start_atomic(ctx, 0x1000); - intel_batchbuffer_emit_mi_flush(ctx); - i965_clear_dest_region(ctx); - i965_render_pipeline_select(ctx); - i965_render_state_sip(ctx); - i965_render_state_base_address(ctx); - i965_render_binding_table_pointers(ctx); - i965_render_constant_color(ctx); - i965_render_pipelined_pointers(ctx); - i965_render_urb_layout(ctx); - i965_render_cs_urb_layout(ctx); - i965_render_drawing_rectangle(ctx); - i965_render_vertex_elements(ctx); - i965_render_startup(ctx); - intel_batchbuffer_end_atomic(ctx); -} - -static void -i965_subpic_render_pipeline_setup(VADriverContextP ctx) -{ - intel_batchbuffer_start_atomic(ctx, 0x1000); - intel_batchbuffer_emit_mi_flush(ctx); - i965_render_pipeline_select(ctx); - i965_render_state_sip(ctx); - i965_render_state_base_address(ctx); - i965_render_binding_table_pointers(ctx); - i965_render_constant_color(ctx); - i965_render_pipelined_pointers(ctx); - i965_render_urb_layout(ctx); - i965_render_cs_urb_layout(ctx); - i965_render_drawing_rectangle(ctx); - i965_render_vertex_elements(ctx); - i965_render_startup(ctx); - intel_batchbuffer_end_atomic(ctx); -} - - -static void -i965_render_initialize(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - int i; - dri_bo *bo; - - /* VERTEX BUFFER */ - dri_bo_unreference(render_state->vb.vertex_buffer); - bo = dri_bo_alloc(i965->intel.bufmgr, - "vertex buffer", - 4096, - 4096); - assert(bo); - render_state->vb.vertex_buffer = bo; - - /* VS */ - dri_bo_unreference(render_state->vs.state); - bo = dri_bo_alloc(i965->intel.bufmgr, - "vs state", - sizeof(struct i965_vs_unit_state), - 64); - assert(bo); - render_state->vs.state = bo; - - /* GS */ - /* CLIP */ - /* SF */ - dri_bo_unreference(render_state->sf.state); - bo = dri_bo_alloc(i965->intel.bufmgr, - "sf state", - sizeof(struct i965_sf_unit_state), - 64); - assert(bo); - render_state->sf.state = bo; - - /* WM */ - for (i = 0; i < MAX_RENDER_SURFACES; i++) { - dri_bo_unreference(render_state->wm.surface[i]); - render_state->wm.surface[i] = NULL; - } - - dri_bo_unreference(render_state->wm.binding_table); - bo = dri_bo_alloc(i965->intel.bufmgr, - "binding table", - MAX_RENDER_SURFACES * sizeof(unsigned int), - 64); - assert(bo); - render_state->wm.binding_table = bo; - - dri_bo_unreference(render_state->wm.sampler); - bo = dri_bo_alloc(i965->intel.bufmgr, - "sampler state", - MAX_SAMPLERS * sizeof(struct i965_sampler_state), - 64); - assert(bo); - render_state->wm.sampler = bo; - render_state->wm.sampler_count = 0; - - dri_bo_unreference(render_state->wm.state); - bo = dri_bo_alloc(i965->intel.bufmgr, - "wm state", - sizeof(struct i965_wm_unit_state), - 64); - assert(bo); - render_state->wm.state = bo; - - /* COLOR CALCULATOR */ - dri_bo_unreference(render_state->cc.state); - bo = dri_bo_alloc(i965->intel.bufmgr, - "color calc state", - sizeof(struct i965_cc_unit_state), - 64); - assert(bo); - render_state->cc.state = bo; - - dri_bo_unreference(render_state->cc.viewport); - bo = dri_bo_alloc(i965->intel.bufmgr, - "cc viewport", - sizeof(struct i965_cc_viewport), - 64); - assert(bo); - render_state->cc.viewport = bo; -} - -void -i965_render_put_surface(VADriverContextP ctx, - VASurfaceID surface, - short srcx, - short srcy, - unsigned short srcw, - unsigned short srch, - short destx, - short desty, - unsigned short destw, - unsigned short desth) -{ - i965_render_initialize(ctx); - i965_surface_render_state_setup(ctx, surface, - srcx, srcy, srcw, srch, - destx, desty, destw, desth); - i965_surface_render_pipeline_setup(ctx); - intel_batchbuffer_flush(ctx); -} - -void -i965_render_put_subpic(VADriverContextP ctx, - VASurfaceID surface, - short srcx, - short srcy, - unsigned short srcw, - unsigned short srch, - short destx, - short desty, - unsigned short destw, - unsigned short desth) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct object_surface *obj_surface = SURFACE(surface); - struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic); - assert(obj_subpic); - - i965_render_initialize(ctx); - i965_subpic_render_state_setup(ctx, surface, - srcx, srcy, srcw, srch, - destx, desty, destw, desth); - i965_subpic_render_pipeline_setup(ctx); - i965_render_upload_image_palette(ctx, obj_subpic->image, 0xff); - intel_batchbuffer_flush(ctx); -} - - -Bool -i965_render_init(VADriverContextP ctx) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - int i; - - /* kernel */ - assert(NUM_RENDER_KERNEL == (sizeof(render_kernels_gen5) / - sizeof(render_kernels_gen5[0]))); - - if (IS_IGDNG(i965->intel.device_id)) - render_kernels = render_kernels_gen5; - else - render_kernels = render_kernels_gen4; - - for (i = 0; i < NUM_RENDER_KERNEL; i++) { - struct render_kernel *kernel = &render_kernels[i]; - kernel->bo = dri_bo_alloc(i965->intel.bufmgr, - kernel->name, - kernel->size, 64); - assert(kernel->bo); - dri_bo_subdata(kernel->bo, 0, kernel->size, kernel->bin); - } - - return True; -} - -Bool -i965_render_terminate(VADriverContextP ctx) -{ - int i; - struct i965_driver_data *i965 = i965_driver_data(ctx); - struct i965_render_state *render_state = &i965->render_state; - - for (i = 0; i < NUM_RENDER_KERNEL; i++) { - struct render_kernel *kernel = &render_kernels[i]; - - dri_bo_unreference(kernel->bo); - kernel->bo = NULL; - } - - dri_bo_unreference(render_state->vb.vertex_buffer); - render_state->vb.vertex_buffer = NULL; - dri_bo_unreference(render_state->vs.state); - render_state->vs.state = NULL; - dri_bo_unreference(render_state->sf.state); - render_state->sf.state = NULL; - dri_bo_unreference(render_state->wm.binding_table); - render_state->wm.binding_table = NULL; - dri_bo_unreference(render_state->wm.sampler); - render_state->wm.sampler = NULL; - dri_bo_unreference(render_state->wm.state); - render_state->wm.state = NULL; - - for (i = 0; i < MAX_RENDER_SURFACES; i++) { - dri_bo_unreference(render_state->wm.surface[i]); - render_state->wm.surface[i] = NULL; - } - - dri_bo_unreference(render_state->cc.viewport); - render_state->cc.viewport = NULL; - dri_bo_unreference(render_state->cc.state); - render_state->cc.state = NULL; - - if (render_state->draw_region) { - dri_bo_unreference(render_state->draw_region->bo); - free(render_state->draw_region); - render_state->draw_region = NULL; - } - - return True; -} - diff -Nru libva-0.31.0+latest2/.pc/038_g45_vaPutSurface_cliprects.patch/i965_drv_video/i965_render.h libva-0.31.0+latest3/.pc/038_g45_vaPutSurface_cliprects.patch/i965_drv_video/i965_render.h --- libva-0.31.0+latest2/.pc/038_g45_vaPutSurface_cliprects.patch/i965_drv_video/i965_render.h 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/038_g45_vaPutSurface_cliprects.patch/i965_drv_video/i965_render.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,91 +0,0 @@ -/* - * Copyright © 2006 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, sublicense, - * 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 NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS 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 - * - */ - -#ifndef _I965_RENDER_H_ -#define _I965_RENDER_H_ - -#define MAX_RENDER_SURFACES 16 -#define MAX_SAMPLERS 16 - -struct i965_render_state -{ - struct { - dri_bo *vertex_buffer; - } vb; - - struct { - dri_bo *state; - } vs; - - struct { - dri_bo *state; - dri_bo *prog; - } sf; - - struct { - int sampler_count; - dri_bo *sampler; - dri_bo *surface[MAX_RENDER_SURFACES]; - dri_bo *binding_table; - dri_bo *state; - dri_bo *prog; - } wm; - - struct { - dri_bo *state; - dri_bo *viewport; - } cc; - - struct intel_region *draw_region; -}; - -Bool i965_render_init(VADriverContextP ctx); -Bool i965_render_terminate(VADriverContextP ctx); -void i965_render_put_surface(VADriverContextP ctx, - VASurfaceID surface, - short srcx, - short srcy, - unsigned short srcw, - unsigned short srch, - short destx, - short desty, - unsigned short destw, - unsigned short desth); - - -void -i965_render_put_subpic(VADriverContextP ctx, - VASurfaceID surface, - short srcx, - short srcy, - unsigned short srcw, - unsigned short srch, - short destx, - short desty, - unsigned short destw, - unsigned short desth); -#endif /* _I965_RENDER_H_ */ diff -Nru libva-0.31.0+latest2/.pc/039_g45_add_vaDeriveImage.patch/i965_drv_video/i965_drv_video.c libva-0.31.0+latest3/.pc/039_g45_add_vaDeriveImage.patch/i965_drv_video/i965_drv_video.c --- libva-0.31.0+latest2/.pc/039_g45_add_vaDeriveImage.patch/i965_drv_video/i965_drv_video.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/039_g45_add_vaDeriveImage.patch/i965_drv_video/i965_drv_video.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,1707 +0,0 @@ -/* - * 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 - -#include "va/x11/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; i965_subpic_formats_map[i].type != 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_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 + size2; - image->pitches[2] = width2; - image->offsets[2] = size; - 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) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - - struct object_surface *obj_surface = SURFACE(surface); - if (!obj_surface) - return VA_STATUS_ERROR_INVALID_SURFACE; - - struct object_image *obj_image = IMAGE(image); - if (!obj_image) - return VA_STATUS_ERROR_INVALID_IMAGE; - - /* XXX: we only support full-size surface readback */ - if (x != 0 || - y != 0 || - width != obj_surface->width || - height != obj_surface->height) - return VA_STATUS_ERROR_INVALID_PARAMETER; - - /* XXX: we only support 1:1 image copies */ - if (width != obj_image->image.width || - height != obj_image->image.height) - return VA_STATUS_ERROR_INVALID_PARAMETER; - - VAStatus va_status; - void *image_data = NULL; - - va_status = i965_MapBuffer(ctx, obj_image->image.buf, &image_data); - if (va_status != VA_STATUS_SUCCESS) - return va_status; - - dri_bo_map(obj_surface->bo, 0); - - switch (obj_image->image.format.fourcc) { - case VA_FOURCC('Y','V','1','2'): /* YV12 is native format here */ - memcpy(image_data, obj_surface->bo->virtual, obj_surface->bo->size); - break; - default: - va_status = VA_STATUS_ERROR_OPERATION_FAILED; - break; - } - - dri_bo_unmap(obj_surface->bo); - - i965_UnmapBuffer(ctx, obj_image->image.buf); - return va_status; -} - -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) -{ - struct i965_driver_data *i965 = i965_driver_data(ctx); - - struct object_surface *obj_surface = SURFACE(surface); - if (!obj_surface) - return VA_STATUS_ERROR_INVALID_SURFACE; - - struct object_image *obj_image = IMAGE(image); - if (!obj_image) - return VA_STATUS_ERROR_INVALID_IMAGE; - - /* XXX: we don't support partial video surface updates */ - if (src_x != 0 || - src_y != 0 || - src_width != obj_image->image.width || - src_height != obj_image->image.height) - return VA_STATUS_ERROR_OPERATION_FAILED; - if (dest_x != 0 || - dest_y != 0 || - dest_width != obj_surface->width || - dest_height != obj_surface->height) - return VA_STATUS_ERROR_OPERATION_FAILED; - if (src_width != dest_width || - src_height != dest_height) - return VA_STATUS_ERROR_OPERATION_FAILED; - - VAStatus va_status; - void *image_data = NULL; - - va_status = i965_MapBuffer(ctx, obj_image->image.buf, &image_data); - if (va_status != VA_STATUS_SUCCESS) - return va_status; - - dri_bo_map(obj_surface->bo, 1); - - switch (obj_image->image.format.fourcc) { - case VA_FOURCC('Y','V','1','2'): /* YV12 is native format here */ - memcpy(obj_surface->bo->virtual, image_data, obj_surface->bo->size); - break; - default: - va_status = VA_STATUS_ERROR_OPERATION_FAILED; - break; - } - - dri_bo_unmap(obj_surface->bo); - - i965_UnmapBuffer(ctx, obj_image->image.buf); - return va_status; -} - -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; - VARectangle src_rect, dst_rect; - Bool new_region = False; - - /* Currently don't support DRI1 */ - if (dri_state->driConnectedFlag != VA_DRI2) - return VA_STATUS_ERROR_UNKNOWN; - - /* XXX: we currently only support up to 64 cliprects */ - if (number_cliprects > MAX_CLIP_RECTS) - return VA_STATUS_ERROR_OPERATION_FAILED; - - obj_surface = SURFACE(surface); - if (!obj_surface) - return VA_STATUS_ERROR_INVALID_SURFACE; - - 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); - } - - src_rect.x = srcx; - src_rect.y = srcy; - src_rect.width = srcw; - src_rect.height = srch; - - dst_rect.x = destx; - dst_rect.y = desty; - dst_rect.width = destw; - dst_rect.height = desth; - - i965_render_put_surface(ctx, surface, &src_rect, &dst_rect, - cliprects, number_cliprects); - - if (obj_surface->subpic != VA_INVALID_ID) - i965_render_put_subpic(ctx, surface, &src_rect, &dst_rect, - cliprects, number_cliprects); - - 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 -Nru libva-0.31.0+latest2/.pc/039_g45_add_vaDeriveImage.patch/i965_drv_video/i965_drv_video.h libva-0.31.0+latest3/.pc/039_g45_add_vaDeriveImage.patch/i965_drv_video/i965_drv_video.h --- libva-0.31.0+latest2/.pc/039_g45_add_vaDeriveImage.patch/i965_drv_video/i965_drv_video.h 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/039_g45_add_vaDeriveImage.patch/i965_drv_video/i965_drv_video.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,174 +0,0 @@ -/* - * 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 - * - */ - -#ifndef _I965_DRV_VIDEO_H_ -#define _I965_DRV_VIDEO_H_ - -#include -#include - -#include "object_heap.h" - -#include "intel_driver.h" - -#include "i965_media.h" -#include "i965_render.h" - -#define I965_MAX_PROFILES 11 -#define I965_MAX_ENTRYPOINTS 5 -#define I965_MAX_CONFIG_ATTRIBUTES 10 -#define I965_MAX_IMAGE_FORMATS 1 -#define I965_MAX_SUBPIC_FORMATS 4 -#define I965_MAX_DISPLAY_ATTRIBUTES 4 -#define I965_STR_VENDOR "i965 Driver 0.1" - -struct buffer_store -{ - unsigned char *buffer; - dri_bo *bo; - int ref_count; -}; - -struct object_config -{ - struct object_base base; - VAProfile profile; - VAEntrypoint entrypoint; - VAConfigAttrib attrib_list[I965_MAX_CONFIG_ATTRIBUTES]; - int num_attribs; -}; - -struct decode_state -{ - struct buffer_store *pic_param; - struct buffer_store *slice_param; - struct buffer_store *iq_matrix; - struct buffer_store *bit_plane; - struct buffer_store *slice_data; - VASurfaceID current_render_target; - int num_slices; -}; - -struct object_context -{ - struct object_base base; - VAContextID context_id; - VAConfigID config_id; - VASurfaceID *render_targets; - int num_render_targets; - int picture_width; - int picture_height; - int flags; - struct decode_state decode_state; -}; - -struct object_surface -{ - struct object_base base; - VASurfaceStatus status; - VASubpictureID subpic; - int width; - int height; - int size; - dri_bo *bo; -}; - -struct object_buffer -{ - struct object_base base; - struct buffer_store *buffer_store; - int max_num_elements; - int num_elements; - int size_element; - VABufferType type; -}; - -struct object_image -{ - struct object_base base; - VAImage image; - dri_bo *bo; - unsigned int *palette; -}; - -struct object_subpic -{ - struct object_base base; - VAImageID image; - VARectangle src_rect; - VARectangle dst_rect; - unsigned int format; - int width; - int height; - int pitch; - dri_bo *bo; -}; - - - -struct i965_driver_data -{ - struct intel_driver_data intel; - struct object_heap config_heap; - struct object_heap context_heap; - struct object_heap surface_heap; - struct object_heap buffer_heap; - struct object_heap image_heap; - struct object_heap subpic_heap; - struct i965_media_state media_state; - struct i965_render_state render_state; -}; - -#define NEW_CONFIG_ID() object_heap_allocate(&i965->config_heap); -#define NEW_CONTEXT_ID() object_heap_allocate(&i965->context_heap); -#define NEW_SURFACE_ID() object_heap_allocate(&i965->surface_heap); -#define NEW_BUFFER_ID() object_heap_allocate(&i965->buffer_heap); -#define NEW_IMAGE_ID() object_heap_allocate(&i965->image_heap); -#define NEW_SUBPIC_ID() object_heap_allocate(&i965->subpic_heap); - -#define CONFIG(id) ((struct object_config *)object_heap_lookup(&i965->config_heap, id)) -#define CONTEXT(id) ((struct object_context *)object_heap_lookup(&i965->context_heap, id)) -#define SURFACE(id) ((struct object_surface *)object_heap_lookup(&i965->surface_heap, id)) -#define BUFFER(id) ((struct object_buffer *)object_heap_lookup(&i965->buffer_heap, id)) -#define IMAGE(id) ((struct object_image *)object_heap_lookup(&i965->image_heap, id)) -#define SUBPIC(id) ((struct object_subpic *)object_heap_lookup(&i965->subpic_heap, id)) - -#define FOURCC_IA44 0x34344149 -#define FOURCC_AI44 0x34344941 - -#define STRIDE(w) (((w) + 0xf) & ~0xf) -#define SIZE_YUV420(w, h) (h * (STRIDE(w) + STRIDE(w >> 1))) - -static INLINE struct i965_driver_data * -i965_driver_data(VADriverContextP ctx) -{ - return (struct i965_driver_data *)(ctx->pDriverData); -} - -#endif /* _I965_DRV_VIDEO_H_ */ diff -Nru libva-0.31.0+latest2/.pc/102_attribute_visibility.patch/configure.ac libva-0.31.0+latest3/.pc/102_attribute_visibility.patch/configure.ac --- libva-0.31.0+latest2/.pc/102_attribute_visibility.patch/configure.ac 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/102_attribute_visibility.patch/configure.ac 1970-01-01 01:00:00.000000000 +0100 @@ -1,136 +0,0 @@ -# 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. - -# libva package version number, (as distinct from shared library version) -m4_define([libva_major_version], [0]) -m4_define([libva_minor_version], [31]) -m4_define([libva_micro_version], [0]) - -m4_define([libva_version], - [libva_major_version.libva_minor_version.libva_micro_version]) - -# if the library source code has changed, increment revision -m4_define([libva_lt_revision], [1]) -# if any interface was added/removed/changed, then inc current, reset revision -m4_define([libva_lt_current], [1]) -# if any interface was added since last public release, then increment age -# if any interface was removed since last public release, then set age to 0 -m4_define([libva_lt_age], [0]) - -AC_PREREQ(2.57) -AC_INIT([libva], [libva_version], [waldo.bastian@intel.com], libva) -AC_CONFIG_SRCDIR([Makefile.am]) -AM_INIT_AUTOMAKE([dist-bzip2]) - -AM_CONFIG_HEADER([config.h]) - -LIBVA_MAJOR_VERSION=libva_major_version -LIBVA_MINOR_VERSION=libva_minor_version -LIBVA_MICRO_VERSION=libva_micro_version -LIBVA_VERSION=libva_version -AC_SUBST(LIBVA_MAJOR_VERSION) -AC_SUBST(LIBVA_MINOR_VERSION) -AC_SUBST(LIBVA_MICRO_VERSION) -AC_SUBST(LIBVA_VERSION) - -LIBVA_LT_CURRENT=libva_lt_current -LIBVA_LT_REV=libva_lt_revision -LIBVA_LT_AGE=libva_lt_age -LIBVA_LT_VERSION="$LIBVA_LT_CURRENT:$LIBVA_LT_REV:$LIBVA_LT_AGE" -LIBVA_LT_LDFLAGS="-version-info $LIBVA_LT_VERSION" -AC_SUBST(LIBVA_LT_VERSION) -AC_SUBST(LIBVA_LT_LDFLAGS) - -AC_ARG_ENABLE(dummy-driver, - [AC_HELP_STRING([--enable-dummy-driver], - [build dummy video driver])], - [], [enable_dummy_driver=yes]) -AM_CONDITIONAL(BUILD_DUMMY_DRIVER, test x$enable_dummy_driver = xyes) - -AC_ARG_ENABLE(i965-driver, - [AC_HELP_STRING([--enable-i965-driver], - [build i965 video driver])], - [], [enable_i965_driver=no]) - -AC_ARG_WITH(drivers-path, - [AC_HELP_STRING([--with-drivers-path=[[path]]], [drivers path])],, - [with_drivers_path="$libdir/dri"]) - -LIBVA_DRIVERS_PATH="$with_drivers_path" -AC_SUBST(LIBVA_DRIVERS_PATH) - -AC_DISABLE_STATIC -AC_PROG_LIBTOOL -AC_PROG_CC - -AC_HEADER_STDC -AC_SYS_LARGEFILE - -PKG_CHECK_MODULES([X11], [x11]) -PKG_CHECK_MODULES([XEXT],[xext]) -PKG_CHECK_MODULES([XFIXES], [xfixes]) -PKG_CHECK_MODULES([DRM], [libdrm]) - -PKG_CHECK_MODULES(GEN4ASM, [intel-gen4asm >= 1.0], [gen4asm=yes], [gen4asm=no]) -AM_CONDITIONAL(HAVE_GEN4ASM, test x$gen4asm = xyes) - -# Check for libdrm >= 2.4 (needed for i965_drv_video.so) -if test x$enable_i965_driver = xyes && ! $PKG_CONFIG --atleast-version=2.4 libdrm; then - AC_MSG_WARN([libdrm < 2.4 found, disabling build of i965 video driver]) - enable_i965_driver=no -fi -AM_CONDITIONAL(BUILD_I965_DRIVER, test x$enable_i965_driver = xyes) - -# We only need the headers, we don't link against the DRM libraries -LIBVA_CFLAGS="$DRM_CFLAGS" -AC_SUBST(LIBVA_CFLAGS) -AC_SUBST(LIBVA_LIBS) - -pkgconfigdir=${libdir}/pkgconfig -AC_SUBST(pkgconfigdir) - -LIBVA_DISPLAY=x11 -libvacorelib=libva.la -libvabackendlib=libva-$LIBVA_DISPLAY.la -AC_SUBST([libvacorelib]) -AC_SUBST([libvabackendlib]) - -AC_OUTPUT([ - Makefile - va/Makefile - va/va_version.h - va/x11/Makefile - dummy_drv_video/Makefile - i965_drv_video/Makefile - i965_drv_video/shaders/Makefile - i965_drv_video/shaders/mpeg2/Makefile - i965_drv_video/shaders/mpeg2/vld/Makefile - i965_drv_video/shaders/render/Makefile - test/Makefile - test/basic/Makefile - test/decode/Makefile - test/putsurface/Makefile - test/encode/Makefile - libva.pc - libva-x11.pc -]) - diff -Nru libva-0.31.0+latest2/.pc/103_fix_vainfo_deps.patch/test/Makefile.am libva-0.31.0+latest3/.pc/103_fix_vainfo_deps.patch/test/Makefile.am --- libva-0.31.0+latest2/.pc/103_fix_vainfo_deps.patch/test/Makefile.am 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/103_fix_vainfo_deps.patch/test/Makefile.am 1970-01-01 01:00:00.000000000 +0100 @@ -1,36 +0,0 @@ -# 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. - - -bin_PROGRAMS = vainfo - -AM_CFLAGS = -I$(top_srcdir)/va -I$(top_srcdir)/test/basic -I$(top_srcdir)/src/x11 - - -vainfo_LDADD = $(top_srcdir)/va/$(libvabackendlib) -vainfo_DEPENDENCIES = $(top_srcdir)/va/$(libvabackendlib) -vainfo_SOURCES = vainfo.c - -SUBDIRS = basic decode encode putsurface - -valgrind: vainfo - valgrind --leak-check=full --show-reachable=yes .libs/vainfo; diff -Nru libva-0.31.0+latest2/.pc/104_fix_libva_pkgconfig_deps.patch/libva-x11.pc.in libva-0.31.0+latest3/.pc/104_fix_libva_pkgconfig_deps.patch/libva-x11.pc.in --- libva-0.31.0+latest2/.pc/104_fix_libva_pkgconfig_deps.patch/libva-x11.pc.in 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/104_fix_libva_pkgconfig_deps.patch/libva-x11.pc.in 1970-01-01 01:00:00.000000000 +0100 @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ -display=x11 - -Name: libva-${display} -Description: Userspace Video Acceleration (VA) ${display} interface -Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -lva-${display} -Cflags: -I${includedir} diff -Nru libva-0.31.0+latest2/.pc/105_dont_search_LIBGL_DRIVERS_PATH.patch/va/va.c libva-0.31.0+latest3/.pc/105_dont_search_LIBGL_DRIVERS_PATH.patch/va/va.c --- libva-0.31.0+latest2/.pc/105_dont_search_LIBGL_DRIVERS_PATH.patch/va/va.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/105_dont_search_LIBGL_DRIVERS_PATH.patch/va/va.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,1263 +0,0 @@ -/* - * 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 - - -#define DRIVER_INIT_FUNC "__vaDriverInit_0_31" - -#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->vadpy_magic == VA_DISPLAY_MAGIC) && 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 = getenv("LIBGL_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) - { - 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 -Nru libva-0.31.0+latest2/.pc/108_drivers_path.patch/configure.ac libva-0.31.0+latest3/.pc/108_drivers_path.patch/configure.ac --- libva-0.31.0+latest2/.pc/108_drivers_path.patch/configure.ac 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/108_drivers_path.patch/configure.ac 1970-01-01 01:00:00.000000000 +0100 @@ -1,160 +0,0 @@ -# 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. - -# libva package version number, (as distinct from shared library version) -m4_define([libva_major_version], [0]) -m4_define([libva_minor_version], [31]) -m4_define([libva_micro_version], [0]) - -m4_define([libva_version], - [libva_major_version.libva_minor_version.libva_micro_version]) - -# if the library source code has changed, increment revision -m4_define([libva_lt_revision], [1]) -# if any interface was added/removed/changed, then inc current, reset revision -m4_define([libva_lt_current], [1]) -# if any interface was added since last public release, then increment age -# if any interface was removed since last public release, then set age to 0 -m4_define([libva_lt_age], [0]) - -AC_PREREQ(2.57) -AC_INIT([libva], [libva_version], [waldo.bastian@intel.com], libva) -AC_CONFIG_SRCDIR([Makefile.am]) -AM_INIT_AUTOMAKE([dist-bzip2]) - -AM_CONFIG_HEADER([config.h]) - -LIBVA_MAJOR_VERSION=libva_major_version -LIBVA_MINOR_VERSION=libva_minor_version -LIBVA_MICRO_VERSION=libva_micro_version -LIBVA_VERSION=libva_version -AC_SUBST(LIBVA_MAJOR_VERSION) -AC_SUBST(LIBVA_MINOR_VERSION) -AC_SUBST(LIBVA_MICRO_VERSION) -AC_SUBST(LIBVA_VERSION) - -LIBVA_LT_CURRENT=libva_lt_current -LIBVA_LT_REV=libva_lt_revision -LIBVA_LT_AGE=libva_lt_age -LIBVA_LT_VERSION="$LIBVA_LT_CURRENT:$LIBVA_LT_REV:$LIBVA_LT_AGE" -LIBVA_LT_LDFLAGS="-version-info $LIBVA_LT_VERSION" -AC_SUBST(LIBVA_LT_VERSION) -AC_SUBST(LIBVA_LT_LDFLAGS) - -AC_ARG_ENABLE(dummy-driver, - [AC_HELP_STRING([--enable-dummy-driver], - [build dummy video driver])], - [], [enable_dummy_driver=yes]) -AM_CONDITIONAL(BUILD_DUMMY_DRIVER, test x$enable_dummy_driver = xyes) - -AC_ARG_ENABLE(i965-driver, - [AC_HELP_STRING([--enable-i965-driver], - [build i965 video driver])], - [], [enable_i965_driver=no]) - -AC_ARG_WITH(drivers-path, - [AC_HELP_STRING([--with-drivers-path=[[path]]], [drivers path])],, - [with_drivers_path="$libdir/dri"]) - -LIBVA_DRIVERS_PATH="$with_drivers_path" -AC_SUBST(LIBVA_DRIVERS_PATH) - -AC_DISABLE_STATIC -AC_PROG_LIBTOOL -AC_PROG_CC - -AC_HEADER_STDC -AC_SYS_LARGEFILE - -PKG_CHECK_MODULES([X11], [x11]) -PKG_CHECK_MODULES([XEXT],[xext]) -PKG_CHECK_MODULES([XFIXES], [xfixes]) -PKG_CHECK_MODULES([DRM], [libdrm]) - -PKG_CHECK_MODULES(GEN4ASM, [intel-gen4asm >= 1.0], [gen4asm=yes], [gen4asm=no]) -AM_CONDITIONAL(HAVE_GEN4ASM, test x$gen4asm = xyes) - -# Check for libdrm >= 2.4 (needed for i965_drv_video.so) -if test x$enable_i965_driver = xyes && ! $PKG_CONFIG --atleast-version=2.4 libdrm; then - AC_MSG_WARN([libdrm < 2.4 found, disabling build of i965 video driver]) - enable_i965_driver=no -fi -AM_CONDITIONAL(BUILD_I965_DRIVER, test x$enable_i965_driver = xyes) - -dnl Check for __attribute__((visibility())) -AC_CACHE_CHECK([whether __attribute__((visibility())) is supported], - libva_cv_visibility_attribute, - [cat > conftest.c </dev/null 2>&1; then - if grep '\.hidden.*foo' conftest.s >/dev/null; then - if grep '\.protected.*bar' conftest.s >/dev/null; then - libva_cv_visibility_attribute=yes - fi - fi - fi - rm -f conftest.[cs] -]) -ATTRIBUTE_HIDDEN="" -if test $libva_cv_visibility_attribute = yes; then - ATTRIBUTE_HIDDEN="__attribute__((visibility(\"hidden\")))" -fi -AC_DEFINE_UNQUOTED([ATTRIBUTE_HIDDEN], [$ATTRIBUTE_HIDDEN], - [Defined to __attribute__((visibility("hidden"))) when available]) - -# We only need the headers, we don't link against the DRM libraries -LIBVA_CFLAGS="$DRM_CFLAGS" -AC_SUBST(LIBVA_CFLAGS) -AC_SUBST(LIBVA_LIBS) - -pkgconfigdir=${libdir}/pkgconfig -AC_SUBST(pkgconfigdir) - -LIBVA_DISPLAY=x11 -libvacorelib=libva.la -libvabackendlib=libva-$LIBVA_DISPLAY.la -AC_SUBST([libvacorelib]) -AC_SUBST([libvabackendlib]) - -AC_OUTPUT([ - Makefile - va/Makefile - va/va_version.h - va/x11/Makefile - dummy_drv_video/Makefile - i965_drv_video/Makefile - i965_drv_video/shaders/Makefile - i965_drv_video/shaders/mpeg2/Makefile - i965_drv_video/shaders/mpeg2/vld/Makefile - i965_drv_video/shaders/render/Makefile - test/Makefile - test/basic/Makefile - test/decode/Makefile - test/putsurface/Makefile - test/encode/Makefile - libva.pc - libva-x11.pc -]) - diff -Nru libva-0.31.0+latest2/.pc/201_libva_LIBVA_DRIVER_NAME.patch/va/va.c libva-0.31.0+latest3/.pc/201_libva_LIBVA_DRIVER_NAME.patch/va/va.c --- libva-0.31.0+latest2/.pc/201_libva_LIBVA_DRIVER_NAME.patch/va/va.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/201_libva_LIBVA_DRIVER_NAME.patch/va/va.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,1259 +0,0 @@ -/* - * 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 - - -#define DRIVER_INIT_FUNC "__vaDriverInit_0_31" - -#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->vadpy_magic == VA_DISPLAY_MAGIC) && 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) - { - 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 -Nru libva-0.31.0+latest2/.pc/201_libva_LIBVA_DRIVER_NAME.patch/va/x11/va_x11.c libva-0.31.0+latest3/.pc/201_libva_LIBVA_DRIVER_NAME.patch/va/x11/va_x11.c --- libva-0.31.0+latest2/.pc/201_libva_LIBVA_DRIVER_NAME.patch/va/x11/va_x11.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/201_libva_LIBVA_DRIVER_NAME.patch/va/x11/va_x11.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,217 +0,0 @@ -/* - * 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 -#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); - } - 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_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); - - 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) - { - pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC; - - 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 -Nru libva-0.31.0+latest2/.pc/202_check_crystalhd.patch/va/Makefile.am libva-0.31.0+latest3/.pc/202_check_crystalhd.patch/va/Makefile.am --- libva-0.31.0+latest2/.pc/202_check_crystalhd.patch/va/Makefile.am 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/202_check_crystalhd.patch/va/Makefile.am 1970-01-01 01:00:00.000000000 +0100 @@ -1,54 +0,0 @@ -# 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)/va/x11 \ - -DVA_DRIVERS_PATH="\"$(LIBVA_DRIVERS_PATH)\"" - -LDADD = \ - $(LIBVA_LT_LDFLAGS) - -lib_LTLIBRARIES = \ - libva.la \ - libva-x11.la - -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) $(DRM_LIBS) $(XFIXES_LIBS) -libva_x11_la_LDFLAGS = $(LDADD) -libva_x11_la_DEPENDENCIES = $(libvacorelib) x11/libva_x11.la - -SUBDIRS = x11 - -libva_la_SOURCES = va.c - -libvaincludedir = ${includedir}/va -libvainclude_HEADERS = va.h va_x11.h va_backend.h va_version.h - -DISTCLEANFILES = \ - va_version.h - -EXTRA_DIST = \ - va_version.h.in diff -Nru libva-0.31.0+latest2/.pc/202_check_crystalhd.patch/va/va.c libva-0.31.0+latest3/.pc/202_check_crystalhd.patch/va/va.c --- libva-0.31.0+latest2/.pc/202_check_crystalhd.patch/va/va.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/202_check_crystalhd.patch/va/va.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,1271 +0,0 @@ -/* - * 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 - - -#define DRIVER_INIT_FUNC "__vaDriverInit_0_31" - -#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->vadpy_magic == VA_DISPLAY_MAGIC) && 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) - { - 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 */ -) -{ - const char *driver_name_env = NULL; - 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); - - driver_name_env = getenv("LIBVA_DRIVER_NAME"); - if (driver_name_env && geteuid() == getuid()) - { - /* Don't allow setuid apps to use LIBVA_DRIVER_NAME */ - driver_name = strdup(driver_name_env); - vaStatus = VA_STATUS_SUCCESS; - va_infoMessage("User requested driver '%s'\n", driver_name); - } - else - { - 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 -Nru libva-0.31.0+latest2/.pc/203_fix_fglrx_detection.patch/va/Makefile.am libva-0.31.0+latest3/.pc/203_fix_fglrx_detection.patch/va/Makefile.am --- libva-0.31.0+latest2/.pc/203_fix_fglrx_detection.patch/va/Makefile.am 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/203_fix_fglrx_detection.patch/va/Makefile.am 1970-01-01 01:00:00.000000000 +0100 @@ -1,55 +0,0 @@ -# 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)/va/x11 \ - -DVA_DRIVERS_PATH="\"$(LIBVA_DRIVERS_PATH)\"" - -LDADD = \ - $(LIBVA_LT_LDFLAGS) - -lib_LTLIBRARIES = \ - libva.la \ - libva-x11.la - -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) $(DRM_LIBS) $(XFIXES_LIBS) -libva_x11_la_LDFLAGS = $(LDADD) -libva_x11_la_DEPENDENCIES = $(libvacorelib) x11/libva_x11.la - -SUBDIRS = x11 - -libva_la_SOURCES = va.c va_crystalhd.c - -libvaincludedir = ${includedir}/va -libvainclude_HEADERS = va.h va_x11.h va_backend.h va_version.h - -DISTCLEANFILES = \ - va_version.h - -EXTRA_DIST = \ - va_version.h.in \ - va_crystalhd.h diff -Nru libva-0.31.0+latest2/.pc/203_fix_fglrx_detection.patch/va/x11/dri1_util.c libva-0.31.0+latest3/.pc/203_fix_fglrx_detection.patch/va/x11/dri1_util.c --- libva-0.31.0+latest2/.pc/203_fix_fglrx_detection.patch/va/x11/dri1_util.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/203_fix_fglrx_detection.patch/va/x11/dri1_util.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,157 +0,0 @@ -#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 -Nru libva-0.31.0+latest2/.pc/203_fix_fglrx_detection.patch/va/x11/dri2_util.c libva-0.31.0+latest3/.pc/203_fix_fglrx_detection.patch/va/x11/dri2_util.c --- libva-0.31.0+latest2/.pc/203_fix_fglrx_detection.patch/va/x11/dri2_util.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/203_fix_fglrx_detection.patch/va/x11/dri2_util.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,200 +0,0 @@ -#include -#include -#include -#include - -#include - -#include -#include -#include "va.h" -#include "va_backend.h" - -#include "va_dri2.h" -#include "va_dri2tokens.h" -#include "va_dricommon.h" - -#define __DRI_BUFFER_FRONT_LEFT 0 -#define __DRI_BUFFER_BACK_LEFT 1 -#define __DRI_BUFFER_FRONT_RIGHT 2 -#define __DRI_BUFFER_BACK_RIGHT 3 -#define __DRI_BUFFER_DEPTH 4 -#define __DRI_BUFFER_STENCIL 5 -#define __DRI_BUFFER_ACCUM 6 -#define __DRI_BUFFER_FAKE_FRONT_LEFT 7 -#define __DRI_BUFFER_FAKE_FRONT_RIGHT 8 - -struct dri2_drawable -{ - struct dri_drawable base; - union dri_buffer buffers[5]; - int width; - int height; - int has_backbuffer; - int back_index; - int front_index; -}; - -static struct dri_drawable * -dri2CreateDrawable(VADriverContextP ctx, XID x_drawable) -{ - struct dri2_drawable *dri2_drawable; - - dri2_drawable = calloc(1, sizeof(*dri2_drawable)); - - if (!dri2_drawable) - return NULL; - - dri2_drawable->base.x_drawable = x_drawable; - dri2_drawable->base.x = 0; - dri2_drawable->base.y = 0; - VA_DRI2CreateDrawable(ctx->x11_dpy, x_drawable); - - return &dri2_drawable->base; -} - -static void -dri2DestroyDrawable(VADriverContextP ctx, struct dri_drawable *dri_drawable) -{ - VA_DRI2DestroyDrawable(ctx->x11_dpy, dri_drawable->x_drawable); - free(dri_drawable); -} - -static void -dri2SwapBuffer(VADriverContextP ctx, struct dri_drawable *dri_drawable) -{ - struct dri2_drawable *dri2_drawable = (struct dri2_drawable *)dri_drawable; - XRectangle xrect; - XserverRegion region; - - if (dri2_drawable->has_backbuffer) { - xrect.x = 0; - xrect.y = 0; - xrect.width = dri2_drawable->width; - xrect.height = dri2_drawable->height; - - region = XFixesCreateRegion(ctx->x11_dpy, &xrect, 1); - VA_DRI2CopyRegion(ctx->x11_dpy, dri_drawable->x_drawable, region, - DRI2BufferFrontLeft, DRI2BufferBackLeft); - XFixesDestroyRegion(ctx->x11_dpy, region); - } -} - -static union dri_buffer * -dri2GetRenderingBuffer(VADriverContextP ctx, struct dri_drawable *dri_drawable) -{ - struct dri2_drawable *dri2_drawable = (struct dri2_drawable *)dri_drawable; - int i; - int count; - unsigned int attachments[5]; - VA_DRI2Buffer *buffers; - - i = 0; - attachments[i++] = __DRI_BUFFER_BACK_LEFT; - attachments[i++] = __DRI_BUFFER_FRONT_LEFT; - buffers = VA_DRI2GetBuffers(ctx->x11_dpy, dri_drawable->x_drawable, - &dri2_drawable->width, &dri2_drawable->height, - attachments, i, &count); - assert(buffers); - if (buffers == NULL) - return NULL; - - dri2_drawable->has_backbuffer = 0; - - for (i = 0; i < count; i++) { - dri2_drawable->buffers[i].dri2.attachment = buffers[i].attachment; - dri2_drawable->buffers[i].dri2.name = buffers[i].name; - dri2_drawable->buffers[i].dri2.pitch = buffers[i].pitch; - dri2_drawable->buffers[i].dri2.cpp = buffers[i].cpp; - dri2_drawable->buffers[i].dri2.flags = buffers[i].flags; - - if (buffers[i].attachment == __DRI_BUFFER_BACK_LEFT) { - dri2_drawable->has_backbuffer = 1; - dri2_drawable->back_index = i; - } - - if (buffers[i].attachment == __DRI_BUFFER_FRONT_LEFT) - dri2_drawable->front_index = i; - } - - dri_drawable->width = dri2_drawable->width; - dri_drawable->height = dri2_drawable->height; - Xfree(buffers); - - if (dri2_drawable->has_backbuffer) - return &dri2_drawable->buffers[dri2_drawable->back_index]; - - return &dri2_drawable->buffers[dri2_drawable->front_index]; -} - -static void -dri2Close(VADriverContextP ctx) -{ - struct dri_state *dri_state = (struct dri_state *)ctx->dri_state; - - free_drawable_hashtable(ctx); - assert(dri_state->fd >= 0); - close(dri_state->fd); -} - -Bool -isDRI2Connected(VADriverContextP ctx, char **driver_name) -{ - struct dri_state *dri_state = (struct dri_state *)ctx->dri_state; - int major, minor; - int error_base; - int event_base; - char *device_name = NULL; - drm_magic_t magic; - *driver_name = NULL; - dri_state->fd = -1; - dri_state->driConnectedFlag = VA_NONE; - if (!VA_DRI2QueryExtension(ctx->x11_dpy, &event_base, &error_base)) - goto err_out; - - if (!VA_DRI2QueryVersion(ctx->x11_dpy, &major, &minor)) - goto err_out; - - - if (!VA_DRI2Connect(ctx->x11_dpy, RootWindow(ctx->x11_dpy, ctx->x11_screen), - driver_name, &device_name)) - goto err_out; - - dri_state->fd = open(device_name, O_RDWR); - assert(dri_state->fd >= 0); - - if (dri_state->fd < 0) - goto err_out; - - if (drmGetMagic(dri_state->fd, &magic)) - goto err_out; - - if (!VA_DRI2Authenticate(ctx->x11_dpy, RootWindow(ctx->x11_dpy, ctx->x11_screen), - magic)) - goto err_out; - - dri_state->driConnectedFlag = VA_DRI2; - dri_state->createDrawable = dri2CreateDrawable; - dri_state->destroyDrawable = dri2DestroyDrawable; - dri_state->swapBuffer = dri2SwapBuffer; - dri_state->getRenderingBuffer = dri2GetRenderingBuffer; - dri_state->close = dri2Close; - - return True; - -err_out: - if (device_name) - Xfree(device_name); - - if (*driver_name) - Xfree(*driver_name); - - if (dri_state->fd >= 0) - close(dri_state->fd); - - *driver_name = NULL; - dri_state->fd = -1; - - return False; -} - diff -Nru libva-0.31.0+latest2/.pc/203_fix_fglrx_detection.patch/va/x11/Makefile.am libva-0.31.0+latest3/.pc/203_fix_fglrx_detection.patch/va/x11/Makefile.am --- libva-0.31.0+latest2/.pc/203_fix_fglrx_detection.patch/va/x11/Makefile.am 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/203_fix_fglrx_detection.patch/va/x11/Makefile.am 1970-01-01 01:00:00.000000000 +0100 @@ -1,30 +0,0 @@ -# INTEL CONFIDENTIAL -# Copyright 2007 Intel Corporation. All Rights Reserved. -# -# The source code contained or described herein and all documents related to -# the source code ("Material") are owned by Intel Corporation or its suppliers -# or licensors. Title to the Material remains with Intel Corporation or its -# suppliers and licensors. The Material may contain trade secrets and -# proprietary and confidential information of Intel Corporation and its -# suppliers and licensors, and is protected by worldwide copyright and trade -# secret laws and treaty provisions. No part of the Material may be used, -# copied, reproduced, modified, published, uploaded, posted, transmitted, -# distributed, or disclosed in any way without Intel's prior express written -# permission. -# -# No license under any patent, copyright, trade secret or other intellectual -# property right is granted to or conferred upon you by disclosure or delivery -# of the Materials, either expressly, by implication, inducement, estoppel or -# otherwise. Any license under such intellectual property rights must be -# express and approved by Intel in writing. - -AM_CFLAGS = -DLINUX -I$(top_srcdir)/va $(DRM_CFLAGS) - -noinst_LTLIBRARIES = libva_x11.la - -libva_x11includedir = ${includedir}/va -libva_x11include_HEADERS = va_dri.h va_dri2.h va_dricommon.h - -libva_x11_la_SOURCES = va_x11.c va_dri.c va_dri2.c va_dricommon.c dri2_util.c dri1_util.c va_nvctrl.c - -EXTRA_DIST = va_dristr.h va_dri2str.h va_dri2tokens.h va_nvctrl.h diff -Nru libva-0.31.0+latest2/.pc/203_fix_fglrx_detection.patch/va/x11/va_dricommon.h libva-0.31.0+latest3/.pc/203_fix_fglrx_detection.patch/va/x11/va_dricommon.h --- libva-0.31.0+latest2/.pc/203_fix_fglrx_detection.patch/va/x11/va_dricommon.h 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/203_fix_fglrx_detection.patch/va/x11/va_dricommon.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,68 +0,0 @@ -#ifndef _VA_DRICOMMON_H_ -#define _VA_DRICOMMON_H_ - -#include - -#include -#include -#include - -#include - -enum -{ - VA_NONE = 0, - VA_DRI1 = 1, - VA_DRI2 = 2 -}; - -union dri_buffer -{ - struct { - unsigned int attachment; - unsigned int name; - unsigned int pitch; - unsigned int cpp; - unsigned int flags; - } dri2; - - struct { - } dri1; -}; - -struct dri_drawable -{ - XID x_drawable; - int x; - int y; - unsigned int width; - unsigned int height; - struct dri_drawable *next; -}; - -#define DRAWABLE_HASH_SZ 32 -struct dri_state -{ - int fd; - int driConnectedFlag; /* 0: disconnected, 1: DRI, 2: DRI2 */ - drm_handle_t hSAREA; - drm_context_t hwContext; - drmAddress pSAREA; - XID hwContextID; - struct dri_drawable *drawable_hash[DRAWABLE_HASH_SZ]; - - struct dri_drawable *(*createDrawable)(VADriverContextP ctx, XID x_drawable); - void (*destroyDrawable)(VADriverContextP ctx, struct dri_drawable *dri_drawable); - void (*swapBuffer)(VADriverContextP ctx, struct dri_drawable *dri_drawable); - union dri_buffer *(*getRenderingBuffer)(VADriverContextP ctx, struct dri_drawable *dri_drawable); - void (*close)(VADriverContextP ctx); -}; - -Bool isDRI2Connected(VADriverContextP ctx, char **driver_name); -Bool isDRI1Connected(VADriverContextP ctx, char **driver_name); -void free_drawable_hashtable(VADriverContextP ctx); -struct dri_drawable *dri_get_drawable(VADriverContextP ctx, XID drawable); -void dri_swap_buffer(VADriverContextP ctx, struct dri_drawable *dri_drawable); -union dri_buffer *dri_get_rendering_buffer(VADriverContextP ctx, struct dri_drawable *dri_drawable); - -#endif /* _VA_DRICOMMON_H_ */ diff -Nru libva-0.31.0+latest2/.pc/203_fix_fglrx_detection.patch/va/x11/va_x11.c libva-0.31.0+latest3/.pc/203_fix_fglrx_detection.patch/va/x11/va_x11.c --- libva-0.31.0+latest2/.pc/203_fix_fglrx_detection.patch/va/x11/va_x11.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/203_fix_fglrx_detection.patch/va/x11/va_x11.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,208 +0,0 @@ -/* - * 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 -#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); - } - 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_DisplayContextGetDriverName ( - VADisplayContextP pDisplayContext, - char **driver_name -) -{ - VAStatus vaStatus; - - if (driver_name) - *driver_name = NULL; - - 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); - - 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) - { - pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC; - - 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 -Nru libva-0.31.0+latest2/.pc/204_check_ATIFGLEXTENSION.patch/va/Makefile.am libva-0.31.0+latest3/.pc/204_check_ATIFGLEXTENSION.patch/va/Makefile.am --- libva-0.31.0+latest2/.pc/204_check_ATIFGLEXTENSION.patch/va/Makefile.am 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/204_check_ATIFGLEXTENSION.patch/va/Makefile.am 1970-01-01 01:00:00.000000000 +0100 @@ -1,55 +0,0 @@ -# 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)/va/x11 \ - -DVA_DRIVERS_PATH="\"$(LIBVA_DRIVERS_PATH)\"" - -LDADD = \ - $(LIBVA_LT_LDFLAGS) - -lib_LTLIBRARIES = \ - libva.la \ - libva-x11.la - -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) -libva_x11_la_LDFLAGS = $(LDADD) -libva_x11_la_DEPENDENCIES = $(libvacorelib) x11/libva_x11.la - -SUBDIRS = x11 - -libva_la_SOURCES = va.c va_crystalhd.c - -libvaincludedir = ${includedir}/va -libvainclude_HEADERS = va.h va_x11.h va_backend.h va_version.h - -DISTCLEANFILES = \ - va_version.h - -EXTRA_DIST = \ - va_version.h.in \ - va_crystalhd.h diff -Nru libva-0.31.0+latest2/.pc/204_check_ATIFGLEXTENSION.patch/va/x11/Makefile.am libva-0.31.0+latest3/.pc/204_check_ATIFGLEXTENSION.patch/va/x11/Makefile.am --- libva-0.31.0+latest2/.pc/204_check_ATIFGLEXTENSION.patch/va/x11/Makefile.am 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/204_check_ATIFGLEXTENSION.patch/va/x11/Makefile.am 1970-01-01 01:00:00.000000000 +0100 @@ -1,30 +0,0 @@ -# INTEL CONFIDENTIAL -# Copyright 2007 Intel Corporation. All Rights Reserved. -# -# The source code contained or described herein and all documents related to -# the source code ("Material") are owned by Intel Corporation or its suppliers -# or licensors. Title to the Material remains with Intel Corporation or its -# suppliers and licensors. The Material may contain trade secrets and -# proprietary and confidential information of Intel Corporation and its -# suppliers and licensors, and is protected by worldwide copyright and trade -# secret laws and treaty provisions. No part of the Material may be used, -# copied, reproduced, modified, published, uploaded, posted, transmitted, -# distributed, or disclosed in any way without Intel's prior express written -# permission. -# -# No license under any patent, copyright, trade secret or other intellectual -# property right is granted to or conferred upon you by disclosure or delivery -# of the Materials, either expressly, by implication, inducement, estoppel or -# otherwise. Any license under such intellectual property rights must be -# express and approved by Intel in writing. - -AM_CFLAGS = -DLINUX -I$(top_srcdir)/va $(DRM_CFLAGS) - -noinst_LTLIBRARIES = libva_x11.la - -libva_x11includedir = ${includedir}/va -libva_x11include_HEADERS = va_dri.h va_dri2.h va_dricommon.h - -libva_x11_la_SOURCES = va_x11.c va_dri.c va_dri2.c va_dricommon.c dri2_util.c dri1_util.c va_nvctrl.c libdrm_glue.c - -EXTRA_DIST = va_dristr.h va_dri2str.h va_dri2tokens.h va_nvctrl.h libdrm_glue.h diff -Nru libva-0.31.0+latest2/.pc/204_check_ATIFGLEXTENSION.patch/va/x11/va_x11.c libva-0.31.0+latest3/.pc/204_check_ATIFGLEXTENSION.patch/va/x11/va_x11.c --- libva-0.31.0+latest2/.pc/204_check_ATIFGLEXTENSION.patch/va/x11/va_x11.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/204_check_ATIFGLEXTENSION.patch/va/x11/va_x11.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,211 +0,0 @@ -/* - * 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 "libdrm_glue.h" -#include -#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_DisplayContextGetDriverName ( - VADisplayContextP pDisplayContext, - char **driver_name -) -{ - VAStatus vaStatus; - - if (driver_name) - *driver_name = NULL; - - 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); - - 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) - { - pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC; - - 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 -Nru libva-0.31.0+latest2/.pc/300_sds_version.patch/configure.ac libva-0.31.0+latest3/.pc/300_sds_version.patch/configure.ac --- libva-0.31.0+latest2/.pc/300_sds_version.patch/configure.ac 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/300_sds_version.patch/configure.ac 1970-01-01 01:00:00.000000000 +0100 @@ -1,160 +0,0 @@ -# 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. - -# libva package version number, (as distinct from shared library version) -m4_define([libva_major_version], [0]) -m4_define([libva_minor_version], [31]) -m4_define([libva_micro_version], [0]) - -m4_define([libva_version], - [libva_major_version.libva_minor_version.libva_micro_version]) - -# if the library source code has changed, increment revision -m4_define([libva_lt_revision], [1]) -# if any interface was added/removed/changed, then inc current, reset revision -m4_define([libva_lt_current], [1]) -# if any interface was added since last public release, then increment age -# if any interface was removed since last public release, then set age to 0 -m4_define([libva_lt_age], [0]) - -AC_PREREQ(2.57) -AC_INIT([libva], [libva_version], [waldo.bastian@intel.com], libva) -AC_CONFIG_SRCDIR([Makefile.am]) -AM_INIT_AUTOMAKE([dist-bzip2]) - -AM_CONFIG_HEADER([config.h]) - -LIBVA_MAJOR_VERSION=libva_major_version -LIBVA_MINOR_VERSION=libva_minor_version -LIBVA_MICRO_VERSION=libva_micro_version -LIBVA_VERSION=libva_version -AC_SUBST(LIBVA_MAJOR_VERSION) -AC_SUBST(LIBVA_MINOR_VERSION) -AC_SUBST(LIBVA_MICRO_VERSION) -AC_SUBST(LIBVA_VERSION) - -LIBVA_LT_CURRENT=libva_lt_current -LIBVA_LT_REV=libva_lt_revision -LIBVA_LT_AGE=libva_lt_age -LIBVA_LT_VERSION="$LIBVA_LT_CURRENT:$LIBVA_LT_REV:$LIBVA_LT_AGE" -LIBVA_LT_LDFLAGS="-version-info $LIBVA_LT_VERSION" -AC_SUBST(LIBVA_LT_VERSION) -AC_SUBST(LIBVA_LT_LDFLAGS) - -AC_ARG_ENABLE(dummy-driver, - [AC_HELP_STRING([--enable-dummy-driver], - [build dummy video driver])], - [], [enable_dummy_driver=yes]) -AM_CONDITIONAL(BUILD_DUMMY_DRIVER, test x$enable_dummy_driver = xyes) - -AC_ARG_ENABLE(i965-driver, - [AC_HELP_STRING([--enable-i965-driver], - [build i965 video driver])], - [], [enable_i965_driver=no]) - -AC_ARG_WITH(drivers-path, - [AC_HELP_STRING([--with-drivers-path=[[path]]], [drivers path])],, - [with_drivers_path="$libdir/va/drivers"]) - -LIBVA_DRIVERS_PATH="$with_drivers_path" -AC_SUBST(LIBVA_DRIVERS_PATH) - -AC_DISABLE_STATIC -AC_PROG_LIBTOOL -AC_PROG_CC - -AC_HEADER_STDC -AC_SYS_LARGEFILE - -PKG_CHECK_MODULES([X11], [x11]) -PKG_CHECK_MODULES([XEXT],[xext]) -PKG_CHECK_MODULES([XFIXES], [xfixes]) -PKG_CHECK_MODULES([DRM], [libdrm]) - -PKG_CHECK_MODULES(GEN4ASM, [intel-gen4asm >= 1.0], [gen4asm=yes], [gen4asm=no]) -AM_CONDITIONAL(HAVE_GEN4ASM, test x$gen4asm = xyes) - -# Check for libdrm >= 2.4 (needed for i965_drv_video.so) -if test x$enable_i965_driver = xyes && ! $PKG_CONFIG --atleast-version=2.4 libdrm; then - AC_MSG_WARN([libdrm < 2.4 found, disabling build of i965 video driver]) - enable_i965_driver=no -fi -AM_CONDITIONAL(BUILD_I965_DRIVER, test x$enable_i965_driver = xyes) - -dnl Check for __attribute__((visibility())) -AC_CACHE_CHECK([whether __attribute__((visibility())) is supported], - libva_cv_visibility_attribute, - [cat > conftest.c </dev/null 2>&1; then - if grep '\.hidden.*foo' conftest.s >/dev/null; then - if grep '\.protected.*bar' conftest.s >/dev/null; then - libva_cv_visibility_attribute=yes - fi - fi - fi - rm -f conftest.[cs] -]) -ATTRIBUTE_HIDDEN="" -if test $libva_cv_visibility_attribute = yes; then - ATTRIBUTE_HIDDEN="__attribute__((visibility(\"hidden\")))" -fi -AC_DEFINE_UNQUOTED([ATTRIBUTE_HIDDEN], [$ATTRIBUTE_HIDDEN], - [Defined to __attribute__((visibility("hidden"))) when available]) - -# We only need the headers, we don't link against the DRM libraries -LIBVA_CFLAGS="$DRM_CFLAGS" -AC_SUBST(LIBVA_CFLAGS) -AC_SUBST(LIBVA_LIBS) - -pkgconfigdir=${libdir}/pkgconfig -AC_SUBST(pkgconfigdir) - -LIBVA_DISPLAY=x11 -libvacorelib=libva.la -libvabackendlib=libva-$LIBVA_DISPLAY.la -AC_SUBST([libvacorelib]) -AC_SUBST([libvabackendlib]) - -AC_OUTPUT([ - Makefile - va/Makefile - va/va_version.h - va/x11/Makefile - dummy_drv_video/Makefile - i965_drv_video/Makefile - i965_drv_video/shaders/Makefile - i965_drv_video/shaders/mpeg2/Makefile - i965_drv_video/shaders/mpeg2/vld/Makefile - i965_drv_video/shaders/render/Makefile - test/Makefile - test/basic/Makefile - test/decode/Makefile - test/putsurface/Makefile - test/encode/Makefile - libva.pc - libva-x11.pc -]) - diff -Nru libva-0.31.0+latest2/.pc/300_sds_version.patch/libva.pc.in libva-0.31.0+latest3/.pc/300_sds_version.patch/libva.pc.in --- libva-0.31.0+latest2/.pc/300_sds_version.patch/libva.pc.in 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/300_sds_version.patch/libva.pc.in 1970-01-01 01:00:00.000000000 +0100 @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ -driverdir=@LIBVA_DRIVERS_PATH@ - -Name: libva -Description: Userspace Video Acceleration (VA) core interface -Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -lva -Cflags: -I${includedir} diff -Nru libva-0.31.0+latest2/.pc/300_sds_version.patch/va/va.c libva-0.31.0+latest3/.pc/300_sds_version.patch/va/va.c --- libva-0.31.0+latest2/.pc/300_sds_version.patch/va/va.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/300_sds_version.patch/va/va.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,1282 +0,0 @@ -/* - * 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_crystalhd.h" - -#include -#include -#include -#include -#include -#include -#include - - -#define DRIVER_INIT_FUNC "__vaDriverInit_0_31" - -#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->vadpy_magic == VA_DISPLAY_MAGIC) && 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) - { - 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 */ -) -{ - const char *driver_name_env = NULL; - 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); - - driver_name_env = getenv("LIBVA_DRIVER_NAME"); - if (driver_name_env && geteuid() == getuid()) - { - /* Don't allow setuid apps to use LIBVA_DRIVER_NAME */ - driver_name = strdup(driver_name_env); - vaStatus = VA_STATUS_SUCCESS; - va_infoMessage("User requested driver '%s'\n", driver_name); - } - else - { - 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); - - if (vaStatus != VA_STATUS_SUCCESS && !driver_name_env) - { - if (va_hasCrystalHD()) - { - vaStatus = va_openDriver(dpy, "crystalhd"); - 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 -Nru libva-0.31.0+latest2/.pc/300_sds_version.patch/va/va_version.h.in libva-0.31.0+latest3/.pc/300_sds_version.patch/va/va_version.h.in --- libva-0.31.0+latest2/.pc/300_sds_version.patch/va/va_version.h.in 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/300_sds_version.patch/va/va_version.h.in 1970-01-01 01:00:00.000000000 +0100 @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2009 Splitted-Desktop Systems. 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. - */ - -#ifndef VA_VERSION_H -#define VA_VERSION_H - -/** - * VA_MAJOR_VERSION: - * - * The major version of the VA library (1, if %VA_VERSION is 1.2.3) - */ -#define VA_MAJOR_VERSION (@LIBVA_MAJOR_VERSION@) - -/** - * VA_MINOR_VERSION: - * - * The minor version of the VA library (2, if %VA_VERSION is 1.2.3) - */ -#define VA_MINOR_VERSION (@LIBVA_MINOR_VERSION@) - -/** - * VA_MICRO_VERSION: - * - * The micro version of the VA library (3, if %VA_VERSION is 1.2.3) - */ -#define VA_MICRO_VERSION (@LIBVA_MICRO_VERSION@) - -/** - * VA_VERSION: - * - * The full version of the VA library, like 1.2.3 - */ -#define VA_VERSION @LIBVA_VERSION@ - -/** - * VA_VERSION_S: - * - * The full version of the VA library, in string form (suited for - * string concatenation) - */ -#define VA_VERSION_S "@LIBVA_VERSION@" - -/** - * VA_VERSION_HEX: - * - * Numerically encoded version of the VA library, like 0x010203 - */ -#define VA_VERSION_HEX ((VA_MAJOR_VERSION << 24) | \ - (VA_MINOR_VERSION << 16) | \ - (VA_MICRO_VERSION << 8)) - -/** - * VA_CHECK_VERSION: - * @major: major version, like 1 in 1.2.3 - * @minor: minor version, like 2 in 1.2.3 - * @micro: micro version, like 3 in 1.2.3 - * - * Evaluates to %TRUE if the version of the VA library is greater - * than @major, @minor and @micro - */ -#define VA_CHECK_VERSION(major,minor,micro) \ - (VA_MAJOR_VERSION > (major) || \ - (VA_MAJOR_VERSION == (major) && VA_MINOR_VERSION > (minor)) || \ - (VA_MAJOR_VERSION == (major) && VA_MINOR_VERSION == (minor) && VA_MICRO_VERSION >= (micro))) - -#endif /* VA_VERSION_H */ diff -Nru libva-0.31.0+latest2/.pc/321_libva_glx.base.patch/configure.ac libva-0.31.0+latest3/.pc/321_libva_glx.base.patch/configure.ac --- libva-0.31.0+latest2/.pc/321_libva_glx.base.patch/configure.ac 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/321_libva_glx.base.patch/configure.ac 1970-01-01 01:00:00.000000000 +0100 @@ -1,166 +0,0 @@ -# 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. - -# libva package version number, (as distinct from shared library version) -m4_define([libva_major_version], [0]) -m4_define([libva_minor_version], [31]) -m4_define([libva_micro_version], [0]) - -m4_define([libva_version], - [libva_major_version.libva_minor_version.libva_micro_version]) - -# increase this number for each API change -m4_define([libva_sds_version], [6]) - -# if the library source code has changed, increment revision -m4_define([libva_lt_revision], [1]) -# if any interface was added/removed/changed, then inc current, reset revision -m4_define([libva_lt_current], [1]) -# if any interface was added since last public release, then increment age -# if any interface was removed since last public release, then set age to 0 -m4_define([libva_lt_age], [0]) - -AC_PREREQ(2.57) -AC_INIT([libva], [libva_version], [waldo.bastian@intel.com], libva) -AC_CONFIG_SRCDIR([Makefile.am]) -AM_INIT_AUTOMAKE([dist-bzip2]) - -AM_CONFIG_HEADER([config.h]) - -LIBVA_MAJOR_VERSION=libva_major_version -LIBVA_MINOR_VERSION=libva_minor_version -LIBVA_MICRO_VERSION=libva_micro_version -LIBVA_VERSION=libva_version -AC_SUBST(LIBVA_MAJOR_VERSION) -AC_SUBST(LIBVA_MINOR_VERSION) -AC_SUBST(LIBVA_MICRO_VERSION) -AC_SUBST(LIBVA_VERSION) - -LIBVA_SDS_VERSION=libva_sds_version -AC_SUBST(LIBVA_SDS_VERSION) - -LIBVA_LT_CURRENT=libva_lt_current -LIBVA_LT_REV=libva_lt_revision -LIBVA_LT_AGE=libva_lt_age -LIBVA_LT_VERSION="$LIBVA_LT_CURRENT:$LIBVA_LT_REV:$LIBVA_LT_AGE" -LIBVA_LT_LDFLAGS="-version-info $LIBVA_LT_VERSION -release $LIBVA_VERSION.$LIBVA_SDS_VERSION" -AC_SUBST(LIBVA_LT_VERSION) -AC_SUBST(LIBVA_LT_LDFLAGS) - -AC_ARG_ENABLE(dummy-driver, - [AC_HELP_STRING([--enable-dummy-driver], - [build dummy video driver])], - [], [enable_dummy_driver=yes]) -AM_CONDITIONAL(BUILD_DUMMY_DRIVER, test x$enable_dummy_driver = xyes) - -AC_ARG_ENABLE(i965-driver, - [AC_HELP_STRING([--enable-i965-driver], - [build i965 video driver])], - [], [enable_i965_driver=no]) - -AC_ARG_WITH(drivers-path, - [AC_HELP_STRING([--with-drivers-path=[[path]]], [drivers path])],, - [with_drivers_path="$libdir/va/drivers"]) - -LIBVA_DRIVERS_PATH="$with_drivers_path" -AC_SUBST(LIBVA_DRIVERS_PATH) - -AC_DISABLE_STATIC -AC_PROG_LIBTOOL -AC_PROG_CC - -AC_HEADER_STDC -AC_SYS_LARGEFILE - -PKG_CHECK_MODULES([X11], [x11]) -PKG_CHECK_MODULES([XEXT],[xext]) -PKG_CHECK_MODULES([XFIXES], [xfixes]) -PKG_CHECK_MODULES([DRM], [libdrm]) - -PKG_CHECK_MODULES(GEN4ASM, [intel-gen4asm >= 1.0], [gen4asm=yes], [gen4asm=no]) -AM_CONDITIONAL(HAVE_GEN4ASM, test x$gen4asm = xyes) - -# Check for libdrm >= 2.4 (needed for i965_drv_video.so) -if test x$enable_i965_driver = xyes && ! $PKG_CONFIG --atleast-version=2.4 libdrm; then - AC_MSG_WARN([libdrm < 2.4 found, disabling build of i965 video driver]) - enable_i965_driver=no -fi -AM_CONDITIONAL(BUILD_I965_DRIVER, test x$enable_i965_driver = xyes) - -dnl Check for __attribute__((visibility())) -AC_CACHE_CHECK([whether __attribute__((visibility())) is supported], - libva_cv_visibility_attribute, - [cat > conftest.c </dev/null 2>&1; then - if grep '\.hidden.*foo' conftest.s >/dev/null; then - if grep '\.protected.*bar' conftest.s >/dev/null; then - libva_cv_visibility_attribute=yes - fi - fi - fi - rm -f conftest.[cs] -]) -ATTRIBUTE_HIDDEN="" -if test $libva_cv_visibility_attribute = yes; then - ATTRIBUTE_HIDDEN="__attribute__((visibility(\"hidden\")))" -fi -AC_DEFINE_UNQUOTED([ATTRIBUTE_HIDDEN], [$ATTRIBUTE_HIDDEN], - [Defined to __attribute__((visibility("hidden"))) when available]) - -# We only need the headers, we don't link against the DRM libraries -LIBVA_CFLAGS="$DRM_CFLAGS" -AC_SUBST(LIBVA_CFLAGS) -AC_SUBST(LIBVA_LIBS) - -pkgconfigdir=${libdir}/pkgconfig -AC_SUBST(pkgconfigdir) - -LIBVA_DISPLAY=x11 -libvacorelib=libva.la -libvabackendlib=libva-$LIBVA_DISPLAY.la -AC_SUBST([libvacorelib]) -AC_SUBST([libvabackendlib]) - -AC_OUTPUT([ - Makefile - va/Makefile - va/va_version.h - va/x11/Makefile - dummy_drv_video/Makefile - i965_drv_video/Makefile - i965_drv_video/shaders/Makefile - i965_drv_video/shaders/mpeg2/Makefile - i965_drv_video/shaders/mpeg2/vld/Makefile - i965_drv_video/shaders/render/Makefile - test/Makefile - test/basic/Makefile - test/decode/Makefile - test/putsurface/Makefile - test/encode/Makefile - libva.pc - libva-x11.pc -]) - diff -Nru libva-0.31.0+latest2/.pc/321_libva_glx.base.patch/Makefile.am libva-0.31.0+latest3/.pc/321_libva_glx.base.patch/Makefile.am --- libva-0.31.0+latest2/.pc/321_libva_glx.base.patch/Makefile.am 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/321_libva_glx.base.patch/Makefile.am 1970-01-01 01:00:00.000000000 +0100 @@ -1,41 +0,0 @@ -# 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. - -AUTOMAKE_OPTIONS = foreign - -SUBDIRS = va test -if BUILD_DUMMY_DRIVER -SUBDIRS += dummy_drv_video -endif -if BUILD_I965_DRIVER -SUBDIRS += i965_drv_video -endif - -pcfiles = libva.pc -pcfiles += libva-x11.pc - -pkgconfigdir = @pkgconfigdir@ -pkgconfig_DATA = $(pcfiles) - -EXTRA_DIST = libva.pc.in libva-x11.pc.in - -CLEANFILES = $(pcfiles) diff -Nru libva-0.31.0+latest2/.pc/321_libva_glx.base.patch/va/Makefile.am libva-0.31.0+latest3/.pc/321_libva_glx.base.patch/va/Makefile.am --- libva-0.31.0+latest2/.pc/321_libva_glx.base.patch/va/Makefile.am 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/321_libva_glx.base.patch/va/Makefile.am 1970-01-01 01:00:00.000000000 +0100 @@ -1,55 +0,0 @@ -# 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)/va/x11 \ - -DVA_DRIVERS_PATH="\"$(LIBVA_DRIVERS_PATH)\"" - -LDADD = \ - $(LIBVA_LT_LDFLAGS) - -lib_LTLIBRARIES = \ - libva.la \ - libva-x11.la - -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 - -SUBDIRS = x11 - -libva_la_SOURCES = va.c va_crystalhd.c - -libvaincludedir = ${includedir}/va -libvainclude_HEADERS = va.h va_x11.h va_backend.h va_version.h - -DISTCLEANFILES = \ - va_version.h - -EXTRA_DIST = \ - va_version.h.in \ - va_crystalhd.h diff -Nru libva-0.31.0+latest2/.pc/321_libva_glx.base.patch/va/va_backend.h libva-0.31.0+latest3/.pc/321_libva_glx.base.patch/va/va_backend.h --- libva-0.31.0+latest2/.pc/321_libva_glx.base.patch/va/va_backend.h 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/321_libva_glx.base.patch/va/va_backend.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,419 +0,0 @@ -/* - * 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_ - -#include -#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 - ); -}; - -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; -}; - -#define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */ -struct VADisplayContext -{ - int vadpy_magic; - - VADisplayContextP pNext; - VADriverContextP pDriverContext; - - int (*vaIsValid) ( - VADisplayContextP ctx - ); - - void (*vaDestroy) ( - VADisplayContextP ctx - ); - - VAStatus (*vaGetDriverName) ( - VADisplayContextP ctx, - char **driver_name - ); -}; - -typedef VAStatus (*VADriverInit) ( - VADriverContextP driver_context -); - - -#endif /* _VA_BACKEND_H_ */ diff -Nru libva-0.31.0+latest2/.pc/321_libva_glx.base.patch/va/x11/va_x11.c libva-0.31.0+latest3/.pc/321_libva_glx.base.patch/va/x11/va_x11.c --- libva-0.31.0+latest2/.pc/321_libva_glx.base.patch/va/x11/va_x11.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/321_libva_glx.base.patch/va/x11/va_x11.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,236 +0,0 @@ -/* - * 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 -#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; - - if (driver_name) - *driver_name = NULL; - - 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) - { - pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC; - - 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 -Nru libva-0.31.0+latest2/.pc/390_compat.base.patch/va/Makefile.am libva-0.31.0+latest3/.pc/390_compat.base.patch/va/Makefile.am --- libva-0.31.0+latest2/.pc/390_compat.base.patch/va/Makefile.am 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/390_compat.base.patch/va/Makefile.am 1970-01-01 01:00:00.000000000 +0100 @@ -1,70 +0,0 @@ -# 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)/va/x11 \ - -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 va_crystalhd.c - -libvaincludedir = ${includedir}/va -libvainclude_HEADERS = va.h va_x11.h va_backend.h va_version.h - -DISTCLEANFILES = \ - va_version.h - -EXTRA_DIST = \ - va_version.h.in \ - va_crystalhd.h diff -Nru libva-0.31.0+latest2/.pc/390_compat.base.patch/va/va_backend.h libva-0.31.0+latest3/.pc/390_compat.base.patch/va/va_backend.h --- libva-0.31.0+latest2/.pc/390_compat.base.patch/va/va_backend.h 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/390_compat.base.patch/va/va_backend.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,425 +0,0 @@ -/* - * 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_ - -#include -#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 */ -}; - -#define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */ -struct VADisplayContext -{ - int vadpy_magic; - - 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 -Nru libva-0.31.0+latest2/.pc/390_compat.base.patch/va/va.c libva-0.31.0+latest3/.pc/390_compat.base.patch/va/va.c --- libva-0.31.0+latest2/.pc/390_compat.base.patch/va/va.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/390_compat.base.patch/va/va.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,1290 +0,0 @@ -/* - * 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_crystalhd.h" - -#include -#include -#include -#include -#include -#include -#include - - -#define DRIVER_INIT_FUNC "__vaDriverInit_0_31" - -#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->vadpy_magic == VA_DISPLAY_MAGIC) && 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; - char driver_init_func_sds[32]; - /* First, try SDS extensions (VDPAU and XvBA backends) */ - sprintf(driver_init_func_sds, "%s_%d_sds%d", - DRIVER_INIT_FUNC, VA_MICRO_VERSION, VA_SDS_VERSION); - init_func = (VADriverInit) dlsym(handle, driver_init_func_sds); - if (!init_func) - { - init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC); - } - 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 */ -) -{ - const char *driver_name_env = NULL; - 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); - - driver_name_env = getenv("LIBVA_DRIVER_NAME"); - if (driver_name_env && geteuid() == getuid()) - { - /* Don't allow setuid apps to use LIBVA_DRIVER_NAME */ - driver_name = strdup(driver_name_env); - vaStatus = VA_STATUS_SUCCESS; - va_infoMessage("User requested driver '%s'\n", driver_name); - } - else - { - 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); - - if (vaStatus != VA_STATUS_SUCCESS && !driver_name_env) - { - if (va_hasCrystalHD()) - { - vaStatus = va_openDriver(dpy, "crystalhd"); - 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 -Nru libva-0.31.0+latest2/.pc/392_compat.dso.patch/va/Makefile.am libva-0.31.0+latest3/.pc/392_compat.dso.patch/va/Makefile.am --- libva-0.31.0+latest2/.pc/392_compat.dso.patch/va/Makefile.am 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/392_compat.dso.patch/va/Makefile.am 1970-01-01 01:00:00.000000000 +0100 @@ -1,74 +0,0 @@ -# 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)/va/x11 \ - -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 va_crystalhd.c va_compat.c - -libvaincludedir = ${includedir}/va -libvainclude_HEADERS = va.h va_x11.h va_backend.h va_version.h - -DISTCLEANFILES = \ - va_version.h - -EXTRA_DIST = \ - va_version.h.in \ - va_crystalhd.h \ - va_compat.h \ - va_compat_template.h - -va_compat.c: va_compat_template.h diff -Nru libva-0.31.0+latest2/.pc/applied-patches libva-0.31.0+latest3/.pc/applied-patches --- libva-0.31.0+latest2/.pc/applied-patches 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/applied-patches 1970-01-01 01:00:00.000000000 +0100 @@ -1,23 +0,0 @@ -032_g45_fix_subpic_formats.patch -033_g45_add_rgba_subpic.patch -034_g45_fix_return_for_unimpl.patch -035_g45_add_yv12_image_format.patch -036_g45_add_vaGetImage.patch -037_g45_add_vaPutImage.patch -038_g45_vaPutSurface_cliprects.patch -039_g45_add_vaDeriveImage.patch -102_attribute_visibility.patch -103_fix_vainfo_deps.patch -104_fix_libva_pkgconfig_deps.patch -105_dont_search_LIBGL_DRIVERS_PATH.patch -108_drivers_path.patch -201_libva_LIBVA_DRIVER_NAME.patch -202_check_crystalhd.patch -203_fix_fglrx_detection.patch -204_check_ATIFGLEXTENSION.patch -300_sds_version.patch -321_libva_glx.base.patch -322_libva_glx.patch -390_compat.base.patch -391_compat.patch -392_compat.dso.patch diff -Nru libva-0.31.0+latest2/.pc/.version libva-0.31.0+latest3/.pc/.version --- libva-0.31.0+latest2/.pc/.version 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/.pc/.version 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ -2 diff -Nru libva-0.31.0+latest2/test/Makefile.am libva-0.31.0+latest3/test/Makefile.am --- libva-0.31.0+latest2/test/Makefile.am 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/test/Makefile.am 2010-03-18 08:39:37.000000000 +0000 @@ -25,8 +25,9 @@ AM_CFLAGS = -I$(top_srcdir)/va -I$(top_srcdir)/test/basic -I$(top_srcdir)/src/x11 -vainfo_LDADD = $(top_srcdir)/va/libva.la $(top_srcdir)/va/$(libvabackendlib) -vainfo_DEPENDENCIES = $(top_srcdir)/va/libva.la $(top_srcdir)/va/$(libvabackendlib) + +vainfo_LDADD = $(top_srcdir)/va/$(libvabackendlib) +vainfo_DEPENDENCIES = $(top_srcdir)/va/$(libvabackendlib) vainfo_SOURCES = vainfo.c SUBDIRS = basic decode encode putsurface diff -Nru libva-0.31.0+latest2/va/glx/Makefile.am libva-0.31.0+latest3/va/glx/Makefile.am --- libva-0.31.0+latest2/va/glx/Makefile.am 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/va/glx/Makefile.am 1970-01-01 01:00:00.000000000 +0100 @@ -1,41 +0,0 @@ -# Copyright (C) 2009 Splitted-Desktop Systems. 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. - -AM_CFLAGS = -DLINUX -I$(top_srcdir)/va -I$(top_srcdir)/va/x11 - -source_c = \ - va_glx.c \ - va_glx_impl.c - -source_h = \ - va_glx.h \ - va_backend_glx.h - -source_h_priv = \ - va_glx_impl.h \ - va_glx_private.h - -noinst_LTLIBRARIES = libva_glx.la -libva_glxincludedir = ${includedir}/va -libva_glxinclude_HEADERS = $(source_h) -libva_glx_la_SOURCES = $(source_c) -noinst_HEADERS = $(source_h_priv) diff -Nru libva-0.31.0+latest2/va/glx/va_backend_glx.h libva-0.31.0+latest3/va/glx/va_backend_glx.h --- libva-0.31.0+latest2/va/glx/va_backend_glx.h 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/va/glx/va_backend_glx.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2009 Splitted-Desktop Systems. 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. - */ - -#ifndef VA_BACKEND_GLX_H -#define VA_BACKEND_GLX_H - -struct VADriverContext; - -struct VADriverVTableGLX { - /* Optional: create a surface used for display to OpenGL */ - VAStatus (*vaCreateSurfaceGLX)( - struct VADriverContext *ctx, - unsigned int gl_target, - unsigned int gl_texture, - void **gl_surface - ); - - /* Optional: destroy a VA/GLX surface */ - VAStatus (*vaDestroySurfaceGLX)( - struct VADriverContext *ctx, - void *gl_surface - ); - - /* Optional: copy a VA surface to a VA/GLX surface */ - VAStatus (*vaCopySurfaceGLX)( - struct VADriverContext *ctx, - void *gl_surface, - VASurfaceID surface, - unsigned int flags - ); -}; - -#endif /* VA_BACKEND_GLX_H */ diff -Nru libva-0.31.0+latest2/va/glx/va_glx.c libva-0.31.0+latest3/va/glx/va_glx.c --- libva-0.31.0+latest2/va/glx/va_glx.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/va/glx/va_glx.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,202 +0,0 @@ -/* - * Copyright (C) 2009 Splitted-Desktop Systems. 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. - */ - -#include -#include "va_glx_private.h" -#include "va_glx_impl.h" - -#define INIT_CONTEXT(ctx, dpy) do { \ - if (!vaDisplayIsValid(dpy)) \ - return VA_STATUS_ERROR_INVALID_DISPLAY; \ - \ - ctx = ((VADisplayContextP)(dpy))->pDriverContext; \ - if (!(ctx)) \ - return VA_STATUS_ERROR_INVALID_DISPLAY; \ - \ - VAStatus status = va_glx_init_context(ctx); \ - if (status != VA_STATUS_SUCCESS) \ - return status; \ - } while (0) - -#define INIT_SURFACE(surface, surface_arg) do { \ - surface = (VASurfaceGLXP)(surface_arg); \ - if (!vaSurfaceIsValid(surface)) \ - return VA_STATUS_ERROR_INVALID_SURFACE; \ - } while (0) - -#define INVOKE(ctx, func, args) do { \ - VADriverVTableGLXP vtable; \ - vtable = &VA_DRIVER_CONTEXT_GLX(ctx)->vtable; \ - if (!vtable->va##func##GLX) \ - return VA_STATUS_ERROR_UNIMPLEMENTED; \ - status = vtable->va##func##GLX args; \ - } while (0) - -// Check VADisplay is valid -static inline int vaDisplayIsValid(VADisplay dpy) -{ - VADisplayContextP pDisplayContext = (VADisplayContextP)dpy; - - return (pDisplayContext && - pDisplayContext->vaIsValid && - pDisplayContext->vaIsValid(pDisplayContext)); -} - -// Check VASurfaceGLX is valid -static inline int vaSurfaceIsValid(VASurfaceGLXP pSurfaceGLX) -{ - return pSurfaceGLX && pSurfaceGLX->magic == VA_SURFACE_GLX_MAGIC; -} - -// Destroy VA/GLX display context -static void va_DisplayContextDestroy(VADisplayContextP pDisplayContext) -{ - VADisplayContextGLXP pDisplayContextGLX; - VADriverContextP pDriverContext; - VADriverContextGLXP pDriverContextGLX; - - if (!pDisplayContext) - return; - - pDriverContext = pDisplayContext->pDriverContext; - pDriverContextGLX = pDriverContext->glx; - if (pDriverContextGLX) { - free(pDriverContextGLX); - pDriverContext->glx = NULL; - } - - pDisplayContextGLX = pDisplayContext->opaque; - if (pDisplayContextGLX) { - vaDestroyFunc vaDestroy = pDisplayContextGLX->vaDestroy; - free(pDisplayContextGLX); - pDisplayContext->opaque = NULL; - if (vaDestroy) - vaDestroy(pDisplayContext); - } -} - -// Return a suitable VADisplay for VA API -VADisplay vaGetDisplayGLX(Display *native_dpy) -{ - VADisplay dpy = NULL; - VADisplayContextP pDisplayContext = NULL; - VADisplayContextGLXP pDisplayContextGLX = NULL; - VADriverContextP pDriverContext; - VADriverContextGLXP pDriverContextGLX = NULL; - - dpy = vaGetDisplay(native_dpy); - if (!dpy) - return NULL; - pDisplayContext = (VADisplayContextP)dpy; - pDriverContext = pDisplayContext->pDriverContext; - - pDisplayContextGLX = calloc(1, sizeof(*pDisplayContextGLX)); - if (!pDisplayContextGLX) - goto error; - - pDriverContextGLX = calloc(1, sizeof(*pDriverContextGLX)); - if (!pDriverContextGLX) - goto error; - - pDisplayContextGLX->vaDestroy = pDisplayContext->vaDestroy; - pDisplayContext->vaDestroy = va_DisplayContextDestroy; - pDisplayContext->opaque = pDisplayContextGLX; - pDriverContext->glx = pDriverContextGLX; - return dpy; - -error: - free(pDriverContextGLX); - free(pDisplayContextGLX); - pDisplayContext->vaDestroy(pDisplayContext); - return NULL; -} - -// Create a surface used for display to OpenGL -VAStatus vaCreateSurfaceGLX( - VADisplay dpy, - GLenum target, - GLuint texture, - void **gl_surface -) -{ - VADriverContextP ctx; - VASurfaceGLXP pSurfaceGLX; - VAStatus status; - - /* Make sure it is a valid GL texture object */ - if (!glIsTexture(texture)) - return VA_STATUS_ERROR_INVALID_PARAMETER; - - INIT_CONTEXT(ctx, dpy); - - pSurfaceGLX = va_glx_create_surface(ctx, target, texture); - if (!pSurfaceGLX) - return VA_STATUS_ERROR_ALLOCATION_FAILED; - - INVOKE(ctx, CreateSurface, (ctx, target, texture, &pSurfaceGLX->priv)); - - if (status != VA_STATUS_SUCCESS) - va_glx_destroy_surface(ctx, &pSurfaceGLX); - - *gl_surface = pSurfaceGLX; - return status; -} - -// Destroy a VA/GLX surface -VAStatus vaDestroySurfaceGLX( - VADisplay dpy, - void *gl_surface -) -{ - VADriverContextP ctx; - VASurfaceGLXP pSurfaceGLX; - VAStatus status; - - INIT_CONTEXT(ctx, dpy); - INIT_SURFACE(pSurfaceGLX, gl_surface); - - INVOKE(ctx, DestroySurface, (ctx, pSurfaceGLX)); - - free(pSurfaceGLX); - return status; -} - -// Copy a VA surface to a VA/GLX surface -VAStatus vaCopySurfaceGLX( - VADisplay dpy, - void *gl_surface, - VASurfaceID surface, - unsigned int flags -) -{ - VADriverContextP ctx; - VASurfaceGLXP pSurfaceGLX; - VAStatus status; - - INIT_CONTEXT(ctx, dpy); - INIT_SURFACE(pSurfaceGLX, gl_surface); - - INVOKE(ctx, CopySurface, (ctx, pSurfaceGLX, surface, flags)); - return status; -} diff -Nru libva-0.31.0+latest2/va/glx/va_glx.h libva-0.31.0+latest3/va/glx/va_glx.h --- libva-0.31.0+latest2/va/glx/va_glx.h 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/va/glx/va_glx.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2009 Splitted-Desktop Systems. 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. - */ - -#ifndef VA_GLX_H -#define VA_GLX_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Return a suitable VADisplay for VA API - * - * @param[in] dpy the X11 display - * @return a VADisplay - */ -VADisplay vaGetDisplayGLX( - Display *dpy -); - -/** - * Create a surface used for display to OpenGL - * - * The application shall maintain the live GLX context itself. - * Implementations are free to use glXGetCurrentContext() and - * glXGetCurrentDrawable() functions for internal purposes. - * - * @param[in] dpy the VA display - * @param[in] target the GL target to which the texture needs to be bound - * @param[in] texture the GL texture - * @param[out] gl_surface the VA/GLX surface - * @return VA_STATUS_SUCCESS if successful - */ -VAStatus vaCreateSurfaceGLX( - VADisplay dpy, - GLenum target, - GLuint texture, - void **gl_surface -); - -/** - * Destroy a VA/GLX surface - * - * The application shall maintain the live GLX context itself. - * Implementations are free to use glXGetCurrentContext() and - * glXGetCurrentDrawable() functions for internal purposes. - * - * @param[in] dpy the VA display - * @param[in] gl_surface the VA surface - * @return VA_STATUS_SUCCESS if successful - */ -VAStatus vaDestroySurfaceGLX( - VADisplay dpy, - void *gl_surface -); - -/** - * Copy a VA surface to a VA/GLX surface - * - * This function will not return until the copy is completed. At this - * point, the underlying GL texture will contain the surface pixels - * in an RGB format defined by the user. - * - * The application shall maintain the live GLX context itself. - * Implementations are free to use glXGetCurrentContext() and - * glXGetCurrentDrawable() functions for internal purposes. - * - * @param[in] dpy the VA display - * @param[in] gl_surface the VA/GLX destination surface - * @param[in] surface the VA source surface - * @param[in] flags the PutSurface flags - * @return VA_STATUS_SUCCESS if successful - */ -VAStatus vaCopySurfaceGLX( - VADisplay dpy, - void *gl_surface, - VASurfaceID surface, - unsigned int flags -); - -#ifdef __cplusplus -} -#endif - -#endif /* VA_GLX_H */ diff -Nru libva-0.31.0+latest2/va/glx/va_glx_impl.c libva-0.31.0+latest3/va/glx/va_glx_impl.c --- libva-0.31.0+latest2/va/glx/va_glx_impl.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/va/glx/va_glx_impl.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,1013 +0,0 @@ -/* - * Copyright (C) 2009 Splitted-Desktop Systems. 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_glx_private.h" -#include "va_glx_impl.h" -#include -#include -#include -#include -#include -#include - -static void va_glx_error_message(const char *format, ...) -{ - va_list args; - va_start(args, format); - fprintf(stderr, "[%s] ", PACKAGE_NAME); - vfprintf(stderr, format, args); - va_end(args); -} - -// X error trap -static int x11_error_code = 0; -static int (*old_error_handler)(Display *, XErrorEvent *); - -static int error_handler(Display *dpy, XErrorEvent *error) -{ - x11_error_code = error->error_code; - return 0; -} - -static void x11_trap_errors(void) -{ - x11_error_code = 0; - old_error_handler = XSetErrorHandler(error_handler); -} - -static int x11_untrap_errors(void) -{ - XSetErrorHandler(old_error_handler); - return x11_error_code; -} - -// Returns a string representation of an OpenGL error -static const char *gl_get_error_string(GLenum error) -{ - static const struct { - GLenum val; - const char *str; - } - gl_errors[] = { - { GL_NO_ERROR, "no error" }, - { GL_INVALID_ENUM, "invalid enumerant" }, - { GL_INVALID_VALUE, "invalid value" }, - { GL_INVALID_OPERATION, "invalid operation" }, - { GL_STACK_OVERFLOW, "stack overflow" }, - { GL_STACK_UNDERFLOW, "stack underflow" }, - { GL_OUT_OF_MEMORY, "out of memory" }, -#ifdef GL_INVALID_FRAMEBUFFER_OPERATION_EXT - { GL_INVALID_FRAMEBUFFER_OPERATION_EXT, "invalid framebuffer operation" }, -#endif - { ~0, NULL } - }; - - int i; - for (i = 0; gl_errors[i].str; i++) { - if (gl_errors[i].val == error) - return gl_errors[i].str; - } - return "unknown"; -} - -static inline int gl_do_check_error(int report) -{ - GLenum error; - int is_error = 0; - while ((error = glGetError()) != GL_NO_ERROR) { - if (report) - va_glx_error_message("glError: %s caught\n", - gl_get_error_string(error)); - is_error = 1; - } - return is_error; -} - -static inline void gl_purge_errors(void) -{ - gl_do_check_error(0); -} - -static inline int gl_check_error(void) -{ - return gl_do_check_error(1); -} - -// glGetFloatv() wrapper -static int gl_get_current_color(float color[4]) -{ - gl_purge_errors(); - glGetFloatv(GL_CURRENT_COLOR, color); - if (gl_check_error()) - return -1; - return 0; -} - -// glGetIntegerv() wrapper -static int gl_get_param(GLenum param, unsigned int *pval) -{ - GLint val; - - gl_purge_errors(); - glGetIntegerv(param, &val); - if (gl_check_error()) - return -1; - if (pval) - *pval = val; - return 0; -} - -// glGetTexLevelParameteriv() wrapper -static int gl_get_texture_param(GLenum param, unsigned int *pval) -{ - GLint val; - - gl_purge_errors(); - glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, param, &val); - if (gl_check_error()) - return -1; - if (pval) - *pval = val; - return 0; -} - -// Returns the OpenGL VTable -static inline VAOpenGLVTableP gl_get_vtable(VADriverContextP ctx) -{ - return &VA_DRIVER_CONTEXT_GLX(ctx)->gl_vtable; -} - -// Lookup for a GLX function -typedef void (*GLFuncPtr)(void); -typedef GLFuncPtr (*GLXGetProcAddressProc)(const char *); - -static GLFuncPtr get_proc_address_default(const char *name) -{ - return NULL; -} - -static GLXGetProcAddressProc get_proc_address_func(void) -{ - GLXGetProcAddressProc get_proc_func; - - dlerror(); - get_proc_func = (GLXGetProcAddressProc) - dlsym(RTLD_DEFAULT, "glXGetProcAddress"); - if (dlerror() == NULL) - return get_proc_func; - - get_proc_func = (GLXGetProcAddressProc) - dlsym(RTLD_DEFAULT, "glXGetProcAddressARB"); - if (dlerror() == NULL) - return get_proc_func; - - return get_proc_address_default; -} - -static inline GLFuncPtr get_proc_address(const char *name) -{ - static GLXGetProcAddressProc get_proc_func = NULL; - if (get_proc_func == NULL) - get_proc_func = get_proc_address_func(); - return get_proc_func(name); -} - -// Check for GLX extensions (TFP, FBO) -static int check_extension(const char *name, const char *ext) -{ - const char *end; - int name_len, n; - - if (name == NULL || ext == NULL) - return 0; - - end = ext + strlen(ext); - name_len = strlen(name); - while (ext < end) { - n = strcspn(ext, " "); - if (n == name_len && strncmp(name, ext, n) == 0) - return 1; - ext += (n + 1); - } - return 0; -} - -static int check_tfp_extensions(VADriverContextP ctx) -{ - const char *gl_extensions; - const char *glx_extensions; - - gl_extensions = (const char *)glGetString(GL_EXTENSIONS); - if (!check_extension("GL_ARB_texture_non_power_of_two", gl_extensions)) - return 0; - - glx_extensions = glXQueryExtensionsString(ctx->x11_dpy, ctx->x11_screen); - if (!check_extension("GLX_EXT_texture_from_pixmap", glx_extensions)) - return 0; - return 1; -} - -static int check_fbo_extensions(VADriverContextP ctx) -{ - const char *gl_extensions; - - gl_extensions = (const char *)glGetString(GL_EXTENSIONS); - if (check_extension("GL_ARB_framebuffer_object", gl_extensions)) - return 1; - if (check_extension("GL_EXT_framebuffer_object", gl_extensions)) - return 1; - return 0; -} - -// Load GLX extensions -static int load_tfp_extensions(VADriverContextP ctx) -{ - VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); - - pOpenGLVTable->glx_bind_tex_image = (PFNGLXBINDTEXIMAGEEXTPROC) - get_proc_address("glXBindTexImageEXT"); - if (pOpenGLVTable->glx_bind_tex_image == NULL) - return 0; - pOpenGLVTable->glx_release_tex_image = (PFNGLXRELEASETEXIMAGEEXTPROC) - get_proc_address("glXReleaseTexImageEXT"); - if (pOpenGLVTable->glx_release_tex_image == NULL) - return 0; - return 1; -} - -static int load_fbo_extensions(VADriverContextP ctx) -{ - VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); - - pOpenGLVTable->gl_gen_framebuffers = (PFNGLGENFRAMEBUFFERSEXTPROC) - get_proc_address("glGenFramebuffersEXT"); - if (pOpenGLVTable->gl_gen_framebuffers == NULL) - return 0; - pOpenGLVTable->gl_delete_framebuffers = (PFNGLDELETEFRAMEBUFFERSEXTPROC) - get_proc_address("glDeleteFramebuffersEXT"); - if (pOpenGLVTable->gl_delete_framebuffers == NULL) - return 0; - pOpenGLVTable->gl_bind_framebuffer = (PFNGLBINDFRAMEBUFFEREXTPROC) - get_proc_address("glBindFramebufferEXT"); - if (pOpenGLVTable->gl_bind_framebuffer == NULL) - return 0; - pOpenGLVTable->gl_gen_renderbuffers = (PFNGLGENRENDERBUFFERSEXTPROC) - get_proc_address("glGenRenderbuffersEXT"); - if (pOpenGLVTable->gl_gen_renderbuffers == NULL) - return 0; - pOpenGLVTable->gl_delete_renderbuffers = (PFNGLDELETERENDERBUFFERSEXTPROC) - get_proc_address("glDeleteRenderbuffersEXT"); - if (pOpenGLVTable->gl_delete_renderbuffers == NULL) - return 0; - pOpenGLVTable->gl_bind_renderbuffer = (PFNGLBINDRENDERBUFFEREXTPROC) - get_proc_address("glBindRenderbufferEXT"); - if (pOpenGLVTable->gl_bind_renderbuffer == NULL) - return 0; - pOpenGLVTable->gl_renderbuffer_storage = (PFNGLRENDERBUFFERSTORAGEEXTPROC) - get_proc_address("glRenderbufferStorageEXT"); - if (pOpenGLVTable->gl_renderbuffer_storage == NULL) - return 0; - pOpenGLVTable->gl_framebuffer_renderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) - get_proc_address("glFramebufferRenderbufferEXT"); - if (pOpenGLVTable->gl_framebuffer_renderbuffer == NULL) - return 0; - pOpenGLVTable->gl_framebuffer_texture_2d = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) - get_proc_address("glFramebufferTexture2DEXT"); - if (pOpenGLVTable->gl_framebuffer_texture_2d == NULL) - return 0; - pOpenGLVTable->gl_check_framebuffer_status = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) - get_proc_address("glCheckFramebufferStatusEXT"); - if (pOpenGLVTable->gl_check_framebuffer_status == NULL) - return 0; - return 1; -} - - -/* ========================================================================= */ -/* === VA/GLX helpers === */ -/* ========================================================================= */ - -// OpenGL texture state -typedef struct OpenGLTextureState *OpenGLTextureStateP; - -struct OpenGLTextureState { - int was_enabled; - int was_bound; - GLenum target; - GLuint old_texture; -}; - -// Bind texture, preserve previous texture state -static int bind_texture(OpenGLTextureStateP ts, GLenum target, GLuint texture) -{ - ts->target = target; - ts->old_texture = 0; - ts->was_bound = 0; - ts->was_enabled = glIsEnabled(target); - if (!ts->was_enabled) - glEnable(target); - - GLenum texture_binding; - switch (target) { - case GL_TEXTURE_1D: - texture_binding = GL_TEXTURE_BINDING_1D; - break; - case GL_TEXTURE_2D: - texture_binding = GL_TEXTURE_BINDING_2D; - break; - case GL_TEXTURE_3D: - texture_binding = GL_TEXTURE_BINDING_3D; - break; - case GL_TEXTURE_RECTANGLE_ARB: - texture_binding = GL_TEXTURE_BINDING_RECTANGLE_ARB; - break; - default: - assert(!target); - return -1; - } - - if (ts->was_enabled && gl_get_param(texture_binding, &ts->old_texture) < 0) - return -1; - - ts->was_bound = texture == ts->old_texture; - if (!ts->was_bound) { - gl_purge_errors(); - glBindTexture(target, texture); - if (gl_check_error()) - return -1; - } - return 0; -} - -// Unbind texture, restore previous texture state -static void unbind_texture(OpenGLTextureStateP ts) -{ - if (!ts->was_bound && ts->old_texture) - glBindTexture(ts->target, ts->old_texture); - if (!ts->was_enabled) - glDisable(ts->target); -} - -// Create Pixmaps for GLX texture-from-pixmap extension -static int create_tfp_surface(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) -{ - const unsigned int width = pSurfaceGLX->width; - const unsigned int height = pSurfaceGLX->height; - Pixmap pixmap = None; - GLXFBConfig *fbconfig = NULL; - GLXPixmap glx_pixmap = None; - Window root_window; - XWindowAttributes wattr; - int *attrib; - int n_fbconfig_attribs, x, y, status; - unsigned int border_width, depth, dummy; - - root_window = RootWindow(ctx->x11_dpy, ctx->x11_screen); - XGetWindowAttributes(ctx->x11_dpy, root_window, &wattr); - pixmap = XCreatePixmap(ctx->x11_dpy, root_window, - width, height, wattr.depth); - if (!pixmap) - return -1; - pSurfaceGLX->pixmap = pixmap; - - x11_trap_errors(); - status = XGetGeometry(ctx->x11_dpy, - (Drawable)pixmap, - &root_window, - &x, - &y, - &dummy, - &dummy, - &border_width, - &depth); - if (x11_untrap_errors() != 0 || status == 0) - return -1; - if (depth != 24 && depth != 32) - return -1; - - int fbconfig_attribs[32] = { - GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT, - GLX_DOUBLEBUFFER, GL_TRUE, - GLX_RENDER_TYPE, GLX_RGBA_BIT, - GLX_X_RENDERABLE, GL_TRUE, - GLX_Y_INVERTED_EXT, GL_TRUE, - GLX_RED_SIZE, 8, - GLX_GREEN_SIZE, 8, - GLX_BLUE_SIZE, 8, - GL_NONE, - }; - for (attrib = fbconfig_attribs; *attrib != GL_NONE; attrib += 2) - ; - *attrib++ = GLX_DEPTH_SIZE; *attrib++ = depth; - if (depth == 32) { - *attrib++ = GLX_ALPHA_SIZE; *attrib++ = 8; - *attrib++ = GLX_BIND_TO_TEXTURE_RGBA_EXT; *attrib++ = GL_TRUE; - } - else { - *attrib++ = GLX_BIND_TO_TEXTURE_RGB_EXT; *attrib++ = GL_TRUE; - } - *attrib++ = GL_NONE; - - fbconfig = glXChooseFBConfig(ctx->x11_dpy, ctx->x11_screen, fbconfig_attribs, &n_fbconfig_attribs); - if (fbconfig == NULL) - return -1; - - int pixmap_attribs[10] = { - GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT, - GLX_MIPMAP_TEXTURE_EXT, GL_FALSE, - GL_NONE, - }; - for (attrib = pixmap_attribs; *attrib != GL_NONE; attrib += 2) - ; - *attrib++ = GLX_TEXTURE_FORMAT_EXT; - if (depth == 32) - *attrib++ = GLX_TEXTURE_FORMAT_RGBA_EXT; - else - *attrib++ = GLX_TEXTURE_FORMAT_RGB_EXT; - *attrib++ = GL_NONE; - - x11_trap_errors(); - glx_pixmap = glXCreatePixmap(ctx->x11_dpy, - fbconfig[0], - pixmap, - pixmap_attribs); - free(fbconfig); - if (x11_untrap_errors() != 0) - return -1; - pSurfaceGLX->glx_pixmap = glx_pixmap; - return 0; -} - -// Destroy Pixmaps used for TFP -static void destroy_tfp_surface(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) -{ - if (pSurfaceGLX->glx_pixmap) { - glXDestroyPixmap(ctx->x11_dpy, pSurfaceGLX->glx_pixmap); - pSurfaceGLX->glx_pixmap = None; - } - - if (pSurfaceGLX->pixmap) { - XFreePixmap(ctx->x11_dpy, pSurfaceGLX->pixmap); - pSurfaceGLX->pixmap = None; - } -} - -// Bind GLX Pixmap to texture -static int bind_pixmap(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) -{ - VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); - - if (pSurfaceGLX->is_bound) - return 0; - - x11_trap_errors(); - pOpenGLVTable->glx_bind_tex_image(ctx->x11_dpy, pSurfaceGLX->glx_pixmap, - GLX_FRONT_LEFT_EXT, NULL); - XSync(ctx->x11_dpy, False); - if (x11_untrap_errors() != 0) { - va_glx_error_message("failed to bind pixmap\n"); - return -1; - } - - pSurfaceGLX->is_bound = 1; - return 0; -} - -// Release GLX Pixmap from texture -static int unbind_pixmap(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) -{ - VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); - - if (!pSurfaceGLX->is_bound) - return 0; - - x11_trap_errors(); - pOpenGLVTable->glx_release_tex_image(ctx->x11_dpy, pSurfaceGLX->glx_pixmap, - GLX_FRONT_LEFT_EXT); - XSync(ctx->x11_dpy, False); - if (x11_untrap_errors() != 0) { - va_glx_error_message("failed to release pixmap\n"); - return -1; - } - - pSurfaceGLX->is_bound = 0; - return 0; -} - -// Render GLX Pixmap to texture -static void render_pixmap(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) -{ - const unsigned int w = pSurfaceGLX->width; - const unsigned int h = pSurfaceGLX->height; - float old_color[4]; - - gl_get_current_color(old_color); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glBegin(GL_QUADS); - { - glTexCoord2f(0.0f, 0.0f); glVertex2i(0, 0); - glTexCoord2f(0.0f, 1.0f); glVertex2i(0, h); - glTexCoord2f(1.0f, 1.0f); glVertex2i(w, h); - glTexCoord2f(1.0f, 0.0f); glVertex2i(w, 0); - } - glEnd(); - glColor4fv(old_color); -} - -// Create offscreen surface -static int create_fbo_surface(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) -{ - VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); - const GLenum texture = pSurfaceGLX->texture; - const unsigned int texture_width = pSurfaceGLX->width; - const unsigned int texture_height = pSurfaceGLX->height; - GLuint fbo, fbo_buffer, fbo_texture; - GLenum status; - - glGenTextures(1, &fbo_texture); - glBindTexture(GL_TEXTURE_2D, fbo_texture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture_width, texture_height, 0, - GL_BGRA, GL_UNSIGNED_BYTE, NULL); - - pOpenGLVTable->gl_gen_framebuffers(1, &fbo); - pOpenGLVTable->gl_bind_framebuffer(GL_FRAMEBUFFER_EXT, fbo); - pOpenGLVTable->gl_gen_renderbuffers(1, &fbo_buffer); - pOpenGLVTable->gl_bind_renderbuffer(GL_RENDERBUFFER_EXT, fbo_buffer); - - glBindTexture(GL_TEXTURE_2D, texture); - pOpenGLVTable->gl_framebuffer_texture_2d(GL_FRAMEBUFFER_EXT, - GL_COLOR_ATTACHMENT0_EXT, - GL_TEXTURE_2D, texture, 0); - - status = pOpenGLVTable->gl_check_framebuffer_status(GL_DRAW_FRAMEBUFFER_EXT); - pOpenGLVTable->gl_bind_framebuffer(GL_FRAMEBUFFER_EXT, 0); - if (status != GL_FRAMEBUFFER_COMPLETE_EXT) - return -1; - - pSurfaceGLX->fbo = fbo; - pSurfaceGLX->fbo_buffer = fbo_buffer; - pSurfaceGLX->fbo_texture = fbo_texture; - return 0; -} - -// Destroy offscreen surface -static void destroy_fbo_surface(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) -{ - VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); - - if (pSurfaceGLX->fbo_texture) { - glDeleteTextures(1, &pSurfaceGLX->fbo_texture); - pSurfaceGLX->fbo_texture = 0; - } - - if (pSurfaceGLX->fbo_buffer) { - pOpenGLVTable->gl_delete_renderbuffers(1, &pSurfaceGLX->fbo_buffer); - pSurfaceGLX->fbo_buffer = 0; - } - - if (pSurfaceGLX->fbo) { - pOpenGLVTable->gl_delete_framebuffers(1, &pSurfaceGLX->fbo); - pSurfaceGLX->fbo = 0; - } -} - -// Setup matrices to match the FBO texture dimensions -static void fbo_enter(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) -{ - VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); - const unsigned int width = pSurfaceGLX->width; - const unsigned int height = pSurfaceGLX->height; - - pOpenGLVTable->gl_bind_framebuffer(GL_FRAMEBUFFER_EXT, pSurfaceGLX->fbo); - glPushAttrib(GL_VIEWPORT_BIT); - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - glViewport(0, 0, width, height); - glTranslatef(-1.0f, -1.0f, 0.0f); - glScalef(2.0f / width, 2.0f / height, 1.0f); - - glBindTexture(GL_TEXTURE_2D, pSurfaceGLX->fbo_texture); -} - -// Restore original OpenGL matrices -static void fbo_leave(VADriverContextP ctx) -{ - VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); - - glPopAttrib(); - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - pOpenGLVTable->gl_bind_framebuffer(GL_FRAMEBUFFER_EXT, 0); -} - -// Create VA/GLX surface -VASurfaceGLXP -va_glx_create_surface(VADriverContextP ctx, GLenum target, GLuint texture) -{ - VADriverContextGLXP pDriverContextGLX = VA_DRIVER_CONTEXT_GLX(ctx); - VASurfaceGLXP pSurfaceGLX; - unsigned int internal_format, border_width, width, height; - int is_error = 1; - - /* Make sure binding succeeds, if texture was not already bound */ - struct OpenGLTextureState ts; - if (bind_texture(&ts, target, texture) < 0) - goto end; - - pSurfaceGLX = malloc(sizeof(*pSurfaceGLX)); - if (!pSurfaceGLX) - goto end; - - pSurfaceGLX->magic = VA_SURFACE_GLX_MAGIC; - pSurfaceGLX->target = target; - pSurfaceGLX->texture = texture; - pSurfaceGLX->surface = VA_INVALID_SURFACE; - pSurfaceGLX->is_bound = 0; - pSurfaceGLX->pixmap = None; - pSurfaceGLX->glx_pixmap = None; - pSurfaceGLX->fbo = 0; - pSurfaceGLX->fbo_buffer = 0; - pSurfaceGLX->fbo_texture = 0; - pSurfaceGLX->priv = NULL; - - /* XXX: we don't support other textures than RGBA */ - if (gl_get_texture_param(GL_TEXTURE_INTERNAL_FORMAT, &internal_format) < 0) - goto end; - if (internal_format != GL_RGBA) - goto end; - - /* Check texture dimensions */ - if (gl_get_texture_param(GL_TEXTURE_BORDER, &border_width) < 0) - goto end; - if (gl_get_texture_param(GL_TEXTURE_WIDTH, &width) < 0) - goto end; - if (gl_get_texture_param(GL_TEXTURE_HEIGHT, &height) < 0) - goto end; - - width -= 2 * border_width; - height -= 2 * border_width; - if (width == 0 || height == 0) - goto end; - - pSurfaceGLX->width = width; - pSurfaceGLX->height = height; - - /* Create Pixmaps for TFP */ - if (pDriverContextGLX->use_tfp) { - if (create_tfp_surface(ctx, pSurfaceGLX) < 0) - goto end; - } - - /* Create Pixmaps for FBO */ - if (pDriverContextGLX->use_fbo) { - if (create_fbo_surface(ctx, pSurfaceGLX) < 0) - goto end; - } - - is_error = 0; -end: - if (is_error && pSurfaceGLX) - va_glx_destroy_surface(ctx, &pSurfaceGLX); - - unbind_texture(&ts); - return pSurfaceGLX; -} - -// Destroy VA/GLX surface -void va_glx_destroy_surface(VADriverContextP ctx, VASurfaceGLXP *ppSurfaceGLX) -{ - VASurfaceGLXP pSurfaceGLX = *ppSurfaceGLX; - - unbind_pixmap(ctx, pSurfaceGLX); - destroy_fbo_surface(ctx, pSurfaceGLX); - destroy_tfp_surface(ctx, pSurfaceGLX); - - free(pSurfaceGLX); - *ppSurfaceGLX = NULL; -} - - -/* ========================================================================= */ -/* === VA/GLX implementation from the driver (fordward calls) === */ -/* ========================================================================= */ - -#define INVOKE(ctx, func, args) do { \ - VADriverVTableGLXP vtable = (ctx)->vtable.glx; \ - if (!vtable->va##func##GLX) \ - return VA_STATUS_ERROR_UNIMPLEMENTED; \ - \ - VAStatus status = vtable->va##func##GLX args; \ - if (status != VA_STATUS_SUCCESS) \ - return status; \ - } while (0) - -static VAStatus -vaCreateSurfaceGLX_impl_driver( - VADriverContextP ctx, - GLenum target, - GLuint texture, - void **gl_surface -) -{ - INVOKE(ctx, CreateSurface, (ctx, target, texture, gl_surface)); - return VA_STATUS_SUCCESS; -} - -static VAStatus -vaDestroySurfaceGLX_impl_driver(VADriverContextP ctx, void *gl_surface) -{ - VASurfaceGLXP pSurfaceGLX = gl_surface; - - INVOKE(ctx, DestroySurface, (ctx, pSurfaceGLX->priv)); - return VA_STATUS_SUCCESS; -} - -static VAStatus -vaCopySurfaceGLX_impl_driver( - VADriverContextP ctx, - void *gl_surface, - VASurfaceID surface, - unsigned int flags -) -{ - VASurfaceGLXP pSurfaceGLX = gl_surface; - - INVOKE(ctx, CopySurface, (ctx, pSurfaceGLX->priv, surface, flags)); - return VA_STATUS_SUCCESS; -} - -#undef INVOKE - - -/* ========================================================================= */ -/* === VA/GLX implementation from libVA (generic and suboptimal path) === */ -/* ========================================================================= */ - -static VAStatus -vaCreateSurfaceGLX_impl_libva( - VADriverContextP ctx, - GLenum target, - GLuint texture, - void **gl_surface -) -{ - VADriverContextGLXP pDriverContextGLX = VA_DRIVER_CONTEXT_GLX(ctx); - - if (!pDriverContextGLX->use_tfp) - return VA_STATUS_ERROR_UNIMPLEMENTED; - - *gl_surface = NULL; - return VA_STATUS_SUCCESS; -} - -static VAStatus -vaDestroySurfaceGLX_impl_libva(VADriverContextP ctx, void *gl_surface) -{ - VADriverContextGLXP pDriverContextGLX = VA_DRIVER_CONTEXT_GLX(ctx); - - if (!pDriverContextGLX->use_tfp) - return VA_STATUS_ERROR_UNIMPLEMENTED; - - return VA_STATUS_SUCCESS; -} - -static VAStatus -vaDeassociateSurfaceGLX_impl_libva(VADriverContextP ctx, void *gl_surface) -{ - VADriverContextGLXP pDriverContextGLX = VA_DRIVER_CONTEXT_GLX(ctx); - VASurfaceGLXP pSurfaceGLX = gl_surface; - - if (!pDriverContextGLX->use_tfp) - return VA_STATUS_ERROR_UNIMPLEMENTED; - - if (unbind_pixmap(ctx, pSurfaceGLX) < 0) - return VA_STATUS_ERROR_OPERATION_FAILED; - - pSurfaceGLX->surface = VA_INVALID_SURFACE; - return VA_STATUS_SUCCESS; -} - -static VAStatus -vaAssociateSurfaceGLX_impl_libva( - VADriverContextP ctx, - void *gl_surface, - VASurfaceID surface, - unsigned int flags -) -{ - VADriverContextGLXP pDriverContextGLX = VA_DRIVER_CONTEXT_GLX(ctx); - VASurfaceGLXP pSurfaceGLX = gl_surface; - VAStatus status; - - if (!pDriverContextGLX->use_tfp) - return VA_STATUS_ERROR_UNIMPLEMENTED; - - /* XXX: only support VA_FRAME_PICTURE */ - if (flags != VA_FRAME_PICTURE) - return VA_STATUS_ERROR_FLAG_NOT_SUPPORTED; - - /* XXX: optimise case where we are associating the same VA surface - as before an no changed occurred to it */ - status = vaDeassociateSurfaceGLX_impl_libva(ctx, gl_surface); - if (status != VA_STATUS_SUCCESS) - return status; - - x11_trap_errors(); - status = ctx->vtable.vaPutSurface(ctx, - surface, - pSurfaceGLX->pixmap, - 0, 0, - pSurfaceGLX->width, - pSurfaceGLX->height, - 0, 0, - pSurfaceGLX->width, - pSurfaceGLX->height, - NULL, 0, - flags); - XSync(ctx->x11_dpy, False); - if (x11_untrap_errors() != 0) - return VA_STATUS_ERROR_OPERATION_FAILED; - if (status != VA_STATUS_SUCCESS) - return status; - - pSurfaceGLX->surface = surface; - return VA_STATUS_SUCCESS; -} - -static VAStatus -vaSyncSurfaceGLX_impl_libva(VADriverContextP ctx, void *gl_surface) -{ - VADriverContextGLXP pDriverContextGLX = VA_DRIVER_CONTEXT_GLX(ctx); - VASurfaceGLXP pSurfaceGLX = gl_surface; - - if (!pDriverContextGLX->use_tfp) - return VA_STATUS_ERROR_UNIMPLEMENTED; - - if (pSurfaceGLX->surface == VA_INVALID_SURFACE) - return VA_STATUS_ERROR_INVALID_SURFACE; - - return ctx->vtable.vaSyncSurface(ctx, pSurfaceGLX->surface); -} - -static VAStatus -vaBeginRenderSurfaceGLX_impl_libva(VADriverContextP ctx, void *gl_surface) -{ - VADriverContextGLXP pDriverContextGLX = VA_DRIVER_CONTEXT_GLX(ctx); - VASurfaceGLXP pSurfaceGLX = gl_surface; - VAStatus status; - - if (!pDriverContextGLX->use_tfp) - return VA_STATUS_ERROR_UNIMPLEMENTED; - - status = vaSyncSurfaceGLX_impl_libva(ctx, gl_surface); - if (status != VA_STATUS_SUCCESS) - return status; - - if (bind_pixmap(ctx, pSurfaceGLX) < 0) - return VA_STATUS_ERROR_OPERATION_FAILED; - - return VA_STATUS_SUCCESS; -} - -static VAStatus -vaEndRenderSurfaceGLX_impl_libva(VADriverContextP ctx, void *gl_surface) -{ - VADriverContextGLXP pDriverContextGLX = VA_DRIVER_CONTEXT_GLX(ctx); - VASurfaceGLXP pSurfaceGLX = gl_surface; - - if (!pDriverContextGLX->use_tfp) - return VA_STATUS_ERROR_UNIMPLEMENTED; - - if (unbind_pixmap(ctx, pSurfaceGLX) < 0) - return VA_STATUS_ERROR_OPERATION_FAILED; - - return VA_STATUS_SUCCESS; -} - -static VAStatus -vaCopySurfaceGLX_impl_libva( - VADriverContextP ctx, - void *gl_surface, - VASurfaceID surface, - unsigned int flags -) -{ - VADriverContextGLXP pDriverContextGLX = VA_DRIVER_CONTEXT_GLX(ctx); - VASurfaceGLXP pSurfaceGLX = gl_surface; - VAStatus status; - - if (!pDriverContextGLX->use_fbo) - return VA_STATUS_ERROR_UNIMPLEMENTED; - - /* XXX: only support VA_FRAME_PICTURE */ - if (flags != VA_FRAME_PICTURE) - return VA_STATUS_ERROR_FLAG_NOT_SUPPORTED; - - /* Associate VA surface */ - status = vaAssociateSurfaceGLX_impl_libva(ctx, gl_surface, surface, flags); - if (status != VA_STATUS_SUCCESS) - return status; - - /* Make sure binding succeeds, if texture was not already bound */ - struct OpenGLTextureState ts; - if (bind_texture(&ts, pSurfaceGLX->target, pSurfaceGLX->texture) < 0) - return VA_STATUS_ERROR_OPERATION_FAILED; - - /* Render to FBO */ - fbo_enter(ctx, pSurfaceGLX); - status = vaBeginRenderSurfaceGLX_impl_libva(ctx, gl_surface); - if (status == VA_STATUS_SUCCESS) { - render_pixmap(ctx, pSurfaceGLX); - status = vaEndRenderSurfaceGLX_impl_libva(ctx, gl_surface); - } - fbo_leave(ctx); - unbind_texture(&ts); - if (status != VA_STATUS_SUCCESS) - return status; - - return vaDeassociateSurfaceGLX_impl_libva(ctx, gl_surface); -} - - -/* ========================================================================= */ -/* === Private VA/GLX vtable initialization === */ -/* ========================================================================= */ - -// Initialize GLX driver context -VAStatus va_glx_init_context(VADriverContextP ctx) -{ - VADriverContextGLXP glx_ctx = VA_DRIVER_CONTEXT_GLX(ctx); - VADriverVTableGLXP vtable = &glx_ctx->vtable; - int needs_tfp = 0, needs_fbo = 0; - - if (glx_ctx->is_initialized) - return VA_STATUS_SUCCESS; - - if (ctx->vtable.glx && ctx->vtable.glx->vaCopySurfaceGLX) { - vtable->vaCreateSurfaceGLX = vaCreateSurfaceGLX_impl_driver; - vtable->vaDestroySurfaceGLX = vaDestroySurfaceGLX_impl_driver; - vtable->vaCopySurfaceGLX = vaCopySurfaceGLX_impl_driver; - } - else { - needs_tfp = 1; - needs_fbo = 1; - vtable->vaCreateSurfaceGLX = vaCreateSurfaceGLX_impl_libva; - vtable->vaDestroySurfaceGLX = vaDestroySurfaceGLX_impl_libva; - vtable->vaCopySurfaceGLX = vaCopySurfaceGLX_impl_libva; - } - - glx_ctx->has_tfp = 0; - glx_ctx->use_tfp = 0; - glx_ctx->has_fbo = 0; - glx_ctx->use_fbo = 0; - - if (needs_tfp) { - glx_ctx->has_tfp = check_tfp_extensions(ctx); - if (!glx_ctx->has_tfp || !load_tfp_extensions(ctx)) - return VA_STATUS_ERROR_UNIMPLEMENTED; - glx_ctx->use_tfp = 1; - } - - if (needs_fbo) { - glx_ctx->has_fbo = check_fbo_extensions(ctx); - if (!glx_ctx->has_fbo || !load_fbo_extensions(ctx)) - return VA_STATUS_ERROR_UNIMPLEMENTED; - glx_ctx->use_fbo = 1; - } - - glx_ctx->is_initialized = 1; - return VA_STATUS_SUCCESS; -} diff -Nru libva-0.31.0+latest2/va/glx/va_glx_impl.h libva-0.31.0+latest3/va/glx/va_glx_impl.h --- libva-0.31.0+latest2/va/glx/va_glx_impl.h 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/va/glx/va_glx_impl.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2009 Splitted-Desktop Systems. 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. - */ - -#ifndef VA_GLX_IMPL_H -#define VA_GLX_IMPL_H - -/** - * Initialize GLX driver context - * - * @param[in] ctx the VA driver context - * @return VA_STATUS_SUCCESS if successful - */ -VAStatus va_glx_init_context(VADriverContextP ctx) - ATTRIBUTE_HIDDEN; - -/** Create VA/GLX surface */ -VASurfaceGLXP -va_glx_create_surface(VADriverContextP ctx, GLenum target, GLuint texture) - ATTRIBUTE_HIDDEN; - -/** Destroy VA/GLX surface */ -void va_glx_destroy_surface(VADriverContextP ctx, VASurfaceGLXP *pSurfaceGLX) - ATTRIBUTE_HIDDEN; - -#endif /* VA_GLX_IMPL_H */ diff -Nru libva-0.31.0+latest2/va/glx/va_glx_private.h libva-0.31.0+latest3/va/glx/va_glx_private.h --- libva-0.31.0+latest2/va/glx/va_glx_private.h 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/va/glx/va_glx_private.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2009 Splitted-Desktop Systems. 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. - */ - -#ifndef VA_GLX_PRIVATE_H -#define VA_GLX_PRIVATE_H - -#include "config.h" -#include "va.h" -#include "va_backend.h" -#include "va_x11.h" -#include "va_glx.h" -#include "va_backend_glx.h" - -#if GLX_GLXEXT_VERSION < 18 -typedef void (*PFNGLXBINDTEXIMAGEEXTPROC)(Display *, GLXDrawable, int, const int *); -typedef void (*PFNGLXRELEASETEXIMAGEEXTPROC)(Display *, GLXDrawable, int); -#endif - -typedef struct VAOpenGLVTable *VAOpenGLVTableP; - -struct VAOpenGLVTable { - PFNGLXBINDTEXIMAGEEXTPROC glx_bind_tex_image; - PFNGLXRELEASETEXIMAGEEXTPROC glx_release_tex_image; - PFNGLGENFRAMEBUFFERSEXTPROC gl_gen_framebuffers; - PFNGLDELETEFRAMEBUFFERSEXTPROC gl_delete_framebuffers; - PFNGLBINDFRAMEBUFFEREXTPROC gl_bind_framebuffer; - PFNGLGENRENDERBUFFERSEXTPROC gl_gen_renderbuffers; - PFNGLDELETERENDERBUFFERSEXTPROC gl_delete_renderbuffers; - PFNGLBINDRENDERBUFFEREXTPROC gl_bind_renderbuffer; - PFNGLRENDERBUFFERSTORAGEEXTPROC gl_renderbuffer_storage; - PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC gl_framebuffer_renderbuffer; - PFNGLFRAMEBUFFERTEXTURE2DEXTPROC gl_framebuffer_texture_2d; - PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC gl_check_framebuffer_status; -}; - -typedef struct VADisplayContextGLX *VADisplayContextGLXP; -typedef struct VADriverContextGLX *VADriverContextGLXP; -typedef struct VASurfaceGLX *VASurfaceGLXP; -typedef struct VADriverVTableGLX *VADriverVTableGLXP; - -typedef void (*vaDestroyFunc)(VADisplayContextP); - -struct VADisplayContextGLX { - vaDestroyFunc vaDestroy; -}; - -#define VA_DRIVER_CONTEXT_GLX(ctx) ((VADriverContextGLXP)((ctx)->glx)) - -struct VADriverContextGLX { - struct VADriverVTableGLX vtable; - struct VAOpenGLVTable gl_vtable; - unsigned int is_initialized : 1; - unsigned int has_tfp : 1; - unsigned int has_fbo : 1; - unsigned int use_tfp : 1; - unsigned int use_fbo : 1; -}; - -/** Unique VASurfaceGLX identifier */ -#define VA_SURFACE_GLX_MAGIC VA_FOURCC('V','A','G','L') - -struct VASurfaceGLX { - uint32_t magic; ///< Magic number identifying a VASurfaceGLX - GLenum target; ///< GL target to which the texture is bound - GLuint texture; ///< GL texture - VASurfaceID surface; ///< Associated VA surface - unsigned int width; - unsigned int height; - int is_bound; - Pixmap pixmap; - GLXPixmap glx_pixmap; - GLuint fbo; - GLuint fbo_buffer; - GLuint fbo_texture; - void *priv; ///< Private VA/GLX surface data from driver -}; - -#endif /* VA_GLX_PRIVATE_H */ diff -Nru libva-0.31.0+latest2/va/Makefile.am libva-0.31.0+latest3/va/Makefile.am --- libva-0.31.0+latest2/va/Makefile.am 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/va/Makefile.am 2010-03-18 08:39:39.000000000 +0000 @@ -27,37 +27,22 @@ 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) +lib_LTLIBRARIES = \ + libva.la \ + libva-x11.la 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_LIBADD = $(libvacorelib) x11/libva_x11.la $(LIBVA_LIBS) $(X11_LIBS) $(XEXT_LIBS) $(DRM_LIBS) $(XFIXES_LIBS) 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 +SUBDIRS = x11 -libva_la_SOURCES = va.c va_crystalhd.c va_compat.c +libva_la_SOURCES = va.c libvaincludedir = ${includedir}/va libvainclude_HEADERS = va.h va_x11.h va_backend.h va_version.h @@ -66,14 +51,4 @@ va_version.h EXTRA_DIST = \ - va_version.h.in \ - va_crystalhd.h \ - va_compat.h \ - va_compat_template.h - -va_compat.c: va_compat_template.h - -lib_LTLIBRARIES += libva-compat.la -libva_compat_la_SOURCES = va_compat_lib.c -libva_compat_la_LIBADD = libva-x11.la -ldl -libva_compat_la_DEPENDENCIES = libva-x11.la + va_version.h.in diff -Nru libva-0.31.0+latest2/va/va_backend.h libva-0.31.0+latest3/va/va_backend.h --- libva-0.31.0+latest2/va/va_backend.h 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/va/va_backend.h 2010-03-18 08:39:39.000000000 +0000 @@ -365,9 +365,6 @@ unsigned int *chroma_v_offset, void **buffer ); - - /* Optional: GLX support hooks */ - struct VADriverVTableGLX *glx; }; struct VADriverContext @@ -390,8 +387,6 @@ void *handle; /* dlopen handle */ void *dri_state; - void *glx; /* opaque for GLX code */ - void *compat; /* opaque for compat code */ }; #define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */ @@ -414,8 +409,6 @@ VADisplayContextP ctx, char **driver_name ); - - void *opaque; /* opaque for display extensions (e.g. GLX) */ }; typedef VAStatus (*VADriverInit) ( diff -Nru libva-0.31.0+latest2/va/va.c libva-0.31.0+latest3/va/va.c --- libva-0.31.0+latest2/va/va.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/va/va.c 2010-03-18 08:39:39.000000000 +0000 @@ -24,11 +24,8 @@ #define _GNU_SOURCE 1 -#include "config.h" #include "va.h" #include "va_backend.h" -#include "va_crystalhd.h" -#include "va_compat.h" #include #include @@ -40,8 +37,6 @@ #define DRIVER_INIT_FUNC "__vaDriverInit_0_31" -#define DRIVER_INIT_FUNC_0_29 "__vaDriverInit_0_29" -#define DRIVER_INIT_FUNC_0_30 "__vaDriverInit_0_30" #define DRIVER_EXTENSION "_drv_video.so" @@ -132,6 +127,10 @@ { /* don't allow setuid apps to use LIBVA_DRIVERS_PATH */ search_path = getenv("LIBVA_DRIVERS_PATH"); + if (!search_path) + { + search_path = getenv("LIBGL_DRIVERS_PATH"); + } } if (!search_path) { @@ -165,26 +164,7 @@ else { VADriverInit init_func; - char driver_init_func_sds[32]; - int compat_version = 0; - /* First, try SDS extensions (VDPAU and XvBA backends) */ - sprintf(driver_init_func_sds, "%s_%d_sds%d", - DRIVER_INIT_FUNC, VA_MICRO_VERSION, VA_SDS_VERSION); - init_func = (VADriverInit) dlsym(handle, driver_init_func_sds); - if (!init_func) - { - /* Otherwise, we need the compatibility layer for some buffers */ - init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC); - compat_version = VA_MINOR_VERSION; - if (!init_func) { - init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC_0_29); - compat_version = 29; - } - if (!init_func) { - init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC_0_30); - compat_version = 30; - } - } + init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC); if (!init_func) { va_errorMessage("%s has no function %s\n", driver_path, DRIVER_INIT_FUNC); @@ -192,36 +172,7 @@ } else { - struct VADriverContext_0_29 ctx_0_29; - struct VADriverContext_0_30 ctx_0_30; - void *compat_ctx = NULL; - - switch (compat_version) { - case 29: - compat_ctx = &ctx_0_29; - ctx_0_29.pDriverData = NULL; - ctx_0_29.x11_dpy = ctx->x11_dpy; - ctx_0_29.x11_screen = ctx->x11_screen; - break; - case 30: - compat_ctx = &ctx_0_30; - ctx_0_30.pDriverData = NULL; - ctx_0_30.x11_dpy = ctx->x11_dpy; - ctx_0_30.x11_screen = ctx->x11_screen; - break; - case VA_MINOR_VERSION: - compat_ctx = ctx; - break; - default: - ASSERT(compat_version == 0); - vaStatus = VA_STATUS_ERROR_UNKNOWN; - break; - } - - vaStatus = (*init_func)(compat_ctx ? compat_ctx : ctx); - - if (VA_STATUS_SUCCESS == vaStatus) - vaStatus = va_compat_init(dpy, compat_version, compat_ctx); + vaStatus = (*init_func)(ctx); if (VA_STATUS_SUCCESS == vaStatus) { @@ -373,51 +324,30 @@ int *minor_version /* out */ ) { - const char *driver_name_env = NULL; - 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); - - driver_name_env = getenv("LIBVA_DRIVER_NAME"); - if (driver_name_env && geteuid() == getuid()) - { - /* Don't allow setuid apps to use LIBVA_DRIVER_NAME */ - driver_name = strdup(driver_name_env); - vaStatus = VA_STATUS_SUCCESS; - va_infoMessage("User requested driver '%s'\n", driver_name); - } - else - { - vaStatus = va_getDriverName(dpy, &driver_name); - va_infoMessage("va_getDriverName() returns %d\n", vaStatus); - } + char *driver_name = NULL; + VAStatus vaStatus; + + CHECK_DISPLAY(dpy); - if (VA_STATUS_SUCCESS == vaStatus) - { - vaStatus = va_openDriver(dpy, driver_name); - va_infoMessage("va_openDriver() returns %d\n", vaStatus); + va_debug_trace = (getenv("LIBVA_DEBUG_TRACE") != NULL); - if (vaStatus != VA_STATUS_SUCCESS && !driver_name_env) - { - if (va_hasCrystalHD()) - { - vaStatus = va_openDriver(dpy, "crystalhd"); - va_infoMessage("va_openDriver() returns %d\n", vaStatus); - } - } + va_infoMessage("libva version %s\n", VA_VERSION_S); - *major_version = VA_MAJOR_VERSION; - *minor_version = VA_MINOR_VERSION; - } + 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; + if (driver_name) + free(driver_name); + return vaStatus; } @@ -442,8 +372,6 @@ old_ctx->handle = NULL; } - va_compat_fini(dpy); - if (VA_STATUS_SUCCESS == vaStatus) pDisplayContext->vaDestroy(pDisplayContext); return vaStatus; diff -Nru libva-0.31.0+latest2/va/va_compat.c libva-0.31.0+latest3/va/va_compat.c --- libva-0.31.0+latest2/va/va_compat.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/va/va_compat.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,1178 +0,0 @@ -/* - * Copyright (C) 2009 Splitted-Desktop Systems. 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. - */ - -#include "config.h" -#include "va.h" -#include "va_compat.h" -#include "va_backend.h" -#include -#include -#include -#include - -#define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext) -#define COMPAT_CTX(ctx) ((VACompatContextP)(ctx)->compat) -#define ASSERT assert - -/* Invoke the normal VA API entry-point. This one can be replaced with - one of the va_compat_*() functions */ -#define VA_INVOKE(FUNC, CTX, ...) \ - (CTX)->vtable.FUNC(CTX, __VA_ARGS__) - -/* Invoke the real VA API entry-point. That is, the driver's function */ -#define VA_INVOKE_COMPAT_ARGS(CTX, ...) \ - (COMPAT_CTX(CTX)->compat_ctx, __VA_ARGS__) -#define VA_INVOKE_COMPAT(FUNC, CTX, ...) \ - COMPAT_CTX(CTX)->vtable.FUNC VA_INVOKE_COMPAT_ARGS(CTX, __VA_ARGS__) - -typedef struct VACompatContext *VACompatContextP; - -typedef VAStatus (*VABufferTranslateFunc)(VACompatContextP ctx, void *dest, const void *src); - -typedef enum { - VA_DRIVER_ID_UNKNOWN, - VA_DRIVER_ID_POULSBO, - VA_DRIVER_ID_IEGD -} VADriverID; - -typedef struct { - VABufferID id; - VABufferType type; - unsigned int size; - unsigned int num_elements; - unsigned char *data; - VABufferTranslateFunc translate; - VABufferID compat_id; - unsigned int compat_size; - unsigned char *compat_data; - unsigned int map_count; -} VABufferCompat; - -typedef struct VAContextMap *VAContextMapP; -typedef struct VAContextMap { - VASurfaceID surface; - VAContextID context; - VAContextMapP next; -} VAContextMap; - -typedef struct { - VAStatus (*vaTerminate)(void *); - VAStatus (*vaQueryConfigProfiles)(void *, VAProfile *, int *); - VAStatus (*vaQueryConfigEntrypoints)(void *, VAProfile, VAEntrypoint *, int *); - VAStatus (*vaGetConfigAttributes)(void *, VAProfile, VAEntrypoint, VAConfigAttrib *, int); - VAStatus (*vaCreateConfig)(void *, VAProfile, VAEntrypoint, VAConfigAttrib *, int, VAConfigID *); - VAStatus (*vaDestroyConfig)(void *, VAConfigID); - VAStatus (*vaQueryConfigAttributes)(void *, VAConfigID, VAProfile *, VAEntrypoint *, VAConfigAttrib *, int *); - VAStatus (*vaCreateSurfaces)(void *, int, int, int, int, VASurfaceID *); - VAStatus (*vaDestroySurfaces)(void *, VASurfaceID *, int); - VAStatus (*vaCreateContext)(void *, VAConfigID, int, int, int, VASurfaceID *, int, VAContextID *); - VAStatus (*vaDestroyContext)(void *, VAContextID); - VAStatus (*vaCreateBuffer)(void *, VAContextID, VABufferType, unsigned int, unsigned int, void *, VABufferID *); - VAStatus (*vaBufferSetNumElements)(void *, VABufferID, unsigned int); - VAStatus (*vaMapBuffer)(void *, VABufferID, void **); - VAStatus (*vaUnmapBuffer)(void *, VABufferID); - VAStatus (*vaDestroyBuffer)(void *, VABufferID); - VAStatus (*vaBeginPicture)(void *, VAContextID, VASurfaceID); - VAStatus (*vaRenderPicture)(void *, VAContextID, VABufferID *, int); - VAStatus (*vaEndPicture)(void *, VAContextID); - VAStatus (*vaSyncSurface_pre31)(void *, VAContextID, VASurfaceID); - VAStatus (*vaQuerySurfaceStatus)(void *, VASurfaceID, VASurfaceStatus *); - VAStatus (*vaPutSurface)(void *, VASurfaceID, unsigned long, short, short, unsigned short, unsigned short, short, short, unsigned short, unsigned short, VARectangle *, unsigned int, unsigned int); - VAStatus (*vaQueryImageFormats)(void *, VAImageFormat *, int *); - VAStatus (*vaCreateImage)(void *, VAImageFormat *, int, int, VAImage *); - VAStatus (*vaDeriveImage)(void *, VASurfaceID, VAImage *); - VAStatus (*vaDestroyImage)(void *, VAImageID); - VAStatus (*vaSetImagePalette)(void *, VAImageID, unsigned char *); - VAStatus (*vaGetImage)(void *, VASurfaceID, int, int, unsigned int, unsigned int, VAImageID); - VAStatus (*vaPutImage_pre31)(void *, VASurfaceID, VAImageID, int, int, unsigned int, unsigned int, int, int); - VAStatus (*vaPutImage2_pre31)(void *, VASurfaceID, VAImageID, int, int, unsigned int, unsigned int, int, int, unsigned int, unsigned int); - VAStatus (*vaQuerySubpictureFormats)(void *, VAImageFormat *, unsigned int *, unsigned int *); - VAStatus (*vaCreateSubpicture)(void *, VAImageID, VASubpictureID *); - VAStatus (*vaDestroySubpicture)(void *, VASubpictureID); - VAStatus (*vaSetSubpictureImage)(void *, VASubpictureID, VAImageID); - VAStatus (*vaSetSubpictureChromakey)(void *, VASubpictureID, unsigned int, unsigned int, unsigned int); - VAStatus (*vaSetSubpictureGlobalAlpha)(void *, VASubpictureID, float); - VAStatus (*vaAssociateSubpicture_pre31)(void *, VASubpictureID, VASurfaceID *, int, short, short, short, short, unsigned short, unsigned short, unsigned int); - VAStatus (*vaAssociateSubpicture2_pre31)(void *, VASubpictureID, VASurfaceID *, int, short, short, unsigned short, unsigned short, short, short, unsigned short, unsigned short, unsigned int); - VAStatus (*vaDeassociateSubpicture)(void *, VASubpictureID, VASurfaceID *, int); - VAStatus (*vaQueryDisplayAttributes)(void *, VADisplayAttribute *, int *); - VAStatus (*vaGetDisplayAttributes)(void *, VADisplayAttribute *, int); - VAStatus (*vaSetDisplayAttributes)(void *, VADisplayAttribute *, int); - - /* 0.29 hooks */ - VAStatus (*vaSetSubpicturePalette)(void *, VASubpictureID, unsigned char *); - VAStatus (*vaDbgCopySurfaceToBuffer)(void *, VASurfaceID, void **, unsigned int *); - - /* 0.30 hooks */ - VAStatus (*vaCreateSurfaceFromCIFrame)(void *, unsigned long, VASurfaceID *); - VAStatus (*vaCreateSurfaceFromV4L2Buf)(void *, int, struct v4l2_format *, struct v4l2_buffer *, VASurfaceID *); - VAStatus (*vaCopySurfaceToBuffer)(void *, VASurfaceID, unsigned int *, unsigned int *, unsigned int *, unsigned int *, unsigned int *, unsigned int *, unsigned int *, void **); - - /* 0.31 hooks */ - VAStatus (*vaPutImage)(void *, VASurfaceID, VAImageID, int, int, unsigned int, unsigned int, int, int, unsigned int, unsigned int); - VAStatus (*vaAssociateSubpicture)(void *, VASubpictureID, VASurfaceID *, int, short, short, unsigned short, unsigned short, short, short, unsigned short, unsigned short, unsigned int); - VAStatus (*vaSyncSurface)(void *, VASurfaceID); -} VACompatDriverVTable; - -typedef struct VACompatContext { - VABufferCompat *buffers; - unsigned int buffers_count_max; - unsigned int compat_version; - void *compat_ctx; - VACompatDriverVTable vtable; /* original vtable */ - VADriverID driver_id; - char *driver_name; - VAContextMapP context_map; - VAContextMapP last_context_map_match; - unsigned int skip_frame : 1; -} VACompatContext; - -#define COMPAT_MAJOR 0 -#define COMPAT_MINOR 29 -#include "va_compat_template.h" - -#define COMPAT_MAJOR 0 -#define COMPAT_MINOR 30 -#include "va_compat_template.h" - -#define COMPAT_MAJOR 0 -#define COMPAT_MINOR 31 -#include "va_compat_template.h" - -static inline int va_IsIntelBuffer(VADriverContextP ctx, VABufferID id) -{ - VACompatContextP compat = ctx->compat; - - if (compat->driver_id == VA_DRIVER_ID_POULSBO) { - /* There were only Intel implementations for VA API. Besides, the - returned buffer IDs had the following format [ 0 BASE ID ] where - BASE is the 7-bit value 0x04 and ID an index into the heap of - objects */ - return (id & 0x7f000000) == 0x04000000; - } - - if (compat->driver_id == VA_DRIVER_ID_IEGD) { - /* XXX: there is no means to differentiate the buffers, they - are linearly generated (IEGD 10.0 build 1335) */ - return 1; - } - - return 0; -} - -static VAContextMapP va_context_map_lookup_p( - VACompatContextP ctx, - VASurfaceID surface -) -{ - VAContextMapP m = ctx->context_map; - - while (m) { - if (m->surface == surface) - return m; - m = m->next; - } - return NULL; -} - -static VAContextID va_context_map_lookup( - VACompatContextP ctx, - VASurfaceID surface -) -{ - VAContextMapP m; - - /* Lookup in cached */ - m = ctx->last_context_map_match; - if (m && m->surface == surface) - return m->context; - - /* Full (slow) lookup */ - m = va_context_map_lookup_p(ctx, surface); - if (m) { - ctx->last_context_map_match = m; - return m->context; - } - return VA_INVALID_ID; -} - -static void va_context_map_add( - VACompatContextP ctx, - VAContextID context, - VASurfaceID surface -) -{ - VAContextMapP m; - - /* Update existing entry */ - m = va_context_map_lookup_p(ctx, surface); - if (m) { - m->context = context; - return; - } - - /* Create new mapping */ - m = malloc(sizeof(*m)); - ASSERT(m); - if (m) { - m->surface = surface; - m->context = context; - m->next = ctx->context_map; - ctx->context_map = m; - } -} - -static void va_context_map_remove( - VACompatContextP ctx, - VAContextID context -) -{ - VAContextMapP p = NULL; - VAContextMapP m = ctx->context_map; - VAContextMapP d; - - while (m) { - if (m->context == context) { - d = m; - - /* Unlink current node */ - if (p) - p->next = m->next; - else - ctx->context_map = m->next; - m = m->next; - - /* Reset cache */ - if (ctx->last_context_map_match == d) - ctx->last_context_map_match = NULL; - - free(d); - } - else { - p = m; - m = m->next; - } - } -} - -static VABufferCompat *va_GetBufferCompat ( - VADriverContextP ctx, - VABufferID id -) -{ - VACompatContextP compat = ctx->compat; - int index; - - if (!va_IsIntelBuffer(ctx, id)) - return NULL; - - index = id & 0x00ffffff; - if (index >= compat->buffers_count_max) - return NULL; - - if (compat->buffers[index].id != id) - return NULL; - - return &compat->buffers[index]; -} - -static VAStatus va_TranslateBufferCompat ( - VADriverContextP ctx, - VABufferCompat *compat_buffer -) -{ - VAStatus status; - unsigned char *src, *dest; - int i; - - status = VA_INVOKE(vaMapBuffer, ctx, compat_buffer->id, (void **)&src); - if (status != VA_STATUS_SUCCESS) - return status; - - ASSERT(compat_buffer->data); - ASSERT(src == compat_buffer->data); - ASSERT(compat_buffer->compat_data); - dest = compat_buffer->compat_data; - for (i = 0; i < compat_buffer->num_elements; i++) - { - /* XXX: check errors */ - status = compat_buffer->translate(ctx->compat, dest, src); - - src += compat_buffer->size; - dest += compat_buffer->compat_size; - } - - return VA_INVOKE(vaUnmapBuffer, ctx, compat_buffer->id); -} - -static VAStatus va_CreateBufferCompat ( - VADriverContextP ctx, - VAContextID context, - VABufferID id, - VABufferType type, - unsigned int size, - unsigned int num_elements, - unsigned int compat_size, - VABufferTranslateFunc translate_func -) -{ - VACompatContextP compat = ctx->compat; - VABufferCompat *compat_buffer; - int index; - - if (!va_IsIntelBuffer(ctx, id)) - return VA_STATUS_ERROR_INVALID_BUFFER; - index = id & 0x00ffffff; - - /* XXX: this allocation strategy is not really space efficient... */ - if (index >= compat->buffers_count_max) - { - compat->buffers_count_max = index + 1; - compat->buffers = realloc(compat->buffers, - (compat->buffers_count_max * - sizeof(VABufferCompat))); - if (compat->buffers == NULL) - return VA_STATUS_ERROR_ALLOCATION_FAILED; - } - - compat_buffer = &compat->buffers[index]; - compat_buffer->id = id; - compat_buffer->type = type; - compat_buffer->size = size; - compat_buffer->num_elements = num_elements; - compat_buffer->data = NULL; - compat_buffer->translate = translate_func; - compat_buffer->compat_size = compat_size; - compat_buffer->compat_data = NULL; - compat_buffer->map_count = 0; - - return VA_INVOKE_COMPAT(vaCreateBuffer, - ctx, - context, - type, - compat_size, - num_elements, - NULL, - &compat_buffer->compat_id); -} - -static VAStatus va_DestroyBufferCompat ( - VADriverContextP ctx, - VABufferID id -) -{ - VABufferCompat *compat_buffer; - VAStatus status; - - if ((compat_buffer = va_GetBufferCompat(ctx, id)) == NULL) - return VA_STATUS_SUCCESS; - - /* Force unmap if there were more maps than unmaps */ - if (compat_buffer->map_count > 1) - compat_buffer->map_count = 1; - if (compat_buffer->map_count > 1) - { - if ((status = VA_INVOKE(vaUnmapBuffer, ctx, id)) != VA_STATUS_SUCCESS) - return status; - } - - compat_buffer->id = 0; - return VA_INVOKE_COMPAT(vaDestroyBuffer, ctx, compat_buffer->compat_id); -} - -static VAStatus va_compat_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 */ -) -{ - VABufferTranslateFunc translate_func = NULL; - unsigned int compat_size = 0; - VAStatus status; - - status = VA_INVOKE_COMPAT(vaCreateBuffer, - ctx, - context, - type, - size, - num_elements, - data, - buf_id); - - if (status != VA_STATUS_SUCCESS) - return status; - -#define INIT_TRANSLATE_FUNC_(STRUCT, MAJOR, MINOR) do { \ - translate_func = va_compat_translate_VA##STRUCT##_##MAJOR##_##MINOR; \ - compat_size = sizeof(VA##STRUCT##_##MAJOR##_##MINOR); \ -} while (0) -#define INIT_TRANSLATE_FUNC(BUFFER, CODEC, MAJOR, MINOR) \ - INIT_TRANSLATE_FUNC_(BUFFER##Buffer##CODEC, MAJOR, MINOR) - - /* XXX: this assumes all structures have different sizes from each other */ - switch (size) { - case sizeof(VAPictureParameterBufferH264): - if (type == VAPictureParameterBufferType && ctx->version_major == 0) - { - switch (ctx->version_minor) { - case 29: INIT_TRANSLATE_FUNC(PictureParameter,H264, 0,29); break; - case 30: INIT_TRANSLATE_FUNC(PictureParameter,H264, 0,30); break; - } - } - break; - case sizeof(VASliceParameterBufferH264): - if (type == VASliceParameterBufferType && ctx->version_major == 0) - { - switch (ctx->version_minor) { - case 29: INIT_TRANSLATE_FUNC(SliceParameter,H264, 0,29); break; - case 30: INIT_TRANSLATE_FUNC(SliceParameter,H264, 0,30); break; - } - } - break; - case sizeof(VAPictureParameterBufferVC1): - if (type == VAPictureParameterBufferType && ctx->version_major == 0) - { - switch (ctx->version_minor) { - case 29: INIT_TRANSLATE_FUNC(PictureParameter,VC1, 0,29); break; - case 30: INIT_TRANSLATE_FUNC(PictureParameter,VC1, 0,30); break; - } - } - break; - case sizeof(VAPictureParameterBufferMPEG2): - if (type == VAPictureParameterBufferType && ctx->version_major == 0) - { - switch (ctx->version_minor) { - case 29: INIT_TRANSLATE_FUNC(PictureParameter,MPEG2, 0,29); break; - case 30: INIT_TRANSLATE_FUNC(PictureParameter,MPEG2, 0,30); break; - } - } - break; - case sizeof(VASliceParameterBufferMPEG2): - if (type == VASliceParameterBufferType && ctx->version_major == 0) - { - switch (ctx->version_minor) { - case 29: INIT_TRANSLATE_FUNC(SliceParameter,MPEG2, 0,29); break; - case 30: INIT_TRANSLATE_FUNC(SliceParameter,MPEG2, 0,30); break; - } - } - break; - case sizeof(VAPictureParameterBufferMPEG4): - if (type == VAPictureParameterBufferType && ctx->version_major == 0) - { - switch (ctx->version_minor) { - case 29: INIT_TRANSLATE_FUNC(PictureParameter,MPEG4, 0,29); break; - case 30: INIT_TRANSLATE_FUNC(PictureParameter,MPEG4, 0,30); break; - case 31: INIT_TRANSLATE_FUNC(PictureParameter,MPEG4, 0,31); break; - } - } - break; - case sizeof(VAEncSliceParameterBuffer): - if (type == VAEncSliceParameterBufferType && ctx->version_major == 0) - { - switch (ctx->version_minor) { - case 30: INIT_TRANSLATE_FUNC_(EncSliceParameterBuffer, 0,30); break; - } - } - break; - } - -#undef INIT_TRANSLATE_FUNC - - /* Create thunk */ - if (buf_id && translate_func) - { - ASSERT(compat_size > 0); - - status = va_CreateBufferCompat(ctx, - context, - *buf_id, - type, - size, - num_elements, - compat_size, - translate_func); - } - - return status; -} - -static VAStatus va_compat_BufferSetNumElements ( - VADriverContextP ctx, - VABufferID buf_id, /* in */ - unsigned int num_elements /* in */ -) -{ - VABufferCompat *compat_buffer; - VAStatus status; - - status = VA_INVOKE_COMPAT(vaBufferSetNumElements, ctx, buf_id, num_elements); - if (status != VA_STATUS_SUCCESS) - return status; - - if ((compat_buffer = va_GetBufferCompat(ctx, buf_id)) != NULL) - { - compat_buffer->num_elements = num_elements; - status = VA_INVOKE_COMPAT(vaBufferSetNumElements, - ctx, - compat_buffer->compat_id, - num_elements); - } - - return status; -} - -static VAStatus va_compat_DestroyBuffer ( - VADriverContextP ctx, - VABufferID buffer_id -) -{ - VAStatus status; - if ((status = va_DestroyBufferCompat(ctx, buffer_id)) != VA_STATUS_SUCCESS) - return status; - - return VA_INVOKE_COMPAT(vaDestroyBuffer, ctx, buffer_id); -} - -static VAStatus va_compat_MapBuffer ( - VADriverContextP ctx, - VABufferID buf_id, /* in */ - void **pbuf /* out */ -) -{ - VABufferCompat *compat_buffer; - VAStatus status; - - if ((compat_buffer = va_GetBufferCompat(ctx, buf_id)) == NULL) - return VA_INVOKE_COMPAT(vaMapBuffer, ctx, buf_id, pbuf); - - if (compat_buffer->map_count++ == 0) - { - status = VA_INVOKE_COMPAT(vaMapBuffer, ctx, buf_id, (void **)&compat_buffer->data); - if (status != VA_STATUS_SUCCESS) - return status; - - status = VA_INVOKE_COMPAT(vaMapBuffer, ctx, compat_buffer->compat_id, (void **)&compat_buffer->compat_data); - if (status != VA_STATUS_SUCCESS) - return status; - } - - if (pbuf) - *pbuf = compat_buffer->data; - - return VA_STATUS_SUCCESS; -} - -static VAStatus va_compat_UnmapBuffer ( - VADriverContextP ctx, - VABufferID buf_id /* in */ -) -{ - VABufferCompat *compat_buffer; - VAStatus status; - - if ((compat_buffer = va_GetBufferCompat(ctx, buf_id)) == NULL) - return VA_INVOKE_COMPAT(vaUnmapBuffer, ctx, buf_id); - - if (--compat_buffer->map_count == 0) - { - status = VA_INVOKE_COMPAT(vaUnmapBuffer, ctx, compat_buffer->compat_id); - if (status != VA_STATUS_SUCCESS) - return status; - compat_buffer->compat_data = NULL; - - status = VA_INVOKE_COMPAT(vaUnmapBuffer, ctx, compat_buffer->id); - if (status != VA_STATUS_SUCCESS) - return status; - compat_buffer->data = NULL; - } - - return VA_STATUS_SUCCESS; -} - -static VAStatus va_compat_BeginPicture ( - VADriverContextP ctx, - VAContextID context, - VASurfaceID render_target -) -{ - VACompatContextP compat = ctx->compat; - compat->skip_frame = 0; - return VA_INVOKE_COMPAT(vaBeginPicture, ctx, context, render_target); -} - -static VAStatus va_compat_EndPicture ( - VADriverContextP ctx, - VAContextID context -) -{ - VACompatContextP compat = ctx->compat; - VAStatus status = VA_INVOKE_COMPAT(vaEndPicture, ctx, context); - - /* Ignore errors if the HW decoder did not handle VC-1 skipped P-frames */ - if (compat->skip_frame && status == VA_STATUS_ERROR_UNKNOWN) - status = VA_STATUS_SUCCESS; - - return status; -} - -static VAStatus va_compat_RenderPicture ( - VADriverContextP ctx, - VAContextID context, - VABufferID *buffers, - int num_buffers -) -{ - VACompatContextP compat = ctx->compat; - VABufferCompat *compat_buffer; - VABufferID *compat_buffer_ids; - VAStatus status; - int i, n; - - if ((n = num_buffers) < 1) - n = 1; - compat_buffer_ids = alloca(n * sizeof(compat_buffer_ids[0])); - - for (i = 0; i < num_buffers; i++) - { - if ((compat_buffer = va_GetBufferCompat(ctx, buffers[i])) == NULL) - compat_buffer_ids[i] = buffers[i]; - else - { - status = va_TranslateBufferCompat(ctx, compat_buffer); - if (status != VA_STATUS_SUCCESS) - return status; - compat_buffer_ids[i] = compat_buffer->compat_id; - } - } - - if (!compat->skip_frame) - { - status = VA_INVOKE_COMPAT(vaRenderPicture, ctx, context, compat_buffer_ids, num_buffers); - if (status != VA_STATUS_SUCCESS) - return status; - } - - /* Buffers are automatically destroyed afterwards */ - for (i = 0; i < num_buffers; i++) - { - if ((compat_buffer = va_GetBufferCompat(ctx, buffers[i])) != NULL) - { - status = VA_INVOKE_COMPAT(vaDestroyBuffer, ctx, compat_buffer->id); - if (status != VA_STATUS_SUCCESS) - return status; - } - } - - return VA_STATUS_SUCCESS; -} - -#define DEFINE_VTABLE_ENTRY_(RETVAL, PROC, ARGS, COMPAT_PROC, COMPAT_ARGS, COMPAT_PRE, COMPAT_POST) \ -static RETVAL va_compat_##PROC ARGS \ -{ \ - if (COMPAT_CTX(ctx)->vtable.va##COMPAT_PROC == NULL) \ - return VA_STATUS_ERROR_OPERATION_FAILED; \ - COMPAT_PRE; \ - RETVAL ret = COMPAT_CTX(ctx)->vtable.va##COMPAT_PROC VA_INVOKE_COMPAT_ARGS COMPAT_ARGS; \ - COMPAT_POST; \ - return ret; \ -} - -#define DEFINE_VTABLE_ENTRY(RETVAL, PROC, DECL_ARGS, CALL_ARGS) \ -DEFINE_VTABLE_ENTRY_(RETVAL, PROC, DECL_ARGS, PROC, CALL_ARGS, {}, {}) - -static VAStatus va_compat_Terminate(VADriverContextP ctx) -{ - if (COMPAT_CTX(ctx)->vtable.vaTerminate == NULL) - return VA_STATUS_ERROR_OPERATION_FAILED; - return COMPAT_CTX(ctx)->vtable.vaTerminate(COMPAT_CTX(ctx)->compat_ctx); -} - -DEFINE_VTABLE_ENTRY( - VAStatus, QueryConfigProfiles, - (VADriverContextP ctx, VAProfile *profile_list, int *num_profiles), - (ctx, profile_list, num_profiles)) - -DEFINE_VTABLE_ENTRY( - VAStatus, QueryConfigEntrypoints, - (VADriverContextP ctx, VAProfile profile, - VAEntrypoint *entrypoint_list, int *num_entrypoints), - (ctx, profile, entrypoint_list, num_entrypoints)) - -DEFINE_VTABLE_ENTRY( - VAStatus, GetConfigAttributes, - (VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, - VAConfigAttrib *attrib_list, int num_attribs), - (ctx, profile, entrypoint, attrib_list, num_attribs)) - -DEFINE_VTABLE_ENTRY( - VAStatus, CreateConfig, - (VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, - VAConfigAttrib *attrib_list, int num_attribs, VAConfigID *config_id), - (ctx, profile, entrypoint, attrib_list, num_attribs, config_id)) - -DEFINE_VTABLE_ENTRY( - VAStatus, DestroyConfig, - (VADriverContextP ctx, VAConfigID config_id), - (ctx, config_id)) - -DEFINE_VTABLE_ENTRY( - VAStatus, QueryConfigAttributes, - (VADriverContextP ctx, VAConfigID config_id, VAProfile *profile, - VAEntrypoint *entrypoint, VAConfigAttrib *attrib_list, int *num_attribs), - (ctx, config_id, profile, entrypoint, attrib_list, num_attribs)) - -DEFINE_VTABLE_ENTRY( - VAStatus, CreateSurfaces, - (VADriverContextP ctx, int width, int height, int format, - int num_surfaces, VASurfaceID *surfaces), - (ctx, width, height, format, num_surfaces, surfaces)) - -DEFINE_VTABLE_ENTRY( - VAStatus, DestroySurfaces, - (VADriverContextP ctx, VASurfaceID *surface_list, int num_surfaces), - (ctx, surface_list, num_surfaces)) - -DEFINE_VTABLE_ENTRY( - VAStatus, CreateContext, - (VADriverContextP ctx, VAConfigID config_id, - int picture_width, int picture_height, int flag, - VASurfaceID *render_targets, int num_render_targets, VAContextID *context), - (ctx, config_id, picture_width, picture_height, flag, - render_targets, num_render_targets, context)) - -DEFINE_VTABLE_ENTRY( - VAStatus, DestroyContext, - (VADriverContextP ctx, VAContextID context), - (ctx, context)) - -DEFINE_VTABLE_ENTRY( - VAStatus, SyncSurface, - (VADriverContextP ctx, VASurfaceID render_target), - (ctx, render_target)) - -DEFINE_VTABLE_ENTRY( - VAStatus, QuerySurfaceStatus, - (VADriverContextP ctx, VASurfaceID render_target, VASurfaceStatus *status), - (ctx, render_target, status)) - -DEFINE_VTABLE_ENTRY_( - VAStatus, PutSurface, - (VADriverContextP ctx, VASurfaceID surface, Drawable draw, - short srcx, short srcy, unsigned short srcw, unsigned short srch, - short destx, short desty, unsigned short destw, unsigned short desth, - VARectangle *cliprects, unsigned int number_cliprects, unsigned int flags), - PutSurface, - (ctx, surface, draw, srcx, srcy, srcw, srch, destx, desty, destw, desth, - cliprects, number_cliprects, flags), - { - if (COMPAT_CTX(ctx)->compat_version < 30) /* 0.30 */ - flags &= (VA_TOP_FIELD|VA_BOTTOM_FIELD|VA_CLEAR_DRAWABLE); - }, - {}) - -DEFINE_VTABLE_ENTRY( - VAStatus, QueryImageFormats, - (VADriverContextP ctx, VAImageFormat *format_list, int *num_formats), - (ctx, format_list, num_formats)) - -DEFINE_VTABLE_ENTRY( - VAStatus, CreateImage, - (VADriverContextP ctx, VAImageFormat *format, - int width, int height, VAImage *image), - (ctx, format, width, height, image)) - -DEFINE_VTABLE_ENTRY( - VAStatus, DeriveImage, - (VADriverContextP ctx, VASurfaceID surface, VAImage *image), - (ctx, surface, image)) - -DEFINE_VTABLE_ENTRY( - VAStatus, DestroyImage, - (VADriverContextP ctx, VAImageID image), - (ctx, image)) - -DEFINE_VTABLE_ENTRY( - VAStatus, SetImagePalette, - (VADriverContextP ctx, VAImageID image, unsigned char *palette), - (ctx, image, palette)) - -DEFINE_VTABLE_ENTRY( - VAStatus, GetImage, - (VADriverContextP ctx, VASurfaceID surface, - int x, int y, unsigned int width, unsigned int height, VAImageID image), - (ctx, surface, x, y, width, height, image)) - -DEFINE_VTABLE_ENTRY( - VAStatus, PutImage, - (VADriverContextP ctx, VASurfaceID surface, VAImageID image, - int srcx, int srcy, unsigned int srcw, unsigned int srch, - int destx, int desty, unsigned int destw, unsigned int desth), - (ctx, surface, image, srcx, srcy, srcw, srch, destx, desty, destw, desth)) - -DEFINE_VTABLE_ENTRY( - VAStatus, QuerySubpictureFormats, - (VADriverContextP ctx, VAImageFormat *format_list, - unsigned int *flags, unsigned int *num_formats), - (ctx, format_list, flags, num_formats)) - -DEFINE_VTABLE_ENTRY( - VAStatus, CreateSubpicture, - (VADriverContextP ctx, VAImageID image, VASubpictureID *subpicture), - (ctx, image, subpicture)) - -DEFINE_VTABLE_ENTRY( - VAStatus, DestroySubpicture, - (VADriverContextP ctx, VASubpictureID subpicture), - (ctx, subpicture)) - -DEFINE_VTABLE_ENTRY( - VAStatus, SetSubpictureImage, - (VADriverContextP ctx, VASubpictureID subpicture, VAImageID image), - (ctx, subpicture, image)) - -DEFINE_VTABLE_ENTRY( - VAStatus, SetSubpictureChromakey, - (VADriverContextP ctx, VASubpictureID subpicture, - unsigned int chromakey_min, - unsigned int chromakey_max, - unsigned int chromakey_mask), - (ctx, subpicture, chromakey_min, chromakey_max, chromakey_mask)) - -DEFINE_VTABLE_ENTRY( - VAStatus, SetSubpictureGlobalAlpha, - (VADriverContextP ctx, VASubpictureID subpicture, float global_alpha), - (ctx, subpicture, global_alpha)) - -DEFINE_VTABLE_ENTRY( - VAStatus, AssociateSubpicture, - (VADriverContextP ctx, VASubpictureID subpicture, - VASurfaceID *target_surfaces, int num_surfaces, - short srcx, short srcy, unsigned short srcw, unsigned short srch, - short destx, short desty, unsigned short destw, unsigned short desth, - unsigned int flags), - (ctx, subpicture, target_surfaces, num_surfaces, - srcx, srcy, srcw, srch, destx, desty, destw, desth, flags)) - -DEFINE_VTABLE_ENTRY( - VAStatus, DeassociateSubpicture, - (VADriverContextP ctx, VASubpictureID subpicture, - VASurfaceID *target_surfaces, int num_surfaces), - (ctx, subpicture, target_surfaces, num_surfaces)) - -DEFINE_VTABLE_ENTRY( - VAStatus, QueryDisplayAttributes, - (VADriverContextP ctx, VADisplayAttribute *attr_list, int *num_attributes), - (ctx, attr_list, num_attributes)) - -DEFINE_VTABLE_ENTRY( - VAStatus, GetDisplayAttributes, - (VADriverContextP ctx, VADisplayAttribute *attr_list, int num_attributes), - (ctx, attr_list, num_attributes)) - -DEFINE_VTABLE_ENTRY( - VAStatus, SetDisplayAttributes, - (VADriverContextP ctx, VADisplayAttribute *attr_list, int num_attributes), - (ctx, attr_list, num_attributes)) - -DEFINE_VTABLE_ENTRY( - VAStatus, CreateSurfaceFromCIFrame, - (VADriverContextP ctx, unsigned long frame_id, VASurfaceID *surface), - (ctx, frame_id, surface)) - -DEFINE_VTABLE_ENTRY( - VAStatus, CreateSurfaceFromV4L2Buf, - (VADriverContextP ctx, int v4l2_fd, - struct v4l2_format *v4l2_fmt, struct v4l2_buffer *v4l2_buf, - VASurfaceID *surface), - (ctx, v4l2_fd, v4l2_fmt, v4l2_buf, surface)) - -DEFINE_VTABLE_ENTRY( - VAStatus, CopySurfaceToBuffer, - (VADriverContextP ctx, VASurfaceID surface, unsigned int *fourcc, - 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), - (ctx, surface, fourcc, - luma_stride, chroma_u_stride, chroma_v_stride, - luma_offset, chroma_u_offset, chroma_v_offset, - buffer)) - -DEFINE_VTABLE_ENTRY_( - VAStatus, SyncSurface_pre31, - (VADriverContextP ctx, VASurfaceID render_target), - SyncSurface_pre31, - (ctx, va_context_map_lookup(COMPAT_CTX(ctx), render_target), render_target), - {}, {}) - -DEFINE_VTABLE_ENTRY_( - VAStatus, PutImage_pre31, - (VADriverContextP ctx, VASurfaceID surface, VAImageID image, - int srcx, int srcy, unsigned int srcw, unsigned int srch, - int destx, int desty, unsigned int destw, unsigned int desth), - PutImage2_pre31, - (ctx, surface, image, srcx, srcy, srcw, srch, destx, desty, destw, desth), - {}, {}) - -DEFINE_VTABLE_ENTRY_( - VAStatus, AssociateSubpicture_pre31, - (VADriverContextP ctx, VASubpictureID subpicture, - VASurfaceID *target_surfaces, int num_surfaces, - short srcx, short srcy, unsigned short srcw, unsigned short srch, - short destx, short desty, unsigned short destw, unsigned short desth, - unsigned int flags), - AssociateSubpicture2_pre31, - (ctx, subpicture, target_surfaces, num_surfaces, - srcx, srcy, srcw, srch, destx, desty, destw, desth, flags), - {}, {}) - -DEFINE_VTABLE_ENTRY_( - VAStatus, CreateContext_pre31, - (VADriverContextP ctx, VAConfigID config_id, - int picture_width, int picture_height, int flag, - VASurfaceID *render_targets, int num_render_targets, VAContextID *context), - CreateContext, - (ctx, config_id, picture_width, picture_height, flag, - render_targets, num_render_targets, context), - {}, { - VACompatContextP const compat_ctx = COMPAT_CTX(ctx); - int i; - for (i = 0; i < num_render_targets; i++) - va_context_map_add(compat_ctx, *context, render_targets[i]); - }) - -DEFINE_VTABLE_ENTRY_( - VAStatus, DestroyContext_pre31, - (VADriverContextP ctx, VAContextID context), - DestroyContext, - (ctx, context), - {}, { va_context_map_remove(COMPAT_CTX(ctx), context); }) - -#undef DEFINE_VTABLE_ENTRY -#undef DEFINE_VTABLE_ENTRY_ - -static void va_compat_init_VADriverVTable(VADriverContextP ctx, int compat_version) -{ -#define INIT_VTABLE_(CTX, DST_PROC, SRC_PROC) \ - (CTX)->vtable.va##DST_PROC = va_compat_##SRC_PROC -#define INIT_VTABLE(CTX, PROC) \ - INIT_VTABLE_(CTX, PROC, PROC) - - INIT_VTABLE(ctx, Terminate); - INIT_VTABLE(ctx, QueryConfigProfiles); - INIT_VTABLE(ctx, QueryConfigEntrypoints); - INIT_VTABLE(ctx, GetConfigAttributes); - INIT_VTABLE(ctx, CreateConfig); - INIT_VTABLE(ctx, DestroyConfig); - INIT_VTABLE(ctx, QueryConfigAttributes); - INIT_VTABLE(ctx, CreateSurfaces); - INIT_VTABLE(ctx, DestroySurfaces); - INIT_VTABLE(ctx, CreateContext); - INIT_VTABLE(ctx, DestroyContext); - INIT_VTABLE(ctx, CreateBuffer); - INIT_VTABLE(ctx, BufferSetNumElements); - INIT_VTABLE(ctx, MapBuffer); - INIT_VTABLE(ctx, UnmapBuffer); - INIT_VTABLE(ctx, DestroyBuffer); - INIT_VTABLE(ctx, BeginPicture); - INIT_VTABLE(ctx, RenderPicture); - INIT_VTABLE(ctx, EndPicture); - INIT_VTABLE(ctx, SyncSurface); - INIT_VTABLE(ctx, QuerySurfaceStatus); - INIT_VTABLE(ctx, PutSurface); - INIT_VTABLE(ctx, QueryImageFormats); - INIT_VTABLE(ctx, CreateImage); - INIT_VTABLE(ctx, DeriveImage); - INIT_VTABLE(ctx, DestroyImage); - INIT_VTABLE(ctx, SetImagePalette); - INIT_VTABLE(ctx, GetImage); - INIT_VTABLE(ctx, PutImage); - INIT_VTABLE(ctx, QuerySubpictureFormats); - INIT_VTABLE(ctx, CreateSubpicture); - INIT_VTABLE(ctx, DestroySubpicture); - INIT_VTABLE(ctx, SetSubpictureImage); - INIT_VTABLE(ctx, SetSubpictureChromakey); - INIT_VTABLE(ctx, SetSubpictureGlobalAlpha); - INIT_VTABLE(ctx, AssociateSubpicture); - INIT_VTABLE(ctx, DeassociateSubpicture); - INIT_VTABLE(ctx, QueryDisplayAttributes); - INIT_VTABLE(ctx, GetDisplayAttributes); - INIT_VTABLE(ctx, SetDisplayAttributes); - INIT_VTABLE(ctx, CreateSurfaceFromCIFrame); - INIT_VTABLE(ctx, CreateSurfaceFromV4L2Buf); - INIT_VTABLE(ctx, CopySurfaceToBuffer); - - if (compat_version && compat_version < 31) { - INIT_VTABLE_(ctx, CreateContext, CreateContext_pre31); - INIT_VTABLE_(ctx, DestroyContext, DestroyContext_pre31); - INIT_VTABLE_(ctx, SyncSurface, SyncSurface_pre31); - INIT_VTABLE_(ctx, PutImage, PutImage_pre31); - INIT_VTABLE_(ctx, AssociateSubpicture, AssociateSubpicture_pre31); - } - -#undef INIT_VTABLE -#undef INIT_VTABLE__ -} - -VAStatus va_compat_init(VADisplay dpy, int compat_version, void *compat_ctx) -{ - VADisplayContextP pDisplayContext = (VADisplayContextP)dpy; - VADriverContextP ctx = CTX(dpy); - VADriverContextP_0_29 ctx_0_29; - VADriverContextP_0_30 ctx_0_30; - VACompatContextP compat; - VAStatus status; - char *driver_name; - - ctx->compat = NULL; - - if (compat_version == 0) - return VA_STATUS_SUCCESS; - - ASSERT(compat_ctx); - if (compat_ctx == NULL) - return VA_STATUS_ERROR_UNKNOWN; - - driver_name = NULL; - status = pDisplayContext->vaGetDriverName(pDisplayContext, &driver_name); - ASSERT(status == VA_STATUS_SUCCESS); - if (status != VA_STATUS_SUCCESS) - return status; - - if ((compat = malloc(sizeof(*compat))) == NULL) - return VA_STATUS_ERROR_ALLOCATION_FAILED; - compat->buffers = NULL; - compat->buffers_count_max = 0; - compat->compat_version = compat_version; - compat->compat_ctx = NULL; - compat->driver_name = driver_name; - compat->context_map = NULL; - compat->last_context_map_match = NULL; - ctx->compat = compat; - - if (strcmp(driver_name, "psb") == 0) - compat->driver_id = VA_DRIVER_ID_POULSBO; - else if (strcmp(driver_name, "iegd") == 0) - compat->driver_id = VA_DRIVER_ID_IEGD; - else - compat->driver_id = VA_DRIVER_ID_UNKNOWN; - - switch (compat_version) { - case 29: - if ((ctx_0_29 = malloc(sizeof(*ctx_0_29))) == NULL) - return VA_STATUS_ERROR_ALLOCATION_FAILED; - memcpy(ctx_0_29, compat_ctx, sizeof(*ctx_0_29)); - va_compat_translate_VADriverContext_0_29(compat, ctx_0_29); - compat->compat_ctx = ctx_0_29; - COPY_FIELD(ctx, ctx_0_29, version_major); - COPY_FIELD(ctx, ctx_0_29, version_minor); - COPY_FIELD(ctx, ctx_0_29, max_profiles); - COPY_FIELD(ctx, ctx_0_29, max_entrypoints); - COPY_FIELD(ctx, ctx_0_29, max_attributes); - COPY_FIELD(ctx, ctx_0_29, max_image_formats); - COPY_FIELD(ctx, ctx_0_29, max_subpic_formats); - COPY_FIELD(ctx, ctx_0_29, max_display_attributes); - COPY_FIELD(ctx, ctx_0_29, str_vendor); - break; - case 30: - if ((ctx_0_30 = malloc(sizeof(*ctx_0_30))) == NULL) - return VA_STATUS_ERROR_ALLOCATION_FAILED; - memcpy(ctx_0_30, compat_ctx, sizeof(*ctx_0_30)); - va_compat_translate_VADriverContext_0_30(compat, ctx_0_30); - compat->compat_ctx = ctx_0_30; - COPY_FIELD(ctx, ctx_0_30, version_major); - COPY_FIELD(ctx, ctx_0_30, version_minor); - COPY_FIELD(ctx, ctx_0_30, max_profiles); - COPY_FIELD(ctx, ctx_0_30, max_entrypoints); - COPY_FIELD(ctx, ctx_0_30, max_attributes); - COPY_FIELD(ctx, ctx_0_30, max_image_formats); - COPY_FIELD(ctx, ctx_0_30, max_subpic_formats); - COPY_FIELD(ctx, ctx_0_30, max_display_attributes); - COPY_FIELD(ctx, ctx_0_30, str_vendor); - break; - case VA_MINOR_VERSION: - va_compat_translate_VADriverContext(compat, compat_ctx); - compat->compat_ctx = compat_ctx; - break; - default: - ASSERT(compat_version == 0); - return VA_STATUS_ERROR_UNKNOWN; - } - - va_compat_init_VADriverVTable(ctx, compat_version); - return VA_STATUS_SUCCESS; -} - -VAStatus va_compat_fini(VADisplay dpy) -{ - VADriverContextP ctx = CTX(dpy); - VACompatContextP compat = ctx->compat; - int i; - - if (compat == NULL) - return VA_STATUS_SUCCESS; - - if (compat->driver_name) - { - free(compat->driver_name); - compat->driver_name = NULL; - } - - if (compat->buffers) - { - for (i = 0; i < compat->buffers_count_max; i++) - { - if (compat->buffers[i].id) - va_DestroyBufferCompat(ctx, compat->buffers[i].id); - } - free(compat->buffers); - compat->buffers = NULL; - } - - if (compat->compat_ctx && compat->compat_version != VA_MINOR_VERSION) - { - free(compat->compat_ctx); - compat->compat_ctx = NULL; - } - - if (compat->context_map) - { - VAContextMapP d, m = compat->context_map; - while (m) { - d = m; - m = m->next; - free(d); - } - } - compat->last_context_map_match = NULL; - - free(compat); - ctx->compat = NULL; - return VA_STATUS_SUCCESS; -} diff -Nru libva-0.31.0+latest2/va/va_compat.h libva-0.31.0+latest3/va/va_compat.h --- libva-0.31.0+latest2/va/va_compat.h 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/va/va_compat.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,1467 +0,0 @@ -/* - * Copyright (C) 2009 Splitted-Desktop Systems. 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. - */ - -#ifndef VA_COMPAT_H -#define VA_COMPAT_H - -VAStatus va_compat_init(VADisplay dpy, int compat_version, void *compat_ctx); -VAStatus va_compat_fini(VADisplay dpy); - -/* H.264 Picture (0.29) */ -typedef struct _VAPictureH264_0_29 -{ - VASurfaceID picture_id; - unsigned int flags; - unsigned int TopFieldOrderCnt; - unsigned int BottomFieldOrderCnt; -} VAPictureH264_0_29; - -/* H.264 Picture Parameter Buffer (0.29) */ -typedef struct _VAPictureParameterBufferH264_0_29 -{ - VAPictureH264_0_29 CurrPic; - VAPictureH264_0_29 ReferenceFrames[16]; /* in DPB */ - unsigned short picture_width_in_mbs_minus1; - unsigned short picture_height_in_mbs_minus1; - unsigned char bit_depth_luma_minus8; - unsigned char bit_depth_chroma_minus8; - unsigned char num_ref_frames; - union { - struct { - unsigned char chroma_format_idc : 2; - unsigned char residual_colour_transform_flag : 1; - unsigned char frame_mbs_only_flag : 1; - unsigned char mb_adaptive_frame_field_flag : 1; - unsigned char direct_8x8_inference_flag : 1; - unsigned char MinLumaBiPredSize8x8 : 1; /* see A.3.3.2 */ - }; - unsigned char seq_fields; - }; - unsigned char num_slice_groups_minus1; - unsigned char slice_group_map_type; - signed char pic_init_qp_minus26; - signed char chroma_qp_index_offset; - signed char second_chroma_qp_index_offset; - union { - struct { - unsigned char entropy_coding_mode_flag : 1; - unsigned char weighted_pred_flag : 1; - unsigned char weighted_bipred_idc : 2; - unsigned char transform_8x8_mode_flag : 1; - unsigned char field_pic_flag : 1; - unsigned char constrained_intra_pred_flag : 1; - }; - unsigned char pic_fields; - }; - unsigned short frame_num; -} VAPictureParameterBufferH264_0_29; - -/* H.264 Slice Parameter Buffer (0.29) */ -typedef struct _VASliceParameterBufferH264_0_29 -{ - unsigned int slice_data_size;/* number of bytes in the slice data buffer for this slice */ - unsigned int slice_data_offset;/* the offset to the NAL start code for this slice */ - unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */ - unsigned short slice_data_bit_offset; /* bit offset from NAL start code to the beginning of slice data */ - unsigned short first_mb_in_slice; - unsigned char slice_type; - unsigned char direct_spatial_mv_pred_flag; - unsigned char num_ref_idx_l0_active_minus1; - unsigned char num_ref_idx_l1_active_minus1; - unsigned char cabac_init_idc; - char slice_qp_delta; - unsigned char disable_deblocking_filter_idc; - char slice_alpha_c0_offset_div2; - char slice_beta_offset_div2; - VAPictureH264_0_29 RefPicList0[32]; /* See 8.2.4.2 */ - VAPictureH264_0_29 RefPicList1[32]; /* See 8.2.4.2 */ - unsigned char luma_log2_weight_denom; - unsigned char chroma_log2_weight_denom; - unsigned char luma_weight_l0_flag; - short luma_weight_l0[32]; - short luma_offset_l0[32]; - unsigned char chroma_weight_l0_flag; - short chroma_weight_l0[32][2]; - short chroma_offset_l0[32][2]; - unsigned char luma_weight_l1_flag; - short luma_weight_l1[32]; - short luma_offset_l1[32]; - unsigned char chroma_weight_l1_flag; - short chroma_weight_l1[32][2]; - short chroma_offset_l1[32][2]; -} VASliceParameterBufferH264_0_29; - -/* VC-1 Picture Parameter Buffer (0.29) */ -typedef struct _VAPictureParameterBufferVC1_0_29 -{ - VASurfaceID forward_reference_picture; - VASurfaceID backward_reference_picture; - /* if out-of-loop post-processing is done on the render - target, then we need to keep the in-loop decoded - picture as a reference picture */ - VASurfaceID inloop_decoded_picture; - - /* sequence layer for AP or meta data for SP and MP */ - union { - struct { - unsigned char interlace : 1; /* SEQUENCE_LAYER::INTERLACE */ - unsigned char syncmarker : 1;/* METADATA::SYNCMARKER */ - unsigned char overlap : 1;/* METADATA::OVERLAP */ - }; - unsigned char sequence_fields; - }; - - unsigned short coded_width; /* ENTRY_POINT_LAYER::CODED_WIDTH */ - unsigned short coded_height; /* ENTRY_POINT_LAYER::CODED_HEIGHT */ - unsigned char closed_entry; /* ENTRY_POINT_LAYER::CLOSED_ENTRY */ - unsigned char broken_link; /* ENTRY_POINT_LAYER::BROKEN_LINK */ - unsigned char loopfilter; /* ENTRY_POINT_LAYER::LOOPFILTER */ - unsigned char conditional_overlap_flag; /* ENTRY_POINT_LAYER::CONDOVER */ - unsigned char fast_uvmc_flag; /* ENTRY_POINT_LAYER::FASTUVMC */ - union { - struct { - unsigned char range_mapping_luma_flag: 1; /* ENTRY_POINT_LAYER::RANGE_MAPY_FLAG */ - unsigned char range_mapping_luma: 3; /* ENTRY_POINT_LAYER::RANGE_MAPY */ - unsigned char range_mapping_chroma_flag: 1; /* ENTRY_POINT_LAYER::RANGE_MAPUV_FLAG */ - unsigned char range_mapping_chroma: 3; /* ENTRY_POINT_LAYER::RANGE_MAPUV */ - }; - unsigned char range_mapping_fields; - }; - - unsigned char b_picture_fraction; /* PICTURE_LAYER::BFRACTION */ - unsigned char cbp_table; /* PICTURE_LAYER::CBPTAB/ICBPTAB */ - unsigned char mb_mode_table; /* PICTURE_LAYER::MBMODETAB */ - unsigned char range_reduction_frame;/* PICTURE_LAYER::RANGEREDFRM */ - unsigned char rounding_control; /* PICTURE_LAYER::RNDCTRL */ - unsigned char post_processing; /* PICTURE_LAYER::POSTPROC */ - unsigned char picture_resolution_index; /* PICTURE_LAYER::RESPIC */ - unsigned char luma_scale; /* PICTURE_LAYER::LUMSCALE */ - unsigned char luma_shift; /* PICTURE_LAYER::LUMSHIFT */ - union { - struct { - unsigned char picture_type : 2; /* PICTURE_LAYER::PTYPE */ - unsigned char frame_coding_mode : 3;/* PICTURE_LAYER::FCM */ - unsigned char top_field_first : 1;/* PICTURE_LAYER::TFF */ - unsigned char is_first_field : 1; /* set to 1 if it is the first field */ - unsigned char intensity_compensation: 1;/* PICTURE_LAYER::INTCOMP */ - }; - unsigned char picture_fields; - }; - union { - struct { - unsigned char mv_type_mb : 1; /* PICTURE::MVTYPEMB */ - unsigned char direct_mb : 1; /* PICTURE::DIRECTMB */ - unsigned char skip_mb : 1; /* PICTURE::SKIPMB */ - unsigned char field_tx : 1; /* PICTURE::FIELDTX */ - unsigned char forward_mb : 1; /* PICTURE::FORWARDMB */ - unsigned char ac_pred : 1; /* PICTURE::ACPRED */ - unsigned char overflags : 1; /* PICTURE::OVERFLAGS */ - }; - unsigned char raw_coding_flag; - }; - union { - struct { - unsigned char bp_mv_type_mb : 1; /* PICTURE::MVTYPEMB */ - unsigned char bp_direct_mb : 1; /* PICTURE::DIRECTMB */ - unsigned char bp_skip_mb : 1; /* PICTURE::SKIPMB */ - unsigned char bp_field_tx : 1; /* PICTURE::FIELDTX */ - unsigned char bp_forward_mb : 1; /* PICTURE::FORWARDMB */ - unsigned char bp_ac_pred : 1; /* PICTURE::ACPRED */ - unsigned char bp_overflags : 1; /* PICTURE::OVERFLAGS */ - }; - unsigned char bitplane_present_flag; /* signal what bitplane is being passed via the bitplane buffer */ - }; - union { - struct { - unsigned char reference_distance_flag : 1;/* PICTURE_LAYER::REFDIST_FLAG */ - unsigned char reference_distance : 5;/* PICTURE_LAYER::REFDIST */ - unsigned char num_reference_pictures: 1;/* PICTURE_LAYER::NUMREF */ - unsigned char reference_field_pic_indicator : 1;/* PICTURE_LAYER::REFFIELD */ - }; - unsigned short reference_fields; - }; - union { - struct { - VAMvModeVC1 mv_mode : 3; /* PICTURE_LAYER::MVMODE */ - VAMvModeVC1 mv_mode2 : 3; /* PICTURE_LAYER::MVMODE2 */ - unsigned char mv_table : 3; /* PICTURE_LAYER::MVTAB/IMVTAB */ - unsigned char two_mv_block_pattern_table: 2; /* PICTURE_LAYER::2MVBPTAB */ - unsigned char four_mv_switch : 1; /* PICTURE_LAYER::4MVSWITCH */ - unsigned char four_mv_block_pattern_table : 2; /* PICTURE_LAYER::4MVBPTAB */ - unsigned char extended_mv_flag : 1; /* ENTRY_POINT_LAYER::EXTENDED_MV */ - unsigned char extended_mv_range : 2; /* PICTURE_LAYER::MVRANGE */ - unsigned char extended_dmv_flag : 1; /* ENTRY_POINT_LAYER::EXTENDED_DMV */ - unsigned char extended_dmv_range : 2; /* PICTURE_LAYER::DMVRANGE */ - }; - unsigned int mv_fields; - }; - union { - struct { - unsigned char dquant : 2; /* ENTRY_POINT_LAYER::DQUANT */ - unsigned char quantizer : 2; /* ENTRY_POINT_LAYER::QUANTIZER */ - unsigned char half_qp : 1; /* PICTURE_LAYER::HALFQP */ - unsigned char pic_quantizer_scale : 5;/* PICTURE_LAYER::PQUANT */ - unsigned char pic_quantizer_type : 1;/* PICTURE_LAYER::PQUANTIZER */ - unsigned char dq_frame : 1; /* VOPDQUANT::DQUANTFRM */ - unsigned char dq_profile : 2; /* VOPDQUANT::DQPROFILE */ - unsigned char dq_sb_edge : 2; /* VOPDQUANT::DQSBEDGE */ - unsigned char dq_db_edge : 2; /* VOPDQUANT::DQDBEDGE */ - unsigned char dq_binary_level : 1; /* VOPDQUANT::DQBILEVEL */ - unsigned char alt_pic_quantizer : 5;/* VOPDQUANT::ALTPQUANT */ - }; - unsigned long pic_quantizer_fields; - }; - union { - struct { - unsigned char variable_sized_transform_flag : 1;/* ENTRY_POINT_LAYER::VSTRANSFORM */ - unsigned char mb_level_transform_type_flag : 1;/* PICTURE_LAYER::TTMBF */ - unsigned char frame_level_transform_type : 2;/* PICTURE_LAYER::TTFRM */ - unsigned char transform_ac_codingset_idx1 : 2;/* PICTURE_LAYER::TRANSACFRM */ - unsigned char transform_ac_codingset_idx2 : 2;/* PICTURE_LAYER::TRANSACFRM2 */ - unsigned char intra_transform_dc_table : 1;/* PICTURE_LAYER::TRANSDCTAB */ - }; - unsigned short transform_fields; - }; -} VAPictureParameterBufferVC1_0_29; - -/* MPEG-2 Picture Parameter Buffer (0.29) */ -typedef struct _VAPictureParameterBufferMPEG2_0_29 -{ - unsigned short horizontal_size; - unsigned short vertical_size; - VASurfaceID forward_reference_picture; - VASurfaceID backward_reference_picture; - /* meanings of the following fields are the same as in the standard */ - int picture_coding_type; - int f_code; /* pack all four fcode into this */ - union { - struct { - unsigned char intra_dc_precision : 2; - unsigned char picture_structure : 2; - unsigned char top_field_first : 1; - unsigned char frame_pred_frame_dct : 1; - unsigned char concealment_motion_vectors : 1; - unsigned char q_scale_type : 1; - unsigned char intra_vlc_format : 1; - unsigned char alternate_scan : 1; - unsigned char repeat_first_field : 1; - unsigned char progressive_frame : 1; - unsigned char is_first_field : 1; /* indicate whether the current field - * is the first field for field picture - */ - }; - unsigned int picture_coding_extension; - }; -} VAPictureParameterBufferMPEG2_0_29; - -/* MPEG-2 Slice Parameter Buffer (0.29) */ -typedef struct _VASliceParameterBufferMPEG2_0_29 -{ - unsigned int slice_data_size;/* number of bytes in the slice data buffer for this slice */ - unsigned int slice_data_offset;/* the offset to the first byte of slice data */ - unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */ - unsigned int macroblock_offset;/* the offset to the first bit of MB from the first byte of slice data */ - unsigned int slice_vertical_position; - int quantiser_scale_code; - int intra_slice_flag; -} VASliceParameterBufferMPEG2_0_29; - -/* MPEG-4 Picture Parameter Buffer (0.29) */ -typedef struct _VAPictureParameterBufferMPEG4_0_29 -{ - unsigned short vop_width; - unsigned short vop_height; - VASurfaceID forward_reference_picture; - VASurfaceID backward_reference_picture; - union { - struct { - unsigned char short_video_header : 1; - unsigned char chroma_format : 2; - unsigned char interlaced : 1; - unsigned char obmc_disable : 1; - unsigned char sprite_enable : 2; - unsigned char sprite_warping_accuracy : 2; - unsigned char quant_type : 1; - unsigned char quarter_sample : 1; - unsigned char data_partitioned : 1; - unsigned char reversible_vlc : 1; - }; - unsigned short vol_fields; - }; - unsigned char no_of_sprite_warping_points; - short sprite_trajectory_du[3]; - short sprite_trajectory_dv[3]; - unsigned char quant_precision; - union { - struct { - unsigned char vop_coding_type : 2; - unsigned char backward_reference_vop_coding_type : 2; - unsigned char vop_rounding_type : 1; - unsigned char intra_dc_vlc_thr : 3; - unsigned char top_field_first : 1; - unsigned char alternate_vertical_scan_flag : 1; - }; - unsigned short vop_fields; - }; - unsigned char vop_fcode_forward; - unsigned char vop_fcode_backward; - /* short header related */ - unsigned char num_gobs_in_vop; - unsigned char num_macroblocks_in_gob; - /* for direct mode prediction */ - short TRB; - short TRD; -} VAPictureParameterBufferMPEG4_0_29; - -/* H.264 Picture (0.30) */ -typedef struct _VAPictureH264_0_30 -{ - VASurfaceID picture_id; - unsigned int flags; - unsigned int TopFieldOrderCnt; - unsigned int BottomFieldOrderCnt; -} VAPictureH264_0_30; - -/* H.264 Picture Parameter Buffer (0.30) */ -typedef struct _VAPictureParameterBufferH264_0_30 -{ - VAPictureH264 CurrPic; - VAPictureH264 ReferenceFrames[16]; /* in DPB */ - unsigned short picture_width_in_mbs_minus1; - unsigned short picture_height_in_mbs_minus1; - unsigned char bit_depth_luma_minus8; - unsigned char bit_depth_chroma_minus8; - unsigned char num_ref_frames; - union { - struct { - unsigned char chroma_format_idc : 2; - unsigned char residual_colour_transform_flag : 1; - unsigned char frame_mbs_only_flag : 1; - unsigned char mb_adaptive_frame_field_flag : 1; - unsigned char direct_8x8_inference_flag : 1; - unsigned char MinLumaBiPredSize8x8 : 1; /* see A.3.3.2 */ - } bits; - unsigned char value; - } seq_fields; - unsigned char num_slice_groups_minus1; - unsigned char slice_group_map_type; - signed char pic_init_qp_minus26; - signed char chroma_qp_index_offset; - signed char second_chroma_qp_index_offset; - union { - struct { - unsigned char entropy_coding_mode_flag : 1; - unsigned char weighted_pred_flag : 1; - unsigned char weighted_bipred_idc : 2; - unsigned char transform_8x8_mode_flag : 1; - unsigned char field_pic_flag : 1; - unsigned char constrained_intra_pred_flag : 1; - } bits; - unsigned char value; - } pic_fields; - unsigned short frame_num; -} VAPictureParameterBufferH264_0_30; - -/* H.264 Slice Parameter Buffer (0.30) */ -typedef struct _VASliceParameterBufferH264_0_30 -{ - unsigned int slice_data_size;/* number of bytes in the slice data buffer for this slice */ - unsigned int slice_data_offset;/* the offset to the NAL start code for this slice */ - unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */ - unsigned short slice_data_bit_offset; /* bit offset from NAL start code to the beginning of slice data */ - unsigned short first_mb_in_slice; - unsigned char slice_type; - unsigned char direct_spatial_mv_pred_flag; - unsigned char num_ref_idx_l0_active_minus1; - unsigned char num_ref_idx_l1_active_minus1; - unsigned char cabac_init_idc; - char slice_qp_delta; - unsigned char disable_deblocking_filter_idc; - char slice_alpha_c0_offset_div2; - char slice_beta_offset_div2; - VAPictureH264 RefPicList0[32]; /* See 8.2.4.2 */ - VAPictureH264 RefPicList1[32]; /* See 8.2.4.2 */ - unsigned char luma_log2_weight_denom; - unsigned char chroma_log2_weight_denom; - unsigned char luma_weight_l0_flag; - short luma_weight_l0[32]; - short luma_offset_l0[32]; - unsigned char chroma_weight_l0_flag; - short chroma_weight_l0[32][2]; - short chroma_offset_l0[32][2]; - unsigned char luma_weight_l1_flag; - short luma_weight_l1[32]; - short luma_offset_l1[32]; - unsigned char chroma_weight_l1_flag; - short chroma_weight_l1[32][2]; - short chroma_offset_l1[32][2]; -} VASliceParameterBufferH264_0_30; - -/* VC-1 Picture Parameter Buffer (0.30) */ -typedef struct _VAPictureParameterBufferVC1_0_30 -{ - VASurfaceID forward_reference_picture; - VASurfaceID backward_reference_picture; - /* if out-of-loop post-processing is done on the render - target, then we need to keep the in-loop decoded - picture as a reference picture */ - VASurfaceID inloop_decoded_picture; - - /* sequence layer for AP or meta data for SP and MP */ - union { - struct { - unsigned char interlace : 1; /* SEQUENCE_LAYER::INTERLACE */ - unsigned char syncmarker : 1;/* METADATA::SYNCMARKER */ - unsigned char overlap : 1;/* METADATA::OVERLAP */ - } bits; - unsigned char value; - } sequence_fields; - - unsigned short coded_width; /* ENTRY_POINT_LAYER::CODED_WIDTH */ - unsigned short coded_height; /* ENTRY_POINT_LAYER::CODED_HEIGHT */ - unsigned char closed_entry; /* ENTRY_POINT_LAYER::CLOSED_ENTRY */ - unsigned char broken_link; /* ENTRY_POINT_LAYER::BROKEN_LINK */ - unsigned char loopfilter; /* ENTRY_POINT_LAYER::LOOPFILTER */ - unsigned char conditional_overlap_flag; /* ENTRY_POINT_LAYER::CONDOVER */ - unsigned char fast_uvmc_flag; /* ENTRY_POINT_LAYER::FASTUVMC */ - union { - struct { - unsigned char luma_flag : 1; /* ENTRY_POINT_LAYER::RANGE_MAPY_FLAG */ - unsigned char luma : 3; /* ENTRY_POINT_LAYER::RANGE_MAPY */ - unsigned char chroma_flag : 1; /* ENTRY_POINT_LAYER::RANGE_MAPUV_FLAG */ - unsigned char chroma : 3; /* ENTRY_POINT_LAYER::RANGE_MAPUV */ - } bits; - unsigned char value; - } range_mapping_fields; - - unsigned char b_picture_fraction; /* PICTURE_LAYER::BFRACTION */ - unsigned char cbp_table; /* PICTURE_LAYER::CBPTAB/ICBPTAB */ - unsigned char mb_mode_table; /* PICTURE_LAYER::MBMODETAB */ - unsigned char range_reduction_frame;/* PICTURE_LAYER::RANGEREDFRM */ - unsigned char rounding_control; /* PICTURE_LAYER::RNDCTRL */ - unsigned char post_processing; /* PICTURE_LAYER::POSTPROC */ - unsigned char picture_resolution_index; /* PICTURE_LAYER::RESPIC */ - unsigned char luma_scale; /* PICTURE_LAYER::LUMSCALE */ - unsigned char luma_shift; /* PICTURE_LAYER::LUMSHIFT */ - union { - struct { - unsigned char picture_type : 2; /* PICTURE_LAYER::PTYPE */ - unsigned char frame_coding_mode : 3; /* PICTURE_LAYER::FCM */ - unsigned char top_field_first : 1; /* PICTURE_LAYER::TFF */ - unsigned char is_first_field : 1; /* set to 1 if it is the first field */ - unsigned char intensity_compensation : 1; /* PICTURE_LAYER::INTCOMP */ - } bits; - unsigned char value; - } picture_fields; - union { - struct { - unsigned char mv_type_mb : 1; /* PICTURE::MVTYPEMB */ - unsigned char direct_mb : 1; /* PICTURE::DIRECTMB */ - unsigned char skip_mb : 1; /* PICTURE::SKIPMB */ - unsigned char field_tx : 1; /* PICTURE::FIELDTX */ - unsigned char forward_mb : 1; /* PICTURE::FORWARDMB */ - unsigned char ac_pred : 1; /* PICTURE::ACPRED */ - unsigned char overflags : 1; /* PICTURE::OVERFLAGS */ - } flags; - unsigned char value; - } raw_coding; - union { - struct { - unsigned char bp_mv_type_mb : 1; /* PICTURE::MVTYPEMB */ - unsigned char bp_direct_mb : 1; /* PICTURE::DIRECTMB */ - unsigned char bp_skip_mb : 1; /* PICTURE::SKIPMB */ - unsigned char bp_field_tx : 1; /* PICTURE::FIELDTX */ - unsigned char bp_forward_mb : 1; /* PICTURE::FORWARDMB */ - unsigned char bp_ac_pred : 1; /* PICTURE::ACPRED */ - unsigned char bp_overflags : 1; /* PICTURE::OVERFLAGS */ - } flags; - unsigned char value; - } bitplane_present; /* signal what bitplane is being passed via the bitplane buffer */ - union { - struct { - unsigned char reference_distance_flag : 1;/* PICTURE_LAYER::REFDIST_FLAG */ - unsigned char reference_distance : 5;/* PICTURE_LAYER::REFDIST */ - unsigned char num_reference_pictures: 1;/* PICTURE_LAYER::NUMREF */ - unsigned char reference_field_pic_indicator : 1;/* PICTURE_LAYER::REFFIELD */ - } bits; - unsigned short value; - } reference_fields; - union { - struct { - unsigned char mv_mode : 3; /* PICTURE_LAYER::MVMODE */ - unsigned char mv_mode2 : 3; /* PICTURE_LAYER::MVMODE2 */ - unsigned char mv_table : 3; /* PICTURE_LAYER::MVTAB/IMVTAB */ - unsigned char two_mv_block_pattern_table: 2; /* PICTURE_LAYER::2MVBPTAB */ - unsigned char four_mv_switch : 1; /* PICTURE_LAYER::4MVSWITCH */ - unsigned char four_mv_block_pattern_table : 2; /* PICTURE_LAYER::4MVBPTAB */ - unsigned char extended_mv_flag : 1; /* ENTRY_POINT_LAYER::EXTENDED_MV */ - unsigned char extended_mv_range : 2; /* PICTURE_LAYER::MVRANGE */ - unsigned char extended_dmv_flag : 1; /* ENTRY_POCHAR_LAYER::EXTENDED_DMV */ - unsigned char extended_dmv_range : 2; /* PICTURE_LAYER::DMVRANGE */ - } bits; - unsigned int value; - } mv_fields; - union { - struct { - unsigned char dquant : 2; /* ENTRY_POINT_LAYER::DQUANT */ - unsigned char quantizer : 2; /* ENTRY_POINT_LAYER::QUANTIZER */ - unsigned char half_qp : 1; /* PICTURE_LAYER::HALFQP */ - unsigned char pic_quantizer_scale : 5;/* PICTURE_LAYER::PQUANT */ - unsigned char pic_quantizer_type : 1;/* PICTURE_LAYER::PQUANTIZER */ - unsigned char dq_frame : 1; /* VOPDQUANT::DQUANTFRM */ - unsigned char dq_profile : 2; /* VOPDQUANT::DQPROFILE */ - unsigned char dq_sb_edge : 2; /* VOPDQUANT::DQSBEDGE */ - unsigned char dq_db_edge : 2; /* VOPDQUANT::DQDBEDGE */ - unsigned char dq_binary_level : 1; /* VOPDQUANT::DQBILEVEL */ - unsigned char alt_pic_quantizer : 5;/* VOPDQUANT::ALTPQUANT */ - } bits; - unsigned long value; - } pic_quantizer_fields; - union { - struct { - unsigned char variable_sized_transform_flag : 1;/* ENTRY_POINT_LAYER::VSTRANSFORM */ - unsigned char mb_level_transform_type_flag : 1;/* PICTURE_LAYER::TTMBF */ - unsigned char frame_level_transform_type : 2;/* PICTURE_LAYER::TTFRM */ - unsigned char transform_ac_codingset_idx1 : 2;/* PICTURE_LAYER::TRANSACFRM */ - unsigned char transform_ac_codingset_idx2 : 2;/* PICTURE_LAYER::TRANSACFRM2 */ - unsigned char intra_transform_dc_table : 1;/* PICTURE_LAYER::TRANSDCTAB */ - } bits; - unsigned short value; - } transform_fields; -} VAPictureParameterBufferVC1_0_30; - -/* MPEG-2 Picture Parameter Buffer (0.30) */ -typedef struct _VAPictureParameterBufferMPEG2_0_30 -{ - unsigned short horizontal_size; - unsigned short vertical_size; - VASurfaceID forward_reference_picture; - VASurfaceID backward_reference_picture; - /* meanings of the following fields are the same as in the standard */ - int picture_coding_type; - int f_code; /* pack all four fcode into this */ - union { - struct { - unsigned int intra_dc_precision : 2; - unsigned int picture_structure : 2; - unsigned int top_field_first : 1; - unsigned int frame_pred_frame_dct : 1; - unsigned int concealment_motion_vectors : 1; - unsigned int q_scale_type : 1; - unsigned int intra_vlc_format : 1; - unsigned int alternate_scan : 1; - unsigned int repeat_first_field : 1; - unsigned int progressive_frame : 1; - unsigned int is_first_field : 1; /* indicate whether the current field - * is the first field for field picture - */ - } bits; - unsigned int value; - } picture_coding_extension; -} VAPictureParameterBufferMPEG2_0_30; - -/* MPEG-2 Slice Parameter Buffer (0.29) */ -typedef VASliceParameterBufferMPEG2_0_29 VASliceParameterBufferMPEG2_0_30; - -/* MPEG-4 Picture Parameter Buffer (0.30) */ -typedef struct _VAPictureParameterBufferMPEG4_0_30 -{ - unsigned short vop_width; - unsigned short vop_height; - VASurfaceID forward_reference_picture; - VASurfaceID backward_reference_picture; - union { - struct { - unsigned char short_video_header : 1; - unsigned char chroma_format : 2; - unsigned char interlaced : 1; - unsigned char obmc_disable : 1; - unsigned char sprite_enable : 2; - unsigned char sprite_warping_accuracy : 2; - unsigned char quant_type : 1; - unsigned char quarter_sample : 1; - unsigned char data_partitioned : 1; - unsigned char reversible_vlc : 1; - } bits; - unsigned short value; - } vol_fields; - unsigned char no_of_sprite_warping_points; - short sprite_trajectory_du[3]; - short sprite_trajectory_dv[3]; - unsigned char quant_precision; - union { - struct { - unsigned char vop_coding_type : 2; - unsigned char backward_reference_vop_coding_type : 2; - unsigned char vop_rounding_type : 1; - unsigned char intra_dc_vlc_thr : 3; - unsigned char top_field_first : 1; - unsigned char alternate_vertical_scan_flag : 1; - } bits; - unsigned short value; - } vop_fields; - unsigned char vop_fcode_forward; - unsigned char vop_fcode_backward; - /* short header related */ - unsigned char num_gobs_in_vop; - unsigned char num_macroblocks_in_gob; - /* for direct mode prediction */ - short TRB; - short TRD; -} VAPictureParameterBufferMPEG4_0_30; - -/* Encode Slice Parameter Buffer (0.30) */ -typedef struct _VAEncSliceParameterBuffer_0_30 -{ - unsigned int start_row_number; /* starting MB row number for this slice */ - unsigned int slice_height; /* slice height measured in MB */ - union { - struct { - unsigned char is_intra : 1; - unsigned char disable_deblocking_filter_idc : 2; - } bits; - unsigned char value; - } slice_flags; -} VAEncSliceParameterBuffer_0_30; - -/* MPEG-4 Picture Parameter Buffer (0.31) */ -typedef struct _VAPictureParameterBufferMPEG4_0_31 -{ - unsigned short vop_width; - unsigned short vop_height; - VASurfaceID forward_reference_picture; - VASurfaceID backward_reference_picture; - union { - struct { - unsigned int short_video_header : 1; - unsigned int chroma_format : 2; - unsigned int interlaced : 1; - unsigned int obmc_disable : 1; - unsigned int sprite_enable : 2; - unsigned int sprite_warping_accuracy : 2; - unsigned int quant_type : 1; - unsigned int quarter_sample : 1; - unsigned int data_partitioned : 1; - unsigned int reversible_vlc : 1; - } bits; - unsigned int value; - } vol_fields; - unsigned char no_of_sprite_warping_points; - short sprite_trajectory_du[3]; - short sprite_trajectory_dv[3]; - unsigned char quant_precision; - union { - struct { - unsigned int vop_coding_type : 2; - unsigned int backward_reference_vop_coding_type : 2; - unsigned int vop_rounding_type : 1; - unsigned int intra_dc_vlc_thr : 3; - unsigned int top_field_first : 1; - unsigned int alternate_vertical_scan_flag : 1; - } bits; - unsigned int value; - } vop_fields; - unsigned char vop_fcode_forward; - unsigned char vop_fcode_backward; - /* short header related */ - unsigned char num_gobs_in_vop; - unsigned char num_macroblocks_in_gob; - /* for direct mode prediction */ - short TRB; - short TRD; -} VAPictureParameterBufferMPEG4_0_31; - -typedef struct VADriverContext_0_29 *VADriverContextP_0_29; - -/* Driver VTable (0.29) */ -struct VADriverVTable_0_29 -{ - VAStatus (*vaTerminate) ( VADriverContextP_0_29 ctx ); - - VAStatus (*vaQueryConfigProfiles) ( - VADriverContextP_0_29 ctx, - VAProfile *profile_list, /* out */ - int *num_profiles /* out */ - ); - - VAStatus (*vaQueryConfigEntrypoints) ( - VADriverContextP_0_29 ctx, - VAProfile profile, - VAEntrypoint *entrypoint_list, /* out */ - int *num_entrypoints /* out */ - ); - - VAStatus (*vaGetConfigAttributes) ( - VADriverContextP_0_29 ctx, - VAProfile profile, - VAEntrypoint entrypoint, - VAConfigAttrib *attrib_list, /* in/out */ - int num_attribs - ); - - VAStatus (*vaCreateConfig) ( - VADriverContextP_0_29 ctx, - VAProfile profile, - VAEntrypoint entrypoint, - VAConfigAttrib *attrib_list, - int num_attribs, - VAConfigID *config_id /* out */ - ); - - VAStatus (*vaDestroyConfig) ( - VADriverContextP_0_29 ctx, - VAConfigID config_id - ); - - VAStatus (*vaQueryConfigAttributes) ( - VADriverContextP_0_29 ctx, - VAConfigID config_id, - VAProfile *profile, /* out */ - VAEntrypoint *entrypoint, /* out */ - VAConfigAttrib *attrib_list, /* out */ - int *num_attribs /* out */ - ); - - VAStatus (*vaCreateSurfaces) ( - VADriverContextP_0_29 ctx, - int width, - int height, - int format, - int num_surfaces, - VASurfaceID *surfaces /* out */ - ); - - VAStatus (*vaDestroySurfaces) ( - VADriverContextP_0_29 ctx, - VASurfaceID *surface_list, - int num_surfaces - ); - - VAStatus (*vaCreateContext) ( - VADriverContextP_0_29 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_0_29 ctx, - VAContextID context - ); - - VAStatus (*vaCreateBuffer) ( - VADriverContextP_0_29 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_0_29 ctx, - VABufferID buf_id, /* in */ - unsigned int num_elements /* in */ - ); - - VAStatus (*vaMapBuffer) ( - VADriverContextP_0_29 ctx, - VABufferID buf_id, /* in */ - void **pbuf /* out */ - ); - - VAStatus (*vaUnmapBuffer) ( - VADriverContextP_0_29 ctx, - VABufferID buf_id /* in */ - ); - - VAStatus (*vaDestroyBuffer) ( - VADriverContextP_0_29 ctx, - VABufferID buffer_id - ); - - VAStatus (*vaBeginPicture) ( - VADriverContextP_0_29 ctx, - VAContextID context, - VASurfaceID render_target - ); - - VAStatus (*vaRenderPicture) ( - VADriverContextP_0_29 ctx, - VAContextID context, - VABufferID *buffers, - int num_buffers - ); - - VAStatus (*vaEndPicture) ( - VADriverContextP_0_29 ctx, - VAContextID context - ); - - VAStatus (*vaSyncSurface) ( - VADriverContextP_0_29 ctx, - VAContextID context, - VASurfaceID render_target - ); - - VAStatus (*vaQuerySurfaceStatus) ( - VADriverContextP_0_29 ctx, - VASurfaceID render_target, - VASurfaceStatus *status /* out */ - ); - - VAStatus (*vaPutSurface) ( - VADriverContextP_0_29 ctx, - VASurfaceID surface, - unsigned long 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_0_29 ctx, - VAImageFormat *format_list, /* out */ - int *num_formats /* out */ - ); - - VAStatus (*vaCreateImage) ( - VADriverContextP_0_29 ctx, - VAImageFormat *format, - int width, - int height, - VAImage *image /* out */ - ); - - VAStatus (*vaDeriveImage) ( - VADriverContextP_0_29 ctx, - VASurfaceID surface, - VAImage *image /* out */ - ); - - VAStatus (*vaDestroyImage) ( - VADriverContextP_0_29 ctx, - VAImageID image - ); - - VAStatus (*vaSetImagePalette) ( - VADriverContextP_0_29 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_0_29 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_0_29 ctx, - VASurfaceID surface, - VAImageID image, - int src_x, - int src_y, - unsigned int width, - unsigned int height, - int dest_x, - int dest_y - ); - - VAStatus (*vaPutImage2) ( - VADriverContextP_0_29 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_0_29 ctx, - VAImageFormat *format_list, /* out */ - unsigned int *flags, /* out */ - unsigned int *num_formats /* out */ - ); - - VAStatus (*vaCreateSubpicture) ( - VADriverContextP_0_29 ctx, - VAImageID image, - VASubpictureID *subpicture /* out */ - ); - - VAStatus (*vaDestroySubpicture) ( - VADriverContextP_0_29 ctx, - VASubpictureID subpicture - ); - - VAStatus (*vaSetSubpictureImage) ( - VADriverContextP_0_29 ctx, - VASubpictureID subpicture, - VAImageID image - ); - - VAStatus (*vaSetSubpicturePalette) ( - VADriverContextP_0_29 ctx, - VASubpictureID subpicture, - /* - * 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 - */ - unsigned char *palette - ); - - VAStatus (*vaSetSubpictureChromakey) ( - VADriverContextP_0_29 ctx, - VASubpictureID subpicture, - unsigned int chromakey_min, - unsigned int chromakey_max, - unsigned int chromakey_mask - ); - - VAStatus (*vaSetSubpictureGlobalAlpha) ( - VADriverContextP_0_29 ctx, - VASubpictureID subpicture, - float global_alpha - ); - - VAStatus (*vaAssociateSubpicture) ( - VADriverContextP_0_29 ctx, - VASubpictureID subpicture, - VASurfaceID *target_surfaces, - int num_surfaces, - short src_x, /* upper left offset in subpicture */ - short src_y, - short dest_x, /* upper left offset in surface */ - short dest_y, - unsigned short width, - unsigned short height, - /* - * whether to enable chroma-keying or global-alpha - * see VA_SUBPICTURE_XXX values - */ - unsigned int flags - ); - - VAStatus (*vaAssociateSubpicture2) ( - VADriverContextP_0_29 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_0_29 ctx, - VASubpictureID subpicture, - VASurfaceID *target_surfaces, - int num_surfaces - ); - - VAStatus (*vaQueryDisplayAttributes) ( - VADriverContextP_0_29 ctx, - VADisplayAttribute *attr_list, /* out */ - int *num_attributes /* out */ - ); - - VAStatus (*vaGetDisplayAttributes) ( - VADriverContextP_0_29 ctx, - VADisplayAttribute *attr_list, /* in/out */ - int num_attributes - ); - - VAStatus (*vaSetDisplayAttributes) ( - VADriverContextP_0_29 ctx, - VADisplayAttribute *attr_list, - int num_attributes - ); - - - VAStatus (*vaDbgCopySurfaceToBuffer) ( - VADriverContextP_0_29 ctx, - VASurfaceID surface, - void **buffer, /* out */ - unsigned int *stride /* out */ - ); -}; - -/* Driver context (0.29) */ -struct VADriverContext_0_29 -{ - void *old_pNext; /* preserved for binary compatibility */ - - void *pDriverData; - struct VADriverVTable_0_29 vtable; - - void *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 */ -}; - -/* Forward declarations for VA API 0.30 */ -struct v4l2_format; -struct v4l2_buffer; -typedef struct VADriverContext_0_30 *VADriverContextP_0_30; - -/* Driver VTable (0.30) */ -struct VADriverVTable_0_30 -{ - VAStatus (*vaTerminate) ( VADriverContextP_0_30 ctx ); - - VAStatus (*vaQueryConfigProfiles) ( - VADriverContextP_0_30 ctx, - VAProfile *profile_list, /* out */ - int *num_profiles /* out */ - ); - - VAStatus (*vaQueryConfigEntrypoints) ( - VADriverContextP_0_30 ctx, - VAProfile profile, - VAEntrypoint *entrypoint_list, /* out */ - int *num_entrypoints /* out */ - ); - - VAStatus (*vaGetConfigAttributes) ( - VADriverContextP_0_30 ctx, - VAProfile profile, - VAEntrypoint entrypoint, - VAConfigAttrib *attrib_list, /* in/out */ - int num_attribs - ); - - VAStatus (*vaCreateConfig) ( - VADriverContextP_0_30 ctx, - VAProfile profile, - VAEntrypoint entrypoint, - VAConfigAttrib *attrib_list, - int num_attribs, - VAConfigID *config_id /* out */ - ); - - VAStatus (*vaDestroyConfig) ( - VADriverContextP_0_30 ctx, - VAConfigID config_id - ); - - VAStatus (*vaQueryConfigAttributes) ( - VADriverContextP_0_30 ctx, - VAConfigID config_id, - VAProfile *profile, /* out */ - VAEntrypoint *entrypoint, /* out */ - VAConfigAttrib *attrib_list, /* out */ - int *num_attribs /* out */ - ); - - VAStatus (*vaCreateSurfaces) ( - VADriverContextP_0_30 ctx, - int width, - int height, - int format, - int num_surfaces, - VASurfaceID *surfaces /* out */ - ); - - VAStatus (*vaDestroySurfaces) ( - VADriverContextP_0_30 ctx, - VASurfaceID *surface_list, - int num_surfaces - ); - - VAStatus (*vaCreateContext) ( - VADriverContextP_0_30 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_0_30 ctx, - VAContextID context - ); - - VAStatus (*vaCreateBuffer) ( - VADriverContextP_0_30 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_0_30 ctx, - VABufferID buf_id, /* in */ - unsigned int num_elements /* in */ - ); - - VAStatus (*vaMapBuffer) ( - VADriverContextP_0_30 ctx, - VABufferID buf_id, /* in */ - void **pbuf /* out */ - ); - - VAStatus (*vaUnmapBuffer) ( - VADriverContextP_0_30 ctx, - VABufferID buf_id /* in */ - ); - - VAStatus (*vaDestroyBuffer) ( - VADriverContextP_0_30 ctx, - VABufferID buffer_id - ); - - VAStatus (*vaBeginPicture) ( - VADriverContextP_0_30 ctx, - VAContextID context, - VASurfaceID render_target - ); - - VAStatus (*vaRenderPicture) ( - VADriverContextP_0_30 ctx, - VAContextID context, - VABufferID *buffers, - int num_buffers - ); - - VAStatus (*vaEndPicture) ( - VADriverContextP_0_30 ctx, - VAContextID context - ); - - VAStatus (*vaSyncSurface) ( - VADriverContextP_0_30 ctx, - VAContextID context, - VASurfaceID render_target - ); - - VAStatus (*vaQuerySurfaceStatus) ( - VADriverContextP_0_30 ctx, - VASurfaceID render_target, - VASurfaceStatus *status /* out */ - ); - - VAStatus (*vaPutSurface) ( - VADriverContextP_0_30 ctx, - VASurfaceID surface, - unsigned long 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_0_30 ctx, - VAImageFormat *format_list, /* out */ - int *num_formats /* out */ - ); - - VAStatus (*vaCreateImage) ( - VADriverContextP_0_30 ctx, - VAImageFormat *format, - int width, - int height, - VAImage *image /* out */ - ); - - VAStatus (*vaDeriveImage) ( - VADriverContextP_0_30 ctx, - VASurfaceID surface, - VAImage *image /* out */ - ); - - VAStatus (*vaDestroyImage) ( - VADriverContextP_0_30 ctx, - VAImageID image - ); - - VAStatus (*vaSetImagePalette) ( - VADriverContextP_0_30 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_0_30 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_0_30 ctx, - VASurfaceID surface, - VAImageID image, - int src_x, - int src_y, - unsigned int width, - unsigned int height, - int dest_x, - int dest_y - ); - - VAStatus (*vaPutImage2) ( - VADriverContextP_0_30 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_0_30 ctx, - VAImageFormat *format_list, /* out */ - unsigned int *flags, /* out */ - unsigned int *num_formats /* out */ - ); - - VAStatus (*vaCreateSubpicture) ( - VADriverContextP_0_30 ctx, - VAImageID image, - VASubpictureID *subpicture /* out */ - ); - - VAStatus (*vaDestroySubpicture) ( - VADriverContextP_0_30 ctx, - VASubpictureID subpicture - ); - - VAStatus (*vaSetSubpictureImage) ( - VADriverContextP_0_30 ctx, - VASubpictureID subpicture, - VAImageID image - ); - - VAStatus (*vaSetSubpictureChromakey) ( - VADriverContextP_0_30 ctx, - VASubpictureID subpicture, - unsigned int chromakey_min, - unsigned int chromakey_max, - unsigned int chromakey_mask - ); - - VAStatus (*vaSetSubpictureGlobalAlpha) ( - VADriverContextP_0_30 ctx, - VASubpictureID subpicture, - float global_alpha - ); - - VAStatus (*vaAssociateSubpicture) ( - VADriverContextP_0_30 ctx, - VASubpictureID subpicture, - VASurfaceID *target_surfaces, - int num_surfaces, - short src_x, /* upper left offset in subpicture */ - short src_y, - short dest_x, /* upper left offset in surface */ - short dest_y, - unsigned short width, - unsigned short height, - /* - * whether to enable chroma-keying or global-alpha - * see VA_SUBPICTURE_XXX values - */ - unsigned int flags - ); - - VAStatus (*vaAssociateSubpicture2) ( - VADriverContextP_0_30 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_0_30 ctx, - VASubpictureID subpicture, - VASurfaceID *target_surfaces, - int num_surfaces - ); - - VAStatus (*vaQueryDisplayAttributes) ( - VADriverContextP_0_30 ctx, - VADisplayAttribute *attr_list, /* out */ - int *num_attributes /* out */ - ); - - VAStatus (*vaGetDisplayAttributes) ( - VADriverContextP_0_30 ctx, - VADisplayAttribute *attr_list, /* in/out */ - int num_attributes - ); - - VAStatus (*vaSetDisplayAttributes) ( - VADriverContextP_0_30 ctx, - VADisplayAttribute *attr_list, - int num_attributes - ); - - /* device specific */ - VAStatus (*vaCreateSurfaceFromCIFrame) ( - VADriverContextP_0_30 ctx, - unsigned long frame_id, - VASurfaceID *surface /* out */ - ); - - - VAStatus (*vaCreateSurfaceFromV4L2Buf) ( - VADriverContextP_0_30 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_0_30 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 - ); -}; - -/* Driver context (0.30) */ -struct VADriverContext_0_30 -{ - void *pDriverData; - struct VADriverVTable_0_30 vtable; - - void *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; -}; - -/* Driver VTable and context (0.31) */ -#define VADriverVTable_0_31 VADriverVTable -#define VADriverContext_0_31 VADriverContext - -#endif /* VA_COMPAT_H */ diff -Nru libva-0.31.0+latest2/va/va_compat_lib.c libva-0.31.0+latest3/va/va_compat_lib.c --- libva-0.31.0+latest2/va/va_compat_lib.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/va/va_compat_lib.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,158 +0,0 @@ -/* - * Copyright (C) 2009 Splitted-Desktop Systems. 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 -#include -#include - -typedef void *VADisplay; -typedef int VAStatus; -typedef unsigned int VAGenericID; -typedef VAGenericID VAContextID; -typedef VAGenericID VASurfaceID; -typedef VAGenericID VAImageID; -typedef VAGenericID VASubpictureID; - -#define PREPARE_FUNC(NAME, RET, ARGS) \ - static RET (*lib_##NAME) ARGS; \ - if (lib_##NAME == NULL) \ - lib_##NAME = dlsym(RTLD_NEXT, #NAME); \ - assert(lib_##NAME != NULL) - -VAStatus -vaSyncSurface( - VADisplay dpy, - VAContextID context, - VASurfaceID render_target -) -{ - PREPARE_FUNC(vaSyncSurface, VAStatus, (VADisplay, VASurfaceID)); - - return lib_vaSyncSurface(dpy, render_target); -} - -VAStatus -vaPutImage( - VADisplay dpy, - VASurfaceID surface, - VAImageID image, - int src_x, - int src_y, - unsigned int width, - unsigned int height, - int dest_x, - int dest_y -) -{ - PREPARE_FUNC(vaPutImage, VAStatus, (VADisplay, VASurfaceID, VAImageID, - int, int, unsigned int, unsigned int, - int, int, unsigned int, unsigned int)); - - return lib_vaPutImage(dpy, surface, image, - src_x, src_y, width, height, - dest_x, dest_y, width, height); -} - -VAStatus -vaPutImage2( - 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 -) -{ - PREPARE_FUNC(vaPutImage, VAStatus, (VADisplay, VASurfaceID, VAImageID, - int, int, unsigned int, unsigned int, - int, int, unsigned int, unsigned int)); - - return lib_vaPutImage(dpy, surface, image, - src_x, src_y, src_width, src_height, - dest_x, dest_y, dest_width, dest_height); -} - -VAStatus -vaAssociateSubpicture( - VADisplay dpy, - VASubpictureID subpicture, - VASurfaceID *target_surfaces, - int num_surfaces, - short src_x, - short src_y, - short dest_x, - short dest_y, - unsigned short width, - unsigned short height, - unsigned int flags -) -{ - PREPARE_FUNC(vaAssociateSubpicture, - VAStatus, (VADisplay, VASubpictureID, VASurfaceID *, int, - short, short, unsigned short, unsigned short, - short, short, unsigned short, unsigned short, - unsigned int)); - - return lib_vaAssociateSubpicture(dpy, subpicture, - target_surfaces, num_surfaces, - src_x, src_y, width, height, - dest_x, dest_y, width, height, - flags); -} - -VAStatus -vaAssociateSubpicture2( - VADisplay dpy, - VASubpictureID subpicture, - VASurfaceID *target_surfaces, - int num_surfaces, - short src_x, - short src_y, - unsigned short src_width, - unsigned short src_height, - short dest_x, - short dest_y, - unsigned short dest_width, - unsigned short dest_height, - unsigned int flags -) -{ - PREPARE_FUNC(vaAssociateSubpicture, - VAStatus, (VADisplay, VASubpictureID, VASurfaceID *, int, - short, short, unsigned short, unsigned short, - short, short, unsigned short, unsigned short, - unsigned int)); - - return lib_vaAssociateSubpicture(dpy, subpicture, - target_surfaces, num_surfaces, - src_x, src_y, src_width, src_height, - dest_x, dest_y, dest_width, dest_height, - flags); -} diff -Nru libva-0.31.0+latest2/va/va_compat_template.h libva-0.31.0+latest3/va/va_compat_template.h --- libva-0.31.0+latest2/va/va_compat_template.h 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/va/va_compat_template.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,539 +0,0 @@ -/* - * Copyright (C) 2009 Splitted-Desktop Systems. 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. - */ - -#undef CONCAT_ -#define CONCAT_(x, y) x##y -#undef CONCAT -#define CONCAT(x, y) CONCAT_(x, y) -#undef MKCOMPAT_ -#define MKCOMPAT_(NAME,MINOR) CONCAT(CONCAT(NAME,_0_),MINOR) -#undef MKCOMPAT -#define MKCOMPAT(NAME) MKCOMPAT_(NAME,COMPAT_MINOR) -#undef STRUCT -#define STRUCT(BUFFER, CODEC) MKCOMPAT(VA##BUFFER##Buffer##CODEC) -#undef TRANSLATE_1 -#define TRANSLATE_1(NAME) CONCAT(va_compat_translate_,NAME) -#undef TRANSLATE_ -#define TRANSLATE_(NAME) TRANSLATE_1(MKCOMPAT(NAME)) -#undef TRANSLATE -#define TRANSLATE(BUFFER, CODEC) TRANSLATE_1(STRUCT(BUFFER,CODEC)) - -#undef COPY_ARRAY -#define COPY_ARRAY(DST, SRC, ARRAY) \ - memcpy((DST)->ARRAY, (SRC)->ARRAY, sizeof((DST)->ARRAY)) - -#undef COPY_FIELD -#define COPY_FIELD(DST, SRC, MEMBER) \ - (DST)->MEMBER = (SRC)->MEMBER - -#undef COPY_VTABLE__ -#define COPY_VTABLE__(DST, DST_MEMBER, SRC, SRC_MEMBER) \ - (DST##_vtable)->DST_MEMBER = (SRC##_vtable)->SRC_MEMBER - -#undef COPY_VTABLE_ -#define COPY_VTABLE_(DST, DST_SUFFIX, SRC, MEMBER) \ - COPY_VTABLE__(DST, MEMBER##_##DST_SUFFIX, SRC, MEMBER) - -#undef COPY_VTABLE -#define COPY_VTABLE(DST, SRC, MEMBER) \ - COPY_VTABLE__(DST, MEMBER, SRC, MEMBER) - -/* 0.29 */ -#if COMPAT_MAJOR == 0 && COMPAT_MINOR == 29 -#undef BFV -#define BFV(a, b) a -#undef BFM -#define BFM(a, b, c) c -#undef COPY_BIT_FIELD -#define COPY_BIT_FIELD(DST, SRC, FIELD, MEMBER) \ - (DST)->MEMBER = (SRC)->FIELD.bits.MEMBER -#undef COPY_BIT_FLAG -#define COPY_BIT_FLAG(DST, SRC, FIELD, MEMBER) \ - (DST)->MEMBER = (SRC)->FIELD.flags.MEMBER -#endif - -/* 0.29 glue to match 0.30 names */ -#undef M_raw_coding -#undef M_bitplane_present -#undef M_luma_flag -#undef M_luma -#undef M_chroma_flag -#undef M_chroma - -#if COMPAT_MAJOR == 0 && COMPAT_MINOR == 29 -#define M_raw_coding raw_coding_flag -#define M_bitplane_present bitplane_present_flag -#define M_luma_flag range_mapping_luma_flag -#define M_luma range_mapping_luma -#define M_chroma_flag range_mapping_chroma_flag -#define M_chroma range_mapping_chroma -#else -#define M_raw_coding raw_coding -#define M_bitplane_present bitplane_present -#define M_luma_flag luma_flag -#define M_luma luma -#define M_chroma_flag chroma_flag -#define M_chroma chroma -#endif - -/* 0.30 */ -#if COMPAT_MAJOR == 0 && COMPAT_MINOR == 30 -#undef BFV -#define BFV(a, b) a.b -#undef BFM -#define BFM(a, b, c) a.b.c -#undef COPY_BIT_FIELD -#define COPY_BIT_FIELD(DST, SRC, FIELD, MEMBER) \ - (DST)->FIELD.bits.MEMBER = (SRC)->FIELD.bits.MEMBER -#undef COPY_BIT_FLAG -#define COPY_BIT_FLAG(DST, SRC, FIELD, MEMBER) \ - (DST)->FIELD.flags.MEMBER = (SRC)->FIELD.flags.MEMBER -#endif - -#if COMPAT_MAJOR == 0 && COMPAT_MINOR < 31 -static VAStatus TRANSLATE_(VAPictureH264)( - VACompatContextP ctx, - void *dest_pic, - const void *src_pic -) -{ - MKCOMPAT(VAPictureH264) *dest = dest_pic; - const VAPictureH264 *src = src_pic; - - COPY_FIELD(dest, src, picture_id); - COPY_FIELD(dest, src, flags); - COPY_FIELD(dest, src, TopFieldOrderCnt); - COPY_FIELD(dest, src, BottomFieldOrderCnt); - - return VA_STATUS_SUCCESS; -} - -static VAStatus TRANSLATE(PictureParameter,H264)( - VACompatContextP ctx, - void *dest_buffer, - const void *src_buffer -) -{ - STRUCT(PictureParameter,H264) *dest = dest_buffer; - const VAPictureParameterBufferH264 *src = src_buffer; - VAStatus status; - int i; - - status = TRANSLATE_(VAPictureH264)(ctx, - &dest->CurrPic, &src->CurrPic); - if (status != VA_STATUS_SUCCESS) - return status; - - for (i = 0; i < 16; i++) { - status = TRANSLATE_(VAPictureH264)(ctx, - &dest->ReferenceFrames[i], - &src->ReferenceFrames[i]); - if (status != VA_STATUS_SUCCESS) - return status; - } - - COPY_FIELD(dest, src, picture_width_in_mbs_minus1); - COPY_FIELD(dest, src, picture_height_in_mbs_minus1); - COPY_FIELD(dest, src, bit_depth_luma_minus8); - COPY_FIELD(dest, src, bit_depth_chroma_minus8); - COPY_FIELD(dest, src, num_ref_frames); - dest->BFV(seq_fields, value) = 0; /* reset all bits */ - COPY_BIT_FIELD(dest, src, seq_fields, chroma_format_idc); - COPY_BIT_FIELD(dest, src, seq_fields, residual_colour_transform_flag); - COPY_BIT_FIELD(dest, src, seq_fields, frame_mbs_only_flag); - COPY_BIT_FIELD(dest, src, seq_fields, mb_adaptive_frame_field_flag); - COPY_BIT_FIELD(dest, src, seq_fields, direct_8x8_inference_flag); - COPY_BIT_FIELD(dest, src, seq_fields, MinLumaBiPredSize8x8); - COPY_FIELD(dest, src, num_slice_groups_minus1); - COPY_FIELD(dest, src, slice_group_map_type); - COPY_FIELD(dest, src, pic_init_qp_minus26); - COPY_FIELD(dest, src, chroma_qp_index_offset); - COPY_FIELD(dest, src, second_chroma_qp_index_offset); - dest->BFV(pic_fields, value) = 0; /* reset all bits */ - COPY_BIT_FIELD(dest, src, pic_fields, entropy_coding_mode_flag); - COPY_BIT_FIELD(dest, src, pic_fields, weighted_pred_flag); - COPY_BIT_FIELD(dest, src, pic_fields, weighted_bipred_idc); - COPY_BIT_FIELD(dest, src, pic_fields, transform_8x8_mode_flag); - COPY_BIT_FIELD(dest, src, pic_fields, field_pic_flag); - COPY_BIT_FIELD(dest, src, pic_fields, constrained_intra_pred_flag); - COPY_FIELD(dest, src, frame_num); - - return VA_STATUS_SUCCESS; -} - -static VAStatus TRANSLATE(SliceParameter,H264)( - VACompatContextP ctx, - void *dest_buffer, - const void *src_buffer -) -{ - STRUCT(SliceParameter,H264) *dest = dest_buffer; - const VASliceParameterBufferH264 *src = src_buffer; - VAStatus status; - int i; - - COPY_FIELD(dest, src, slice_data_size); - COPY_FIELD(dest, src, slice_data_offset); - COPY_FIELD(dest, src, slice_data_flag); - COPY_FIELD(dest, src, slice_data_bit_offset); - COPY_FIELD(dest, src, first_mb_in_slice); - COPY_FIELD(dest, src, slice_type); - COPY_FIELD(dest, src, direct_spatial_mv_pred_flag); - COPY_FIELD(dest, src, num_ref_idx_l0_active_minus1); - COPY_FIELD(dest, src, num_ref_idx_l1_active_minus1); - COPY_FIELD(dest, src, cabac_init_idc); - COPY_FIELD(dest, src, slice_qp_delta); - COPY_FIELD(dest, src, disable_deblocking_filter_idc); - COPY_FIELD(dest, src, slice_alpha_c0_offset_div2); - COPY_FIELD(dest, src, slice_beta_offset_div2); - for (i = 0; i < 32; i++) { - status = TRANSLATE_(VAPictureH264)(ctx, - &dest->RefPicList0[i], - &src->RefPicList0[i]); - if (status != VA_STATUS_SUCCESS) - return status; - status = TRANSLATE_(VAPictureH264)(ctx, - &dest->RefPicList1[i], - &src->RefPicList1[i]); - if (status != VA_STATUS_SUCCESS) - return status; - } - COPY_FIELD(dest, src, luma_log2_weight_denom); - COPY_FIELD(dest, src, chroma_log2_weight_denom); - COPY_FIELD(dest, src, luma_weight_l0_flag); - COPY_ARRAY(dest, src, luma_weight_l0); - COPY_ARRAY(dest, src, luma_offset_l0); - COPY_FIELD(dest, src, chroma_weight_l0_flag); - COPY_ARRAY(dest, src, chroma_weight_l0); - COPY_ARRAY(dest, src, chroma_offset_l0); - COPY_FIELD(dest, src, luma_weight_l1_flag); - COPY_ARRAY(dest, src, luma_weight_l1); - COPY_ARRAY(dest, src, luma_offset_l1); - COPY_FIELD(dest, src, chroma_weight_l1_flag); - COPY_ARRAY(dest, src, chroma_weight_l1); - COPY_ARRAY(dest, src, chroma_offset_l1); - - return VA_STATUS_SUCCESS; -} - -static VAStatus TRANSLATE(PictureParameter,VC1)( - VACompatContextP ctx, - void *dest_buffer, - const void *src_buffer -) -{ - STRUCT(PictureParameter,VC1) *dest = dest_buffer; - const VAPictureParameterBufferVC1 *src = src_buffer; - - COPY_FIELD(dest, src, forward_reference_picture); - COPY_FIELD(dest, src, backward_reference_picture); - COPY_FIELD(dest, src, inloop_decoded_picture); - dest->BFV(sequence_fields, value) = 0; /* reset all bits */ - COPY_BIT_FIELD(dest, src, sequence_fields, interlace); - COPY_BIT_FIELD(dest, src, sequence_fields, syncmarker); - COPY_BIT_FIELD(dest, src, sequence_fields, overlap); - COPY_FIELD(dest, src, coded_width); - COPY_FIELD(dest, src, coded_height); -#if COMPAT_MAJOR == 0 && COMPAT_MINOR == 30 - dest->closed_entry = src->entrypoint_fields.bits.closed_entry; - dest->broken_link = src->entrypoint_fields.bits.broken_link; - dest->loopfilter = src->entrypoint_fields.bits.loopfilter; -#else - COPY_BIT_FIELD(dest, src, entrypoint_fields, closed_entry); - COPY_BIT_FIELD(dest, src, entrypoint_fields, broken_link); - COPY_BIT_FIELD(dest, src, entrypoint_fields, loopfilter); -#endif - COPY_FIELD(dest, src, conditional_overlap_flag); - COPY_FIELD(dest, src, fast_uvmc_flag); - dest->BFV(range_mapping_fields, value) = 0; /* reset all bits */ - dest->BFM(range_mapping_fields, bits, M_luma_flag) = - src->range_mapping_fields.bits.luma_flag; - dest->BFM(range_mapping_fields, bits, M_luma) = - src->range_mapping_fields.bits.luma; - dest->BFM(range_mapping_fields, bits, M_chroma_flag) = - src->range_mapping_fields.bits.chroma_flag; - dest->BFM(range_mapping_fields, bits, M_chroma) = - src->range_mapping_fields.bits.chroma; - COPY_FIELD(dest, src, b_picture_fraction); - COPY_FIELD(dest, src, cbp_table); - COPY_FIELD(dest, src, mb_mode_table); - COPY_FIELD(dest, src, range_reduction_frame); - COPY_FIELD(dest, src, rounding_control); - COPY_FIELD(dest, src, post_processing); - COPY_FIELD(dest, src, picture_resolution_index); - COPY_FIELD(dest, src, luma_scale); - COPY_FIELD(dest, src, luma_shift); - dest->BFV(picture_fields, value) = 0; /* reset all bits */ - COPY_BIT_FIELD(dest, src, picture_fields, picture_type); - COPY_BIT_FIELD(dest, src, picture_fields, frame_coding_mode); - COPY_BIT_FIELD(dest, src, picture_fields, top_field_first); - COPY_BIT_FIELD(dest, src, picture_fields, is_first_field); - COPY_BIT_FIELD(dest, src, picture_fields, intensity_compensation); - dest->BFV(M_raw_coding, value) = 0; /* reset all bits */ - COPY_BIT_FLAG(dest, src, raw_coding, mv_type_mb); - COPY_BIT_FLAG(dest, src, raw_coding, direct_mb); - COPY_BIT_FLAG(dest, src, raw_coding, skip_mb); - COPY_BIT_FLAG(dest, src, raw_coding, field_tx); - COPY_BIT_FLAG(dest, src, raw_coding, forward_mb); - COPY_BIT_FLAG(dest, src, raw_coding, ac_pred); - COPY_BIT_FLAG(dest, src, raw_coding, overflags); - dest->BFV(M_bitplane_present, value) = 0; /* reset all bits */ - COPY_BIT_FLAG(dest, src, bitplane_present, bp_mv_type_mb); - COPY_BIT_FLAG(dest, src, bitplane_present, bp_direct_mb); - COPY_BIT_FLAG(dest, src, bitplane_present, bp_skip_mb); - COPY_BIT_FLAG(dest, src, bitplane_present, bp_field_tx); - COPY_BIT_FLAG(dest, src, bitplane_present, bp_forward_mb); - COPY_BIT_FLAG(dest, src, bitplane_present, bp_ac_pred); - COPY_BIT_FLAG(dest, src, bitplane_present, bp_overflags); - dest->BFV(reference_fields, value) = 0; /* reset all bits */ - COPY_BIT_FIELD(dest, src, reference_fields, reference_distance_flag); - COPY_BIT_FIELD(dest, src, reference_fields, reference_distance); - COPY_BIT_FIELD(dest, src, reference_fields, num_reference_pictures); - COPY_BIT_FIELD(dest, src, reference_fields, reference_field_pic_indicator); - dest->BFV(mv_fields, value) = 0; /* reset all bits */ - COPY_BIT_FIELD(dest, src, mv_fields, mv_mode); - COPY_BIT_FIELD(dest, src, mv_fields, mv_mode2); - COPY_BIT_FIELD(dest, src, mv_fields, mv_table); - COPY_BIT_FIELD(dest, src, mv_fields, two_mv_block_pattern_table); - COPY_BIT_FIELD(dest, src, mv_fields, four_mv_switch); - COPY_BIT_FIELD(dest, src, mv_fields, four_mv_block_pattern_table); - COPY_BIT_FIELD(dest, src, mv_fields, extended_mv_flag); - COPY_BIT_FIELD(dest, src, mv_fields, extended_mv_range); - COPY_BIT_FIELD(dest, src, mv_fields, extended_dmv_flag); - COPY_BIT_FIELD(dest, src, mv_fields, extended_dmv_range); - dest->BFV(pic_quantizer_fields, value) = 0; /* reset all bits */ - COPY_BIT_FIELD(dest, src, pic_quantizer_fields, dquant); - COPY_BIT_FIELD(dest, src, pic_quantizer_fields, quantizer); - COPY_BIT_FIELD(dest, src, pic_quantizer_fields, half_qp); - COPY_BIT_FIELD(dest, src, pic_quantizer_fields, pic_quantizer_scale); - COPY_BIT_FIELD(dest, src, pic_quantizer_fields, pic_quantizer_type); - COPY_BIT_FIELD(dest, src, pic_quantizer_fields, dq_frame); - COPY_BIT_FIELD(dest, src, pic_quantizer_fields, dq_profile); - COPY_BIT_FIELD(dest, src, pic_quantizer_fields, dq_sb_edge); - COPY_BIT_FIELD(dest, src, pic_quantizer_fields, dq_db_edge); - COPY_BIT_FIELD(dest, src, pic_quantizer_fields, dq_binary_level); - COPY_BIT_FIELD(dest, src, pic_quantizer_fields, alt_pic_quantizer); - dest->BFV(transform_fields, value) = 0; /* reset all bits */ - COPY_BIT_FIELD(dest, src, transform_fields, variable_sized_transform_flag); - COPY_BIT_FIELD(dest, src, transform_fields, mb_level_transform_type_flag); - COPY_BIT_FIELD(dest, src, transform_fields, frame_level_transform_type); - COPY_BIT_FIELD(dest, src, transform_fields, transform_ac_codingset_idx1); - COPY_BIT_FIELD(dest, src, transform_fields, transform_ac_codingset_idx2); - COPY_BIT_FIELD(dest, src, transform_fields, intra_transform_dc_table); - - if (src->picture_fields.bits.picture_type == 4) { - dest->BFM(picture_fields, bits, picture_type) = 1; /* P-frame */ - ctx->skip_frame = 1; - } - - return VA_STATUS_SUCCESS; -} - -static VAStatus TRANSLATE(PictureParameter,MPEG2)( - VACompatContextP ctx, - void *dest_buffer, - const void *src_buffer -) -{ - STRUCT(PictureParameter,MPEG2) *dest = dest_buffer; - const VAPictureParameterBufferMPEG2 *src = src_buffer; - - COPY_FIELD(dest, src, horizontal_size); - COPY_FIELD(dest, src, vertical_size); - COPY_FIELD(dest, src, forward_reference_picture); - COPY_FIELD(dest, src, backward_reference_picture); - COPY_FIELD(dest, src, picture_coding_type); - COPY_FIELD(dest, src, f_code); - dest->BFV(picture_coding_extension, value) = 0; /* reset all bits */ - COPY_BIT_FIELD(dest, src, picture_coding_extension, intra_dc_precision); - COPY_BIT_FIELD(dest, src, picture_coding_extension, picture_structure); - COPY_BIT_FIELD(dest, src, picture_coding_extension, top_field_first); - COPY_BIT_FIELD(dest, src, picture_coding_extension, frame_pred_frame_dct); - COPY_BIT_FIELD(dest, src, picture_coding_extension, concealment_motion_vectors); - COPY_BIT_FIELD(dest, src, picture_coding_extension, q_scale_type); - COPY_BIT_FIELD(dest, src, picture_coding_extension, intra_vlc_format); - COPY_BIT_FIELD(dest, src, picture_coding_extension, alternate_scan); - COPY_BIT_FIELD(dest, src, picture_coding_extension, repeat_first_field); - COPY_BIT_FIELD(dest, src, picture_coding_extension, progressive_frame); - COPY_BIT_FIELD(dest, src, picture_coding_extension, is_first_field); - - return VA_STATUS_SUCCESS; -} - -static VAStatus TRANSLATE(SliceParameter,MPEG2)( - VACompatContextP ctx, - void *dest_buffer, - const void *src_buffer -) -{ - STRUCT(SliceParameter,MPEG2) *dest = dest_buffer; - const VASliceParameterBufferMPEG2 *src = src_buffer; - - COPY_FIELD(dest, src, slice_data_size); - COPY_FIELD(dest, src, slice_data_offset); - COPY_FIELD(dest, src, slice_data_flag); - COPY_FIELD(dest, src, macroblock_offset); - COPY_FIELD(dest, src, slice_vertical_position); - COPY_FIELD(dest, src, quantiser_scale_code); - COPY_FIELD(dest, src, intra_slice_flag); - - return VA_STATUS_SUCCESS; -} -#endif - -static VAStatus TRANSLATE(PictureParameter,MPEG4)( - VACompatContextP ctx, - void *dest_buffer, - const void *src_buffer -) -{ - STRUCT(PictureParameter,MPEG4) *dest = dest_buffer; - const VAPictureParameterBufferMPEG4 *src = src_buffer; - - COPY_FIELD(dest, src, vop_width); - COPY_FIELD(dest, src, vop_height); - COPY_FIELD(dest, src, forward_reference_picture); - COPY_FIELD(dest, src, backward_reference_picture); - dest->BFV(vol_fields, value) = 0; /* reset all bits */ - COPY_BIT_FIELD(dest, src, vol_fields, short_video_header); - COPY_BIT_FIELD(dest, src, vol_fields, chroma_format); - COPY_BIT_FIELD(dest, src, vol_fields, interlaced); - COPY_BIT_FIELD(dest, src, vol_fields, obmc_disable); - COPY_BIT_FIELD(dest, src, vol_fields, sprite_enable); - COPY_BIT_FIELD(dest, src, vol_fields, sprite_warping_accuracy); - COPY_BIT_FIELD(dest, src, vol_fields, quant_type); - COPY_BIT_FIELD(dest, src, vol_fields, quarter_sample); - COPY_BIT_FIELD(dest, src, vol_fields, data_partitioned); - COPY_BIT_FIELD(dest, src, vol_fields, reversible_vlc); - COPY_FIELD(dest, src, no_of_sprite_warping_points); - COPY_ARRAY(dest, src, sprite_trajectory_du); - COPY_ARRAY(dest, src, sprite_trajectory_dv); - COPY_FIELD(dest, src, quant_precision); - dest->BFV(vop_fields, value) = 0; /* reset all bits */ - COPY_BIT_FIELD(dest, src, vop_fields, vop_coding_type); - COPY_BIT_FIELD(dest, src, vop_fields, backward_reference_vop_coding_type); - COPY_BIT_FIELD(dest, src, vop_fields, vop_rounding_type); - COPY_BIT_FIELD(dest, src, vop_fields, intra_dc_vlc_thr); - COPY_BIT_FIELD(dest, src, vop_fields, top_field_first); - COPY_BIT_FIELD(dest, src, vop_fields, alternate_vertical_scan_flag); - COPY_FIELD(dest, src, vop_fcode_forward); - COPY_FIELD(dest, src, vop_fcode_backward); - COPY_FIELD(dest, src, num_gobs_in_vop); - COPY_FIELD(dest, src, num_macroblocks_in_gob); - COPY_FIELD(dest, src, TRB); - COPY_FIELD(dest, src, TRD); - - return VA_STATUS_SUCCESS; -} - -#if COMPAT_MAJOR == 0 && COMPAT_MINOR == 30 -static VAStatus TRANSLATE_(VAEncSliceParameterBuffer)( - VACompatContextP ctx, - void *dest_buffer, - const void *src_buffer -) -{ - MKCOMPAT(VAEncSliceParameterBuffer) * const dest = dest_buffer; - const VAEncSliceParameterBuffer * const src = src_buffer; - - COPY_FIELD(dest, src, start_row_number); - COPY_FIELD(dest, src, slice_height); - dest->BFV(slice_flags, value) = 0; /* reset all bits */ - COPY_BIT_FIELD(dest, src, slice_flags, is_intra); - COPY_BIT_FIELD(dest, src, slice_flags, disable_deblocking_filter_idc); - - return VA_STATUS_SUCCESS; -} -#endif - -static void TRANSLATE_(VADriverContext)( - VACompatContext *dest, - const struct MKCOMPAT(VADriverContext) *src -) -{ - VACompatDriverVTable *dest_vtable = &dest->vtable; - const struct MKCOMPAT(VADriverVTable) *src_vtable = &src->vtable; - - memset(dest_vtable, 0, sizeof(*dest_vtable)); - COPY_VTABLE(dest, src, vaTerminate); - COPY_VTABLE(dest, src, vaQueryConfigProfiles); - COPY_VTABLE(dest, src, vaQueryConfigEntrypoints); - COPY_VTABLE(dest, src, vaGetConfigAttributes); - COPY_VTABLE(dest, src, vaCreateConfig); - COPY_VTABLE(dest, src, vaDestroyConfig); - COPY_VTABLE(dest, src, vaQueryConfigAttributes); - COPY_VTABLE(dest, src, vaCreateSurfaces); - COPY_VTABLE(dest, src, vaDestroySurfaces); - COPY_VTABLE(dest, src, vaCreateContext); - COPY_VTABLE(dest, src, vaDestroyContext); - COPY_VTABLE(dest, src, vaCreateBuffer); - COPY_VTABLE(dest, src, vaBufferSetNumElements); - COPY_VTABLE(dest, src, vaMapBuffer); - COPY_VTABLE(dest, src, vaUnmapBuffer); - COPY_VTABLE(dest, src, vaDestroyBuffer); - COPY_VTABLE(dest, src, vaBeginPicture); - COPY_VTABLE(dest, src, vaRenderPicture); - COPY_VTABLE(dest, src, vaEndPicture); - COPY_VTABLE(dest, src, vaQuerySurfaceStatus); - COPY_VTABLE(dest, src, vaPutSurface); - COPY_VTABLE(dest, src, vaQueryImageFormats); - COPY_VTABLE(dest, src, vaCreateImage); - COPY_VTABLE(dest, src, vaDeriveImage); - COPY_VTABLE(dest, src, vaDestroyImage); - COPY_VTABLE(dest, src, vaSetImagePalette); - COPY_VTABLE(dest, src, vaGetImage); - COPY_VTABLE(dest, src, vaQuerySubpictureFormats); - COPY_VTABLE(dest, src, vaCreateSubpicture); - COPY_VTABLE(dest, src, vaDestroySubpicture); - COPY_VTABLE(dest, src, vaSetSubpictureImage); - COPY_VTABLE(dest, src, vaSetSubpictureChromakey); - COPY_VTABLE(dest, src, vaSetSubpictureGlobalAlpha); - COPY_VTABLE(dest, src, vaDeassociateSubpicture); - COPY_VTABLE(dest, src, vaQueryDisplayAttributes); - COPY_VTABLE(dest, src, vaGetDisplayAttributes); - COPY_VTABLE(dest, src, vaSetDisplayAttributes); -#if COMPAT_MAJOR == 0 && COMPAT_MINOR <= 29 - COPY_VTABLE(dest, src, vaSetSubpicturePalette); - COPY_VTABLE(dest, src, vaDbgCopySurfaceToBuffer); -#endif -#if COMPAT_MAJOR == 0 && COMPAT_MINOR >= 30 - COPY_VTABLE(dest, src, vaCreateSurfaceFromCIFrame); - COPY_VTABLE(dest, src, vaCreateSurfaceFromV4L2Buf); - COPY_VTABLE(dest, src, vaCopySurfaceToBuffer); -#endif -#if COMPAT_MAJOR == 0 && COMPAT_MINOR >= 31 - COPY_VTABLE(dest, src, vaSyncSurface); - COPY_VTABLE(dest, src, vaPutImage); - COPY_VTABLE(dest, src, vaAssociateSubpicture); -#else - COPY_VTABLE_(dest, pre31, src, vaSyncSurface); - COPY_VTABLE_(dest, pre31, src, vaPutImage); - COPY_VTABLE_(dest, pre31, src, vaPutImage2); - COPY_VTABLE_(dest, pre31, src, vaAssociateSubpicture); - COPY_VTABLE_(dest, pre31, src, vaAssociateSubpicture2); -#endif -} - -#undef COMPAT_MAJOR -#undef COMPAT_MINOR diff -Nru libva-0.31.0+latest2/va/va_crystalhd.c libva-0.31.0+latest3/va/va_crystalhd.c --- libva-0.31.0+latest2/va/va_crystalhd.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/va/va_crystalhd.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2010 Splitted-Desktop Systems. 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. - */ - -#include -#include -#include -#include "config.h" -#include "va_crystalhd.h" - -/* Checks if the Broadcom Crystal HD decoder is available */ -int va_hasCrystalHD(void) -{ - char line[1024]; - int len, vendor, device, dummy, found = 0; - FILE *fp; - - fp = fopen("/proc/bus/pci/devices", "r"); - if (!fp) - return 0; - - while (!found && fgets(line, sizeof(line), fp)) { - len = strlen(line); - if (len == 0) - continue; - line[len - 1] = 0; - if (sscanf(line, "%x %04x%04x", &dummy, &vendor, &device) == 3) { - if (vendor == 0x14e4 && device == 0x1612) /* BCM70012 */ - found = 1; - } - } - fclose(fp); - return found; -} diff -Nru libva-0.31.0+latest2/va/va_crystalhd.h libva-0.31.0+latest3/va/va_crystalhd.h --- libva-0.31.0+latest2/va/va_crystalhd.h 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/va/va_crystalhd.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2010 Splitted-Desktop Systems. 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. - */ - -#ifndef VA_CRYSTALHD_H -#define VA_CRYSTALHD_H - -/** Checks if the Broadcom Crystal HD decoder is available */ -int va_hasCrystalHD(void) - ATTRIBUTE_HIDDEN; - -#endif /* VA_CRYSTALHD_H */ diff -Nru libva-0.31.0+latest2/va/va_version.h.in libva-0.31.0+latest3/va/va_version.h.in --- libva-0.31.0+latest2/va/va_version.h.in 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/va/va_version.h.in 2010-03-18 08:39:39.000000000 +0000 @@ -47,13 +47,6 @@ #define VA_MICRO_VERSION (@LIBVA_MICRO_VERSION@) /** - * VA_SDS_VERSION: - * - * The version of the SDS API extensions to the VA library - */ -#define VA_SDS_VERSION (@LIBVA_SDS_VERSION@) - -/** * VA_VERSION: * * The full version of the VA library, like 1.2.3 @@ -66,7 +59,7 @@ * The full version of the VA library, in string form (suited for * string concatenation) */ -#define VA_VERSION_S "@LIBVA_VERSION@-sds@LIBVA_SDS_VERSION@" +#define VA_VERSION_S "@LIBVA_VERSION@" /** * VA_VERSION_HEX: diff -Nru libva-0.31.0+latest2/va/x11/dri1_util.c libva-0.31.0+latest3/va/x11/dri1_util.c --- libva-0.31.0+latest2/va/x11/dri1_util.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/va/x11/dri1_util.c 2010-03-18 08:39:39.000000000 +0000 @@ -1,13 +1,10 @@ -#include "config.h" -#include #include -#include /* strcasecmp() */ #include #include #include #include -#include "libdrm_glue.h" +#include #include "X11/Xlib.h" #include "va.h" @@ -24,75 +21,6 @@ int height; }; -static int -firegl_drmOpenMinor(int minor) -{ - char buf[64]; - int fd; - - sprintf(buf, "/dev/ati/card%d", minor); - if ((fd = open(buf, O_RDWR, 0)) >= 0) - return fd; - return -1; -} - -static int -firegl_drmOpenByBusID(const char *busid) -{ - int i, fd; - drmSetVersion sv; - const char *buf; - - for (i = 0; i < DRM_MAX_MINOR; i++) { - if ((fd = firegl_drmOpenMinor(i)) < 0) - continue; - sv.drm_di_major = 1; - sv.drm_di_minor = 1; - sv.drm_dd_major = -1; - sv.drm_dd_minor = -1; - libdrm_drmSetInterfaceVersion(fd, &sv); - buf = libdrm_drmGetBusid(fd); - if (buf && strcasecmp(buf, busid) == 0) { /* XXX: drmMatchBusID() */ - libdrm_drmFreeBusid(buf); - return fd; - } - if (buf) - libdrm_drmFreeBusid(buf); - close(fd); - } - return -1; -} - -static int -drm_open_once(struct dri_state *dri_state, const char *BusID, int *newlyopened) -{ - dri_state->driConnectedFlag = VA_NONE; - dri_state->fd = libdrm_drmOpenOnce(NULL, BusID, newlyopened); - if (dri_state->fd < 0) { - dri_state->fd = firegl_drmOpenByBusID(BusID); - if (dri_state->fd >= 0) { - *newlyopened = 1; - dri_state->driConnectedFlag |= VA_DRI_AMD; - } - } - return dri_state->fd; -} - -static void -drm_close_once(struct dri_state *dri_state) -{ - /* XXX: dri_state->close() doesn't seem to be called, thus this - function is never called either */ - if (dri_state->fd < 0) - return; - if (dri_state->driConnectedFlag & VA_DRI_AMD) - close(dri_state->fd); - else - libdrm_drmCloseOnce(dri_state->fd); - dri_state->fd = -1; - dri_state->driConnectedFlag = VA_NONE; -} - static struct dri_drawable * dri1CreateDrawable(VADriverContextP ctx, XID x_drawable) { @@ -136,9 +64,9 @@ free_drawable_hashtable(ctx); VA_DRIDestroyContext(ctx->x11_dpy, ctx->x11_screen, dri_state->hwContextID); assert(dri_state->pSAREA != MAP_FAILED); - libdrm_drmUnmap(dri_state->pSAREA, SAREA_MAX); + drmUnmap(dri_state->pSAREA, SAREA_MAX); assert(dri_state->fd >= 0); - drm_close_once(dri_state); + drmCloseOnce(dri_state->fd); VA_DRICloseConnection(ctx->x11_dpy, ctx->x11_screen); } @@ -176,20 +104,21 @@ &dri_state->hSAREA, &BusID)) goto err_out0; - drm_open_once(dri_state, BusID, &newlyopened); + + dri_state->fd = drmOpenOnce(NULL, BusID, &newlyopened); XFree(BusID); if (dri_state->fd < 0) goto err_out1; - if (libdrm_drmGetMagic(dri_state->fd, &magic)) + if (drmGetMagic(dri_state->fd, &magic)) goto err_out1; if (newlyopened && !VA_DRIAuthConnection(ctx->x11_dpy, ctx->x11_screen, magic)) goto err_out1; - if (libdrm_drmMap(dri_state->fd, dri_state->hSAREA, SAREA_MAX, &dri_state->pSAREA)) + 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, @@ -197,8 +126,7 @@ &dri_state->hwContextID, &dri_state->hwContext)) goto err_out1; - dri_state->driConnectedFlag &= VA_DRI_AMD; /* clear flags but AMD bit */ - dri_state->driConnectedFlag |= VA_DRI1; + dri_state->driConnectedFlag = VA_DRI1; dri_state->createDrawable = dri1CreateDrawable; dri_state->destroyDrawable = dri1DestroyDrawable; dri_state->swapBuffer = dri1SwapBuffer; @@ -209,10 +137,10 @@ err_out1: if (dri_state->pSAREA != MAP_FAILED) - libdrm_drmUnmap(dri_state->pSAREA, SAREA_MAX); + drmUnmap(dri_state->pSAREA, SAREA_MAX); if (dri_state->fd >= 0) - drm_close_once(dri_state); + drmCloseOnce(dri_state->fd); VA_DRICloseConnection(ctx->x11_dpy, ctx->x11_screen); diff -Nru libva-0.31.0+latest2/va/x11/dri2_util.c libva-0.31.0+latest3/va/x11/dri2_util.c --- libva-0.31.0+latest2/va/x11/dri2_util.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/va/x11/dri2_util.c 2010-03-18 08:39:39.000000000 +0000 @@ -3,7 +3,7 @@ #include #include -#include "libdrm_glue.h" +#include #include #include @@ -166,7 +166,7 @@ if (dri_state->fd < 0) goto err_out; - if (libdrm_drmGetMagic(dri_state->fd, &magic)) + if (drmGetMagic(dri_state->fd, &magic)) goto err_out; if (!VA_DRI2Authenticate(ctx->x11_dpy, RootWindow(ctx->x11_dpy, ctx->x11_screen), diff -Nru libva-0.31.0+latest2/va/x11/libdrm_glue.c libva-0.31.0+latest3/va/x11/libdrm_glue.c --- libva-0.31.0+latest2/va/x11/libdrm_glue.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/va/x11/libdrm_glue.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,209 +0,0 @@ -/* - * Copyright (C) 2009 Splitted-Desktop Systems. 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 "libdrm_glue.h" -#include -#include -#include -#include -#include - -#define LOAD_FUNC_(NAME, RET, ARGS, FALLBACK) \ - static RET (*lib_##NAME) ARGS; \ - if (lib_##NAME == NULL) { \ - lib_##NAME = libdrm_symbol(#NAME); \ - if (!lib_##NAME) \ - lib_##NAME = FALLBACK; \ - } \ - assert(lib_##NAME != NULL) - -#define LOAD_FUNC(NAME, RET, ARGS) \ - LOAD_FUNC_(NAME, RET, ARGS, NULL) - -static void *libdrm_handle; -static int libdrm_handle_ok = -1; - -static inline void *libdrm_symbol(const char *name) -{ - if (!libdrm_open()) - return NULL; - return dlsym(libdrm_handle, name); -} - -int libdrm_open(void) -{ - if (libdrm_handle_ok < 0) { - libdrm_handle = dlopen("libdrm.so.2", RTLD_LOCAL|RTLD_LAZY); - libdrm_handle_ok = libdrm_handle != NULL; - } - assert(libdrm_handle); - return libdrm_handle_ok; -} - -void libdrm_close(void) -{ - if (libdrm_handle) - dlclose(libdrm_handle); -} - -// Default drmOpenOnce() and drmCloseOnce() implementations based on current GIT -#define DRM_MAX_FDS 16 -static struct { - char *BusID; - int fd; - int refcount; -} connection[DRM_MAX_FDS]; - -static int nr_fds = 0; - -// Default implementation for drmOpenOnce() if none exists in the library -static int -libdrm_default_drmOpenOnce(void *unused, const char *BusID, int *newlyopened) -{ - int i; - int fd; - - for (i = 0; i < nr_fds; i++) - if (strcmp(BusID, connection[i].BusID) == 0) { - connection[i].refcount++; - *newlyopened = 0; - return connection[i].fd; - } - - fd = libdrm_drmOpen(unused, BusID); - if (fd <= 0 || nr_fds == DRM_MAX_FDS) - return fd; - - connection[nr_fds].BusID = strdup(BusID); - connection[nr_fds].fd = fd; - connection[nr_fds].refcount = 1; - *newlyopened = 1; - - if (0) - fprintf(stderr, "saved connection %d for %s %d\n", - nr_fds, connection[nr_fds].BusID, - strcmp(BusID, connection[nr_fds].BusID)); - nr_fds++; - return fd; -} - -// Default implementation for drmCloseOnce() if none exists in the library -static void libdrm_default_drmCloseOnce(int fd) -{ - int i; - - for (i = 0; i < nr_fds; i++) { - if (fd == connection[i].fd) { - if (--connection[i].refcount == 0) { - libdrm_drmClose(connection[i].fd); - free(connection[i].BusID); - if (i < --nr_fds) - connection[i] = connection[nr_fds]; - return; - } - } - } -} - -// Determine whether the DRM kernel driver has been loaded -int libdrm_drmAvailable(void) -{ - LOAD_FUNC(drmAvailable, int, (void)); - return lib_drmAvailable(); -} - -// Open the DRM device -int libdrm_drmOpen(const char *name, const char *busid) -{ - LOAD_FUNC(drmOpen, int, (const char *, const char *)); - return lib_drmOpen(name, busid); -} - -// Close the device -int libdrm_drmClose(int fd) -{ - LOAD_FUNC(drmClose, int, (int)); - return lib_drmClose(fd); -} - -// Open the DRM device (re-use an existing connection) -int libdrm_drmOpenOnce(void *unused, const char *BusID, int *newlyopened) -{ - LOAD_FUNC_(drmOpenOnce, int, (void *, const char *, int *), - libdrm_default_drmOpenOnce); - return lib_drmOpenOnce(unused, BusID, newlyopened); -} - -// Close the device (unref an existing connection prior to actually closing it) -void libdrm_drmCloseOnce(int fd) -{ - LOAD_FUNC_(drmCloseOnce, void, (int), libdrm_default_drmCloseOnce); - lib_drmCloseOnce(fd); -} - -// DRM connection cookie -int libdrm_drmGetMagic(int fd, drm_magic_t * magic) -{ - LOAD_FUNC(drmGetMagic, int, (int, drm_magic_t *)); - return lib_drmGetMagic(fd, magic); -} - -// Issue a set-version ioctl -int libdrm_drmSetInterfaceVersion(int fd, drmSetVersion *version) -{ - LOAD_FUNC(drmSetInterfaceVersion, int, (int, drmSetVersion *)); - return lib_drmSetInterfaceVersion(fd, version); -} - -// Get the bus ID of the device -char *libdrm_drmGetBusid(int fd) -{ - LOAD_FUNC(drmGetBusid, char *, (int)); - return lib_drmGetBusid(fd); -} - -// Free the bus ID information -void libdrm_drmFreeBusid(const char *busid) -{ - LOAD_FUNC(drmFreeBusid, void, (const char *)); - lib_drmFreeBusid(busid); -} - -// Map a region of memory -int libdrm_drmMap(int fd, - drm_handle_t handle, - drmSize size, - drmAddressPtr address) -{ - LOAD_FUNC(drmMap, int, (int, drm_handle_t, drmSize, drmAddressPtr)); - return lib_drmMap(fd, handle, size, address); -} - -// Unmap mappings obtained with drmMap() -int libdrm_drmUnmap(drmAddress address, drmSize size) -{ - LOAD_FUNC(drmUnmap, int, (drmAddress, drmSize)); - return lib_drmUnmap(address, size); -} diff -Nru libva-0.31.0+latest2/va/x11/libdrm_glue.h libva-0.31.0+latest3/va/x11/libdrm_glue.h --- libva-0.31.0+latest2/va/x11/libdrm_glue.h 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/va/x11/libdrm_glue.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2009 Splitted-Desktop Systems. 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. - */ - -#ifndef LIBDRM_GLUE_H -#define LIBDRM_GLUE_H - -#include "config.h" -#include - -int libdrm_open(void) - ATTRIBUTE_HIDDEN; - -void libdrm_close(void) - ATTRIBUTE_HIDDEN; - -int libdrm_drmAvailable(void) - ATTRIBUTE_HIDDEN; - -int libdrm_drmOpen(const char *name, const char *busid) - ATTRIBUTE_HIDDEN; - -int libdrm_drmClose(int fd) - ATTRIBUTE_HIDDEN; - -int libdrm_drmOpenOnce(void *unused, const char *BusID, int *newlyopened) - ATTRIBUTE_HIDDEN; - -void libdrm_drmCloseOnce(int fd) - ATTRIBUTE_HIDDEN; - -int libdrm_drmGetMagic(int fd, drm_magic_t * magic) - ATTRIBUTE_HIDDEN; - -int libdrm_drmSetInterfaceVersion(int fd, drmSetVersion *version) - ATTRIBUTE_HIDDEN; - -char *libdrm_drmGetBusid(int fd) - ATTRIBUTE_HIDDEN; - -void libdrm_drmFreeBusid(const char *busid) - ATTRIBUTE_HIDDEN; - -int libdrm_drmMap(int fd, - drm_handle_t handle, - drmSize size, - drmAddressPtr address) - ATTRIBUTE_HIDDEN; - -int libdrm_drmUnmap(drmAddress address, drmSize size) - ATTRIBUTE_HIDDEN; - -#endif /* LIBDRM_GLUE_H */ diff -Nru libva-0.31.0+latest2/va/x11/Makefile.am libva-0.31.0+latest3/va/x11/Makefile.am --- libva-0.31.0+latest2/va/x11/Makefile.am 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/va/x11/Makefile.am 2010-03-18 08:39:39.000000000 +0000 @@ -25,23 +25,6 @@ libva_x11includedir = ${includedir}/va libva_x11include_HEADERS = va_dri.h va_dri2.h va_dricommon.h -libva_x11_la_SOURCES = \ - dri1_util.c \ - dri2_util.c \ - libdrm_glue.c \ - va_dri.c \ - va_dri2.c \ - va_dricommon.c \ - va_fglext.c \ - va_nvctrl.c \ - va_x11.c \ - $(NULL) +libva_x11_la_SOURCES = va_x11.c va_dri.c va_dri2.c va_dricommon.c dri2_util.c dri1_util.c va_nvctrl.c -EXTRA_DIST = \ - libdrm_glue.h \ - va_dri2str.h \ - va_dri2tokens.h \ - va_dristr.h \ - va_fglext.h \ - va_nvctrl.h \ - $(NULL) +EXTRA_DIST = va_dristr.h va_dri2str.h va_dri2tokens.h va_nvctrl.h diff -Nru libva-0.31.0+latest2/va/x11/va_dricommon.h libva-0.31.0+latest3/va/x11/va_dricommon.h --- libva-0.31.0+latest2/va/x11/va_dricommon.h 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/va/x11/va_dricommon.h 2010-03-18 08:39:39.000000000 +0000 @@ -13,8 +13,7 @@ { VA_NONE = 0, VA_DRI1 = 1, - VA_DRI2 = 2, - VA_DRI_AMD = 4 /* AMD DRI implementation */ + VA_DRI2 = 2 }; union dri_buffer diff -Nru libva-0.31.0+latest2/va/x11/va_fglext.c libva-0.31.0+latest3/va/x11/va_fglext.c --- libva-0.31.0+latest2/va/x11/va_fglext.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/va/x11/va_fglext.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,175 +0,0 @@ -/* - * Copyright (C) 2009 Splitted-Desktop Systems. 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 - -#define NEED_REPLIES -#include -#include -#include -#include -#include -#include "va_fglext.h" - -#define ATIFGL_EXTENSION_NAME "ATIFGLEXTENSION" -#define ATIFGL_EXTENSION_EVENTS 0 - -typedef struct _FGLGetDriverData { - CARD8 reqType; - CARD8 fireglReqType; - CARD16 length B16; - CARD32 screen B32; - CARD16 size B16; - CARD16 pad1; -} xFGLGetDriverDataReq; -#define sz_xFGLGetDriverDataReq sizeof(xFGLGetDriverDataReq) - -typedef struct { - BYTE type; - BYTE pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD8 majorVersion; - CARD8 minorVersion; - CARD8 patchlevel B16; - CARD8 BIOSVersionMajor; - CARD8 BIOSVersionMinor; - CARD8 HasSecondary; - CARD16 pad3 B16; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; - CARD32 pad7 B32; - // ... there are more fields -} xFGLGetDriverDataReply; -#define sz_xFGLGetDriverDataReply sizeof(xFGLGetDriverDataReply) - -#define X_FGLGetDriverData 0 - -static XExtensionInfo _fglext_ext_info_data; -static XExtensionInfo *fglext_ext_info = &_fglext_ext_info_data; -static /* const */ char *fglext_extension_name = ATIFGL_EXTENSION_NAME; - -#define xFGLCheckExtension(dpy,i,val) \ - XextCheckExtension (dpy, i, fglext_extension_name, val) - -static int close_display(); -static /* const */ XExtensionHooks fglext_extension_hooks = { - NULL, /* create_gc */ - NULL, /* copy_gc */ - NULL, /* flush_gc */ - NULL, /* free_gc */ - NULL, /* create_font */ - NULL, /* free_font */ - close_display, /* close_display */ - NULL, /* wire_to_event */ - NULL, /* event_to_wire */ - NULL, /* error */ - NULL, /* error_string */ -}; - -static XEXT_GENERATE_FIND_DISPLAY (find_display, fglext_ext_info, - fglext_extension_name, - &fglext_extension_hooks, - ATIFGL_EXTENSION_EVENTS, NULL) - -static XEXT_GENERATE_CLOSE_DISPLAY (close_display, fglext_ext_info) - -Bool VA_FGLEXTQueryDirectRenderingCapable( Display *dpy, int screen, - Bool *isCapable ) -{ - char **extensions; - int i, n_extensions, has_fglext = 0, has_fglrxdri = 0; - - if (isCapable) - *isCapable = False; - - extensions = XListExtensions(dpy, &n_extensions); - if (!extensions) - return False; - - for (i = 0; i < n_extensions; i++) { - if (strcmp(extensions[i], ATIFGL_EXTENSION_NAME) == 0) - has_fglext = 1; - if (strcmp(extensions[i], "ATIFGLRXDRI") == 0) - has_fglrxdri = 1; - } - XFreeExtensionList(extensions); - - if (!has_fglext) - return False; - - if (isCapable) - *isCapable = has_fglrxdri; - - return True; -} - -Bool VA_FGLEXTGetClientDriverName( Display *dpy, int screen, - int *ddxDriverMajorVersion, int *ddxDriverMinorVersion, - int *ddxDriverPatchVersion, char **clientDriverName ) -{ - XExtDisplayInfo *info = find_display (dpy); - xFGLGetDriverDataReply rep; - xFGLGetDriverDataReq *req; - - if (ddxDriverMajorVersion) - *ddxDriverMajorVersion = 0; - if (ddxDriverMinorVersion) - *ddxDriverMinorVersion = 0; - if (ddxDriverPatchVersion) - *ddxDriverPatchVersion = 0; - if (clientDriverName) - *clientDriverName = NULL; - - if(!XextHasExtension(info)) - return False; - - xFGLCheckExtension (dpy, info, False); - - LockDisplay (dpy); - GetReq (FGLGetDriverData, req); - req->reqType = info->codes->major_opcode; - req->fireglReqType = X_FGLGetDriverData; - req->screen = screen; - if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { - UnlockDisplay (dpy); - SyncHandle (); - return False; - } - UnlockDisplay (dpy); - SyncHandle (); - - if (ddxDriverMajorVersion) - *ddxDriverMajorVersion = rep.majorVersion; - if (ddxDriverMinorVersion) - *ddxDriverMinorVersion = rep.minorVersion; - if (ddxDriverPatchVersion) - *ddxDriverPatchVersion = rep.patchlevel; - if (clientDriverName) - *clientDriverName = strdup("fglrx"); - - return True; -} diff -Nru libva-0.31.0+latest2/va/x11/va_fglext.h libva-0.31.0+latest3/va/x11/va_fglext.h --- libva-0.31.0+latest2/va/x11/va_fglext.h 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/va/x11/va_fglext.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2009 Splitted-Desktop Systems. 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. - */ - -#ifndef VA_FGLEXTLIB_H -#define VA_FGLEXTLIB_H - -#include - -Bool VA_FGLEXTQueryDirectRenderingCapable( Display *dpy, int screen, - Bool *isCapable ); - -Bool VA_FGLEXTGetClientDriverName( Display *dpy, int screen, - int *ddxDriverMajorVersion, int *ddxDriverMinorVersion, - int *ddxDriverPatchVersion, char **clientDriverName ); - -#endif /* VA_FGLEXTLIB_H */ diff -Nru libva-0.31.0+latest2/va/x11/va_x11.c libva-0.31.0+latest3/va/x11/va_x11.c --- libva-0.31.0+latest2/va/x11/va_x11.c 2010-04-18 14:36:16.000000000 +0100 +++ libva-0.31.0+latest3/va/x11/va_x11.c 2010-03-18 08:39:39.000000000 +0000 @@ -31,8 +31,6 @@ #include "va_dri2.h" #include "va_dricommon.h" #include "va_nvctrl.h" -#include "va_fglext.h" -#include "libdrm_glue.h" #include #include #include @@ -77,8 +75,6 @@ } ctx = &((*ctx)->pNext); } - - libdrm_close(); free(pDisplayContext->pDriverContext->dri_state); free(pDisplayContext->pDriverContext); free(pDisplayContext); @@ -134,46 +130,31 @@ 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; } @@ -217,7 +198,6 @@ pDisplayContext->vaIsValid = va_DisplayContextIsValid; pDisplayContext->vaDestroy = va_DisplayContextDestroy; pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName; - pDisplayContext->opaque = NULL; pDisplayContexts = pDisplayContext; pDriverContext->dri_state = dri_state; dpy = (VADisplay)pDisplayContext;