1
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_video.c,v 1.11 2002/11/26 23:41:59 mvojkovi Exp $ */
4
#include "xf86_OSproc.h"
5
#include "xf86Resources.h"
6
#include "xf86_ansic.h"
8
#include "xf86PciInfo.h"
10
#include "xf86fbman.h"
11
#include "regionstr.h"
17
#include "dixstruct.h"
20
#include "nv_include.h"
23
#define OFF_DELAY 450 /* milliseconds */
24
#define FREE_DELAY 10000
26
#define OFF_TIMER 0x01
27
#define FREE_TIMER 0x02
28
#define CLIENT_VIDEO_ON 0x04
30
#define TIMER_MASK (OFF_TIMER | FREE_TIMER)
35
void NVInitVideo(ScreenPtr pScreen) {}
38
typedef struct _NVPortPrivRec {
45
Bool autopaintColorKey;
55
} NVPortPrivRec, *NVPortPrivPtr;
58
static XF86VideoAdaptorPtr NVSetupImageVideo(ScreenPtr);
60
static void NVStopOverlay (ScrnInfoPtr);
61
static void NVPutOverlayImage(ScrnInfoPtr pScrnInfo,
66
int x1, int y1, int x2, int y2,
67
short width, short height,
68
short src_w, short src_h,
69
short dst_w, short dst_h,
72
static int NVSetPortAttribute(ScrnInfoPtr, Atom, INT32, pointer);
73
static int NVGetPortAttribute(ScrnInfoPtr, Atom ,INT32 *, pointer);
75
static void NVStopOverlayVideo(ScrnInfoPtr, pointer, Bool);
77
static int NVPutImage( ScrnInfoPtr, short, short, short, short, short, short, short, short, int, unsigned char*, short, short, Bool, RegionPtr, pointer);
78
static void NVQueryBestSize(ScrnInfoPtr, Bool, short, short, short, short, unsigned int *, unsigned int *, pointer);
79
static int NVQueryImageAttributes(ScrnInfoPtr, int, unsigned short *, unsigned short *, int *, int *);
81
static void NVVideoTimerCallback(ScrnInfoPtr, Time);
83
static void NVInitOffscreenImages (ScreenPtr pScreen);
86
#define GET_OVERLAY_PRIVATE(pNv) \
87
(NVPortPrivPtr)((pNv)->overlayAdaptor->pPortPrivates[0].ptr)
89
#define GET_BLIT_PRIVATE(pNv) \
90
(NVPortPrivPtr)((pNv)->blitAdaptor->pPortPrivates[0].ptr)
92
#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
94
static Atom xvBrightness, xvContrast, xvColorKey, xvSaturation,
95
xvHue, xvAutopaintColorKey, xvSetDefaults, xvDoubleBuffer,
98
/* client libraries expect an encoding */
99
static XF86VideoEncodingRec DummyEncoding =
107
#define NUM_FORMATS_ALL 6
109
XF86VideoFormatRec NVFormats[NUM_FORMATS_ALL] =
111
{15, TrueColor}, {16, TrueColor}, {24, TrueColor},
112
{15, DirectColor}, {16, DirectColor}, {24, DirectColor}
115
#define NUM_ATTRIBUTES 9
117
XF86AttributeRec NVAttributes[NUM_ATTRIBUTES] =
119
{XvSettable | XvGettable, 0, 1, "XV_DOUBLE_BUFFER"},
120
{XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLORKEY"},
121
{XvSettable | XvGettable, 0, 1, "XV_AUTOPAINT_COLORKEY"},
122
{XvSettable , 0, 0, "XV_SET_DEFAULTS"},
123
{XvSettable | XvGettable, -512, 511, "XV_BRIGHTNESS"},
124
{XvSettable | XvGettable, 0, 8191, "XV_CONTRAST"},
125
{XvSettable | XvGettable, 0, 8191, "XV_SATURATION"},
126
{XvSettable | XvGettable, 0, 360, "XV_HUE"},
127
{XvSettable | XvGettable, 0, 1, "XV_ITURBT_709"}
130
#define NUM_IMAGES_ALL 4
132
static XF86ImageRec NVImages[NUM_IMAGES_ALL] =
141
NVSetPortDefaults (ScrnInfoPtr pScrnInfo, NVPortPrivPtr pPriv)
143
NVPtr pNv = NVPTR(pScrnInfo);
145
pPriv->brightness = 0;
146
pPriv->contrast = 4096;
147
pPriv->saturation = 4096;
149
pPriv->colorKey = pNv->videoKey;
150
pPriv->autopaintColorKey = TRUE;
151
pPriv->doubleBuffer = TRUE;
152
pPriv->iturbt_709 = FALSE;
157
NVResetVideo (ScrnInfoPtr pScrnInfo)
159
NVPtr pNv = NVPTR(pScrnInfo);
160
NVPortPrivPtr pPriv = GET_OVERLAY_PRIVATE(pNv);
161
RIVA_HW_INST *pRiva = &(pNv->riva);
162
int satSine, satCosine;
165
angle = (double)pPriv->hue * 3.1415927 / 180.0;
167
satSine = pPriv->saturation * sin(angle);
170
satCosine = pPriv->saturation * cos(angle);
171
if (satCosine < -1024)
174
pRiva->PMC[0x00008910/4] = (pPriv->brightness << 16) | pPriv->contrast;
175
pRiva->PMC[0x00008914/4] = (pPriv->brightness << 16) | pPriv->contrast;
176
pRiva->PMC[0x00008918/4] = (satSine << 16) | (satCosine & 0xffff);
177
pRiva->PMC[0x0000891C/4] = (satSine << 16) | (satCosine & 0xffff);
178
pRiva->PMC[0x00008b00/4] = pPriv->colorKey;
184
NVStopOverlay (ScrnInfoPtr pScrnInfo)
186
NVPtr pNv = NVPTR(pScrnInfo);
187
RIVA_HW_INST *pRiva = &(pNv->riva);
189
pRiva->PMC[0x00008704/4] = 1;
193
NVAllocateOverlayMemory(
199
FBLinearPtr new_linear;
202
if(linear->size >= size)
205
if(xf86ResizeOffscreenLinear(linear, size))
208
xf86FreeOffscreenLinear(linear);
211
pScreen = screenInfo.screens[pScrn->scrnIndex];
213
new_linear = xf86AllocateOffscreenLinear(pScreen, size, 32,
219
xf86QueryLargestOffscreenLinear(pScreen, &max_size, 32,
225
xf86PurgeUnlockedOffscreenAreas(pScreen);
226
new_linear = xf86AllocateOffscreenLinear(pScreen, size, 32,
233
static void NVFreeOverlayMemory(ScrnInfoPtr pScrnInfo)
235
NVPtr pNv = NVPTR(pScrnInfo);
236
NVPortPrivPtr pPriv = GET_OVERLAY_PRIVATE(pNv);
239
xf86FreeOffscreenLinear(pPriv->linear);
240
pPriv->linear = NULL;
245
void NVInitVideo (ScreenPtr pScreen)
247
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
248
XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL;
249
XF86VideoAdaptorPtr overlayAdaptor = NULL;
250
NVPtr pNv = NVPTR(pScrn);
253
if((pScrn->bitsPerPixel != 8) && (pNv->riva.Architecture >= NV_ARCH_10))
255
overlayAdaptor = NVSetupImageVideo(pScreen);
258
NVInitOffscreenImages(pScreen);
261
num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors);
264
int size = num_adaptors + 1;
266
if((newAdaptors = xalloc(size * sizeof(XF86VideoAdaptorPtr*)))) {
268
memcpy(newAdaptors, adaptors,
269
num_adaptors * sizeof(XF86VideoAdaptorPtr));
272
newAdaptors[num_adaptors] = overlayAdaptor;
275
adaptors = newAdaptors;
280
xf86XVScreenInit(pScreen, adaptors, num_adaptors);
287
static XF86VideoAdaptorPtr
288
NVSetupImageVideo (ScreenPtr pScreen)
290
ScrnInfoPtr pScrnInfo = xf86Screens[pScreen->myNum];
291
NVPtr pNv = NVPTR(pScrnInfo);
292
XF86VideoAdaptorPtr adapt;
295
if (!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) +
296
sizeof(NVPortPrivRec) +
302
adapt->type = XvWindowMask | XvInputMask | XvImageMask;
303
adapt->flags = VIDEO_OVERLAID_IMAGES|VIDEO_CLIP_TO_VIEWPORT;
304
adapt->name = "NV Video Overlay";
305
adapt->nEncodings = 1;
306
adapt->pEncodings = &DummyEncoding;
307
adapt->nFormats = NUM_FORMATS_ALL;
308
adapt->pFormats = NVFormats;
310
adapt->pPortPrivates = (DevUnion*)(&adapt[1]);
311
pPriv = (NVPortPrivPtr)(&adapt->pPortPrivates[1]);
312
adapt->pPortPrivates[0].ptr = (pointer)(pPriv);
313
adapt->pAttributes = NVAttributes;
314
adapt->nAttributes = NUM_ATTRIBUTES;
315
adapt->pImages = NVImages;
316
adapt->nImages = NUM_IMAGES_ALL;
317
adapt->PutVideo = NULL;
318
adapt->PutStill = NULL;
319
adapt->GetVideo = NULL;
320
adapt->GetStill = NULL;
321
adapt->StopVideo = NVStopOverlayVideo;
322
adapt->SetPortAttribute = NVSetPortAttribute;
323
adapt->GetPortAttribute = NVGetPortAttribute;
324
adapt->QueryBestSize = NVQueryBestSize;
325
adapt->PutImage = NVPutImage;
326
adapt->QueryImageAttributes = NVQueryImageAttributes;
328
pPriv->videoStatus = 0;
329
pPriv->currentBuffer = 0;
330
pPriv->grabbedByV4L = FALSE;
332
NVSetPortDefaults (pScrnInfo, pPriv);
334
/* gotta uninit this someplace */
335
REGION_INIT(pScreen, &pPriv->clip, NullBox, 0);
337
pNv->overlayAdaptor = adapt;
339
xvBrightness = MAKE_ATOM("XV_BRIGHTNESS");
340
xvDoubleBuffer = MAKE_ATOM("XV_DOUBLE_BUFFER");
341
xvContrast = MAKE_ATOM("XV_CONTRAST");
342
xvColorKey = MAKE_ATOM("XV_COLORKEY");
343
xvSaturation = MAKE_ATOM("XV_SATURATION");
344
xvHue = MAKE_ATOM("XV_HUE");
345
xvAutopaintColorKey = MAKE_ATOM("XV_AUTOPAINT_COLORKEY");
346
xvSetDefaults = MAKE_ATOM("XV_SET_DEFAULTS");
347
xvITURBT709 = MAKE_ATOM("XV_ITURBT_709");
349
NVResetVideo(pScrnInfo);
357
static Bool RegionsEqual
366
num = REGION_NUM_RECTS(A);
367
if (num != REGION_NUM_RECTS(B))
370
if ((A->extents.x1 != B->extents.x1) ||
371
(A->extents.x2 != B->extents.x2) ||
372
(A->extents.y1 != B->extents.y1) ||
373
(A->extents.y2 != B->extents.y2))
376
dataA = (int*)REGION_RECTS(A);
377
dataB = (int*)REGION_RECTS(B);
381
if((dataA[0] != dataB[0]) || (dataA[1] != dataB[1]))
391
ScrnInfoPtr pScrnInfo,
409
NVPtr pNv = NVPTR(pScrnInfo);
410
NVPortPrivPtr pPriv = GET_OVERLAY_PRIVATE(pNv);
411
RIVA_HW_INST *pRiva = &(pNv->riva);
412
int buffer = pPriv->currentBuffer;
414
/* paint the color key */
415
if(pPriv->autopaintColorKey &&
416
(pPriv->grabbedByV4L || !RegionsEqual(&pPriv->clip, clipBoxes)))
418
/* we always paint V4L's color key */
419
if(!pPriv->grabbedByV4L)
420
REGION_COPY(pScrnInfo->pScreen, &pPriv->clip, clipBoxes);
421
xf86XVFillKeyHelper(pScrnInfo->pScreen, pPriv->colorKey, clipBoxes);
424
pRiva->PMC[(0x8900/4) + buffer] = offset;
425
pRiva->PMC[(0x8928/4) + buffer] = (height << 16) | width;
426
pRiva->PMC[(0x8930/4) + buffer] = ((y1 << 4) & 0xffff0000) | (x1 >> 12);
427
pRiva->PMC[(0x8938/4) + buffer] = (src_w << 20) / drw_w;
428
pRiva->PMC[(0x8940/4) + buffer] = (src_h << 20) / drw_h;
429
pRiva->PMC[(0x8948/4) + buffer] = (dstBox->y1 << 16) | dstBox->x1;
430
pRiva->PMC[(0x8950/4) + buffer] = ((dstBox->y2 - dstBox->y1) << 16) |
431
(dstBox->x2 - dstBox->x1);
433
dstPitch |= 1 << 20; /* use color key */
435
if(id != FOURCC_UYVY)
437
if(pPriv->iturbt_709)
440
pRiva->PMC[(0x8958/4) + buffer] = dstPitch;
441
pRiva->PMC[0x00008704/4] = 0;
442
pRiva->PMC[0x8700/4] = 1 << (buffer << 2);
444
pPriv->videoStatus = CLIENT_VIDEO_ON;
452
static void NVStopOverlayVideo
454
ScrnInfoPtr pScrnInfo,
459
NVPtr pNv = NVPTR(pScrnInfo);
460
NVPortPrivPtr pPriv = (NVPortPrivPtr)data;
462
if(pPriv->grabbedByV4L) return;
464
REGION_EMPTY(pScrnInfo->pScreen, &pPriv->clip);
468
if(pPriv->videoStatus & CLIENT_VIDEO_ON)
469
NVStopOverlay(pScrnInfo);
470
NVFreeOverlayMemory(pScrnInfo);
471
pPriv->videoStatus = 0;
472
pNv->VideoTimerCallback = NULL;
476
if(pPriv->videoStatus & CLIENT_VIDEO_ON)
478
pPriv->videoStatus = OFF_TIMER | CLIENT_VIDEO_ON;
479
pPriv->videoTime = currentTime.milliseconds + OFF_DELAY;
480
pNv->VideoTimerCallback = NVVideoTimerCallback;
487
static int NVSetPortAttribute
489
ScrnInfoPtr pScrnInfo,
495
NVPortPrivPtr pPriv = (NVPortPrivPtr)data;
497
if (attribute == xvBrightness)
499
if ((value < -512) || (value > 512))
501
pPriv->brightness = value;
503
else if (attribute == xvDoubleBuffer)
505
if ((value < 0) || (value > 1))
507
pPriv->doubleBuffer = value;
509
else if (attribute == xvContrast)
511
if ((value < 0) || (value > 8191))
513
pPriv->contrast = value;
515
else if (attribute == xvHue)
522
else if (attribute == xvSaturation)
524
if ((value < 0) || (value > 8191))
526
pPriv->saturation = value;
528
else if (attribute == xvColorKey)
530
pPriv->colorKey = value;
531
REGION_EMPTY(pScrnInfo->pScreen, &pPriv->clip);
533
else if (attribute == xvAutopaintColorKey)
535
if ((value < 0) || (value > 1))
537
pPriv->autopaintColorKey = value;
539
else if (attribute == xvITURBT709)
541
if ((value < 0) || (value > 1))
543
pPriv->iturbt_709 = value;
545
else if (attribute == xvSetDefaults)
547
NVSetPortDefaults(pScrnInfo, pPriv);
552
NVResetVideo(pScrnInfo);
559
static int NVGetPortAttribute
561
ScrnInfoPtr pScrnInfo,
567
NVPortPrivPtr pPriv = (NVPortPrivPtr)data;
569
if (attribute == xvBrightness)
570
*value = pPriv->brightness;
571
else if (attribute == xvDoubleBuffer)
572
*value = (pPriv->doubleBuffer) ? 1 : 0;
573
else if (attribute == xvContrast)
574
*value = pPriv->contrast;
575
else if (attribute == xvSaturation)
576
*value = pPriv->saturation;
577
else if (attribute == xvHue)
579
else if (attribute == xvColorKey)
580
*value = pPriv->colorKey;
581
else if (attribute == xvAutopaintColorKey)
582
*value = (pPriv->autopaintColorKey) ? 1 : 0;
583
else if (attribute == xvITURBT709)
584
*value = (pPriv->iturbt_709) ? 1 : 0;
595
static void NVQueryBestSize
597
ScrnInfoPtr pScrnInfo,
608
if(vid_w > (drw_w << 3))
610
if(vid_h > (drw_h << 3))
619
static void NVCopyData422
640
static void NVCopyData420
659
for(j = 0; j < h; j++) {
661
s1 = src1; s2 = src2; s3 = src3;
664
#if X_BYTE_ORDER == X_BIG_ENDIAN
665
dst[0] = (s1[0] << 24) | (s1[1] << 8) | (s3[0] << 16) | s2[0];
666
dst[1] = (s1[2] << 24) | (s1[3] << 8) | (s3[1] << 16) | s2[1];
667
dst[2] = (s1[4] << 24) | (s1[5] << 8) | (s3[2] << 16) | s2[2];
668
dst[3] = (s1[6] << 24) | (s1[7] << 8) | (s3[3] << 16) | s2[3];
670
dst[0] = s1[0] | (s1[1] << 16) | (s3[0] << 8) | (s2[0] << 24);
671
dst[1] = s1[2] | (s1[3] << 16) | (s3[1] << 8) | (s2[1] << 24);
672
dst[2] = s1[4] | (s1[5] << 16) | (s3[2] << 8) | (s2[2] << 24);
673
dst[3] = s1[6] | (s1[7] << 16) | (s3[3] << 8) | (s2[3] << 24);
675
dst += 4; s2 += 4; s3 += 4; s1 += 8;
680
#if X_BYTE_ORDER == X_BIG_ENDIAN
681
dst[0] = (s1[0] << 24) | (s1[1] << 8) | (s3[0] << 16) | s2[0];
683
dst[0] = s1[0] | (s1[1] << 16) | (s3[0] << 8) | (s2[0] << 24);
700
static int NVPutImage
702
ScrnInfoPtr pScrnInfo,
720
NVPortPrivPtr pPriv = (NVPortPrivPtr)data;
721
NVPtr pNv = NVPTR(pScrnInfo);
722
INT32 xa, xb, ya, yb;
723
unsigned char *dst_start;
724
int pitch, newSize, offset, s2offset, s3offset;
725
int srcPitch, srcPitch2, dstPitch;
726
int top, left, npixels, nlines, bpp;
732
* s2offset, s3offset - byte offsets into U and V plane of the
733
* source where copying starts. Y plane is
734
* done by editing "buf".
736
* offset - byte offset to the first line of the destination.
738
* dst_start - byte address to the first displayed pel.
742
if(pPriv->grabbedByV4L) return Success;
744
/* make the compiler happy */
745
s2offset = s3offset = srcPitch2 = 0;
747
if(src_w > (drw_w << 3))
749
if(src_h > (drw_h << 3))
759
dstBox.x2 = drw_x + drw_w;
761
dstBox.y2 = drw_y + drw_h;
763
if(!xf86XVClipVideoHelper(&dstBox, &xa, &xb, &ya, &yb, clipBoxes,
767
dstBox.x1 -= pScrnInfo->frameX0;
768
dstBox.x2 -= pScrnInfo->frameX0;
769
dstBox.y1 -= pScrnInfo->frameY0;
770
dstBox.y2 -= pScrnInfo->frameY0;
772
bpp = pScrnInfo->bitsPerPixel >> 3;
773
pitch = bpp * pScrnInfo->displayWidth;
775
dstPitch = ((width << 1) + 63) & ~63;
780
srcPitch = (width + 3) & ~3; /* of luma */
781
s2offset = srcPitch * height;
782
srcPitch2 = ((width >> 1) + 3) & ~3;
783
s3offset = (srcPitch2 * (height >> 1)) + s2offset;
788
srcPitch = (width << 1);
792
newSize = height * dstPitch / bpp;
794
if(pPriv->doubleBuffer)
797
pPriv->linear = NVAllocateOverlayMemory(pScrnInfo,
801
if(!pPriv->linear) return BadAlloc;
803
offset = pPriv->linear->offset * bpp;
805
if(pPriv->doubleBuffer) {
806
RIVA_HW_INST *pRiva = &(pNv->riva);
807
int mask = 1 << (pPriv->currentBuffer << 2);
810
/* burn the CPU until the next buffer is available */
811
while(pRiva->PMC[0x00008700/4] & mask);
813
/* overwrite the newest buffer if there's not one free */
814
if(pRiva->PMC[0x00008700/4] & mask) {
815
if(!pPriv->currentBuffer)
816
offset += (newSize * bpp) >> 1;
820
if(pPriv->currentBuffer)
821
offset += (newSize * bpp) >> 1;
824
dst_start = pNv->FbStart + offset;
828
left = (xa >> 16) & ~1;
829
npixels = ((((xb + 0xffff) >> 16) + 1) & ~1) - left;
835
dst_start += (left << 1) + (top * dstPitch);
836
tmp = ((top >> 1) * srcPitch2) + (left >> 1);
839
if(id == FOURCC_I420) {
844
nlines = ((((yb + 0xffff) >> 16) + 1) & ~1) - top;
845
NVCopyData420(buf + (top * srcPitch) + left, buf + s2offset,
846
buf + s3offset, dst_start, srcPitch, srcPitch2,
847
dstPitch, nlines, npixels);
853
buf += (top * srcPitch) + left;
854
nlines = ((yb + 0xffff) >> 16) - top;
855
dst_start += left + (top * dstPitch);
856
NVCopyData422(buf, dst_start, srcPitch, dstPitch, nlines, npixels);
861
NVPutOverlayImage(pScrnInfo, offset, id, dstPitch, &dstBox,
863
width, height, src_w, src_h, drw_w, drw_h, clipBoxes);
864
pPriv->currentBuffer ^= 1;
870
* QueryImageAttributes
872
static int NVQueryImageAttributes
874
ScrnInfoPtr pScrnInfo,
898
size = (*w + 3) & ~3;
904
tmp = ((*w >> 1) + 3) & ~3;
906
pitches[1] = pitches[2] = tmp;
925
static void NVVideoTimerCallback
927
ScrnInfoPtr pScrnInfo,
931
NVPtr pNv = NVPTR(pScrnInfo);
932
NVPortPrivPtr pOverPriv = NULL;
934
pNv->VideoTimerCallback = NULL;
936
if(!pScrnInfo->vtSema) return;
938
if(pNv->overlayAdaptor) {
939
pOverPriv = GET_OVERLAY_PRIVATE(pNv);
940
if(!pOverPriv->videoStatus)
945
if(pOverPriv->videoTime < currentTime) {
946
if(pOverPriv->videoStatus & OFF_TIMER) {
947
NVStopOverlay(pScrnInfo);
948
pOverPriv->videoStatus = FREE_TIMER;
949
pOverPriv->videoTime = currentTime + FREE_DELAY;
950
pNv->VideoTimerCallback = NVVideoTimerCallback;
952
if(pOverPriv->videoStatus & FREE_TIMER) {
953
NVFreeOverlayMemory(pScrnInfo);
954
pOverPriv->videoStatus = 0;
957
pNv->VideoTimerCallback = NVVideoTimerCallback;
962
/***** Exported offscreen surface stuff ****/
967
ScrnInfoPtr pScrnInfo,
971
XF86SurfacePtr surface
974
NVPtr pNv = NVPTR(pScrnInfo);
975
NVPortPrivPtr pPriv = GET_OVERLAY_PRIVATE(pNv);
979
bpp = pScrnInfo->bitsPerPixel >> 3;
981
if(pPriv->grabbedByV4L) return BadAlloc;
983
if((w > 2046) || (h > 2046)) return BadValue;
986
pPriv->pitch = ((w << 1) + 63) & ~63;
987
size = h * pPriv->pitch / bpp;
989
pPriv->linear = NVAllocateOverlayMemory(pScrnInfo, pPriv->linear,
992
if(!pPriv->linear) return BadAlloc;
994
pPriv->offset = pPriv->linear->offset * bpp;
995
address = pPriv->offset + pNv->FbStart;
999
surface->pScrn = pScrnInfo;
1000
surface->pitches = &pPriv->pitch;
1001
surface->offsets = &pPriv->offset;
1002
surface->devPrivate.ptr = (pointer)pPriv;
1005
/* grab the video */
1006
NVStopOverlay(pScrnInfo);
1007
pPriv->videoStatus = 0;
1008
REGION_EMPTY(pScrnInfo->pScreen, &pPriv->clip);
1009
pNv->VideoTimerCallback = NULL;
1010
pPriv->grabbedByV4L = TRUE;
1016
NVStopSurface (XF86SurfacePtr surface)
1018
NVPortPrivPtr pPriv = (NVPortPrivPtr)(surface->devPrivate.ptr);
1020
if(pPriv->grabbedByV4L && pPriv->videoStatus) {
1021
NVStopOverlay(surface->pScrn);
1022
pPriv->videoStatus = 0;
1029
NVFreeSurface (XF86SurfacePtr surface)
1031
NVPortPrivPtr pPriv = (NVPortPrivPtr)(surface->devPrivate.ptr);
1033
if(pPriv->grabbedByV4L) {
1034
NVStopSurface(surface);
1035
NVFreeOverlayMemory(surface->pScrn);
1036
pPriv->grabbedByV4L = FALSE;
1043
NVGetSurfaceAttribute (
1044
ScrnInfoPtr pScrnInfo,
1049
NVPtr pNv = NVPTR(pScrnInfo);
1050
NVPortPrivPtr pPriv = GET_OVERLAY_PRIVATE(pNv);
1052
return NVGetPortAttribute(pScrnInfo, attribute, value, (pointer)pPriv);
1056
NVSetSurfaceAttribute(
1057
ScrnInfoPtr pScrnInfo,
1062
NVPtr pNv = NVPTR(pScrnInfo);
1063
NVPortPrivPtr pPriv = GET_OVERLAY_PRIVATE(pNv);
1065
return NVSetPortAttribute(pScrnInfo, attribute, value, (pointer)pPriv);
1070
XF86SurfacePtr surface,
1071
short src_x, short src_y,
1072
short drw_x, short drw_y,
1073
short src_w, short src_h,
1074
short drw_w, short drw_h,
1078
ScrnInfoPtr pScrnInfo = surface->pScrn;
1079
NVPortPrivPtr pPriv = (NVPortPrivPtr)(surface->devPrivate.ptr);
1080
INT32 xa, xb, ya, yb;
1083
if(!pPriv->grabbedByV4L) return Success;
1085
if(src_w > (drw_w << 3))
1087
if(src_h > (drw_h << 3))
1097
dstBox.x2 = drw_x + drw_w;
1099
dstBox.y2 = drw_y + drw_h;
1101
if(!xf86XVClipVideoHelper(&dstBox, &xa, &xb, &ya, &yb, clipBoxes,
1102
surface->width, surface->height))
1107
dstBox.x1 -= pScrnInfo->frameX0;
1108
dstBox.x2 -= pScrnInfo->frameX0;
1109
dstBox.y1 -= pScrnInfo->frameY0;
1110
dstBox.y2 -= pScrnInfo->frameY0;
1112
pPriv->currentBuffer = 0;
1114
NVPutOverlayImage (pScrnInfo, surface->offsets[0], surface->id,
1115
surface->pitches[0], &dstBox, xa, ya, xb, yb,
1116
surface->width, surface->height, src_w, src_h,
1117
drw_w, drw_h, clipBoxes);
1122
XF86OffscreenImageRec NVOffscreenImages[2] =
1126
VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT,
1131
NVGetSurfaceAttribute,
1132
NVSetSurfaceAttribute,
1139
VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT,
1144
NVGetSurfaceAttribute,
1145
NVSetSurfaceAttribute,
1153
NVInitOffscreenImages (ScreenPtr pScreen)
1155
xf86XVRegisterOffscreenImages(pScreen, NVOffscreenImages, 2);