From 17645e10c7d837b1cbd8959476f9d41983304b91 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 25 Jun 2007 15:33:10 -0700 Subject: [PATCH] Change Volari_Idle from a macro (#define) to a function. --- src/vb_def.h | 16 +++++++ src/xgi_accel.c | 115 +++++++++++++++++++++++++++++++++++++++++++++--- src/xgi_accel.h | 115 ++++++++++-------------------------------------- src/xgi_dac.c | 18 +------- src/xgi_dri.c | 8 ++-- 5 files changed, 154 insertions(+), 118 deletions(-) diff --git a/src/vb_def.h b/src/vb_def.h index 400f73b..cbb0247 100644 --- a/src/vb_def.h +++ b/src/vb_def.h @@ -1047,4 +1047,20 @@ #define RES1280x960x120 0x47 #define LFBDRAMTrap 0x30 + +/** + * MMIO 8C55 - command queue read pointer + */ +#define IDLE_ALL (1 << 31) /**< 3D & 2D idle, HQ & SQ empty */ +#define EMPTY_HQ (1 << 30) /**< HQ empty */ +#define IDLE_2D (1 << 29) /**< 2D idle */ +#define IDLE_3D (1 << 28) /**< 3D idle */ +#define EMPTY_HW_CQ (1 << 27) /**< Hardware command queue empty */ +#define EMPTY_2D (1 << 26) /**< 2D queue empty */ +#define EMPTY_3D (1 << 25) /**< 3D queue empty */ +#define EMPTY_SW_CQ (1 << 24) /**< Software command queue empty */ +#define COUNTER_3_MASK (0xff << 16) +#define COUNTER_2_MASK (0xff << 8) +#define COUNTER_1_MASK (0xff << 0) + #endif diff --git a/src/xgi_accel.c b/src/xgi_accel.c index 4ef4284..1dbbfa0 100644 --- a/src/xgi_accel.c +++ b/src/xgi_accel.c @@ -47,6 +47,7 @@ #include "xgi_accel.h" #include "xgi_regs.h" #include "xgi.h" +#include "vb_def.h" #include "xaarop.h" #include @@ -103,7 +104,111 @@ static CARD32 BE_SWAP32 (CARD32 val) #endif +#ifdef DEBUG +static void dump_cq_read_pointer(unsigned int cqrp) +{ + static const char *const field_name[8] = { + "all idle", + "hardware queues empty", + "2D idle", + "3D idle", + "hardware command queue empty", + "2D queue empty", + "3D queue empty", + "software command queue empty", + }; + unsigned i; + xf86DrvMsg(0, X_INFO, "IO(0x85CC) = 0x%08x\n", cqrp); + for (i = 31; i > 23; i--) { + if ((cqrp & (1U << i)) != 0) { + xf86DrvMsg(0, X_INFO, " %s\n", field_name[31 - i]); + } + } +} +#endif /* DEBUG */ + + +void Volari_Idle(XGIPtr pXGI) +{ + int i; + unsigned int WaitCount = 65535; +#ifdef DEBUG + unsigned int last_cqrp = 0; +#endif /* DEBUG */ + + if (pXGI->Chipset == PCI_CHIP_XGIXG20) { + WaitCount = 1; + switch (CurrentHDisplay) { + case 640: + if(CurrentColorDepth == 8) + WaitCount=1; + else if(CurrentColorDepth == 16) + WaitCount=1000; + else if(CurrentColorDepth == 24) + WaitCount=3000; + break; + + case 800: + if(CurrentColorDepth == 8) + WaitCount=160; + else if(CurrentColorDepth == 16) + WaitCount=1200; + else if(CurrentColorDepth == 24) + WaitCount=4000; + break; + + case 1024: + if(CurrentColorDepth == 8) + WaitCount=200; + else if(CurrentColorDepth == 16) + WaitCount=1600; + else if(CurrentColorDepth == 24) + WaitCount=6000; + break; + + case 1280: + if(CurrentColorDepth == 8) + WaitCount=500; + else if(CurrentColorDepth == 16) + WaitCount=2000; + else if(CurrentColorDepth == 24) + WaitCount=8000; + break; + + default: + break; + } + } + + do { + int bIdle = 0; + unsigned int cqrp; + + for (i = 0; i < WaitCount; i++) { + cqrp = MMIO_IN32(pXGI->IOBase, 0x85CC); + if (cqrp & IDLE_ALL) { + bIdle = 1; + break; + } + } + + if (bIdle) + break; + +#ifdef DEBUG + if (last_cqrp != cqrp) { + dump_cq_read_pointer(cqrp); + last_cqrp = cqrp; + } + + sleep(1); +#endif /* DEBUG */ + + if (pXGI->Chipset == PCI_CHIP_XGIXG20) + usleep(1); + } while (1); +} void @@ -280,9 +385,9 @@ Volari_InitCmdQueue(ScrnInfoPtr pScrn) if(pXGI->Chipset == PCI_CHIP_XGIXG40) { - Volari_Idle ; + Volari_Idle(pXGI); Volari_DisableDualPipe(pScrn) ; - Volari_Idle ; + Volari_Idle(pXGI); } PDEBUG(ErrorF("Volari_InitCmdQueue() done.\n")) ; @@ -322,7 +427,7 @@ Volari_DisableAccelerator(ScrnInfoPtr pScrn) PDEBUG(ErrorF("Volari_DisableAccelerator(pScrn)\n")) ; - Volari_Idle ; + Volari_Idle(pXGI); if( pXGI->TurboQueue ) { @@ -509,7 +614,7 @@ Volari_Sync(ScrnInfoPtr pScrn) PDEBUG1(ErrorF("Volari_Sync()\n")); pXGI->DoColorExpand = FALSE; - Volari_Idle ; + Volari_Idle(pXGI); } static int xgiG2_ALUConv[] = @@ -745,7 +850,7 @@ Volari_SubsequentMonoPatternFill(ScrnInfoPtr pScrn, Volari_SetupDSTXY(x,y) ; Volari_SetupRect(w,h) ; Volari_DoCMD ; - /*Volari_Idle*/; + /*Volari_Idle(pXGI)*/; } /************************************************************************/ diff --git a/src/xgi_accel.h b/src/xgi_accel.h index 99b5dff..99f9669 100644 --- a/src/xgi_accel.h +++ b/src/xgi_accel.h @@ -126,76 +126,7 @@ extern unsigned int CurrentHDisplay; extern unsigned int CurrentVDisplay; extern unsigned int CurrentColorDepth; -/* Jong; 08222005 */ - -#define Volari_Idle \ - {\ - int i; \ - unsigned int WaitCount;\ -\ - WaitCount=65535;\ - if(pXGI->Chipset == PCI_CHIP_XGIXG20)\ - {\ - WaitCount=1;\ - switch (CurrentHDisplay) {\ - case 640:\ - if(CurrentColorDepth == 8)\ - WaitCount=1;\ - else if(CurrentColorDepth == 16)\ - WaitCount=1000;\ - else if(CurrentColorDepth == 24)\ - WaitCount=3000;\ - break;\ -\ - case 800:\ - if(CurrentColorDepth == 8)\ - WaitCount=160;\ - else if(CurrentColorDepth == 16)\ - WaitCount=1200;\ - else if(CurrentColorDepth == 24)\ - WaitCount=4000;\ - break;\ -\ - case 1024:\ - if(CurrentColorDepth == 8)\ - WaitCount=200;\ - else if(CurrentColorDepth == 16)\ - WaitCount=1600;\ - else if(CurrentColorDepth == 24)\ - WaitCount=6000;\ - break;\ -\ - case 1280:\ - if(CurrentColorDepth == 8)\ - WaitCount=500;\ - else if(CurrentColorDepth == 16)\ - WaitCount=2000;\ - else if(CurrentColorDepth == 24)\ - WaitCount=8000;\ - break;\ -\ - default:\ - break;\ - }\ - }\ -\ - do {\ - bool bIdle = 0;\ - for (i=0; iIOBase, 0x85CC); \ - if (ulTemp & 0x80000000) {\ - bIdle=1; \ - break;\ - }\ - }\ - if (bIdle == 1) \ - break; \ -\ - if (pXGI->Chipset == PCI_CHIP_XGIXG20)\ - usleep(1);\ - } while(1);\ - } - +extern void Volari_Idle(XGIPtr pXGI); #define Volari_GetSwWP() (unsigned long)(*(pXGI->pCQ_shareWritePort)) #define Volari_GetHwRP() (unsigned long)(MMIO_IN32(pXGI->IOBase, 0x85c8)) @@ -326,7 +257,7 @@ extern unsigned int CurrentColorDepth; /********************************************************************** #define Volari_SetupSRCBase(base) \ - if (G2CmdQueLen <= 0) Volari_Idle;\ + if (G2CmdQueLen <= 0) Volari_Idle(pXGI);\ MMIO_OUT32(pXGI->IOBase, BR(0), base);\ G2CmdQueLen --; **********************************************************************/ @@ -359,7 +290,7 @@ extern unsigned int CurrentColorDepth; /*********************************************************************** #define Volari_SetupSRCPitch(pitch) \ - if (G2CmdQueLen <= 0) Volari_Idle;\ + if (G2CmdQueLen <= 0) Volari_Idle(pXGI);\ MMIO_OUT16(pXGI->IOBase, BR(1), pitch);\ G2CmdQueLen --; @@ -392,7 +323,7 @@ extern unsigned int CurrentColorDepth; /*********************************************************************** #define Volari_SetupSRCXY(x,y) \ - if (G2CmdQueLen <= 0) Volari_Idle;\ + if (G2CmdQueLen <= 0) Volari_Idle(pXGI);\ MMIO_OUT32(pXGI->IOBase, BR(2), (x)<<16 | (y) );\ G2CmdQueLen --; ***********************************************************************/ @@ -424,7 +355,7 @@ extern unsigned int CurrentColorDepth; /*********************************************************************** #define Volari_SetupDSTBase(base) \ - if (G2CmdQueLen <= 0) Volari_Idle;\ + if (G2CmdQueLen <= 0) Volari_Idle(pXGI);\ MMIO_OUT32(pXGI->IOBase, BR(4), base);\ G2CmdQueLen --; @@ -457,7 +388,7 @@ extern unsigned int CurrentColorDepth; /*********************************************************************** #define Volari_SetupDSTXY(x,y) \ - if (G2CmdQueLen <= 0) Volari_Idle;\ + if (G2CmdQueLen <= 0) Volari_Idle(pXGI);\ MMIO_OUT32(pXGI->IOBase, BR(3), (x)<<16 | (y) );\ G2CmdQueLen --; @@ -490,7 +421,7 @@ extern unsigned int CurrentColorDepth; /*********************************************************************** #define Volari_SetupDSTRect(x,y) \ - if (G2CmdQueLen <= 0) Volari_Idle;\ + if (G2CmdQueLen <= 0) Volari_Idle(pXGI);\ MMIO_OUT32(pXGI->IOBase, BR(5), (y)<<16 | (x) );\ G2CmdQueLen --; @@ -524,7 +455,7 @@ extern unsigned int CurrentColorDepth; /*********************************************************************** #define Volari_SetupDSTColorDepth(bpp) \ - if (G2CmdQueLen <= 0) Volari_Idle;\ + if (G2CmdQueLen <= 0) Volari_Idle(pXGI);\ MMIO_OUT16(pXGI->IOBase, BR(1)+2, bpp);\ G2CmdQueLen --; ***********************************************************************/ @@ -534,7 +465,7 @@ extern unsigned int CurrentColorDepth; /*********************************************************************** #define Volari_SetupRect(w,h) \ - if (G2CmdQueLen <= 0) Volari_Idle;\ + if (G2CmdQueLen <= 0) Volari_Idle(pXGI);\ MMIO_OUT32(pXGI->IOBase, BR(6), (h)<<16 | (w) );\ G2CmdQueLen --; ***********************************************************************/ @@ -566,25 +497,25 @@ extern unsigned int CurrentColorDepth; /*********************************************************************** #define Volari_SetupPATFG(color) \ - if (G2CmdQueLen <= 0) Volari_Idle;\ + if (G2CmdQueLen <= 0) Volari_Idle(pXGI);\ MMIO_OUT32(pXGI->IOBase, BR(7), color);\ G2CmdQueLen --; ***********************************************************************/ /*********************************************************************** #define Volari_SetupPATBG(color) \ - if (G2CmdQueLen <= 0) Volari_Idle;\ + if (G2CmdQueLen <= 0) Volari_Idle(pXGI);\ MMIO_OUT32(pXGI->IOBase, BR(8), color);\ G2CmdQueLen --; ***********************************************************************/ /*********************************************************************** #define Volari_SetupSRCFG(color) \ - if (G2CmdQueLen <= 0) Volari_Idle;\ + if (G2CmdQueLen <= 0) Volari_Idle(pXGI);\ MMIO_OUT32(pXGI->IOBase, BR(9), color);\ G2CmdQueLen --; ***********************************************************************/ /*********************************************************************** #define Volari_SetupSRCBG(color) \ - if (G2CmdQueLen <= 0) Volari_Idle;\ + if (G2CmdQueLen <= 0) Volari_Idle(pXGI);\ MMIO_OUT32(pXGI->IOBase, BR(10), color);\ G2CmdQueLen --; ***********************************************************************/ @@ -692,7 +623,7 @@ extern unsigned int CurrentColorDepth; /*********************************************************************** #define Volari_SetupMONOPAT(p0,p1) \ - if (G2CmdQueLen <= 1) Volari_Idle;\ + if (G2CmdQueLen <= 1) Volari_Idle(pXGI);\ MMIO_OUT32(pXGI->IOBase, BR(11), p0);\ MMIO_OUT32(pXGI->IOBase, BR(12), p1);\ G2CmdQueLen =G2CmdQueLen-2; @@ -749,13 +680,13 @@ extern unsigned int CurrentColorDepth; } /*********************************************************************** #define Volari_SetupClipLT(left,top) \ - if (G2CmdQueLen <= 0) Volari_Idle;\ + if (G2CmdQueLen <= 0) Volari_Idle(pXGI);\ MMIO_OUT32(pXGI->IOBase, BR(13), ((left) & 0xFFFF) | (top)<<16 );\ G2CmdQueLen--; ***********************************************************************/ /*********************************************************************** #define Volari_SetupClipRB(right,bottom) \ - if (G2CmdQueLen <= 0) Volari_Idle;\ + if (G2CmdQueLen <= 0) Volari_Idle(pXGI);\ MMIO_OUT32(pXGI->IOBase, BR(14), ((right) & 0xFFFF) | (bottom)<<16 );\ G2CmdQueLen --; ***********************************************************************/ @@ -843,7 +774,7 @@ extern unsigned int CurrentColorDepth; pXGI->CommandReg |= (flags); #define Volari_DoCMD \ - if (G2CmdQueLen <= 1) Volari_Idle;\ + if (G2CmdQueLen <= 1) Volari_Idle(pXGI);\ MMIO_OUT32(pXGI->IOBase, BR(15), pXGI->CommandReg); \ MMIO_OUT32(pXGI->IOBase, BR(16), 0);\ G2CmdQueLen =G2CmdQueLen-2; @@ -851,27 +782,27 @@ extern unsigned int CurrentColorDepth; /*********************************************************************** #define Volari_SetupX0Y0(x,y) \ - if (G2CmdQueLen <= 0) Volari_Idle;\ + if (G2CmdQueLen <= 0) Volari_Idle(pXGI);\ MMIO_OUT32(pXGI->IOBase, BR(2), (y)<<16 | (x) );\ G2CmdQueLen --; #define Volari_SetupX1Y1(x,y) \ - if (G2CmdQueLen <= 0) Volari_Idle;\ + if (G2CmdQueLen <= 0) Volari_Idle(pXGI);\ MMIO_OUT32(pXGI->IOBase, BR(3), (y)<<16 | (x) );\ G2CmdQueLen --; #define Volari_SetupLineCount(c) \ - if (G2CmdQueLen <= 0) Volari_Idle;\ + if (G2CmdQueLen <= 0) Volari_Idle(pXGI);\ MMIO_OUT16(pXGI->IOBase, BR(6), c);\ G2CmdQueLen --; #define Volari_SetupStylePeriod(p) \ - if (G2CmdQueLen <= 0) Volari_Idle;\ + if (G2CmdQueLen <= 0) Volari_Idle(pXGI);\ MMIO_OUT16(pXGI->IOBase, BR(6)+2, p);\ G2CmdQueLen --; #define Volari_SetupStyleLow(ls) \ - if (G2CmdQueLen <= 0) Volari_Idle;\ + if (G2CmdQueLen <= 0) Volari_Idle(pXGI);\ MMIO_OUT32(pXGI->IOBase, BR(11), ls);\ G2CmdQueLen --; #define Volari_SetupStyleHigh(ls) \ - if (G2CmdQueLen <= 0) Volari_Idle;\ + if (G2CmdQueLen <= 0) Volari_Idle(pXGI);\ MMIO_OUT32(pXGI->IOBase, BR(12), ls);\ G2CmdQueLen --; ***********************************************************************/ diff --git a/src/xgi_dac.c b/src/xgi_dac.c index 7212164..5dbb7db 100644 --- a/src/xgi_dac.c +++ b/src/xgi_dac.c @@ -370,30 +370,14 @@ PDEBUG(ErrorF("--- Volari_Restore(). \n")) ; #if 1 /* Volari_DisableAccelerator(pScrn) ; */ - -#ifdef DEBUG -/* - PDEBUG(ErrorF("--- MMIO Info. \n")) ; - for( i = 0x85c0 ;i <= 0x85CC ; i+=4 ) - { - ErrorF("MMIO[0x%04lX] = 0x%08X\n", i, MMIO_IN32(pXGI->IOBase,i)) ; - } -*/ -#endif #else inXGIIDXREG(XGISR, 0x1E, temp); if (temp & 0x42) { - while( (MMIO_IN32(pXGI->IOBase, 0x85CC) & 0x80000000) != 0x80000000){}; - while( (MMIO_IN32(pXGI->IOBase, 0x85CC) & 0x80000000) != 0x80000000){}; - while( (MMIO_IN32(pXGI->IOBase, 0x85CC) & 0x80000000) != 0x80000000){}; + Volari_Idle(pXGI); } PDEBUG(XGIDumpRegs(pScrn)) ; - temp = MMIO_IN32(pXGI->IOBase,0x85CC) ; -/* ErrorF( "\npXGI->IOBase = 0x%lX, [85CC] = 0x%lX\n", */ - (unsigned long)(pXGI->IOBase), temp ) ; - outXGIIDXREG(XGICR, 0x55, 0) ; andXGIIDXREG(XGISR, 0x1E, ~0xC2) ; diff --git a/src/xgi_dri.c b/src/xgi_dri.c index 1219164..8d4eb5a 100644 --- a/src/xgi_dri.c +++ b/src/xgi_dri.c @@ -568,7 +568,7 @@ XGIDRIFinishScreenInit(ScreenPtr pScreen) - Volari_Idle + Volari_Idle(pXGI); } return DRIFinishScreenInit(pScreen); @@ -592,7 +592,7 @@ XGIDRISwapContext(ScreenPtr pScreen, DRISyncType syncType, *(unsigned int *)(pXGI->IOBase + 0x8B60) = -1; */ - Volari_Idle + Volari_Idle(pXGI); } static void @@ -602,7 +602,7 @@ XGIDRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index) ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; XGIPtr pXGI = XGIPTR(pScrn); - Volari_Idle + Volari_Idle(pXGI); } static void @@ -613,7 +613,7 @@ XGIDRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg, ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; XGIPtr pXGI = XGIPTR(pScrn); - Volari_Idle + Volari_Idle(pXGI); } /*******************************************************************************