xf86-video-intel: Branch 'xf86-video-intel-2.5-branch' - 8 commits - src/i830_accel.c src/i830_dri.c src/i830_driver.c src/i830_exa.c src/i830.h src/i830_sdvo.c src/i830_xaa.c src/reg_dumper/gtt.c src/reg_dumper/Makefile.am

Jesse Barnes jbarnes at kemper.freedesktop.org
Sat Oct 18 15:49:44 PDT 2008


 src/i830.h                 |    2 
 src/i830_accel.c           |    9 ++-
 src/i830_dri.c             |  135 ++++++++++++++++++++++-----------------------
 src/i830_driver.c          |   10 ++-
 src/i830_exa.c             |    4 -
 src/i830_sdvo.c            |    2 
 src/i830_xaa.c             |   10 +--
 src/reg_dumper/Makefile.am |   13 ++++
 src/reg_dumper/gtt.c       |  118 +++++++++++++++++++++++++++++++++++++++
 9 files changed, 222 insertions(+), 81 deletions(-)

New commits:
commit 7ddea0447c8972104d43cd7966f5ce89b4cca20c
Author: Keith Packard <keithp at keithp.com>
Date:   Fri Oct 17 00:07:09 2008 -0700

    Handle differently tiled front/back/depth/third in DRI window management
    
    When moving or clearing the extra buffer contents associated with DRI
    windows, the XAA code needs to see which buffer is being manipulated in the
    Setup functions to program the tiling values correctly. Calling
    I830SelectBuffer and not then calling I830Setup... would result in mis-tiled
    rendering.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Eric Anholt <eric at anholt.net>

diff --git a/src/i830.h b/src/i830.h
index 89f19d2..5da4181 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -748,7 +748,7 @@ extern Bool I830CursorInit(ScreenPtr pScreen);
 extern void IntelEmitInvarientState(ScrnInfoPtr pScrn);
 extern void I830EmitInvarientState(ScrnInfoPtr pScrn);
 extern void I915EmitInvarientState(ScrnInfoPtr pScrn);
-extern void I830SelectBuffer(ScrnInfoPtr pScrn, int buffer);
+extern Bool I830SelectBuffer(ScrnInfoPtr pScrn, int buffer);
 void i830_update_cursor_offsets(ScrnInfoPtr pScrn);
 
 /* CRTC-based cursor functions */
diff --git a/src/i830_accel.c b/src/i830_accel.c
index a9b3005..2743445 100644
--- a/src/i830_accel.c
+++ b/src/i830_accel.c
@@ -244,7 +244,7 @@ I830EmitFlush(ScrnInfoPtr pScrn)
    }
 }
 
