summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2011-07-20 20:32:46 +0000
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2011-07-20 20:38:44 +0000
commitb9b59b2c928fe9028a6aced9bb39e9299a015763 (patch)
treebfa1ee8f20af8dbc695af7f8a19a181ee5160e1a
parentc4394709aafb90dab872b0d5eb9cbd0ace3cd27d (diff)
Expose a minimal drm_state interface to the driver
Move X11-related stuff into a x-backend specific dri_state subclass of drm_state. Same for drm_drawable and dri_drawable.
-rw-r--r--i965_drv_video/Makefile.am2
-rw-r--r--i965_drv_video/i965_drv_video.c26
-rw-r--r--i965_drv_video/i965_render.c2
-rw-r--r--i965_drv_video/intel_driver.c18
-rw-r--r--va/va_backend.h2
-rw-r--r--va/va_drmcommon.h58
-rw-r--r--va/x11/dri1_util.c56
-rw-r--r--va/x11/dri2_util.c62
-rw-r--r--va/x11/va_dricommon.c18
-rw-r--r--va/x11/va_dricommon.h51
-rw-r--r--va/x11/va_x11.c6
11 files changed, 164 insertions, 137 deletions
diff --git a/i965_drv_video/Makefile.am b/i965_drv_video/Makefile.am
index 541e4af..c6c978f 100644
--- a/i965_drv_video/Makefile.am
+++ b/i965_drv_video/Makefile.am
@@ -22,7 +22,7 @@
SUBDIRS = shaders
-AM_CFLAGS = -Wall -I$(top_srcdir) -I$(top_srcdir)/va -I$(top_srcdir)/va/x11 -DPTHREADS @DRM_CFLAGS@
+AM_CFLAGS = -Wall -I$(top_srcdir) -I$(top_srcdir)/va -DPTHREADS @DRM_CFLAGS@
i965_drv_video_la_LTLIBRARIES = i965_drv_video.la
i965_drv_video_ladir = @LIBVA_DRIVERS_PATH@
diff --git a/i965_drv_video/i965_drv_video.c b/i965_drv_video/i965_drv_video.c
index 68748cb..38d078a 100644
--- a/i965_drv_video/i965_drv_video.c
+++ b/i965_drv_video/i965_drv_video.c
@@ -32,7 +32,7 @@
#include <string.h>
#include <assert.h>
-#include "va/x11/va_dricommon.h"
+#include "va/va_drmcommon.h"
#include "intel_driver.h"
#include "intel_memman.h"
@@ -2236,10 +2236,10 @@ i965_PutSurface(VADriverContextP ctx,
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 drm_state *drm_state = (struct drm_state *)ctx->drm_state;
struct i965_render_state *render_state = &i965->render_state;
- struct dri_drawable *dri_drawable;
- union dri_buffer *buffer;
+ struct drm_drawable *drm_drawable;
+ union drm_buffer *buffer;
struct intel_region *dest_region;
struct object_surface *obj_surface;
VARectangle src_rect, dst_rect;
@@ -2249,7 +2249,7 @@ i965_PutSurface(VADriverContextP ctx,
int pp_flag = 0;
/* Currently don't support DRI1 */
- if (dri_state->driConnectedFlag != VA_DRI2)
+ if (drm_state->driConnectedFlag != VA_DRI2)
return VA_STATUS_ERROR_UNKNOWN;
/* Some broken sources such as H.264 conformance case FM2_SVA_C
@@ -2261,9 +2261,9 @@ i965_PutSurface(VADriverContextP ctx,
_i965LockMutex(&i965->render_mutex);
- dri_drawable = dri_state->getDrawable(ctx, draw);
- assert(dri_drawable);
- buffer = dri_state->getRenderingBuffer(ctx, dri_drawable);
+ drm_drawable = drm_state->getDrawable(ctx, draw);
+ assert(drm_drawable);
+ buffer = drm_state->getRenderingBuffer(ctx, drm_drawable);
assert(buffer);
dest_region = render_state->draw_region;
@@ -2284,10 +2284,10 @@ i965_PutSurface(VADriverContextP ctx,
}
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->x = drm_drawable->x;
+ dest_region->y = drm_drawable->y;
+ dest_region->width = drm_drawable->width;
+ dest_region->height = drm_drawable->height;
dest_region->cpp = buffer->dri2.cpp;
dest_region->pitch = buffer->dri2.pitch;
@@ -2320,7 +2320,7 @@ i965_PutSurface(VADriverContextP ctx,
intel_render_put_subpicture(ctx, surface, &src_rect, &dst_rect);
}
- dri_state->swapBuffer(ctx, dri_drawable);
+ drm_state->swapBuffer(ctx, drm_drawable);
obj_surface->flags |= SURFACE_DISPLAYED;
diff --git a/i965_drv_video/i965_render.c b/i965_drv_video/i965_render.c
index fee7109..cf44943 100644
--- a/i965_drv_video/i965_render.c
+++ b/i965_drv_video/i965_render.c
@@ -37,7 +37,7 @@
#include <assert.h>
#include <va/va_backend.h>
-#include "va/x11/va_dricommon.h"
+#include "va/va_drmcommon.h"
#include "intel_batchbuffer.h"
#include "intel_driver.h"
diff --git a/i965_drv_video/intel_driver.c b/i965_drv_video/intel_driver.c
index 5ccdfa5..d251d3b 100644
--- a/i965_drv_video/intel_driver.c
+++ b/i965_drv_video/intel_driver.c
@@ -29,7 +29,7 @@
#include <assert.h>
-#include "va_dricommon.h"
+#include "va_drmcommon.h"
#include "intel_batchbuffer.h"
#include "intel_memman.h"
@@ -50,21 +50,21 @@ Bool
intel_driver_init(VADriverContextP ctx)
{
struct intel_driver_data *intel = intel_driver_data(ctx);
- struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
+ struct drm_state *drm_state = (struct drm_state *)ctx->drm_state;
int has_exec2, has_bsd, has_blt;
- assert(dri_state);
- assert(dri_state->driConnectedFlag == VA_DRI2 ||
- dri_state->driConnectedFlag == VA_DRI1);
+ assert(drm_state);
+ assert(drm_state->driConnectedFlag == VA_DRI2 ||
+ drm_state->driConnectedFlag == VA_DRI1);
- intel->fd = dri_state->fd;
- intel->dri2Enabled = (dri_state->driConnectedFlag == VA_DRI2);
+ intel->fd = drm_state->fd;
+ intel->dri2Enabled = (drm_state->driConnectedFlag == VA_DRI2);
if (!intel->dri2Enabled) {
drm_sarea_t *pSAREA;
- pSAREA = (drm_sarea_t *)dri_state->pSAREA;
- intel->hHWContext = dri_state->hwContext;
+ pSAREA = (drm_sarea_t *)drm_state->pSAREA;
+ intel->hHWContext = drm_state->hwContext;
intel->driHwLock = (drmLock *)(&pSAREA->lock);
intel->pPrivSarea = (void *)pSAREA + sizeof(drm_sarea_t);
}
diff --git a/va/va_backend.h b/va/va_backend.h
index 9b47cae..fe6086e 100644
--- a/va/va_backend.h
+++ b/va/va_backend.h
@@ -431,7 +431,7 @@ struct VADriverContext
void *handle; /* dlopen handle */
- void *dri_state;
+ void *drm_state;
void *glx; /* opaque for GLX code */
unsigned long reserved[45]; /* reserve for future add-ins, decrease the subscript accordingly */
diff --git a/va/va_drmcommon.h b/va/va_drmcommon.h
new file mode 100644
index 0000000..f43b6b0
--- /dev/null
+++ b/va/va_drmcommon.h
@@ -0,0 +1,58 @@
+#ifndef _VA_DRMCOMMON_H_
+#define _VA_DRMCOMMON_H_
+
+#ifndef ANDROID
+#include <xf86drm.h>
+#include <drm.h>
+#include <drm_sarea.h>
+#endif
+
+#include <va/va_backend.h>
+
+enum
+{
+ VA_NONE = 0,
+ VA_DRI1 = 1,
+ VA_DRI2 = 2,
+ VA_DUMMY = 3
+};
+
+union drm_buffer
+{
+ struct {
+ unsigned int attachment;
+ unsigned int name;
+ unsigned int pitch;
+ unsigned int cpp;
+ unsigned int flags;
+ } dri2;
+
+ struct {
+ } dri1;
+};
+
+struct drm_drawable
+{
+ int x;
+ int y;
+ unsigned int width;
+ unsigned int height;
+};
+
+struct drm_state
+{
+ int fd;
+ int driConnectedFlag; /* 0: disconnected, 1: DRM, 2: DRM2 */
+#ifndef ANDROID
+ drm_handle_t hSAREA;
+ drm_context_t hwContext;
+ drmAddress pSAREA;
+
+ struct drm_drawable *(*getDrawable)(VADriverContextP ctx, void *native_drawable);
+
+ void (*swapBuffer)(VADriverContextP ctx, struct drm_drawable *drm_drawable);
+ union drm_buffer *(*getRenderingBuffer)(VADriverContextP ctx, struct drm_drawable *drm_drawable);
+#endif
+};
+
+#endif /* _VA_DRMCOMMON_H_ */
diff --git a/va/x11/dri1_util.c b/va/x11/dri1_util.c
index b513ea1..711b6c8 100644
--- a/va/x11/dri1_util.c
+++ b/va/x11/dri1_util.c
@@ -43,15 +43,15 @@ dri1DestroyDrawable(VADriverContextP ctx, struct dri_drawable *dri_drawable)
}
static void
-dri1SwapBuffer(VADriverContextP ctx, struct dri_drawable *dri_drawable)
+dri1SwapBuffer(VADriverContextP ctx, struct drm_drawable *drm_drawable)
{
}
static union dri_buffer *
-dri1GetRenderingBuffer(VADriverContextP ctx, struct dri_drawable *dri_drawable)
+dri1GetRenderingBuffer(VADriverContextP ctx, struct drm_drawable *drm_drawable)
{
- struct dri1_drawable *dri1_drawable = (struct dri1_drawable *)dri_drawable;
+ struct dri1_drawable *dri1_drawable = (struct dri1_drawable *)drm_drawable;
return &dri1_drawable->buffer;
}
@@ -59,21 +59,21 @@ dri1GetRenderingBuffer(VADriverContextP ctx, struct dri_drawable *dri_drawable)
static void
dri1Close(VADriverContextP ctx)
{
- struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
+ struct dri_state *dri_state = (struct dri_state *)ctx->drm_state;
free_drawable_hashtable(ctx);
VA_DRIDestroyContext((Display *)ctx->native_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);
+ assert(dri_state->base.pSAREA != MAP_FAILED);
+ drmUnmap(dri_state->base.pSAREA, SAREA_MAX);
+ assert(dri_state->base.fd >= 0);
+ drmCloseOnce(dri_state->base.fd);
VA_DRICloseConnection((Display *)ctx->native_dpy, ctx->x11_screen);
}
Bool
isDRI1Connected(VADriverContextP ctx, char **driver_name)
{
- struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
+ struct dri_state *dri_state = (struct dri_state *)ctx->drm_state;
int direct_capable;
int driver_major;
int driver_minor;
@@ -83,9 +83,9 @@ isDRI1Connected(VADriverContextP ctx, char **driver_name)
drm_magic_t magic;
*driver_name = NULL;
- dri_state->fd = -1;
- dri_state->pSAREA = MAP_FAILED;
- dri_state->driConnectedFlag = VA_NONE;
+ dri_state->base.fd = -1;
+ dri_state->base.pSAREA = MAP_FAILED;
+ dri_state->base.driConnectedFlag = VA_NONE;
if (!VA_DRIQueryDirectRenderingCapable((Display *)ctx->native_dpy,
ctx->x11_screen,
@@ -101,47 +101,47 @@ isDRI1Connected(VADriverContextP ctx, char **driver_name)
goto err_out0;
if (!VA_DRIOpenConnection((Display *)ctx->native_dpy, ctx->x11_screen,
- &dri_state->hSAREA, &BusID))
+ &dri_state->base.hSAREA, &BusID))
goto err_out0;
- dri_state->fd = drmOpenOnce(NULL, BusID, &newlyopened);
+ dri_state->base.fd = drmOpenOnce(NULL, BusID, &newlyopened);
XFree(BusID);
- if (dri_state->fd < 0)
+ if (dri_state->base.fd < 0)
goto err_out1;
- if (drmGetMagic(dri_state->fd, &magic))
+ if (drmGetMagic(dri_state->base.fd, &magic))
goto err_out1;
if (newlyopened && !VA_DRIAuthConnection((Display *)ctx->native_dpy, ctx->x11_screen, magic))
goto err_out1;
- if (drmMap(dri_state->fd, dri_state->hSAREA, SAREA_MAX, &dri_state->pSAREA))
+ if (drmMap(dri_state->base.fd, dri_state->base.hSAREA, SAREA_MAX, &dri_state->base.pSAREA))
goto err_out1;
if (!VA_DRICreateContext((Display *)ctx->native_dpy, ctx->x11_screen,
DefaultVisual((Display *)ctx->native_dpy, ctx->x11_screen),
- &dri_state->hwContextID, &dri_state->hwContext))
+ &dri_state->hwContextID, &dri_state->base.hwContext))
goto err_out1;
- dri_state->driConnectedFlag = VA_DRI1;
+ dri_state->base.driConnectedFlag = VA_DRI1;
dri_state->createDrawable = dri1CreateDrawable;
dri_state->destroyDrawable = dri1DestroyDrawable;
- dri_state->swapBuffer = dri1SwapBuffer;
- dri_state->getRenderingBuffer = dri1GetRenderingBuffer;
+ dri_state->base.swapBuffer = dri1SwapBuffer;
+ dri_state->base.getRenderingBuffer = dri1GetRenderingBuffer;
dri_state->close = dri1Close;
- dri_state->getDrawable = dri_get_drawable;
+ dri_state->base.getDrawable = dri_get_drawable;
return True;
err_out1:
- if (dri_state->pSAREA != MAP_FAILED)
- drmUnmap(dri_state->pSAREA, SAREA_MAX);
+ if (dri_state->base.pSAREA != MAP_FAILED)
+ drmUnmap(dri_state->base.pSAREA, SAREA_MAX);
- if (dri_state->fd >= 0)
- drmCloseOnce(dri_state->fd);
+ if (dri_state->base.fd >= 0)
+ drmCloseOnce(dri_state->base.fd);
VA_DRICloseConnection((Display *)ctx->native_dpy, ctx->x11_screen);
@@ -149,8 +149,8 @@ err_out0:
if (*driver_name)
XFree(*driver_name);
- dri_state->pSAREA = MAP_FAILED;
- dri_state->fd = -1;
+ dri_state->base.pSAREA = MAP_FAILED;
+ dri_state->base.fd = -1;
*driver_name = NULL;
return False;
diff --git a/va/x11/dri2_util.c b/va/x11/dri2_util.c
index df82b3e..14c6dc7 100644
--- a/va/x11/dri2_util.c
+++ b/va/x11/dri2_util.c
@@ -48,8 +48,8 @@ dri2CreateDrawable(VADriverContextP ctx, XID x_drawable)
return NULL;
dri2_drawable->base.x_drawable = x_drawable;
- dri2_drawable->base.x = 0;
- dri2_drawable->base.y = 0;
+ dri2_drawable->base.base.x = 0;
+ dri2_drawable->base.base.y = 0;
VA_DRI2CreateDrawable((Display *)ctx->native_dpy, x_drawable);
return &dri2_drawable->base;
@@ -63,17 +63,17 @@ dri2DestroyDrawable(VADriverContextP ctx, struct dri_drawable *dri_drawable)
}
static void
-dri2SwapBuffer(VADriverContextP ctx, struct dri_drawable *dri_drawable)
+dri2SwapBuffer(VADriverContextP ctx, struct drm_drawable *drm_drawable)
{
- struct dri2_drawable *dri2_drawable = (struct dri2_drawable *)dri_drawable;
+ struct dri2_drawable *dri2_drawable = (struct dri2_drawable *)drm_drawable;
XRectangle xrect;
XserverRegion region;
if (dri2_drawable->has_backbuffer) {
if (gsDRI2SwapAvailable) {
CARD64 ret;
- VA_DRI2SwapBuffers(ctx->native_dpy, dri_drawable->x_drawable, 0, 0,
- 0, &ret);
+ VA_DRI2SwapBuffers(ctx->native_dpy, dri2_drawable->base.x_drawable,
+ 0, 0, 0, &ret);
} else {
xrect.x = 0;
xrect.y = 0;
@@ -81,29 +81,29 @@ dri2SwapBuffer(VADriverContextP ctx, struct dri_drawable *dri_drawable)
xrect.height = dri2_drawable->height;
region = XFixesCreateRegion(ctx->native_dpy, &xrect, 1);
- VA_DRI2CopyRegion(ctx->native_dpy, dri_drawable->x_drawable, region,
- DRI2BufferFrontLeft, DRI2BufferBackLeft);
+ VA_DRI2CopyRegion(ctx->native_dpy, dri2_drawable->base.x_drawable,
+ region, DRI2BufferFrontLeft, DRI2BufferBackLeft);
XFixesDestroyRegion(ctx->native_dpy, region);
}
}
}
static union dri_buffer *
-dri2GetRenderingBuffer(VADriverContextP ctx, struct dri_drawable *dri_drawable)
+dri2GetRenderingBuffer(VADriverContextP ctx, struct drm_drawable *drm_drawable)
{
- struct dri2_drawable *dri2_drawable = (struct dri2_drawable *)dri_drawable;
+ struct dri2_drawable *dri2_drawable = (struct dri2_drawable *)drm_drawable;
int i;
int count;
unsigned int attachments[5];
VA_DRI2Buffer *buffers;
i = 0;
- if (dri_drawable->is_window)
+ if (dri2_drawable->base.is_window)
attachments[i++] = __DRI_BUFFER_BACK_LEFT;
else
attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
- buffers = VA_DRI2GetBuffers(ctx->native_dpy, dri_drawable->x_drawable,
+ buffers = VA_DRI2GetBuffers(ctx->native_dpy, dri2_drawable->base.x_drawable,
&dri2_drawable->width, &dri2_drawable->height,
attachments, i, &count);
assert(buffers);
@@ -128,8 +128,8 @@ dri2GetRenderingBuffer(VADriverContextP ctx, struct dri_drawable *dri_drawable)
dri2_drawable->front_index = i;
}
- dri_drawable->width = dri2_drawable->width;
- dri_drawable->height = dri2_drawable->height;
+ drm_drawable->width = dri2_drawable->width;
+ drm_drawable->height = dri2_drawable->height;
Xfree(buffers);
if (dri2_drawable->has_backbuffer)
@@ -141,26 +141,26 @@ dri2GetRenderingBuffer(VADriverContextP ctx, struct dri_drawable *dri_drawable)
void
dri2Close(VADriverContextP ctx)
{
- struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
+ struct dri_state *dri_state = (struct dri_state *)ctx->drm_state;
free_drawable_hashtable(ctx);
- if (dri_state->fd >= 0);
- close(dri_state->fd);
+ if (dri_state->base.fd >= 0);
+ close(dri_state->base.fd);
}
Bool
isDRI2Connected(VADriverContextP ctx, char **driver_name)
{
- struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
+ struct dri_state *dri_state = (struct dri_state *)ctx->drm_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;
+ dri_state->base.fd = -1;
+ dri_state->base.driConnectedFlag = VA_NONE;
if (!VA_DRI2QueryExtension((Display *)ctx->native_dpy, &event_base, &error_base))
goto err_out;
@@ -172,26 +172,26 @@ isDRI2Connected(VADriverContextP ctx, char **driver_name)
driver_name, &device_name))
goto err_out;
- dri_state->fd = open(device_name, O_RDWR);
- assert(dri_state->fd >= 0);
+ dri_state->base.fd = open(device_name, O_RDWR);
+ assert(dri_state->base.fd >= 0);
- if (dri_state->fd < 0)
+ if (dri_state->base.fd < 0)
goto err_out;
- if (drmGetMagic(dri_state->fd, &magic))
+ if (drmGetMagic(dri_state->base.fd, &magic))
goto err_out;
if (!VA_DRI2Authenticate((Display *)ctx->native_dpy, RootWindow((Display *)ctx->native_dpy, ctx->x11_screen),
magic))
goto err_out;
- dri_state->driConnectedFlag = VA_DRI2;
+ dri_state->base.driConnectedFlag = VA_DRI2;
dri_state->createDrawable = dri2CreateDrawable;
dri_state->destroyDrawable = dri2DestroyDrawable;
- dri_state->swapBuffer = dri2SwapBuffer;
- dri_state->getRenderingBuffer = dri2GetRenderingBuffer;
+ dri_state->base.swapBuffer = dri2SwapBuffer;
+ dri_state->base.getRenderingBuffer = dri2GetRenderingBuffer;
dri_state->close = dri2Close;
- dri_state->getDrawable = dri_get_drawable;
+ dri_state->base.getDrawable = dri_get_drawable;
gsDRI2SwapAvailable = (minor >= 2);
if (device_name)
@@ -206,11 +206,11 @@ err_out:
if (*driver_name)
Xfree(*driver_name);
- if (dri_state->fd >= 0)
- close(dri_state->fd);
+ if (dri_state->base.fd >= 0)
+ close(dri_state->base.fd);
*driver_name = NULL;
- dri_state->fd = -1;
+ dri_state->base.fd = -1;
return False;
}
diff --git a/va/x11/va_dricommon.c b/va/x11/va_dricommon.c
index 603354b..eaab8e3 100644
--- a/va/x11/va_dricommon.c
+++ b/va/x11/va_dricommon.c
@@ -38,7 +38,7 @@ is_window(Display *dpy, Drawable drawable)
static struct dri_drawable *
do_drawable_hash(VADriverContextP ctx, XID drawable)
{
- struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
+ struct dri_state *dri_state = (struct dri_state *)ctx->drm_state;
int index = drawable % DRAWABLE_HASH_SZ;
struct dri_drawable *dri_drawable = dri_state->drawable_hash[index];
@@ -60,7 +60,7 @@ do_drawable_hash(VADriverContextP ctx, XID drawable)
void
free_drawable(VADriverContextP ctx, struct dri_drawable* dri_drawable)
{
- struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
+ struct dri_state *dri_state = (struct dri_state *)ctx->drm_state;
int i = 0;
while (i++ < DRAWABLE_HASH_SZ) {
@@ -74,7 +74,7 @@ free_drawable(VADriverContextP ctx, struct dri_drawable* dri_drawable)
void
free_drawable_hashtable(VADriverContextP ctx)
{
- struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
+ struct dri_state *dri_state = (struct dri_state *)ctx->drm_state;
int i;
struct dri_drawable *dri_drawable, *prev;
@@ -91,10 +91,10 @@ free_drawable_hashtable(VADriverContextP ctx)
}
}
-struct dri_drawable *
+struct drm_drawable *
dri_get_drawable(VADriverContextP ctx, void *drawable)
{
- return do_drawable_hash(ctx, (XID) drawable);
+ return &(do_drawable_hash(ctx, (XID) drawable)->base);
}
/* FIXME: remove swap_buffer and get_rendering_buffer
@@ -104,15 +104,15 @@ dri_get_drawable(VADriverContextP ctx, void *drawable)
void
dri_swap_buffer(VADriverContextP ctx, struct dri_drawable *dri_drawable)
{
- struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
+ struct dri_state *dri_state = (struct dri_state *)ctx->drm_state;
- dri_state->swapBuffer(ctx, dri_drawable);
+ dri_state->base.swapBuffer(ctx, &dri_drawable->base);
}
union dri_buffer *
dri_get_rendering_buffer(VADriverContextP ctx, struct dri_drawable *dri_drawable)
{
- struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
+ struct dri_state *dri_state = (struct dri_state *)ctx->drm_state;
- return dri_state->getRenderingBuffer(ctx, dri_drawable);
+ return dri_state->base.getRenderingBuffer(ctx, &dri_drawable->base);
}
diff --git a/va/x11/va_dricommon.h b/va/x11/va_dricommon.h
index 8ad6504..4342be8 100644
--- a/va/x11/va_dricommon.h
+++ b/va/x11/va_dricommon.h
@@ -1,73 +1,42 @@
#ifndef _VA_DRICOMMON_H_
#define _VA_DRICOMMON_H_
+#include <va_drmcommon.h>
+
#ifndef ANDROID
-#ifndef WAYLAND
#include <X11/Xlib.h>
#endif
-#include <xf86drm.h>
-#include <drm.h>
-#include <drm_sarea.h>
-#endif
#include <va/va_backend.h>
-#if defined(ANDROID) || defined(WAYLAND)
-#define XID unsigned long
+#ifdef ANDROID
+#define XID unsigned int
#define Bool int
#endif
-enum
-{
- VA_NONE = 0,
- VA_DRI1 = 1,
- VA_DRI2 = 2,
- VA_DUMMY = 3
-};
-
-union dri_buffer
-{
- struct {
- unsigned int attachment;
- unsigned int name;
- unsigned int pitch;
- unsigned int cpp;
- unsigned int flags;
- } dri2;
-
- struct {
- } dri1;
-};
+#define dri_buffer drm_buffer
struct dri_drawable
{
+ struct drm_drawable base;
XID x_drawable;
int is_window;
- 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 */
+ struct drm_state base;
+
#ifndef ANDROID
- 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);
- struct dri_drawable *(*getDrawable)(VADriverContextP ctx, void *drawable);
#endif
};
@@ -75,7 +44,7 @@ Bool isDRI2Connected(VADriverContextP ctx, char **driver_name);
Bool isDRI1Connected(VADriverContextP ctx, char **driver_name);
void free_drawable(VADriverContextP ctx, struct dri_drawable* dri_drawable);
void free_drawable_hashtable(VADriverContextP ctx);
-struct dri_drawable *dri_get_drawable(VADriverContextP ctx, void *drawable);
+struct drm_drawable *dri_get_drawable(VADriverContextP ctx, void *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);
diff --git a/va/x11/va_x11.c b/va/x11/va_x11.c
index 947b5b1..0a36250 100644
--- a/va/x11/va_x11.c
+++ b/va/x11/va_x11.c
@@ -61,12 +61,12 @@ static void va_DisplayContextDestroy (
return;
ctx = pDisplayContext->pDriverContext;
- dri_state = ctx->dri_state;
+ dri_state = ctx->drm_state;
if (dri_state && dri_state->close)
dri_state->close(ctx);
- free(pDisplayContext->pDriverContext->dri_state);
+ free(pDisplayContext->pDriverContext->drm_state);
free(pDisplayContext->pDriverContext);
free(pDisplayContext);
}
@@ -188,7 +188,7 @@ VADisplay vaGetDisplay (
pDisplayContext->vaDestroy = va_DisplayContextDestroy;
pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
pDisplayContext->opaque = NULL;
- pDriverContext->dri_state = dri_state;
+ pDriverContext->drm_state = dri_state;
dpy = (VADisplay)pDisplayContext;
}
else