[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

X Strike Force XFree86 SVN commit: r1724 - in trunk/debian: . patches



Author: branden
Date: 2004-08-10 18:53:36 -0500 (Tue, 10 Aug 2004)
New Revision: 1724

Modified:
   trunk/debian/CHANGESETS
   trunk/debian/patches/000_stolen_from_HEAD_nv_driver.diff
Log:
Update file missing from r1723 commit.


Modified: trunk/debian/CHANGESETS
===================================================================
--- trunk/debian/CHANGESETS	2004-08-10 23:52:25 UTC (rev 1723)
+++ trunk/debian/CHANGESETS	2004-08-10 23:53:36 UTC (rev 1724)
@@ -279,6 +279,6 @@
 and the "mystery" TNT2 card with a PCI model ID of 0x002a.  Extend
 reversion of REGION_EQUAL macro implementation to nv driver in patch #030.
 Resync patch #911.
-    1723
+    1723, 1724
 
 vim:set ai et sts=4 sw=4 tw=80:

Modified: trunk/debian/patches/000_stolen_from_HEAD_nv_driver.diff
===================================================================
--- trunk/debian/patches/000_stolen_from_HEAD_nv_driver.diff	2004-08-10 23:52:25 UTC (rev 1723)
+++ trunk/debian/patches/000_stolen_from_HEAD_nv_driver.diff	2004-08-10 23:53:36 UTC (rev 1724)
@@ -1,23 +1,140 @@
 $Id$
 
-Numerous nv driver updates, including manpage updates, general bug fixes, and
-more supported cards.
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv_xaa.c @ 1.30
+     Do a little more thourough reset of the graphics engine state at startup
+  and after VT switches.
+[Mark Vojkovich]
 
-diff -urN xc.orig/programs/Xserver/hw/xfree86/drivers/nv/nv.man xc/programs/Xserver/hw/xfree86/drivers/nv/nv.man
---- xc.orig/programs/Xserver/hw/xfree86/drivers/nv/nv.man	2003-02-11 11:00:18.000000000 +1100
-+++ xc/programs/Xserver/hw/xfree86/drivers/nv/nv.man	2003-04-09 05:01:10.000000000 +1000
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv.man @ 1.18
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c @ 1.102
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c @ 1.28
+xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.c @ 1.48
+     Fix a problem on the new Apple PowerBooks with NVIDIA chips.
+  Also, new PCI IDs.
+[Mark Vojkovich]
+
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv_video.c @ 1.12
+     Fix a problem where the HW filter would include pixels outside
+  of the image rect being displayed.
+[Mark Vojkovich]
+
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c @ 1.103
+     Modification to work around broken DPMS support in some monitors.
+[Mark Vojkovich]
+
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c @ 1.104
+     Add symbol to the list of used symbols.
+[Mark Vojkovich]
+
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c @ 1.105
+    I've got multiple NVIDIA people telling me there is no such
+  chip with PCI ID 0x002A.  How come I get bug reports about this
+  chip?   I don't get it.
+[Mark Vojkovich]
+
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c @ 1.29
+    Fix a crash on riva128 when doing DDC.
+[Mark Vojkovich]
+
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c @ 1.106
+     Don't enable the video overlay when we are rotated.
+[Mark Vojkovich]
+
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv_video.c @ 1.13
+     Don't use XAAMoveDWORDs because it's not available when not
+  using acceleration and the xaa module hasn't been loaded.
+[Mark Vojkovich]
+
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c @ 1.107
+     Since DPMS doesn't work on DVI, don't go through our DPMS code path
+  because it has some unintended side effects on some cards.
+[Mark Vojkovich]
+
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv_video.c @ 1.14
+[...]
+   127. Centralise a region comparison primitive into 'mi' and use it instead of
+        local definitions throughout the server (Marc La France).
+[This was reverted; see patch #030.]
+
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv_dac.c @ 1.32
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c @ 1.108
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv_proto.h @ 1.9
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c @ 1.30
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv_type.h @ 1.40
+xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.c @ 1.49
+xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.h @ 1.25
+     We should now be able to autodetect which head is being used and
+  flat panel vs. CRTC much better in the nv driver.
+[Mark Vojkovich]
+
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv.man @ 1.19
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c @ 1.31
+     Turn on DDC EDID probing on PowerPC.
+[Mark Vojkovich]
+
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c @ 1.32
+    NV3 and NV4 don't support flat panels.
+[Mark Vojkovich]
+
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c @ 1.33
+  Fix fatal typo in new monitor probing code.
+[Mark Vojkovich]
+
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv.man @ 1.20
+[...]
+  Fix manual pages typos (Bugzilla #316, Jens Schweikhardt).
+[Matthieu Herrb]
+
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv.man @ 1.21
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv_dac.c @ 1.33
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c @ 1.109
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c @ 1.34
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv_type.h @ 1.41
+     TV-out sortof works at 640x400 on some early chips.  It's kindof
+  a work in progress and the geometry is messed up on many models.  Newer,
+  dual head, cards probably won't work.
+     New PCI IDs.
+[Mark Vojkovich]
+
+xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.c @ 1.50
+     Fix problem with 256 Meg cards being detected as 16 Meg.
+[Mark Vojkovich]
+
+xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c @ 1.110
+     NVIDIA hardware starting with NV30 finally start supporting
+  interlaced modes again.  None of the NV2x and most of the NV1x
+  chips didn't have support for it.
+[Mark Vojkovich]
+
+Index: xc/programs/Xserver/hw/xfree86/drivers/nv/nv.man
+===================================================================
+RCS file: /cvs/xc/programs/Xserver/hw/xfree86/drivers/nv/nv.man,v
+retrieving revision 1.17
+retrieving revision 1.21
+diff -u -r1.17 -r1.21
+--- xc/programs/Xserver/hw/xfree86/drivers/nv/nv.man	11 Feb 2003 00:00:18 -0000	1.17
++++ xc/programs/Xserver/hw/xfree86/drivers/nv/nv.man	23 Jun 2003 21:38:40 -0000	1.21
 @@ -1,4 +1,4 @@
 -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv.man,v 1.17 2003/02/11 00:00:18 mvojkovi Exp $ 
-+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv.man,v 1.18 2003/03/12 21:27:18 mvojkovi Exp $ 
++.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv.man,v 1.21 2003/06/23 21:38:40 mvojkovi Exp $ 
  .\" shorthand for double quote that works everywhere.
  .ds q \N'34'
  .TH NV __drivermansuffix__ __vendorversion__
+@@ -14,7 +14,7 @@
+ .fi
+ .SH DESCRIPTION
+ .B nv 
+-is an XFree86 driver for NVIDIA video cards.  The driver supports full 2D 
++is an XFree86 driver for NVIDIA video cards.  The driver supports 2D 
+ acceleration and provides support for the following framebuffer depths:
+ 8, 15, 16 (except Riva128) and 24.  All
+ visual types are supported for depth 8, TrueColor and DirectColor
 @@ -51,7 +51,7 @@
  NV17, NV18, NV25, NV28
  .TP 22
  .B GeForce FX, QUADRO FX
 -NV30
-+NV30, NV31, NV34
++NV30, NV31, NV34, NV35
  .SH CONFIGURATION DETAILS
  Please refer to XF86Config(__filemansuffix__) for general configuration
  details.  This section only covers configuration details specific to this
@@ -26,12 +143,12 @@
  .TP
  .BI "Option \*qCrtcNumber\*q \*q" integer \*q
 -nForce2, Quadro4, GeForce4 and NV30 may have two video outputs.  
-+nForce2, Quadro4, GeForce4, Quadro FX and GeForce FX 
++GeForce2 MX, nForce2, Quadro4, GeForce4, Quadro FX and GeForce FX 
 +may have two video outputs.  
  The driver attempts to autodetect
  which one the monitor is connected to.  In the case that autodetection picks
  the wrong one, this option may be used to force usage of a particular output. 
-@@ -84,17 +85,20 @@
+@@ -84,17 +85,21 @@
  Default: autodetected.
  .TP
  .BI "Option \*qFlatPanel\*q \*q" boolean \*q
@@ -39,8 +156,9 @@
 -this option should be set when used with a flat panel.  With this driver
 -a flat panel will only work if it was POSTed by the BIOS, that is, the
 -machine must have booted to the panel.
-+The driver usually cannot autodetect the presence of a digital flat panel so
-+this option should be set when used with a digital flat panel.  With this 
++The driver usually can autodetect the presence of a digital flat panel.  In
++the case that this fails, this option can be used to force the driver to 
++treat the attached device as a digital flat panel.  With this 
 +driver, a digital flat panel will only work if it was POSTed by the BIOS, 
 +that is, the
 +machine must have booted to the panel.  If you have a dual head card
@@ -52,25 +170,157 @@
 +Many digital flat panels (particularly ones on laptops) have only 6 bits 
 +per component color resolution.
  This option tells the driver to dither from 8 bits per component to 6 before
- the flat panel truncates it. This is only suported in depth 24 on NV11, 
+-the flat panel truncates it. This is only suported in depth 24 on NV11, 
 -nForce2, GeForce4, Quadro4 and NV30.
++the flat panel truncates it. This is only supported in depth 24 on GeForce2 MX, 
 +nForce2, GeForce4, Quadro4, Geforce FX and Quadro FX.
  Default: off.
  .TP
  .BI "Option \*qRotate\*q \*qCW\*q"
-diff -urN xc.orig/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c
---- xc.orig/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c	2003-02-11 10:42:51.000000000 +1100
-+++ xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c	2003-04-09 05:01:10.000000000 +1000
+Index: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_dac.c
+===================================================================
+RCS file: /cvs/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_dac.c,v
+retrieving revision 1.31
+retrieving revision 1.33
+diff -u -r1.31 -r1.33
+--- xc/programs/Xserver/hw/xfree86/drivers/nv/nv_dac.c	2 Jan 2003 20:44:56 -0000	1.31
++++ xc/programs/Xserver/hw/xfree86/drivers/nv/nv_dac.c	23 Jun 2003 21:38:42 -0000	1.33
 @@ -24,7 +24,7 @@
  /* Hacked together from mga driver and 3.3.4 NVIDIA driver by Jarno Paananen
     <jpaana@s2.org> */
  
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_dac.c,v 1.31 2003/01/02 20:44:56 mvojkovi Exp $ */
++/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_dac.c,v 1.33 2003/06/23 21:38:42 mvojkovi Exp $ */
+ 
+ #include "nv_include.h"
+ 
+@@ -106,6 +106,9 @@
+ 
+     pVga->Attribute[0x10] = 0x01;
+ 
++    if(pNv->Television)
++       pVga->Attribute[0x11] = 0x00;
++
+     nvReg->screen = SetBitField(horizBlankEnd,6:6,4:4)
+                   | SetBitField(vertBlankStart,10:10,3:3)
+                   | SetBitField(vertStart,10:10,2:2)
+@@ -155,8 +158,6 @@
+     if(pNv->riva.Architecture >= NV_ARCH_10)
+ 	pNv->riva.CURSOR = (U032 *)(pNv->FbStart + pNv->riva.CursorStart);
+ 
+-    pNv->riva.LockUnlock(&pNv->riva, 0);
+-
+     pNv->riva.CalcStateExt(&pNv->riva, 
+                            nvReg,
+                            i,
+@@ -171,7 +172,7 @@
+        nvReg->pixel |= (1 << 7);
+        nvReg->scale |= (1 << 8) ;
+     }
+-    if(pNv->SecondCRTC) {
++    if(pNv->CRTCnumber) {
+        nvReg->head  = pNv->riva.PCRTC0[0x00000860/4] & ~0x00001000;
+        nvReg->head2 = pNv->riva.PCRTC0[0x00002860/4] | 0x00001000;
+        nvReg->crtcOwner = 3;
+@@ -251,10 +252,13 @@
+     saveFonts = FALSE;
+ #endif
+ 
++    pNv->riva.LockUnlock(&pNv->riva, 0);
++
+     vgaHWSave(pScrn, vgaReg, VGA_SR_CMAP | VGA_SR_MODE | 
+                              (saveFonts? VGA_SR_FONTS : 0));
+     pNv->riva.UnloadStateExt(&pNv->riva, nvReg);
+ 
++    /* can't read this reliably on NV11 */
+     if((pNv->Chipset & 0x0ff0) == 0x0110) 
+        nvReg->crtcOwner = ((pNv->Chipset & 0x0fff) == 0x0112) ? 3 : 0;
+ }
+@@ -318,24 +322,6 @@
+ #define DDC_SDA_WRITE_MASK (1 << 4)
+ #define DDC_SCL_WRITE_MASK (1 << 5)
+ 
+-static unsigned int
+-NV_ddc1Read(ScrnInfoPtr pScrn)
+-{
+-    NVPtr pNv = NVPTR(pScrn);
+-    unsigned char val;
+-
+-    /* wait for Vsync */
+-    while(VGA_RD08(pNv->riva.PCIO, 0x3da) & 0x08);
+-    while(!(VGA_RD08(pNv->riva.PCIO, 0x3da) & 0x08));
+-
+-    /* Get the result */
+-    VGA_WR08(pNv->riva.PCIO, 0x3d4, pNv->DDCBase);
+-    val = VGA_RD08(pNv->riva.PCIO, 0x3d5);
+-    DEBUG(ErrorF("NV_ddc1Read(%p,...) returns %d\n",
+-                 pScrn, val));
+-    return (val & DDC_SDA_READ_MASK) != 0;
+-}
+-
+ static void
+ NV_I2CGetBits(I2CBusPtr b, int *clock, int *data)
+ {
+@@ -376,8 +362,8 @@
+     DEBUG(ErrorF("NV_I2CPutBits(%p, %d, %d) val=0x%x\n", b, clock, data, val));
+ }
+ 
+-static Bool
+-NV_i2cInit(ScrnInfoPtr pScrn)
++Bool
++NVDACi2cInit(ScrnInfoPtr pScrn)
+ {
+     NVPtr pNv = NVPTR(pScrn);
+     I2CBusPtr I2CPtr;
+@@ -399,17 +385,3 @@
+     return TRUE;
+ }
+ 
+-/*
+- * NVRamdacInit
+- */
+-void
+-NVRamdacInit(ScrnInfoPtr pScrn)
+-{
+-    NVPtr pNv = NVPTR(pScrn);
+-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "NVRamdacInit\n"));
+-    pNv->ddc1Read = NV_ddc1Read;
+-    /* vgaHWddc1SetSpeed will only work if the card is in VGA mode */
+-    pNv->DDC1SetSpeed = vgaHWddc1SetSpeed;
+-    pNv->i2cInit = NV_i2cInit;
+-}
+-
+Index: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c
+===================================================================
+RCS file: /cvs/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c,v
+retrieving revision 1.101
+retrieving revision 1.110
+diff -u -r1.101 -r1.110
+--- xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c	10 Feb 2003 23:42:51 -0000	1.101
++++ xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c	16 Jul 2003 19:53:46 -0000	1.110
+@@ -24,7 +24,7 @@
+ /* Hacked together from mga driver and 3.3.4 NVIDIA driver by Jarno Paananen
+    <jpaana@s2.org> */
+ 
 -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c,v 1.101 2003/02/10 23:42:51 mvojkovi Exp $ */
-+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c,v 1.104 2003/03/19 18:02:49 mvojkovi Exp $ */
++/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c,v 1.110 2003/07/16 19:53:46 mvojkovi Exp $ */
  
  #include "nv_include.h"
  
-@@ -145,8 +145,8 @@
+@@ -84,6 +84,7 @@
+   { 0x12D20018, "RIVA 128" },
+   { 0x10DE0020, "RIVA TNT" },
+   { 0x10DE0028, "RIVA TNT2" },
++  { 0x10DE002A, "Unknown TNT2" },
+   { 0x10DE002C, "Vanta" },
+   { 0x10DE0029, "RIVA TNT2 Ultra" },
+   { 0x10DE002D, "RIVA TNT2 Model 64" },
+@@ -140,30 +141,38 @@
+   { 0x10DE028C, "Quadro4 700 GoGL" },
+   { 0x10DE0288, "Quadro4 980 XGL" },
+   { 0x10DE0289, "Quadro4 780 XGL" },
+-  { 0x10DE0300, "0x0300" },
+   { 0x10DE0301, "GeForce FX 5800 Ultra" },
    { 0x10DE0302, "GeForce FX 5800" },
    { 0x10DE0308, "Quadro FX 2000" },
    { 0x10DE0309, "Quadro FX 1000" },
@@ -78,10 +328,18 @@
 -  { 0x10DE0312, "0x0312" },
 +  { 0x10DE0311, "GeForce FX 5600 Ultra" },
 +  { 0x10DE0312, "GeForce FX 5600" },
++  { 0x10DE0313, "0x0313"},
++  { 0x10DE0314, "GeForce FX 5600SE" },
    { 0x10DE0316, "0x0316" },
    { 0x10DE0317, "0x0317" },
-   { 0x10DE0318, "0x0318" },
-@@ -157,13 +157,16 @@
+-  { 0x10DE0318, "0x0318" },
+-  { 0x10DE0319, "0x0319" },
+-  { 0x10DE031A, "0x031A" },
+-  { 0x10DE031B, "0x031B" },
+-  { 0x10DE031C, "0x031C" },
++  { 0x10DE031A, "GeForce FX Go5600" },
++  { 0x10DE031B, "GeForce FX Go5650" },
++  { 0x10DE031C, "Quadro FX Go700" },
    { 0x10DE031D, "0x031D" },
    { 0x10DE031E, "0x031E" },
    { 0x10DE031F, "0x031F" },
@@ -93,17 +351,23 @@
 -  { 0x10DE0326, "0x0326" },
 +  { 0x10DE0324, "GeForce FX Go5200" },
 +  { 0x10DE0325, "GeForce FX Go5250" },
++  { 0x10DE0323, "0x0323" },
++  { 0x10DE0328, "0x0328" },
++  { 0x10DE0329, "0x0329" },
    { 0x10DE032A, "0x032A" },
 -  { 0x10DE032B, "0x032B" },
 -  { 0x10DE032E, "0x032E" },
 +  { 0x10DE032B, "Quadro FX 500" },
 +  { 0x10DE032C, "0x032C" },
-+  { 0x10DE032D, "0x032D" },
++  { 0x10DE032D, "GeForce FX Go5100" },
 +  { 0x10DE032F, "0x032F" },
++  { 0x10DE0330, "GeForce FX 5900 Ultra" },
++  { 0x10DE0331, "GeForce FX 5900" },
++  { 0x10DE0338, "Quadro FX 3000" },
    {-1, NULL}
  };
  
-@@ -178,6 +181,7 @@
+@@ -178,6 +187,7 @@
   */
  
  static const char *vgahwSymbols[] = {
@@ -111,28 +375,254 @@
      "vgaHWDPMSSet",
      "vgaHWFreeHWRec",
      "vgaHWGetHWRec",
-@@ -1568,11 +1572,18 @@
+@@ -188,7 +198,6 @@
+     "vgaHWRestore",
+     "vgaHWSave",
+     "vgaHWSaveScreen",
+-    "vgaHWddc1SetSpeed",
+     NULL
+ };
+ 
+@@ -215,22 +224,17 @@
+     NULL
+ };
+ 
+-#define NVuseI2C 1
+-
+ static const char *ddcSymbols[] = {
+     "xf86PrintEDID",
+-    "xf86DoEDID_DDC1",
+-#if NVuseI2C
+     "xf86DoEDID_DDC2",
+-#endif
+     "xf86SetDDCproperties",
+     NULL
+ };
+ 
+ static const char *vbeSymbols[] = {
+     "VBEInit",
+-    "vbeDoEDID",
+     "vbeFree",
++    "vbeDoEDID",
+     NULL
+ };
+ 
+@@ -729,129 +733,37 @@
+     return (MODE_OK);
+ }
+ 
+-static xf86MonPtr
+-nvDoDDC2(ScrnInfoPtr pScrn)
+-{
+-    NVPtr pNv = NVPTR(pScrn);
+-    xf86MonPtr MonInfo = NULL;
+-
+-    if (!pNv->i2cInit) return NULL;
+-
+-    /* - DDC can use I2C bus */
+-    /* Load I2C if we have the code to use it */
+-    if ( xf86LoadSubModule(pScrn, "i2c") ) {
+-        xf86LoaderReqSymLists(i2cSymbols,NULL);
+-        if (pNv->i2cInit(pScrn)) {
+-	    DEBUG(ErrorF("I2C initialized on %p\n",pNv->I2C));
+-	    if ((MonInfo = xf86DoEDID_DDC2(pScrn->scrnIndex,pNv->I2C))) {  
+-	        xf86DrvMsg(pScrn->scrnIndex, X_INFO, "DDC Monitor info: %p\n",
+-			   MonInfo);
+-		xf86PrintEDID( MonInfo );
+-		xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of DDC Monitor "
+-			   "info\n\n");
+-		xf86SetDDCproperties(pScrn,MonInfo);
+-	    }
+-	}
+-    }
+-    return MonInfo;
+-}
+-
+-#if 0
+-static xf86MonPtr
+-nvDoDDC1(ScrnInfoPtr pScrn)
+-{
+-    NVPtr pNv = NVPTR(pScrn);
+-    xf86MonPtr MonInfo = NULL;
+-
+-    if (!pNv->ddc1Read || !pNv->DDC1SetSpeed) return NULL;
+-    if (!pNv->Primary 
+-	&& (pNv->DDC1SetSpeed == vgaHWddc1SetSpeed)) return NULL;
+-
+-    if ((MonInfo = xf86DoEDID_DDC1(pScrn->scrnIndex, pNv->DDC1SetSpeed,
+-				  pNv->ddc1Read ))) {
+-        xf86DrvMsg(pScrn->scrnIndex, X_INFO, "DDC Monitor info: %p\n",
+-		   MonInfo);
+-	xf86PrintEDID( MonInfo );
+-	xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of DDC Monitor info\n\n");
+-	xf86SetDDCproperties(pScrn,MonInfo);
+-    }
+-    return MonInfo;
+-}
+-#endif
+- 
+-/*
+-static xf86MonPtr
+-nvDoDDCVBE(ScrnInfoPtr pScrn)
++static void
++nvProbeDDC(ScrnInfoPtr pScrn, int index)
+ {
+-    NVPtr pNv = NVPTR(pScrn);
+-    xf86MonPtr MonInfo = NULL;
+     vbeInfoPtr pVbe;
+ 
+     if (xf86LoadSubModule(pScrn, "vbe")) {
+-        xf86LoaderReqSymLists(vbeSymbols,NULL);
+-	pVbe = VBEInit(pNv->pInt,pNv->pEnt->index);
+-	if (pVbe) {
+-	    if ((MonInfo = vbeDoEDID(pVbe,NULL))) {
+-	        xf86DrvMsg(pScrn->scrnIndex, X_INFO, "DDC Monitor info: %p\n",
+- 			   MonInfo);
+- 		xf86PrintEDID( MonInfo );       
+- 		xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of DDC Monitor info\n\n");
+- 		xf86SetDDCproperties(pScrn,MonInfo);
+- 	    }
+- 	    vbeFree(pVbe);
+- 	}
+-     }
+-     return MonInfo;
++        pVbe = VBEInit(NULL,index);
++        ConfiguredMonitor = vbeDoEDID(pVbe, NULL);
++	vbeFree(pVbe);
++    }
+ }
+-*/ 
+-
+-/* Internally used */
+-xf86MonPtr
+-NVdoDDC(ScrnInfoPtr pScrn)
+-{
+-    NVPtr pNv;
+-    NVRamdacPtr NVdac;
+-    xf86MonPtr MonInfo = NULL;
+-
+-    pNv = NVPTR(pScrn);
+-    NVdac = &pNv->Dac;
+-
+-    /* Load DDC if we have the code to use it */
+-
+-    if (!xf86LoadSubModule(pScrn, "ddc")) return NULL;
+-    
+-    xf86LoaderReqSymLists(ddcSymbols, NULL);
+ 
+-    /*    if ((MonInfo = nvDoDDCVBE(pScrn))) return MonInfo;      */
+ 
+-    /* Enable access to extended registers */
+-    pNv->riva.LockUnlock(&pNv->riva, 0);
+-    /* Save the current state */
+-    NVSave(pScrn);
+-
+-    if ((MonInfo = nvDoDDC2(pScrn))) goto done;
+-#if 0 /* disable for now - causes problems on AXP */
+-    if ((MonInfo = nvDoDDC1(pScrn))) goto done;
+-#endif
++Bool NVI2CInit(ScrnInfoPtr pScrn)
++{
++    char *mod = "i2c";
+ 
+- done:
+-    /* Restore previous state */
+-    NVRestore(pScrn);
+-    pNv->riva.LockUnlock(&pNv->riva, 1);
++    if (xf86LoadSubModule(pScrn, mod)) {
++        xf86LoaderReqSymLists(i2cSymbols,NULL);
+ 
+-    return MonInfo;
+-}
++        mod = "ddc";
++        if(xf86LoadSubModule(pScrn, mod)) {
++            xf86LoaderReqSymLists(ddcSymbols, NULL);
++            return NVDACi2cInit(pScrn);
++        } 
++    }
+ 
+-static void
+-nvProbeDDC(ScrnInfoPtr pScrn, int index)
+-{
+-    vbeInfoPtr pVbe;
++    xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
++              "Couldn't load %s module.  DDC probing can't be done\n", mod);
+ 
+-    if (xf86LoadSubModule(pScrn, "vbe")) {
+-        pVbe = VBEInit(NULL,index);
+-        ConfiguredMonitor = vbeDoEDID(pVbe, NULL);
+-	vbeFree(pVbe);
+-    }
++    return FALSE;
+ }
+ 
+ /* Mandatory */
+@@ -1170,15 +1082,17 @@
+     if (xf86GetOptValBool(pNv->Options, OPTION_FP_DITHER, &(pNv->FPDither))) 
+         xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "enabling flat panel dither\n");
+ 
+-    if (xf86GetOptValInteger(pNv->Options, OPTION_CRTC_NUMBER, 
+-                                &pNv->forceCRTC)) 
++    if (xf86GetOptValInteger(pNv->Options, OPTION_CRTC_NUMBER,
++                             &pNv->CRTCnumber)) 
+     {
+-	if((pNv->forceCRTC < 0) || (pNv->forceCRTC > 1)) {
+-           pNv->forceCRTC = -1;
++	if((pNv->CRTCnumber < 0) || (pNv->CRTCnumber > 1)) {
++           pNv->CRTCnumber = -1;
+            xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, 
+                       "Invalid CRTC number.  Must be 0 or 1\n");
+         }
+-    } else pNv->forceCRTC = -1;
++    } else {
++        pNv->CRTCnumber = -1; /* autodetect later */
++    }
+ 
+     
+     if (pNv->pEnt->device->MemBase != 0) {
+@@ -1341,11 +1255,15 @@
+     clockRanges->maxClock = pNv->MaxClock;
+     clockRanges->clockIndex = -1;		/* programmable */
+     if(((pNv->Chipset & 0x0ff0) <= 0x0100) ||
+-       ((pNv->Chipset & 0x0ff0) == 0x0150))
++       ((pNv->Chipset & 0x0ff0) == 0x0150) ||
++       ((pNv->Chipset & 0x0ff0) >= 0x0300))
+     {
+        clockRanges->interlaceAllowed = TRUE;
+-    } else  /* Chips after NV15 (including NV11) do not support interlaced */
++    } else {
++        /* No NV2x chips support interlaced modes and the only
++           NV1x chips that do are NV10 and NV15 */
+        clockRanges->interlaceAllowed = FALSE;
++    }
+     clockRanges->doubleScanAllowed = TRUE;
+ 
+     if(pNv->FlatPanel == 1) {
+@@ -1565,13 +1483,21 @@
+ 	return FALSE;
+     pScrn->vtSema = TRUE;
+ 
++    vgaReg = &hwp->ModeReg;
++    nvReg = &pNv->ModeReg;
++
      if(!(*pNv->ModeInit)(pScrn, mode))
          return FALSE;
  
--    /* Program the registers */
--    vgaHWProtect(pScrn, TRUE);
-     vgaReg = &hwp->ModeReg;
-     nvReg = &pNv->ModeReg;
- 
++    pNv->riva.LockUnlock(&pNv->riva, 0);
 +    if(pNv->riva.twoHeads) {
 +        VGA_WR08(pNv->riva.PCIO, 0x03D4, 0x44);
 +        VGA_WR08(pNv->riva.PCIO, 0x03D5, nvReg->crtcOwner);
 +        pNv->riva.LockUnlock(&pNv->riva, 0);
-+     }
++    }
 +