-void
+Bool
 I830SelectBuffer(ScrnInfoPtr pScrn, int buffer)
 {
    I830Ptr pI830 = I830PTR(pScrn);
@@ -253,12 +253,18 @@ I830SelectBuffer(ScrnInfoPtr pScrn, int buffer)
 #ifdef XF86DRI
    case I830_SELECT_BACK:
       pI830->bufferOffset = pI830->back_buffer->offset;
+      if (pI830->back_buffer->tiling == TILE_YMAJOR)
+	 return FALSE;
       break;
    case I830_SELECT_THIRD:
       pI830->bufferOffset = pI830->third_buffer->offset;
+      if (pI830->third_buffer->tiling == TILE_YMAJOR)
+	 return FALSE;
       break;
    case I830_SELECT_DEPTH:
       pI830->bufferOffset = pI830->depth_buffer->offset;
+      if (pI830->depth_buffer->tiling == TILE_YMAJOR)
+	 return FALSE;
       break;
 #endif
    default:
@@ -270,6 +276,7 @@ I830SelectBuffer(ScrnInfoPtr pScrn, int buffer)
    if (I810_DEBUG & DEBUG_VERBOSE_ACCEL)
       ErrorF("I830SelectBuffer %d --> offset %x\n",
 	     buffer, pI830->bufferOffset);
+   return TRUE;
 }
 
 /* The following function sets up the supported acceleration. Call it
diff --git a/src/i830_dri.c b/src/i830_dri.c
index bf64fa3..16f3735 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -1193,47 +1193,42 @@ I830DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index)
 {
    ScreenPtr pScreen = pWin->drawable.pScreen;
    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-   BoxPtr pbox = REGION_RECTS(prgn);
-   int nbox = REGION_NUM_RECTS(prgn);
+   BoxPtr pbox;
+   int nbox;
+   int buffer, first_buffer, last_buffer;
 
+   return;
    if (I810_DEBUG & DEBUG_VERBOSE_DRI)
       ErrorF("I830DRIInitBuffers\n");
 
-   I830SetupForSolidFill(pScrn, 0, GXcopy, -1);
-   while (nbox--) {
-      I830SelectBuffer(pScrn, I830_SELECT_BACK);
-      I830SubsequentSolidFillRect(pScrn, pbox->x1, pbox->y1,
-				  pbox->x2 - pbox->x1, pbox->y2 - pbox->y1);
+   first_buffer = I830_SELECT_BACK;
+   last_buffer = I830_SELECT_DEPTH;
+   if (I830PTR(pScrn)->third_buffer)
+      last_buffer = I830_SELECT_THIRD;
 
-      if (I830PTR(pScrn)->third_buffer) {
-	 I830SelectBuffer(pScrn, I830_SELECT_THIRD);
+   for (buffer = first_buffer; buffer <= last_buffer; buffer++) {
+      pbox = REGION_RECTS(prgn);
+      nbox = REGION_NUM_RECTS(prgn);
+
+      if (!I830SelectBuffer(pScrn, buffer))
+	 continue;
+
+      if (buffer == I830_SELECT_DEPTH) {
+	 switch (pScrn->bitsPerPixel) {
+	 case 16:
+	    I830SetupForSolidFill(pScrn, 0xffff, GXcopy, -1);
+	    break;
+	 case 32:
+	    I830SetupForSolidFill(pScrn, 0xffffff, GXcopy, -1);
+	    break;
+	 }
+      } else
+	 I830SetupForSolidFill(pScrn, 0, GXcopy, -1);
+      while (nbox--) {
 	 I830SubsequentSolidFillRect(pScrn, pbox->x1, pbox->y1,
 				     pbox->x2 - pbox->x1, pbox->y2 - pbox->y1);
+	 pbox++;
       }
-
-      pbox++;
-   }
-
-   /* Clear the depth buffer - uses 0xffff rather than 0.
-    */
-   pbox = REGION_RECTS(prgn);
-   nbox = REGION_NUM_RECTS(prgn);
-
-   I830SelectBuffer(pScrn, I830_SELECT_DEPTH);
-
-   switch (pScrn->bitsPerPixel) {
-   case 16:
-      I830SetupForSolidFill(pScrn, 0xffff, GXcopy, -1);
-      break;
-   case 32:
-      I830SetupForSolidFill(pScrn, 0xffffff, GXcopy, -1);
-      break;
-   }
-
-   while (nbox--) {
-      I830SubsequentSolidFillRect(pScrn, pbox->x1, pbox->y1,
-				  pbox->x2 - pbox->x1, pbox->y2 - pbox->y1);
-      pbox++;
    }
 
    I830SelectBuffer(pScrn, I830_SELECT_FRONT);
@@ -1274,6 +1269,7 @@ I830DRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg,
 
    int dx = pParent->drawable.x - ptOldOrg.x;
    int dy = pParent->drawable.y - ptOldOrg.y;
