summaryrefslogtreecommitdiff
path: root/xc
diff options
context:
space:
mode:
authorkeithw <keithw>2000-01-20 04:57:11 +0000
committerkeithw <keithw>2000-01-20 04:57:11 +0000
commitd1fcc319e105ef528b1554397ac0550ff26f351b (patch)
treed2e775a96d267b576ac41c873f1832c83c774e18 /xc
parent3070cca054efa800aa6e3f9123df88395b4ef4b0 (diff)
debug commit for jeff
Diffstat (limited to 'xc')
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile2
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h2
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c66
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c52
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c117
5 files changed, 154 insertions, 85 deletions
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile
index f13c9c659..ce7285652 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile
@@ -33,7 +33,7 @@ INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
-I$(SERVERSRC)/Xext \
-I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
-I$(EXTINCSRC) \
- -Ios-support $(DRIINCLUDES)
+ $(DRIINCLUDES)
#endif
DEFINES = $(DRIDEFINES)
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h
index 1d4d34abc..fb249541e 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h
@@ -230,10 +230,8 @@ extern int I810AllocHigh( I810MemRange *result, I810MemRange *pool, int size );
extern void I810SetCursorPosition(ScrnInfoPtr pScrn, int x, int y);
-#ifndef XF86DRI
extern int I810AllocateGARTMemory( ScrnInfoPtr pScrn );
extern void I810FreeGARTMemory( ScrnInfoPtr pScrn );
-#endif
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c
index 970b57d75..b987af78f 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c
@@ -20,6 +20,25 @@
#include "i810.h"
#include "i810_dri.h"
+#include <linux/ioctl.h>
+#include "xf86drm.h"
+
+
+#define DRM_IOCTL_BASE 'd'
+#define DRM_IOCTL_NR(n) _IOC_NR(n)
+#define DRM_IO(nr) _IO(DRM_IOCTL_BASE,nr)
+#define DRM_IOR(nr,size) _IOR(DRM_IOCTL_BASE,nr,size)
+#define DRM_IOW(nr,size) _IOW(DRM_IOCTL_BASE,nr,size)
+#define DRM_IOWR(nr,size) _IOWR(DRM_IOCTL_BASE,nr,size)
+
+typedef struct drm_agp_binding {
+ unsigned long handle; /* From drm_agp_buffer */
+ unsigned long offset; /* In bytes -- will round to page boundary */
+} drm_agp_binding_t;
+
+#define DRM_IOCTL_AGP_BIND DRM_IOWR(0x36, drm_agp_binding_t)
+
+
static char I810KernelDriverName[] = "i810";
static char I810ClientDriverName[] = "i810";
@@ -39,6 +58,7 @@ static void I810DRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg,
RegionPtr prgnSrc, CARD32 index);
+extern int xf86ioctl(int fd, unsigned long request, pointer argp);
extern void GlxSetVisualConfigs(int nconfigs,
__GLXvisualConfig *configs,
@@ -228,7 +248,11 @@ Bool I810DRIScreenInit(ScreenPtr pScreen)
/* int bufs; */
pDRIInfo = DRICreateInfoRec();
- if (!pDRIInfo) return FALSE;
+ if (!pDRIInfo) {
+ ErrorF("DRICreateInfoRec failed\n");
+ return FALSE;
+ }
+
pI810->pDRIInfo = pDRIInfo;
pDRIInfo->drmDriverName = I810KernelDriverName;
@@ -281,6 +305,7 @@ Bool I810DRIScreenInit(ScreenPtr pScreen)
* to allocate it. Scary stuff, hold on...
*/
if (!DRIScreenInit(pScreen, pDRIInfo, &pI810->drmSubFD)) {
+ ErrorF("DRIScreenInit failed\n");
xfree(pDRIInfo->devPrivate);
pDRIInfo->devPrivate=0;
DRIDestroyInfoRec(pI810->pDRIInfo);
@@ -291,6 +316,7 @@ Bool I810DRIScreenInit(ScreenPtr pScreen)
pI810DRI->regsSize=I810_REG_SIZE;
if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810->MMIOAddr,
pI810DRI->regsSize, DRM_REGISTERS, 0, &pI810DRI->regs)<0) {
+ ErrorF("drmAddMap(regs) failed\n");
DRICloseScreen(pScreen);
return FALSE;
}
@@ -302,14 +328,20 @@ Bool I810DRIScreenInit(ScreenPtr pScreen)
/* Agp Support - Need this just to get the framebuffer.
*/
if(drmAgpAcquire(pI810->drmSubFD) < 0) {
+ ErrorF("drmAgpAquire failed\n");
DRICloseScreen(pScreen);
return FALSE;
}
pI810DRI->agpSize = drmAgpSize(pI810->drmSubFD);
pI810DRI->agpBase = drmAgpBase(pI810->drmSubFD);
+
+
+ /* Don't we already have this as the framebuffer map?
+ */
if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810DRI->agpBase,
pI810DRI->agpSize, DRM_AGP, DRM_WRITE_COMBINING,
&pI810DRI->agp) < 0) {
+ ErrorF("drmAddMap(agp space) failed\n");
DRICloseScreen(pScreen);
return FALSE;
}
@@ -322,14 +354,43 @@ Bool I810DRIScreenInit(ScreenPtr pScreen)
*/
pI810DRI->agpHandle = drmAgpAlloc(pI810->drmSubFD, pScrn->videoRam * 1024);
if(pI810DRI->agpHandle == 0) {
+ ErrorF("drmAgpAlloc failed\n");
DRICloseScreen(pScreen);
return FALSE;
}
- if(drmAgpBind(pI810->drmSubFD, pI810DRI->agpHandle, 0) < 0) {
+#if 1
+ {
+ struct {
+ unsigned long handle; /* From drm_agp_buffer */
+ unsigned long offset; /* In bytes -- will round to page boundary */
+ } b;
+
+ int rv;
+
+ b.handle = pI810DRI->agpHandle;
+ b.offset = 0;
+
+ rv = xf86ioctl(pI810->drmSubFD, DRM_IOCTL_AGP_BIND, &b);
+
+ ErrorF("xf86ioctl(%d, %x, {%x,%x}) returns %d\n",
+ pI810->drmSubFD, DRM_IOCTL_AGP_BIND, b.handle, b.offset, rv);
+
+
+ if (rv < 0) {
+ ErrorF("drmAgpBind failed\n");
+ DRICloseScreen(pScreen);
+ return FALSE;
+ }
+ }
+#else
+ ErrorF("Calling bloody drmAgpBind, handle %x \n", pI810DRI->agpHandle);
+ if(drmAgpBind(pI810->drmSubFD, pI810DRI->agpHandle, 0) != 0) {
+ ErrorF("drmAgpBind failed\n");
DRICloseScreen(pScreen);
return FALSE;
}
+#endif
pI810->SysMem.Start = 0;
pI810->SysMem.Size = pScrn->videoRam * 1024;
@@ -390,6 +451,7 @@ Bool I810DRIScreenInit(ScreenPtr pScreen)
#endif
if (!(I810InitVisualConfigs(pScreen))) {
+ ErrorF("I810InitVisualConfigs failed\n");
DRICloseScreen(pScreen);
return FALSE;
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c
index ee5ba34da..de1cd5868 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c
@@ -208,16 +208,32 @@ static const char *ramdacSymbols[] = {
#ifdef XF86DRI
static const char *drmSymbols[] = {
- "drmAddBufs",
- "drmAddMap",
- "drmAvailable",
- "drmCtlAddCommand",
- "drmCtlInstHandler",
- "drmGetInterruptFromBusID",
- "drmMapBufs",
- "drmMarkBufs",
- "drmUnmapBufs",
- NULL
+ "drmAddBufs",
+ "drmAddMap",
+ "drmAvailable",
+ "drmCtlAddCommand",
+ "drmCtlInstHandler",
+ "drmGetInterruptFromBusID",
+ "drmMapBufs",
+ "drmMarkBufs",
+ "drmUnmapBufs",
+ "drmAgpAcquire",
+ "drmAgpRelease",
+ "drmAgpEnable",
+ "drmAgpAlloc",
+ "drmAgpFree",
+ "drmAgpBind",
+ "drmAgpUnbind",
+ "drmAgpVersionMajor",
+ "drmAgpVersionMinor",
+ "drmAgpGetMode",
+ "drmAgpBase",
+ "drmAgpSize",
+ "drmAgpMemoryUsed",
+ "drmAgpMemoryAvail",
+ "drmAgpVendorId",
+ "drmAgpDeviceId",
+ NULL
};
static const char *driSymbols[] = {
@@ -1711,11 +1727,27 @@ I810ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) {
if (pI810->directRenderingEnabled) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering: Enabled\n");
+
} else {
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering: Disabled\n");
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Allocating memory from agpgart.o\n");
+
+ if (!I810AllocateGARTMemory( pScrn )) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Failed to alloc gart memory\n");
+ return FALSE;
+ }
+ }
+
+
+#else
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Allocating memory from agpgart.o\n");
+ if (!I810AllocateGARTMemory( pScrn )) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Failed to alloc gart memory\n");
+ return FALSE;
}
#endif
+
pScreen->SaveScreen = I810SaveScreen;
pI810->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = I810CloseScreen;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c
index 9da36fc0a..2c9408c5b 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c
@@ -41,10 +41,12 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "xf86Priv.h"
#include "xf86_OSlib.h"
+/* #include "xf86_ansic.h" */
+
#include "i810.h"
#include "i810_reg.h"
-#include <agpgart.h>
+#include <linux/agpgart.h>
int I810AllocLow( I810MemRange *result, I810MemRange *pool, int size )
{
@@ -70,83 +72,80 @@ int I810AllocHigh( I810MemRange *result, I810MemRange *pool, int size )
}
-
-
-/* This communicates with the 'old' agpgart.o module, which was never
- * part of the standard kernel, but which shipped with the XFree86 3.3
- * server. There is a rewritten version of that driver in the current
- * 2.3 kernels - we talk to that module via the DRI. So currently, the
- * choices are -
- * 2.2-early 2.3 kernels - use the old i810AgpGart module
- * 2.3-2.4 kernels - use the DRM to talk to the new agpgart module.
- *
- * It may be useful to add an interface to talk to the new agpgart
- * without the drm, but perhaps that should happen only once this
- * interface is retired:
- */
-#ifndef XF86DRI
-
-
#define XCONFIG_PROBED "()"
#define NAME "i810"
+extern int xf86open(const char *path, int flags, ...);
+extern int xf86ioctl(int fd, unsigned long request, pointer argp);
+extern int xf86errno;
+
int I810AllocateGARTMemory( ScrnInfoPtr pScrn )
{
- struct stat sb;
- struct gart_info gartinf;
- int i, pages = pScrn->videoRam / 4;
+ struct _agp_info agpinf;
+ struct _agp_bind bind;
+ struct _agp_allocate alloc;
+ int pages = pScrn->videoRam / 4;
I810Ptr pI810 = I810PTR(pScrn);
+ pI810->gartfd = xf86open("/dev/agpgart", O_RDWR, 0);
- if (stat("/dev/agpgart", &sb) != 0) {
- ErrorF("%s %s: Stat failed on /dev/agpgart: %s\n",
- XCONFIG_PROBED, NAME,
- sys_errlist[errno]);
+ if (pI810->gartfd == -1) {
+ ErrorF("%s %s: unable to open /dev/agpgart\n",
+ XCONFIG_PROBED, NAME);
return FALSE;
}
- pI810->gartfd = open("/dev/agpgart", O_RDWR);
-
- if (pI810->gartfd == -1) {
- ErrorF("%s %s: unable to open /dev/agpgart: %s\n",
- XCONFIG_PROBED, NAME,
- sys_errlist[errno]);
+ if (xf86ioctl(pI810->gartfd, AGPIOC_ACQUIRE, 0) != 0) {
+ ErrorF("%s %s: AGPIOC_ACQUIRE failed\n",
+ XCONFIG_PROBED, NAME);
return FALSE;
}
- if (ioctl(pI810->gartfd, GARTIOCINFO, &gartinf) != 0) {
- ErrorF("%s %s: error doing ioctl(GARTIOCINFO): %s\n",
- XCONFIG_PROBED, NAME,
- sys_errlist[errno]);
+ if (xf86ioctl(pI810->gartfd, AGPIOC_INFO, &agpinf) != 0) {
+ ErrorF("%s %s: error doing xf86ioctl(GARTIOCINFO)\n",
+ XCONFIG_PROBED, NAME);
return FALSE;
}
+
/* Dcache - half the speed of normal ram, so not really useful for
* a 2d server. Don't bother reporting its presence. This is
* mapped in addition to the requested amount of system ram.
*/
- if (gartinf.num_dcache_slots) {
+#if 0
+ if () {
pI810->DcacheMem.Start = gartinf.num_of_slots * 4096;
pI810->DcacheMem.Size = gartinf.num_dcache_slots * 4096;
pI810->DcacheMem.End = pI810->DcacheMem.Start + pI810->DcacheMem.Size;
- }
+ }
+#endif
/* Treat the gart like video memory - we assume we own all that is
* there, so ignore EBUSY errors. Don't try to remove it on
* failure, either, as other X server may be using it.
*/
- for (i = 0; i < pages; i++)
- if (ioctl(pI810->gartfd, GARTIOCINSERT, &i) != 0) {
- if (errno != EBUSY)
- {
- perror("gart insert");
- ErrorF("%s %s: GART: allocation of %d pages failed at page %d\n",
- XCONFIG_PROBED, NAME, pages, i);
- return FALSE;
- }
- }
+ alloc.pg_count = pages;
+ alloc.type = 0;
+
+ ErrorF("Calling AGPIOC_ALLOCATE, pages: %d\n", pages);
+
+ if (xf86ioctl(pI810->gartfd, AGPIOC_ALLOCATE, &alloc) != 0) {
+ ErrorF("%s %s: GART: allocation of %d pages failed\n",
+ XCONFIG_PROBED, NAME, pages);
+ return FALSE;
+ }
+
+ bind.pg_start = 0;
+ bind.key = alloc.key;
+
+ if (xf86ioctl(pI810->gartfd, AGPIOC_BIND, &bind) != 0) {
+ ErrorF("%s %s: GART: allocation of %d pages failed\n",
+ XCONFIG_PROBED, NAME, pages);
+ return FALSE;
+ }
+
pI810->SysMem.Start = 0;
pI810->SysMem.Size = pages * 4096;
@@ -169,29 +168,8 @@ void I810FreeGARTMemory( ScrnInfoPtr pScrn )
}
}
-unsigned long I810LocalToPhysical( ScrnInfoPtr pScrn, unsigned long local )
-{
- I810Ptr pI810 = I810PTR(pScrn);
- struct gart_pge_info gart_pg_inf;
-
- gart_pg_inf.index = (local + 4095) / 4096;
-
- if (ioctl(pI810->gartfd, GARTIOCPGINFO, &gart_pg_inf) != 0) {
- ErrorF("%s %s: error doing ioctl(GARTIOCINFO, %x): %s\n",
- XCONFIG_PROBED, NAME, gart_pg_inf.index,
- sys_errlist[errno]);
- return 0;
- }
-
- ErrorF( "local: 0x%lx physical 0x%lx\n", local,
- gart_pg_inf.physical + (local & 4095));
-
- return gart_pg_inf.physical + (local & 4095);
-}
-
-#else
-/* Need to add this to new agpgart as a device-specific ioctl, or
+/* Need to add this to new agpgart as a device-specific xf86ioctl, or
* perhaps a special ioctl to alloc a page *and* return a physical
* address in system ram.
*/
@@ -200,5 +178,4 @@ unsigned long I810LocalToPhysical( ScrnInfoPtr pScrn, unsigned long local )
return 0; /* no hardware cursor */
}
-#endif