~ubuntu-branches/ubuntu/gutsy/vnc4/gutsy

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_video.c

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2006-05-15 20:35:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515203517-l4lre1ku942mn26k
Tags: 4.1.1+X4.3.0-10
* Correction of critical security issue. Thanks to Martin Kogler
  <e9925248@student.tuwien.ac.at> that informed me about the issue,
  and provided the patch.
  This flaw was originally found by Steve Wiseman of intelliadmin.com.
* Applied patch from Javier Kohen <jkohen@users.sourceforge.net> that
  inform the user that only 8 first characters of the password will
  actually be used when typing more than 8 characters, closes:
  #355619.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_video.c,v 1.11 2002/11/26 23:41:59 mvojkovi Exp $ */
 
2
 
 
3
#include "xf86.h"
 
4
#include "xf86_OSproc.h"
 
5
#include "xf86Resources.h"
 
6
#include "xf86_ansic.h"
 
7
#include "compiler.h"
 
8
#include "xf86PciInfo.h"
 
9
#include "xf86Pci.h"
 
10
#include "xf86fbman.h"
 
11
#include "regionstr.h"
 
12
 
 
13
#include "xf86xv.h"
 
14
#include "Xv.h"
 
15
#include "xaa.h"
 
16
#include "xaalocal.h"
 
17
#include "dixstruct.h"
 
18
#include "fourcc.h"
 
19
 
 
20
#include "nv_include.h"
 
21
 
 
22
 
 
23
#define OFF_DELAY       450  /* milliseconds */
 
24
#define FREE_DELAY      10000
 
25
 
 
26
#define OFF_TIMER       0x01
 
27
#define FREE_TIMER      0x02
 
28
#define CLIENT_VIDEO_ON 0x04
 
29
 
 
30
#define TIMER_MASK      (OFF_TIMER | FREE_TIMER)
 
31
 
 
32
 
 
33
 
 
34
#ifndef XvExtension
 
35
void NVInitVideo(ScreenPtr pScreen) {}
 
36
#else
 
37
 
 
38
typedef struct _NVPortPrivRec {
 
39
   short        brightness;
 
40
   short        contrast;
 
41
   short        saturation;
 
42
   short        hue;
 
43
   RegionRec    clip;
 
44
   CARD32       colorKey;
 
45
   Bool         autopaintColorKey;
 
46
   Bool         doubleBuffer;
 
47
   CARD32       videoStatus;
 
48
   int          currentBuffer;
 
49
   Time         videoTime;
 
50
   Bool         grabbedByV4L;
 
51
   Bool         iturbt_709;
 
52
   FBLinearPtr  linear;
 
53
   int pitch;
 
54
   int offset;
 
55
} NVPortPrivRec, *NVPortPrivPtr;
 
56
 
 
57
 
 
58
static XF86VideoAdaptorPtr NVSetupImageVideo(ScreenPtr);
 
59
 
 
60
static void NVStopOverlay (ScrnInfoPtr);
 
61
static void NVPutOverlayImage(ScrnInfoPtr pScrnInfo,
 
62
                              int offset,
 
63
                              int id,
 
64
                              int dstPitch,
 
65
                              BoxPtr dstBox,
 
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,
 
70
                              RegionPtr cliplist);
 
71
 
 
72
static int  NVSetPortAttribute(ScrnInfoPtr, Atom, INT32, pointer);
 
73
static int  NVGetPortAttribute(ScrnInfoPtr, Atom ,INT32 *, pointer);
 
74
 
 
75
static void NVStopOverlayVideo(ScrnInfoPtr, pointer, Bool);
 
76
 
 
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 *);
 
80
 
 
81
static void NVVideoTimerCallback(ScrnInfoPtr, Time);
 
82
 
 
83
static void NVInitOffscreenImages (ScreenPtr pScreen);
 
84
 
 
85
 
 
86
#define GET_OVERLAY_PRIVATE(pNv) \
 
87
   (NVPortPrivPtr)((pNv)->overlayAdaptor->pPortPrivates[0].ptr)
 
88
 
 
89
#define GET_BLIT_PRIVATE(pNv) \
 
90
   (NVPortPrivPtr)((pNv)->blitAdaptor->pPortPrivates[0].ptr)
 
91
 
 
92
#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
 
93
 
 
94
static Atom xvBrightness, xvContrast, xvColorKey, xvSaturation, 
 
95
            xvHue, xvAutopaintColorKey, xvSetDefaults, xvDoubleBuffer,
 
96
            xvITURBT709;
 
97
 
 
98
/* client libraries expect an encoding */
 
99
static XF86VideoEncodingRec DummyEncoding =
 
100
 
101
   0,
 
102
   "XV_IMAGE",
 
103
   2046, 2046,
 
104
   {1, 1}
 
105
};
 
106
 
 
107
#define NUM_FORMATS_ALL 6
 
108
 
 
109
XF86VideoFormatRec NVFormats[NUM_FORMATS_ALL] = 
 
110
{
 
111
   {15, TrueColor}, {16, TrueColor}, {24, TrueColor},
 
112
   {15, DirectColor}, {16, DirectColor}, {24, DirectColor}
 
113
};
 
