From 1ca09bad07528d32db406998e8b6176989f29216 Mon Sep 17 00:00:00 2001 From: "Y.C. Chen" Date: Thu, 8 Jan 2009 17:03:19 +0800 Subject: Support AST2200/2150 --- src/ast.h | 5 +- src/ast_2dtool.c | 16 +++ src/ast_accel.c | 402 ++++++++++++++++++++++++++++++------------------------ src/ast_cursor.c | 12 ++ src/ast_driver.c | 79 +++++++---- src/ast_mode.c | 12 +- src/ast_vgatool.c | 274 ++++++++++++++++++++++++++++++++++++- 7 files changed, 590 insertions(+), 210 deletions(-) (limited to 'src') diff --git a/src/ast.h b/src/ast.h index 7cd51c0..937709a 100644 --- a/src/ast.h +++ b/src/ast.h @@ -48,7 +48,9 @@ typedef enum _CHIP_ID { VGALegacy, AST2000, AST2100, - AST1100 + AST1100, + AST2200, + AST2150 } CHIP_ID; /* AST REC Info */ @@ -161,6 +163,7 @@ typedef struct _ASTRec { Bool MMIO2D; int ENGCaps; int DBGSelect; + Bool VGA2Clone; ULONG FBPhysAddr; /* Frame buffer physical address */ ULONG MMIOPhysAddr; /* MMIO region physical address */ diff --git a/src/ast_2dtool.c b/src/ast_2dtool.c index 39fa46c..f9d6b97 100644 --- a/src/ast_2dtool.c +++ b/src/ast_2dtool.c @@ -189,6 +189,22 @@ bEnableCMDQ(ScrnInfoPtr pScrn, ASTRecPtr pAST) Bool bEnable2D(ScrnInfoPtr pScrn, ASTRecPtr pAST) { + ULONG ulData; + + switch (pAST->jChipType) + { + case AST2100: + case AST1100: + case AST2200: + case AST2150: + *(ULONG *) (pAST->MMIOVirtualAddr + 0xF004) = 0x1e6e0000; + *(ULONG *) (pAST->MMIOVirtualAddr + 0xF000) = 0x1; + + ulData = *(ULONG *) (pAST->MMIOVirtualAddr + 0x1200c); + *(ULONG *) (pAST->MMIOVirtualAddr + 0x1200c) = (ulData & 0xFFFFFFFD); + break; + } + SetIndexRegMask(CRTC_PORT, 0xA4, 0xFE, 0x01); /* enable 2D */ if (!bInitCMDQInfo(pScrn, pAST)) diff --git a/src/ast_accel.c b/src/ast_accel.c index 1ef3095..ad954e8 100644 --- a/src/ast_accel.c +++ b/src/ast_accel.c @@ -316,6 +316,10 @@ static void ASTSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, ASTSetupSRCPitch(pSingleCMD, pAST->VideoModeInfo.ScreenPitch); pSingleCMD++; ASTSetupDSTPitchHeight(pSingleCMD, pAST->VideoModeInfo.ScreenPitch, -1); + + /* Update Write Pointer */ + mUpdateWritePointer; + } else { @@ -337,83 +341,91 @@ ASTSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1, int x2, /* xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSubsequentScreenToScreenCopy\n"); */ - - /* Modify Reg. Value */ - cmdreg = pAST->ulCMDReg; - if (pAST->EnableClip) - cmdreg |= CMD_ENABLE_CLIP; - else - cmdreg &= ~CMD_ENABLE_CLIP; - srcbase = dstbase = 0; - if (y1 >= MAX_SRC_Y) - { - srcbase=pAST->VideoModeInfo.ScreenPitch*y1; - y1=0; - } + if ((width != 0) && (height != 0)) + { + /* Modify Reg. Value */ + cmdreg = pAST->ulCMDReg; + if (pAST->EnableClip) + cmdreg |= CMD_ENABLE_CLIP; + else + cmdreg &= ~CMD_ENABLE_CLIP; + srcbase = dstbase = 0; - if (y2 >= pScrn->virtualY) - { - dstbase=pAST->VideoModeInfo.ScreenPitch*y2; - y2=0; - } + if (y1 >= MAX_SRC_Y) + { + srcbase=pAST->VideoModeInfo.ScreenPitch*y1; + } + + if (y2 >= pScrn->virtualY) + { + dstbase=pAST->VideoModeInfo.ScreenPitch*y2; + } + + 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) + { + if (srcbase) y1 = 0; + if (dstbase) y2 = 0; + + src_y = y1 + height - 1; + dst_y = y2 + height - 1; + cmdreg |= CMD_Y_DEC; + } + else + { + if (srcbase) y1 = 0; + if (dstbase) y2 = 0; + + src_y = y1; + dst_y = y2; + } + + if (!pAST->MMIO2D) + { + /* Write to CMDQ */ + pSingleCMD = (PKT_SC *) pjRequestCMDQ(pAST, PKT_SINGLE_LENGTH*6); - 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; - } + 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; - 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); - } + } + 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); + } + + } /* width & height check */ } /* end of ASTSubsequentScreenToScreenCopy */ @@ -455,7 +467,11 @@ ASTSetupForSolidFill(ScrnInfoPtr pScrn, ASTSetupDSTPitchHeight(pSingleCMD, pAST->VideoModeInfo.ScreenPitch, -1); pSingleCMD++; - ASTSetupFG(pSingleCMD, color); + ASTSetupFG(pSingleCMD, color); + + /* Update Write Pointer */ + mUpdateWritePointer; + } else { @@ -477,47 +493,51 @@ ASTSubsequentSolidFillRect(ScrnInfoPtr pScrn, xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSubsequentSolidFillRect\n"); */ - /* Modify Reg. Value */ - cmdreg = pAST->ulCMDReg; - if (pAST->EnableClip) - cmdreg |= CMD_ENABLE_CLIP; - else - 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); - - } + if ((width != 0) && (height != 0)) + { + /* Modify Reg. Value */ + cmdreg = pAST->ulCMDReg; + if (pAST->EnableClip) + cmdreg |= CMD_ENABLE_CLIP; + else + 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); + + } + + } /* width & height check */ } /* end of ASTSubsequentSolidFillRect */ @@ -563,6 +583,9 @@ static void ASTSetupForSolidLine(ScrnInfoPtr pScrn, pSingleCMD++; ASTSetupBG(pSingleCMD, 0); + /* Update Write Pointer */ + mUpdateWritePointer; + } else { @@ -586,58 +609,61 @@ static void ASTSubsequentSolidHorVertLine(ScrnInfoPtr pScrn, /* xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ASTSubsequentSolidHorVertLine\n"); */ - - /* Modify Reg. Value */ - cmdreg = (pAST->ulCMDReg & (~CMD_MASK)) | CMD_BITBLT; - if (pAST->EnableClip) - cmdreg |= CMD_ENABLE_CLIP; - else - 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); - - } + if (len != 0) + { + /* Modify Reg. Value */ + cmdreg = (pAST->ulCMDReg & (~CMD_MASK)) | CMD_BITBLT; + if (pAST->EnableClip) + cmdreg |= CMD_ENABLE_CLIP; + else + 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); + + } + + } /* len check */ } /* end of ASTSubsequentSolidHorVertLine */ @@ -674,7 +700,7 @@ static void ASTSubsequentSolidTwoPointLine(ScrnInfoPtr pScrn, y1 -= miny; y2 -= miny; } - + LineInfo.X1 = x1; LineInfo.Y1 = y1; LineInfo.X2 = x2; @@ -783,7 +809,10 @@ ASTSetupForDashedLine(ScrnInfoPtr pScrn, pSingleCMD++; ASTSetupLineStyle1(pSingleCMD, *pattern); pSingleCMD++; - ASTSetupLineStyle2(pSingleCMD, *(pattern+4)); + ASTSetupLineStyle2(pSingleCMD, *(pattern+4)); + + /* Update Write Pointer */ + mUpdateWritePointer; } else @@ -825,7 +854,7 @@ ASTSubsequentDashedTwoPointLine(ScrnInfoPtr pScrn, if (pAST->EnableClip) ulCommand |= CMD_ENABLE_CLIP; else - ulCommand &= ~CMD_ENABLE_CLIP; + ulCommand &= ~CMD_ENABLE_CLIP; dstbase = 0; miny = (y1 > y2) ? y2 : y1; maxy = (y1 > y2) ? y1 : y2; @@ -834,7 +863,7 @@ ASTSubsequentDashedTwoPointLine(ScrnInfoPtr pScrn, y1 -= miny; y2 -= miny; } - + LineInfo.X1 = x1; LineInfo.Y1 = y1; LineInfo.X2 = x2; @@ -873,7 +902,7 @@ ASTSubsequentDashedTwoPointLine(ScrnInfoPtr pScrn, /* Patch KDE pass abnormal point, ycchen@052507 */ vWaitEngIdle(pScrn, pAST); - + } else { @@ -937,7 +966,11 @@ ASTSetupForMonoPatternFill(ScrnInfoPtr pScrn, pSingleCMD++; ASTSetupMONO1(pSingleCMD, patx); pSingleCMD++; - ASTSetupMONO2(pSingleCMD, paty); + ASTSetupMONO2(pSingleCMD, paty); + + /* Update Write Pointer */ + mUpdateWritePointer; + } else { @@ -968,7 +1001,7 @@ ASTSubsequentMonoPatternFill(ScrnInfoPtr pScrn, if (pAST->EnableClip) cmdreg |= CMD_ENABLE_CLIP; else - cmdreg &= ~CMD_ENABLE_CLIP; + cmdreg &= ~CMD_ENABLE_CLIP; dstbase = 0; if (dst_y >= pScrn->virtualY) @@ -1056,7 +1089,11 @@ ASTSetupForColor8x8PatternFill(ScrnInfoPtr pScrn, int patx, int paty, ASTSetupPatReg(pSingleCMD, (i*j + j) , (*(CARD32 *) (pataddr++))); pSingleCMD++; } - } + } + + /* Update Write Pointer */ + mUpdateWritePointer; + } else { @@ -1089,7 +1126,7 @@ ASTSubsequentColor8x8PatternFillRect(ScrnInfoPtr pScrn, int patx, int paty, if (pAST->EnableClip) cmdreg |= CMD_ENABLE_CLIP; else - cmdreg &= ~CMD_ENABLE_CLIP; + cmdreg &= ~CMD_ENABLE_CLIP; dstbase = 0; if (dst_y >= pScrn->virtualY) @@ -1174,6 +1211,9 @@ ASTSetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, ASTSetupFG(pSingleCMD, fg); pSingleCMD++; ASTSetupBG(pSingleCMD, bg); + + /* Update Write Pointer */ + mUpdateWritePointer; } else @@ -1205,7 +1245,7 @@ ASTSubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, if (pAST->EnableClip) cmdreg |= CMD_ENABLE_CLIP; else - cmdreg &= ~CMD_ENABLE_CLIP; + cmdreg &= ~CMD_ENABLE_CLIP; dstbase = 0; if (dst_y >= pScrn->virtualY) @@ -1298,6 +1338,9 @@ ASTSetupForScreenToScreenColorExpandFill(ScrnInfoPtr pScrn, ASTSetupFG(pSingleCMD, fg); pSingleCMD++; ASTSetupBG(pSingleCMD, bg); + + /* Update Write Pointer */ + mUpdateWritePointer; } else @@ -1398,7 +1441,11 @@ ASTSetClippingRectangle(ScrnInfoPtr pScrn, ASTSetupCLIP1(pSingleCMD, left, top); pSingleCMD++; - ASTSetupCLIP2(pSingleCMD, right, bottom); + ASTSetupCLIP2(pSingleCMD, right, bottom); + + /* Update Write Pointer */ + mUpdateWritePointer; + } else { @@ -1418,5 +1465,4 @@ ASTDisableClipping(ScrnInfoPtr pScrn) pAST->EnableClip = FALSE; } - #endif /* end of Accel_2D */ diff --git a/src/ast_cursor.c b/src/ast_cursor.c index aaa9cb3..6b6cb94 100644 --- a/src/ast_cursor.c +++ b/src/ast_cursor.c @@ -242,6 +242,12 @@ ASTLoadCursorImage(ScrnInfoPtr pScrn, UCHAR *src) 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); + ulTempDstData32[1] = ((jTempSrcXor32 >> (k-1)) & 0x01) ? (pAST->HWCInfo.fg << 16):(pAST->HWCInfo.bg << 16); + /* No inverse for X Window cursor, ycchen@111808 */ + if (ulTempDstAnd32[0]) + ulTempDstXor32[0] = 0; + if (ulTempDstAnd32[1]) + ulTempDstXor32[1] = 0; *((ULONG *) pjDstData) = ulTempDstAnd32[0] | ulTempDstXor32[0] | ulTempDstData32[0] | ulTempDstAnd32[1] | ulTempDstXor32[1] | ulTempDstData32[1]; ulCheckSum += *((ULONG *) pjDstData); pjDstData += 4; @@ -276,6 +282,9 @@ ASTLoadCursorImage(ScrnInfoPtr pScrn, UCHAR *src) static Bool ASTUseHWCursor(ScreenPtr pScreen, CursorPtr pCurs) { + if ( (pCurs->bits->width > MAX_HWC_WIDTH) || (pCurs->bits->height > MAX_HWC_HEIGHT) ) + return FALSE; + return TRUE; } @@ -377,6 +386,9 @@ ASTLoadCursorARGB(ScrnInfoPtr pScrn, CursorPtr pCurs) static Bool ASTUseHWCursorARGB(ScreenPtr pScreen, CursorPtr pCurs) { + if ( (pCurs->bits->width > MAX_HWC_WIDTH) || (pCurs->bits->height > MAX_HWC_HEIGHT) ) + return FALSE; + return TRUE; } diff --git a/src/ast_driver.c b/src/ast_driver.c index 0cd991f..7718c29 100644 --- a/src/ast_driver.c +++ b/src/ast_driver.c @@ -72,6 +72,7 @@ extern void ASTDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementM extern void vSetStartAddressCRT1(ASTRecPtr pAST, ULONG base); extern Bool ASTSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode); extern Bool GetVGA2EDID(ScrnInfoPtr pScrn, unsigned char *pEDIDBuffer); +extern void vInitDRAMReg(ScrnInfoPtr pScrn); extern Bool bInitCMDQInfo(ScrnInfoPtr pScrn, ASTRecPtr pAST); extern Bool bEnableCMDQ(ScrnInfoPtr pScrn, ASTRecPtr pAST); @@ -123,8 +124,8 @@ _X_EXPORT DriverRec AST = { /* Chipsets */ static SymTabRec ASTChipsets[] = { - {PCI_CHIP_AST2000, "AST2000 Family"}, - {PCI_CHIP_AST2100, "AST1100_2050_2100"}, + {PCI_CHIP_AST2000, "ASPEED Graphics Family"}, + {PCI_CHIP_AST2100, "ASPEED Graphics Family"}, {-1, NULL} }; @@ -223,6 +224,7 @@ const char *int10Symbols[] = { "xf86InitInt10", "xf86Int10AllocPages", "xf86int10Addr", + "xf86FreeInt10", NULL }; @@ -612,38 +614,58 @@ ASTPreInit(ScrnInfoPtr pScrn, int flags) xf86DrvMsg(pScrn->scrnIndex, X_INFO, "IO registers at addr 0x%lX\n", (unsigned long) pAST->MMIOPhysAddr); + /* Map MMIO */ + pAST->MMIOMapSize = DEFAULT_MMIO_SIZE; + if (!ASTMapMMIO(pScrn)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Map Memory Map IO Failed \n"); + return FALSE; + } + + /* Init VGA Adapter */ + if (!xf86IsPrimaryPci(pAST->PciInfo)) + { + if (xf86LoadSubModule(pScrn, "int10")) { + xf86Int10InfoPtr pInt10; + xf86LoaderReqSymLists(int10Symbols, NULL); + xf86DrvMsg(pScrn->scrnIndex,X_INFO,"initializing int10\n"); + pInt10 = xf86InitInt10(pAST->pEnt->index); + xf86FreeInt10(pInt10); + } + } + + vASTOpenKey(pScrn); + bASTRegInit(pScrn); + + /* Get Chip Type */ + if (PCI_DEV_REVISION(pAST->PciInfo) >= 0x10) + GetChipType(pScrn); + else + pAST->jChipType = AST2000; + + if (!xf86IsPrimaryPci(pAST->PciInfo)) + { + vInitDRAMReg (pScrn); + } + + /* Map Framebuffer */ 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; - - /* Map resource */ + if (!ASTMapMem(pScrn)) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Map FB Memory Failed \n"); return FALSE; } - - if (!ASTMapMMIO(pScrn)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Map Memory Map IO Failed \n"); - return FALSE; - } pScrn->memPhysBase = (ULONG)pAST->FBPhysAddr; pScrn->fbOffset = 0; - /* Get Revision */ - if (PCI_DEV_REVISION(pAST->PciInfo) >= 0x10) - GetChipType(pScrn); - else - pAST->jChipType = AST2000; - /* Do DDC * should be done after xf86CollectOptions */ @@ -659,7 +681,7 @@ ASTPreInit(ScrnInfoPtr pScrn, int flags) clockRanges->doubleScanAllowed = FALSE; /* Add for AST2100, ycchen@061807 */ - if (pAST->jChipType == AST2100) + if ((pAST->jChipType == AST2100) || (pAST->jChipType == AST2200)) i = xf86ValidateModes(pScrn, pScrn->monitor->Modes, pScrn->display->modes, clockRanges, 0, 320, 1920, 8 * pScrn->bitsPerPixel, @@ -1020,7 +1042,7 @@ ASTValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) } /* Add for AST2100, ycchen@061807 */ - if (pAST->jChipType == AST2100) + if ((pAST->jChipType == AST2100) || (pAST->jChipType == AST2200)) { if ( (mode->CrtcHDisplay == 1920) && (mode->CrtcVDisplay == 1200) ) return MODE_OK; @@ -1084,7 +1106,6 @@ ASTFreeRec(ScrnInfoPtr pScrn) static Bool ASTSaveScreen(ScreenPtr pScreen, Bool unblack) { - /* more ref. SiS */ return vgaHWSaveScreen(pScreen, unblack); } @@ -1148,7 +1169,12 @@ ASTSave(ScrnInfoPtr pScrn) astReg = &pAST->SavedReg; /* do save */ - vgaHWSave(pScrn, vgaReg, VGA_SR_ALL); + if (xf86IsPrimaryPci(pAST->PciInfo)) { + vgaHWSave(pScrn, vgaReg, VGA_SR_ALL); + } + else { + vgaHWSave(pScrn, vgaReg, VGA_SR_MODE); + } /* Ext. Save */ vASTOpenKey(pScrn); @@ -1175,8 +1201,11 @@ ASTRestore(ScrnInfoPtr pScrn) astReg = &pAST->SavedReg; /* do restore */ - vgaHWProtect(pScrn, TRUE); - vgaHWRestore(pScrn, vgaReg, VGA_SR_ALL); + vgaHWProtect(pScrn, TRUE); + if (xf86IsPrimaryPci(pAST->PciInfo)) + vgaHWRestore(pScrn, vgaReg, VGA_SR_ALL); + else + vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE); vgaHWProtect(pScrn, FALSE); /* Ext. restore */ @@ -1230,7 +1259,7 @@ ASTDoDDC(ScrnInfoPtr pScrn, int index) MonInfo = MonInfo1; /* For VGA2 CLONE Support, ycchen@012508 */ - if (xf86ReturnOptValBool(pAST->Options, OPTION_VGA2_CLONE, FALSE)) { + if ((xf86ReturnOptValBool(pAST->Options, OPTION_VGA2_CLONE, FALSE)) || pAST->VGA2Clone) { if (GetVGA2EDID(pScrn, DDC_data) == TRUE) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Get VGA2 EDID Correctly!! \n"); MonInfo2 = xf86InterpretEDID(pScrn->scrnIndex, DDC_data); diff --git a/src/ast_mode.c b/src/ast_mode.c index 50a8a69..60cd1fd 100644 --- a/src/ast_mode.c +++ b/src/ast_mode.c @@ -684,8 +684,16 @@ void vSetExtReg(ScrnInfoPtr pScrn, DisplayModePtr mode, PVBIOS_MODE_INFO pVGAMod SetIndexRegMask(CRTC_PORT,0xA8, 0xFD, (UCHAR) jRegA8); /* Set Threshold */ - SetIndexReg(CRTC_PORT,0xA7, 0x2F); - SetIndexReg(CRTC_PORT,0xA6, 0x1F); + if ((pAST->jChipType == AST2100) || (pAST->jChipType == AST1100) || (pAST->jChipType == AST2200) || (pAST->jChipType == AST2150) ) + { + SetIndexReg(CRTC_PORT,0xA7, 0x3F); + SetIndexReg(CRTC_PORT,0xA6, 0x2F); + } + else + { + SetIndexReg(CRTC_PORT,0xA7, 0x2F); + SetIndexReg(CRTC_PORT,0xA6, 0x1F); + } } diff --git a/src/ast_vgatool.c b/src/ast_vgatool.c index 91a6a1d..9319d58 100644 --- a/src/ast_vgatool.c +++ b/src/ast_vgatool.c @@ -68,6 +68,7 @@ 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); Bool GetVGA2EDID(ScrnInfoPtr pScrn, unsigned char *pEDIDBuffer); +void vInitDRAMReg(ScrnInfoPtr pScrn); void vASTOpenKey(ScrnInfoPtr pScrn) @@ -176,20 +177,23 @@ GetMaxDCLK(ScrnInfoPtr pScrn) /* Get Bandwidth */ /* Modify DARM utilization to 60% for AST1100/2100 16bits DRAM, ycchen@032508 */ - if ( ((pAST->jChipType == AST2100) || (pAST->jChipType == AST1100)) && (ulDRAMBusWidth == 16) ) + if ( ((pAST->jChipType == AST2100) || (pAST->jChipType == AST1100) || (pAST->jChipType == AST2200) || (pAST->jChipType == AST2150)) && (ulDRAMBusWidth == 16) ) DRAMEfficiency = 600; ulDRAMBandwidth = ulMCLK * ulDRAMBusWidth * 2 / 8; ActualDRAMBandwidth = ulDRAMBandwidth * DRAMEfficiency / 1000; - /* Get Max DCLK */ + /* Get Max DCLK */ + /* Fixed Fixed KVM + CRT threshold issue on AST2100 8bpp modes, ycchen@100708 */ GetIndexRegMask(CRTC_PORT, 0xD0, 0xFF, jReg); - if (jReg & 0x08) + if ((jReg & 0x08) && (pAST->jChipType == AST2000)) ulDCLK = ActualDRAMBandwidth / ((pScrn->bitsPerPixel+1+16) / 8); + else if ((jReg & 0x08) && (pScrn->bitsPerPixel == 8)) + ulDCLK = ActualDRAMBandwidth / ((pScrn->bitsPerPixel+1+24) / 8); else ulDCLK = ActualDRAMBandwidth / ((pScrn->bitsPerPixel+1) / 8); /* Add for AST2100, ycchen@061807 */ - if (pAST->jChipType == AST2100) + if ((pAST->jChipType == AST2100) || (pAST->jChipType == AST2200)) if (ulDCLK > 200) ulDCLK = 200; else if (ulDCLK > 165) ulDCLK = 165; @@ -203,6 +207,7 @@ GetChipType(ScrnInfoPtr pScrn) { ASTRecPtr pAST = ASTPTR(pScrn); ULONG ulData; + UCHAR jReg; pAST->jChipType = AST2100; @@ -211,8 +216,34 @@ GetChipType(ScrnInfoPtr pScrn) ulData = *(ULONG *) (pAST->MMIOVirtualAddr + 0x1207c); +#if 0 if ((ulData & 0x0300) == 0x0200) pAST->jChipType = AST1100; +#endif + switch (ulData & 0x0300) + { + case 0x0200: + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "AST1100 Detected.\n"); + pAST->jChipType = AST1100; + break; + case 0x0100: + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "AST2200 Detected.\n"); + pAST->jChipType = AST2200; + break; + case 0x0000: + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "AST2150 Detected.\n"); + pAST->jChipType = AST2150; + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "AST2100 Detected.\n"); + pAST->jChipType = AST2100; + } + + /* VGA2 Clone Support */ + GetIndexRegMask(CRTC_PORT, 0x90, 0xFF, jReg); + if (jReg & 0x10) + pAST->VGA2Clone = TRUE; + } void @@ -438,3 +469,238 @@ GetVGA2EDID(ScrnInfoPtr pScrn, unsigned char *pEDIDBuffer) return (TRUE); } /* GetVGA2EDID */ + +typedef struct _AST_DRAMStruct { + + USHORT Index; + ULONG Data; + +} AST_DRAMStruct, *PAST_DRAMStruct; + +AST_DRAMStruct AST2000DRAMTableData[] = { + { 0x0108, 0x00000000 }, + { 0x0120, 0x00004a21 }, + { 0xFF00, 0x00000043 }, + { 0x0000, 0xFFFFFFFF }, + { 0x0004, 0x00000089 }, + { 0x0008, 0x22331353 }, + { 0x000C, 0x0d07000b }, + { 0x0010, 0x11113333 }, + { 0x0020, 0x00110350 }, + { 0x0028, 0x1e0828f0 }, + { 0x0024, 0x00000001 }, + { 0x001C, 0x00000000 }, + { 0x0014, 0x00000003 }, + { 0xFF00, 0x00000043 }, + { 0x0018, 0x00000131 }, + { 0x0014, 0x00000001 }, + { 0xFF00, 0x00000043 }, + { 0x0018, 0x00000031 }, + { 0x0014, 0x00000001 }, + { 0xFF00, 0x00000043 }, + { 0x0028, 0x1e0828f1 }, + { 0x0024, 0x00000003 }, + { 0x002C, 0x1f0f28fb }, + { 0x0030, 0xFFFFFE01 }, + { 0xFFFF, 0xFFFFFFFF } +}; + +AST_DRAMStruct AST1100DRAMTableData[] = { + { 0x2000, 0x1688a8a8 }, + { 0x2020, 0x000041f0 }, + { 0xFF00, 0x00000043 }, + { 0x0000, 0xfc600309 }, + { 0x006C, 0x00909090 }, + { 0x0064, 0x00050000 }, + { 0x0004, 0x00000585 }, + { 0x0008, 0x0011030f }, + { 0x0010, 0x22201724 }, + { 0x0018, 0x1e29011a }, + { 0x0020, 0x00c82222 }, + { 0x0014, 0x01001523 }, + { 0x001C, 0x1024010d }, + { 0x0024, 0x00cb2522 }, + { 0x0038, 0xffffff82 }, + { 0x003C, 0x00000000 }, + { 0x0040, 0x00000000 }, + { 0x0044, 0x00000000 }, + { 0x0048, 0x00000000 }, + { 0x004C, 0x00000000 }, + { 0x0050, 0x00000000 }, + { 0x0054, 0x00000000 }, + { 0x0058, 0x00000000 }, + { 0x005C, 0x00000000 }, + { 0x0060, 0x032aa02a }, + { 0x0064, 0x002d3000 }, + { 0x0068, 0x00000000 }, + { 0x0070, 0x00000000 }, + { 0x0074, 0x00000000 }, + { 0x0078, 0x00000000 }, + { 0x007C, 0x00000000 }, + { 0x0034, 0x00000001 }, + { 0xFF00, 0x00000043 }, + { 0x002C, 0x00000732 }, + { 0x0030, 0x00000040 }, + { 0x0028, 0x00000005 }, + { 0x0028, 0x00000007 }, + { 0x0028, 0x00000003 }, + { 0x0028, 0x00000001 }, + { 0x000C, 0x00005a08 }, + { 0x002C, 0x00000632 }, + { 0x0028, 0x00000001 }, + { 0x0030, 0x000003c0 }, + { 0x0028, 0x00000003 }, + { 0x0030, 0x00000040 }, + { 0x0028, 0x00000003 }, + { 0x000C, 0x00005a21 }, + { 0x0034, 0x00007c03 }, + { 0x0120, 0x00004c41 }, + { 0xffff, 0xffffffff }, +}; + +AST_DRAMStruct AST2100DRAMTableData[] = { + { 0x2000, 0x1688a8a8 }, + { 0x2020, 0x00004120 }, + { 0xFF00, 0x00000043 }, + { 0x0000, 0xfc600309 }, + { 0x006C, 0x00909090 }, + { 0x0064, 0x00070000 }, + { 0x0004, 0x00000489 }, + { 0x0008, 0x0011030f }, + { 0x0010, 0x32302926 }, + { 0x0018, 0x274c0122 }, + { 0x0020, 0x00ce2222 }, + { 0x0014, 0x01001523 }, + { 0x001C, 0x1024010d }, + { 0x0024, 0x00cb2522 }, + { 0x0038, 0xffffff82 }, + { 0x003C, 0x00000000 }, + { 0x0040, 0x00000000 }, + { 0x0044, 0x00000000 }, + { 0x0048, 0x00000000 }, + { 0x004C, 0x00000000 }, + { 0x0050, 0x00000000 }, + { 0x0054, 0x00000000 }, + { 0x0058, 0x00000000 }, + { 0x005C, 0x00000000 }, + { 0x0060, 0x0f2aa02a }, + { 0x0064, 0x003f3005 }, + { 0x0068, 0x02020202 }, + { 0x0070, 0x00000000 }, + { 0x0074, 0x00000000 }, + { 0x0078, 0x00000000 }, + { 0x007C, 0x00000000 }, + { 0x0034, 0x00000001 }, + { 0xFF00, 0x00000043 }, + { 0x002C, 0x00000942 }, + { 0x0030, 0x00000040 }, + { 0x0028, 0x00000005 }, + { 0x0028, 0x00000007 }, + { 0x0028, 0x00000003 }, + { 0x0028, 0x00000001 }, + { 0x000C, 0x00005a08 }, + { 0x002C, 0x00000842 }, + { 0x0028, 0x00000001 }, + { 0x0030, 0x000003c0 }, + { 0x0028, 0x00000003 }, + { 0x0030, 0x00000040 }, + { 0x0028, 0x00000003 }, + { 0x000C, 0x00005a21 }, + { 0x0034, 0x00007c03 }, + { 0x0120, 0x00005061 }, + { 0xffff, 0xffffffff }, +}; + +void vInitDRAMReg(ScrnInfoPtr pScrn) +{ + AST_DRAMStruct *pjDRAMRegInfo; + ASTRecPtr pAST = ASTPTR(pScrn); + ULONG i, ulTemp; + UCHAR jReg; + + GetIndexRegMask(CRTC_PORT, 0xD0, 0xFF, jReg); + + if ((jReg & 0x80) == 0) /* VGA only */ + { + if (pAST->jChipType == AST2000) + { + pjDRAMRegInfo = AST2000DRAMTableData; + + *(ULONG *) (pAST->MMIOVirtualAddr + 0xF004) = 0x1e6e0000; + *(ULONG *) (pAST->MMIOVirtualAddr + 0xF000) = 0x1; + *(ULONG *) (pAST->MMIOVirtualAddr + 0x10100) = 0xa8; + + do { + ; + } while (*(volatile ULONG *) (pAST->MMIOVirtualAddr + 0x10100) != 0xa8); + + } + else /* AST2100/1100 */ + { + GetChipType(pScrn); + + if ((pAST->jChipType == AST2100) || (pAST->jChipType == AST2200)) + pjDRAMRegInfo = AST2100DRAMTableData; + else + pjDRAMRegInfo = AST1100DRAMTableData; + + *(ULONG *) (pAST->MMIOVirtualAddr + 0xF004) = 0x1e6e0000; + *(ULONG *) (pAST->MMIOVirtualAddr + 0xF000) = 0x1; + + *(ULONG *) (pAST->MMIOVirtualAddr + 0x12000) = 0x1688A8A8; + do { + ; + } while (*(volatile ULONG *) (pAST->MMIOVirtualAddr + 0x12000) != 0x01); + + *(ULONG *) (pAST->MMIOVirtualAddr + 0x10000) = 0xFC600309; + do { + ; + } while (*(volatile ULONG *) (pAST->MMIOVirtualAddr + 0x10000) != 0x01); + + } + + while (pjDRAMRegInfo->Index != 0xFFFF) + { + if (pjDRAMRegInfo->Index == 0xFF00) /* Delay function */ + { + for (i=0; i<15; i++) + xf86UDelay(pjDRAMRegInfo->Data); + } + else if ( (pjDRAMRegInfo->Index == 0x0004) && (pAST->jChipType != AST2000) ) + { + ulTemp = *(ULONG *) (pAST->MMIOVirtualAddr + 0x12070); + ulTemp &= 0x0000000C; + *(ULONG *) (pAST->MMIOVirtualAddr + 0x10000 + pjDRAMRegInfo->Index) = (pjDRAMRegInfo->Data | ulTemp); + } + else + { + *(ULONG *) (pAST->MMIOVirtualAddr + 0x10000 + pjDRAMRegInfo->Index) = pjDRAMRegInfo->Data; + } + pjDRAMRegInfo++; + } + + switch (pAST->jChipType) + { + case AST2000: + *(ULONG *) (pAST->MMIOVirtualAddr + 0x10140) |= 0x40; + break; + + case AST1100: + case AST2100: + case AST2200: + case AST2150: + ulTemp = *(ULONG *) (pAST->MMIOVirtualAddr + 0x1200c); + *(ULONG *) (pAST->MMIOVirtualAddr + 0x1200c) = (ulTemp & 0xFFFFFFFD); + + *(ULONG *) (pAST->MMIOVirtualAddr + 0x12040) |= 0x40; + break; + } + + } /* Init DRAM */ + + /* wait ready */ + do { + GetIndexRegMask(CRTC_PORT, 0xD0, 0xFF, jReg); + } while ((jReg & 0x40) == 0); + +} /* vInitDRAMReg */ -- cgit v1.2.3