summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuc Verhaegen <libv@skynet.be>2009-09-01 00:00:21 +0200
committerLuc Verhaegen <libv@skynet.be>2009-11-04 15:13:02 +0100
commit68d0041686102325950c8398375ebb12657da3f0 (patch)
tree15aa3b9834ae697323391788bd9f549f7d1e76f6
parentbc724491e1ccedcacc1cee09cac2b2bf433efcf0 (diff)
XvMC: Initial subpicture support: fill in XvMC hooks.
-rw-r--r--lib/xvmc/xvmc_unichrome.c36
-rw-r--r--src/via_mpeg.c101
-rw-r--r--src/via_mpeg.h21
-rw-r--r--src/via_video.c17
-rw-r--r--src/via_xvmc.c16
5 files changed, 172 insertions, 19 deletions
diff --git a/lib/xvmc/xvmc_unichrome.c b/lib/xvmc/xvmc_unichrome.c
index 96add99..13774a7 100644
--- a/lib/xvmc/xvmc_unichrome.c
+++ b/lib/xvmc/xvmc_unichrome.c
@@ -589,7 +589,7 @@ XvMCSyncSubpicture(Display *display, XvMCSubpicture *subpicture)
{
printf("%s\n", __func__);
- return BadImplementation;
+ return Success;
}
@@ -601,7 +601,7 @@ XvMCFlushSubpicture(Display *display, XvMCSubpicture *subpicture)
{
printf("%s\n", __func__);
- return BadImplementation;
+ return Success;
}
@@ -613,7 +613,9 @@ XvMCGetSubpictureStatus(Display *display, XvMCSubpicture *subpicture, int *stat)
{
printf("%s\n", __func__);
- return BadImplementation;
+ *stat = 0; /* placeholder */
+
+ return Success;
}
@@ -625,9 +627,27 @@ XvMCCreateSubpicture(Display *display, XvMCContext *context,
XvMCSubpicture *subpicture, unsigned short width,
unsigned short height, int xvimage_id)
{
- printf("%s\n", __func__);
+ Status status = Success;
+ int priv_count;
+ CARD32 *priv_data = NULL;
- return BadImplementation;
+ if (!display || !context || !subpicture)
+ return XvMCBadContext;
+
+ printf("%s: 0x%08X: 0x%08X %dx%d\n", __func__,
+ subpicture->subpicture_id, xvimage_id, width, height);
+
+ subpicture->width = context->width;
+ subpicture->height = context->height;
+ subpicture->xvimage_id = xvimage_id;
+
+ status = _xvmc_create_subpicture(display, context, subpicture, &priv_count, &priv_data);
+
+ if (status != Success)
+ fprintf(stderr, "%s: Error: _xvmc_create_subpicture failed: %d\n",
+ status);
+
+ return status;
}
@@ -641,7 +661,7 @@ XvMCClearSubpicture(Display *display, XvMCSubpicture *subpicture,
{
printf("%s\n", __func__);
- return BadImplementation;
+ return Success;
}
@@ -666,9 +686,9 @@ XvMCCompositeSubpicture(Display *display, XvMCSubpicture *subpicture,
_X_EXPORT Status
XvMCDestroySubpicture(Display *display, XvMCSubpicture *subpicture)
{
- printf("%s\n", __func__);
+ printf("%s: 0x%08X\n", __func__, subpicture->subpicture_id);
- return Success;
+ return _xvmc_destroy_subpicture(display, subpicture);
}
diff --git a/src/via_mpeg.c b/src/via_mpeg.c
index 653fa9e..4d49252 100644
--- a/src/via_mpeg.c
+++ b/src/via_mpeg.c
@@ -41,6 +41,90 @@
/*
*
*/
+int
+ViaSubPictureGrab(struct ViaSubPicture *SubPicture, XID ID,
+ CARD16 Width, CARD16 Height, CARD8 Type)
+{
+ int i;
+
+ ViaDebug(SubPicture->scrnIndex, "%s: Grabbing 0x%08X\n", __func__, ID);
+
+ /* We only track type and dimensions once. */
+ if ((SubPicture->Width == Width) && (SubPicture->Height == Height) &&
+ (SubPicture->Type == Type)) {
+ for (i = 0; i < VIA_SUBPICTURE_COUNT; i++)
+ if (!SubPicture->SubPictures[i].ID &&
+ !SubPicture->SubPictures[i].Mem)
+ break;
+
+ if (i == VIA_SUBPICTURE_COUNT) {
+ xf86DrvMsg(SubPicture->scrnIndex, X_ERROR, "%s: No more slots "
+ "available for 0x%08X\n", __func__, ID);
+ return BadAlloc;
+ }
+ } else {
+ for (i = 0; i < VIA_SUBPICTURE_COUNT; i++)
+ if (SubPicture->SubPictures[i].ID ||
+ SubPicture->SubPictures[i].Mem) {
+ xf86DrvMsg(SubPicture->scrnIndex, X_ERROR, "%s: Cannot change "
+ "layout. Subpictures still in use.\n", __func__);
+ return BadAccess;
+ }
+
+ SubPicture->Width = Width;
+ SubPicture->Height = Height;
+ SubPicture->Type = Type;
+
+ i = 0;
+ }
+
+ SubPicture->SubPictures[i].Mem =
+ ViaMemAlloc(xf86Screens[SubPicture->scrnIndex], Width * Height, 16);
+ if (!SubPicture->SubPictures[i].Mem) {
+ xf86DrvMsg(SubPicture->scrnIndex, X_ERROR, "%s: Memory allocation "
+ "failed for 0x%08X\n", __func__, ID);
+ return BadAlloc;
+ }
+
+ SubPicture->SubPictures[i].ID = ID;
+
+ return Success;
+}
+
+/*
+ *
+ */
+void
+ViaSubPictureRelease(struct ViaSubPicture *SubPicture, XID ID)
+{
+ int i;
+
+ ViaDebug(SubPicture->scrnIndex, "%s: Releasing 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;
+ }
+
+ SubPicture->SubPictures[i].ID = 0;
+
+ if (SubPicture->SubPictures[i].Mem) {
+ ViaMemFree(xf86Screens[SubPicture->scrnIndex],
+ SubPicture->SubPictures[i].Mem);
+ SubPicture->SubPictures[i].Mem = NULL;
+ }
+}
+
+#if 0
+
+/*
+ *
+ */
static int
ViaSubPicturePut(ScrnInfoPtr pScrn, CARD16 Width, CARD16 Height, CARD8 IA44,
CARD32 *Palette, CARD8 *Buffer)
@@ -80,6 +164,7 @@ ViaSubPicturePut(ScrnInfoPtr pScrn, CARD16 Width, CARD16 Height, CARD8 IA44,
return Success;
}
+#endif
/*
*
@@ -89,18 +174,26 @@ ViaSubPictureStop(ScrnInfoPtr pScrn)
{
struct ViaSwov *Swov = VIAPTR(pScrn)->Swov;
struct ViaSubPicture *SubPicture = Swov->SubPicture;
+ int i;
if (!SubPicture)
return;
SubPicture->Regs->Control = 0x00000000;
- if (SubPicture->Mem)
- ViaMemFree(pScrn, SubPicture->Mem);
+ for (i = 0; i < VIA_SUBPICTURE_COUNT; i++) {
+ SubPicture->SubPictures[i].ID = 0;
+
+ if (SubPicture->SubPictures[i].Mem) {
+ ViaMemFree(xf86Screens[SubPicture->scrnIndex],
+ SubPicture->SubPictures[i].Mem);
+ SubPicture->SubPictures[i].Mem = NULL;
+ }
+ }
- SubPicture->Mem = NULL;
SubPicture->Width = 0;
SubPicture->Height = 0;
+ SubPicture->Type = 0;
}
/*
@@ -521,7 +614,7 @@ ViaMpegSliceInit(struct ViaMpeg *Mpeg, XID BufferID, XID FRefID, XID BRefID,
CrOffset = Width * Height;
CbOffset = CrOffset + (Width >> 1) * (Height >> 1);
-#if 1
+#if 0
ViaDebug(Mpeg->scrnIndex, " Picture: 0x%08lX\n", Picture);
ViaDebug(Mpeg->scrnIndex, " LineOffset: 0x%08lX\n", Offset);
ViaDebug(Mpeg->scrnIndex, " SliceControl1: 0x%08lX\n", SliceControl1);
diff --git a/src/via_mpeg.h b/src/via_mpeg.h
index c6e02a1..34403de 100644
--- a/src/via_mpeg.h
+++ b/src/via_mpeg.h
@@ -63,10 +63,18 @@ struct ViaMpeg {
struct ViaSubPicture {
int scrnIndex;
+#define VIA_SUBPICTURE_TYPE_AI44 0
+#define VIA_SUBPICTURE_TYPE_IA44 1
+ int Type;
+
CARD16 Width;
CARD16 Height;
- struct ViaMem *Mem;
+#define VIA_SUBPICTURE_COUNT 4
+ struct {
+ XID ID;
+ struct ViaMem *Mem;
+ } SubPictures[VIA_SUBPICTURE_COUNT];
struct ViaSubPictureRegs *Regs;
};
@@ -92,7 +100,9 @@ Bool ViaMpegBufferIDVerify(struct ViaMpeg *Mpeg, XID BufferID,
int Width, int Height);
unsigned long ViaMpegBufferFlip(struct ViaMpeg *Mpeg, XID BufferID);
-/* prototypes for the X extension. */
+/*
+ * Mpeg support for XvMC(E).
+ */
Bool ViaMpegEngineInit(struct ViaMpeg *Mpeg, CARD16 Width, CARD16 Height);
Bool ViaMpegBufferGrab(struct ViaMpeg *Mpeg, XID BufferID);
void ViaMpegBufferRelease(struct ViaMpeg *Mpeg, XID BufferID);
@@ -112,4 +122,11 @@ int ViaMpegSlicePut(struct ViaMpeg *Mpeg, XID BufferID, CARD8 SliceCode,
CARD32 SliceLength, CARD8 *Slice);
void ViaMpegQMatrix(struct ViaMpeg *Mpeg, CARD32 Type, CARD8 Matrix[64]);
+/*
+ * Subpicture support for XvMC(E).
+ */
+int ViaSubPictureGrab(struct ViaSubPicture *SubPicture, XID ID,
+ CARD16 Width, CARD16 Height, CARD8 Type);
+void ViaSubPictureRelease(struct ViaSubPicture *SubPicture, XID ID);
+
#endif /* HAVE_VIA_MPEG_H */
diff --git a/src/via_video.c b/src/via_video.c
index 768f01c..f49f3c3 100644
--- a/src/via_video.c
+++ b/src/via_video.c
@@ -2286,6 +2286,23 @@ viaQueryImageAttributes(ScrnInfoPtr pScrn, int FourCC, CARD16 *Width,
offsets[0] = 0;
break;
+ case FOURCC_AI44:
+ case FOURCC_IA44:
+ /* Subpicture types, why are they mashed in here? */
+
+ /* Just match MPEG */
+ *Width = ALIGN_TO(*Width, 32);
+ *Height = ALIGN_TO(*Height, 16);
+
+ Size = *Width * *Height;
+
+ if (pitches)
+ pitches[0] = *Width;
+
+ if (offsets)
+ offsets[0] = 0;
+
+ break;
case FOURCC_YUY2: /* YUV422 */
case FOURCC_RV15: /* RGB555 */
case FOURCC_RV16: /* RGB565 */
diff --git a/src/via_xvmc.c b/src/via_xvmc.c
index 4fc75a5..8a7aa65 100644
--- a/src/via_xvmc.c
+++ b/src/via_xvmc.c
@@ -267,6 +267,7 @@ XvMCEProcBufferSliceInit(ClientPtr client)
UseIntraDCTable1 = FALSE;
ViaDebug(pScrn->scrnIndex, "%s: Buffer 0x%08X\n", __func__, stuff->Buffer);
+#if 0
ViaDebug(pScrn->scrnIndex, "\t PictureType: 0x%02X, SliceFlags: 0x%02X\n",
stuff->PictureType, stuff->SliceFlags);
ViaDebug(pScrn->scrnIndex, "\t Present %01X: backwards 0x%08X, forwards 0x%08X\n",
@@ -275,6 +276,7 @@ XvMCEProcBufferSliceInit(ClientPtr client)
ViaDebug(pScrn->scrnIndex, "\t Ranges BH %d, BV %d, FH %d, FV %d\n",
stuff->MVRange_BackwardsHorizontal, stuff->MVRange_BackwardsVertical,
stuff->MVRange_ForwardsHorizontal, stuff->MVRange_ForwardsVertical);
+#endif
status = ViaMpegSliceInit(VIAPTR(pScrn)->Swov->Mpeg, stuff->Buffer,
stuff->ForwardsReferenceBuffer,
@@ -506,11 +508,14 @@ ViaMCBufferDestroy(ScrnInfoPtr pScrn, XvMCSurfacePtr Buffer)
*/
static int
ViaMCCreateSubpicture(ScrnInfoPtr pScrn, XvMCSubpicturePtr subpicture,
- int *num_priv, CARD32 **priv)
+ int *num_priv, CARD32 **priv)
{
- VIAFUNC(pScrn);
-
- return BadAlloc;
+ return ViaSubPictureGrab(VIAPTR(pScrn)->Swov->SubPicture,
+ subpicture->subpicture_id,
+ subpicture->width, subpicture->height,
+ (subpicture->xvimage_id == FOURCC_AI44) ?
+ VIA_SUBPICTURE_TYPE_AI44 :
+ VIA_SUBPICTURE_TYPE_IA44);
}
/*
@@ -519,7 +524,8 @@ ViaMCCreateSubpicture(ScrnInfoPtr pScrn, XvMCSubpicturePtr subpicture,
static void
ViaMCDestroySubpicture(ScrnInfoPtr pScrn, XvMCSubpicturePtr subpicture)
{
- VIAFUNC(pScrn);
+ ViaSubPictureRelease(VIAPTR(pScrn)->Swov->SubPicture,
+ subpicture->subpicture_id);
}
static XF86MCAdaptorRec ViaMCAdaptor = {