-+    /* Program the registers */
-+    vgaHWProtect(pScrn, TRUE);
-+
+     /* Program the registers */
+     vgaHWProtect(pScrn, TRUE);
+-    vgaReg = &hwp->ModeReg;
+-    nvReg = &pNv->ModeReg;
+ 
      (*pNv->Restore)(pScrn, vgaReg, nvReg, FALSE);
  
- #if X_BYTE_ORDER == X_BIG_ENDIAN
-@@ -1608,6 +1619,13 @@
+@@ -1608,6 +1534,15 @@
      NVRegPtr nvReg = &pNv->SavedReg;
  
      DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "NVRestore\n"));
@@ -143,20 +633,41 @@
 +        pNv->riva.LockUnlock(&pNv->riva, 0);
 +    }
 +
++    pNv->riva.LockUnlock(&pNv->riva, 0);
++
      /* Only restore text mode fonts/text for the primary card */
      vgaHWProtect(pScrn, TRUE);
      (*pNv->Restore)(pScrn, vgaReg, nvReg, pNv->Primary);
-@@ -1639,6 +1657,9 @@
+@@ -1619,6 +1554,7 @@
+ {
+   unsigned char crtc1A;
+   vgaHWPtr hwp = VGAHWPTR(pScrn);
++  NVPtr pNv = NVPTR(pScrn);
+ 
+   if (!pScrn->vtSema) return;
+ 
+@@ -1639,7 +1575,11 @@
      break;
    }
  