114
 
 
115
#define NUM_ATTRIBUTES 9
 
116
 
 
117
XF86AttributeRec NVAttributes[NUM_ATTRIBUTES] =
 
118
{
 
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"}
 
128
};
 
129
 
 
130
#define NUM_IMAGES_ALL 4
 
131
 
 
132
static XF86ImageRec NVImages[NUM_IMAGES_ALL] =
 
133
{
 
134
    XVIMAGE_YUY2,
 
135
    XVIMAGE_YV12,
 
136
    XVIMAGE_UYVY,
 
137
    XVIMAGE_I420
 
138
};
 
139
 
 
140
static void 
 
141
NVSetPortDefaults (ScrnInfoPtr pScrnInfo, NVPortPrivPtr pPriv)
 
142
{
 
143
    NVPtr pNv = NVPTR(pScrnInfo);
 
144
 
 
145
    pPriv->brightness           = 0;
 
146
    pPriv->contrast             = 4096;
 
147
    pPriv->saturation           = 4096;
 
148
    pPriv->hue                  = 0;
 
149
    pPriv->colorKey             = pNv->videoKey;
 
150
    pPriv->autopaintColorKey    = TRUE;
 
151
    pPriv->doubleBuffer         = TRUE;
 
152
    pPriv->iturbt_709           = FALSE;
 
153
}
 
154
 
 
155
 
 
156
void 
 
157
NVResetVideo (ScrnInfoPtr pScrnInfo)
 
158
{
 
159
    NVPtr          pNv     = NVPTR(pScrnInfo);
 
160
    NVPortPrivPtr  pPriv   = GET_OVERLAY_PRIVATE(pNv);
 
161
    RIVA_HW_INST  *pRiva   = &(pNv->riva);
 
162
    int            satSine, satCosine;
 
163
    double         angle;
 
164
    
 
165
    angle = (double)pPriv->hue * 3.1415927 / 180.0;
 
166
    
 
167
    satSine = pPriv->saturation * sin(angle);
 
168
    if (satSine < -1024)
 
169
        satSine = -1024;
 
170
    satCosine = pPriv->saturation * cos(angle);
 
171
    if (satCosine < -1024)
 
172
        satCosine = -1024;
 
173
    
 
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;
 
179
}
 
180
 
 
181
 
 
182
 
 
183
static void 
 
184
NVStopOverlay (ScrnInfoPtr pScrnInfo)
 
185
{
 
186
    NVPtr          pNv     = NVPTR(pScrnInfo);
 
187
    RIVA_HW_INST  *pRiva   = &(pNv->riva);
 
188
 
 
189
    pRiva->PMC[0x00008704/4] = 1;
 
190
}
 
191
 
 
192
static FBLinearPtr
 
193
NVAllocateOverlayMemory(
 
194
   ScrnInfoPtr pScrn,
 
195
   FBLinearPtr linear,
 
196
   int size
 
197
){
 
198
   ScreenPtr pScreen;
 
199
   FBLinearPtr new_linear;
 
200
 
 
201
   if(linear) {
 
202
        if(linear->size >= size) 
 
203
           return linear;
 
204
        
 
205
        if(xf86ResizeOffscreenLinear(linear, size))
 
206
           return linear;
 
207
 
 
208
        xf86FreeOffscreenLinear(linear);
 
209
   }
 
210
 
 
211
   pScreen = screenInfo.screens[pScrn->scrnIndex];
 
212
 
 
213
   new_linear = xf86AllocateOffscreenLinear(pScreen, size, 32, 
 
214
                                                NULL, NULL, NULL);
 
215
 
 
216
   if(!new_linear) {
 
217
        int max_size;
 
218
 
 
219
        xf86QueryLargestOffscreenLinear(pScreen, &max_size, 32, 
 
220
                                                PRIORITY_EXTREME);
 
221
        
 
222
        if(max_size < size)
 
223
           return NULL;
 
224
 
 
225
        xf86PurgeUnlockedOffscreenAreas(pScreen);
 
226
        new_linear = xf86AllocateOffscreenLinear(pScreen, size, 32, 
 
227
                                                NULL, NULL, NULL);
 
228
   }
 
229
 
 
230
   return new_linear;
 
231
}
 
232
 
 
233
static void NVFreeOverlayMemory(ScrnInfoPtr pScrnInfo)
 
234
{
 
235
    NVPtr               pNv   = NVPTR(pScrnInfo);
 
236
    NVPortPrivPtr  pPriv   = GET_OVERLAY_PRIVATE(pNv);
 
237
 
 
238
    if(pPriv->linear) {
 
239
        xf86FreeOffscreenLinear(pPriv->linear);
 
240
        pPriv->linear = NULL;
 
241
    }
 
242
}
 
243
 
 
244
 
 
245
void NVInitVideo (ScreenPtr pScreen)
 
