Bring some more initialization code from the 2d driver. 2d accels now

work (glClear).  Pageflip now works for swapbuffers.
This commit is contained in:
Keith Whitwell 2002-12-30 13:15:55 +00:00
parent e17d611067
commit 695b197cb2
7 changed files with 204 additions and 93 deletions

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.1.2.6 2002/12/25 12:51:21 keithw Exp $
# $Id: Makefile,v 1.1.2.7 2002/12/30 13:15:55 keithw Exp $
# Mesa 3-D graphics library
# Version: 5.0
@ -71,7 +71,7 @@ radeon_dri.so: $(COREMESA) $(OBJECTS) Makefile
rm -f $@ && gcc -o $@ -shared $(OBJECTS) $(COREMESA) -L$(MESA)/src/miniglx -lGL -lc -lm
install:
rm -f $(MESA)/lib/fb_dri.so && \
rm -f $(MESA)/lib/radeon_dri.so && \
install -C radeon_dri.so $(MESA)/lib/radeon_dri.so
clean:

View file

@ -108,8 +108,9 @@ void radeonGetLock( radeonContextPtr rmesa, GLuint flags )
*/
DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv );
if ( rmesa->lastStamp != dPriv->lastStamp ) {
radeonUpdatePageFlipping( rmesa );
if ( rmesa->lastStamp != dPriv->lastStamp ) {
if (rmesa->glCtx->Color._DrawDestMask == BACK_LEFT_BIT)
radeonSetCliprects( rmesa, GL_BACK_LEFT );
else

View file

@ -378,6 +378,7 @@ void radeonInitSpanFuncs( GLcontext *ctx )
break;
default:
assert(0);
break;
}
@ -402,6 +403,7 @@ void radeonInitSpanFuncs( GLcontext *ctx )
break;
default:
assert(0);
break;
}

View file

@ -32,6 +32,156 @@
#endif
static void RADEONWaitForFifo( struct MiniGLXDisplayRec *dpy,
int entries )
{
unsigned char *RADEONMMIO = dpy->MMIOAddress;
int i;
for (i = 0; i < 512; i++) {
int fifo_slots =
INREG(RADEON_RBBM_STATUS) & RADEON_RBBM_FIFOCNT_MASK;
if (fifo_slots >= entries) return;
}
/* There are recoveries possible, but I haven't seen them work
* in practice:
*/
fprintf(stderr, "FIFO timed out: %d entries, stat=0x%08x\n",
INREG(RADEON_RBBM_STATUS) & RADEON_RBBM_FIFOCNT_MASK,
INREG(RADEON_RBBM_STATUS));
exit(1);
}
unsigned int RADEONINPLL( struct MiniGLXDisplayRec *dpy, int addr)
{
unsigned char *RADEONMMIO = dpy->MMIOAddress;
unsigned int data;
OUTREG8(RADEON_CLOCK_CNTL_INDEX, addr & 0x3f);
data = INREG(RADEON_CLOCK_CNTL_DATA);
return data;
}
/* Reset graphics card to known state */
void RADEONEngineReset( struct MiniGLXDisplayRec *dpy )
{
unsigned char *RADEONMMIO = dpy->MMIOAddress;
unsigned int clock_cntl_index;
unsigned int mclk_cntl;
unsigned int rbbm_soft_reset;
unsigned int host_path_cntl;
int i;
OUTREGP(RADEON_RB2D_DSTCACHE_CTLSTAT,
RADEON_RB2D_DC_FLUSH_ALL,
~RADEON_RB2D_DC_FLUSH_ALL);
for (i = 0; i < 512; i++) {
if (!(INREG(RADEON_RB2D_DSTCACHE_CTLSTAT) & RADEON_RB2D_DC_BUSY))
break;
}
clock_cntl_index = INREG(RADEON_CLOCK_CNTL_INDEX);
mclk_cntl = INPLL(dpy, RADEON_MCLK_CNTL);
OUTPLL(RADEON_MCLK_CNTL, (mclk_cntl |
RADEON_FORCEON_MCLKA |
RADEON_FORCEON_MCLKB |
RADEON_FORCEON_YCLKA |
RADEON_FORCEON_YCLKB |
RADEON_FORCEON_MC |
RADEON_FORCEON_AIC));
/* Soft resetting HDP thru RBBM_SOFT_RESET register can cause some
* unexpected behaviour on some machines. Here we use
* RADEON_HOST_PATH_CNTL to reset it.
*/
host_path_cntl = INREG(RADEON_HOST_PATH_CNTL);
rbbm_soft_reset = INREG(RADEON_RBBM_SOFT_RESET);
OUTREG(RADEON_RBBM_SOFT_RESET, (rbbm_soft_reset |
RADEON_SOFT_RESET_CP |
RADEON_SOFT_RESET_HI |
RADEON_SOFT_RESET_SE |
RADEON_SOFT_RESET_RE |
RADEON_SOFT_RESET_PP |
RADEON_SOFT_RESET_E2 |
RADEON_SOFT_RESET_RB));
INREG(RADEON_RBBM_SOFT_RESET);
OUTREG(RADEON_RBBM_SOFT_RESET, (rbbm_soft_reset &
(unsigned int) ~(RADEON_SOFT_RESET_CP |
RADEON_SOFT_RESET_HI |
RADEON_SOFT_RESET_SE |
RADEON_SOFT_RESET_RE |
RADEON_SOFT_RESET_PP |
RADEON_SOFT_RESET_E2 |
RADEON_SOFT_RESET_RB)));
INREG(RADEON_RBBM_SOFT_RESET);
OUTREG(RADEON_HOST_PATH_CNTL, host_path_cntl | RADEON_HDP_SOFT_RESET);
INREG(RADEON_HOST_PATH_CNTL);
OUTREG(RADEON_HOST_PATH_CNTL, host_path_cntl);
OUTREG(RADEON_RBBM_SOFT_RESET, rbbm_soft_reset);
OUTREG(RADEON_CLOCK_CNTL_INDEX, clock_cntl_index);
OUTPLL(RADEON_MCLK_CNTL, mclk_cntl);
}
static int RADEONEngineRestore( struct MiniGLXDisplayRec *dpy,
RADEONInfoPtr info )
{
unsigned char *RADEONMMIO = dpy->MMIOAddress;
int pitch64, datatype, dp_gui_master_cntl;
OUTREG(RADEON_RB3D_CNTL, 0);
RADEONEngineReset( dpy );
switch (dpy->VarInfo.bits_per_pixel) {
case 16: datatype = 4; break;
case 32: datatype = 6; break;
default: return 0;
}
dp_gui_master_cntl =
((datatype << RADEON_GMC_DST_DATATYPE_SHIFT)
| RADEON_GMC_CLR_CMP_CNTL_DIS);
pitch64 = ((dpy->VarInfo.xres_virtual * (dpy->VarInfo.bits_per_pixel / 8) + 0x3f)) >> 6;
RADEONWaitForFifo(dpy, 1);
OUTREG(RADEON_DEFAULT_OFFSET, ((INREG(RADEON_DEFAULT_OFFSET) & 0xC0000000)
| (pitch64 << 22)));
/* RADEONWaitForFifo(dpy, 1); */
/* OUTREG(RADEON_SURFACE_CNTL, info->ModeReg.surface_cntl); */
RADEONWaitForFifo(dpy, 1);
OUTREG(RADEON_DEFAULT_SC_BOTTOM_RIGHT, (RADEON_DEFAULT_SC_RIGHT_MAX
| RADEON_DEFAULT_SC_BOTTOM_MAX));
RADEONWaitForFifo(dpy, 1);
OUTREG(RADEON_DP_GUI_MASTER_CNTL, (dp_gui_master_cntl
| RADEON_GMC_BRUSH_SOLID_COLOR
| RADEON_GMC_SRC_DATATYPE_COLOR));
RADEONWaitForFifo(dpy, 7);
OUTREG(RADEON_DST_LINE_START, 0);
OUTREG(RADEON_DST_LINE_END, 0);
OUTREG(RADEON_DP_BRUSH_FRGD_CLR, 0xffffffff);
OUTREG(RADEON_DP_BRUSH_BKGD_CLR, 0);
OUTREG(RADEON_DP_SRC_FRGD_CLR, 0xffffffff);
OUTREG(RADEON_DP_SRC_BKGD_CLR, 0);
OUTREG(RADEON_DP_WRITE_MASK, 0xffffffff);
OUTREG(RADEON_AUX_SC_CNTL, 0);
/* RADEONWaitForIdleMMIO(dpy); */
sleep(2);
}
/* Compute log base 2 of val */
static int RADEONMinBits(int val)
{
@ -645,6 +795,9 @@ static int RADEONScreenInit( struct MiniGLXDisplayRec *dpy, RADEONInfoPtr info )
RADEONDRIAgpHeapInit(dpy, info);
fprintf(stderr, "RADEONDRIAgpHeapInit finished\n");
RADEONEngineRestore( dpy, info );
/* Initialize and start the CP if required */
RADEONDRICPInit( dpy, info );
fprintf(stderr, "RADEONDRICPInit finished\n");
@ -655,6 +808,7 @@ static int RADEONScreenInit( struct MiniGLXDisplayRec *dpy, RADEONInfoPtr info )
pSAREAPriv = (RADEONSAREAPrivPtr)(((char*)dpy->pSAREA) +
sizeof(XF86DRISAREARec));
memset(pSAREAPriv, 0, sizeof(*pSAREAPriv));
pSAREAPriv->pfAllowPageFlip = 1;
}
/* Can release the lock now */
@ -806,6 +960,7 @@ int __driInitFBDev( struct MiniGLXDisplayRec *dpy )
}
/* Stop the CP */
int RADEONCPStop( struct MiniGLXDisplayRec *dpy )
{

View file

@ -85,7 +85,7 @@ do { \
OUTREG(addr, tmp); \
} while (0)
#define INPLL(pScrn, addr) RADEONINPLL(pScrn, addr)
#define INPLL(dpy, addr) RADEONINPLL(dpy, addr)
#define OUTPLL(addr, val) \
do { \
@ -94,9 +94,9 @@ do { \
OUTREG(RADEON_CLOCK_CNTL_DATA, val); \
} while (0)
#define OUTPLLP(pScrn, addr, val, mask) \
#define OUTPLLP(dpy, addr, val, mask) \
do { \
GLuint tmp = INPLL(pScrn, addr); \
GLuint tmp = INPLL(dpy, addr); \
tmp &= (mask); \
tmp |= (val); \
OUTPLL(addr, tmp); \

View file

@ -12,11 +12,6 @@
#include "sarea.h"
#include "dri_util.h"
#define XF86DRI_MAJOR_VERSION 4
#define XF86DRI_MINOR_VERSION 1
#define XF86DRI_PATCH_VERSION 0
/**
* \brief Print message to \c stderr if the \c LIBGL_DEBUG environment variable
@ -39,15 +34,6 @@ __driUtilMessage(const char *f, ...)
}
/*****************************************************************/
/**
@ -200,32 +186,9 @@ static Bool driBindContext(Display *dpy, int scrn,
void __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp)
{
__DRIscreenPrivate *psp;
__DRIcontextPrivate *pcp = pdp->driContextPriv;
if (!pcp || (pdp != pcp->driDrawablePriv))
return;
psp = pdp->driScreenPriv;
if (!psp)
return;
if (pdp->pClipRects) {
free(pdp->pClipRects);
}
pdp->index = 0;
pdp->x = 0;
pdp->y = 0;
pdp->w = pdp->draw->w;
pdp->h = pdp->draw->h;
pdp->numClipRects = 1;
pdp->pClipRects = (XF86DRIClipRectPtr) malloc(sizeof(XF86DRIClipRectRec));
(pdp->pClipRects)[0].x1 = 0;
(pdp->pClipRects)[0].y1 = 0;
(pdp->pClipRects)[0].x2 = pdp->draw->w;
(pdp->pClipRects)[0].y2 = pdp->draw->h;
/* nothing to do, should never be called, but is referenced
* as an external symbol from client drivers
*/
}
/*****************************************************************/
@ -273,7 +236,7 @@ static void *driCreateDrawable(Display *dpy, int scrn,
pdp->draw = draw;
pdp->refcount = 0;
pdp->pStamp = &pdp->lastStamp;
pdp->pStamp = &pdp->lastStamp; /* cliprects will never change */
pdp->lastStamp = 0;
pdp->index = 0;
pdp->numBackClipRects = 0;
@ -281,6 +244,8 @@ static void *driCreateDrawable(Display *dpy, int scrn,
pdp->display = dpy;
pdp->screen = scrn;
/* Initialize with the invarient window dimensions and cliprects here.
*/
pdp->x = 0;
pdp->y = 0;
pdp->w = pdp->draw->w;
@ -380,7 +345,6 @@ static void *driCreateContext(Display *dpy, XVisualInfo *vis,
free(pcp);
return NULL;
}
fprintf(stderr, ">>> drmCreateContext worked: 0x%x\n", (int) pcp->hHWContext);
}
@ -404,7 +368,6 @@ static void *driCreateContext(Display *dpy, XVisualInfo *vis,
pctx->bindContext = driBindContext;
pctx->unbindContext = driUnbindContext;
fprintf(stderr, "%s: succeeded\n", __FUNCTION__);
return pcp;
}
@ -414,17 +377,12 @@ static void driDestroyScreen(Display *dpy, int scrn, void *screenPrivate)
{
__DRIscreenPrivate *psp = (__DRIscreenPrivate *) screenPrivate;
fprintf(stderr, "%s\n", __FUNCTION__);
if (psp) {
if (psp->DriverAPI.DestroyScreen)
(*psp->DriverAPI.DestroyScreen)(psp);
if (psp->fd) {
/* (void)drmUnmap((drmAddress)psp->pSAREA, SAREA_MAX); */
fprintf(stderr, "%s: Closing DRM fd\n", __FUNCTION__);
if (psp->fd)
(void)drmClose(psp->fd);
}
free(psp->pDevPriv);
free(psp);
@ -452,7 +410,8 @@ __driUtilCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
psp->fd = drmOpen(NULL,dpy->pciBusID);
if (psp->fd < 0) {
fprintf(stderr, "libGL error: failed to open DRM: %s\n", strerror(-psp->fd));
fprintf(stderr, "libGL error: failed to open DRM: %s\n",
strerror(-psp->fd));
free(psp);
return NULL;
}
@ -474,18 +433,14 @@ __driUtilCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
}
/*
* Fake the ddx version numbers.
* Fake various version numbers.
*/
psp->ddxMajor = 4;
psp->ddxMinor = 0;
psp->ddxPatch = 1;
/*
* Fake the DRI X extension version.
*/
psp->driMajor = XF86DRI_MAJOR_VERSION;
psp->driMinor = XF86DRI_MINOR_VERSION;
psp->driPatch = XF86DRI_PATCH_VERSION;
psp->driMajor = 4;
psp->driMinor = 1;
psp->driPatch = 0;
/* install driver's callback functions */
memcpy(&psp->DriverAPI, driverAPI, sizeof(struct __DriverAPIRec));
@ -511,7 +466,6 @@ __driUtilCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
if (psp->DriverAPI.InitDriver) {
if (!(*psp->DriverAPI.InitDriver)(psp)) {
fprintf(stderr, "libGL error: InitDriver failed\n");
/* (void)drmUnmap((drmAddress)psp->pSAREA, SAREA_MAX); */
free(psp->pDevPriv);
(void)drmClose(psp->fd);
free(psp);
@ -540,8 +494,6 @@ __driUtilCreateScreenNoDRM(Display *dpy, int scrn, __DRIscreen *psc,
__DRIscreenPrivate *psp;
char *driverName;
fprintf(stderr, "%s\n", __FUNCTION__);
psp = (__DRIscreenPrivate *)calloc(1, sizeof(__DRIscreenPrivate));
if (!psp)
return NULL;
@ -549,9 +501,9 @@ __driUtilCreateScreenNoDRM(Display *dpy, int scrn, __DRIscreen *psc,
psp->ddxMajor = 4;
psp->ddxMinor = 0;
psp->ddxPatch = 1;
psp->driMajor = XF86DRI_MAJOR_VERSION;
psp->driMinor = XF86DRI_MINOR_VERSION;
psp->driPatch = XF86DRI_PATCH_VERSION;
psp->driMajor = 4;
psp->driMinor = 1;
psp->driPatch = 0;
psp->display = dpy;
psp->myNum = scrn;
psp->fd = 0;

View file

@ -22,7 +22,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* $Id: miniglx.c,v 1.1.4.25 2002/12/27 11:25:08 keithw Exp $ */
/* $Id: miniglx.c,v 1.1.4.26 2002/12/30 13:15:56 keithw Exp $ */
/**
@ -578,28 +578,29 @@ InitializeScreenConfigs(int *numConfigs, __GLXvisualConfig **configs)
*/
int __read_config_file( Display *dpy )
{
#if 1
dpy->fbdevDevice = "/dev/fb0";
dpy->clientDriverName = "radeon_dri.so";
dpy->drmModuleName = "radeon";
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);
#else
dpy->fbdevDevice = "/dev/fb0";
dpy->clientDriverName = "fb_dri.so";
dpy->drmModuleName = 0;
dpy->pciBus = 0;
dpy->pciDevice = 0;
dpy->pciFunc = 0;
dpy->chipset = 0;
dpy->pciBusID = 0;
#endif
const char *dev = getenv("MINIGLX_DRIVER");
if (dev && strcmp(dev, "radeon") == 0) {
dpy->fbdevDevice = "/dev/fb0";
dpy->clientDriverName = "radeon_dri.so";
dpy->drmModuleName = "radeon";
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);
}
else {
dpy->fbdevDevice = "/dev/fb0";
dpy->clientDriverName = "fb_dri.so";
dpy->drmModuleName = 0;
dpy->pciBus = 0;
dpy->pciDevice = 0;
dpy->pciFunc = 0;
dpy->chipset = 0;
dpy->pciBusID = 0;
}
return 1;
}