+-  hwp->writeCrtc(hwp, 0x1A, crtc1A);
 +  /* vgaHWDPMSSet will merely cut the dac output */
 +  vgaHWDPMSSet(pScrn, PowerManagementMode, flags);
 +
-   hwp->writeCrtc(hwp, 0x1A, crtc1A);
++  if(!pNv->FlatPanel)  /* this doesn't work for flat panels */
++     hwp->writeCrtc(hwp, 0x1A, crtc1A);
  }
  
-@@ -1874,13 +1895,7 @@
+ 
+@@ -1695,7 +1635,6 @@
+ 	    return FALSE;
+     } else {
+ 	/* Save the current state */
+-        pNv->riva.LockUnlock(&pNv->riva, 0);
+ 	NVSave(pScrn);
+ 	/* Initialise the first mode */
+ 	if (!NVModeInit(pScrn, pScrn->currentMode))
+@@ -1874,13 +1813,7 @@
  	ShadowFBInit(pScreen, refreshArea);
      }
  
@@ -170,63 +681,868 @@
      DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "- DPMS set up\n"));
  
      DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "- Color maps etc. set up\n"));
-diff -urN xc.orig/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c
---- xc.orig/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c	2003-02-11 10:42:51.000000000 +1100
-+++ xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c	2003-04-09 05:01:10.000000000 +1000
-@@ -229,8 +229,12 @@
-        case 0x031D:
-        case 0x031E:
-        case 0x031F:
+@@ -1888,7 +1821,8 @@
+     pScrn->memPhysBase = pNv->FbAddress;
+     pScrn->fbOffset = 0;
+ 
+-    NVInitVideo(pScreen);
++    if(pNv->Rotate == 0)
++       NVInitVideo(pScreen);
+ 
+     pScreen->SaveScreen = NVSaveScreen;
+ 
+Index: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_proto.h
+===================================================================
+RCS file: /cvs/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_proto.h,v
+retrieving revision 1.8
+retrieving revision 1.9
+diff -u -r1.8 -r1.9
+--- xc/programs/Xserver/hw/xfree86/drivers/nv/nv_proto.h	26 Nov 2002 23:41:59 -0000	1.8
++++ xc/programs/Xserver/hw/xfree86/drivers/nv/nv_proto.h	4 May 2003 01:20:52 -0000	1.9
+@@ -1,4 +1,4 @@
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_proto.h,v 1.8 2002/11/26 23:41:59 mvojkovi Exp $ */
++/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_proto.h,v 1.9 2003/05/04 01:20:52 mvojkovi Exp $ */
+ 
+ #ifndef __NV_PROTO_H__
+ #define __NV_PROTO_H__
+@@ -6,11 +6,10 @@
+ /* in nv_driver.c */
+ Bool    NVSwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
+ void    NVAdjustFrame(int scrnIndex, int x, int y, int flags);
+-xf86MonPtr NVdoDDC(ScrnInfoPtr pScrn);
++Bool    NVI2CInit(ScrnInfoPtr pScrn);
+ 
+ 
+ /* in nv_dac.c */
+-void    NVRamdacInit(ScrnInfoPtr pScrn);
+ Bool    NVDACInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
+ void    NVDACSave(ScrnInfoPtr pScrn, vgaRegPtr vgaReg,
+                   NVRegPtr nvReg, Bool saveFonts);
+@@ -18,6 +17,8 @@
+                      NVRegPtr nvReg, Bool restoreFonts);
+ void    NVDACLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
+                          LOCO *colors, VisualPtr pVisual );
++Bool    NVDACi2cInit(ScrnInfoPtr pScrn);
++
+ 
+ /* in nv_video.c */
+ void NVInitVideo(ScreenPtr);
+@@ -25,7 +26,6 @@
+ 
+ /* in nv_setup.c */
+ void    RivaEnterLeave(ScrnInfoPtr pScrn, Bool enter);
+-void    NV1Setup(ScrnInfoPtr pScrn);
+ void    NV3Setup(ScrnInfoPtr pScrn);
+ void    NV4Setup(ScrnInfoPtr pScrn);
+ void    NV10Setup(ScrnInfoPtr pScrn);
+@@ -42,5 +42,6 @@
+ /* in nv_dga.c */
+ Bool    NVDGAInit(ScreenPtr pScreen);
+ 
++
+ #endif /* __NV_PROTO_H__ */
+ 
+Index: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c
+===================================================================
+RCS file: /cvs/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c,v
+retrieving revision 1.27.2.1
+retrieving revision 1.34
+diff -u -r1.27.2.1 -r1.34
+--- xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c	9 May 2003 02:17:49 -0000	1.27.2.1
++++ xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c	23 Jun 2003 21:38:42 -0000	1.34
+@@ -24,7 +24,7 @@
+ /* Hacked together from mga driver and 3.3.4 NVIDIA driver by Jarno Paananen
+    <jpaana@s2.org> */
+ 
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c,v 1.27.2.1 2003/05/09 02:17:49 dawes Exp $ */
++/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_setup.c,v 1.34 2003/06/23 21:38:42 mvojkovi Exp $ */
+ 
+ #include "nv_include.h"
+ 
+@@ -153,14 +153,18 @@
+ }
+ 
+ static Bool 
+-NVIsConnected (ScrnInfoPtr pScrn, Bool second)
++NVIsConnected (ScrnInfoPtr pScrn, int output)
+ {
+     NVPtr pNv = NVPTR(pScrn);
+     volatile U032 *PRAMDAC = pNv->riva.PRAMDAC0;
+     CARD32 reg52C, reg608;
+     Bool present;
+ 
+-    if(second) PRAMDAC += 0x800;
++    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
++               "Probing for analog device on output %s...\n", 
++                output ? "B" : "A");
++
++    if(output) PRAMDAC += 0x800;
+ 
+     reg52C = PRAMDAC[0x052C/4];
+     reg608 = PRAMDAC[0x0608/4];
+@@ -178,6 +182,11 @@
+ 
+     present = (PRAMDAC[0x0608/4] & (1 << 28)) ? TRUE : FALSE;
+ 
++    if(present)
++       xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "  ...found one\n");
++    else
++       xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "  ...can't find one\n");
++
+     pNv->riva.PRAMDAC0[0x0608/4] &= 0x0000EFFF;
+ 
+     PRAMDAC[0x052C/4] = reg52C;
+@@ -187,74 +196,49 @@
+ }
+ 
+ static void
+-NVOverrideCRTC(ScrnInfoPtr pScrn)
++NVSelectHeadRegisters(ScrnInfoPtr pScrn, int head)
+ {
+     NVPtr pNv = NVPTR(pScrn);
+ 
+-    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+-               "Detected CRTC controller %i being used\n",
+-               pNv->SecondCRTC ? 1 : 0);
+-
+-    if(pNv->forceCRTC != -1) {
+-        xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+-                   "Forcing usage of CRTC %i\n", pNv->forceCRTC);
+-        pNv->SecondCRTC = pNv->forceCRTC;
++    if(head) {
++       pNv->riva.PCIO = pNv->riva.PCIO0 + 0x2000;
++       pNv->riva.PCRTC = pNv->riva.PCRTC0 + 0x800;
++       pNv->riva.PRAMDAC = pNv->riva.PRAMDAC0 + 0x800;
++       pNv->riva.PDIO = pNv->riva.PDIO0 + 0x2000;
++    } else {
++       pNv->riva.PCIO = pNv->riva.PCIO0;
++       pNv->riva.PCRTC = pNv->riva.PCRTC0;
++       pNv->riva.PRAMDAC = pNv->riva.PRAMDAC0;
++       pNv->riva.PDIO = pNv->riva.PDIO0;
+     }
+ }
+ 
+-static void
+-NVIsSecond (ScrnInfoPtr pScrn)
++
++
++static xf86MonPtr 
++NVProbeDDC (ScrnInfoPtr pScrn, int bus)
+ {
+     NVPtr pNv = NVPTR(pScrn);
++    xf86MonPtr MonInfo = NULL;
+ 
+-    if(pNv->FlatPanel == 1) {
+-       switch(pNv->Chipset & 0xffff) {
+-       case 0x0174:
+-       case 0x0175:
+-       case 0x0176:
+-       case 0x0177:
+-       case 0x0179:
+-       case 0x017C:
+-       case 0x017D:
+-       case 0x0186:
+-       case 0x0187:
+-       /* this might not be a good default for the chips below */
+-       case 0x0286:
+-       case 0x028C:
+-       case 0x0316:
+-       case 0x0317:
+-       case 0x031A:
+-       case 0x031B:
+-       case 0x031C:
+-       case 0x031D:
+-       case 0x031E:
+-       case 0x031F:
 -       case 0x0326:
 -       case 0x032E:
-+       case 0x0324:
-+       case 0x0325:
-+       case 0x0328:
-+       case 0x0329:
-+       case 0x032C:
-+       case 0x032D:
-            pNv->SecondCRTC = TRUE;
-            break;
-        default:
-@@ -377,8 +381,12 @@
-        case 0x031D:
-        case 0x031E:
-        case 0x031F:
+-           pNv->SecondCRTC = TRUE;
+-           break;
+-       default:
+-           pNv->SecondCRTC = FALSE;
+-           break;
+-       }
++    if(!pNv->I2C) return NULL;
++
++    pNv->DDCBase = bus ? 0x36 : 0x3e;
++
++    xf86DrvMsg(pScrn->scrnIndex, X_INFO, 
++               "Probing for EDID on I2C bus %s...\n", bus ? "B" : "A");
++
++    if ((MonInfo = xf86DoEDID_DDC2(pScrn->scrnIndex, pNv->I2C))) {
++       xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
++                  "DDC detected a %s:\n", MonInfo->features.input_type ?
++                  "DFP" : "CRT");
++       xf86PrintEDID( MonInfo );
+     } else {
+-       if(NVIsConnected(pScrn, 0)) {
+-          if(pNv->riva.PRAMDAC0[0x0000052C/4] & 0x100)
+-             pNv->SecondCRTC = TRUE;
+-          else
+-             pNv->SecondCRTC = FALSE;
+-       } else 
+-       if (NVIsConnected(pScrn, 1)) {
+-          pNv->DDCBase = 0x36;
+-          if(pNv->riva.PRAMDAC0[0x0000252C/4] & 0x100)
+-             pNv->SecondCRTC = TRUE;
+-          else
+-             pNv->SecondCRTC = FALSE;
+-       } else /* default */
+-          pNv->SecondCRTC = FALSE;
++       xf86DrvMsg(pScrn->scrnIndex, X_INFO, 
++                  "  ... none found\n");
+     }
+ 
+-    NVOverrideCRTC(pScrn);
++    return MonInfo;
+ }
+ 
+ static void
+@@ -263,6 +247,13 @@
+     NVPtr pNv = NVPTR(pScrn);
+     vgaHWPtr pVga = VGAHWPTR(pScrn);
+     CARD32 regBase = pNv->IOAddress;
++    CARD16 implementation = pNv->Chipset & 0x0ff0;
++    xf86MonPtr monitorA, monitorB;
++    Bool mobile = FALSE;
++    Bool tvA = FALSE;
++    Bool tvB = FALSE;
++    int FlatPanel = -1;   /* really means the CRTC is slaved */
++    Bool Television = FALSE;
+     int mmioFlags;
+     
+     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "NVCommonSetup\n"));
+@@ -307,39 +298,26 @@
+      * No IRQ in use.
+      */
+     pNv->riva.EnableIRQ = 0;
+-    /*
+-     * Map remaining registers. This MUST be done in the OS specific driver code.
+-     */
+     pNv->riva.IO      = VGA_IOBASE_COLOR;
+ 
+-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "- IO %x\n", pNv->riva.IO));
+-
+     mmioFlags = VIDMEM_MMIO | VIDMEM_READSIDEEFFECT;
+ 
+     pNv->riva.PRAMDAC0 = xf86MapPciMem(pScrn->scrnIndex, mmioFlags, pNv->PciTag,
+                                       regBase+0x00680000, 0x00003000);
+-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "- PRAMDAC %x\n", pNv->riva.PRAMDAC0));
+     pNv->riva.PFB     = xf86MapPciMem(pScrn->scrnIndex, mmioFlags, pNv->PciTag,
+                                       regBase+0x00100000, 0x00001000);
+-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "- PFB %x\n", pNv->riva.PFB));
+     pNv->riva.PFIFO   = xf86MapPciMem(pScrn->scrnIndex, mmioFlags, pNv->PciTag,
+                                       regBase+0x00002000, 0x00002000);
+-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "- PFIFO %x\n", pNv->riva.PFIFO));
+     pNv->riva.PGRAPH  = xf86MapPciMem(pScrn->scrnIndex, mmioFlags, pNv->PciTag,
+                                       regBase+0x00400000, 0x00002000);
+-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "- PGRAPH %x\n", pNv->riva.PGRAPH));
+     pNv->riva.PEXTDEV = xf86MapPciMem(pScrn->scrnIndex, mmioFlags, pNv->PciTag,
+                                       regBase+0x00101000, 0x00001000);
+-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "- PEXTDEV %x\n", pNv->riva.PEXTDEV));
+     pNv->riva.PTIMER  = xf86MapPciMem(pScrn->scrnIndex, mmioFlags, pNv->PciTag,
+                                       regBase+0x00009000, 0x00001000);
+-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "- PTIMER %x\n", pNv->riva.PTIMER));
+     pNv->riva.PMC     = xf86MapPciMem(pScrn->scrnIndex, mmioFlags, pNv->PciTag,
+                                       regBase+0x00000000, 0x00009000);
+-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "- PMC %x\n", pNv->riva.PMC));
+     pNv->riva.FIFO    = xf86MapPciMem(pScrn->scrnIndex, mmioFlags, pNv->PciTag,
+                                       regBase+0x00800000, 0x00010000);
+-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "- FIFO %x\n", pNv->riva.FIFO));
+ 
+     /*
+      * These registers are read/write as 8 bit values.  Probably have to map
+@@ -355,115 +333,267 @@
+                                            pNv->PciTag, regBase+0x000C0000,
+                                            0x00001000);
+ 
+-    if(pNv->FlatPanel == -1) {
+-       switch(pNv->Chipset & 0xffff) {
+-       case 0x0112:   /* known laptop chips */
+-       case 0x0174:
+-       case 0x0175:
+-       case 0x0176:
+-       case 0x0177:
+-       case 0x0179:
+-       case 0x017C:
+-       case 0x017D:
+-       case 0x0186:
+-       case 0x0187:
+-       case 0x0286:
+-       case 0x028C:
+-       case 0x0316:
+-       case 0x0317:
+-       case 0x031A:
+-       case 0x031B:
+-       case 0x031C:
+-       case 0x031D:
+-       case 0x031E:
+-       case 0x031F:
 -       case 0x0326:
 -       case 0x032E:
