summaryrefslogtreecommitdiff
path: root/src/ct_driver.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ct_driver.c')
-rw-r--r--src/ct_driver.c129
1 files changed, 53 insertions, 76 deletions
diff --git a/src/ct_driver.c b/src/ct_driver.c
index 65d833c..87ece8b 100644
--- a/src/ct_driver.c
+++ b/src/ct_driver.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.c,v 1.132tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.c,v 1.128 2003/08/23 16:09:15 dawes Exp $ */
/*
* Copyright 1993 by Jon Block <block@frc.com>
@@ -142,7 +142,7 @@ static Bool CHIPSEnterVT(int scrnIndex, int flags);
static void CHIPSLeaveVT(int scrnIndex, int flags);
static Bool CHIPSCloseScreen(int scrnIndex, ScreenPtr pScreen);
static void CHIPSFreeScreen(int scrnIndex, int flags);
-static ModeStatus CHIPSValidMode(int scrnIndex, DisplayModePtr mode,
+static int CHIPSValidMode(int scrnIndex, DisplayModePtr mode,
Bool verbose, int flags);
static Bool CHIPSSaveScreen(ScreenPtr pScreen, int mode);
@@ -158,8 +158,7 @@ static void chipsLock(ScrnInfoPtr pScrn);
static void chipsUnlock(ScrnInfoPtr pScrn);
static void chipsClockSave(ScrnInfoPtr pScrn, CHIPSClockPtr Clock);
static void chipsClockLoad(ScrnInfoPtr pScrn, CHIPSClockPtr Clock);
-static Bool chipsClockFind(ScrnInfoPtr pScrn, DisplayModePtr mode,
- int no, CHIPSClockPtr Clock);
+static Bool chipsClockFind(ScrnInfoPtr pScrn, int no, CHIPSClockPtr Clock);
static void chipsCalcClock(ScrnInfoPtr pScrn, int Clock,
unsigned char *vclk);
static int chipsGetHWClock(ScrnInfoPtr pScrn);
@@ -582,7 +581,7 @@ static const OptionInfoRec Chips655xxOptions[] = {
{ OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_STN, "STN", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_USE_MODELINE, "UseModeline", OPTV_BOOLEAN, {0}, FALSE },
- { OPTION_LCD_STRETCH, "Stretch", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_LCD_STRETCH, "NoStretch", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_LCD_CENTER, "LcdCenter", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_MMIO, "MMIO", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_SUSPEND_HACK, "SuspendHack", OPTV_BOOLEAN, {0}, FALSE },
@@ -624,7 +623,7 @@ static const OptionInfoRec ChipsHiQVOptions[] = {
{ OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_STN, "STN", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_USE_MODELINE, "UseModeline", OPTV_BOOLEAN, {0}, FALSE },
- { OPTION_LCD_STRETCH, "Stretch", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_LCD_STRETCH, "NoStretch", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_LCD_CENTER, "LcdCenter", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_MMIO, "MMIO", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_FULL_MMIO, "FullMMIO", OPTV_BOOLEAN, {0}, FALSE },
@@ -749,7 +748,7 @@ static XF86ModuleVersionInfo chipsVersRec =
MODULEVENDORSTRING,
MODINFOSTRING1,
MODINFOSTRING2,
- XORG_VERSION_CURRENT,
+ XF86_VERSION_CURRENT,
CHIPS_MAJOR_VERSION, CHIPS_MINOR_VERSION, CHIPS_PATCHLEVEL,
ABI_CLASS_VIDEODRV,
ABI_VIDEODRV_VERSION,
@@ -1559,7 +1558,7 @@ chipsPreInitHiQV(ScrnInfoPtr pScrn, int flags)
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
"Enabling linear addressing\n");
xf86DrvMsg(pScrn->scrnIndex, from,
- "base address is set at 0x%lX.\n", cPtr->FbAddress);
+ "base address is set at 0x%X.\n", cPtr->FbAddress);
cPtr->IOAddress = cPtr->FbAddress + 0x400000L;
} else
xf86DrvMsg(pScrn->scrnIndex, from,
@@ -1770,12 +1769,10 @@ chipsPreInitHiQV(ScrnInfoPtr pScrn, int flags)
case CHIPS_CT69030:
/* The ct69030 has 4Mb of SGRAM integrated */
pScrn->videoRam = 4096;
- cPtr->Flags |= Chips64BitMemory;
break;
case CHIPS_CT69000:
/* The ct69000 has 2Mb of SGRAM integrated */
pScrn->videoRam = 2048;
- cPtr->Flags |= Chips64BitMemory;
break;
case CHIPS_CT65550:
/* XR43: DRAM interface */
@@ -1824,13 +1821,6 @@ chipsPreInitHiQV(ScrnInfoPtr pScrn, int flags)
pScrn->videoRam = 1024;
break;
}
- /* XR43: DRAM interface */
- /* bit 4-5 mem interface width */
- /* 00: 32Bit */
- /* 01: 64Bit */
- tmp = cPtr->readXR(cPtr, 0x43);
- if ((tmp & 0x10) == 0x10)
- cPtr->Flags |= Chips64BitMemory;
break;
}
}
@@ -1841,8 +1831,6 @@ chipsPreInitHiQV(ScrnInfoPtr pScrn, int flags)
* This takes gives either half or the amount of memory specified
* with the Crt2Memory option
*/
- pScrn->memPhysBase = cPtr->FbAddress;
-
if(cPtr->SecondCrtc == FALSE) {
int crt2mem = -1, adjust;
@@ -1865,15 +1853,12 @@ chipsPreInitHiQV(ScrnInfoPtr pScrn, int flags)
cPtr->FbMapSize =
cPtrEnt->masterFbMapSize = pScrn->videoRam * 1024;
cPtrEnt->slaveFbMapSize = cPtrEnt->slavevideoRam * 1024;
- pScrn->fbOffset = 0;
} else {
cPtrEnt->slaveFbAddress = cPtr->FbAddress +
- cPtrEnt->masterFbMapSize;
+ cPtrEnt->masterFbAddress;
cPtr->FbMapSize = cPtrEnt->slaveFbMapSize;
pScrn->videoRam = cPtrEnt->slavevideoRam;
- pScrn->fbOffset = cPtrEnt->masterFbMapSize;
}
-
cPtrEnt->refCount++;
} else {
/* Normal Handling of video ram etc */
@@ -2251,27 +2236,26 @@ chipsPreInitHiQV(ScrnInfoPtr pScrn, int flags)
cPtr->ClockMulFactor = 1;
- /* Set the min/max pixel clock */
+ /* Set the min pixel clock */
+ cPtr->MinClock = 11000; /* XXX Guess, need to check this */
+ xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT, "Min pixel clock is %7.3f MHz\n",
+ (float)(cPtr->MinClock / 1000.));
+ /* Set the max pixel clock */
switch (cPtr->Chipset) {
case CHIPS_CT69030:
- cPtr->MinClock = 3000;
cPtr->MaxClock = 170000;
break;
case CHIPS_CT69000:
- cPtr->MinClock = 3000;
cPtr->MaxClock = 135000;
break;
case CHIPS_CT68554:
case CHIPS_CT65555:
- cPtr->MinClock = 1000;
cPtr->MaxClock = 110000;
break;
case CHIPS_CT65554:
- cPtr->MinClock = 1000;
cPtr->MaxClock = 95000;
break;
case CHIPS_CT65550:
- cPtr->MinClock = 1000;
if (((cPtr->readXR(cPtr, 0x04)) & 0xF) < 6) {
if ((cPtr->readFR(cPtr, 0x0A)) & 2) {
/*5V Vcc */
@@ -2284,15 +2268,13 @@ chipsPreInitHiQV(ScrnInfoPtr pScrn, int flags)
cPtr->MaxClock = 95000; /* Revision B */
break;
}
- xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT, "Min pixel clock is %7.3f MHz\n",
- (float)(cPtr->MinClock / 1000.));
/* Check if maxClock is limited by the MemClk. Only 70% to allow for */
/* RAS/CAS. Extra byte per memory clock needed if framebuffer used */
/* Extra byte if the overlay plane is activated */
- /* If flag Chips64BitMemory is set assume a 64bitmemory interface, */
- /* and 32bits on the others. Thus multiply by a suitable factor */
- if (cPtr->Flags & Chips64BitMemory) {
+ /* We have a 64bit wide memory bus on the 69030 and 69000, and 32bits */
+ /* on the others. Thus multiply by a suitable factor */
+ if ((cPtr->Chipset == CHIPS_CT69030) || (cPtr->Chipset == CHIPS_CT69000)) {
if (cPtr->FrameBufferSize && (cPtr->PanelType & ChipsLCD))
if (cPtr->Flags & ChipsOverlay8plus16 )
cPtr->MaxClock = min(cPtr->MaxClock, MemClk->Clk * 8 * 0.7 / 4);
@@ -2637,7 +2619,7 @@ chipsPreInitWingine(ScrnInfoPtr pScrn, int flags)
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
"Enabling linear addressing\n");
xf86DrvMsg(pScrn->scrnIndex, from,
- "base address is set at 0x%lX.\n", cPtr->FbAddress);
+ "base address is set at 0x%X.\n", cPtr->FbAddress);
if (xf86ReturnOptValBool(cPtr->Options, OPTION_MMIO, FALSE) &&
(cPtr->Flags & ChipsMMIOSupport)) {
cPtr->UseMMIO = TRUE;
@@ -3125,7 +3107,7 @@ chipsPreInit655xx(ScrnInfoPtr pScrn, int flags)
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
"Enabling linear addressing\n");
xf86DrvMsg(pScrn->scrnIndex, from,
- "base address is set at 0x%lX.\n", cPtr->FbAddress);
+ "base address is set at 0x%X.\n", cPtr->FbAddress);
if (xf86ReturnOptValBool(cPtr->Options, OPTION_MMIO, FALSE) &&
(cPtr->Flags & ChipsMMIOSupport)) {
cPtr->UseMMIO = TRUE;
@@ -3257,7 +3239,7 @@ chipsPreInit655xx(ScrnInfoPtr pScrn, int flags)
Size->HRetraceStart = ((tmp + ((xr17 & 0x04) << 9)) + 1) << 3;
tmp1 = cPtr->readXR(cPtr, 0x1A);
tmp2 = (tmp1 & 0x1F) + ((xr17 & 0x08) << 2) - (tmp & 0x3F);
- Size->HRetraceEnd = ((((tmp2 & 0x080u) ? (tmp2 + 0x40) : tmp2) << 3)
+ Size->HRetraceEnd = ((((tmp2 < 0) ? (tmp2 + 0x40) : tmp2) << 3)
+ Size->HRetraceStart);
tmp1 = cPtr->readXR(cPtr, 0x65);
tmp = cPtr->readXR(cPtr, 0x68);
@@ -4354,7 +4336,14 @@ CHIPSScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
if (cPtr->Flags & ChipsDPMSSupport)
xf86DPMSInit(pScreen, (DPMSSetProcPtr)chipsDisplayPowerManagementSet,
0);
-
+
+#if 0 /* #### Shouldn't be needed */
+ /* Dual head, needs to fix framebuffer memory address */
+ if ((cPtr->Flags & ChipsDualChannelSupport) &&
+ (cPtr->SecondCrtc == TRUE))
+ pScrn->memPhysBase = cPtr->FbAddress + cPtrEnt->masterFbMapSize;
+#endif
+
/* Wrap the current CloseScreen function */
cPtr->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = CHIPSCloseScreen;
@@ -4542,7 +4531,7 @@ CHIPSFreeScreen(int scrnIndex, int flags)
}
/* Optional */
-static ModeStatus
+static int
CHIPSValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
{
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
@@ -4702,7 +4691,7 @@ chipsClockSelect(ScrnInfoPtr pScrn, int no)
break;
default:
- if (!chipsClockFind(pScrn, NULL, no, &TmpClock))
+ if (!chipsClockFind(pScrn, no, &TmpClock))
return (FALSE);
chipsClockLoad(pScrn, &TmpClock);
}
@@ -4783,8 +4772,7 @@ chipsClockSave(ScrnInfoPtr pScrn, CHIPSClockPtr Clock)
}
static Bool
-chipsClockFind(ScrnInfoPtr pScrn, DisplayModePtr mode,
- int no, CHIPSClockPtr Clock )
+chipsClockFind(ScrnInfoPtr pScrn, int no, CHIPSClockPtr Clock)
{
vgaHWPtr hwp = VGAHWPTR(pScrn);
CHIPSPtr cPtr = CHIPSPTR(pScrn);
@@ -4804,9 +4792,9 @@ chipsClockFind(ScrnInfoPtr pScrn, DisplayModePtr mode,
case HiQV_STYLE:
Clock->msr = cPtr->CRTclkInx << 2;
Clock->fr03 = cPtr->FPclkInx << 2;
- Clock->Clock = mode ? mode->Clock : 0;
+ Clock->Clock = pScrn->currentMode->Clock;
if (xf86ReturnOptValBool(cPtr->Options, OPTION_USE_MODELINE, FALSE)) {
- Clock->FPClock = mode ? mode->Clock : 0;
+ Clock->FPClock = pScrn->currentMode->Clock;
} else
Clock->FPClock = cPtr->FPclock;
break;
@@ -4845,7 +4833,7 @@ chipsClockFind(ScrnInfoPtr pScrn, DisplayModePtr mode,
if ((cPtr->PanelType & ChipsLCD) && cPtr->FPclock)
Clock->Clock = cPtr->FPclock;
else
- Clock->Clock = mode ? mode->SynthClock : 0;
+ Clock->Clock = pScrn->currentMode->SynthClock;
}
break;
case OLD_STYLE:
@@ -4870,7 +4858,7 @@ chipsClockFind(ScrnInfoPtr pScrn, DisplayModePtr mode,
} else {
Clock->msr = 3 << 2;
Clock->xr33 = 0;
- Clock->Clock = mode ? mode->SynthClock : 0;
+ Clock->Clock = pScrn->currentMode->SynthClock;
}
break;
}
@@ -5081,10 +5069,7 @@ chipsCalcClock(ScrnInfoPtr pScrn, int Clock, unsigned char *vclk)
int M, N, P = 0, PSN = 0, PSNx = 0;
int bestM = 0, bestN = 0, bestP = 0, bestPSN = 0;
- double abest = 42;
-#ifdef DEBUG
- double bestFout = 0;
-#endif
+ double bestError, abest = 42, bestFout = 0;
double target;
double Fvco, Fout;
@@ -5192,13 +5177,12 @@ chipsCalcClock(ScrnInfoPtr pScrn, int Clock, unsigned char *vclk)
aerror = (error < 0) ? -error : error;
if (aerror < abest) {
abest = aerror;
+ bestError = error;
bestM = M;
bestN = N;
bestP = P;
bestPSN = PSN;
-#ifdef DEBUG
bestFout = Fout;
-#endif
}
}
}
@@ -5387,7 +5371,7 @@ chipsModeInitHiQV(ScrnInfoPtr pScrn, DisplayModePtr mode)
pScrn->vtSema = TRUE;
/* init clock */
- if (!chipsClockFind(pScrn, mode, mode->ClockIndex, &ChipsNew->Clock)) {
+ if (!chipsClockFind(pScrn, mode->ClockIndex, &ChipsNew->Clock)) {
ErrorF("bomb 2\n");
return (FALSE);
}
@@ -5595,7 +5579,7 @@ chipsModeInitHiQV(ScrnInfoPtr pScrn, DisplayModePtr mode)
/* centering/stretching */
if (!xf86ReturnOptValBool(cPtr->Options, OPTION_SUSPEND_HACK, FALSE)) {
- if (!xf86ReturnOptValBool(cPtr->Options, OPTION_LCD_STRETCH, FALSE) ||
+ if (xf86ReturnOptValBool(cPtr->Options, OPTION_LCD_STRETCH, FALSE) ||
(cPtr->Flags & ChipsOverlay8plus16)) {
ChipsNew->FR[0x40] &= 0xDF; /* Disable Horizontal stretching */
ChipsNew->FR[0x48] &= 0xFB; /* Disable vertical stretching */
@@ -5616,7 +5600,7 @@ chipsModeInitHiQV(ScrnInfoPtr pScrn, DisplayModePtr mode)
}
}
- if ((xf86ReturnOptValBool(cPtr->Options, OPTION_LCD_CENTER, TRUE))
+ if ((xf86ReturnOptValBool(cPtr->Options, OPTION_LCD_CENTER, FALSE))
|| (cPtr->Flags & ChipsOverlay8plus16)) {
ChipsNew->FR[0x40] |= 0x3; /* Enable Horizontal centering */
ChipsNew->FR[0x48] |= 0x3; /* Enable Vertical centering */
@@ -5771,16 +5755,12 @@ chipsModeInitHiQV(ScrnInfoPtr pScrn, DisplayModePtr mode)
- (ChipsNew->FR[0x31] & 0xF0)
- (ChipsNew->FR[0x32] & 0x0F)
- ((ChipsNew->FR[0x35] & 0xF0) << 4));
- if (!xf86ReturnOptValBool(cPtr->Options, OPTION_LCD_STRETCH, FALSE)
- && xf86ReturnOptValBool(cPtr->Options, OPTION_LCD_CENTER, TRUE))
- {
- if (cPtr->PanelSize.HDisplay > mode->CrtcHDisplay)
- cPtr->OverlaySkewX += (cPtr->PanelSize.HDisplay -
- mode->CrtcHDisplay) / 2;
- if (cPtr->PanelSize.VDisplay > mode->CrtcVDisplay)
- cPtr->OverlaySkewY += (cPtr->PanelSize.VDisplay -
- mode->CrtcVDisplay) / 2;
- }
+ if (cPtr->PanelSize.HDisplay > mode->CrtcHDisplay)
+ cPtr->OverlaySkewX += (cPtr->PanelSize.HDisplay -
+ mode->CrtcHDisplay) / 2;
+ if (cPtr->PanelSize.VDisplay > mode->CrtcVDisplay)
+ cPtr->OverlaySkewY += (cPtr->PanelSize.VDisplay -
+ mode->CrtcVDisplay) / 2;
} else {
cPtr->OverlaySkewX = mode->CrtcHTotal - mode->CrtcHBlankStart - 9;
cPtr->OverlaySkewY = mode->CrtcVTotal - mode->CrtcVSyncEnd - 1;
@@ -5996,7 +5976,7 @@ chipsModeInitWingine(ScrnInfoPtr pScrn, DisplayModePtr mode)
pScrn->vtSema = TRUE;
/* init clock */
- if (!chipsClockFind(pScrn, mode, mode->ClockIndex, &ChipsNew->Clock)) {
+ if (!chipsClockFind(pScrn, mode->ClockIndex, &ChipsNew->Clock)) {
ErrorF("bomb 4\n");
return (FALSE);
}
@@ -6238,7 +6218,7 @@ chipsModeInit655xx(ScrnInfoPtr pScrn, DisplayModePtr mode)
pScrn->vtSema = TRUE;
/* init clock */
- if (!chipsClockFind(pScrn, mode, mode->ClockIndex, &ChipsNew->Clock)) {
+ if (!chipsClockFind(pScrn, mode->ClockIndex, &ChipsNew->Clock)) {
ErrorF("bomb 6\n");
return (FALSE);
}
@@ -6448,15 +6428,12 @@ chipsModeInit655xx(ScrnInfoPtr pScrn, DisplayModePtr mode)
ChipsNew->XR[0x51] |= 0x40; /* enable FP compensation */
ChipsNew->XR[0x55] |= 0x01; /* enable horiz. compensation */
ChipsNew->XR[0x57] |= 0x01; /* enable horiz. compensation */
- if (!xf86ReturnOptValBool(cPtr->Options, OPTION_LCD_STRETCH,
+ if (xf86ReturnOptValBool(cPtr->Options, OPTION_LCD_STRETCH,
FALSE)) {
if (mode->CrtcHDisplay < 1489) /* HWBug */
- ChipsNew->XR[0x55] |= 0x02; /* enable auto h-centering */
- else {
- ChipsNew->XR[0x55] &= 0xFD; /* disable auto h-centering */
- if (pScrn->bitsPerPixel == 24) /* ? */
- ChipsNew->XR[0x56] = (lcdHDisplay - CrtcHDisplay) >> 1;
- }
+ ChipsNew->XR[0x55] |= 0x02; /* enable h-centering */
+ else if (pScrn->bitsPerPixel == 24)
+ ChipsNew->XR[0x56] = (lcdHDisplay - CrtcHDisplay) >> 1;
} else {
ChipsNew->XR[0x55] &= 0xFD; /* disable h-centering */
ChipsNew->XR[0x56] = 0;
@@ -6637,9 +6614,9 @@ chipsModeInit655xx(ScrnInfoPtr pScrn, DisplayModePtr mode)
}
if (cPtr->PanelType & ChipsLCD)
- ChipsNew->XR[0x51] |= 0x04;
+ ChipsNew->XR[0x51] |= 0x02;
else
- ChipsNew->XR[0x51] &= ~0x04;
+ ChipsNew->XR[0x51] &= ~0x02;
/* Program the registers */
/*vgaHWProtect(pScrn, TRUE);*/