246
{
 
247
    ScrnInfoPtr         pScrn = xf86Screens[pScreen->myNum];
 
248
    XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL;
 
249
    XF86VideoAdaptorPtr overlayAdaptor = NULL;
 
250
    NVPtr               pNv   = NVPTR(pScrn);
 
251
    int                 num_adaptors;
 
252
 
 
253
    if((pScrn->bitsPerPixel != 8) && (pNv->riva.Architecture >= NV_ARCH_10))
 
254
    {
 
255
        overlayAdaptor = NVSetupImageVideo(pScreen);
 
256
  
 
257
        if(overlayAdaptor)
 
258
            NVInitOffscreenImages(pScreen);
 
259
    }
 
260
 
 
261
    num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors);
 
262
    
 
263
    if(overlayAdaptor) {
 
264
        int size = num_adaptors + 1;
 
265
 
 
266
        if((newAdaptors = xalloc(size * sizeof(XF86VideoAdaptorPtr*)))) {
 
267
            if(num_adaptors)
 
268
                memcpy(newAdaptors, adaptors,
 
269
                        num_adaptors * sizeof(XF86VideoAdaptorPtr));
 
270
 
 
271
            if(overlayAdaptor) {
 
272
                newAdaptors[num_adaptors] = overlayAdaptor;
 
273
                num_adaptors++;
 
274
            }
 
275
            adaptors = newAdaptors;
 
276
        }
 
277
    }
 
278
 
 
279
    if (num_adaptors)
 
280
        xf86XVScreenInit(pScreen, adaptors, num_adaptors);
 
281
 
 
282
    if (newAdaptors)
 
283
        xfree(newAdaptors);    
 
284
}
 
285
 
 
286
 
 
287
static XF86VideoAdaptorPtr 
 
288
NVSetupImageVideo (ScreenPtr pScreen)
 
289
{
 
290
    ScrnInfoPtr pScrnInfo = xf86Screens[pScreen->myNum];
 
291
    NVPtr       pNv       = NVPTR(pScrnInfo);
 
292
    XF86VideoAdaptorPtr adapt;
 
293
    NVPortPrivPtr       pPriv;
 
294
    
 
295
    if (!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) + 
 
296
                             sizeof(NVPortPrivRec) + 
 
297
                             sizeof(DevUnion))))
 
298
    {
 
299
        return NULL;
 
300
    } 
 
301
 
 
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;
 
309
    adapt->nPorts               = 1;
 
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;
 
327
    
 
328
    pPriv->videoStatus          = 0;
 
329
    pPriv->currentBuffer        = 0;
 
330
    pPriv->grabbedByV4L         = FALSE;
 
331
 
 
332
    NVSetPortDefaults (pScrnInfo, pPriv);
 
333
    
 
334
    /* gotta uninit this someplace */
 
335
    REGION_INIT(pScreen, &pPriv->clip, NullBox, 0); 
 
336
    
 
337
    pNv->overlayAdaptor         = adapt;
 
338
    
 
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");
 
348
 
 
349
    NVResetVideo(pScrnInfo);
 
350
 
 
351
    return adapt;
 
352
}
 
353
 
 
354
/*
 
355
 * RegionsEqual
 
356
 */
 
357
static Bool RegionsEqual
 
358
(
 
359
    RegionPtr A,
 
360
    RegionPtr B
 
361
)
 
362
{
 
363
    int *dataA, *dataB;
 
364
    int num;
 
365
    
 
366
    num = REGION_NUM_RECTS(A);
 
367
    if (num != REGION_NUM_RECTS(B))
 
368
        return FALSE;
 
369
    
 
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))
 
374
        return FALSE;
 
375
    
 
376
    dataA = (int*)REGION_RECTS(A);
 
377
    dataB = (int*)REGION_RECTS(B);
 
378
    
 
379
    while(num--)
 
380
    {
 
381
        if((dataA[0] != dataB[0]) || (dataA[1] != dataB[1]))
 
382
            return FALSE;
 
383
        dataA += 2; 
 
384
        dataB += 2;
 
385
    }
 
386
    return TRUE;
 
387
}
 
388
 
 
389
static void
 
390
NVPutOverlayImage (
 
391
    ScrnInfoPtr pScrnInfo,
 
392
    int         offset,
 
393
    int         id,
 
394
    int         dstPitch,
 
395
    BoxPtr      dstBox,
 
396
    int         x1,
 
397
    int         y1,
 
398
    int         x2,
 
399
    int         y2,
 
400
    short       width,
 
401
    short       height,
 
402
    short       src_w,
 
403
    short       src_h,
 
404
    short       drw_w,
 
405
    short       drw_h,
 
406
    RegionPtr   clipBoxes
 
407
)
 
408
{
 
409
    NVPtr          pNv     = NVPTR(pScrnInfo);
 
410
    NVPortPrivPtr  pPriv   = GET_OVERLAY_PRIVATE(pNv);
 
411
    RIVA_HW_INST  *pRiva   = &(pNv->riva);
 
412
    int buffer = pPriv->currentBuffer;
 
413
 
 
414
    /* paint the color key */
 
415
    if(pPriv->autopaintColorKey && 
 
416
       (pPriv->grabbedByV4L || !RegionsEqual(&pPriv->clip, clipBoxes)))
 
417
    {
 
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);
 
422
    }
 
