summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <idr@us.ibm.com>2007-02-02 15:50:14 -0800
committerIan Romanick <idr@us.ibm.com>2007-02-02 15:50:14 -0800
commit741c50c162986a14647301c2c5f8e080a7664efd (patch)
treeccaf5818ceb0db906df8e516813cf08c8fdb9242
parent4432091b2597cf4bba09009622d247c0d8ff151f (diff)
Code refactoring in MGAScreenInit.
Rearrange code so that functions that are selected based on MergedFB and SecondCrtc are selected in one place instead of 3. Rearrange some code that selects on FBDev and Primary to flow a little better.
-rw-r--r--src/mga_driver.c84
1 files changed, 42 insertions, 42 deletions
diff --git a/src/mga_driver.c b/src/mga_driver.c
index 4f86b9c..866e46a 100644
--- a/src/mga_driver.c
+++ b/src/mga_driver.c
@@ -2956,6 +2956,7 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
#ifdef XF86DRI
MessageType driFrom = X_DEFAULT;
#endif
+ DPMSSetProcPtr mga_dpms_set_proc = NULL;
/*
* First get the ScrnInfoRec
@@ -2973,10 +2974,31 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
pMga->FbMapSize = pScrn->videoRam * 1024;
}
+
/* Map the MGA memory and MMIO areas */
if (!MGAMapMem(pScrn))
return FALSE;
-
+
+
+ /* Select functions that vary based on the CRTC configureation of the
+ * screen.
+ */
+ if (!pMga->MergedFB) {
+ if (pMga->SecondCrtc) {
+ mga_dpms_set_proc = MGADisplayPowerManagementSetCrtc2;
+ pScreen->SaveScreen = MGASaveScreenCrtc2;
+ }
+ else {
+ mga_dpms_set_proc = MGADisplayPowerManagementSet;
+ pScreen->SaveScreen = MGASaveScreen;
+ }
+ }
+ else {
+ pScreen->SaveScreen = MGASaveScreenMerged;
+ mga_dpms_set_proc = MGADisplayPowerManagementSetMerged;
+ }
+
+
if ((pMga->Chipset == PCI_CHIP_MGAG100)
|| (pMga->Chipset == PCI_CHIP_MGAG100_PCI))
MGAG100BlackMagic(pScrn);
@@ -3067,13 +3089,20 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
vgaHWGetIOBase(hwp);
/* Map the VGA memory when the primary video */
- if (pMga->Primary && !pMga->FBDev) {
- hwp->MapSize = 0x10000;
- if (!vgaHWMapMem(pScrn))
+ if (!pMga->FBDev) {
+ if (pMga->Primary) {
+ hwp->MapSize = 0x10000;
+ if (!vgaHWMapMem(pScrn))
+ return FALSE;
+ }
+
+ /* Save the current state */
+ MGASave(pScrn);
+ /* Initialise the first mode */
+ if (!MGAModeInit(pScrn, pScrn->currentMode))
return FALSE;
}
-
- if (pMga->FBDev) {
+ else {
fbdevHWSave(pScrn);
/* Disable VGA core, and leave memory access on */
pci_device_cfg_write_bits(pMga->PciInfo, 0x00000100, 0x00000000,
@@ -3088,25 +3117,14 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
}
MGAStormEngineInit(pScrn);
- } else {
- /* 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 );
}
+
+ /* Darken the screen for aesthetic reasons and set the viewport
+ */
+ (*pScreen->SaveScreen)(pScreen, SCREEN_SAVER_ON);
pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+
/*
* The next step is to setup the screen's visuals, and initialise the
* framebuffer code. In cases where the framebuffer's default
@@ -3343,29 +3361,11 @@ 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);
- }
-
+ xf86DPMSInit(pScreen, mga_dpms_set_proc, 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;
- }
-
MGAInitVideo(pScreen);
#ifdef XF86DRI