summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <Alan.Coopersmith@sun.com>2006-03-14 23:51:52 +0000
committerAlan Coopersmith <Alan.Coopersmith@sun.com>2006-03-14 23:51:52 +0000
commit24d5661d2c703582e44ce140d0eb7251433e1ad0 (patch)
tree596fcffe716a6fb4f8c4d56c0378493298ba38bb
parent4e31187407a6dfe53a9d15f06c8c4584e20125ba (diff)
Version 0.80 from ASPEED Technology Inc. (Fixed get video buffer size
incorrect issue) Bugzilla #4937 <https://bugs.freedesktop.org/show_bug.cgi?id=4937> Attachment #4932 <https://bugs.freedesktop.org/attachment.cgi?id=4932>
-rw-r--r--ChangeLog13
-rw-r--r--src/ast.h5
-rw-r--r--src/ast_2dtool.c463
-rw-r--r--src/ast_2dtool.h102
-rw-r--r--src/ast_accel.c11
-rw-r--r--src/ast_driver.c35
-rw-r--r--src/ast_vgatool.c71
7 files changed, 228 insertions, 472 deletions
diff --git a/ChangeLog b/ChangeLog
index 1af881f..0509827 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,19 @@
2006-03-14 Alan Coopersmith <alan.coopersmith@sun.com>
* src/ast.h:
+ * src/ast_2dtool.c:
+ * src/ast_2dtool.h:
+ * src/ast_accel.c:
+ * src/ast_driver.c:
+ * src/ast_vgatool.c:
+ Version 0.80 from ASPEED Technology Inc.
+ (Fixed get video buffer size incorrect issue)
+ Bugzilla #4937 <https://bugs.freedesktop.org/show_bug.cgi?id=4937>
+ Attachment #4932 <https://bugs.freedesktop.org/attachment.cgi?id=4932>
+
+2006-03-14 Alan Coopersmith <alan.coopersmith@sun.com>
+
+ * src/ast.h:
* src/ast_driver.c:
* src/ast_vgatool.c:
Version 0.62 from ASPEED Technology Inc.
diff --git a/src/ast.h b/src/ast.h
index 16ec028..2ec9846 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -38,7 +38,7 @@
#define AST_NAME "AST1000/2000"
#define AST_DRIVER_NAME "ast"
#define AST_MAJOR_VERSION 0
-#define AST_MINOR_VERSION 62
+#define AST_MINOR_VERSION 80
#define AST_PATCH_VERSION 0
#define AST_VERSION \
((AST_MAJOR_VERSION << 20) | (AST_MINOR_VERSION << 10) | AST_PATCH_VERSION)
@@ -47,6 +47,7 @@
#define DEFAULT_VIDEOMEM_SIZE 0x00800000
#define DEFAULT_MMIO_SIZE 0x00020000
#define DEFAULT_CMDQ_SIZE 0x00100000
+#define MIN_CMDQ_SIZE 0x00040000
#define CMD_QUEUE_GUARD_BAND 0x00000020
#define DEFAULT_HWC_NUM 0x00000002
@@ -148,7 +149,7 @@ typedef struct _ASTRec {
IOADDRESS IODBase; /* Base of PIO memory area */
IOADDRESS PIOOffset;
IOADDRESS RelocateIO;
-
+
VIDEOMODE VideoModeInfo;
ASTRegRec SavedReg;
CMDQINFO CMDQInfo;
diff --git a/src/ast_2dtool.c b/src/ast_2dtool.c
index b539ea5..22f0b5b 100644
--- a/src/ast_2dtool.c
+++ b/src/ast_2dtool.c
@@ -64,12 +64,13 @@ void vDisable2D(ScrnInfoPtr pScrn, ASTRecPtr pAST);
void vWaitEngIdle(ScrnInfoPtr pScrn, ASTRecPtr pAST);
UCHAR *pjRequestCMDQ(ASTRecPtr pAST, ULONG ulDataLen);
Bool bGetLineTerm(_LINEInfo *LineInfo, LINEPARAM *dsLineParam);
-LONG lGetDiaRg(LONG GFracX, LONG GFracY);
Bool
bInitCMDQInfo(ScrnInfoPtr pScrn, ASTRecPtr pAST)
{
+ ScreenPtr pScreen;
+
pAST->CMDQInfo.pjCmdQBasePort = pAST->MMIOVirtualAddr+ 0x8044;
pAST->CMDQInfo.pjWritePort = pAST->MMIOVirtualAddr+ 0x8048;
pAST->CMDQInfo.pjReadPort = pAST->MMIOVirtualAddr+ 0x804C;
@@ -78,23 +79,35 @@ bInitCMDQInfo(ScrnInfoPtr pScrn, ASTRecPtr pAST)
/* CMDQ mode Init */
if (!pAST->MMIO2D) {
pAST->CMDQInfo.ulCMDQType = VM_CMD_QUEUE;
-
- ScreenPtr pScreen;
pScreen = screenInfo.screens[pScrn->scrnIndex];
- pAST->pCMDQPtr = xf86AllocateOffscreenLinear (pScreen, 1024*1024, 8, NULL, NULL, NULL);
-
- if (!pAST->pCMDQPtr) {
+ do {
+ pAST->pCMDQPtr = xf86AllocateOffscreenLinear (pScreen, pAST->CMDQInfo.ulCMDQSize, 8, NULL, NULL, NULL);
+
+ if (pAST->pCMDQPtr) break;
+
+ pAST->CMDQInfo.ulCMDQSize >>= 1;
+
+ } while (pAST->CMDQInfo.ulCMDQSize >= MIN_CMDQ_SIZE);
+
+ if (pAST->pCMDQPtr)
+ {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,"Allocate CMDQ size is %ld kbyte \n", (unsigned long) (pAST->CMDQInfo.ulCMDQSize/1024));
+
+ pAST->CMDQInfo.ulCMDQOffsetAddr = pAST->pCMDQPtr->offset*((pScrn->bitsPerPixel + 1) / 8);
+ pAST->CMDQInfo.pjCMDQVirtualAddr = pAST->FBVirtualAddr + pAST->CMDQInfo.ulCMDQOffsetAddr;
+
+ pAST->CMDQInfo.ulCurCMDQueueLen = pAST->CMDQInfo.ulCMDQSize - CMD_QUEUE_GUARD_BAND;
+ pAST->CMDQInfo.ulCMDQMask = pAST->CMDQInfo.ulCMDQSize - 1 ;
+
+ }
+ else
+ {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"Allocate CMDQ failed \n");
pAST->MMIO2D = TRUE; /* set to MMIO mode if CMDQ allocate failed */
}
- pAST->CMDQInfo.ulCMDQOffsetAddr = pAST->pCMDQPtr->offset*((pScrn->bitsPerPixel + 1) / 8);
- pAST->CMDQInfo.pjCMDQVirtualAddr = pAST->FBVirtualAddr + pAST->CMDQInfo.ulCMDQOffsetAddr;
-
- pAST->CMDQInfo.ulCurCMDQueueLen = pAST->CMDQInfo.ulCMDQSize - CMD_QUEUE_GUARD_BAND;
- pAST->CMDQInfo.ulCMDQMask = pAST->CMDQInfo.ulCMDQSize - 1 ;
}
/* MMIO mode init */
@@ -348,16 +361,9 @@ ASTRecPtr pAST, ULONG ulDataLen)
Bool bGetLineTerm(_LINEInfo *LineInfo, LINEPARAM *dsLineParam)
{
LONG GAbsX, GAbsY, GXInc, GYInc, GSlopeOne, GXMajor;
- Bool tmpFlipH=0, tmpFlipV=0, tmpFlipD=0;
- LONG tmpStartX, tmpStartY, tmpFStartX, tmpFStartY;
- LONG GFAbsX, GFAbsY, GFStartX, GFStartY, GFFracX[2], GFFracY[2];
- LONG flag, GXRoundDown, GYRoundDown, GFlipH, GFlipV, GFlipD;
- LONG tmpx, tmpy, GFGamma;
- LONG i, region, tmpDiaRg[2], tmpGFX1, GFAdd, GNTWidth;
- LONG tmp1GFX, tmp1GFY, tmp2GFX, tmp2GFY, tmpGK1Term, tmpGK2Term, tmpGNTErr;
- LONG GFX, GFY, GK1Term, GK2Term, GNTErr;
+ LONG MM, mm, Error0, K1, K2;
- /*Init Calucate */
+ /* Init */
#ifdef LONG64
GAbsX = abs (LineInfo->X1 - LineInfo->X2);
GAbsY = abs (LineInfo->Y1 - LineInfo->Y2);
@@ -371,173 +377,30 @@ Bool bGetLineTerm(_LINEInfo *LineInfo, LINEPARAM *dsLineParam)
GSlopeOne = (GAbsX ==GAbsY) ? 1:0;
GXMajor = (GAbsX >= GAbsY) ? 1:0;
- /*Flip */
- tmpStartX = LineInfo->X1;
- tmpStartY = LineInfo->Y1;
- if (!GXInc)
- {
- tmpStartX = ~LineInfo->X1+ 1;
- tmpFlipH = 1;
- }
-
- if (!GYInc)
- {
- tmpStartY = ~LineInfo->Y1 + 1;
- tmpFlipV = 1;
- }
-
- if (GXMajor ==0)
+ /* Calculate */
+ if (GXMajor)
{
- tmpFlipD = 1;
- tmpFStartX = tmpStartY;
- tmpFStartY = tmpStartX;
- GFAbsX = GAbsY;
- GFAbsY = GAbsX;
+ MM = GAbsX;
+ mm = GAbsY;
}
else
{
- tmpFlipD = 0;
- tmpFStartX = tmpStartX;
- tmpFStartY = tmpStartY;
- GFAbsX = GAbsX;
- GFAbsY = GAbsY;
- }
-
- GFStartX = tmpFStartX >> 4;
- GFStartY = tmpFStartY >> 4;
- GFFracX[0] = tmpFStartX & 0xF;
- GFFracY[0] = tmpFStartY & 0xF;
-
- /* Flag = GSlopeOne & tmpFlipH & tmpFlipV & tmpFlipD */
- flag = (GSlopeOne<<3) + (tmpFlipH<<2) + (tmpFlipV<<1) + tmpFlipD;
- switch(flag) /* GSlopeOne tmpFlipH tmpFlipV tmpFlipD */
- {
- case 0: /* 0 0 0 0 */
- case 1: /* 0 0 0 1 */
- GXRoundDown = 1;
- GYRoundDown = 1;
- GFlipH = tmpFlipH;
- GFlipV = tmpFlipV;
- GFlipD = tmpFlipD;
- break;
- case 2: /* 0 0 1 0 */
- case 5: /* 0 1 0 1 */
- case 10: /* 1 0 1 0 */
- case 14: /* 1 1 1 0 */
- GXRoundDown = 1;
- GYRoundDown = 0;
- GFlipH = tmpFlipH;
- GFlipV = tmpFlipV;
- GFlipD = tmpFlipD;
- break;
- case 3: /* 0 0 1 1 */
- case 4: /* 0 1 0 0 */
- case 8: /* 1 0 0 0 */
- case 12: /* 1 1 0 0 */
- GXRoundDown = 0;
- GYRoundDown = 1;
- GFlipH = tmpFlipH;
- GFlipV = tmpFlipV;
- GFlipD = tmpFlipD;
- break;
- case 6: /* 0 1 1 0 */
- case 7: /* 0 1 1 1 */
- GXRoundDown = 0;
- GYRoundDown = 0;
- GFlipH = tmpFlipH;
- GFlipV = tmpFlipV;
- GFlipD = tmpFlipD;
- break;
- /* case 9, 11, 13, 15 */
- default:
- GXRoundDown = 1; /* 1 0 0 1 */
- GYRoundDown = 1; /* 1 0 1 1 */
- GFlipH = 1; /* 1 1 0 1 */
- GFlipV = 1; /* 1 1 1 1 */
- GFlipD = 1;
- }
-
- /*Err */
- tmpx = (GFFracY[0] +8) * GFAbsX;
- tmpy = GFFracX[0] * GFAbsY;
- if(GYRoundDown==1)
- GFGamma=(signed)(tmpx - tmpy - 1) >> 4;
- else
- GFGamma=(signed)(tmpx - tmpy) >> 4;
-
- /*GIQ */
- GFFracX[1] = (GFFracX[0] + GFAbsX) & 0xF;
- GFFracY[1] = (GFFracY[0] + GFAbsY) & 0xF;
-
- for (i=0; i<2; i++)
- {
- tmpDiaRg[i] = 0;
- region = lGetDiaRg(GFFracX[i], GFFracY[i]);
-
- if(region==1 && GXRoundDown==0)
- tmpDiaRg[i] |= 1;
-
- if(region==2 && (GSlopeOne==0 || GXRoundDown==0))
- tmpDiaRg[i] |= 1;
-
- if(region==3)
- tmpDiaRg[i] |= 1;
-
- }
-
- tmpGFX1 =((signed)(GFFracX[0]+GFAbsX)>>4)-1+tmpDiaRg[1]; /* signed left shifter!! */
- GFAdd = tmpDiaRg[0];
- GNTWidth = tmpGFX1 - tmpDiaRg[0] + 1;
-
- /* FXY */
- tmpGK1Term = GFAbsY;
- tmpGK2Term = GFAbsY - GFAbsX;
-
- if(GFAdd==1){
- tmpGNTErr = GFGamma - GFAbsX + GFAbsY;
- }else{
- tmpGNTErr = GFGamma - GFAbsX;
- }
-
- tmp1GFX = GFStartX + GFAdd;
- if((signed)tmpGNTErr >= 0){
- tmp1GFY = GFStartY+1;
- GNTErr = tmpGNTErr + tmpGK2Term;
- }else{
- tmp1GFY = GFStartY;
- GNTErr = tmpGNTErr + tmpGK1Term;
- }
-
- if(GFlipD == 1){
- tmp2GFX = tmp1GFY;
- tmp2GFY = tmp1GFX;
- }else{
- tmp2GFX = tmp1GFX;
- tmp2GFY = tmp1GFY;
- }
-
- if(GFlipV == 1){
- GFY = ~tmp2GFY+1;
- }else{
- GFY = tmp2GFY;
- }
-
- if(GFlipH == 1){
- GFX = ~tmp2GFX+1;
- }else{
- GFX = tmp2GFX;
+ MM = GAbsY;
+ mm = GAbsX;
}
- GK1Term = tmpGK1Term;
- GK2Term = tmpGK2Term;
+ Error0 = (signed) (2*mm - MM);
+
+ K1 = 2* mm;
+ K2 = (signed) (2*mm - 2*MM);
/*save the Param to dsLineParam */
- dsLineParam->dsLineX = (USHORT) GFX;
- dsLineParam->dsLineY = (USHORT) GFY;
- dsLineParam->dsLineWidth = (USHORT) GNTWidth;
- dsLineParam->dwErrorTerm = (ULONG) GNTErr;
- dsLineParam->dwK1Term = GK1Term;
- dsLineParam->dwK2Term = GK2Term;
+ dsLineParam->dsLineX = (USHORT) LineInfo->X1;
+ dsLineParam->dsLineY = (USHORT) LineInfo->Y1;
+ dsLineParam->dsLineWidth = (USHORT) MM;
+ dsLineParam->dwErrorTerm = (ULONG) Error0;
+ dsLineParam->dwK1Term = K1;
+ dsLineParam->dwK2Term = K2;
dsLineParam->dwLineAttributes = 0;
if (GXMajor) dsLineParam->dwLineAttributes |= LINEPARAM_XM;
@@ -548,248 +411,6 @@ Bool bGetLineTerm(_LINEInfo *LineInfo, LINEPARAM *dsLineParam)
}
-LONG lGetDiaRg(LONG GFracX, LONG GFracY)
-{
- LONG region;
-
- switch(GFracY)
- {
- case 0x0:
- switch(GFracX)
- {
- case 0x0:
- case 0x1:
- case 0x2:
- case 0x3:
- case 0x4:
- case 0x5:
- case 0x6:
- case 0x7:
- region=0;
- break;
- case 0x8:
- region=1;
- break;
- default:
- region=3;
- }
- break;
- case 0x1:
- switch(GFracX)
- {
- case 0x0:
- case 0x1:
- case 0x2:
- case 0x3:
- case 0x4:
- case 0x5:
- case 0x6:
- region=0;
- break;
- default:
- region=3;
- }
- break;
- case 0x2:
- switch(GFracX)
- {
- case 0x0:
- case 0x1:
- case 0x2:
- case 0x3:
- case 0x4:
- case 0x5:
- region=0; break;
- default:
- region=3;
- }
- break;
- case 0x3:
- switch(GFracX)
- {
- case 0x0:
- case 0x1:
- case 0x2:
- case 0x3:
- case 0x4:
- region=0;
- break;
- default:
- region=3;
- }
- break;
- case 0x4:
- switch(GFracX)
- {
- case 0x0:
- case 0x1:
- case 0x2:
- case 0x3:
- region=0;
- break;
- default:
- region=3;
- }
- break;
- case 0x5:
- switch(GFracX)
- {
- case 0x0:
- case 0x1:
- case 0x2:
- region=0; break;
- default:
- region=3;
- }
- break;
- case 0x6:
- switch(GFracX)
- {
- case 0x0:
- case 0x1:
- region=0;
- break;
- default:
- region=3;
- }
- break;
- case 0x7:
- switch(GFracX)
- {
- case 0x0:
- region=0;
- break;
- default:
- region=3;
- }
- break;
- case 0x8:
- switch(GFracX)
- {
- case 0x0:
- region=0;
- break;
- default:
- region=3;
- }
- break;
- case 0x9:
- switch(GFracX)
- {
- case 0x0:
- region=0;
- break;
- case 0x1:
- region=2;
- break;
- default:
- region=3;
- }
- break;
- case 0xa:
- switch(GFracX)
- {
- case 0x0:
- case 0x1:
- region=0;
- break;
- case 0x2:
- region=2;
- break;
- default:
- region=3;
- }
- break;
- case 0xb:
- switch(GFracX)
- {
- case 0x0:
- case 0x1:
- case 0x2:
- region=0;
- break;
- case 0x3:
- region=2;
- break;
- default:
- region=3;
- }
- break;
- case 0xc:
- switch(GFracX)
- {
- case 0x0:
- case 0x1:
- case 0x2:
- case 0x3:
- region=0;
- break;
- case 0x4:
- region=2;
- break;
- default:
- region=3;
- }
- break;
- case 0xd:
- switch(GFracX)
- {
- case 0x0:
- case 0x1:
- case 0x2:
- case 0x3:
- case 0x4:
- region=0;
- break;
- case 0x5:
- region=2;
- break;
- default:
- region=3;
- }
- break;
- case 0xe:
- switch(GFracX)
- {
- case 0x0:
- case 0x1:
- case 0x2:
- case 0x3:
- case 0x4:
- case 0x5:
- region=0;
- break;
- case 0x6:
- region=2;
- break;
- default:
- region=3;
- }
- break;
- default:
- switch(GFracX)
- {
- case 0x0:
- case 0x1:
- case 0x2:
- case 0x3:
- case 0x4:
- case 0x5:
- case 0x6:
- region=0;
- break;
- case 0x7:
- region=2;
- break;
- default:
- region=3;
- }
- }
-
- return (region);
-
-}
-
#endif /* end of Accel_2D */
diff --git a/src/ast_2dtool.h b/src/ast_2dtool.h
index 2539705..193d3cd 100644
--- a/src/ast_2dtool.h
+++ b/src/ast_2dtool.h
@@ -206,55 +206,93 @@ typedef struct {
/* MMIO 2D Macro */
#define ASTSetupSRCBase_MMIO(base) \
{ \
- *(ULONG *)(MMIOREG_SRC_BASE) = (ULONG) (base); \
+ do { \
+ *(ULONG *)(MMIOREG_SRC_BASE) = (ULONG) (base); \
+ } while (*(ULONG *)(MMIOREG_SRC_BASE) != (ULONG) (base)); \
}
#define ASTSetupSRCPitch_MMIO(pitch) \
{ \
- *(ULONG *)(MMIOREG_SRC_PITCH) = (ULONG)(pitch << 16); \
+ do { \
+ *(ULONG *)(MMIOREG_SRC_PITCH) = (ULONG)(pitch << 16); \
+ } while (*(ULONG *)(MMIOREG_SRC_PITCH) != (ULONG)(pitch << 16)); \
}
#define ASTSetupDSTBase_MMIO(base) \
{ \
- *(ULONG *)(MMIOREG_DST_BASE) = (ULONG)(base); \
+ do { \
+ *(ULONG *)(MMIOREG_DST_BASE) = (ULONG)(base); \
+ } while (*(ULONG *)(MMIOREG_DST_BASE) != (ULONG)(base)); \
}
#define ASTSetupDSTPitchHeight_MMIO(pitch, height) \
{ \
- *(ULONG *)(MMIOREG_DST_PITCH) = (ULONG)((pitch << 16) + ((height) & MAX_DST_HEIGHT)); \
+ ULONG dstpitch; \
+ dstpitch = (ULONG)((pitch << 16) + ((height) & MAX_DST_HEIGHT)); \
+ do { \
+ *(ULONG *)(MMIOREG_DST_PITCH) = dstpitch; \
+ } while (*(ULONG *)(MMIOREG_DST_PITCH) != dstpitch); \
}
#define ASTSetupDSTXY_MMIO(x, y) \
{ \
- *(ULONG *)(MMIOREG_DST_XY) = (ULONG)(((x & MAX_DST_X) << 16) + (y & MAX_DST_Y)); \
+ ULONG dstxy; \
+ dstxy = (ULONG)(((x & MAX_DST_X) << 16) + (y & MAX_DST_Y)); \
+ do { \
+ *(ULONG *)(MMIOREG_DST_XY) = dstxy; \
+ } while (*(ULONG *)(MMIOREG_DST_XY) != dstxy); \
}
#define ASTSetupSRCXY_MMIO(x, y) \
{ \
- *(ULONG *)(MMIOREG_SRC_XY) = (ULONG)(((x & MAX_SRC_X) << 16) + (y & MAX_SRC_Y)); \
+ ULONG srcxy; \
+ srcxy = (ULONG)(((x & MAX_SRC_X) << 16) + (y & MAX_SRC_Y)); \
+ do { \
+ *(ULONG *)(MMIOREG_SRC_XY) = srcxy; \
+ } while (*(ULONG *)(MMIOREG_SRC_XY) != srcxy); \
}
#define ASTSetupRECTXY_MMIO(x, y) \
{ \
- *(ULONG *)(MMIOREG_RECT_XY) = (ULONG)(((x & MAX_RECT_WIDTH) << 16) + (y & MAX_RECT_WIDTH)); \
+ ULONG rectxy; \
+ rectxy = (ULONG)(((x & MAX_RECT_WIDTH) << 16) + (y & MAX_RECT_WIDTH)); \
+ do { \
+ *(ULONG *)(MMIOREG_RECT_XY) = rectxy; \
+ } while (*(ULONG *)(MMIOREG_RECT_XY) != rectxy); \
}
#define ASTSetupFG_MMIO(color) \
{ \
- *(ULONG *)(MMIOREG_FG) = (ULONG)(color); \
+ do { \
+ *(ULONG *)(MMIOREG_FG) = (ULONG)(color); \
+ } while (*(ULONG *)(MMIOREG_FG) != (ULONG)(color)); \
}
#define ASTSetupBG_MMIO(color) \
{ \
- *(ULONG *)(MMIOREG_BG) = (ULONG)(color); \
+ do { \
+ *(ULONG *)(MMIOREG_BG) = (ULONG)(color); \
+ } while (*(ULONG *)(MMIOREG_BG) != (ULONG)(color)); \
}
#define ASTSetupMONO1_MMIO(pat) \
{ \
- *(ULONG *)(MMIOREG_MONO1) = (ULONG)(pat); \
+ do { \
+ *(ULONG *)(MMIOREG_MONO1) = (ULONG)(pat); \
+ } while (*(ULONG *)(MMIOREG_MONO1) != (ULONG)(pat)); \
}
#define ASTSetupMONO2_MMIO(pat) \
{ \
- *(ULONG *)(MMIOREG_MONO2) = (ULONG)(pat); \
+ do { \
+ *(ULONG *)(MMIOREG_MONO2) = (ULONG)(pat); \
+ } while (*(ULONG *)(MMIOREG_MONO2) != (ULONG)(pat)); \
}
#define ASTSetupCLIP1_MMIO(left, top) \
{ \
- *(ULONG *)(MMIOREG_CLIP1) = (ULONG)(((left & MAX_CLIP) << 16) + (top & MAX_CLIP)); \
+ ULONG clip1; \
+ clip1 = (ULONG)(((left & MAX_CLIP) << 16) + (top & MAX_CLIP)); \
+ do { \
+ *(ULONG *)(MMIOREG_CLIP1) = clip1; \
+ } while (*(ULONG *)(MMIOREG_CLIP1) != clip1); \
}
#define ASTSetupCLIP2_MMIO(right, bottom) \
{ \
- *(ULONG *)(MMIOREG_CLIP2) = (ULONG)(((right & MAX_CLIP) << 16) + (bottom & MAX_CLIP)); \
+ ULONG clip2; \
+ clip2 = (ULONG)(((right & MAX_CLIP) << 16) + (bottom & MAX_CLIP)); \
+ do { \
+ *(ULONG *)(MMIOREG_CLIP2) = clip2; \
+ } while (*(ULONG *)(MMIOREG_CLIP2) != clip2); \
}
#define ASTSetupCMDReg_MMIO(reg) \
{ \
@@ -262,37 +300,59 @@ typedef struct {
}
#define ASTSetupPatReg_MMIO(patreg, pat) \
{ \
- *(ULONG *)(MMIOREG_PAT + patreg*4) = (ULONG)(pat); \
+ do { \
+ *(ULONG *)(MMIOREG_PAT + patreg*4) = (ULONG)(pat); \
+ } while (*(ULONG *)(MMIOREG_PAT + patreg*4) != (ULONG)(pat)); \
}
/* Line CMD */
#define ASTSetupLineXY_MMIO(x, y) \
{ \
- *(ULONG *)(MMIOREG_LINE_XY) = (ULONG)(((x & MAX_LINE_X) << 16) + (y & MAX_LINE_Y)); \
+ ULONG linexy; \
+ linexy = (ULONG)(((x & MAX_LINE_X) << 16) + (y & MAX_LINE_Y)); \
+ do { \
+ *(ULONG *)(MMIOREG_LINE_XY) = linexy; \
+ } while (*(ULONG *)(MMIOREG_LINE_XY) != linexy); \
}
#define ASTSetupLineXMErrTerm_MMIO(xm, err) \
{ \
- *(ULONG *)(MMIOREG_LINE_Err) = (ULONG)((xm << 24) + (err & MAX_LINE_ERR)); \
+ ULONG lineerr; \
+ lineerr = (ULONG)((xm << 24) + (err & MAX_LINE_ERR)); \
+ do { \
+ *(ULONG *)(MMIOREG_LINE_Err) = lineerr; \
+ } while (*(ULONG *)(MMIOREG_LINE_Err) != lineerr); \
}
#define ASTSetupLineWidth_MMIO(width) \
{ \
- *(ULONG *)(MMIOREG_LINE_WIDTH) = (ULONG)((width & MAX_LINE_WIDTH) << 16); \
+ ULONG linewidth; \
+ linewidth = (ULONG)((width & MAX_LINE_WIDTH) << 16); \
+ do { \
+ *(ULONG *)(MMIOREG_LINE_WIDTH) = linewidth; \
+ } while (*(ULONG *)(MMIOREG_LINE_WIDTH) != linewidth); \
}
#define ASTSetupLineK1Term_MMIO(err) \
{ \
- *(ULONG *)(MMIOREG_LINE_K1) = (ULONG)(err & MAX_LINE_K1); \
+ do { \
+ *(ULONG *)(MMIOREG_LINE_K1) = (ULONG)(err & MAX_LINE_K1); \
+ } while (*(ULONG *)(MMIOREG_LINE_K1) != (ULONG)(err & MAX_LINE_K1)); \
}
#define ASTSetupLineK2Term_MMIO(err) \
{ \
- *(ULONG *)(MMIOREG_LINE_K2) = (ULONG)(err & MAX_LINE_K2); \
+ do { \
+ *(ULONG *)(MMIOREG_LINE_K2) = (ULONG)(err & MAX_LINE_K2); \
+ } while (*(ULONG *)(MMIOREG_LINE_K2) != (ULONG)(err & MAX_LINE_K2)); \
}
#define ASTSetupLineStyle1_MMIO(pat) \
{ \
- *(ULONG *)(MMIOREG_LINE_STYLE1) = (ULONG)(pat); \
+ do { \
+ *(ULONG *)(MMIOREG_LINE_STYLE1) = (ULONG)(pat); \
+ } while (*(ULONG *)(MMIOREG_LINE_STYLE1) != (ULONG)(pat)); \
}
#define ASTSetupLineStyle2_MMIO(pat) \
{ \
- *(ULONG *)(MMIOREG_LINE_STYLE2) = (ULONG)(pat); \
+ do { \
+ *(ULONG *)(MMIOREG_LINE_STYLE2) = (ULONG)(pat); \
+ } while (*(ULONG *)(MMIOREG_LINE_STYLE2) != (ULONG)(pat)); \
}
/* CMDQ Mode Macro */
diff --git a/src/ast_accel.c b/src/ast_accel.c
index b47db38..1e327c6 100644
--- a/src/ast_accel.c
+++ b/src/ast_accel.c
@@ -100,7 +100,6 @@ int ASTXAAPatternROP[16]=
extern void vWaitEngIdle(ScrnInfoPtr pScrn, ASTRecPtr pAST);
extern UCHAR *pjRequestCMDQ(ASTRecPtr pAST, ULONG ulDataLen);
extern Bool bGetLineTerm(_LINEInfo *LineInfo, LINEPARAM *dsLineParam);
-extern LONG lGetDiaRg(LONG GFracX, LONG GFracY);
/* Prototype type declaration */
Bool ASTAccelInit(ScreenPtr pScreen);
@@ -667,11 +666,6 @@ static void ASTSubsequentSolidTwoPointLine(ScrnInfoPtr pScrn,
y2 -= miny;
}
- LineInfo.X1 = x1 << 4;
- LineInfo.X2 = x2 << 4;
- LineInfo.Y1 = y1 << 4;
- LineInfo.Y2 = y2 << 4;
-
bGetLineTerm(&LineInfo, &dsLineParam); /* Get Line Parameter */
if (dsLineParam.dwLineAttributes & LINEPARAM_X_DEC)
@@ -822,11 +816,6 @@ ASTSubsequentDashedTwoPointLine(ScrnInfoPtr pScrn,
y2 -= miny;
}
- LineInfo.X1 = x1 << 4;
- LineInfo.X2 = x2 << 4;
- LineInfo.Y1 = y1 << 4;
- LineInfo.Y2 = y2 << 4;
-
bGetLineTerm(&LineInfo, &dsLineParam); /* Get Line Parameter */
if (dsLineParam.dwLineAttributes & LINEPARAM_X_DEC)
diff --git a/src/ast_driver.c b/src/ast_driver.c
index a0bf8f3..ac4c453 100644
--- a/src/ast_driver.c
+++ b/src/ast_driver.c
@@ -63,6 +63,7 @@ extern void ASTUnmapMMIO(ScrnInfoPtr pScrn);
extern void vASTOpenKey(ScrnInfoPtr pScrn);
extern Bool bASTRegInit(ScrnInfoPtr pScrn);
extern ULONG GetVRAMInfo(ScrnInfoPtr pScrn);
+extern ULONG GetMaxDCLK(ScrnInfoPtr pScrn);
extern void vASTLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, VisualPtr pVisual);
extern void ASTDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags);
extern void vSetStartAddressCRT1(ASTRecPtr pAST, ULONG base);
@@ -133,7 +134,7 @@ typedef enum {
OPTION_HWC_NUM,
OPTION_ENG_CAPS,
OPTION_DBG_SELECT,
- OPTION_NO_DDC,
+ OPTION_NO_DDC
} ASTOpts;
static const OptionInfoRec ASTOptions[] = {
@@ -610,6 +611,20 @@ ASTPreInit(ScrnInfoPtr pScrn, int flags)
pAST->FbMapSize = pScrn->videoRam * 1024;
pAST->MMIOMapSize = DEFAULT_MMIO_SIZE;
+ /* Map resource */
+ if (!ASTMapMem(pScrn)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Map FB Memory Failed \n");
+ return FALSE;
+ }
+
+ if (!ASTMapMMIO(pScrn)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Map Memory Map IO Failed \n");
+ return FALSE;
+ }
+
+ pScrn->memPhysBase = (ULONG)pAST->FBPhysAddr;
+ pScrn->fbOffset = 0;
+
/* Do DDC
* should be done after xf86CollectOptions
*/
@@ -619,11 +634,11 @@ ASTPreInit(ScrnInfoPtr pScrn, int flags)
clockRanges = xnfcalloc(sizeof(ClockRange), 1);
clockRanges->next = NULL;
clockRanges->minClock = 9500;
- clockRanges->maxClock = 165000;
+ clockRanges->maxClock = GetMaxDCLK(pScrn) * 1000;
clockRanges->clockIndex = -1;
clockRanges->interlaceAllowed = FALSE;
clockRanges->doubleScanAllowed = FALSE;
-
+
i = xf86ValidateModes(pScrn, pScrn->monitor->Modes,
pScrn->display->modes, clockRanges,
0, 320, 1600, 8 * pScrn->bitsPerPixel,
@@ -732,21 +747,7 @@ ASTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
pScrn = xf86Screens[pScreen->myNum];
pAST = ASTPTR(pScrn);
hwp = VGAHWPTR(pScrn);
-
- if (!ASTMapMem(pScrn)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Map FB Memory Failed \n");
- return FALSE;
- }
-
- if (!ASTMapMMIO(pScrn)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Map Memory Map IO Failed \n");
- return FALSE;
- }
-
- pScrn->memPhysBase = (ULONG)pAST->FBPhysAddr;
- pScrn->fbOffset = 0;
-
/* if (!pAST->noAccel) */
{
/* AvailFBSize = pAST->FbMapSize - pAST->CMDQInfo.ulCMDQSize; */
diff --git a/src/ast_vgatool.c b/src/ast_vgatool.c
index 85b105c..fc761ab 100644
--- a/src/ast_vgatool.c
+++ b/src/ast_vgatool.c
@@ -58,6 +58,7 @@
void vASTOpenKey(ScrnInfoPtr pScrn);
Bool bASTRegInit(ScrnInfoPtr pScrn);
ULONG GetVRAMInfo(ScrnInfoPtr pScrn);
+ULONG GetMaxDCLK(ScrnInfoPtr pScrn);
void vAST1000DisplayOn(ASTRecPtr pAST);
void vAST1000DisplayOff(ASTRecPtr pAST);
void vSetStartAddressCRT1(ASTRecPtr pAST, ULONG base);
@@ -111,6 +112,76 @@ GetVRAMInfo(ScrnInfoPtr pScrn)
}
+ULONG
+GetMaxDCLK(ScrnInfoPtr pScrn)
+{
+ ASTRecPtr pAST = ASTPTR(pScrn);
+ UCHAR jReg;
+ ULONG ulData, ulData2;
+ ULONG ulRefPLL, ulDeNumerator, ulNumerator, ulDivider;
+ ULONG ulDRAMBusWidth, ulMCLK, ulDRAMBandwidth, ActualDRAMBandwidth, DRAMEfficiency = 500;
+ ULONG ulDCLK;
+
+ vASTOpenKey(pScrn);
+
+ *(ULONG *) (pAST->MMIOVirtualAddr + 0xF004) = 0x1e6e0000;
+ *(ULONG *) (pAST->MMIOVirtualAddr + 0xF000) = 0x00000001;
+
+ /* Get BusWidth */
+ ulData = *(ULONG * ) (pAST->MMIOVirtualAddr + 0x10004);
+ if (ulData & 0x40)
+ ulDRAMBusWidth = 16;
+ else
+ ulDRAMBusWidth = 32;
+
+ /* Get MCLK */
+ {
+ *(ULONG *) (pAST->MMIOVirtualAddr + 0x10100) = 0x000000A8;
+
+ ulData = *(ULONG *) (pAST->MMIOVirtualAddr + 0x10120);
+ ulData2 = *(ULONG *) (pAST->MMIOVirtualAddr + 0x10170);
+ if (ulData2 & 0x2000)
+ ulRefPLL = 14318;
+ else
+ ulRefPLL = 12000;
+
+ ulDeNumerator = ulData & 0x1F;
+ ulNumerator = (ulData & 0x3FE0) >> 5;
+
+ ulData = (ulData & 0xC000) >> 14;
+ switch (ulData)
+ {
+ case 0x03:
+ ulDivider = 0x04;
+ break;
+ case 0x02:
+ case 0x01:
+ ulDivider = 0x02;
+ break;
+ default:
+ ulDivider = 0x01;
+ }
+
+ ulMCLK = ulRefPLL * (ulNumerator + 2) / ((ulDeNumerator + 2) * ulDivider * 1000);
+
+ }
+
+ /* Get Bandwidth */
+ ulDRAMBandwidth = ulMCLK * ulDRAMBusWidth * 2 / 8;
+ ActualDRAMBandwidth = ulDRAMBandwidth * DRAMEfficiency / 1000;
+
+ /* Get Max DCLK */
+ GetIndexRegMask(CRTC_PORT, 0xD0, 0xFF, jReg);
+ if (jReg & 0x08)
+ ulDCLK = ActualDRAMBandwidth / ((pScrn->bitsPerPixel+1+16) / 8);
+ else
+ ulDCLK = ActualDRAMBandwidth / ((pScrn->bitsPerPixel+1) / 8);
+
+ if (ulDCLK > 165) ulDCLK = 165;
+
+ return(ulDCLK);
+
+}
void
vSetStartAddressCRT1(ASTRecPtr pAST, ULONG base)