summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuc Verhaegen <libv@skynet.be>2009-10-17 01:47:25 +0200
committerLuc Verhaegen <libv@skynet.be>2009-11-04 15:13:02 +0100
commit8348ea2d89f81c54fcd17d242ae7788ce36cb3d7 (patch)
tree05b61238c3885ceeec5b55b9ec06fc679a41b4a4
parent68d0041686102325950c8398375ebb12657da3f0 (diff)
XvMC: Subpicture: Implement preliminary Clear.
The API for subpictures is horrible. And quite amazingly so..
-rw-r--r--lib/xvmc/xvmc_unichrome.c19
-rw-r--r--lib/xvmc/xvmce.c24
-rw-r--r--lib/xvmc/xvmce_proto.h13
-rw-r--r--src/via_mpeg.c32
-rw-r--r--src/via_mpeg.h1
-rw-r--r--src/via_xvmc.c45
6 files changed, 126 insertions, 8 deletions
diff --git a/lib/xvmc/xvmc_unichrome.c b/lib/xvmc/xvmc_unichrome.c
index 13774a7..8a717dc 100644
--- a/lib/xvmc/xvmc_unichrome.c
+++ b/lib/xvmc/xvmc_unichrome.c
@@ -634,8 +634,7 @@ XvMCCreateSubpicture(Display *display, XvMCContext *context,
if (!display || !context || !subpicture)
return XvMCBadContext;
- printf("%s: 0x%08X: 0x%08X %dx%d\n", __func__,
- subpicture->subpicture_id, xvimage_id, width, height);
+ printf("%s: 0x%08X %dx%d\n", __func__, xvimage_id, width, height);
subpicture->width = context->width;
subpicture->height = context->height;
@@ -646,6 +645,9 @@ XvMCCreateSubpicture(Display *display, XvMCContext *context,
if (status != Success)
fprintf(stderr, "%s: Error: _xvmc_create_subpicture failed: %d\n",
status);
+ else
+ printf("%s: 0x%08X: %2d/%1d\n", __func__, subpicture->subpicture_id,
+ subpicture->num_palette_entries, subpicture->entry_bytes);
return status;
}
@@ -657,11 +659,16 @@ XvMCCreateSubpicture(Display *display, XvMCContext *context,
_X_EXPORT Status
XvMCClearSubpicture(Display *display, XvMCSubpicture *subpicture,
short x, short y, unsigned short width,
- unsigned short height, unsigned int flags)
+ unsigned short height, unsigned int colour)
{
printf("%s\n", __func__);
- return Success;
+ /* WTF sort of API is this? */
+ if (x || y || colour || (width != subpicture->width) ||
+ (height != subpicture->height))
+ printf("%s: Warning: nulling whole subpicture!\n", __func__);
+
+ return XvMCESubPictureClear(display, XvMCPortID, subpicture->subpicture_id);
}
@@ -701,7 +708,7 @@ XvMCSetSubpicturePalette(Display *display, XvMCSubpicture *subpicture,
{
printf("%s\n", __func__);
- return BadImplementation;
+ return Success;
}
@@ -717,7 +724,7 @@ XvMCBlendSubpicture(Display *display, XvMCSurface *surface,
{
printf("%s\n", __func__);
- return BadImplementation;
+ return Success;
}
diff --git a/lib/xvmc/xvmce.c b/lib/xvmc/xvmce.c
index 562b593..8fbe8d3 100644
--- a/lib/xvmc/xvmce.c
+++ b/lib/xvmc/xvmce.c
@@ -270,3 +270,27 @@ XVMCEBufferSliceSend(Display *dpy, XvPortID port, XID Buffer,
return Success;
}
+
+/*
+ *
+ */
+Status
+XvMCESubPictureClear(Display *dpy, XvPortID port, XID SubPicture)
+{
+ XExtDisplayInfo *info = XvMCEFindDisplay(dpy);
+ xvmceSubPictureClearReq *req;
+
+ XvMCECheckExtension(dpy, info, BadImplementation);
+
+ LockDisplay(dpy);
+
+ XvMCEGetReq(SubPictureClear, req);
+
+ req->Port = port;
+ req->SubPicture = SubPicture;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return Success;
+}
diff --git a/lib/xvmc/xvmce_proto.h b/lib/xvmc/xvmce_proto.h
index 47777f1..8dff60a 100644
--- a/lib/xvmc/xvmce_proto.h
+++ b/lib/xvmc/xvmce_proto.h
@@ -37,6 +37,7 @@
#define xvmce_BufferStatus 2
#define xvmce_BufferSliceInit 3
#define xvmce_BufferSliceSend 4
+#define xvmce_SubPictureClear 5
/*
* Version, are we compatible?
@@ -180,4 +181,16 @@ typedef struct {
} xvmceBufferSliceSendReq;
#define sz_xvmceBufferSliceSendReq 20
+/*
+ *
+ */
+typedef struct {
+ CARD8 reqType;
+ CARD8 xvmceReqType; /* xvmce_SubPictureClear */
+ CARD16 length B16;
+ CARD32 Port B32;
+ CARD32 SubPicture B32;
+} xvmceSubPictureClearReq;
+#define sz_xvmceSubPictureClearReq 12
+
#endif /* XVMCE_PROTO_H */
diff --git a/src/via_mpeg.c b/src/via_mpeg.c
index 4d49252..e747c45 100644
--- a/src/via_mpeg.c
+++ b/src/via_mpeg.c
@@ -99,7 +99,7 @@ ViaSubPictureRelease(struct ViaSubPicture *SubPicture, XID ID)
{
int i;
- ViaDebug(SubPicture->scrnIndex, "%s: Releasing 0x%08X\n", __func__, ID);
+ ViaDebug(SubPicture->scrnIndex, "%s: 0x%08X\n", __func__, ID);
for (i = 0; i < VIA_SUBPICTURE_COUNT; i++)
if (SubPicture->SubPictures[i].ID == ID)
@@ -120,8 +120,36 @@ ViaSubPictureRelease(struct ViaSubPicture *SubPicture, XID ID)
}
}
-#if 0
+/*
+ *
+ */
+int
+ViaSubPictureClear(struct ViaSubPicture *SubPicture, XID ID)
+{
+ int i;
+
+ ViaDebug(SubPicture->scrnIndex, "%s: 0x%08X\n", __func__, ID);
+
+ for (i = 0; i < VIA_SUBPICTURE_COUNT; i++)
+ if (SubPicture->SubPictures[i].ID == ID)
+ break;
+
+ if (i == VIA_SUBPICTURE_COUNT) {
+ xf86DrvMsg(SubPicture->scrnIndex, X_ERROR, "%s: Unknown ID: 0x%08X\n",
+ __func__, ID);
+ return BadAccess;
+ }
+ /* Quick and dirty, and most likely wrong, but will find out
+ what this does for real later on. */
+ memset(VIAPTR(xf86Screens[SubPicture->scrnIndex])->FBBase +
+ SubPicture->SubPictures[i].Mem->Base,
+ 0, SubPicture->SubPictures[i].Mem->Size);
+
+ return Success;
+}
+
+#if 0
/*
*
*/
diff --git a/src/via_mpeg.h b/src/via_mpeg.h
index 34403de..f05fb00 100644
--- a/src/via_mpeg.h
+++ b/src/via_mpeg.h
@@ -128,5 +128,6 @@ void ViaMpegQMatrix(struct ViaMpeg *Mpeg, CARD32 Type, CARD8 Matrix[64]);
int ViaSubPictureGrab(struct ViaSubPicture *SubPicture, XID ID,
CARD16 Width, CARD16 Height, CARD8 Type);
void ViaSubPictureRelease(struct ViaSubPicture *SubPicture, XID ID);
+int ViaSubPictureClear(struct ViaSubPicture *SubPicture, XID ID);
#endif /* HAVE_VIA_MPEG_H */
diff --git a/src/via_xvmc.c b/src/via_xvmc.c
index 8a7aa65..eef1842 100644
--- a/src/via_xvmc.c
+++ b/src/via_xvmc.c
@@ -290,6 +290,7 @@ XvMCEProcBufferSliceInit(ClientPtr client)
return (client->noClientException);
}
+
/*
*
*/
@@ -331,6 +332,45 @@ XvMCEProcBufferSliceSend(ClientPtr client)
*
*/
static int
+XvMCEProcSubPictureClear(ClientPtr client)
+{
+ ExtensionEntry *XvMCE_Ext;
+ struct XvMCEPrivates *Private;
+ ScrnInfoPtr pScrn;
+ XvPortPtr Port;
+ int ret;
+
+ REQUEST(xvmceSubPictureClearReq);
+ REQUEST_SIZE_MATCH(xvmceSubPictureClearReq);
+
+ XvMCE_Ext = CheckExtension(XVMCE_EXT_NAME);
+ if (!XvMCE_Ext || !XvMCE_Ext->extPrivate) {
+ xf86Msg(X_WARNING, "%s: Extension not initialised.\n", __func__);
+ return BadMatch;
+ }
+
+ Private = XvMCE_Ext->extPrivate;
+ pScrn = xf86Screens[Private->scrnIndex];
+
+ /* Does our client own this port? */
+ Port = LookupIDByType(stuff->Port, XvGetRTPort());
+ if (!Port) {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "%s: Client doesn't own this Xv Port.\n", __func__);
+ return BadAccess;
+ }
+
+ ret = ViaSubPictureClear(VIAPTR(pScrn)->Swov->SubPicture, stuff->SubPicture);
+ if (ret != Success)
+ return ret;
+
+ return (client->noClientException);
+}
+
+/*
+ *
+ */
+static int
XvMCEHandler(ClientPtr client)
{
REQUEST(xReq);
@@ -346,6 +386,8 @@ XvMCEHandler(ClientPtr client)
return XvMCEProcBufferSliceInit(client);
case xvmce_BufferSliceSend:
return XvMCEProcBufferSliceSend(client);
+ case xvmce_SubPictureClear:
+ return XvMCEProcSubPictureClear(client);
default:
break;
}
@@ -510,6 +552,9 @@ static int
ViaMCCreateSubpicture(ScrnInfoPtr pScrn, XvMCSubpicturePtr subpicture,
int *num_priv, CARD32 **priv)
{
+ subpicture->num_palette_entries = 16;
+ subpicture->entry_bytes = 3;
+
return ViaSubPictureGrab(VIAPTR(pScrn)->Swov->SubPicture,
subpicture->subpicture_id,
subpicture->width, subpicture->height,