summaryrefslogtreecommitdiff
path: root/src/nv_video.c
diff options
context:
space:
mode:
authorDeron Johnson <deron.johnson@sun.com>2005-02-17 22:44:41 +0000
committerDeron Johnson <deron.johnson@sun.com>2005-02-17 22:44:41 +0000
commitf8a8feb0e89949217e34560abd53134b70624c79 (patch)
tree91ab46128ce82e27c7d23c348acfc0f4f84d0ab5 /src/nv_video.c
parentbbafc6d2fcb21671de3cfb4ff973409405162e7a (diff)
Diffstat (limited to 'src/nv_video.c')
-rw-r--r--src/nv_video.c91
1 files changed, 70 insertions, 21 deletions
diff --git a/src/nv_video.c b/src/nv_video.c
index f985461..7bfa94b 100644
--- a/src/nv_video.c
+++ b/src/nv_video.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_video.c,v 1.19 2003/09/01 20:54:26 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_video.c,v 1.23 2004/03/20 22:07:06 mvojkovi Exp $ */
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -46,6 +46,7 @@ typedef struct _NVPortPrivRec {
Bool grabbedByV4L;
Bool iturbt_709;
Bool blitter;
+ Bool SyncToVBlank;
FBLinearPtr linear;
int pitch;
int offset;
@@ -95,7 +96,7 @@ static void NVInitOffscreenImages (ScreenPtr pScreen);
static Atom xvBrightness, xvContrast, xvColorKey, xvSaturation,
xvHue, xvAutopaintColorKey, xvSetDefaults, xvDoubleBuffer,
- xvITURBT709;
+ xvITURBT709, xvSyncToVBlank;
/* client libraries expect an encoding */
static XF86VideoEncodingRec DummyEncoding =
@@ -114,9 +115,8 @@ XF86VideoFormatRec NVFormats[NUM_FORMATS_ALL] =
{15, DirectColor}, {16, DirectColor}, {24, DirectColor}
};
-#define NUM_ATTRIBUTES 9
-
-XF86AttributeRec NVAttributes[NUM_ATTRIBUTES] =
+#define NUM_OVERLAY_ATTRIBUTES 9
+XF86AttributeRec NVOverlayAttributes[NUM_OVERLAY_ATTRIBUTES] =
{
{XvSettable | XvGettable, 0, 1, "XV_DOUBLE_BUFFER"},
{XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLORKEY"},
@@ -129,6 +129,14 @@ XF86AttributeRec NVAttributes[NUM_ATTRIBUTES] =
{XvSettable | XvGettable, 0, 1, "XV_ITURBT_709"}
};
+#define NUM_BLIT_ATTRIBUTES 2
+XF86AttributeRec NVBlitAttributes[NUM_BLIT_ATTRIBUTES] =
+{
+ {XvSettable , 0, 0, "XV_SET_DEFAULTS"},
+ {XvSettable | XvGettable, 0, 1, "XV_SYNC_TO_VBLANK"}
+};
+
+
#define NUM_IMAGES_YUV 4
#define NUM_IMAGES_ALL 5
@@ -285,7 +293,10 @@ void NVInitVideo (ScreenPtr pScreen)
NVPtr pNv = NVPTR(pScrn);
int num_adaptors;
- if((pScrn->bitsPerPixel != 8) && (pNv->Architecture >= NV_ARCH_10)) {
+ if((pScrn->bitsPerPixel != 8) && (pNv->Architecture >= NV_ARCH_10) &&
+ ((pNv->Architecture <= NV_ARCH_30) ||
+ ((pNv->Chipset & 0xfff0) == 0x0040)))
+ {
overlayAdaptor = NVSetupOverlayVideo(pScreen);
if(overlayAdaptor)
@@ -358,8 +369,13 @@ NVSetupBlitVideo (ScreenPtr pScreen)
for(i = 0; i < NUM_BLIT_PORTS; i++)
adapt->pPortPrivates[i].ptr = (pointer)(pPriv);
- adapt->pAttributes = NULL;
- adapt->nAttributes = 0;
+ if(pNv->WaitVSyncPossible) {
+ adapt->pAttributes = NVBlitAttributes;
+ adapt->nAttributes = NUM_BLIT_ATTRIBUTES;
+ } else {
+ adapt->pAttributes = NULL;
+ adapt->nAttributes = 0;
+ }
adapt->pImages = NVImages;
adapt->nImages = NUM_IMAGES_ALL;
adapt->PutVideo = NULL;
@@ -377,9 +393,12 @@ NVSetupBlitVideo (ScreenPtr pScreen)
pPriv->grabbedByV4L = FALSE;
pPriv->blitter = TRUE;
pPriv->doubleBuffer = FALSE;
+ pPriv->SyncToVBlank = pNv->WaitVSyncPossible;
pNv->blitAdaptor = adapt;
+ xvSyncToVBlank = MAKE_ATOM("XV_SYNC_TO_VBLANK");
+
return adapt;
}
@@ -409,8 +428,8 @@ NVSetupOverlayVideo (ScreenPtr pScreen)
adapt->pPortPrivates = (DevUnion*)(&adapt[1]);
pPriv = (NVPortPrivPtr)(&adapt->pPortPrivates[1]);
adapt->pPortPrivates[0].ptr = (pointer)(pPriv);
- adapt->pAttributes = NVAttributes;
- adapt->nAttributes = NUM_ATTRIBUTES;
+ adapt->pAttributes = NVOverlayAttributes;
+ adapt->nAttributes = NUM_OVERLAY_ATTRIBUTES;
adapt->pImages = NVImages;
adapt->nImages = NUM_IMAGES_YUV;
adapt->PutVideo = NULL;
@@ -432,7 +451,7 @@ NVSetupOverlayVideo (ScreenPtr pScreen)
NVSetPortDefaults (pScrnInfo, pPriv);
/* gotta uninit this someplace */
- REGION_INIT(pScreen, &pPriv->clip, NullBox, 0);
+ REGION_NULL(pScreen, &pPriv->clip);
pNv->overlayAdaptor = adapt;
@@ -571,8 +590,19 @@ NVPutBlitImage (
NVDmaNext (pNv, SURFACE_FORMAT_DEPTH15);
}
- NVDmaStart(pNv, STRETCH_BLIT_FORMAT, 1);
- NVDmaNext (pNv, format);
+ if(pPriv->SyncToVBlank) {
+ NVDmaKickoff(pNv);
+ NVWaitVSync(pNv);
+ }
+
+ if(pNv->BlendingPossible) {
+ NVDmaStart(pNv, STRETCH_BLIT_FORMAT, 2);
+ NVDmaNext (pNv, format);
+ NVDmaNext (pNv, STRETCH_BLIT_OPERATION_COPY);
+ } else {
+ NVDmaStart(pNv, STRETCH_BLIT_FORMAT, 1);
+ NVDmaNext (pNv, format);
+ }
while(nbox--) {
NVDmaStart(pNv, RECT_SOLID_COLOR, 1);
@@ -757,7 +787,20 @@ static int NVSetBlitPortAttribute
pointer data
)
{
- return BadMatch;
+ NVPortPrivPtr pPriv = (NVPortPrivPtr)data;
+ NVPtr pNv = NVPTR(pScrnInfo);
+
+ if ((attribute == xvSyncToVBlank) && pNv->WaitVSyncPossible) {
+ if ((value < 0) || (value > 1))
+ return BadValue;
+ pPriv->SyncToVBlank = value;
+ } else
+ if (attribute == xvSetDefaults) {
+ pPriv->SyncToVBlank = pNv->WaitVSyncPossible;
+ } else
+ return BadMatch;
+
+ return Success;
}
static int NVGetBlitPortAttribute
@@ -768,7 +811,14 @@ static int NVGetBlitPortAttribute
pointer data
)
{
- return BadMatch;
+ NVPortPrivPtr pPriv = (NVPortPrivPtr)data;
+
+ if(attribute == xvSyncToVBlank)
+ *value = (pPriv->SyncToVBlank) ? 1 : 0;
+ else
+ return BadMatch;
+
+ return Success;
}
@@ -958,7 +1008,7 @@ static int NVPutImage
NVPtr pNv = NVPTR(pScrnInfo);
INT32 xa, xb, ya, yb;
unsigned char *dst_start;
- int pitch, newSize, offset, s2offset, s3offset;
+ int newSize, offset, s2offset, s3offset;
int srcPitch, srcPitch2, dstPitch;
int top, left, right, bottom, npixels, nlines, bpp;
Bool skip = FALSE;
@@ -1011,7 +1061,6 @@ static int NVPutImage
}
bpp = pScrnInfo->bitsPerPixel >> 3;
- pitch = bpp * pScrnInfo->displayWidth;
switch(id) {
case FOURCC_YV12:
@@ -1435,8 +1484,8 @@ XF86OffscreenImageRec NVOffscreenImages[2] =
NVGetSurfaceAttribute,
NVSetSurfaceAttribute,
2046, 2046,
- NUM_ATTRIBUTES - 1,
- &NVAttributes[1]
+ NUM_OVERLAY_ATTRIBUTES - 1,
+ &NVOverlayAttributes[1]
},
{
&NVImages[2],
@@ -1448,8 +1497,8 @@ XF86OffscreenImageRec NVOffscreenImages[2] =
NVGetSurfaceAttribute,
NVSetSurfaceAttribute,
2046, 2046,
- NUM_ATTRIBUTES - 1,
- &NVAttributes[1]
+ NUM_OVERLAY_ATTRIBUTES - 1,
+ &NVOverlayAttributes[1]
},
};