Refactor code that selects max wait iterations to its own function

Move code that selects the maximum wait iterations out of Volari_Wait
into Volari_SetDefaultIdleWait.  This function is called from
XGIModeInit.  The win here is that we can eliminate the Current*
global variables.
This commit is contained in:
Ian Romanick
2007-06-25 16:12:05 -07:00
parent 34069dec0a
commit b03d7713bb
4 changed files with 38 additions and 59 deletions

View File

@@ -754,6 +754,11 @@ typedef struct {
XGI_DSReg SRList[ExtRegSize] ;
XGI_DSReg CRList[ExtRegSize] ;
/**
* Total number of iterations to wait in \c Volari_Idle.
*/
unsigned int idle_wait_count;
//:::: for capture
Bool v4l_videoin;
int v4l_devnum; /* v4l device number, 0,1,2....*/

View File

@@ -129,63 +129,47 @@ static void dump_cq_read_pointer(unsigned int cqrp)
#endif /* DEBUG */
void Volari_SetDefaultIdleWait(XGIPtr pXGI, unsigned HDisplay,
unsigned depth)
{
static const unsigned wait_table[5][4] = {
{ 1, 1, 1, 1 },
{ 65535, 1, 1000, 3000 },
{ 65535, 160, 1200, 4000 },
{ 65535, 200, 1600, 6000 },
{ 65535, 500, 2000, 8000 }
};
if (pXGI->Chipset == PCI_CHIP_XGIXG20) {
unsigned i;
switch (HDisplay) {
case 640: i = 1; break;
case 800: i = 2; break;
case 1024: i = 3; break;
case 1280: i = 4; break;
default: i = 0; break;
}
pXGI->idle_wait_count = wait_table[i][3 & (depth / 8)];
}
else {
pXGI->idle_wait_count = 65535;
}
}
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++) {
for (i = 0; i < pXGI->idle_wait_count; i++) {
cqrp = MMIO_IN32(pXGI->IOBase, 0x85CC);
if (cqrp & IDLE_ALL) {
bIdle = 1;

View File

@@ -124,11 +124,8 @@ int G2CmdQueLen;
int Alignment ;
/* int GBCount = 0 ; */
/* Jong Lin 08-26-2005 */
extern unsigned int CurrentHDisplay;
extern unsigned int CurrentVDisplay;
extern unsigned int CurrentColorDepth;
extern void Volari_SetDefaultIdleWait(XGIPtr pXGI, unsigned HDisplay,
unsigned depth);
extern void Volari_Idle(XGIPtr pXGI);
#define Volari_GetSwWP() (unsigned long)(*(pXGI->pCQ_shareWritePort))

View File

@@ -106,11 +106,6 @@ void Volari_EnableAccelerator(ScrnInfoPtr pScrn);
static int XGIEntityIndex = -1;
#endif
/* Jong Lin 08-26-2005; keep current mode info */
unsigned int CurrentHDisplay;
unsigned int CurrentVDisplay;
unsigned int CurrentColorDepth;
/*
* This is intentionally screen-independent. It indicates the binding
* choice made in the first PreInit.
@@ -3803,9 +3798,7 @@ XGIModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
PDEBUG(ErrorF("XGIModeInit Color Depth (%d) \n", pScrn->depth));
/* Jong Lin 08-26-2005; save current mode */
CurrentHDisplay = mode->HDisplay;
CurrentVDisplay = mode->VDisplay;
CurrentColorDepth = pScrn->depth;
Volari_SetDefaultIdleWait(pXGI, mode->HDisplay, pScrn->depth);
andXGIIDXREG(XGICR, 0x11, 0x7f); /* Unlock CRTC registers */