Module Name: xsrc Committed By: mrg Date: Sun Dec 30 06:46:48 UTC 2018
Modified Files: xsrc/external/mit/xf86-video-mga/dist/src: mga_bios.c mga_dac3026.c mga_dacG.c mga_dga.c mga_dri.c mga_driver.c mga_exa.c mga_g450pll.c mga_merge.c mga_storm.c mga_video.c xsrc/external/mit/xf86-video-r128/dist/src: r128.h r128_driver.c r128_exa.c r128_output.c Removed Files: xsrc/external/mit/xf86-video-mga/dist: README README_HALLIB xsrc/external/mit/xf86-video-mga/dist/src: binding.h client.h mga_halmod.c Log Message: merge mga 2.0.0 and r128 6.12.0 drivers. To generate a diff of this commit: cvs rdiff -u -r1.1.1.2 -r0 xsrc/external/mit/xf86-video-mga/dist/README cvs rdiff -u -r1.1.1.1 -r0 \ xsrc/external/mit/xf86-video-mga/dist/README_HALLIB cvs rdiff -u -r1.1.1.2 -r0 \ xsrc/external/mit/xf86-video-mga/dist/src/binding.h \ xsrc/external/mit/xf86-video-mga/dist/src/client.h \ xsrc/external/mit/xf86-video-mga/dist/src/mga_halmod.c cvs rdiff -u -r1.3 -r1.4 xsrc/external/mit/xf86-video-mga/dist/src/mga_bios.c \ xsrc/external/mit/xf86-video-mga/dist/src/mga_dga.c \ xsrc/external/mit/xf86-video-mga/dist/src/mga_dri.c \ xsrc/external/mit/xf86-video-mga/dist/src/mga_g450pll.c \ xsrc/external/mit/xf86-video-mga/dist/src/mga_video.c cvs rdiff -u -r1.8 -r1.9 \ xsrc/external/mit/xf86-video-mga/dist/src/mga_dac3026.c cvs rdiff -u -r1.5 -r1.6 xsrc/external/mit/xf86-video-mga/dist/src/mga_dacG.c cvs rdiff -u -r1.4 -r1.5 \ xsrc/external/mit/xf86-video-mga/dist/src/mga_driver.c \ xsrc/external/mit/xf86-video-mga/dist/src/mga_exa.c \ xsrc/external/mit/xf86-video-mga/dist/src/mga_merge.c \ xsrc/external/mit/xf86-video-mga/dist/src/mga_storm.c cvs rdiff -u -r1.9 -r1.10 xsrc/external/mit/xf86-video-r128/dist/src/r128.h cvs rdiff -u -r1.18 -r1.19 \ xsrc/external/mit/xf86-video-r128/dist/src/r128_driver.c cvs rdiff -u -r1.2 -r1.3 \ xsrc/external/mit/xf86-video-r128/dist/src/r128_exa.c cvs rdiff -u -r1.6 -r1.7 \ xsrc/external/mit/xf86-video-r128/dist/src/r128_output.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: xsrc/external/mit/xf86-video-mga/dist/src/mga_bios.c diff -u xsrc/external/mit/xf86-video-mga/dist/src/mga_bios.c:1.3 xsrc/external/mit/xf86-video-mga/dist/src/mga_bios.c:1.4 --- xsrc/external/mit/xf86-video-mga/dist/src/mga_bios.c:1.3 Sat Aug 20 00:27:21 2016 +++ xsrc/external/mit/xf86-video-mga/dist/src/mga_bios.c Sun Dec 30 06:46:48 2018 @@ -297,7 +297,6 @@ Bool mga_read_and_process_bios( ScrnInfo #ifndef XSERVER_LIBPCIACCESS Bool pciBIOS = TRUE; #endif - int rlen; static const unsigned expected_length[] = { 0, 64, 64, 64, 128, 128 }; unsigned version; unsigned pins_len; Index: xsrc/external/mit/xf86-video-mga/dist/src/mga_dga.c diff -u xsrc/external/mit/xf86-video-mga/dist/src/mga_dga.c:1.3 xsrc/external/mit/xf86-video-mga/dist/src/mga_dga.c:1.4 --- xsrc/external/mit/xf86-video-mga/dist/src/mga_dga.c:1.3 Sat Aug 20 00:27:21 2016 +++ xsrc/external/mit/xf86-video-mga/dist/src/mga_dga.c Sun Dec 30 06:46:48 2018 @@ -15,7 +15,7 @@ static Bool MGA_OpenFramebuffer(ScrnInfo static Bool MGA_SetMode(ScrnInfoPtr, DGAModePtr); static int MGA_GetViewport(ScrnInfoPtr); static void MGA_SetViewport(ScrnInfoPtr, int, int, int); -#ifdef HAVE_XAA_H +#ifdef USE_XAA static void MGA_FillRect(ScrnInfoPtr, int, int, int, int, unsigned long); static void MGA_BlitRect(ScrnInfoPtr, int, int, int, int, int, int); static void MGA_BlitTransRect(ScrnInfoPtr, int, int, int, int, int, int, @@ -30,7 +30,7 @@ DGAFunctionRec MGA_DGAFuncs = { MGA_SetViewport, MGA_GetViewport, MGAStormSync, -#ifdef HAVE_XAA_H +#ifdef USE_XAA MGA_FillRect, MGA_BlitRect, MGA_BlitTransRect @@ -124,7 +124,7 @@ SECOND_PASS: mode->flags = DGA_CONCURRENT_ACCESS; if(pixmap) mode->flags |= DGA_PIXMAP_AVAILABLE; -#ifdef HAVE_XAA_H +#ifdef USE_XAA if(!pMga->NoAccel) { mode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT; if((Bpp != 3) && (pMga->Chipset != PCI_CHIP_MGA2064)) @@ -365,7 +365,7 @@ MGA_SetViewport( pMga->DGAViewportStatus = 0; /* MGAAdjustFrame loops until finished */ } -#ifdef HAVE_XAA_H +#ifdef USE_XAA static void MGA_FillRect ( ScrnInfoPtr pScrn, Index: xsrc/external/mit/xf86-video-mga/dist/src/mga_dri.c diff -u xsrc/external/mit/xf86-video-mga/dist/src/mga_dri.c:1.3 xsrc/external/mit/xf86-video-mga/dist/src/mga_dri.c:1.4 --- xsrc/external/mit/xf86-video-mga/dist/src/mga_dri.c:1.3 Sat Aug 20 00:27:21 2016 +++ xsrc/external/mit/xf86-video-mga/dist/src/mga_dri.c Sun Dec 30 06:46:48 2018 @@ -48,15 +48,8 @@ #include "mga_drm.h" #define _XF86DRI_SERVER_ -#include "GL/glxtokens.h" #include "sarea.h" - - - - -#include "GL/glxtokens.h" - #include "mga_reg.h" #include "mga.h" #include "mga_macros.h" @@ -67,224 +60,6 @@ static char MGAKernelDriverName[] = "mga"; static char MGAClientDriverName[] = "mga"; -/* Initialize the visual configs that are supported by the hardware. - * These are combined with the visual configs that the indirect - * rendering core supports, and the intersection is exported to the - * client. - */ -static Bool MGAInitVisualConfigs( ScreenPtr pScreen ) -{ - ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); - MGAPtr pMga = MGAPTR(pScrn); - int numConfigs = 0; - __GLXvisualConfig *pConfigs = 0; - MGAConfigPrivPtr pMGAConfigs = 0; - MGAConfigPrivPtr *pMGAConfigPtrs = 0; - int i, db, depth, stencil, accum; - - switch ( pScrn->bitsPerPixel ) { - case 8: - case 24: - break; - - case 16: - numConfigs = 8; - - pConfigs = (__GLXvisualConfig*)calloc( sizeof(__GLXvisualConfig), - numConfigs ); - if ( !pConfigs ) { - return FALSE; - } - - pMGAConfigs = (MGAConfigPrivPtr)calloc( sizeof(MGAConfigPrivRec), - numConfigs ); - if ( !pMGAConfigs ) { - free(pConfigs); - return FALSE; - } - - pMGAConfigPtrs = (MGAConfigPrivPtr*)calloc( sizeof(MGAConfigPrivPtr), - numConfigs ); - if ( !pMGAConfigPtrs ) { - free(pConfigs); - free(pMGAConfigs); - return FALSE; - } - - for ( i = 0 ; i < numConfigs ; i++ ) { - pMGAConfigPtrs[i] = &pMGAConfigs[i]; - } - - i = 0; - for ( accum = 0 ; accum <= 1 ; accum++ ) { - for ( stencil = 0 ; stencil <= 1 ; stencil++ ) { - for ( db = 1 ; db >= 0 ; db-- ) { - pConfigs[i].vid = -1; - pConfigs[i].class = -1; - pConfigs[i].rgba = TRUE; - pConfigs[i].redSize = 5; - pConfigs[i].greenSize = 6; - pConfigs[i].blueSize = 5; - pConfigs[i].alphaSize = 0; - pConfigs[i].redMask = 0x0000F800; - pConfigs[i].greenMask = 0x000007E0; - pConfigs[i].blueMask = 0x0000001F; - pConfigs[i].alphaMask = 0; - if ( accum ) { - pConfigs[i].accumRedSize = 16; - pConfigs[i].accumGreenSize = 16; - pConfigs[i].accumBlueSize = 16; - pConfigs[i].accumAlphaSize = 0; - } else { - pConfigs[i].accumRedSize = 0; - pConfigs[i].accumGreenSize = 0; - pConfigs[i].accumBlueSize = 0; - pConfigs[i].accumAlphaSize = 0; - } - if ( db ) { - pConfigs[i].doubleBuffer = TRUE; - } else { - pConfigs[i].doubleBuffer = FALSE; - } - pConfigs[i].stereo = FALSE; - pConfigs[i].bufferSize = 16; - pConfigs[i].depthSize = 16; - if ( stencil ) { - pConfigs[i].stencilSize = 8; - } else { - pConfigs[i].stencilSize = 0; - } - pConfigs[i].auxBuffers = 0; - pConfigs[i].level = 0; - if ( accum || stencil ) { - pConfigs[i].visualRating = GLX_SLOW_CONFIG; - } else { - pConfigs[i].visualRating = GLX_NONE; - } - pConfigs[i].transparentPixel = GLX_NONE; - pConfigs[i].transparentRed = 0; - pConfigs[i].transparentGreen = 0; - pConfigs[i].transparentBlue = 0; - pConfigs[i].transparentAlpha = 0; - pConfigs[i].transparentIndex = 0; - i++; - } - } - } - if ( i != numConfigs ) { - xf86DrvMsg( pScrn->scrnIndex, X_ERROR, - "[drm] Incorrect initialization of visuals\n" ); - return FALSE; - } - break; - - case 32: - numConfigs = 8; - - pConfigs = (__GLXvisualConfig*)calloc( sizeof(__GLXvisualConfig), - numConfigs ); - if ( !pConfigs ) { - return FALSE; - } - - pMGAConfigs = (MGAConfigPrivPtr)calloc( sizeof(MGAConfigPrivRec), - numConfigs ); - if ( !pMGAConfigs ) { - free(pConfigs); - return FALSE; - } - - pMGAConfigPtrs = (MGAConfigPrivPtr*)calloc( sizeof(MGAConfigPrivPtr), - numConfigs ); - if ( !pMGAConfigPtrs ) { - free(pConfigs); - free(pMGAConfigs); - return FALSE; - } - - for ( i = 0 ; i < numConfigs ; i++ ) { - pMGAConfigPtrs[i] = &pMGAConfigs[i]; - } - - i = 0; - for ( accum = 0 ; accum <= 1 ; accum++ ) { - for ( depth = 0 ; depth <= 1 ; depth++ ) { /* and stencil */ - for ( db = 1 ; db >= 0 ; db-- ) { - pConfigs[i].vid = -1; - pConfigs[i].class = -1; - pConfigs[i].rgba = TRUE; - pConfigs[i].redSize = 8; - pConfigs[i].greenSize = 8; - pConfigs[i].blueSize = 8; - pConfigs[i].alphaSize = 0; - pConfigs[i].redMask = 0x00FF0000; - pConfigs[i].greenMask = 0x0000FF00; - pConfigs[i].blueMask = 0x000000FF; - pConfigs[i].alphaMask = 0x0; - if ( accum ) { - pConfigs[i].accumRedSize = 16; - pConfigs[i].accumGreenSize = 16; - pConfigs[i].accumBlueSize = 16; - pConfigs[i].accumAlphaSize = 0; - } else { - pConfigs[i].accumRedSize = 0; - pConfigs[i].accumGreenSize = 0; - pConfigs[i].accumBlueSize = 0; - pConfigs[i].accumAlphaSize = 0; - } - if ( db ) { - pConfigs[i].doubleBuffer = TRUE; - } else { - pConfigs[i].doubleBuffer = FALSE; - } - pConfigs[i].stereo = FALSE; - pConfigs[i].bufferSize = 24; - if ( depth ) { - pConfigs[i].depthSize = 24; - pConfigs[i].stencilSize = 8; - } - else { - pConfigs[i].depthSize = 0; - pConfigs[i].stencilSize = 0; - } - pConfigs[i].auxBuffers = 0; - pConfigs[i].level = 0; - if ( accum ) { - pConfigs[i].visualRating = GLX_SLOW_CONFIG; - } else { - pConfigs[i].visualRating = GLX_NONE; - } - pConfigs[i].transparentPixel = GLX_NONE; - pConfigs[i].transparentRed = 0; - pConfigs[i].transparentGreen = 0; - pConfigs[i].transparentBlue = 0; - pConfigs[i].transparentAlpha = 0; - pConfigs[i].transparentIndex = 0; - i++; - } - } - } - if ( i != numConfigs ) { - xf86DrvMsg( pScrn->scrnIndex, X_ERROR, - "[drm] Incorrect initialization of visuals\n" ); - return FALSE; - } - break; - - default: - /* Unexpected bits/pixels */ - break; - } - - pMga->numVisualConfigs = numConfigs; - pMga->pVisualConfigs = pConfigs; - pMga->pVisualConfigsPriv = pMGAConfigs; - - GlxSetVisualConfigs( numConfigs, pConfigs, (void **)pMGAConfigPtrs ); - - return TRUE; -} - static Bool MGACreateContext( ScreenPtr pScreen, VisualPtr visual, drm_context_t hwContext, void *pVisualConfigPriv, DRIContextType contextStore ) @@ -346,12 +121,13 @@ static void MGAWaitForIdleDMA( ScrnInfoP void MGAGetQuiescence( ScrnInfoPtr pScrn ) { MGAPtr pMga = MGAPTR(pScrn); +#ifdef USE_XAA + MGAFBLayout *pLayout = &pMga->CurrentLayout; +#endif /* USE_XAA */ pMga->haveQuiescense = 1; if ( pMga->directRenderingEnabled ) { - MGAFBLayout *pLayout = &pMga->CurrentLayout; - MGAWaitForIdleDMA( pScrn ); /* FIXME what about EXA? */ @@ -958,7 +734,7 @@ static void MGADRIMoveBuffersXAA(WindowP pboxNew1 = 0; pptNew1 = 0; pboxNew2 = 0; - pboxNew2 = 0; + pptNew2 = 0; pptSrc = &ptOldOrg; dx = pParent->drawable.x - ptOldOrg.x; @@ -1095,10 +871,9 @@ Bool MGADRIScreenInit( ScreenPtr pScreen return FALSE; } - /* Check that the GLX, DRI, and DRM modules have been loaded by testing + /* Check that the DRI, and DRM modules have been loaded by testing * for canonical symbols in each module. */ - if ( !xf86LoaderCheckSymbol( "GlxSetVisualConfigs" ) ) return FALSE; if ( !xf86LoaderCheckSymbol( "drmAvailable" ) ) return FALSE; if ( !xf86LoaderCheckSymbol( "DRIQueryVersion" ) ) { xf86DrvMsg( pScreen->myNum, X_ERROR, @@ -1350,10 +1125,6 @@ Bool MGADRIScreenInit( ScreenPtr pScreen &scratch_ptr); } - if ( !MGAInitVisualConfigs( pScreen ) ) { - DRICloseScreen( pScreen ); - return FALSE; - } xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[dri] visual configs initialized\n" ); return TRUE; @@ -1495,6 +1266,4 @@ void MGADRICloseScreen( ScreenPtr pScree } free(pMga->DRIServerInfo); pMga->DRIServerInfo = 0; - free(pMga->pVisualConfigs); - free(pMga->pVisualConfigsPriv); } Index: xsrc/external/mit/xf86-video-mga/dist/src/mga_g450pll.c diff -u xsrc/external/mit/xf86-video-mga/dist/src/mga_g450pll.c:1.3 xsrc/external/mit/xf86-video-mga/dist/src/mga_g450pll.c:1.4 --- xsrc/external/mit/xf86-video-mga/dist/src/mga_g450pll.c:1.3 Sat Aug 20 00:27:22 2016 +++ xsrc/external/mit/xf86-video-mga/dist/src/mga_g450pll.c Sun Dec 30 06:46:48 2018 @@ -134,7 +134,7 @@ static CARD32 G450FindNextPLLParam(ScrnI *pulPLLMNP |= (CARD32)ucP; #ifdef DEBUG - ErrorF("FINS_S: VCO = %d, S = %02X, *pulPLLMNP = %08X\n", ulVCO, (ULONG)ucS, *pulPLLMNP); + ErrorF("FINS_S: VCO = %d, S = %02X, *pulPLLMNP = %08X\n", (unsigned)ulVCO, (unsigned)ucS, (unsigned)*pulPLLMNP); #endif } @@ -315,7 +315,7 @@ double MGAG450SetPLLFreq(ScrnInfoPtr pSc MGAPtr pMga = MGAPTR(pScrn); #ifdef DEBUG - xf86DrvMsg(pScrn->scrnIndex,X_INFO, "Restoring PLLClk = %d\n",f_out); + xf86DrvMsg(pScrn->scrnIndex,X_INFO, "Restoring PLLClk = %ld\n", f_out); #endif G450FindFirstPLLParam(pScrn, f_out, &ulMNP); ulMNPTable[0] = ulMNP; @@ -489,7 +489,7 @@ MGAG450SavePLLFreq(ScrnInfoPtr pScrn) G450ApplyPFactor(pScrn, ucP, &freq); #ifdef DEBUG - xf86DrvMsg(pScrn->scrnIndex,X_INFO,"Saved PLLClk = %d\n",freq); + xf86DrvMsg(pScrn->scrnIndex,X_INFO,"Saved PLLClk = %u\n", (unsigned)freq); #endif return freq; } @@ -506,7 +506,7 @@ MGAG450PrintPLL(ScrnInfoPtr pScrn) ucP = (CARD8)(ulMNP & 0x03); G450ApplyPFactor(pScrn, ucP, &freq); - xf86DrvMsg(pScrn->scrnIndex,X_INFO,"MGAGClock = %d -- MNP = 0x%x\n", - freq,ulMNP); + xf86DrvMsg(pScrn->scrnIndex,X_INFO,"MGAGClock = %u -- MNP = 0x%x\n", + (unsigned)freq, (unsigned)ulMNP); } #endif Index: xsrc/external/mit/xf86-video-mga/dist/src/mga_video.c diff -u xsrc/external/mit/xf86-video-mga/dist/src/mga_video.c:1.3 xsrc/external/mit/xf86-video-mga/dist/src/mga_video.c:1.4 --- xsrc/external/mit/xf86-video-mga/dist/src/mga_video.c:1.3 Sat Aug 20 00:27:22 2016 +++ xsrc/external/mit/xf86-video-mga/dist/src/mga_video.c Sun Dec 30 06:46:48 2018 @@ -565,8 +565,12 @@ MGAAllocateMemory( void **mem_struct, int size ){ +#if defined(USE_XAA) || defined(USE_EXA) MGAPtr pMga = MGAPTR(pScrn); +#endif /* defined(USE_XAA) || defined(USE_EXA) */ +#ifdef USE_XAA ScreenPtr pScreen = xf86ScrnToScreen(pScrn); +#endif /* USE_XAA */ int offset = 0; #ifdef USE_EXA @@ -644,7 +648,9 @@ MGAAllocateMemory( static void MGAFreeMemory(ScrnInfoPtr pScrn, void *mem_struct) { +#if defined(USE_XAA) || defined(USE_EXA) MGAPtr pMga = MGAPTR(pScrn); +#endif /* defined(USE_XAA) || defined(USE_EXA) */ #ifdef USE_EXA if (pMga->Exa) { @@ -1374,6 +1380,7 @@ static void CopyMungedScanline_AXP(CARD3 } } +#if 0 static void CopyMungedScanline_AXP2(CARD32 *fb_ptr, short src_w, CARD32 *tsp, CARD32 *tpu, CARD32 *tpv) { @@ -1393,6 +1400,7 @@ static void CopyMungedScanline_AXP2(CARD fb_ptr+=4; } } +#endif static void CopyMungedScanlineFilter_AXP(CARD32 *fb_ptr, short src_w, @@ -1466,6 +1474,7 @@ static void CopyMungedScanlineFilter_AXP } } +#if 0 static void CopyMungedScanlineFilterDown_AXP(CARD32 *fb_ptr, short src_w, CARD32 *tsp1, CARD32 *tpu1, CARD32 *tpv1, CARD32 *tsp2, CARD32 *tpu2, CARD32 *tpv2, @@ -1504,6 +1513,7 @@ static void CopyMungedScanlineFilterDown fb_ptr+=4; } } +#endif static void MGACopyScaledILOAD( ScrnInfoPtr pScrn, @@ -1520,7 +1530,12 @@ static void MGACopyScaledILOAD( CARD32 *fb_ptr; unsigned char *ubuf, *vbuf, *tbuf; CARD32 *pu, *pv; - int k,l, pl, dl, xds, yds; + int k,l; +#ifdef MGA2164_BLIT_DUP + int pl; +#endif /* MGA2164_BLIT_DUP */ + int dl; + int xds, yds; short box_h; short scr_pitch = ( pScrn->virtualX + 15) & ~15; @@ -1606,8 +1621,10 @@ static void MGACopyScaledILOAD( ubuf=vbuf+width*height/4; pu = (CARD32 *)(ubuf+(src_y/2)*(width/2)); pv = (CARD32 *)(vbuf+(src_y/2)*(width/2)); - - for(pl=-1,dl=0;dl<box_h;dl++) { +#ifdef MGA2164_BLIT_DUP + pl = -1; +#endif /* MGA2164_BLIT_DUP */ + for(dl=0;dl<box_h;dl++) { int beta; l=(dl+(pbox->y1-drw_y))*src_h/drw_h; /* FIXME: check the math */ @@ -1764,7 +1781,9 @@ static void MGACopyScaledILOAD( default: break; } +#ifdef MGA2164_BLIT_DUP pl=l; +#endif /* MGA2164_BLIT_DUP */ } else { /* dup lines */ @@ -1801,7 +1820,10 @@ static void MGACopyILOAD( CARD32 *fb_ptr; CARD8 *ubuf, *vbuf; CARD32 *pu, *pv; - int k,l; +#ifdef CUSTOM_MEMCOPY + int k; +#endif /* CUSTOM_MEMCOPY */ + int l; short clip_x1, clip_x2, tmp_w; #ifdef DEBUG_MGA2164 @@ -1968,7 +1990,6 @@ MGAPutImageILOAD( MGAPortPrivPtr pPriv = pMga->portPrivate; INT32 x1, x2, y1, y2; int dstPitch = 0; - int bpp; BoxRec dstBox; int nbox; BoxPtr pbox; @@ -1984,9 +2005,7 @@ MGAPutImageILOAD( clipBoxes, width, height)) return Success; - bpp = pScrn->bitsPerPixel >> 3; - -#ifdef HAVE_XAA_H +#ifdef USE_XAA if( pMga->AccelInfoRec->NeedToSync && ((long)data != pPriv->lastPort) ) { MGAStormSync(pScrn); } @@ -2020,7 +2039,7 @@ MGAPutImageILOAD( pbox++; } -#ifdef HAVE_XAA_H +#ifdef USE_XAA pMga->AccelInfoRec->NeedToSync = TRUE; #endif pPriv->videoStatus = FREE_TIMER; Index: xsrc/external/mit/xf86-video-mga/dist/src/mga_dac3026.c diff -u xsrc/external/mit/xf86-video-mga/dist/src/mga_dac3026.c:1.8 xsrc/external/mit/xf86-video-mga/dist/src/mga_dac3026.c:1.9 --- xsrc/external/mit/xf86-video-mga/dist/src/mga_dac3026.c:1.8 Sun Mar 5 01:32:02 2017 +++ xsrc/external/mit/xf86-video-mga/dist/src/mga_dac3026.c Sun Dec 30 06:46:48 2018 @@ -694,8 +694,8 @@ MGA3026Init(ScrnInfoPtr pScrn, DisplayMo MGA_NOT_HAL(MGATi3026SetMCLK(pScrn, MGAdac->MemoryClock)); #ifdef DEBUG - ErrorF("%6ld: %02X %02X %02X %02X %02X %02X %08lX\n", mode->Clock, - pReg->DacClk[0], pReg->DacClk[1], pReg->DacClk[2], pReg->DacClk[3], pReg->DacClk[4], pReg->DacClk[5], pReg->Option); + ErrorF("%6d: %02X %02X %02X %02X %02X %02X %08X\n", mode->Clock, + pReg->DacClk[0], pReg->DacClk[1], pReg->DacClk[2], pReg->DacClk[3], pReg->DacClk[4], pReg->DacClk[5], (unsigned)pReg->Option); for (i=0; i<sizeof(MGADACregs); i++) ErrorF("%02X ", pReg->DacRegs[i]); for (i=0; i<6; i++) ErrorF(" %02X", pReg->ExtVga[i]); ErrorF("\n"); @@ -863,8 +863,8 @@ MGA3026Save(ScrnInfoPtr pScrn, vgaRegPtr #endif #ifdef DEBUG - ErrorF("read: %02X %02X %02X %02X %02X %02X %08lX\n", - mgaReg->DacClk[0], mgaReg->DacClk[1], mgaReg->DacClk[2], mgaReg->DacClk[3], mgaReg->DacClk[4], mgaReg->DacClk[5], mgaReg->Option); + ErrorF("read: %02X %02X %02X %02X %02X %02X %08X\n", + mgaReg->DacClk[0], mgaReg->DacClk[1], mgaReg->DacClk[2], mgaReg->DacClk[3], mgaReg->DacClk[4], mgaReg->DacClk[5], (unsigned)mgaReg->Option); for (i=0; i<sizeof(MGADACregs); i++) ErrorF("%02X ", mgaReg->DacRegs[i]); for (i=0; i<6; i++) ErrorF(" %02X", mgaReg->ExtVga[i]); ErrorF("\n"); Index: xsrc/external/mit/xf86-video-mga/dist/src/mga_dacG.c diff -u xsrc/external/mit/xf86-video-mga/dist/src/mga_dacG.c:1.5 xsrc/external/mit/xf86-video-mga/dist/src/mga_dacG.c:1.6 --- xsrc/external/mit/xf86-video-mga/dist/src/mga_dacG.c:1.5 Sun Mar 5 01:32:02 2017 +++ xsrc/external/mit/xf86-video-mga/dist/src/mga_dacG.c Sun Dec 30 06:46:48 2018 @@ -58,7 +58,6 @@ MGAG200E4ComputePLLParam(ScrnInfoPtr pSc { unsigned int ulComputedFo; unsigned int ulFDelta; - unsigned int ulFPermitedDelta; unsigned int ulFTmpDelta; unsigned int ulVCOMax, ulVCOMin; unsigned int ulTestP; @@ -81,8 +80,6 @@ MGAG200E4ComputePLLParam(ScrnInfoPtr pSc ulFoInternal = lFo * 2; ulFDelta = 0xFFFFFFFF; - /* Permited delta is 0.5% as VESA Specification */ - ulFPermitedDelta = ulFoInternal * 5 / 1000; for (i = 0 ; i < P_ARRAY_SIZE ; i++) { @@ -125,7 +122,6 @@ MGAG200SEComputePLLParam(ScrnInfoPtr pSc { unsigned int ulComputedFo; unsigned int ulFDelta; - unsigned int ulFPermitedDelta; unsigned int ulFTmpDelta; unsigned int ulVCOMax, ulVCOMin; unsigned int ulTestP; @@ -138,8 +134,6 @@ MGAG200SEComputePLLParam(ScrnInfoPtr pSc ulPLLFreqRef = 25000; ulFDelta = 0xFFFFFFFF; - /* Permited delta is 0.5% as VESA Specification */ - ulFPermitedDelta = lFo * 5 / 1000; /* Then we need to minimize the M while staying within 0.5% */ for (ulTestP = 8; ulTestP > 0; ulTestP >>= 1) { @@ -170,7 +164,6 @@ MGAG200EVComputePLLParam(ScrnInfoPtr pSc { unsigned int ulComputedFo; unsigned int ulFDelta; - unsigned int ulFPermitedDelta; unsigned int ulFTmpDelta; unsigned int ulTestP; unsigned int ulTestM; @@ -184,8 +177,6 @@ MGAG200EVComputePLLParam(ScrnInfoPtr pSc ulPLLFreqRef = 50000; ulFDelta = 0xFFFFFFFF; - /* Permited delta is 0.5% as VESA Specification */ - ulFPermitedDelta = lFo * 5 / 1000; /* Then we need to minimize the M while staying within 0.5% */ for (ulTestP = 16; ulTestP > 0; ulTestP--) { @@ -221,7 +212,6 @@ MGAG200WBComputePLLParam(ScrnInfoPtr pSc { unsigned int ulComputedFo; unsigned int ulFDelta; - unsigned int ulFPermitedDelta; unsigned int ulFTmpDelta; unsigned int ulVCOMax, ulVCOMin; unsigned int ulTestP; @@ -244,8 +234,6 @@ MGAG200WBComputePLLParam(ScrnInfoPtr pSc ulTestMEnd = 16; ulFDelta = 0xFFFFFFFF; - /* Permited delta is 0.5% as VESA Specification */ - ulFPermitedDelta = lFo * 5 / 1000; /* Then we need to minimize the M while staying within 0.5% */ for (ulTestP = ulTestPStart; ulTestP < 9; ulTestP++) { @@ -281,7 +269,6 @@ MGAG200EW3ComputePLLParam(ScrnInfoPtr pS { unsigned int ulComputedFo; unsigned int ulFDelta; - unsigned int ulFPermitedDelta; unsigned int ulFTmpDelta; unsigned int ulVCOMax, ulVCOMin; unsigned int ulTestP1; @@ -311,8 +298,6 @@ MGAG200EW3ComputePLLParam(ScrnInfoPtr pS ulTestNEnd = 2048; ulFDelta = 0xFFFFFFFF; - /* Permited delta is 0.5% as VESA Specification */ - ulFPermitedDelta = lFo * 5 / 1000; /* Then we need to minimize the M while staying within 0.5% */ for (ulTestP1 = ulTestP1Start; ulTestP1 < ulTestP1End; ulTestP1++) { @@ -349,7 +334,6 @@ MGAG200EHComputePLLParam(ScrnInfoPtr pSc { unsigned int ulComputedFo; unsigned int ulFDelta; - unsigned int ulFPermitedDelta; unsigned int ulFTmpDelta; unsigned int ulTestP; unsigned int ulTestM; @@ -363,8 +347,6 @@ MGAG200EHComputePLLParam(ScrnInfoPtr pSc ulPLLFreqRef = 33333; ulFDelta = 0xFFFFFFFF; - /* Permited delta is 0.5% as VESA Specification */ - ulFPermitedDelta = lFo * 5 / 1000; /* Then we need to minimize the M while staying within 0.5% */ for (ulTestP = 16; ulTestP > 0; ulTestP>>= 1) { @@ -393,6 +375,49 @@ MGAG200EHComputePLLParam(ScrnInfoPtr pSc } } +void +MGAG200EH3ComputePLLParam(ScrnInfoPtr pScrn, long lFo, int *M, int *N, int *P) +{ + unsigned int ulComputedFo; + unsigned int ulFDelta; + unsigned int ulFTmpDelta; + unsigned int ulTestP; + unsigned int ulTestM; + unsigned int ulTestN; + unsigned int ulVCOMax; + unsigned int ulVCOMin; + unsigned int ulPLLFreqRef; + + ulVCOMax = 3000000; + ulVCOMin = 1500000; + ulPLLFreqRef = 25000; + + ulTestP = 0; + + ulFDelta = 0xFFFFFFFF; + + /* Then we need to minimize the M while staying within 0.5% */ + for (ulTestM = 150; ulTestM >= 6; ulTestM--) { + if ((lFo * ulTestM) > ulVCOMax) continue; + if ((lFo * ulTestM) < ulVCOMin) continue; + + for (ulTestN = 120; ulTestN >= 60; ulTestN--) { + ulComputedFo = (ulPLLFreqRef * ulTestN) / ulTestM; + if (ulComputedFo > lFo) + ulFTmpDelta = ulComputedFo - lFo; + else + ulFTmpDelta = lFo - ulComputedFo; + + if (ulFTmpDelta < ulFDelta) { + ulFDelta = ulFTmpDelta; + *M = (CARD8)(ulTestM); + *N = (CARD8)(ulTestN); + *P = (CARD8)(ulTestP); + } + } + } +} + static void MGAG200EVPIXPLLSET(ScrnInfoPtr pScrn, MGARegPtr mgaReg) { @@ -781,12 +806,8 @@ MGAG200EHPIXPLLSET(ScrnInfoPtr pScrn, MG { MGAPtr pMga = MGAPTR(pScrn); - unsigned long ulFallBackCounter, ulLoopCount, ulLockCheckIterations = 0, ulTempCount, ulVCount; + unsigned long ulLoopCount, ulLockCheckIterations = 0, ulTempCount, ulVCount; unsigned char ucTempByte, ucPixCtrl, ucPLLLocked = FALSE; - unsigned char ucM; - unsigned char ucN; - unsigned char ucP; - unsigned char ucS; while(ulLockCheckIterations <= 32 && ucPLLLocked == FALSE) { @@ -941,9 +962,8 @@ MGAGCalcClock ( ScrnInfoPtr pScrn, long /* * Pick the closest frequency. */ - av = fabs(calc_f - f_vco); - if ( av < m_err ) { - m_err = av; + if ( fabs(calc_f - f_vco) < m_err ) { + m_err = fabs(calc_f - f_vco); *best_m = m; *best_n = n; } @@ -1058,7 +1078,14 @@ MGAGSetPCLK( ScrnInfoPtr pScrn, long f_o pReg->PllN = n; pReg->PllP = p; } else if (pMga->is_G200EH) { - MGAG200EHComputePLLParam(pScrn, f_out, &m, &n, &p); + if (pMga->Chipset == PCI_CHIP_MGAG200_EH3_PCI) + { + MGAG200EH3ComputePLLParam(pScrn, f_out, &m, &n, &p); + } + else + { + MGAG200EHComputePLLParam(pScrn, f_out, &m, &n, &p); + } pReg->PllM = m; pReg->PllN = n; @@ -1265,6 +1292,7 @@ MGAGInit(ScrnInfoPtr pScrn, DisplayModeP break; case PCI_CHIP_MGAG200_EH_PCI: + case PCI_CHIP_MGAG200_EH3_PCI: pReg->DacRegs[MGA1064_MISC_CTL] = MGA1064_MISC_CTL_VGA8 | MGA1064_MISC_CTL_DAC_RAM_CS; @@ -1758,8 +1786,8 @@ MGA_NOT_HAL( ErrorF("0x%02X, ", mgaReg->DacRegs[i]); #endif } - ErrorF("\nOPTION = %08lX\n", mgaReg->Option); - ErrorF("OPTION2 = %08lX\n", mgaReg->Option2); + ErrorF("\nOPTION = %08X\n", (unsigned)mgaReg->Option); + ErrorF("OPTION2 = %08X\n", (unsigned)mgaReg->Option2); ErrorF("CRTCEXT:"); for (i=0; i<6; i++) ErrorF(" %02X", mgaReg->ExtVga[i]); ErrorF("\n"); @@ -1903,8 +1931,8 @@ MGAGSave(ScrnInfoPtr pScrn, vgaRegPtr vg ErrorF("0x%02X, ", mgaReg->DacRegs[i]); #endif } - ErrorF("\nOPTION = %08lX\n:", mgaReg->Option); - ErrorF("OPTION2 = %08lX\nCRTCEXT:", mgaReg->Option2); + ErrorF("\nOPTION = %08X\n:", (unsigned)mgaReg->Option); + ErrorF("OPTION2 = %08X\nCRTCEXT:", (unsigned)mgaReg->Option2); for (i=0; i<6; i++) ErrorF(" %02X", mgaReg->ExtVga[i]); ErrorF("\n"); #endif @@ -2121,7 +2149,7 @@ MGAG_I2CPutBits(I2CBusPtr b, int clock, static I2CBusPtr -mgag_create_i2c_bus(const char *name, unsigned bus_index, unsigned scrn_index) +mgag_create_i2c_bus(char *name, unsigned bus_index, unsigned scrn_index) { I2CBusPtr I2CPtr = xf86CreateI2CBusRec(); @@ -2131,7 +2159,7 @@ mgag_create_i2c_bus(const char *name, un I2CPtr->I2CPutBits = MGAG_I2CPutBits; I2CPtr->I2CGetBits = MGAG_I2CGetBits; I2CPtr->AcknTimeout = 5; - I2CPtr->DriverPrivate.ptr = & i2c_priv[bus_index]; + I2CPtr->DriverPrivate.ptr = (void *) &i2c_priv[bus_index]; if (!xf86I2CBusInit(I2CPtr)) { xf86DestroyI2CBusRec(I2CPtr, TRUE, TRUE); Index: xsrc/external/mit/xf86-video-mga/dist/src/mga_driver.c diff -u xsrc/external/mit/xf86-video-mga/dist/src/mga_driver.c:1.4 xsrc/external/mit/xf86-video-mga/dist/src/mga_driver.c:1.5 --- xsrc/external/mit/xf86-video-mga/dist/src/mga_driver.c:1.4 Sun Mar 5 01:32:02 2017 +++ xsrc/external/mit/xf86-video-mga/dist/src/mga_driver.c Sun Dec 30 06:46:48 2018 @@ -424,6 +424,21 @@ static const struct mga_device_attribute }, 16384, 0x4000, /* Memory probe size & offset values */ + }, + + [17] = { 0, 1, 0, 0, 1, 0, 0, 0, new_BARs, + (TRANSC_SOLID_FILL | TWO_PASS_COLOR_EXPAND | USE_LINEAR_EXPANSION), + { + { 50000, 230000 }, /* System VCO frequencies */ + { 50000, 203400 }, /* Pixel VCO frequencies */ + { 0, 0 }, /* Video VCO frequencies */ + 45000, /* Memory clock */ + 27050, /* PLL reference frequency */ + 0, /* Supports fast bitblt? */ + MGA_HOST_PCI /* Host interface */ + }, + + 16384, 0x4000, /* Memory probe size & offset values */ } }; @@ -458,6 +473,8 @@ static const struct pci_id_match mga_dev MGA_DEVICE_MATCH( PCI_CHIP_MGAG200_EW3_PCI, 16 ), + MGA_DEVICE_MATCH( PCI_CHIP_MGAG200_EH3_PCI, 17 ), + { 0, 0, 0 }, }; #endif @@ -479,6 +496,7 @@ static SymTabRec MGAChipsets[] = { { PCI_CHIP_MGAG200_WINBOND_PCI, "mgag200 eW Nuvoton" }, { PCI_CHIP_MGAG200_EW3_PCI, "mgag200 eW3 Nuvoton" }, { PCI_CHIP_MGAG200_EH_PCI, "mgag200eH" }, + { PCI_CHIP_MGAG200_EH3_PCI, "mgag200eH3" }, { PCI_CHIP_MGAG400, "mgag400" }, { PCI_CHIP_MGAG550, "mgag550" }, {-1, NULL } @@ -507,6 +525,8 @@ static PciChipsets MGAPciChipsets[] = { RES_SHARED_VGA }, { PCI_CHIP_MGAG200_EH_PCI, PCI_CHIP_MGAG200_EH_PCI, RES_SHARED_VGA }, + { PCI_CHIP_MGAG200_EH3_PCI, PCI_CHIP_MGAG200_EH3_PCI, + RES_SHARED_VGA }, { PCI_CHIP_MGAG400, PCI_CHIP_MGAG400, RES_SHARED_VGA }, { PCI_CHIP_MGAG550, PCI_CHIP_MGAG550, RES_SHARED_VGA }, { -1, -1, RES_UNDEFINED } @@ -680,7 +700,6 @@ MGAPciProbe(DriverPtr drv, int entity_nu intptr_t match_data) { ScrnInfoPtr pScrn = NULL; - EntityInfoPtr pEnt; MGAPtr pMga; if (pci_device_has_kernel_driver(dev)) { @@ -693,6 +712,7 @@ MGAPciProbe(DriverPtr drv, int entity_nu case PCI_CHIP_MGAG200_ER_PCI: case PCI_CHIP_MGAG200_WINBOND_PCI: case PCI_CHIP_MGAG200_EH_PCI: + case PCI_CHIP_MGAG200_EH3_PCI: xf86DrvMsg(0, X_ERROR, "mga: The PCI device 0x%x at %2.2d@%2.2d:%2.2d:%1.1d has a kernel module claiming it.\n", dev->device_id, dev->bus, dev->domain, dev->dev, dev->func); @@ -737,7 +757,6 @@ MGAPciProbe(DriverPtr drv, int entity_nu * For cards that can do dual head per entity, mark the entity * as sharable. */ - pEnt = xf86GetEntityInfo(entity_num); if (pMga->chip_attribs->dual_head_possible) { MGAEntPtr pMgaEnt = NULL; DevUnion *pPriv; @@ -948,6 +967,10 @@ MGAProbe(DriverPtr drv, int flags) attrib_no = 16; break; + case PCI_CHIP_MGAG200_EH3_PCI: + attrib_no = 17; + break; + default: return FALSE; } @@ -999,7 +1022,9 @@ MGASoftReset(ScrnInfoPtr pScrn) MGAPtr pMga = MGAPTR(pScrn); pMga->FbMapSize = 8192 * 1024; - MGAMapMem(pScrn); + if (!MGAMapMem(pScrn)) { + return; + } /* set soft reset bit */ OUTREG(MGAREG_Reset, 1); @@ -1120,7 +1145,9 @@ MGACountRam(ScrnInfoPtr pScrn) ProbeSize = 16384; ProbeSizeOffset = 0x10000; pMga->FbMapSize = ProbeSize * 1024; - MGAMapMem(pScrn); + if (!MGAMapMem(pScrn)) { + return 0; + } base = pMga->FbBase; } @@ -1135,7 +1162,7 @@ MGACountRam(ScrnInfoPtr pScrn) } if (pMga->is_G200WB) { - CARD32 Option, MaxMapSize; + uint32_t Option, MaxMapSize; #ifdef XSERVER_LIBPCIACCESS pci_device_cfg_read_u32(pMga->PciInfo, &Option, @@ -1160,7 +1187,9 @@ MGACountRam(ScrnInfoPtr pScrn) else { MGAUnmapMem(pScrn); pMga->FbMapSize = ProbeSize * 1024; - MGAMapMem(pScrn); + if (!MGAMapMem(pScrn)) { + return 0; + } base = pMga->FbBase; } } @@ -1567,7 +1596,8 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) pMga->is_G200EV = (pMga->Chipset == PCI_CHIP_MGAG200_EV_PCI); pMga->is_G200WB = (pMga->Chipset == PCI_CHIP_MGAG200_WINBOND_PCI) || (pMga->Chipset == PCI_CHIP_MGAG200_EW3_PCI); - pMga->is_G200EH = (pMga->Chipset == PCI_CHIP_MGAG200_EH_PCI); + pMga->is_G200EH = (pMga->Chipset == PCI_CHIP_MGAG200_EH_PCI) + || (pMga->Chipset == PCI_CHIP_MGAG200_EH3_PCI); pMga->is_G200ER = (pMga->Chipset == PCI_CHIP_MGAG200_ER_PCI); pMga->DualHeadEnabled = FALSE; @@ -1594,6 +1624,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) case PCI_CHIP_MGAG200_ER_PCI: case PCI_CHIP_MGAG200_WINBOND_PCI: case PCI_CHIP_MGAG200_EH_PCI: + case PCI_CHIP_MGAG200_EH3_PCI: pMga->HWCursor = FALSE; xf86DrvMsg(pScrn->scrnIndex, X_INFO, "HW cursor is not supported with video redirection on" @@ -1933,11 +1964,14 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) } else { int from = X_DEFAULT; #ifdef USE_EXA - char *s = xf86GetOptValString(pMga->Options, OPTION_ACCELMETHOD); + const char *s = xf86GetOptValString(pMga->Options, OPTION_ACCELMETHOD); #endif pMga->NoAccel = FALSE; pMga->Exa = FALSE; #ifdef USE_EXA +#ifndef USE_XAA + pMga->Exa = TRUE; +#endif if (!xf86NameCmp(s, "EXA")) { pMga->Exa = TRUE; from = X_CONFIG; @@ -2078,6 +2112,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) case PCI_CHIP_MGAG200_EV_PCI: case PCI_CHIP_MGAG200_EH_PCI: case PCI_CHIP_MGAG200_ER_PCI: + case PCI_CHIP_MGAG200_EH3_PCI: case PCI_CHIP_MGAG400: case PCI_CHIP_MGAG550: MGAGSetupFuncs(pScrn); @@ -2192,6 +2227,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) case PCI_CHIP_MGAG200_EW3_PCI: case PCI_CHIP_MGAG200_EV_PCI: case PCI_CHIP_MGAG200_EH_PCI: + case PCI_CHIP_MGAG200_EH3_PCI: case PCI_CHIP_MGAG200_ER_PCI: pMga->SrcOrg = 0; pMga->DstOrg = 0; @@ -2376,7 +2412,8 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) case PCI_CHIP_MGAG200_WINBOND_PCI: case PCI_CHIP_MGAG200_EW3_PCI: case PCI_CHIP_MGAG200_EV_PCI: - case PCI_CHIP_MGAG200_EH_PCI: + case PCI_CHIP_MGAG200_EH_PCI: + case PCI_CHIP_MGAG200_EH3_PCI: case PCI_CHIP_MGAG200_ER_PCI: case PCI_CHIP_MGAG400: case PCI_CHIP_MGAG550: @@ -2612,7 +2649,7 @@ MGAMapMem(ScrnInfoPtr pScrn) #ifdef XSERVER_LIBPCIACCESS struct pci_device *const dev = pMga->PciInfo; struct pci_mem_region *region; - int i, err; + int err; #endif @@ -2637,7 +2674,7 @@ MGAMapMem(ScrnInfoPtr pScrn) xf86DrvMsg(pScrn->scrnIndex, X_INFO, "MAPPED Framebuffer %08llX %llx to %08llX.\n", (long long)fbaddr, (long long)fbsize, - (long long)pMga->FbBase); + (long long)(uintptr_t)pMga->FbBase); if(pMga->entityPrivate == NULL || pMga->entityPrivate->mappedIOUsage == 0) { region = &dev->regions[pMga->io_bar]; @@ -2773,7 +2810,7 @@ MGAUnmapMem(ScrnInfoPtr pScrn) pMga->entityPrivate->mappedIOBase = NULL; } - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "UNMAPPING framebuffer 0x%08llX, 0x%llX.\n", (long long)pMga->FbBase, (long long)pMga->FbMapSize); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "UNMAPPING framebuffer 0x%08llX, 0x%llX.\n", (long long)(uintptr_t)pMga->FbBase, (long long)pMga->FbMapSize); pci_device_unmap_range(dev, pMga->FbBase, pMga->FbMapSize); #else @@ -2941,19 +2978,27 @@ MGAModeInit(ScrnInfoPtr pScrn, DisplayMo ulMemoryBandwidth = (mode->Clock * ulBitsPerPixel) / 1000; - if (ulMemoryBandwidth > 3100) ucHiPriLvl = 0; - else if (ulMemoryBandwidth > 2600) ucHiPriLvl = 1; - else if (ulMemoryBandwidth > 1900) ucHiPriLvl = 2; - else if (ulMemoryBandwidth > 1160) ucHiPriLvl = 3; - else if (ulMemoryBandwidth > 440) ucHiPriLvl = 4; - else ucHiPriLvl = 5; + if (pMga->reg_1e24 >= 0x04) + { + ucHiPriLvl = 0; + } + else + { + + if (ulMemoryBandwidth > 3100) ucHiPriLvl = 0; + else if (ulMemoryBandwidth > 2600) ucHiPriLvl = 1; + else if (ulMemoryBandwidth > 1900) ucHiPriLvl = 2; + else if (ulMemoryBandwidth > 1160) ucHiPriLvl = 3; + else if (ulMemoryBandwidth > 440) ucHiPriLvl = 4; + else ucHiPriLvl = 5; + } OUTREG8(0x1FDE, 0x06); OUTREG8(0x1FDF, ucHiPriLvl); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Clock == %d\n", mode->Clock); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "BitsPerPixel == %d\n", pScrn->bitsPerPixel); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "MemoryBandwidth == %d\n", ulMemoryBandwidth); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Clock == %u\n", mode->Clock); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "BitsPerPixel == %u\n", pScrn->bitsPerPixel); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "MemoryBandwidth == %u\n", (unsigned)ulMemoryBandwidth); xf86DrvMsg(pScrn->scrnIndex, X_INFO, "HiPriLvl == %02X\n", ucHiPriLvl); } else @@ -3103,7 +3148,7 @@ MGACrtc2FillStrip(ScrnInfoPtr pScrn) (pScrn->bitsPerPixel >> 3) * pScrn->displayWidth * pScrn->virtualY); } else { xf86SetLastScrnFlag(pScrn->entityList[0], pScrn->scrnIndex); -#ifdef HAVE_XAA_H +#ifdef USE_XAA pMga->RestoreAccelState(pScrn); pMga->SetupForSolidFill(pScrn, 0, GXcopy, 0xFFFFFFFF); pMga->SubsequentSolidFillRect(pScrn, pScrn->virtualX, 0, @@ -3126,16 +3171,12 @@ MGAScreenInit(SCREEN_INIT_ARGS_DECL) vgaHWPtr hwp; MGAPtr pMga; MGARamdacPtr MGAdac; - int ret; VisualPtr visual; unsigned char *FBStart; int width, height, displayWidth; MGAEntPtr pMgaEnt = NULL; int f; - CARD32 VRTemp, FBTemp; -#ifdef MGADRI - MessageType driFrom = X_DEFAULT; -#endif + CARD32 VRTemp = 0, FBTemp = 0; DPMSSetProcPtr mga_dpms_set_proc = NULL; hwp = VGAHWPTR(pScrn); @@ -3317,20 +3358,16 @@ MGAScreenInit(SCREEN_INIT_ARGS_DECL) xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Not supported by hardware, not initializing the DRI\n"); pMga->directRenderingEnabled = FALSE; - driFrom = X_PROBED; } else if (!xf86ReturnOptValBool(pMga->Options, OPTION_DRI, TRUE)) { - driFrom = X_CONFIG; } else if ( pMga->NoAccel ) { xf86DrvMsg( pScrn->scrnIndex, X_ERROR, "Acceleration disabled, not initializing the DRI\n" ); pMga->directRenderingEnabled = FALSE; - driFrom = X_CONFIG; } else if ( pMga->TexturedVideo == TRUE ) { xf86DrvMsg( pScrn->scrnIndex, X_ERROR, "Textured video enabled, not initializing the DRI\n" ); pMga->directRenderingEnabled = FALSE; - driFrom = X_CONFIG; } else if (pMga->SecondCrtc == TRUE) { xf86DrvMsg( pScrn->scrnIndex, X_ERROR, @@ -3345,7 +3382,6 @@ MGAScreenInit(SCREEN_INIT_ARGS_DECL) "Need at least %d kB video memory at this resolution, bit depth\n", (3 * displayWidth * height * (pScrn->bitsPerPixel >> 3)) / 1024 ); pMga->directRenderingEnabled = FALSE; - driFrom = X_PROBED; } else { pMga->directRenderingEnabled = MGADRIScreenInit(pScreen); @@ -3712,7 +3748,7 @@ MGACloseScreen(CLOSE_SCREEN_ARGS_DECL) vgaHWPtr hwp = VGAHWPTR(pScrn); MGAPtr pMga = MGAPTR(pScrn); MGAEntPtr pMgaEnt = NULL; - CARD32 VRTemp, FBTemp; + CARD32 VRTemp = 0, FBTemp = 0; if (pMga->MergedFB) MGACloseScreenMerged(pScreen); @@ -3853,15 +3889,17 @@ MGAValidMode(SCRN_ARG_TYPE arg, DisplayM return MODE_VIRTUAL_Y; if (xf86ModeBandwidth(mode, pScrn->bitsPerPixel) > 244) return MODE_BANDWIDTH; - } else { - if (pMga->reg_1e24 == 0x02) { - if (mode->HDisplay > 1920) - return MODE_VIRTUAL_X; - if (mode->VDisplay > 1200) - return MODE_VIRTUAL_Y; - if (xf86ModeBandwidth(mode, pScrn->bitsPerPixel) > 301) - return MODE_BANDWIDTH; - } + } else if (pMga->reg_1e24 == 0x02) { + if (mode->HDisplay > 1920) + return MODE_VIRTUAL_X; + if (mode->VDisplay > 1200) + return MODE_VIRTUAL_Y; + if (xf86ModeBandwidth(mode, pScrn->bitsPerPixel) > 301) + return MODE_BANDWIDTH; + } + else { + if (xf86ModeBandwidth(mode, pScrn->bitsPerPixel) > 550) + return MODE_BANDWIDTH; } } else if (pMga->is_G200WB){ if (mode->Flags & V_DBLSCAN) @@ -3878,7 +3916,7 @@ MGAValidMode(SCRN_ARG_TYPE arg, DisplayM } else if (pMga->is_G200EV && (xf86ModeBandwidth(mode, pScrn->bitsPerPixel) > 327)) { return MODE_BANDWIDTH; - } else if (pMga->is_G200EH + } else if (pMga->is_G200EH && (pMga->Chipset != PCI_CHIP_MGAG200_EH3_PCI) && (xf86ModeBandwidth(mode, pScrn->bitsPerPixel) > 375)) { return MODE_BANDWIDTH; } else if (pMga->is_G200ER Index: xsrc/external/mit/xf86-video-mga/dist/src/mga_exa.c diff -u xsrc/external/mit/xf86-video-mga/dist/src/mga_exa.c:1.4 xsrc/external/mit/xf86-video-mga/dist/src/mga_exa.c:1.5 --- xsrc/external/mit/xf86-video-mga/dist/src/mga_exa.c:1.4 Sun Mar 5 01:32:02 2017 +++ xsrc/external/mit/xf86-video-mga/dist/src/mga_exa.c Sun Dec 30 06:46:48 2018 @@ -695,6 +695,14 @@ mgaComposite(PixmapPtr pDst, int srcx, i OUTREG(MGAREG_YDSTLEN | MGAREG_EXEC, (dsty << 16) | (h & 0xffff)); } +struct unaligned_32 { + uint32_t val; +} __attribute__((packed)); + +struct unaligned_64 { + uint64_t val; +} __attribute__((packed)); + static Bool mgaUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src, int src_pitch) @@ -720,7 +728,15 @@ mgaUploadToScreen(PixmapPtr pDst, int x, OUTREG(MGAREG_YDSTLEN | MGAREG_EXEC, (y << 16) | (h & 0xffff)); while (h--) { - memcpy (pMga->ILOADBase, src, bytes_padded); + int i = 0; + + if (sizeof(long) == 8) { + for (; i + 4 < bytes_padded; i += 8) + *(volatile uint64_t *)(pMga->ILOADBase + i) = ((struct unaligned_64 *)(src + i))->val; + } + + for (; i < bytes_padded; i += 4) + *(volatile uint32_t *)(pMga->ILOADBase + i) = ((struct unaligned_32 *)(src + i))->val; src += src_pitch; } @@ -737,7 +753,7 @@ mgaWaitMarker(ScreenPtr pScreen, int mar WAITFIFO(1); - OUTREG(MGAREG_CACHEFLUSH, 0); + OUTREG8(MGAREG_CACHEFLUSH, 0); /* wait until the "drawing engine busy" bit is unset */ while (INREG (MGAREG_Status) & 0x10000); Index: xsrc/external/mit/xf86-video-mga/dist/src/mga_merge.c diff -u xsrc/external/mit/xf86-video-mga/dist/src/mga_merge.c:1.4 xsrc/external/mit/xf86-video-mga/dist/src/mga_merge.c:1.5 --- xsrc/external/mit/xf86-video-mga/dist/src/mga_merge.c:1.4 Sun Mar 5 01:32:02 2017 +++ xsrc/external/mit/xf86-video-mga/dist/src/mga_merge.c Sun Dec 30 06:46:48 2018 @@ -357,6 +357,7 @@ MGAPreInitMergedFB(ScrnInfoPtr pScrn1, i case PCI_CHIP_MGAG200_EV_PCI: case PCI_CHIP_MGAG200_EH_PCI: case PCI_CHIP_MGAG200_ER_PCI: + case PCI_CHIP_MGAG200_EH3_PCI: case PCI_CHIP_MGAG400: case PCI_CHIP_MGAG550: MGAGSetupFuncs(pScrn); @@ -510,6 +511,7 @@ MGAPreInitMergedFB(ScrnInfoPtr pScrn1, i case PCI_CHIP_MGAG200_EV_PCI: case PCI_CHIP_MGAG200_EH_PCI: case PCI_CHIP_MGAG200_ER_PCI: + case PCI_CHIP_MGAG200_EH3_PCI: case PCI_CHIP_MGAG400: case PCI_CHIP_MGAG550: maxPitch = 4096; Index: xsrc/external/mit/xf86-video-mga/dist/src/mga_storm.c diff -u xsrc/external/mit/xf86-video-mga/dist/src/mga_storm.c:1.4 xsrc/external/mit/xf86-video-mga/dist/src/mga_storm.c:1.5 --- xsrc/external/mit/xf86-video-mga/dist/src/mga_storm.c:1.4 Sun Mar 5 01:32:02 2017 +++ xsrc/external/mit/xf86-video-mga/dist/src/mga_storm.c Sun Dec 30 06:46:48 2018 @@ -23,10 +23,6 @@ #include "miline.h" #include "servermd.h" -#ifdef MGADRI -#include "GL/glxtokens.h" -#endif - #include "mga.h" #include "mga_reg.h" #include "mga_macros.h" @@ -61,7 +57,7 @@ do { \ XAAMoveDWORDS((d),(s),(c)); \ } while (0) -#ifdef HAVE_XAA_H +#ifdef USE_XAA static void mgaSetupForSolidFill( ScrnInfoPtr pScrn, int color, int rop, unsigned int planemask ); @@ -576,20 +572,29 @@ MGASubsequentCPUToScreenTexture ( Bool mgaAccelInit( ScreenPtr pScreen ) { -#ifdef HAVE_XAA_H +#ifdef USE_XAA XAAInfoRecPtr infoPtr; #endif ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); MGAPtr pMga = MGAPTR(pScrn); - int maxFastBlitMem, maxlines; +// int maxFastBlitMem, maxlines; +#ifdef USE_XAA + int maxFastBlitMem; +#endif /* USE_XAA */ + int maxlines; + +#if defined(USE_XAA) && defined(RENDER) Bool doRender = FALSE; +#endif /* defined(USE_XAA) && defined(RENDER) */ BoxRec AvailFBArea; +#ifdef USE_XAA int i; +#endif /* USE_XAA */ pMga->ScratchBuffer = malloc(((pScrn->displayWidth * pMga->CurrentLayout.bitsPerPixel) + 127) >> 3); if(!pMga->ScratchBuffer) return FALSE; -#ifdef HAVE_XAA_H +#ifdef USE_XAA pMga->AccelInfoRec = infoPtr = XAACreateInfoRec(); if(!infoPtr) return FALSE; #endif @@ -625,7 +630,7 @@ Bool mgaAccelInit( ScreenPtr pScreen ) pMga->AtypeNoBLK = MGAAtypeNoBLK; } -#ifdef HAVE_XAA_H +#ifdef USE_XAA /* fill out infoPtr here */ infoPtr->Flags = PIXMAP_CACHE | OFFSCREEN_PIXMAPS | @@ -932,7 +937,7 @@ Bool mgaAccelInit( ScreenPtr pScreen ) } -#ifdef HAVE_XAA_H +#ifdef USE_XAA for (i = 0; i < pScrn->numEntities; i++) { if (xf86IsEntityShared(pScrn->entityList[i])) { infoPtr->RestoreAccelState = mgaRestoreAccelState; @@ -971,7 +976,7 @@ Bool mgaAccelInit( ScreenPtr pScreen ) } -#ifdef HAVE_XAA_H +#ifdef USE_XAA /* Support for multiscreen */ static void mgaRestoreAccelState(ScrnInfoPtr pScrn) { @@ -1100,7 +1105,7 @@ void MGAStormEngineInit( ScrnInfoPtr pSc opmode &= ~0x30000; #endif -#ifdef HAVE_XAA_H +#ifdef USE_XAA pMga->SetupForSolidFill = mgaSetupForSolidFill; pMga->SubsequentSolidFillRect = mgaSubsequentSolidFillRect; pMga->RestoreAccelState = mgaRestoreAccelState; @@ -1152,6 +1157,7 @@ void MGAStormEngineInit( ScrnInfoPtr pSc case PCI_CHIP_MGAG200_EV_PCI: case PCI_CHIP_MGAG200_EH_PCI: case PCI_CHIP_MGAG200_ER_PCI: + case PCI_CHIP_MGAG200_EH3_PCI: pMga->SrcOrg = 0; OUTREG(MGAREG_SRCORG, pMga->realSrcOrg); OUTREG(MGAREG_DSTORG, pMga->DstOrg); @@ -1178,7 +1184,7 @@ void MGAStormEngineInit( ScrnInfoPtr pSc } -#ifdef HAVE_XAA_H +#ifdef USE_XAA static void MGASetClippingRectangle( ScrnInfoPtr pScrn, Index: xsrc/external/mit/xf86-video-r128/dist/src/r128.h diff -u xsrc/external/mit/xf86-video-r128/dist/src/r128.h:1.9 xsrc/external/mit/xf86-video-r128/dist/src/r128.h:1.10 --- xsrc/external/mit/xf86-video-r128/dist/src/r128.h:1.9 Sat Aug 20 00:27:22 2016 +++ xsrc/external/mit/xf86-video-r128/dist/src/r128.h Sun Dec 30 06:46:48 2018 @@ -70,7 +70,6 @@ #define _XF86DRI_SERVER_ #include "r128_dripriv.h" #include "dri.h" -#include "GL/glxint.h" #endif #include "fb.h" @@ -122,13 +121,14 @@ #if R128_DEBUG #include "r128_version.h" -#define R128TRACE(x) \ - do { \ - ErrorF("(**) %s(%d): ", R128_NAME, pScrn->scrnIndex); \ - ErrorF x; \ - } while (0); +#endif + +#if R128_DEBUG +#define DEBUG(x) x + #else -#define R128TRACE(x) +#define DEBUG(x) + #endif @@ -342,6 +342,8 @@ typedef struct { #ifdef HAVE_XAA_H XAAInfoRecPtr accel; #endif + + Bool noAccel; Bool accelOn; Bool useEXA; Bool RenderAccel; @@ -354,6 +356,7 @@ typedef struct { int fifo_slots; /* Free slots in the FIFO (64 max) */ int pix24bpp; /* Depth of pixmap for 24bpp framebuffer */ Bool dac6bits; /* Use 6 bit DAC? */ + Bool swCursor; /* Computed values for Rage 128 */ int pitch; @@ -389,9 +392,6 @@ typedef struct { DRIInfoPtr pDRIInfo; int drmFD; drm_context_t drmCtx; - int numVisualConfigs; - __GLXvisualConfig *pVisualConfigs; - R128ConfigPrivPtr pVisualConfigsPriv; drm_handle_t fbHandle; @@ -509,6 +509,12 @@ do { info->fifo_slots -= entries; \ } while (0) +/* Compute n/d with rounding. */ +static inline int R128Div(int n, int d) +{ + return (n + (d / 2)) / d; +} + extern R128EntPtr R128EntPriv(ScrnInfoPtr pScrn); extern void R128WaitForFifoFunction(ScrnInfoPtr pScrn, int entries); extern void R128WaitForIdle(ScrnInfoPtr pScrn); @@ -518,7 +524,7 @@ extern void R128EngineFlush(ScrnI extern unsigned R128INPLL(ScrnInfoPtr pScrn, int addr); extern void R128WaitForVerticalSync(ScrnInfoPtr pScrn); -extern Bool R128AccelInit(ScreenPtr pScreen); +extern Bool R128XAAAccelInit(ScreenPtr pScreen); extern void R128EngineInit(ScrnInfoPtr pScrn); extern Bool R128CursorInit(ScreenPtr pScreen); @@ -528,18 +534,9 @@ extern xf86OutputPtr R128FirstOutput(xf8 extern void R128InitVideo(ScreenPtr pScreen); extern void R128InitCommonRegisters(R128SavePtr save, R128InfoPtr info); -extern void R128InitDACRegisters(R128SavePtr orig, R128SavePtr save, xf86OutputPtr output); extern void R128InitRMXRegisters(R128SavePtr orig, R128SavePtr save, xf86OutputPtr output, DisplayModePtr mode); extern void R128InitFPRegisters(R128SavePtr orig, R128SavePtr save, xf86OutputPtr output); extern void R128InitLVDSRegisters(R128SavePtr orig, R128SavePtr save, xf86OutputPtr output); -extern Bool R128InitCrtcBase(xf86CrtcPtr crtc, R128SavePtr save, int x, int y); -extern Bool R128InitCrtcRegisters(xf86CrtcPtr crtc, R128SavePtr save, DisplayModePtr mode); -extern void R128InitPLLRegisters(xf86CrtcPtr crtc, R128SavePtr save, R128PLLPtr pll, double dot_clock); -extern Bool R128InitDDARegisters(xf86CrtcPtr crtc, R128SavePtr save, R128PLLPtr pll, DisplayModePtr mode); -extern Bool R128InitCrtc2Base(xf86CrtcPtr crtc, R128SavePtr save, int x, int y); -extern Bool R128InitCrtc2Registers(xf86CrtcPtr crtc, R128SavePtr save, DisplayModePtr mode); -extern void R128InitPLL2Registers(xf86CrtcPtr crtc, R128SavePtr save, R128PLLPtr pll, double dot_clock); -extern Bool R128InitDDA2Registers(xf86CrtcPtr crtc, R128SavePtr save, R128PLLPtr pll, DisplayModePtr mode); extern void R128RestoreCommonRegisters(ScrnInfoPtr pScrn, R128SavePtr restore); extern void R128RestoreDACRegisters(ScrnInfoPtr pScrn, R128SavePtr restore); extern void R128RestoreRMXRegisters(ScrnInfoPtr pScrn, R128SavePtr restore); @@ -614,11 +611,35 @@ extern int R128CCEStop(ScrnInfoP extern void R128CopySwap(uint8_t *dst, uint8_t *src, unsigned int size, int swap); #ifdef USE_EXA -extern Bool R128EXAInit(ScreenPtr pScreen); +extern Bool R128EXAInit(ScreenPtr pScreen, int total); extern Bool R128GetDatatypeBpp(int bpp, uint32_t *type); extern Bool R128GetPixmapOffsetPitch(PixmapPtr pPix, uint32_t *pitch_offset); extern void R128DoPrepareCopy(ScrnInfoPtr pScrn, uint32_t src_pitch_offset, uint32_t dst_pitch_offset, uint32_t datatype, int alu, Pixel planemask); +extern void R128Done(PixmapPtr pPixmap); + +#ifdef R128DRI +extern void EmitCCE2DState(ScrnInfoPtr pScrn); +#endif + +#ifdef RENDER +extern Bool R128CCECheckComposite(int op, + PicturePtr pSrcPicture, + PicturePtr pMaskPicture, + PicturePtr pDstPicture); +extern Bool R128CCEPrepareComposite(int op, PicturePtr pSrcPicture, + PicturePtr pMaskPicture, + PicturePtr pDstPicture, + PixmapPtr pSrc, + PixmapPtr pMask, + PixmapPtr pDst); +extern void R128CCEComposite(PixmapPtr pDst, + int srcX, int srcY, + int maskX, int maskY, + int dstX, int dstY, + int w, int h); +#define R128CCEDoneComposite R128Done +#endif #endif Index: xsrc/external/mit/xf86-video-r128/dist/src/r128_driver.c diff -u xsrc/external/mit/xf86-video-r128/dist/src/r128_driver.c:1.18 xsrc/external/mit/xf86-video-r128/dist/src/r128_driver.c:1.19 --- xsrc/external/mit/xf86-video-r128/dist/src/r128_driver.c:1.18 Sun Mar 5 01:32:03 2017 +++ xsrc/external/mit/xf86-video-r128/dist/src/r128_driver.c Sun Dec 30 06:46:48 2018 @@ -120,13 +120,6 @@ #include <dev/wscons/wsconsio.h> #endif -#ifndef MAX -#define MAX(a,b) ((a)>(b)?(a):(b)) -#endif - -#define USE_CRT_ONLY 0 - - /* Forward definitions for driver functions */ static Bool R128CloseScreen(CLOSE_SCREEN_ARGS_DECL); static Bool R128SaveScreen(ScreenPtr pScreen, int mode); static void R128Save(ScrnInfoPtr pScrn); @@ -134,9 +127,17 @@ static void R128Restore(ScrnInfoPtr pScr typedef enum { OPTION_NOACCEL, - OPTION_SW_CURSOR, +#ifndef AVOID_FBDEV + OPTION_FBDEV, +#endif OPTION_DAC_6BIT, - OPTION_DAC_8BIT, + OPTION_VGA_ACCESS, + OPTION_SHOW_CACHE, + OPTION_SW_CURSOR, + OPTION_VIDEO_KEY, + OPTION_PANEL_WIDTH, + OPTION_PANEL_HEIGHT, + OPTION_PROG_FP_REGS, #ifdef R128DRI OPTION_XV_DMA, OPTION_IS_PCI, @@ -149,29 +150,23 @@ typedef enum { OPTION_BUFFER_SIZE, OPTION_PAGE_FLIP, #endif -#if USE_CRT_ONLY - /* FIXME: Disable CRTOnly until it is tested */ - OPTION_CRT, -#endif - OPTION_DISPLAY, - OPTION_PANEL_WIDTH, - OPTION_PANEL_HEIGHT, - OPTION_PROG_FP_REGS, -#ifndef AVOID_FBDEV - OPTION_FBDEV, -#endif - OPTION_VIDEO_KEY, - OPTION_SHOW_CACHE, - OPTION_VGA_ACCESS, OPTION_ACCELMETHOD, OPTION_RENDERACCEL } R128Opts; static const OptionInfoRec R128Options[] = { - { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_DAC_6BIT, "Dac6Bit", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_DAC_8BIT, "Dac8Bit", OPTV_BOOLEAN, {0}, TRUE }, +{ OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, +#ifndef AVOID_FBDEV +{ OPTION_FBDEV, "UseFBDev", OPTV_BOOLEAN, {0}, FALSE }, +#endif +{ OPTION_DAC_6BIT, "Dac6Bit", OPTV_BOOLEAN, {0}, FALSE }, +{ OPTION_VGA_ACCESS, "VGAAccess", OPTV_BOOLEAN, {0}, TRUE }, +{ OPTION_SHOW_CACHE, "ShowCache", OPTV_BOOLEAN, {0}, FALSE }, +{ OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, +{ OPTION_VIDEO_KEY, "VideoKey", OPTV_INTEGER, {0}, FALSE }, +{ OPTION_PANEL_WIDTH, "PanelWidth", OPTV_INTEGER, {0}, FALSE }, +{ OPTION_PANEL_HEIGHT, "PanelHeight", OPTV_INTEGER, {0}, FALSE }, +{ OPTION_PROG_FP_REGS, "ProgramFPRegs", OPTV_BOOLEAN, {0}, FALSE }, #ifdef R128DRI { OPTION_XV_DMA, "DMAForXv", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_IS_PCI, "ForcePCIMode", OPTV_BOOLEAN, {0}, FALSE }, @@ -184,15 +179,6 @@ static const OptionInfoRec R128Options[] { OPTION_BUFFER_SIZE, "BufferSize", OPTV_INTEGER, {0}, FALSE }, { OPTION_PAGE_FLIP, "EnablePageFlip", OPTV_BOOLEAN, {0}, FALSE }, #endif - { OPTION_PANEL_WIDTH, "PanelWidth", OPTV_INTEGER, {0}, FALSE }, - { OPTION_PANEL_HEIGHT, "PanelHeight", OPTV_INTEGER, {0}, FALSE }, - { OPTION_PROG_FP_REGS, "ProgramFPRegs", OPTV_BOOLEAN, {0}, FALSE }, -#ifndef AVOID_FBDEV - { OPTION_FBDEV, "UseFBDev", OPTV_BOOLEAN, {0}, FALSE }, -#endif - { OPTION_VIDEO_KEY, "VideoKey", OPTV_INTEGER, {0}, FALSE }, - { OPTION_SHOW_CACHE, "ShowCache", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_VGA_ACCESS, "VGAAccess", OPTV_BOOLEAN, {0}, TRUE }, { OPTION_ACCELMETHOD, "AccelMethod", OPTV_STRING, {0}, FALSE }, { OPTION_RENDERACCEL, "RenderAccel", OPTV_BOOLEAN, {0}, FALSE }, { -1, NULL, OPTV_NONE, {0}, FALSE } @@ -423,12 +409,6 @@ int R128MinBits(int val) return bits; } -/* Compute n/d with rounding. */ -static int R128Div(int n, int d) -{ - return (n + (d / 2)) / d; -} - /* Finds the first output using a given crtc. */ xf86OutputPtr R128FirstOutput(xf86CrtcPtr crtc) { @@ -668,8 +648,9 @@ static Bool R128GetPLLParameters(ScrnInf } else { uint16_t bios_header = R128_BIOS16(0x48); uint16_t pll_info_block = R128_BIOS16(bios_header + 0x30); - R128TRACE(("Header at 0x%04x; PLL Information at 0x%04x\n", - bios_header, pll_info_block)); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Header at 0x%04x; PLL Information at 0x%04x\n", + bios_header, pll_info_block)); pll->reference_freq = R128_BIOS16(pll_info_block + 0x0e); pll->reference_div = R128_BIOS16(pll_info_block + 0x10); @@ -693,8 +674,6 @@ static Bool R128GetPLLParameters(ScrnInf /* This is called by R128PreInit to set up the default visual. */ static Bool R128PreInitVisual(ScrnInfoPtr pScrn) { - R128InfoPtr info = R128PTR(pScrn); - if (!xf86SetDepthBpp(pScrn, 0, 0, 0, (Support24bppFb | Support32bppFb | SupportConvert32to24 @@ -716,23 +695,6 @@ static Bool R128PreInitVisual(ScrnInfoPt xf86PrintDepthBpp(pScrn); - info->fifo_slots = 0; - info->pix24bpp = xf86GetBppFromDepth(pScrn, pScrn->depth); - info->CurrentLayout.bitsPerPixel = pScrn->bitsPerPixel; - info->CurrentLayout.depth = pScrn->depth; - info->CurrentLayout.pixel_bytes = pScrn->bitsPerPixel / 8; - info->CurrentLayout.pixel_code = (pScrn->bitsPerPixel != 16 - ? pScrn->bitsPerPixel - : pScrn->depth); - - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Pixel depth = %d bits stored in %d byte%s (%d bpp pixmaps)\n", - pScrn->depth, - info->CurrentLayout.pixel_bytes, - info->CurrentLayout.pixel_bytes > 1 ? "s" : "", - info->pix24bpp); - - if (!xf86SetDefaultVisual(pScrn, -1)) return FALSE; if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { @@ -749,29 +711,33 @@ static Bool R128PreInitVisual(ScrnInfoPt static Bool R128PreInitWeight(ScrnInfoPtr pScrn) { R128InfoPtr info = R128PTR(pScrn); + rgb defaultWeight = { 0, 0, 0 }; - /* Save flag for 6 bit DAC to use for - setting CRTC registers. Otherwise use - an 8 bit DAC, even if xf86SetWeight sets - pScrn->rgbBits to some value other than - 8. */ - info->dac6bits = FALSE; - if (pScrn->depth > 8) { - rgb defaultWeight = { 0, 0, 0 }; - if (!xf86SetWeight(pScrn, defaultWeight, defaultWeight)) return FALSE; + /* + * Save flag for 6 bit DAC to use for setting CRTC registers. + * Otherwise use an 8 bit DAC, even if xf86SetWeight sets + * pScrn->rgbBits to some value other than 8. + */ + if (pScrn->depth <= 8) { + if (info->dac6bits) { + pScrn->rgbBits = 6; + } else { + pScrn->rgbBits = 8; + } } else { - pScrn->rgbBits = 8; - if (xf86ReturnOptValBool(info->Options, OPTION_DAC_6BIT, FALSE)) { - pScrn->rgbBits = 6; - info->dac6bits = TRUE; - } + info->dac6bits = FALSE; + pScrn->rgbBits = 8; } + + if (pScrn->depth > 8) { + if (!xf86SetWeight(pScrn, defaultWeight, defaultWeight)) return FALSE; + } + xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Using %d bits per RGB (%d bit DAC)\n", - pScrn->rgbBits, info->dac6bits ? 6 : 8); + "Using %d bits per RGB (%d bit DAC)\n", + pScrn->rgbBits, info->dac6bits ? 6 : 8); return TRUE; - } /* This is called by R128PreInit to handle config file overrides for things @@ -1010,18 +976,8 @@ static Bool R128PreInitConfig(ScrnInfoPt info->FbMapSize = pScrn->videoRam * 1024; #ifdef R128DRI - /* DMA for Xv */ - info->DMAForXv = xf86ReturnOptValBool(info->Options, OPTION_XV_DMA, FALSE); - if (info->DMAForXv) { - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Will try to use DMA for Xv image transfers\n"); - } - - /* AGP/PCI */ - if (xf86ReturnOptValBool(info->Options, OPTION_IS_PCI, FALSE)) { - info->IsPCI = TRUE; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Forced into PCI-only mode\n"); - } else { + /* AGP/PCI */ + if (!info->IsPCI) { switch (info->Chipset) { case PCI_CHIP_RAGE128LE: case PCI_CHIP_RAGE128RE: @@ -1120,7 +1076,7 @@ static Bool R128PreInitCursor(ScrnInfoPt { R128InfoPtr info = R128PTR(pScrn); - if (!xf86ReturnOptValBool(info->Options, OPTION_SW_CURSOR, FALSE)) { + if (!info->swCursor) { if (!xf86LoadSubModule(pScrn, "ramdac")) return FALSE; } return TRUE; @@ -1144,21 +1100,6 @@ static Bool R128PreInitDRI(ScrnInfoPtr p { R128InfoPtr info = R128PTR(pScrn); - if (xf86ReturnOptValBool(info->Options, OPTION_CCE_PIO, FALSE)) { - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Forcing CCE into PIO mode\n"); - info->CCEMode = R128_DEFAULT_CCE_PIO_MODE; - } else { - info->CCEMode = R128_DEFAULT_CCE_BM_MODE; - } - - if (xf86ReturnOptValBool(info->Options, OPTION_NO_SECURITY, FALSE)) { - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "WARNING!!! CCE Security checks disabled!!! **********\n"); - info->CCESecure = FALSE; - } else { - info->CCESecure = TRUE; - } - info->agpMode = R128_DEFAULT_AGP_MODE; info->agpSize = R128_DEFAULT_AGP_SIZE; info->ringSize = R128_DEFAULT_RING_SIZE; @@ -1286,17 +1227,163 @@ static Bool R128PreInitControllers(ScrnI } static void -R128ProbeDDC(ScrnInfoPtr pScrn, int indx) +r128UMSOption(ScrnInfoPtr pScrn) { - vbeInfoPtr pVbe; + R128InfoPtr info = R128PTR(pScrn); -#if !defined(__powerpc__) && !defined(__alpha__) && !defined(__sparc__) - if (xf86LoadSubModule(pScrn, "vbe")) { - pVbe = VBEInit(NULL,indx); - ConfiguredMonitor = vbeDoEDID(pVbe, NULL); - vbeFree(pVbe); + info->dac6bits = xf86ReturnOptValBool(info->Options, + OPTION_DAC_6BIT, FALSE); + +#ifndef AVOID_FBDEV +#ifdef __powerpc__ + if (xf86ReturnOptValBool(info->Options, OPTION_FBDEV, TRUE)) +#else + if (xf86ReturnOptValBool(info->Options, OPTION_FBDEV, FALSE)) +#endif + { + info->FBDev = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Using framebuffer device.\n"); + } +#endif + + /* By default, don't access VGA IOs on PowerPC or SPARC. */ +#if defined(__powerpc__) || defined(__sparc__) || !defined(WITH_VGAHW) + info->VGAAccess = FALSE; +#else + info->VGAAccess = TRUE; +#endif + +#ifdef WITH_VGAHW + xf86GetOptValBool(info->Options, OPTION_VGA_ACCESS, + &info->VGAAccess); + if (info->VGAAccess) { + if (!xf86LoadSubModule(pScrn, "vgahw")) + info->VGAAccess = FALSE; + else { + if (!vgaHWGetHWRec(pScrn)) + info->VGAAccess = FALSE; + } + + if (!info->VGAAccess) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Loading VGA module failed, trying to " + "run without it.\n"); + } + } else + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "VGAAccess option set to FALSE, VGA " + "module load skipped.\n"); + if (info->VGAAccess) { + vgaHWSetStdFuncs(VGAHWPTR(pScrn)); + vgaHWGetIOBase(VGAHWPTR(pScrn)); + } +#else + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "VGAHW support not compiled, VGA " + "module load skipped.\n"); +#endif + + if (xf86ReturnOptValBool(info->Options, + OPTION_SHOW_CACHE, FALSE)) { + info->showCache = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "ShowCache enabled.\n"); + } + + if (xf86ReturnOptValBool(info->Options, + OPTION_SW_CURSOR, FALSE)) { + info->swCursor = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Software cursor requested.\n"); + } + + if(xf86GetOptValInteger(info->Options, + OPTION_VIDEO_KEY, &info->videoKey)) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Video key set to 0x%x.\n", info->videoKey); + } else { + info->videoKey = 0x1E; + } + +#ifdef R128DRI + /* DMA for Xv */ + info->DMAForXv = xf86ReturnOptValBool(info->Options, + OPTION_XV_DMA, FALSE); + if (info->DMAForXv) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Will try to use DMA for Xv image transfers.\n"); + } + + /* Force PCI Mode */ + info->IsPCI = xf86ReturnOptValBool(info->Options, + OPTION_IS_PCI, FALSE); + if (info->IsPCI) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Forced into PCI only mode.\n"); + } + + if (xf86ReturnOptValBool(info->Options, OPTION_CCE_PIO, FALSE)) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Forcing CCE into PIO mode.\n"); + info->CCEMode = R128_DEFAULT_CCE_PIO_MODE; + } else { + info->CCEMode = R128_DEFAULT_CCE_BM_MODE; + } + + if (xf86ReturnOptValBool(info->Options, OPTION_NO_SECURITY, FALSE)) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "WARNING!!! CCE Security checks disabled!!!\n"); + info->CCESecure = FALSE; + } else { + info->CCESecure = TRUE; + } + + +#endif +} + +static void +r128AcquireOption(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); +#ifdef USE_EXA + char *optstr; +#endif + + if (xf86ReturnOptValBool(info->Options, OPTION_NOACCEL, FALSE)) { + info->noAccel = TRUE; + } + +#ifdef USE_EXA + if (!info->noAccel) { + optstr = (char *) xf86GetOptValString(info->Options, + OPTION_ACCELMETHOD); + if (optstr) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "AccelMethod option found.\n"); + if (xf86NameCmp(optstr, "EXA") == 0) { + info->useEXA = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "AccelMethod is set to EXA, turning " + "EXA on.\n"); + } + } + +#ifdef RENDER + info->RenderAccel = xf86ReturnOptValBool(info->Options, + OPTION_RENDERACCEL, + TRUE); + if (info->RenderAccel) + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Acceleration of RENDER operations will be " + "enabled upon successful loading of DRI and " + "EXA.\n"); +#endif } #endif + + r128UMSOption(pScrn); } static Bool R128CRTCResize(ScrnInfoPtr pScrn, int width, int height) @@ -1310,16 +1397,115 @@ static const xf86CrtcConfigFuncsRec R128 R128CRTCResize }; +static Bool R128LegacyMS(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + xf86Int10InfoPtr pInt10 = NULL; + Bool ret = FALSE; + +#ifndef AVOID_FBDEV + if (info->FBDev) { + /* check for linux framebuffer device */ + if (!xf86LoadSubModule(pScrn, "fbdevhw")) goto exit; + if (!fbdevHWInit(pScrn, info->PciInfo, NULL)) goto exit; + pScrn->SwitchMode = fbdevHWSwitchModeWeak(); + pScrn->AdjustFrame = fbdevHWAdjustFrameWeak(); + pScrn->ValidMode = fbdevHWValidModeWeak(); + } else { +#endif /* !AVOID_FBDEV */ + if (!R128PreInitInt10(pScrn, &pInt10)) goto exit; +#ifndef AVOID_FBDEV + } +#endif /* !AVOID_FBDEV */ + + if (!R128PreInitConfig(pScrn)) goto freeInt10; + + xf86CrtcSetSizeRange(pScrn, 320, 200, 4096, 4096); + + if (!R128PreInitCursor(pScrn)) goto freeInt10; + + /* Don't fail on this one */ + info->DDC = R128PreInitDDC(pScrn, pInt10); + + if (!R128PreInitControllers(pScrn, pInt10)) goto freeInt10; + +#ifdef R128DRI + if (!R128PreInitDRI(pScrn)) goto freeInt10; +#endif + + ret = TRUE; +freeInt10: + /* Free int10 info */ + if (pInt10) { + xf86FreeInt10(pInt10); + } + +exit: + return ret; +} + +static void +R128PreInitAccel(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); +#ifdef USE_EXA + int errmaj, errmin; +#endif + + if (!info->noAccel) { + if (info->useEXA) { +#ifdef USE_EXA + info->exaReq.majorversion = EXA_VERSION_MAJOR; + info->exaReq.minorversion = EXA_VERSION_MINOR; + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Loading EXA module...\n"); + if (LoadSubModule(pScrn->module, "exa", NULL, NULL, NULL, + &info->exaReq, &errmaj, &errmin)) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Loading EXA module.\n"); + } else { + LoaderErrorMsg(NULL, "exa", errmaj, errmin); + } +#endif + } + + if ((!info->useEXA) || + ((info->useEXA) && (!info->accelOn))) { +#ifdef HAVE_XAA_H + if (xf86LoadSubModule(pScrn, "xaa")) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Loading XAA module.\n"); + } +#endif + } + } +} + /* R128PreInit is called once at server startup. */ Bool R128PreInit(ScrnInfoPtr pScrn, int flags) { R128InfoPtr info; - xf86Int10InfoPtr pInt10 = NULL; #ifdef __NetBSD__ struct wsdisplayio_bus_id bid; #endif - R128TRACE(("R128PreInit\n")); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "%s\n", __func__)); + + if (flags & PROBE_DETECT) { + return TRUE; + } + + pScrn->monitor = pScrn->confScreen->monitor; + + if (!R128PreInitVisual(pScrn)) { + return FALSE; + } + + if (!R128PreInitGamma(pScrn)) { + return FALSE; + } if (pScrn->numEntities != 1) return FALSE; @@ -1332,11 +1518,6 @@ Bool R128PreInit(ScrnInfoPtr pScrn, int info->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); if (info->pEnt->location.type != BUS_PCI) goto fail; - if (flags & PROBE_DETECT) { - R128ProbeDDC(pScrn, info->pEnt->index); - return TRUE; - } - info->PciInfo = xf86GetPciInfoForEntity(info->pEnt->index); xf86DrvMsg(pScrn->scrnIndex, X_INFO, @@ -1378,12 +1559,22 @@ Bool R128PreInit(ScrnInfoPtr pScrn, int pScrn->racMemFlags = RAC_FB | RAC_COLORMAP | RAC_VIEWPORT | RAC_CURSOR; #endif - pScrn->monitor = pScrn->confScreen->monitor; - /* Allocate an xf86CrtcConfig */ - xf86CrtcConfigInit(pScrn, &R128CRTCResizeFuncs); + info->fifo_slots = 0; + info->pix24bpp = xf86GetBppFromDepth(pScrn, pScrn->depth); + info->CurrentLayout.bitsPerPixel = pScrn->bitsPerPixel; + info->CurrentLayout.depth = pScrn->depth; + info->CurrentLayout.pixel_bytes = pScrn->bitsPerPixel / 8; + info->CurrentLayout.pixel_code = (pScrn->bitsPerPixel != 16 + ? pScrn->bitsPerPixel + : pScrn->depth); - if (!R128PreInitVisual(pScrn)) goto fail; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Pixel depth = %d bits stored in %d byte%s (%d bpp pixmaps)\n", + pScrn->depth, + info->CurrentLayout.pixel_bytes, + info->CurrentLayout.pixel_bytes > 1 ? "s" : "", + info->pix24bpp); /* We can't do this until we have a pScrn->display. */ @@ -1392,90 +1583,31 @@ Bool R128PreInit(ScrnInfoPtr pScrn, int memcpy(info->Options, R128Options, sizeof(R128Options)); xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, info->Options); - /* By default, don't do VGA IOs on ppc */ -#if defined(__powerpc__) || defined(__sparc__) || !defined(WITH_VGAHW) - info->VGAAccess = FALSE; -#else - info->VGAAccess = TRUE; -#endif + info->noAccel = FALSE; + info->accelOn = FALSE; -#ifdef WITH_VGAHW - xf86GetOptValBool(info->Options, OPTION_VGA_ACCESS, &info->VGAAccess); - if (info->VGAAccess) { - if (!xf86LoadSubModule(pScrn, "vgahw")) - info->VGAAccess = FALSE; - else { - if (!vgaHWGetHWRec(pScrn)) - info->VGAAccess = FALSE; - } - if (!info->VGAAccess) - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Loading VGA module failed," - " trying to run without it\n"); - } else - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VGAAccess option set to FALSE," - " VGA module load skipped\n"); - if (info->VGAAccess) { - vgaHWSetStdFuncs(VGAHWPTR(pScrn)); - vgaHWGetIOBase(VGAHWPTR(pScrn)); - } -#else - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VGAHW support not compiled, VGA " - "module load skipped\n"); + info->useEXA = FALSE; +#ifdef USE_EXA +#ifndef HAVE_XAA_H + info->useEXA = TRUE; #endif + info->swCursor = FALSE; + + r128AcquireOption(pScrn); + if (!R128PreInitWeight(pScrn)) goto fail; - if(xf86GetOptValInteger(info->Options, OPTION_VIDEO_KEY, &(info->videoKey))) { - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "video key set to 0x%x\n", - info->videoKey); - } else { - info->videoKey = 0x1E; - } + /* Allocate an xf86CrtcConfig */ + xf86CrtcConfigInit(pScrn, &R128CRTCResizeFuncs); - if (xf86ReturnOptValBool(info->Options, OPTION_SHOW_CACHE, FALSE)) { - info->showCache = TRUE; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ShowCache enabled\n"); + R128LegacyMS(pScrn); + + if (!xf86InitialConfiguration(pScrn, TRUE)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes.\n"); + goto fail; } - -#ifndef AVOID_FBDEV -#ifdef __powerpc__ - if (xf86ReturnOptValBool(info->Options, OPTION_FBDEV, TRUE)) -#else - if (xf86ReturnOptValBool(info->Options, OPTION_FBDEV, FALSE)) -#endif - { - info->FBDev = TRUE; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Using framebuffer device\n"); - } - - if (info->FBDev) { - /* check for linux framebuffer device */ - if (!xf86LoadSubModule(pScrn, "fbdevhw")) return FALSE; - if (!fbdevHWInit(pScrn, info->PciInfo, NULL)) return FALSE; - pScrn->SwitchMode = fbdevHWSwitchModeWeak(); - pScrn->AdjustFrame = fbdevHWAdjustFrameWeak(); - pScrn->ValidMode = fbdevHWValidModeWeak(); - } - - if (!info->FBDev) -#endif /* !AVOID_FBDEV */ - if (!R128PreInitInt10(pScrn, &pInt10)) goto fail; - - if (!R128PreInitConfig(pScrn)) goto fail; - - xf86CrtcSetSizeRange(pScrn, 320, 200, 4096, 4096); - - /* Don't fail on this one */ - info->DDC = R128PreInitDDC(pScrn, pInt10); - - if (!R128PreInitControllers(pScrn, pInt10)) goto fail; - - if (!xf86InitialConfiguration(pScrn, TRUE)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes.\n"); - goto fail; - } - pScrn->displayWidth = (pScrn->virtualX + 63) & ~63; + pScrn->displayWidth = (pScrn->virtualX + 63) & ~63; /* Set display resolution */ xf86SetDpi(pScrn, 0, 0); @@ -1483,13 +1615,7 @@ Bool R128PreInit(ScrnInfoPtr pScrn, int /* Get ScreenInit function */ if (!xf86LoadSubModule(pScrn, "fb")) return FALSE; - if (!R128PreInitGamma(pScrn)) goto fail; - - if (!R128PreInitCursor(pScrn)) goto fail; - -#ifdef R128DRI - if (!R128PreInitDRI(pScrn)) goto fail; -#endif + R128PreInitAccel(pScrn); info->CurrentLayout.displayWidth = pScrn->displayWidth; @@ -1509,10 +1635,6 @@ Bool R128PreInit(ScrnInfoPtr pScrn, int info->VBIOS = NULL; } - /* Free int10 info */ - if (pInt10) - xf86FreeInt10(pInt10); - if (info->MMIO) R128UnmapMMIO(pScrn); info->MMIO = NULL; @@ -1527,10 +1649,6 @@ Bool R128PreInit(ScrnInfoPtr pScrn, int info->VBIOS = NULL; } - /* Free int10 info */ - if (pInt10) - xf86FreeInt10(pInt10); - #ifdef WITH_VGAHW if (info->VGAAccess) vgaHWFreeHWRec(pScrn); @@ -1632,51 +1750,6 @@ R128BlockHandler(BLOCKHANDLER_ARGS_DECL) } } -#ifdef USE_EXA -Bool R128VerboseInitEXA(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); - R128InfoPtr info = R128PTR(pScrn); - - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Going to init EXA...\n"); - - if (R128EXAInit(pScreen)) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "EXA Acceleration enabled\n"); - info->accelOn = TRUE; - - return TRUE; - } else { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "EXA Acceleration initialization failed\n"); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "EXA Acceleration disabled\n"); - info->accelOn = FALSE; - - return FALSE; - } -} -#endif - -void R128VerboseInitAccel(Bool noAccel, ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); - R128InfoPtr info = R128PTR(pScrn); - - if (!noAccel) { - if (R128AccelInit(pScreen)) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Acceleration enabled\n"); - info->accelOn = TRUE; - } else { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Acceleration initialization failed\n"); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Acceleration disabled\n"); - info->accelOn = FALSE; - } - } else { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Acceleration disabled\n"); - info->accelOn = FALSE; - } -} - /* Called at the start of each server generation. */ Bool R128ScreenInit(SCREEN_INIT_ARGS_DECL) { @@ -1684,40 +1757,22 @@ Bool R128ScreenInit(SCREEN_INIT_ARGS_DEC R128InfoPtr info = R128PTR(pScrn); BoxRec MemBox; int width_bytes = (pScrn->displayWidth * - info->CurrentLayout.pixel_bytes); - int x1 = 0, x2 = 0, y1 = 0, y2 = 0; - Bool noAccel; + info->CurrentLayout.pixel_bytes); + int scanlines; + int total = info->FbMapSize; + FBAreaPtr fbarea = NULL; +#ifdef R128DRI + int cpp = info->CurrentLayout.pixel_bytes; + int x1 = 0, x2 = 0, y1 = 0, y2 = 0; #ifdef USE_EXA ExaOffscreenArea* osArea = NULL; -#else - void* osArea = NULL; -#endif - char *optstr; - - R128TRACE(("R128ScreenInit %x %d\n", pScrn->memPhysBase, pScrn->fbOffset)); - info->useEXA = FALSE; -#ifdef USE_EXA -#ifndef HAVE_XAA_H - info->useEXA = TRUE; -#endif -#endif +#endif /* USE_EXA */ +#endif /* R128DRI */ -#ifdef USE_EXA - optstr = (char *)xf86GetOptValString(info->Options, OPTION_ACCELMETHOD); - if (optstr != NULL) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "AccelMethod option found\n"); - if (xf86NameCmp(optstr, "EXA") == 0) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "AccelMethod is set to EXA, turning EXA on\n"); - info->useEXA = TRUE; - } - } -#ifdef RENDER - info->RenderAccel = xf86ReturnOptValBool(info->Options, OPTION_RENDERACCEL, TRUE); - if (info->RenderAccel) - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Acceleration of RENDER operations will be enabled " - "upon successful loading of DRI and EXA\n"); -#endif -#endif + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "%s %lx %lx\n", + __func__, + pScrn->memPhysBase, pScrn->fbOffset)); #ifdef R128DRI /* Turn off the CCE for now. */ @@ -1747,22 +1802,17 @@ Bool R128ScreenInit(SCREEN_INIT_ARGS_DEC pScrn->defaultVisual)) return FALSE; miSetPixmapDepths (); - noAccel = xf86ReturnOptValBool(info->Options, OPTION_NOACCEL, FALSE); - if (noAccel) info->useEXA = FALSE; - #ifdef R128DRI /* Setup DRI after visuals have been established, but before fbScreenInit is - called. fbScreenInit will eventually - call the driver's InitGLXVisuals call - back. */ + called. */ { /* FIXME: When we move to dynamic allocation of back and depth buffers, we will want to revisit the following check for 3 times the virtual size of the screen below. */ int maxy = info->FbMapSize / width_bytes; - if (noAccel) { + if (info->noAccel) { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Acceleration disabled, not initializing the DRI\n"); info->directRenderingEnabled = FALSE; @@ -1809,11 +1859,8 @@ Bool R128ScreenInit(SCREEN_INIT_ARGS_DEC /* Memory manager setup */ #ifdef R128DRI if (info->directRenderingEnabled) { - FBAreaPtr fbarea = NULL; - int cpp = info->CurrentLayout.pixel_bytes; int bufferSize = pScrn->virtualY * width_bytes; - int l, total; - int scanlines; + int l; switch (info->CCEMode) { case R128_DEFAULT_CCE_PIO_MODE: @@ -1873,19 +1920,26 @@ Bool R128ScreenInit(SCREEN_INIT_ARGS_DEC info->textureSize = 0; } - total = info->FbMapSize - info->textureSize; - scanlines = total / width_bytes; - if (scanlines > 8191) scanlines = 8191; + total = info->FbMapSize - info->textureSize; + } +#endif /* R128DRI */ - /* Recalculate the texture offset and size to accomodate any - * rounding to a whole number of scanlines. - */ - info->textureOffset = scanlines * width_bytes; + scanlines = total / width_bytes; + if (scanlines > 8191) scanlines = 8191; - MemBox.x1 = 0; - MemBox.y1 = 0; - MemBox.x2 = pScrn->displayWidth; - MemBox.y2 = scanlines; +#ifdef R128DRI + if (info->directRenderingEnabled) + /* + * Recalculate the texture offset and size to accomodate any + * rounding to a whole number of scanlines. + */ + info->textureOffset = scanlines * width_bytes; +#endif /* R128DRI */ + + MemBox.x1 = 0; + MemBox.y1 = 0; + MemBox.x2 = pScrn->displayWidth; + MemBox.y2 = scanlines; if (!info->useEXA) { if (!xf86InitFBManager(pScreen, &MemBox)) { @@ -1916,28 +1970,45 @@ Bool R128ScreenInit(SCREEN_INIT_ARGS_DEC width, height); } - R128VerboseInitAccel(noAccel, pScreen); - } - } + if (!info->noAccel) { + if (R128XAAAccelInit(pScreen)) { + info->accelOn = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "XAA acceleration enabled.\n"); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Acceleration disabled.\n"); + } + } + } + } #ifdef USE_EXA - else { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Filling in EXA memory info\n"); - - R128VerboseInitAccel(noAccel, pScreen); - info->ExaDriver->offScreenBase = pScrn->virtualY * width_bytes; - - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Filled in offs\n"); + else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Filling in EXA memory info\n"); - /* Don't give EXA the true full memory size, because the - textureSize sized chunk on the end is handled by DRI */ - info->ExaDriver->memorySize = total; - R128VerboseInitEXA(pScreen); - } + /* + * Don't give EXA the true full memory size, because + * the textureSize sized chunk on the end is handled + * by DRI. + */ + if (R128EXAInit(pScreen, total)) { + info->accelOn = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "EXA Acceleration enabled.\n"); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "EXA Acceleration initialization " + "failed.\n"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Acceleration disabled.\n"); + } + } #endif +#ifdef R128DRI + if (info->directRenderingEnabled) { /* Allocate the shared back buffer */ if(!info->useEXA) { fbarea = xf86AllocateOffscreenArea(pScreen, @@ -2047,67 +2118,7 @@ Bool R128ScreenInit(SCREEN_INIT_ARGS_DEC "Reserved %d kb for textures at offset 0x%x\n", info->textureSize/1024, info->textureOffset); } - else #endif /* R128DRI */ - { - MemBox.x1 = 0; - MemBox.y1 = 0; - MemBox.x2 = pScrn->displayWidth; - y2 = (info->FbMapSize - / (pScrn->displayWidth * - info->CurrentLayout.pixel_bytes)); - /* The acceleration engine uses 14 bit - signed coordinates, so we can't have any - drawable caches beyond this region. */ - if (y2 > 8191) y2 = 8191; - MemBox.y2 = y2; - - if (!info->useEXA) { - if (!xf86InitFBManager(pScreen, &MemBox)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Memory manager initialization to (%d,%d) (%d,%d) failed\n", - MemBox.x1, MemBox.y1, MemBox.x2, MemBox.y2); - return FALSE; - } else { - int width, height; - FBAreaPtr fbarea; - - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Memory manager initialized to (%d,%d) (%d,%d)\n", - MemBox.x1, MemBox.y1, MemBox.x2, MemBox.y2); - if ((fbarea = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth, 2, 0, NULL, NULL, NULL))) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Reserved area from (%d,%d) to (%d,%d)\n", - fbarea->box.x1, fbarea->box.y1, - fbarea->box.x2, fbarea->box.y2); - } else { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Unable to reserve area\n"); - } - if (xf86QueryLargestOffscreenArea(pScreen, &width, &height, 0, 0, 0)) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Largest offscreen area available: %d x %d\n", - width, height); - } - - R128VerboseInitAccel(noAccel, pScreen); - } - } -#ifdef USE_EXA - else { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Filling in EXA memory info\n"); - - R128VerboseInitAccel(noAccel, pScreen); - info->ExaDriver->offScreenBase = pScrn->virtualY * width_bytes; - - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Filled in offs\n"); - - info->ExaDriver->memorySize = info->FbMapSize; - R128VerboseInitEXA(pScreen); - } -#endif - } pScrn->vtSema = TRUE; /* xf86CrtcRotate accesses pScrn->pScreen */ @@ -2141,7 +2152,7 @@ Bool R128ScreenInit(SCREEN_INIT_ARGS_DEC miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); /* Hardware cursor setup */ - if (!xf86ReturnOptValBool(info->Options, OPTION_SW_CURSOR, FALSE)) { + if (!info->swCursor) { if (R128CursorInit(pScreen)) { int width, height; @@ -2244,54 +2255,6 @@ void R128RestoreCommonRegisters(ScrnInfo OUTREG(R128_CONFIG_CNTL, restore->config_cntl); } -/* Write CRTC registers. */ -void R128RestoreCrtcRegisters(ScrnInfoPtr pScrn, R128SavePtr restore) -{ - R128InfoPtr info = R128PTR(pScrn); - unsigned char *R128MMIO = info->MMIO; - - OUTREG(R128_CRTC_GEN_CNTL, restore->crtc_gen_cntl); - - OUTREGP(R128_CRTC_EXT_CNTL, restore->crtc_ext_cntl, - R128_CRTC_VSYNC_DIS | R128_CRTC_HSYNC_DIS | R128_CRTC_DISPLAY_DIS); - - OUTREG(R128_CRTC_H_TOTAL_DISP, restore->crtc_h_total_disp); - OUTREG(R128_CRTC_H_SYNC_STRT_WID, restore->crtc_h_sync_strt_wid); - OUTREG(R128_CRTC_V_TOTAL_DISP, restore->crtc_v_total_disp); - OUTREG(R128_CRTC_V_SYNC_STRT_WID, restore->crtc_v_sync_strt_wid); - OUTREG(R128_CRTC_OFFSET, restore->crtc_offset); - OUTREG(R128_CRTC_OFFSET_CNTL, restore->crtc_offset_cntl); - OUTREG(R128_CRTC_PITCH, restore->crtc_pitch); -} - -/* Write CRTC2 registers. */ -void R128RestoreCrtc2Registers(ScrnInfoPtr pScrn, R128SavePtr restore) -{ - R128InfoPtr info = R128PTR(pScrn); - unsigned char *R128MMIO = info->MMIO; - - OUTREGP(R128_CRTC2_GEN_CNTL, restore->crtc2_gen_cntl, - R128_CRTC2_DISP_DIS); - - OUTREG(R128_CRTC2_H_TOTAL_DISP, restore->crtc2_h_total_disp); - OUTREG(R128_CRTC2_H_SYNC_STRT_WID, restore->crtc2_h_sync_strt_wid); - OUTREG(R128_CRTC2_V_TOTAL_DISP, restore->crtc2_v_total_disp); - OUTREG(R128_CRTC2_V_SYNC_STRT_WID, restore->crtc2_v_sync_strt_wid); - OUTREG(R128_CRTC2_OFFSET, restore->crtc2_offset); - OUTREG(R128_CRTC2_OFFSET_CNTL, restore->crtc2_offset_cntl); - OUTREG(R128_CRTC2_PITCH, restore->crtc2_pitch); -} - -/* Write DAC registers */ -void R128RestoreDACRegisters(ScrnInfoPtr pScrn, R128SavePtr restore) -{ - R128InfoPtr info = R128PTR(pScrn); - unsigned char *R128MMIO = info->MMIO; - - OUTREGP(R128_DAC_CNTL, restore->dac_cntl, - R128_DAC_RANGE_CNTL | R128_DAC_BLANKING); -} - /* Write RMX registers */ void R128RestoreRMXRegisters(ScrnInfoPtr pScrn, R128SavePtr restore) { @@ -2347,181 +2310,6 @@ void R128RestoreLVDSRegisters(ScrnInfoPt } } -static void R128PLLWaitForReadUpdateComplete(ScrnInfoPtr pScrn) -{ - while (INPLL(pScrn, R128_PPLL_REF_DIV) & R128_PPLL_ATOMIC_UPDATE_R); -} - -static void R128PLLWriteUpdate(ScrnInfoPtr pScrn) -{ - R128InfoPtr info = R128PTR(pScrn); - unsigned char *R128MMIO = info->MMIO; - - while (INPLL(pScrn, R128_PPLL_REF_DIV) & R128_PPLL_ATOMIC_UPDATE_R); - - OUTPLLP(pScrn, R128_PPLL_REF_DIV, R128_PPLL_ATOMIC_UPDATE_W, - ~R128_PPLL_ATOMIC_UPDATE_W); - -} - -static void R128PLL2WaitForReadUpdateComplete(ScrnInfoPtr pScrn) -{ - while (INPLL(pScrn, R128_P2PLL_REF_DIV) & R128_P2PLL_ATOMIC_UPDATE_R); -} - -static void R128PLL2WriteUpdate(ScrnInfoPtr pScrn) -{ - R128InfoPtr info = R128PTR(pScrn); - unsigned char *R128MMIO = info->MMIO; - - while (INPLL(pScrn, R128_P2PLL_REF_DIV) & R128_P2PLL_ATOMIC_UPDATE_R); - - OUTPLLP(pScrn, R128_P2PLL_REF_DIV, - R128_P2PLL_ATOMIC_UPDATE_W, - ~(R128_P2PLL_ATOMIC_UPDATE_W)); -} - -/* Write PLL registers. */ -void R128RestorePLLRegisters(ScrnInfoPtr pScrn, R128SavePtr restore) -{ - R128InfoPtr info = R128PTR(pScrn); - unsigned char *R128MMIO = info->MMIO; - - - OUTPLLP(pScrn, R128_VCLK_ECP_CNTL, - R128_VCLK_SRC_SEL_CPUCLK, - ~(R128_VCLK_SRC_SEL_MASK)); - - OUTPLLP(pScrn, - R128_PPLL_CNTL, - R128_PPLL_RESET - | R128_PPLL_ATOMIC_UPDATE_EN - | R128_PPLL_VGA_ATOMIC_UPDATE_EN, - ~(R128_PPLL_RESET - | R128_PPLL_ATOMIC_UPDATE_EN - | R128_PPLL_VGA_ATOMIC_UPDATE_EN)); - - OUTREGP(R128_CLOCK_CNTL_INDEX, R128_PLL_DIV_SEL, ~(R128_PLL_DIV_SEL)); - -/* R128PLLWaitForReadUpdateComplete(pScrn);*/ - OUTPLLP(pScrn, R128_PPLL_REF_DIV, - restore->ppll_ref_div, ~R128_PPLL_REF_DIV_MASK); -/* R128PLLWriteUpdate(pScrn); - - R128PLLWaitForReadUpdateComplete(pScrn);*/ - OUTPLLP(pScrn, R128_PPLL_DIV_3, - restore->ppll_div_3, ~R128_PPLL_FB3_DIV_MASK); -/* R128PLLWriteUpdate(pScrn);*/ - OUTPLLP(pScrn, R128_PPLL_DIV_3, - restore->ppll_div_3, ~R128_PPLL_POST3_DIV_MASK); - - R128PLLWriteUpdate(pScrn); - R128PLLWaitForReadUpdateComplete(pScrn); - - OUTPLLP(pScrn, R128_PPLL_DIV_0, - restore->ppll_div_0, ~R128_PPLL_FB0_DIV_MASK); -/* R128PLLWriteUpdate(pScrn);*/ - OUTPLLP(pScrn, R128_PPLL_DIV_0, - restore->ppll_div_0, ~R128_PPLL_POST0_DIV_MASK); - - R128PLLWriteUpdate(pScrn); - R128PLLWaitForReadUpdateComplete(pScrn); - - OUTPLL(R128_HTOTAL_CNTL, restore->htotal_cntl); -/* R128PLLWriteUpdate(pScrn);*/ - - OUTPLLP(pScrn, R128_PPLL_CNTL, 0, ~(R128_PPLL_RESET - | R128_PPLL_SLEEP - | R128_PPLL_ATOMIC_UPDATE_EN - | R128_PPLL_VGA_ATOMIC_UPDATE_EN)); - - R128TRACE(("Wrote: 0x%08x 0x%08x 0x%08x (0x%08x)\n", - restore->ppll_ref_div, - restore->ppll_div_3, - restore->htotal_cntl, - INPLL(pScrn, R128_PPLL_CNTL))); - R128TRACE(("Wrote: rd=%d, fd=%d, pd=%d\n", - restore->ppll_ref_div & R128_PPLL_REF_DIV_MASK, - restore->ppll_div_3 & R128_PPLL_FB3_DIV_MASK, - (restore->ppll_div_3 & R128_PPLL_POST3_DIV_MASK) >> 16)); - - usleep(5000); /* let the clock lock */ - - OUTPLLP(pScrn, R128_VCLK_ECP_CNTL, - R128_VCLK_SRC_SEL_PPLLCLK, - ~(R128_VCLK_SRC_SEL_MASK)); - -} - -/* Write PLL2 registers. */ -void R128RestorePLL2Registers(ScrnInfoPtr pScrn, R128SavePtr restore) -{ - R128InfoPtr info = R128PTR(pScrn); - unsigned char *R128MMIO = info->MMIO; - - OUTPLLP(pScrn, R128_V2CLK_VCLKTV_CNTL, - R128_V2CLK_SRC_SEL_CPUCLK, - ~R128_V2CLK_SRC_SEL_MASK); - - OUTPLLP(pScrn, - R128_P2PLL_CNTL, - R128_P2PLL_RESET - | R128_P2PLL_ATOMIC_UPDATE_EN - | R128_P2PLL_VGA_ATOMIC_UPDATE_EN, - ~(R128_P2PLL_RESET - | R128_P2PLL_ATOMIC_UPDATE_EN - | R128_P2PLL_VGA_ATOMIC_UPDATE_EN)); - -#if 1 - OUTREGP(R128_CLOCK_CNTL_INDEX, 0, R128_PLL2_DIV_SEL_MASK); -#endif - - /*R128PLL2WaitForReadUpdateComplete(pScrn);*/ - - OUTPLLP(pScrn, R128_P2PLL_REF_DIV, restore->p2pll_ref_div, ~R128_P2PLL_REF_DIV_MASK); - -/* R128PLL2WriteUpdate(pScrn); - R128PLL2WaitForReadUpdateComplete(pScrn);*/ - - OUTPLLP(pScrn, R128_P2PLL_DIV_0, - restore->p2pll_div_0, ~R128_P2PLL_FB0_DIV_MASK); - -/* R128PLL2WriteUpdate(pScrn); - R128PLL2WaitForReadUpdateComplete(pScrn);*/ - - OUTPLLP(pScrn, R128_P2PLL_DIV_0, - restore->p2pll_div_0, ~R128_P2PLL_POST0_DIV_MASK); - - R128PLL2WriteUpdate(pScrn); - R128PLL2WaitForReadUpdateComplete(pScrn); - - OUTPLL(R128_HTOTAL2_CNTL, restore->htotal_cntl2); - -/* R128PLL2WriteUpdate(pScrn);*/ - - OUTPLLP(pScrn, R128_P2PLL_CNTL, 0, ~(R128_P2PLL_RESET - | R128_P2PLL_SLEEP - | R128_P2PLL_ATOMIC_UPDATE_EN - | R128_P2PLL_VGA_ATOMIC_UPDATE_EN)); - - R128TRACE(("Wrote: 0x%08x 0x%08x 0x%08x (0x%08x)\n", - restore->p2pll_ref_div, - restore->p2pll_div_0, - restore->htotal_cntl2, - INPLL(pScrn, R128_P2PLL_CNTL))); - R128TRACE(("Wrote: rd=%d, fd=%d, pd=%d\n", - restore->p2pll_ref_div & R128_P2PLL_REF_DIV_MASK, - restore->p2pll_div_0 & R128_P2PLL_FB0_DIV_MASK, - (restore->p2pll_div_0 & R128_P2PLL_POST0_DIV_MASK) >>16)); - - usleep(5000); /* Let the clock to lock */ - - OUTPLLP(pScrn, R128_V2CLK_VCLKTV_CNTL, - R128_V2CLK_SRC_SEL_P2PLLCLK, - ~R128_V2CLK_SRC_SEL_MASK); - -} - /* Write DDA registers. */ void R128RestoreDDARegisters(ScrnInfoPtr pScrn, R128SavePtr restore) { @@ -2625,14 +2413,17 @@ static void R128SavePLLRegisters(ScrnInf save->ppll_div_0 = INPLL(pScrn, R128_PPLL_DIV_0); save->htotal_cntl = INPLL(pScrn, R128_HTOTAL_CNTL); - R128TRACE(("Read: 0x%08x 0x%08x 0x%08x\n", - save->ppll_ref_div, - save->ppll_div_3, - save->htotal_cntl)); - R128TRACE(("Read: rd=%d, fd=%d, pd=%d\n", - save->ppll_ref_div & R128_PPLL_REF_DIV_MASK, - save->ppll_div_3 & R128_PPLL_FB3_DIV_MASK, - (save->ppll_div_3 & R128_PPLL_POST3_DIV_MASK) >> 16)); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Read: 0x%08x 0x%08x 0x%08x\n", + save->ppll_ref_div, + save->ppll_div_3, + save->htotal_cntl)); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Read: rd=%d, fd=%d, pd=%d\n", + save->ppll_ref_div & R128_PPLL_REF_DIV_MASK, + save->ppll_div_3 & R128_PPLL_FB3_DIV_MASK, + (save->ppll_div_3 & + R128_PPLL_POST3_DIV_MASK) >> 16)); } /* Read PLL2 registers. */ @@ -2642,14 +2433,17 @@ static void R128SavePLL2Registers(ScrnIn save->p2pll_div_0 = INPLL(pScrn, R128_P2PLL_DIV_0); save->htotal_cntl2 = INPLL(pScrn, R128_HTOTAL2_CNTL); - R128TRACE(("Read: 0x%08x 0x%08x 0x%08x\n", - save->p2pll_ref_div, - save->p2pll_div_0, - save->htotal_cntl2)); - R128TRACE(("Read: rd=%d, fd=%d, pd=%d\n", - save->p2pll_ref_div & R128_P2PLL_REF_DIV_MASK, - save->p2pll_div_0 & R128_P2PLL_FB0_DIV_MASK, - (save->p2pll_div_0 & R128_P2PLL_POST0_DIV_MASK) >> 16)); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Read: 0x%08x 0x%08x 0x%08x\n", + save->p2pll_ref_div, + save->p2pll_div_0, + save->htotal_cntl2)); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Read: rd=%d, fd=%d, pd=%d\n", + save->p2pll_ref_div & R128_P2PLL_REF_DIV_MASK, + save->p2pll_div_0 & R128_P2PLL_FB0_DIV_MASK, + (save->p2pll_div_0 & + R128_P2PLL_POST0_DIV_MASK) >> 16)); } /* Read DDA registers. */ @@ -2694,7 +2488,8 @@ static void R128SaveMode(ScrnInfoPtr pSc R128InfoPtr info = R128PTR(pScrn); R128EntPtr pR128Ent = R128EntPriv(pScrn); - R128TRACE(("R128SaveMode(%p)\n", save)); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "%s(%p)\n", __func__, save)); R128SaveCommonRegisters(pScrn, save); R128SaveCrtcRegisters(pScrn, save); @@ -2710,7 +2505,8 @@ static void R128SaveMode(ScrnInfoPtr pSc } R128SavePalette(pScrn, save); - R128TRACE(("R128SaveMode returns %p\n", save)); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "%s returns %p\n", __func__, save)); } /* Save everything needed to restore the original VC state. */ @@ -2720,8 +2516,9 @@ static void R128Save(ScrnInfoPtr pScrn) unsigned char *R128MMIO = info->MMIO; R128SavePtr save = &info->SavedReg; - R128TRACE(("R128Save\n")); #ifndef AVOID_FBDEV + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "%s\n", __func__)); if (info->FBDev) { fbdevHWSave(pScrn); return; @@ -2765,8 +2562,9 @@ static void R128Restore(ScrnInfoPtr pScr unsigned char *R128MMIO = info->MMIO; R128SavePtr restore = &info->SavedReg; - R128TRACE(("R128Restore\n")); #ifndef AVOID_FBDEV + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "%s\n", __func__)); if (info->FBDev) { fbdevHWRestore(pScrn); return; @@ -2847,266 +2645,6 @@ void R128InitCommonRegisters(R128SavePtr save->bus_cntl |= R128_BUS_RD_DISCARD_EN | R128_BUS_RD_ABORT_EN; } -Bool R128InitCrtcBase(xf86CrtcPtr crtc, R128SavePtr save, int x, int y) -{ - ScrnInfoPtr pScrn = crtc->scrn; - R128InfoPtr info = R128PTR(pScrn); - int offset = y * info->CurrentLayout.displayWidth + x; - int Base = pScrn->fbOffset; - - switch (info->CurrentLayout.pixel_code) { - case 15: - case 16: offset *= 2; break; - case 24: offset *= 3; break; - case 32: offset *= 4; break; - } - Base += offset; - - if (crtc->rotatedData != NULL) - Base = pScrn->fbOffset + (char *)crtc->rotatedData - (char *)info->FB; - - Base &= ~7; /* 3 lower bits are always 0 */ - if (info->CurrentLayout.pixel_code == 24) - Base += 8 * (Base % 3); /* Must be multiple of 8 and 3 */ - - save->crtc_offset = Base; - save->crtc_offset_cntl = 0; - - return TRUE; -} - -Bool R128InitCrtc2Base(xf86CrtcPtr crtc, R128SavePtr save, int x, int y) -{ - ScrnInfoPtr pScrn = crtc->scrn; - R128InfoPtr info = R128PTR(pScrn); - int offset = y * info->CurrentLayout.displayWidth + x; - int Base = pScrn->fbOffset; - - switch (info->CurrentLayout.pixel_code) { - case 15: - case 16: offset *= 2; break; - case 24: offset *= 3; break; - case 32: offset *= 4; break; - } - Base += offset; - - if (crtc->rotatedData != NULL) - Base = pScrn->fbOffset + (char *)crtc->rotatedData - (char *)info->FB; - - Base &= ~7; /* 3 lower bits are always 0 */ - if (info->CurrentLayout.pixel_code == 24) - Base += 8 * (Base % 3); /* Must be multiple of 8 and 3 */ - - save->crtc2_offset = Base; - save->crtc2_offset_cntl = 0; - - return TRUE; -} - -/* Define CRTC registers for requested video mode. */ -Bool R128InitCrtcRegisters(xf86CrtcPtr crtc, R128SavePtr save, DisplayModePtr mode) -{ - ScrnInfoPtr pScrn = crtc->scrn; - R128InfoPtr info = R128PTR(pScrn); - xf86OutputPtr output = R128FirstOutput(crtc); - R128OutputPrivatePtr r128_output = output->driver_private; - - int format; - int hsync_start; - int hsync_wid; - int hsync_fudge; - int vsync_wid; - int hsync_fudge_default[] = { 0x00, 0x12, 0x09, 0x09, 0x06, 0x05 }; - int hsync_fudge_fp[] = { 0x12, 0x11, 0x09, 0x09, 0x05, 0x05 }; -// int hsync_fudge_fp_crt[] = { 0x12, 0x10, 0x08, 0x08, 0x04, 0x04 }; - - switch (info->CurrentLayout.pixel_code) { - case 4: format = 1; break; - case 8: format = 2; break; - case 15: format = 3; break; /* 555 */ - case 16: format = 4; break; /* 565 */ - case 24: format = 5; break; /* RGB */ - case 32: format = 6; break; /* xRGB */ - default: - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Unsupported pixel depth (%d)\n", - info->CurrentLayout.bitsPerPixel); - return FALSE; - } - - if (r128_output->MonType == MT_LCD || r128_output->MonType == MT_DFP) - hsync_fudge = hsync_fudge_fp[format-1]; - else - hsync_fudge = hsync_fudge_default[format-1]; - - save->crtc_gen_cntl = (R128_CRTC_EXT_DISP_EN - | R128_CRTC_EN - | (format << 8) - | ((mode->Flags & V_DBLSCAN) - ? R128_CRTC_DBL_SCAN_EN - : 0) - | ((mode->Flags & V_INTERLACE) - ? R128_CRTC_INTERLACE_EN - : 0) - | ((mode->Flags & V_CSYNC) - ? R128_CRTC_CSYNC_EN - : 0)); - - if (r128_output->MonType == MT_LCD || r128_output->MonType == MT_DFP) - save->crtc_gen_cntl &= ~(R128_CRTC_DBL_SCAN_EN | R128_CRTC_INTERLACE_EN); - - save->crtc_ext_cntl |= R128_VGA_ATI_LINEAR | R128_XCRT_CNT_EN; - - save->crtc_h_total_disp = ((((mode->CrtcHTotal / 8) - 1) & 0xffff) - | (((mode->CrtcHDisplay / 8) - 1) << 16)); - - hsync_wid = (mode->CrtcHSyncEnd - mode->CrtcHSyncStart) / 8; - if (!hsync_wid) hsync_wid = 1; - if (hsync_wid > 0x3f) hsync_wid = 0x3f; - - hsync_start = mode->CrtcHSyncStart - 8 + hsync_fudge; - - save->crtc_h_sync_strt_wid = ((hsync_start & 0xfff) - | (hsync_wid << 16) - | ((mode->Flags & V_NHSYNC) - ? R128_CRTC_H_SYNC_POL - : 0)); - -#if 1 - /* This works for double scan mode. */ - save->crtc_v_total_disp = (((mode->CrtcVTotal - 1) & 0xffff) - | ((mode->CrtcVDisplay - 1) << 16)); -#else - /* This is what cce/nbmode.c example code - does -- is this correct? */ - save->crtc_v_total_disp = (((mode->CrtcVTotal - 1) & 0xffff) - | ((mode->CrtcVDisplay - * ((mode->Flags & V_DBLSCAN) ? 2 : 1) - 1) - << 16)); -#endif - - vsync_wid = mode->CrtcVSyncEnd - mode->CrtcVSyncStart; - if (!vsync_wid) vsync_wid = 1; - if (vsync_wid > 0x1f) vsync_wid = 0x1f; - - save->crtc_v_sync_strt_wid = (((mode->CrtcVSyncStart - 1) & 0xfff) - | (vsync_wid << 16) - | ((mode->Flags & V_NVSYNC) - ? R128_CRTC_V_SYNC_POL - : 0)); - save->crtc_pitch = info->CurrentLayout.displayWidth / 8; - - R128TRACE(("Pitch = %d bytes (virtualX = %d, displayWidth = %d)\n", - save->crtc_pitch, pScrn->virtualX, info->CurrentLayout.displayWidth)); - -#if X_BYTE_ORDER == X_BIG_ENDIAN - /* Change the endianness of the aperture */ - switch (info->CurrentLayout.pixel_code) { - case 15: - case 16: save->config_cntl |= APER_0_BIG_ENDIAN_16BPP_SWAP; break; - case 32: save->config_cntl |= APER_0_BIG_ENDIAN_32BPP_SWAP; break; - default: break; - } -#endif - - return TRUE; -} - -/* Define CRTC2 registers for requested video mode. */ -Bool R128InitCrtc2Registers(xf86CrtcPtr crtc, R128SavePtr save, DisplayModePtr mode) -{ - ScrnInfoPtr pScrn = crtc->scrn; - R128InfoPtr info = R128PTR(pScrn); - - int format; - int hsync_start; - int hsync_wid; - int hsync_fudge; - int vsync_wid; - int hsync_fudge_default[] = { 0x00, 0x12, 0x09, 0x09, 0x06, 0x05 }; - - switch (info->CurrentLayout.pixel_code) { - case 4: format = 1; break; - case 8: format = 2; break; - case 15: format = 3; break; /* 555 */ - case 16: format = 4; break; /* 565 */ - case 24: format = 5; break; /* RGB */ - case 32: format = 6; break; /* xRGB */ - default: - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Unsupported pixel depth (%d)\n", info->CurrentLayout.bitsPerPixel); - return FALSE; - } - - hsync_fudge = hsync_fudge_default[format-1]; - - save->crtc2_gen_cntl = (R128_CRTC2_EN - | (format << 8) - | ((mode->Flags & V_DBLSCAN) - ? R128_CRTC2_DBL_SCAN_EN - : 0)); -/* - save->crtc2_gen_cntl &= ~R128_CRTC_EXT_DISP_EN; - save->crtc2_gen_cntl |= (1 << 21); -*/ - save->crtc2_h_total_disp = ((((mode->CrtcHTotal / 8) - 1) & 0xffff) - | (((mode->CrtcHDisplay / 8) - 1) << 16)); - - hsync_wid = (mode->CrtcHSyncEnd - mode->CrtcHSyncStart) / 8; - if (!hsync_wid) hsync_wid = 1; - if (hsync_wid > 0x3f) hsync_wid = 0x3f; - - hsync_start = mode->CrtcHSyncStart - 8 + hsync_fudge; - - save->crtc2_h_sync_strt_wid = ((hsync_start & 0xfff) - | (hsync_wid << 16) - | ((mode->Flags & V_NHSYNC) - ? R128_CRTC2_H_SYNC_POL - : 0)); - -#if 1 - /* This works for double scan mode. */ - save->crtc2_v_total_disp = (((mode->CrtcVTotal - 1) & 0xffff) - | ((mode->CrtcVDisplay - 1) << 16)); -#else - /* This is what cce/nbmode.c example code - does -- is this correct? */ - save->crtc2_v_total_disp = (((mode->CrtcVTotal - 1) & 0xffff) - | ((mode->CrtcVDisplay - * ((mode->Flags & V_DBLSCAN) ? 2 : 1) - 1) - << 16)); -#endif - - vsync_wid = mode->CrtcVSyncEnd - mode->CrtcVSyncStart; - if (!vsync_wid) vsync_wid = 1; - if (vsync_wid > 0x1f) vsync_wid = 0x1f; - - save->crtc2_v_sync_strt_wid = (((mode->CrtcVSyncStart - 1) & 0xfff) - | (vsync_wid << 16) - | ((mode->Flags & V_NVSYNC) - ? R128_CRTC2_V_SYNC_POL - : 0)); - save->crtc2_pitch = info->CurrentLayout.displayWidth / 8; - - R128TRACE(("Pitch = %d bytes (virtualX = %d, displayWidth = %d)\n", - save->crtc2_pitch, pScrn->virtualX, - info->CurrentLayout.displayWidth)); - return TRUE; -} - -/* Define DAC registers for the requested video mode. */ -void R128InitDACRegisters(R128SavePtr orig, R128SavePtr save, xf86OutputPtr output) -{ - ScrnInfoPtr pScrn = output->scrn; - R128InfoPtr info = R128PTR(pScrn); - xf86CrtcPtr crtc = output->crtc; - R128CrtcPrivatePtr r128_crtc = crtc->driver_private; - - save->dac_cntl = (R128_DAC_MASK_ALL | R128_DAC_VGA_ADR_EN | - (!r128_crtc->crtc_id ? 0 : R128_DAC_CRT_SEL_CRTC2) | - (info->dac6bits ? 0 : R128_DAC_8BIT_EN)); -} - /* Define RMX registers for the requested video mode. */ void R128InitRMXRegisters(R128SavePtr orig, R128SavePtr save, xf86OutputPtr output, DisplayModePtr mode) @@ -3210,265 +2748,6 @@ void R128InitLVDSRegisters(R128SavePtr o save->lvds_gen_cntl &= ~R128_LVDS_SEL_CRTC2; } -/* Define PLL registers for requested video mode. */ -void R128InitPLLRegisters(xf86CrtcPtr crtc, R128SavePtr save, - R128PLLPtr pll, double dot_clock) -{ -#if R128_DEBUG - ScrnInfoPtr pScrn = crtc->scrn; -#endif - unsigned long freq = dot_clock * 100; - struct { - int divider; - int bitvalue; - } *post_div, - post_divs[] = { - /* From RAGE 128 VR/RAGE 128 GL Register - Reference Manual (Technical Reference - Manual P/N RRG-G04100-C Rev. 0.04), page - 3-17 (PLL_DIV_[3:0]). */ - { 1, 0 }, /* VCLK_SRC */ - { 2, 1 }, /* VCLK_SRC/2 */ - { 4, 2 }, /* VCLK_SRC/4 */ - { 8, 3 }, /* VCLK_SRC/8 */ - - { 3, 4 }, /* VCLK_SRC/3 */ - /* bitvalue = 5 is reserved */ - { 6, 6 }, /* VCLK_SRC/6 */ - { 12, 7 }, /* VCLK_SRC/12 */ - { 0, 0 } - }; - - if (freq > pll->max_pll_freq) freq = pll->max_pll_freq; - if (freq * 12 < pll->min_pll_freq) freq = pll->min_pll_freq / 12; - - for (post_div = &post_divs[0]; post_div->divider; ++post_div) { - save->pll_output_freq = post_div->divider * freq; - if (save->pll_output_freq >= pll->min_pll_freq - && save->pll_output_freq <= pll->max_pll_freq) break; - } - - save->dot_clock_freq = freq; - save->feedback_div = R128Div(pll->reference_div * save->pll_output_freq, - pll->reference_freq); - save->post_div = post_div->divider; - - R128TRACE(("dc=%d, of=%d, fd=%d, pd=%d\n", - save->dot_clock_freq, - save->pll_output_freq, - save->feedback_div, - save->post_div)); - - save->ppll_ref_div = pll->reference_div; - save->ppll_div_3 = (save->feedback_div | (post_div->bitvalue << 16)); - save->htotal_cntl = 0; - -} - -/* Define PLL2 registers for requested video mode. */ -void R128InitPLL2Registers(xf86CrtcPtr crtc, R128SavePtr save, - R128PLLPtr pll, double dot_clock) -{ -#if R128_DEBUG - ScrnInfoPtr pScrn = crtc->scrn; -#endif - unsigned long freq = dot_clock * 100; - struct { - int divider; - int bitvalue; - } *post_div, - post_divs[] = { - /* From RAGE 128 VR/RAGE 128 GL Register - Reference Manual (Technical Reference - Manual P/N RRG-G04100-C Rev. 0.04), page - 3-17 (PLL_DIV_[3:0]). */ - { 1, 0 }, /* VCLK_SRC */ - { 2, 1 }, /* VCLK_SRC/2 */ - { 4, 2 }, /* VCLK_SRC/4 */ - { 8, 3 }, /* VCLK_SRC/8 */ - - { 3, 4 }, /* VCLK_SRC/3 */ - /* bitvalue = 5 is reserved */ - { 6, 6 }, /* VCLK_SRC/6 */ - { 12, 7 }, /* VCLK_SRC/12 */ - { 0, 0 } - }; - - if (freq > pll->max_pll_freq) freq = pll->max_pll_freq; - if (freq * 12 < pll->min_pll_freq) freq = pll->min_pll_freq / 12; - - for (post_div = &post_divs[0]; post_div->divider; ++post_div) { - save->pll_output_freq_2 = post_div->divider * freq; - if (save->pll_output_freq_2 >= pll->min_pll_freq - && save->pll_output_freq_2 <= pll->max_pll_freq) break; - } - - save->dot_clock_freq_2 = freq; - save->feedback_div_2 = R128Div(pll->reference_div - * save->pll_output_freq_2, - pll->reference_freq); - save->post_div_2 = post_div->divider; - - R128TRACE(("dc=%d, of=%d, fd=%d, pd=%d\n", - save->dot_clock_freq_2, - save->pll_output_freq_2, - save->feedback_div_2, - save->post_div_2)); - - save->p2pll_ref_div = pll->reference_div; - save->p2pll_div_0 = (save->feedback_div_2 | (post_div->bitvalue<<16)); - save->htotal_cntl2 = 0; -} - -/* Define DDA registers for requested video mode. */ -Bool R128InitDDARegisters(xf86CrtcPtr crtc, R128SavePtr save, - R128PLLPtr pll, DisplayModePtr mode) -{ - ScrnInfoPtr pScrn = crtc->scrn; - R128InfoPtr info = R128PTR(pScrn); - xf86OutputPtr output = R128FirstOutput(crtc); - R128OutputPrivatePtr r128_output = output->driver_private; - - int DisplayFifoWidth = 128; - int DisplayFifoDepth = 32; - int XclkFreq; - int VclkFreq; - int XclksPerTransfer; - int XclksPerTransferPrecise; - int UseablePrecision; - int Roff; - int Ron; - - XclkFreq = pll->xclk; - - VclkFreq = R128Div(pll->reference_freq * save->feedback_div, - pll->reference_div * save->post_div); - - if (info->isDFP && !info->isPro2 && r128_output->PanelXRes > 0) { - if (r128_output->PanelXRes != mode->CrtcHDisplay) - VclkFreq = (VclkFreq * mode->CrtcHDisplay) / r128_output->PanelXRes; - } - - XclksPerTransfer = R128Div(XclkFreq * DisplayFifoWidth, - VclkFreq * (info->CurrentLayout.pixel_bytes * 8)); - - UseablePrecision = R128MinBits(XclksPerTransfer) + 1; - - XclksPerTransferPrecise = R128Div((XclkFreq * DisplayFifoWidth) - << (11 - UseablePrecision), - VclkFreq * (info->CurrentLayout.pixel_bytes * 8)); - - Roff = XclksPerTransferPrecise * (DisplayFifoDepth - 4); - - Ron = (4 * info->ram->MB - + 3 * MAX(info->ram->Trcd - 2, 0) - + 2 * info->ram->Trp - + info->ram->Twr - + info->ram->CL - + info->ram->Tr2w - + XclksPerTransfer) << (11 - UseablePrecision); - - if (Ron + info->ram->Rloop >= Roff) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "(Ron = %d) + (Rloop = %d) >= (Roff = %d)\n", - Ron, info->ram->Rloop, Roff); - return FALSE; - } - - save->dda_config = (XclksPerTransferPrecise - | (UseablePrecision << 16) - | (info->ram->Rloop << 20)); - - save->dda_on_off = (Ron << 16) | Roff; - - R128TRACE(("XclkFreq = %d; VclkFreq = %d; per = %d, %d (useable = %d)\n", - XclkFreq, - VclkFreq, - XclksPerTransfer, - XclksPerTransferPrecise, - UseablePrecision)); - R128TRACE(("Roff = %d, Ron = %d, Rloop = %d\n", - Roff, Ron, info->ram->Rloop)); - - return TRUE; -} - -/* Define DDA2 registers for requested video mode. */ -Bool R128InitDDA2Registers(xf86CrtcPtr crtc, R128SavePtr save, - R128PLLPtr pll, DisplayModePtr mode) -{ - ScrnInfoPtr pScrn = crtc->scrn; - R128InfoPtr info = R128PTR(pScrn); - xf86OutputPtr output = R128FirstOutput(crtc); - R128OutputPrivatePtr r128_output = output->driver_private; - - int DisplayFifoWidth = 128; - int DisplayFifoDepth = 32; - int XclkFreq; - int VclkFreq; - int XclksPerTransfer; - int XclksPerTransferPrecise; - int UseablePrecision; - int Roff; - int Ron; - - XclkFreq = pll->xclk; - - VclkFreq = R128Div(pll->reference_freq * save->feedback_div_2, - pll->reference_div * save->post_div_2); - - if (info->isDFP && !info->isPro2 && r128_output->PanelXRes > 0) { - if (r128_output->PanelXRes != mode->CrtcHDisplay) - VclkFreq = (VclkFreq * mode->CrtcHDisplay) / r128_output->PanelXRes; - } - - XclksPerTransfer = R128Div(XclkFreq * DisplayFifoWidth, - VclkFreq * (info->CurrentLayout.pixel_bytes * 8)); - - UseablePrecision = R128MinBits(XclksPerTransfer) + 1; - - XclksPerTransferPrecise = R128Div((XclkFreq * DisplayFifoWidth) - << (11 - UseablePrecision), - VclkFreq * (info->CurrentLayout.pixel_bytes * 8)); - - Roff = XclksPerTransferPrecise * (DisplayFifoDepth - 4); - - Ron = (4 * info->ram->MB - + 3 * MAX(info->ram->Trcd - 2, 0) - + 2 * info->ram->Trp - + info->ram->Twr - + info->ram->CL - + info->ram->Tr2w - + XclksPerTransfer) << (11 - UseablePrecision); - - - if (Ron + info->ram->Rloop >= Roff) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "(Ron = %d) + (Rloop = %d) >= (Roff = %d)\n", - Ron, info->ram->Rloop, Roff); - return FALSE; - } - - save->dda2_config = (XclksPerTransferPrecise - | (UseablePrecision << 16) - | (info->ram->Rloop << 20)); - - /*save->dda2_on_off = (Ron << 16) | Roff;*/ - /* shift most be 18 otherwise there's corruption on crtc2 */ - save->dda2_on_off = (Ron << 18) | Roff; - - R128TRACE(("XclkFreq = %d; VclkFreq = %d; per = %d, %d (useable = %d)\n", - XclkFreq, - VclkFreq, - XclksPerTransfer, - XclksPerTransferPrecise, - UseablePrecision)); - R128TRACE(("Roff = %d, Ron = %d, Rloop = %d\n", - Roff, Ron, info->ram->Rloop)); - - return TRUE; -} - #if 0 /* Define initial palette for requested video mode. This doesn't do anything for XFree86 4.0. */ @@ -3628,7 +2907,8 @@ Bool R128EnterVT(VT_FUNC_ARGS_DECL) SCRN_INFO_PTR(arg); R128InfoPtr info = R128PTR(pScrn); - R128TRACE(("R128EnterVT\n")); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "%s\n", __func__)); pScrn->vtSema = TRUE; #ifndef AVOID_FBDEV @@ -3670,7 +2950,8 @@ void R128LeaveVT(VT_FUNC_ARGS_DECL) R128InfoPtr info = R128PTR(pScrn); R128SavePtr save = &info->ModeReg; - R128TRACE(("R128LeaveVT\n")); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "%s\n", __func__)); #ifdef R128DRI if (info->directRenderingEnabled) { DRILock(pScrn->pScreen, 0); @@ -3700,7 +2981,8 @@ static Bool R128CloseScreen(CLOSE_SCREEN ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); R128InfoPtr info = R128PTR(pScrn); - R128TRACE(("R128CloseScreen\n")); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "%s\n", __func__)); #ifdef R128DRI /* Disable direct rendering */ @@ -3749,7 +3031,8 @@ void R128FreeScreen(FREE_SCREEN_ARGS_DEC SCRN_INFO_PTR(arg); R128InfoPtr info = R128PTR(pScrn); - R128TRACE(("R128FreeScreen\n")); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "%s\n", __func__)); if (info == NULL) return; #ifdef WITH_VGAHW Index: xsrc/external/mit/xf86-video-r128/dist/src/r128_exa.c diff -u xsrc/external/mit/xf86-video-r128/dist/src/r128_exa.c:1.2 xsrc/external/mit/xf86-video-r128/dist/src/r128_exa.c:1.3 --- xsrc/external/mit/xf86-video-r128/dist/src/r128_exa.c:1.2 Fri Sep 9 22:40:01 2016 +++ xsrc/external/mit/xf86-video-r128/dist/src/r128_exa.c Sun Dec 30 06:46:48 2018 @@ -36,31 +36,10 @@ #include "exa.h" #include "r128_reg.h" +#include "r128_rop.h" #include "xf86.h" -static struct { - int rop; - int pattern; -} R128_ROP[] = { - { R128_ROP3_ZERO, R128_ROP3_ZERO }, /* GXclear */ - { R128_ROP3_DSa, R128_ROP3_DPa }, /* Gxand */ - { R128_ROP3_SDna, R128_ROP3_PDna }, /* GXandReverse */ - { R128_ROP3_S, R128_ROP3_P }, /* GXcopy */ - { R128_ROP3_DSna, R128_ROP3_DPna }, /* GXandInverted */ - { R128_ROP3_D, R128_ROP3_D }, /* GXnoop */ - { R128_ROP3_DSx, R128_ROP3_DPx }, /* GXxor */ - { R128_ROP3_DSo, R128_ROP3_DPo }, /* GXor */ - { R128_ROP3_DSon, R128_ROP3_DPon }, /* GXnor */ - { R128_ROP3_DSxn, R128_ROP3_PDxn }, /* GXequiv */ - { R128_ROP3_Dn, R128_ROP3_Dn }, /* GXinvert */ - { R128_ROP3_SDno, R128_ROP3_PDno }, /* GXorReverse */ - { R128_ROP3_Sn, R128_ROP3_Pn }, /* GXcopyInverted */ - { R128_ROP3_DSno, R128_ROP3_DPno }, /* GXorInverted */ - { R128_ROP3_DSan, R128_ROP3_DPan }, /* GXnand */ - { R128_ROP3_ONE, R128_ROP3_ONE } /* GXset */ -}; - /* Assumes that depth 15 and 16 can be used as depth 16, which is okay since we * require src and dest datatypes to be equal. */ @@ -92,12 +71,14 @@ static Bool R128GetOffsetPitch(PixmapPtr R128InfoPtr info = R128PTR(pScrn); if (pitch > 16320 || pitch % info->ExaDriver->pixmapPitchAlign != 0) { - R128TRACE(("Bad pitch 0x%08x\n", pitch)); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Bad pitch 0x%08x\n", pitch)); return FALSE; } if (offset % info->ExaDriver->pixmapOffsetAlign != 0) { - R128TRACE(("Bad offset 0x%08x\n", offset)); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Bad offset 0x%08x\n", offset)); return FALSE; } @@ -143,7 +124,7 @@ static void Emit2DState(ScrnInfoPtr pScr } #ifdef R128DRI -static void EmitCCE2DState(ScrnInfoPtr pScrn) +void EmitCCE2DState(ScrnInfoPtr pScrn) { R128InfoPtr info = R128PTR(pScrn); int has_src = info->state_2d.src_pitch_offset; @@ -182,11 +163,13 @@ R128PrepareSolid(PixmapPtr pPixmap, int uint32_t datatype, dst_pitch_offset; if (!R128GetDatatypeBpp(bpp, &datatype)) { - R128TRACE(("R128GetDatatypeBpp failed\n")); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "R128GetDatatypeBpp failed\n")); return FALSE; } if (!R128GetPixmapOffsetPitch(pPixmap, &dst_pitch_offset)) { - R128TRACE(("R128GetPixmapOffsetPitch failed\n")); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "R128GetPixmapOffsetPitch failed\n")); return FALSE; } if (info->state_2d.in_use) return FALSE; @@ -282,15 +265,19 @@ R128PrepareCopy(PixmapPtr pSrcPixmap, Pi uint32_t datatype, src_pitch_offset, dst_pitch_offset; if (!R128GetDatatypeBpp(bpp, &datatype)) { - R128TRACE(("R128GetDatatypeBpp failed\n")); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "R128GetDatatypeBpp failed\n")); return FALSE; } if (!R128GetPixmapOffsetPitch(pSrcPixmap, &src_pitch_offset)) { - R128TRACE(("R128GetPixmapOffsetPitch source failed\n")); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "R128GetPixmapOffsetPitch source " + "failed\n")); return FALSE; } if (!R128GetPixmapOffsetPitch(pDstPixmap, &dst_pitch_offset)) { - R128TRACE(("R128GetPixmapOffsetPitch dest failed\n")); + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "R128GetPixmapOffsetPitch dest failed\n")); return FALSE; } if (info->state_2d.in_use) return FALSE; @@ -329,7 +316,7 @@ R128Sync(ScreenPtr pScreen, int marker) R128WaitForIdle(xf86ScreenToScrn(pScreen)); } -static void +void R128Done(PixmapPtr pPixmap) { ScreenPtr pScreen = pPixmap->drawable.pScreen; @@ -406,10 +393,6 @@ R128CCESync(ScreenPtr pScreen, int marke R128CCEWaitForIdle(xf86ScreenToScrn(pScreen)); } -#ifdef RENDER -#include "r128_exa_render.c" -#endif - #endif /* @@ -538,15 +521,26 @@ R128DownloadFromScreen(PixmapPtr pSrc, i } Bool -R128EXAInit(ScreenPtr pScreen) +R128EXAInit(ScreenPtr pScreen, int total) { ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); R128InfoPtr info = R128PTR(pScrn); + info->ExaDriver = exaDriverAlloc(); + if (!info->ExaDriver) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Could not allocate EXA driver...\n"); + return FALSE; + } + info->ExaDriver->exa_major = EXA_VERSION_MAJOR; info->ExaDriver->exa_minor = EXA_VERSION_MINOR; info->ExaDriver->memoryBase = info->FB + pScrn->fbOffset; + info->ExaDriver->offScreenBase = pScrn->virtualY * + (pScrn->displayWidth * + info->CurrentLayout.pixel_bytes); + info->ExaDriver->memorySize = total; info->ExaDriver->flags = EXA_OFFSCREEN_PIXMAPS; #if EXA_VERSION_MAJOR > 2 || (EXA_VERSION_MAJOR == 2 && EXA_VERSION_MINOR >= 3) @@ -611,7 +605,7 @@ R128EXAInit(ScreenPtr pScreen) } xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Initalizing 2D acceleration engine...\n"); + "Initializing 2D acceleration engine...\n"); R128EngineInit(pScrn); Index: xsrc/external/mit/xf86-video-r128/dist/src/r128_output.c diff -u xsrc/external/mit/xf86-video-r128/dist/src/r128_output.c:1.6 xsrc/external/mit/xf86-video-r128/dist/src/r128_output.c:1.7 --- xsrc/external/mit/xf86-video-r128/dist/src/r128_output.c:1.6 Sun Mar 5 01:32:03 2017 +++ xsrc/external/mit/xf86-video-r128/dist/src/r128_output.c Sun Dec 30 06:46:48 2018 @@ -58,6 +58,29 @@ static void R128ConnectorFindMonitor(ScrnInfoPtr pScrn, xf86OutputPtr output); +/* Define DAC registers for the requested video mode. */ +void R128InitDACRegisters(R128SavePtr orig, R128SavePtr save, xf86OutputPtr output) +{ + ScrnInfoPtr pScrn = output->scrn; + R128InfoPtr info = R128PTR(pScrn); + xf86CrtcPtr crtc = output->crtc; + R128CrtcPrivatePtr r128_crtc = crtc->driver_private; + + save->dac_cntl = (R128_DAC_MASK_ALL | R128_DAC_VGA_ADR_EN | + (!r128_crtc->crtc_id ? 0 : R128_DAC_CRT_SEL_CRTC2) | + (info->dac6bits ? 0 : R128_DAC_8BIT_EN)); +} + +/* Write DAC registers */ +void R128RestoreDACRegisters(ScrnInfoPtr pScrn, R128SavePtr restore) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + OUTREGP(R128_DAC_CNTL, restore->dac_cntl, + R128_DAC_RANGE_CNTL | R128_DAC_BLANKING); +} + static void r128_dpms(xf86OutputPtr output, int mode) { switch(mode) { @@ -308,10 +331,10 @@ static R128MonitorType R128DisplayDDCCon if (r128_output->pI2CBus) { R128I2CBusPtr pR128I2CBus = &(r128_output->ddc_i2c); - /* XXX: Radeon does something here to appease old monitors. */ - OUTREG(pR128I2CBus->ddc_reg, INREG(pR128I2CBus->ddc_reg) | mask1); - OUTREG(pR128I2CBus->ddc_reg, INREG(pR128I2CBus->ddc_reg) & ~mask2); - *MonInfo = xf86DoEDID_DDC2(XF86_SCRN_ARG(pScrn), r128_output->pI2CBus); + /* XXX: Radeon does something here to appease old monitors. */ + OUTREG(pR128I2CBus->ddc_reg, INREG(pR128I2CBus->ddc_reg) | mask1); + OUTREG(pR128I2CBus->ddc_reg, INREG(pR128I2CBus->ddc_reg) & ~mask2); + *MonInfo = xf86DoEDID_DDC2(XF86_SCRN_ARG(pScrn), r128_output->pI2CBus); } else { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "DDC2/I2C is not properly initialized\n"); return MT_NONE; @@ -325,7 +348,7 @@ static R128MonitorType R128DisplayDDCCon MonType = MT_DFP; else MonType = MT_CRT; - } + } } return MonType; @@ -371,8 +394,8 @@ DisplayModePtr R128ProbeOutputModes(xf86 } } - xf86SetModeCrtc(mode, INTERLACE_HALVE_V); - if (mode->status == MODE_OK) + xf86SetModeCrtc(mode, INTERLACE_HALVE_V); + if (mode->status == MODE_OK) mode->status = R128DoValidMode(output, mode, MODECHECK_FINAL); } @@ -441,40 +464,47 @@ static Bool R128I2CInit(xf86OutputPtr ou return TRUE; } -void R128SetupGenericConnectors(ScrnInfoPtr pScrn, R128OutputType *otypes) -{ - R128InfoPtr info = R128PTR(pScrn); - R128EntPtr pR128Ent = R128EntPriv(pScrn); - - if (!pR128Ent->HasCRTC2 && !info->isDFP) { - otypes[0] = OUTPUT_VGA; - otypes[1] = OUTPUT_NONE; - return; - } else if (!pR128Ent->HasCRTC2) { - otypes[0] = OUTPUT_DVI; - otypes[1] = OUTPUT_NONE; - return; - } - - otypes[0] = OUTPUT_LVDS; - otypes[1] = OUTPUT_VGA; -} - void R128GetConnectorInfoFromBIOS(ScrnInfoPtr pScrn, R128OutputType *otypes) { R128InfoPtr info = R128PTR(pScrn); - uint16_t bios_header; - int offset; + uint16_t bios_header, offset; + uint32_t i; - /* XXX: Currently, this function only finds VGA ports misidentified as DVI. */ - if (!info->VBIOS || otypes[0] != OUTPUT_DVI) return; + for (i = 0; i < R128_MAX_BIOS_CONNECTOR; i++) { + otypes[i] = OUTPUT_NONE; + } + + /* non-x86 platform */ + if (!info->VBIOS) { + otypes[0] = OUTPUT_VGA; + } bios_header = R128_BIOS16(0x48); - offset = R128_BIOS16(bios_header + 0x60); + offset = R128_BIOS16(bios_header + 0x40); + if (offset) { + otypes[0] = OUTPUT_LVDS; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Found FP table, assuming FP connector.\n"); + } else { + bios_header = R128_BIOS16(0x48); + offset = R128_BIOS16(bios_header + 0x34); + if (offset) { + otypes[0] = OUTPUT_DVI; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Found DVI table, assuming DVI connector.\n"); + } + } + offset = R128_BIOS16(bios_header + 0x2e); if (offset) { - otypes[0] = OUTPUT_VGA; - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Found CRT table, assuming VGA connector\n"); + if (otypes[0] == OUTPUT_NONE) { + otypes[0] = OUTPUT_VGA; + } else { + otypes[1] = OUTPUT_VGA; + } + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Found CRT table, assuming VGA connector.\n"); } } @@ -489,7 +519,6 @@ Bool R128SetupConnectors(ScrnInfoPtr pSc int num_dvi = 0; int i; - R128SetupGenericConnectors(pScrn, otypes); R128GetConnectorInfoFromBIOS(pScrn, otypes); for (i = 0; i < R128_MAX_BIOS_CONNECTOR; i++) { @@ -502,7 +531,7 @@ Bool R128SetupConnectors(ScrnInfoPtr pSc for (i = 0; i < R128_MAX_BIOS_CONNECTOR; i++) { if (otypes[i] == OUTPUT_NONE) continue; - R128I2CBusRec i2c; + R128I2CBusRec i2c; R128OutputPrivatePtr r128_output; r128_output = xnfcalloc(sizeof(R128OutputPrivateRec), 1); @@ -524,11 +553,11 @@ Bool R128SetupConnectors(ScrnInfoPtr pSc output->interlaceAllowed = TRUE; output->doubleScanAllowed = TRUE; output->driver_private = r128_output; - output->possible_clones = 0; - if (otypes[i] == OUTPUT_LVDS || !pR128Ent->HasCRTC2) - output->possible_crtcs = 1; - else - output->possible_crtcs = 2; + output->possible_clones = 0; + if (otypes[i] == OUTPUT_LVDS || !pR128Ent->HasCRTC2) + output->possible_crtcs = 1; + else + output->possible_crtcs = 2; if (otypes[i] != OUTPUT_LVDS && info->DDC) { i2c.ddc_reg = R128_GPIO_MONID;