summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--src/i810_driver.c2
-rw-r--r--src/i830_dri.c5
-rw-r--r--src/i830_driver.c98
-rw-r--r--src/i830_memory.c10
5 files changed, 125 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 0d1f506d..190c8b34 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2006-03-22 Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
+
+ * src/i810_driver.c:
+ * src/i830_dri.c: (I830DRIDoMappings):
+ * src/i830_driver.c: (I830DrmMMInit), (I830DrmMMTakedown),
+ (I830BIOSScreenInit), (I830BIOSCloseScreen):
+ * src/i830_memory.c: (I830Allocate3DMemory), (I830FixupOffsets),
+ (I830BindGARTMemory), (I830UnbindGARTMemory):
+ New branch. Initialize the drm memory manager. Don't allocate
+ texture memory.
+
2005-12-20 Kevin E. Martin <kem-at-freedesktop-dot-org>
* configure.ac:
diff --git a/src/i810_driver.c b/src/i810_driver.c
index bfa1dae9..8096612b 100644
--- a/src/i810_driver.c
+++ b/src/i810_driver.c
@@ -299,6 +299,8 @@ const char *I810drmSymbols[] = {
"drmGetInterruptFromBusID",
"drmGetLibVersion",
"drmGetVersion",
+ "drmMMInit",
+ "drmMMtakedown",
NULL
};
diff --git a/src/i830_dri.c b/src/i830_dri.c
index ade0c0ce..092a6ee7 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -664,7 +664,7 @@ I830DRIDoMappings(ScreenPtr pScreen)
}
xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] ring buffer = 0x%08x\n",
pI830->ring_map);
-
+#ifdef NOTTM
pI830DRI->textureSize = pI830->TexMem.Size;
pI830DRI->logTextureGranularity = pI830->TexGranularity;
@@ -679,6 +679,7 @@ I830DRIDoMappings(ScreenPtr pScreen)
}
xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] textures = 0x%08x\n",
pI830DRI->textures);
+#endif
if (!I830InitDma(pScrn)) {
DRICloseScreen(pScreen);
@@ -748,7 +749,9 @@ I830DRIDoMappings(ScreenPtr pScreen)
pI830DRI->bitsPerPixel = pScrn->bitsPerPixel;
+#ifdef NOTTM
pI830DRI->textureOffset = pI830->TexMem.Start;
+#endif
pI830DRI->backOffset = pI830->BackBuffer.Start;
pI830DRI->depthOffset = pI830->DepthBuffer.Start;
diff --git a/src/i830_driver.c b/src/i830_driver.c
index b281affd..840471c5 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -4451,6 +4451,66 @@ I830_dump_registers(ScrnInfoPtr pScrn)
}
#endif
+#ifdef XF86DRI
+
+#ifndef DRM_MM_TT
+#error "Wrong drm.h file included. You need to compile and install the new libdrm."
+#endif
+
+static int
+I830DrmMMInit(int drmFD, unsigned long vRamOffs, unsigned long vRamSize,
+ unsigned long ttPageOffs, unsigned long ttNumPages)
+{
+
+ drm_mm_init_arg_t ma;
+ int ret;
+
+ memset(&ma, 0, sizeof(ma));
+ ma.req.vr_offset_lo = vRamOffs & 0xFFFFFFFFU;
+ ma.req.vr_offset_lo = vRamOffs & 0xFFFFFFFFU;
+ ma.req.vr_size_lo = vRamSize & 0xFFFFFFFFU;
+ ma.req.tt_p_offset_lo = ttPageOffs & 0xFFFFFFFFU;
+ ma.req.tt_p_size_lo = ttNumPages & 0xFFFFFFFFU;
+ if (sizeof(vRamOffs) == 8) {
+ int shift = 32;
+
+ ma.req.vr_offset_hi = vRamOffs >> shift;
+ ma.req.vr_size_hi = vRamSize >> shift;
+ ma.req.tt_p_offset_hi = ttPageOffs >> shift;
+ ma.req.tt_p_size_hi = ttNumPages >> shift;
+ }
+ ma.req.op = mm_init;
+
+ ret = ioctl(drmFD, DRM_IOCTL_MM_INIT, &ma);
+
+ if (ret)
+ return -errno;
+
+ return 0;
+
+ /*
+ * Skip MM Sarea mapping for now. We don't use it in the X server
+ */
+}
+
+static int
+I830DrmMMTakedown(int drmFD)
+{
+ drm_mm_init_arg_t ma;
+ int ret = 0;
+
+ ma.req.op = mm_takedown;
+ if (ioctl(drmFD, DRM_IOCTL_MM_INIT, &ma)) {
+ ret = -errno;
+ }
+
+ return ret;
+}
+
+
+
+#endif
+
static Bool
I830BIOSScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
{
@@ -4856,9 +4916,46 @@ I830BIOSScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
pI830->starting = FALSE;
pI830->closing = FALSE;
pI830->suspended = FALSE;
+
+#ifdef XF86DRI
+ if (pI830->directRenderingEnabled) {
+ unsigned pageSize = getpagesize();
+ unsigned long aperOffset =
+ ROUND_TO(pI830->MemoryAperture.Start, pageSize) / pageSize;
+ unsigned long aperSize =
+ ROUND_DOWN_TO(pI830->MemoryAperture.End, pageSize) / pageSize -
+ aperOffset;
+
+ if (aperSize < 10) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Too little aperture space for DRI.\n");
+ pI830->directRenderingOpen = FALSE;
+ I830DRICloseScreen(pScreen);
+ pI830->directRenderingEnabled = FALSE;
+ } else {
+ if (I830DrmMMInit(pI830->drmSubFD, 0, 0, aperOffset, aperSize)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Could not initialize video memory manager.\n");
+
+ pI830->directRenderingOpen = FALSE;
+ I830DRICloseScreen(pScreen);
+ pI830->directRenderingEnabled = FALSE;
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Initialized video memory manager, %ld AGP pages\n",
+ aperSize);
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "at AGP offset 0x%lx\n",
+ aperOffset);
+ }
+ pI830->MemoryAperture.Size = 0;
+ }
+ }
+#endif
+
return TRUE;
}
+
static void
I830BIOSAdjustFrame(int scrnIndex, int x, int y, int flags)
{
@@ -5481,6 +5578,7 @@ I830BIOSCloseScreen(int scrnIndex, ScreenPtr pScreen)
pI830->closing = TRUE;
#ifdef XF86DRI
if (pI830->directRenderingOpen) {
+ drmMMTakedown(pI830->drmSubFD);
pI830->directRenderingOpen = FALSE;
I830DRICloseScreen(pScreen);
}
diff --git a/src/i830_memory.c b/src/i830_memory.c
index 27cf0178..38b84c02 100644
--- a/src/i830_memory.c
+++ b/src/i830_memory.c
@@ -1018,6 +1018,9 @@ I830Allocate3DMemory(ScrnInfoPtr pScrn, const int flags)
/* Allocate the remaining space for textures. */
memset(&(pI830->TexMem), 0, sizeof(pI830->TexMem));
pI830->TexMem.Key = -1;
+
+#ifdef NOTTM
+
size = GetFreeSpace(pScrn);
if (dryrun && (size < MB(1)))
size = MB(1);
@@ -1049,6 +1052,7 @@ I830Allocate3DMemory(ScrnInfoPtr pScrn, const int flags)
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
"%sAllocated %ld kB for textures at 0x%lx\n", s,
alloced / 1024, pI830->TexMem.Start);
+#endif
return TRUE;
}
@@ -1204,7 +1208,9 @@ I830FixupOffsets(ScrnInfoPtr pScrn)
FixOffset(pScrn, &(pI830->BackBuffer));
FixOffset(pScrn, &(pI830->DepthBuffer));
FixOffset(pScrn, &(pI830->ContextMem));
+#ifdef NOTTM
FixOffset(pScrn, &(pI830->TexMem));
+#endif
}
#endif
return TRUE;
@@ -1528,8 +1534,10 @@ I830BindGARTMemory(ScrnInfoPtr pScrn)
return FALSE;
if (!BindMemRange(pScrn, &(pI830->ContextMem)))
return FALSE;
+#ifdef NOTTM
if (!BindMemRange(pScrn, &(pI830->TexMem)))
return FALSE;
+#endif
}
#endif
pI830->GttBound = 1;
@@ -1600,8 +1608,10 @@ I830UnbindGARTMemory(ScrnInfoPtr pScrn)
return FALSE;
if (!UnbindMemRange(pScrn, &(pI830->ContextMem)))
return FALSE;
+#ifdef NOTTM
if (!UnbindMemRange(pScrn, &(pI830->TexMem)))
return FALSE;
+#endif
}
#endif
if (!xf86ReleaseGART(pScrn->scrnIndex))