summaryrefslogtreecommitdiff
path: root/src/mga_driver.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mga_driver.c')
-rw-r--r--src/mga_driver.c1738
1 files changed, 251 insertions, 1487 deletions
diff --git a/src/mga_driver.c b/src/mga_driver.c
index a9323fe..b3a9f07 100644
--- a/src/mga_driver.c
+++ b/src/mga_driver.c
@@ -100,6 +100,9 @@
#include "dri.h"
#endif
+#include "xf86Crtc.h"
+#include "xf86RandR12.h"
+
#include <unistd.h>
/*
@@ -117,8 +120,7 @@ static Bool MGAEnterVT(int scrnIndex, int flags);
static Bool MGAEnterVTFBDev(int scrnIndex, int flags);
static void MGALeaveVT(int scrnIndex, int flags);
static Bool MGACloseScreen(int scrnIndex, ScreenPtr pScreen);
-static Bool MGASaveScreen(ScreenPtr pScreen, int mode);
-static Bool MGASaveScreenCrtc2(ScreenPtr pScreen, int mode);
+static Bool MGASwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
/* This shouldn't be needed since RAC will disable all I/O for MGA cards. */
#ifdef DISABLE_VGA_IO
@@ -136,14 +138,11 @@ static Bool MGAMapMem(ScrnInfoPtr pScrn);
static Bool MGAUnmapMem(ScrnInfoPtr pScrn);
static void MGASave(ScrnInfoPtr pScrn);
static void MGARestore(ScrnInfoPtr pScrn);
-static Bool MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
+static Bool MGASetMode(ScrnInfoPtr pScrn, DisplayModePtr mode);
static void MGABlockHandler(int, pointer, pointer, pointer);
static void MGAG100BlackMagic(ScrnInfoPtr pScrn);
-static int MGAEntityIndex = -1;
-
-#include "mga_merge.h"
-
+static Bool crtc_config_resize(ScrnInfoPtr scrn, int width, int height);
/*
* This contains the functions needed by the server after loading the
@@ -199,12 +198,10 @@ static PciChipsets MGAPciChipsets[] = {
};
static const OptionInfoRec MGAOptions[] = {
- { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_PCI_RETRY, "PciRetry", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_SYNC_ON_GREEN, "SyncOnGreen", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE },
- { OPTION_SHOWCACHE, "ShowCache", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_OVERLAY, "Overlay", OPTV_ANYSTR, {0}, FALSE },
{ OPTION_MGA_SDRAM, "MGASDRAM", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE },
@@ -213,26 +210,11 @@ static const OptionInfoRec MGAOptions[] = {
{ OPTION_SET_MCLK, "SetMclk", OPTV_FREQ, {0}, FALSE },
{ OPTION_OVERCLOCK_MEM, "OverclockMem", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_VIDEO_KEY, "VideoKey", OPTV_INTEGER, {0}, FALSE },
- { OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE },
{ OPTION_TEXTURED_VIDEO, "TexturedVideo",OPTV_BOOLEAN, {0}, FALSE },
- { OPTION_CRTC2HALF, "Crtc2Half", OPTV_BOOLEAN, {0}, FALSE },
- { OPTION_CRTC2RAM, "Crtc2Ram", OPTV_INTEGER, {0}, FALSE },
{ OPTION_INT10, "Int10", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_AGP_MODE, "AGPMode", OPTV_INTEGER, {0}, FALSE },
{ OPTION_AGP_SIZE, "AGPSize", OPTV_INTEGER, {0}, FALSE },
- { OPTION_DIGITAL1, "DigitalScreen1",OPTV_BOOLEAN, {0}, FALSE },
- { OPTION_DIGITAL2, "DigitalScreen2",OPTV_BOOLEAN, {0}, FALSE },
- { OPTION_TV, "TV", OPTV_BOOLEAN, {0}, FALSE },
- { OPTION_TVSTANDARD, "TVStandard", OPTV_ANYSTR, {0}, FALSE },
- { OPTION_CABLETYPE, "CableType", OPTV_ANYSTR, {0}, FALSE },
- { OPTION_NOHAL, "NoHal", OPTV_BOOLEAN, {0}, FALSE },
- { OPTION_SWAPPED_HEAD, "SwappedHead", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_DRI, "DRI", OPTV_BOOLEAN, {0}, FALSE },
- { OPTION_MERGEDFB, "MergedFB", OPTV_BOOLEAN, {0}, FALSE },
- { OPTION_HSYNC2, "Monitor2HSync", OPTV_ANYSTR, {0}, FALSE },
- { OPTION_VREFRESH2, "Monitor2VRefresh", OPTV_ANYSTR, {0}, FALSE },
- { OPTION_MONITOR2POS, "Monitor2Position", OPTV_ANYSTR, {0}, FALSE },
- { OPTION_METAMODES, "MetaModes", OPTV_ANYSTR, {0}, FALSE },
{ OPTION_OLDDMA, "OldDmaInit", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_PCIDMA, "ForcePciDma", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_ACCELMETHOD, "AccelMethod", OPTV_ANYSTR, {0}, FALSE },
@@ -260,7 +242,6 @@ static const char *vgahwSymbols[] = {
"vgaHWProtect",
"vgaHWRestore",
"vgaHWSave",
- "vgaHWSaveScreen",
"vgaHWSetMmioFuncs",
"vgaHWUnlock",
"vgaHWUnmapMem",
@@ -413,22 +394,6 @@ static const char *fbdevHWSymbols[] = {
NULL
};
-#ifdef USEMGAHAL
-static const char *halSymbols[] = {
- "MGACloseLibrary",
- "MGAGetBOARDHANDLESize",
- "MGAGetHardwareInfo",
- "MGAOpenLibrary",
- "MGARestoreVgaState",
- "MGASaveVgaState",
- "MGASetMode",
- "MGASetVgaMode",
- "MGAValidateMode",
- "MGAValidateVideoParameters",
- "HALSetDisplayStart",
- NULL
-};
-#endif
#ifdef XFree86LOADER
static MODULESETUPPROTO(mgaSetup);
@@ -449,6 +414,10 @@ static XF86ModuleVersionInfo mgaVersRec =
_X_EXPORT XF86ModuleData MGA_MODULE_DATA = { &mgaVersRec, mgaSetup, NULL };
+static const xf86CrtcConfigFuncsRec crtc_config_funcs = {
+ .resize = crtc_config_resize
+};
+
static pointer
mgaSetup(pointer module, pointer opts, int *errmaj, int *errmin)
{
@@ -483,9 +452,6 @@ mgaSetup(pointer module, pointer opts, int *errmaj, int *errmin)
#ifdef XF86DRI
drmSymbols, driSymbols,
#endif
-#ifdef USEMGAHAL
- halSymbols,
-#endif
NULL);
/*
@@ -622,7 +588,6 @@ MGAProbe(DriverPtr drv, int flags)
foundScreen = TRUE;
else for (i = 0; i < numUsed; i++) {
ScrnInfoPtr pScrn;
- EntityInfoPtr pEnt;
#ifdef DISABLE_VGA_IO
MgaSavePtr smga;
#endif
@@ -659,37 +624,6 @@ MGAProbe(DriverPtr drv, int flags)
foundScreen = TRUE;
}
-
- /*
- * For cards that can do dual head per entity, mark the entity
- * as sharable.
- */
- pEnt = xf86GetEntityInfo(usedChips[i]);
- if ((pEnt->chipset == PCI_CHIP_MGAG400 || pEnt->chipset == PCI_CHIP_MGAG550)) {
- MGAEntPtr pMgaEnt = NULL;
- DevUnion *pPriv;
-
- xf86SetEntitySharable(usedChips[i]);
- /* Allocate an entity private if necessary */
- if (MGAEntityIndex < 0)
- MGAEntityIndex = xf86AllocateEntityPrivateIndex();
- pPriv = xf86GetEntityPrivate(pScrn->entityList[0], MGAEntityIndex);
- if (!pPriv->ptr) {
- pPriv->ptr = xnfcalloc(sizeof(MGAEntRec), 1);
- pMgaEnt = pPriv->ptr;
- pMgaEnt->lastInstance = -1;
- } else {
- pMgaEnt = pPriv->ptr;
- }
- /*
- * Set the entity instance for this instance of the driver. For
- * dual head per card, instance 0 is the "master" instance, driving
- * the primary head, and instance 1 is the "slave".
- */
- pMgaEnt->lastInstance++;
- xf86SetEntityInstanceForScreen(pScrn, pScrn->entityList[0],
- pMgaEnt->lastInstance);
- }
}
xfree(usedChips);
@@ -931,33 +865,11 @@ MGAdoDDC(ScrnInfoPtr pScrn)
hwp = VGAHWPTR(pScrn);
pMga = MGAPTR(pScrn);
- /* Load DDC if we have the code to use it */
- /* This gives us DDC1 */
- if (pMga->ddc1Read || pMga->i2cInit) {
- if (xf86LoadSubModule(pScrn, "ddc")) {
- xf86LoaderReqSymLists(ddcSymbols, NULL);
- } else {
- /* ddc module not found, we can do without it */
- pMga->ddc1Read = NULL;
- pMga->DDC_Bus1 = NULL;
- pMga->DDC_Bus2 = NULL;
- return NULL;
- }
- } else
- return NULL;
-
#if MGAuseI2C
/* - DDC can use I2C bus */
/* Load I2C if we have the code to use it */
if (pMga->i2cInit) {
- if ( xf86LoadSubModule(pScrn, "i2c") ) {
- xf86LoaderReqSymLists(i2cSymbols,NULL);
- } else {
- /* i2c module not found, we can do without it */
- pMga->i2cInit = NULL;
- pMga->DDC_Bus1 = NULL;
- pMga->DDC_Bus2 = NULL;
- }
+ xf86LoaderReqSymLists(i2cSymbols,NULL);
}
#endif /* MGAuseI2C */
@@ -1148,24 +1060,65 @@ MGAMavenRead(ScrnInfoPtr pScrn, I2CByte reg, I2CByte *val)
return TRUE;
}
+static void
+setup_g_outputs(ScrnInfoPtr scrn)
+{
+ MGAPtr pMga;
+ xf86OutputPtr output;
+ Bool number_vga = FALSE, number_dvi = FALSE;
+
+ pMga = MGAPTR(scrn);
+
+ /* first output */
+ switch (pMga->bios.connector[0]) {
+ case MGA_CONNECTOR_DVI:
+ number_dvi = pMga->bios.connector[1] == MGA_CONNECTOR_DVI;
+ output = MgaGOutputPanel1Init (scrn, number_dvi);
+ break;
+ default:
+ /* in case PInS doesn't contain connector info
+ * or it claims there's no primary output
+ * we just assume it's VGA.
+ */
+ number_vga = pMga->bios.connector[1] == MGA_CONNECTOR_HD15;
+ output = MgaGOutputDac1Init (scrn, number_vga);
+ break;
+ }
+
+ /* the first output can be mapped to any crtc */
+ output->possible_crtcs = 1 | 2;
+
+ /* second output */
+ switch (pMga->bios.connector[1]) {
+ case MGA_CONNECTOR_HD15:
+ output = MgaGOutputDac2Init (scrn, number_vga);
+ break;
+ case MGA_CONNECTOR_DVI:
+ output = MgaGOutputPanel2Init (scrn, number_dvi);
+ break;
+ default:
+ output = NULL;
+ break;
+ }
+
+ /* the second output can only be mapped to crtc 2 */
+ if (output)
+ output->possible_crtcs = 2;
+}
+
/* Mandatory */
static Bool
MGAPreInit(ScrnInfoPtr pScrn, int flags)
{
MGAPtr pMga;
MessageType from;
- int i;
double real;
int bytesPerPixel;
ClockRangePtr clockRanges;
const char *s;
int flags24;
- MGAEntPtr pMgaEnt = NULL;
- Bool Default;
-#ifdef USEMGAHAL
- ULONG status;
- CARD8 MiscCtlReg;
-#endif
+ Bool Default, is_2064 = FALSE;
+ xf86OutputPtr output;
/*
* Note: This function is only called once at server startup, and
@@ -1199,13 +1152,6 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
if (pMga->pEnt->location.type != BUS_PCI)
return FALSE;
- /* Allocate an entity private if necessary */
- if (xf86IsEntityShared(pScrn->entityList[0])) {
- pMgaEnt = xf86GetEntityPrivate(pScrn->entityList[0],
- MGAEntityIndex)->ptr;
- pMga->entityPrivate = pMgaEnt;
- }
-
/* Set pMga->device to the relevant Device section */
pMga->device = xf86GetDevFromEntity(pScrn->entityList[0],
pScrn->entityInstanceList[0]);
@@ -1306,103 +1252,13 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
|| (pMga->Chipset == PCI_CHIP_MGAG550);
pMga->is_G200SE = (pMga->Chipset == PCI_CHIP_MGAG200_SE_A_PCI)
|| (pMga->Chipset == PCI_CHIP_MGAG200_SE_B_PCI);
- pMga->is_HAL_chipset = ((pMga->Chipset == PCI_CHIP_MGAG200_PCI) ||
- (pMga->Chipset == PCI_CHIP_MGAG200) ||
- (pMga->Chipset == PCI_CHIP_MGAG200_SE_A_PCI) ||
- (pMga->Chipset == PCI_CHIP_MGAG200_SE_B_PCI) ||
- (pMga->Chipset == PCI_CHIP_MGAG400) ||
- (pMga->Chipset == PCI_CHIP_MGAG550));
-
-#ifdef USEMGAHAL
- if (HAL_CHIPSETS) {
- Bool loadHal = TRUE;
-
- from = X_DEFAULT;
- if (xf86FindOption(pMga->device->options, "NoHal")) {
- loadHal = !xf86SetBoolOption(pMga->device->options,
- "NoHal", !loadHal);
- from = X_CONFIG;
- } else if (xf86FindOption(pMga->device->options, "Hal")) {
- loadHal = xf86SetBoolOption(pMga->device->options,
- "Hal", loadHal);
- from = X_CONFIG;
- }
- if (loadHal && xf86LoadSubModule(pScrn, "mga_hal")) {
- xf86LoaderReqSymLists(halSymbols, NULL);
- xf86DrvMsg(pScrn->scrnIndex, from,"Matrox HAL module used\n");
- pMga->HALLoaded = TRUE;
- } else {
- xf86DrvMsg(pScrn->scrnIndex, from, "Matrox HAL module not loaded "
- "- using builtin mode setup instead\n");
- pMga->HALLoaded = FALSE;
- }
- }
-#endif
- pMga->DualHeadEnabled = FALSE;
- if (xf86IsEntityShared(pScrn->entityList[0])) {/* dual-head mode requested*/
- if (
-#ifdef USEMGAHAL
- pMga->HALLoaded ||
-#endif
- !MGA_DH_NEEDS_HAL(pMga)) {
- pMga->DualHeadEnabled = TRUE;
- } else if (xf86IsPrimInitDone(pScrn->entityList[0])) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "This card requires the \"mga_hal\" module for dual-head operation\n"
- "\tIt can be found at the Matrox web site <http://www.matrox.com>\n");
- }
- }
-
- /*
- * In case of DualHead, we need to determine if we are the 'master' head
- * or the 'slave' head. In order to do that, at the end of the first
- * initialisation, PrimInit is set as DONE to the shared entity. So that
- * the second initialisation knows that something has been done before it.
- * This always assume that the first device initialised is the master
- * head, and the second the slave.
- *
- */
- if (xf86IsEntityShared(pScrn->entityList[0])) { /* dual-head mode */
- if (!xf86IsPrimInitDone(pScrn->entityList[0])) { /* Is it the first initialisation? */
- /* First CRTC */
- pMga->SecondCrtc = FALSE;
- pMga->HWCursor = TRUE;
- pMgaEnt->pScrn_1 = pScrn;
- } else if (pMga->DualHeadEnabled) {
- /* Second CRTC */
- pMga->SecondCrtc = TRUE;
- pMga->HWCursor = FALSE;
- pMgaEnt->pScrn_2 = pScrn;
- pScrn->AdjustFrame = MGAAdjustFrameCrtc2;
- /*
- * Fail initialization of second head if we are in MergeFB mode,
- * since we do it ourselfs.
- */
- if(pMgaEnt->pScrn_1 && MGAPTR(pMgaEnt->pScrn_1)->MergedFB) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Primary head in Merged framebuffer mode. \n"
- "Don't let Xfree try to manage the second head.\n"
- "Remove the second screen in the \"ServerLayout\"\n"
- "Section of the config file.");
- return FALSE;
- }
- } else {
- return FALSE;
- }
- }
+ pMga->SecondCrtc = FALSE;
+ pMga->HWCursor = TRUE;
- if (pMga->DualHeadEnabled) {
#ifdef XF86DRI
- pMga->GetQuiescence = MGAGetQuiescenceShared;
+ pMga->GetQuiescence = MGAGetQuiescence;
#endif
- } else { /* single-head mode */
- pMga->SecondCrtc = FALSE;
- pMga->HWCursor = TRUE;
-#ifdef XF86DRI
- pMga->GetQuiescence = MGAGetQuiescence;
-#endif
- }
@@ -1584,10 +1440,6 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
pMga->SyncOnGreen = TRUE;
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Sync-on-Green enabled\n");
}
- if (xf86ReturnOptValBool(pMga->Options, OPTION_SHOWCACHE, FALSE)) {
- pMga->ShowCache = TRUE;
- xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ShowCache enabled\n");
- }
if (xf86ReturnOptValBool(pMga->Options, OPTION_MGA_SDRAM, FALSE)) {
pMga->HasSDRAM = TRUE;
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Has SDRAM\n");
@@ -1643,41 +1495,6 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
if (xf86ReturnOptValBool(pMga->Options, OPTION_TEXTURED_VIDEO, FALSE)) {
pMga->TexturedVideo = TRUE;
}
- if (xf86ReturnOptValBool(pMga->Options, OPTION_MERGEDFB, FALSE)) {
- if(!MGAISGx50(pMga)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "\"Merged Framebuffer\" mode only supported on G450 and G550 boards.\n");
- } else {
-#ifdef USEMGAHAL
- if(pMga->HALLoaded)
- {
- pMga->MergedFB = TRUE;
- xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
- "Using \"Merged Framebuffer\" mode.\n");
- /*
- * a few options that won't work well together
- */
- if(pMga->HWCursor) /*Should we give the choice? */
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- " -- Hardware Cursor disabled.\n");
- pMga->HWCursor = FALSE;
- if(pMga->ShadowFB)
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- " -- Shadow Framebuffer disabled.\n");
- pMga->ShadowFB = FALSE;
- if(pMga->FBDev)
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- " -- Framebuffer device disabled.\n");
- pMga->FBDev = FALSE;
- } /* MGA_HAL */
- else
-#endif
- {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "HALLib not loaded! NOT using \"Merged Framebuffer\" mode.\n");
- } /* MGA_NOT_HAL */
- } /* ISMGAGx50() */
- }
if (pMga->FBDev) {
/* check for linux framebuffer device */
if (!xf86LoadSubModule(pScrn, "fbdevhw"))
@@ -1692,39 +1509,11 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
pScrn->ValidMode = fbdevHWValidModeWeak();
}
pMga->Rotate = 0;
- if ((s = xf86GetOptValString(pMga->Options, OPTION_ROTATE))) {
- if(!pMga->MergedFB) {
- if(!xf86NameCmp(s, "CW")) {
- pMga->ShadowFB = TRUE;
- pMga->NoAccel = TRUE;
- pMga->HWCursor = FALSE;
- pMga->Rotate = 1;
- xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
- "Rotating screen clockwise - acceleration disabled\n");
- } else
- if(!xf86NameCmp(s, "CCW")) {
- pMga->ShadowFB = TRUE;
- pMga->NoAccel = TRUE;
- pMga->HWCursor = FALSE;
- pMga->Rotate = -1;
- xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
- "Rotating screen counter clockwise - acceleration disabled\n");
- } else {
- xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
- "\"%s\" is not a valid value for Option \"Rotate\"\n", s);
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Valid options are \"CW\" or \"CCW\"\n");
- }
- } else {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- " -- Rotation disabled.\n");
- }
- }
-
switch (pMga->Chipset) {
case PCI_CHIP_MGA2064:
case PCI_CHIP_MGA2164:
case PCI_CHIP_MGA2164_AGP:
+ is_2064 = TRUE;
MGA2064SetupFuncs(pScrn);
break;
case PCI_CHIP_MGA1064:
@@ -1913,64 +1702,22 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
pScrn->videoRam = MGACountRam(pScrn);
}
- if (pMga->DualHeadEnabled) {
- /* This takes gives either half or 8 meg to the second head
- * whichever is less. */
- if(pMga->SecondCrtc == FALSE) {
- Bool UseHalf = FALSE;
- int adjust;
-
- xf86GetOptValBool(pMga->Options, OPTION_CRTC2HALF, &UseHalf);
- adjust = pScrn->videoRam / 2;
-
- if (UseHalf == TRUE ||
- xf86GetOptValInteger(pMga->Options, OPTION_CRTC2RAM, &adjust)) {
- xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
- "Crtc2 will use %dK of VideoRam\n",
- adjust);
- } else {
- adjust = min(adjust, 8192);
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "Crtc2 will use %dK of VideoRam\n",
- adjust);
- }
- pMgaEnt->mastervideoRam = pScrn->videoRam - adjust;
- pScrn->videoRam = pMgaEnt->mastervideoRam;
- pMgaEnt->slavevideoRam = adjust;
- pMgaEnt->masterFbAddress = pMga->FbAddress;
- pMga->FbMapSize =
- pMgaEnt->masterFbMapSize = pScrn->videoRam * 1024;
- pMgaEnt->slaveFbAddress = pMga->FbAddress +
- pMgaEnt->masterFbMapSize;
- pMgaEnt->slaveFbMapSize = pMgaEnt->slavevideoRam * 1024;
- pMga->realSrcOrg = pMga->SrcOrg = 0;
- pMga->DstOrg = 0;
- } else {
- pMga->FbAddress = pMgaEnt->slaveFbAddress;
- pMga->FbMapSize = pMgaEnt->slaveFbMapSize;
- pScrn->videoRam = pMgaEnt->slavevideoRam;
- pMga->DstOrg = pMga->realSrcOrg =
- pMgaEnt->slaveFbAddress - pMgaEnt->masterFbAddress;
- pMga->SrcOrg = 0; /* This is not stored in hw format!! */
- }
- pMgaEnt->refCount++;
- } else {
- /* Normal Handling of video ram etc */
- pMga->FbMapSize = pScrn->videoRam * 1024;
- switch(pMga->Chipset) {
- case PCI_CHIP_MGAG550:
- case PCI_CHIP_MGAG400:
- case PCI_CHIP_MGAG200:
- case PCI_CHIP_MGAG200_PCI:
- case PCI_CHIP_MGAG200_SE_A_PCI:
- case PCI_CHIP_MGAG200_SE_B_PCI:
- pMga->SrcOrg = 0;
- pMga->DstOrg = 0;
- break;
- default:
- break;
- }
+ /* Normal Handling of video ram etc */
+ pMga->FbMapSize = pScrn->videoRam * 1024;
+ switch(pMga->Chipset) {
+ case PCI_CHIP_MGAG550:
+ case PCI_CHIP_MGAG400:
+ case PCI_CHIP_MGAG200:
+ case PCI_CHIP_MGAG200_PCI:
+ case PCI_CHIP_MGAG200_SE_A_PCI:
+ case PCI_CHIP_MGAG200_SE_B_PCI:
+ pMga->SrcOrg = 0;
+ pMga->DstOrg = 0;
+ break;
+ default:
+ break;
}
+
xf86DrvMsg(pScrn->scrnIndex, from, "VideoRAM: %d kByte\n",
pScrn->videoRam);
@@ -1980,17 +1727,59 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
pMga->BppShifts[2] = 0;
pMga->BppShifts[3] = 2;
+ /* Allocate an xf86CrtcConfig */
+ xf86CrtcConfigInit(pScrn, &crtc_config_funcs);
+
+ xf86CrtcSetSizeRange(pScrn, 320, 200, 2560, 1024);
+
+ if (is_2064)
+ Mga2064CrtcInit (pScrn);
+ else {
+ switch(pMga->Chipset) {
+ case PCI_CHIP_MGAG400:
+ case PCI_CHIP_MGAG550:
+ MgaGCrtc1Init (pScrn);
+ MgaGCrtc2Init (pScrn);
+ break;
+ default:
+ MgaGCrtc1Init (pScrn);
+ }
+ }
+
+ if (pMga->i2cInit) {
+ pMga->i2cInit(pScrn);
+ }
+
+ if (is_2064) {
+ output = Mga2064OutputInit (pScrn);
+ output->possible_crtcs = 1;
+ } else
+ setup_g_outputs (pScrn);
+
/*
* fill MGAdac struct
* Warning: currently, it should be after RAM counting
*/
(*pMga->PreInit)(pScrn);
+#if 0
#if !defined(__powerpc__)
/* Read and print the Monitor DDC info */
pScrn->monitor->DDC = MGAdoDDC(pScrn);
#endif /* !__powerpc__ */
+#endif
+ if (!MGAMapMem(pScrn)) {
+ ErrorF("cannot map memory for probing.\n");
+ return FALSE;
+ }
+
+ if (!xf86InitialConfiguration(pScrn, FALSE)) {
+ MGAUnmapMem(pScrn);
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found.\n");
+ return FALSE;
+ }
+ MGAUnmapMem(pScrn);
if (!pScrn->monitor->DDC && pMga->is_G200SE) {
/* Jam in ranges big enough for 1024x768 */
@@ -2077,15 +1866,8 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
clockRanges->minClock = pMga->MinClock;
clockRanges->maxClock = pMga->MaxClock;
clockRanges->clockIndex = -1; /* programmable */
- clockRanges->interlaceAllowed = TRUE;
+ clockRanges->interlaceAllowed = !pMga->SecondCrtc;
clockRanges->doubleScanAllowed = TRUE;
-#ifdef USEMGAHAL
- MGA_HAL(clockRanges->interlaceAllowed = FALSE);
- MGA_HAL(clockRanges->doubleScanAllowed = FALSE);
-#endif
- if (pMga->SecondCrtc == TRUE)
- clockRanges->interlaceAllowed = FALSE;
-
clockRanges->ClockMulFactor = 1;
clockRanges->ClockDivFactor = 1;
@@ -2100,161 +1882,11 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
pMga->MemClk / 1000.0);
}
- /*
- * xf86ValidateModes will check that the mode HTotal and VTotal values
- * don't exceed the chipset's limit if pScrn->maxHValue and
- * pScrn->maxVValue are set. Since our MGAValidMode() already takes
- * care of this, we don't worry about setting them here.
- */
- {
- int Pitches1[] =
- {640, 768, 800, 960, 1024, 1152, 1280, 1600, 1920, 2048, 0};
- int Pitches2[] =
- {512, 640, 768, 800, 832, 960, 1024, 1152, 1280, 1600, 1664,
- 1920, 2048, 0};
- int *linePitches = NULL;
- int minPitch = 256;
- int maxPitch = 2048;
-
- switch(pMga->Chipset) {
- case PCI_CHIP_MGA2064:
- if (!pMga->NoAccel) {
- linePitches = xalloc(sizeof(Pitches1));
- memcpy(linePitches, Pitches1, sizeof(Pitches1));
- minPitch = maxPitch = 0;
- }
- break;
- case PCI_CHIP_MGA2164:
- case PCI_CHIP_MGA2164_AGP:
- case PCI_CHIP_MGA1064:
- if (!pMga->NoAccel) {
- linePitches = xalloc(sizeof(Pitches2));
- memcpy(linePitches, Pitches2, sizeof(Pitches2));
- minPitch = maxPitch = 0;
- }
- break;
- case PCI_CHIP_MGAG100:
- case PCI_CHIP_MGAG100_PCI:
- maxPitch = 2048;
- break;
- case PCI_CHIP_MGAG200:
- case PCI_CHIP_MGAG200_PCI:
- case PCI_CHIP_MGAG200_SE_A_PCI:
- case PCI_CHIP_MGAG200_SE_B_PCI:
- case PCI_CHIP_MGAG400:
- case PCI_CHIP_MGAG550:
- maxPitch = 4096;
- break;
- }
-
- i = xf86ValidateModes(pScrn, pScrn->monitor->Modes,
- pScrn->display->modes, clockRanges,
- linePitches, minPitch, maxPitch,
- pMga->Roundings[(pScrn->bitsPerPixel >> 3) - 1] *
- pScrn->bitsPerPixel, 128, 2048,
- pScrn->display->virtualX,
- pScrn->display->virtualY,
- pMga->FbMapSize,
- LOOKUP_BEST_REFRESH);
-
- if (linePitches)
- xfree(linePitches);
- }
-
-
- if (i < 1 && pMga->FBDev) {
- fbdevHWUseBuildinMode(pScrn);
- pScrn->displayWidth = pScrn->virtualX; /* FIXME: might be wrong */
- i = 1;
- }
- if (i == -1) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Validate Modes Failed\n");
- MGAFreeRec(pScrn);
- return FALSE;
- }
-
- /* Prune the modes marked as invalid */
- xf86PruneDriverModes(pScrn);
-
- if (i == 0 || pScrn->modes == NULL) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n");
- MGAFreeRec(pScrn);
- return FALSE;
- }
-#ifdef USEMGAHAL
- MGA_HAL(
-
- if(pMga->SecondCrtc == FALSE) {
-
- pMga->pBoard = xalloc(sizeof(CLIENTDATA) + MGAGetBOARDHANDLESize());
- pMga->pClientStruct = xalloc(sizeof(CLIENTDATA));
- pMga->pClientStruct->pMga = (MGAPtr) pMga;
-
- MGAMapMem(pScrn);
- /*
- * For some reason the MGAOPM_DMA_BLIT bit needs to be set
- * on G200 before opening the HALlib. I don't know why.
- * MATROX: hint, hint.
- */
- /*if (pMga->Chipset == PCI_CHIP_MGAG200 ||
- pMga->Chipset == PCI_CHIP_MGAG200_PCI) */{
- CARD32 opmode;
- opmode = INREG(MGAREG_OPMODE);
- OUTREG(MGAREG_OPMODE, MGAOPM_DMA_BLIT | opmode);
- }
- /* wrapping OpenLibrary to fix broken registers. MATROX: hint, hint. */
- MiscCtlReg = inMGAdac(MGA1064_MISC_CTL);
- MGAOpenLibrary(pMga->pBoard,pMga->pClientStruct,sizeof(CLIENTDATA));
- outMGAdac(MGA1064_MISC_CTL,MiscCtlReg);
- MGAUnmapMem(pScrn);
- pMga->pMgaHwInfo = xalloc(sizeof(MGAHWINFO));
- MGAGetHardwareInfo(pMga->pBoard,pMga->pMgaHwInfo);
-
- /* copy the board handles */
- if (pMga->DualHeadEnabled) {
- pMgaEnt->pClientStruct = pMga->pClientStruct;
- pMgaEnt->pBoard = pMga->pBoard;
- pMgaEnt->pMgaHwInfo = pMga->pMgaHwInfo;
- }
-
- } else { /* Second CRTC && entity is shared */
- pMga->pBoard = pMgaEnt->pBoard;
- pMga->pClientStruct = pMgaEnt->pClientStruct;
- pMga->pMgaHwInfo = pMgaEnt->pMgaHwInfo;
-
- }
-
- MGAFillModeInfoStruct(pScrn,NULL);
- /* Fields usually handled by MGAFillModeInfoStruct, but are unavailable
- * because no mode is given
- */
- pMga->pMgaModeInfo->ulDispWidth = pScrn->virtualX;
- pMga->pMgaModeInfo->ulDispHeight = pScrn->virtualY;
-
-
- if (ISDIGITAL1(pMga))
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Digital screen detected on first head.\n");
- if (ISTV1(pMga))
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "TV detected on first head.\n");
- if (ISDIGITAL2(pMga))
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Digital screen detected on second head.\n");
- if (ISTV2(pMga))
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "TV detected on second head.\n");
-
-
- if((status = MGAValidateMode(pMga->pBoard,pMga->pMgaModeInfo)) != 0) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "MGAValidateMode from HALlib found the mode to be invalid.\n"
- "\tError: 0x%lx\n", status);
+ if (!xf86RandR12PreInit(pScrn)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "RandR initialization failure.\n");
return FALSE;
}
- pScrn->displayWidth = pMga->pMgaModeInfo->ulFBPitch;
- ); /* MGA_HAL */
-#endif
if (pMga->HasSDRAM) { /* don't bother checking */ }
else if ((pMga->PciInfo->subsysCard == PCI_CARD_MILL_G200_SD) ||
@@ -2263,16 +1895,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
(pMga->PciInfo->subsysCard == PCI_CARD_PROD_G100_SD)) {
pMga->HasSDRAM = TRUE;
xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Has SDRAM\n");
- }
- /*
- * Can we trust HALlib to set the memory configuration
- * registers correctly?
- */
- else if ((pMga->softbooted || pMga->Primary
-#ifdef USEMGAHAL
- /*|| pMga->HALLoaded*/
-#endif
- ) &&
+ } else if ((pMga->softbooted || pMga->Primary) &&
(pMga->Chipset != PCI_CHIP_MGA2064) &&
(pMga->Chipset != PCI_CHIP_MGA2164) &&
(pMga->Chipset != PCI_CHIP_MGA2164_AGP)) {
@@ -2291,10 +1914,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
* driver and if the driver doesn't provide code to set them. They
* are not pre-initialised at all.
*/
-#ifdef USEMGAHAL
- MGA_HAL(xf86SetCrtcForModes(pScrn, 0));
-#endif
- MGA_NOT_HAL(xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V));
+ xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V);
/* Set the current mode to the first in the list */
pScrn->currentMode = pScrn->modes;
@@ -2354,47 +1974,25 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "YDstOrg is set to %d\n",
pMga->YDstOrg);
- if(pMga->DualHeadEnabled) {
- if(pMga->SecondCrtc == FALSE) {
- pMga->FbUsableSize = pMgaEnt->masterFbMapSize;
- /* Allocate HW cursor buffer at the end of video ram */
- if( pMga->HWCursor && pMga->Dac.CursorOffscreenMemSize ) {
- if( pScrn->virtualY * pScrn->displayWidth *
- pScrn->bitsPerPixel / 8 <=
- pMga->FbUsableSize - pMga->Dac.CursorOffscreenMemSize ) {
- pMga->FbUsableSize -= pMga->Dac.CursorOffscreenMemSize;
- pMga->FbCursorOffset =
- pMgaEnt->masterFbMapSize -
- pMga->Dac.CursorOffscreenMemSize;
- } else {
- pMga->HWCursor = FALSE;
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "Too little offscreen memory for HW cursor; "
- "using SW cursor\n");
- }
- }
- } else { /* Second CRTC */
- pMga->FbUsableSize = pMgaEnt->slaveFbMapSize;
- pMga->HWCursor = FALSE;
- }
- } else {
- pMga->FbUsableSize = pMga->FbMapSize - pMga->YDstOrg * bytesPerPixel;
- /* Allocate HW cursor buffer at the end of video ram */
- if( pMga->HWCursor && pMga->Dac.CursorOffscreenMemSize ) {
- if( pScrn->virtualY * pScrn->displayWidth *
- pScrn->bitsPerPixel / 8 <=
- pMga->FbUsableSize - pMga->Dac.CursorOffscreenMemSize ) {
- pMga->FbUsableSize -= pMga->Dac.CursorOffscreenMemSize;
- pMga->FbCursorOffset =
- pMga->FbMapSize - pMga->Dac.CursorOffscreenMemSize;
- } else {
- pMga->HWCursor = FALSE;
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "Too little offscreen memory for HW cursor; "
- "using SW cursor\n");
- }
- }
+
+ pMga->FbUsableSize = pMga->FbMapSize - pMga->YDstOrg * bytesPerPixel;
+
+ /* Allocate HW cursor buffer at the end of video ram */
+ if (pMga->HWCursor && pMga->Dac.CursorOffscreenMemSize) {
+ if (pScrn->virtualY * pScrn->displayWidth *
+ pScrn->bitsPerPixel / 8 <=
+ pMga->FbUsableSize - pMga->Dac.CursorOffscreenMemSize) {
+ pMga->FbUsableSize -= pMga->Dac.CursorOffscreenMemSize;
+ pMga->FbCursorOffset =
+ pMga->FbMapSize - pMga->Dac.CursorOffscreenMemSize;
+ } else {
+ pMga->HWCursor = FALSE;
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "Too little offscreen memory for HW cursor; "
+ "using SW cursor\n");
+ }
}
+
/*
* XXX This should be taken into account in some way in the mode valdation
* section.
@@ -2474,52 +2072,6 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
pMga->CurrentLayout.mode = pScrn->currentMode;
-
- if(pMga->MergedFB) {
- MGAPreInitMergedFB(pScrn,flags);
- };
-
-
-#ifdef USEMGAHAL
- MGA_HAL(
- /* Close the library after preinit */
- /* This needs to only happen after this board has completed preinit
- * both times
- */
-
- if(pMga->DualHeadEnabled) {
- /* Entity is shared make sure refcount == 2 */
- /* If ref count is 2 then reset it to 0 */
- if(pMgaEnt->refCount == 2) {
- /* Both boards have done there initialization */
- MGACloseLibrary(pMga->pBoard);
-
- if (pMga->pBoard)
- xfree(pMga->pBoard);
- if (pMga->pClientStruct)
- xfree(pMga->pClientStruct);
- if (pMga->pMgaModeInfo)
- xfree(pMga->pMgaModeInfo);
- if (pMga->pMgaHwInfo)
- xfree(pMga->pMgaHwInfo);
- pMgaEnt->refCount = 0;
- }
- } else {
- MGACloseLibrary(pMga->pBoard);
-
- if (pMga->pBoard)
- xfree(pMga->pBoard);
- if (pMga->pClientStruct)
- xfree(pMga->pClientStruct);
- if (pMga->pMgaModeInfo)
- xfree(pMga->pMgaModeInfo);
- if (pMga->pMgaHwInfo)
- xfree(pMga->pMgaHwInfo);
- }
-
- ); /* MGA_HAL */
-#endif
-
xf86SetPrimInitDone(pScrn->entityList[0]);
return TRUE;
@@ -2645,185 +2197,42 @@ MGAUnmapMemFBDev(ScrnInfoPtr pScrn)
return TRUE;
}
-
-
-
/*
* This function saves the video state.
*/
static void
-MGASave(ScrnInfoPtr pScrn)
-{
- vgaHWPtr hwp = VGAHWPTR(pScrn);
- vgaRegPtr vgaReg = &hwp->SavedReg;
- MGAPtr pMga = MGAPTR(pScrn);
- MGARegPtr mgaReg = &pMga->SavedReg;
-
- if(pMga->SecondCrtc == TRUE) return;
-#ifdef USEMGAHAL
- MGA_HAL(if (pMga->pBoard != NULL) MGASaveVgaState(pMga->pBoard));
-#endif
-
- /* I need to save the registers for the second head also */
- /* Save the register for 0x80 to 0xa0 */
- /* Could call it dac2Saved */
-
- /* Only save text mode fonts/text for the primary card */
- (*pMga->Save)(pScrn, vgaReg, mgaReg, pMga->Primary);
-}
-
-#ifdef USEMGAHAL
-/* Convert DisplayModeRec parameters in MGAMODEINFO parameters.
-* mode parameter optionnal. */
-void
-MGAFillModeInfoStruct(ScrnInfoPtr pScrn, DisplayModePtr mode)
+MGASave(ScrnInfoPtr scrn)
{
- const char *s;
- MGAPtr pMga = MGAPTR(pScrn);
-
- Bool digital1 = FALSE;
- Bool digital2 = FALSE;
- Bool tv1 = FALSE;
- Bool tv2 = FALSE;
- Bool swap_head
- = xf86ReturnOptValBool(pMga->Options, OPTION_SWAPPED_HEAD, FALSE);
-
- if(pMga->MergedFB && mode && mode->Private && (mode->PrivSize == 0)) {
- mode = pMga->SecondCrtc ?
- ((MergedDisplayModePtr)mode->Private)->Monitor2
- : ((MergedDisplayModePtr)mode->Private)->Monitor1;
- }
-
-
- if (pMga->pMgaHwInfo)
- {
- digital1 = ISDIGITAL1(pMga);
- digital2 = ISDIGITAL2(pMga);
- tv1 = ISTV1(pMga);
- tv2 = ISTV2(pMga);
- }
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
+ int i;
- /*FIXME: causes segfault elsewhere if not commented*/
- /*if(!pMga->pMgaModeInfo)*/ pMga->pMgaModeInfo = xalloc(sizeof(MGAMODEINFO));
- pMga->pMgaModeInfo->flOutput = 0;
- pMga->pMgaModeInfo->ulDeskWidth = pScrn->virtualX;
- pMga->pMgaModeInfo->ulDeskHeight = pScrn->virtualY;
- pMga->pMgaModeInfo->ulFBPitch = 0;
- pMga->pMgaModeInfo->ulBpp = pScrn->bitsPerPixel;
- pMga->pMgaModeInfo->ulZoom = 1;
- pMga->pMgaModeInfo->flSignalMode = 0x10;
-
- /* Set TV standard */
- if ((s = xf86GetOptValString(pMga->Options, OPTION_TVSTANDARD))) {
- if (!xf86NameCmp(s, "PAL")) {
- pMga->pMgaModeInfo->flSignalMode = 0x00;
- pMga->pMgaModeInfo->ulRefreshRate = 50;
- pMga->pMgaModeInfo->ulTVStandard = TV_PAL;
- } else {
- pMga->pMgaModeInfo->ulRefreshRate = 60;
- pMga->pMgaModeInfo->ulTVStandard = TV_NTSC;
- }
- } else {
- pMga->pMgaModeInfo->ulRefreshRate = 0;
- pMga->pMgaModeInfo->ulTVStandard = TV_NTSC;
- }
+ /* Save CRTC states */
+ for (i = 0; i < config->num_crtc; i++) {
+ xf86CrtcPtr crtc = config->crtc[i];
- /* Set Cable Type */
- if ((s = xf86GetOptValString(pMga->Options, OPTION_CABLETYPE))) {
- if (!xf86NameCmp(s, "SCART_RGB")) {
- pMga->pMgaModeInfo->ulCableType = TV_SCART_RGB;
- } else if (!xf86NameCmp(s, "SCART_COMPOSITE")) {
- pMga->pMgaModeInfo->ulCableType = TV_SCART_COMPOSITE;
- } else if (!xf86NameCmp(s, "SCART_TYPE2")) {
- pMga->pMgaModeInfo->ulCableType = TV_SCART_TYPE2;
- } else {
- pMga->pMgaModeInfo->ulCableType = TV_YC_COMPOSITE;
- }
- } else {
- pMga->pMgaModeInfo->ulCableType = TV_YC_COMPOSITE;
+ crtc->funcs->save(crtc);
}
- if(mode) {
- pMga->pMgaModeInfo->ulHorizRate = 0;
- pMga->pMgaModeInfo->ulDispWidth = mode->HDisplay;
- pMga->pMgaModeInfo->ulDispHeight = mode->VDisplay;
- pMga->pMgaModeInfo->ulPixClock = mode->Clock;
- pMga->pMgaModeInfo->ulHFPorch = mode->HSyncStart - mode->HDisplay;
- pMga->pMgaModeInfo->ulHSync = mode->HSyncEnd - mode->HSyncStart;
- pMga->pMgaModeInfo->ulHBPorch = mode->HTotal - mode->HSyncEnd;
- pMga->pMgaModeInfo->ulVFPorch = mode->VSyncStart - mode->VDisplay;
- pMga->pMgaModeInfo->ulVSync = mode->VSyncEnd - mode->VSyncStart;
- pMga->pMgaModeInfo->ulVBPorch = mode->VTotal - mode->VSyncEnd;
- }
- /* Use DstOrg directly */
- /* This is an offset in pixels not memory */
- pMga->pMgaModeInfo->ulDstOrg = pMga->DstOrg / (pScrn->bitsPerPixel / 8);
- pMga->pMgaModeInfo->ulDisplayOrg = pMga->DstOrg / (pScrn->bitsPerPixel / 8);
- pMga->pMgaModeInfo->ulPanXGran = 0;
- pMga->pMgaModeInfo->ulPanYGran = 0;
+ /* Save output states */
+ for (i = 0; i < config->num_output; i++) {
+ xf86OutputPtr output = config->output[i];
- if(pMga->SecondCrtc == TRUE) {
- pMga->pMgaModeInfo->flOutput = MGAMODEINFO_SECOND_CRTC |
- MGAMODEINFO_FORCE_PITCH |
- MGAMODEINFO_FORCE_DISPLAYORG;
- if (digital2) {
- pMga->pMgaModeInfo->flOutput |= MGAMODEINFO_DIGITAL2;
- } else if (tv2) {
- pMga->pMgaModeInfo->flOutput |= MGAMODEINFO_TV;
- } else {
- if (!swap_head) {
- pMga->pMgaModeInfo->flOutput |= MGAMODEINFO_ANALOG2;
- } else {
- pMga->pMgaModeInfo->flOutput |= MGAMODEINFO_ANALOG1;
- }
- }
- } else {
- pMga->pMgaModeInfo->flOutput = MGAMODEINFO_FORCE_PITCH;
- if (digital1) {
- if ((pMga->Chipset == PCI_CHIP_MGAG200) ||
- (pMga->Chipset == PCI_CHIP_MGAG200_PCI)) {
- pMga->pMgaModeInfo->flOutput |= MGAMODEINFO_FLATPANEL1;
- pMga->pMgaModeInfo->flOutput |= MGAMODEINFO_DIGITAL2;
- } else {
- pMga->pMgaModeInfo->flOutput |= MGAMODEINFO_DIGITAL1;
- }
- } else if (tv1) {
- pMga->pMgaModeInfo->flOutput |= MGAMODEINFO_TV;
- } else {
- if (!swap_head) {
- pMga->pMgaModeInfo->flOutput |= MGAMODEINFO_ANALOG1;
- } else {
- pMga->pMgaModeInfo->flOutput |= MGAMODEINFO_ANALOG2;
- }
- }
+ output->funcs->save(output);
}
- pMga->pMgaModeInfo->ulFBPitch = pScrn->displayWidth;
}
-#endif
-
-/*
- * Initialise a new mode. This is currently still using the old
- * "initialise struct, restore/write struct to HW" model. That could
- * be changed.
- */
static Bool
-MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
+MGASetMode(ScrnInfoPtr scrn, DisplayModePtr mode)
{
+ MGAPtr pMga = MGAPTR(scrn);
+
+#if 0 /* old */
vgaHWPtr hwp = VGAHWPTR(pScrn);
vgaRegPtr vgaReg;
- MGAPtr pMga = MGAPTR(pScrn);
MGARegPtr mgaReg;
-#ifdef USEMGAHAL
- ULONG status;
-#endif
vgaHWUnlock(hwp);
-/* if(pMga->MergedFB && mode && mode->Private && (mode->PrivSize == 0)) {
- mode = (DisplayModePtr)mode->Private;
- }*/
-
/* Initialise the ModeReg values */
if (!vgaHWInit(pScrn, mode))
return FALSE;
@@ -2834,129 +2243,23 @@ MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
/* Program the registers */
if (pMga->is_G200SE) {
- MGAG200SEHWProtect(pScrn, TRUE);
+ MGAG200SEHWProtect(pScrn, TRUE);
} else {
- vgaHWProtect(pScrn, TRUE);
+ vgaHWProtect(pScrn, TRUE);
}
vgaReg = &hwp->ModeReg;
mgaReg = &pMga->ModeReg;
-#ifdef USEMGAHAL
- MGA_HAL(
- MGAFillModeInfoStruct(pScrn,mode);
-
- /* Validate the parameters */
- if ((status = MGAValidateMode(pMga->pBoard, pMga->pMgaModeInfo)) != 0) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "MGAValidateMode from HALlib found the mode to be invalid.\n"
- "\tError: %lx\n", status);
- return FALSE;
- }
-
- /*
- * Find mode for second head.
- */
- if(pMga->MergedFB) {
-
- MGAFillModeInfoStruct(pMga->pScrn2,mode);
- /* Validates the Video parameters */
- if ((status = MGAValidateVideoParameters(pMga->pBoard, MGAPTR(pMga->pScrn2)->pMgaModeInfo))
- != 0) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "MGAValidateVideoParameters from HALlib found the mode to be invalid.\n\tError: %lx\n", status);
- return FALSE;
- }
- }
- ); /*MGA_HAL */
-
-#endif
-
-#ifdef USEMGAHAL
-MGA_HAL(
-
- /*************************** ESC *****************************/
- TmpMgaModeInfo[0] = *pMga->pMgaModeInfo;
-
- if(pMga->SecondCrtc == TRUE)
- pMgaModeInfo[1] = pMga->pMgaModeInfo;
- else
- pMgaModeInfo[0] = pMga->pMgaModeInfo;
-
- TmpMgaModeInfo[0].ulDispWidth = 0;
-
- if(!pMga->MergedFB) /* FIXME: Must deal with this once PowerDesk & MergedFB
- compatibility will exist */
- MGAFillDisplayModeStruct(mode, pMga->pMgaModeInfo);
- /*************************************************************/
-
-); /* MGA_HAL */
-#endif
-
-#ifdef XF86DRI
- if (pMga->directRenderingEnabled) {
- DRILock(screenInfo.screens[pScrn->scrnIndex], 0);
- }
#endif
-#ifdef USEMGAHAL
- MGA_HAL(
- /* Initialize the board */
- if(MGASetMode(pMga->pBoard,pMga->pMgaModeInfo) != 0) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "MGASetMode returned an error."
- " Make sure to validate the mode before.\n");
- return FALSE;
- }
- if(pMga->MergedFB
- && MGASetMode(pMga->pBoard,MGAPTR(pMga->pScrn2)->pMgaModeInfo) != 0) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "MGASetMode returned an error."
- " Make sure to validate the mode before.\n");
- }
+ xf86SetSingleMode(scrn, mode, RR_Rotate_0);
- ); /* MGA_HAL */
-
- /* getting around bugs in the HAL lib. MATROX: hint, hint. */
- MGA_HAL(
- switch (pMga->Chipset) {
- case PCI_CHIP_MGA1064:
- case PCI_CHIP_MGAG100:
- case PCI_CHIP_MGAG100_PCI:
- case PCI_CHIP_MGAG200:
- case PCI_CHIP_MGAG200_PCI:
- case PCI_CHIP_MGAG200_SE_A_PCI:
- case PCI_CHIP_MGAG200_SE_B_PCI:
- case PCI_CHIP_MGAG400:
- case PCI_CHIP_MGAG550:
- if(pMga->SecondCrtc == FALSE && pMga->HWCursor == TRUE) {
- outMGAdac(MGA1064_CURSOR_BASE_ADR_LOW,
- pMga->FbCursorOffset >> 10);
- outMGAdac(MGA1064_CURSOR_BASE_ADR_HI,
- pMga->FbCursorOffset >> 18);
- outMGAdac(MGA1064_CURSOR_CTL, 0x00);
- }
- if (pMga->Overlay8Plus24 == TRUE) {
- outMGAdac(MGA1064_MUL_CTL, MGA1064_MUL_CTL_32bits);
- outMGAdac(MGA1064_COL_KEY_MSK_LSB,0xFF);
- outMGAdac(MGA1064_COL_KEY_LSB,pMga->colorKey);
- outMGAdac(MGA1064_COL_KEY_MSK_MSB,0xFF);
- outMGAdac(MGA1064_COL_KEY_MSB,0xFF);
- }
- break;
- default:
- break;
- }
- ); /* MGA_HAL */
-#endif
-
- MGA_NOT_HAL((*pMga->Restore)(pScrn, vgaReg, mgaReg, FALSE));
-
- MGAStormSync(pScrn);
- MGAStormEngineInit(pScrn);
+ MGAStormSync(scrn);
+ MGAStormEngineInit(scrn);
if (pMga->is_G200SE) {
- MGAG200SEHWProtect(pScrn,FALSE);
+ MGAG200SEHWProtect(scrn, FALSE);
} else {
- vgaHWProtect(pScrn, FALSE);
+ vgaHWProtect(scrn, FALSE);
}
if (xf86IsPc98()) {
@@ -2966,132 +2269,38 @@ MGA_HAL(
outb(0xfac, 0x02);
}
- MGA_NOT_HAL(
- if (pMga->is_G200SE) {
- OUTREG8(0x1FDE, 0x06);
- OUTREG8(0x1FDF, 0x14);
- }
- );
-
- pMga->CurrentLayout.mode = mode;
-
- if(pMga->MergedFB && mode->Private && (mode->PrivSize == 0)) {
- pMga->M1currentMode = (DisplayModePtr)mode->Private;
+ if (pMga->is_G200SE) {
+ OUTREG8(0x1FDE, 0x06);
+ OUTREG8(0x1FDF, 0x14);
}
-#ifdef XF86DRI
- if (pMga->directRenderingEnabled)
- DRIUnlock(screenInfo.screens[pScrn->scrnIndex]);
-#endif
-#ifdef DEBUG
- MGAG450PrintPLL(pScrn);
-#endif
return TRUE;
}
-static
-void MGARestoreSecondCrtc(ScrnInfoPtr pScrn)
-{
- MGAPtr pMga = MGAPTR(pScrn);
-
- if (MGAISGx50(pMga)) {
- /* Force to return in clone mode */
- if (pMga->SecondOutput
- && (xf86IsEntityShared(pScrn->entityList[0]) || pMga->SecondCrtc)
- && !pMga->MergedFB) {
- /* Do this branch if
- * SecondOutput
- * and not Unshared Primary
- * and not Merged Mode (usualy means Unshared Primary)
- */
- CARD8 ucXDispCtrl = inMGAdac(MGA1064_DISP_CTL);
-
- ucXDispCtrl &= ~MGA1064_DISP_CTL_DAC2OUTSEL_MASK;
- ucXDispCtrl |= MGA1064_DISP_CTL_DAC2OUTSEL_CRTC1;
-
- outMGAdac(MGA1064_DISP_CTL, ucXDispCtrl);
-
- } else {
- CARD8 ucXDispCtrl = inMGAdac(MGA1064_DISP_CTL);
- CARD32 ulC2CTL = INREG(MGAREG_C2CTL);
-
- ucXDispCtrl &= ~MGA1064_DISP_CTL_DAC2OUTSEL_MASK;
- ucXDispCtrl |= MGA1064_DISP_CTL_DAC1OUTSEL_EN;
- ucXDispCtrl |= MGA1064_DISP_CTL_DAC2OUTSEL_CRTC1;
-
- /* crtcdacsel -> crtc1 */
- ulC2CTL &= ~MGAREG_C2CTL_CRTCDACSEL_CRTC2;
- ulC2CTL |= MGAREG_C2CTL_CRTCDACSEL_CRTC1;
-
- outMGAdac(MGA1064_DISP_CTL, ucXDispCtrl);
- OUTREG(MGAREG_C2CTL, ulC2CTL);
- }
-
- } else {
- /* Force to close second crtc */
- CARD32 ulC2CTL = INREG(MGAREG_C2CTL);
-
- ulC2CTL &= ~MGAREG_C2CTL_C2_EN;
-
- OUTREG(MGAREG_C2CTL, ulC2CTL);
- }
-}
-
/*
* Restore the initial (text) mode.
*/
static void
-MGARestore(ScrnInfoPtr pScrn)
+MGARestore(ScrnInfoPtr scrn)
{
- vgaHWPtr hwp = VGAHWPTR(pScrn);
- vgaRegPtr vgaReg = &hwp->SavedReg;
- MGAPtr pMga = MGAPTR(pScrn);
- MGARegPtr mgaReg = &pMga->SavedReg;
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
+ int i;
- if (pScrn->pScreen != NULL)
- MGAStormSync(pScrn);
+ if (scrn->pScreen != NULL)
+ MGAStormSync(scrn);
- /*
- * Restore the second crtc if:
- * first and only driver entity
- * second entity
- * Merged Framebuffer mode (first and only driver entity)
- */
- if((!xf86IsEntityShared(pScrn->entityList[0]) && !pMga->SecondCrtc)
- || pMga->SecondCrtc || pMga->MergedFB) {
- /* if(pMga->MergedFB) {
- if(pMga->pScrn2)
- MGARestoreSecondCrtc(pMga->pScrn2);
- } else*/
- MGARestoreSecondCrtc(pScrn);
- /* if we are second instance of driver, we've done our job, exit */
- if(pMga->SecondCrtc) return;
- }
-
- /* Only restore text mode fonts/text for the primary card */
- if (pMga->is_G200SE) {
- MGAG200SEHWProtect(pScrn,TRUE);
- } else {
- vgaHWProtect(pScrn, TRUE);
- }
- if (pMga->Primary) {
-#ifdef USEMGAHAL
- MGA_HAL(
- if(pMga->pBoard != NULL) {
- MGASetVgaMode(pMga->pBoard);
- MGARestoreVgaState(pMga->pBoard);
- }
- ); /* MGA_HAL */
-#endif
- (*pMga->Restore)(pScrn, vgaReg, mgaReg, TRUE);
- } else {
- vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE);
+ /* Restore CRTC states */
+ for (i = 0; i < config->num_crtc; i++) {
+ xf86CrtcPtr crtc = config->crtc[i];
+
+ crtc->funcs->restore(crtc);
}
- if (pMga->is_G200SE) {
- MGAG200SEHWProtect(pScrn,FALSE);
- } else {
- vgaHWProtect(pScrn,FALSE);
+ /* Restore output states */
+ for (i = 0; i < config->num_output; i++) {
+ xf86OutputPtr output = config->output[i];
+
+ output->funcs->restore(output);
}
}
@@ -3133,7 +2342,6 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
VisualPtr visual;
unsigned char *FBStart;
int width, height, displayWidth;
- MGAEntPtr pMgaEnt = NULL;
int f;
CARD32 VRTemp, FBTemp;
#ifdef XF86DRI
@@ -3169,86 +2377,10 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
|| (pMga->Chipset == PCI_CHIP_MGAG100_PCI))
MGAG100BlackMagic(pScrn);
- if (pMga->DualHeadEnabled) {
- DevUnion *pPriv;
- pPriv = xf86GetEntityPrivate(pScrn->entityList[0], MGAEntityIndex);
- pMgaEnt = pPriv->ptr;
- pMgaEnt->refCount++;
-#ifdef USEMGAHAL
- MGA_HAL(
- if(pMgaEnt->refCount == 1) {
- CARD8 MiscCtlReg;
- pMga->pBoard = xalloc(sizeof(CLIENTDATA) + MGAGetBOARDHANDLESize());
- pMga->pClientStruct = xalloc(sizeof(CLIENTDATA));
- pMga->pClientStruct->pMga = (MGAPtr) pMga;
-
- /* wrapping OpenLibrary to fix broken registers. MATROX: hint,hint.*/
- MiscCtlReg = inMGAdac(MGA1064_MISC_CTL);
- MGAOpenLibrary(pMga->pBoard,pMga->pClientStruct,sizeof(CLIENTDATA));
- outMGAdac(MGA1064_MISC_CTL,MiscCtlReg);
- pMga->pMgaHwInfo = xalloc(sizeof(MGAHWINFO));
- MGAGetHardwareInfo(pMga->pBoard,pMga->pMgaHwInfo);
-
- /* Detecting for type of display */
- if (pMga->pMgaHwInfo->ulCapsSecondOutput & MGAHWINFOCAPS_OUTPUT_TV) {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "TV detected\n");
- }
- if (pMga->pMgaHwInfo->ulCapsFirstOutput &
- MGAHWINFOCAPS_OUTPUT_DIGITAL) {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "Digital Screen detected\n");
- }
- if (pMga->pMgaHwInfo->ulCapsSecondOutput &
- MGAHWINFOCAPS_OUTPUT_DIGITAL) {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "Digital Screen detected\n");
- }
-
- /* Now copy these to the entitystructure */
- pMgaEnt->pClientStruct = pMga->pClientStruct;
- pMgaEnt->pBoard = pMga->pBoard;
- pMgaEnt->pMgaHwInfo = pMga->pMgaHwInfo;
- } else { /* Ref count is 2 */
- pMga->pClientStruct = pMgaEnt->pClientStruct;
- pMga->pBoard = pMgaEnt->pBoard;
- pMga->pMgaHwInfo = pMgaEnt->pMgaHwInfo;
- }
- ); /* MGA_HAL */
-#endif
- } else {
-#ifdef USEMGAHAL
- CARD8 MiscCtlReg;
-
- MGA_HAL(
- pMga->pBoard = xalloc(sizeof(CLIENTDATA) + MGAGetBOARDHANDLESize());
- pMga->pClientStruct = xalloc(sizeof(CLIENTDATA));
- pMga->pClientStruct->pMga = (MGAPtr) pMga;
-
- MiscCtlReg = inMGAdac(MGA1064_MISC_CTL);
- /* wrapping OpenLibrary to fix broken registers. MATROX: hint,hint.*/
- MGAOpenLibrary(pMga->pBoard,pMga->pClientStruct,sizeof(CLIENTDATA));
- outMGAdac(MGA1064_MISC_CTL,MiscCtlReg);
- pMga->pMgaHwInfo = xalloc(sizeof(MGAHWINFO));
- MGAGetHardwareInfo(pMga->pBoard,pMga->pMgaHwInfo);
- ); /* MGA_HAL */
-#endif
- }
if (pMga->is_G200SE) {
pScrn->videoRam = VRTemp;
pMga->FbMapSize = FBTemp;
}
-#ifdef USEMGAHAL
- MGA_HAL(
- /* There is a problem in the HALlib: set soft reset bit */
- /* MATROX: hint, hint. */
- if (!pMga->Primary && !pMga->FBDev &&
- (pMga->PciInfo->subsysCard == PCI_CARD_MILL_G200_SG) ) {
- OUTREG(MGAREG_Reset, 1);
- usleep(200);
- OUTREG(MGAREG_Reset, 0);
- }
- ); /* MGA_HAL */
-#endif
/* Initialise the MMIO vgahw functions */
vgaHWSetMmioFuncs(hwp, pMga->IOBase, PORT_OFFSET);
@@ -3288,23 +2420,16 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
MGAStormEngineInit(pScrn);
} else {
+ pScrn->vtSema = TRUE;
+
/* Save the current state */
MGASave(pScrn);
- /* Initialise the first mode */
- if (!MGAModeInit(pScrn, pScrn->currentMode))
- return FALSE;
- }
- /* Darken the screen for aesthetic reasons and set the viewport */
- if (pMga->SecondCrtc == TRUE && !pMga->MergedFB) {
- MGASaveScreenCrtc2(pScreen, SCREEN_SAVER_ON);
- }
- if (pMga->SecondCrtc == FALSE && !pMga->MergedFB) {
- MGASaveScreen(pScreen, SCREEN_SAVER_ON);
- }
- if( pMga->MergedFB ) {
- MGASaveScreenMerged( pScreen, SCREEN_SAVER_ON );
+
+ xf86SetDesiredModes(pScrn);
+
+ MGAStormSync(pScrn);
+ MGAStormEngineInit(pScrn);
}
- pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
/*
* The next step is to setup the screen's visuals, and initialise the
@@ -3356,10 +2481,8 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
* pScreen fields.
*/
- width = pScrn->virtualX;
+ width = displayWidth = pScrn->displayWidth = pScrn->virtualX;
height = pScrn->virtualY;
- displayWidth = pScrn->displayWidth;
-
if(pMga->Rotate) {
height = pScrn->virtualX;
@@ -3462,8 +2585,10 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
pMga->BlockHandler = pScreen->BlockHandler;
pScreen->BlockHandler = MGABlockHandler;
+#if 0
if(!pMga->ShadowFB) /* hardware cursor needs to wrap this layer */
MGADGAInit(pScreen);
+#endif
if (!pMga->NoAccel) {
#ifdef USE_EXA
@@ -3476,6 +2601,18 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
#endif
}
+ pMga->CurrentLayout.bitsPerPixel = pScrn->bitsPerPixel;
+ pMga->CurrentLayout.depth = pScrn->depth;
+ pMga->CurrentLayout.displayWidth = pScrn->displayWidth;
+ pMga->CurrentLayout.weight.red = pScrn->weight.red;
+ pMga->CurrentLayout.weight.green = pScrn->weight.green;
+ pMga->CurrentLayout.weight.blue = pScrn->weight.blue;
+ pMga->CurrentLayout.Overlay8Plus24 = pMga->Overlay8Plus24;
+ pMga->CurrentLayout.mode = pScrn->currentMode;
+
+ if (!MGAEnterVT(scrnIndex, 0))
+ return FALSE;
+
miInitializeBackingStore(pScreen);
xf86SetBackingStore(pScreen);
xf86SetSilkenMouse(pScreen);
@@ -3491,6 +2628,7 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Hardware cursor initialization failed\n");
}
+#if 0
if(pMga->MergedFB) {
/* Rotate and MergedFB are mutiualy exclusive, so we can use this
* variable.
@@ -3500,6 +2638,7 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
pScrn->PointerMoved = MGAMergePointerMoved;
}
+#endif
/* Initialise default colourmap */
if (!miCreateDefColormap(pScreen))
@@ -3541,28 +2680,17 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
ShadowFBInit(pScreen, refreshArea);
}
- if(pMga->SecondCrtc == TRUE && !pMga->MergedFB) {
- xf86DPMSInit(pScreen, MGADisplayPowerManagementSetCrtc2, 0);
- }
- if(pMga->SecondCrtc == FALSE && !pMga->MergedFB) {
- xf86DPMSInit(pScreen, MGADisplayPowerManagementSet, 0);
- }
- if(pMga->MergedFB) {
- xf86DPMSInit(pScreen, MGADisplayPowerManagementSetMerged, 0);
- }
-
pScrn->memPhysBase = pMga->FbAddress;
pScrn->fbOffset = pMga->YDstOrg * (pScrn->bitsPerPixel / 8);
- if(!pMga->MergedFB) {
- if(pMga->SecondCrtc == TRUE) {
- pScreen->SaveScreen = MGASaveScreenCrtc2;
- } else {
- pScreen->SaveScreen = MGASaveScreen;
- }
- } else { /* Merged FB */
- pScreen->SaveScreen = MGASaveScreenMerged;
- }
+ xf86DPMSInit(pScreen, xf86DPMSSet, 0);
+
+ /* Wrap the current CloseScreen function */
+ pScreen->SaveScreen = xf86SaveScreen;
+ pMga->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = MGACloseScreen;
+
+ xf86CrtcScreenInit(pScreen);
MGAInitVideo(pScreen);
@@ -3578,129 +2706,25 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
} else {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Direct rendering disabled\n");
}
- if (pMga->DualHeadEnabled && pMga->SecondCrtc == FALSE)
- pMgaEnt->directRenderingEnabled = pMga->directRenderingEnabled;
+
pMga->haveQuiescense = 1;
#endif
- /* Wrap the current CloseScreen function */
- pMga->CloseScreen = pScreen->CloseScreen;
- pScreen->CloseScreen = MGACloseScreen;
-
/* Report any unused options (only for the first generation) */
if (serverGeneration == 1) {
xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
}
- /* For the second head, work around display problem. */
- if (!pMga->MergedFB && pMga->SecondCrtc) {
- MGACrtc2FillStrip(pScrn);
- }
-
- /* Done */
return TRUE;
}
/* Usually mandatory */
-Bool
+static Bool
MGASwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
{
-#ifdef USEMGAHAL
- char sCmdIn[256];
- char sCmdOut[256];
- FILE* fdIn;
-# ifdef MATROX_WRITEBACK
- FILE* fdOut;
-# endif
-#endif
-
- if (mode->Flags & 0x80000000) {
-#ifdef USEMGAHAL
-
-# ifdef MATROX_WRITEBACK
-# define MWB(x) { x; }
-# define MWB_COND(x) x
-# else
-# define MWB(x)
-# define MWB_COND(x) 1
-# endif
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-
- MGA_HAL(
- fdIn = fopen("/tmp/mgaDriverIn", "rt");
- MWB(fdOut = fopen("/tmp/mgaDriverOut", "wt"))
-
- if(fdIn && MWB_COND(fdOut))
- {
-
- fgets(sCmdIn, 255, fdIn);
-
- if(sCmdIn)
- {
-
- MGAExecuteEscCmd(xf86Screens[scrnIndex], sCmdIn, sCmdOut, mode);
-
- /* Remove file and close file descriptor */
- remove("/tmp/mgaDriverIn");
- fclose(fdIn);
- MWB(
- /* Write output data to output file for
- calling application */
- fputs(sCmdOut, fdOut);
- fclose(fdOut);
- )
- mode->Flags &= 0x7FFFFFFF;
- return TRUE;
- }
- else
- {
- mode->Flags &= 0x7FFFFFFF;
- return FALSE;
- }
- }
- else
- {
- mode->Flags &= 0x7FFFFFFF;
- return FALSE;
- }
- )
-#endif
- return FALSE;
- } else
- return MGAModeInit(xf86Screens[scrnIndex], mode);
+ return MGASetMode(xf86Screens[scrnIndex], mode);
}
-
- /* Adjusts coordinates to match Panning granularity.
- * does nothing if the HALlib is not loaded
- */
-void
-MGAAdjustGranularity(ScrnInfoPtr pScrn, int* x, int* y)
-{
-#ifdef USEMGAHAL
- MGA_HAL(
- MGAPtr pMga = MGAPTR(pScrn);
- MGAPtr pMga2;
- int xg = 1;
- int yg = 1;
- if(pMga->pMgaModeInfo && pMga->pMgaModeInfo->ulPanXGran && pMga->pMgaModeInfo->ulPanYGran) {
- xg = pMga->pMgaModeInfo->ulPanXGran;
- yg = pMga->pMgaModeInfo->ulPanYGran;
- }
- if(pMga->pScrn2 && (pMga2 = MGAPTR(pMga->pScrn2)) ) {
-
- if(pMga2->pMgaModeInfo && pMga2->pMgaModeInfo->ulPanXGran && pMga2->pMgaModeInfo->ulPanYGran) {
- xg = max(xg,pMga2->pMgaModeInfo->ulPanXGran);
- yg = max(yg,pMga2->pMgaModeInfo->ulPanYGran);
- }
- }
- xg=16; /*ncoder: temporary */
- *x -= *x % xg;
- *y -= *y % yg;
- );
-#endif
-}
-
/*
* This function is used to initialize the Start Address - the first
@@ -3710,92 +2734,21 @@ MGAAdjustGranularity(ScrnInfoPtr pScrn, int* x, int* y)
void
MGAAdjustFrame(int scrnIndex, int x, int y, int flags)
{
- ScrnInfoPtr pScrn;
- int Base, tmp, count;
+#if 0
+ /* FIXME */
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ xf86OutputPtr output = config->output[config->compat_output];
+ xf86CrtcPtr crtc = output->crtc;
- MGAFBLayout *pLayout;
- MGAPtr pMga;
+ if (!crtc || !crtc->enabled)
+ return;
-
- pScrn = xf86Screens[scrnIndex];
- pMga = MGAPTR(pScrn);
- pLayout = &pMga->CurrentLayout;
-
- /* wanted to improve panning granularity problems without risking
- * compatibility issues. Existing code looked hardware dependent.
- */
-#ifdef USEMGAHAL
- MGA_HAL(
- pMga->HALGranularityOffX = x;
- pMga->HALGranularityOffY = y;
- MGAAdjustGranularity(pScrn,&x,&y);
- pMga->HALGranularityOffX = pMga->HALGranularityOffX - x;
- pMga->HALGranularityOffY = pMga->HALGranularityOffY - y;
- HALSetDisplayStart(pMga->pBoard,x,y,0);
- );
+ mga_crtc_adjust_frame(crtc, x, y);
#endif
- MGA_NOT_HAL(
- if(pMga->ShowCache && y && pScrn->vtSema)
- y += pScrn->virtualY - 1;
-
- Base = (y * pLayout->displayWidth + x + pMga->YDstOrg) >>
- (3 - pMga->BppShifts[(pLayout->bitsPerPixel >> 3) - 1]);
-
- if (pLayout->bitsPerPixel == 24) {
- if (pMga->Chipset == PCI_CHIP_MGAG400 || pMga->Chipset == PCI_CHIP_MGAG550)
- Base &= ~1; /*1 Not sure why */
- Base *= 3;
- }
-
- /* find start of retrace */
- while (INREG8(0x1FDA) & 0x08);
- while (!(INREG8(0x1FDA) & 0x08));
- /* wait until we're past the start (fixseg.c in the DDK) */
- count = INREG(MGAREG_VCOUNT) + 2;
- while(INREG(MGAREG_VCOUNT) < count);
-
- OUTREG16(MGAREG_CRTC_INDEX, (Base & 0x00FF00) | 0x0C);
- OUTREG16(MGAREG_CRTC_INDEX, ((Base & 0x0000FF) << 8) | 0x0D);
- OUTREG8(MGAREG_CRTCEXT_INDEX, 0x00);
- tmp = INREG8(MGAREG_CRTCEXT_DATA);
- OUTREG8(MGAREG_CRTCEXT_DATA, (tmp & 0xF0) | ((Base & 0x0F0000) >> 16));
- );
}
-void
-MGAAdjustFrameCrtc2(int scrnIndex, int x, int y, int flags)
-{
- ScrnInfoPtr pScrn;
- int Base;
- MGAFBLayout *pLayout;
- MGAPtr pMga;
-
- pScrn = xf86Screens[scrnIndex];
- pMga = MGAPTR(pScrn);
- pLayout = &pMga->CurrentLayout;
-#ifdef USEMGAHAL
- MGA_HAL(
- MGAAdjustGranularity(pScrn,&x,&y);
- HALSetDisplayStart(pMga->pBoard,x,y,1);
- );
-#endif
- MGA_NOT_HAL(
- if(pMga->ShowCache && y && pScrn->vtSema)
- y += pScrn->virtualY - 1;
-
- /* 3-85 c2offset
- * 3-93 c2startadd0
- * 3-96 c2vcount
- */
-
- Base = (y * pLayout->displayWidth + x) * pLayout->bitsPerPixel >> 3;
- Base += pMga->DstOrg;
- Base &= 0x01ffffc0;
- OUTREG(MGAREG_C2STARTADD0, Base);
- );
-}
-
/*
* This is called when VT switching back to the X server. Its job is
* to reinitialise the video mode.
@@ -3807,10 +2760,8 @@ MGAAdjustFrameCrtc2(int scrnIndex, int x, int y, int flags)
static Bool
MGAEnterVT(int scrnIndex, int flags)
{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
- MGAPtr pMga;
-
- pMga = MGAPTR(pScrn);
+ ScrnInfoPtr scrn = xf86Screens[scrnIndex];
+ MGAPtr pMga = MGAPTR(scrn);
#ifdef XF86DRI
if (pMga->directRenderingEnabled) {
@@ -3818,17 +2769,18 @@ MGAEnterVT(int scrnIndex, int flags)
/* Need to make sure interrupts are enabled */
OUTREG(MGAREG_IEN, pMga->reg_ien);
}
- DRIUnlock(screenInfo.screens[scrnIndex]);
+ MGADRIUnlock(scrn);
}
#endif
- if (!MGAModeInit(pScrn, pScrn->currentMode))
- return FALSE;
- pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+ xf86SetDesiredModes(scrn);
+
+ MGAStormSync(scrn);
+ MGAStormEngineInit(scrn);
/* For the second head, work around display problem. */
- if (pMga->SecondCrtc) {
- MGACrtc2FillStrip(pScrn);
+ if (pMga->SecondCrtc) {
+ MGACrtc2FillStrip(scrn);
}
return TRUE;
@@ -3838,15 +2790,9 @@ static Bool
MGAEnterVTFBDev(int scrnIndex, int flags)
{
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-#ifdef XF86DRI
- ScreenPtr pScreen;
- MGAPtr pMga;
- pMga = MGAPTR(pScrn);
- if (pMga->directRenderingEnabled) {
- pScreen = screenInfo.screens[scrnIndex];
- DRIUnlock(pScreen);
- }
+#ifdef XF86DRI
+ MGADRIUnlock(pScrn);
#endif
fbdevHWEnterVT(scrnIndex,flags);
@@ -3854,16 +2800,6 @@ MGAEnterVTFBDev(int scrnIndex, int flags)
return TRUE;
}
-#define RESTORE_TEXTMODE_ON_DVI(x) \
- if (MGAISGx50(x) && \
- (ISDIGITAL1(x) || ISDIGITAL2(x))) { \
- /* Reset DUALDVI register */ \
- outMGAdac(MGA1064_DVI_PIPE_CTL, 0x0); \
- /* Set Panel mode between 20 and 54 MHz */ \
- outMGAdac(MGA1064_PAN_CTL, 0x7); \
- }
-
-
/*
* This is called when VT switching away from the X server. Its job is
* to restore the previous (text) mode.
@@ -3877,24 +2813,17 @@ MGALeaveVT(int scrnIndex, int flags)
{
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
vgaHWPtr hwp = VGAHWPTR(pScrn);
-#ifdef XF86DRI
- MGAPtr pMga = MGAPTR(pScrn);
- ScreenPtr pScreen;
-#endif
+
+ xf86DrvMsg(scrnIndex, X_INFO, "Leaving VT\n");
MGARestore(pScrn);
vgaHWLock(hwp);
if (xf86IsPc98())
outb(0xfac, 0x00);
+
#ifdef XF86DRI
- if (pMga->directRenderingEnabled) {
- pScreen = screenInfo.screens[scrnIndex];
- DRILock(pScreen, 0);
- }
-#endif
-#ifdef USEMGAHAL
- MGA_HAL( RESTORE_TEXTMODE_ON_DVI(pMga); );
+ MGADRILock(pScrn);
#endif
}
@@ -3913,13 +2842,6 @@ MGACloseScreen(int scrnIndex, ScreenPtr pScreen)
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
vgaHWPtr hwp = VGAHWPTR(pScrn);
MGAPtr pMga = MGAPTR(pScrn);
- MGAEntPtr pMgaEnt = NULL;
-
-#ifdef USEMGAHAL
- MGA_HAL( RESTORE_TEXTMODE_ON_DVI(pMga); );
-#endif
- if (pMga->MergedFB)
- MGACloseScreenMerged(scrnIndex, pScreen);
if (pScrn->vtSema) {
if (pMga->FBDev) {
@@ -3939,44 +2861,6 @@ MGACloseScreen(int scrnIndex, ScreenPtr pScreen)
}
#endif
- if (pMga->DualHeadEnabled) {
- DevUnion *pPriv;
- pPriv = xf86GetEntityPrivate(pScrn->entityList[0], MGAEntityIndex);
- pMgaEnt = pPriv->ptr;
- pMgaEnt->refCount--;
- }
-
-#ifdef USEMGAHAL
- MGA_HAL(
- if(pMga->DualHeadEnabled) {
- if(pMgaEnt->refCount == 0) {
- /* Both boards have closed there screen */
- MGACloseLibrary(pMga->pBoard);
-
- if (pMga->pBoard)
- xfree(pMga->pBoard);
- if (pMga->pClientStruct)
- xfree(pMga->pClientStruct);
- if (pMga->pMgaModeInfo)
- xfree(pMga->pMgaModeInfo);
- if (pMga->pMgaHwInfo)
- xfree(pMga->pMgaHwInfo);
- }
- } else {
- MGACloseLibrary(pMga->pBoard);
-
- if (pMga->pBoard)
- xfree(pMga->pBoard);
- if (pMga->pClientStruct)
- xfree(pMga->pClientStruct);
- if (pMga->pMgaModeInfo)
- xfree(pMga->pMgaModeInfo);
- if (pMga->pMgaHwInfo)
- xfree(pMga->pMgaHwInfo);
- }
- ); /* MGA_HAL */
-#endif
-
#ifdef USE_XAA
if (pMga->AccelInfoRec)
XAADestroyInfoRec(pMga->AccelInfoRec);
@@ -4072,134 +2956,6 @@ MGAValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
}
-/*
- * This routine is required but since we can't easily blank the
- * second display without risking powering off the monitor, return
- * FALSE and let the X server do something generic.
- */
-static Bool
-MGASaveScreenCrtc2(ScreenPtr pScreen, int mode)
-{
- return FALSE;
-}
-
-/* Do screen blanking */
-
-static Bool
-MGASaveScreen(ScreenPtr pScreen, int mode)
-{
- return vgaHWSaveScreen(pScreen, mode);
-}
-
-
-/*
- * MGADisplayPowerManagementSet --
- *
- * Sets VESA Display Power Management Signaling (DPMS) Mode.
- *
- * XXX This needs fixing for sync-on-green!
- */
-void
-MGADisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode,
- int flags)
-{
- MGAPtr pMga = MGAPTR(pScrn);
- unsigned char seq1 = 0, crtcext1 = 0;
-
- switch (PowerManagementMode)
- {
- case DPMSModeOn:
- /* Screen: On; HSync: On, VSync: On */
- seq1 = 0x00;
- crtcext1 = 0x00;
- break;
- case DPMSModeStandby:
- /* Screen: Off; HSync: Off, VSync: On */
- seq1 = 0x20;
- crtcext1 = 0x10;
- break;
- case DPMSModeSuspend:
- /* Screen: Off; HSync: On, VSync: Off */
- seq1 = 0x20;
- crtcext1 = 0x20;
- break;
- case DPMSModeOff:
- /* Screen: Off; HSync: Off, VSync: Off */
- seq1 = 0x20;
- crtcext1 = 0x30;
- break;
- }
-
- /* XXX Prefer an implementation that doesn't depend on VGA specifics */
- OUTREG8(MGAREG_SEQ_INDEX, 0x01); /* Select SEQ1 */
- seq1 |= INREG8(MGAREG_SEQ_DATA) & ~0x20;
- MGAWAITVSYNC();
- MGAWAITBUSY();
- OUTREG8(MGAREG_SEQ_DATA, seq1);
- usleep(20000);
- OUTREG8(MGAREG_CRTCEXT_INDEX, 0x01); /* Select CRTCEXT1 */
- crtcext1 |= INREG8(MGAREG_CRTCEXT_DATA) & ~0x30;
- OUTREG8(MGAREG_CRTCEXT_DATA, crtcext1);
-}
-
-
-void
-MGADisplayPowerManagementSetCrtc2(ScrnInfoPtr pScrn, int PowerManagementMode,
- int flags)
-{
- MGAPtr pMga = MGAPTR(pScrn);
- CARD32 val = INREG(MGAREG_C2CTL);
-
- if (PowerManagementMode==DPMSModeOn) {
- /* Enable CRTC2 */
- val |= MGAREG_C2CTL_C2_EN;
- val &= ~MGAREG_C2CTL_PIXCLKDIS_DISABLE;
- 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 |= MGAREG_C2CTL_PIXCLKDIS_DISABLE;
- val &= ~MGAREG_C2CTL_C2_EN;
- 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);
- }
-
- }
-}
-
-
static void
MGABlockHandler (
int i,
@@ -4345,3 +3101,11 @@ MGAG100BlackMagic(ScrnInfoPtr pScrn)
usleep(10);
}
+static Bool
+crtc_config_resize(ScrnInfoPtr scrn, int width, int height)
+{
+ scrn->virtualX = width;
+ scrn->virtualY = height;
+
+ return TRUE;
+}