summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2010-03-10 18:59:29 +0100
committerOwain G. Ainsworth <oga@openbsd.org>2010-05-16 19:59:29 +0100
commit68f749dfcb36c964f93bafba33daea4e875e4e72 (patch)
tree3553abe354f381e8028e1a414c3b9645b50e3ca8
parentb55d91b7c81c13fd6383efd938e6f12500881c7e (diff)
libXvMC: derive driver context from struct intel_xvmc_context
... by putting struct intel_xvmc_surface at the beginning. Also kill the common context handling code and simply keep a pointer in the surface private to the context. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> (cherry picked from commit 8a31dacb067f813a5b0eafc16d265434e48ec5fc) Signed-off-by: Owain G. Ainsworth <oga@openbsd.org>
-rw-r--r--src/xvmc/i915_xvmc.c2
-rw-r--r--src/xvmc/i915_xvmc.h1
-rw-r--r--src/xvmc/i965_xvmc.c27
-rw-r--r--src/xvmc/intel_xvmc.c71
-rw-r--r--src/xvmc/intel_xvmc.h12
-rw-r--r--src/xvmc/xvmc_vld.c44
6 files changed, 48 insertions, 109 deletions
diff --git a/src/xvmc/i915_xvmc.c b/src/xvmc/i915_xvmc.c
index 55d81960..45be718e 100644
--- a/src/xvmc/i915_xvmc.c
+++ b/src/xvmc/i915_xvmc.c
@@ -1103,7 +1103,7 @@ static int i915_xvmc_mc_render_surface(Display * display, XvMCContext * context,
if (!i915_xvmc_alloc_render_state_buffers(pI915XvMC))
return BadAlloc;
- intel_ctx = intel_xvmc_find_context(context->context_id);
+ intel_ctx = context->privData;
if (!intel_ctx) {
XVMC_ERR("Can't find intel xvmc context\n");
return BadValue;
diff --git a/src/xvmc/i915_xvmc.h b/src/xvmc/i915_xvmc.h
index e5b84220..246faf9c 100644
--- a/src/xvmc/i915_xvmc.h
+++ b/src/xvmc/i915_xvmc.h
@@ -50,6 +50,7 @@
* pointer in the XvMCContext structure.
*/
typedef struct _i915XvMCContext {
+ struct intel_xvmc_context comm;
unsigned int ctxno;
unsigned int dual_prime; /* Flag to identify when dual prime is in use. */
unsigned int yStride;
diff --git a/src/xvmc/i965_xvmc.c b/src/xvmc/i965_xvmc.c
index 91086ee6..3005a597 100644
--- a/src/xvmc/i965_xvmc.c
+++ b/src/xvmc/i965_xvmc.c
@@ -241,11 +241,10 @@ out:
static Status destroy_context(Display * display, XvMCContext * context)
{
- struct i965_xvmc_context *private_context;
- private_context = context->privData;
-
- free_object(&media_state);
- Xfree(private_context);
+ struct intel_xvmc_context *intel_ctx;
+ intel_ctx = context->privData;
+ Xfree(intel_ctx->hw);
+ free(intel_ctx);
return Success;
}
@@ -720,7 +719,7 @@ static Status render_surface(Display * display,
struct intel_xvmc_surface *priv_future_surface =
future_surface ? future_surface->privData : 0;
unsigned short *block_ptr;
- intel_ctx = intel_xvmc_find_context(context->context_id);
+ intel_ctx = context->privData;
i965_ctx = context->privData;
if (!intel_ctx) {
XVMC_ERR("Can't find intel xvmc context\n");
@@ -871,12 +870,18 @@ static Status render_surface(Display * display,
static Status create_context(Display * display, XvMCContext * context,
int priv_count, CARD32 * priv_data)
{
- struct intel_xvmc_hw_context *ctx;
- ctx = (struct intel_xvmc_hw_context *)priv_data;
- context->privData = ctx;
+ struct intel_xvmc_context *intel_ctx;
+ struct intel_xvmc_hw_context *hw_ctx;
+ hw_ctx = (struct intel_xvmc_hw_context *)priv_data;
+
+ intel_ctx = calloc(1, sizeof(struct intel_xvmc_context));
+ if (!intel_ctx)
+ return BadAlloc;
+ intel_ctx->hw = hw_ctx;
+ context->privData = intel_ctx;
- media_state.is_g4x = ctx->i965.is_g4x;
- media_state.is_965_q = ctx->i965.is_965_q;
+ media_state.is_g4x = hw_ctx->i965.is_g4x;
+ media_state.is_965_q = hw_ctx->i965.is_965_q;
if (alloc_object(&media_state))
return BadAlloc;
diff --git a/src/xvmc/intel_xvmc.c b/src/xvmc/intel_xvmc.c
index 0b778c84..0d543479 100644
--- a/src/xvmc/intel_xvmc.c
+++ b/src/xvmc/intel_xvmc.c
@@ -128,60 +128,6 @@ void UNLOCK_HARDWARE(drm_context_t ctx)
PPTHREAD_MUTEX_UNLOCK();
}
-static intel_xvmc_context_ptr intel_xvmc_new_context(Display * dpy)
-{
- intel_xvmc_context_ptr ret;
-
- ret = (intel_xvmc_context_ptr) calloc(1, sizeof(intel_xvmc_context_t));
- if (!ret)
- return NULL;
-
- if (!xvmc_driver->ctx_list)
- ret->next = NULL;
- else
- ret->next = xvmc_driver->ctx_list;
- xvmc_driver->ctx_list = ret;
- xvmc_driver->num_ctx++;
-
- return ret;
-
-}
-
-static void intel_xvmc_free_context(XID id)
-{
- intel_xvmc_context_ptr p = xvmc_driver->ctx_list;
- intel_xvmc_context_ptr pre = p;
-
- while (p) {
- if (p->context && p->context->context_id == id) {
- if (p == xvmc_driver->ctx_list)
- xvmc_driver->ctx_list = p->next;
- else
- pre->next = p->next;
- break;
- }
- pre = p;
- p = p->next;
- }
-
- if (p) {
- free(p);
- xvmc_driver->num_ctx--;
- }
-}
-
-intel_xvmc_context_ptr intel_xvmc_find_context(XID id)
-{
- intel_xvmc_context_ptr p = xvmc_driver->ctx_list;
-
- while (p) {
- if (p->context && p->context->context_id == id)
- return p;
- p = p->next;
- }
- return NULL;
-}
-
static int
dri2_connect(Display *display)
{
@@ -364,14 +310,6 @@ _X_EXPORT Status XvMCCreateContext(Display * display, XvPortID port,
XVMC_INFO("decoder type is %s", intel_xvmc_decoder_string(comm->type));
- /* assign local ctx info */
- intel_ctx = intel_xvmc_new_context(display);
- if (!intel_ctx) {
- XVMC_ERR("Intel XvMC context create fail\n");
- return BadAlloc;
- }
- intel_ctx->context = context;
-
/* check DRI2 */
ret = Success;
xvmc_driver->fd = -1;
@@ -440,8 +378,6 @@ _X_EXPORT Status XvMCDestroyContext(Display * display, XvMCContext * context)
dri_bufmgr_destroy(xvmc_driver->bufmgr);
- intel_xvmc_free_context(context->context_id);
-
ret = _xvmc_destroy_context(display, context);
if (ret != Success) {
XVMC_ERR("_xvmc_destroy_context fail\n");
@@ -492,6 +428,7 @@ _X_EXPORT Status XvMCCreateSurface(Display * display, XvMCContext * context,
}
intel_surf = surface->privData;
+ intel_surf->context = context;
intel_surf->image = XvCreateImage(display, context->port,
FOURCC_XVMC,
@@ -701,17 +638,15 @@ _X_EXPORT Status XvMCPutSurface(Display * display, XvMCSurface * surface,
{
Status ret = Success;
XvMCContext *context;
- intel_xvmc_context_ptr intel_ctx;
intel_xvmc_surface_ptr intel_surf;
if (!display || !surface)
return XvMCBadSurface;
- intel_ctx = intel_xvmc_find_context(surface->context_id);
intel_surf = surface->privData;
- if (!intel_ctx || !intel_surf)
+ context = intel_surf->context;
+ if (!context || !intel_surf)
return XvMCBadSurface;
- context = intel_ctx->context;
if (intel_surf->gc_init == FALSE) {
intel_surf->gc = XCreateGC(display, draw, 0, NULL);
diff --git a/src/xvmc/intel_xvmc.h b/src/xvmc/intel_xvmc.h
index 23af6bb8..8ff29dab 100644
--- a/src/xvmc/intel_xvmc.h
+++ b/src/xvmc/intel_xvmc.h
@@ -103,13 +103,14 @@ extern Status _xvmc_create_subpicture(Display * dpy, XvMCContext * context,
extern Status _xvmc_destroy_subpicture(Display * dpy,
XvMCSubpicture * subpicture);
-typedef struct _intel_xvmc_context {
- XvMCContext *context;
+struct intel_xvmc_context {
+ struct intel_xvmc_hw_context *hw;
drm_context_t hw_context; /* context id to kernel drm */
- struct _intel_xvmc_context *next;
-} intel_xvmc_context_t, *intel_xvmc_context_ptr;
+};
+typedef struct intel_xvmc_context *intel_xvmc_context_ptr;
struct intel_xvmc_surface {
+ XvMCContext *context;
XvImage *image;
GC gc;
Bool gc_init;
@@ -248,9 +249,6 @@ static inline const char *intel_xvmc_decoder_string(int flag)
}
}
-extern intel_xvmc_context_ptr intel_xvmc_find_context(XID id);
-extern intel_xvmc_surface_ptr intel_xvmc_find_surface(XID id);
-
extern unsigned int mb_bytes_420[64];
/* dump function */
diff --git a/src/xvmc/xvmc_vld.c b/src/xvmc/xvmc_vld.c
index f314a4f3..5443f021 100644
--- a/src/xvmc/xvmc_vld.c
+++ b/src/xvmc/xvmc_vld.c
@@ -595,23 +595,30 @@ static Status cs_init(int interface_offset)
static Status create_context(Display * display, XvMCContext * context,
int priv_count, CARD32 * priv_data)
{
- struct intel_xvmc_hw_context *ctx;
- ctx = (struct intel_xvmc_hw_context *)priv_data;
- context->privData = priv_data;
+ struct intel_xvmc_context *intel_ctx;
+ struct intel_xvmc_hw_context *hw_ctx;
+ hw_ctx = (struct intel_xvmc_hw_context *)priv_data;
+
+ intel_ctx = calloc(1, sizeof(struct intel_xvmc_context));
+ if (!intel_ctx)
+ return BadAlloc;
+ intel_ctx->hw = hw_ctx;
+ context->privData = intel_ctx;
if (alloc_object(&media_state))
return BadAlloc;
- if (setup_media_kernels(ctx))
+ if (setup_media_kernels(hw_ctx))
return BadAlloc;
return Success;
}
static Status destroy_context(Display * display, XvMCContext * context)
{
- struct i965_xvmc_context *i965_ctx;
- i965_ctx = context->privData;
- Xfree(i965_ctx);
+ struct intel_xvmc_context *intel_ctx;
+ intel_ctx = context->privData;
+ Xfree(intel_ctx->hw);
+ free(intel_ctx);
return Success;
}
@@ -796,10 +803,9 @@ static Status begin_surface(Display * display, XvMCContext * context,
{
struct i965_xvmc_contex *i965_ctx;
struct intel_xvmc_surface *priv_target, *priv_past, *priv_future;
- intel_xvmc_context_ptr intel_ctx;
+ intel_xvmc_context_ptr intel_ctx = context->privData;
Status ret;
- intel_ctx = intel_xvmc_find_context(context->context_id);
priv_target = target->privData;
priv_past = past ? past->privData : NULL;
priv_future = future ? future->privData : NULL;
@@ -989,11 +995,10 @@ static Status put_slice2(Display * display, XvMCContext * context,
unsigned char *slice, int nbytes, int sliceCode)
{
unsigned int bit_buf;
- intel_xvmc_context_ptr intel_ctx;
- struct intel_xvmc_hw_context *ctx;
+ intel_xvmc_context_ptr intel_ctx = context->privData;
+ struct intel_xvmc_hw_context *hw_ctx = intel_ctx->hw;
int q_scale_code, mb_row;
- ctx = (struct intel_xvmc_hw_context *)context->privData;
mb_row = *(slice - 1) - 1;
bit_buf =
(slice[0] << 24) | (slice[1] << 16) | (slice[2] << 8) | (slice[3]);
@@ -1014,9 +1019,8 @@ static Status put_slice2(Display * display, XvMCContext * context,
memcpy(media_state.slice_data.bo->virtual, slice, nbytes);
- intel_ctx = intel_xvmc_find_context(context->context_id);
LOCK_HARDWARE(intel_ctx->hw_context);
- state_base_address(ctx);
+ state_base_address(hw_ctx);
pipeline_select();
media_state_pointers(VFE_VLD_MODE);
urb_layout();
@@ -1049,15 +1053,11 @@ static Status render_surface(Display * display,
unsigned short *block_ptr;
int i, j;
int block_offset = 0;
- struct intel_xvmc_hw_context *ctx;
+ struct intel_xvmc_hw_context *hw_ctx;
- intel_ctx = intel_xvmc_find_context(context->context_id);
- if (!intel_ctx) {
- XVMC_ERR("Can't find intel xvmc context\n");
- return BadValue;
- }
+ intel_ctx = context->privData;
- ctx = (struct intel_xvmc_hw_context *)context->privData;
+ hw_ctx = (struct intel_xvmc_hw_context *)context->privData;
priv_target = target_surface->privData;
priv_past = past_surface ? past_surface->privData : NULL;
priv_future = future_surface ? future_surface->privData : NULL;
@@ -1140,7 +1140,7 @@ static Status render_surface(Display * display,
}
LOCK_HARDWARE(intel_ctx->hw_context);
- state_base_address(ctx);
+ state_base_address(hw_ctx);
flush();
pipeline_select();
urb_layout();