+   int buffer, first_buffer, last_buffer;
 
    /* If the copy will overlap in Y, reverse the order */
    if (dy > 0) {
@@ -1355,44 +1351,47 @@ I830DRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg,
    /* SelectBuffer isn't really a good concept for the i810.
     */
    I830EmitFlush(pScrn);
-   I830SetupForScreenToScreenCopy(pScrn, xdir, ydir, GXcopy, -1, -1);
-   for (; nbox--; pbox++) {
-
-      int x1 = pbox->x1;
-      int y1 = pbox->y1;
-      int destx = x1 + dx;
-      int desty = y1 + dy;
-      int w = pbox->x2 - x1 + 1;
-      int h = pbox->y2 - y1 + 1;
-
-      if (destx < 0)
-	 x1 -= destx, w += destx, destx = 0;
-      if (desty < 0)
-	 y1 -= desty, h += desty, desty = 0;
-      if (destx + w > screenwidth)
-	 w = screenwidth - destx;
-      if (desty + h > screenheight)
-	 h = screenheight - desty;
-      if (w <= 0)
-	 continue;
-      if (h <= 0)
-	 continue;
+   first_buffer = I830_SELECT_BACK;
+   last_buffer = I830_SELECT_DEPTH;
+   if (pI830->third_buffer)
+      last_buffer = I830_SELECT_THIRD;
 
-      if (I810_DEBUG & DEBUG_VERBOSE_DRI)
-	 ErrorF("MoveBuffers %d,%d %dx%d dx: %d dy: %d\n",
-		x1, y1, w, h, dx, dy);
+   for (buffer = first_buffer; buffer <= last_buffer; buffer++) {
+      if (!I830SelectBuffer(pScrn, buffer))
+	 continue;
+      I830SetupForScreenToScreenCopy(pScrn, xdir, ydir, GXcopy, -1, -1);
+      pbox = REGION_RECTS(prgnSrc);
+      nbox = REGION_NUM_RECTS(prgnSrc);
+      for (; nbox--; pbox++) {
+
+	 int x1 = pbox->x1;
+	 int y1 = pbox->y1;
+	 int destx = x1 + dx;
+	 int desty = y1 + dy;
+	 int w = pbox->x2 - x1 + 1;
+	 int h = pbox->y2 - y1 + 1;
+
+	 if (destx < 0)
+	    x1 -= destx, w += destx, destx = 0;
+	 if (desty < 0)
+	    y1 -= desty, h += desty, desty = 0;
+	 if (destx + w > screenwidth)
+	    w = screenwidth - destx;
+	 if (desty + h > screenheight)
+	    h = screenheight - desty;
+	 if (w <= 0)
+	    continue;
+	 if (h <= 0)
+	    continue;
+
+	 if (I810_DEBUG & DEBUG_VERBOSE_DRI)
+	    ErrorF("MoveBuffers %d,%d %dx%d dx: %d dy: %d\n",
+		   x1, y1, w, h, dx, dy);
 
-      I830SelectBuffer(pScrn, I830_SELECT_BACK);
-      I830SubsequentScreenToScreenCopy(pScrn, x1, y1, destx, desty, w, h);
-      if (pI830->third_buffer) {
-	 I830SelectBuffer(pScrn, I830_SELECT_THIRD);
 	 I830SubsequentScreenToScreenCopy(pScrn, x1, y1, destx, desty, w, h);
       }
-      if (!IS_I965G(pI830)) {
-         I830SelectBuffer(pScrn, I830_SELECT_DEPTH);
-         I830SubsequentScreenToScreenCopy(pScrn, x1, y1, destx, desty, w, h);
-      }
    }
+
    I830SelectBuffer(pScrn, I830_SELECT_FRONT);
    I830EmitFlush(pScrn);
 
commit c946383afc644ae7740e3c3146424fdd86c05285
Author: Keith Packard <keithp at keithp.com>
Date:   Fri Oct 17 00:07:08 2008 -0700

    XAA tiling support was mis-computing adjusted pitch (>>4 instead of >>2)
    
    This may well explain why XAA never worked well on tiled front buffers;
    tiled buffers require a different pitch programming on 965 than non-tiled
    buffers, in dwords rather than bytes.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Eric Anholt <eric at anholt.net>

diff --git a/src/i830_xaa.c b/src/i830_xaa.c
index c9c26b0..e5e849d 100644
--- a/src/i830_xaa.c
+++ b/src/i830_xaa.c
@@ -314,7 +314,7 @@ I830SetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop,
 	       color, rop, planemask);
 
     if (IS_I965G(pI830) && I830CheckTiling(pScrn)) {
-	pI830->BR[13] = (pScrn->displayWidth * pI830->cpp) >> 4;
+	pI830->BR[13] = (pScrn->displayWidth * pI830->cpp) >> 2;
     } else {
 	pI830->BR[13] = (pScrn->displayWidth * pI830->cpp);
     }
@@ -385,7 +385,7 @@ I830SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir, int rop,
 	       xdir, ydir, rop, planemask, transparency_color);
 
     if (IS_I965G(pI830) && I830CheckTiling(pScrn)) {
-	pI830->BR[13] = (pScrn->displayWidth * pI830->cpp) >> 4;
+	pI830->BR[13] = (pScrn->displayWidth * pI830->cpp) >> 2;
     } else {
 	pI830->BR[13] = (pScrn->displayWidth * pI830->cpp);
     }
@@ -468,7 +468,7 @@ I830SetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int pattx, int patty,
     pI830->BR[19] = fg;
 
     if (IS_I965G(pI830) && I830CheckTiling(pScrn)) {
-	pI830->BR[13] = (pScrn->displayWidth * pI830->cpp) >> 4;
+	pI830->BR[13] = (pScrn->displayWidth * pI830->cpp) >> 2;
     } else {
 	pI830->BR[13] = (pScrn->displayWidth * pI830->cpp);
     }
@@ -565,7 +565,7 @@ I830SetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn,
 
     /* Fill out register values */
     if (IS_I965G(pI830) && I830CheckTiling(pScrn)) {
-	pI830->BR[13] = (pScrn->displayWidth * pI830->cpp) >> 4;
+	pI830->BR[13] = (pScrn->displayWidth * pI830->cpp) >> 2;
     } else {
 	pI830->BR[13] = (pScrn->displayWidth * pI830->cpp);
     }
@@ -671,7 +671,7 @@ I830SetupForScanlineImageWrite(ScrnInfoPtr pScrn, int rop,
 
     /* Fill out register values */
     if (IS_I965G(pI830) && I830CheckTiling(pScrn)) {
-	pI830->BR[13] = (pScrn->displayWidth * pI830->cpp) >> 4;
+	pI830->BR[13] = (pScrn->displayWidth * pI830->cpp) >> 2;
     } else {
 	pI830->BR[13] = (pScrn->displayWidth * pI830->cpp);
     }
commit 871728a0cbba12579c830e67020cc0c69c1611bb
Author: Zhenyu Wang <zhenyu.z.wang at intel.com>
Date:   Thu Oct 16 10:35:17 2008 +0800

    Don't handle irq in GEM mode

diff --git a/src/i830_dri.c b/src/i830_dri.c
index fb9b6f6..bf64fa3 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -939,12 +939,14 @@ Bool
 I830DRIResume(ScreenPtr pScreen)
 {
    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+   I830Ptr pI830 = I830PTR(pScrn);
 
    DPRINTF(PFX, "I830DRIResume\n");
 
    I830ResumeDma(pScrn);
 
-   I830DRIInstIrqHandler(pScrn);
+   if (!pI830->memory_manager)
+       I830DRIInstIrqHandler(pScrn);
 
    return TRUE;
 }
diff --git a/src/i830_driver.c b/src/i830_driver.c
index eaf5d27..2e503af 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -3546,8 +3546,10 @@ I830LeaveVT(int scrnIndex, int flags)
    if (pI830->directRenderingOpen) {
       DRILock(screenInfo.screens[pScrn->scrnIndex], 0);
 
-      I830DRISetVBlankInterrupt (pScrn, FALSE);
-      drmCtlUninstHandler(pI830->drmSubFD);
+      if (!pI830->memory_manager) {
+	  I830DRISetVBlankInterrupt (pScrn, FALSE);
+	  drmCtlUninstHandler(pI830->drmSubFD);
+      }
    }
 #endif
 
commit 2419bce9efbff63529074e64af5ec5c2e62e368b
Author: Zhenyu Wang <zhenyu.z.wang at intel.com>
Date:   Thu Oct 16 10:28:16 2008 +0800

    Make GTT dumper work on other 9XX chips

diff --git a/src/reg_dumper/gtt.c b/src/reg_dumper/gtt.c
index cf9e37a..eca4bc6 100644
--- a/src/reg_dumper/gtt.c
+++ b/src/reg_dumper/gtt.c
@@ -36,22 +36,42 @@
 #include "reg_dumper.h"
 #include "../i810_reg.h"
 
-#define INGTT(offset) INREG(gtt_base + (offset) / (KB(4) / 4))
+#define INGTT(offset) (*(volatile uint32_t *)(gtt + (offset) / (KB(4) / 4)))
 
 int main(int argc, char **argv)
 {
 	I830Rec i830;
 	I830Ptr pI830 = &i830;
-	int gtt_base, start, aper_size;
+	int start, aper_size;
+	unsigned char *gtt;
+
 	intel_i830rec_init(pI830);
 
+	if (!IS_I9XX(pI830)) {
+		printf("Unsupported chipset for gtt dumper\n");
+		exit(1);
+	}
+
 	if (IS_G4X(pI830) || IS_GM45(pI830))
-		gtt_base = MB(2);
+		gtt = (unsigned char *)(pI830->mmio + MB(2));
+	else if (IS_I965G(pI830))
+		gtt = (unsigned char *)(pI830->mmio + KB(512));
 	else {
-		printf("Unsupported chipset for gtt dumper\n");
+		/* 915/945 chips has GTT range in bar 3*/
+		int err = 0;
+		err = pci_device_map_range (pI830->pci_dev,
+				pI830->pci_dev->regions[3].base_addr,
+				pI830->pci_dev->regions[3].size,
+				PCI_DEV_MAP_FLAG_WRITABLE,
+				(void **)&gtt);
+		if (err != 0) {
+			fprintf(stderr, "mapping GTT bar failed\n");
+			exit(1);
+		}
 	}
 
-	aper_size = MB(256);
+	aper_size = pI830->pci_dev->regions[2].size;
+
 	for (start = 0; start < aper_size; start += KB(4)) {
 		uint32_t start_pte = INGTT(start);
 		uint32_t end;
commit 986c8df79e83c369655ad786a6bf6342b53c535d
Author: Adam Jackson <ajax at nwnk.net>
Date:   Thu Oct 16 10:24:04 2008 +0800

    Fix Mac mini crash in DDC mode probe
    
    SDVO on Mac mini trys to get EDID from CRT port, which
    failed with recent DVI-I change.

diff --git a/src/i830_sdvo.c b/src/i830_sdvo.c
index 8f1b20b..35fccd5 100644
--- a/src/i830_sdvo.c
+++ b/src/i830_sdvo.c
@@ -1495,7 +1495,9 @@ i830_sdvo_get_ddc_modes(xf86OutputPtr output)
     intel_output = crt->driver_private;
     if (intel_output->type == I830_OUTPUT_ANALOG &&
 	crt->funcs->detect(crt) == XF86OutputStatusDisconnected) {
+	I830I2CInit(pScrn, &intel_output->pDDCBus, GPIOA, "CRTDDC_A");
 	edid_mon = xf86OutputGetEDID(crt, intel_output->pDDCBus);
+	xf86DestroyI2CBusRec(intel_output->pDDCBus, TRUE, TRUE);
     }
     if (edid_mon) {
 	xf86OutputSetEDID(output, edid_mon);
commit 6707371176147340fabc9ab6f1e3d6d5ac980662
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Oct 15 08:12:11 2008 -0700

    Remove gratuitous flushing in EXA after solid operations.
    
    This snuck in with the UXA rename commit.

diff --git a/src/i830_exa.c b/src/i830_exa.c
index 8623159..cba9622 100644
--- a/src/i830_exa.c
+++ b/src/i830_exa.c
@@ -248,10 +248,10 @@ I830EXASolid(PixmapPtr pPixmap, int x1, int y1, int x2, int y2)
 static void
 I830EXADoneSolid(PixmapPtr pPixmap)
 {
-#if ALWAYS_SYNC || ALWAYS_FLUSH || 1
+#if ALWAYS_SYNC || ALWAYS_FLUSH
     ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
 
-#if ALWAYS_FLUSH || 1
+#if ALWAYS_FLUSH
     intel_batch_flush(pScrn);
 #endif
 #if ALWAYS_SYNC
commit 4dd00681dd0f9fce8dfd4592b46418edbbd2eeb4
Author: Eric Anholt <eric at anholt.net>
Date:   Tue Oct 14 11:33:33 2008 -0700

    Fix broken stolen memory counting on G4X.
    
    On the GM45 we were assuming too little stolen memory (mostly harmless,
    except when it wasn't, until the AGP fix), and on the G45 we were assuming too
    much stolen memory, which was quite harmful when we touched the page that
    didn't get mapped.
    
    Future stolen memory accounting should use src/reg_dumper/intel_gtt before and
    after enabling AGP on the chipset to confirm that only the GTT entries not
    mapped to stolen are replaced, and that all of the unmapped GTT entries are
    replaced with the constant scratch page.

diff --git a/src/i830_driver.c b/src/i830_driver.c
index c1d61f4..eaf5d27 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -502,8 +502,8 @@ I830DetectMemory(ScrnInfoPtr pScrn)
    range = gtt_size + 4;
 
    /* new 4 series hardware has seperate GTT stolen with GFX stolen */
-   if (IS_G4X(pI830))
-       range = 0;
+   if (IS_G4X(pI830) || IS_GM45(pI830))
+       range = 4;
 
    if (IS_I85X(pI830) || IS_I865G(pI830) || IS_I9XX(pI830)) {
       switch (gmch_ctrl & I855_GMCH_GMS_MASK) {
commit e7e49bed7e254256f8cc0d4afcdfadc6dadf19e6
Author: Eric Anholt <eric at anholt.net>
Date:   Tue Oct 14 10:38:05 2008 -0700

    Add a GTT dumper for G4x debugging.

diff --git a/src/reg_dumper/Makefile.am b/src/reg_dumper/Makefile.am
index 1127581..b04395a 100644
--- a/src/reg_dumper/Makefile.am
+++ b/src/reg_dumper/Makefile.am
@@ -1,4 +1,9 @@
-noinst_PROGRAMS = intel_reg_dumper intel_idle intel_stepping intel_statuspage intel_hotplug
+noinst_PROGRAMS = intel_reg_dumper \
+	intel_gtt \
+	intel_idle \
+	intel_stepping \
+	intel_statuspage \
+	intel_hotplug
 
 intel_reg_dumper_SOURCES = \
 	main.c \
@@ -6,6 +11,11 @@ intel_reg_dumper_SOURCES = \
 	xprintf.c \
 	../i830_debug.c
 
+intel_gtt_SOURCES = \
+	gtt.c \
+	reg_dumper.h \
+	util.c
+
 intel_idle_SOURCES = \
 	idle.c \
 	reg_dumper.h \
@@ -28,6 +38,7 @@ intel_statuspage_SOURCES = \
 
 intel_hotplug_LDADD = $(PCIACCESS_LIBS)
 intel_reg_dumper_LDADD = $(PCIACCESS_LIBS)
+intel_gtt_LDADD = $(PCIACCESS_LIBS)
 intel_idle_LDADD = $(PCIACCESS_LIBS)
 intel_stepping_LDADD = $(PCIACCESS_LIBS)
 intel_statuspage_LDADD = $(PCIACCESS_LIBS)
diff --git a/src/reg_dumper/gtt.c b/src/reg_dumper/gtt.c
new file mode 100644
index 0000000..cf9e37a
--- /dev/null
+++ b/src/reg_dumper/gtt.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright © 2008 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Eric Anholt <eric at anholt.net>
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <pciaccess.h>
+#include <err.h>
+#include <unistd.h>
+
+#include "reg_dumper.h"
+#include "../i810_reg.h"
+
+#define INGTT(offset) INREG(gtt_base + (offset) / (KB(4) / 4))
+
+int main(int argc, char **argv)
+{
+	I830Rec i830;
+	I830Ptr pI830 = &i830;
+	int gtt_base, start, aper_size;
+	intel_i830rec_init(pI830);
+
+	if (IS_G4X(pI830) || IS_GM45(pI830))
+		gtt_base = MB(2);
+	else {
+		printf("Unsupported chipset for gtt dumper\n");
+	}
+
+	aper_size = MB(256);
+	for (start = 0; start < aper_size; start += KB(4)) {
+		uint32_t start_pte = INGTT(start);
+		uint32_t end;
+		int constant_length = 0;
+		int linear_length = 0;
+
+		/* Check if it's a linear sequence */
+		for (end = start + KB(4); end < aper_size; end += KB(4)) {
+			uint32_t end_pte = INGTT(end);
+			if (end_pte == start_pte + (end - start))
+				linear_length++;
+			else
+				break;
+		}
+		if (linear_length > 0) {
+			printf("0x%08x - 0x%08x: linear from "
+			       "0x%08x to 0x%08x\n",
+			       start, end - KB(4),
+			       start_pte, start_pte + (end - start) - KB(4));
+			start = end - KB(4);
+			continue;
+		}
+
+		/* Check if it's a constant sequence */
+		for (end = start + KB(4); end < aper_size; end += KB(4)) {
+			uint32_t end_pte = INGTT(end);
+			if (end_pte == start_pte)
+				constant_length++;
+			else
+				break;
+		}
+		if (constant_length > 0) {
+			printf("0x%08x - 0x%08x: constant 0x%08x\n",
+			       start, end - KB(4),
+			       start_pte);
+			start = end - KB(4);
+			continue;
+		}
+
+		printf("0x%08x: 0x%08x\n", start, start_pte);
+	}
+
+	return 0;
+}


More information about the xorg-commit mailing list