Radeon driver and hw init code compiles.

This commit is contained in:
Keith Whitwell 2002-12-19 10:16:18 +00:00
parent eb7eb6e171
commit 3af2be61fd
8 changed files with 835 additions and 883 deletions

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.1.2.3 2002/12/11 14:44:50 keithw Exp $
# $Id: Makefile,v 1.1.2.4 2002/12/19 10:16:18 keithw Exp $
# Mesa 3-D graphics library
# Version: 5.0
@ -24,7 +24,8 @@ COREMESA = $(MESABUILDDIR)/swrast_setup/swrast_setup.a \
$(MESABUILDDIR)/swrast/swrast.a \
$(MESABUILDDIR)/mesa.a
DRIVER_SOURCES = radeon_compat.c \
DRIVER_SOURCES = server/radeon_dri.c \
radeon_compat.c \
radeon_context.c \
radeon_ioctl.c \
radeon_lock.c \

View file

@ -30,7 +30,7 @@
#ifndef _RADEON_H_
#define _RADEON_H_
#include "dri.h"
#include "xf86drm.h" /* drmHandle, etc */
#define PCI_CHIP_RADEON_LW 0x4C57
#define PCI_CHIP_RADEON_LX 0x4C58
@ -74,97 +74,87 @@ typedef enum {
CHIP_FAMILY_R300
} RADEONChipFamily;
typedef unsigned long memType;
typedef struct {
pciVideoPtr PciInfo;
int Chipset;
RADEONChipFamily ChipFamily;
int Chipset;
RADEONChipFamily ChipFamily;
unsigned long LinearAddr; /* Frame buffer physical address */
unsigned long MMIOAddr; /* MMIO region physical address */
unsigned long BIOSAddr; /* BIOS physical address */
Bool FBDev;
unsigned long LinearAddr; /* Frame buffer physical address */
unsigned long MMIOAddr; /* MMIO region physical address */
unsigned long BIOSAddr; /* BIOS physical address */
unsigned char *MMIO; /* Map of MMIO region */
unsigned char *FB; /* Map of frame buffer */
CARD8 *VBIOS; /* Video BIOS pointer */
unsigned char *MMIO; /* Map of MMIO region */
unsigned char *FB; /* Map of frame buffer */
int drmFD;
Bool directRenderingEnabled;
DRIInfoPtr pDRIInfo; /* XXX: defined in dri.h */
int drmFD;
drmHandle fbHandle;
drmHandle fbHandle;
drmSize registerSize;
drmHandle registerHandle;
drmSize registerSize;
drmHandle registerHandle;
drmSize agpSize;
drmHandle agpMemHandle; /* Handle from drmAgpAlloc */
unsigned long agpOffset;
unsigned char *AGP; /* Map */
int agpMode;
int agpFastWrite;
drmSize agpSize;
drmHandle agpMemHandle; /* Handle from drmAgpAlloc */
unsigned long agpOffset;
unsigned char *AGP; /* Map */
int agpMode;
int agpFastWrite;
/* CP ring buffer data */
unsigned long ringStart; /* Offset into AGP space */
drmHandle ringHandle; /* Handle from drmAddMap */
drmSize ringMapSize; /* Size of map */
int ringSize; /* Size of ring (in MB) */
unsigned char *ring; /* Map */
int ringSizeLog2QW;
unsigned long ringStart; /* Offset into AGP space */
drmHandle ringHandle; /* Handle from drmAddMap */
drmSize ringMapSize; /* Size of map */
int ringSize; /* Size of ring (in MB) */
unsigned char *ring; /* Map */
int ringSizeLog2QW;
unsigned long ringReadOffset; /* Offset into AGP space */
drmHandle ringReadPtrHandle; /* Handle from drmAddMap */
drmSize ringReadMapSize; /* Size of map */
unsigned char *ringReadPtr; /* Map */
unsigned long ringReadOffset; /* Offset into AGP space */
drmHandle ringReadPtrHandle; /* Handle from drmAddMap */
drmSize ringReadMapSize; /* Size of map */
unsigned char *ringReadPtr; /* Map */
/* CP vertex/indirect buffer data */
unsigned long bufStart; /* Offset into AGP space */
drmHandle bufHandle; /* Handle from drmAddMap */
drmSize bufMapSize; /* Size of map */
int bufSize; /* Size of buffers (in MB) */
unsigned char *buf; /* Map */
int bufNumBufs; /* Number of buffers */
drmBufMapPtr buffers; /* Buffer map */
unsigned long bufStart; /* Offset into AGP space */
drmHandle bufHandle; /* Handle from drmAddMap */
drmSize bufMapSize; /* Size of map */
int bufSize; /* Size of buffers (in MB) */
unsigned char *buf; /* Map */
int bufNumBufs; /* Number of buffers */
drmBufMapPtr buffers; /* Buffer map */
/* CP AGP Texture data */
unsigned long agpTexStart; /* Offset into AGP space */
drmHandle agpTexHandle; /* Handle from drmAddMap */
drmSize agpTexMapSize; /* Size of map */
int agpTexSize; /* Size of AGP tex space (in MB) */
unsigned char *agpTex; /* Map */
int log2AGPTexGran;
unsigned long agpTexStart; /* Offset into AGP space */
drmHandle agpTexHandle; /* Handle from drmAddMap */
drmSize agpTexMapSize; /* Size of map */
int agpTexSize; /* Size of AGP tex space (in MB) */
unsigned char *agpTex; /* Map */
int log2AGPTexGran;
int drmMinor;
int frontOffset;
int frontPitch;
int backOffset;
int backPitch;
int depthOffset;
int depthPitch;
int textureOffset;
int textureSize;
int log2TexGran;
int frontOffset;
int frontPitch;
int backOffset;
int backPitch;
int depthOffset;
int depthPitch;
int textureOffset;
int textureSize;
int log2TexGran;
CARD32 frontPitchOffset;
CARD32 backPitchOffset;
CARD32 depthPitchOffset;
unsigned int frontPitchOffset;
unsigned int backPitchOffset;
unsigned int depthPitchOffset;
CARD32 dst_pitch_offset;
unsigned int dst_pitch_offset;
int irq;
CARD32 gen_int_cntl;
int irq;
unsigned int gen_int_cntl;
} RADEONInfoRec, *RADEONInfoPtr;
extern Bool RADEONDRIScreenInit(ScreenPtr pScreen);
extern void RADEONDRICloseScreen(ScreenPtr pScreen);
extern Bool RADEONDRIFinishScreenInit(ScreenPtr pScreen);
#endif /* XF86DRI */
#endif /* _RADEON_H_ */

