summaryrefslogtreecommitdiff
path: root/src/ast_driver.c
diff options
context:
space:
mode:
authorroot <root@localhost.localdomain>2012-04-03 19:58:42 +0800
committerroot <root@localhost.localdomain>2012-04-03 19:58:42 +0800
commit6f0b593c273979bc4a83e845e037ab35d4565b72 (patch)
tree6db0306d410bf3822e14ba3bdf803c503ec34668 /src/ast_driver.c
parent18c8547d4afdeb87120e2af7c0563f76c27dcdfe (diff)
xf86-video-ast-ast 0.95.00xf86-video-ast-0.95.0
Diffstat (limited to 'src/ast_driver.c')
-rwxr-xr-x[-rw-r--r--]src/ast_driver.c651
1 files changed, 373 insertions, 278 deletions
diff --git a/src/ast_driver.c b/src/ast_driver.c
index 896f22c..5da19a6 100644..100755
--- a/src/ast_driver.c
+++ b/src/ast_driver.c
@@ -82,6 +82,7 @@ extern Bool InitVGA(ScrnInfoPtr pScrn, ULONG Flags);
extern Bool GetVGAEDID(ScrnInfoPtr pScrn, unsigned char *pEDIDBuffer);
extern Bool bInitAST1180(ScrnInfoPtr pScrn);
extern void GetAST1180DRAMInfo(ScrnInfoPtr pScrn);
+extern void vEnableASTVGAMMIO(ScrnInfoPtr pScrn);
extern Bool bInitCMDQInfo(ScrnInfoPtr pScrn, ASTRecPtr pAST);
extern Bool bEnableCMDQ(ScrnInfoPtr pScrn, ASTRecPtr pAST);
@@ -338,9 +339,11 @@ static Bool
ASTPreInit(ScrnInfoPtr pScrn, int flags)
{
EntityInfoPtr pEnt;
- vgaHWPtr hwp;
int flags24;
rgb defaultWeight = { 0, 0, 0 };
+#if !(defined(__sparc__)) && !(defined(__mips__))
+ vgaHWPtr hwp;
+#endif
ASTRecPtr pAST;
@@ -368,19 +371,22 @@ ASTPreInit(ScrnInfoPtr pScrn, int flags)
return FALSE;
#endif
+#if !(defined(__sparc__)) && !(defined(__mips__))
/* The vgahw module should be loaded here when needed */
if (!xf86LoadSubModule(pScrn, "vgahw"))
return FALSE;
+#endif
/* The fb module should be loaded here when needed */
if (!xf86LoadSubModule(pScrn, "fb"))
return FALSE;
-
+
+#if !(defined(__sparc__)) && !(defined(__mips__))
/* Allocate a vgaHWRec */
if (!vgaHWGetHWRec(pScrn))
return FALSE;
hwp = VGAHWPTR(pScrn);
- vgaHWSetStdFuncs(hwp);
+#endif
/* Color Depth Check */
flags24 = Support32bppFb;
@@ -579,7 +585,10 @@ ASTPreInit(ScrnInfoPtr pScrn, int flags)
}
else
- {
+ {
+ /* Enable VGA MMIO Access */
+ vEnableASTVGAMMIO(pScrn);
+
/* Init VGA Adapter */
if (!xf86IsPrimaryPci(pAST->PciInfo))
{
@@ -693,34 +702,31 @@ ASTPreInit(ScrnInfoPtr pScrn, int flags)
pAST->pCMDQPtr = NULL;
pAST->CMDQInfo.ulCMDQSize = 0;
#ifdef Accel_2D
- if (!xf86ReturnOptValBool(pAST->Options, OPTION_NOACCEL, FALSE)) do {
- if (!xf86LoadSubModule(pScrn, "xaa")) {\
- xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "XAA not available\n");
- pAST->noAccel = TRUE;
- break;
- }
-
- 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;
- }
+ if (!xf86ReturnOptValBool(pAST->Options, OPTION_NOACCEL, FALSE))
+ {
+ if (xf86LoadSubModule(pScrn, "xaa")) {
+
+ 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");
- }
- } while (0);
-#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;
@@ -757,16 +763,13 @@ 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");
@@ -795,7 +798,11 @@ ASTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
}
- vgaHWGetIOBase(hwp);
+#if !(defined(__sparc__)) && !(defined(__mips__))
+ vgaHWPtr hwp;
+ hwp = VGAHWPTR(pScrn);
+ vgaHWSetMmioFuncs(hwp, pAST->MMIOVirtualAddr, 0);
+#endif
vFillASTModeInfo (pScrn);
@@ -999,7 +1006,9 @@ ASTLeaveVT(int scrnIndex, int flags)
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
ASTRecPtr pAST = ASTPTR(pScrn);
+#if !(defined(__sparc__)) && !(defined(__mips__))
vgaHWPtr hwp = VGAHWPTR(pScrn);
+#endif
#ifdef HWC
if (pAST->pHWCPtr) {
@@ -1022,7 +1031,9 @@ ASTLeaveVT(int scrnIndex, int flags)
if (pAST->jChipType == AST1180)
ASTBlankScreen(pScrn, 0);
+#if !(defined(__sparc__)) && !(defined(__mips__))
vgaHWLock(hwp);
+#endif
}
@@ -1030,8 +1041,10 @@ static void
ASTFreeScreen(int scrnIndex, int flags)
{
ASTFreeRec(xf86Screens[scrnIndex]);
+#if !(defined(__sparc__)) && !(defined(__mips__))
if (xf86LoaderCheckSymbol("vgaHWFreeHWRec"))
vgaHWFreeHWRec(xf86Screens[scrnIndex]);
+#endif
}
static ModeStatus
@@ -1095,8 +1108,14 @@ ASTValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
if ( (pAST->jChipType == AST2100) || (pAST->jChipType == AST2200) || (pAST->jChipType == AST2300) || (pAST->jChipType == AST1180) )
{
if ( (mode->CrtcHDisplay == 1920) && (mode->CrtcVDisplay == 1200) )
- return MODE_OK;
- }
+ {
+ GetIndexRegMask(CRTC_PORT, 0xD1, 0xFF, jReg);
+ if (jReg & 0x01)
+ return MODE_NOMODE;
+ else
+ return MODE_OK;
+ }
+ }
switch (mode->CrtcHDisplay)
{
@@ -1154,6 +1173,7 @@ ASTFreeRec(ScrnInfoPtr pScrn)
static Bool
ASTSaveScreen(ScreenPtr pScreen, Bool unblack)
{
+#if !(defined(__sparc__)) && !(defined(__mips__))
/* replacement of vgaHWBlankScreen(pScrn, unblank) without seq reset */
/* return vgaHWSaveScreen(pScreen, unblack); */
ScrnInfoPtr pScrn = NULL;
@@ -1165,43 +1185,50 @@ ASTSaveScreen(ScreenPtr pScreen, Bool unblack)
ASTBlankScreen(pScrn, unblack);
}
return (TRUE);
+#endif
}
static Bool
ASTCloseScreen(int scrnIndex, ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
- vgaHWPtr hwp = VGAHWPTR(pScrn);
ASTRecPtr pAST = ASTPTR(pScrn);
+#if !(defined(__sparc__)) && !(defined(__mips__))
+ vgaHWPtr hwp = VGAHWPTR(pScrn);
+#endif
if (pScrn->vtSema == TRUE)
{
#ifdef HWC
- if (pAST->pHWCPtr) {
- xf86FreeOffscreenLinear(pAST->pHWCPtr); /* free HWC Cache */
- pAST->pHWCPtr = NULL;
- }
+ if (pAST->pHWCPtr) {
+ xf86FreeOffscreenLinear(pAST->pHWCPtr); /* free HWC Cache */
+ pAST->pHWCPtr = NULL;
+ }
ASTDisableHWC(pScrn);
#endif
#ifdef Accel_2D
- if (pAST->pCMDQPtr) {
- xf86FreeOffscreenLinear(pAST->pCMDQPtr); /* free CMDQ */
- pAST->pCMDQPtr = NULL;
- }
- vDisable2D(pScrn, pAST);
+ if (pAST->pCMDQPtr) {
+ xf86FreeOffscreenLinear(pAST->pCMDQPtr); /* free CMDQ */
+ pAST->pCMDQPtr = NULL;
+ }
+ vDisable2D(pScrn, pAST);
#endif
- ASTRestore(pScrn);
-
- if (pAST->jChipType == AST1180)
- ASTBlankScreen(pScrn, 0);
+ ASTRestore(pScrn);
- vgaHWLock(hwp);
+ if (pAST->jChipType == AST1180)
+ ASTBlankScreen(pScrn, 0);
+
+#if !(defined(__sparc__)) && !(defined(__mips__))
+ vgaHWLock(hwp);
+#endif
}
ASTUnmapMem(pScrn);
+#if !(defined(__sparc__)) && !(defined(__mips__))
vgaHWUnmapMem(pScrn);
+#endif
if(pAST->AccelInfoPtr) {
XAADestroyInfoRec(pAST->AccelInfoPtr);
@@ -1222,24 +1249,13 @@ static void
ASTSave(ScrnInfoPtr pScrn)
{
ASTRecPtr pAST;
- vgaRegPtr vgaReg;
ASTRegPtr astReg;
int i, icount=0;
ULONG ulData;
pAST = ASTPTR(pScrn);
- vgaReg = &VGAHWPTR(pScrn)->SavedReg;
- astReg = &pAST->SavedReg;
-
- /* do save */
- if (xf86IsPrimaryPci(pAST->PciInfo)) {
- vgaHWSave(pScrn, vgaReg, VGA_SR_ALL);
- }
- else {
- vgaHWSave(pScrn, vgaReg, VGA_SR_MODE);
- }
+ astReg = &pAST->SavedReg;
- /* Ext. Save */
if (pAST->jChipType == AST1180)
{
for (i=0; i<12; i++)
@@ -1249,7 +1265,45 @@ ASTSave(ScrnInfoPtr pScrn)
}
}
else
- {
+ {
+#if defined(__sparc__) || defined(__mips__)
+ UCHAR jReg;
+
+ /* Save Misc */
+ astReg->MISC = GetReg(MISC_PORT_READ);
+
+ /* Save SR */
+ for (i=0; i<4; i++)
+ GetIndexReg(SEQ_PORT, (UCHAR) (i), astReg->SEQ[i]);
+
+ /* Save CR */
+ for (i=0; i<25; i++)
+ GetIndexReg(CRTC_PORT, (UCHAR) (i), astReg->CRTC[i]);
+
+ /* Save GR */
+ for (i=0; i<9; i++)
+ GetIndexReg(GR_PORT, (UCHAR) (i), astReg->GR[i]);
+
+ /* Save AR */
+ jReg = GetReg(INPUT_STATUS1_READ);
+ for (i=0; i<20; i++)
+ GetIndexReg(AR_PORT_WRITE, (UCHAR) (i), astReg->AR[i]);
+ jReg = GetReg(INPUT_STATUS1_READ);
+ SetReg (AR_PORT_WRITE, 0x20); /* set POS */
+#else
+ vgaRegPtr vgaReg;
+ vgaReg = &VGAHWPTR(pScrn)->SavedReg;
+
+ /* do save */
+ if (xf86IsPrimaryPci(pAST->PciInfo)) {
+ vgaHWSave(pScrn, vgaReg, VGA_SR_MODE | VGA_SR_FONTS);
+ }
+ else {
+ vgaHWSave(pScrn, vgaReg, VGA_SR_MODE);
+ }
+#endif
+
+ /* Save Ext. */
vASTOpenKey(pScrn);
/* fixed Console Switch Refresh Rate Incorrect issue, ycchen@051106 */
@@ -1258,31 +1312,25 @@ ASTSave(ScrnInfoPtr pScrn)
for (i=0xBC; i<=0xC1; i++)
GetIndexReg(CRTC_PORT, (UCHAR) (i), astReg->ExtCRTC[icount++]);
GetIndexReg(CRTC_PORT, (UCHAR) (0xBB), astReg->ExtCRTC[icount]);
+
+ /* Save DAC */
+ for (i=0; i<256; i++)
+ VGA_GET_PALETTE_INDEX (i, astReg->DAC[i][0], astReg->DAC[i][1], astReg->DAC[i][2]);
}
-
+
}
static void
ASTRestore(ScrnInfoPtr pScrn)
{
ASTRecPtr pAST;
- vgaRegPtr vgaReg;
ASTRegPtr astReg;
int i, icount=0;
ULONG ulData;
pAST = ASTPTR(pScrn);
- vgaReg = &VGAHWPTR(pScrn)->SavedReg;
- astReg = &pAST->SavedReg;
+ astReg = &pAST->SavedReg;
- /* do restore */
- vgaHWProtect(pScrn, TRUE);
- if (xf86IsPrimaryPci(pAST->PciInfo))
- vgaHWRestore(pScrn, vgaReg, VGA_SR_ALL);
- else
- vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE);
- vgaHWProtect(pScrn, FALSE);
-
if (pAST->jChipType == AST1180)
{
for (i=0; i<12; i++)
@@ -1292,7 +1340,51 @@ ASTRestore(ScrnInfoPtr pScrn)
}
}
else
- {
+ {
+#if defined(__sparc__) || defined(__mips__)
+ UCHAR jReg;
+
+ /* Restore Misc */
+ SetReg(MISC_PORT_WRITE, astReg->MISC);
+
+ /* Restore SR */
+ for (i=0; i<4; i++)
+ SetIndexReg(SEQ_PORT, (UCHAR) (i), astReg->SEQ[i]);
+
+ /* Restore CR */
+ SetIndexRegMask(CRTC_PORT,0x11, 0x7F, 0x00);
+ for (i=0; i<25; i++)
+ SetIndexReg(CRTC_PORT, (UCHAR) (i), astReg->CRTC[i]);
+
+ /* Restore GR */
+ for (i=0; i<9; i++)
+ SetIndexReg(GR_PORT, (UCHAR) (i), astReg->GR[i]);
+
+ /* Restore AR */
+ jReg = GetReg(INPUT_STATUS1_READ);
+ for (i=0; i<20; i++)
+ {
+ SetReg(AR_PORT_WRITE, (UCHAR) i);
+ SetReg(AR_PORT_WRITE, astReg->AR[i]);
+ }
+ SetReg(AR_PORT_WRITE, 0x14);
+ SetReg(AR_PORT_WRITE, 0x00);
+
+ jReg = GetReg(INPUT_STATUS1_READ);
+ SetReg (AR_PORT_WRITE, 0x20); /* set POS */
+#else
+ vgaRegPtr vgaReg;
+ vgaReg = &VGAHWPTR(pScrn)->SavedReg;
+
+ /* do restore */
+ vgaHWProtect(pScrn, TRUE);
+ if (xf86IsPrimaryPci(pAST->PciInfo))
+ vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE | VGA_SR_FONTS);
+ else
+ vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE);
+ vgaHWProtect(pScrn, FALSE);
+#endif
+
/* Ext. restore */
vASTOpenKey(pScrn);
@@ -1302,6 +1394,10 @@ ASTRestore(ScrnInfoPtr pScrn)
for (i=0xBC; i<=0xC1; i++)
SetIndexReg(CRTC_PORT, (UCHAR) (i), astReg->ExtCRTC[icount++]);
SetIndexReg(CRTC_PORT, (UCHAR) (0xBB), astReg->ExtCRTC[icount]);
+
+ /* Restore DAC */
+ for (i=0; i<256; i++)
+ VGA_LOAD_PALETTE_INDEX (i, astReg->DAC[i][0], astReg->DAC[i][1], astReg->DAC[i][2]);
}
}
@@ -1309,33 +1405,29 @@ ASTRestore(ScrnInfoPtr pScrn)
static void
ASTProbeDDC(ScrnInfoPtr pScrn, int index)
{
- vbeInfoPtr pVbe;
ASTRecPtr pAST = ASTPTR(pScrn);
unsigned char DDC_data[128];
Bool Flags;
- if ( (pAST->jChipType == AST1180) || (!xf86IsPrimaryPci(pAST->PciInfo)) )
+ if (xf86LoadSubModule(pScrn, "ddc"))
{
- if (pAST->jChipType == AST1180)
- Flags = GetVGA2EDID(pScrn, DDC_data);
- else
- Flags = GetVGAEDID(pScrn, DDC_data);
-
- if (Flags)
- {
- ConfiguredMonitor = xf86InterpretEDID(pScrn->scrnIndex, DDC_data);
- }
- else
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,"[ASTProbeDDC] Can't Get EDID Properly \n");
- }
+ if (pAST->jChipType == AST1180)
+ Flags = GetVGA2EDID(pScrn, DDC_data);
+ else
+ Flags = GetVGAEDID(pScrn, DDC_data);
+
+ if (Flags)
+ {
+ ConfiguredMonitor = xf86InterpretEDID(pScrn->scrnIndex, DDC_data);
+ }
+ else
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,"[ASTProbeDDC] Can't Get EDID Properly \n");
+ }
else
{
- if (xf86LoadSubModule(pScrn, "vbe")) {
- pVbe = VBEInit(NULL, index);
- ConfiguredMonitor = vbeDoEDID(pVbe, NULL);
- vbeFree(pVbe);
- }
- }
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,"[ASTProbeDDC] Can't Load DDC Sub-Modules or Read EDID Failed \n");
+ }
+
}
#define SkipDT 0x00
@@ -1345,201 +1437,194 @@ ASTProbeDDC(ScrnInfoPtr pScrn, int index)
static xf86MonPtr
ASTDoDDC(ScrnInfoPtr pScrn, int index)
{
- vbeInfoPtr pVbe;
- xf86MonPtr MonInfo = NULL, MonInfo1 = NULL, MonInfo2 = NULL;
+ xf86MonPtr MonInfo = NULL;
ASTRecPtr pAST = ASTPTR(pScrn);
- unsigned long i, j, k;
unsigned char DDC_data[128];
+ Bool Flags;
+
+ xf86MonPtr MonInfo1 = NULL, MonInfo2 = NULL;
+ unsigned long i, j, k;
struct monitor_ranges ranges, ranges1, ranges2;
int DTSelect, dclock1=0, h_active1=0, v_active1=0, dclock2=0, h_active2=0, v_active2=0;
struct std_timings stdtiming, *stdtiming1, *stdtiming2;
- Bool Flags;
-
+
/* Honour Option "noDDC" */
if (xf86ReturnOptValBool(pAST->Options, OPTION_NO_DDC, FALSE)) {
return MonInfo;
}
- if ( (pAST->jChipType == AST1180) || (!xf86IsPrimaryPci(pAST->PciInfo)) )
+ if (xf86LoadSubModule(pScrn, "ddc"))
{
-
- if (pAST->jChipType == AST1180)
- Flags = GetVGA2EDID(pScrn, DDC_data);
- else
- Flags = GetVGAEDID(pScrn, DDC_data);
-
- if (Flags)
- {
- MonInfo = xf86InterpretEDID(pScrn->scrnIndex, DDC_data);
- xf86PrintEDID(MonInfo);
- xf86SetDDCproperties(pScrn, MonInfo);
- }
- else
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,"[ASTDoDDC] Can't Get EDID Properly \n");
-
- }
- else
- {
-
- if (xf86LoadSubModule(pScrn, "vbe") && (pVbe = VBEInit(NULL, index))) {
- MonInfo1 = vbeDoEDID(pVbe, NULL);
- MonInfo = MonInfo1;
+ if (pAST->jChipType == AST1180)
+ Flags = GetVGA2EDID(pScrn, DDC_data);
+ else
+ Flags = GetVGAEDID(pScrn, DDC_data);
- /* For VGA2 CLONE Support, ycchen@012508 */
- 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);
- if (MonInfo1 == NULL) /* No DDC1 EDID */
- MonInfo = MonInfo2;
- else { /* Check with VGA1 & VGA2 EDID */
- /* Update establishment timing */
- MonInfo->timings1.t1 = MonInfo1->timings1.t1 & MonInfo2->timings1.t1;
- MonInfo->timings1.t2 = MonInfo1->timings1.t2 & MonInfo2->timings1.t2;
- MonInfo->timings1.t_manu = MonInfo1->timings1.t_manu & MonInfo2->timings1.t_manu;
-
- /* Update Std. Timing */
- for (i=0; i<8; i++) {
- stdtiming.hsize = stdtiming.vsize = stdtiming.refresh = stdtiming.id = 0;
- for (j=0; j<8; j++) {
- if ((MonInfo1->timings2[i].hsize == MonInfo2->timings2[j].hsize) && \
- (MonInfo1->timings2[i].vsize == MonInfo2->timings2[j].vsize) && \
- (MonInfo1->timings2[i].refresh == MonInfo2->timings2[j].refresh)) {
- stdtiming = MonInfo1->timings2[i];
- break;
- }
- }
-
- MonInfo->timings2[i] = stdtiming;
- } /* Std. Timing */
+ if (Flags)
+ {
+ MonInfo = MonInfo1 = xf86InterpretEDID(pScrn->scrnIndex, DDC_data);
+ }
+
+ /* For VGA2 CLONE Support, ycchen@012508 */
+ 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);
+ if (MonInfo1 == NULL) /* No DDC1 EDID */
+ MonInfo = MonInfo2;
+ else { /* Check with VGA1 & VGA2 EDID */
+ /* Update establishment timing */
+ MonInfo->timings1.t1 = MonInfo1->timings1.t1 & MonInfo2->timings1.t1;
+ MonInfo->timings1.t2 = MonInfo1->timings1.t2 & MonInfo2->timings1.t2;
+ MonInfo->timings1.t_manu = MonInfo1->timings1.t_manu & MonInfo2->timings1.t_manu;
- /* Get Detailed Timing */
- for (i=0;i<4;i++) {
- if (MonInfo1->det_mon[i].type == 0xFD)
- ranges1 = MonInfo1->det_mon[i].section.ranges;
- else if (MonInfo1->det_mon[i].type == 0xFA)
- stdtiming1 = MonInfo1->det_mon[i].section.std_t;
- else if (MonInfo1->det_mon[i].type == 0x00) {
- if (MonInfo1->det_mon[i].section.d_timings.clock > dclock1)
- dclock1 = MonInfo1->det_mon[i].section.d_timings.clock;
- if (MonInfo1->det_mon[i].section.d_timings.h_active > h_active1)
- h_active1 = MonInfo1->det_mon[i].section.d_timings.h_active;
- if (MonInfo1->det_mon[i].section.d_timings.v_active > v_active1)
- v_active1 = MonInfo1->det_mon[i].section.d_timings.v_active;
- }
- if (MonInfo2->det_mon[i].type == 0xFD)
- ranges2 = MonInfo2->det_mon[i].section.ranges;
- else if (MonInfo1->det_mon[i].type == 0xFA)
- stdtiming2 = MonInfo2->det_mon[i].section.std_t;
- else if (MonInfo2->det_mon[i].type == 0x00) {
- if (MonInfo2->det_mon[i].section.d_timings.clock > dclock2)
- dclock2 = MonInfo2->det_mon[i].section.d_timings.clock;
- if (MonInfo2->det_mon[i].section.d_timings.h_active > h_active2)
- h_active2 = MonInfo2->det_mon[i].section.d_timings.h_active;
- if (MonInfo2->det_mon[i].section.d_timings.v_active > v_active2)
- v_active2 = MonInfo2->det_mon[i].section.d_timings.v_active;
- }
- } /* Get Detailed Timing */
-
- /* Chk Detailed Timing */
- if ((dclock1 >= dclock2) && (h_active1 >= h_active2) && (v_active1 >= v_active2))
- DTSelect = DT2;
- else if ((dclock2 >= dclock1) && (h_active2 >= h_active1) && (v_active2 >= v_active1))
- DTSelect = DT1;
- else
- DTSelect = SkipDT;
-
- /* Chk Monitor Descriptor */
- ranges = ranges1;
- ranges.min_h = ranges1.min_h > ranges2.min_h ? ranges1.min_h:ranges2.min_h;
- ranges.min_v = ranges1.min_v > ranges2.min_v ? ranges1.min_v:ranges2.min_v;
- ranges.max_h = ranges1.max_h < ranges2.max_h ? ranges1.max_h:ranges2.max_h;
- ranges.max_v = ranges1.max_v < ranges2.max_v ? ranges1.max_v:ranges2.max_v;
- ranges.max_clock = ranges1.max_clock < ranges2.max_clock ? ranges1.max_clock:ranges2.max_clock;
-
- /* Update Detailed Timing */
- for (i=0; i<4; i++)
- {
- if (MonInfo->det_mon[i].type == 0xFD) {
- MonInfo->det_mon[i].section.ranges = ranges;
- }
- else if (MonInfo->det_mon[i].type == 0xFA) {
- for (j=0; j<5; j++) {
- stdtiming.hsize = stdtiming.vsize = stdtiming.refresh = stdtiming.id = 0;
- for (k=0; k<5; k++) {
- if ((stdtiming1[j].hsize == stdtiming2[k].hsize) && \
- (stdtiming1[j].vsize == stdtiming2[k].vsize) && \
- (stdtiming1[j].refresh == stdtiming2[k].refresh)) {
- stdtiming = stdtiming1[j];
- break;
- }
- }
- stdtiming1[j] = stdtiming;
- } /* Std. Timing */
- } /* FA */
- else if (MonInfo->det_mon[i].type == 0x00) {
- if (DTSelect == DT2)
- MonInfo->det_mon[i] = MonInfo2->det_mon[i];
- else if (DTSelect == DT1)
- MonInfo->det_mon[i] = MonInfo1->det_mon[i];
- else /* SkipDT */
- { /* use 1024x768 as default */
- MonInfo->det_mon[i] = MonInfo1->det_mon[i];
- MonInfo->det_mon[i].section.d_timings.clock = 65000000;
- MonInfo->det_mon[i].section.d_timings.h_active = 1024;
- MonInfo->det_mon[i].section.d_timings.h_blanking = 320;
- MonInfo->det_mon[i].section.d_timings.v_active = 768;
- MonInfo->det_mon[i].section.d_timings.v_blanking = 38;
- MonInfo->det_mon[i].section.d_timings.h_sync_off = 24;
- MonInfo->det_mon[i].section.d_timings.h_sync_width = 136;
- MonInfo->det_mon[i].section.d_timings.v_sync_off = 3;
- MonInfo->det_mon[i].section.d_timings.v_sync_width = 6;
- }
- } /* 00 */
- else { /* use Monitor 1 as default */
- MonInfo->det_mon[i] = MonInfo1->det_mon[i];
- }
-
- } /* Update Detailed Timing */
-
- /* set feature size */
- if (DTSelect == DT2) {
- MonInfo->features.hsize = MonInfo2->features.hsize;
- MonInfo->features.vsize = MonInfo2->features.vsize;
- }
- else if (DTSelect == DT1) {
- MonInfo->features.hsize = MonInfo1->features.hsize;
- MonInfo->features.vsize = MonInfo1->features.vsize;
- }
- else /* Skip DT */
- { /* use 1024x768 as default */
- MonInfo->features.hsize = 0x20;
- MonInfo->features.vsize = 0x18;
+ /* Update Std. Timing */
+ for (i=0; i<8; i++) {
+ stdtiming.hsize = stdtiming.vsize = stdtiming.refresh = stdtiming.id = 0;
+ for (j=0; j<8; j++) {
+ if ((MonInfo1->timings2[i].hsize == MonInfo2->timings2[j].hsize) && \
+ (MonInfo1->timings2[i].vsize == MonInfo2->timings2[j].vsize) && \
+ (MonInfo1->timings2[i].refresh == MonInfo2->timings2[j].refresh)) {
+ stdtiming = MonInfo1->timings2[i];
+ break;
+ }
+ }
+
+ MonInfo->timings2[i] = stdtiming;
+ } /* Std. Timing */
+
+ /* Get Detailed Timing */
+ for (i=0;i<4;i++) {
+ if (MonInfo1->det_mon[i].type == 0xFD)
+ ranges1 = MonInfo1->det_mon[i].section.ranges;
+ else if (MonInfo1->det_mon[i].type == 0xFA)
+ stdtiming1 = MonInfo1->det_mon[i].section.std_t;
+ else if (MonInfo1->det_mon[i].type == 0x00) {
+ if (MonInfo1->det_mon[i].section.d_timings.clock > dclock1)
+ dclock1 = MonInfo1->det_mon[i].section.d_timings.clock;
+ if (MonInfo1->det_mon[i].section.d_timings.h_active > h_active1)
+ h_active1 = MonInfo1->det_mon[i].section.d_timings.h_active;
+ if (MonInfo1->det_mon[i].section.d_timings.v_active > v_active1)
+ v_active1 = MonInfo1->det_mon[i].section.d_timings.v_active;
}
-
- } /* Check with VGA1 & VGA2 EDID */
-
- } /* GetVGA2EDID */
- else {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Can't Get VGA2 EDID Correctly!! \n");
- }
-
- }
-
- /* save MonInfo to Private */
- pAST->mon_h_active = MonInfo->det_mon[0].section.d_timings.h_active;
- pAST->mon_v_active = MonInfo->det_mon[0].section.d_timings.v_active;
-
- xf86PrintEDID(MonInfo);
- xf86SetDDCproperties(pScrn, MonInfo);
- vbeFree(pVbe);
- } else {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "this driver cannot do DDC without VBE\n");
- }
+ if (MonInfo2->det_mon[i].type == 0xFD)
+ ranges2 = MonInfo2->det_mon[i].section.ranges;
+ else if (MonInfo1->det_mon[i].type == 0xFA)
+ stdtiming2 = MonInfo2->det_mon[i].section.std_t;
+ else if (MonInfo2->det_mon[i].type == 0x00) {
+ if (MonInfo2->det_mon[i].section.d_timings.clock > dclock2)
+ dclock2 = MonInfo2->det_mon[i].section.d_timings.clock;
+ if (MonInfo2->det_mon[i].section.d_timings.h_active > h_active2)
+ h_active2 = MonInfo2->det_mon[i].section.d_timings.h_active;
+ if (MonInfo2->det_mon[i].section.d_timings.v_active > v_active2)
+ v_active2 = MonInfo2->det_mon[i].section.d_timings.v_active;
+ }
+ } /* Get Detailed Timing */
+
+ /* Chk Detailed Timing */
+ if ((dclock1 >= dclock2) && (h_active1 >= h_active2) && (v_active1 >= v_active2))
+ DTSelect = DT2;
+ else if ((dclock2 >= dclock1) && (h_active2 >= h_active1) && (v_active2 >= v_active1))
+ DTSelect = DT1;
+ else
+ DTSelect = SkipDT;
- } /* AST1180 */
+ /* Chk Monitor Descriptor */
+ ranges = ranges1;
+ ranges.min_h = ranges1.min_h > ranges2.min_h ? ranges1.min_h:ranges2.min_h;
+ ranges.min_v = ranges1.min_v > ranges2.min_v ? ranges1.min_v:ranges2.min_v;
+ ranges.max_h = ranges1.max_h < ranges2.max_h ? ranges1.max_h:ranges2.max_h;
+ ranges.max_v = ranges1.max_v < ranges2.max_v ? ranges1.max_v:ranges2.max_v;
+ ranges.max_clock = ranges1.max_clock < ranges2.max_clock ? ranges1.max_clock:ranges2.max_clock;
+
+ /* Update Detailed Timing */
+ for (i=0; i<4; i++)
+ {
+ if (MonInfo->det_mon[i].type == 0xFD) {
+ MonInfo->det_mon[i].section.ranges = ranges;
+ }
+ else if (MonInfo->det_mon[i].type == 0xFA) {
+ for (j=0; j<5; j++) {
+ stdtiming.hsize = stdtiming.vsize = stdtiming.refresh = stdtiming.id = 0;
+ for (k=0; k<5; k++) {
+ if ((stdtiming1[j].hsize == stdtiming2[k].hsize) && \
+ (stdtiming1[j].vsize == stdtiming2[k].vsize) && \
+ (stdtiming1[j].refresh == stdtiming2[k].refresh)) {
+ stdtiming = stdtiming1[j];
+ break;
+ }
+ }
+ stdtiming1[j] = stdtiming;
+ } /* Std. Timing */
+ } /* FA */
+ else if (MonInfo->det_mon[i].type == 0x00) {
+ if (DTSelect == DT2)
+ MonInfo->det_mon[i] = MonInfo2->det_mon[i];
+ else if (DTSelect == DT1)
+ MonInfo->det_mon[i] = MonInfo1->det_mon[i];
+ else /* SkipDT */
+ { /* use 1024x768 as default */
+ MonInfo->det_mon[i] = MonInfo1->det_mon[i];
+ MonInfo->det_mon[i].section.d_timings.clock = 65000000;
+ MonInfo->det_mon[i].section.d_timings.h_active = 1024;
+ MonInfo->det_mon[i].section.d_timings.h_blanking = 320;
+ MonInfo->det_mon[i].section.d_timings.v_active = 768;
+ MonInfo->det_mon[i].section.d_timings.v_blanking = 38;
+ MonInfo->det_mon[i].section.d_timings.h_sync_off = 24;
+ MonInfo->det_mon[i].section.d_timings.h_sync_width = 136;
+ MonInfo->det_mon[i].section.d_timings.v_sync_off = 3;
+ MonInfo->det_mon[i].section.d_timings.v_sync_width = 6;
+ }
+ } /* 00 */
+ else { /* use Monitor 1 as default */
+ MonInfo->det_mon[i] = MonInfo1->det_mon[i];
+ }
+
+ } /* Update Detailed Timing */
+
+ /* set feature size */
+ if (DTSelect == DT2) {
+ MonInfo->features.hsize = MonInfo2->features.hsize;
+ MonInfo->features.vsize = MonInfo2->features.vsize;
+ }
+ else if (DTSelect == DT1) {
+ MonInfo->features.hsize = MonInfo1->features.hsize;
+ MonInfo->features.vsize = MonInfo1->features.vsize;
+ }
+ else /* Skip DT */
+ { /* use 1024x768 as default */
+ MonInfo->features.hsize = 0x20;
+ MonInfo->features.vsize = 0x18;
+ }
+
+ } /* Check with VGA1 & VGA2 EDID */
+
+ } /* GetVGA2EDID */
+ else {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Can't Get VGA2 EDID Correctly!! \n");
+ }
+ } /* VGA2Clone */
+
+ xf86PrintEDID(MonInfo);
+ xf86SetDDCproperties(pScrn, MonInfo);
+ }
+ else
+ {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,"[ASTDoDDC] Can't Load DDC Sub-Modules or Read EDID Failed \n");
+ }
+ /* Fill pAST Monitor Info */
+ if (MonInfo == NULL)
+ { /* default for Non-EDID */
+ pAST->mon_h_active = 1024;
+ pAST->mon_v_active = 768;
+ }
+ else
+ { /* save MonInfo to Private */
+ pAST->mon_h_active = MonInfo->det_mon[0].section.d_timings.h_active;
+ pAST->mon_v_active = MonInfo->det_mon[0].section.d_timings.v_active;
+ }
+
return MonInfo;
}
@@ -1561,12 +1646,21 @@ vFillASTModeInfo (ScrnInfoPtr pScrn)
static Bool
ASTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
{
- vgaHWPtr hwp;
ASTRecPtr pAST;
- hwp = VGAHWPTR(pScrn);
pAST = ASTPTR(pScrn);
+ pScrn->vtSema = TRUE;
+ pAST->ModePtr = mode;
+
+#if defined(__sparc__) || defined(__mips__)
+ if (!ASTSetMode(pScrn, mode))
+ return FALSE;
+#else
+ vgaHWPtr hwp;
+
+ hwp = VGAHWPTR(pScrn);
+
vgaHWUnlock(hwp);
if (!vgaHWInit(pScrn, mode))
@@ -1579,6 +1673,7 @@ ASTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
return FALSE;
vgaHWProtect(pScrn, FALSE);
+#endif
return TRUE;
}