summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2011-07-20 20:34:31 +0000
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2011-07-20 20:41:14 +0000
commit5b88f270c151df7f39efaea47358149bc2d860f9 (patch)
treedc35a4c61a760c66b7e331ac06a3db2db2ab47a9
parentb9b59b2c928fe9028a6aced9bb39e9299a015763 (diff)
va/wayland: Update to drm_state
l---------va/wayland/va_dricommon.h1
-rw-r--r--va/wayland/va_wayland.c85
2 files changed, 46 insertions, 40 deletions
diff --git a/va/wayland/va_dricommon.h b/va/wayland/va_dricommon.h
deleted file mode 120000
index 18a0364..0000000
--- a/va/wayland/va_dricommon.h
+++ /dev/null
@@ -1 +0,0 @@
-../x11/va_dricommon.h \ No newline at end of file
diff --git a/va/wayland/va_wayland.c b/va/wayland/va_wayland.c
index 2ba5b6b..6d660b7 100644
--- a/va/wayland/va_wayland.c
+++ b/va/wayland/va_wayland.c
@@ -25,7 +25,7 @@
#include "va.h"
#include "va_backend.h"
#include "va_wayland.h"
-#include "va_dricommon.h"
+#include "va_drmcommon.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -53,9 +53,10 @@ struct wldrm_ctx {
};
struct wldrm_buffer {
- union dri_buffer base;
+ union drm_buffer base;
drm_intel_bo *bo;
struct wl_buffer *buf;
+
};
enum wldrm_buffer_type {
@@ -64,13 +65,21 @@ enum wldrm_buffer_type {
WLDRM_BUFFER_COUNT
};
+#define DRAWABLE_HASH_SZ 32
struct wldrm_drawable {
- struct dri_drawable base;
+ struct drm_drawable base;
struct wl_egl_window *win;
int block_swap_buffers;
struct wldrm_buffer *buffer[WLDRM_BUFFER_COUNT];
+
+ struct wldrm_drawable *next;
+};
+
+struct wldrm_state {
+ struct drm_state base;
+ struct wldrm_drawable *drawable_hash[DRAWABLE_HASH_SZ];
};
enum {
@@ -94,7 +103,7 @@ wldrm_ctx(struct VADriverContext *driver_ctx)
}
static inline struct wldrm_drawable *
-wldrm_drawable(struct dri_drawable *drawable)
+wldrm_drawable(struct drm_drawable *drawable)
{
return (struct wldrm_drawable *) drawable;
}
@@ -159,9 +168,9 @@ bo_alloc(struct wldrm_ctx *wctx,
return bo;
}
-static union dri_buffer *
+static union drm_buffer *
wldrm_get_render_buffer(struct VADriverContext *ctx,
- struct dri_drawable *drawable)
+ struct drm_drawable *drawable)
{
struct wldrm_ctx *wctx = wldrm_ctx(ctx);
struct wldrm_drawable *wdrawable = wldrm_drawable(drawable);
@@ -198,7 +207,7 @@ wldrm_frame_callback(struct wl_surface *surface, void *data, uint32_t time)
static void
wldrm_swap_buffer(struct VADriverContext *ctx,
- struct dri_drawable *drawable)
+ struct drm_drawable *drawable)
{
struct wldrm_ctx *wctx = wldrm_ctx(ctx);
struct wldrm_drawable *wdrawable = wldrm_drawable(drawable);
@@ -233,17 +242,16 @@ wldrm_swap_buffer(struct VADriverContext *ctx,
wl_display_flush(display);
}
-static struct dri_drawable *
+static struct drm_drawable *
wldrm_get_drawable(struct VADriverContext *ctx, void *native_drawable)
{
- struct dri_state *dri_state = ctx->dri_state;
+ struct wldrm_state *drm_state = ctx->drm_state;
struct wl_egl_window *win = native_drawable;
struct wldrm_drawable *wdrawable;
int index = surface_get_id(win->surface) % DRAWABLE_HASH_SZ;
- for (wdrawable = wldrm_drawable(dri_state->drawable_hash[index]);
- wdrawable != NULL;
- wdrawable = wldrm_drawable(wdrawable->base.next)) {
+ for (wdrawable = drm_state->drawable_hash[index];
+ wdrawable != NULL; wdrawable = wdrawable->next) {
if (wdrawable->win == win)
return &wdrawable->base;
}
@@ -252,10 +260,9 @@ wldrm_get_drawable(struct VADriverContext *ctx, void *native_drawable)
if (!wdrawable)
return NULL;
- wdrawable->base.next = dri_state->drawable_hash[index];
- dri_state->drawable_hash[index] = &wdrawable->base;
+ wdrawable->next = drm_state->drawable_hash[index];
+ drm_state->drawable_hash[index] = wdrawable;
- wdrawable->base.is_window = 1;
wdrawable->base.x = 0;
wdrawable->base.y = 0;
wdrawable->base.width = win->width;
@@ -272,7 +279,7 @@ static void
drm_handle_device(void *data, struct wl_drm *drm, const char *device)
{
struct wldrm_ctx *wctx = data;
- struct dri_state *dri_state = wctx->base.dri_state;
+ struct drm_state *drm_state = wctx->base.drm_state;
drm_magic_t magic;
struct stat st;
@@ -287,14 +294,14 @@ drm_handle_device(void *data, struct wl_drm *drm, const char *device)
return;
}
- dri_state->fd = open(device, O_RDWR);
- if (dri_state->fd == -1) {
+ drm_state->fd = open(device, O_RDWR);
+ if (drm_state->fd == -1) {
fprintf(stderr, "Cannot open '%s': %d, %s\n",
device, errno, strerror(errno));
return;
}
- drmGetMagic(dri_state->fd, &magic);
+ drmGetMagic(drm_state->fd, &magic);
wl_drm_authenticate(wctx->drm, magic);
}
@@ -316,11 +323,11 @@ wldrm_display_ctx_get_driver_name(struct VADisplayContext *display_ctx,
char **driver_name)
{
struct wldrm_ctx *wctx = wldrm_ctx(va_driver_ctx(display_ctx));
- struct dri_state *dri_state = wctx->base.dri_state;
+ struct drm_state *drm_state = wctx->base.drm_state;
struct wl_display *display = wctx->base.native_dpy;
uint32_t id;
- memset(dri_state, 0, sizeof(*dri_state));
+ memset(drm_state, 0, sizeof(*drm_state));
id = wl_display_get_global(display, "wl_drm", 1);
if (id == 0)
force_roundtrip(display);
@@ -332,7 +339,7 @@ wldrm_display_ctx_get_driver_name(struct VADisplayContext *display_ctx,
goto error_unknown;
wl_drm_add_listener(wctx->drm, &drm_listener, wctx);
force_roundtrip(display);
- if (dri_state->fd == -1) {
+ if (drm_state->fd == -1) {
fprintf(stderr, "can't open DRM devices\n");
goto cleanup_drm;
}
@@ -341,21 +348,21 @@ wldrm_display_ctx_get_driver_name(struct VADisplayContext *display_ctx,
if (!wctx->authenticated)
goto cleanup_fd;
- wctx->bufmgr = intel_bufmgr_gem_init(dup(dri_state->fd), 0x80000);
+ wctx->bufmgr = intel_bufmgr_gem_init(dup(drm_state->fd), 0x80000);
//intel_bufmgr_gem_enable_reuse(wctx->bufmgr);
*driver_name = strdup("i965");
- dri_state->driConnectedFlag = VA_DRI2;
+ drm_state->driConnectedFlag = VA_DRI2;
- dri_state->getRenderingBuffer = wldrm_get_render_buffer;
- dri_state->swapBuffer = wldrm_swap_buffer;
- dri_state->getDrawable = wldrm_get_drawable;
+ drm_state->getRenderingBuffer = wldrm_get_render_buffer;
+ drm_state->swapBuffer = wldrm_swap_buffer;
+ drm_state->getDrawable = wldrm_get_drawable;
return VA_STATUS_SUCCESS;
cleanup_fd:
- close(dri_state->fd);
- dri_state->fd = -1;
+ close(drm_state->fd);
+ drm_state->fd = -1;
cleanup_drm:
wl_drm_destroy(wctx->drm);
error_unknown:
@@ -372,18 +379,18 @@ static void
wldrm_display_ctx_destroy(struct VADisplayContext *display_ctx)
{
struct wldrm_ctx *wctx;
- struct dri_state *dri_state;
+ struct drm_state *drm_state;
if (!wldrm_display_ctx_is_valid(display_ctx))
return;
wctx = wldrm_ctx(va_driver_ctx(display_ctx));
- dri_state = wctx->base.dri_state;
+ drm_state = wctx->base.drm_state;
drm_intel_bufmgr_destroy(wctx->bufmgr);
- close(dri_state->fd);
+ close(drm_state->fd);
- free(dri_state);
+ free(drm_state);
free(wctx);
free(display_ctx);
}
@@ -400,13 +407,13 @@ vaGetDisplay(struct wl_display *native_dpy)
if (!dpy) {
/* create new entry */
struct wldrm_ctx *wctx;
- struct dri_state *dri_state;
+ struct wldrm_state *drm_state;
display_ctx = calloc(1, sizeof *display_ctx);
wctx = calloc(1, sizeof *wctx);
- dri_state = calloc(1, sizeof *dri_state);
+ drm_state = calloc(1, sizeof *drm_state);
- if (display_ctx && wctx && dri_state) {
+ if (display_ctx && wctx && drm_state) {
display_ctx->vadpy_magic = VA_DISPLAY_MAGIC;
display_ctx->pDriverContext = &wctx->base;
display_ctx->vaGetDriverName =
@@ -415,7 +422,7 @@ vaGetDisplay(struct wl_display *native_dpy)
display_ctx->vaDestroy = wldrm_display_ctx_destroy;
wctx->base.native_dpy = native_dpy;
- wctx->base.dri_state = dri_state;
+ wctx->base.drm_state = drm_state;
dpy = (VADisplay) display_ctx;
} else {
@@ -423,8 +430,8 @@ vaGetDisplay(struct wl_display *native_dpy)
free(display_ctx);
if (wctx)
free(wctx);
- if (dri_state)
- free(dri_state);
+ if (drm_state)
+ free(drm_state);
}
}