diff options
-rw-r--r-- | ChangeLog | 17 | ||||
-rw-r--r-- | src/ast.h | 167 | ||||
-rw-r--r-- | src/ast_2dtool.c | 795 | ||||
-rw-r--r-- | src/ast_2dtool.h | 419 | ||||
-rw-r--r-- | src/ast_accel.c | 1358 | ||||
-rw-r--r-- | src/ast_cursor.c | 376 | ||||
-rw-r--r-- | src/ast_cursor.h | 30 | ||||
-rw-r--r-- | src/ast_driver.c | 1220 | ||||
-rw-r--r-- | src/ast_mode.c | 712 | ||||
-rw-r--r-- | src/ast_mode.h | 115 | ||||
-rw-r--r-- | src/ast_tool.c | 124 | ||||
-rw-r--r-- | src/ast_vgatool.c | 240 | ||||
-rw-r--r-- | src/ast_vgatool.h | 70 |
13 files changed, 5643 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..7c4c4d5 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,17 @@ +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_cursor.c: + * src/ast_cursor.h: + * src/ast_driver.c: + * src/ast_mode.c: + * src/ast_mode.h: + * src/ast_tool.c: + * src/ast_vgatool.c: + * src/ast_vgatool.h: + Initial code release from ASPEED Technology Inc. + Bugzilla #4937 <https://bugs.freedesktop.org/show_bug.cgi?id=4937> + Attachment 3686 <https://bugs.freedesktop.org/attachment.cgi?id=3686>
\ No newline at end of file diff --git a/src/ast.h b/src/ast.h new file mode 100644 index 0000000..bbffa11 --- /dev/null +++ b/src/ast.h @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2005 ASPEED Technology Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the authors not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. The authors makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* Compiler Options */ +#define Accel_2D +/* #define MMIO_2D */ +#define HWC + +/* Vendor & Device Info */ +#ifndef PCI_VENDOR_AST +#define PCI_VENDOR_AST 0x1A03 +#endif + +#ifndef PCI_CHIP_AST2000 +#define PCI_CHIP_AST2000 0x2000 +#endif + +/* AST REC Info */ +#define AST_NAME "AST" +#define AST_DRIVER_NAME "ast" +#define AST_MAJOR_VERSION 0 +#define AST_MINOR_VERSION 51 +#define AST_PATCH_VERSION 0 +#define AST_VERSION \ + ((AST_MAJOR_VERSION << 20) | (AST_MINOR_VERSION << 10) | AST_PATCH_VERSION) + +/* Customized Info */ +#define DEFAULT_VIDEOMEM_SIZE 0x00800000 +#define DEFAULT_MMIO_SIZE 0x00020000 +#define DEFAULT_CMDQ_SIZE 0x00100000 +#define CMD_QUEUE_GUARD_BAND 0x00000020 +#define DEFAULT_HWC_NUM 0x00000002 + +/* Data Type Definition */ +typedef INT32 LONG; +typedef CARD8 UCHAR; +typedef CARD16 USHORT; +typedef CARD32 ULONG; + +/* Data Structure Definition */ +typedef struct _ASTRegRec { + UCHAR ExtCRTC[0x50]; + +} ASTRegRec, *ASTRegPtr; + +typedef struct _VIDEOMODE { + + int ScreenWidth; + int ScreenHeight; + int bitsPerPixel; + int ScreenPitch; + +} VIDEOMODE, *PVIDEOMODE; + +typedef struct { + + ULONG ulCMDQSize; + ULONG ulCMDQType; + + ULONG ulCMDQOffsetAddr; + UCHAR *pjCMDQVirtualAddr; + + UCHAR *pjCmdQBasePort; + UCHAR *pjWritePort; + UCHAR *pjReadPort; + UCHAR *pjEngStatePort; + + ULONG ulCMDQMask; + ULONG ulCurCMDQueueLen; + + ULONG ulWritePointer; + ULONG ulReadPointer; + + ULONG ulReadPointer_OK; /* for Eng_DBGChk */ + +} CMDQINFO, *PCMDQINFO; + +typedef struct { + + int HWC_NUM; + int HWC_NUM_Next; + + ULONG ulHWCOffsetAddr; + UCHAR *pjHWCVirtualAddr; + + USHORT cursortype; + USHORT width; + USHORT height; + USHORT offset_x; + USHORT offset_y; + ULONG fg; + ULONG bg; + + +} HWCINFO, *PHWCINFO; + +typedef struct _ASTRec { + + EntityInfoPtr pEnt; + pciVideoPtr PciInfo; + PCITAG PciTag; + + OptionInfoPtr Options; + DisplayModePtr ModePtr; + FBLinearPtr pCMDQPtr; + XAAInfoRecPtr AccelInfoPtr; + xf86CursorInfoPtr HWCInfoPtr; + FBLinearPtr pHWCPtr; + + CloseScreenProcPtr CloseScreen; + ScreenBlockHandlerProcPtr BlockHandler; + + Bool noAccel; + Bool noHWC; + Bool MMIO2D; + int ENGCaps; + int DBGSelect; + + ULONG FBPhysAddr; /* Frame buffer physical address */ + ULONG MMIOPhysAddr; /* MMIO region physical address */ + ULONG BIOSPhysAddr; /* BIOS physical address */ + + UCHAR *FBVirtualAddr; /* Map of frame buffer */ + UCHAR *MMIOVirtualAddr; /* Map of MMIO region */ + + unsigned long FbMapSize; + unsigned long MMIOMapSize; + + IOADDRESS IODBase; /* Base of PIO memory area */ + IOADDRESS PIOOffset; + IOADDRESS RelocateIO; + + VIDEOMODE VideoModeInfo; + ASTRegRec SavedReg; + CMDQINFO CMDQInfo; + HWCINFO HWCInfo; + ULONG ulCMDReg; + Bool EnableClip; + +} ASTRec, *ASTRecPtr; + +#define ASTPTR(p) ((ASTRecPtr)((p)->driverPrivate)) + +/* Include Files */ +#include "ast_mode.h" +#include "ast_vgatool.h" +#include "ast_2dtool.h" +#include "ast_cursor.h" diff --git a/src/ast_2dtool.c b/src/ast_2dtool.c new file mode 100644 index 0000000..b539ea5 --- /dev/null +++ b/src/ast_2dtool.c @@ -0,0 +1,795 @@ +/* + * Copyright (c) 2005 ASPEED Technology Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the authors not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. The authors makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#include "xf86.h" +#include "xf86_ansic.h" +#include "xf86_OSproc.h" +#include "xf86Resources.h" +#include "xf86RAC.h" +#include "xf86cmap.h" +#include "compiler.h" +#include "mibstore.h" +#include "vgaHW.h" +#include "mipointer.h" +#include "micmap.h" + +#include "fb.h" +#include "regionstr.h" +#include "xf86xv.h" +#include "Xv.h" +#include "vbe.h" + +#include "xf86PciInfo.h" +#include "xf86Pci.h" + +/* framebuffer offscreen manager */ +#include "xf86fbman.h" + +/* include xaa includes */ +#include "xaa.h" +#include "xaarop.h" + +/* H/W cursor support */ +#include "xf86Cursor.h" + +/* Driver specific headers */ +#include "ast.h" + +#ifdef Accel_2D + +/* Prototype type declaration */ +Bool bInitCMDQInfo(ScrnInfoPtr pScrn, ASTRecPtr pAST); +Bool bEnableCMDQ(ScrnInfoPtr pScrn, ASTRecPtr pAST); +Bool bEnable2D(ScrnInfoPtr pScrn, ASTRecPtr pAST); +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) +{ + + pAST->CMDQInfo.pjCmdQBasePort = pAST->MMIOVirtualAddr+ 0x8044; + pAST->CMDQInfo.pjWritePort = pAST->MMIOVirtualAddr+ 0x8048; + pAST->CMDQInfo.pjReadPort = pAST->MMIOVirtualAddr+ 0x804C; + pAST->CMDQInfo.pjEngStatePort = pAST->MMIOVirtualAddr+ 0x804C; + + /* 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) { + 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 */ + if (pAST->MMIO2D) { + pAST->CMDQInfo.ulCMDQType = VM_CMD_MMIO; + } + + return (TRUE); +} + +Bool +bEnableCMDQ(ScrnInfoPtr pScrn, ASTRecPtr pAST) +{ + ULONG ulVMCmdQBasePort = 0; + + vWaitEngIdle(pScrn, pAST); + + /* set DBG Select Info */ + if (pAST->DBGSelect) + { + *(ULONG *) (pAST->MMIOVirtualAddr + 0x804C) = (ULONG) (pAST->DBGSelect); + } + + /* set CMDQ base */ + switch (pAST->CMDQInfo.ulCMDQType) + { + case VM_CMD_QUEUE: + ulVMCmdQBasePort = (pAST->CMDQInfo.ulCMDQOffsetAddr - 0) >> 3; + + /* set CMDQ Threshold */ + ulVMCmdQBasePort |= 0xF0000000; + + /* set CMDQ Size */ + switch (pAST->CMDQInfo.ulCMDQSize) + { + case CMD_QUEUE_SIZE_256K: + ulVMCmdQBasePort |= 0x00000000; + break; + + case CMD_QUEUE_SIZE_512K: + ulVMCmdQBasePort |= 0x04000000; + break; + + case CMD_QUEUE_SIZE_1M: + ulVMCmdQBasePort |= 0x08000000; + break; + + case CMD_QUEUE_SIZE_2M: + ulVMCmdQBasePort |= 0x0C000000; + break; + + default: + return(FALSE); + break; + } + + *(ULONG *) (pAST->CMDQInfo.pjCmdQBasePort) = ulVMCmdQBasePort; + pAST->CMDQInfo.ulWritePointer = *(ULONG *) (pAST->CMDQInfo.pjWritePort); + break; + + case VM_CMD_MMIO: + /* set CMDQ Threshold */ + ulVMCmdQBasePort |= 0xF0000000; + + ulVMCmdQBasePort |= 0x02000000; /* MMIO mode */ + *(ULONG *) (pAST->CMDQInfo.pjCmdQBasePort) = ulVMCmdQBasePort; + break; + + default: + return (FALSE); + break; + } + + return (TRUE); +} + +Bool +bEnable2D(ScrnInfoPtr pScrn, ASTRecPtr pAST) +{ + SetIndexRegMask(CRTC_PORT, 0xA4, 0xFE, 0x01); /* enable 2D */ + + if (!bInitCMDQInfo(pScrn, pAST)) + { + vDisable2D(pScrn, pAST); + return (FALSE); + } + + if (!bEnableCMDQ(pScrn, pAST)) + { + vDisable2D(pScrn, pAST); + return (FALSE); + } + + return (TRUE); +} + +void +vDisable2D(ScrnInfoPtr pScrn, ASTRecPtr pAST) +{ + + vWaitEngIdle(pScrn, pAST); + vWaitEngIdle(pScrn, pAST); + + SetIndexRegMask(CRTC_PORT, 0xA4, 0xFE, 0x00); + +} + + +void +vWaitEngIdle(ScrnInfoPtr pScrn, ASTRecPtr pAST) +{ + ULONG ulEngState, ulEngState2; + UCHAR jReg; + ULONG ulEngCheckSetting; + + if (pAST->MMIO2D) + ulEngCheckSetting = 0x10000000; + else + ulEngCheckSetting = 0x80000000; + + /* 2D disable if 0xA4 D[0] = 1 */ + GetIndexRegMask(CRTC_PORT, 0xA4, 0x01, jReg); + if (!jReg) goto Exit_vWaitEngIdle; + + /* 2D not work if in std. mode */ + GetIndexRegMask(CRTC_PORT, 0xA3, 0x0F, jReg); + if (!jReg) goto Exit_vWaitEngIdle; + + do + { + ulEngState = (*(volatile ULONG *)(pAST->CMDQInfo.pjEngStatePort)) & 0xFFFC0000; + ulEngState2 = (*(volatile ULONG *)(pAST->CMDQInfo.pjEngStatePort)) & 0xFFFC0000; + ulEngState2 = (*(volatile ULONG *)(pAST->CMDQInfo.pjEngStatePort)) & 0xFFFC0000; + ulEngState2 = (*(volatile ULONG *)(pAST->CMDQInfo.pjEngStatePort)) & 0xFFFC0000; + ulEngState2 = (*(volatile ULONG *)(pAST->CMDQInfo.pjEngStatePort)) & 0xFFFC0000; + ulEngState2 = (*(volatile ULONG *)(pAST->CMDQInfo.pjEngStatePort)) & 0xFFFC0000; + + } while ((ulEngState & ulEngCheckSetting) || (ulEngState != ulEngState2)); + +Exit_vWaitEngIdle: + ; +} + +/* ULONG ulGetCMDQLength() */ +__inline ULONG ulGetCMDQLength(ASTRecPtr pAST, ULONG ulWritePointer, ULONG ulCMDQMask) +{ + ULONG ulReadPointer, ulReadPointer2; + + do { + ulReadPointer = *((volatile ULONG *)(pAST->CMDQInfo.pjReadPort)) & 0x0003FFFF; + ulReadPointer2 = *((volatile ULONG *)(pAST->CMDQInfo.pjReadPort)) & 0x0003FFFF; + ulReadPointer2 = *((volatile ULONG *)(pAST->CMDQInfo.pjReadPort)) & 0x0003FFFF; + ulReadPointer2 = *((volatile ULONG *)(pAST->CMDQInfo.pjReadPort)) & 0x0003FFFF; + ulReadPointer2 = *((volatile ULONG *)(pAST->CMDQInfo.pjReadPort)) & 0x0003FFFF; + ulReadPointer2 = *((volatile ULONG *)(pAST->CMDQInfo.pjReadPort)) & 0x0003FFFF; + } while (ulReadPointer != ulReadPointer2); + + return ((ulReadPointer << 3) - ulWritePointer - CMD_QUEUE_GUARD_BAND) & ulCMDQMask; +} + +UCHAR *pjRequestCMDQ( +ASTRecPtr pAST, ULONG ulDataLen) +{ + UCHAR *pjBuffer; + ULONG i, ulWritePointer, ulCMDQMask, ulCurCMDQLen, ulContinueCMDQLen; + + ulWritePointer = pAST->CMDQInfo.ulWritePointer; + ulContinueCMDQLen = pAST->CMDQInfo.ulCMDQSize - ulWritePointer; + ulCMDQMask = pAST->CMDQInfo.ulCMDQMask; + + if (ulContinueCMDQLen >= ulDataLen) + { + /* Get CMDQ Buffer */ + if (pAST->CMDQInfo.ulCurCMDQueueLen >= ulDataLen) + { + ; + } + else + { + + do + { + ulCurCMDQLen = ulGetCMDQLength(pAST, ulWritePointer, ulCMDQMask); + } while (ulCurCMDQLen < ulDataLen); + + pAST->CMDQInfo.ulCurCMDQueueLen = ulCurCMDQLen; + + } + + pjBuffer = pAST->CMDQInfo.pjCMDQVirtualAddr + ulWritePointer; + pAST->CMDQInfo.ulCurCMDQueueLen -= ulDataLen; + pAST->CMDQInfo.ulWritePointer = (ulWritePointer + ulDataLen) & ulCMDQMask; + return pjBuffer; + } + else + { + + /* Fill NULL CMD to the last of the CMDQ */ + if (pAST->CMDQInfo.ulCurCMDQueueLen >= ulContinueCMDQLen) + { + ; + } + else + { + + do + { + ulCurCMDQLen = ulGetCMDQLength(pAST, ulWritePointer, ulCMDQMask); + } while (ulCurCMDQLen < ulContinueCMDQLen); + + pAST->CMDQInfo.ulCurCMDQueueLen = ulCurCMDQLen; + + } + + pjBuffer = pAST->CMDQInfo.pjCMDQVirtualAddr + ulWritePointer; + for (i = 0; i<ulContinueCMDQLen/8; i++, pjBuffer+=8) + { + *(ULONG *)pjBuffer = (ULONG) PKT_NULL_CMD; + *(ULONG *) (pjBuffer+4) = 0; + + } + pAST->CMDQInfo.ulCurCMDQueueLen -= ulContinueCMDQLen; + pAST->CMDQInfo.ulWritePointer = ulWritePointer = 0; + + /* Get CMDQ Buffer */ + if (pAST->CMDQInfo.ulCurCMDQueueLen >= ulDataLen) + { + ; + } + else + { + + do + { + ulCurCMDQLen = ulGetCMDQLength(pAST, ulWritePointer, ulCMDQMask); + } while (ulCurCMDQLen < ulDataLen); + + pAST->CMDQInfo.ulCurCMDQueueLen = ulCurCMDQLen; + + } + + pAST->CMDQInfo.ulCurCMDQueueLen -= ulDataLen; + pjBuffer = pAST->CMDQInfo.pjCMDQVirtualAddr + ulWritePointer; + pAST->CMDQInfo.ulWritePointer = (ulWritePointer + ulDataLen) & ulCMDQMask; + return pjBuffer; + + } + +} /* end of pjRequestCmdQ() */ + +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; + + /*Init Calucate */ +#ifdef LONG64 + GAbsX = abs (LineInfo->X1 - LineInfo->X2); + GAbsY = abs (LineInfo->Y1 - LineInfo->Y2); +#else + GAbsX = labs (LineInfo->X1 - LineInfo->X2); + GAbsY = labs (LineInfo->Y1 - LineInfo->Y2); +#endif + + GXInc = (LineInfo->X1 < LineInfo->X2) ? 1:0; + GYInc = (LineInfo->Y1 < LineInfo->Y2) ? 1:0; + 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) + { + tmpFlipD = 1; + tmpFStartX = tmpStartY; + tmpFStartY = tmpStartX; + GFAbsX = GAbsY; + GFAbsY = GAbsX; + } + 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; + } + + GK1Term = tmpGK1Term; + GK2Term = tmpGK2Term; + + /*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->dwLineAttributes = 0; + if (GXMajor) dsLineParam->dwLineAttributes |= LINEPARAM_XM; + if (!GXInc) dsLineParam->dwLineAttributes |= LINEPARAM_X_DEC; + if (!GYInc) dsLineParam->dwLineAttributes |= LINEPARAM_Y_DEC; + + return(TRUE); + +} + +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 new file mode 100644 index 0000000..2539705 --- /dev/null +++ b/src/ast_2dtool.h @@ -0,0 +1,419 @@ +/* + * Copyright (c) 2005 ASPEED Technology Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the authors not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. The authors makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* Eng Capability Definition */ +#define ENG_CAP_Sync 0x0001 +#define ENG_CAP_ScreenToScreenCopy 0x0002 +#define ENG_CAP_SolidFill 0x0004 +#define ENG_CAP_SolidLine 0x0008 +#define ENG_CAP_DashedLine 0x0010 +#define ENG_CAP_Mono8x8PatternFill 0x0020 +#define ENG_CAP_Color8x8PatternFill 0x0040 +#define ENG_CAP_CPUToScreenColorExpand 0x0080 +#define ENG_CAP_ScreenToScreenColorExpand 0x0100 +#define ENG_CAP_Clipping 0x0200 +#define ENG_CAP_ALL (ENG_CAP_Sync | ENG_CAP_ScreenToScreenCopy | ENG_CAP_SolidFill | \ + ENG_CAP_SolidLine | ENG_CAP_DashedLine | \ + ENG_CAP_Mono8x8PatternFill | ENG_CAP_Color8x8PatternFill | \ + ENG_CAP_Clipping); + +/* CMDQ Definition */ +#define AGP_CMD_QUEUE 1 +#define VM_CMD_QUEUE 0 +#define VM_CMD_MMIO 2 + +#define CMD_QUEUE_SIZE_256K 0x00040000 +#define CMD_QUEUE_SIZE_512K 0x00080000 +#define CMD_QUEUE_SIZE_1M 0x00100000 +#define CMD_QUEUE_SIZE_2M 0x00200000 +#define CMD_QUEUE_SIZE_4M 0x00400000 + +/* CMD Type Info */ +#define PKT_NULL_CMD 0x00009561 + +#define PKT_SINGLE_LENGTH 8 +#define PKT_SINGLE_CMD_HEADER 0x00009562 + +typedef struct _PKT_SC +{ + ULONG PKT_SC_dwHeader; + ULONG PKT_SC_dwData[1]; + +} PKT_SC, *PPKT_SC; + +/* Eng Reg. Limitation */ +#define MAX_SRC_PITCH 0x1FFF +#define MAX_DST_PITCH 0x1FFF +#define MAX_DST_HEIGHT 0x7FF +#define MAX_SRC_X 0x7FF +#define MAX_SRC_Y 0x7FF +#define MAX_DST_X 0x7FF +#define MAX_DST_Y 0x7FF +#define MAX_RECT_WIDTH 0x7FF +#define MAX_RECT_HEIGHT 0x7FF +#define MAX_CLIP 0xFFF + +#define MAX_LINE_X 0x7FF +#define MAX_LINE_Y 0x7FF +#define MAX_LINE_ERR 0x3FFFFF +#define MAX_LINE_WIDTH 0x7FF +#define MAX_LINE_K1 0x3FFFFF +#define MAX_LINE_K2 0x3FFFFF + +#define MAX_PATReg_Size 256 + +/* Eng Reg. Definition */ +/* MMIO Reg */ +#define MMIOREG_SRC_BASE (pAST->MMIOVirtualAddr + 0x8000) +#define MMIOREG_SRC_PITCH (pAST->MMIOVirtualAddr + 0x8004) +#define MMIOREG_DST_BASE (pAST->MMIOVirtualAddr + 0x8008) +#define MMIOREG_DST_PITCH (pAST->MMIOVirtualAddr + 0x800C) +#define MMIOREG_DST_XY (pAST->MMIOVirtualAddr + 0x8010) +#define MMIOREG_SRC_XY (pAST->MMIOVirtualAddr + 0x8014) +#define MMIOREG_RECT_XY (pAST->MMIOVirtualAddr + 0x8018) +#define MMIOREG_FG (pAST->MMIOVirtualAddr + 0x801C) +#define MMIOREG_BG (pAST->MMIOVirtualAddr + 0x8020) +#define MMIOREG_FG_SRC (pAST->MMIOVirtualAddr + 0x8024) +#define MMIOREG_BG_SRC (pAST->MMIOVirtualAddr + 0x8028) +#define MMIOREG_MONO1 (pAST->MMIOVirtualAddr + 0x802C) +#define MMIOREG_MONO2 (pAST->MMIOVirtualAddr + 0x8030) +#define MMIOREG_CLIP1 (pAST->MMIOVirtualAddr + 0x8034) +#define MMIOREG_CLIP2 (pAST->MMIOVirtualAddr + 0x8038) +#define MMIOREG_CMD (pAST->MMIOVirtualAddr + 0x803C) +#define MMIOREG_PAT (pAST->MMIOVirtualAddr + 0x8100) + +#define MMIOREG_LINE_XY (pAST->MMIOVirtualAddr + 0x8010) +#define MMIOREG_LINE_Err (pAST->MMIOVirtualAddr + 0x8014) +#define MMIOREG_LINE_WIDTH (pAST->MMIOVirtualAddr + 0x8018) +#define MMIOREG_LINE_K1 (pAST->MMIOVirtualAddr + 0x8024) +#define MMIOREG_LINE_K2 (pAST->MMIOVirtualAddr + 0x8028) +#define MMIOREG_LINE_STYLE1 (pAST->MMIOVirtualAddr + 0x802C) +#define MMIOREG_LINE_STYLE2 (pAST->MMIOVirtualAddr + 0x8030) + +/* CMDQ Reg */ +#define CMDQREG_SRC_BASE (0x00 << 24) +#define CMDQREG_SRC_PITCH (0x01 << 24) +#define CMDQREG_DST_BASE (0x02 << 24) +#define CMDQREG_DST_PITCH (0x03 << 24) +#define CMDQREG_DST_XY (0x04 << 24) +#define CMDQREG_SRC_XY (0x05 << 24) +#define CMDQREG_RECT_XY (0x06 << 24) +#define CMDQREG_FG (0x07 << 24) +#define CMDQREG_BG (0x08 << 24) +#define CMDQREG_FG_SRC (0x09 << 24) +#define CMDQREG_BG_SRC (0x0A << 24) +#define CMDQREG_MONO1 (0x0B << 24) +#define CMDQREG_MONO2 (0x0C << 24) +#define CMDQREG_CLIP1 (0x0D << 24) +#define CMDQREG_CLIP2 (0x0E << 24) +#define CMDQREG_CMD (0x0F << 24) +#define CMDQREG_PAT (0x40 << 24) + +#define CMDQREG_LINE_XY (0x04 << 24) +#define CMDQREG_LINE_Err (0x05 << 24) +#define CMDQREG_LINE_WIDTH (0x06 << 24) +#define CMDQREG_LINE_K1 (0x09 << 24) +#define CMDQREG_LINE_K2 (0x0A << 24) +#define CMDQREG_LINE_STYLE1 (0x0B << 24) +#define CMDQREG_LINE_STYLE2 (0x0C << 24) + +/* CMD Reg. Definition */ +#define CMD_BITBLT 0x00000000 +#define CMD_LINEDRAW 0x00000001 +#define CMD_COLOREXP 0x00000002 +#define CMD_ENHCOLOREXP 0x00000003 +#define CMD_MASK 0x00000007 + +#define CMD_DISABLE_CLIP 0x00000000 +#define CMD_ENABLE_CLIP 0x00000008 + +#define CMD_COLOR_08 0x00000000 +#define CMD_COLOR_16 0x00000010 +#define CMD_COLOR_32 0x00000020 + +#define CMD_SRC_SIQ 0x00000040 + +#define CMD_TRANSPARENT 0x00000080 + +#define CMD_PAT_FGCOLOR 0x00000000 +#define CMD_PAT_MONOMASK 0x00010000 +#define CMD_PAT_PATREG 0x00020000 + +#define CMD_OPAQUE 0x00000000 +#define CMD_FONT_TRANSPARENT 0x00040000 + +#define CMD_X_INC 0x00000000 +#define CMD_X_DEC 0x00200000 + +#define CMD_Y_INC 0x00000000 +#define CMD_Y_DEC 0x00100000 + +#define CMD_DRAW_LAST_PIXEL 0x00000000 +#define CMD_NOT_DRAW_LAST_PIXEL 0x00800000 + +#define CMD_DISABLE_LINE_STYLE 0x00000000 +#define CMD_ENABLE_LINE_STYLE 0x40000000 + +#define CMD_RESET_STYLE_COUNTER 0x80000000 +#define CMD_NOT_RESET_STYLE_COUNTER 0x00000000 + +#define BURST_FORCE_CMD 0x80000000 + +/* Line */ +#define LINEPARAM_XM 0x00000001 +#define LINEPARAM_X_DEC 0x00000002 +#define LINEPARAM_Y_DEC 0x00000004 + +typedef struct _LINEPARAM { + USHORT dsLineX; + USHORT dsLineY; + USHORT dsLineWidth; + ULONG dwErrorTerm; + ULONG dwK1Term; + ULONG dwK2Term; + ULONG dwLineAttributes; +} LINEPARAM, *PLINEPARAM; + +typedef struct { + + ULONG X1; + ULONG Y1; + ULONG X2; + ULONG Y2; + +} _LINEInfo; + +/* Macro */ +/* MMIO 2D Macro */ +#define ASTSetupSRCBase_MMIO(base) \ + { \ + *(ULONG *)(MMIOREG_SRC_BASE) = (ULONG) (base); \ + } +#define ASTSetupSRCPitch_MMIO(pitch) \ + { \ + *(ULONG *)(MMIOREG_SRC_PITCH) = (ULONG)(pitch << 16); \ + } +#define ASTSetupDSTBase_MMIO(base) \ + { \ + *(ULONG *)(MMIOREG_DST_BASE) = (ULONG)(base); \ + } +#define ASTSetupDSTPitchHeight_MMIO(pitch, height) \ + { \ + *(ULONG *)(MMIOREG_DST_PITCH) = (ULONG)((pitch << 16) + ((height) & MAX_DST_HEIGHT)); \ + } +#define ASTSetupDSTXY_MMIO(x, y) \ + { \ + *(ULONG *)(MMIOREG_DST_XY) = (ULONG)(((x & MAX_DST_X) << 16) + (y & MAX_DST_Y)); \ + } +#define ASTSetupSRCXY_MMIO(x, y) \ + { \ + *(ULONG *)(MMIOREG_SRC_XY) = (ULONG)(((x & MAX_SRC_X) << 16) + (y & MAX_SRC_Y)); \ + } +#define ASTSetupRECTXY_MMIO(x, y) \ + { \ + *(ULONG *)(MMIOREG_RECT_XY) = (ULONG)(((x & MAX_RECT_WIDTH) << 16) + (y & MAX_RECT_WIDTH)); \ + } +#define ASTSetupFG_MMIO(color) \ + { \ + *(ULONG *)(MMIOREG_FG) = (ULONG)(color); \ + } +#define ASTSetupBG_MMIO(color) \ + { \ + *(ULONG *)(MMIOREG_BG) = (ULONG)(color); \ + } +#define ASTSetupMONO1_MMIO(pat) \ + { \ + *(ULONG *)(MMIOREG_MONO1) = (ULONG)(pat); \ + } +#define ASTSetupMONO2_MMIO(pat) \ + { \ + *(ULONG *)(MMIOREG_MONO2) = (ULONG)(pat); \ + } +#define ASTSetupCLIP1_MMIO(left, top) \ + { \ + *(ULONG *)(MMIOREG_CLIP1) = (ULONG)(((left & MAX_CLIP) << 16) + (top & MAX_CLIP)); \ + } +#define ASTSetupCLIP2_MMIO(right, bottom) \ + { \ + *(ULONG *)(MMIOREG_CLIP2) = (ULONG)(((right & MAX_CLIP) << 16) + (bottom & MAX_CLIP)); \ + } +#define ASTSetupCMDReg_MMIO(reg) \ + { \ + *(ULONG *)(MMIOREG_CMD) = (ULONG)(reg); \ + } +#define ASTSetupPatReg_MMIO(patreg, pat) \ + { \ + *(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)); \ + } +#define ASTSetupLineXMErrTerm_MMIO(xm, err) \ + { \ + *(ULONG *)(MMIOREG_LINE_Err) = (ULONG)((xm << 24) + (err & MAX_LINE_ERR)); \ + } +#define ASTSetupLineWidth_MMIO(width) \ + { \ + *(ULONG *)(MMIOREG_LINE_WIDTH) = (ULONG)((width & MAX_LINE_WIDTH) << 16); \ + } +#define ASTSetupLineK1Term_MMIO(err) \ + { \ + *(ULONG *)(MMIOREG_LINE_K1) = (ULONG)(err & MAX_LINE_K1); \ + } +#define ASTSetupLineK2Term_MMIO(err) \ + { \ + *(ULONG *)(MMIOREG_LINE_K2) = (ULONG)(err & MAX_LINE_K2); \ + } +#define ASTSetupLineStyle1_MMIO(pat) \ + { \ + *(ULONG *)(MMIOREG_LINE_STYLE1) = (ULONG)(pat); \ + } +#define ASTSetupLineStyle2_MMIO(pat) \ + { \ + *(ULONG *)(MMIOREG_LINE_STYLE2) = (ULONG)(pat); \ + } + +/* CMDQ Mode Macro */ +#define mUpdateWritePointer *(ULONG *) (pAST->CMDQInfo.pjWritePort) = (pAST->CMDQInfo.ulWritePointer >>3) + +/* General CMD */ +#define ASTSetupSRCBase(addr, base) \ + { \ + addr->PKT_SC_dwHeader = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_SRC_BASE); \ + addr->PKT_SC_dwData[0] = (ULONG)(base); \ + } +#define ASTSetupSRCPitch(addr, pitch) \ + { \ + addr->PKT_SC_dwHeader = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_SRC_PITCH); \ + addr->PKT_SC_dwData[0] = (ULONG)(pitch << 16); \ + } +#define ASTSetupDSTBase(addr, base) \ + { \ + addr->PKT_SC_dwHeader = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_DST_BASE); \ + addr->PKT_SC_dwData[0] = (ULONG)(base); \ + } +#define ASTSetupDSTPitchHeight(addr, pitch, height) \ + { \ + addr->PKT_SC_dwHeader = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_DST_PITCH); \ + addr->PKT_SC_dwData[0] = (ULONG)((pitch << 16) + ((height) & MAX_DST_HEIGHT)); \ + } +#define ASTSetupDSTXY(addr, x, y) \ + { \ + addr->PKT_SC_dwHeader = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_DST_XY); \ + addr->PKT_SC_dwData[0] = (ULONG)(((x & MAX_DST_X) << 16) + (y & MAX_DST_Y)); \ + } +#define ASTSetupSRCXY(addr, x, y) \ + { \ + addr->PKT_SC_dwHeader = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_SRC_XY); \ + addr->PKT_SC_dwData[0] = (ULONG)(((x & MAX_SRC_X) << 16) + (y & MAX_SRC_Y)); \ + } +#define ASTSetupRECTXY(addr, x, y) \ + { \ + addr->PKT_SC_dwHeader = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_RECT_XY); \ + addr->PKT_SC_dwData[0] = (ULONG)(((x & MAX_RECT_WIDTH) << 16) + (y & MAX_RECT_WIDTH)); \ + } +#define ASTSetupFG(addr, color) \ + { \ + addr->PKT_SC_dwHeader = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_FG); \ + addr->PKT_SC_dwData[0] = (ULONG)(color); \ + } +#define ASTSetupBG(addr, color) \ + { \ + addr->PKT_SC_dwHeader = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_BG); \ + addr->PKT_SC_dwData[0] = (ULONG)(color); \ + } +#define ASTSetupMONO1(addr, pat) \ + { \ + addr->PKT_SC_dwHeader = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_MONO1); \ + addr->PKT_SC_dwData[0] = (ULONG)(pat); \ + } +#define ASTSetupMONO2(addr, pat) \ + { \ + addr->PKT_SC_dwHeader = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_MONO2); \ + addr->PKT_SC_dwData[0] = (ULONG)(pat); \ + } +#define ASTSetupCLIP1(addr, left, top) \ + { \ + addr->PKT_SC_dwHeader = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_CLIP1); \ + addr->PKT_SC_dwData[0] = (ULONG)(((left & MAX_CLIP) << 16) + (top & MAX_CLIP)); \ + } +#define ASTSetupCLIP2(addr, right, bottom) \ + { \ + addr->PKT_SC_dwHeader = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_CLIP2); \ + addr->PKT_SC_dwData[0] = (ULONG)(((right & MAX_CLIP) << 16) + (bottom & MAX_CLIP)); \ + } +#define ASTSetupCMDReg(addr, reg) \ + { \ + addr->PKT_SC_dwHeader = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_CMD); \ + addr->PKT_SC_dwData[0] = (ULONG)(reg); \ + } +#define ASTSetupPatReg(addr, patreg, pat) \ + { \ + addr->PKT_SC_dwHeader = (ULONG)(PKT_SINGLE_CMD_HEADER + (CMDQREG_PAT + (patreg << 24))); \ + addr->PKT_SC_dwData[0] = (ULONG)(pat); \ + } + +/* Line CMD */ +#define ASTSetupLineXY(addr, x, y) \ + { \ + addr->PKT_SC_dwHeader = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_LINE_XY); \ + addr->PKT_SC_dwData[0] = (ULONG)(((x & MAX_LINE_X) << 16) + (y & MAX_LINE_Y)); \ + } +#define ASTSetupLineXMErrTerm(addr, xm, err) \ + { \ + addr->PKT_SC_dwHeader = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_LINE_Err); \ + addr->PKT_SC_dwData[0] = (ULONG)((xm << 24) + (err & MAX_LINE_ERR)); \ + } +#define ASTSetupLineWidth(addr, width) \ + { \ + addr->PKT_SC_dwHeader = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_LINE_WIDTH); \ + addr->PKT_SC_dwData[0] = (ULONG)((width & MAX_LINE_WIDTH) << 16); \ + } +#define ASTSetupLineK1Term(addr, err) \ + { \ + addr->PKT_SC_dwHeader = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_LINE_K1); \ + addr->PKT_SC_dwData[0] = (ULONG)(err & MAX_LINE_K1); \ + } +#define ASTSetupLineK2Term(addr, err) \ + { \ + addr->PKT_SC_dwHeader = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_LINE_K2); \ + addr->PKT_SC_dwData[0] = (ULONG)(err & MAX_LINE_K2); \ + } +#define ASTSetupLineStyle1(addr, pat) \ + { \ + addr->PKT_SC_dwHeader = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_LINE_STYLE1); \ + addr->PKT_SC_dwData[0] = (ULONG)(pat); \ + } +#define ASTSetupLineStyle2(addr, pat) \ + { \ + addr->PKT_SC_dwHeader = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_LINE_STYLE2); \ + addr->PKT_SC_dwData[0] = (ULONG)(pat); \ + } + +#define ASTSetupNULLCMD(addr) \ + { \ + addr->PKT_SC_dwHeader = (ULONG) (PKT_NULL_CMD); \ + addr->PKT_SC_dwData[0] = (ULONG) 0; \ + } diff --git a/src/ast_accel.c b/src/ast_accel.c new file mode 100644 index 0000000..69da85f --- /dev/null +++ b/src/ast_accel.c @@ -0,0 +1,1358 @@ +/*
+ * Copyright (c) 2005 ASPEED Technology Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the authors not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. The authors makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "xf86.h"
+#include "xf86_ansic.h"
+#include "xf86_OSproc.h"
+#include "xf86Resources.h"
+#include "xf86RAC.h"
+#include "xf86cmap.h"
+#include "compiler.h"
+#include "mibstore.h"
+#include "vgaHW.h"
+#include "mipointer.h"
+#include "micmap.h"
+
+#include "fb.h"
+#include "regionstr.h"
+#include "xf86xv.h"
+#include "Xv.h"
+#include "vbe.h"
+
+#include "xf86PciInfo.h"
+#include "xf86Pci.h"
+
+/* framebuffer offscreen manager */
+#include "xf86fbman.h"
+
+/* include xaa includes */
+#include "xaa.h"
+#include "xaarop.h"
+
+/* H/W cursor support */
+#include "xf86Cursor.h"
+
+/* Driver specific headers */
+#include "ast.h"
+
+#ifdef Accel_2D
+
+/* extern function */
+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);
+static void ASTSync(ScrnInfoPtr pScrn);
+static void ASTSetupForScreenToScreenCopy(ScrnInfoPtr pScrn,
+ int xdir, int ydir, int rop,
+ unsigned int planemask, int trans_color);
+static void ASTSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1, int x2,
+ int y2, int w, int h);
+static void ASTSetupForSolidFill(ScrnInfoPtr pScrn,
+ int color, int rop, unsigned int planemask);
+static void ASTSubsequentSolidFillRect(ScrnInfoPtr pScrn,
+ int dst_x, int dst_y, int width, int height);
+static void ASTSetupForSolidLine(ScrnInfoPtr pScrn,
+ int color, int rop, unsigned int planemask);
+static void ASTSubsequentSolidHorVertLine(ScrnInfoPtr pScrn,
+ int x, int y, int len, int dir);
+static void ASTSubsequentSolidTwoPointLine(ScrnInfoPtr pScrn,
+ int x1, int y1, int x2, int y2, int flags);
+static void ASTSetupForDashedLine(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop, unsigned int planemask,
+ int length, UCHAR *pattern);
+static void ASTSubsequentDashedTwoPointLine(ScrnInfoPtr pScrn,
+ int x1, int y1, int x2, int y2,
+ int flags, int phase);
+static void ASTSetupForMonoPatternFill(ScrnInfoPtr pScrn,
+ int patx, int paty, int fg, int bg,
+ int rop, unsigned int planemask);
+static void ASTSubsequentMonoPatternFill(ScrnInfoPtr pScrn,
+ int patx, int paty,
+ int x, int y, int w, int h);
+static void ASTSetupForColor8x8PatternFill(ScrnInfoPtr pScrn, int patx, int paty,
+ int rop, unsigned int planemask, int trans_col);
+static void ASTSubsequentColor8x8PatternFillRect(ScrnInfoPtr pScrn, int patx, int paty,
+ int x, int y, int w, int h);
+static void ASTSetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn,
+ int fg, int bg,
+ int rop, unsigned int planemask);
+static void ASTSubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn,
+ int x, int y,
+ int width, int height, int skipleft);
+static void ASTSetupForScreenToScreenColorExpandFill(ScrnInfoPtr pScrn,
+ int fg, int bg,
+ int rop, unsigned int planemask);
+static void ASTSubsequentScreenToScreenColorExpandFill(ScrnInfoPtr pScrn,
+ int x, int y, int width, int height,
+ int src_x, int src_y, int offset);
+static void ASTSetClippingRectangle(ScrnInfoPtr pScrn,
+ int left, int top, int right, int bottom);
+static void ASTDisableClipping(ScrnInfoPtr pScrn);
+
+Bool
+ASTAccelInit(ScreenPtr pScreen)
+{
+ XAAInfoRecPtr infoPtr;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ ASTRecPtr pAST = ASTPTR(pScrn);
+
+ pAST->AccelInfoPtr = infoPtr = XAACreateInfoRec();
+ if (!infoPtr) return FALSE;
+
+ infoPtr->Flags = LINEAR_FRAMEBUFFER |
+ OFFSCREEN_PIXMAPS |
+ PIXMAP_CACHE;
+
+ /* Sync */
+ if (pAST->ENGCaps & ENG_CAP_Sync)
+ infoPtr->Sync = ASTSync;
+
+ /* Screen To Screen copy */
+ if (pAST->ENGCaps & ENG_CAP_ScreenToScreenCopy)
+ {
+ infoPtr->SetupForScreenToScreenCopy = ASTSetupForScreenToScreenCopy;
+ infoPtr->SubsequentScreenToScreenCopy = ASTSubsequentScreenToScreenCopy;
+ infoPtr->ScreenToScreenCopyFlags = NO_TRANSPARENCY | NO_PLANEMASK;
+ }
+
+ /* Solid fill */
+ if (pAST->ENGCaps & ENG_CAP_SolidFill)
+ {
+ infoPtr->SetupForSolidFill = ASTSetupForSolidFill;
+ infoPtr->SubsequentSolidFillRect = ASTSubsequentSolidFillRect;
+ infoPtr->SolidFillFlags = NO_PLANEMASK;
+ }
+
+ /* Solid Lines */
+ if (pAST->ENGCaps & ENG_CAP_SolidLine)
+ {
+ infoPtr->SetupForSolidLine = ASTSetupForSolidLine;
+ infoPtr->SubsequentSolidHorVertLine = ASTSubsequentSolidHorVertLine;
+ infoPtr->SubsequentSolidTwoPointLine = ASTSubsequentSolidTwoPointLine;
+ infoPtr->SolidLineFlags = NO_PLANEMASK;
+ }
+
+ /* Dashed Lines */
+ if (pAST->ENGCaps & ENG_CAP_DashedLine)
+ {
+ infoPtr->SetupForDashedLine = ASTSetupForDashedLine;
+ infoPtr->SubsequentDashedTwoPointLine = ASTSubsequentDashedTwoPointLine;
+ infoPtr->DashPatternMaxLength = 64;
+ infoPtr->DashedLineFlags = NO_PLANEMASK |
+ LINE_PATTERN_MSBFIRST_LSBJUSTIFIED;
+ }
+
+ /* 8x8 mono pattern fill */
+ if (pAST->ENGCaps & ENG_CAP_Mono8x8PatternFill)
+ {
+ infoPtr->SetupForMono8x8PatternFill = ASTSetupForMonoPatternFill;
+ infoPtr->SubsequentMono8x8PatternFillRect = ASTSubsequentMonoPatternFill;
+ infoPtr->Mono8x8PatternFillFlags = NO_PLANEMASK |
+ NO_TRANSPARENCY |
+ HARDWARE_PATTERN_SCREEN_ORIGIN |
+ HARDWARE_PATTERN_PROGRAMMED_BITS |
+ BIT_ORDER_IN_BYTE_MSBFIRST;
+ }
+
+ /* 8x8 color pattern fill */
+ if (pAST->ENGCaps & ENG_CAP_Color8x8PatternFill)
+ {
+ infoPtr->SetupForColor8x8PatternFill = ASTSetupForColor8x8PatternFill;
+ infoPtr->SubsequentColor8x8PatternFillRect = ASTSubsequentColor8x8PatternFillRect;
+ infoPtr->Color8x8PatternFillFlags = NO_PLANEMASK |
+ NO_TRANSPARENCY |
+ HARDWARE_PATTERN_SCREEN_ORIGIN;
+ }
+
+ /* CPU To Screen Color Expand */
+ if (pAST->ENGCaps & ENG_CAP_CPUToScreenColorExpand)
+ {
+ infoPtr->SetupForCPUToScreenColorExpandFill = ASTSetupForCPUToScreenColorExpandFill;
+ infoPtr->SubsequentCPUToScreenColorExpandFill = ASTSubsequentCPUToScreenColorExpandFill;
+ infoPtr->ColorExpandRange = MAX_PATReg_Size;
+ infoPtr->ColorExpandBase = MMIOREG_PAT;
+ infoPtr->CPUToScreenColorExpandFillFlags = NO_PLANEMASK |
+ BIT_ORDER_IN_BYTE_MSBFIRST;
+ }
+
+ /* Screen To Screen Color Expand */
+ if (pAST->ENGCaps & ENG_CAP_ScreenToScreenColorExpand)
+ {
+ infoPtr->SetupForScreenToScreenColorExpandFill = ASTSetupForScreenToScreenColorExpandFill;
+ infoPtr->SubsequentScreenToScreenColorExpandFill = ASTSubsequentScreenToScreenColorExpandFill;
+ infoPtr->ScreenToScreenColorExpandFillFlags = NO_PLANEMASK |
+ BIT_ORDER_IN_BYTE_MSBFIRST;
+ }
+
+ /* Clipping */
+ if (pAST->ENGCaps & ENG_CAP_Clipping)
+ {
+ infoPtr->SetClippingRectangle = ASTSetClippingRectangle;
+ infoPtr->DisableClipping = ASTDisableClipping;
+ infoPtr->ClippingFlags = HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY |
+ HARDWARE_CLIP_MONO_8x8_FILL |
+ HARDWARE_CLIP_COLOR_8x8_FILL |
+ HARDWARE_CLIP_SOLID_FILL |
+ HARDWARE_CLIP_SOLID_LINE |
+ HARDWARE_CLIP_DASHED_LINE |
+ HARDWARE_CLIP_SOLID_LINE;
+ }
+
+ return(XAAInit(pScreen, infoPtr));
+
+} /* end of ASTAccelInit */
+
+
+static void
+ASTSync(ScrnInfoPtr pScrn)
+{
+ ASTRecPtr pAST = ASTPTR(pScrn);
+
+ /* wait engle idle */
+ vWaitEngIdle(pScrn, pAST);
+
+} /* end of ASTSync */
+
+
+static void ASTSetupForScreenToScreenCopy(ScrnInfoPtr pScrn,
+ int xdir, int ydir, int rop,
+ unsigned int planemask, int trans_color)
+{
+
+ ASTRecPtr pAST = ASTPTR(pScrn);
+ PKT_SC *pSingleCMD;
+ ULONG cmdreg;
+
+/*
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSetupForScreenToScreenCopy\n");
+*/
+ /* Modify Reg. Value */
+ cmdreg = CMD_BITBLT;
+ switch (pAST->VideoModeInfo.bitsPerPixel)
+ {
+ case 8:
+ cmdreg |= CMD_COLOR_08;
+ break;
+ case 15:
+ case 16:
+ cmdreg |= CMD_COLOR_16;
+ break;
+ case 24:
+ case 32:
+ cmdreg |= CMD_COLOR_32;
+ break;
+ }
+ cmdreg |= (XAACopyROP[rop] << 8);
+ pAST->ulCMDReg = cmdreg;
+
+ if (!pAST->MMIO2D)
+ {
+ /* Write to CMDQ */
+ pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*2);
+
+ ASTSetupSRCPitch(pSingleCMD, pAST->VideoModeInfo.ScreenPitch);
+ pSingleCMD++;
+ ASTSetupDSTPitchHeight(pSingleCMD, pAST->VideoModeInfo.ScreenPitch, -1);
+ }
+ else
+ {
+ /* Write to MMIO */
+ ASTSetupSRCPitch_MMIO(pAST->VideoModeInfo.ScreenPitch);
+ ASTSetupDSTPitchHeight_MMIO(pAST->VideoModeInfo.ScreenPitch, -1);
+ }
+
+} /* end of ASTSetupForScreenToScreenCopy */
+
+static void
+ASTSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1, int x2,
+ int y2, int width, int height)
+{
+ ASTRecPtr pAST = ASTPTR(pScrn);
+ PKT_SC *pSingleCMD;
+ int src_x, src_y, dst_x, dst_y;
+ ULONG srcbase, dstbase, cmdreg;
+/*
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSubsequentScreenToScreenCopy\n");
+*/
+
+ /* Modify Reg. Value */
+ cmdreg = pAST->ulCMDReg;
+ if (pAST->EnableClip)
+ cmdreg |= CMD_ENABLE_CLIP;
+ srcbase = dstbase = 0;
+
+ if (y1 >= MAX_SRC_Y)
+ {
+ srcbase=pAST->VideoModeInfo.ScreenPitch*y1;
+ y1=0;
+ }
+
+ if (y2 >= pScrn->virtualY)
+ {
+ dstbase=pAST->VideoModeInfo.ScreenPitch*y2;
+ y2=0;
+ }
+
+ if (x1 < x2)
+ {
+ src_x = x1 + width - 1;
+ dst_x = x2 + width - 1;
+ cmdreg |= CMD_X_DEC;
+ }
+ else
+ {
+ src_x = x1;
+ dst_x = x2;
+ }
+
+ if (y1 < y2)
+ {
+ src_y = y1 + height - 1;
+ dst_y = y2 + height - 1;
+ cmdreg |= CMD_Y_DEC;
+ }
+ else
+ {
+ src_y = y1;
+ dst_y = y2;
+ }
+
+ if (!pAST->MMIO2D)
+ {
+ /* Write to CMDQ */
+ pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*6);
+
+ ASTSetupSRCBase(pSingleCMD, srcbase);
+ pSingleCMD++;
+ ASTSetupDSTBase(pSingleCMD, dstbase);
+ pSingleCMD++;
+ ASTSetupDSTXY(pSingleCMD, dst_x, dst_y);
+ pSingleCMD++;
+ ASTSetupSRCXY(pSingleCMD, src_x, src_y);
+ pSingleCMD++;
+ ASTSetupRECTXY(pSingleCMD, width, height);
+ pSingleCMD++;
+ ASTSetupCMDReg(pSingleCMD, cmdreg);
+
+ /* Update Write Pointer */
+ mUpdateWritePointer;
+
+ }
+ else
+ {
+ ASTSetupSRCBase_MMIO(srcbase);
+ ASTSetupDSTBase_MMIO(dstbase);
+ ASTSetupDSTXY_MMIO(dst_x, dst_y);
+ ASTSetupSRCXY_MMIO(src_x, src_y);
+ ASTSetupRECTXY_MMIO(width, height);
+ ASTSetupCMDReg_MMIO(cmdreg);
+
+ vWaitEngIdle(pScrn, pAST);
+ }
+
+} /* end of ASTSubsequentScreenToScreenCopy */
+
+static void
+ASTSetupForSolidFill(ScrnInfoPtr pScrn,
+ int color, int rop, unsigned int planemask)
+{
+
+ ASTRecPtr pAST = ASTPTR(pScrn);
+ PKT_SC *pSingleCMD;
+ ULONG cmdreg;
+
+/*
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSetupForSolidFill\n");
+*/
+ /* Modify Reg. Value */
+ cmdreg = CMD_BITBLT | CMD_PAT_FGCOLOR;
+ switch (pAST->VideoModeInfo.bitsPerPixel)
+ {
+ case 8:
+ cmdreg |= CMD_COLOR_08;
+ break;
+ case 15:
+ case 16:
+ cmdreg |= CMD_COLOR_16;
+ break;
+ case 24:
+ case 32:
+ cmdreg |= CMD_COLOR_32;
+ break;
+ }
+ cmdreg |= (XAAPatternROP[rop] << 8);
+ pAST->ulCMDReg = cmdreg;
+
+ if (!pAST->MMIO2D)
+ {
+ /* Write to CMDQ */
+ pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*2);
+
+ ASTSetupDSTPitchHeight(pSingleCMD, pAST->VideoModeInfo.ScreenPitch, -1);
+ pSingleCMD++;
+ ASTSetupFG(pSingleCMD, color);
+ }
+ else
+ {
+ ASTSetupDSTPitchHeight_MMIO(pAST->VideoModeInfo.ScreenPitch, -1);
+ ASTSetupFG_MMIO(color);
+ }
+
+} /* end of ASTSetupForSolidFill */
+
+
+static void
+ASTSubsequentSolidFillRect(ScrnInfoPtr pScrn,
+ int dst_x, int dst_y, int width, int height)
+{
+ ASTRecPtr pAST = ASTPTR(pScrn);
+ PKT_SC *pSingleCMD;
+ ULONG dstbase, cmdreg;
+/*
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSubsequentSolidFillRect\n");
+*/
+
+ /* Modify Reg. Value */
+ cmdreg = pAST->ulCMDReg;
+ if (pAST->EnableClip)
+ cmdreg |= CMD_ENABLE_CLIP;
+ dstbase = 0;
+
+ if (dst_y >= pScrn->virtualY)
+ {
+ dstbase=pAST->VideoModeInfo.ScreenPitch*dst_y;
+ dst_y=0;
+ }
+
+ if (!pAST->MMIO2D)
+ {
+ /* Write to CMDQ */
+ pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*4);
+
+ ASTSetupDSTBase(pSingleCMD, dstbase);
+ pSingleCMD++;
+ ASTSetupDSTXY(pSingleCMD, dst_x, dst_y);
+ pSingleCMD++;
+ ASTSetupRECTXY(pSingleCMD, width, height);
+ pSingleCMD++;
+ ASTSetupCMDReg(pSingleCMD, cmdreg);
+
+ /* Update Write Pointer */
+ mUpdateWritePointer;
+
+ }
+ else
+ {
+ ASTSetupDSTBase_MMIO(dstbase);
+ ASTSetupDSTXY_MMIO(dst_x, dst_y);
+ ASTSetupRECTXY_MMIO(width, height);
+ ASTSetupCMDReg_MMIO(cmdreg);
+
+ vWaitEngIdle(pScrn, pAST);
+
+ }
+
+
+} /* end of ASTSubsequentSolidFillRect */
+
+/* Line */
+static void ASTSetupForSolidLine(ScrnInfoPtr pScrn,
+ int color, int rop, unsigned int planemask)
+{
+
+ ASTRecPtr pAST = ASTPTR(pScrn);
+ PKT_SC *pSingleCMD;
+ ULONG cmdreg;
+/*
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSetupForSolidLine\n");
+*/
+ /* Modify Reg. Value */
+ cmdreg = CMD_BITBLT;
+ switch (pAST->VideoModeInfo.bitsPerPixel)
+ {
+ case 8:
+ cmdreg |= CMD_COLOR_08;
+ break;
+ case 15:
+ case 16:
+ cmdreg |= CMD_COLOR_16;
+ break;
+ case 24:
+ case 32:
+ cmdreg |= CMD_COLOR_32;
+ break;
+ }
+ cmdreg |= (XAAPatternROP[rop] << 8);
+ pAST->ulCMDReg = cmdreg;
+
+ if (!pAST->MMIO2D)
+ {
+ /* Write to CMDQ */
+ pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*3);
+
+ ASTSetupDSTPitchHeight(pSingleCMD, pAST->VideoModeInfo.ScreenPitch, -1);
+ pSingleCMD++;
+ ASTSetupFG(pSingleCMD, color);
+ pSingleCMD++;
+ ASTSetupBG(pSingleCMD, 0);
+
+ }
+ else
+ {
+ /* Write to MMIO */
+ ASTSetupDSTPitchHeight_MMIO(pAST->VideoModeInfo.ScreenPitch, -1);
+ ASTSetupFG_MMIO(color);
+ ASTSetupBG_MMIO(0);
+ }
+
+} /* end of ASTSetupForSolidLine */
+
+
+static void ASTSubsequentSolidHorVertLine(ScrnInfoPtr pScrn,
+ int x, int y, int len, int dir)
+{
+
+ ASTRecPtr pAST = ASTPTR(pScrn);
+ PKT_SC *pSingleCMD;
+ ULONG dstbase, cmdreg;
+ int width, height;
+/*
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSubsequentSolidHorVertLine\n");
+*/
+
+ /* Modify Reg. Value */
+ cmdreg = (pAST->ulCMDReg & (~CMD_MASK)) | CMD_BITBLT;
+ if (pAST->EnableClip)
+ cmdreg |= CMD_ENABLE_CLIP;
+ dstbase = 0;
+
+ if(dir == DEGREES_0) { /* horizontal */
+ width = len;
+ height = 1;
+ } else { /* vertical */
+ width = 1;
+ height = len;
+ }
+
+ if ((y + height) >= pScrn->virtualY)
+ {
+ dstbase=pAST->VideoModeInfo.ScreenPitch*y;
+ y=0;
+ }
+
+
+ if (!pAST->MMIO2D)
+ {
+ /* Write to CMDQ */
+ pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*4);
+
+ ASTSetupDSTBase(pSingleCMD, dstbase);
+ pSingleCMD++;
+ ASTSetupDSTXY(pSingleCMD, x, y);
+ pSingleCMD++;
+ ASTSetupRECTXY(pSingleCMD, width, height);
+ pSingleCMD++;
+ ASTSetupCMDReg(pSingleCMD, cmdreg);
+
+ /* Update Write Pointer */
+ mUpdateWritePointer;
+
+ }
+ else
+ {
+ ASTSetupDSTBase_MMIO(dstbase);
+ ASTSetupDSTXY_MMIO(x, y);
+ ASTSetupRECTXY_MMIO(width, height);
+ ASTSetupCMDReg_MMIO(cmdreg);
+
+ vWaitEngIdle(pScrn, pAST);
+
+ }
+
+
+} /* end of ASTSubsequentSolidHorVertLine */
+
+static void ASTSubsequentSolidTwoPointLine(ScrnInfoPtr pScrn,
+ int x1, int y1, int x2, int y2, int flags)
+{
+
+ ASTRecPtr pAST = ASTPTR(pScrn);
+ PKT_SC *pSingleCMD;
+ LINEPARAM dsLineParam;
+ _LINEInfo LineInfo;
+ ULONG dstbase, ulCommand;
+ ULONG miny, maxy;
+ USHORT usXM;
+/*
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSubsequentSolidTwoPointLine\n");
+*/
+
+ /* Modify Reg. Value */
+ ulCommand = (pAST->ulCMDReg & (~CMD_MASK)) | CMD_LINEDRAW;
+ if(flags & OMIT_LAST)
+ ulCommand |= CMD_NOT_DRAW_LAST_PIXEL;
+ else
+ ulCommand &= ~CMD_NOT_DRAW_LAST_PIXEL;
+ if (pAST->EnableClip)
+ ulCommand |= CMD_ENABLE_CLIP;
+ dstbase = 0;
+ miny = (y1 > y2) ? y2 : y1;
+ maxy = (y1 > y2) ? y1 : y2;
+ if(maxy >= pScrn->virtualY) {
+ dstbase = pAST->VideoModeInfo.ScreenPitch * miny;
+ y1 -= miny;
+ 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)
+ ulCommand |= CMD_X_DEC;
+ if (dsLineParam.dwLineAttributes & LINEPARAM_Y_DEC)
+ ulCommand |= CMD_Y_DEC;
+
+ usXM = (dsLineParam.dwLineAttributes & LINEPARAM_XM) ? 1:0;
+
+ if (!pAST->MMIO2D)
+ {
+ /* Write to CMDQ */
+ pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*7);
+
+ ASTSetupDSTBase(pSingleCMD, dstbase);
+ pSingleCMD++;
+ ASTSetupLineXY(pSingleCMD, dsLineParam.dsLineX, dsLineParam.dsLineY);
+ pSingleCMD++;
+ ASTSetupLineXMErrTerm(pSingleCMD, usXM , dsLineParam.dwErrorTerm);
+ pSingleCMD++;
+ ASTSetupLineWidth(pSingleCMD, dsLineParam.dsLineWidth);
+ pSingleCMD++;
+ ASTSetupLineK1Term(pSingleCMD, dsLineParam.dwK1Term);
+ pSingleCMD++;
+ ASTSetupLineK2Term(pSingleCMD, dsLineParam.dwK2Term);
+ pSingleCMD++;
+ ASTSetupCMDReg(pSingleCMD, ulCommand);
+
+ /* Update Write Pointer */
+ mUpdateWritePointer;
+
+ }
+ else
+ {
+ ASTSetupDSTBase_MMIO(dstbase);
+ ASTSetupLineXY_MMIO(dsLineParam.dsLineX, dsLineParam.dsLineY);
+ ASTSetupLineXMErrTerm_MMIO( usXM , dsLineParam.dwErrorTerm);
+ ASTSetupLineWidth_MMIO(dsLineParam.dsLineWidth);
+ ASTSetupLineK1Term_MMIO(dsLineParam.dwK1Term);
+ ASTSetupLineK2Term_MMIO(dsLineParam.dwK2Term);
+ ASTSetupCMDReg_MMIO(ulCommand);
+
+ vWaitEngIdle(pScrn, pAST);
+
+ }
+
+
+} /* end of ASTSubsequentSolidTwoPointLine */
+
+/* Dash Line */
+static void
+ASTSetupForDashedLine(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop, unsigned int planemask,
+ int length, UCHAR *pattern)
+{
+
+ ASTRecPtr pAST = ASTPTR(pScrn);
+ PKT_SC *pSingleCMD;
+ ULONG cmdreg;
+/*
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSetupForDashedLine\n");
+*/
+ /* Modify Reg. Value */
+ cmdreg = CMD_LINEDRAW | CMD_RESET_STYLE_COUNTER | CMD_ENABLE_LINE_STYLE;
+
+ switch (pAST->VideoModeInfo.bitsPerPixel)
+ {
+ case 8:
+ cmdreg |= CMD_COLOR_08;
+ break;
+ case 15:
+ case 16:
+ cmdreg |= CMD_COLOR_16;
+ break;
+ case 24:
+ case 32:
+ cmdreg |= CMD_COLOR_32;
+ break;
+ }
+ cmdreg |= (XAAPatternROP[rop] << 8);
+ if(bg == -1) {
+ cmdreg |= CMD_TRANSPARENT;
+ bg = 0;
+ }
+ cmdreg |= (((length-1) & 0x3F) << 24); /* line period */
+ pAST->ulCMDReg = cmdreg;
+
+ if (!pAST->MMIO2D)
+ {
+ /* Write to CMDQ */
+ pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*5);
+
+ ASTSetupDSTPitchHeight(pSingleCMD, pAST->VideoModeInfo.ScreenPitch, -1);
+ pSingleCMD++;
+ ASTSetupFG(pSingleCMD, fg);
+ pSingleCMD++;
+ ASTSetupBG(pSingleCMD, bg);
+ pSingleCMD++;
+ ASTSetupLineStyle1(pSingleCMD, *pattern);
+ pSingleCMD++;
+ ASTSetupLineStyle2(pSingleCMD, *(pattern+4));
+
+ }
+ else
+ {
+ /* Write to MMIO */
+ ASTSetupDSTPitchHeight_MMIO(pAST->VideoModeInfo.ScreenPitch, -1);
+ ASTSetupFG_MMIO(fg);
+ ASTSetupBG_MMIO(bg);
+ ASTSetupLineStyle1_MMIO(*pattern);
+ ASTSetupLineStyle2_MMIO(*(pattern+4));
+
+ }
+
+}
+
+static void
+ASTSubsequentDashedTwoPointLine(ScrnInfoPtr pScrn,
+ int x1, int y1, int x2, int y2,
+ int flags, int phase)
+{
+
+ ASTRecPtr pAST = ASTPTR(pScrn);
+ PKT_SC *pSingleCMD;
+ LINEPARAM dsLineParam;
+ _LINEInfo LineInfo;
+ ULONG dstbase, ulCommand;
+ ULONG miny, maxy;
+ USHORT usXM;
+/*
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSubsequentDashedTwoPointLine\n");
+*/
+
+ /* Modify Reg. Value */
+ ulCommand = pAST->ulCMDReg;
+ if(flags & OMIT_LAST)
+ ulCommand |= CMD_NOT_DRAW_LAST_PIXEL;
+ else
+ ulCommand &= ~CMD_NOT_DRAW_LAST_PIXEL;
+ if (pAST->EnableClip)
+ ulCommand |= CMD_ENABLE_CLIP;
+ dstbase = 0;
+ miny = (y1 > y2) ? y2 : y1;
+ maxy = (y1 > y2) ? y1 : y2;
+ if(maxy >= pScrn->virtualY) {
+ dstbase = pAST->VideoModeInfo.ScreenPitch * miny;
+ y1 -= miny;
+ 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)
+ ulCommand |= CMD_X_DEC;
+ if (dsLineParam.dwLineAttributes & LINEPARAM_Y_DEC)
+ ulCommand |= CMD_Y_DEC;
+
+ usXM = (dsLineParam.dwLineAttributes & LINEPARAM_XM) ? 1:0;
+
+ if (!pAST->MMIO2D)
+ {
+ /* Write to CMDQ */
+ pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*7);
+
+ ASTSetupDSTBase(pSingleCMD, dstbase);
+ pSingleCMD++;
+ ASTSetupLineXY(pSingleCMD, dsLineParam.dsLineX, dsLineParam.dsLineY);
+ pSingleCMD++;
+ ASTSetupLineXMErrTerm(pSingleCMD, usXM , dsLineParam.dwErrorTerm);
+ pSingleCMD++;
+ ASTSetupLineWidth(pSingleCMD, dsLineParam.dsLineWidth);
+ pSingleCMD++;
+ ASTSetupLineK1Term(pSingleCMD, dsLineParam.dwK1Term);
+ pSingleCMD++;
+ ASTSetupLineK2Term(pSingleCMD, dsLineParam.dwK2Term);
+ pSingleCMD++;
+ ASTSetupCMDReg(pSingleCMD, ulCommand);
+
+ /* Update Write Pointer */
+ mUpdateWritePointer;
+
+ }
+ else
+ {
+ ASTSetupDSTBase_MMIO(dstbase);
+ ASTSetupLineXY_MMIO(dsLineParam.dsLineX, dsLineParam.dsLineY);
+ ASTSetupLineXMErrTerm_MMIO( usXM , dsLineParam.dwErrorTerm);
+ ASTSetupLineWidth_MMIO(dsLineParam.dsLineWidth);
+ ASTSetupLineK1Term_MMIO(dsLineParam.dwK1Term);
+ ASTSetupLineK2Term_MMIO(dsLineParam.dwK2Term);
+ ASTSetupCMDReg_MMIO(ulCommand);
+
+ vWaitEngIdle(pScrn, pAST);
+
+ }
+
+}
+
+/* Mono Pattern Fill */
+static void
+ASTSetupForMonoPatternFill(ScrnInfoPtr pScrn,
+ int patx, int paty, int fg, int bg,
+ int rop, unsigned int planemask)
+{
+
+ ASTRecPtr pAST = ASTPTR(pScrn);
+ PKT_SC *pSingleCMD;
+ ULONG cmdreg;
+
+/*
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSetupForMonoPatternFill\n");
+*/
+ /* Modify Reg. Value */
+ cmdreg = CMD_BITBLT | CMD_PAT_MONOMASK;
+ switch (pAST->VideoModeInfo.bitsPerPixel)
+ {
+ case 8:
+ cmdreg |= CMD_COLOR_08;
+ break;
+ case 15:
+ case 16:
+ cmdreg |= CMD_COLOR_16;
+ break;
+ case 24:
+ case 32:
+ cmdreg |= CMD_COLOR_32;
+ break;
+ }
+ cmdreg |= (XAAPatternROP[rop] << 8);
+ pAST->ulCMDReg = cmdreg;
+
+ if (!pAST->MMIO2D)
+ {
+ /* Write to CMDQ */
+ pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*5);
+
+ ASTSetupDSTPitchHeight(pSingleCMD, pAST->VideoModeInfo.ScreenPitch, -1);
+ pSingleCMD++;
+ ASTSetupFG(pSingleCMD, fg);
+ pSingleCMD++;
+ ASTSetupBG(pSingleCMD, bg);
+ pSingleCMD++;
+ ASTSetupMONO1(pSingleCMD, patx);
+ pSingleCMD++;
+ ASTSetupMONO2(pSingleCMD, paty);
+ }
+ else
+ {
+ ASTSetupDSTPitchHeight_MMIO(pAST->VideoModeInfo.ScreenPitch, -1);
+ ASTSetupFG_MMIO(fg);
+ ASTSetupBG_MMIO(bg);
+ ASTSetupMONO1_MMIO(patx);
+ ASTSetupMONO2_MMIO(paty);
+ }
+
+} /* end of ASTSetupForMonoPatternFill */
+
+
+static void
+ASTSubsequentMonoPatternFill(ScrnInfoPtr pScrn,
+ int patx, int paty,
+ int dst_x, int dst_y, int width, int height)
+{
+ ASTRecPtr pAST = ASTPTR(pScrn);
+ PKT_SC *pSingleCMD;
+ ULONG dstbase, cmdreg;
+/*
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSubsequentMonoPatternFill\n");
+*/
+
+ /* Modify Reg. Value */
+ cmdreg = pAST->ulCMDReg;
+ if (pAST->EnableClip)
+ cmdreg |= CMD_ENABLE_CLIP;
+ dstbase = 0;
+
+ if (dst_y >= pScrn->virtualY)
+ {
+ dstbase=pAST->VideoModeInfo.ScreenPitch*dst_y;
+ dst_y=0;
+ }
+
+ if (!pAST->MMIO2D)
+ {
+ /* Write to CMDQ */
+ pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*4);
+
+ ASTSetupDSTBase(pSingleCMD, dstbase);
+ pSingleCMD++;
+ ASTSetupDSTXY(pSingleCMD, dst_x, dst_y);
+ pSingleCMD++;
+ ASTSetupRECTXY(pSingleCMD, width, height);
+ pSingleCMD++;
+ ASTSetupCMDReg(pSingleCMD, cmdreg);
+
+ /* Update Write Pointer */
+ mUpdateWritePointer;
+
+ }
+ else
+ {
+ ASTSetupDSTBase_MMIO(dstbase);
+ ASTSetupDSTXY_MMIO(dst_x, dst_y);
+ ASTSetupRECTXY_MMIO(width, height);
+ ASTSetupCMDReg_MMIO(cmdreg);
+
+ vWaitEngIdle(pScrn, pAST);
+ }
+
+} /* end of ASTSubsequentMonoPatternFill */
+
+static void
+ASTSetupForColor8x8PatternFill(ScrnInfoPtr pScrn, int patx, int paty,
+ int rop, unsigned int planemask, int trans_col)
+{
+
+ ASTRecPtr pAST = ASTPTR(pScrn);
+ PKT_SC *pSingleCMD;
+ ULONG cmdreg;
+ CARD32 *pataddr;
+ ULONG ulPatSize;
+ int i, j, cpp;
+/*
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSetupForColor8x8PatternFill\n");
+*/
+ /* Modify Reg. Value */
+ cmdreg = CMD_BITBLT | CMD_PAT_PATREG;
+ switch (pAST->VideoModeInfo.bitsPerPixel)
+ {
+ case 8:
+ cmdreg |= CMD_COLOR_08;
+ break;
+ case 15:
+ case 16:
+ cmdreg |= CMD_COLOR_16;
+ break;
+ case 24:
+ case 32:
+ cmdreg |= CMD_COLOR_32;
+ break;
+ }
+ cmdreg |= (XAAPatternROP[rop] << 8);
+ pAST->ulCMDReg = cmdreg;
+ cpp = (pScrn->bitsPerPixel + 1) / 8;
+ pataddr = (CARD32 *)(pAST->FBVirtualAddr +
+ (paty * pAST->VideoModeInfo.ScreenWidth) + (patx * cpp));
+ ulPatSize = 8*8*cpp;
+
+ if (!pAST->MMIO2D)
+ {
+ /* Write to CMDQ */
+ pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*(1 + ulPatSize/4));
+ ASTSetupDSTPitchHeight(pSingleCMD, pAST->VideoModeInfo.ScreenPitch, -1);
+ pSingleCMD++;
+ for (i=0; i<8; i++)
+ {
+ for (j=0; j<8*cpp/4; j++)
+ {
+ ASTSetupPatReg(pSingleCMD, (i*j + j) , (*(CARD32 *) (pataddr++)));
+ pSingleCMD++;
+ }
+ }
+ }
+ else
+ {
+ ASTSetupDSTPitchHeight_MMIO(pAST->VideoModeInfo.ScreenPitch, -1);
+ for (i=0; i<8; i++)
+ {
+ for (j=0; j<8*cpp/4; j++)
+ {
+ ASTSetupPatReg_MMIO((i*j + j) , (*(CARD32 *) (pataddr++)));
+ }
+ }
+
+ }
+
+} /* end of ASTSetupForColor8x8PatternFill */
+
+static void
+ASTSubsequentColor8x8PatternFillRect(ScrnInfoPtr pScrn, int patx, int paty,
+ int dst_x, int dst_y, int width, int height)
+{
+ ASTRecPtr pAST = ASTPTR(pScrn);
+ PKT_SC *pSingleCMD;
+ ULONG dstbase, cmdreg;
+/*
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSubsequentColor8x8PatternFillRect\n");
+*/
+
+ /* Modify Reg. Value */
+ cmdreg = pAST->ulCMDReg;
+ if (pAST->EnableClip)
+ cmdreg |= CMD_ENABLE_CLIP;
+ dstbase = 0;
+
+ if (dst_y >= pScrn->virtualY)
+ {
+ dstbase=pAST->VideoModeInfo.ScreenPitch*dst_y;
+ dst_y=0;
+ }
+
+ if (!pAST->MMIO2D)
+ {
+ /* Write to CMDQ */
+ pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*4);
+
+ ASTSetupDSTBase(pSingleCMD, dstbase);
+ pSingleCMD++;
+ ASTSetupDSTXY(pSingleCMD, dst_x, dst_y);
+ pSingleCMD++;
+ ASTSetupRECTXY(pSingleCMD, width, height);
+ pSingleCMD++;
+ ASTSetupCMDReg(pSingleCMD, cmdreg);
+
+ /* Update Write Pointer */
+ mUpdateWritePointer;
+
+ }
+ else
+ {
+ ASTSetupDSTBase_MMIO(dstbase);
+ ASTSetupDSTXY_MMIO(dst_x, dst_y);
+ ASTSetupRECTXY_MMIO(width, height);
+ ASTSetupCMDReg_MMIO(cmdreg);
+
+ vWaitEngIdle(pScrn, pAST);
+ }
+
+} /* ASTSubsequentColor8x8PatternFillRect */
+
+/* CPU to Screen Expand */
+static void
+ASTSetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn,
+ int fg, int bg,
+ int rop, unsigned int planemask)
+{
+
+ ASTRecPtr pAST = ASTPTR(pScrn);
+ PKT_SC *pSingleCMD;
+ ULONG cmdreg;
+
+/*
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSetupForCPUToScreenColorExpandFill\n");
+*/
+ /* Modify Reg. Value */
+ cmdreg = CMD_COLOREXP;
+ switch (pAST->VideoModeInfo.bitsPerPixel)
+ {
+ case 8:
+ cmdreg |= CMD_COLOR_08;
+ break;
+ case 15:
+ case 16:
+ cmdreg |= CMD_COLOR_16;
+ break;
+ case 24:
+ case 32:
+ cmdreg |= CMD_COLOR_32;
+ break;
+ }
+ cmdreg |= (XAAPatternROP[rop] << 8);
+ if(bg == -1) {
+ cmdreg |= CMD_FONT_TRANSPARENT;
+ bg = 0;
+ }
+ pAST->ulCMDReg = cmdreg;
+
+ if (!pAST->MMIO2D)
+ {
+ /* Write to CMDQ */
+ pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*3);
+
+ ASTSetupDSTPitchHeight(pSingleCMD, pAST->VideoModeInfo.ScreenPitch, -1);
+ pSingleCMD++;
+ ASTSetupFG(pSingleCMD, fg);
+ pSingleCMD++;
+ ASTSetupBG(pSingleCMD, bg);
+
+ }
+ else
+ {
+ ASTSetupDSTPitchHeight_MMIO(pAST->VideoModeInfo.ScreenPitch, -1);
+ ASTSetupFG_MMIO(fg);
+ ASTSetupBG_MMIO(bg);
+
+ }
+
+}
+
+static void
+ASTSubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn,
+ int dst_x, int dst_y,
+ int width, int height, int offset)
+{
+
+ ASTRecPtr pAST = ASTPTR(pScrn);
+ PKT_SC *pSingleCMD;
+ ULONG dstbase, cmdreg;
+
+/*
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSubsequentCPUToScreenColorExpandFill\n");
+*/
+
+ /* Modify Reg. Value */
+ cmdreg = pAST->ulCMDReg;
+ if (pAST->EnableClip)
+ cmdreg |= CMD_ENABLE_CLIP;
+ dstbase = 0;
+
+ if (dst_y >= pScrn->virtualY)
+ {
+ dstbase=pAST->VideoModeInfo.ScreenPitch*dst_y;
+ dst_y=0;
+ }
+
+ if (!pAST->MMIO2D)
+ {
+ /* Write to CMDQ */
+ pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*5);
+
+ ASTSetupSRCPitch(pSingleCMD, ((width+7)/8));
+ pSingleCMD++;
+ ASTSetupDSTBase(pSingleCMD, dstbase);
+ pSingleCMD++;
+ ASTSetupDSTXY(pSingleCMD, dst_x, dst_y);
+ pSingleCMD++;
+ ASTSetupRECTXY(pSingleCMD, width, height);
+ pSingleCMD++;
+ ASTSetupCMDReg(pSingleCMD, cmdreg);
+
+ /* Update Write Pointer */
+ mUpdateWritePointer;
+
+ }
+ else
+ {
+ ASTSetupSRCPitch_MMIO((width+7)/8);
+ ASTSetupDSTBase_MMIO(dstbase);
+ ASTSetupDSTXY_MMIO(dst_x, dst_y);
+ ASTSetupSRCXY_MMIO(0, 0);
+
+ ASTSetupRECTXY_MMIO(width, height);
+ ASTSetupCMDReg_MMIO(cmdreg);
+
+ vWaitEngIdle(pScrn, pAST);
+
+ }
+
+}
+
+
+/* Screen to Screen Color Expand */
+static void
+ASTSetupForScreenToScreenColorExpandFill(ScrnInfoPtr pScrn,
+ int fg, int bg,
+ int rop, unsigned int planemask)
+{
+
+ ASTRecPtr pAST = ASTPTR(pScrn);
+ PKT_SC *pSingleCMD;
+ ULONG cmdreg;
+
+/*
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSetupForScreenToScreenColorExpandFill\n");
+*/
+
+ /* Modify Reg. Value */
+ cmdreg = CMD_ENHCOLOREXP;
+ switch (pAST->VideoModeInfo.bitsPerPixel)
+ {
+ case 8:
+ cmdreg |= CMD_COLOR_08;
+ break;
+ case 15:
+ case 16:
+ cmdreg |= CMD_COLOR_16;
+ break;
+ case 24:
+ case 32:
+ cmdreg |= CMD_COLOR_32;
+ break;
+ }
+ cmdreg |= (XAAPatternROP[rop] << 8);
+ if(bg == -1) {
+ cmdreg |= CMD_FONT_TRANSPARENT;
+ bg = 0;
+ }
+ pAST->ulCMDReg = cmdreg;
+
+ if (!pAST->MMIO2D)
+ {
+ /* Write to CMDQ */
+ pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*3);
+
+ ASTSetupDSTPitchHeight(pSingleCMD, pAST->VideoModeInfo.ScreenPitch, -1);
+ pSingleCMD++;
+ ASTSetupFG(pSingleCMD, fg);
+ pSingleCMD++;
+ ASTSetupBG(pSingleCMD, bg);
+
+ }
+ else
+ {
+ ASTSetupDSTPitchHeight_MMIO(pAST->VideoModeInfo.ScreenPitch, -1);
+ ASTSetupFG_MMIO(fg);
+ ASTSetupBG_MMIO(bg);
+
+ }
+
+}
+
+
+
+static void
+ASTSubsequentScreenToScreenColorExpandFill(ScrnInfoPtr pScrn,
+ int dst_x, int dst_y, int width, int height,
+ int src_x, int src_y, int offset)
+{
+ ASTRecPtr pAST = ASTPTR(pScrn);
+ PKT_SC *pSingleCMD;
+ ULONG srcbase, dstbase, cmdreg;
+ USHORT srcpitch;
+
+/*
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSubsequentScreenToScreenColorExpandFill\n");
+*/
+
+ /* Modify Reg. Value */
+ cmdreg = pAST->ulCMDReg;
+ if (pAST->EnableClip)
+ cmdreg |= CMD_ENABLE_CLIP;
+ dstbase = 0;
+ if (dst_y >= pScrn->virtualY)
+ {
+ dstbase=pAST->VideoModeInfo.ScreenPitch*dst_y;
+ dst_y=0;
+ }
+ srcbase = pAST->VideoModeInfo.ScreenPitch*src_y + ((pScrn->bitsPerPixel+1)/8)*src_x;
+ srcpitch = (pScrn->displayWidth+7)/8;
+
+ if (!pAST->MMIO2D)
+ {
+ /* Write to CMDQ */
+ pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*6);
+
+ ASTSetupSRCBase(pSingleCMD, srcbase);
+ pSingleCMD++;
+ ASTSetupSRCPitch(pSingleCMD,srcpitch);
+ pSingleCMD++;
+ ASTSetupDSTBase(pSingleCMD, dstbase);
+ pSingleCMD++;
+ ASTSetupDSTXY(pSingleCMD, dst_x, dst_y);
+ pSingleCMD++;
+ ASTSetupRECTXY(pSingleCMD, width, height);
+ pSingleCMD++;
+ ASTSetupCMDReg(pSingleCMD, cmdreg);
+
+ /* Update Write Pointer */
+ mUpdateWritePointer;
+
+ }
+ else
+ {
+ ASTSetupSRCBase_MMIO(srcbase);
+ ASTSetupSRCPitch_MMIO(srcpitch);
+ ASTSetupDSTBase_MMIO(dstbase);
+ ASTSetupDSTXY_MMIO(dst_x, dst_y);
+ ASTSetupRECTXY_MMIO(width, height);
+ ASTSetupCMDReg_MMIO(cmdreg);
+
+ vWaitEngIdle(pScrn, pAST);
+
+ }
+
+}
+
+
+/* Clipping */
+static void
+ASTSetClippingRectangle(ScrnInfoPtr pScrn,
+ int left, int top, int right, int bottom)
+{
+
+ ASTRecPtr pAST = ASTPTR(pScrn);
+ PKT_SC *pSingleCMD;
+/*
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSetClippingRectangle\n");
+*/
+ pAST->EnableClip = TRUE;
+
+ if (!pAST->MMIO2D)
+ {
+ /* Write to CMDQ */
+ pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*2);
+
+ ASTSetupCLIP1(pSingleCMD, left, top);
+ pSingleCMD++;
+ ASTSetupCLIP2(pSingleCMD, right, bottom);
+ }
+ else
+ {
+ ASTSetupCLIP1_MMIO(left, top);
+ ASTSetupCLIP2_MMIO(right, bottom);
+ }
+
+}
+
+static void
+ASTDisableClipping(ScrnInfoPtr pScrn)
+{
+ ASTRecPtr pAST = ASTPTR(pScrn);
+/*
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTDisableClipping\n");
+*/
+ pAST->EnableClip = FALSE;
+}
+
+
+#endif /* end of Accel_2D */
diff --git a/src/ast_cursor.c b/src/ast_cursor.c new file mode 100644 index 0000000..fbbce1b --- /dev/null +++ b/src/ast_cursor.c @@ -0,0 +1,376 @@ +/* + * Copyright (c) 2005 ASPEED Technology Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the authors not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. The authors makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#include "xf86.h" +#include "xf86_ansic.h" +#include "xf86_OSproc.h" +#include "xf86Resources.h" +#include "xf86RAC.h" +#include "xf86cmap.h" +#include "compiler.h" +#include "mibstore.h" +#include "vgaHW.h" +#include "mipointer.h" +#include "micmap.h" + +#include "fb.h" +#include "regionstr.h" +#include "xf86xv.h" +#include "Xv.h" +#include "vbe.h" + +#include "xf86PciInfo.h" +#include "xf86Pci.h" + +/* framebuffer offscreen manager */ +#include "xf86fbman.h" + +/* include xaa includes */ +#include "xaa.h" +#include "xaarop.h" + +/* H/W cursor support */ +#include "xf86Cursor.h" +#include "cursorstr.h" + +/* Driver specific headers */ +#include "ast.h" + +#ifdef HWC +/* Prototype type declaration */ +Bool ASTCursorInit(ScreenPtr pScreen); +Bool bInitHWC(ScrnInfoPtr pScrn, ASTRecPtr pAST); +static void ASTShowCursor(ScrnInfoPtr pScrn); +static void ASTHideCursor(ScrnInfoPtr pScrn); +static void ASTSetCursorPosition(ScrnInfoPtr pScrn, int x, int y); +static void ASTSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg); +static void ASTLoadCursorImage(ScrnInfoPtr pScrn, UCHAR *src); +static Bool ASTUseHWCursor(ScreenPtr pScreen, CursorPtr pCurs); +static void ASTLoadCursorARGB(ScrnInfoPtr pScrn, CursorPtr pCurs); +static Bool ASTUseHWCursorARGB(ScreenPtr pScreen, CursorPtr pCurs); + +static void ASTFireCursor(ScrnInfoPtr pScrn); + +Bool +ASTCursorInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ASTRecPtr pAST = ASTPTR(pScrn); + xf86CursorInfoPtr infoPtr; + + infoPtr = xf86CreateCursorInfoRec(); + if(!infoPtr) return FALSE; + + pAST->HWCInfoPtr = infoPtr; + + infoPtr->Flags = HARDWARE_CURSOR_TRUECOLOR_AT_8BPP | + HARDWARE_CURSOR_INVERT_MASK | + HARDWARE_CURSOR_BIT_ORDER_MSBFIRST; + + infoPtr->MaxWidth = MAX_HWC_WIDTH; + infoPtr->MaxHeight = MAX_HWC_HEIGHT; + infoPtr->ShowCursor = ASTShowCursor; + infoPtr->HideCursor = ASTHideCursor; + infoPtr->SetCursorPosition = ASTSetCursorPosition; + infoPtr->SetCursorColors = ASTSetCursorColors; + infoPtr->LoadCursorImage = ASTLoadCursorImage; + infoPtr->UseHWCursor = ASTUseHWCursor; +#ifdef ARGB_CURSOR + infoPtr->UseHWCursorARGB = ASTUseHWCursorARGB; + infoPtr->LoadCursorARGB = ASTLoadCursorARGB; +#endif + + return(xf86InitCursor(pScreen, infoPtr)); + +} + +Bool bInitHWC(ScrnInfoPtr pScrn, ASTRecPtr pAST) +{ + ScreenPtr pScreen; + + /* init cursor cache info */ + /* Set HWC_NUM in Options instead */ + /* pAST->HWCInfo.HWC_NUM = DEFAULT_HWC_NUM; */ + pAST->HWCInfo.HWC_NUM_Next = 0; + + /* allocate HWC cache */ + if (!pAST->pHWCPtr) { + pScreen = screenInfo.screens[pScrn->scrnIndex]; + pAST->pHWCPtr = xf86AllocateOffscreenLinear (pScreen, (HWC_SIZE+HWC_SIGNATURE_SIZE)*pAST->HWCInfo.HWC_NUM, HWC_ALIGN, NULL, NULL, NULL); + + if (!pAST->pHWCPtr) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"Allocate HWC Cache failed \n"); + return (FALSE); + } + + pAST->HWCInfo.ulHWCOffsetAddr = pAST->pHWCPtr->offset*((pScrn->bitsPerPixel + 1) / 8); + pAST->HWCInfo.pjHWCVirtualAddr = pAST->FBVirtualAddr + pAST->HWCInfo.ulHWCOffsetAddr; + } + + return (TRUE); +} + + +static void +ASTShowCursor(ScrnInfoPtr pScrn) +{ + ASTRecPtr pAST = ASTPTR(pScrn); + UCHAR jReg; + + jReg= 0x02; + if (pAST->HWCInfo.cursortype ==HWC_COLOR) + jReg |= 0x01; + + SetIndexRegMask(CRTC_PORT, 0xCB, 0xFC, jReg); /* enable mono */ + +} + +static void +ASTHideCursor(ScrnInfoPtr pScrn) +{ + ASTRecPtr pAST = ASTPTR(pScrn); + + SetIndexRegMask(CRTC_PORT, 0xCB, 0xFC, 0x00); /* disable HWC */ + +} + +static void +ASTSetCursorPosition(ScrnInfoPtr pScrn, int x, int y) +{ + ASTRecPtr pAST = ASTPTR(pScrn); + DisplayModePtr mode = pAST->ModePtr; + int x_offset, y_offset; + + x_offset = pAST->HWCInfo.offset_x; + y_offset = pAST->HWCInfo.offset_y; + + if(x < 0) { + x_offset = (-x) + pAST->HWCInfo.offset_x; + x = 0; + } + + if(y < 0) { + y_offset = (-y) + pAST->HWCInfo.offset_y; + y = 0; + } + + if(mode->Flags & V_DBLSCAN) y *= 2; + + /* Set to Reg. */ + SetIndexReg(CRTC_PORT, 0xC2, (UCHAR) (x_offset)); + SetIndexReg(CRTC_PORT, 0xC3, (UCHAR) (y_offset)); + SetIndexReg(CRTC_PORT, 0xC4, (UCHAR) (x & 0xFF)); + SetIndexReg(CRTC_PORT, 0xC5, (UCHAR) ((x >> 8) & 0x0F)); + SetIndexReg(CRTC_PORT, 0xC6, (UCHAR) (y & 0xFF)); + SetIndexReg(CRTC_PORT, 0xC7, (UCHAR) ((y >> 8) & 0x07)); + + /* Fire HWC */ + ASTFireCursor(pScrn); + +} + +static void +ASTSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) +{ + ASTRecPtr pAST = ASTPTR(pScrn); + + pAST->HWCInfo.fg = (fg & 0x0F) | (((fg>>8) & 0x0F) << 4) | (((fg>>16) & 0x0F) << 8); + pAST->HWCInfo.bg = (bg & 0x0F) | (((bg>>8) & 0x0F) << 4) | (((bg>>16) & 0x0F) << 8); +} + +static void +ASTLoadCursorImage(ScrnInfoPtr pScrn, UCHAR *src) +{ + ASTRecPtr pAST = ASTPTR(pScrn); + int i, j, k; + UCHAR *pjSrcAnd, *pjSrcXor, *pjDstData; + ULONG ulTempDstAnd32[2], ulTempDstXor32[2], ulTempDstData32[2]; + UCHAR jTempSrcAnd32, jTempSrcXor32; + ULONG ulCheckSum = 0; + ULONG ulPatternAddr; + + /* init cursor info. */ + pAST->HWCInfo.cursortype = HWC_MONO; + pAST->HWCInfo.width = (USHORT) MAX_HWC_WIDTH; + pAST->HWCInfo.height = (USHORT) MAX_HWC_HEIGHT; + pAST->HWCInfo.offset_x = MAX_HWC_WIDTH - pAST->HWCInfo.width; + pAST->HWCInfo.offset_y = MAX_HWC_HEIGHT - pAST->HWCInfo.height; + + /* copy cursor image to cache */ + pjSrcXor = src; + pjSrcAnd = src + (MAX_HWC_WIDTH*MAX_HWC_HEIGHT/8); + pjDstData = pAST->HWCInfo.pjHWCVirtualAddr+(HWC_SIZE+HWC_SIGNATURE_SIZE)*pAST->HWCInfo.HWC_NUM_Next; + + for (j = 0; j < MAX_HWC_HEIGHT; j++) + { + for (i = 0; i < (MAX_HWC_WIDTH/8); i++ ) + { + for (k=7; k>0; k-=2) + { + jTempSrcAnd32 = *((UCHAR *) pjSrcAnd); + jTempSrcXor32 = *((UCHAR *) pjSrcXor); + ulTempDstAnd32[0] = ((jTempSrcAnd32 >> k) & 0x01) ? 0x00008000L:0x00L; + ulTempDstXor32[0] = ((jTempSrcXor32 >> k) & 0x01) ? 0x00004000L:0x00L; + ulTempDstData32[0] = ((jTempSrcXor32 >> k) & 0x01) ? pAST->HWCInfo.fg:pAST->HWCInfo.bg; + ulTempDstAnd32[1] = ((jTempSrcAnd32 >> (k-1)) & 0x01) ? 0x80000000L:0x00L; + ulTempDstXor32[1] = ((jTempSrcXor32 >> (k-1)) & 0x01) ? 0x40000000L:0x00L; + ulTempDstData32[1] = ((jTempSrcXor32 >> (k-1)) & 0x01) ? (pAST->HWCInfo.fg << 16):(pAST->HWCInfo.bg << 16); + *((ULONG *) pjDstData) = ulTempDstAnd32[0] | ulTempDstXor32[0] | ulTempDstData32[0] | ulTempDstAnd32[1] | ulTempDstXor32[1] | ulTempDstData32[1]; + ulCheckSum += *((ULONG *) pjDstData); + pjDstData += 4; + + } + pjSrcAnd ++; + pjSrcXor ++; + + } + + } + + /* Write Checksum as signature */ + pjDstData = (UCHAR *) pAST->HWCInfo.pjHWCVirtualAddr + (HWC_SIZE+HWC_SIGNATURE_SIZE)*pAST->HWCInfo.HWC_NUM_Next + HWC_SIZE; + *((ULONG *) pjDstData) = ulCheckSum; + + /* set pattern offset */ + ulPatternAddr = ((pAST->HWCInfo.ulHWCOffsetAddr+(HWC_SIZE+HWC_SIGNATURE_SIZE)*pAST->HWCInfo.HWC_NUM_Next) >> 3); + SetIndexReg(CRTC_PORT, 0xC8, (UCHAR) (ulPatternAddr & 0xFF)); + SetIndexReg(CRTC_PORT, 0xC9, (UCHAR) ((ulPatternAddr >> 8) & 0xFF)); + SetIndexReg(CRTC_PORT, 0xCA, (UCHAR) ((ulPatternAddr >> 16) & 0xFF)); + + /* update HWC_NUM_Next */ + pAST->HWCInfo.HWC_NUM_Next = (pAST->HWCInfo.HWC_NUM_Next+1) % pAST->HWCInfo.HWC_NUM; + +} + +static Bool +ASTUseHWCursor(ScreenPtr pScreen, CursorPtr pCurs) +{ + return TRUE; +} + +static void +ASTLoadCursorARGB(ScrnInfoPtr pScrn, CursorPtr pCurs) +{ + ASTRecPtr pAST = ASTPTR(pScrn); + + UCHAR *pjDstXor, *pjSrcXor; + ULONG i, j, ulSrcWidth, ulSrcHeight; + ULONG ulPerPixelCopy, ulTwoPixelCopy; + LONG lAlphaDstDelta, lLastAlphaDstDelta; + union + { + ULONG ul; + UCHAR b[4]; + } ulSrcData32[2], ulData32; + union + { + USHORT us; + UCHAR b[2]; + } usData16; + ULONG ulCheckSum = 0; + ULONG ulPatternAddr; + + /* init cursor info. */ + pAST->HWCInfo.cursortype = HWC_COLOR; + pAST->HWCInfo.width = pCurs->bits->width; + pAST->HWCInfo.height = pCurs->bits->height; + pAST->HWCInfo.offset_x = MAX_HWC_WIDTH - pAST->HWCInfo.width; + pAST->HWCInfo.offset_y = MAX_HWC_HEIGHT - pAST->HWCInfo.height; + + /* copy cursor image to cache */ + ulSrcWidth = pAST->HWCInfo.width; + ulSrcHeight = pAST->HWCInfo.height; + + lAlphaDstDelta = MAX_HWC_WIDTH << 1; + lLastAlphaDstDelta = lAlphaDstDelta - (ulSrcWidth << 1); + + pjSrcXor = (UCHAR *) pCurs->bits->argb;; + pjDstXor = (UCHAR *) pAST->HWCInfo.pjHWCVirtualAddr + (HWC_SIZE+HWC_SIGNATURE_SIZE)*pAST->HWCInfo.HWC_NUM_Next + + lLastAlphaDstDelta + (MAX_HWC_HEIGHT - ulSrcHeight) * lAlphaDstDelta; + + ulPerPixelCopy = ulSrcWidth & 1; + ulTwoPixelCopy = ulSrcWidth >> 1; + + for (j = 0; j < ulSrcHeight; j++) + { + + for (i = 0; i < ulTwoPixelCopy; i++ ) + { + ulSrcData32[0].ul = *((ULONG *) pjSrcXor) & 0xF0F0F0F0; + ulSrcData32[1].ul = *((ULONG *) (pjSrcXor+4)) & 0xF0F0F0F0; + ulData32.b[0] = ulSrcData32[0].b[1] | (ulSrcData32[0].b[0] >> 4); + ulData32.b[1] = ulSrcData32[0].b[3] | (ulSrcData32[0].b[2] >> 4); + ulData32.b[2] = ulSrcData32[1].b[1] | (ulSrcData32[1].b[0] >> 4); + ulData32.b[3] = ulSrcData32[1].b[3] | (ulSrcData32[1].b[2] >> 4); + *((ULONG *) pjDstXor) = ulData32.ul; + ulCheckSum += (ULONG) ulData32.ul; + pjDstXor += 4; + pjSrcXor += 8; + } + + for (i = 0; i < ulPerPixelCopy; i++ ) + { + ulSrcData32[0].ul = *((ULONG *) pjSrcXor) & 0xF0F0F0F0; + usData16.b[0] = ulSrcData32[0].b[1] | (ulSrcData32[0].b[0] >> 4); + usData16.b[1] = ulSrcData32[0].b[3] | (ulSrcData32[0].b[2] >> 4); + *((USHORT *) pjDstXor) = usData16.us; + ulCheckSum += (ULONG) usData16.us; + pjDstXor += 2; + pjSrcXor += 4; + } + + /* Point to next source and dest scans */ + pjDstXor += lLastAlphaDstDelta; + + } /* end of for-loop */ + + /* Write Checksum as signature */ + pjDstXor = (UCHAR *) pAST->HWCInfo.pjHWCVirtualAddr + (HWC_SIZE+HWC_SIGNATURE_SIZE)*pAST->HWCInfo.HWC_NUM_Next + HWC_SIZE; + *((ULONG *) pjDstXor) = ulCheckSum; + + /* set pattern offset */ + ulPatternAddr = ((pAST->HWCInfo.ulHWCOffsetAddr +(HWC_SIZE+HWC_SIGNATURE_SIZE)*pAST->HWCInfo.HWC_NUM_Next) >> 3); + SetIndexReg(CRTC_PORT, 0xC8, (UCHAR) (ulPatternAddr & 0xFF)); + SetIndexReg(CRTC_PORT, 0xC9, (UCHAR) ((ulPatternAddr >> 8) & 0xFF)); + SetIndexReg(CRTC_PORT, 0xCA, (UCHAR) ((ulPatternAddr >> 16) & 0xFF)); + + /* update HWC_NUM_Next */ + pAST->HWCInfo.HWC_NUM_Next = (pAST->HWCInfo.HWC_NUM_Next+1) % pAST->HWCInfo.HWC_NUM; + +} + +static Bool +ASTUseHWCursorARGB(ScreenPtr pScreen, CursorPtr pCurs) +{ + return TRUE; +} + +static void +ASTFireCursor(ScrnInfoPtr pScrn) +{ + ASTRecPtr pAST = ASTPTR(pScrn); + + SetIndexRegMask(CRTC_PORT, 0xCB, 0xFF, 0x00); /* dummp write to fire HWC */ + +} + +#endif /* End of HWC */ diff --git a/src/ast_cursor.h b/src/ast_cursor.h new file mode 100644 index 0000000..b513f3f --- /dev/null +++ b/src/ast_cursor.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2005 ASPEED Technology Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the authors not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. The authors makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#define MAX_HWC_WIDTH 64 +#define MAX_HWC_HEIGHT 64 +#define HWC_SIZE (MAX_HWC_WIDTH*MAX_HWC_HEIGHT*2) +#define HWC_SIGNATURE_SIZE 32 +#define HWC_ALIGN 32 + +#define HWC_MONO 0 +#define HWC_COLOR 1 diff --git a/src/ast_driver.c b/src/ast_driver.c new file mode 100644 index 0000000..44a57d3 --- /dev/null +++ b/src/ast_driver.c @@ -0,0 +1,1220 @@ +/* + * Copyright (c) 2005 ASPEED Technology Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the authors not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. The authors makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#include "xf86.h" +#include "xf86_ansic.h" +#include "xf86_OSproc.h" +#include "xf86Resources.h" +#include "xf86RAC.h" +#include "xf86cmap.h" +#include "compiler.h" +#include "mibstore.h" +#include "vgaHW.h" +#include "mipointer.h" +#include "micmap.h" + +#include "fb.h" +#include "regionstr.h" +#include "xf86xv.h" +#include "Xv.h" +#include "vbe.h" + +#include "xf86PciInfo.h" +#include "xf86Pci.h" + +/* framebuffer offscreen manager */ +#include "xf86fbman.h" + +/* include xaa includes */ +#include "xaa.h" +#include "xaarop.h" + +/* H/W cursor support */ +#include "xf86Cursor.h" + +/* Driver specific headers */ +#include "ast.h" + +/* external reference fucntion */ +extern Bool ASTMapMem(ScrnInfoPtr pScrn); +extern Bool ASTUnmapMem(ScrnInfoPtr pScrn); +extern Bool ASTMapMMIO(ScrnInfoPtr pScrn); +extern void ASTUnmapMMIO(ScrnInfoPtr pScrn); + +extern void vASTOpenKey(ScrnInfoPtr pScrn); +extern Bool bASTRegInit(ScrnInfoPtr pScrn); +extern ULONG GetVRAMInfo(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); +extern Bool ASTSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode); + +extern Bool bInitCMDQInfo(ScrnInfoPtr pScrn, ASTRecPtr pAST); +extern Bool bEnableCMDQ(ScrnInfoPtr pScrn, ASTRecPtr pAST); +extern void vDisable2D(ScrnInfoPtr pScrn, ASTRecPtr pAST); + +extern Bool ASTAccelInit(ScreenPtr pScreen); + +extern Bool ASTCursorInit(ScreenPtr pScreen); + +/* Mandatory functions */ +static void ASTIdentify(int flags); +const OptionInfoRec *ASTAvailableOptions(int chipid, int busid); +static Bool ASTProbe(DriverPtr drv, int flags); +static Bool ASTPreInit(ScrnInfoPtr pScrn, int flags); +static Bool ASTScreenInit(int Index, ScreenPtr pScreen, int argc, char **argv); +Bool ASTSwitchMode(int scrnIndex, DisplayModePtr mode, int flags); +void ASTAdjustFrame(int scrnIndex, int x, int y, int flags); +static Bool ASTEnterVT(int scrnIndex, int flags); +static void ASTLeaveVT(int scrnIndex, int flags); +static void ASTFreeScreen(int scrnIndex, int flags); +static ModeStatus ASTValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags); + +/* Internally used functions */ +static Bool ASTGetRec(ScrnInfoPtr pScrn); +static void ASTFreeRec(ScrnInfoPtr pScrn); +static Bool ASTSaveScreen(ScreenPtr pScreen, Bool unblack); +static Bool ASTCloseScreen(int scrnIndex, ScreenPtr pScreen); +static void ASTSave(ScrnInfoPtr pScrn); +static void ASTRestore(ScrnInfoPtr pScrn); +static void ASTProbeDDC(ScrnInfoPtr pScrn, int index); +static xf86MonPtr ASTDoDDC(ScrnInfoPtr pScrn, int index); +static void vFillASTModeInfo (ScrnInfoPtr pScrn); +static Bool ASTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); + +/* + * This is intentionally screen-independent. It indicates the binding + * choice made in the first PreInit. + */ +DriverRec AST = { + AST_VERSION, + AST_DRIVER_NAME, + ASTIdentify, + ASTProbe, + ASTAvailableOptions, + NULL, + 0 +}; + +/* Chipsets */ +static SymTabRec ASTChipsets[] = { + {PCI_CHIP_AST2000, "AST2000"}, + {-1, NULL} +}; + +static PciChipsets ASTPciChipsets[] = { + {PCI_CHIP_AST2000, PCI_CHIP_AST2000, RES_SHARED_VGA}, + {-1, -1, RES_UNDEFINED } +}; + +typedef enum { + OPTION_NOACCEL, + OPTION_MMIO2D, + OPTION_SW_CURSOR, + OPTION_HWC_NUM, + OPTION_ENG_CAPS, + OPTION_DBG_SELECT, + OPTION_NO_DDC, +} ASTOpts; + +static const OptionInfoRec ASTOptions[] = { + {OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_MMIO2D, "MMIO2D", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_SW_CURSOR, "SWCursor", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_HWC_NUM, "HWCNumber", OPTV_INTEGER, {0}, FALSE}, + {OPTION_ENG_CAPS, "ENGCaps", OPTV_INTEGER, {0}, FALSE}, + {OPTION_DBG_SELECT, "DBGSelect", OPTV_INTEGER, {0}, FALSE}, + {OPTION_NO_DDC, "NoDDC", OPTV_BOOLEAN, {0}, FALSE}, + {-1, NULL, OPTV_NONE, {0}, FALSE} +}; + +const char *vgahwSymbols[] = { + "vgaHWFreeHWRec", + "vgaHWGetHWRec", + "vgaHWGetIOBase", + "vgaHWGetIndex", + "vgaHWInit", + "vgaHWLock", + "vgaHWMapMem", + "vgaHWProtect", + "vgaHWRestore", + "vgaHWSave", + "vgaHWSaveScreen", + "vgaHWSetMmioFuncs", + "vgaHWUnlock", + "vgaHWUnmapMem", + NULL +}; + +const char *fbSymbols[] = { + "fbPictureInit", + "fbScreenInit", + NULL +}; + +const char *vbeSymbols[] = { + "VBEInit", + "VBEFreeModeInfo", + "VBEFreeVBEInfo", + "VBEGetModeInfo", + "VBEGetModePool", + "VBEGetVBEInfo", + "VBEGetVBEMode", + "VBEPrintModes", + "VBESaveRestore", + "VBESetDisplayStart", + "VBESetGetDACPaletteFormat", + "VBESetGetLogicalScanlineLength", + "VBESetGetPaletteData", + "VBESetModeNames", + "VBESetModeParameters", + "VBESetVBEMode", + "VBEValidateModes", + "vbeDoEDID", + "vbeFree", + NULL +}; + +#ifdef XFree86LOADER +static const char *vbeOptionalSymbols[] = { + "VBEDPMSSet", + "VBEGetPixelClock", + NULL +}; +#endif + +const char *ddcSymbols[] = { + "xf86PrintEDID", + "xf86SetDDCproperties", + NULL +}; + +const char *int10Symbols[] = { + "xf86ExecX86int10", + "xf86InitInt10", + "xf86Int10AllocPages", + "xf86int10Addr", + NULL +}; + +const char *xaaSymbols[] = { + "XAACreateInfoRec", + "XAADestroyInfoRec", + "XAAInit", + "XAACopyROP", + "XAAPatternROP", + NULL +}; + +const char *ramdacSymbols[] = { + "xf86CreateCursorInfoRec", + "xf86DestroyCursorInfoRec", + "xf86InitCursor", + NULL +}; + + +#ifdef XFree86LOADER + +static MODULESETUPPROTO(astSetup); + +static XF86ModuleVersionInfo astVersRec = { + AST_DRIVER_NAME, + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XF86_VERSION_CURRENT, + AST_MAJOR_VERSION, AST_MINOR_VERSION, AST_PATCH_VERSION, + ABI_CLASS_VIDEODRV, + ABI_VIDEODRV_VERSION, + MOD_CLASS_VIDEODRV, + {0, 0, 0, 0} +}; + +XF86ModuleData astModuleData = { &astVersRec, astSetup, NULL }; + +static pointer +astSetup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + static Bool setupDone = FALSE; + + /* This module should be loaded only once, but check to be sure. + */ + if (!setupDone) { + setupDone = TRUE; + xf86AddDriver(&AST, module, 0); + + /* + * Tell the loader about symbols from other modules that this module + * might refer to. + */ + LoaderRefSymLists(vgahwSymbols, + fbSymbols, xaaSymbols, ramdacSymbols, + vbeSymbols, vbeOptionalSymbols, + ddcSymbols, int10Symbols, NULL); + + /* + * The return value must be non-NULL on success even though there + * is no TearDownProc. + */ + return (pointer) TRUE; + } else { + if (errmaj) + *errmaj = LDR_ONCEONLY; + return NULL; + } +} + +#endif /* XFree86LOADER */ + +/* + * ASTIdentify -- + * + * Returns the string name for the driver based on the chipset. In this + * case it will always be an AST, so we can return a static string. + * + */ +static void +ASTIdentify(int flags) +{ + xf86PrintChipsets(AST_NAME, "Driver for AST Graphics Chipsets", + ASTChipsets); +} + +const OptionInfoRec * +ASTAvailableOptions(int chipid, int busid) +{ + + return ASTOptions; + +} + +/* + * ASTProbe -- + * + * Look through the PCI bus to find cards that are AST boards. + * Setup the dispatch table for the rest of the driver functions. + * + */ +static Bool +ASTProbe(DriverPtr drv, int flags) +{ + int i, numUsed, numDevSections, *usedChips; + Bool foundScreen = FALSE; + GDevPtr *devSections; + + /* + * Find the config file Device sections that match this + * driver, and return if there are none. + */ + if ((numDevSections = + xf86MatchDevice(AST_DRIVER_NAME, &devSections)) <= 0) { + return FALSE; + } + + /* + * This probing is just checking the PCI data the server already + * collected. + */ + if (xf86GetPciVideoInfo() == NULL) { + return FALSE; + } + + numUsed = xf86MatchPciInstances(AST_NAME, PCI_VENDOR_AST, + ASTChipsets, ASTPciChipsets, + devSections, numDevSections, + drv, &usedChips); + + xfree(devSections); + + if (flags & PROBE_DETECT) { + if (numUsed > 0) + foundScreen = TRUE; + } else { + for (i = 0; i < numUsed; i++) { + ScrnInfoPtr pScrn = NULL; + + /* Allocate new ScrnInfoRec and claim the slot */ + if ((pScrn = xf86ConfigPciEntity(pScrn, 0, usedChips[i], + ASTPciChipsets, 0, 0, 0, 0, 0))) + { + EntityInfoPtr pEnt; + + pEnt = xf86GetEntityInfo(usedChips[i]); + + pScrn->driverVersion = AST_VERSION; + pScrn->driverName = AST_DRIVER_NAME; + pScrn->name = AST_NAME; + + pScrn->Probe = ASTProbe; + pScrn->PreInit = ASTPreInit; + pScrn->ScreenInit = ASTScreenInit; + pScrn->SwitchMode = ASTSwitchMode; + pScrn->AdjustFrame = ASTAdjustFrame; + pScrn->EnterVT = ASTEnterVT; + pScrn->LeaveVT = ASTLeaveVT; + pScrn->FreeScreen = ASTFreeScreen; + pScrn->ValidMode = ASTValidMode; + + foundScreen = TRUE; + + } /* end of if */ + } /* end of for-loop */ + } /* end of if flags */ + + xfree(usedChips); + + return foundScreen; +} + +/* + * ASTPreInit -- + * + * Do initial setup of the board before we know what resolution we will + * be running at. + * + */ +static Bool +ASTPreInit(ScrnInfoPtr pScrn, int flags) +{ + EntityInfoPtr pEnt; + vgaHWPtr hwp; + int flags24; + rgb defaultWeight = { 0, 0, 0 }; + + ASTRecPtr pAST; + + ClockRangePtr clockRanges; + int i; + MessageType from; + + /* Suport one adapter only now */ + if (pScrn->numEntities != 1) + return FALSE; + + pEnt = xf86GetEntityInfo(pScrn->entityList[0]); + + if (flags & PROBE_DETECT) { + ASTProbeDDC(pScrn, pEnt->index); + return TRUE; + } + + if (pEnt->location.type != BUS_PCI) + return FALSE; + + if (xf86RegisterResources(pEnt->index, 0, ResExclusive)) + return FALSE; + + /* The vgahw module should be loaded here when needed */ + if (!xf86LoadSubModule(pScrn, "vgahw")) + return FALSE; + xf86LoaderReqSymLists(vgahwSymbols, NULL); + + /* The fb module should be loaded here when needed */ + if (!xf86LoadSubModule(pScrn, "fb")) + return FALSE; + xf86LoaderReqSymLists(fbSymbols, NULL); + + /* Allocate a vgaHWRec */ + if (!vgaHWGetHWRec(pScrn)) + return FALSE; + hwp = VGAHWPTR(pScrn); + + /* Color Depth Check */ + flags24 = Support32bppFb; + if (!xf86SetDepthBpp(pScrn, 0, 0, 0, flags24)) { + return FALSE; + } else { + switch (pScrn->depth) { + case 8: + case 16: + case 24: + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Given depth (%d) is not supported by ast driver\n", + pScrn->depth); + return FALSE; + } + } + xf86PrintDepthBpp(pScrn); + + switch (pScrn->bitsPerPixel) { + case 8: + case 16: + case 32: + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Given bpp (%d) is not supported by ast driver\n", + pScrn->bitsPerPixel); + return FALSE; + } + + /* fill pScrn misc. */ + pScrn->progClock = TRUE; + pScrn->rgbBits = 6; + pScrn->monitor = pScrn->confScreen->monitor; /* should be initialized before set gamma */ + pScrn->racMemFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT; + pScrn->racIoFlags = RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT; + + /* + * If the driver can do gamma correction, it should call xf86SetGamma() + * here. + */ + { + Gamma zeros = { 0.0, 0.0, 0.0 }; + + if (!xf86SetGamma(pScrn, zeros)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "call xf86SetGamma failed \n"); + return FALSE; + } + } + + + if (!xf86SetWeight(pScrn, defaultWeight, defaultWeight)) { + return FALSE; + } + + if (!xf86SetDefaultVisual(pScrn, -1)) { + return FALSE; + } + + /* Allocate driverPrivate */ + if (!ASTGetRec(pScrn)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "call ASTGetRec failed \n"); + return FALSE; + } + + /* Fill AST Info */ + pAST = ASTPTR(pScrn); + pAST->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); + pAST->PciInfo = xf86GetPciInfoForEntity(pAST->pEnt->index); + pAST->PciTag = pciTag(pAST->PciInfo->bus, pAST->PciInfo->device, + pAST->PciInfo->func); + + /* Process the options + * pScrn->confScreen, pScrn->display, pScrn->monitor, pScrn->numEntities, + * and pScrn->entityList should be initialized before + */ + xf86CollectOptions(pScrn, NULL); + if (!(pAST->Options = xalloc(sizeof(ASTOptions)))) + { + ASTFreeRec(pScrn); + return FALSE; + } + memcpy(pAST->Options, ASTOptions, sizeof(ASTOptions)); + xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pAST->Options); + + /* + * Set the Chipset and ChipRev, allowing config file entries to + * override. + */ + if (pAST->pEnt->device->chipset && *pAST->pEnt->device->chipset) { + pScrn->chipset = pAST->pEnt->device->chipset; + from = X_CONFIG; + } else if (pAST->pEnt->device->chipID >= 0) { + pScrn->chipset = (char *)xf86TokenToString(ASTChipsets, + pAST->pEnt->device->chipID); + from = X_CONFIG; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipID override: 0x%04X\n", + pAST->pEnt->device->chipID); + } else { + from = X_PROBED; + pScrn->chipset = (char *)xf86TokenToString(ASTChipsets, + pAST->PciInfo->chipType); + } + if (pAST->pEnt->device->chipRev >= 0) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n", + pAST->pEnt->device->chipRev); + } + + xf86DrvMsg(pScrn->scrnIndex, from, "Chipset: \"%s\"\n", + (pScrn->chipset != NULL) ? pScrn->chipset : "Unknown ast"); + + /* Resource Allocation */ +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,99,0,0) + pAST->IODBase = 0; +#else + pAST->IODBase = pScrn->domainIOBase; +#endif + /* "Patch" the PIOOffset inside vgaHW in order to force + * the vgaHW module to use our relocated i/o ports. + */ + VGAHWPTR(pScrn)->PIOOffset = pAST->PIOOffset = pAST->IODBase + pAST->PciInfo->ioBase[2] - 0x380; + + pAST->RelocateIO = (IOADDRESS)(pAST->PciInfo->ioBase[2] + pAST->IODBase); + + if (pAST->pEnt->device->MemBase != 0) { + pAST->FBPhysAddr = pAST->pEnt->device->MemBase; + from = X_CONFIG; + } else { + if (pAST->PciInfo->memBase[0] != 0) { + pAST->FBPhysAddr = pAST->PciInfo->memBase[0] & 0xFFF00000; + from = X_PROBED; + } else { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "No valid FB address in PCI config space\n"); + ASTFreeRec(pScrn); + return FALSE; + } + } + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Linear framebuffer at 0x%lX\n", + (unsigned long) pAST->FBPhysAddr); + + if (pAST->pEnt->device->IOBase != 0) { + pAST->MMIOPhysAddr = pAST->pEnt->device->IOBase; + from = X_CONFIG; + } else { + if (pAST->PciInfo->memBase[1]) { + pAST->MMIOPhysAddr = pAST->PciInfo->memBase[1] & 0xFFFF0000; + from = X_PROBED; + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "No valid MMIO address in PCI config space\n"); + ASTFreeRec(pScrn); + return FALSE; + } + } + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "IO registers at addr 0x%lX\n", + (unsigned long) pAST->MMIOPhysAddr); + + pScrn->videoRam = GetVRAMInfo(pScrn) / 1024; + from = X_DEFAULT; + + + if (pAST->pEnt->device->videoRam) { + pScrn->videoRam = pAST->pEnt->device->videoRam; + from = X_CONFIG; + } + + pAST->FbMapSize = pScrn->videoRam * 1024; + pAST->MMIOMapSize = DEFAULT_MMIO_SIZE; + + /* Do DDC + * should be done after xf86CollectOptions + */ + pScrn->monitor->DDC = ASTDoDDC(pScrn, pAST->pEnt->index); + + /* Mode Valid */ + clockRanges = xnfcalloc(sizeof(ClockRange), 1); + clockRanges->next = NULL; + clockRanges->minClock = 9500; + clockRanges->maxClock = 165000; + 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, + 200, 1200, + pScrn->display->virtualX, pScrn->display->virtualY, + pAST->FbMapSize, LOOKUP_BEST_REFRESH); + + if (i == -1) { + ASTFreeRec(pScrn); + return FALSE; + } + + xf86PruneDriverModes(pScrn); + + if (!i || !pScrn->modes) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n"); + ASTFreeRec(pScrn); + return FALSE; + } + + xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V); + + pScrn->currentMode = pScrn->modes; + + xf86PrintModes(pScrn); + + xf86SetDpi(pScrn, 0, 0); + + /* Accelaration Check */ + pAST->noAccel = TRUE; + pAST->AccelInfoPtr = NULL; + pAST->pCMDQPtr = NULL; + pAST->CMDQInfo.ulCMDQSize = 0; +#ifdef Accel_2D + if (!xf86ReturnOptValBool(pAST->Options, OPTION_NOACCEL, FALSE)) + { + if (!xf86LoadSubModule(pScrn, "xaa")) { + ASTFreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymLists(xaaSymbols, NULL); + + pAST->noAccel = FALSE; + + pAST->MMIO2D = TRUE; +#ifndef MMIO_2D + if (!xf86ReturnOptValBool(pAST->Options, OPTION_MMIO2D, FALSE)) { + pAST->CMDQInfo.ulCMDQSize = DEFAULT_CMDQ_SIZE; + pAST->MMIO2D = FALSE; + } +#endif + + pAST->ENGCaps = ENG_CAP_ALL; + if (!xf86GetOptValInteger(pAST->Options, OPTION_ENG_CAPS, &pAST->ENGCaps)) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "No ENG Capability options found\n"); + } + + pAST->DBGSelect = 0; + if (!xf86GetOptValInteger(pAST->Options, OPTION_DBG_SELECT, &pAST->DBGSelect)) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "No DBG Seleclt options found\n"); + } + } +#endif + + /* HW Cursor Check */ + pAST->noHWC = TRUE; + pAST->HWCInfoPtr = NULL; + pAST->pHWCPtr = NULL; +#ifdef HWC + if (!xf86ReturnOptValBool(pAST->Options, OPTION_SW_CURSOR, FALSE)) { + if (!xf86LoadSubModule(pScrn, "ramdac")) { + ASTFreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymLists(ramdacSymbols, NULL); + + pAST->noHWC = FALSE; + pAST->HWCInfo.HWC_NUM = DEFAULT_HWC_NUM; + if (!xf86GetOptValInteger(pAST->Options, OPTION_HWC_NUM, &pAST->HWCInfo.HWC_NUM)) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "No HWC_NUM options found\n"); + } + + } +#endif + + /* We won't be using the VGA access after the probe */ + xf86SetOperatingState(resVgaIo, pAST->pEnt->index, ResUnusedOpr); + xf86SetOperatingState(resVgaMem, pAST->pEnt->index, ResDisableOpr); + + return TRUE; +} + + +static Bool +ASTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) +{ + ScrnInfoPtr pScrn; + ASTRecPtr pAST; + vgaHWPtr hwp; + VisualPtr visual; + + /* for FB Manager */ + BoxRec FBMemBox; + int AvailFBSize; + + 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; */ + AvailFBSize = pAST->FbMapSize; + + FBMemBox.x1 = 0; + FBMemBox.y1 = 0; + FBMemBox.x2 = pScrn->displayWidth; + FBMemBox.y2 = (AvailFBSize / (pScrn->displayWidth * ((pScrn->bitsPerPixel+1)/8))) - 1; + + if (!xf86InitFBManager(pScreen, &FBMemBox)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to init memory manager\n"); + return FALSE; + } + + } + + vgaHWGetIOBase(hwp); + + vFillASTModeInfo (pScrn); + + ASTSave(pScrn); + if (!ASTModeInit(pScrn, pScrn->currentMode)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Mode Init Failed \n"); + return FALSE; + } + + ASTSaveScreen(pScreen, FALSE); + ASTAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + + miClearVisualTypes(); + + /* Re-implemented Direct Color support, -jens */ + if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth), + pScrn->rgbBits, pScrn->defaultVisual)) + return FALSE; + + if (!miSetPixmapDepths()) + { + ASTSaveScreen(pScreen, SCREEN_SAVER_OFF); + return FALSE; + } + + switch(pScrn->bitsPerPixel) { + case 8: + case 16: + case 32: + if (!fbScreenInit(pScreen, pAST->FBVirtualAddr + pScrn->fbOffset, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, + pScrn->displayWidth, pScrn->bitsPerPixel)) + return FALSE; + break; + default: + return FALSE; + + } + + if (pScrn->bitsPerPixel > 8) { + /* Fixup RGB ordering */ + visual = pScreen->visuals + pScreen->numVisuals; + while (--visual >= pScreen->visuals) { + if ((visual->class | DynamicClass) == DirectColor) { + visual->offsetRed = pScrn->offset.red; + visual->offsetGreen = pScrn->offset.green; + visual->offsetBlue = pScrn->offset.blue; + visual->redMask = pScrn->mask.red; + visual->greenMask = pScrn->mask.green; + visual->blueMask = pScrn->mask.blue; + } + } + } + + fbPictureInit(pScreen, 0, 0); + + xf86SetBlackWhitePixels(pScreen); + +#ifdef Accel_2D + if (!pAST->noAccel) + { + if (!ASTAccelInit(pScreen)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"Hardware acceleration initialization failed\n"); + pAST->noAccel = TRUE; + } + } +#endif /* end of Accel_2D */ + + miInitializeBackingStore(pScreen); + xf86SetBackingStore(pScreen); + xf86SetSilkenMouse(pScreen); + + miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); + + if (!pAST->noHWC) + { + if (!ASTCursorInit(pScreen)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"Hardware cursor initialization failed\n"); + pAST->noHWC = TRUE; + } + } + + if (!miCreateDefColormap(pScreen)) + return FALSE; + + if(!xf86HandleColormaps(pScreen, 256, (pScrn->depth == 8) ? 8 : pScrn->rgbBits, + vASTLoadPalette, NULL, + CMAP_PALETTED_TRUECOLOR | CMAP_RELOAD_ON_MODE_SWITCH)) { + return FALSE; + } + + xf86DPMSInit(pScreen, ASTDisplayPowerManagementSet, 0); + + pScreen->SaveScreen = ASTSaveScreen; + pAST->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = ASTCloseScreen; + + if (serverGeneration == 1) + xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); + + return TRUE; + +} /* ASTScreenInit */ + + +Bool +ASTSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + ASTRecPtr pAST = ASTPTR(pScrn); + +#ifdef HWC + if (pAST->pHWCPtr) { + xf86FreeOffscreenLinear(pAST->pHWCPtr); /* free HWC Cache */ + pAST->pHWCPtr = NULL; + } +#endif + +#ifdef Accel_2D + if (pAST->pCMDQPtr) { + xf86FreeOffscreenLinear(pAST->pCMDQPtr); /* free CMDQ */ + pAST->pCMDQPtr = NULL; + } + vDisable2D(pScrn, pAST); +#endif + + ASTRestore(pScrn); + + return ASTModeInit(pScrn, mode); + +} + +void +ASTAdjustFrame(int scrnIndex, int x, int y, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + ASTRecPtr pAST = ASTPTR(pScrn); + ULONG base; + + base = y * pAST->VideoModeInfo.ScreenWidth + x * ((pAST->VideoModeInfo.bitsPerPixel + 1) / 8); + base = base >> 2; /* DW unit */ + + vSetStartAddressCRT1(pAST, base); + +} + +/* enter into X Server */ +static Bool +ASTEnterVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + + if (!ASTModeInit(pScrn, pScrn->currentMode)) + return FALSE; + ASTAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + + return TRUE; + +} + +/* leave X server */ +static void +ASTLeaveVT(int scrnIndex, int flags) +{ + + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + vgaHWPtr hwp = VGAHWPTR(pScrn); + ASTRecPtr pAST = ASTPTR(pScrn); + +#ifdef HWC + if (pAST->pHWCPtr) { + xf86FreeOffscreenLinear(pAST->pHWCPtr); /* free HWC Cache */ + pAST->pHWCPtr = NULL; + } +#endif + +#ifdef Accel_2D + if (pAST->pCMDQPtr) { + xf86FreeOffscreenLinear(pAST->pCMDQPtr); /* free CMDQ */ + pAST->pCMDQPtr = NULL; + } + vDisable2D(pScrn, pAST); +#endif + + ASTRestore(pScrn); + vgaHWLock(hwp); + +} + +static void +ASTFreeScreen(int scrnIndex, int flags) +{ + ASTFreeRec(xf86Screens[scrnIndex]); + if (xf86LoaderCheckSymbol("vgaHWFreeHWRec")) + vgaHWFreeHWRec(xf86Screens[scrnIndex]); +} + + +static ModeStatus +ASTValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) +{ + + Bool Flags = MODE_NOMODE; + + if (mode->Flags & V_INTERLACE) { + if (verbose) { + xf86DrvMsg(scrnIndex, X_PROBED, + "Removing interlaced mode \"%s\"\n", mode->name); + } + return MODE_NO_INTERLACE; + } + + if ((mode->CrtcHDisplay > MAX_HResolution) || (mode->CrtcVDisplay > MAX_VResolution)) { + if (verbose) { + xf86DrvMsg(scrnIndex, X_PROBED, + "Removing the mode \"%s\"\n", mode->name); + } + return Flags; + } + + switch (mode->CrtcHDisplay) + { + case 640: + if (mode->CrtcVDisplay == 480) Flags=MODE_OK; + break; + case 800: + if (mode->CrtcVDisplay == 600) Flags=MODE_OK; + break; + case 1024: + if (mode->CrtcVDisplay == 768) Flags=MODE_OK; + break; + case 1280: + if (mode->CrtcVDisplay == 1024) Flags=MODE_OK; + break; + case 1600: + if (mode->CrtcVDisplay == 1200) Flags=MODE_OK; + break; + default: + return Flags; + } + + return Flags; + +} + + +/* Internal used modules */ +/* + * ASTGetRec and ASTFreeRec -- + * + * Private data for the driver is stored in the screen structure. + * These two functions create and destroy that private data. + * + */ +static Bool +ASTGetRec(ScrnInfoPtr pScrn) +{ + if (pScrn->driverPrivate) + return TRUE; + + pScrn->driverPrivate = xnfcalloc(sizeof(ASTRec), 1); + return TRUE; +} + +static void +ASTFreeRec(ScrnInfoPtr pScrn) +{ + if (!pScrn) + return; + if (!pScrn->driverPrivate) + return; + xfree(pScrn->driverPrivate); + pScrn->driverPrivate = 0; +} + +static Bool +ASTSaveScreen(ScreenPtr pScreen, Bool unblack) +{ + /* more ref. SiS */ + return vgaHWSaveScreen(pScreen, unblack); +} + +static Bool +ASTCloseScreen(int scrnIndex, ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + vgaHWPtr hwp = VGAHWPTR(pScrn); + ASTRecPtr pAST = ASTPTR(pScrn); + + if (pScrn->vtSema == TRUE) + { +#ifdef HWC + if (pAST->pHWCPtr) { + xf86FreeOffscreenLinear(pAST->pHWCPtr); /* free HWC Cache */ + pAST->pHWCPtr = NULL; + } +#endif + +#ifdef Accel_2D + if (pAST->pCMDQPtr) { + xf86FreeOffscreenLinear(pAST->pCMDQPtr); /* free CMDQ */ + pAST->pCMDQPtr = NULL; + } + vDisable2D(pScrn, pAST); +#endif + + ASTRestore(pScrn); + vgaHWLock(hwp); + } + + ASTUnmapMem(pScrn); + vgaHWUnmapMem(pScrn); + + if(pAST->AccelInfoPtr) { + XAADestroyInfoRec(pAST->AccelInfoPtr); + pAST->AccelInfoPtr = NULL; + } + + if(pAST->HWCInfoPtr) { + xf86DestroyCursorInfoRec(pAST->HWCInfoPtr); + pAST->HWCInfoPtr = NULL; + } + + pScrn->vtSema = FALSE; + pScreen->CloseScreen = pAST->CloseScreen; + return (*pScreen->CloseScreen) (scrnIndex, pScreen); +} + +static void +ASTSave(ScrnInfoPtr pScrn) +{ + ASTRecPtr pAST; + vgaRegPtr vgaReg; + ASTRegPtr astReg; + int i; + + pAST = ASTPTR(pScrn); + vgaReg = &VGAHWPTR(pScrn)->SavedReg; + astReg = &pAST->SavedReg; + + /* do save */ + vgaHWSave(pScrn, vgaReg, VGA_SR_ALL); + + /* Ext. Save */ + vASTOpenKey(pScrn); + + for (i=0; i<0x50; i++) + GetIndexReg(CRTC_PORT, (UCHAR) (i+0x80), astReg->ExtCRTC[i]); + +} + +static void +ASTRestore(ScrnInfoPtr pScrn) +{ + ASTRecPtr pAST; + vgaRegPtr vgaReg; + ASTRegPtr astReg; + int i; + + pAST = ASTPTR(pScrn); + vgaReg = &VGAHWPTR(pScrn)->SavedReg; + astReg = &pAST->SavedReg; + + /* do restore */ + vgaHWProtect(pScrn, TRUE); + vgaHWRestore(pScrn, vgaReg, VGA_SR_ALL); + vgaHWProtect(pScrn, FALSE); + + /* Ext. restore */ + vASTOpenKey(pScrn); + + for (i=0; i<0x50; i++) + SetIndexReg(CRTC_PORT, (UCHAR) (i+0x80), astReg->ExtCRTC[i]); + +} + +static void +ASTProbeDDC(ScrnInfoPtr pScrn, int index) +{ + vbeInfoPtr pVbe; + + if (xf86LoadSubModule(pScrn, "vbe")) { + pVbe = VBEInit(NULL, index); + ConfiguredMonitor = vbeDoEDID(pVbe, NULL); + vbeFree(pVbe); + } +} + +static xf86MonPtr +ASTDoDDC(ScrnInfoPtr pScrn, int index) +{ + vbeInfoPtr pVbe; + xf86MonPtr MonInfo = NULL; + ASTRecPtr pAST = ASTPTR(pScrn); + + /* Honour Option "noDDC" */ + if (xf86ReturnOptValBool(pAST->Options, OPTION_NO_DDC, FALSE)) { + return MonInfo; + } + + if (xf86LoadSubModule(pScrn, "vbe") && (pVbe = VBEInit(NULL, index))) { + xf86LoaderReqSymLists(vbeSymbols, NULL); + MonInfo = vbeDoEDID(pVbe, NULL); + xf86PrintEDID(MonInfo); + xf86SetDDCproperties(pScrn, MonInfo); + vbeFree(pVbe); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "this driver cannot do DDC without VBE\n"); + } + + return MonInfo; +} + +static void +vFillASTModeInfo (ScrnInfoPtr pScrn) +{ + ASTRecPtr pAST; + + pAST = ASTPTR(pScrn); + + pAST->VideoModeInfo.ScreenWidth = pScrn->virtualX; + pAST->VideoModeInfo.ScreenHeight = pScrn->virtualY; + pAST->VideoModeInfo.bitsPerPixel = pScrn->bitsPerPixel; + pAST->VideoModeInfo.ScreenPitch = pScrn->virtualX * ((pScrn->bitsPerPixel + 1) / 8) ; + +} + +static Bool +ASTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + vgaHWPtr hwp; + ASTRecPtr pAST; + + hwp = VGAHWPTR(pScrn); + pAST = ASTPTR(pScrn); + + vgaHWUnlock(hwp); + + if (!vgaHWInit(pScrn, mode)) + return FALSE; + + pScrn->vtSema = TRUE; + pAST->ModePtr = mode; + + if (!ASTSetMode(pScrn, mode)) + return FALSE; + + vgaHWProtect(pScrn, FALSE); + + return TRUE; +} diff --git a/src/ast_mode.c b/src/ast_mode.c new file mode 100644 index 0000000..94d2ef5 --- /dev/null +++ b/src/ast_mode.c @@ -0,0 +1,712 @@ +/* + * Copyright (c) 2005 ASPEED Technology Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the authors not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. The authors makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#include "xf86.h" +#include "xf86_ansic.h" +#include "xf86_OSproc.h" +#include "xf86Resources.h" +#include "xf86RAC.h" +#include "xf86cmap.h" +#include "compiler.h" +#include "mibstore.h" +#include "vgaHW.h" +#include "mipointer.h" +#include "micmap.h" + +#include "fb.h" +#include "regionstr.h" +#include "xf86xv.h" +#include "Xv.h" +#include "vbe.h" + +#include "xf86PciInfo.h" +#include "xf86Pci.h" + +/* framebuffer offscreen manager */ +#include "xf86fbman.h" + +/* include xaa includes */ +#include "xaa.h" +#include "xaarop.h" + +/* H/W cursor support */ +#include "xf86Cursor.h" + +/* Driver specific headers */ +#include "ast.h" + +VBIOS_STDTABLE_STRUCT StdTable[] = { + /* MD_2_3_400 */ + { + 0x67, + {0x00,0x03,0x00,0x02}, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0xbf,0x1f, + 0x00,0x4f,0x0d,0x0e,0x00,0x00,0x00,0x00, + 0x9c,0x8e,0x8f,0x28,0x1f,0x96,0xb9,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, + 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, + 0x0c,0x00,0x0f,0x08}, + {0x00,0x00,0x00,0x00,0x00,0x10,0x0e,0x00, + 0xff} + }, + /* Mode12/ExtEGATable */ + { + 0xe3, + {0x01,0x0f,0x00,0x06}, + {0x5f,0x4f,0x50,0x82,0x55,0x81,0x0b,0x3e, + 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, + 0xe9,0x8b,0xdf,0x28,0x00,0xe7,0x04,0xe3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x14,0x07, + 0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, + 0x01,0x00,0x0f,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f, + 0xff} + }, + /* ExtVGATable */ + { + 0x2f, + {0x01,0x0f,0x00,0x0e}, + {0x5f,0x4f,0x50,0x82,0x54,0x80,0x0b,0x3e, + 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, + 0xea,0x8c,0xdf,0x28,0x40,0xe7,0x04,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, + 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, + 0x01,0x00,0x00,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x40,0x05,0x0f, + 0xff} + }, + /* ExtHiCTable */ + { + 0x2f, + {0x01,0x0f,0x00,0x0e}, + {0x5f,0x4f,0x50,0x82,0x54,0x80,0x0b,0x3e, + 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, + 0xea,0x8c,0xdf,0x28,0x40,0xe7,0x04,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, + 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, + 0x01,0x00,0x00,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f, + 0xff} + }, + /* ExtTrueCTable */ + { + 0x2f, + {0x01,0x0f,0x00,0x0e}, + {0x5f,0x4f,0x50,0x82,0x54,0x80,0x0b,0x3e, + 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00, + 0xea,0x8c,0xdf,0x28,0x40,0xe7,0x04,0xa3, + 0xff}, + {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, + 0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, + 0x01,0x00,0x00,0x00}, + {0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x0f, + 0xff} + }, +}; + +VBIOS_ENHTABLE_STRUCT Res640x480Table[] = { + { 800, 640, 8, 96, 525, 480, 2, 2, VCLK28_322, /* 60Hz */ + (SyncNN | HBorder | VBorder | Charx8Dot), 60, 1, 0x2E }, + { 832, 640, 16, 40, 520, 480, 1, 3, VCLK31_5, /* 72Hz */ + (SyncNN | HBorder | VBorder | Charx8Dot), 72, 2, 0x2E }, + { 840, 640, 16, 64, 500, 480, 1, 3, VCLK31_5, /* 75Hz */ + (SyncNN | Charx8Dot) , 75, 3, 0x2E }, + { 832, 640, 56, 56, 509, 480, 1, 3, VCLK36, /* 85Hz */ + (SyncNN | Charx8Dot) , 85, 4, 0x2E }, + { 832, 640, 56, 56, 509, 480, 1, 3, VCLK36, /* end */ + (SyncNN | Charx8Dot) , 0xFF, 4, 0x2E }, +}; + + +VBIOS_ENHTABLE_STRUCT Res800x600Table[] = { + {1024, 800, 24, 72, 625, 600, 1, 2, VCLK36, /* 56Hz */ + (SyncPP | Charx8Dot), 56, 1, 0x30 }, + {1056, 800, 40, 128, 628, 600, 1, 4, VCLK40, /* 60Hz */ + (SyncPP | Charx8Dot), 60, 2, 0x30 }, + {1040, 800, 56, 120, 666, 600, 37, 6, VCLK50, /* 72Hz */ + (SyncPP | Charx8Dot), 72, 3, 0x30 }, + {1056, 800, 16, 80, 625, 600, 1, 3, VCLK49_5, /* 75Hz */ + (SyncPP | Charx8Dot), 75, 4, 0x30 }, + {1048, 800, 32, 64, 631, 600, 1, 3, VCLK56_25, /* 85Hz */ + (SyncPP | Charx8Dot), 85, 5, 0x30 }, + {1048, 800, 32, 64, 631, 600, 1, 3, VCLK56_25, /* end */ + (SyncPP | Charx8Dot), 0xFF, 5, 0x30 }, +}; + + +VBIOS_ENHTABLE_STRUCT Res1024x768Table[] = { + {1344, 1024, 24, 136, 806, 768, 3, 6, VCLK65, /* 60Hz */ + (SyncNN | Charx8Dot), 60, 1, 0x31 }, + {1328, 1024, 24, 136, 806, 768, 3, 6, VCLK75, /* 70Hz */ + (SyncNN | Charx8Dot), 70, 2, 0x31 }, + {1312, 1024, 16, 96, 800, 768, 1, 3, VCLK78_75, /* 75Hz */ + (SyncPP | Charx8Dot), 75, 3, 0x31 }, + {1376, 1024, 48, 96, 808, 768, 1, 3, VCLK94_5, /* 85Hz */ + (SyncPP | Charx8Dot), 85, 4, 0x31 }, + {1376, 1024, 48, 96, 808, 768, 1, 3, VCLK94_5, /* end */ + (SyncPP | Charx8Dot), 0xFF, 4, 0x31 }, +}; + +VBIOS_ENHTABLE_STRUCT Res1280x1024Table[] = { + {1688, 1280, 48, 112, 1066, 1024, 1, 3, VCLK108, /* 60Hz */ + (SyncPP | Charx8Dot), 60, 1, 0x32 }, + {1688, 1280, 16, 144, 1066, 1024, 1, 3, VCLK135, /* 75Hz */ + (SyncPP | Charx8Dot), 75, 2, 0x32 }, + {1728, 1280, 64, 160, 1072, 1024, 1, 3, VCLK157_5, /* 85Hz */ + (SyncPP | Charx8Dot), 85, 3, 0x32 }, + {1728, 1280, 64, 160, 1072, 1024, 1, 3, VCLK157_5, /* end */ + (SyncPP | Charx8Dot), 0xFF, 3, 0x32 }, +}; + +VBIOS_ENHTABLE_STRUCT Res1600x1200Table[] = { + {2160, 1600, 64, 192, 1250, 1200, 1, 3, VCLK162, /* 60Hz */ + (SyncPP | Charx8Dot), 60, 1, 0x33 }, + {2160, 1600, 64, 192, 1250, 1200, 1, 3, VCLK162, /* end */ + (SyncPP | Charx8Dot), 60, 1, 0x33 }, +}; + +VBIOS_DCLK_INFO DCLKTable [] = { + {0x2C, 0xE7, 0x03}, /* 00: VCLK25_175 */ + {0x95, 0x62, 0x03}, /* 01: VCLK28_322 */ + {0x67, 0x63, 0x01}, /* 02: VCLK31_5 */ + {0x76, 0x63, 0x01}, /* 03: VCLK36 */ + {0xEE, 0x67, 0x01}, /* 04: VCLK40 */ + {0x82, 0x62, 0x01}, /* 05: VCLK49_5 */ + {0xC6, 0x64, 0x01}, /* 06: VCLK50 */ + {0x94, 0x62, 0x01}, /* 07: VCLK56_25 */ + {0x80, 0x64, 0x00}, /* 08: VCLK65 */ + {0x7B, 0x63, 0x00}, /* 09: VCLK75 */ + {0x67, 0x62, 0x00}, /* 0A: VCLK78_75 */ + {0x7C, 0x62, 0x00}, /* 0B: VCLK94_5 */ + {0x8E, 0x62, 0x00}, /* 0C: VCLK108 */ + {0x85, 0x24, 0x00}, /* 0D: VCLK135 */ + {0x67, 0x22, 0x00}, /* 0E: VCLK157_5 */ + {0x6A, 0x22, 0x00}, /* 0F: VCLK162 */ +}; + +VBIOS_DAC_INFO DAC_TEXT[] = { + { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x2a }, { 0x00, 0x2a, 0x00 }, { 0x00, 0x2a, 0x2a }, + { 0x2a, 0x00, 0x00 }, { 0x2a, 0x00, 0x2a }, { 0x2a, 0x2a, 0x00 }, { 0x2a, 0x2a, 0x2a }, + { 0x00, 0x00, 0x15 }, { 0x00, 0x00, 0x3f }, { 0x00, 0x2a, 0x15 }, { 0x00, 0x2a, 0x3f }, + { 0x2a, 0x00, 0x15 }, { 0x2a, 0x00, 0x3f }, { 0x2a, 0x2a, 0x15 }, { 0x2a, 0x2a, 0x3f }, + { 0x00, 0x15, 0x00 }, { 0x00, 0x15, 0x2a }, { 0x00, 0x3f, 0x00 }, { 0x00, 0x3f, 0x2a }, + { 0x2a, 0x15, 0x00 }, { 0x2a, 0x15, 0x2a }, { 0x2a, 0x3f, 0x00 }, { 0x2a, 0x3f, 0x2a }, + { 0x00, 0x15, 0x15 }, { 0x00, 0x15, 0x3f }, { 0x00, 0x3f, 0x15 }, { 0x00, 0x3f, 0x3f }, + { 0x2a, 0x15, 0x15 }, { 0x2a, 0x15, 0x3f }, { 0x2a, 0x3f, 0x15 }, { 0x2a, 0x3f, 0x3f }, + { 0x15, 0x00, 0x00 }, { 0x15, 0x00, 0x2a }, { 0x15, 0x2a, 0x00 }, { 0x15, 0x2a, 0x2a }, + { 0x3f, 0x00, 0x00 }, { 0x3f, 0x00, 0x2a }, { 0x3f, 0x2a, 0x00 }, { 0x3f, 0x2a, 0x2a }, + { 0x15, 0x00, 0x15 }, { 0x15, 0x00, 0x3f }, { 0x15, 0x2a, 0x15 }, { 0x15, 0x2a, 0x3f }, + { 0x3f, 0x00, 0x15 }, { 0x3f, 0x00, 0x3f }, { 0x3f, 0x2a, 0x15 }, { 0x3f, 0x2a, 0x3f }, + { 0x15, 0x15, 0x00 }, { 0x15, 0x15, 0x2a }, { 0x15, 0x3f, 0x00 }, { 0x15, 0x3f, 0x2a }, + { 0x3f, 0x15, 0x00 }, { 0x3f, 0x15, 0x2a }, { 0x3f, 0x3f, 0x00 }, { 0x3f, 0x3f, 0x2a }, + { 0x15, 0x15, 0x15 }, { 0x15, 0x15, 0x3f }, { 0x15, 0x3f, 0x15 }, { 0x15, 0x3f, 0x3f }, + { 0x3f, 0x15, 0x15 }, { 0x3f, 0x15, 0x3f }, { 0x3f, 0x3f, 0x15 }, { 0x3f, 0x3f, 0x3f }, +}; + +VBIOS_DAC_INFO DAC_EGA[] = { + { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x2a }, { 0x00, 0x2a, 0x00 }, { 0x00, 0x2a, 0x2a }, + { 0x2a, 0x00, 0x00 }, { 0x2a, 0x00, 0x2a }, { 0x2a, 0x2a, 0x00 }, { 0x2a, 0x2a, 0x2a }, + { 0x00, 0x00, 0x15 }, { 0x00, 0x00, 0x3f }, { 0x00, 0x2a, 0x15 }, { 0x00, 0x2a, 0x3f }, + { 0x2a, 0x00, 0x15 }, { 0x2a, 0x00, 0x3f }, { 0x2a, 0x2a, 0x15 }, { 0x2a, 0x2a, 0x3f }, + { 0x00, 0x15, 0x00 }, { 0x00, 0x15, 0x2a }, { 0x00, 0x3f, 0x00 }, { 0x00, 0x3f, 0x2a }, + { 0x2a, 0x15, 0x00 }, { 0x2a, 0x15, 0x2a }, { 0x2a, 0x3f, 0x00 }, { 0x2a, 0x3f, 0x2a }, + { 0x00, 0x15, 0x15 }, { 0x00, 0x15, 0x3f }, { 0x00, 0x3f, 0x15 }, { 0x00, 0x3f, 0x3f }, + { 0x2a, 0x15, 0x15 }, { 0x2a, 0x15, 0x3f }, { 0x2a, 0x3f, 0x15 }, { 0x2a, 0x3f, 0x3f }, + { 0x15, 0x00, 0x00 }, { 0x15, 0x00, 0x2a }, { 0x15, 0x2a, 0x00 }, { 0x15, 0x2a, 0x2a }, + { 0x3f, 0x00, 0x00 }, { 0x3f, 0x00, 0x2a }, { 0x3f, 0x2a, 0x00 }, { 0x3f, 0x2a, 0x2a }, + { 0x15, 0x00, 0x15 }, { 0x15, 0x00, 0x3f }, { 0x15, 0x2a, 0x15 }, { 0x15, 0x2a, 0x3f }, + { 0x3f, 0x00, 0x15 }, { 0x3f, 0x00, 0x3f }, { 0x3f, 0x2a, 0x15 }, { 0x3f, 0x2a, 0x3f }, + { 0x15, 0x15, 0x00 }, { 0x15, 0x15, 0x2a }, { 0x15, 0x3f, 0x00 }, { 0x15, 0x3f, 0x2a }, + { 0x3f, 0x15, 0x00 }, { 0x3f, 0x15, 0x2a }, { 0x3f, 0x3f, 0x00 }, { 0x3f, 0x3f, 0x2a }, + { 0x15, 0x15, 0x15 }, { 0x15, 0x15, 0x3f }, { 0x15, 0x3f, 0x15 }, { 0x15, 0x3f, 0x3f }, + { 0x3f, 0x15, 0x15 }, { 0x3f, 0x15, 0x3f }, { 0x3f, 0x3f, 0x15 }, { 0x3f, 0x3f, 0x3f }, +}; + +VBIOS_DAC_INFO DAC_VGA[] = { + { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x2a }, { 0x00, 0x2a, 0x00 }, { 0x00, 0x2a, 0x2a }, + { 0x2a, 0x00, 0x00 }, { 0x2a, 0x00, 0x2a }, { 0x2a, 0x15, 0x00 }, { 0x2a, 0x2a, 0x2a }, + { 0x15, 0x15, 0x15 }, { 0x15, 0x15, 0x3f }, { 0x15, 0x3f, 0x15 }, { 0x15, 0x3f, 0x3f }, + { 0x3f, 0x15, 0x15 }, { 0x3f, 0x15, 0x3f }, { 0x3f, 0x3f, 0x15 }, { 0x3f, 0x3f, 0x3f }, + { 0x00, 0x00, 0x00 }, { 0x05, 0x05, 0x05 }, { 0x08, 0x08, 0x08 }, { 0x0b, 0x0b, 0x0b }, + { 0x0e, 0x0e, 0x0e }, { 0x11, 0x11, 0x11 }, { 0x14, 0x14, 0x14 }, { 0x18, 0x18, 0x18 }, + { 0x1c, 0x1c, 0x1c }, { 0x20, 0x20, 0x20 }, { 0x24, 0x24, 0x24 }, { 0x28, 0x28, 0x28 }, + { 0x2d, 0x2d, 0x2d }, { 0x32, 0x32, 0x32 }, { 0x38, 0x38, 0x38 }, { 0x3f, 0x3f, 0x3f }, + { 0x00, 0x00, 0x3f }, { 0x10, 0x00, 0x3f }, { 0x1f, 0x00, 0x3f }, { 0x2f, 0x00, 0x3f }, + { 0x3f, 0x00, 0x3f }, { 0x3f, 0x00, 0x2f }, { 0x3f, 0x00, 0x1f }, { 0x3f, 0x00, 0x10 }, + { 0x3f, 0x00, 0x00 }, { 0x3f, 0x10, 0x00 }, { 0x3f, 0x1f, 0x00 }, { 0x3f, 0x2f, 0x00 }, + { 0x3f, 0x3f, 0x00 }, { 0x2f, 0x3f, 0x00 }, { 0x1f, 0x3f, 0x00 }, { 0x10, 0x3f, 0x00 }, + { 0x00, 0x3f, 0x00 }, { 0x00, 0x3f, 0x10 }, { 0x00, 0x3f, 0x1f }, { 0x00, 0x3f, 0x2f }, + { 0x00, 0x3f, 0x3f }, { 0x00, 0x2f, 0x3f }, { 0x00, 0x1f, 0x3f }, { 0x00, 0x10, 0x3f }, + { 0x1f, 0x1f, 0x3f }, { 0x27, 0x1f, 0x3f }, { 0x2f, 0x1f, 0x3f }, { 0x37, 0x1f, 0x3f }, + { 0x3f, 0x1f, 0x3f }, { 0x3f, 0x1f, 0x37 }, { 0x3f, 0x1f, 0x2f }, { 0x3f, 0x1f, 0x27 }, + { 0x3f, 0x1f, 0x1f }, { 0x3f, 0x27, 0x1f }, { 0x3f, 0x2f, 0x1f }, { 0x3f, 0x37, 0x1f }, + { 0x3f, 0x3f, 0x1f }, { 0x37, 0x3f, 0x1f }, { 0x2f, 0x3f, 0x1f }, { 0x27, 0x3f, 0x1f }, + { 0x1f, 0x3f, 0x1f }, { 0x1f, 0x3f, 0x27 }, { 0x1f, 0x3f, 0x2f }, { 0x1f, 0x3f, 0x37 }, + { 0x1f, 0x3f, 0x3f }, { 0x1f, 0x37, 0x3f }, { 0x1f, 0x2f, 0x3f }, { 0x1f, 0x27, 0x3f }, + { 0x2d, 0x2d, 0x3f }, { 0x31, 0x2d, 0x3f }, { 0x36, 0x2d, 0x3f }, { 0x3a, 0x2d, 0x3f }, + { 0x3f, 0x2d, 0x3f }, { 0x3f, 0x2d, 0x3a }, { 0x3f, 0x2d, 0x36 }, { 0x3f, 0x2d, 0x31 }, + { 0x3f, 0x2d, 0x2d }, { 0x3f, 0x31, 0x2d }, { 0x3f, 0x36, 0x2d }, { 0x3f, 0x3a, 0x2d }, + { 0x3f, 0x3f, 0x2d }, { 0x3a, 0x3f, 0x2d }, { 0x36, 0x3f, 0x2d }, { 0x31, 0x3f, 0x2d }, + { 0x2d, 0x3f, 0x2d }, { 0x2d, 0x3f, 0x31 }, { 0x2d, 0x3f, 0x36 }, { 0x2d, 0x3f, 0x3a }, + { 0x2d, 0x3f, 0x3f }, { 0x2d, 0x3a, 0x3f }, { 0x2d, 0x36, 0x3f }, { 0x2d, 0x31, 0x3f }, + { 0x00, 0x00, 0x1c }, { 0x07, 0x00, 0x1c }, { 0x0e, 0x00, 0x1c }, { 0x15, 0x00, 0x1c }, + { 0x1c, 0x00, 0x1c }, { 0x1c, 0x00, 0x15 }, { 0x1c, 0x00, 0x0e }, { 0x1c, 0x00, 0x07 }, + { 0x1c, 0x00, 0x00 }, { 0x1c, 0x07, 0x00 }, { 0x1c, 0x0e, 0x00 }, { 0x1c, 0x15, 0x00 }, + { 0x1c, 0x1c, 0x00 }, { 0x15, 0x1c, 0x00 }, { 0x0e, 0x1c, 0x00 }, { 0x07, 0x1c, 0x00 }, + { 0x00, 0x1c, 0x00 }, { 0x00, 0x1c, 0x07 }, { 0x00, 0x1c, 0x0e }, { 0x00, 0x1c, 0x15 }, + { 0x00, 0x1c, 0x1c }, { 0x00, 0x15, 0x1c }, { 0x00, 0x0e, 0x1c }, { 0x00, 0x07, 0x1c }, + { 0x0e, 0x0e, 0x1c }, { 0x11, 0x0e, 0x1c }, { 0x15, 0x0e, 0x1c }, { 0x18, 0x0e, 0x1c }, + { 0x1c, 0x0e, 0x1c }, { 0x1c, 0x0e, 0x18 }, { 0x1c, 0x0e, 0x15 }, { 0x1c, 0x0e, 0x11 }, + { 0x1c, 0x0e, 0x0e }, { 0x1c, 0x11, 0x0e }, { 0x1c, 0x15, 0x0e }, { 0x1c, 0x18, 0x0e }, + { 0x1c, 0x1c, 0x0e }, { 0x18, 0x1c, 0x0e }, { 0x15, 0x1c, 0x0e }, { 0x11, 0x1c, 0x0e }, + { 0x0e, 0x1c, 0x0e }, { 0x0e, 0x1c, 0x11 }, { 0x0e, 0x1c, 0x15 }, { 0x0e, 0x1c, 0x18 }, + { 0x0e, 0x1c, 0x1c }, { 0x0e, 0x18, 0x1c }, { 0x0e, 0x15, 0x1c }, { 0x0e, 0x11, 0x1c }, + { 0x14, 0x14, 0x1c }, { 0x16, 0x14, 0x1c }, { 0x18, 0x14, 0x1c }, { 0x1a, 0x14, 0x1c }, + { 0x1c, 0x14, 0x1c }, { 0x1c, 0x14, 0x1a }, { 0x1c, 0x14, 0x18 }, { 0x1c, 0x14, 0x16 }, + { 0x1c, 0x14, 0x14 }, { 0x1c, 0x16, 0x14 }, { 0x1c, 0x18, 0x14 }, { 0x1c, 0x1a, 0x14 }, + { 0x1c, 0x1c, 0x14 }, { 0x1a, 0x1c, 0x14 }, { 0x18, 0x1c, 0x14 }, { 0x16, 0x1c, 0x14 }, + { 0x14, 0x1c, 0x14 }, { 0x14, 0x1c, 0x16 }, { 0x14, 0x1c, 0x18 }, { 0x14, 0x1c, 0x1a }, + { 0x14, 0x1c, 0x1c }, { 0x14, 0x1a, 0x1c }, { 0x14, 0x18, 0x1c }, { 0x14, 0x16, 0x1c }, + { 0x00, 0x00, 0x10 }, { 0x04, 0x00, 0x10 }, { 0x08, 0x00, 0x10 }, { 0x0c, 0x00, 0x10 }, + { 0x10, 0x00, 0x10 }, { 0x10, 0x00, 0x0c }, { 0x10, 0x00, 0x08 }, { 0x10, 0x00, 0x04 }, + { 0x10, 0x00, 0x00 }, { 0x10, 0x04, 0x00 }, { 0x10, 0x08, 0x00 }, { 0x10, 0x0c, 0x00 }, + { 0x10, 0x10, 0x00 }, { 0x0c, 0x10, 0x00 }, { 0x08, 0x10, 0x00 }, { 0x04, 0x10, 0x00 }, + { 0x00, 0x10, 0x00 }, { 0x00, 0x10, 0x04 }, { 0x00, 0x10, 0x08 }, { 0x00, 0x10, 0x0c }, + { 0x00, 0x10, 0x10 }, { 0x00, 0x0c, 0x10 }, { 0x00, 0x08, 0x10 }, { 0x00, 0x04, 0x10 }, + { 0x08, 0x08, 0x10 }, { 0x0a, 0x08, 0x10 }, { 0x0c, 0x08, 0x10 }, { 0x0e, 0x08, 0x10 }, + { 0x10, 0x08, 0x10 }, { 0x10, 0x08, 0x0e }, { 0x10, 0x08, 0x0c }, { 0x10, 0x08, 0x0a }, + { 0x10, 0x08, 0x08 }, { 0x10, 0x0a, 0x08 }, { 0x10, 0x0c, 0x08 }, { 0x10, 0x0e, 0x08 }, + { 0x10, 0x10, 0x08 }, { 0x0e, 0x10, 0x08 }, { 0x0c, 0x10, 0x08 }, { 0x0a, 0x10, 0x08 }, + { 0x08, 0x10, 0x08 }, { 0x08, 0x10, 0x0a }, { 0x08, 0x10, 0x0c }, { 0x08, 0x10, 0x0e }, + { 0x08, 0x10, 0x10 }, { 0x08, 0x0e, 0x10 }, { 0x08, 0x0c, 0x10 }, { 0x08, 0x0a, 0x10 }, + { 0x0b, 0x0b, 0x10 }, { 0x0c, 0x0b, 0x10 }, { 0x0d, 0x0b, 0x10 }, { 0x0f, 0x0b, 0x10 }, + { 0x10, 0x0b, 0x10 }, { 0x10, 0x0b, 0x0f }, { 0x10, 0x0b, 0x0d }, { 0x10, 0x0b, 0x0c }, + { 0x10, 0x0b, 0x0b }, { 0x10, 0x0c, 0x0b }, { 0x10, 0x0d, 0x0b }, { 0x10, 0x0f, 0x0b }, + { 0x10, 0x10, 0x0b }, { 0x0f, 0x10, 0x0b }, { 0x0d, 0x10, 0x0b }, { 0x0c, 0x10, 0x0b }, + { 0x0b, 0x10, 0x0b }, { 0x0b, 0x10, 0x0c }, { 0x0b, 0x10, 0x0d }, { 0x0b, 0x10, 0x0f }, + { 0x0b, 0x10, 0x10 }, { 0x0b, 0x0f, 0x10 }, { 0x0b, 0x0d, 0x10 }, { 0x0b, 0x0c, 0x10 }, + { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, + { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, +}; + +/* extern. function */ +extern void vASTOpenKey(ScrnInfoPtr pScrn); +extern Bool bASTRegInit(ScrnInfoPtr pScrn); +extern void vAST1000DisplayOn(ASTRecPtr pAST); +extern void vAST1000DisplayOff(ASTRecPtr pAST); + +extern Bool bEnable2D(ScrnInfoPtr pScrn, ASTRecPtr pAST); +extern void vDisable2D(ScrnInfoPtr pScrn, ASTRecPtr pAST); + +extern Bool bInitHWC(ScrnInfoPtr pScrn, ASTRecPtr pAST); + +/* Prototype type declaration*/ +Bool ASTSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode); +Bool bGetAST1000VGAModeInfo(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo); +void vSetStdReg(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo); +void vSetCRTCReg(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo); +void vSetOffsetReg(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo); +void vSetDCLKReg(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo); +void vSetExtReg(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo); +Bool bSetDACReg(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo); + +Bool +ASTSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + ASTRecPtr pAST; + VBIOS_MODE_INFO vgamodeinfo; + + pAST = ASTPTR(pScrn); + + vASTOpenKey(pScrn); + bASTRegInit(pScrn); + + /* pre set mode */ + bGetAST1000VGAModeInfo(pScrn, mode, &vgamodeinfo); + + /* set mode */ + vSetStdReg(pScrn, mode, &vgamodeinfo); + vSetCRTCReg(pScrn, mode, &vgamodeinfo); + vSetOffsetReg(pScrn, mode, &vgamodeinfo); + vSetDCLKReg(pScrn, mode, &vgamodeinfo); + vSetExtReg(pScrn, mode, &vgamodeinfo); + bSetDACReg(pScrn, mode, &vgamodeinfo); + + /* post set mode */ +#ifdef Accel_2D + if (!pAST->noAccel) { + if (!bEnable2D(pScrn, pAST)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"Enable 2D failed\n"); + pAST->noAccel = TRUE; + } + } +#endif +#ifdef HWC + if (!pAST->noHWC) { + if (!bInitHWC(pScrn, pAST)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"Init HWC failed\n"); + pAST->noHWC = TRUE; + } + } +#endif + vAST1000DisplayOn(pAST); + + return (TRUE); +} + + +Bool bGetAST1000VGAModeInfo(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo) +{ + ASTRecPtr pAST; + ULONG ulModeID, ulColorIndex, ulRefreshRate, ulRefreshRateIndex = 0; + ULONG ulHBorder, ulVBorder; + + pAST = ASTPTR(pScrn); + + switch (pScrn->bitsPerPixel) + { + case 8: + pVGAModeInfo->pStdTableEntry = (PVBIOS_STDTABLE_STRUCT) &StdTable[VGAModeIndex]; + ulColorIndex = VGAModeIndex-1; + break; + case 16: + pVGAModeInfo->pStdTableEntry = (PVBIOS_STDTABLE_STRUCT) &StdTable[HiCModeIndex]; + ulColorIndex = HiCModeIndex-1; + break; + case 24: + case 32: + pVGAModeInfo->pStdTableEntry = (PVBIOS_STDTABLE_STRUCT) &StdTable[TrueCModeIndex]; + ulColorIndex = TrueCModeIndex-1; + break; + default: + return (FALSE); + } + + switch (mode->CrtcHDisplay) + { + case 640: + pVGAModeInfo->pEnhTableEntry = (PVBIOS_ENHTABLE_STRUCT) &Res640x480Table[ulRefreshRateIndex]; + break; + case 800: + pVGAModeInfo->pEnhTableEntry = (PVBIOS_ENHTABLE_STRUCT) &Res800x600Table[ulRefreshRateIndex]; + break; + case 1024: + pVGAModeInfo->pEnhTableEntry = (PVBIOS_ENHTABLE_STRUCT) &Res1024x768Table[ulRefreshRateIndex]; + break; + case 1280: + pVGAModeInfo->pEnhTableEntry = (PVBIOS_ENHTABLE_STRUCT) &Res1280x1024Table[ulRefreshRateIndex]; + break; + case 1600: + pVGAModeInfo->pEnhTableEntry = (PVBIOS_ENHTABLE_STRUCT) &Res1600x1200Table[ulRefreshRateIndex]; + break; + default: + return (FALSE); + } + + /* Get Proper Mode Index */ + ulRefreshRate = (mode->Clock * 1000) / (mode->HTotal * mode->VTotal); + + while (pVGAModeInfo->pEnhTableEntry->ulRefreshRate < ulRefreshRate) + { + pVGAModeInfo->pEnhTableEntry++; + if ((pVGAModeInfo->pEnhTableEntry->ulRefreshRate > ulRefreshRate) || + (pVGAModeInfo->pEnhTableEntry->ulRefreshRate == 0xFF)) + { + pVGAModeInfo->pEnhTableEntry--; + break; + } + } + + /* Update mode CRTC info */ + ulHBorder = (pVGAModeInfo->pEnhTableEntry->Flags & HBorder) ? 1:0; + ulVBorder = (pVGAModeInfo->pEnhTableEntry->Flags & VBorder) ? 1:0; + + mode->CrtcHTotal = (int) pVGAModeInfo->pEnhTableEntry->HT; + mode->CrtcHBlankStart = (int) (pVGAModeInfo->pEnhTableEntry->HDE + ulHBorder); + mode->CrtcHBlankEnd = (int) (pVGAModeInfo->pEnhTableEntry->HT - ulHBorder); + mode->CrtcHSyncStart = (int) (pVGAModeInfo->pEnhTableEntry->HDE + ulHBorder + + pVGAModeInfo->pEnhTableEntry->HFP); + mode->CrtcHSyncEnd = (int) (pVGAModeInfo->pEnhTableEntry->HDE + ulHBorder + + pVGAModeInfo->pEnhTableEntry->HFP + + pVGAModeInfo->pEnhTableEntry->HSYNC); + + mode->CrtcVTotal = (int) pVGAModeInfo->pEnhTableEntry->VT; + mode->CrtcVBlankStart = (int) (pVGAModeInfo->pEnhTableEntry->VDE + ulVBorder); + mode->CrtcVBlankEnd = (int) (pVGAModeInfo->pEnhTableEntry->VT - ulVBorder); + mode->CrtcVSyncStart = (int) (pVGAModeInfo->pEnhTableEntry->VDE + ulVBorder + + pVGAModeInfo->pEnhTableEntry->VFP); + mode->CrtcVSyncEnd = (int) (pVGAModeInfo->pEnhTableEntry->VDE + ulVBorder + + pVGAModeInfo->pEnhTableEntry->VFP + + pVGAModeInfo->pEnhTableEntry->VSYNC); + + /* Write mode info to scratch */ + ulRefreshRateIndex = pVGAModeInfo->pEnhTableEntry->ulRefreshRateIndex; + ulModeID = pVGAModeInfo->pEnhTableEntry->ulModeID; + + SetIndexReg(CRTC_PORT, 0x8C, (UCHAR) ((ulColorIndex & 0x0F) << 4)); + SetIndexReg(CRTC_PORT, 0x8D, (UCHAR) (ulRefreshRateIndex & 0xFF)); + SetIndexReg(CRTC_PORT, 0x8E, (UCHAR) (ulModeID & 0xFF)); + + return (TRUE); +} + +void vSetStdReg(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo) +{ + + PVBIOS_STDTABLE_STRUCT pStdModePtr; + ASTRecPtr pAST; + ULONG i; + UCHAR jReg; + + pStdModePtr = pVGAModeInfo->pStdTableEntry; + pAST = ASTPTR(pScrn); + + /* Set Misc */ + jReg = pStdModePtr->MISC; + SetReg(MISC_PORT_WRITE,jReg); + + /* Set Seq */ + SetIndexReg(SEQ_PORT,0x00, 0x03); + for (i=0; i<4; i++) + { + jReg = pStdModePtr->SEQ[i]; + if (!i) (jReg |= 0x20); /* display off */ + SetIndexReg(SEQ_PORT,(UCHAR) (i+1), jReg); + } + + /* Set CRTC */ + SetIndexRegMask(CRTC_PORT,0x11, 0x7F, 0x00); + for (i=0; i<25; i++) + { + jReg = pStdModePtr->CRTC[i]; + SetIndexReg(CRTC_PORT,(UCHAR) i, jReg); + } + + /* Set AR */ + jReg = GetReg(INPUT_STATUS1_READ); + for (i=0; i<20; i++) + { + jReg = pStdModePtr->AR[i]; + SetReg(AR_PORT_WRITE, (UCHAR) i); + SetReg(AR_PORT_WRITE, jReg); + } + SetReg(AR_PORT_WRITE, 0x14); + SetReg(AR_PORT_WRITE, 0x00); + + jReg = GetReg(INPUT_STATUS1_READ); + SetReg (AR_PORT_WRITE, 0x20); /* set POS */ + + /* Set GR */ + for (i=0; i<9; i++) + { + SetIndexReg(GR_PORT,(UCHAR) i, jReg); + + } + + +} + +void +vSetCRTCReg(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo) +{ + ASTRecPtr pAST; + USHORT usTemp; + UCHAR jReg05, jReg07, jReg09, jRegAC, jRegAD, jRegAE; + + pAST = ASTPTR(pScrn); + jReg05 = jReg07 = jReg09 = jRegAC = jRegAD = jRegAE = 0; + + /* unlock CRTC */ + SetIndexRegMask(CRTC_PORT,0x11, 0x7F, 0x00); + + /* Horizontal Timing Programming */ + usTemp = (mode->CrtcHTotal >> 3) - 5; + if (usTemp & 0x100) jRegAC |= 0x01; /* HT D[8] */ + SetIndexRegMask(CRTC_PORT,0x00, 0x00, (UCHAR) usTemp); + usTemp = (mode->CrtcHDisplay >> 3) - 1; + if (usTemp & 0x100) jRegAC |= 0x04; /* HDE D[8] */ + SetIndexRegMask(CRTC_PORT,0x01, 0x00, (UCHAR) usTemp); + usTemp = (mode->CrtcHBlankStart >> 3) - 1; + if (usTemp & 0x100) jRegAC |= 0x10; /* HBS D[8] */ + SetIndexRegMask(CRTC_PORT,0x02, 0x00, (UCHAR) usTemp); + usTemp = ((mode->CrtcHBlankEnd >> 3) - 1) & 0x7F; + if (usTemp & 0x20) jReg05 |= 0x80; /* HBE D[5] */ + if (usTemp & 0x40) jRegAD |= 0x01; /* HBE D[6] */ + SetIndexRegMask(CRTC_PORT,0x03, 0xE0, (UCHAR) (usTemp & 0x1F)); + usTemp = (mode->CrtcHSyncStart >> 3 ); + if (usTemp & 0x100) jRegAC |= 0x40; /* HRS D[5] */ + SetIndexRegMask(CRTC_PORT,0x04, 0x00, (UCHAR) (usTemp)); + usTemp = (mode->CrtcHSyncEnd >> 3 ) & 0x3F; + if (usTemp & 0x20) jRegAD |= 0x04; /* HRE D[5] */ + SetIndexRegMask(CRTC_PORT,0x05, 0x60, (UCHAR) ((usTemp & 0x1F) | jReg05)); + + SetIndexRegMask(CRTC_PORT,0xAC, 0x00, (UCHAR) jRegAC); + SetIndexRegMask(CRTC_PORT,0xAD, 0x00, (UCHAR) jRegAD); + + /* Vetical Timing Programming */ + usTemp = (mode->CrtcVTotal) - 2; + if (usTemp & 0x100) jReg07 |= 0x01; /* VT D[8] */ + if (usTemp & 0x200) jReg07 |= 0x20; + if (usTemp & 0x400) jRegAE |= 0x01; /* VT D[10] */ + SetIndexRegMask(CRTC_PORT,0x06, 0x00, (UCHAR) usTemp); + usTemp = (mode->CrtcVSyncStart) - 1; + if (usTemp & 0x100) jReg07 |= 0x04; /* VRS D[8] */ + if (usTemp & 0x200) jReg07 |= 0x80; /* VRS D[9] */ + if (usTemp & 0x400) jRegAE |= 0x08; /* VRS D[10] */ + SetIndexRegMask(CRTC_PORT,0x10, 0x00, (UCHAR) usTemp); + usTemp = ((mode->CrtcVSyncEnd) - 1) & 0x3F; + if (usTemp & 0x10) jRegAE |= 0x20; /* VRE D[4] */ + if (usTemp & 0x20) jRegAE |= 0x40; /* VRE D[5] */ + SetIndexRegMask(CRTC_PORT,0x11, 0x70, (UCHAR) (usTemp & 0x0F)); + usTemp = (mode->CrtcVDisplay) - 1; + if (usTemp & 0x100) jReg07 |= 0x02; /* VDE D[8] */ + if (usTemp & 0x200) jReg07 |= 0x40; /* VDE D[9] */ + if (usTemp & 0x400) jRegAE |= 0x02; /* VDE D[10] */ + SetIndexRegMask(CRTC_PORT,0x12, 0x00, (UCHAR) usTemp); + usTemp = (mode->CrtcVBlankStart) - 1; + if (usTemp & 0x100) jReg07 |= 0x08; /* VBS D[8] */ + if (usTemp & 0x200) jReg09 |= 0x20; /* VBS D[9] */ + if (usTemp & 0x400) jRegAE |= 0x04; /* VBS D[10] */ + SetIndexRegMask(CRTC_PORT,0x15, 0x00, (UCHAR) usTemp); + usTemp = (mode->CrtcVBlankEnd) - 1 ; + if (usTemp & 0x100) jRegAE |= 0x10; /* VBE D[8] */ + SetIndexRegMask(CRTC_PORT,0x16, 0x00, (UCHAR) usTemp); + + SetIndexRegMask(CRTC_PORT,0x07, 0x00, (UCHAR) jReg07); + SetIndexRegMask(CRTC_PORT,0x09, 0xDF, (UCHAR) jReg09); + SetIndexRegMask(CRTC_PORT,0xAE, 0x00, (UCHAR) (jRegAE | 0x80)); /* disable line compare */ + + /* lock CRTC */ + SetIndexRegMask(CRTC_PORT,0x11, 0x7F, 0x80); + +} + +void vSetOffsetReg(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo) +{ + ASTRecPtr pAST; + USHORT usOffset; + + pAST = ASTPTR(pScrn); + + usOffset = pAST->VideoModeInfo.ScreenPitch >> 3; /* Unit: char */ + + SetIndexReg(CRTC_PORT,0x13, (UCHAR) (usOffset & 0xFF)); + SetIndexReg(CRTC_PORT,0xB0, (UCHAR) ((usOffset >> 8) & 0x3F)); + +} + +void vSetDCLKReg(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo) +{ + PVBIOS_ENHTABLE_STRUCT pEnhModePtr; + PVBIOS_DCLK_INFO pDCLKPtr; + ASTRecPtr pAST; + + pAST = ASTPTR(pScrn); + + pEnhModePtr = pVGAModeInfo->pEnhTableEntry; + pDCLKPtr = &DCLKTable[pEnhModePtr->DCLKIndex]; + + SetIndexRegMask(CRTC_PORT,0xC0, 0x00, pDCLKPtr->Param1); + SetIndexRegMask(CRTC_PORT,0xC1, 0x00, pDCLKPtr->Param2); + SetIndexRegMask(CRTC_PORT,0xBB, 0xCF, ((pDCLKPtr->Param3 & 0x03) << 4)); + +} + + +void vSetExtReg(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo) +{ + + ASTRecPtr pAST; + UCHAR jRegA0, jRegA3, jRegA8; + + pAST = ASTPTR(pScrn); + + jRegA0=jRegA3=jRegA8=0; + /* Mode Type Setting */ + switch (pScrn->bitsPerPixel) { + case 8: + jRegA0 = 0x70; + jRegA3 = 0x01; + jRegA8 = 0x00; + break; + case 15: + case 16: + jRegA0 = 0x70; + jRegA3 = 0x04; + jRegA8 = 0x02; + break; + case 32: + jRegA0 = 0x70; + jRegA3 = 0x08; + jRegA8 = 0x02; + break; + } + SetIndexRegMask(CRTC_PORT,0xA0, 0x8F, (UCHAR) jRegA0); + SetIndexRegMask(CRTC_PORT,0xA3, 0xF0, (UCHAR) jRegA3); + SetIndexRegMask(CRTC_PORT,0xA8, 0xFD, (UCHAR) jRegA8); + + /* Set Threshold */ + SetIndexReg(CRTC_PORT,0xA7, 0x2F); + SetIndexReg(CRTC_PORT,0xA6, 0x1F); + +} + + +Bool bSetDACReg(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAModeInfo) +{ + PVBIOS_DAC_INFO pDACPtr; + ASTRecPtr pAST; + ULONG i, ulDACNumber; + UCHAR DACR, DACG, DACB; + + pAST = ASTPTR(pScrn); + + switch (pScrn->bitsPerPixel) + { + case 8: + ulDACNumber = DAC_NUM_VGA; + pDACPtr = (PVBIOS_DAC_INFO) &DAC_VGA[0]; + break; + default: + return (FALSE); + } + + for (i=0; i<ulDACNumber; i++) + { + DACR = pDACPtr->DACR; + DACG = pDACPtr->DACG; + DACB = pDACPtr->DACB; + + VGA_LOAD_PALETTE_INDEX (i, DACR, DACG, DACB); + + pDACPtr++; + } + + return (TRUE); + +} + + diff --git a/src/ast_mode.h b/src/ast_mode.h new file mode 100644 index 0000000..0a8e20c --- /dev/null +++ b/src/ast_mode.h @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2005 ASPEED Technology Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the authors not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. The authors makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* Mode Limitation */ +#define MAX_HResolution 1600 +#define MAX_VResolution 1200 + +/* Std. Table Index Definition */ +#define TextModeIndex 0 +#define EGAModeIndex 1 +#define VGAModeIndex 2 +#define HiCModeIndex 3 +#define TrueCModeIndex 4 + +/* DCLK Index */ +#define VCLK25_175 0x00 +#define VCLK28_322 0x01 +#define VCLK31_5 0x02 +#define VCLK36 0x03 +#define VCLK40 0x04 +#define VCLK49_5 0x05 +#define VCLK50 0x06 +#define VCLK56_25 0x07 +#define VCLK65 0x08 +#define VCLK75 0x09 +#define VCLK78_75 0x0A +#define VCLK94_5 0x0B +#define VCLK108 0x0C +#define VCLK135 0x0D +#define VCLK157_5 0x0E +#define VCLK162 0x0F + +/* Flags Definition */ +#define Charx8Dot 0x00000001 +#define HalfDCLK 0x00000002 +#define DoubleScanMode 0x00000004 +#define LineCompareOff 0x00000008 +#define SyncPP 0x00000000 +#define SyncPN 0x00000040 +#define SyncNP 0x00000080 +#define SyncNN 0x000000C0 +#define HBorder 0x00000020 +#define VBorder 0x00000010 + +/* DAC Definition */ +#define DAC_NUM_TEXT 64 +#define DAC_NUM_EGA 64 +#define DAC_NUM_VGA 256 + +/* Data Structure decalration for internal use */ +typedef struct { + + UCHAR MISC; + UCHAR SEQ[4]; + UCHAR CRTC[25]; + UCHAR AR[20]; + UCHAR GR[9]; + +} VBIOS_STDTABLE_STRUCT, *PVBIOS_STDTABLE_STRUCT; + +typedef struct { + + ULONG HT; + ULONG HDE; + ULONG HFP; + ULONG HSYNC; + ULONG VT; + ULONG VDE; + ULONG VFP; + ULONG VSYNC; + ULONG DCLKIndex; + ULONG Flags; + + ULONG ulRefreshRate; + ULONG ulRefreshRateIndex; + ULONG ulModeID; + +} VBIOS_ENHTABLE_STRUCT, *PVBIOS_ENHTABLE_STRUCT; + +typedef struct { + UCHAR Param1; + UCHAR Param2; + UCHAR Param3; +} VBIOS_DCLK_INFO, *PVBIOS_DCLK_INFO; + +typedef struct { + UCHAR DACR; + UCHAR DACG; + UCHAR DACB; +} VBIOS_DAC_INFO, *PVBIOS_DAC_INFO; + +typedef struct { + PVBIOS_STDTABLE_STRUCT pStdTableEntry; + PVBIOS_ENHTABLE_STRUCT pEnhTableEntry; + +} VBIOS_MODE_INFO, *PVBIOS_MODE_INFO; diff --git a/src/ast_tool.c b/src/ast_tool.c new file mode 100644 index 0000000..61e9861 --- /dev/null +++ b/src/ast_tool.c @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2005 ASPEED Technology Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the authors not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. The authors makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#include "xf86.h" +#include "xf86_ansic.h" +#include "xf86_OSproc.h" +#include "xf86Resources.h" +#include "xf86RAC.h" +#include "xf86cmap.h" +#include "compiler.h" +#include "mibstore.h" +#include "vgaHW.h" +#include "mipointer.h" +#include "micmap.h" + +#include "fb.h" +#include "regionstr.h" +#include "xf86xv.h" +#include "Xv.h" +#include "vbe.h" + +#include "xf86PciInfo.h" +#include "xf86Pci.h" + +/* framebuffer offscreen manager */ +#include "xf86fbman.h" + +/* include xaa includes */ +#include "xaa.h" +#include "xaarop.h" + +/* H/W cursor support */ +#include "xf86Cursor.h" + +/* Driver specific headers */ +#include "ast.h" + +/* Prototype type declaration*/ +Bool ASTMapMem(ScrnInfoPtr pScrn); +Bool ASTUnmapMem(ScrnInfoPtr pScrn); +Bool ASTMapMMIO(ScrnInfoPtr pScrn); +void ASTUnmapMMIO(ScrnInfoPtr pScrn); + +Bool +ASTMapMem(ScrnInfoPtr pScrn) +{ + ASTRecPtr pAST = ASTPTR(pScrn); + + + pAST->FBVirtualAddr = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER, + pAST->PciTag, + pAST->FBPhysAddr, pAST->FbMapSize); + + if (!pAST->FBVirtualAddr) + return FALSE; + + return TRUE; +} + +Bool +ASTUnmapMem(ScrnInfoPtr pScrn) +{ + ASTRecPtr pAST = ASTPTR(pScrn); + + xf86UnMapVidMem(pScrn->scrnIndex, (pointer) pAST->FBVirtualAddr, + pAST->FbMapSize); + + pAST->FBVirtualAddr = 0; + + return TRUE; +} + +Bool +ASTMapMMIO(ScrnInfoPtr pScrn) +{ + int mmioFlags; + ASTRecPtr pAST = ASTPTR(pScrn); + +#if !defined(__alpha__) + mmioFlags = VIDMEM_MMIO | VIDMEM_READSIDEEFFECT; +#else + mmioFlags = VIDMEM_MMIO | VIDMEM_READSIDEEFFECT | VIDMEM_SPARSE; +#endif + + pAST->MMIOVirtualAddr = xf86MapPciMem(pScrn->scrnIndex, mmioFlags, + pAST->PciTag, + pAST->MMIOPhysAddr, pAST->MMIOMapSize); + if (!pAST->MMIOVirtualAddr) + return FALSE; + + return TRUE; +} + +void +ASTUnmapMMIO(ScrnInfoPtr pScrn) +{ + ASTRecPtr pAST = ASTPTR(pScrn); + + xf86UnMapVidMem(pScrn->scrnIndex, (pointer) pAST->MMIOVirtualAddr, + pAST->MMIOMapSize); + pAST->MMIOVirtualAddr = 0; + +} + + diff --git a/src/ast_vgatool.c b/src/ast_vgatool.c new file mode 100644 index 0000000..92013c9 --- /dev/null +++ b/src/ast_vgatool.c @@ -0,0 +1,240 @@ +/*
+ * Copyright (c) 2005 ASPEED Technology Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the authors not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. The authors makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "xf86.h"
+#include "xf86_ansic.h"
+#include "xf86_OSproc.h"
+#include "xf86Resources.h"
+#include "xf86RAC.h"
+#include "xf86cmap.h"
+#include "compiler.h"
+#include "mibstore.h"
+#include "vgaHW.h"
+#include "mipointer.h"
+#include "micmap.h"
+
+#include "fb.h"
+#include "regionstr.h"
+#include "xf86xv.h"
+#include "Xv.h"
+#include "vbe.h"
+
+#include "xf86PciInfo.h"
+#include "xf86Pci.h"
+
+/* framebuffer offscreen manager */
+#include "xf86fbman.h"
+
+/* include xaa includes */
+#include "xaa.h"
+#include "xaarop.h"
+
+/* H/W cursor support */
+#include "xf86Cursor.h"
+
+/* Driver specific headers */
+#include "ast.h"
+
+/* Prototype type declaration*/
+void vASTOpenKey(ScrnInfoPtr pScrn);
+Bool bASTRegInit(ScrnInfoPtr pScrn);
+ULONG GetVRAMInfo(ScrnInfoPtr pScrn);
+void vAST1000DisplayOn(ASTRecPtr pAST);
+void vAST1000DisplayOff(ASTRecPtr pAST);
+void vSetStartAddressCRT1(ASTRecPtr pAST, ULONG base);
+void vASTLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, VisualPtr pVisual);
+void ASTDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags);
+
+void
+vASTOpenKey(ScrnInfoPtr pScrn)
+{
+ ASTRecPtr pAST = ASTPTR(pScrn);
+
+ SetIndexReg(CRTC_PORT,0x80, 0xA8);
+
+}
+
+Bool
+bASTRegInit(ScrnInfoPtr pScrn)
+{
+ ASTRecPtr pAST = ASTPTR(pScrn);
+
+ /* Enable MMIO */
+ SetIndexRegMask(CRTC_PORT,0xA1, 0xFF, 0x04);
+
+ return (TRUE);
+
+}
+
+ULONG
+GetVRAMInfo(ScrnInfoPtr pScrn)
+{
+ ASTRecPtr pAST = ASTPTR(pScrn);
+ UCHAR jReg;
+
+ GetIndexRegMask(CRTC_PORT, 0xAA, 0xFF, jReg);
+
+ switch (jReg & 0x03)
+ {
+ case 0x00:
+ return (VIDEOMEM_SIZE_08M);
+ case 0x01:
+ return (VIDEOMEM_SIZE_16M);
+ case 0x02:
+ return (VIDEOMEM_SIZE_32M);
+ case 0x03:
+ return (VIDEOMEM_SIZE_64M);
+ }
+
+ return (DEFAULT_VIDEOMEM_SIZE);
+
+}
+
+
+void
+vSetStartAddressCRT1(ASTRecPtr pAST, ULONG base)
+{
+ SetIndexReg(CRTC_PORT,0x0D, (UCHAR) (base & 0xFF));
+ SetIndexReg(CRTC_PORT,0x0C, (UCHAR) ((base >> 8) & 0xFF));
+ SetIndexReg(CRTC_PORT,0xAF, (UCHAR) ((base >> 16) & 0xFF));
+
+}
+
+void
+vAST1000DisplayOff(ASTRecPtr pAST)
+{
+ SetIndexRegMask(SEQ_PORT,0x01, 0xDF, 0x20);
+
+}
+
+
+void
+vAST1000DisplayOn(ASTRecPtr pAST)
+{
+
+ SetIndexRegMask(SEQ_PORT,0x01, 0xDF, 0x00);
+
+}
+
+
+void
+vASTLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors,
+ VisualPtr pVisual)
+{
+
+ ASTRecPtr pAST = ASTPTR(pScrn);
+ int i, j, index;
+ UCHAR DACIndex, DACR, DACG, DACB;
+
+ switch (pScrn->bitsPerPixel) {
+ case 15:
+ for(i=0; i<numColors; i++) {
+ index = indices[i];
+ for(j=0; j<8; j++) {
+ DACIndex = (index * 8) + j;
+ DACR = colors[index].red << (8- pScrn->rgbBits);
+ DACG = colors[index].green << (8- pScrn->rgbBits);
+ DACB = colors[index].blue << (8- pScrn->rgbBits);
+
+ VGA_LOAD_PALETTE_INDEX (DACIndex, DACR, DACG, DACB);
+ }
+ }
+ break;
+
+ case 16:
+ for(i=0; i<numColors; i++) {
+ index = indices[i];
+ for(j=0; j<4; j++) {
+ DACIndex = (index * 4) + j;
+ DACR = colors[index/2].red << (8- pScrn->rgbBits);
+ DACG = colors[index].green << (8- pScrn->rgbBits);
+ DACB = colors[index/2].blue << (8- pScrn->rgbBits);
+
+ VGA_LOAD_PALETTE_INDEX (DACIndex, DACR, DACG, DACB);
+ }
+ }
+ break;
+
+ case 24:
+ for(i=0; i<numColors; i++) {
+ index = indices[i];
+ DACIndex = index;
+ DACR = colors[index].red;
+ DACG = colors[index].green;
+ DACB = colors[index].blue;
+
+ VGA_LOAD_PALETTE_INDEX (DACIndex, DACR, DACG, DACB);
+ }
+ break;
+
+ default:
+ for(i=0; i<numColors; i++) {
+ index = indices[i];
+ DACIndex = index;
+ DACR = colors[index].red >> (8 - pScrn->rgbBits);
+ DACG = colors[index].green >> (8 - pScrn->rgbBits);
+ DACB = colors[index].blue >> (8 - pScrn->rgbBits);
+
+ VGA_LOAD_PALETTE_INDEX (DACIndex, DACR, DACG, DACB);
+ }
+
+ } /* end of switch */
+
+} /* end of vASTLoadPalette */
+
+void
+ASTDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags)
+{
+ ASTRecPtr pAST;
+ UCHAR SEQ01, CRB6;
+
+ pAST = ASTPTR(pScrn);
+ SEQ01=CRB6=0;
+
+ switch (PowerManagementMode) {
+ case DPMSModeOn:
+ /* Screen: On; HSync: On, VSync: On */
+ SEQ01 = 0x00;
+ CRB6 = 0x00;
+ break;
+ case DPMSModeStandby:
+ /* Screen: Off; HSync: Off, VSync: On */
+ SEQ01 = 0x20;
+ CRB6 = 0x01;
+ break;
+ case DPMSModeSuspend:
+ /* Screen: Off; HSync: On, VSync: Off */
+ SEQ01 = 0x20;
+ CRB6 = 0x02;
+ break;
+ case DPMSModeOff:
+ /* Screen: Off; HSync: Off, VSync: Off */
+ SEQ01 = 0x20;
+ CRB6 = 0x03;
+ break;
+ }
+
+ SetIndexRegMask(SEQ_PORT,0x01, 0xDF, SEQ01);
+ SetIndexRegMask(CRTC_PORT,0xB6, 0xFC, CRB6);
+
+
+}
diff --git a/src/ast_vgatool.h b/src/ast_vgatool.h new file mode 100644 index 0000000..8a4f683 --- /dev/null +++ b/src/ast_vgatool.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2005 ASPEED Technology Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the authors not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. The authors makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* VRAM Size Definition */ +#define VIDEOMEM_SIZE_08M 0x00800000 +#define VIDEOMEM_SIZE_16M 0x01000000 +#define VIDEOMEM_SIZE_32M 0x02000000 +#define VIDEOMEM_SIZE_64M 0x04000000 + +#define AR_PORT_WRITE (pAST->RelocateIO + 0x40) +#define MISC_PORT_WRITE (pAST->RelocateIO + 0x42) +#define SEQ_PORT (pAST->RelocateIO + 0x44) +#define DAC_INDEX_WRITE (pAST->RelocateIO + 0x48) +#define DAC_DATA (pAST->RelocateIO + 0x49) +#define GR_PORT (pAST->RelocateIO + 0x4E) +#define CRTC_PORT (pAST->RelocateIO + 0x54) +#define INPUT_STATUS1_READ (pAST->RelocateIO + 0x5A) + +#define GetReg(base) inb(base) +#define SetReg(base,val) outb(base,val) +#define GetIndexReg(base,index,val) do { \ + outb(base,index); \ + val = inb(base+1); \ + } while (0) +#define SetIndexReg(base,index, val) do { \ + outb(base,index); \ + outb(base+1,val); \ + } while (0) +#define GetIndexRegMask(base,index, and, val) do { \ + outb(base,index); \ + val = (inb(base+1) & and); \ + } while (0) +#define SetIndexRegMask(base,index, and, val) do { \ + UCHAR __Temp; \ + outb(base,index); \ + __Temp = (inb((base)+1)&(and))|(val); \ + SetIndexReg(base,index,__Temp); \ + } while (0) + +#define VGA_LOAD_PALETTE_INDEX(index, red, green, blue) \ +{ \ + UCHAR __junk; \ + SetReg(DAC_INDEX_WRITE,(UCHAR)(index)); \ + __junk = GetReg(SEQ_PORT); \ + SetReg(DAC_DATA,(UCHAR)(red)); \ + __junk = GetReg(SEQ_PORT); \ + SetReg(DAC_DATA,(UCHAR)(green)); \ + __junk = GetReg(SEQ_PORT); \ + SetReg(DAC_DATA,(UCHAR)(blue)); \ + __junk = GetReg(SEQ_PORT); \ +} |