File diff suppressed because it is too large Load diff

View file

@ -50,6 +50,7 @@
#define RADEON_DEFAULT_BUFFER_SIZE 2 /* MB (must be page aligned) */
#define RADEON_DEFAULT_AGP_TEX_SIZE 1 /* MB (must be page aligned) */
#define RADEON_DEFAULT_CP_TIMEOUT 10000 /* usecs */
#define RADEON_BUFFER_ALIGN 0x00000fff
typedef struct {
/* DRI screen private data */

View file

@ -38,38 +38,6 @@ __driUtilMessage(const char *f, ...)
/* KW: this looks like a reasonable place to hook in the
* hardware init lifted from the 2d driver.
*/
static void GetDeviceInfo(Display* dpy,
int screen,
drmHandlePtr hFrameBuffer,
int* fbOrigin,
int* fbSize,
int* fbStride,
int* devPrivateSize,
void** pDevPrivate)
{
#if 0
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
*hFrameBuffer = pDRIPriv->hFrameBuffer;
*fbOrigin = 0;
*fbSize = pDRIPriv->pDriverInfo->frameBufferSize;
*fbStride = pDRIPriv->pDriverInfo->frameBufferStride;
*devPrivateSize = 0;
*pDevPrivate = 0;
#else
/* typical observed values: */
*hFrameBuffer = 0xd0000000;
*fbOrigin = 0; /* duplicates values in pDevPriv on radeon */
*fbSize = 128 * 1024 * 1024; /* needed for drmMap/Unmap */
*fbStride = 1600 * 4; /* ? */
*devPrivateSize = 100; /* RADEONDRIRec from Xserver */
*pDevPrivate = calloc(1, *devPrivateSize); /* pointer to RADEONDRIRec */
#endif
}
@ -443,7 +411,6 @@ static void driDestroyScreen(Display *dpy, int scrn, void *screenPrivate)
if (psp->fd) {
(void)drmUnmap((drmAddress)psp->pSAREA, SAREA_MAX);
(void)drmUnmap((drmAddress)psp->pFB, psp->fbSize);
(void)drmClose(psp->fd);
}
@ -476,20 +443,12 @@ __driUtilCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
hSAREA = 0xe090c000;
BusID = "PCI:1:0:0";
printf("hSAREA = 0x%x BusID = %s\n", (int) hSAREA, BusID);
psp->fd = drmOpen(NULL,BusID);
if (psp->fd < 0) {
fprintf(stderr, "libGL error: failed to open DRM: %s\n", strerror(-psp->fd));
fprintf(stderr, "libGL error: reverting to (slow) indirect rendering\n");
free(psp);
return NULL;
}
if (drmGetMagic(psp->fd, &magic)) {
fprintf(stderr, "libGL error: drmGetMagic failed\n");
(void)drmClose(psp->fd);
free(psp);
return NULL;
}
@ -503,9 +462,10 @@ __driUtilCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
drmFreeVersion(version);
}
else {
psp->drmMajor = -1;
psp->drmMinor = -1;
psp->drmPatch = -1;
fprintf(stderr, "libGL error: failed to get drm version: %s\n",
strerror(-psp->fd));
free(psp);
return NULL;
}
}
@ -522,8 +482,6 @@ __driUtilCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
psp->driMajor = XF86DRI_MAJOR_VERSION;
psp->driMinor = XF86DRI_MINOR_VERSION;
psp->driPatch = XF86DRI_PATCH_VERSION;
printf("ClientDriver %d %d %d\n", psp->driMajor, psp->driMinor,
psp->driPatch);
/* install driver's callback functions */
memcpy(&psp->DriverAPI, driverAPI, sizeof(struct __DriverAPIRec));
@ -534,34 +492,16 @@ __driUtilCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
* that has information about the screen size, depth, pitch,
* ancilliary buffers, DRM mmap handles, etc.
*/
GetDeviceInfo(dpy, scrn,
&hFB,
&psp->fbOrigin,
&psp->fbSize,
&psp->fbStride,
&psp->devPrivSize,
&psp->pDevPriv);
psp->pFB = dpy->FrameBuffer;
psp->fbOrigin = 0;
psp->fbSize = dpy->FrameBufferSize;
psp->fbStride = dpy->VarInfo.xres_virtual * dpy->cpp;
psp->devPrivSize = dpy->driverInfoSize;
psp->pDevPriv = dpy->driverInfo;
psp->fbWidth = dpy->VarInfo.xres;
psp->fbHeight = dpy->VarInfo.yres;
psp->fbBPP = dpy->VarInfo.bits_per_pixel;
printf("hFB = 0x%x\n", (int) hFB);
printf("fbOrigin=%d fbSize=%d fbStride=%d devPrivSize=%d pDevPriv=%p\n",
psp->fbOrigin, psp->fbSize, psp->fbStride, psp->devPrivSize,
psp->pDevPriv);
printf("w=%d h=%d\n", psp->fbWidth, psp->fbHeight);
/*
* Map the framebuffer region.
*/
if (drmMap(psp->fd, hFB, psp->fbSize, (drmAddressPtr)&psp->pFB)) {
fprintf(stderr, "libGL error: drmMap of framebuffer failed\n");
free(psp->pDevPriv);
(void)drmClose(psp->fd);
free(psp);
return NULL;
}
/*
* Map the SAREA region. Further mmap regions may be setup in
@ -569,7 +509,6 @@ __driUtilCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
*/
if (drmMap(psp->fd, hSAREA, SAREA_MAX, (drmAddressPtr)&psp->pSAREA)) {
fprintf(stderr, "libGL error: drmMap of sarea failed\n");
(void)drmUnmap((drmAddress)psp->pFB, psp->fbSize);
free(psp->pDevPriv);
(void)drmClose(psp->fd);
free(psp);
@ -581,7 +520,6 @@ __driUtilCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
if (!(*psp->DriverAPI.InitDriver)(psp)) {
fprintf(stderr, "libGL error: InitDriver failed\n");
(void)drmUnmap((drmAddress)psp->pSAREA, SAREA_MAX);
(void)drmUnmap((drmAddress)psp->pFB, psp->fbSize);
free(psp->pDevPriv);
(void)drmClose(psp->fd);
free(psp);
@ -615,20 +553,9 @@ __driUtilCreateScreenNoDRM(Display *dpy, int scrn, __DRIscreen *psc,
if (!psp)
return NULL;
/*
* Get device name (like "tdfx") and the ddx version numbers.
* We'll check the version in each DRI driver's "createScreen"
* function.
*/
GetClientDriverName(dpy, scrn,
&psp->ddxMajor,
&psp->ddxMinor,
&psp->ddxPatch,
&driverName);
/* Screen private information -- yet another duplicate of
* fbdev info.
*/
psp->ddxMajor = 4;
psp->ddxMinor = 0;
psp->ddxPatch = 1;
psp->driMajor = XF86DRI_MAJOR_VERSION;
psp->driMinor = XF86DRI_MINOR_VERSION;
psp->driPatch = XF86DRI_PATCH_VERSION;

View file

@ -60,14 +60,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "GL/internal/glcore.h" /* for __GLcontextModes */
#include "miniglxP.h" /* XID, etc */
/* Warning : Do not change XF86DRIClipRect without changing the kernel
* structure! */
typedef struct _XF86DRIClipRect {
unsigned short x1; /* Upper left: inclusive */
unsigned short y1;
unsigned short x2; /* Lower right: exclusive */
unsigned short y2;
} XF86DRIClipRectRec, *XF86DRIClipRectPtr;
typedef struct __DRIdisplayPrivateRec __DRIdisplayPrivate;

View file

@ -1,4 +1,4 @@
/* $Id: miniglx.c,v 1.1.4.15 2002/12/16 18:55:44 keithw Exp $ */
/* $Id: miniglx.c,v 1.1.4.16 2002/12/19 10:16:19 keithw Exp $ */
/*
* Mesa 3-D graphics library
@ -177,7 +177,7 @@ OpenFBDev( Display *dpy )
}
/* open the framebuffer device */
dpy->FrameBufferFD = open("/dev/fb0", O_RDWR);
dpy->FrameBufferFD = open(dpy->fbdevDevice, O_RDWR);
if (dpy->FrameBufferFD < 0) {
fprintf(stderr, "Error opening /dev/fb0: %s\n", strerror(errno));
return GL_FALSE;
@ -341,6 +341,7 @@ SetupFBDev( Display *dpy, Window win )
return GL_FALSE;
}
if (0)
{
int x, y;
char *scrn = (char *)dpy->FrameBuffer;
@ -372,6 +373,8 @@ SetupFBDev( Display *dpy, Window win )
return GL_FALSE;
}
/* TODO: Tell kernel not to use accelerated functions -- see fbdevhw.c */
return GL_TRUE;
}
@ -495,6 +498,24 @@ InitializeScreenConfigs(int *numConfigs, __GLXvisualConfig **configs)
/* Public API functions (Xlib and GLX) */
/**********************************************************************/
/* Replace with a config file read at runtime, eventually...
*/
int __read_config_file( Display *dpy )
{
dpy->fbdevDevice = "/dev/fb0";
dpy->clientDriverName = "radeon_dri.so";
dpy->drmModuleName = "radeon.o";
dpy->pciBus = 1;
dpy->pciDevice = 0;
dpy->pciFunc = 0;
dpy->chipset = 0x5144; /* radeon qd */
dpy->pciBusID = malloc(64);
sprintf((char *)dpy->pciBusID, "PCI:%d:%d:%d",
dpy->pciBus, dpy->pciDevice, dpy->pciFunc);
}
/* Jose: This function not stable
*/
Display *
@ -506,6 +527,14 @@ XOpenDisplay( const char *display_name )
if (!dpy)
return NULL;
if (!__read_config_file( dpy )) {
fprintf(stderr, "Couldn't get configuration details\n");
FREE(dpy);
return NULL;
}
if (!OpenFBDev(dpy)) {
fprintf(stderr, "OpenFBDev failed\n");
FREE(dpy);
@ -519,20 +548,31 @@ XOpenDisplay( const char *display_name )
* We're kind of combining the per-display and per-screen information
* which was kept separate in XFree86/DRI's libGL.
*/
#define DRIVER_DRI_SO "fb_dri.so"
dpy->dlHandle = dlopen(DRIVER_DRI_SO, RTLD_NOW | RTLD_GLOBAL);
dpy->dlHandle = dlopen(dpy->clientDriverName, RTLD_NOW | RTLD_GLOBAL);
if (!dpy->dlHandle) {
fprintf(stderr, "Unable to open %s: %s\n", DRIVER_DRI_SO, dlerror());
fprintf(stderr, "Unable to open %s: %s\n", dpy->clientDriverName,
dlerror());
CleanupFBDev(dpy);
FREE(dpy);
return NULL;
}
dpy->driverInitFBDev = (InitFBDevFunc) dlsym(dpy->dlHandle,
"__driInitFBDev");
if (!dpy->driverInitFBDev) {
fprintf(stderr, "Couldn't find __driInitFBDev in %s\n",
dpy->clientDriverName);
dlclose(dpy->dlHandle);
FREE(dpy);
return NULL;
}
dpy->createScreen = (CreateScreenFunc) dlsym(dpy->dlHandle,
"__driCreateScreen");
if (!dpy->createScreen) {
fprintf(stderr, "Couldn't find __driCreateScreen in %s\n",
DRIVER_DRI_SO);
dpy->clientDriverName);
dlclose(dpy->dlHandle);
FREE(dpy);
return NULL;

View file

@ -88,6 +88,8 @@ typedef struct __DRIdrawableRec __DRIdrawable;
typedef void *(*CreateScreenFunc)(Display *dpy, int scrn, __DRIscreen *psc,
int numConfigs, __GLXvisualConfig *config);
typedef void *(*InitFBDevFunc)( Display *dpy );
/*
** Screen dependent methods. This structure is initialized during the
@ -252,17 +254,53 @@ struct MiniGLXDisplayRec {
int width;
int height;
int bpp;
int cpp;
int numConfigs;
__GLXvisualConfig *configs;
/* From __GLXdisplayPrivate */
/* ScreenInitFunc screenInit; */
InitFBDevFunc driverInitFBDev;
CreateScreenFunc createScreen;
__DRIscreen driScreen;
void *dlHandle;
/* Configuration details -- will come from a file, hardcoded for now
* Can we get chipset from fbdev? -- kindof, see fbdevhw.c
*/
const char *fbdevDevice;
const char *clientDriverName;
const char *drmModuleName;
const char *pciBusID;
int pciBus;
int pciDevice;
int pciFunc;
int chipset;
/* From DRIInfoRec
*/
int drmFD;
unsigned long hSAREA;
int SAREASize;
void *pSAREA;
/* Driver private, poplulated by __driInitFBDev();
*/
void *driverPrivate;
void *driverInfo;
int driverInfoSize;
};
/* Warning : Do not change XF86DRIClipRect without changing the kernel
* structure! */
typedef struct _XF86DRIClipRect {
unsigned short x1; /* Upper left: inclusive */
unsigned short y1;
unsigned short x2; /* Lower right: exclusive */
unsigned short y2;
} XF86DRIClipRectRec, *XF86DRIClipRectPtr;
extern __DRIscreen *__glXFindDRIScreen(Display *dpy, int scrn);