-+       case 0x0324:
-+       case 0x0325:
-+       case 0x0328:
-+       case 0x0329:
-+       case 0x032C:
-+       case 0x032D:
-            xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
-                       "On a laptop.  Assuming Digital Flat Panel\n");
-            pNv->FlatPanel = 1;
-diff -urN xc.orig/programs/Xserver/hw/xfree86/drivers/nv/nv_video.c xc/programs/Xserver/hw/xfree86/drivers/nv/nv_video.c
---- xc.orig/programs/Xserver/hw/xfree86/drivers/nv/nv_video.c	2002-11-27 10:41:59.000000000 +1100
-+++ xc/programs/Xserver/hw/xfree86/drivers/nv/nv_video.c	2003-04-09 05:01:10.000000000 +1000
+-           xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+-                      "On a laptop.  Assuming Digital Flat Panel\n");
+-           pNv->FlatPanel = 1;
+-           break;
+-       default:
+-           break;
+-       }
+-    }
+-
+-    pNv->DDCBase = 0x3e;
++    if(pNv->riva.Architecture == 3)
++       pNv->riva.PCRTC0 = pNv->riva.PGRAPH;
+ 
+-    switch(pNv->Chipset & 0x0ff0) {
+-    case 0x0110:
+-        if((pNv->Chipset & 0xffff) == 0x0112)
+-            pNv->SecondCRTC = TRUE;
+-#if defined(__powerpc__)
+-        else if(pNv->FlatPanel == 1)
+-            pNv->SecondCRTC = TRUE;
+-#endif
+-        NVOverrideCRTC(pScrn);
+-        break;
+-    case 0x0170:
+-    case 0x0180:
+-    case 0x01F0:
+-    case 0x0250:
+-    case 0x0280:
+-    case 0x0300:
+-    case 0x0310:
+-    case 0x0320:
+-    case 0x0330:
+-    case 0x0340:
+-        NVIsSecond(pScrn);
++    pNv->twoHeads =  (implementation >= 0x0110) &&
++                     (implementation != 0x0150) &&
++                     (implementation != 0x01A0) &&
++                     (implementation != 0x0200);
++
++    /* look for known laptop chips */
++    switch(pNv->Chipset & 0xffff) {
++    case 0x0112:
++    case 0x0174:
++    case 0x0175:
++    case 0x0176:
++    case 0x0177:
++    case 0x0179:
++    case 0x017C:
++    case 0x017D:
++    case 0x0186:
++    case 0x0187:
++    case 0x0286:
++    case 0x028C:
++    case 0x0316:
++    case 0x0317:
++    case 0x031A:
++    case 0x031B:
++    case 0x031C:
++    case 0x031D:
++    case 0x031E:
++    case 0x031F:
++    case 0x0324:
++    case 0x0325:
++    case 0x0328:
++    case 0x0329:
++    case 0x032C:
++    case 0x032D:
++        mobile = TRUE;
+         break;
+     default:
+         break;
+     }
++ 
++    RivaGetConfig(pNv);
+ 
+-    if(pNv->riva.Architecture == 3)
+-       pNv->riva.PCRTC0 = pNv->riva.PGRAPH;
++    NVSelectHeadRegisters(pScrn, 0);
+ 
+-    if(pNv->SecondCRTC) {
+-       pNv->riva.PCIO = pNv->riva.PCIO0 + 0x2000;
+-       pNv->riva.PCRTC = pNv->riva.PCRTC0 + 0x800;
+-       pNv->riva.PRAMDAC = pNv->riva.PRAMDAC0 + 0x800;
+-       pNv->riva.PDIO = pNv->riva.PDIO0 + 0x2000;
++    pNv->riva.LockUnlock(&pNv->riva, 0);
++
++    NVI2CInit(pScrn);
++
++    pNv->Television = FALSE;
++
++    if(!pNv->twoHeads) {
++       pNv->CRTCnumber = 0;
++       if((monitorA = NVProbeDDC(pScrn, 0))) {
++           FlatPanel = monitorA->features.input_type ? 1 : 0;
++
++           /* NV3 and NV4 don't support FlatPanels */
++           if((pNv->Chipset & 0x0fff) <= 0x0020)
++              FlatPanel = 0;
++       } else {
++           VGA_WR08(pNv->riva.PCIO, 0x03D4, 0x28);
++           if(VGA_RD08(pNv->riva.PCIO, 0x03D5) & 0x80) {
++              VGA_WR08(pNv->riva.PCIO, 0x03D4, 0x33);
++              if(!(VGA_RD08(pNv->riva.PCIO, 0x03D5) & 0x01)) 
++                 Television = TRUE;
++              FlatPanel = 1;
++           } else {
++              FlatPanel = 0;
++           }
++           xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
++                         "HW is currently programmed for %s\n",
++                          FlatPanel ? (Television ? "TV" : "DFP") : "CRT");
++       } 
++
++       if(pNv->FlatPanel == -1) {
++           pNv->FlatPanel = FlatPanel;
++           pNv->Television = Television;
++       } else {
++           xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
++                      "Forcing display type to %s as specified\n", 
++                       pNv->FlatPanel ? "DFP" : "CRT");
++       }
+     } else {
+-       pNv->riva.PCIO = pNv->riva.PCIO0;
+-       pNv->riva.PCRTC = pNv->riva.PCRTC0;
+-       pNv->riva.PRAMDAC = pNv->riva.PRAMDAC0;
+-       pNv->riva.PDIO = pNv->riva.PDIO0;
+-    }
++       CARD8 outputAfromCRTC, outputBfromCRTC;
++       int CRTCnumber = -1;
++       CARD8 slaved_on_A, slaved_on_B;
++       Bool analog_on_A, analog_on_B;
++       CARD32 oldhead;
++       CARD8 cr44;
++      
++       if(implementation != 0x0110) {
++           if(pNv->riva.PRAMDAC0[0x0000052C/4] & 0x100)
++               outputAfromCRTC = 1;
++           else            
++               outputAfromCRTC = 0;
++           if(pNv->riva.PRAMDAC0[0x0000252C/4] & 0x100)
++               outputBfromCRTC = 1;
++           else
++               outputBfromCRTC = 0;
++          analog_on_A = NVIsConnected(pScrn, 0);
++          analog_on_B = NVIsConnected(pScrn, 1);
++       } else {
++          outputAfromCRTC = 0;
++          outputBfromCRTC = 1;
++          analog_on_A = FALSE;
++          analog_on_B = FALSE;
++       }
+ 
+-    RivaGetConfig(pNv);
+ 
+-    pNv->Dac.maxPixelClock = pNv->riva.MaxVClockFreqKHz;
++       VGA_WR08(pNv->riva.PCIO, 0x03D4, 0x44);
++       cr44 = VGA_RD08(pNv->riva.PCIO, 0x03D5);
+ 
+-    pNv->riva.LockUnlock(&pNv->riva, 0);
++       VGA_WR08(pNv->riva.PCIO, 0x03D5, 3);
++       NVSelectHeadRegisters(pScrn, 1);
++       pNv->riva.LockUnlock(&pNv->riva, 0);
++
++       VGA_WR08(pNv->riva.PCIO, 0x03D4, 0x28);
++       slaved_on_B = VGA_RD08(pNv->riva.PCIO, 0x03D5) & 0x80;
++       if(slaved_on_B) {
++           VGA_WR08(pNv->riva.PCIO, 0x03D4, 0x33);
++           tvB = !(VGA_RD08(pNv->riva.PCIO, 0x03D5) & 0x01);
++       }
+ 
+-    NVRamdacInit(pScrn);
++       VGA_WR08(pNv->riva.PCIO, 0x03D4, 0x44);
++       VGA_WR08(pNv->riva.PCIO, 0x03D5, 0);
++       NVSelectHeadRegisters(pScrn, 0);
++       pNv->riva.LockUnlock(&pNv->riva, 0);
++
++       VGA_WR08(pNv->riva.PCIO, 0x03D4, 0x28);
++       slaved_on_A = VGA_RD08(pNv->riva.PCIO, 0x03D5) & 0x80; 
++       if(slaved_on_A) {
++           VGA_WR08(pNv->riva.PCIO, 0x03D4, 0x33);
++           tvA = !(VGA_RD08(pNv->riva.PCIO, 0x03D5) & 0x01);
++       }
+ 
+-#if !defined(__powerpc__)
+-    /* Read and print the Monitor DDC info */
+-    pScrn->monitor->DDC = NVdoDDC(pScrn);
+-#endif
+-    if(pNv->FlatPanel == -1) {
+-        pNv->FlatPanel = 0;
+-        if(pScrn->monitor->DDC) {
+-           xf86MonPtr ddc = (xf86MonPtr)pScrn->monitor->DDC;
+-
+-           if(ddc->features.input_type) {
+-               pNv->FlatPanel = 1;
+-               xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+-                         "autodetected Digital Flat Panel\n");
++       oldhead = pNv->riva.PCRTC0[0x00000860/4];
++       pNv->riva.PCRTC0[0x00000860/4] = oldhead | 0x00000010;
++
++       monitorA = NVProbeDDC(pScrn, 0);
++       monitorB = NVProbeDDC(pScrn, 1);
++
++       if(slaved_on_A) {
++          CRTCnumber = 0;
++          FlatPanel = 1;
++          Television = tvA;
++          xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
++                    "CRTC 0 is currently programmed for %s\n",
++                     Television ? "TV" : "DFP");
++       } else 
++       if(slaved_on_B) {
++          CRTCnumber = 1;
++          FlatPanel = 1;
++          Television = tvB;
++          xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
++                    "CRTC 1 is currently programmed for %s\n",
++                     Television ? "TV" : "DFP");
++       } else
++       if(analog_on_A) {
++          CRTCnumber = outputAfromCRTC;
++          FlatPanel = 0;
++          xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
++                    "CRTC %i appears to have a CRT attached\n", CRTCnumber);
++       } else
++       if(analog_on_B) {
++           CRTCnumber = outputBfromCRTC;
++           FlatPanel = 0;
++           xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
++                    "CRTC %i appears to have a CRT attached\n", CRTCnumber);
++       } else if(monitorA) {
++           FlatPanel = monitorA->features.input_type ? 1 : 0;
++       } else if(monitorB) {
++           FlatPanel = monitorB->features.input_type ? 1 : 0;
++       }
++
++       if(pNv->FlatPanel == -1) {
++          if(FlatPanel != -1) {
++             pNv->FlatPanel = FlatPanel;
++             pNv->Television = Television;
++          } else {
++             xf86DrvMsg(pScrn->scrnIndex, X_INFO,
++                        "Unable to detect display type...\n");
++             if(mobile) {
++                 xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT,
++                            "...On a laptop, assuming DFP\n");
++                 pNv->FlatPanel = 1;
++             } else {
++                 xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT,
++                            "...Using default of CRT\n");
++                 pNv->FlatPanel = 0;
++             }
++          }
++       } else {
++           xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
++                      "Forcing display type to %s as specified\n", 
++                       pNv->FlatPanel ? "DFP" : "CRT");
++       }
++
++       if(pNv->CRTCnumber == -1) {
++          if(CRTCnumber != -1) pNv->CRTCnumber = CRTCnumber;
++          else {
++             xf86DrvMsg(pScrn->scrnIndex, X_INFO,
++                        "Unable to detect which CRTCNumber...\n");
++             if(pNv->FlatPanel) pNv->CRTCnumber = 1;
++             else pNv->CRTCnumber = 0;
++             xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT,
++                        "...Defaulting to CRTCNumber %i\n", pNv->CRTCnumber);
++          }
++       } else {
++           xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
++                      "Forcing CRTCNumber %i as specified\n", pNv->CRTCnumber);
++       }
++     
++       if(monitorA) {
++           if((monitorA->features.input_type && pNv->FlatPanel) ||
++              (!monitorA->features.input_type && !pNv->FlatPanel))
++           {
++               if(monitorB) { 
++                  xfree(monitorB);
++                  monitorB = NULL;
++               }
++           } else {
++              xfree(monitorA);
++              monitorA = NULL;
+            }
+-        }
++       }
++
++       if(monitorB) {
++           if((monitorB->features.input_type && !pNv->FlatPanel) ||
++              (!monitorB->features.input_type && pNv->FlatPanel)) 
++           {
++              xfree(monitorB);
++           } else {
++              monitorA = monitorB;
++           }
++           monitorB = NULL;
++       }
++
++       if(implementation == 0x0110)
++           cr44 = pNv->CRTCnumber * 0x3;
++
++       pNv->riva.PCRTC0[0x00000860/4] = oldhead;
++
++       VGA_WR08(pNv->riva.PCIO, 0x03D4, 0x44);
++       VGA_WR08(pNv->riva.PCIO, 0x03D5, cr44);
++       NVSelectHeadRegisters(pScrn, pNv->CRTCnumber);
+     }
+-    pNv->riva.flatPanel = (pNv->FlatPanel > 0) ? FP_ENABLE : 0;
+-    if(pNv->riva.flatPanel && pNv->FPDither && (pScrn->depth == 24))
+-       pNv->riva.flatPanel |= FP_DITHER;
+ 
+-}
++    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
++              "Using %s on CRTC %i\n",
++              pNv->FlatPanel ? (pNv->Television ? "TV" : "DFP") : "CRT", 
++              pNv->CRTCnumber);
+ 
+-void
+-NV1Setup(ScrnInfoPtr pScrn)
+-{
++    if(monitorA)
++      xf86SetDDCproperties(pScrn, monitorA);
++
++    pNv->Dac.maxPixelClock = pNv->riva.MaxVClockFreqKHz;
++
++    pNv->riva.flatPanel = pNv->FlatPanel ? FP_ENABLE : 0;
++    if(pNv->riva.flatPanel && pNv->FPDither && (pScrn->depth == 24))
++       pNv->riva.flatPanel |= FP_DITHER;
+ }
+ 
+ void
+@@ -475,13 +605,7 @@
+ 
+     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "NV3Setup\n"));
+ 
+-    /*
+-     * Record chip architecture based in PCI probe.
+-     */
+     pNv->riva.Architecture = 3;
+-    /*
+-     * Map chip-specific memory-mapped registers. This MUST be done in the OS specific driver code.
+-     */
+     mmioFlags = VIDMEM_MMIO | VIDMEM_READSIDEEFFECT;
+     pNv->riva.PRAMIN = xf86MapPciMem(pScrn->scrnIndex, mmioFlags, pNv->PciTag,
+                                      frameBase+0x00C00000, 0x00008000);
+@@ -499,9 +623,6 @@
+     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "NV4Setup\n"));
+ 
+     pNv->riva.Architecture = 4;
+-    /*
+-     * Map chip-specific memory-mapped registers. This MUST be done in the OS specific driver code.
+-     */
+     mmioFlags = VIDMEM_MMIO | VIDMEM_READSIDEEFFECT;
+     pNv->riva.PRAMIN = xf86MapPciMem(pScrn->scrnIndex, mmioFlags, pNv->PciTag,
+                                      regBase+0x00710000, 0x00010000);
+Index: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_type.h
+===================================================================
+RCS file: /cvs/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_type.h,v
+retrieving revision 1.39
+retrieving revision 1.41
+diff -u -r1.39 -r1.41
+--- xc/programs/Xserver/hw/xfree86/drivers/nv/nv_type.h	28 Nov 2002 23:02:13 -0000	1.39
++++ xc/programs/Xserver/hw/xfree86/drivers/nv/nv_type.h	23 Jun 2003 21:38:42 -0000	1.41
 @@ -1,4 +1,4 @@
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_type.h,v 1.39 2002/11/28 23:02:13 mvojkovi Exp $ */
++/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_type.h,v 1.41 2003/06/23 21:38:42 mvojkovi Exp $ */
+ 
+ #ifndef __NV_STRUCT_H__
+ #define __NV_STRUCT_H__
+@@ -105,9 +105,6 @@
+     unsigned int        opaqueMonochrome;
+     int                 currentRop;
+     /* I2C / DDC */
+-    unsigned int        (*ddc1Read)(ScrnInfoPtr);
+-    void                (*DDC1SetSpeed)(ScrnInfoPtr, xf86ddcSpeed);
+-    Bool                (*i2cInit)(ScrnInfoPtr);
+     I2CBusPtr           I2C;
+     xf86Int10InfoPtr    pInt;
+     void		(*VideoTimerCallback)(ScrnInfoPtr, Time);
+@@ -115,11 +112,12 @@
+     int			videoKey;
+     int			FlatPanel;
+     Bool                FPDither;
+-    Bool		SecondCRTC;
+-    int			forceCRTC;
++    Bool                Television;
++    int			CRTCnumber;
+     OptionInfoPtr	Options;
+     Bool                alphaCursor;
+     unsigned char       DDCBase;
++    Bool                twoHeads;
+ } NVRec, *NVPtr;
+ 
+ #define NVPTR(p) ((NVPtr)((p)->driverPrivate))
+Index: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_video.c
+===================================================================
+RCS file: /cvs/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_video.c,v
+retrieving revision 1.11
+retrieving revision 1.14
+diff -u -r1.11 -r1.14
+--- xc/programs/Xserver/hw/xfree86/drivers/nv/nv_video.c	26 Nov 2002 23:41:59 -0000	1.11
++++ xc/programs/Xserver/hw/xfree86/drivers/nv/nv_video.c	23 Apr 2003 21:51:42 -0000	1.14
+@@ -1,4 +1,4 @@
 -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_video.c,v 1.11 2002/11/26 23:41:59 mvojkovi Exp $ */
