summaryrefslogtreecommitdiff
path: root/src/mga_driver.c
diff options
context:
space:
mode:
authorAlexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de>2004-09-15 16:34:01 +0000
committerAlexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de>2004-09-15 16:34:01 +0000
commit4e817ed76a09bbbf4bdbd5a840907eb03c31bf5c (patch)
tree1fa5b167e4a81565f3d0839b52a220d01cbd98eb /src/mga_driver.c
parenta4e8e48b089815fbdf28fa9b2205451725cf24d3 (diff)
Diffstat (limited to 'src/mga_driver.c')
-rw-r--r--src/mga_driver.c205
1 files changed, 141 insertions, 64 deletions
diff --git a/src/mga_driver.c b/src/mga_driver.c
index 7e45fc4..c2c3724 100644
--- a/src/mga_driver.c
+++ b/src/mga_driver.c
@@ -47,11 +47,6 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c,v 1.244tsi Exp $ */
-/*
- * This is a first cut at a non-accelerated version to work with the
- * new server design (DHD).
- */
-
/* All drivers should typically include these */
#include "xf86.h"
@@ -88,6 +83,7 @@
#include "mga_reg.h"
#include "mga.h"
#include "mga_macros.h"
+#include "mga_maven.h"
#include "xaa.h"
#include "xf86cmap.h"
@@ -251,7 +247,7 @@ static const char *vgahwSymbols[] = {
"vgaHWSetMmioFuncs",
"vgaHWUnlock",
"vgaHWUnmapMem",
- "vgaHWddc1SetSpeed",
+ "vgaHWddc1SetSpeedWeak",
NULL
};
@@ -271,7 +267,7 @@ static const char *xaaSymbols[] = {
"XAACachePlanarMonoStipple",
"XAACreateInfoRec",
"XAADestroyInfoRec",
- "XAAFallbackOps",
+ "XAAGetFallbackOps",
"XAAInit",
"XAAMoveDWORDS",
"XAA_888_plus_PICT_a8_to_8888",
@@ -325,6 +321,7 @@ static const char *driSymbols[] = {
"DRIScreenInit",
"DRIUnlock",
"GlxSetVisualConfigs",
+ "DRICreatePCIBusID",
NULL
};
#endif
@@ -368,22 +365,22 @@ static const char *int10Symbols[] = {
};
static const char *fbdevHWSymbols[] = {
- "fbdevHWAdjustFrame",
+ "fbdevHWAdjustFrameWeak",
"fbdevHWEnterVT",
"fbdevHWGetVidmem",
"fbdevHWInit",
- "fbdevHWLeaveVT",
- "fbdevHWLoadPalette",
+ "fbdevHWLeaveVTWeak",
+ "fbdevHWLoadPaletteWeak",
"fbdevHWMapMMIO",
"fbdevHWMapVidmem",
"fbdevHWModeInit",
"fbdevHWRestore",
"fbdevHWSave",
- "fbdevHWSwitchMode",
+ "fbdevHWSwitchModeWeak",
"fbdevHWUnmapMMIO",
"fbdevHWUnmapVidmem",
"fbdevHWUseBuildinMode",
- "fbdevHWValidMode",
+ "fbdevHWValidModeWeak",
NULL
};
@@ -413,7 +410,7 @@ static XF86ModuleVersionInfo mgaVersRec =
MODULEVENDORSTRING,
MODINFOSTRING1,
MODINFOSTRING2,
- XF86_VERSION_CURRENT,
+ XORG_VERSION_CURRENT,
MGA_MAJOR_VERSION, MGA_MINOR_VERSION, MGA_PATCHLEVEL,
ABI_CLASS_VIDEODRV, /* This is a video driver */
ABI_VIDEODRV_VERSION,
@@ -711,10 +708,6 @@ MGAReadBios(ScrnInfoPtr pScrn)
pBios = &pMga->Bios;
pBios2 = &pMga->Bios2;
- /* Get the output mode set by the BIOS */
- xf86ReadDomainMemory(pMga->PciTag, pMga->BiosAddress + 0x7ff1u,
- sizeof(CARD8), &pMga->BiosOutputMode);
-
/*
* If the BIOS address was probed, it was found from the PCI config
* space. If it was given in the config file, try to guess when it
@@ -738,6 +731,9 @@ MGAReadBios(ScrnInfoPtr pScrn)
return;
}
+ /* Get the output mode set by the BIOS */
+ pMga->BiosOutputMode = BIOS[0x7ff1];
+
/* Get the video BIOS info block */
if (strncmp((char *)(&BIOS[45]), "MATROX", 6)) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
@@ -995,9 +991,8 @@ MGAdoDDC(ScrnInfoPtr pScrn)
} else {
/* ddc module not found, we can do without it */
pMga->ddc1Read = NULL;
-
- /* Without DDC, we have no use for the I2C bus */
- pMga->i2cInit = NULL;
+ pMga->DDC_Bus1 = NULL;
+ pMga->DDC_Bus2 = NULL;
return NULL;
}
} else
@@ -1012,7 +1007,8 @@ MGAdoDDC(ScrnInfoPtr pScrn)
} else {
/* i2c module not found, we can do without it */
pMga->i2cInit = NULL;
- pMga->I2C = NULL;
+ pMga->DDC_Bus1 = NULL;
+ pMga->DDC_Bus2 = NULL;
}
}
#endif /* MGAuseI2C */
@@ -1032,7 +1028,7 @@ MGAdoDDC(ScrnInfoPtr pScrn)
return NULL;
} else {
/* XXX Need to write an MGA mode ddc1SetSpeed */
- if (pMga->DDC1SetSpeed == vgaHWddc1SetSpeed) {
+ if (pMga->DDC1SetSpeed == vgaHWddc1SetSpeedWeak()) {
pMga->DDC1SetSpeed = NULL;
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
"DDC1 disabled - chip not in VGA mode\n");
@@ -1045,47 +1041,58 @@ MGAdoDDC(ScrnInfoPtr pScrn)
/* It is now safe to talk to the card */
#if MGAuseI2C
- /* Initialize I2C bus - used by DDC if available */
+ /* Initialize I2C buses - used by DDC if available */
if (pMga->i2cInit) {
pMga->i2cInit(pScrn);
}
- /* Read and output monitor info using DDC2 over I2C bus */
- if (pMga->I2C) {
- MonInfo = xf86DoEDID_DDC2(pScrn->scrnIndex,pMga->I2C);
+
+ /* DDC for second head... */
+ if (pMga->SecondCrtc && pMga->DDC_Bus2) {
+ MonInfo = xf86DoEDID_DDC2(pScrn->scrnIndex,pMga->DDC_Bus2);
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "I2C Monitor info: %p\n",
(void *)MonInfo);
xf86PrintEDID(MonInfo);
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of I2C Monitor info\n");
+ xf86SetDDCproperties(pScrn, MonInfo);
+ return MonInfo;
}
- if (!MonInfo)
-#endif /* MGAuseI2C */
- /* Read and output monitor info using DDC1 */
- if (pMga->ddc1Read && pMga->DDC1SetSpeed) {
- MonInfo = xf86DoEDID_DDC1(pScrn->scrnIndex,
- pMga->DDC1SetSpeed,
- pMga->ddc1Read ) ;
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "DDC Monitor info: %p\n",
- (void *)MonInfo);
- xf86PrintEDID( MonInfo );
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of DDC Monitor info\n");
- }
- if (!MonInfo){
- vbeInfoPtr pVbe;
- if (xf86LoadSubModule(pScrn, "vbe")) {
- pVbe = VBEInit(NULL,pMga->pEnt->index);
- MonInfo = vbeDoEDID(pVbe, NULL);
- vbeFree(pVbe);
-
- if (MonInfo){
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VBE DDC Monitor info: %p\n",
- (void *)MonInfo);
- xf86PrintEDID( MonInfo );
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of VBE DDC Monitor info\n\n");
- }
- }
- }
-
+ else {
+ /* Its the first head... */
+ if (pMga->DDC_Bus1) {
+ MonInfo = xf86DoEDID_DDC2(pScrn->scrnIndex,pMga->DDC_Bus1);
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "I2C Monitor info: %p\n", MonInfo);
+ xf86PrintEDID(MonInfo);
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of I2C Monitor info\n");
+ }
+ if (!MonInfo)
+#endif /* MGAuseI2C */
+ /* Read and output monitor info using DDC1 */
+ if (pMga->ddc1Read && pMga->DDC1SetSpeed) {
+ MonInfo = xf86DoEDID_DDC1(pScrn->scrnIndex,
+ pMga->DDC1SetSpeed,
+ pMga->ddc1Read ) ;
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "DDC Monitor info: %p\n", MonInfo);
+ xf86PrintEDID( MonInfo );
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of DDC Monitor info\n");
+ }
+ if (!MonInfo){
+ vbeInfoPtr pVbe;
+ if (xf86LoadSubModule(pScrn, "vbe")) {
+ pVbe = VBEInit(NULL,pMga->pEnt->index);
+ MonInfo = vbeDoEDID(pVbe, NULL);
+ vbeFree(pVbe);
+
+ if (MonInfo){
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VBE DDC Monitor info: %p\n", MonInfo);
+ xf86PrintEDID( MonInfo );
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of VBE DDC Monitor info\n\n");
+ }
+ }
+ }
+#if MGAuseI2C
+ }
+#endif
/* Restore previous state and unmap MGA memory and MMIO areas */
MGARestore(pScrn);
MGAUnmapMem(pScrn);
@@ -1169,6 +1176,30 @@ MGAProbeDDC(ScrnInfoPtr pScrn, int index)
}
}
+Bool
+MGAMavenRead(ScrnInfoPtr pScrn, I2CByte reg, I2CByte *val)
+{
+ MGAPtr pMga = MGAPTR(pScrn);
+
+ if (!pMga->Maven) return FALSE;
+
+ /* FIXME: Using private interfaces for the moment until a more
+ * flexible xf86I2CWriteRead() variant shows up for us
+ *
+ * MAVEN does _not_ like a start bit in the middle of its transaction
+ * MAVEN does _not_ like ACK at the end of the transaction
+ */
+
+ if (!pMga->Maven_Bus->I2CStart(pMga->Maven_Bus, pMga->Maven->ByteTimeout)) return FALSE;
+ if (!pMga->Maven_Bus->I2CPutByte(pMga->Maven, MAVEN_READ)) return FALSE;
+ if (!pMga->Maven_Bus->I2CPutByte(pMga->Maven, reg)) return FALSE;
+ pMga->Maven_Bus->I2CStop(pMga->Maven);
+ if (!pMga->Maven_Bus->I2CGetByte(pMga->Maven, val, 0)) return FALSE;
+ pMga->Maven_Bus->I2CStop(pMga->Maven);
+
+ return TRUE;
+}
+
/* Mandatory */
static Bool
MGAPreInit(ScrnInfoPtr pScrn, int flags)
@@ -1660,11 +1691,11 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
xf86LoaderReqSymLists(fbdevHWSymbols, NULL);
if (!fbdevHWInit(pScrn, pMga->PciInfo, NULL))
return FALSE;
- pScrn->SwitchMode = fbdevHWSwitchMode;
- pScrn->AdjustFrame = fbdevHWAdjustFrame;
+ pScrn->SwitchMode = fbdevHWSwitchModeWeak();
+ pScrn->AdjustFrame = fbdevHWAdjustFrameWeak();
pScrn->EnterVT = MGAEnterVTFBDev;
- pScrn->LeaveVT = fbdevHWLeaveVT;
- pScrn->ValidMode = fbdevHWValidMode;
+ pScrn->LeaveVT = fbdevHWLeaveVTWeak();
+ pScrn->ValidMode = fbdevHWValidModeWeak();
}
pMga->Rotate = 0;
if ((s = xf86GetOptValString(pMga->Options, OPTION_ROTATE))) {
@@ -3396,7 +3427,8 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
else
f = CMAP_RELOAD_ON_MODE_SWITCH;
if(!xf86HandleColormaps(pScreen, 256, 8,
- (pMga->FBDev ? fbdevHWLoadPalette : MGAdac->LoadPalette), NULL, f))
+ pMga->FBDev ? fbdevHWLoadPaletteWeak() : MGAdac->LoadPalette,
+ NULL, f))
return FALSE;
if(pMga->Overlay8Plus24) { /* Must come after colormap initialization */
@@ -3973,6 +4005,8 @@ MGASaveScreen(ScreenPtr pScreen, int mode)
* MGADisplayPowerManagementSet --
*
* Sets VESA Display Power Management Signaling (DPMS) Mode.
+ *
+ * XXX This needs fixing for sync-on-green!
*/
void
MGADisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode,
@@ -4019,12 +4053,55 @@ MGADisplayPowerManagementSetCrtc2(ScrnInfoPtr pScrn, int PowerManagementMode,
int flags)
{
MGAPtr pMga = MGAPTR(pScrn);
- CARD32 crtc2 = 0;
+ CARD32 val = INREG(MGAREG_C2CTL);
+
+ if (PowerManagementMode==DPMSModeOn) {
+ /* Enable CRTC2 */
+ val |= 0x1;
+ val &= ~(0x8);
+ OUTREG(MGAREG_C2CTL, val);
+ /* Restore normal MAVEN values */
+ if (pMga->Maven) {
+ /* if TV MODE -- for later implementation
+ MAVW(MONEN, 0xb3);
+ MAVW(MONSET, 0x20);
+ MAVW(OUTMODE, 0x08); output: SVideo/Composite
+ MAVW(STABLE, 0x02); makes picture stable?
+ fixme? linux uses 0x14...
+ MAVW(TEST, (MAVR(TEST) & 0x10));
+
+ */
+ /* else monitor mode */
+
+ xf86I2CWriteByte(pMga->Maven, MGAMAV_MONEN, 0xb2);
+ /* must be set to this in monitor mode */
+ xf86I2CWriteByte(pMga->Maven, MGAMAV_MONSET, 0x20);
+ /* output: monitor mode */
+ xf86I2CWriteByte(pMga->Maven, MGAMAV_OUTMODE, 0x03);
+ /* makes picture stable? */
+ xf86I2CWriteByte(pMga->Maven, MGAMAV_STABLE, 0x22);
+ /* turn off test signal */
+ xf86I2CWriteByte(pMga->Maven, MGAMAV_TEST, 0x00);
+ }
+ }
+ else {
+ /* Disable CRTC2 video */
+ val |= 0x8;
+ val &= ~(0x1);
+ OUTREG(MGAREG_C2CTL, val);
+
+ /* Disable MAVEN display */
+ if (pMga->Maven) {
+ /* In order to blank the 2nd display, we must set some MAVEN registers.
+ * It seems that not always the same values work on different hardware so
+ * we try a few different (possibly redundant) ones. */
+ /* xf86I2CWriteByte(pMga->Maven, MGAMAV_STABLE, 0x6a); */
+ /* xf86I2CWriteByte(pMga->Maven, MGAMAV_TEST, 0x03); */
+ /* xf86I2CWriteByte(pMga->Maven, MGAMAV_TEST, 0x10); */
+ xf86I2CWriteByte(pMga->Maven, MGAMAV_OUTMODE, 0x80);
+ }
- if (PowerManagementMode != DPMSModeOn)
- crtc2 = 0x8; /* c2pixclkdis */
- crtc2 |= INREG(MGAREG_C2CTL) & ~0x8;
- OUTREG(MGAREG_C2CTL, crtc2);
+ }
}