Commit 036cd4bb authored by Daniel Vetter's avatar Daniel Vetter

i965 XvMC: don't create any surface state in the ddx

Like for i915. Also drop that now totally superflous limit on the
available surfaces.

Move the surface struct into the userspace library header now that
the ddx doesn't use it anymore.
Signed-off-by: Daniel Vetter's avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 69218cc1
......@@ -114,10 +114,6 @@ Bool intel_xvmc_screen_init(ScreenPtr pScreen)
/* i915 hwmc support */
#define _INTEL_XVMC_SERVER_
#define I915_XVMC_MAX_BUFFERS 2
#define I915_XVMC_MAX_CONTEXTS 4
#define I915_XVMC_MAX_SURFACES 20
static XF86MCSurfaceInfoRec i915_YV12_mpg2_surface = {
SURFACE_TYPE_MPEG2_MPML,
XVMC_CHROMA_FORMAT_420,
......@@ -337,49 +333,11 @@ static void destroy_context(ScrnInfoPtr scrn, XvMCContextPtr context)
static int create_surface(ScrnInfoPtr scrn, XvMCSurfacePtr surface,
int *num_priv, CARD32 ** priv)
{
XvMCContextPtr ctx = surface->context;
struct i965_xvmc_surface *priv_surface, *surface_dup;
struct i965_xvmc_context *priv_ctx = ctx->driver_priv;
int i;
for (i = 0; i < I965_MAX_SURFACES; i++) {
if (priv_ctx->surfaces[i] == NULL) {
priv_surface = Xcalloc(sizeof(*priv_surface));
if (priv_surface == NULL)
return BadAlloc;
surface_dup = Xcalloc(sizeof(*priv_surface));
if (surface_dup == NULL)
return BadAlloc;
priv_surface->no = i;
priv_surface->handle = priv_surface;
priv_surface->w = ctx->width;
priv_surface->h = ctx->height;
priv_ctx->surfaces[i] = surface->driver_priv
= priv_surface;
memcpy(surface_dup, priv_surface,
sizeof(*priv_surface));
*num_priv = sizeof(*priv_surface) / sizeof(CARD32);
*priv = (CARD32 *) surface_dup;
break;
}
}
if (i >= I965_MAX_SURFACES) {
ErrorF("I965 XVMC too many surfaces in one context\n");
return BadAlloc;
}
return Success;
}
static void destory_surface(ScrnInfoPtr scrn, XvMCSurfacePtr surface)
{
XvMCContextPtr ctx = surface->context;
struct i965_xvmc_surface *priv_surface = surface->driver_priv;
struct i965_xvmc_context *priv_ctx = ctx->driver_priv;
priv_ctx->surfaces[priv_surface->no] = NULL;
Xfree(priv_surface);
}
static XF86MCSurfaceInfoRec yv12_mpeg2_vld_surface = {
......
#define I965_MC_STATIC_BUFFER_SIZE (1024*512)
#define I965_MAX_SURFACES 12
struct i965_xvmc_surface {
int w, h;
unsigned int no;
void *handle;
dri_bo *bo;
};
struct i965_xvmc_context {
struct _intel_xvmc_common comm;
struct i965_xvmc_surface *surfaces[I965_MAX_SURFACES];
unsigned int is_g4x:1;
unsigned int is_965_q:1;
unsigned int is_igdng:1;
......
......@@ -256,12 +256,18 @@ static Status create_surface(Display * display,
XvMCContext * context, XvMCSurface * surface,
int priv_count, CARD32 * priv_data)
{
struct i965_xvmc_surface *priv_surface =
(struct i965_xvmc_surface *)priv_data;
size_t size = SIZE_YUV420(priv_surface->w, priv_surface->h);
surface->privData = priv_data;
struct i965_xvmc_surface *priv_surface = malloc(sizeof(struct i965_xvmc_surface));
if (!priv_surface)
return BadAlloc;
size_t size = SIZE_YUV420(context->width, context->height);
surface->privData = priv_surface;
priv_surface->bo = drm_intel_bo_alloc(xvmc_driver->bufmgr, "surface",
size, 0x1000);
Xfree(priv_data);
return Success;
}
......@@ -269,8 +275,8 @@ static Status destroy_surface(Display * display, XvMCSurface * surface)
{
struct i965_xvmc_surface *priv_surface = surface->privData;
XSync(display, False);
drm_intel_bo_unreference(priv_surface->bo);
free(priv_surface);
return Success;
}
......
#include "intel_xvmc.h"
#define I965_MAX_SURFACES 12
struct i965_xvmc_surface {
dri_bo *bo;
};
......@@ -620,13 +620,18 @@ static Status create_surface(Display * display,
XvMCContext * context, XvMCSurface * surface,
int priv_count, CARD32 * priv_data)
{
struct i965_xvmc_surface *priv_surface =
(struct i965_xvmc_surface *)priv_data;
size_t size = SIZE_YUV420(priv_surface->w, priv_surface->h);
surface->privData = priv_data;
struct i965_xvmc_surface *priv_surface = malloc(sizeof(struct i965_xvmc_surface));
if (!priv_surface)
return BadAlloc;
size_t size = SIZE_YUV420(context->width, context->height);
surface->privData = priv_surface;
priv_surface->bo = drm_intel_bo_alloc(xvmc_driver->bufmgr, "surface",
size, 0x1000);
Xfree(priv_data);
return Success;
}
......@@ -635,6 +640,7 @@ static Status destroy_surface(Display * display, XvMCSurface * surface)
struct i965_xvmc_surface *priv_surface = surface->privData;
XSync(display, False);
drm_intel_bo_unreference(priv_surface->bo);
free(priv_surface);
return Success;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment