Commit b6228604 authored by Haihao Xiang's avatar Haihao Xiang Committed by Nan Hai Zou

DRI2 for XvMC

parent 50c10ede
......@@ -78,10 +78,10 @@ else
DEBUGFLAGS=""
fi
dnl AC_ARG_ENABLE(xvmc, AC_HELP_STRING([--disable-xvmc],
dnl [Disable XvMC support [[default=auto]]]),
dnl [XVMC="$enableval"],
dnl [XVMC=auto])
AC_ARG_ENABLE(xvmc, AC_HELP_STRING([--disable-xvmc],
[Disable XvMC support [[default=yes]]]),
[XVMC="$enableval"],
[XVMC=yes])
# Checks for extensions
XORG_DRIVER_CHECK_EXT(XINERAMA, xineramaproto)
......@@ -151,12 +151,6 @@ if test "$VIDEO_DEBUG" = yes; then
AC_DEFINE(VIDEO_DEBUG,1,[Enable debug support])
fi
if test "$XVMC" = auto; then
XVMC="$DRI"
fi
if test "$XVMC" = yes && test "$DRI" = no; then
AC_MSG_ERROR([XvMC can't be enabled without DRI])
fi
if test "$XVMC" = yes; then
PKG_CHECK_MODULES(XVMCLIB, [xvmc], [XVMC=yes], [XVMC=no])
PKG_CHECK_MODULES(XEXT, [xext])
......
......@@ -2767,8 +2767,9 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
#ifdef INTEL_XVMC
pI830->XvMCEnabled = FALSE;
from = xf86GetOptValBool(pI830->Options, OPTION_XVMC,
&pI830->XvMCEnabled) ? X_CONFIG : X_DEFAULT;
from = ((pI830->directRenderingType == DRI_DRI2) &&
xf86GetOptValBool(pI830->Options, OPTION_XVMC,
&pI830->XvMCEnabled) ? X_CONFIG : X_DEFAULT);
xf86DrvMsg(pScrn->scrnIndex, from, "Intel XvMC decoder %sabled\n",
pI830->XvMCEnabled ? "en" : "dis");
#endif
......
......@@ -52,12 +52,6 @@ Bool intel_xvmc_probe(ScrnInfoPtr pScrn)
I830Ptr pI830 = I830PTR(pScrn);
Bool ret = FALSE;
/* Disable XvMC on DRI2 for now */
if (pI830->directRenderingType == DRI_DRI2) {
pI830->XvMCEnabled = FALSE;
return FALSE;
}
if (!pI830->XvMCEnabled)
return FALSE;
......@@ -85,6 +79,9 @@ void intel_xvmc_finish(ScrnInfoPtr pScrn)
Bool intel_xvmc_driver_init(ScreenPtr pScreen, XF86VideoAdaptorPtr xv_adaptor)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
I830Ptr pI830 = I830PTR(pScrn);
struct drm_i915_setparam sp;
int ret;
if (!xvmc_driver) {
ErrorF("Failed to probe XvMC driver.\n");
......@@ -95,14 +92,23 @@ Bool intel_xvmc_driver_init(ScreenPtr pScreen, XF86VideoAdaptorPtr xv_adaptor)
ErrorF("XvMC driver initialize failed.\n");
return FALSE;
}
return TRUE;
/* Currently XvMC uses batchbuffer */
sp.param = I915_SETPARAM_ALLOW_BATCHBUFFER;
sp.value = 1;
ret = drmCommandWrite(pI830->drmSubFD, DRM_I915_SETPARAM,
&sp, sizeof(sp));
if (ret == 0)
return TRUE;
return FALSE;
}
Bool intel_xvmc_screen_init(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
I830Ptr pI830 = I830PTR(pScrn);
DRIInfoPtr pDRIInfo = pI830->pDRIInfo;
char buf[64];
if (!xvmc_driver)
return FALSE;
......@@ -119,9 +125,15 @@ Bool intel_xvmc_screen_init(ScreenPtr pScreen)
return FALSE;
}
sprintf(buf, "pci:%04x:%02x:%02x.%d",
pI830->PciInfo->domain,
pI830->PciInfo->bus,
pI830->PciInfo->dev,
pI830->PciInfo->func);
xf86XvMCRegisterDRInfo(pScreen, INTEL_XVMC_LIBNAME,
pDRIInfo->busIdString,
INTEL_XVMC_MAJOR, INTEL_XVMC_MINOR, INTEL_XVMC_PATCHLEVEL);
buf,
INTEL_XVMC_MAJOR, INTEL_XVMC_MINOR, INTEL_XVMC_PATCHLEVEL);
return TRUE;
}
......
......@@ -65,7 +65,6 @@ struct hwmc_buffer
struct _intel_xvmc_common {
unsigned int type;
unsigned int sarea_size;
struct hwmc_buffer batchbuffer;
};
......
......@@ -416,8 +416,6 @@ static int i915_xvmc_create_context (ScrnInfoPtr pScrn, XvMCContextPtr pContext,
int *num_priv, long **priv )
{
I830Ptr pI830 = I830PTR(pScrn);
DRIInfoPtr pDRIInfo = pI830->pDRIInfo;
I830DRIPtr pI830DRI = pDRIInfo->devPrivate;
I915XvMCCreateContextRec *contextRec = NULL;
I915XvMCPtr pXvMC = (I915XvMCPtr)xvmc_driver->devPrivate;
I915XvMCContextPriv *ctxpriv = NULL;
......@@ -490,7 +488,6 @@ static int i915_xvmc_create_context (ScrnInfoPtr pScrn, XvMCContextPtr pContext,
/* common context items */
contextRec->comm.type = xvmc_driver->flag;
contextRec->comm.sarea_size = pDRIInfo->SAREASize;
contextRec->comm.batchbuffer.offset = xvmc_driver->batch->offset;
contextRec->comm.batchbuffer.size = xvmc_driver->batch->size;
contextRec->comm.batchbuffer.handle = xvmc_driver->batch_handle;
......@@ -515,8 +512,7 @@ static int i915_xvmc_create_context (ScrnInfoPtr pScrn, XvMCContextPtr pContext,
contextRec->corrdata.handle = ctxpriv->corrdata_handle;
contextRec->corrdata.offset = ctxpriv->mcCorrdata->offset;
contextRec->corrdata.size = ctxpriv->mcCorrdata->size;
contextRec->sarea_priv_offset = sizeof(XF86DRISAREARec);
contextRec->deviceID = pI830DRI->deviceID;
contextRec->deviceID = DEVICE_ID(pI830->PciInfo);
if (IS_I915G(pI830) || IS_I915GM(pI830)) {
contextRec->sis.bus_addr = ctxpriv->mcStaticIndirectState->bus_addr;
......
......@@ -49,7 +49,6 @@ typedef struct
struct hwmc_buffer psp;
struct hwmc_buffer psc;
struct hwmc_buffer corrdata;/* Correction Data Buffer */
unsigned int sarea_priv_offset;
int deviceID;
} I915XvMCCreateContextRec;
......
......@@ -172,7 +172,10 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
OUT_BATCH(_3DSTATE_MAP_STATE | 3);
OUT_BATCH(0x00000001); /* texture map #1 */
OUT_RELOC(pPriv->buf, I915_GEM_DOMAIN_SAMPLER, 0, pPriv->YBuf0offset);
if (pPriv->buf)
OUT_RELOC(pPriv->buf, I915_GEM_DOMAIN_SAMPLER, 0, pPriv->YBuf0offset);
else
OUT_BATCH(pPriv->YBuf0offset);
ms3 = MAPSURF_422 | MS3_USE_FENCE_REGS;
switch (id) {
......@@ -281,7 +284,11 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
OUT_BATCH(_3DSTATE_MAP_STATE | 9);
OUT_BATCH(0x00000007);
OUT_RELOC(pPriv->buf, I915_GEM_DOMAIN_SAMPLER, 0, pPriv->YBuf0offset);
if (pPriv->buf)
OUT_RELOC(pPriv->buf, I915_GEM_DOMAIN_SAMPLER, 0, pPriv->YBuf0offset);
else
OUT_BATCH(pPriv->YBuf0offset);
ms3 = MAPSURF_8BIT | MT_8BIT_I8 | MS3_USE_FENCE_REGS;
ms3 |= (height - 1) << MS3_HEIGHT_SHIFT;
ms3 |= (width - 1) << MS3_WIDTH_SHIFT;
......@@ -294,14 +301,22 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
else
OUT_BATCH(((video_pitch * 2 / 4) - 1) << MS4_PITCH_SHIFT);
OUT_RELOC(pPriv->buf, I915_GEM_DOMAIN_SAMPLER, 0, pPriv->UBuf0offset);
if (pPriv->buf)
OUT_RELOC(pPriv->buf, I915_GEM_DOMAIN_SAMPLER, 0, pPriv->UBuf0offset);
else
OUT_BATCH(pPriv->UBuf0offset);
ms3 = MAPSURF_8BIT | MT_8BIT_I8 | MS3_USE_FENCE_REGS;
ms3 |= (height / 2 - 1) << MS3_HEIGHT_SHIFT;
ms3 |= (width / 2 - 1) << MS3_WIDTH_SHIFT;
OUT_BATCH(ms3);
OUT_BATCH(((video_pitch / 4) - 1) << MS4_PITCH_SHIFT);
OUT_RELOC(pPriv->buf, I915_GEM_DOMAIN_SAMPLER, 0, pPriv->VBuf0offset);
if (pPriv->buf)
OUT_RELOC(pPriv->buf, I915_GEM_DOMAIN_SAMPLER, 0, pPriv->VBuf0offset);
else
OUT_BATCH(pPriv->VBuf0offset);
ms3 = MAPSURF_8BIT | MT_8BIT_I8 | MS3_USE_FENCE_REGS;
ms3 |= (height / 2 - 1) << MS3_HEIGHT_SHIFT;
ms3 |= (width / 2 - 1) << MS3_WIDTH_SHIFT;
......
......@@ -89,7 +89,6 @@ static int create_context(ScrnInfoPtr pScrn,
{
struct i965_xvmc_context *private_context, *context_dup;
I830Ptr I830 = I830PTR(pScrn);
DRIInfoPtr driinfo = I830->pDRIInfo;
unsigned int blocknum =
(((context->width + 15)/16)*((context->height+15)/16));
......@@ -108,7 +107,6 @@ static int create_context(ScrnInfoPtr pScrn,
private_context->is_g4x = IS_G4X(I830);
private_context->is_965_q = IS_965_Q(I830);
private_context->comm.type = xvmc_driver->flag;
private_context->comm.sarea_size = driinfo->SAREASize;
private_context->comm.batchbuffer.offset = xvmc_driver->batch->offset;
private_context->comm.batchbuffer.size = xvmc_driver->batch->size;
private_context->comm.batchbuffer.handle = xvmc_driver->batch_handle;
......
......@@ -25,9 +25,8 @@ libIntelXvMC_la_SOURCES = intel_xvmc.c \
xvmc_vld.h \
intel_batchbuffer.c \
intel_batchbuffer.h \
xf86dri.c \
xf86dri.h \
xf86dristr.h
dri2.c \
dri2.h
libIntelXvMC_la_CFLAGS = @XORG_CFLAGS@ @DRM_CFLAGS@ @DRI_CFLAGS@ \
@XVMCLIB_CFLAGS@ -I$(top_srcdir)/src -DTRUE=1 -DFALSE=0
......
/*
* Copyright © 2008 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Soft-
* ware"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, provided that the above copyright
* notice(s) and this permission notice appear in all copies of the Soft-
* ware and that both the above copyright notice(s) and this permission
* notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
* ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
* RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
* THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
* QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR-
* MANCE OF THIS SOFTWARE.
*
* Except as contained in this notice, the name of a copyright holder shall
* not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization of
* the copyright holder.
*
* Authors:
* Kristian Høgsberg (krh@redhat.com)
*/
#define NEED_REPLIES
#include <X11/Xlibint.h>
#include <X11/extensions/Xext.h>
#include <X11/extensions/extutil.h>
#include <X11/extensions/dri2proto.h>
#include "xf86drm.h"
#include "dri2.h"
static char dri2ExtensionName[] = DRI2_NAME;
static XExtensionInfo *dri2Info;
static XEXT_GENERATE_CLOSE_DISPLAY (DRI2CloseDisplay, dri2Info)
static /* const */ XExtensionHooks dri2ExtensionHooks = {
NULL, /* create_gc */
NULL, /* copy_gc */
NULL, /* flush_gc */
NULL, /* free_gc */
NULL, /* create_font */
NULL, /* free_font */
DRI2CloseDisplay, /* close_display */
NULL, /* wire_to_event */
NULL, /* event_to_wire */
NULL, /* error */
NULL, /* error_string */
};
static XEXT_GENERATE_FIND_DISPLAY (DRI2FindDisplay, dri2Info,
dri2ExtensionName,
&dri2ExtensionHooks,
0, NULL)
Bool DRI2QueryExtension(Display *dpy, int *eventBase, int *errorBase)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
if (XextHasExtension(info)) {
*eventBase = info->codes->first_event;
*errorBase = info->codes->first_error;
return True;
}
return False;
}
Bool DRI2QueryVersion(Display *dpy, int *major, int *minor)
{
XExtDisplayInfo *info = DRI2FindDisplay (dpy);
xDRI2QueryVersionReply rep;
xDRI2QueryVersionReq *req;
XextCheckExtension (dpy, info, dri2ExtensionName, False);
LockDisplay(dpy);
GetReq(DRI2QueryVersion, req);
req->reqType = info->codes->major_opcode;
req->dri2ReqType = X_DRI2QueryVersion;
req->majorVersion = DRI2_MAJOR;
req->minorVersion = DRI2_MINOR;
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
}
*major = rep.majorVersion;
*minor = rep.minorVersion;
UnlockDisplay(dpy);
SyncHandle();
return True;
}
Bool DRI2Connect(Display *dpy, XID window,
char **driverName, char **deviceName)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
xDRI2ConnectReply rep;
xDRI2ConnectReq *req;
XextCheckExtension (dpy, info, dri2ExtensionName, False);
LockDisplay(dpy);
GetReq(DRI2Connect, req);
req->reqType = info->codes->major_opcode;
req->dri2ReqType = X_DRI2Connect;
req->window = window;
req->driverType = DRI2DriverDRI;
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
}
if (rep.driverNameLength == 0 && rep.deviceNameLength == 0) {
UnlockDisplay(dpy);
SyncHandle();
return False;
}
*driverName = Xmalloc(rep.driverNameLength + 1);
if (*driverName == NULL) {
_XEatData(dpy,
((rep.driverNameLength + 3) & ~3) +
((rep.deviceNameLength + 3) & ~3));
UnlockDisplay(dpy);
SyncHandle();
return False;
}
_XReadPad(dpy, *driverName, rep.driverNameLength);
(*driverName)[rep.driverNameLength] = '\0';
*deviceName = Xmalloc(rep.deviceNameLength + 1);
if (*deviceName == NULL) {
Xfree(*driverName);
_XEatData(dpy, ((rep.deviceNameLength + 3) & ~3));
UnlockDisplay(dpy);
SyncHandle();
return False;
}
_XReadPad(dpy, *deviceName, rep.deviceNameLength);
(*deviceName)[rep.deviceNameLength] = '\0';
UnlockDisplay(dpy);
SyncHandle();
return True;
}
Bool DRI2Authenticate(Display *dpy, XID window, drm_magic_t magic)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
xDRI2AuthenticateReq *req;
xDRI2AuthenticateReply rep;
XextCheckExtension (dpy, info, dri2ExtensionName, False);
LockDisplay(dpy);
GetReq(DRI2Authenticate, req);
req->reqType = info->codes->major_opcode;
req->dri2ReqType = X_DRI2Authenticate;
req->window = window;
req->magic = magic;
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
}
UnlockDisplay(dpy);
SyncHandle();
return rep.authenticated;
}
void DRI2CreateDrawable(Display *dpy, XID drawable)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
xDRI2CreateDrawableReq *req;
XextSimpleCheckExtension (dpy, info, dri2ExtensionName);
LockDisplay(dpy);
GetReq(DRI2CreateDrawable, req);
req->reqType = info->codes->major_opcode;
req->dri2ReqType = X_DRI2CreateDrawable;
req->drawable = drawable;
UnlockDisplay(dpy);
SyncHandle();
}
void DRI2DestroyDrawable(Display *dpy, XID drawable)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
xDRI2DestroyDrawableReq *req;
XextSimpleCheckExtension (dpy, info, dri2ExtensionName);
XSync(dpy, False);
LockDisplay(dpy);
GetReq(DRI2DestroyDrawable, req);
req->reqType = info->codes->major_opcode;
req->dri2ReqType = X_DRI2DestroyDrawable;
req->drawable = drawable;
UnlockDisplay(dpy);
SyncHandle();
}
DRI2Buffer *DRI2GetBuffers(Display *dpy, XID drawable,
int *width, int *height,
unsigned int *attachments, int count,
int *outCount)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
xDRI2GetBuffersReply rep;
xDRI2GetBuffersReq *req;
DRI2Buffer *buffers;
xDRI2Buffer repBuffer;
CARD32 *p;
int i;
XextCheckExtension (dpy, info, dri2ExtensionName, False);
LockDisplay(dpy);
GetReqExtra(DRI2GetBuffers, count * 4, req);
req->reqType = info->codes->major_opcode;
req->dri2ReqType = X_DRI2GetBuffers;
req->drawable = drawable;
req->count = count;
p = (CARD32 *) &req[1];
for (i = 0; i < count; i++)
p[i] = attachments[i];
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return NULL;
}
*width = rep.width;
*height = rep.height;
*outCount = rep.count;
buffers = Xmalloc(rep.count * sizeof buffers[0]);
if (buffers == NULL) {
_XEatData(dpy, rep.count * sizeof repBuffer);
UnlockDisplay(dpy);
SyncHandle();
return NULL;
}
for (i = 0; i < rep.count; i++) {
_XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer);
buffers[i].attachment = repBuffer.attachment;
buffers[i].name = repBuffer.name;
buffers[i].pitch = repBuffer.pitch;
buffers[i].cpp = repBuffer.cpp;
buffers[i].flags = repBuffer.flags;
}
UnlockDisplay(dpy);
SyncHandle();
return buffers;
}
void DRI2CopyRegion(Display *dpy, XID drawable, XserverRegion region,
CARD32 dest, CARD32 src)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
xDRI2CopyRegionReq *req;
xDRI2CopyRegionReply rep;
XextSimpleCheckExtension (dpy, info, dri2ExtensionName);
LockDisplay(dpy);
GetReq(DRI2CopyRegion, req);
req->reqType = info->codes->major_opcode;
req->dri2ReqType = X_DRI2CopyRegion;
req->drawable = drawable;
req->region = region;
req->dest = dest;
req->src = src;
_XReply(dpy, (xReply *)&rep, 0, xFalse);
UnlockDisplay(dpy);
SyncHandle();
}
/*
* Copyright © 2007,2008 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Soft-
* ware"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, provided that the above copyright
* notice(s) and this permission notice appear in all copies of the Soft-
* ware and that both the above copyright notice(s) and this permission
* notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
* ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
* RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
* THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
* QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR-
* MANCE OF THIS SOFTWARE.
*
* Except as contained in this notice, the name of a copyright holder shall
* not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization of
* the copyright holder.
*
* Authors:
* Kristian Høgsberg (krh@redhat.com)
*/
#ifndef _DRI2_H_
#define _DRI2_H_
#include <X11/extensions/Xfixes.h>
#include <X11/extensions/dri2tokens.h>
typedef struct {
unsigned int attachment;
unsigned int name;
unsigned int pitch;
unsigned int cpp;
unsigned int flags;
} DRI2Buffer;
extern Bool
DRI2QueryExtension(Display *display, int *eventBase, int *errorBase);
extern Bool
DRI2QueryVersion(Display *display, int *major, int *minor);
extern Bool
DRI2Connect(Display *display, XID window,
char **driverName, char **deviceName);
extern Bool
DRI2Authenticate(Display *display, XID window, drm_magic_t magic);
extern void
DRI2CreateDrawable(Display *display, XID drawable);
extern void
DRI2DestroyDrawable(Display *display, XID handle);
extern DRI2Buffer *
DRI2GetBuffers(Display *dpy, XID drawable,
int *width, int *height,
unsigned int *attachments, int count,
int *outCount);
extern void
DRI2CopyRegion(Display *dpy, XID drawable, XserverRegion region,
CARD32 dest, CARD32 src);
#endif
......@@ -1560,7 +1560,6 @@ static Status i915_xvmc_mc_create_context(Display *display, XvMCContext *context
{
i915XvMCContext *pI915XvMC = NULL;
I915XvMCCreateContextRec *tmpComm = NULL;
drm_sarea_t *pSAREA;
XVMC_DBG("%s\n", __FUNCTION__);
......@@ -1612,15 +1611,11 @@ static Status i915_xvmc_mc_create_context(Display *display, XvMCContext *context
pI915XvMC->corrdata.handle = tmpComm->corrdata.handle;
pI915XvMC->corrdata.offset = tmpComm->corrdata.offset;
pI915XvMC->corrdata.size = tmpComm->corrdata.size;
pI915XvMC->sarea_priv_offset = tmpComm->sarea_priv_offset;
/* Must free the private data we were passed from X */
XFree(priv_data);
priv_data = NULL;
pSAREA = (drm_sarea_t *)xvmc_driver->sarea_address;
pI915XvMC->sarea = (drmI830Sarea*)((char*)pSAREA + pI915XvMC->sarea_priv_offset);
if (i915_xvmc_map_buffers(pI915XvMC)) {
i915_xvmc_unmap_buffers(pI915XvMC);
free(pI915XvMC);
......@@ -2042,11 +2037,6 @@ static int i915_xvmc_mc_get_surface_status(Display *display,
}
}
if (pI915Surface->last_render &&
(pI915Surface->last_render > pI915XvMC->sarea->last_dispatch)) {
*stat |= XVMC_RENDERING;
}
PPTHREAD_MUTEX_UNLOCK();
return 0;
}
......@@ -2457,12 +2447,7 @@ Status i915_xvmc_get_subpict_status(Display *display, XvMCSubpicture *subpicture
return XvMCBadSubpicture;
PPTHREAD_MUTEX_LOCK();
/* FIXME: */
if (pI915Subpicture->last_render &&
(pI915Subpicture->last_render > pI915XvMC->sarea->last_dispatch)) {
*stat |= XVMC_RENDERING;
}
PPTHREAD_MUTEX_UNLOCK();
return Success;
}
......
......@@ -55,8 +55,6 @@ typedef struct _i915XvMCContext {
unsigned int yStride;
unsigned int uvStride;
unsigned short ref;
volatile drmI830Sarea *sarea;
unsigned int sarea_priv_offset; /* Offset in sarea to private part */
unsigned int depth;
XvPortID port; /* Xv Port ID when displaying */
int haveXv; /* Have I initialized the Xv
......
......@@ -100,21 +100,12 @@ unsigned int mb_bytes_420[] = {
int DEBUG;
static int error_base;
static int event_base;
static void intel_xvmc_debug_init(void)
{
if (getenv("INTEL_XVMC_DEBUG"))
DEBUG = 1;
}
/* locking */
static void intel_xvmc_try_heavy_lock(drm_context_t ctx)
{
drmGetLock(xvmc_driver->fd, ctx, 0);
}
void LOCK_HARDWARE(drm_context_t ctx)
{
char __ret = 0;
......@@ -122,19 +113,13 @@ void LOCK_HARDWARE(drm_context_t ctx)
PPTHREAD_MUTEX_LOCK();
assert(!xvmc_driver->locked);
DRM_CAS(xvmc_driver->driHwLock, ctx,
(DRM_LOCK_HELD | ctx), __ret);
if (__ret)
intel_xvmc_try_heavy_lock(ctx);
xvmc_driver->locked = 1;
}
void UNLOCK_HARDWARE(drm_context_t ctx)
{
xvmc_driver->locked = 0;
DRM_UNLOCK(xvmc_driver->fd, xvmc_driver->driHwLock, ctx);
PPTHREAD_MUTEX_UNLOCK();
}
......@@ -269,17 +254,18 @@ _X_EXPORT Status XvMCCreateContext(Display *display, XvPortID port,
int flags, XvMCContext *context)
{
Status ret;
drm_sarea_t *pSAREA;
char *curBusID;
CARD32 *priv_data = NULL;
struct _intel_xvmc_common *comm;
drm_magic_t magic;
int major, minor;
int error_base;
int event_base;
int priv_count;
int isCapable;
int screen = DefaultScreen(display);
intel_xvmc_context_ptr intel_ctx;
int fd;
char *driverName = NULL, *deviceName = NULL;
/* Verify Obvious things first */
if (!display || !context)
......@@ -356,7 +342,6 @@ _X_EXPORT Status XvMCCreateContext(Display *display, XvPortID port,
XVMC_INFO("decoder type is %s", intel_xvmc_decoder_string(comm->type));
xvmc_driver->sarea_size = comm->sarea_size;
xvmc_driver->batchbuffer.handle = comm->batchbuffer.handle;
xvmc_driver->batchbuffer.offset = comm->batchbuffer.offset;
xvmc_driver->batchbuffer.size = comm->batchbuffer.size;
......@@ -369,70 +354,60 @@ _X_EXPORT Status XvMCCreateContext(Display *display, XvPortID port,
}
intel_ctx->context = context;
ret = uniDRIQueryDirectRenderingCapable(display, screen,
&isCapable);
if (!ret || !isCapable) {
XVMC_ERR("Direct Rendering is not available on this system!");
XFree(priv_data);
return BadValue;
}
/* check DRI2 */
ret = Success;