summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>2012-06-29 14:56:28 +0200
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>2012-08-06 14:13:00 +0200
commitfe56f00399596b577e312c6e199f4a167d2be9fc (patch)
treedfb2091735223fa5b2ecf7a4a5123e6e35af87bc
parent4119bbe6008fbfde0bfc5a1a5e6b3570d1703ef1 (diff)
downloadvaapi-intel-driver-fe56f00399596b577e312c6e199f4a167d2be9fc.tar.gz
vaapi-intel-driver-fe56f00399596b577e312c6e199f4a167d2be9fc.tar.bz2
vaapi-intel-driver-fe56f00399596b577e312c6e199f4a167d2be9fc.zip
Drop explicit dependency on libva-x11.
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
-rwxr-xr-xsrc/Makefile.am3
-rw-r--r--src/i965_drv_video.h3
-rw-r--r--src/i965_output_dri.c72
3 files changed, 73 insertions, 5 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index ea29efb..ee8ecc7 100755
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -40,7 +40,7 @@ driver_ldflags = \
$(NULL)
driver_libs = \
- -lpthread -lm \
+ -lpthread -lm -ldl \
$(DRM_LIBS) -ldrm_intel \
$(LIBVA_DEPS_LIBS) \
$(NULL)
@@ -114,7 +114,6 @@ noinst_HEADERS = $(source_h)
if USE_X11
source_c += i965_output_dri.c
source_h += i965_output_dri.h
-driver_libs += $(LIBVA_X11_DEPS_LIBS)
endif
# Extra clean files so that maintainer-clean removes *everything*
diff --git a/src/i965_drv_video.h b/src/i965_drv_video.h
index e40e9b4..86136fb 100644
--- a/src/i965_drv_video.h
+++ b/src/i965_drv_video.h
@@ -275,6 +275,9 @@ struct i965_driver_data
char va_vendor[256];
VAContextID current_context_id;
+
+ /* VA/DRI (X11) specific data */
+ struct va_dri_output *dri_output;
};
#define NEW_CONFIG_ID() object_heap_allocate(&i965->config_heap);
diff --git a/src/i965_output_dri.c b/src/i965_output_dri.c
index 4978b5c..c223143 100644
--- a/src/i965_output_dri.c
+++ b/src/i965_output_dri.c
@@ -23,21 +23,86 @@
*/
#include "config.h"
+#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <va/va_dricommon.h>
#include "i965_drv_video.h"
#include "i965_output_dri.h"
+#include "dso_utils.h"
+
+#define LIBVA_X11_NAME "libva-x11.so.1"
+
+typedef struct dri_drawable *(*dri_get_drawable_func)(
+ VADriverContextP ctx, XID drawable);
+typedef union dri_buffer *(*dri_get_rendering_buffer_func)(
+ VADriverContextP ctx, struct dri_drawable *d);
+typedef void (*dri_swap_buffer_func)(
+ VADriverContextP ctx, struct dri_drawable *d);
+
+struct dri_vtable {
+ dri_get_drawable_func get_drawable;
+ dri_get_rendering_buffer_func get_rendering_buffer;
+ dri_swap_buffer_func swap_buffer;
+};
+
+struct va_dri_output {
+ struct dso_handle *handle;
+ struct dri_vtable vtable;
+};
bool
i965_output_dri_init(VADriverContextP ctx)
{
+ struct i965_driver_data * const i965 = i965_driver_data(ctx);
+ struct dso_handle *dso_handle;
+ struct dri_vtable *dri_vtable;
+
+ static const struct dso_symbol symbols[] = {
+ { "dri_get_drawable",
+ offsetof(struct dri_vtable, get_drawable) },
+ { "dri_get_rendering_buffer",
+ offsetof(struct dri_vtable, get_rendering_buffer) },
+ { "dri_swap_buffer",
+ offsetof(struct dri_vtable, swap_buffer) },
+ { NULL, }
+ };
+
+ i965->dri_output = calloc(1, sizeof(struct va_dri_output));
+ if (!i965->dri_output)
+ goto error;
+
+ i965->dri_output->handle = dso_open(LIBVA_X11_NAME);
+ if (!i965->dri_output->handle)
+ goto error;
+
+ dso_handle = i965->dri_output->handle;
+ dri_vtable = &i965->dri_output->vtable;
+ if (!dso_get_symbols(dso_handle, dri_vtable, sizeof(*dri_vtable), symbols))
+ goto error;
return true;
+
+error:
+ i965_output_dri_terminate(ctx);
+ return false;
}
void
i965_output_dri_terminate(VADriverContextP ctx)
{
+ struct i965_driver_data * const i965 = i965_driver_data(ctx);
+ struct va_dri_output * const dri_output = i965->dri_output;
+
+ if (!dri_output)
+ return;
+
+ if (dri_output->handle) {
+ dso_close(dri_output->handle);
+ dri_output->handle = NULL;
+ }
+
+ free(dri_output);
+ i965->dri_output = NULL;
}
VAStatus
@@ -53,6 +118,7 @@ i965_put_surface_dri(
)
{
struct i965_driver_data * const i965 = i965_driver_data(ctx);
+ struct dri_vtable * const dri_vtable = &i965->dri_output->vtable;
struct dri_state * const dri_state = (struct dri_state *)ctx->drm_state;
struct i965_render_state * const render_state = &i965->render_state;
struct dri_drawable *dri_drawable;
@@ -77,10 +143,10 @@ i965_put_surface_dri(
_i965LockMutex(&i965->render_mutex);
- dri_drawable = dri_get_drawable(ctx, (Drawable)draw);
+ dri_drawable = dri_vtable->get_drawable(ctx, (Drawable)draw);
assert(dri_drawable);
- buffer = dri_get_rendering_buffer(ctx, dri_drawable);
+ buffer = dri_vtable->get_rendering_buffer(ctx, dri_drawable);
assert(buffer);
dest_region = render_state->draw_region;
@@ -129,7 +195,7 @@ i965_put_surface_dri(
intel_render_put_subpicture(ctx, surface, src_rect, dst_rect);
}
- dri_swap_buffer(ctx, dri_drawable);
+ dri_vtable->swap_buffer(ctx, dri_drawable);
obj_surface->flags |= SURFACE_DISPLAYED;
if ((obj_surface->flags & SURFACE_ALL_MASK) == SURFACE_DISPLAYED) {