-+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_video.c,v 1.12 2003/03/13 22:29:40 mvojkovi Exp $ */
++/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_video.c,v 1.14 2003/04/23 21:51:42 tsi Exp $ */
  
  #include "xf86.h"
  #include "xf86_OSproc.h"
-@@ -626,10 +626,9 @@
-   int            w
- )
- {
+@@ -29,12 +29,6 @@
+ 
+ #define TIMER_MASK      (OFF_TIMER | FREE_TIMER)
+ 
+-
+-
+-#ifndef XvExtension
+-void NVInitVideo(ScreenPtr pScreen) {}
+-#else
+-
+ typedef struct _NVPortPrivRec {
+    short        brightness;
+    short        contrast;
+@@ -351,41 +345,6 @@
+     return adapt;
+ }
+ 
+-/*
+- * RegionsEqual
+- */
+-static Bool RegionsEqual
+-(
+-    RegionPtr A,
+-    RegionPtr B
+-)
+-{
+-    int *dataA, *dataB;
+-    int num;
+-    
+-    num = REGION_NUM_RECTS(A);
+-    if (num != REGION_NUM_RECTS(B))
+-        return FALSE;
+-    
+-    if ((A->extents.x1 != B->extents.x1) ||
+-        (A->extents.x2 != B->extents.x2) ||
+-        (A->extents.y1 != B->extents.y1) ||
+-        (A->extents.y2 != B->extents.y2))
+-        return FALSE;
+-    
+-    dataA = (int*)REGION_RECTS(A);
+-    dataB = (int*)REGION_RECTS(B);
+-    
+-    while(num--)
+-    {
+-        if((dataA[0] != dataB[0]) || (dataA[1] != dataB[1]))
+-            return FALSE;
+-        dataA += 2; 
+-        dataB += 2;
+-    }
+-    return TRUE;
+-}
+-
+ static void
+ NVPutOverlayImage (
+     ScrnInfoPtr pScrnInfo,
+@@ -413,7 +372,8 @@
+ 
+     /* paint the color key */
+     if(pPriv->autopaintColorKey && 
+-       (pPriv->grabbedByV4L || !RegionsEqual(&pPriv->clip, clipBoxes)))
++       (pPriv->grabbedByV4L ||
++	!REGION_EQUAL(pScrnInfo->pScreen, &pPriv->clip, clipBoxes)))
+     {
+ 	/* we always paint V4L's color key */
+ 	if(!pPriv->grabbedByV4L)
+@@ -613,87 +573,7 @@
+     *p_w = drw_w;
+     *p_h = drw_h; 
+ }
+-/*
+- * CopyData
+- */
+-static void NVCopyData422
+-(
+-  unsigned char *src,
+-  unsigned char *dst,
+-  int            srcPitch,
+-  int            dstPitch,
+-  int            h,
+-  int            w
+-)
+-{
 -    w <<= 1;
 -    while(h--)
 -    {
 -        memcpy(dst, src, w);
-+    w >>= 1;  /* pixels to DWORDS */
-+    while(h--) {
-+        XAAMoveDWORDS((CARD32*)dst, (CARD32*)src, w);
-         src += srcPitch;
-         dst += dstPitch;
-     }
-@@ -723,7 +722,7 @@
+-        src += srcPitch;
+-        dst += dstPitch;
+-    }
+-}
+-/*
+- * CopyMungedData
+- */
+-static void NVCopyData420
+-(
+-    unsigned char *src1,
+-    unsigned char *src2,
+-    unsigned char *src3,
+-    unsigned char *dst1,
+-    int            srcPitch,
+-    int            srcPitch2,
+-    int            dstPitch,
+-    int            h,
+-    int            w
+-)
+-{
+-   CARD32 *dst;
+-   CARD8 *s1, *s2, *s3;
+-   int i, j;
+-
+-   w >>= 1;
+-
+-   for(j = 0; j < h; j++) {
+-        dst = (CARD32*)dst1;
+-        s1 = src1;  s2 = src2;  s3 = src3;
+-        i = w;
+-        while(i > 4) {
+-#if X_BYTE_ORDER == X_BIG_ENDIAN
+-           dst[0] = (s1[0] << 24) | (s1[1] << 8) | (s3[0] << 16) | s2[0];
+-           dst[1] = (s1[2] << 24) | (s1[3] << 8) | (s3[1] << 16) | s2[1];
+-           dst[2] = (s1[4] << 24) | (s1[5] << 8) | (s3[2] << 16) | s2[2];
+-           dst[3] = (s1[6] << 24) | (s1[7] << 8) | (s3[3] << 16) | s2[3];
+-#else
+-           dst[0] = s1[0] | (s1[1] << 16) | (s3[0] << 8) | (s2[0] << 24);
+-           dst[1] = s1[2] | (s1[3] << 16) | (s3[1] << 8) | (s2[1] << 24);
+-           dst[2] = s1[4] | (s1[5] << 16) | (s3[2] << 8) | (s2[2] << 24);
+-           dst[3] = s1[6] | (s1[7] << 16) | (s3[3] << 8) | (s2[3] << 24);
+-#endif
+-           dst += 4; s2 += 4; s3 += 4; s1 += 8;
+-           i -= 4;
+-        }
+-
+-        while(i--) {
+-#if X_BYTE_ORDER == X_BIG_ENDIAN
+-           dst[0] = (s1[0] << 24) | (s1[1] << 8) | (s3[0] << 16) | s2[0];
+-#else
+-           dst[0] = s1[0] | (s1[1] << 16) | (s3[0] << 8) | (s2[0] << 24);
+-#endif
+-           dst++; s2++; s3++;
+-           s1 += 2;
+-        }
+ 
+-        dst1 += dstPitch;
+-        src1 += srcPitch;
+-        if(j & 1) {
+-            src2 += srcPitch2;
+-            src3 += srcPitch2;
+-        }
+-   }
+-}
+ /*
+  * PutImage
+  */
+@@ -723,7 +603,7 @@
      unsigned char *dst_start;
      int pitch, newSize, offset, s2offset, s3offset;
      int srcPitch, srcPitch2, dstPitch;
@@ -235,7 +1551,7 @@
      Bool skip = FALSE;
      BoxRec dstBox;
      CARD32 tmp;
-@@ -823,15 +822,27 @@
+@@ -823,15 +703,27 @@
  
      dst_start = pNv->FbStart + offset;
          
@@ -267,15 +1583,19 @@
          dst_start += (left << 1) + (top * dstPitch);
          tmp = ((top >> 1) * srcPitch2) + (left >> 1);
          s2offset += tmp;
-@@ -841,7 +852,6 @@
+@@ -841,19 +733,21 @@
             s2offset = s3offset;
             s3offset = tmp;
          }
 -        nlines = ((((yb + 0xffff) >> 16) + 1) & ~1) - top;
