[PATCH -cirrus] Add a check for max_pitch values for GD5446 / FAUmachine

Bryce Harrington bryce at canonical.com
Fri Jan 14 14:50:45 PST 2011


The GD 5446 uses 9 bits to store the pitch value, which then get shifted
by 3 bits to the left in the graphic card. For the resolution of
1360x768 however, X sets the pitch to 1408, which hence results in an
actual used pitch by the card of 128. As a result the screen is garbled.

GD 5446 with 4mb is pretty rare hardware but is simulated by FAUmachine.

Patch originally provided to Ubuntu by Stefan Potyra.
Recently integrated into Debian by KiBi.

Signed-off-by: Bryce Harrington <bryce at canonical.com>
---
 src/alp_driver.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/src/alp_driver.c b/src/alp_driver.c
index b72dfeb..60ba6b4 100644
--- a/src/alp_driver.c
+++ b/src/alp_driver.c
@@ -406,6 +406,7 @@ GetAccelPitchValues(ScrnInfoPtr pScrn)
 	int *linePitches = NULL;
 	int i, n = 0;
 	CirPtr pCir = CIRPTR(pScrn);
+	int max_pitch = 2048;
 
 	/* XXX ajv - 512, 576, and 1536 may not be supported
 	   line pitches. see sdk pp 4-59 for more
@@ -421,8 +422,20 @@ GetAccelPitchValues(ScrnInfoPtr pScrn)
 							1280, 1536, 1600, 1920, 2048, 0 };
 #endif
 
+	switch (pCir->Chipset) {
+	case PCI_CHIP_GD5446:
+		max_pitch = 0x1ff << 3;
+		break;
+
+	default:
+		/* FIXME max_pitch for other chipsets? */
+		max_pitch = (pScrn->bitsPerPixel / 8) * 2048;
+		break;
+	}
+
 	for (i = 0; accelWidths[i] != 0; i++) {
-		if (accelWidths[i] % pCir->Rounding == 0) {
+		if ((accelWidths[i] % pCir->Rounding == 0) &&
+		   ((accelWidths[i] * pScrn->bitsPerPixel / 8) <= max_pitch)){
 			n++;
 			linePitches = xnfrealloc(linePitches, n * sizeof(int));
 			linePitches[n - 1] = accelWidths[i];
-- 
1.7.1



More information about the xorg-devel mailing list