From 800579ef040cf5df4a8b09a4a8db6118c3d84980 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 1 Jul 2005 16:21:35 +0000 Subject: Re-write the PInS processing code This patch dumps all of the old BIOS processing code from the MGA DDX. The new code, located in mga_bios.c, is modeled after the code in matroxfb_misc.c (though no actual code was copied). Basically, the BIOS is processed in one place, with "device independent" values stored in a data structure. This data is then used, without extra switch-statments, throughout the driver. In addition, this patch adds support for processing the BIOS on PowerPC systems. On PPC cards, the magic offset values (that give the location of the PInS data) is not in the BIOS. Instead the driver has to search the BIOS for the PInS structure signature. The patch does this and correctly handles byte-ordering (and data alignement) issues. This code has been tested on an AGP G400 on x86 and a PCI G450 on PowerPC. NOTE: The file mga_bios.h is also removed. The "documentation" in that file was moved to the file mga_PInS.txt. This file documents, as much as possible, the layout of the various PInS datastructure versions. The information in that file is 100% based on the old mga_bios.h and the code in matroxfb_misc.c. No additional information from Matrox documentation is included in that file. This just puts the information that was already known in one place. Xorg Bug: 3553 --- src/mga_dga.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'src/mga_dga.c') diff --git a/src/mga_dga.c b/src/mga_dga.c index d6735b1..a08619f 100644 --- a/src/mga_dga.c +++ b/src/mga_dga.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dga.c,v 1.16 2002/09/16 18:05:55 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dga.c,v 1.14 1999/11/02 23:12:00 mvojkovi Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -7,7 +7,6 @@ #include "xf86PciInfo.h" #include "xaa.h" #include "xaalocal.h" -#include "mga_bios.h" #include "mga.h" #include "mga_reg.h" #include "dgaproc.h" @@ -264,6 +263,30 @@ BitsSet(unsigned long data) return set; } +/* + * This is not strictly required - but it will load a 'sane' + * palette when starting DGA. + */ +static void +mgaDGASetPalette(ScrnInfoPtr pScrn) +{ + MGAPtr pMga = MGAPTR(pScrn); + MGARamdacPtr MGAdac = &pMga->Dac; + unsigned char DAC[256*3]; + int i; + + if (!MGAdac->RestorePalette) + return; + + for (i = 0; i < 256; i++) { + DAC[i*3] = i; + DAC[i*3 + 1] = i; + DAC[i*3 + 2] = i; + } + MGAdac->RestorePalette(pScrn, DAC); +} + + static Bool MGA_SetMode( ScrnInfoPtr pScrn, @@ -299,6 +322,8 @@ MGA_SetMode( /* MGAModeInit() will set the mode field */ pScrn->SwitchMode(index, pMode->mode, 0); + /* not strictly required but nice */ + mgaDGASetPalette(pScrn); } return TRUE; -- cgit v1.2.3