-         NVCopyData420(buf + (top * srcPitch) + left, buf + s2offset,
-                            buf + s3offset, dst_start, srcPitch, srcPitch2,
-                            dstPitch, nlines, npixels);
-@@ -849,10 +859,12 @@
+-        NVCopyData420(buf + (top * srcPitch) + left, buf + s2offset,
+-                           buf + s3offset, dst_start, srcPitch, srcPitch2,
+-                           dstPitch, nlines, npixels);
++        xf86XVCopyYUV12ToPacked(buf + (top * srcPitch) + left,
++				buf + s2offset, buf + s3offset,
++				dst_start, srcPitch, srcPitch2,
++				dstPitch, nlines, npixels);
+         break;
      case FOURCC_UYVY:
      case FOURCC_YUY2:
      default:
@@ -285,19 +1605,131 @@
          buf += (top * srcPitch) + left;
 -        nlines = ((yb + 0xffff) >> 16) - top;
          dst_start += left + (top * dstPitch);
+-        NVCopyData422(buf, dst_start, srcPitch, dstPitch, nlines, npixels);
 +
-         NVCopyData422(buf, dst_start, srcPitch, dstPitch, nlines, npixels);
++        xf86XVCopyPacked(buf, dst_start, srcPitch, dstPitch, nlines, npixels);
          break;
      }
