]> git.pld-linux.org Git - packages/XFree86.git/blob - XFree86-neomagic-Xv-support.patch
- added Requires(post,postun) to -libs
[packages/XFree86.git] / XFree86-neomagic-Xv-support.patch
1 --- XFree86-4.2.0/xc.orig/programs/Xserver/hw/xfree86/drivers/neomagic/Imakefile        Wed Jan 24 01:06:21 2001
2 +++ XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/drivers/neomagic/Imakefile     Thu Apr  4 16:05:44 2002
3 @@ -2,12 +2,12 @@
4  #define IHaveModules
5  #include <Server.tmpl>
6  
7  
8  SRCS = neo_driver.c neo_bank.c neo_cursor.c neo_2097.c neo_2070.c \
9 -       neo_2090.c neo_2200.c neo_i2c.c neo_shadow.c neo_dga.c
10 +       neo_2090.c neo_2200.c neo_i2c.c neo_shadow.c neo_dga.c neo_video.c
11  
12  OBJS = neo_driver.o neo_bank.o neo_cursor.o neo_2097.o neo_2070.o \
13 -       neo_2090.o neo_2200.o neo_i2c.o neo_shadow.o neo_dga.o
14 +       neo_2090.o neo_2200.o neo_i2c.o neo_shadow.o neo_dga.o neo_video.o
15  
16  DEFINES = -DPSZ=8
17  
18 --- XFree86-4.2.0/xc.orig/programs/Xserver/hw/xfree86/drivers/neomagic/NM-reg.txt       Thu Jan  1 01:00:00 1970
19 +++ XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/drivers/neomagic/NM-reg.txt    Thu Apr  4 16:05:44 2002
20 @@ -0,0 +1,69 @@
21 +NM2160 Register GUESS  
22 +   --- Overlay and ZV capture ---
23 +
24 +2002,2.3.
25 +
26 +1. Overlay
27 +  GRB0  bit5    Format; 0:YUY2/1:RGB
28 +        bit1    1
29 +        bit0    Enable overlay ; 1:enable/0:disable
30 +  GRB1  bit7:4  X2[11:8]
31 +        bit3:0  X1[11:8]
32 +  GRB2          X1[7:0]
33 +  GRB3          X2[7:0]
34 +  GRB4  bit7:4  Y2[11:8]
35 +        bit3:0  Y1[11:8]
36 +  GRB5          Y1[7:0]
37 +  GRB6          Y2[7:0]
38 +  GRB7          VRAM offset[24:17]
39 +  GRB8          VRAM offset[16:9]
40 +  GRB9          VRAM offset[8:1]
41 +  GRBA          Width in byte[15:8]
42 +  GRBB          Width in byte[7:0]
43 +  GRBC          0x4f
44 +  GRBD          -
45 +  GRBE          -
46 +  GRBF  bit2    0:normal/1:mirror
47 +        bit1:0  b'10'
48 +  GRC0          X scale[15:8] ; x1.0 == 0x1000
49 +  GRC1          X scale[7:0]
50 +  GRC2          Y scale[15:8] ; x1.0 == 0x1000
51 +  GRC3          Y scale[7:0]
52 +  GRC4          brightness   ; -128 to +127
53 +  GRC5          Color key(R)
54 +  GRC6          Color key(G) / Color key(8bpp)
55 +  GRC7          Color key(B)
56 +
57 +2. ZV capture
58 +  GR0A  bit5    Enable extended SR reg. ; 1:enable/0:disable
59 +        bit0    1
60 +
61 +  SR08  bit7:1  b'1010000'
62 +        bit0    Enable capture ; 1:enable/0:disable
63 +  SR09          0x11
64 +  SR0A          0x00
65 +  SR0B          -
66 +  SR0C          VRAM offset[8:1]
67 +  SR0D          VRAM offset[16:9]
68 +  SR0E          VRAM offset[24:17]
69 +  SR0F          -
70 +  SR10          -
71 +  SR11          -
72 +  SR12          -
73 +  SR13          -
74 +  SR14          Y1[7:0]
75 +  SR15          Y2[7:0]
76 +  SR16  bit7:4  Y2[11:4]
77 +        bit3:0  Y1[11:4]
78 +  SR17          X1[7:0]
79 +  SR18          X2[7:0]
80 +  SR19  bit7:4  X2[11:8]
81 +        bit3:0  X1[11:8]
82 +  SR1A          Width in byte[7:0]
83 +  SR1B          Width in byte[15:8]
84 +  SR1C          0xfb
85 +  SR1D          0x00
86 +  SR1E          0xe2
87 +  SR1F          0x02
88 +
89 +s.nomura@mba.nifty.ne.jp
90 --- XFree86-4.2.0/xc.orig/programs/Xserver/hw/xfree86/drivers/neomagic/neo.h    Mon Oct  1 15:44:07 2001
91 +++ XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo.h Thu Apr  4 16:05:44 2002
92 @@ -60,6 +60,11 @@
93  
94  #include "xf86i2c.h"
95  
96 +#ifdef XvExtension
97 +# include "xf86xv.h"
98 +# include "Xv.h"
99 +#endif /* XvExtension */
100 +
101  /*
102   * Driver data structures.
103   */
104 @@ -121,6 +126,10 @@
105  /* in neo_dga.c */
106  Bool NEODGAInit(ScreenPtr pScreen);
107  
108 +/* in neo_video.c */
109 +extern void NEOInitVideo(ScreenPtr pScreen);
110 +extern void NEOResetVideo(ScrnInfoPtr pScrn);
111 +
112  /* shadow regs */
113  
114  #define NEO_EXT_CR_MAX 0x85
115 @@ -199,6 +208,8 @@
116      unsigned long NeoMMIOAddr;
117      unsigned long NeoLinearAddr;
118      unsigned char* NeoMMIOBase;
119 +    unsigned long NeoMMIOAddr2;
120 +    unsigned char* NeoMMIOBase2;
121      unsigned char* NeoFbBase;
122      long NeoFbMapSize;
123      unsigned long vgaIOBase;
124 @@ -249,6 +260,17 @@
125      RefreshAreaFuncPtr refreshArea;
126      void       (*PointerMoved)(int index, int x, int y);
127      int rotate;
128 +    Bool showcache;
129 +#ifdef XvExtension
130 +    Bool video;
131 +    double videoHZoom;
132 +    double videoVZoom;
133 +    XF86VideoAdaptorPtr overlayAdaptor;
134 +    int overlay;
135 +    int overlay_offset;
136 +    int videoKey;
137 +    int interlace;
138 +#endif /* XvExtension */
139  } NEORec, *NEOPtr;
140  
141  typedef struct {
142 @@ -264,18 +286,20 @@
143  #define GRAX   0x3CE
144  
145  /* vga IO functions */
146 -#define VGArCR(index) hwp->readCrtc(hwp,index)
147 -#define VGAwCR(index,val) hwp->writeCrtc(hwp,index,val)
148 -#define VGArGR(index) hwp->readGr(hwp,index)
149 -#define VGAwGR(index,val) hwp->writeGr(hwp,index,val)
150 +#define VGArCR(index)          (*hwp->readCrtc)(hwp, index)
151 +#define VGAwCR(index, val)     (*hwp->writeCrtc)(hwp, index, val)
152 +#define VGArGR(index)          (*hwp->readGr)(hwp, index)
153 +#define VGAwGR(index, val)     (*hwp->writeGr)(hwp, index, val)
154 +#define VGArSR(index)          (*hwp->readSeq)(hwp, index)
155 +#define VGAwSR(index, val)     (*hwp->writeSeq)(hwp, index, val)
156  
157  /* memory mapped register access macros */
158 -#define INREG8(addr) MMIO_IN8(nPtr->NeoMMIOBase, (addr))
159 -#define INREG16(addr) MMIO_IN16(nPtr->NeoMMIOBase, (addr))
160 -#define INREG(addr) MMIO_IN32(nPtr->NeoMMIOBase, (addr))
161 -#define OUTREG8(addr, val) MMIO_OUT8(nPtr->NeoMMIOBase, (addr), (val))
162 -#define OUTREG16(addr, val) MMIO_OUT16(nPtr->NeoMMIOBase, (addr), (val))
163 -#define OUTREG(addr, val) MMIO_OUT32(nPtr->NeoMMIOBase, (addr), (val))
164 +#define INREG8(addr)           MMIO_IN8(nPtr->NeoMMIOBase, addr)
165 +#define INREG16(addr)          MMIO_IN16(nPtr->NeoMMIOBase, addr)
166 +#define INREG(addr)            MMIO_IN32(nPtr->NeoMMIOBase, addr)
167 +#define OUTREG8(addr, val)     MMIO_OUT8(nPtr->NeoMMIOBase, addr, val)
168 +#define OUTREG16(addr, val)    MMIO_OUT16(nPtr->NeoMMIOBase, addr, val)
169 +#define OUTREG(addr, val)      MMIO_OUT32(nPtr->NeoMMIOBase, addr, val)
170  
171  /* This swizzle macro is to support the manipulation of cursor masks when
172   * the sprite moves off the left edge of the display.  This code is
173 --- XFree86-4.2.0/xc.orig/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2070.c       Tue Sep 26 01:57:08 2000
174 +++ XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2070.c    Thu Apr  4 16:05:44 2002
175 @@ -104,8 +104,6 @@
176      ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
177      NEOPtr nPtr = NEOPTR(pScrn);
178      NEOACLPtr nAcl = NEOACLPTR(pScrn);
179 -    BoxRec AvailFBArea;
180 -    int lines;
181  
182      nPtr->AccelInfoRec = infoPtr = XAACreateInfoRec();
183      if(!infoPtr) return FALSE;
184 @@ -158,23 +156,7 @@
185      default:
186         return FALSE;
187      }
188 -
189 -    /* Initialize for widths */
190 -    nAcl->Pitch = pScrn->displayWidth * nAcl->PixelWidth;
191 -    lines = nAcl->cacheEnd /
192 -      (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3));
193 -    if(lines > 1024) lines = 1024;
194 -
195 -    AvailFBArea.x1 = 0;
196 -    AvailFBArea.y1 = 0;
197 -    AvailFBArea.x2 = pScrn->displayWidth;
198 -    AvailFBArea.y2 = lines;
199 -    xf86InitFBManager(pScreen, &AvailFBArea); 
200 -
201 -    xf86DrvMsg(pScrn->scrnIndex, X_INFO, 
202 -               "Using %i scanlines of offscreen memory for pixmap caching\n",
203 -                lines - pScrn->virtualY);
204 -
205 +    
206      return(XAAInit(pScreen, infoPtr));
207  
208  }
209 --- XFree86-4.2.0/xc.orig/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2090.c       Mon Oct  1 15:44:07 2001
210 +++ XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2090.c    Thu Apr  4 16:05:44 2002
211 @@ -101,8 +101,6 @@
212      ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
213      NEOPtr nPtr = NEOPTR(pScrn);
214      NEOACLPtr nAcl = NEOACLPTR(pScrn);
215 -    BoxRec AvailFBArea;
216 -    int lines;
217  
218      nPtr->AccelInfoRec = infoPtr = XAACreateInfoRec();
219      if(!infoPtr) return FALSE;
220 @@ -197,20 +195,6 @@
221  
222      nAcl->BltCntlFlags |= NEO_BC3_FIFO_EN;
223  
224 -    lines =  nAcl->cacheEnd /
225 -      (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3));
226 -    if(lines > 1024) lines = 1024;
227 -
228 -    AvailFBArea.x1 = 0;
229 -    AvailFBArea.y1 = 0;
230 -    AvailFBArea.x2 = pScrn->displayWidth;
231 -    AvailFBArea.y2 = lines;
232 -    xf86InitFBManager(pScreen, &AvailFBArea); 
233 -
234 -    xf86DrvMsg(pScrn->scrnIndex, X_INFO, 
235 -               "Using %i scanlines of offscreen memory for pixmap caching\n",
236 -                lines - pScrn->virtualY);
237 -
238      return(XAAInit(pScreen, infoPtr));
239  }
240  
241 --- XFree86-4.2.0/xc.orig/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2097.c       Mon Oct  1 15:44:07 2001
242 +++ XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2097.c    Thu Apr  4 16:05:44 2002
243 @@ -123,8 +123,6 @@
244      ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
245      NEOPtr nPtr = NEOPTR(pScrn);
246      NEOACLPtr nAcl = NEOACLPTR(pScrn);
247 -    int lines;
248 -    BoxRec AvailFBArea;
249  
250      nPtr->AccelInfoRec = infoPtr = XAACreateInfoRec();
251      if(!infoPtr) return FALSE;
252 @@ -245,21 +243,7 @@
253      default:
254         return FALSE;
255      }
256 -
257 -    lines =  nAcl->cacheEnd /
258 -      (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3));
259 -    if(lines > 1024) lines = 1024;
260 -
261 -    AvailFBArea.x1 = 0;
262 -    AvailFBArea.y1 = 0;
263 -    AvailFBArea.x2 = pScrn->displayWidth;
264 -    AvailFBArea.y2 = lines;
265 -    xf86InitFBManager(pScreen, &AvailFBArea); 
266 -
267 -    xf86DrvMsg(pScrn->scrnIndex, X_INFO, 
268 -               "Using %i scanlines of offscreen memory for pixmap caching\n",
269 -               lines - pScrn->virtualY);
270 -
271 +    
272      return(XAAInit(pScreen, infoPtr));
273  }
274  
275 --- XFree86-4.2.0/xc.orig/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2200.c       Sun Oct 28 04:33:42 2001
276 +++ XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2200.c    Thu Apr  4 16:05:44 2002
277 @@ -120,8 +120,6 @@
278      ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
279      NEOPtr nPtr = NEOPTR(pScrn);
280      NEOACLPtr nAcl = NEOACLPTR(pScrn);
281 -    BoxRec AvailFBArea;
282 -    int lines;
283  
284      nPtr->AccelInfoRec = infoPtr = XAACreateInfoRec();
285      if(!infoPtr) return FALSE;
286 @@ -251,19 +249,6 @@
287         return FALSE;
288      }
289  
290 -    lines =  nAcl->cacheEnd /
291 -      (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3));
292 -    if(lines > 1024) lines = 1024;
293 -
294 -    AvailFBArea.x1 = 0;
295 -    AvailFBArea.y1 = 0;
296 -    AvailFBArea.x2 = pScrn->displayWidth;
297 -    AvailFBArea.y2 = lines;
298 -    xf86InitFBManager(pScreen, &AvailFBArea); 
299 -
300 -    xf86DrvMsg(pScrn->scrnIndex, X_INFO, 
301 -               "Using %i scanlines of offscreen memory for pixmap caching\n",
302 -                lines - pScrn->virtualY);
303  
304      return(XAAInit(pScreen, infoPtr));
305  }
306 @@ -482,7 +467,7 @@
307      NEOPtr nPtr = NEOPTR(pScrn);
308  
309      WAIT_ENGINE_IDLE();
310 -    OUTREG(NEOREG_DSTSTARTOFF, (y<<16) | (x & 0xffff));
311 +    OUTREG(NEOREG_DSTSTARTOFF, (y <<16) | (x & 0xffff));
312      OUTREG(NEOREG_XYEXT, (h<<16) | (w & 0xffff));
313  }
314  
315 --- XFree86-4.2.0/xc.orig/programs/Xserver/hw/xfree86/drivers/neomagic/neo_dga.c        Mon Oct  1 15:44:07 2001
316 +++ XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_dga.c     Thu Apr  4 16:05:44 2002
317 @@ -43,8 +43,10 @@
318  static void NEO_SetViewport(ScrnInfoPtr, int, int, int);
319  static void NEO_FillRect(ScrnInfoPtr, int, int, int, int, unsigned long);
320  static void NEO_BlitRect(ScrnInfoPtr, int, int, int, int, int, int);
321 +#if 0
322  static void NEO_BlitTransRect(ScrnInfoPtr, int, int, int, int, int, int, 
323                                         unsigned long);
324 +#endif
325  
326  static
327  DGAFunctionRec NEODGAFuncs = {
328 @@ -76,7 +78,7 @@
329     imlines =  (pScrn->videoRam * 1024) /
330        (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3));
331  
332 -   pixlines = (imlines > 1024 && !pNEO->noAccel)  ? 1024 : imlines;
333 +   pixlines =  (imlines > 1024 && !pNEO->noAccel)  ? 1024 : imlines;
334  
335     pMode = firstMode = pScrn->modes;
336  
337 @@ -184,7 +186,7 @@
338  ){
339     NEOPtr pNEO = NEOPTR(pScrn);
340     vgaHWPtr hwp = VGAHWPTR(pScrn);
341 -
342 +   
343     NEOAdjustFrame(pScrn->pScreen->myNum, x, y, flags);
344     /* wait for retrace */
345     while((hwp->readST01(hwp) & 0x08));
346 @@ -240,7 +242,7 @@
347      }
348  }
349  
350 -
351 +#if 0
352  static void 
353  NEO_BlitTransRect(
354     ScrnInfoPtr pScrn, 
355 @@ -252,7 +254,7 @@
356    /* this one should be separate since the XAA function would
357       prohibit usage of ~0 as the key */
358  }
359 -
360 +#endif
361  
362  static Bool 
363  NEO_OpenFramebuffer(
364 --- XFree86-4.2.0/xc.orig/programs/Xserver/hw/xfree86/drivers/neomagic/neo_driver.c     Fri Nov 30 13:11:57 2001
365 +++ XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_driver.c  Sat Apr  6 19:49:40 2002
366 @@ -299,7 +307,11 @@
367      OPTION_PROG_LCD_MODE_REGS,
368      OPTION_PROG_LCD_MODE_STRETCH,
369      OPTION_OVERRIDE_VALIDATE_MODE,
370 +    OPTION_SHOWCACHE,
371      OPTION_ROTATE,
372 +    OPTION_VIDEO_KEY,
373 +    OPTION_OVERLAYMEM,
374 +    OPTION_VIDEO_INTERLACE,
375      OPTION_DISPLAY_HEIGHT_480,
376      OPTION_STRANGE_LOCKUPS
377  } NEOOpts;
378 @@ -314,6 +326,7 @@
379      { OPTION_LCD_STRETCH, "NoStretch", OPTV_BOOLEAN,   {0}, FALSE },
380      { OPTION_SHADOW_FB,   "ShadowFB",  OPTV_BOOLEAN,   {0}, FALSE },
381      { OPTION_PCI_BURST,         "pciBurst",    OPTV_BOOLEAN,   {0}, FALSE },
382 +    { OPTION_SHOWCACHE,  "ShowCache",   OPTV_BOOLEAN,  {0}, FALSE },
383      { OPTION_ROTATE,    "Rotate",      OPTV_ANYSTR,    {0}, FALSE },
384      { OPTION_PROG_LCD_MODE_REGS, "progLcdModeRegs",
385        OPTV_BOOLEAN, {0}, FALSE },
386 @@ -321,6 +334,10 @@
387        OPTV_BOOLEAN, {0}, FALSE },
388      { OPTION_OVERRIDE_VALIDATE_MODE, "overrideValidateMode",
389        OPTV_BOOLEAN, {0}, FALSE },
390 +    { OPTION_VIDEO_KEY, "VideoKey",     OPTV_INTEGER,   {0}, FALSE },
391 +    { OPTION_OVERLAYMEM, "OverlayMem",  OPTV_INTEGER,   {0}, FALSE },
392 +    { OPTION_VIDEO_INTERLACE, "Interlace",
393 +      OPTV_INTEGER,   {0}, FALSE },
394      { -1,                  NULL,           OPTV_NONE,  {0}, FALSE }
395  };
396  
397 @@ -335,6 +352,7 @@
398      { OPTION_SHADOW_FB,  "ShadowFB",   OPTV_BOOLEAN,   {0}, FALSE },
399      { OPTION_LCD_STRETCH,"NoStretch",  OPTV_BOOLEAN,   {0}, FALSE },
400      { OPTION_PCI_BURST,         "pciBurst",    OPTV_BOOLEAN,   {0}, FALSE },
401 +    { OPTION_SHOWCACHE,  "ShowCache",   OPTV_BOOLEAN,  {0}, FALSE },
402      { OPTION_ROTATE,    "Rotate",      OPTV_ANYSTR,    {0}, FALSE },
403      { OPTION_STRANGE_LOCKUPS, "StrangeLockups", OPTV_BOOLEAN, {0}, FALSE },
404      { OPTION_DISPLAY_HEIGHT_480, "DisplayHeight480",
405 @@ -345,6 +363,10 @@
406        OPTV_BOOLEAN, {0}, FALSE },
407      { OPTION_OVERRIDE_VALIDATE_MODE, "overrideValidateMode",
408        OPTV_BOOLEAN, {0}, FALSE },
409 +    { OPTION_VIDEO_KEY, "VideoKey",     OPTV_INTEGER,   {0}, FALSE },
410 +    { OPTION_OVERLAYMEM, "OverlayMem",  OPTV_INTEGER,   {0}, FALSE },
411 +    { OPTION_VIDEO_INTERLACE, "Interlace",
412 +      OPTV_INTEGER,   {0}, FALSE },
413      { -1,                  NULL,           OPTV_NONE,  {0}, FALSE }
414  };
415  
416 @@ -979,6 +1001,7 @@
417      xf86GetOptValBool(nPtr->Options, OPTION_LCD_CENTER,&nPtr->lcdCenter);
418      xf86GetOptValBool(nPtr->Options, OPTION_LCD_STRETCH,&nPtr->noLcdStretch);
419      xf86GetOptValBool(nPtr->Options, OPTION_SHADOW_FB,&nPtr->shadowFB);
420 +    xf86GetOptValBool(nPtr->Options, OPTION_SHOWCACHE,&nPtr->showcache);
421      nPtr->onPciBurst = TRUE;
422      xf86GetOptValBool(nPtr->Options, OPTION_PCI_BURST,&nPtr->onPciBurst);
423      xf86GetOptValBool(nPtr->Options,
424 @@ -1014,6 +1037,39 @@
425                        "Valid options are \"CW\" or \"CCW\"\n");
426        }
427      }
428 +#ifdef XvExtension
429 +    if(xf86GetOptValInteger(nPtr->Options,
430 +                           OPTION_VIDEO_KEY, &(nPtr->videoKey))) {
431 +        xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "video key set to 0x%x\n",
432 +                  nPtr->videoKey);
433 +    } else {
434 +        nPtr->videoKey = (1 << pScrn->offset.red) | 
435 +           (1 << pScrn->offset.green) |
436 +           (((pScrn->mask.blue >> pScrn->offset.blue) - 1)
437 +            << pScrn->offset.blue); 
438 +    }
439 +    if(xf86GetOptValInteger(nPtr->Options, OPTION_OVERLAYMEM,
440 +                           &(nPtr->overlay))) {
441 +        xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
442 +                  "reserve %d bytes for overlay.\n", nPtr->overlay);
443 +    } else {
444 +       nPtr->overlay = 0;
445 +    }
446 +    nPtr->interlace = 0;
447 +    if(xf86GetOptValInteger(nPtr->Options, OPTION_VIDEO_INTERLACE,
448 +                           &(nPtr->interlace))) {
449 +       if (nPtr->interlace >= 0  &&  nPtr->interlace <= 2){
450 +           xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "interlace flag = %d\n",
451 +                      nPtr->interlace);
452 +       } else {
453 +           xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
454 +                      "\"%s\" is not a valid value for "
455 +                      "Option \"Interlaced\"\n", s);
456 +           xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Valid options are  0..2\n");
457 +        }
458 +    }
459 +#endif /* XvExtension */
460 +
461  
462      if (height_480 && nPtr->NeoPanelWidth == 800) {
463         xf86DrvMsg(pScrn->scrnIndex,X_CONFIG,
464 @@ -1069,6 +1125,9 @@
465      if (nPtr->strangeLockups)
466         xf86DrvMsg(pScrn->scrnIndex,X_CONFIG,
467                    "Option StrangeLockups set: disabling some acceleration\n");
468 +    if (nPtr->showcache)
469 +       xf86DrvMsg(pScrn->scrnIndex,X_CONFIG,
470 +                  "Show chache for debugging\n");
471      if (nPtr->shadowFB) {
472         if (nPtr->noLinear) {
473             xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
474 @@ -1096,6 +1155,8 @@
475         nPtr->NeoLinearAddr = 0;
476      }
477  
478 +    nPtr->NeoMMIOAddr2 = 0;
479 +    nPtr->NeoMMIOBase2 = NULL;
480      if (nPtr->pEnt->device->IOBase && !nPtr->noMMIO) {
481         /* XXX Check this matches a PCI base address */
482         nPtr->NeoMMIOAddr = nPtr->pEnt->device->IOBase;
483 @@ -1113,7 +1174,7 @@
484                        "FB base address is set at 0x%X.\n",
485                        nPtr->NeoLinearAddr);
486         }
487 -       if (!nPtr->NeoMMIOAddr) {
488 +       if (!nPtr->NeoMMIOAddr && !nPtr->noMMIO) {
489             switch (nPtr->NeoChipset) {
490             case NM2070 :
491                 nPtr->NeoMMIOAddr = nPtr->NeoLinearAddr + 0x100000;
492 @@ -1129,11 +1190,17 @@
493             case NM2360:
494             case NM2380:
495                 nPtr->NeoMMIOAddr = nPtr->PciInfo->memBase[1];
496 +               nPtr->NeoMMIOAddr2 = nPtr->PciInfo->memBase[2];
497                 break;
498             }
499             xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
500                        "MMIO base address is set at 0x%X.\n",
501                        nPtr->NeoMMIOAddr);
502 +           if (nPtr->NeoMMIOAddr2 != 0){
503 +               xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
504 +                          "MMIO base address2 is set at 0x%X.\n",
505 +                          nPtr->NeoMMIOAddr2);
506 +           }
507         }
508         /* XXX What about VGA resources in OPERATING mode? */
509         if (xf86RegisterResources(nPtr->pEnt->index, NULL, ResExclusive))
510 @@ -1152,7 +1219,7 @@
511                        "FB base address is set at 0x%X.\n",
512                        nPtr->NeoLinearAddr);
513         }
514 -       if (!nPtr->NeoMMIOAddr) {
515 +       if (!nPtr->NeoMMIOAddr && !nPtr->noMMIO) {
516             nPtr->NeoMMIOAddr = nPtr->NeoLinearAddr + 0x100000;
517             xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
518                        "MMIO base address is set at 0x%X.\n",
519 @@ -1293,6 +1360,10 @@
520      /* Should we re-save the text mode on each VT enter? */
521      if(!neoModeInit(pScrn, pScrn->currentMode))
522        return FALSE;
523 +#ifdef XvExtension
524 +    if (nPtr->video)
525 +       NEOResetVideo(pScrn);
526 +#endif
527      if (nPtr->NeoHWCursorShown) 
528         NeoShowCursor(pScrn);
529      NEOAdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);    
530 @@ -1384,12 +1455,12 @@
531      /* Map the Neo memory and possible MMIO areas */
532      if (!neoMapMem(pScrn))
533         return FALSE;
534 -
535 +    
536      /*
537       * next we save the current state and setup the first mode
538       */
539      neoSave(pScrn);
540 -
541 +    
542      if (!neoModeInit(pScrn,pScrn->currentMode))
543         return FALSE;
544      vgaHWSaveScreen(pScreen,SCREEN_SAVER_ON);
545 @@ -1431,7 +1502,7 @@
546         nPtr->ShadowPtr = NULL;
547         FBStart = nPtr->NeoFbBase;
548      }
549 -
550 +    
551      ret = fbScreenInit(pScreen, FBStart,
552                             width, height,
553                             pScrn->xDpi, pScrn->yDpi,
554 @@ -1509,13 +1580,13 @@
555                    nPtr->NeoLinearAddr);
556         /* Setup pointers to free space in video ram */
557         allocatebase = (pScrn->videoRam << 10);
558 -       freespace = allocatebase - pScrn->displayWidth * 
559 +       freespace = allocatebase - pScrn->displayWidth *
560             pScrn->virtualY * (pScrn->bitsPerPixel >> 3);
561         currentaddr = allocatebase;
562         xf86DrvMsg(scrnIndex, X_PROBED,
563                    "%d bytes off-screen memory available\n", freespace);
564  
565 -       if (nPtr->swCursor || nPtr->noMMIO) {
566 +       if (nPtr->swCursor || !nPtr->NeoMMIOBase) {
567             xf86DrvMsg(scrnIndex, X_CONFIG,
568                        "Using Software Cursor.\n");
569         } else if (nPtr->NeoCursorMem <= freespace) {
570 @@ -1530,19 +1601,52 @@
571         } else xf86DrvMsg(scrnIndex, X_ERROR,
572                           "Too little space for H/W cursor.\n");
573         
574 -       if (!nPtr->noAccel && nPtr->noMMIO)
575 +       if (!nPtr->noAccel && !nPtr->NeoMMIOBase)
576           xf86DrvMsg(pScrn->scrnIndex,X_INFO,
577                      "Acceleration disabled when not using MMIO\n");
578 -
579 -       /* Setup the acceleration primitives */
580 -       if (!nPtr->noAccel && !nPtr->noMMIO) {
581 +       {
582 +#ifdef XvExtension
583 +           if (nPtr->overlay > 0){
584 +               if (nPtr->overlay > freespace){
585 +                   xf86DrvMsg(pScrn->scrnIndex,X_INFO,
586 +                              "Can not reserve %d bytes for overlay. "
587 +                              "Resize to %d bytes.\n",
588 +                              nPtr->overlay, freespace);
589 +                   nPtr->overlay = freespace;
590 +               }
591 +               currentaddr -= nPtr->overlay;
592 +               freespace -= nPtr->overlay;
593 +               nPtr->overlay_offset = currentaddr;
594 +               xf86DrvMsg(pScrn->scrnIndex,X_INFO,"Overlay at 0x%x\n",
595 +                          nPtr->overlay_offset);
596 +           }
597 +#endif /* XvExtension */
598             nAcl->cacheStart = currentaddr - freespace;
599             nAcl->cacheEnd = currentaddr;
600             freespace = 0;
601 +           if (nAcl->cacheStart < nAcl->cacheEnd) {
602 +               BoxRec AvailFBArea;
603 +               int lines = nAcl->cacheEnd /
604 +                   (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3));
605 +               if (!nPtr->noAccel && nPtr->NeoMMIOBase && lines > 1024) 
606 +                   lines = 1024;
607 +               AvailFBArea.x1 = 0;
608 +               AvailFBArea.y1 = 0;
609 +               AvailFBArea.x2 = pScrn->displayWidth;
610 +               AvailFBArea.y2 = lines;
611 +               xf86InitFBManager(pScreen, &AvailFBArea); 
612 +
613 +               xf86DrvMsg(pScrn->scrnIndex, X_INFO, 
614 +                          "Using %i scanlines of offscreen memory \n"
615 +                          , lines - pScrn->virtualY);
616 +           }
617 +       }
618 +       /* Setup the acceleration primitives */
619 +       if (!nPtr->noAccel && nPtr->NeoMMIOBase) {
620             if (nAcl->cacheStart >= nAcl->cacheEnd) {
621                 xf86DrvMsg(scrnIndex, X_ERROR,
622                            "Too little space for pixmap cache.\n");
623 -           }
624 +           }       
625             switch(nPtr->NeoChipset) {
626             case NM2070 :
627                 Neo2070AccelInit(pScreen);
628 @@ -1624,6 +1728,8 @@
629  
630      pScrn->racIoFlags = pScrn->racMemFlags = racflag;
631  
632 +    NEOInitVideo(pScreen);
633 +
634      pScreen->SaveScreen = vgaHWSaveScreen;
635  
636      /* Setup DPMS mode */
637 @@ -1635,18 +1741,7 @@
638          pScrn->memPhysBase = (unsigned long)nPtr->NeoFbBase;
639         pScrn->fbOffset = 0;
640      }
641 -
642 -#ifdef XvExtension
643 -    {
644 -        XF86VideoAdaptorPtr *ptr;
645 -       int n;
646 -       
647 -       n = xf86XVListGenericAdaptors(pScrn,&ptr);
648 -       if (n)
649 -           xf86XVScreenInit(pScreen, ptr, n);
650 -    }
651 -#endif
652 -
653 +    
654      /* Wrap the current CloseScreen function */
655      nPtr->CloseScreen = pScreen->CloseScreen;
656      pScreen->CloseScreen = NEOCloseScreen;
657 @@ -1677,11 +1772,21 @@
658      int Base; 
659  
660      pScrn = xf86Screens[scrnIndex];
661 -    Base = (y * pScrn->displayWidth + x) >> 2;
662      hwp = VGAHWPTR(pScrn);
663      nPtr = NEOPTR(pScrn);
664 -    /* Scale Base by the number of bytes per pixel. */
665  
666 +    if (nPtr->showcache && y) {
667 +       int lastline = nPtr->NeoFbMapSize / 
668 +           ((pScrn->displayWidth * pScrn->bitsPerPixel) / 8);
669 +       
670 +       lastline -= pScrn->currentMode->VDisplay;
671 +       y += pScrn->virtualY - 1;
672 +        if (y > lastline) y = lastline;
673 +    }
674 +
675 +    Base = (y * pScrn->displayWidth + x) >> 2;
676 +
677 +    /* Scale Base by the number of bytes per pixel. */
678      switch (pScrn->depth) {
679      case  8 :
680         break;
681 @@ -1730,6 +1835,7 @@
682         if (nPtr->NeoHWCursorShown)
683             NeoHideCursor(pScrn);
684         neoRestore(pScrn, &(VGAHWPTR(pScrn))->SavedReg, &nPtr->NeoSavedReg, TRUE);
685 +
686         neoLock(pScrn);
687         neoUnmapMem(pScrn);
688      }
689 @@ -1845,12 +1951,18 @@
690  
691      if (!nPtr->noLinear) {
692         if (!nPtr->noMMIO) {
693 -           if (nPtr->pEnt->location.type == BUS_PCI)
694 +           if (nPtr->pEnt->location.type == BUS_PCI){
695                 nPtr->NeoMMIOBase =
696                     xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO,
697                                   nPtr->PciTag, nPtr->NeoMMIOAddr,
698                                   0x200000L);
699 -           else
700 +               if (nPtr->NeoMMIOAddr2 != 0){
701 +                   nPtr->NeoMMIOBase2 =
702 +                       xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO,
703 +                                     nPtr->PciTag, nPtr->NeoMMIOAddr2,
704 +                                     0x100000L);
705 +               }
706 +           } else
707                 nPtr->NeoMMIOBase =
708                     xf86MapVidMem(pScrn->scrnIndex,
709                                   VIDMEM_MMIO, nPtr->NeoMMIOAddr,
710 @@ -1889,8 +2001,14 @@
711      NEOPtr nPtr = NEOPTR(pScrn);
712  
713      if (!nPtr->noLinear) {
714 -      xf86UnMapVidMem(pScrn->scrnIndex, (pointer)nPtr->NeoMMIOBase, 0x200000L);
715 +      if (nPtr->NeoMMIOBase)
716 +         xf86UnMapVidMem(pScrn->scrnIndex, (pointer)nPtr->NeoMMIOBase,
717 +                         0x200000L);
718        nPtr->NeoMMIOBase = NULL;
719 +      if (nPtr->NeoMMIOBase2)
720 +         xf86UnMapVidMem(pScrn->scrnIndex, (pointer)nPtr->NeoMMIOBase2,
721 +                         0x100000L);
722 +      nPtr->NeoMMIOBase2 = NULL;
723        xf86UnMapVidMem(pScrn->scrnIndex, (pointer)nPtr->NeoFbBase,
724                     nPtr->NeoFbMapSize); 
725      }
726 @@ -2200,7 +2318,7 @@
727      unsigned char temp;
728      int i;
729      Bool clock_hi = FALSE;
730 -    
731 +
732      vgaHWProtect(pScrn,TRUE);          /* Blank the screen */
733      
734      VGAwGR(0x09,0x26);
735 @@ -2220,6 +2338,7 @@
736       * any reserved bits.
737       */
738      temp = VGArGR(0x90);
739 +
740      switch (nPtr->NeoChipset) {
741      case NM2070 :
742         temp &= 0xF0; /* Save bits 7:4 */
743 @@ -2238,6 +2357,7 @@
744         break;
745      }
746      VGAwGR(0x90,temp);
747 +
748      /*
749       * In some rare cases a lockup might occur if we don't delay
750       * here. (Reported by Miles Lane)
751 @@ -2256,7 +2376,6 @@
752       * had time to take effect.
753       */
754      xf86UDelay(200000);
755 -
756      /*
757       * This function handles restoring the generic VGA registers.  */
758      vgaHWRestore(pScrn, VgaReg,
759 @@ -2273,6 +2392,7 @@
760      VGAwGR(0x11, restore->SysIfaceCntl2);
761      VGAwGR(0x15, restore->SingleAddrPage);
762      VGAwGR(0x16, restore->DualAddrPage);
763 +
764      temp = VGArGR(0x20);
765      switch (nPtr->NeoChipset) {
766      case NM2070 :
767 @@ -2349,7 +2469,7 @@
768      }
769      if (restore->biosMode)
770         VGAwCR(0x23,restore->biosMode);
771 -    
772 +
773      if (restore->reg) {
774         VGAwCR(0x23,restore->reg->CR[0x23]);
775         VGAwCR(0x25,restore->reg->CR[0x25]);
776 @@ -2371,13 +2491,13 @@
777             VGAwGR(i, restore->reg->GR[i]);
778         }
779      }
780 +
781      /* Program vertical extension register */
782      if (nPtr->NeoChipset == NM2200 || nPtr->NeoChipset == NM2230
783         || nPtr->NeoChipset == NM2360 || nPtr->NeoChipset == NM2380) {
784         VGAwCR(0x70, restore->VerticalExt);
785      }
786 -
787 -
788 +    
789      vgaHWProtect(pScrn, FALSE);                /* Turn on screen */
790  
791  }
792 @@ -2574,7 +2694,7 @@
793      NeoNew->PanelHorizCenterReg3 = 0x00;
794      NeoNew->PanelHorizCenterReg4 = 0x00;
795      NeoNew->PanelHorizCenterReg5 = 0x00;
796 -
797 +    
798      if (nPtr->lcdCenter &&
799         (NeoNew->PanelDispCntlReg1 & 0x02)) {
800         if (mode->HDisplay == nPtr->NeoPanelWidth) {
801 @@ -2632,6 +2752,18 @@
802             }
803         }
804      }
805 +#ifdef XvExtension
806 +    if (!noLcdStretch)  {
807 +       if (mode->HDisplay != nPtr->NeoPanelWidth)
808 +           nPtr->videoHZoom = (double)nPtr->NeoPanelWidth/mode->HDisplay;
809 +       if (mode->VDisplay != nPtr->NeoPanelHeight)
810 +           nPtr->videoVZoom = (double)nPtr->NeoPanelHeight/mode->VDisplay;
811 +    } else {
812 +       nPtr->videoHZoom = 1.0;
813 +       nPtr->videoVZoom = 1.0;
814 +    }
815 +#endif
816 +    
817      NeoNew->biosMode = neoFindMode(mode->HDisplay,mode->VDisplay,pScrn->depth);
818      
819      /*
820 @@ -2764,9 +2896,8 @@
821      }
822  
823      /* Turn the screen on/off */
824 -    outb(0x3C4, 0x01);
825 -    SEQ01 |= inb(0x3C5) & ~0x20;
826 -    outb(0x3C5, SEQ01);
827 +    SEQ01 |= VGArSR(0x01) & ~0x20;
828 +    VGAwSR(0x01, SEQ01);
829  
830      /* Turn the LCD on/off */
831      LCD_on |= VGArGR(0x20) & ~0x02;
832 --- XFree86-4.2.0/xc.orig/programs/Xserver/hw/xfree86/drivers/neomagic/neo_video.c      Thu Jan  1 01:00:00 1970
833 +++ XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_video.c   Thu Apr  4 16:05:44 2002
834 @@ -0,0 +1,1232 @@
835 +/**********************************************************************
836 +Copyright 2002 by Shigehiro Nomura.
837 +
838 +                        All Rights Reserved
839 +
840 +Permission to use, copy, modify, distribute, and sell this software and
841 +its documentation for any purpose is hereby granted without fee,
842 +provided that the above copyright notice appear in all copies and that
843 +both that copyright notice and this permission notice appear in
844 +supporting documentation, and that the name of Shigehiro Nomura not be
845 +used in advertising or publicity pertaining to distribution of the
846 +software without specific, written prior permission.  Shigehiro Nomura
847 +and its suppliers make no representations about the suitability of this
848 +software for any purpose.  It is provided "as is" without express or 
849 +implied warranty.
850 +
851 +SHIGEHIRO NOMURA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
852 +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
853 +EVENT SHALL SHIGEHIRO NOMURA AND/OR ITS SUPPLIERS BE LIABLE FOR ANY
854 +SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
855 +RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
856 +CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
857 +CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
858 +**********************************************************************/
859 +
860 +/*
861 + * Copyright 2002 SuSE Linux AG, Author: Egbert Eich
862 + */
863 +
864 +#include "neo.h"
865 +#include "neo_video.h"
866 +
867 +#define nElems(x)              (sizeof(x) / sizeof(x[0]))
868 +#define MAKE_ATOM(a)   MakeAtom(a, sizeof(a) - 1, TRUE)
869 +
870 +#if defined(XvExtension)
871 +
872 +#include "dixstruct.h"
873 +#include "xaa.h"
874 +#include "xaalocal.h"
875 +
876 +static XF86VideoAdaptorPtr NEOSetupVideo(ScreenPtr);
877 +
878 +static int NEOPutVideo(ScrnInfoPtr, short, short, short, short, 
879 +                      short, short, short, short, RegionPtr, pointer);
880 +
881 +static void NEOStopVideo(ScrnInfoPtr, pointer, Bool);
882 +static int NEOSetPortAttribute(ScrnInfoPtr, Atom, INT32, pointer);
883 +static int NEOGetPortAttribute(ScrnInfoPtr, Atom, INT32 *, pointer);
884 +static void NEOQueryBestSize(ScrnInfoPtr, Bool, short, short, short, 
885 +                            short, unsigned int *, unsigned int *, pointer);
886 +static int NEOPutImage(ScrnInfoPtr, short, short, short, short, short, short, 
887 +                      short, short, int, unsigned char *, short, short, Bool,
888 +                      RegionPtr, pointer);
889 +static int NEOQueryImageAttributes(ScrnInfoPtr, int, unsigned short *, 
890 +                                  unsigned short *, int *, int *);
891 +
892 +static Bool RegionsEqual(RegionPtr, RegionPtr);
893 +static void NEODisplayVideo(ScrnInfoPtr, int, int, short, short, int, int, 
894 +                           int, int, int, BoxPtr, short, short, short, short);
895 +
896 +static void NEOInitOffscreenImages(ScreenPtr);
897 +static FBLinearPtr NEOAllocateMemory(ScrnInfoPtr, FBLinearPtr, int);
898 +static void NEOCopyData(unsigned char *, unsigned char *, int, int, int, int);
899 +static void NEOCopyYV12Data(unsigned char *, unsigned char *, unsigned char *,
900 +                           unsigned char *, int, int, int, int, int);
901 +
902 +static int NEOAllocSurface(ScrnInfoPtr, int, unsigned short, unsigned short, 
903 +                          XF86SurfacePtr);
904 +static int NEOFreeSurface(XF86SurfacePtr);
905 +static int NEODisplaySurface(XF86SurfacePtr, short, short, short, short, 
906 +                            short, short, short, short, RegionPtr clipBoxes);
907 +static int NEOStopSurface(XF86SurfacePtr);
908 +static int NEOGetSurfaceAttribute(ScrnInfoPtr, Atom, INT32 *);
909 +static int NEOSetSurfaceAttribute(ScrnInfoPtr, Atom, INT32);
910 +
911 +static Atom xvColorKey, xvBrightness, xvInterlace;
912 +
913 +void
914 +NEOInitVideo(ScreenPtr pScreen)
915 +{
916 +    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
917 +    NEOPtr nPtr = NEOPTR(pScrn);
918 +    XF86VideoAdaptorPtr *overlayAdaptors, *newAdaptors = NULL;
919 +    XF86VideoAdaptorPtr newAdaptor = NULL;
920 +    int numAdaptors;
921 +
922 +    numAdaptors = xf86XVListGenericAdaptors(pScrn, &overlayAdaptors);
923 +
924 +    if (nPtr->NeoChipset >= NM2160 
925 +       && !nPtr->noLinear 
926 +       && nPtr->NeoMMIOBase2 != NULL){
927 +       nPtr->video = TRUE;
928 +       newAdaptor = NEOSetupVideo(pScreen);
929 +       NEOInitOffscreenImages(pScreen);
930 +    } else
931 +       nPtr->video = FALSE;
932 +
933 +    if (newAdaptor){
934 +       if (!numAdaptors){
935 +           numAdaptors = 1;
936 +           overlayAdaptors = &newAdaptor;
937 +       } else {
938 +           newAdaptors = xalloc((numAdaptors + 1) 
939 +                                * sizeof(XF86VideoAdaptorPtr*));
940 +           if (newAdaptors){
941 +               memcpy(newAdaptors, overlayAdaptors, 
942 +                      numAdaptors * sizeof(XF86VideoAdaptorPtr));
943 +               newAdaptors[numAdaptors++] = newAdaptor;
944 +               overlayAdaptors = newAdaptors;
945 +           }
946 +       }
947 +    }
948 +
949 +    if (numAdaptors)
950 +       xf86XVScreenInit(pScreen, overlayAdaptors, numAdaptors);
951 +
952 +    if (newAdaptors)
953 +       xfree(newAdaptors);
954 +}
955 +
956 +static XF86VideoEncodingRec NEOVideoEncodings[] =
957 +{
958 +    {
959 +       NEO_VIDEO_VIDEO,
960 +       "XV_VIDEO",
961 +       1024, 1024,
962 +       {1, 1}
963 +    },
964 +    {
965 +       NEO_VIDEO_IMAGE,
966 +       "XV_IMAGE",
967 +       1024, 1024,
968 +       {1, 1}
969 +    }
970 +};
971 +
972 +static XF86VideoFormatRec NEOVideoFormats[] =
973 +{
974 +    {  8, PseudoColor },
975 +    { 15, TrueColor },
976 +    { 16, TrueColor },
977 +    { 24, TrueColor },
978 +};
979 +
980 +static XF86AttributeRec NEOVideoAttributes[] =
981 +{
982 +    {
983 +       XvSettable | XvGettable,
984 +       0x000000, 0xFFFFFF,
985 +       "XV_COLORKEY"
986 +    },
987 +    {
988 +       XvSettable | XvGettable,
989 +       -128, 127,
990 +       "XV_BRIGHTNESS"
991 +    },
992 +    {
993 +       XvSettable | XvGettable,
994 +       0,2,
995 +       "XV_INTERLACE"
996 +    },
997 +};
998 +
999 +static XF86ImageRec NEOVideoImages[] =
1000 +{
1001 +    XVIMAGE_YUY2,
1002 +    XVIMAGE_YV12,
1003 +    XVIMAGE_I420,
1004 +    {
1005 +       FOURCC_RV15,
1006 +       XvRGB,
1007 +       LSBFirst,
1008 +       { 'R', 'V' ,'1', '5',
1009 +         0x00,'5',0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
1010 +       16,
1011 +       XvPacked,
1012 +       1,
1013 +       15, 0x001F, 0x03E0, 0x7C00,
1014 +       0, 0, 0,
1015 +       0, 0, 0,
1016 +       0, 0, 0,
1017 +       { 'R', 'V', 'B' },
1018 +       XvTopToBottom
1019 +    },
1020 +    {
1021 +       FOURCC_RV16,
1022 +       XvRGB,
1023 +       LSBFirst,
1024 +       { 'R', 'V' ,'1', '6',
1025 +         0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
1026 +       16,
1027 +       XvPacked,
1028 +       1,
1029 +       16, 0x001F, 0x07E0, 0xF800,
1030 +       0, 0, 0,
1031 +       0, 0, 0,
1032 +       0, 0, 0,
1033 +       { 'R', 'V', 'B' },
1034 +       XvTopToBottom
1035 +    }
1036 +};
1037 +
1038 +static XF86VideoAdaptorPtr
1039 +NEOSetupVideo(ScreenPtr pScreen)
1040 +{
1041 +    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
1042 +    NEOPtr nPtr = NEOPTR(pScrn);
1043 +    NEOPortPtr pPriv;
1044 +    XF86VideoAdaptorPtr overlayAdaptor;
1045 +    int i;
1046 +
1047 +#ifdef DEBUG
1048 +    xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOSetupVideo\n");
1049 +#endif
1050 +    if ((overlayAdaptor = xcalloc(1, sizeof(XF86VideoAdaptorRec) +
1051 +                             sizeof(DevUnion) + 
1052 +                             sizeof(NEOPortRec))) == NULL){
1053 +       return (NULL);
1054 +    }
1055 +
1056 +    overlayAdaptor->type = XvInputMask | XvImageMask | XvWindowMask 
1057 +       | XvOutputMask | XvVideoMask;
1058 +    overlayAdaptor->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
1059 +    overlayAdaptor->name = "NeoMagic Video Engine";
1060 +    overlayAdaptor->nEncodings = nElems(NEOVideoEncodings);
1061 +    overlayAdaptor->pEncodings = NEOVideoEncodings;
1062 +    for (i = 0; i < nElems(NEOVideoEncodings); i++){
1063 +       NEOVideoEncodings[i].width = 1024;
1064 +       NEOVideoEncodings[i].height = 1024;
1065 +    }
1066 +    overlayAdaptor->nFormats = nElems(NEOVideoFormats);
1067 +    overlayAdaptor->pFormats = NEOVideoFormats;
1068 +    overlayAdaptor->nPorts = 1;
1069 +    overlayAdaptor->pPortPrivates = (DevUnion*) &overlayAdaptor[1];
1070 +    overlayAdaptor->pPortPrivates[0].ptr = 
1071 +       (pointer) &overlayAdaptor->pPortPrivates[1];
1072 +    overlayAdaptor->nAttributes = nElems(NEOVideoAttributes);
1073 +    overlayAdaptor->pAttributes = NEOVideoAttributes;
1074 +    overlayAdaptor->nImages = nElems(NEOVideoImages);
1075 +    overlayAdaptor->pImages = NEOVideoImages;
1076 +
1077 +    overlayAdaptor->PutVideo = NEOPutVideo;
1078 +    overlayAdaptor->PutStill = NULL;
1079 +    overlayAdaptor->GetVideo = NULL;
1080 +    overlayAdaptor->GetStill = NULL;
1081 +
1082 +    overlayAdaptor->StopVideo = NEOStopVideo;
1083 +    overlayAdaptor->SetPortAttribute = NEOSetPortAttribute;
1084 +    overlayAdaptor->GetPortAttribute = NEOGetPortAttribute;
1085 +    overlayAdaptor->QueryBestSize = NEOQueryBestSize;
1086 +    overlayAdaptor->PutImage = NEOPutImage;
1087 +    overlayAdaptor->QueryImageAttributes = NEOQueryImageAttributes;
1088 +
1089 +    pPriv = (NEOPortPtr)overlayAdaptor->pPortPrivates[0].ptr;
1090 +    pPriv->colorKey = nPtr->videoKey;
1091 +    pPriv->interlace = nPtr->interlace;
1092 +    pPriv->videoStatus = 0;
1093 +    pPriv->brightness = 0;
1094 +    REGION_INIT(pScreen, &pPriv->clip, NullBox, 0);
1095 +    nPtr->overlayAdaptor = overlayAdaptor;
1096 +
1097 +    xvBrightness = MAKE_ATOM("XV_BRIGHTNESS");
1098 +    xvColorKey = MAKE_ATOM("XV_COLORKEY");
1099 +    xvInterlace = MAKE_ATOM("XV_INTERLACE");
1100 +    
1101 +    NEOResetVideo(pScrn);
1102 +
1103 +    return (overlayAdaptor);
1104 +}
1105 +
1106 +void
1107 +NEOResetVideo(ScrnInfoPtr pScrn)
1108 +{
1109 +    NEOPtr nPtr = NEOPTR(pScrn);
1110 +    NEOPortPtr pPriv = (NEOPortPtr)nPtr->overlayAdaptor->pPortPrivates[0].ptr;
1111 +    int r, g, b;
1112 +    VGA_HWP(pScrn);
1113 +
1114 +#ifdef DEBUG
1115 +    xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOResetVideo\n");
1116 +#endif
1117 +    switch (pScrn->depth){
1118 +    case 8:
1119 +       OUTGR(0xc6, pPriv->colorKey & 0);
1120 +       OUTGR(0xc5, pPriv->colorKey & 0xff);
1121 +       OUTGR(0xc7, pPriv->colorKey & 0);
1122 +       break;
1123 +    default:
1124 +       r = (pPriv->colorKey & pScrn->mask.red) >> pScrn->offset.red;
1125 +       g = (pPriv->colorKey & pScrn->mask.green) >> pScrn->offset.green;
1126 +       b = (pPriv->colorKey & pScrn->mask.blue) >> pScrn->offset.blue;
1127 +       OUTGR(0xc5, r);
1128 +       OUTGR(0xc6, g);
1129 +       OUTGR(0xc7, b);
1130 +       break;
1131 +    }
1132 +    OUTGR(0xc4, pPriv->brightness);
1133 +}
1134 +
1135 +static int
1136 +NEOPutVideo(ScrnInfoPtr pScrn, 
1137 +            short src_x, short src_y, short drw_x, short drw_y,
1138 +            short src_w, short src_h, short drw_w, short drw_h,
1139 +            RegionPtr clipBoxes, pointer data)
1140 +{
1141 +    NEOPortPtr pPriv = (NEOPortPtr)data;
1142 +    NEOPtr nPtr = NEOPTR(pScrn);
1143 +    CARD32 src_pitch, offset;
1144 +    int xscale, yscale;
1145 +    BoxRec dstBox;
1146 +    INT32 x1, y1, x2, y2;
1147 +    int size, bpp;
1148 +    unsigned char capctrl;
1149 +    VGA_HWP(pScrn);
1150 +
1151 +#ifdef DEBUG
1152 +    xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOPutVideo: src: %d %d %d %d\n", 
1153 +              src_x, src_y, src_w, src_h);
1154 +    xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOPutVideo: drw: %d %d %d %d\n", 
1155 +              drw_x, drw_y, drw_w, drw_h);
1156 +#endif
1157 +    if (src_w > 720)
1158 +       src_w = 720;
1159 +    if (src_h > 576)
1160 +        src_h = 576;
1161 +    if (pPriv->interlace != 2)
1162 +       src_h /= 2;
1163 +    x1 = src_x;
1164 +    y1 = src_y;
1165 +    x2 = src_x + src_w;
1166 +    y2 = src_y + src_h;
1167 +
1168 +    dstBox.x1 = drw_x;
1169 +    dstBox.y1 = drw_y;
1170 +    dstBox.x2 = drw_x + drw_w;
1171 +    dstBox.y2 = drw_y + drw_h;
1172 +
1173 +    if (!xf86XVClipVideoHelper(&dstBox, &x1, &x2, &y1, &y2,
1174 +                              clipBoxes, src_w, src_h)){
1175 +       return(Success);
1176 +    }
1177 +#ifdef DEBUG
1178 +    xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOPutVideo: %d %d %d %d\n", 
1179 +              x1, y1, x2, y2);
1180 +#endif
1181 +
1182 +    dstBox.x1 -= pScrn->frameX0;
1183 +    dstBox.y1 -= pScrn->frameY0;
1184 +    dstBox.x2 -= pScrn->frameX0;
1185 +    dstBox.y2 -= pScrn->frameY0;
1186 +#ifdef DEBUG
1187 +    xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOPutVideo: dstBox %d %d %d %d\n", 
1188 +              dstBox.x1, dstBox.y1, dstBox.x2, dstBox.y2);
1189 +#endif
1190 +
1191 +    bpp = (pScrn->bitsPerPixel + 1) >> 3;
1192 +    src_pitch = (src_w + 7) & ~7;
1193 +
1194 +    xscale = 0x1000;
1195 +    if (src_w <= drw_w){
1196 +       xscale = (src_w * 0x1000 / drw_w) & 0xffff;
1197 +    }
1198 +
1199 +    yscale = 0x1000;
1200 +    if (src_h <= drw_h){
1201 +       yscale = (src_h * 0x1000 / drw_h) & 0xffff;
1202 +    }
1203 +
1204 +    size = src_h * src_pitch * 2;
1205 +
1206 +    if (size > nPtr->overlay){
1207 +       if ((pPriv->linear = NEOAllocateMemory(pScrn, pPriv->linear, size)) 
1208 +           == NULL){
1209 +           return (BadAlloc);
1210 +       }
1211 +    } else {
1212 +       pPriv->linear = NULL;
1213 +    }
1214 +    
1215 +    if (pPriv->linear == NULL){
1216 +       offset = nPtr->overlay_offset;
1217 +    } else {
1218 +       offset = pPriv->linear->offset * bpp;
1219 +    }
1220 +    
1221 +#ifdef DEBUG
1222 +    xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOPutVideo: offset=0x%x\n", offset);
1223 +#endif
1224 +     WAIT_ENGINE_IDLE();
1225 +     memset(nPtr->NeoFbBase + offset, 0, size);
1226 +
1227 +    if (!RegionsEqual(&pPriv->clip, clipBoxes)){
1228 +       REGION_COPY(pScreen, &pPriv->clip, clipBoxes);
1229 +       xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey,
1230 +                           clipBoxes);
1231 +    }
1232 +
1233 +    x1 >>= 16;
1234 +    y1 >>= 16;
1235 +    x2 >>= 16;
1236 +    y2 >>= 16;
1237 +
1238 +    switch (nPtr->NeoChipset) {
1239 +    default:
1240 +    case NM2160: 
1241 +       offset/=2;
1242 +       OUTGR(0xbc, 0x4f);
1243 +       break;
1244 +    case NM2200:
1245 +    case NM2230:
1246 +    case NM2360:
1247 +    case NM2380:
1248 +       OUTGR(0xbc, 0x2e);
1249 +       break;
1250 +    }
1251
1252 +
1253 +    OUTGR(0xb1, (((dstBox.x2-1) >> 4) & 0xf0) | ((dstBox.x1 >> 8) & 0x0f));
1254 +    OUTGR(0xb2, dstBox.x1);
1255 +    OUTGR(0xb3, dstBox.x2 - 1);
1256 +    OUTGR(0xb4, (((dstBox.y2 - 1) >> 4) & 0xf0) | ((dstBox.y1 >> 8) & 0x0f));
1257 +    OUTGR(0xb5, dstBox.y1);
1258 +    OUTGR(0xb6, dstBox.y2 - 1);
1259 +    OUTGR(0xb7, offset >> 16);
1260 +    OUTGR(0xb8, offset >> 8);
1261 +    OUTGR(0xb9, offset );
1262 +    OUTGR(0xba, src_pitch >> 8);
1263 +    OUTGR(0xbb, src_pitch);
1264 +
1265 +    OUTGR(0xc0, xscale >> 8);
1266 +    OUTGR(0xc1, xscale);
1267 +    OUTGR(0xc2, yscale >> 8);
1268 +    OUTGR(0xc3, yscale);
1269 +    OUTGR(0xbf, 0x02);
1270 +
1271 +    OUTGR(0x0a, 0x21);
1272 +
1273 +    OUTSR(0x0c, offset );
1274 +    OUTSR(0x0d, offset >> 8);
1275 +    OUTSR(0x0e, offset >> 16);
1276 +    OUTSR(0x1a, src_pitch);
1277 +    OUTSR(0x1b, src_pitch>>8);
1278 +
1279 +    OUTSR(0x17, 0 + x1);
1280 +    OUTSR(0x18, 0 + x2 -1);
1281 +    OUTSR(0x19, (((0 + x2 - 1) >> 4) & 0xf0) | (((0 + x1) >> 8) & 0x0f));
1282 +
1283 +    OUTSR(0x14, 14 + y1);
1284 +    OUTSR(0x15, 14 + y2 - 2);
1285 +    OUTSR(0x16, (((14 + y2 - 1) >> 4) & 0xf0) | (((14 + y1) >> 8) & 0x0f));
1286 +
1287 +    OUTSR(0x1c, 0xfb);
1288 +    OUTSR(0x1d, 0x00);
1289 +    OUTSR(0x1e, 0xe2);
1290 +    OUTSR(0x1f, 0x02);
1291 +
1292 +    OUTSR(0x09, 0x11);
1293 +    OUTSR(0x0a, 0x00);
1294 +
1295 +    capctrl = 0x21;
1296 +    switch (pPriv->interlace){
1297 +    case 0: /* Combine 2 fields */
1298 +       break;
1299 +    case 1: /* one field only */
1300 +       capctrl |= 0x80;
1301 +       break;
1302 +    case 2: /* Interlaced fields */
1303 +       capctrl |= 0x40;
1304 +       break;
1305 +    }
1306 +    OUTSR(0x08, capctrl);
1307 +
1308 +#if 0
1309 +    OUTGR(0x0a, 0x01);
1310 +#endif
1311 +    OUTGR(0xb0, 0x03);
1312 +
1313 +    pPriv->videoStatus = CLIENT_VIDEO_ON;
1314 +    return (Success);
1315 +}
1316 +
1317 +static void
1318 +NEOStopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit)
1319 +{
1320 +    NEOPortPtr pPriv = (NEOPortPtr)data;
1321 +    NEOPtr nPtr = NEOPTR(pScrn);
1322 +    VGA_HWP(pScrn);
1323 +
1324 +#ifdef DEBUG
1325 +    xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOStopVideo\n");
1326 +#endif
1327 +    REGION_EMPTY(pScrn->pScreen, &pPriv->clip);
1328 +
1329 +    if (exit){
1330 +       if (pPriv->videoStatus & CLIENT_VIDEO_ON){
1331 +#ifdef DEBUG
1332 +            xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOStopVideo: stop capture\n");
1333 +#endif
1334 +           OUTGR(0xb0, 0x02);
1335 +           OUTGR(0x0a, 0x21);
1336 +           OUTSR(0x08, 0xa0);
1337 +#if 0
1338 +           OUTGR(0x0a, 0x01);
1339 +#endif
1340 +       }
1341 +       if (pPriv->linear != NULL){
1342 +           xf86FreeOffscreenLinear(pPriv->linear);
1343 +           pPriv->linear = NULL;
1344 +       }
1345 +       pPriv->videoStatus = 0;
1346 +    } else {
1347 +       if (pPriv->videoStatus & CLIENT_VIDEO_ON){
1348 +           OUTGR(0xb0, 0x02);
1349 +           OUTGR(0x0a, 0x21);
1350 +           OUTSR(0x08, 0xa0);
1351 +#if 0
1352 +           OUTGR(0x0a, 0x01);
1353 +#endif
1354 +           pPriv->videoStatus |= OFF_TIMER;
1355 +           pPriv->offTime = currentTime.milliseconds + OFF_DELAY;
1356 +       }
1357 +    }
1358 +}
1359 +
1360 +static int
1361 +NEOSetPortAttribute(ScrnInfoPtr pScrn, Atom attribute, INT32 value, 
1362 +                   pointer data)
1363 +{
1364 +    NEOPortPtr pPriv = (NEOPortPtr)data;
1365 +    NEOPtr nPtr = NEOPTR(pScrn);
1366 +    VGA_HWP(pScrn);
1367 +
1368 +#ifdef DEBUG
1369 +    xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOSetPortAttribute\n");
1370 +#endif
1371 +    if (attribute == xvColorKey){
1372 +       int r, g, b;
1373 +
1374 +       pPriv->colorKey = value;
1375 +       switch (pScrn->depth){
1376 +       case 8:
1377 +           OUTGR(0xc6, pPriv->colorKey & 0xff);
1378 +           OUTGR(0xc5, 0x00);
1379 +           OUTGR(0xc7, 0x00);
1380 +           break;
1381 +       default:
1382 +           r = (pPriv->colorKey & pScrn->mask.red) >> pScrn->offset.red;
1383 +           g = (pPriv->colorKey & pScrn->mask.green) >> pScrn->offset.green;
1384 +           b = (pPriv->colorKey & pScrn->mask.blue) >> pScrn->offset.blue;
1385 +           OUTGR(0xc5, r);
1386 +           OUTGR(0xc6, g);
1387 +           OUTGR(0xc7, b);
1388 +       }
1389 +    } else if (attribute == xvBrightness){
1390 +       if ((value < -128) || (value > 127)){
1391 +           return (BadValue);
1392 +       }
1393 +       pPriv->brightness = value;
1394 +       OUTGR(0xc4, value);
1395 +    } else if (attribute == xvInterlace){
1396 +       if (value < 0  ||  value > 2){
1397 +           return (BadValue);
1398 +       }
1399 +       pPriv->interlace = value;
1400 +    } else {
1401 +       return (BadMatch);
1402 +    }
1403 +    return (Success);
1404 +}
1405 +
1406 +static int
1407 +NEOGetPortAttribute(ScrnInfoPtr pScrn, Atom attribute, INT32 *value, 
1408 +                   pointer data)
1409 +{
1410 +    NEOPortPtr pPriv = (NEOPortPtr)data;
1411 +
1412 +#ifdef DEBUG
1413 +    xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOGetPortAttribute\n");
1414 +#endif
1415 +    if (attribute == xvColorKey){
1416 +       *value = pPriv->colorKey;
1417 +    } else if (attribute == xvBrightness){
1418 +       *value = pPriv->brightness;
1419 +    } else if (attribute == xvInterlace){
1420 +       *value = pPriv->interlace;
1421 +    } else {
1422 +       return (BadMatch);
1423 +    }
1424 +    return (Success);
1425 +}
1426 +
1427 +static void
1428 +NEOQueryBestSize(ScrnInfoPtr pScrn, Bool motion, 
1429 +                short vid_w, short vid_h, short drw_w, short drw_h,
1430 +                unsigned int *p_w, unsigned int *p_h,
1431 +                pointer data)
1432 +{
1433 +#ifdef DEBUG
1434 +    xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOQueryBestSize\n");
1435 +#endif
1436 +    *p_w = min(drw_w, 1024);
1437 +    *p_h = min(drw_h, 1024);
1438 +}
1439 +
1440 +static int
1441 +NEOPutImage(ScrnInfoPtr pScrn, 
1442 +           short src_x, short src_y, short drw_x, short drw_y,
1443 +           short src_w, short src_h, short drw_w, short drw_h,
1444 +           int id, unsigned char *buf, short width, short height,
1445 +           Bool sync, RegionPtr clipBoxes, pointer data)
1446 +{
1447 +    NEOPtr nPtr = NEOPTR(pScrn);
1448 +    NEOPortPtr pPriv = (NEOPortPtr)nPtr->overlayAdaptor->pPortPrivates[0].ptr;
1449 +    INT32 x1, y1, x2, y2;
1450 +    int bpp;
1451 +    int srcPitch, srcPitch2 = 0, dstPitch, size;
1452 +    BoxRec dstBox;
1453 +    CARD32 offset, offset2 = 0, offset3 = 0, tmp;
1454 +    int left, top, nPixels, nLines;
1455 +    unsigned char *dstStart;
1456 +
1457 +#ifdef DEBUG
1458 +    xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOPutImage\n");
1459 +#endif
1460 +
1461 +    x1 = src_x;
1462 +    y1 = src_y;
1463 +    x2 = src_x + src_w;
1464 +    y2 = src_y + src_h;
1465 +    
1466 +    dstBox.x1 = drw_x;
1467 +    dstBox.y1 = drw_y;
1468 +    dstBox.x2 = drw_x + drw_w;
1469 +    dstBox.y2 = drw_y + drw_h;
1470 +
1471 +    if (!xf86XVClipVideoHelper(&dstBox, &x1, &x2, &y1, &y2,
1472 +                              clipBoxes, width, height)){
1473 +       return (Success);
1474 +    }
1475 +
1476 +    dstBox.x1 -= pScrn->frameX0;
1477 +    dstBox.y1 -= pScrn->frameY0;
1478 +    dstBox.x2 -= pScrn->frameX0;
1479 +    dstBox.y2 -= pScrn->frameY0;    
1480 +    
1481 +    bpp = ((pScrn->bitsPerPixel + 1) >> 3);
1482 +    
1483 +    switch (id){
1484 +    case FOURCC_YV12:
1485 +       srcPitch  = (width + 3) & ~3;
1486 +       offset2   = srcPitch * height;
1487 +       srcPitch2 = ((width >> 1) + 3) & ~3;
1488 +       offset3   = offset2 + (srcPitch2 * (height >> 1));
1489 +       dstPitch  = ((width << 1) + 15) & ~15; 
1490 +       break;
1491 +    case FOURCC_I420:
1492 +       srcPitch  = (width + 3) & ~3;
1493 +       offset3   = srcPitch * height;
1494 +       srcPitch2 = ((width >> 1) + 3) & ~3;
1495 +       offset2   = offset3 + (srcPitch2 * (height >> 1));
1496 +       dstPitch  = ((width << 1) + 15) & ~15;
1497 +       break;
1498 +    case FOURCC_YUY2:
1499 +    case FOURCC_RV15:
1500 +    case FOURCC_RV16:
1501 +    default:
1502 +       srcPitch = width << 1;
1503 +       dstPitch = (srcPitch + 15) & ~15;
1504 +       break;
1505 +    }
1506 +    
1507 +    size = dstPitch * height;
1508 +    if (size > nPtr->overlay){
1509 +       if ((pPriv->linear = NEOAllocateMemory(pScrn, pPriv->linear, size)) 
1510 +           == NULL){
1511 +           return (BadAlloc);
1512 +       }
1513 +    } else {
1514 +       pPriv->linear = NULL;
1515 +    }
1516 +
1517 +    top = y1 >> 16;
1518 +    left = (x1 >> 16) & ~1;
1519 +    nPixels = ((((x2 + 0xFFFF) >> 16) + 1) & ~1) - left;
1520 +    left <<= 1;
1521 +
1522 +    if (pPriv->linear == NULL){
1523 +       offset = nPtr->overlay_offset;
1524 +    } else {
1525 +       offset =  pPriv->linear->offset * bpp;
1526 +    }
1527 +    
1528 +#ifdef DEBUG
1529 +    xf86DrvMsg(pScrn->scrnIndex,X_INFO,"offset=%x\n", offset);
1530 +#endif
1531 +
1532 +    dstStart = (unsigned char *)(nPtr->NeoFbBase + offset + left);
1533 +    
1534 +    switch (id){
1535 +    case FOURCC_YV12:
1536 +    case FOURCC_I420:
1537 +       top &= ~1;
1538 +       tmp = ((top >> 1) * srcPitch2) + (left >> 2);
1539 +       offset2 += tmp;
1540 +       offset3 += tmp;
1541 +       nLines = ((((y2 + 0xFFFF) >> 16) + 1) & ~1) - top;
1542 +       NEOCopyYV12Data(buf + (top * srcPitch) + (left >> 1), buf + offset2, 
1543 +                       buf + offset3, dstStart, srcPitch, srcPitch2, 
1544 +                       dstPitch, nLines, nPixels);
1545 +       break;
1546 +    default:
1547 +       buf += (top * srcPitch) + left;
1548 +       nLines = ((y2 + 0xFFFF) >> 16) - top;
1549 +       NEOCopyData(buf, dstStart, srcPitch, dstPitch, nLines, nPixels << 1);
1550 +    }
1551 +
1552 +    if (!RegionsEqual(&pPriv->clip, clipBoxes)){
1553 +       REGION_COPY(pScreen, &pPriv->clip, clipBoxes);
1554 +        xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes);
1555 +    }
1556 +       NEODisplayVideo(pScrn, id, offset, width, height, dstPitch, x1, y1,
1557 +                       x2, y2, &dstBox, src_w, src_h, drw_w, drw_h);
1558 +    
1559 +    pPriv->videoStatus = CLIENT_VIDEO_ON;
1560 +    return (Success);
1561 +       
1562 +}
1563 +
1564 +static int
1565 +NEOQueryImageAttributes(ScrnInfoPtr pScrn, int id, 
1566 +                       unsigned short *width, unsigned short *height,
1567 +                       int *pitches, int *offsets)
1568 +{
1569 +    int size, tmp;
1570 +
1571 +#ifdef DEBUG
1572 +    xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOQueryImageAttributes\n");
1573 +#endif
1574 +    if (*width > 1024){
1575 +       *width = 1024;
1576 +    }
1577 +    if (*height > 1024){
1578 +       *height = 1024;
1579 +    }
1580 +
1581 +    *width = (*width + 1) & ~1;
1582 +    if (offsets != NULL){
1583 +       offsets[0] = 0;
1584 +    }
1585 +
1586 +    switch (id){
1587 +    case FOURCC_YV12:
1588 +    case FOURCC_I420:
1589 +       *height = (*height + 1) & ~1;
1590 +       size = (*width + 3) & ~3;
1591 +       if (pitches != NULL){
1592 +           pitches[0] = size;
1593 +       }
1594 +       size *= *height;
1595 +       if (offsets != NULL){
1596 +           offsets[1] = size;
1597 +       }
1598 +       tmp = ((*width >> 1) + 3) & ~3;
1599 +       if (pitches != NULL){
1600 +           pitches[1] = pitches[2] = tmp;
1601 +       }
1602 +       tmp *= (*height >> 1);
1603 +       size += tmp;
1604 +       if (offsets != NULL){
1605 +           offsets[2] = size;
1606 +       }
1607 +       size += tmp;
1608 +       break;
1609 +    case FOURCC_YUY2:
1610 +    case FOURCC_RV15:
1611 +    case FOURCC_RV16:
1612 +    default:
1613 +       size = *width * 2;
1614 +       if (pitches != NULL){
1615 +           pitches[0] = size;
1616 +       }
1617 +       size *= *height;
1618 +       break;
1619 +    }
1620 +    return (size);
1621 +}
1622 +
1623 +static Bool
1624 +RegionsEqual(RegionPtr A, RegionPtr B)
1625 +{
1626 +    int *dataA, *dataB;
1627 +    int num;
1628 +
1629 +    num = REGION_NUM_RECTS(A);
1630 +    if (num != REGION_NUM_RECTS(B)){
1631 +       return (FALSE);
1632 +    }
1633 +
1634 +    if ((A->extents.x1 != B->extents.x1)
1635 +       || (A->extents.y1 != B->extents.y1)
1636 +       || (A->extents.x2 != B->extents.x2)
1637 +       || (A->extents.y2 != B->extents.y2)){
1638 +       return (FALSE);
1639 +    }
1640 +
1641 +    dataA = (int*) REGION_RECTS(A);
1642 +    dataB = (int*) REGION_RECTS(B);
1643 +
1644 +    while (num--){
1645 +       if ((dataA[0] != dataB[0]) || (dataA[1] != dataB[1])){
1646 +           return (FALSE);
1647 +       }
1648 +       dataA += 2;
1649 +       dataB += 2;
1650 +    }
1651 +    return (TRUE);
1652 +}
1653 +
1654 +static void
1655 +NEODisplayVideo(ScrnInfoPtr pScrn, int id, int offset, 
1656 +                short width, short height, int pitch,
1657 +                int x1, int y1, int x2, int y2, BoxPtr dstBox,
1658 +                short src_w, short src_h, short drw_w, short drw_h)
1659 +{
1660 +    NEOPtr nPtr = NEOPTR(pScrn);
1661 +    int hstretch, vstretch, fmt;
1662 +    VGA_HWP(pScrn);
1663 +#ifdef DEBUG
1664 +    xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEODisplayVideo\n");
1665 +    xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEODisplayVideo src_w=%d, src_h=%d, pitch=%d, drw_w=%d, drw_h=%d\n", src_w, src_h, pitch, drw_w, drw_h);
1666 +#endif
1667 +#define WIDTH_THRESHOLD 160
1668 +    if (dstBox->x2 >= pScrn->virtualX) {
1669 +       /*
1670 +        * This is a hack to work around a problem when video is moved
1671 +        * accross the right border.
1672 +        */
1673 +       int diff_s = (width - ((x2 - x1) >> 16)) & ~1;
1674 +       int diff_d = (drw_w - dstBox->x2 + dstBox->x1) & ~1;
1675 +
1676 +       offset -= 2 * ((diff_s > diff_d) ? diff_d : diff_s);
1677 +       dstBox->x1 -= diff_d;
1678 +    } else if (dstBox->x2 - dstBox->x1 < WIDTH_THRESHOLD) {
1679 +       /*
1680 +        * When the video window is less than about 160 pixel wide
1681 +        * it will be distoreted. We attempt to fix it by actually
1682 +        * making it wider and relying on the color key to prevent
1683 +        * it from appearanig outside of the video.
1684 +        */
1685 +       int pre, post;
1686 +       int scale = 1;
1687 +       
1688 +       if (dstBox->x1 < WIDTH_THRESHOLD) {
1689 +           pre = dstBox->x1;
1690 +           post = 160 - pre;
1691 +       } else {
1692 +           pre = 160;
1693 +           post = 0;
1694 +       }
1695 +       offset -= 2 * scale * pre;
1696 +       dstBox->x1 -= pre;
1697 +       dstBox->x2 += post;
1698 +    }
1699 +    if (nPtr->videoHZoom != 1.0) {
1700 +       if ((dstBox->x2 += 5) > pScrn->virtualX)
1701 +           dstBox->x2 = pScrn->virtualX;
1702 +       if (dstBox->x1 > 0) dstBox->x1 += 2;
1703 +    }
1704 +    
1705 +    fmt = 0x00;
1706 +    switch (id){
1707 +    case FOURCC_YV12:
1708 +    case FOURCC_I420:
1709 +    case FOURCC_YUY2:
1710 +       fmt = 0x00;
1711 +       break;
1712 +    case FOURCC_RV15:
1713 +    case FOURCC_RV16:
1714 +       fmt = 0x20;
1715 +       break;
1716 +    }
1717 +
1718 +    offset += (x1 >> 15) & ~0x03;
1719 +    
1720 +    switch (nPtr->NeoChipset) {
1721 +    default:
1722 +    case NM2160: 
1723 +        offset/=2;
1724 +       pitch/=2;
1725 +        OUTGR(0xbc, 0x4f);
1726 +       break;
1727 +    case NM2200:
1728 +    case NM2230:
1729 +    case NM2360:
1730 +    case NM2380:
1731 +        OUTGR(0xbc, 0x2e);
1732 +       break;
1733 +    }
1734 +
1735 +    /* factor 4 for granularity */
1736 +    hstretch = (double)0x1000 * 4 / (int)(nPtr->videoHZoom * 4);
1737 +    if (drw_w > src_w)
1738 +       hstretch = (((int)src_w) * hstretch) / (int) drw_w;
1739 +    
1740 +    vstretch = (double)0x1000 / nPtr->videoVZoom;
1741 +    if (drw_h > src_h)
1742 +       vstretch = (((int)src_h) * vstretch )/ (int) drw_h;
1743 +
1744 +    OUTGR(0xb1, (((dstBox->x2 - 1) >> 4) & 0xf0) | ((dstBox->x1 >> 8) & 0x0f));
1745 +    OUTGR(0xb2, dstBox->x1);
1746 +    OUTGR(0xb3, dstBox->x2 - 1);
1747 +    OUTGR(0xb4, (((dstBox->y2 - 1) >> 4) & 0xf0) | ((dstBox->y1 >> 8) & 0x0f));
1748 +    OUTGR(0xb5, dstBox->y1);
1749 +    OUTGR(0xb6, dstBox->y2 - 1);
1750 +    OUTGR(0xb7, offset >> 16);
1751 +    OUTGR(0xb8, offset >> 8);
1752 +    OUTGR(0xb9, offset );
1753 +    OUTGR(0xba, pitch >> 8);
1754 +    OUTGR(0xbb, pitch);
1755 +     
1756 +    OUTGR(0xbd, 0x02);
1757 +    OUTGR(0xbe, 0x00);
1758 +    OUTGR(0xbf, 0x02);
1759 +
1760 +    OUTGR(0xc0, hstretch >> 8);
1761 +    OUTGR(0xc1, hstretch);
1762 +    OUTGR(0xc2, vstretch >> 8);
1763 +    OUTGR(0xc3, vstretch);
1764 +
1765 +    OUTGR(0xb0, fmt | 0x03);
1766 +
1767 +    OUTGR(0x0a, 0x21);
1768 +    OUTSR(0x08, 0xa0);
1769 +    OUTGR(0x0a, 0x01);
1770 +}
1771 +
1772 +static void
1773 +NEOInitOffscreenImages(ScreenPtr pScreen)
1774 +{
1775 +    XF86OffscreenImagePtr offscreenImages;
1776 +
1777 +#ifdef DEBUG
1778 +    xf86DrvMsg(xf86Screens[pScreen->myNum]->scrnIndex,X_INFO,"NEOInitOffscreenImages\n");
1779 +#endif
1780 +    if ((offscreenImages = xalloc(sizeof(XF86OffscreenImageRec))) == NULL){
1781 +       return;
1782 +    }
1783 +
1784 +    offscreenImages->image = NEOVideoImages;
1785 +    offscreenImages->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
1786 +    offscreenImages->alloc_surface = NEOAllocSurface;
1787 +    offscreenImages->free_surface = NEOFreeSurface;
1788 +    offscreenImages->display = NEODisplaySurface;
1789 +    offscreenImages->stop = NEOStopSurface;
1790 +    offscreenImages->getAttribute = NEOGetSurfaceAttribute;
1791 +    offscreenImages->setAttribute = NEOSetSurfaceAttribute;
1792 +    offscreenImages->max_width = 1024;
1793 +    offscreenImages->max_height = 1024;
1794 +    offscreenImages->num_attributes = nElems(NEOVideoAttributes);
1795 +    offscreenImages->attributes = NEOVideoAttributes;
1796 +
1797 +    xf86XVRegisterOffscreenImages(pScreen, offscreenImages, 1);
1798 +}
1799 +
1800 +static FBLinearPtr
1801 +NEOAllocateMemory(ScrnInfoPtr pScrn, FBLinearPtr linear, int size)
1802 +{
1803 +    ScreenPtr pScreen;
1804 +    FBLinearPtr new_linear;
1805 +    int bytespp = pScrn->bitsPerPixel >> 3;
1806 +
1807 +    /* convert size in bytes into number of pixels */
1808 +    size = (size + bytespp - 1) / bytespp;
1809 +#ifdef DEBUG
1810 +    xf86DrvMsg(pScrn->scrnIndex,X_INFO,
1811 +              "NEOAllocateMemory: linear=%x, size=%d\n", linear, size);
1812 +#endif
1813 +    if (linear){
1814 +#ifdef DEBUG
1815 +        xf86DrvMsg(pScrn->scrnIndex,X_INFO,
1816 +                  "NEOAllocateMemory: linear->size=%d\n", linear->size);
1817 +#endif
1818 +       if (linear->size >= size){
1819 +           return (linear);
1820 +       }
1821 +
1822 +       if (xf86ResizeOffscreenLinear(linear, size)){
1823 +           return (linear);
1824 +       }
1825 +
1826 +       xf86FreeOffscreenLinear(linear);
1827 +    }
1828 +
1829 +
1830 +    pScreen = screenInfo.screens[pScrn->scrnIndex];
1831 +    if ((new_linear = xf86AllocateOffscreenLinear(pScreen, size, 16, NULL,
1832 +                                                 NULL, NULL)) == NULL){
1833 +       int max_size;
1834 +
1835 +       xf86QueryLargestOffscreenLinear(pScreen, &max_size, 16, 
1836 +                                       PRIORITY_EXTREME);
1837 +#ifdef DEBUG
1838 +        xf86DrvMsg(pScrn->scrnIndex,X_INFO,
1839 +                  "NEOAllocateMemory: max_size=%d\n", max_size);
1840 +#endif
1841 +       if (max_size < size){
1842 +           return (NULL);
1843 +       }
1844 +
1845 +       xf86PurgeUnlockedOffscreenAreas(pScreen);
1846 +       new_linear = xf86AllocateOffscreenLinear(pScreen, 
1847 +                                                size, 16, NULL, NULL, NULL);
1848 +    }
1849 +    
1850 +    return (new_linear);
1851 +}
1852 +
1853 +static void
1854 +NEOCopyData(unsigned char *src, unsigned char *dst, 
1855 +           int srcPitch, int dstPitch,
1856 +           int height, int width)
1857 +{
1858 +    while (height-- > 0){
1859 +       memcpy(dst, src, width);
1860 +       src += srcPitch;
1861 +       dst += dstPitch;
1862 +    }
1863 +}
1864 +
1865 +static void
1866 +NEOCopyYV12Data(unsigned char *src1, unsigned char *src2,
1867 +               unsigned char *src3, unsigned char *dst,
1868 +               int srcPitch1, int srcPitch2, int dstPitch,
1869 +               int height, int width)
1870 +{
1871 +    CARD32 *pDst = (CARD32 *) dst;
1872 +    int i;
1873 +
1874 +    width >>= 1;
1875 +    height >>= 1;
1876 +    dstPitch >>= 2;
1877 +    while (--height >= 0){
1878 +       for (i =0; i < width; i++){
1879 +           pDst[i] = src1[i << 1] | (src1[(i << 1) + 1] << 16) |
1880 +               (src3[i] << 8) | (src2[i] << 24);
1881 +       }
1882 +       pDst += dstPitch;
1883 +       src1 += srcPitch1;
1884 +
1885 +       for (i =0; i < width; i++){
1886 +           pDst[i] = src1[i << 1] | (src1[(i << 1) + 1] << 16) |
1887 +               (src3[i] << 8) | (src2[i] << 24);
1888 +       }
1889 +       pDst += dstPitch;
1890 +       src1 += srcPitch1;
1891 +           src2 += srcPitch2;
1892 +           src3 += srcPitch2;
1893 +    }
1894 +}
1895 +
1896 +static int
1897 +NEOAllocSurface(ScrnInfoPtr pScrn, int id, 
1898 +               unsigned short width, unsigned short height,
1899 +               XF86SurfacePtr surface)
1900 +{
1901 +    int pitch, bpp, size;
1902 +    NEOOffscreenPtr pPriv;
1903 +    FBLinearPtr linear;
1904 +
1905 +#ifdef DEBUG
1906 +    xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOAllocSurface\n");
1907 +#endif
1908 +    if (width > 1024  || height > 1024){
1909 +       return (BadAlloc);
1910 +    }
1911 +
1912 +    width = (width + 1) & ~1;
1913 +    bpp = ((pScrn->bitsPerPixel + 1) >> 3);
1914 +    pitch = ((width << 1) + 15) & ~15;
1915 +    size = pitch * height;
1916 +
1917 +    if ((linear = NEOAllocateMemory(pScrn, NULL, size)) == NULL){
1918 +       return (BadAlloc);
1919 +    }
1920 +
1921 +    surface->width = width;
1922 +    surface->height = height;
1923 +    if ((surface->pitches = xalloc(sizeof(int))) == NULL){
1924 +       xf86FreeOffscreenLinear(linear);
1925 +       return (BadAlloc);
1926 +    }
1927 +    if ((surface->offsets = xalloc(sizeof(int))) == NULL){
1928 +       xfree(surface->pitches);
1929 +       xf86FreeOffscreenLinear(linear);
1930 +       return (BadAlloc);
1931 +    }
1932 +
1933 +    if ((pPriv = xalloc(sizeof(NEOOffscreenRec))) == NULL){
1934 +       xfree(surface->pitches);
1935 +       xfree(surface->offsets);
1936 +       xf86FreeOffscreenLinear(linear);
1937 +       return (BadAlloc);
1938 +    }
1939 +
1940 +    pPriv->linear = linear;
1941 +    pPriv->isOn = FALSE;
1942 +
1943 +    surface->pScrn = pScrn;
1944 +    surface->id = id;
1945 +    surface->pitches[0] = pitch;
1946 +    surface->offsets[0] = linear->offset << 1;
1947 +    surface->devPrivate.ptr = (pointer)pPriv;
1948 +    return (Success);
1949 +}
1950 +
1951 +static int
1952 +NEOFreeSurface(XF86SurfacePtr surface)
1953 +{
1954 +    NEOOffscreenPtr pPriv = (NEOOffscreenPtr)surface->devPrivate.ptr;
1955 +
1956 +#ifdef DEBUG
1957 +    xf86DrvMsg(0,X_INFO,"NEOFreeSurface\n");
1958 +#endif
1959 +    if (pPriv->isOn)
1960 +       NEOStopSurface(surface);
1961 +
1962 +    xf86FreeOffscreenLinear(pPriv->linear);
1963 +    xfree(surface->pitches);
1964 +    xfree(surface->offsets);
1965 +    xfree(surface->devPrivate.ptr);
1966 +    return (Success);
1967 +}
1968 +
1969 +static int
1970 +NEODisplaySurface(XF86SurfacePtr surface,
1971 +                 short src_x, short src_y, short drw_x, short drw_y,
1972 +                 short src_w, short src_h, short drw_w, short drw_h,
1973 +                 RegionPtr clipBoxes)
1974 +{
1975 +    NEOOffscreenPtr pPriv = (NEOOffscreenPtr)surface->devPrivate.ptr;
1976 +    NEOPtr nPtr = NEOPTR(surface->pScrn);
1977 +    NEOPortPtr portPriv = nPtr->overlayAdaptor->pPortPrivates[0].ptr;
1978 +    INT32 x1, y1, x2, y2;
1979 +    BoxRec dstBox;
1980 +
1981 +#ifdef DEBUG
1982 +    xf86DrvMsg(surface->pScrn->scrnIndex,X_INFO,"NEODisplaySurface\n");
1983 +#endif
1984 +    x1 = src_x;
1985 +    x2 = src_x + src_w;
1986 +    y1 = src_y;
1987 +    y2 = src_y + src_h;
1988 +
1989 +    dstBox.x1 = drw_x;
1990 +    dstBox.x2 = drw_x + drw_w;
1991 +    dstBox.y1 = drw_y;
1992 +    dstBox.y2 = drw_y + drw_h;
1993 +    if (!xf86XVClipVideoHelper( &dstBox, &x1, &x2, &y1, &y2,
1994 +                              clipBoxes, surface->width, surface->height)){
1995 +       return (Success);
1996 +    }
1997 +
1998 +    dstBox.x1 -= surface->pScrn->frameX0;
1999 +    dstBox.y1 -= surface->pScrn->frameY0;
2000 +    dstBox.x2 -= surface->pScrn->frameX0;
2001 +    dstBox.y2 -= surface->pScrn->frameY0;
2002 +
2003 +    xf86XVFillKeyHelper(surface->pScrn->pScreen, portPriv->colorKey,
2004 +                       clipBoxes);
2005 +    NEOResetVideo(surface->pScrn);
2006 +    NEODisplayVideo(surface->pScrn, surface->id, surface->offsets[0],
2007 +                   surface->width, surface->height, surface->pitches[0], 
2008 +                   x1, y1, x2, y2, &dstBox, src_w, src_h, drw_w, drw_h);
2009 +    
2010 +    pPriv->isOn = TRUE;
2011 +    if (portPriv->videoStatus & CLIENT_VIDEO_ON){
2012 +       REGION_EMPTY(pScrn->pScreen, &portPriv->clip);
2013 +       UpdateCurrentTime();
2014 +       portPriv->videoStatus = FREE_TIMER;
2015 +       portPriv->freeTime = currentTime.milliseconds + FREE_DELAY;
2016 +    }
2017 +    return (Success);
2018 +}
2019 +
2020 +static int
2021 +NEOStopSurface(XF86SurfacePtr surface)
2022 +{
2023 +    NEOOffscreenPtr pPriv = (NEOOffscreenPtr)surface->devPrivate.ptr;
2024 +
2025 +#ifdef DEBUG
2026 +    xf86DrvMsg(surface->pScrn->scrnIndex,X_INFO,"NEOStopSurface\n");
2027 +#endif
2028 +    if (pPriv->isOn){
2029 +       NEOPtr nPtr = NEOPTR(surface->pScrn);
2030 +       VGA_HWP(surface->pScrn);
2031 +       OUTGR(0xb0, 0x02);
2032 +       pPriv->isOn = FALSE;
2033 +    }
2034 +    return (Success);
2035 +}
2036 +
2037 +static int
2038 +NEOGetSurfaceAttribute(ScrnInfoPtr pScrn, Atom attr, INT32 *value)
2039 +{
2040 +    NEOPtr nPtr = NEOPTR(pScrn);
2041 +
2042 +#ifdef DEBUG
2043 +    xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOGetSurfaceAttribute\n");
2044 +#endif
2045 +    return (NEOGetPortAttribute(pScrn, 
2046 +            attr, value, (pointer)nPtr->overlayAdaptor->pPortPrivates[0].ptr));
2047 +}
2048 +
2049 +static int
2050 +NEOSetSurfaceAttribute(ScrnInfoPtr pScrn, Atom attr, INT32 value)
2051 +{
2052 +    NEOPtr nPtr = NEOPTR(pScrn);
2053 +
2054 +#ifdef DEBUG
2055 +    xf86DrvMsg(pScrn->scrnIndex,X_INFO,"NEOSetSurfaceAttribute\n");
2056 +#endif
2057 +    return (NEOSetPortAttribute(pScrn, 
2058 +            attr, value, (pointer)nPtr->overlayAdaptor->pPortPrivates[0].ptr));
2059 +}
2060 +
2061 +#else /* XvExtension */
2062 +
2063 +void NEOInitVideo(ScreenPtr pScreen) {}
2064 +void NEOResetVideo(ScreenPtr pScreen) {}
2065 +
2066 +#endif
2067 --- XFree86-4.2.0/xc.orig/programs/Xserver/hw/xfree86/drivers/neomagic/neo_video.h      Thu Jan  1 01:00:00 1970
2068 +++ XFree86-4.2.0/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_video.h   Thu Apr  4 16:05:44 2002
2069 @@ -0,0 +1,83 @@
2070 +/**********************************************************************
2071 +Copyright 2002 by Shigehiro Nomura.
2072 +
2073 +                        All Rights Reserved
2074 +
2075 +Permission to use, copy, modify, distribute, and sell this software and
2076 +its documentation for any purpose is hereby granted without fee,
2077 +provided that the above copyright notice appear in all copies and that
2078 +both that copyright notice and this permission notice appear in
2079 +supporting documentation, and that the name of Shigehiro Nomura not be
2080 +used in advertising or publicity pertaining to distribution of the
2081 +software without specific, written prior permission.  Shigehiro Nomura
2082 +and its suppliers make no representations about the suitability of this
2083 +software for any purpose.  It is provided "as is" without express or 
2084 +implied warranty.
2085 +
2086 +SHIGEHIRO NOMURA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
2087 +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
2088 +EVENT SHALL SHIGEHIRO NOMURA AND/OR ITS SUPPLIERS BE LIABLE FOR ANY
2089 +SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
2090 +RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
2091 +CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
2092 +CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2093 +**********************************************************************/
2094 +
2095 +#ifndef _NEO_VIDEO_H
2096 +#define _NEO_VIDEO_H
2097 +
2098 +#define ACC_MMIO
2099 +
2100 +#include "vgaHW.h"
2101 +#include "fourcc.h"
2102 +#include "Xv.h"
2103 +
2104 +#define NEO_VIDEO_VIDEO                0
2105 +#define NEO_VIDEO_IMAGE                1
2106 +
2107 +#define FOURCC_RV15                    0x35315652
2108 +#define FOURCC_RV16                    0x36315652
2109 +
2110 +#define OFF_DELAY                      200             /* milliseconds */
2111 +#define FREE_DELAY                     60000   /* milliseconds */
2112 +
2113 +#define OFF_TIMER                      0x01
2114 +#define FREE_TIMER                     0x02
2115 +#define CLIENT_VIDEO_ON                0x04
2116 +#define TIMER_MASK                     (OFF_TIMER | FREE_TIMER)
2117 +
2118 +typedef struct
2119 +{
2120 +    FBLinearPtr        linear;
2121 +    RegionRec  clip;
2122 +    CARD32     colorKey;
2123 +    CARD32     interlace;
2124 +    CARD32     brightness;
2125 +    CARD32     videoStatus;
2126 +    Time       offTime;
2127 +    Time       freeTime;
2128 +} NEOPortRec, *NEOPortPtr;
2129 +
2130 +typedef struct
2131 +{
2132 +    FBLinearPtr        linear;
2133 +    Bool       isOn;
2134 +} NEOOffscreenRec, *NEOOffscreenPtr;
2135 +
2136 +/* I/O Functions */
2137 +# define OUTGR(idx,dat) \
2138 +   if (nPtr->NeoMMIOBase2) \
2139 +     (*(unsigned short *)(nPtr->NeoMMIOBase2+VGA_GRAPH_INDEX)\
2140 +                                                     =(idx)|((dat)<<8));\
2141 +   else \
2142 +      VGAwGR((idx),(dat));
2143 +
2144 +#  define OUTSR(idx,dat) \
2145 +if (nPtr->NeoMMIOBase2) \
2146 +   (*(unsigned short *)(nPtr->NeoMMIOBase2+VGA_SEQ_INDEX)=(idx)|((dat)<<8));\
2147 +else \
2148 +   VGAwSR((idx),(dat));
2149 +
2150 +# define VGA_HWP(x)     vgaHWPtr hwp = VGAHWPTR(x)
2151 +
2152 +#endif /* _NEO_VIDEO_H */
This page took 0.181949 seconds and 3 git commands to generate.