423
 
 
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);
 
432
 
 
433
    dstPitch |= 1 << 20;   /* use color key */
 
434
 
 
435
    if(id != FOURCC_UYVY)
 
436
        dstPitch |= 1 << 16;
 
437
    if(pPriv->iturbt_709)
 
438
        dstPitch |= 1 << 24;
 
439
 
 
440
    pRiva->PMC[(0x8958/4) + buffer] = dstPitch;
 
441
    pRiva->PMC[0x00008704/4] = 0;
 
442
    pRiva->PMC[0x8700/4] = 1 << (buffer << 2);
 
443
 
 
444
    pPriv->videoStatus = CLIENT_VIDEO_ON;
 
445
}
 
446
 
 
447
 
 
448
 
 
449
/*
 
450
 * StopVideo
 
451
 */
 
452
static void NVStopOverlayVideo
 
453
(
 
454
    ScrnInfoPtr pScrnInfo,
 
455
    pointer     data,
 
456
    Bool        Exit
 
457
)
 
458
{
 
459
    NVPtr pNv = NVPTR(pScrnInfo);
 
460
    NVPortPrivPtr pPriv = (NVPortPrivPtr)data;
 
461
 
 
462
    if(pPriv->grabbedByV4L) return;
 
463
    
 
464
    REGION_EMPTY(pScrnInfo->pScreen, &pPriv->clip);   
 
465
 
 
466
    if(Exit)
 
467
    {
 
468
        if(pPriv->videoStatus & CLIENT_VIDEO_ON) 
 
469
            NVStopOverlay(pScrnInfo);
 
470
        NVFreeOverlayMemory(pScrnInfo);
 
471
        pPriv->videoStatus = 0;
 
472
        pNv->VideoTimerCallback = NULL;
 
473
    } 
 
474
    else 
 
475
    {
 
476
        if(pPriv->videoStatus & CLIENT_VIDEO_ON) 
 
477
        {
 
478
            pPriv->videoStatus = OFF_TIMER | CLIENT_VIDEO_ON;
 
479
            pPriv->videoTime = currentTime.milliseconds + OFF_DELAY; 
 
480
            pNv->VideoTimerCallback = NVVideoTimerCallback;
 
481
        }
 
482
    }
 
483
}
 
484
 
 
485
 
 
486
 
 
487
static int NVSetPortAttribute
 
488
(
 
489
    ScrnInfoPtr pScrnInfo, 
 
490
    Atom        attribute,
 
491
    INT32       value, 
 
492
    pointer     data
 
493
)
 
494
{
 
495
    NVPortPrivPtr pPriv = (NVPortPrivPtr)data;
 
496
    
 
497
    if (attribute == xvBrightness)
 
498
    {
 
499
        if ((value < -512) || (value > 512))
 
500
            return BadValue;
 
501
        pPriv->brightness = value;
 
502
    }
 
503
    else if (attribute == xvDoubleBuffer)
 
504
    {
 
505
        if ((value < 0) || (value > 1))
 
506
            return BadValue;
 
507
        pPriv->doubleBuffer = value;
 
508
    }
 
509
    else if (attribute == xvContrast)
 
510
    {
 
511
        if ((value < 0) || (value > 8191))
 
512
            return BadValue;
 
513
        pPriv->contrast = value;
 
514
    }
 
515
    else if (attribute == xvHue)
 
516
    {
 
517
        value %= 360;
 
518
        if (value < 0)
 
519
            value += 360;
 
520
        pPriv->hue = value;
 
521
    }
 
522
    else if (attribute == xvSaturation)
 
523
    {
 
524
        if ((value < 0) || (value > 8191))
 
525
            return BadValue;
 
526
        pPriv->saturation = value;
 
527
    }
 
528
    else if (attribute == xvColorKey)
 
529
    {
 
530
        pPriv->colorKey = value;
 
531
        REGION_EMPTY(pScrnInfo->pScreen, &pPriv->clip);   
 
532
    }
 
533
    else if (attribute == xvAutopaintColorKey)
 
534
    {
 
535
        if ((value < 0) || (value > 1))
 
536
            return BadValue;
 
537
        pPriv->autopaintColorKey = value;
 
538
    }
 
539
    else if (attribute == xvITURBT709)
 
540
    {
 
541
        if ((value < 0) || (value > 1))
 
542
            return BadValue;
 
543
        pPriv->iturbt_709 = value;
 
544
    }
 
545
    else if (attribute == xvSetDefaults)
 
546
    {
 
547
        NVSetPortDefaults(pScrnInfo, pPriv);
 
548
    }
 
549
    else
 
550
        return BadMatch;
 
551
    
 
552
    NVResetVideo(pScrnInfo);
 
553
    return Success;
 
554
}
 
555
 
 
556
 
 
557
 
 
558
 
 
559
static int NVGetPortAttribute
 
560
(
 
561
    ScrnInfoPtr  pScrnInfo, 
 
562
    Atom         attribute,
 
563
    INT32       *value, 
 
564
    pointer      data
 
565
)
 