-diff -urN xc.orig/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.c xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.c
---- xc.orig/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.c	2003-02-11 10:42:51.000000000 +1100
-+++ xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.c	2003-04-09 05:01:10.000000000 +1000
+ 
+@@ -973,7 +867,6 @@
+ {
+     NVPtr pNv = NVPTR(pScrnInfo);
+     NVPortPrivPtr pPriv = GET_OVERLAY_PRIVATE(pNv); 
+-    CARD8 *address;
+     int size, bpp;
+ 
+     bpp = pScrnInfo->bitsPerPixel >> 3;
+@@ -992,7 +885,6 @@
+     if(!pPriv->linear) return BadAlloc;
+ 
+     pPriv->offset = pPriv->linear->offset * bpp;
+-    address = pPriv->offset + pNv->FbStart;
+ 
+     surface->width = w;
+     surface->height = h;
+@@ -1154,7 +1046,3 @@
+ {
+     xf86XVRegisterOffscreenImages(pScreen, NVOffscreenImages, 2);
+ }
+-
+-#endif
+-
+-
+Index: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_xaa.c
+===================================================================
+RCS file: /cvs/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_xaa.c,v
+retrieving revision 1.29
+retrieving revision 1.30
+diff -u -r1.29 -r1.30
+--- xc/programs/Xserver/hw/xfree86/drivers/nv/nv_xaa.c	12 Feb 2003 21:26:27 -0000	1.29
++++ xc/programs/Xserver/hw/xfree86/drivers/nv/nv_xaa.c	8 Mar 2003 23:45:14 -0000	1.30
+@@ -41,7 +41,7 @@
+ /* Hacked together from mga driver and 3.3.4 NVIDIA driver by
+    Jarno Paananen <jpaana@s2.org> */
+ 
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_xaa.c,v 1.29 2003/02/12 21:26:27 mvojkovi Exp $ */
++/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_xaa.c,v 1.30 2003/03/08 23:45:14 mvojkovi Exp $ */
+ 
+ #include "nv_include.h"
+ #include "xaalocal.h"
+@@ -75,8 +75,7 @@
+ static void
+ NVSetPattern(NVPtr pNv, int clr0, int clr1, int pat0, int pat1)
+ {
+-    RIVA_FIFO_FREE(pNv->riva, Patt, 5);
+-    pNv->riva.Patt->Shape         = 0; /* 0 = 8X8, 1 = 64X1, 2 = 1X64 */
++    RIVA_FIFO_FREE(pNv->riva, Patt, 4);
+     pNv->riva.Patt->Color0        = clr0;
+     pNv->riva.Patt->Color1        = clr1;
+     pNv->riva.Patt->Monochrome[0] = pat0;
+@@ -89,9 +88,8 @@
+ static void
+ NVSetRopSolid(NVPtr pNv, int rop)
+ {    
+-    if (pNv->currentRop != rop)
+-    {
+-        if (pNv->currentRop > 16)
++    if (pNv->currentRop != rop) {
++        if (pNv->currentRop >= 16)
+             NVSetPattern(pNv, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
+         pNv->currentRop = rop;
+         RIVA_FIFO_FREE(pNv->riva, Rop, 1);
+@@ -102,8 +100,7 @@
+ static void
+ NVSetRopPattern(NVPtr pNv, int rop)
+ {
+-    if (pNv->currentRop != rop + 16)
+-    {
++    if (pNv->currentRop != (rop + 16)) {
+         pNv->currentRop = rop + 16; /* +16 is important */
+         RIVA_FIFO_FREE(pNv->riva, Rop, 1);
+         pNv->riva.Rop->Rop3 = XAAPatternROP[rop];
+@@ -219,8 +216,11 @@
+ 
+     if(pNv->NoAccel) return;
+ 
+-    pNv->currentRop = -1;
+-    NVSetRopPattern(pNv, GXcopy); 
++    RIVA_FIFO_FREE(pNv->riva, Patt, 1);
++    pNv->riva.Patt->Shape = 0; 
++    NVDisableClipping(pScrn);
++    pNv->currentRop = 16;  /* to force NVSetRopSolid to reset the pattern */
++    NVSetRopSolid(pNv, GXcopy);
+ }
+ 
+ 
+@@ -510,8 +510,6 @@
+      */
+     pNv->opaqueMonochrome = ~((1 << pScrn->depth) - 1);
+ 
+-    pNv->currentRop = -1;
+-
+     infoPtr->Mono8x8PatternFillFlags = HARDWARE_PATTERN_SCREEN_ORIGIN |
+ 				       HARDWARE_PATTERN_PROGRAMMED_BITS |
+ 				       NO_PLANEMASK;
+@@ -566,7 +564,7 @@
+     infoPtr->ValidatePolyPoint = NVValidatePolyPoint;
+     infoPtr->PolyPointMask = GCFunction | GCPlaneMask;
+    
+-    NVDisableClipping(pScrn);
++    NVResetGraphics(pScrn);
+ 
+     return(XAAInit(pScreen, infoPtr));
+ }
+Index: xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.c
+===================================================================
+RCS file: /cvs/xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.c,v
+retrieving revision 1.47
+retrieving revision 1.50
+diff -u -r1.47 -r1.50
+--- xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.c	10 Feb 2003 23:42:51 -0000	1.47
++++ xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.c	8 Jul 2003 18:03:57 -0000	1.50
 @@ -36,7 +36,7 @@
  |*     those rights set forth herein.                                        *|
  |*                                                                           *|
   \***************************************************************************/
 -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.c,v 1.47 2003/02/10 23:42:51 mvojkovi Exp $ */
-+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.c,v 1.48 2003/03/12 21:27:18 mvojkovi Exp $ */
++/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.c,v 1.50 2003/07/08 18:03:57 mvojkovi Exp $ */
  
  #include "nv_local.h"
  #include "compiler.h"
@@ -313,3 +1745,105 @@
  
              LOAD_FIXED_STATE(nv10,PFIFO);
              LOAD_FIXED_STATE(nv10,PRAMIN);
+@@ -1964,33 +1959,7 @@
+ 
+         chip->RamAmountKBytes = (((amt >> 4) & 127) + 1) * 1024;
+     } else {
+-      switch ((chip->PFB[0x0000020C/4] >> 20) & 0x000000FF)
+-      {
+-        case 0x02:
+-            chip->RamAmountKBytes = 1024 * 2;
+-            break;
+-        case 0x04:
+-            chip->RamAmountKBytes = 1024 * 4;
+-            break;
+-        case 0x08:
+-            chip->RamAmountKBytes = 1024 * 8;
+-            break;
+-        case 0x10:
+-            chip->RamAmountKBytes = 1024 * 16;
+-            break;
+-        case 0x20:
+-            chip->RamAmountKBytes = 1024 * 32;
+-            break;
+-        case 0x40:
+-            chip->RamAmountKBytes = 1024 * 64;
+-            break;
+-        case 0x80:
+-            chip->RamAmountKBytes = 1024 * 128;
+-            break;
+-        default:
+-            chip->RamAmountKBytes = 1024 * 16;
+-            break;
+-      }
++        chip->RamAmountKBytes = (chip->PFB[0x020C/4] & 0xFFF00000) >> 10;
+     }
+     switch ((chip->PFB[0x00000000/4] >> 3) & 0x00000003)
+     {
+@@ -2036,25 +2005,6 @@
+     chip->UnloadStateExt  = UnloadStateExt;
+     chip->SetStartAddress = SetStartAddress;
+     chip->LockUnlock      = nv4LockUnlock;
+-
+-    switch(pNv->Chipset & 0x0ff0) {
+-    case 0x0110:
+-    case 0x0170:
+-    case 0x0180:
+-    case 0x01F0:
+-    case 0x0250:
+-    case 0x0280:
+-    case 0x0300:
+-    case 0x0310:
+-    case 0x0320:
+-    case 0x0330:
+-    case 0x0340:
+-        chip->twoHeads = TRUE;
+-        break;
+-    default:
+-        chip->twoHeads = FALSE;
+-        break;
+-    }
+ }
+ int RivaGetConfig
+ (
+@@ -2062,10 +2012,8 @@
+ )
+ {
+     RIVA_HW_INST *chip = &pNv->riva;
+-    /*
+-     * Save this so future SW know whats it's dealing with.
+-     */
+-    chip->Version = RIVA_SW_VERSION;
++
++    chip->twoHeads = pNv->twoHeads;
+     /*
+      * Chip specific configuration.
+      */
+Index: xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.h
+===================================================================
+RCS file: /cvs/xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.h,v
+retrieving revision 1.24
+retrieving revision 1.25
+diff -u -r1.24 -r1.25
+--- xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.h	10 Feb 2003 23:42:51 -0000	1.24
++++ xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.h	4 May 2003 01:20:52 -0000	1.25
+@@ -36,10 +36,9 @@
+ |*     those rights set forth herein.                                        *|
+ |*                                                                           *|
+ \***************************************************************************/
+-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.h,v 1.24 2003/02/10 23:42:51 mvojkovi Exp $ */
++/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.h,v 1.25 2003/05/04 01:20:52 mvojkovi Exp $ */
+ #ifndef __RIVA_HW_H__
+ #define __RIVA_HW_H__
+-#define RIVA_SW_VERSION 0x00010003
+ 
+ /*
+  * Define supported architectures.
+@@ -309,7 +308,6 @@
+      * Chip specific settings.
+      */
+     U032 Architecture;
+-    U032 Version;
+     U032 Chipset;
+     U032 CrystalFreqKHz;
+     U032 RamAmountKBytes;



Reply to: