First off, I'd like to say thank you to Branden for your amazing
work. I've been working on your debs for the last few days, and they
build flawlessly. 

I've been asked by my employer to backport the Intel i845 2d driver so
that we can support it in our next release, and so I did. For anyone
interested, the patch is attached. I didn't follow your naming scheme
exactly, so the patch is not 000 even though it's stolen_from_HEAD. I
did this because I didn't want to have to adjust all of your other
patches which were complaining about offsets, just to get the debs to
compile. 

One problem I did encounter is that when I do a "dpkg-buildpackage
-nc" the object files still seem to get cleaned. Is there something
I'm misunderstanding? 

For now, I've only done the most basic testing. RedHat backported the
same driver and includes it in limbo, which I believe is rh8, so it
must be somewhat stable. As I get more results from our testing dept,
I will forward them to you, if you're interested. 

Thanks again,

  michael

-- 
michael cardenas       | lead software engineer, lindows.com
hyperpoem.net          | GNU/Linux software developer
people.debian.org/~mbc | encrypted mail preferred

"The secrets of this earth are not for all men to see, but only for those who 
will seek them"
- Ayn Rand, Anthem
Index: Imakefile
===================================================================
RCS file: /cvs/xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile       2001/10/04 
18:28:21     1.18
+++ xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile       2002/05/10 
12:50:05     1.19
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile,v 1.18 
2001/10/04 18:28:21 alanh Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile,v 1.19 
2002/05/10 12:50:05 alanh Exp $
 XCOMM
 XCOMM This is the Imakefile for the i810 driver.  
 XCOMM 
@@ -31,7 +31,7 @@
            -I$(SERVERSRC)/fb -I$(XF86SRC)/xaa -I$(XF86SRC)/ramdac      \
           -I$(XF86SRC)/vgahw -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c         \
           -I$(XF86OSSRC)/vbe -I$(XF86SRC)/int10                        \
-          -I$(SERVERSRC)/Xext -I$(XF86SRC)/xf24_32bpp                  \
+          -I$(SERVERSRC)/Xext                                          \
            -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC)     \
           -I$(EXTINCSRC) -I$(SERVERSRC)/render                         \
           $(DRIINCLUDES)
Index: i810.h
===================================================================
RCS file: /cvs/xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h  2002/01/25 21:56:03     
1.30
+++ xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h  2002/05/10 12:50:05     
1.31
@@ -824,6 +824,7 @@
                        pI810->PciInfo->chipType == PCI_CHIP_I810_E)
 #define IS_I815(pI810) (pI810->PciInfo->chipType == PCI_CHIP_I815)
 #define IS_I830(pI810) (pI810->PciInfo->chipType == PCI_CHIP_I830_M)
+#define IS_845G(pI810) (pI810->PciInfo->chipType == PCI_CHIP_845_G)
 
 
 #endif
Index: i810_cursor.c
===================================================================
RCS file: /cvs/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_cursor.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- xc/programs/Xserver/hw/xfree86/drivers/i810/i810_cursor.c   2001/10/10 
14:08:36     1.4
+++ xc/programs/Xserver/hw/xfree86/drivers/i810/i810_cursor.c   2002/05/10 
12:50:05     1.5
@@ -25,7 +25,7 @@
 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 **************************************************************************/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_cursor.c,v 1.4 
2001/10/10 14:08:36 alanh Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_cursor.c,v 1.5 
2002/05/10 12:50:05 alanh Exp $ */
 
 /*
  * Authors:
@@ -77,6 +77,13 @@
   infoPtr->ShowCursor = I810ShowCursor;
   infoPtr->UseHWCursor = I810UseHWCursor;
 
+  if (IS_845G (pI810))
+        {
+               OUTREG(0x700A0,0x00040040);
+               OUTREG(0x70084,pI810->CursorStart);
+        }
+   
+   
   if (!pI810->CursorPhysical)
      return FALSE;
 
@@ -158,7 +165,10 @@
    OUTREG8( CURSOR_Y_HI, (((y >> 8) & 0x07) | flag));
 
    /* FIXME */
-   OUTREG(CURABASE, pI810->CursorPhysical);
+   if (IS_845G (pI810))
+        OUTREG(CURABASE,pI810->CursorStart);
+   else
+        OUTREG(CURABASE, pI810->CursorPhysical);
 }
 
 static void
@@ -174,7 +184,17 @@
       temp |= CURSORA_MODE_64_AND_XOR;
       OUTREG(CURACNTR, temp);
       OUTREG(CURABASE, pI810->CursorPhysical);
-   } else {
+         DPRINTF(PFX,"Value of CursorPhysical is %x   Value of CursorStart is 
%x ",pI810->CursorPhysical,pI810->CursorStart);
+ 
+   } else if (IS_845G (pI810))
+        {
+               temp = INREG(CURACNTR);
+               temp &= CURSORA_RESERVED;
+               temp |= 0x80000000;
+               OUTREG(CURACNTR,temp);
+               OUTREG(CURABASE,pI810->CursorStart);
+        }
+   else {
       OUTREG( CURSOR_BASEADDR, pI810->CursorPhysical);
       OUTREG8( CURSOR_CONTROL, CURSOR_ORIGIN_DISPLAY | CURSOR_MODE_64_3C);
 
@@ -197,7 +217,15 @@
       temp |= CURSORA_DISABLE;
       OUTREG(CURACNTR, temp);
       OUTREG(CURABASE, pI810->CursorPhysical);
-   } else {
+   } else if (IS_845G (pI810))
+               {
+                  temp = INREG(CURACNTR);
+                  temp &= 0x7fffffff;
+                  OUTREG(CURACNTR,temp);
+                  OUTREG(CURABASE,pI810->CursorStart);
+               }
+   
+   else {
       tmp=INREG8( PIXPIPE_CONFIG_0 );
       tmp &= ~HW_CURSOR_ENABLE;
       OUTREG8( PIXPIPE_CONFIG_0, tmp);
@@ -215,7 +243,7 @@
    int tmp;
    I810Ptr pI810 = I810PTR(pScrn);
 
-   if(IS_I830(pI810)) {
+   if(IS_I830(pI810) || IS_845G (pI810)) {
       OUTREG(CURAPALET0, bg & 0x00ffffff);
       OUTREG(CURAPALET1, fg & 0x00ffffff);
       OUTREG(CURAPALET2, fg & 0x00ffffff);
Index: i810_driver.c
===================================================================
RCS file: /cvs/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -r1.67 -r1.68
--- xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c   2002/04/04 
14:05:42     1.67
+++ xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c   2002/05/10 
12:50:05     1.68
@@ -103,6 +103,7 @@
    { PCI_CHIP_I810_E,     "i810e"},
    { PCI_CHIP_I815,          "i815"},
    { PCI_CHIP_I830_M,     "i830M"},
+   { PCI_CHIP_845_G,     "845G"},
    { -1, NULL }
 };
 
@@ -112,6 +113,7 @@
    { PCI_CHIP_I810_E,     PCI_CHIP_I810_E,     RES_SHARED_VGA },
    { PCI_CHIP_I815,          PCI_CHIP_I815,       RES_SHARED_VGA },
    { PCI_CHIP_I830_M,     PCI_CHIP_I830_M,     RES_SHARED_VGA },
+   { PCI_CHIP_845_G,      PCI_CHIP_845_G,      RES_SHARED_VGA },
    { -1, -1, RES_UNDEFINED }
 };
 
@@ -409,7 +411,7 @@
 
                   pEnt = xf86GetEntityInfo(usedChips[i]);
 
-                  if (pEnt->chipset == PCI_CHIP_I830_M) {
+                  if (pEnt->chipset == PCI_CHIP_I830_M || pEnt->chipset == 
PCI_CHIP_845_G) {
                           pScrn->driverVersion = I810_VERSION;
                           pScrn->driverName = I810_DRIVER_NAME;
                           pScrn->name = I810_NAME;
@@ -1349,7 +1351,7 @@
    OUTREG(LP_RING + RING_START, itemp );

    itemp = INREG(LP_RING + RING_LEN);
-   if (IS_I830 (pI810)) {
+   if (IS_I830 (pI810) || IS_845G (pI810)) {
           itemp &= ~(I830_RING_NR_PAGES | RING_REPORT_MASK | RING_VALID_MASK);
    } else {
           itemp &= ~(RING_NR_PAGES | RING_REPORT_MASK | RING_VALID_MASK);
Index: i810_memory.c
===================================================================
RCS file: /cvs/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c   2002/01/09 
00:37:30     1.23
+++ xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c   2002/05/10 
12:50:05     1.24
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c,v 1.23 
2002/01/09 00:37:30 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c,v 1.24 
2002/05/10 12:50:05 alanh Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -100,7 +100,7 @@
    /* This allows the 2d only Xserver to regen */
    pI810->agpAcquired2d = TRUE;
 
-   if (IS_I830 (pI810))
+   if (IS_I830 (pI810) || IS_845G (pI810))
         {
                /*
                 * The I830 is slightly different from the I810/I815, it has no
@@ -298,7 +298,7 @@
 
    i810Reg->Fence[nr] = 0;
 
-   fence_mask = IS_I830 (pI810) ? ~I830_FENCE_START_MASK : ~FENCE_START_MASK;
+   fence_mask = IS_I830 (pI810) || IS_845G (pI810) ? ~I830_FENCE_START_MASK : 
~FENCE_START_MASK;
 
    if (start & fence_mask)
         {
@@ -320,7 +320,7 @@
 
    val = (start | FENCE_X_MAJOR | FENCE_VALID);
 
-   if (IS_I830 (pI810))
+   if (IS_I830 (pI810) || IS_845G (pI810))
         {
                switch (size)
                  {
Index: i830_driver.c
===================================================================
RCS file: /cvs/xc/programs/Xserver/hw/xfree86/drivers/i810/i830_driver.c,v
retrieving revision 1.7
retrieving revision 1.10
diff -u -r1.7 -r1.10
--- xc/programs/Xserver/hw/xfree86/drivers/i810/i830_driver.c   2002/01/08 
18:59:29     1.7
+++ xc/programs/Xserver/hw/xfree86/drivers/i810/i830_driver.c   2002/05/10 
12:50:05     1.10
@@ -111,17 +111,20 @@
 #include "dri.h"
 #endif
 
+#define BDG845G_WORKAROUND
 #define BIT(x) (1 << (x))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 #define NB_OF(x) (sizeof (x) / sizeof (*x))
 
 static SymTabRec I830BIOSChipsets[] = {
    { PCI_CHIP_I830_M,    "i830"},
+   { PCI_CHIP_845_G,      "845G"},
    { -1, NULL }
 };
 
 static PciChipsets I830BIOSPciChipsets[] = {
    { PCI_CHIP_I830_M,    PCI_CHIP_I830_M,             RES_SHARED_VGA },
+   { PCI_CHIP_845_G,      PCI_CHIP_845_G,          RES_SHARED_VGA},
    { -1, -1, RES_UNDEFINED }
 };
 
@@ -1852,6 +1855,141 @@
    return (TRUE);
 }
 
+static Bool I830VESASetMode_845G (ScrnInfoPtr pScrn,DisplayModePtr pMode)
+{
+   I810Ptr pI810;
+   VESAPtr pVesa;
+   ModeInfoData *data;
+   int mode;
+
+   pI810 = I810PTR (pScrn);
+   pVesa = pI810->vesa;
+
+   data = (ModeInfoData *) pMode->Private;
+
+   /* Always Enable Linear Addressing */
+   mode = data->mode | (1 << 15) | (1 << 14);
+   
+
+
+#ifdef XF86DRI
+   if(pI810->directRenderingEnabled)
+        {
+               DRILock (screenInfo.screens[pScrn->scrnIndex],0);
+               pI810->LockHeld = 1;
+        }
+#endif
+
+ 
+
+
+   if (I830VESASetVBEMode (pScrn,mode,data->block) == FALSE)
+        {
+               if ((data->block || (data->mode & (1 << 11))) &&
+                       I830VESASetVBEMode (pScrn,(mode & ~(1 << 11)),NULL) == 
TRUE)
+                 {
+                        xf86DrvMsg (pScrn->scrnIndex,X_WARNING,"Set VBE Mode 
rejected this modeline. Trying current mode instead!\n");
+                        DPRINTF (PFX,"OOPS!\n");
+                        xfree (data->block);
+                        data->block = NULL;
+                        data->mode &= ~(1 << 11);
+                 }
+               else
+                 {
+                        xf86DrvMsg (pScrn->scrnIndex,X_ERROR,"Set VBE Mode 
failed!\n");
+                        return (FALSE);
+                 }
+        }
+
+
+   /* test if CRT display is present */
+   pVesa->pInt->num = 0x10;
+   pVesa->pInt->ax = 0x5f55;
+   xf86ExecX86int10_wrapper (pVesa->pInt,pScrn);
+
+   /* is this a CRT? */
+   if (pVesa->pInt->ax == 0x005f && pVesa->pInt->bx != 0x0002)
+        {
+               DPRINTF (PFX,
+                                "data->data = {\n"
+                                "   XResolution: %d\n"
+                                "   YResolution: %d\n"
+                                "}\n",
+                                
data->data->XResolution,data->data->YResolution);
+               if (data->block != NULL)
+                 DPRINTF (PFX,
+                                  "data->block = {\n"
+                                  "       HorizontalTotal: %d\n"
+                                  "   HorizontalSyncStart: %d\n"
+                                  "     HorizontalSyncEnd: %d\n"
+                                  "         VerticalTotal: %d\n"
+                                  "     VerticalSyncStart: %d\n"
+                                  "       VerticalSyncEnd: %d\n"
+                                  "                 Flags: %d\n"
+                                  "            PixelClock: %d\n"
+                                  "           RefreshRate: %d\n"
+                                  "}\n",
+                                  
data->block->HorizontalTotal,data->block->HorizontalSyncStart,data->block->HorizontalSyncEnd,
+                                  
data->block->VerticalTotal,data->block->VerticalSyncStart,data->block->VerticalSyncEnd,
+                                  
data->block->Flags,data->block->PixelClock,data->block->RefreshRate / 100);
+
+               /* make double sure it's not an LCD */
+               pVesa->pInt->num = 0x10;
+               pVesa->pInt->ax = 0x5f64;
+               pVesa->pInt->bx = 0x0100;
+               xf86ExecX86int10_wrapper (pVesa->pInt,pScrn);
+               if (data->data != NULL && data->block != NULL && 
pVesa->pInt->ax == 0x005f && !(pVesa->pInt->cx & 0x0008))
+                 {
+                        int i;
+                        static const int VesaRefresh[] = { 43, 56, 60, 70, 72, 
75, 85, 100, 120, -1 };
+
+                        for (i = 0; VesaRefresh[i] != -1 && VesaRefresh[i] != 
data->block->RefreshRate / 100; i++) ;
+
+                        if (VesaRefresh[i] == data->block->RefreshRate / 100)
+                          {
+                                 DPRINTF (PFX,
+                                                  "Setting refresh rate to 
%dHz for mode %d\n",
+                                                  VesaRefresh[i],
+                                                  mode & 0xff);
+
+                                 pVesa->pInt->num = 0x10;
+                                 pVesa->pInt->ax = 0x5f05;
+                                 pVesa->pInt->bx = mode & 0xff;
+                                 pVesa->pInt->cx = 1 << i;
+                                 xf86ExecX86int10_wrapper (pVesa->pInt,pScrn);
+
+                                 if (pVesa->pInt->ax != 0x5f)
+                                       xf86DrvMsg 
(pScrn->scrnIndex,X_WARNING,"Failed to set refresh rate to 
%dHz!\n",VesaRefresh[i]);
+                          }
+                 }
+        }
+
+   if (data->data->XResolution != pScrn->displayWidth)
+        I830VESASetLogicalScanline (pScrn,pScrn->displayWidth);
+
+   if (pScrn->bitsPerPixel >= 8 && pVesa->vbeInfo->Capabilities[0] & 0x01)
+        I830VESASetGetDACPaletteFormat (pScrn,8);
+
+
+#ifndef BDG845G_WORKAROUND
+   I830BIOSSetRegisters (pScrn,SET_CURRENT_MODE);
+   I810SetRingRegs (pScrn);   
+#endif
+   
+   
+#ifdef XF86DRI
+   if (pI810->directRenderingEnabled)
+        {
+               DRIUnlock (screenInfo.screens[pScrn->scrnIndex]);
+               pI810->LockHeld = 0;
+        }
+#endif
+
+   pScrn->vtSema = TRUE;
+   return (TRUE);
+}
+
+
 CARD32 *
 I830VESASetGetPaletteData(ScrnInfoPtr pScrn, Bool set, int first, int num,
                          CARD32 *data, Bool secondary, Bool wait_retrace)
@@ -2148,8 +2286,14 @@
 
    if (!xf86ReturnOptValBool(I810AvailableOptions(0,0), OPTION_NOACCEL, 
                             FALSE) &&
-       xf86ReturnOptValBool(I810AvailableOptions(0,0), OPTION_DRI, TRUE)) {
-      pI810->directRenderingEnabled = I830DRIScreenInit(pScreen); 
+      xf86ReturnOptValBool(I810AvailableOptions(0,0), OPTION_DRI, TRUE)) {
+
+      /* Disable direct rendering for 845_G - doesn't work yet */
+      if (IS_845G (pI810)) 
+         pI810->directRenderingEnabled = FALSE;
+      else
+        pI810->directRenderingEnabled = I830DRIScreenInit(pScreen); 
+
    } else {
       pI810->directRenderingEnabled = FALSE;
    }
@@ -2425,13 +2569,47 @@
 Bool
 I830BIOSSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
 {
+   
+   int _head;
+   int _tail;
+   int _i;
+   I810Ptr pI810;       
+   ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+   pI810 = I810PTR (pScrn);
+   if (IS_845G(pI810))  /*Stops head pointer freezes for 845G*/
+        { 
+               do
+                {
+                       _head = INREG(LP_RING + RING_HEAD) & HEAD_ADDR;
+                       _tail = INREG(LP_RING + RING_TAIL) & TAIL_ADDR;
+                        for(_i = 0; _i < 65535; _i++);
+                } while (_head != _tail);
+        }
    DPRINTF (PFX,"mode == %s\n",mode);
-   return I830VESASetMode(xf86Screens[scrnIndex], mode);
-}
+
+if (IS_845G (pI810))
+        {
+                       
+               #ifdef BDG845G_WORKAROUND   
+               return I830VESASetMode_845G(xf86Screens[scrnIndex], mode);
+               #else
+           return I830VESASetMode(xf86Screens[scrnIndex], mode);
+               #endif
+               
+        }
+else
+        {
+           return I830VESASetMode(xf86Screens[scrnIndex], mode);               
+        }
+   
+   
+         
+ }
 
 Bool
 I830BIOSSaveScreen(ScreenPtr pScreen, Bool unblack)
 {
+
    return vgaHWSaveScreen(pScreen, unblack);
 }
 
@@ -2463,27 +2641,46 @@
    vgaHWPtr hwp = VGAHWPTR(pScrn);
    I810Ptr pI810 = I810PTR(pScrn);
    VESAPtr pVesa = pI810->vesa;
-   XAAInfoRecPtr infoPtr = pI810->AccelInfoRec;
+   XAAInfoRecPtr infoPtr = pI810->AccelInfoRec;   
 
 #ifdef XF86DRI
    if (pI810->directRenderingEnabled) {
        I830DRICloseScreen(pScreen);
        pI810->directRenderingEnabled = FALSE;
    }
-#endif
+#endif   
 
    if (pScrn->vtSema == TRUE) {
       if(pI810->AccelInfoRec) {
-        I810Sync(pScrn);
-        DO_RING_IDLE();
-      }
+                
+#ifdef BDG845G_WORKAROUND               
+   if (IS_845G(pI810))
+        {
+                         
+        if ((pScrn->virtualY != 1200 && pScrn->virtualX != 1600))
+                  {
+                       DPRINTF(PFX,"Xres = %d  Yres = 
%d",pScrn->virtualX,pScrn->virtualY);  
+                       I810Sync(pScrn);
+                       DO_RING_IDLE();       
+                  }
+               
+         }              
+#else
+                       I810Sync(pScrn);
+                       DO_RING_IDLE();
+                
+#endif
+         }
+         
+
       I830VESASaveRestore(pScrn, MODE_RESTORE);
       I830VESASetGetPaletteData(pScrn, TRUE, 0, 256,
                                pVesa->savedPal, FALSE, TRUE);
-      I810UnbindGARTMemory(pScrn);
+         I810UnbindGARTMemory(pScrn);
       vgaHWLock(hwp);
    }
-
+   
+   DPRINTF(PFX,"\nUnmapping memory\n");
    I810UnmapMem(pScrn);
    vgaHWUnmapMem(pScrn);
 
Index: xf86PciInfo.h
===================================================================
RCS file: /cvs/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h,v
retrieving revision 1.119
retrieving revision 1.127
diff -u -r1.119 -r1.127
--- xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h 2002/01/16 02:00:43     
1.119
+++ xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h 2002/05/10 12:50:05     
1.127
@@ -646,10 +651,12 @@
 #define PCI_CHIP_NM2380                0x0016
 
 /* Intel */
-#define PCI_CHIP_I830_M_BRIDGE         0x3575
-#define PCI_CHIP_I830_M                        0x3577
+#define PCI_CHIP_845_G_BRIDGE 0x2560
+#define PCI_CHIP_845_G 0x2562
 #define PCI_CHIP_I815_BRIDGE           0x1130
 #define PCI_CHIP_I815                  0x1132
+#define PCI_CHIP_I830_M_BRIDGE         0x3575
+#define PCI_CHIP_I830_M                        0x3577
 #define PCI_CHIP_I810_BRIDGE           0x7120
 #define PCI_CHIP_I810                  0x7121
 #define PCI_CHIP_I810_DC100_BRIDGE     0x7122

Reply via email to