summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZhenyu Wang <zhenyu.z.wang@intel.com>2007-08-07 16:47:13 +0800
committerZhenyu Wang <zhenyu.z.wang@intel.com>2007-08-07 16:47:13 +0800
commitb29a932bec2a3cc5a38e9c09c012cfdc1b6209c1 (patch)
tree36b6b897fcc0abee125a92f0af881a6b2107fc9f /src
parentc4deefa80a6349db968e25bd6778cdf7a514ca7f (diff)
code cleanups
and put wrap function in driver xvmc priv instead of per xv port priv
Diffstat (limited to 'src')
-rw-r--r--src/i830.h4
-rw-r--r--src/i830_driver.c8
-rw-r--r--src/i830_video.c23
-rw-r--r--src/i915_hwmc.c153
4 files changed, 89 insertions, 99 deletions
diff --git a/src/i830.h b/src/i830.h
index de377499..a792f389 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -746,8 +746,8 @@ static inline int i830_fb_compression_supported(I830Ptr pI830)
}
/* i915 XvMC */
-int I915XvMCInitXv(ScrnInfoPtr, XF86VideoAdaptorPtr);
-void I915InitMC(ScreenPtr);
+Bool I915XvMCInit(ScreenPtr, XF86VideoAdaptorPtr);
+Bool I915XvMCScreenInit(ScreenPtr);
unsigned long I915XvMCPutImageSize(ScrnInfoPtr);
extern const int I830PatternROP[16];
diff --git a/src/i830_driver.c b/src/i830_driver.c
index b617bd4a..7957e26e 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -2721,14 +2721,6 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
pI830->directRenderingEnabled = I830DRIFinishScreenInit(pScreen);
}
-#ifdef XvMCExtension
- if (pI830->XvEnabled && (pI830->directRenderingEnabled) &&
- (IS_I915G(pI830) || IS_I915GM(pI830) ||
- IS_I945G(pI830) || IS_I945GM(pI830) ||
- IS_G33CLASS(pI830))) {
- I915InitMC(pScreen);
- }
-#endif
#endif
/* Setup 3D engine, needed for rotation too */
diff --git a/src/i830_video.c b/src/i830_video.c
index 4ee9f761..ed681048 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -560,6 +560,7 @@ I830InitVideo(ScreenPtr pScreen)
XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL;
XF86VideoAdaptorPtr overlayAdaptor = NULL, texturedAdaptor = NULL;
int num_adaptors;
+ Bool xvmc_init = FALSE;
#if 0
{
@@ -602,16 +603,6 @@ I830InitVideo(ScreenPtr pScreen)
if (texturedAdaptor != NULL) {
adaptors[num_adaptors++] = texturedAdaptor;
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Set up textured video\n");
-
-#ifdef XF86DRI
-#ifdef XvMCExtension
- if (IS_I915G(pI830) || IS_I915GM(pI830) ||
- IS_I945G(pI830) || IS_I945GM(pI830) ||
- IS_G33CLASS(pI830)) {
- I915XvMCInitXv(pScrn, texturedAdaptor);
- }
-#endif
-#endif
} else {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Failed to set up textured video\n");
@@ -633,10 +624,18 @@ I830InitVideo(ScreenPtr pScreen)
I830InitOffscreenImages(pScreen);
}
+#ifdef XvMCExtension
+ if (texturedAdaptor)
+ xvmc_init = I915XvMCInit(pScreen, texturedAdaptor);
+#endif
if (num_adaptors)
xf86XVScreenInit(pScreen, adaptors, num_adaptors);
xfree(adaptors);
+#ifdef XvMCExtension
+ if (xvmc_init)
+ I915XvMCScreenInit(pScreen);
+#endif
}
static void
@@ -2631,11 +2630,7 @@ I830QueryImageAttributes(ScrnInfoPtr pScrn,
break;
case FOURCC_XVMC:
*h = (*h + 1) & ~1;
-#ifdef XF86DRI
size = I915XvMCPutImageSize(pScrn);
-#else
- size = 0;
-#endif
if (pitches)
pitches[0] = size;
break;
diff --git a/src/i915_hwmc.c b/src/i915_hwmc.c
index 158b7b8e..19e2b34e 100644
--- a/src/i915_hwmc.c
+++ b/src/i915_hwmc.c
@@ -118,6 +118,9 @@ typedef struct _I915XvMC
I915XvMCSurfacePriv *sfprivs[I915_XVMC_MAX_SURFACES];
I915XvMCContextPriv *ctxprivs[I915_XVMC_MAX_CONTEXTS];
int ncontexts,nsurfaces;
+ SetPortAttributeFuncPtr saveSetPortAttribute;
+ GetPortAttributeFuncPtr saveGetPortAttribute;
+ PutImageFuncPtr savePutImage;
} I915XvMC, *I915XvMCPtr;
#define ARRARY_SIZE(a) (sizeof(a) / sizeof(a[0]))
@@ -234,6 +237,7 @@ static void initI915XvMC(I915XvMCPtr xvmc)
}
}
+//XXX
static void cleanupI915XvMC(I915XvMCPtr xvmc, XF86VideoAdaptorPtr * XvAdaptors, int XvAdaptorCount)
{
unsigned int i;
@@ -483,15 +487,14 @@ static int I915XvMCCreateContext (ScrnInfoPtr pScrn, XvMCContextPtr pContext,
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)pContext->port_priv;
I830PortPrivPtr pPriv = (I830PortPrivPtr)portPriv->DevPriv.ptr;
I915XvMCXVPriv *vx = (I915XvMCXVPriv *)pPriv->xvmc_priv;
-
int i;
*priv = NULL;
*num_priv = 0;
- if (!pI830->directRenderingEnabled) {
+ if (!pI830->XvMCEnabled) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "[XvMC] I915XvMCCreateContext: Cannot use XvMC without DRI!\n");
+ "[XvMC] I915XvMCCreateContext: Cannot use XvMC!\n");
return BadAlloc;
}
@@ -834,6 +837,8 @@ static int I915XvMCInterceptXvGetAttribute(ScrnInfoPtr pScrn, Atom attribute,
unsigned i;
I830PortPrivPtr pPriv = (I830PortPrivPtr)data;
I915XvMCXVPriv *vx = (I915XvMCXVPriv *)pPriv->xvmc_priv;
+ I830Ptr pI830 = I830PTR(pScrn);
+ I915XvMCPtr pXvMC = pI830->xvmc;
if (I830PTR(pScrn)->XvMCEnabled) {
for (i = 0; i < vx->xvAttr.numAttr; ++i) {
@@ -844,7 +849,7 @@ static int I915XvMCInterceptXvGetAttribute(ScrnInfoPtr pScrn, Atom attribute,
}
}
- return vx->GetPortAttribute(pScrn, attribute, value, data);
+ return pXvMC->saveGetPortAttribute(pScrn, attribute, value, data);
}
static int I915XvMCInterceptXvAttribute(ScrnInfoPtr pScrn, Atom attribute,
@@ -853,8 +858,10 @@ static int I915XvMCInterceptXvAttribute(ScrnInfoPtr pScrn, Atom attribute,
unsigned i;
I830PortPrivPtr pPriv = (I830PortPrivPtr)data;
I915XvMCXVPriv *vx = (I915XvMCXVPriv *)pPriv->xvmc_priv;
+ I830Ptr pI830 = I830PTR(pScrn);
+ I915XvMCPtr pXvMC = pI830->xvmc;
- if (I830PTR(pScrn)->XvMCEnabled) {
+ if (pI830->XvMCEnabled) {
for (i = 0; i < vx->xvAttr.numAttr; ++i) {
if (vx->xvAttr.attributes[i].attribute == attribute) {
vx->xvAttr.attributes[i].value = value;
@@ -863,18 +870,19 @@ static int I915XvMCInterceptXvAttribute(ScrnInfoPtr pScrn, Atom attribute,
}
}
- return vx->SetPortAttribute(pScrn, attribute, value, data);
+ return pXvMC->saveSetPortAttribute(pScrn, attribute, value, data);
}
static int I915XvMCDisplayAttributes(ScrnInfoPtr pScrn,
const I915XvMCAttrHolder * ah, I830PortPrivPtr pPriv)
{
- I915XvMCXVPriv *vx = (I915XvMCXVPriv *) pPriv->xvmc_priv;
+ I830Ptr pI830 = I830PTR(pScrn);
+ I915XvMCPtr pXvMC = pI830->xvmc;
unsigned i;
int ret;
for (i = 0; i < ah->numAttr; ++i) {
- ret = vx->SetPortAttribute(pScrn, ah->attributes[i].attribute,
+ ret = pXvMC->saveSetPortAttribute(pScrn, ah->attributes[i].attribute,
ah->attributes[i].value, pPriv);
if (ret)
return ret;
@@ -893,14 +901,12 @@ static int I915XvMCInterceptPutImage(ScrnInfoPtr pScrn, short src_x, short src_y
I830Ptr pI830 = I830PTR(pScrn);
I830PortPrivPtr pPriv = (I830PortPrivPtr)data;
I915XvMCXVPriv *vx = (I915XvMCXVPriv *)pPriv->xvmc_priv;
+ I915XvMCPtr pXvMC = pI830->xvmc;
+ I915XvMCCommandBuffer *i915XvMCData = (I915XvMCCommandBuffer *)buf;
int ret;
- if (I830PTR(pScrn)->XvMCEnabled) {
+ if (pI830->XvMCEnabled) {
if (FOURCC_XVMC == id) {
- I915XvMCPtr pXvMC = pI830->xvmc;
- I915XvMCCommandBuffer *i915XvMCData = (I915XvMCCommandBuffer *)buf;
- int i;
-
switch (i915XvMCData->command) {
case I915_XVMC_COMMAND_ATTRIBUTES:
if ((i915XvMCData->ctxNo | I915_XVMC_VALID) != vx->ctxDisplaying)
@@ -910,33 +916,25 @@ static int I915XvMCInterceptPutImage(ScrnInfoPtr pScrn, short src_x, short src_y
return 0;
case I915_XVMC_COMMAND_DISPLAY:
- for (i = 0; i < I915_XVMC_MAX_SURFACES; i++) {
- i830_memory *mem = NULL;
-
- if ((i915XvMCData->srfNo >= I915_XVMC_MAX_SURFACES) ||
- !pXvMC->surfaces[i915XvMCData->srfNo] ||
- !pXvMC->sfprivs[i915XvMCData->srfNo]) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "[XvMC] I915XvMCInterceptPutImage: Invalid parameters !\n");
- return 1;
- }
+ if ((i915XvMCData->srfNo >= I915_XVMC_MAX_SURFACES) ||
+ !pXvMC->surfaces[i915XvMCData->srfNo] ||
+ !pXvMC->sfprivs[i915XvMCData->srfNo]) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "[XvMC] I915XvMCInterceptPutImage: Invalid parameters !\n");
+ return 1;
+ }
- mem = pXvMC->sfprivs[i915XvMCData->srfNo]->surface;
- buf = pI830->FbBase + mem->offset;
- id = i915XvMCData->real_id;
- pI830->IsXvMCSurface = 1;
- break;
- }
-
- break;
-
+ buf = pI830->FbBase + pXvMC->sfprivs[i915XvMCData->srfNo]->surface->offset;
+ id = i915XvMCData->real_id;
+ pI830->IsXvMCSurface = 1;
+ break;
default:
return 0;
}
}
}
- ret = vx->PutImage(pScrn, src_x, src_y, drw_x, drw_y, src_w, src_h,
+ ret = pXvMC->savePutImage(pScrn, src_x, src_y, drw_x, drw_y, src_w, src_h,
drw_w, drw_h, id, buf, width, height, sync, clipBoxes, data, pDraw);
pI830->IsXvMCSurface = 0;
return ret;
@@ -955,57 +953,38 @@ static int I915XvMCInterceptPutImage(ScrnInfoPtr pScrn, short src_x, short src_y
* None
*
**************************************************************************/
-void I915InitMC(ScreenPtr pScreen)
+
+Bool I915XvMCInit(ScreenPtr pScreen, XF86VideoAdaptorPtr XvAdapt)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
I830Ptr pI830 = I830PTR(pScrn);
- I915XvMCPtr pXvMC = NULL;
+ I830PortPrivPtr pPriv;
+ I915XvMCXVPriv *vx;
+ I915XvMCPtr pXvMC;
+ int i, j;
- pI830->XvMCEnabled = FALSE;
- if (!pI830->directRenderingEnabled) {
- xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
- "[XvMC] Cannot use XvMC without DRI!\n");
- return;
- }
+ if (!IS_I9XX(pI830) || IS_I965G(pI830))
+ return FALSE;
- pXvMC = (I915XvMCPtr)calloc(1, sizeof(I915XvMC));
+ pXvMC = (I915XvMCPtr)xcalloc(1, sizeof(I915XvMC));
if (!pXvMC) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
- "[XvMC] Failure!\n");
- return;
+ "[XvMC] alloc driver private failed!\n");
+ return FALSE;
}
-
pI830->xvmc = pXvMC;
initI915XvMC(pXvMC);
- xf86XvMCScreenInit(pScreen, 1, ppAdapt);
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "[XvMC] Initialized XvMC extension.\n");
- pI830->XvMCEnabled = TRUE;
-}
-
-int I915XvMCInitXv(ScrnInfoPtr pScrn, XF86VideoAdaptorPtr XvAdapt)
-{
- I830PortPrivPtr pPriv;
- I915XvMCXVPriv *vx;
- unsigned i, j;
- SetPortAttributeFuncPtr setportattribute = XvAdapt->SetPortAttribute;
- GetPortAttributeFuncPtr getportattribute = XvAdapt->GetPortAttribute;
- PutImageFuncPtr putimage = XvAdapt->PutImage;
-
- XvAdapt->GetPortAttribute = I915XvMCInterceptXvGetAttribute;
- XvAdapt->SetPortAttribute = I915XvMCInterceptXvAttribute;
- XvAdapt->PutImage = I915XvMCInterceptPutImage;
for (j = 0; j < XvAdapt->nPorts; ++j) {
pPriv = (I830PortPrivPtr) XvAdapt->pPortPrivates[j].ptr;
if (NULL == (pPriv->xvmc_priv = xcalloc(1, sizeof(I915XvMCXVPriv)))) {
+ xfree(pI830->xvmc);
return BadAlloc;
- }
+ }
- for (i = 0; i < I915_NUM_XVMC_ATTRIBUTES; ++i) {
+ for (i = 0; i < I915_NUM_XVMC_ATTRIBUTES; ++i)
attrAtoms[i] = MAKE_ATOM(attrXvMC[i]);
- }
vx = (I915XvMCXVPriv *) pPriv->xvmc_priv;
@@ -1014,24 +993,48 @@ int I915XvMCInitXv(ScrnInfoPtr pScrn, XF86VideoAdaptorPtr XvAdapt)
vx->xvmc_port = -1;
vx->newAttribute = 1;
- /* set up wrappers */
- vx->GetPortAttribute = getportattribute;
- vx->SetPortAttribute = setportattribute;
- vx->PutImage = putimage;
-
for (i = 0; i < I915_NUM_XVMC_ATTRIBUTES; ++i) {
vx->xvAttr.attributes[i].attribute = attrAtoms[i];
- vx->xvAttr.attributes[i].value = 0;
- vx->GetPortAttribute(pScrn, attrAtoms[i],
+ XvAdapt->GetPortAttribute(pScrn, attrAtoms[i],
&(vx->xvAttr.attributes[i].value), pPriv);
}
}
- return Success;
+ /* set up wrappers */
+ pXvMC->saveGetPortAttribute = XvAdapt->GetPortAttribute;
+ pXvMC->saveSetPortAttribute = XvAdapt->SetPortAttribute;
+ pXvMC->savePutImage = XvAdapt->PutImage;
+
+ XvAdapt->GetPortAttribute = I915XvMCInterceptXvGetAttribute;
+ XvAdapt->SetPortAttribute = I915XvMCInterceptXvAttribute;
+ XvAdapt->PutImage = I915XvMCInterceptPutImage;
+ return TRUE;
+}
+
+Bool I915XvMCScreenInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ I830Ptr pI830 = I830PTR(pScrn);
+
+ if (xf86XvMCScreenInit(pScreen, 1, ppAdapt)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "[XvMC] Initialized XvMC.\n");
+ pI830->XvMCEnabled = TRUE;
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "[XvMC] xf86 XvMC initial failed\n");
+ pI830->XvMCEnabled = FALSE;
+ xfree(pI830->xvmc);
+ pI830->xvmc = NULL;
+ return FALSE;
+ }
+ return TRUE;
}
unsigned long I915XvMCPutImageSize(ScrnInfoPtr pScrn)
{
- if (I830PTR(pScrn)->XvMCEnabled)
+ I830Ptr pI830 = I830PTR(pScrn);
+
+ if (pI830->XvMCEnabled)
return sizeof(I915XvMCCommandBuffer);
return 0;