Subject: Re: XFree86 on 164SX with matrox G200
To: None <port-alpha@NetBSD.org>
From: Eike Dehling <e.e.dehling@student.utwente.nl>
List: port-alpha
Date: 06/14/2005 00:37:14
This is a multi-part message in MIME format.
--------------080106050109020803060509
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Eike Dehling wrote:
> With a small change to the mga driver i got a Matrox G200 working on my 
> 164SX, i needed to comment lines 716, 717 in mga_driver.c in the 
> function MGAReadBios(), where it reads the original video mode. Works 
> very nice after that change.

See attached tiny patch for a clean fix. It works like a charm on my 
alpha, i haven't had the opportunity to test on x86 yet. But it's very 
small and simple, so i see no problems.

I wonder why it was implemented in the original way anyways; for some 
reads from the bios the code checks how to do the read, and for some it 
doesn't. While it obviously should, since it crashes otherwise.

Eike.

PS: I have send-pr'd the bug (Bug #30520) with the patch attached.

--------------080106050109020803060509
Content-Type: text/x-patch;
 name="mga_driver.c.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="mga_driver.c.patch"

--- xfree/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c	2005-06-14 00:16:15.000000000 +0200
+++ /root/mga_driver.c	2005-06-14 00:19:46.000000000 +0200
@@ -711,9 +711,6 @@
 	pBios = &pMga->Bios;
 	pBios2 = &pMga->Bios2;
         
-	/* Get the output mode set by the BIOS */
-	xf86ReadDomainMemory(pMga->PciTag, pMga->BiosAddress + 0x7ff1u,
-			     sizeof(CARD8), &pMga->BiosOutputMode); 
 
 	/*
 	 * If the BIOS address was probed, it was found from the PCI config
@@ -725,6 +722,14 @@
 	else if (pMga->BiosFrom == X_CONFIG && pMga->BiosAddress < 0x100000)
 	    pciBIOS = TRUE;
 
+	/* Get the output mode set by the BIOS */
+	if (pciBIOS)
+	    xf86ReadPciBIOS(0, pMga->PciTag, pMga->FbBaseReg + 0x7ff1u,
+			&pMga->BiosOutputMode, sizeof(CARD8));
+	else
+		xf86ReadDomainMemory(pMga->PciTag, pMga->BiosAddress +
+			0x7ff1u, sizeof(CARD8), &pMga->BiosOutputMode); 
+
 	if (pciBIOS)
 	    rlen = xf86ReadPciBIOS(0, pMga->PciTag, pMga->FbBaseReg,
 				   BIOS, sizeof(BIOS));

--------------080106050109020803060509--