566
{
 
567
    NVPortPrivPtr pPriv = (NVPortPrivPtr)data;
 
568
    
 
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)
 
578
        *value = pPriv->hue;
 
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;
 
585
    else
 
586
        return BadMatch;
 
587
    
 
588
    return Success;
 
589
}
 
590
 
 
591
 
 
592
/*
 
593
 * QueryBestSize
 
594
 */
 
595
static void NVQueryBestSize
 
596
(
 
597
    ScrnInfoPtr   pScrnInfo, 
 
598
    Bool          motion,
 
599
    short         vid_w,
 
600
    short         vid_h, 
 
601
    short         drw_w,
 
602
    short         drw_h, 
 
603
    unsigned int *p_w,
 
604
    unsigned int *p_h, 
 
605
    pointer       data
 
606
)
 
607
{
 
608
    if(vid_w > (drw_w << 3))
 
609
        drw_w = vid_w >> 3;
 
610
    if(vid_h > (drw_h << 3))
 
611
        drw_h = vid_h >> 3;
 
612
 
 
613
    *p_w = drw_w;
 
614
    *p_h = drw_h; 
 
615
}
 
616
/*
 
617
 * CopyData
 
618
 */
 
619
static void NVCopyData422
 
620
(
 
621
  unsigned char *src,
 
622
  unsigned char *dst,
 
623
  int            srcPitch,
 
624
  int            dstPitch,
 
625
  int            h,
 
626
  int            w
 
627
)
 
628
{
 
629
    w <<= 1;
 
630
    while(h--)
 
631
    {
 
632
        memcpy(dst, src, w);
 
633
        src += srcPitch;
 
634
        dst += dstPitch;
 
635
    }
 
636
}
 
637
/*
 
638
 * CopyMungedData
 
639
 */
 
640
static void NVCopyData420
 
641
(
 
642
    unsigned char *src1,
 
643
    unsigned char *src2,
 
644
    unsigned char *src3,
 
645
    unsigned char *dst1,
 
646
    int            srcPitch,
 
647
    int            srcPitch2,
 
648
    int            dstPitch,
 
649
    int            h,
 
650
    int            w
 
651
)
 
652
{
 
653
   CARD32 *dst;
 
654
   CARD8 *s1, *s2, *s3;
 
655
   int i, j;
 
656
 
 
657
   w >>= 1;
 
658
 
 
659
   for(j = 0; j < h; j++) {
 
660
        dst = (CARD32*)dst1;
 
661
        s1 = src1;  s2 = src2;  s3 = src3;
 
662
        i = w;
 
663
        while(i > 4) {
 
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];
 
669
#else
 
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);
 
674
#endif
 
675
           dst += 4; s2 += 4; s3 += 4; s1 += 8;
 
676
           i -= 4;
 
677
        }
 
678
 
 
679
        while(i--) {
 
680
#if X_BYTE_ORDER == X_BIG_ENDIAN
 
681
           dst[0] = (s1[0] << 24) | (s1[1] << 8) | (s3[0] << 16) | s2[0];
 
682
#else
 
683
           dst[0] = s1[0] | (s1[1] << 16) | (s3[0] << 8) | (s2[0] << 24);
 
684
#endif
 
685
           dst++; s2++; s3++;
 
686
           s1 += 2;
 
687
        }
 
688
 
 
689
        dst1 += dstPitch;
 
690
        src1 += srcPitch;
 
691
        if(j & 1) {
 
692
            src2 += srcPitch2;
 
693
            src3 += srcPitch2;
 
694
        }
 
695
   }
 
696
}
 
697
/*
 
698
 * PutImage
 
699
 */
 
700
static int NVPutImage
 
701
 
702
    ScrnInfoPtr  pScrnInfo, 
 
703
    short        src_x,
 
704
    short        src_y, 
 
705
    short        drw_x,
 
706
    short        drw_y,
 
707
    short        src_w,
 
708
    short        src_h, 
 
709
    short        drw_w,
 
710
    short        drw_h,
 
711
    int          id,
 
712
    unsigned char *buf, 
 
713
    short        width,
 
714
    short        height, 
 
715
    Bool         Sync,
 
716
    RegionPtr    clipBoxes,
 
717
    pointer      data
 
718
)
 
719
{
 
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;
 
727
    Bool skip = FALSE;
 
728
    BoxRec dstBox;
 
729
    CARD32 tmp;
 
730
 
 
731
   /*
 
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".
 
735
    *
 
736
    * offset - byte offset to the first line of the destination.
 
737
    *
 
738
    * dst_start - byte address to the first displayed pel.
 
739
    *
 
740
    */
 
741
 
 
742
    if(pPriv->grabbedByV4L) return Success;
 
743
 
 
744
    /* make the compiler happy */
 
745
    s2offset = s3offset = srcPitch2 = 0;
 
746
    
 
747
    if(src_w > (drw_w << 3))
 
748
        drw_w = src_w >> 3;
 
749
    if(src_h > (drw_h << 3))
 
750
        drw_h = src_h >> 3;
 
751
 
 
752
    /* Clip */
 
753
    xa = src_x;
 
754
    xb = src_x + src_w;
 
755
    ya = src_y;
 
756
    yb = src_y + src_h;
 
757
    
 
758
    dstBox.x1 = drw_x;
 
759
    dstBox.x2 = drw_x + drw_w;
 
760
    dstBox.y1 = drw_y;
 
761
    dstBox.y2 = drw_y + drw_h;
 
762
    
 
763
    if(!xf86XVClipVideoHelper(&dstBox, &xa, &xb, &ya, &yb, clipBoxes, 
 
764
                              width, height))
 
765
        return Success;
 
766
    
 
767
    dstBox.x1 -= pScrnInfo->frameX0;
 
768
    dstBox.x2 -= pScrnInfo->frameX0;
 
769
    dstBox.y1 -= pScrnInfo->frameY0;
 
770
    dstBox.y2 -= pScrnInfo->frameY0;
 
771
 
 
772
    bpp = pScrnInfo->bitsPerPixel >> 3;
 
773
    pitch = bpp * pScrnInfo->displayWidth;
 
774
 
 
775
    dstPitch = ((width << 1) + 63) & ~63;
 
776
 
 
777
    switch(id) {
 
778
    case FOURCC_YV12:
 
779
    case FOURCC_I420:
 
780
        srcPitch = (width + 3) & ~3;    /* of luma */
 
781
        s2offset = srcPitch * height;
 
782
        srcPitch2 = ((width >> 1) + 3) & ~3;
 
783
        s3offset = (srcPitch2 * (height >> 1)) + s2offset;
 
784
        break;
 
785
    case FOURCC_UYVY:
 
786
    case FOURCC_YUY2:
 
787
    default:
 
788
        srcPitch = (width << 1);
 
789
        break;
 
790
    }
 
791
 
 
792
    newSize = height * dstPitch / bpp;
 
793
 
 
794
    if(pPriv->doubleBuffer)
 
795
        newSize <<= 1;
 
796
 
 
797
    pPriv->linear = NVAllocateOverlayMemory(pScrnInfo, 
 
798
                                            pPriv->linear, 
 
799
                                            newSize);
 
800
 
 
801
    if(!pPriv->linear) return BadAlloc;
 
802
 
 
803
    offset = pPriv->linear->offset * bpp;
 
804
 
 
805
    if(pPriv->doubleBuffer) {
 
806
        RIVA_HW_INST  *pRiva   = &(pNv->riva);
 
807
        int mask = 1 << (pPriv->currentBuffer << 2);
 
808
 
 
809
#if 0
 
810
        /* burn the CPU until the next buffer is available */
 
811
        while(pRiva->PMC[0x00008700/4] & mask);
 
812
#else
 
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;
 
817
           skip = TRUE;
 
818
        } else 
 
819
#endif
 
820
        if(pPriv->currentBuffer)
 
821
            offset += (newSize * bpp) >> 1;
 
822
    }
 
823
 
 
824
    dst_start = pNv->FbStart + offset;
 
825
        
 
826
    /* copy data */
 
827
    top = ya >> 16;
 
828
    left = (xa >> 16) & ~1;
 
829
    npixels = ((((xb + 0xffff) >> 16) + 1) & ~1) - left;
 
830
 
 
831
    switch(id) {
 
832
    case FOURCC_YV12:
 
833
    case FOURCC_I420:
 
834
        top &= ~1;
 
835
        dst_start += (left << 1) + (top * dstPitch);
 
836
        tmp = ((top >> 1) * srcPitch2) + (left >> 1);
 
837
        s2offset += tmp;
 
838
        s3offset += tmp;
 
839
        if(id == FOURCC_I420) {
 
840
           tmp = s2offset;
 
841
           s2offset = s3offset;
 
842
           s3offset = tmp;
 
843
        }
 
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);
 
848
        break;
 
849
    case FOURCC_UYVY:
 
850
    case FOURCC_YUY2:
 
851
    default:
 
852
        left <<= 1;
 
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);
 
857
        break;
 
858
    }
 
859
 
 
860
    if(!skip) {
 
861
       NVPutOverlayImage(pScrnInfo, offset, id, dstPitch, &dstBox, 
 
862
                         xa, ya, xb, yb,
 
863
                         width, height, src_w, src_h, drw_w, drw_h, clipBoxes);
 
864
       pPriv->currentBuffer ^= 1;
 
865
    } 
 
866
 
 
867
    return Success;
 
868
}
 
869
/*
 
870
 * QueryImageAttributes
 
871
 */
 
872
static int NVQueryImageAttributes
 
873
(
 
874
    ScrnInfoPtr pScrnInfo, 
 
875
    int         id, 
 
876
    unsigned short *w,
 
877
    unsigned short *h, 
 
878
    int         *pitches,
 
879
    int         *offsets
 
880
)
 
881
{
 
882
    int size, tmp;
 
883
    
 
884
    if(*w > 2046)
 
885
        *w = 2046;
 
886
    if(*h > 2046)
 
887
        *h = 2046;
 
888
    
 
889
    *w = (*w + 1) & ~1;
 
890
    if (offsets)
 
891
        offsets[0] = 0;
 
892
    
 
893
    switch (id)
 
894
    {
 
895
        case FOURCC_YV12:
 
896
        case FOURCC_I420:
 
897
            *h = (*h + 1) & ~1;
 
898
            size = (*w + 3) & ~3;
 
899
            if (pitches)
 
900
                pitches[0] = size;
 
901
            size *= *h;
 
902
            if (offsets)
 
903
                offsets[1] = size;
 
904
            tmp = ((*w >> 1) + 3) & ~3;
 
905
            if (pitches)
 
906
                pitches[1] = pitches[2] = tmp;
 
907
            tmp *= (*h >> 1);
 
908
            size += tmp;
 
909
            if (offsets)
 
910
                offsets[2] = size;
 
911
            size += tmp;
 
912
            break;
 
913
        case FOURCC_UYVY:
 
914
        case FOURCC_YUY2:
 
915
        default:
 
916
            size = *w << 1;
 
917
            if (pitches)
 
918
                pitches[0] = size;
 
919
            size *= *h;
 
920
            break;
 
921
    }
 
922
    return size;
 
923
}
 
924
 
 
925
static void NVVideoTimerCallback 
 
926
(
 
927
    ScrnInfoPtr pScrnInfo,
 
928
    Time currentTime
 
929
)
 
930
{
 
931
    NVPtr         pNv = NVPTR(pScrnInfo);
 
932
    NVPortPrivPtr pOverPriv = NULL;
 
933
 
 
934
    pNv->VideoTimerCallback = NULL;
 
935
 
 
936
    if(!pScrnInfo->vtSema) return; 
 
937
 
 
938
    if(pNv->overlayAdaptor) {
 
939
        pOverPriv = GET_OVERLAY_PRIVATE(pNv);
 
940
        if(!pOverPriv->videoStatus)
 
941
           pOverPriv = NULL;
 
942
    }
 
943
 
 
944
    if(pOverPriv) {
 
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;
 
951
            } else
 
952
            if(pOverPriv->videoStatus & FREE_TIMER) {
 
953
                NVFreeOverlayMemory(pScrnInfo);
 
954
                pOverPriv->videoStatus = 0;
 
955
            }   
 
956
         } else
 
957
            pNv->VideoTimerCallback = NVVideoTimerCallback;
 
958
    }
 
959
}
 
960
 
 
961
 
 
962
/***** Exported offscreen surface stuff ****/
 
963
 
 
964
 
 
965
static int
 
966
NVAllocSurface (
 
967
    ScrnInfoPtr pScrnInfo,
 
968
    int id,
 
969
    unsigned short w,   
 
970
    unsigned short h,
 
971
    XF86SurfacePtr surface
 
972
)
 
973
{
 
974
    NVPtr pNv = NVPTR(pScrnInfo);
 
975
    NVPortPrivPtr pPriv = GET_OVERLAY_PRIVATE(pNv); 
 
976
    CARD8 *address;
 
977
    int size, bpp;
 
978
 
 
979
    bpp = pScrnInfo->bitsPerPixel >> 3;
 
980
 
 
981
    if(pPriv->grabbedByV4L) return BadAlloc;
 
982
 
 
983
    if((w > 2046) || (h > 2046)) return BadValue;
 
984
 
 
985
    w = (w + 1) & ~1;
 
986
    pPriv->pitch = ((w << 1) + 63) & ~63;
 
987
    size = h * pPriv->pitch / bpp;
 
988
 
 
989
    pPriv->linear = NVAllocateOverlayMemory(pScrnInfo, pPriv->linear,
 
990
                                            size);
 
991
 
 
992
    if(!pPriv->linear) return BadAlloc;
 
993
 
 
994
    pPriv->offset = pPriv->linear->offset * bpp;
 
995
    address = pPriv->offset + pNv->FbStart;
 
996
 
 
997
    surface->width = w;
 
998
    surface->height = h;
 
999
    surface->pScrn = pScrnInfo;
 
1000
    surface->pitches = &pPriv->pitch; 
 
1001
    surface->offsets = &pPriv->offset;
 
1002
    surface->devPrivate.ptr = (pointer)pPriv;
 
1003
    surface->id = id;
 
1004
 
 
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;
 
1011
 
 
1012
    return Success;
 
1013
}
 
1014
 
 
1015
static int
 
1016
NVStopSurface (XF86SurfacePtr surface)
 
1017
{
 
1018
    NVPortPrivPtr pPriv = (NVPortPrivPtr)(surface->devPrivate.ptr);
 
1019
 
 
1020
    if(pPriv->grabbedByV4L && pPriv->videoStatus) {
 
1021
        NVStopOverlay(surface->pScrn);
 
1022
        pPriv->videoStatus = 0;
 
1023
    }
 
1024
 
 
1025
    return Success;
 
1026
}
 
1027
 
 
1028
static int 
 
1029
NVFreeSurface (XF86SurfacePtr surface)
 
