summaryrefslogtreecommitdiff
path: root/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c
diff options
context:
space:
mode:
Diffstat (limited to 'xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c')
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c1104
1 files changed, 683 insertions, 421 deletions
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c
index 303b7f3e8..17e77afc0 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c
@@ -45,7 +45,7 @@
* Added digital screen option for first head
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c,v 1.214 2002/01/07 21:50:11 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c,v 1.222 2002/10/08 22:14:09 tsi Exp $ */
/*
* This is a first cut at a non-accelerated version to work with the
@@ -126,12 +126,6 @@ static void VgaIORestore(int i, void *arg);
static void MGAFreeScreen(int scrnIndex, int flags);
static int MGAValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose,
int flags);
-static void MGADisplayPowerManagementSet(ScrnInfoPtr pScrn,
- int PowerManagementMode,
- int flags);
-static void MGADisplayPowerManagementSetCrtc2(ScrnInfoPtr pScrn,
- int PowerManagementMode,
- int flags);
/* Internally used functions */
static Bool MGAMapMem(ScrnInfoPtr pScrn);
@@ -139,12 +133,14 @@ static Bool MGAUnmapMem(ScrnInfoPtr pScrn);
static void MGASave(ScrnInfoPtr pScrn);
static void MGARestore(ScrnInfoPtr pScrn);
static Bool MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
-void MGAAdjustFrameCrtc2(int scrnIndex, int x, int y, int flags);
static void MGABlockHandler(int, pointer, pointer, pointer);
static void MGAG100BlackMagic(MGAPtr pMga);
static int MGAEntityIndex = -1;
+#include "mga_merge.h"
+
+
/*
* This contains the functions needed by the server after loading the
* driver module. It must be supplied, and gets added the driver list by
@@ -179,50 +175,19 @@ static SymTabRec MGAChipsets[] = {
};
static PciChipsets MGAPciChipsets[] = {
- { PCI_CHIP_MGA2064, PCI_CHIP_MGA2064, RES_SHARED_VGA },
- { PCI_CHIP_MGA1064, PCI_CHIP_MGA1064, RES_SHARED_VGA },
- { PCI_CHIP_MGA2164, PCI_CHIP_MGA2164, RES_SHARED_VGA },
- { PCI_CHIP_MGA2164_AGP, PCI_CHIP_MGA2164_AGP, RES_SHARED_VGA },
- { PCI_CHIP_MGAG100, PCI_CHIP_MGAG100, RES_SHARED_VGA },
- { PCI_CHIP_MGAG100_PCI, PCI_CHIP_MGAG100_PCI, RES_SHARED_VGA },
- { PCI_CHIP_MGAG200, PCI_CHIP_MGAG200, RES_SHARED_VGA },
- { PCI_CHIP_MGAG200_PCI, PCI_CHIP_MGAG200_PCI, RES_SHARED_VGA },
- { PCI_CHIP_MGAG400, PCI_CHIP_MGAG400, RES_SHARED_VGA },
- { PCI_CHIP_MGAG550, PCI_CHIP_MGAG550, RES_SHARED_VGA },
- { -1, -1, RES_UNDEFINED }
+ { PCI_CHIP_MGA2064, PCI_CHIP_MGA2064, (resRange*)RES_SHARED_VGA },
+ { PCI_CHIP_MGA1064, PCI_CHIP_MGA1064, (resRange*)RES_SHARED_VGA },
+ { PCI_CHIP_MGA2164, PCI_CHIP_MGA2164, (resRange*)RES_SHARED_VGA },
+ { PCI_CHIP_MGA2164_AGP, PCI_CHIP_MGA2164_AGP,(resRange*)RES_SHARED_VGA },
+ { PCI_CHIP_MGAG100, PCI_CHIP_MGAG100, (resRange*)RES_SHARED_VGA },
+ { PCI_CHIP_MGAG100_PCI, PCI_CHIP_MGAG100_PCI,(resRange*)RES_SHARED_VGA },
+ { PCI_CHIP_MGAG200, PCI_CHIP_MGAG200, (resRange*)RES_SHARED_VGA },
+ { PCI_CHIP_MGAG200_PCI, PCI_CHIP_MGAG200_PCI,(resRange*)RES_SHARED_VGA },
+ { PCI_CHIP_MGAG400, PCI_CHIP_MGAG400, (resRange*)RES_SHARED_VGA },
+ { PCI_CHIP_MGAG550, PCI_CHIP_MGAG550, (resRange*)RES_SHARED_VGA },
+ { -1, -1, (resRange*)RES_UNDEFINED }
};
-typedef enum {
- OPTION_SW_CURSOR,
- OPTION_HW_CURSOR,
- OPTION_PCI_RETRY,
- OPTION_SYNC_ON_GREEN,
- OPTION_NOACCEL,
- OPTION_SHOWCACHE,
- OPTION_OVERLAY,
- OPTION_MGA_SDRAM,
- OPTION_SHADOW_FB,
- OPTION_FBDEV,
- OPTION_COLOR_KEY,
- OPTION_SET_MCLK,
- OPTION_OVERCLOCK_MEM,
- OPTION_VIDEO_KEY,
- OPTION_ROTATE,
- OPTION_TEXTURED_VIDEO,
- OPTION_CRTC2HALF,
- OPTION_CRTC2RAM,
- OPTION_INT10,
- OPTION_AGP_MODE,
- OPTION_DIGITAL,
- OPTION_TV,
- OPTION_TVSTANDARD,
- OPTION_CABLETYPE,
- OPTION_USEIRQZERO,
- OPTION_NOHAL,
- OPTION_SWAPPED_HEAD,
- OPTION_DRI
-} MGAOpts;
-
static const OptionInfoRec MGAOptions[] = {
{ OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, FALSE },
@@ -244,13 +209,20 @@ static const OptionInfoRec MGAOptions[] = {
{ OPTION_CRTC2RAM, "Crtc2Ram", OPTV_INTEGER, {0}, FALSE },
{ OPTION_INT10, "Int10", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_AGP_MODE, "AGPMode", OPTV_INTEGER, {0}, FALSE },
- { OPTION_DIGITAL, "DigitalScreen",OPTV_BOOLEAN, {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 },
{ -1, NULL, OPTV_NONE, {0}, FALSE }
};
@@ -431,7 +403,8 @@ static const char *halSymbols[] = {
"MGASetVgaMode",
"MGAValidateMode",
"MGAValidateVideoParameters",
- NULL
+ "HALSetDisplayStart",
+ NULL
};
#endif
#ifdef XFree86LOADER
@@ -510,7 +483,7 @@ static MGARamdacRec DacInit = {
0, X_DEFAULT, X_DEFAULT, FALSE
};
-static Bool
+Bool
MGAGetRec(ScrnInfoPtr pScrn)
{
/*
@@ -528,7 +501,7 @@ MGAGetRec(ScrnInfoPtr pScrn)
return TRUE;
}
-static void
+void
MGAFreeRec(ScrnInfoPtr pScrn)
{
if (pScrn->driverPrivate == NULL)
@@ -609,13 +582,14 @@ MGAProbe(DriverPtr drv, int flags)
}
numUsed = xf86MatchPciInstances(MGA_NAME, PCI_VENDOR_MATROX,
- MGAChipsets, MGAPciChipsets, devSections,
- numDevSections, drv, &usedChips);
+ MGAChipsets, MGAPciChipsets, devSections,
+ numDevSections, drv, &usedChips);
/* Free it since we don't need that list after this */
xfree(devSections);
if (numUsed <= 0)
return FALSE;
+
if (flags & PROBE_DETECT)
foundScreen = TRUE;
else for (i = 0; i < numUsed; i++) {
@@ -630,8 +604,8 @@ MGAProbe(DriverPtr drv, int flags)
#ifndef DISABLE_VGA_IO
if ((pScrn = xf86ConfigPciEntity(pScrn, 0,usedChips[i],
- MGAPciChipsets, NULL, NULL,
- NULL, NULL, NULL)))
+ MGAPciChipsets, NULL, NULL,
+ NULL, NULL, NULL)))
#else
smga = xnfalloc(sizeof(MgaSave));
smga->pvp = xf86GetPciInfoForEntity(usedChips[i]);
@@ -654,15 +628,16 @@ MGAProbe(DriverPtr drv, int flags)
pScrn->LeaveVT = MGALeaveVT;
pScrn->FreeScreen = MGAFreeScreen;
pScrn->ValidMode = MGAValidMode;
+
foundScreen = TRUE;
}
/*
* For cards that can do dual head per entity, mark the entity
- * as sharable.
+ * as sharable.
*/
pEnt = xf86GetEntityInfo(usedChips[i]);
- if (pEnt->chipset == PCI_CHIP_MGAG400 || pEnt->chipset == PCI_CHIP_MGAG550) {
+ if ((pEnt->chipset == PCI_CHIP_MGAG400 || pEnt->chipset == PCI_CHIP_MGAG550)) {
MGAEntPtr pMgaEnt = NULL;
DevUnion *pPriv;
@@ -723,7 +698,7 @@ MGAProbe(DriverPtr drv, int flags)
* Written and tested.
*/
-static void
+void
MGAReadBios(ScrnInfoPtr pScrn)
{
CARD8 BIOS[0x10000];
@@ -740,8 +715,9 @@ MGAReadBios(ScrnInfoPtr pScrn)
pBios = &pMga->Bios;
pBios2 = &pMga->Bios2;
- /* Get the output mode set by the BIOS */
- xf86ReadBIOS(pMga->BiosAddress, 0x7ff1, &pMga->BiosOutputMode, sizeof(CARD8));
+ /* 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
@@ -757,14 +733,16 @@ MGAReadBios(ScrnInfoPtr pScrn)
rlen = xf86ReadPciBIOS(0, pMga->PciTag, pMga->FbBaseReg,
BIOS, sizeof(BIOS));
else
- rlen = xf86ReadBIOS(pMga->BiosAddress, 0, BIOS, sizeof(BIOS));
+ rlen = xf86ReadDomainMemory(pMga->PciTag, pMga->BiosAddress,
+ sizeof(BIOS), BIOS);
if (rlen < (BIOS[2] << 9)) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
"Could not retrieve video BIOS!\n");
return;
}
-
+
+ /* Get the video BIOS info block */
if (strncmp((char *)(&BIOS[45]), "MATROX", 6)) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
"Video BIOS info block not detected!\n");
@@ -791,6 +769,7 @@ MGAReadBios(ScrnInfoPtr pScrn)
default:
MGADoBIOSRead(offset,
( CARD8 * ) & pBios2->PinID, sizeof( MGABios2Info ));
+ break;
}
/* matrox millennium-2 and mystique pins info */
@@ -860,7 +839,7 @@ MGAReadBios(ScrnInfoPtr pScrn)
*
* Resets drawing engine
*/
-static void
+void
MGASoftReset(ScrnInfoPtr pScrn)
{
MGAPtr pMga = MGAPTR(pScrn);
@@ -1165,14 +1144,14 @@ VgaIOEnable(void *arg)
}
#endif /* DISABLE_VGA_IO */
-static void
+void
MGAProbeDDC(ScrnInfoPtr pScrn, int index)
{
vbeInfoPtr pVbe;
if (xf86LoadSubModule(pScrn, "vbe")) {
pVbe = VBEInit(NULL,index);
ConfiguredMonitor = vbeDoEDID(pVbe, NULL);
- vbeFree(pVbe);
+ vbeFree(pVbe);
}
}
@@ -1189,14 +1168,10 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
const char *s;
int flags24;
MGAEntPtr pMgaEnt = NULL;
+ Bool Default;
#ifdef USEMGAHAL
- MGAMODEINFO mgaModeInfo = {0};
- Bool digital1 = FALSE;
- Bool digital2 = FALSE;
- Bool tv1 = FALSE;
- Bool tv2 = FALSE;
- Bool swap_head = FALSE;
ULONG status;
+ CARD8 MiscCtlReg;
#endif
/*
@@ -1267,19 +1242,8 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
pMga->Primary = xf86IsPrimaryPci(pMga->PciInfo);
#ifndef DISABLE_VGA_IO
- {
- resRange vgaio[] = { {ResShrIoBlock,0x3B0,0x3BB},
- {ResShrIoBlock,0x3C0,0x3DF},
- _END };
- resRange vga1mem[] = { {ResShrMemBlock,0xA0000,0xAFFFF},
- {ResShrMemBlock,0xB8000,0xBFFFF},
- _END };
- resRange vga2mem[] = { {ResShrMemBlock,0xB0000,0xB7FFF},
- _END };
- xf86SetOperatingState(vgaio, pMga->pEnt->index, ResUnusedOpr);
- xf86SetOperatingState(vga1mem, pMga->pEnt->index, ResDisableOpr);
- xf86SetOperatingState(vga2mem, pMga->pEnt->index, ResDisableOpr);
- }
+ xf86SetOperatingState(resVgaIo, pMga->pEnt->index, ResUnusedOpr);
+ xf86SetOperatingState(resVgaMem, pMga->pEnt->index, ResDisableOpr);
#else
/*
* Set our own access functions, which control the vgaioen bit.
@@ -1299,28 +1263,134 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
pScrn->monitor = pScrn->confScreen->monitor;
/*
- * 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
+ * Set the Chipset and ChipRev, allowing config file entries to
+ * override.
+ */
+ if (pMga->device->chipset && *pMga->device->chipset) {
+ pScrn->chipset = pMga->device->chipset;
+ pMga->Chipset = xf86StringToToken(MGAChipsets, pScrn->chipset);
+ from = X_CONFIG;
+ } else if (pMga->device->chipID >= 0) {
+ pMga->Chipset = pMga->device->chipID;
+ pScrn->chipset = (char *)xf86TokenToString(MGAChipsets, pMga->Chipset);
+ from = X_CONFIG;
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipID override: 0x%04X\n",
+ pMga->Chipset);
+ } else {
+ from = X_PROBED;
+ pMga->Chipset = pMga->PciInfo->chipType;
+ pScrn->chipset = (char *)xf86TokenToString(MGAChipsets, pMga->Chipset);
+ }
+ if (pMga->device->chipRev >= 0) {
+ pMga->ChipRev = pMga->device->chipRev;
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n",
+ pMga->ChipRev);
+ } else {
+ pMga->ChipRev = pMga->PciInfo->chipRev;
+ }
+
+ /*
+ * This shouldn't happen because such problems should be caught in
+ * MGAProbe(), but check it just in case.
+ */
+ if (pScrn->chipset == NULL) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "ChipID 0x%04X is not recognised\n", pMga->Chipset);
+ return FALSE;
+ }
+ if (pMga->Chipset < 0) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Chipset \"%s\" is not recognised\n", pScrn->chipset);
+ return FALSE;
+ }
+
+ xf86DrvMsg(pScrn->scrnIndex, from, "Chipset: \"%s\"", pScrn->chipset);
+ if ((pMga->Chipset == PCI_CHIP_MGAG400) &&
+ (pMga->ChipRev >= 0x80))
+ xf86ErrorF(" (G450)\n");
+ else
+ xf86ErrorF(" (G400)\n");
+
+#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*/
+#ifdef USEMGAHAL
+ if (pMga->HALLoaded || !MGA_DH_NEEDS_HAL(pMga)) {
+#else
+ if (!MGA_DH_NEEDS_HAL(pMga)) {
+#endif
+ 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 {
+ } 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;
+ }
+ }
+
+ if (pMga->DualHeadEnabled) {
#ifdef XF86DRI
pMga->GetQuiescence = MGAGetQuiescenceShared;
#endif
@@ -1332,6 +1402,8 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
#endif
}
+
+
/*
* The first thing we should figure out is the depth, bpp, etc.
* Our default depth is 8, so pass it to the helper function.
@@ -1403,9 +1475,16 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
memcpy(pMga->Options, MGAOptions, sizeof(MGAOptions));
xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pMga->Options);
+
#if !defined(__powerpc__)
pMga->softbooted = FALSE;
- if (xf86ReturnOptValBool(pMga->Options, OPTION_INT10, FALSE) &&
+ if (pMga->Chipset >= PCI_CHIP_MGAG400
+ && !pMga->Primary
+ && !pMga->SecondCrtc)
+ Default = TRUE;
+ else
+ Default = FALSE;
+ if (xf86ReturnOptValBool(pMga->Options, OPTION_INT10, Default) &&
xf86LoadSubModule(pScrn, "int10")) {
xf86Int10InfoPtr pInt;
@@ -1421,65 +1500,6 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
if (pScrn->depth == 8)
pScrn->rgbBits = 8;
- /*
- * Set the Chipset and ChipRev, allowing config file entries to
- * override.
- */
- if (pMga->device->chipset && *pMga->device->chipset) {
- pScrn->chipset = pMga->device->chipset;
- pMga->Chipset = xf86StringToToken(MGAChipsets, pScrn->chipset);
- from = X_CONFIG;
- } else if (pMga->device->chipID >= 0) {
- pMga->Chipset = pMga->device->chipID;
- pScrn->chipset = (char *)xf86TokenToString(MGAChipsets, pMga->Chipset);
- from = X_CONFIG;
- xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipID override: 0x%04X\n",
- pMga->Chipset);
- } else {
- from = X_PROBED;
- pMga->Chipset = pMga->PciInfo->chipType;
- pScrn->chipset = (char *)xf86TokenToString(MGAChipsets, pMga->Chipset);
- }
- if (pMga->device->chipRev >= 0) {
- pMga->ChipRev = pMga->device->chipRev;
- xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n",
- pMga->ChipRev);
- } else {
- pMga->ChipRev = pMga->PciInfo->chipRev;
- }
-
-#ifdef USEMGAHAL
- if (HAL_CHIPSETS) {
- if (!xf86ReturnOptValBool(pMga->Options, OPTION_NOHAL, FALSE)
- && xf86LoadSubModule(pScrn, "mga_hal")) {
- xf86LoaderReqSymLists(halSymbols, NULL);
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,"Matrox HAL module used\n");
- pMga->HALLoaded = TRUE;
- } else {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Matrox HAL module not loaded "
- "- using builtin mode setup instead\n");
- pMga->HALLoaded = FALSE;
- }
- }
-#endif
-
- /*
- * This shouldn't happen because such problems should be caught in
- * MGAProbe(), but check it just in case.
- */
- if (pScrn->chipset == NULL) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "ChipID 0x%04X is not recognised\n", pMga->Chipset);
- return FALSE;
- }
- if (pMga->Chipset < 0) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Chipset \"%s\" is not recognised\n", pScrn->chipset);
- return FALSE;
- }
-
- xf86DrvMsg(pScrn->scrnIndex, from, "Chipset: \"%s\"\n", pScrn->chipset);
-
#ifdef XF86DRI
from = X_DEFAULT;
pMga->agpMode = MGA_DEFAULT_AGP_MODE;
@@ -1494,6 +1514,12 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
}
from = X_CONFIG;
}
+ if (xf86GetOptValInteger(pMga->Options,
+ OPTION_AGP_SIZE, &(pMga->agpSize))) {
+ /* check later */
+ xf86DrvMsg(pScrn->scrnIndex, from, "Using %d MB of AGP memory\n",
+ pMga->agpSize);
+ }
xf86DrvMsg(pScrn->scrnIndex, from, "Using AGP %dx mode\n",
pMga->agpMode);
@@ -1581,6 +1607,41 @@ 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"))
@@ -1596,27 +1657,32 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
}
pMga->Rotate = 0;
if ((s = xf86GetOptValString(pMga->Options, OPTION_ROTATE))) {
- 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");
- }
+ 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) {
@@ -1812,7 +1878,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
pScrn->videoRam = MGACountRam(pScrn);
}
- if(xf86IsEntityShared(pScrn->entityList[0])) {
+ if (pMga->DualHeadEnabled) {
/* This takes gives either half or 8 meg to the second head
* whichever is less. */
if(pMga->SecondCrtc == FALSE) {
@@ -1839,7 +1905,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
pMgaEnt->masterFbAddress = pMga->FbAddress;
pMga->FbMapSize =
pMgaEnt->masterFbMapSize = pScrn->videoRam * 1024;
- pMgaEnt->slaveFbAddress = pMga->FbAddress +
+ pMgaEnt->slaveFbAddress = pMga->FbAddress +
pMgaEnt->masterFbMapSize;
pMgaEnt->slaveFbMapSize = pMgaEnt->slavevideoRam * 1024;
pMga->realSrcOrg = pMga->SrcOrg = 0;
@@ -1941,7 +2007,6 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
}
if(pMga->SecondCrtc == TRUE) {
/* Override on 2nd crtc */
-
if ((pMga->ChipRev >= 0x80) || (pMga->Chipset == PCI_CHIP_MGAG550)) {
/* G450, G550 */
pMga->MaxClock = 234000;
@@ -1966,7 +2031,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
MGA_HAL(clockRanges->interlaceAllowed = FALSE);
MGA_HAL(clockRanges->doubleScanAllowed = FALSE);
#endif
- if (pMga->SecondCrtc == TRUE)
+ if (pMga->SecondCrtc == TRUE)
clockRanges->interlaceAllowed = FALSE;
clockRanges->ClockMulFactor = 1;
@@ -2037,7 +2102,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
pScrn->display->virtualY,
pMga->FbMapSize,
LOOKUP_BEST_REFRESH);
-
+
if (linePitches)
xfree(linePitches);
}
@@ -2064,109 +2129,76 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
}
#ifdef USEMGAHAL
MGA_HAL(
- swap_head
- = xf86ReturnOptValBool(pMga->Options, OPTION_SWAPPED_HEAD, FALSE);
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);
- digital1 = ISDIGITAL1(pMga);
- digital2 = ISDIGITAL2(pMga);
- tv1 = ISTV1(pMga);
- tv2 = ISTV2(pMga);
-
- /* Display type information */
- if (digital1) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Digital screen detected on first head.\n");
- mgaModeInfo.flOutput = MGAMODEINFO_DIGITAL1;
- } else if (tv1) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "TV detected on first head.\n");
- mgaModeInfo.flOutput = MGAMODEINFO_TV;
- } else {
- if (!swap_head) {
- mgaModeInfo.flOutput = MGAMODEINFO_ANALOG1;
- } else {
- mgaModeInfo.flOutput = MGAMODEINFO_ANALOG2;
- }
- }
-
/* copy the board handles */
- if (xf86IsEntityShared(pScrn->entityList[0])) {
+ if (pMga->DualHeadEnabled) {
pMgaEnt->pClientStruct = pMga->pClientStruct;
pMgaEnt->pBoard = pMga->pBoard;
pMgaEnt->pMgaHwInfo = pMga->pMgaHwInfo;
}
- mgaModeInfo.ulDispWidth = pScrn->virtualX;
- mgaModeInfo.ulDispHeight = pScrn->virtualY;
- mgaModeInfo.ulDeskWidth = pScrn->virtualX;
- mgaModeInfo.ulDeskHeight = pScrn->virtualY;
- mgaModeInfo.ulBpp = pScrn->bitsPerPixel;
- mgaModeInfo.ulZoom = 1;
- } else { /* Second CRTC && entity is shared */
- if (digital2 == TRUE) {
- mgaModeInfo.flOutput = MGAMODEINFO_DIGITAL2 |
- MGAMODEINFO_SECOND_CRTC;
- } else if (tv2 == TRUE) {
- mgaModeInfo.flOutput = MGAMODEINFO_TV |
- MGAMODEINFO_SECOND_CRTC;
- } else {
- if (!swap_head) {
- mgaModeInfo.flOutput = MGAMODEINFO_ANALOG2 |
- MGAMODEINFO_SECOND_CRTC;
- } else {
- mgaModeInfo.flOutput = MGAMODEINFO_ANALOG1 |
- MGAMODEINFO_SECOND_CRTC;
- }
- }
- mgaModeInfo.ulDispWidth = pScrn->virtualX;
- mgaModeInfo.ulDispHeight = pScrn->virtualY;
- mgaModeInfo.ulDeskWidth = pScrn->virtualX;
- mgaModeInfo.ulDeskHeight = pScrn->virtualY;
- mgaModeInfo.ulBpp = pScrn->bitsPerPixel;
- mgaModeInfo.ulZoom = 1;
+ } else { /* Second CRTC && entity is shared */
pMga->pBoard = pMgaEnt->pBoard;
pMga->pClientStruct = pMgaEnt->pClientStruct;
pMga->pMgaHwInfo = pMgaEnt->pMgaHwInfo;
- digital1 = ISDIGITAL1(pMga);
- digital2 = ISDIGITAL2(pMga);
- tv1 = ISTV1(pMga);
- tv2 = ISTV2(pMga);
-
- if (digital2) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Digital screen detected on second head.\n");
- mgaModeInfo.flOutput = MGAMODEINFO_DIGITAL2 |
- MGAMODEINFO_SECOND_CRTC;
- } else if (tv2) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "TV detected on second head.\n");
- mgaModeInfo.flOutput = MGAMODEINFO_TV |
- MGAMODEINFO_SECOND_CRTC;
- } else {
- mgaModeInfo.flOutput = MGAMODEINFO_ANALOG2 |
- MGAMODEINFO_SECOND_CRTC;
- }
}
- if((status = MGAValidateMode(pMga->pBoard,&mgaModeInfo)) != 0) {
+ 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);
return FALSE;
}
- pScrn->displayWidth = mgaModeInfo.ulFBPitch;
+ pScrn->displayWidth = pMga->pMgaModeInfo->ulFBPitch;
); /* MGA_HAL */
#endif
@@ -2182,7 +2214,11 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
* Can we trust HALlib to set the memory configuration
* registers correctly?
*/
+#ifdef USEMGAHAL
else if ((pMga->softbooted || pMga->Primary /*|| pMga->HALLoaded*/ ) &&
+#else
+ else if ((pMga->softbooted || pMga->Primary) &&
+#endif
(pMga->Chipset != PCI_CHIP_MGA2064) &&
(pMga->Chipset != PCI_CHIP_MGA2164) &&
(pMga->Chipset != PCI_CHIP_MGA2164_AGP)) {
@@ -2264,7 +2300,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "YDstOrg is set to %d\n",
pMga->YDstOrg);
- if(xf86IsEntityShared(pScrn->entityList[0])) {
+ if(pMga->DualHeadEnabled) {
if(pMga->SecondCrtc == FALSE) {
pMga->FbUsableSize = pMgaEnt->masterFbMapSize;
/* Allocate HW cursor buffer at the end of video ram */
@@ -2287,7 +2323,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
pMga->FbUsableSize = pMgaEnt->slaveFbMapSize;
pMga->HWCursor = FALSE;
}
- } else {
+ } else {
pMga->FbUsableSize = pMga->FbMapSize - pMga->YDstOrg * bytesPerPixel;
/* Allocate HW cursor buffer at the end of video ram */
if( pMga->HWCursor && pMga->Dac.CursorOffscreenMemSize ) {
@@ -2362,13 +2398,22 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
pMga->CurrentLayout.weight.blue = pScrn->weight.blue;
pMga->CurrentLayout.Overlay8Plus24 = pMga->Overlay8Plus24;
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(xf86IsEntityShared(pScrn->entityList[0])) {
+
+ if(pMga->DualHeadEnabled) {
/* Entity is shared make sure refcount == 2 */
/* If ref count is 2 then reset it to 0 */
if(pMgaEnt->refCount == 2) {
@@ -2397,10 +2442,12 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
if (pMga->pMgaHwInfo)
xfree(pMga->pMgaHwInfo);
}
+
); /* MGA_HAL */
#endif
xf86SetPrimInitDone(pScrn->entityList[0]);
+
return TRUE;
}
@@ -2553,16 +2600,39 @@ MGASave(ScrnInfoPtr pScrn)
}
#ifdef USEMGAHAL
-/* Convert DisplayModeRec parameters in MGAMODEINFO parameters. */
-static void FillModeInfoStruct(ScrnInfoPtr pScrn, DisplayModePtr mode)
+/* Convert DisplayModeRec parameters in MGAMODEINFO parameters.
+* mode parameter optionnal. */
+void
+MGAFillModeInfoStruct(ScrnInfoPtr pScrn, DisplayModePtr mode)
{
- const char *s;
+ const char *s;
MGAPtr pMga = MGAPTR(pScrn);
- pMga->pMgaModeInfo = xalloc(sizeof(MGAMODEINFO));
+ 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);
+ }
+
+ /*FIXME: causes segfault elsewhere if not commented*/
+ /*if(!pMga->pMgaModeInfo)*/ pMga->pMgaModeInfo = xalloc(sizeof(MGAMODEINFO));
pMga->pMgaModeInfo->flOutput = 0;
- pMga->pMgaModeInfo->ulDispWidth = mode->HDisplay;
- pMga->pMgaModeInfo->ulDispHeight = mode->VDisplay;
pMga->pMgaModeInfo->ulDeskWidth = pScrn->virtualX;
pMga->pMgaModeInfo->ulDeskHeight = pScrn->virtualY;
pMga->pMgaModeInfo->ulFBPitch = 0;
@@ -2600,20 +2670,55 @@ static void FillModeInfoStruct(ScrnInfoPtr pScrn, DisplayModePtr mode)
pMga->pMgaModeInfo->ulCableType = TV_YC_COMPOSITE;
}
- pMga->pMgaModeInfo->ulHorizRate = 0;
- 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;
+ 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;
+
+ 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) {
+ 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;
+ }
+ }
+ }
+ pMga->pMgaModeInfo->ulFBPitch = pScrn->displayWidth;
}
#endif
@@ -2630,26 +2735,16 @@ MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
vgaRegPtr vgaReg;
MGAPtr pMga = MGAPTR(pScrn);
MGARegPtr mgaReg;
-#ifdef USEMGAHAL
- Bool digital1 = FALSE;
- Bool digital2 = FALSE;
- Bool tv1 = FALSE;
- Bool tv2 = FALSE;
- ULONG status;
- Bool swap_head
- = xf86ReturnOptValBool(pMga->Options, OPTION_SWAPPED_HEAD, FALSE);
- if (pMga->pMgaHwInfo)
- {
- digital1 = ISDIGITAL1(pMga);
- digital2 = ISDIGITAL2(pMga);
- tv1 = ISTV1(pMga);
- tv2 = ISTV2(pMga);
- }
+#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;
@@ -2662,60 +2757,55 @@ MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
vgaHWProtect(pScrn, TRUE);
vgaReg = &hwp->ModeReg;
mgaReg = &pMga->ModeReg;
-
#ifdef USEMGAHAL
- MGA_HAL(
- FillModeInfoStruct(pScrn,mode);
+ 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;
+ }
- 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) {
- 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;
+ /*
+ * 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
- pMga->pMgaModeInfo->ulFBPitch = pScrn->displayWidth;
+#ifdef USEMGAHAL
+MGA_HAL(
- /* 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;
- }
+ /*************************** 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);
+ /*************************************************************/
- /* Validates the Video parameters */
- if ((status = MGAValidateVideoParameters(pMga->pBoard, pMga->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 */
+); /* MGA_HAL */
#endif
#ifdef XF86DRI
@@ -2733,10 +2823,16 @@ MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
" 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");
+ }
+
); /* MGA_HAL */
- /* getting around bugs in the HAL lib. MATROX: hint, hint */
+ /* getting around bugs in the HAL lib. MATROX: hint, hint. */
MGA_HAL(
switch (pMga->Chipset) {
case PCI_CHIP_MGA1064:
@@ -2745,7 +2841,8 @@ MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
case PCI_CHIP_MGAG200:
case PCI_CHIP_MGAG200_PCI:
case PCI_CHIP_MGAG400:
- if(pMga->SecondCrtc == FALSE && pMga->HWCursor == TRUE) {
+ 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,
@@ -2765,10 +2862,12 @@ MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
}
); /* MGA_HAL */
#endif
+
MGA_NOT_HAL((*pMga->Restore)(pScrn, vgaReg, mgaReg, FALSE));
MGAStormSync(pScrn);
MGAStormEngineInit(pScrn);
+
vgaHWProtect(pScrn, FALSE);
if (xf86IsPc98()) {
@@ -2780,11 +2879,17 @@ MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
pMga->CurrentLayout.mode = mode;
+ if(pMga->MergedFB && mode->Private && (mode->PrivSize == 0)) {
+ pMga->M1currentMode = (DisplayModePtr)mode->Private;
+ }
+
#ifdef XF86DRI
if (pMga->directRenderingEnabled)
DRIUnlock(screenInfo.screens[pScrn->scrnIndex]);
#endif
-
+#ifdef DEBUG
+ MGAG450PrintPLL(pScrn);
+#endif
return TRUE;
}
@@ -2795,7 +2900,14 @@ void MGARestoreSecondCrtc(ScrnInfoPtr pScrn)
if (MGAISGx50(pMga)) {
/* Force to return in clone mode */
- if (pMga->SecondOutput) {
+ 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 &= ~0x0c; /* dac2outsel mask */
@@ -2841,21 +2953,33 @@ MGARestore(ScrnInfoPtr pScrn)
if (pScrn->pScreen != NULL)
MGAStormSync(pScrn);
- if(pMga->SecondCrtc) {
- MGARestoreSecondCrtc(pScrn);
- return;
+ /*
+ * 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 */
vgaHWProtect(pScrn, TRUE);
if (pMga->Primary) {
#ifdef USEMGAHAL
- MGA_HAL(
- if(pMga->pBoard != NULL) {
- MGASetVgaMode(pMga->pBoard);
- MGARestoreVgaState(pMga->pBoard);
- }
- ); /* MGA_HAL */
+ MGA_HAL(
+ if(pMga->pBoard != NULL) {
+ MGASetVgaMode(pMga->pBoard);
+ MGARestoreVgaState(pMga->pBoard);
+ }
+ ); /* MGA_HAL */
#endif
(*pMga->Restore)(pScrn, vgaReg, mgaReg, TRUE);
} else {
@@ -2917,6 +3041,7 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
pMga = MGAPTR(pScrn);
MGAdac = &pMga->Dac;
+
/* Map the MGA memory and MMIO areas */
if (pMga->FBDev) {
if (!MGAMapMemFBDev(pScrn))
@@ -2925,12 +3050,12 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
if (!MGAMapMem(pScrn))
return FALSE;
}
-
+
if ((pMga->Chipset == PCI_CHIP_MGAG100)
|| (pMga->Chipset == PCI_CHIP_MGAG100_PCI))
MGAG100BlackMagic(pMga);
- if (xf86IsEntityShared(pScrn->entityList[0])) {
+ if (pMga->DualHeadEnabled) {
DevUnion *pPriv;
pPriv = xf86GetEntityPrivate(pScrn->entityList[0], MGAEntityIndex);
pMgaEnt = pPriv->ptr;
@@ -2938,11 +3063,15 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
#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);
@@ -2974,12 +3103,17 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
#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 */
@@ -2988,7 +3122,7 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
#ifdef USEMGAHAL
MGA_HAL(
/* There is a problem in the HALlib: set soft reset bit */
- /* MATROX: hint, hint */
+ /* MATROX: hint, hint. */
if (!pMga->Primary && !pMga->FBDev &&
(pMga->PciInfo->subsysCard == PCI_CARD_MILL_G200_SG) ) {
OUTREG(MGAREG_Reset, 1);
@@ -3040,12 +3174,15 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
if (!MGAModeInit(pScrn, pScrn->currentMode))
return FALSE;
}
-
/* Darken the screen for aesthetic reasons and set the viewport */
- if (pMga->SecondCrtc == TRUE) {
- MGASaveScreenCrtc2(pScreen, SCREEN_SAVER_ON);
- } else {
- MGASaveScreen(pScreen, SCREEN_SAVER_ON);
+ 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 );
}
pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
@@ -3094,7 +3231,6 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
return FALSE;
}
-
/*
* Call the framebuffer layer's ScreenInit function, and fill in other
* pScreen fields.
@@ -3222,6 +3358,15 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Hardware cursor initialization failed\n");
}
+ if(pMga->MergedFB) {
+ /* Rotate and MergedFB are mutiualy exclusive, so we can use this
+ * variable.
+ */
+ if (!pMga->PointerMoved)
+ pMga->PointerMoved = pScrn->PointerMoved;
+ pScrn->PointerMoved = MGAMergePointerMoved;
+
+ }
/* Initialise default colourmap */
if (!miCreateDefColormap(pScreen))
@@ -3262,20 +3407,29 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
ShadowFBInit(pScreen, refreshArea);
}
- if(pMga->SecondCrtc == TRUE) {
+ if(pMga->SecondCrtc == TRUE && !pMga->MergedFB) {
xf86DPMSInit(pScreen, MGADisplayPowerManagementSetCrtc2, 0);
- } else {
+ }
+ 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->SecondCrtc == TRUE) {
- pScreen->SaveScreen = MGASaveScreenCrtc2;
- } else {
- pScreen->SaveScreen = MGASaveScreen;
+ if(!pMga->MergedFB) {
+ if(pMga->SecondCrtc == TRUE) {
+ pScreen->SaveScreen = MGASaveScreenCrtc2;
+ } else {
+ pScreen->SaveScreen = MGASaveScreen;
+ }
+ } else { /* Merged FB */
+ pScreen->SaveScreen = MGASaveScreenMerged;
}
+
MGAInitVideo(pScreen);
#ifdef XF86DRI
@@ -3283,14 +3437,14 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
/* Now that mi, cfb, drm and others have done their thing,
* complete the DRI setup.
*/
- pMga->directRenderingEnabled = MGADRIFinishScreenInit(pScreen);
+ pMga->directRenderingEnabled = MGADRIFinishScreenInit(pScreen);
}
if (pMga->directRenderingEnabled) {
xf86DrvMsg(pScrn->scrnIndex, driFrom, "Direct rendering enabled\n");
} else {
xf86DrvMsg(pScrn->scrnIndex, driFrom, "Direct rendering disabled\n");
}
- if (xf86IsEntityShared(pScrn->entityList[0]) && pMga->SecondCrtc == FALSE)
+ if (pMga->DualHeadEnabled && pMga->SecondCrtc == FALSE)
pMgaEnt->directRenderingEnabled = pMga->directRenderingEnabled;
pMga->haveQuiescense = 1;
#endif
@@ -3305,7 +3459,7 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
}
/* For the second head, work around display problem. */
- if (pMga->SecondCrtc) {
+ if (!pMga->MergedFB && pMga->SecondCrtc) {
MGACrtc2FillStrip(pScrn);
}
@@ -3318,7 +3472,89 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
Bool
MGASwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
{
- return MGAModeInit(xf86Screens[scrnIndex], mode);
+#ifdef USEMGAHAL
+ char sCmdIn[256];
+ char sCmdOut[256];
+ FILE* fdIn;
+ FILE* fdOut;
+#endif
+ MGAPtr pMga;
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ pMga = MGAPTR(pScrn);
+
+ if (mode->Flags & 0x80000000) {
+#ifdef USEMGAHAL
+ MGA_HAL(
+ fdIn = fopen("/tmp/mgaDriverIn", "rt");
+ fdOut = fopen("/tmp/mgaDriverOut", "wt");
+
+ if(fdIn && fdOut)
+ {
+
+ fgets(sCmdIn, 255, fdIn);
+
+ if(sCmdIn)
+ {
+
+ MGAExecuteEscCmd(xf86Screens[scrnIndex], sCmdIn, sCmdOut, mode);
+
+ /* Remove file and close file descriptor */
+ remove("/tmp/mgaDriverIn");
+ fclose(fdIn);
+
+ /* 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);
+}
+
+ /* 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
}
@@ -3332,38 +3568,54 @@ MGAAdjustFrame(int scrnIndex, int x, int y, int flags)
{
ScrnInfoPtr pScrn;
int Base, tmp, count;
+
MGAFBLayout *pLayout;
MGAPtr pMga;
+
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);
+ );
+#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;
+ }
- 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; /* 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);
+ /* 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));
+ 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));
+ );
}
@@ -3380,19 +3632,26 @@ MGAAdjustFrameCrtc2(int scrnIndex, int x, int y, int flags)
pScrn = xf86Screens[scrnIndex];
pMga = MGAPTR(pScrn);
pLayout = &pMga->CurrentLayout;
-
- 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(C2STARTADD0, Base);
+#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(C2STARTADD0, Base);
+ );
}
/*
@@ -3408,25 +3667,20 @@ MGAEnterVT(int scrnIndex, int flags)
{
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
MGAPtr pMga;
-#ifdef XF86DRI
- ScreenPtr pScreen;
-#endif
pMga = MGAPTR(pScrn);
#ifdef XF86DRI
- if (pMga->directRenderingEnabled) {
- pScreen = screenInfo.screens[scrnIndex];
- DRIUnlock(pScreen);
- }
+ if (pMga->directRenderingEnabled)
+ DRIUnlock(screenInfo.screens[scrnIndex]);
#endif
if (!MGAModeInit(pScrn, pScrn->currentMode))
return FALSE;
- MGAAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+ pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
/* For the second head, work around display problem. */
- if (pMga->SecondCrtc) {
+ if (pMga->SecondCrtc) {
MGACrtc2FillStrip(pScrn);
}
@@ -3513,9 +3767,13 @@ MGACloseScreen(int scrnIndex, ScreenPtr pScreen)
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) {
fbdevHWRestore(pScrn);
@@ -3534,7 +3792,7 @@ MGACloseScreen(int scrnIndex, ScreenPtr pScreen)
}
#endif
- if (xf86IsEntityShared(pScrn->entityList[0])) {
+ if (pMga->DualHeadEnabled) {
DevUnion *pPriv;
pPriv = xf86GetEntityPrivate(pScrn->entityList[0], MGAEntityIndex);
pMgaEnt = pPriv->ptr;
@@ -3543,7 +3801,7 @@ MGACloseScreen(int scrnIndex, ScreenPtr pScreen)
#ifdef USEMGAHAL
MGA_HAL(
- if(xf86IsEntityShared(pScrn->entityList[0])) {
+ if(pMga->DualHeadEnabled) {
if(pMgaEnt->refCount == 0) {
/* Both boards have closed there screen */
MGACloseLibrary(pMga->pBoard);
@@ -3598,6 +3856,7 @@ MGACloseScreen(int scrnIndex, ScreenPtr pScreen)
pScreen->BlockHandler = pMga->BlockHandler;
pScreen->CloseScreen = pMga->CloseScreen;
+
return (*pScreen->CloseScreen)(scrnIndex, pScreen);
}
@@ -3608,6 +3867,7 @@ MGACloseScreen(int scrnIndex, ScreenPtr pScreen)
static void
MGAFreeScreen(int scrnIndex, int flags)
{
+
/*
* This only gets called when a screen is being deleted. It does not
* get called routinely at the end of a server generation.
@@ -3615,6 +3875,7 @@ MGAFreeScreen(int scrnIndex, int flags)
if (xf86LoaderCheckSymbol("vgaHWFreeHWRec"))
vgaHWFreeHWRec(xf86Screens[scrnIndex]);
MGAFreeRec(xf86Screens[scrnIndex]);
+
}
@@ -3681,7 +3942,7 @@ MGASaveScreen(ScreenPtr pScreen, int mode)
*
* Sets VESA Display Power Management Signaling (DPMS) Mode.
*/
-static void
+void
MGADisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode,
int flags)
{
@@ -3721,14 +3982,14 @@ MGADisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode,
}
-static void
+void
MGADisplayPowerManagementSetCrtc2(ScrnInfoPtr pScrn, int PowerManagementMode,
int flags)
{
MGAPtr pMga = MGAPTR(pScrn);
CARD32 crtc2 = 0;
- if (PowerManagementMode != DPMSModeOn)
+ if (PowerManagementMode != DPMSModeOn)
crtc2 = 0x8; /* c2pixclkdis */
crtc2 |= INREG(MGAREG_C2CTL) & ~0x8;
OUTREG(MGAREG_C2CTL, crtc2);
@@ -3884,3 +4145,4 @@ MGAG100BlackMagic(MGAPtr pMga)
OUTREG(MGAREG_MACCESS, 1<<15);
usleep(10);
}
+