1030
{
 
1031
    NVPortPrivPtr pPriv = (NVPortPrivPtr)(surface->devPrivate.ptr);
 
1032
 
 
1033
    if(pPriv->grabbedByV4L) {
 
1034
        NVStopSurface(surface);
 
1035
        NVFreeOverlayMemory(surface->pScrn);
 
1036
        pPriv->grabbedByV4L = FALSE;
 
1037
    }
 
1038
 
 
1039
    return Success;
 
1040
}
 
1041
 
 
1042
static int
 
1043
NVGetSurfaceAttribute (
 
1044
    ScrnInfoPtr pScrnInfo,
 
1045
    Atom attribute,
 
1046
    INT32 *value
 
1047
)
 
1048
{
 
1049
    NVPtr pNv = NVPTR(pScrnInfo);
 
1050
    NVPortPrivPtr pPriv = GET_OVERLAY_PRIVATE(pNv);
 
1051
    
 
1052
    return NVGetPortAttribute(pScrnInfo, attribute, value, (pointer)pPriv);
 
1053
}
 
1054
 
 
1055
static int
 
1056
NVSetSurfaceAttribute(
 
1057
    ScrnInfoPtr pScrnInfo,
 
1058
    Atom attribute,
 
1059
    INT32 value
 
1060
)
 
1061
{
 
1062
    NVPtr pNv = NVPTR(pScrnInfo);
 
1063
    NVPortPrivPtr pPriv = GET_OVERLAY_PRIVATE(pNv);
 
1064
   
 
1065
    return NVSetPortAttribute(pScrnInfo, attribute, value, (pointer)pPriv);
 
1066
}
 
1067
 
 
1068
static int
 
1069
NVDisplaySurface (
 
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,
 
1075
    RegionPtr clipBoxes
 
1076
)
 
1077
{
 
1078
    ScrnInfoPtr pScrnInfo = surface->pScrn;
 
1079
    NVPortPrivPtr pPriv = (NVPortPrivPtr)(surface->devPrivate.ptr);
 
1080
    INT32 xa, xb, ya, yb;
 
1081
    BoxRec dstBox;
 
1082
 
 
1083
    if(!pPriv->grabbedByV4L) return Success;
 
1084
 
 
1085
    if(src_w > (drw_w << 3))
 
1086
        drw_w = src_w >> 3;
 
1087
    if(src_h > (drw_h << 3))
 
1088
        drw_h = src_h >> 3;
 
1089
 
 
1090
    /* Clip */
 
1091
    xa = src_x;
 
1092
    xb = src_x + src_w;
 
1093
    ya = src_y;
 
1094
    yb = src_y + src_h;
 
1095
    
 
1096
    dstBox.x1 = drw_x;
 
1097
    dstBox.x2 = drw_x + drw_w;
 
1098
    dstBox.y1 = drw_y;
 
1099
    dstBox.y2 = drw_y + drw_h;
 
1100
    
 
1101
    if(!xf86XVClipVideoHelper(&dstBox, &xa, &xb, &ya, &yb, clipBoxes, 
 
1102
                    surface->width, surface->height))
 
1103
    {
 
1104
        return Success;
 
1105
    }
 
1106
    
 
1107
    dstBox.x1 -= pScrnInfo->frameX0;
 
1108
    dstBox.x2 -= pScrnInfo->frameX0;
 
1109
    dstBox.y1 -= pScrnInfo->frameY0;
 
1110
    dstBox.y2 -= pScrnInfo->frameY0;
 
1111
 
 
1112
    pPriv->currentBuffer = 0;
 
1113
 
 
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);
 
1118
 
 
1119
    return Success;
 
1120
}
 
1121
 
 
1122
XF86OffscreenImageRec NVOffscreenImages[2] =
 
1123
{
 
1124
 {
 
1125
   &NVImages[0],
 
1126
   VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT,
 
1127
   NVAllocSurface,
 
1128
   NVFreeSurface,
 
1129
   NVDisplaySurface,
 
1130
   NVStopSurface,
 
1131
   NVGetSurfaceAttribute,
 
1132
   NVSetSurfaceAttribute,
 
1133
   2046, 2046,
 
1134
   NUM_ATTRIBUTES - 1,
 
1135
   &NVAttributes[1]
 
1136
  },
 
1137
 {
 
1138
   &NVImages[2],
 
1139
   VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT,
 
1140
   NVAllocSurface,
 
1141
   NVFreeSurface,
 
1142
   NVDisplaySurface,
 
1143
   NVStopSurface,
 
1144
   NVGetSurfaceAttribute,
 
1145
   NVSetSurfaceAttribute,
 
1146
   2046, 2046,
 
1147
   NUM_ATTRIBUTES - 1,
 
1148
   &NVAttributes[1]
 
1149
  },
 
1150
};
 
1151
 
 
1152
static void
 
1153
NVInitOffscreenImages (ScreenPtr pScreen)
 
1154
{
 
1155
    xf86XVRegisterOffscreenImages(pScreen, NVOffscreenImages, 2);
 
1156
}
 
1157
 
 
1158
#endif
 
1159
 
 
1160