summaryrefslogtreecommitdiff
path: root/testing/xf86-video-ark/git-fixes.patch
blob: 2de0f64be489976e678f7bbe8c72249de7d1a108 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
From 9d3769bed020e9796e51411c63de337da5073bb4 Mon Sep 17 00:00:00 2001
From: Ondrej Zary <linux@rainbow-software.org>
Date: Sat, 04 Dec 2010 00:23:51 +0000
Subject: Don't assume that FB address registers are initialized properly

https://bugs.freedesktop.org/show_bug.cgi?id=28249

ark driver does not work with Hercules Stingray 64 card (ark2000pv).
X fails to start with:

[...]
(II) ark(0): vgaHWGetIOBase: hwp->IOBase is 0x03d0, hwp->PIOOffset is
0x0000
(II) ark(0): Creating default Display subsection in Screen section
        "Default Screen Section" for depth/fbbpp 24/32
(==) ark(0): Depth 24, (--) framebuffer bpp 32
(==) ark(0): RGB weight 888
(==) ark(0): Default visual is TrueColor
(**) ark(0): Chipset: "ark2000pv"
(--) ark(0): Framebuffer @ 0xe5e50000
(==) ark(0): Using gamma correction (1.0, 1.0, 1.0)
(--) ark(0): Detected 2048 bytes video ram
[...]
Fatal server error:
AddScreen/ScreenInit failed for driver 0

Comparing with lspci, the framebuffer address is wrong:
00:0f.0 VGA compatible controller: ARK Logic Inc 2000PV [Stingray] (prog-if 00 [VGA controller])
	Flags: medium devsel
	Memory at e5000000 (32-bit, prefetchable) [size=4M]
	[virtual] Expansion ROM at 1c000000 [disabled] [size=64K]

Reviewed-by: Adam Jackson <ajax@redhat.com>
---
diff --git a/src/ark.h b/src/ark.h
index de301dc..077f93b 100644
--- a/src/ark.h
+++ b/src/ark.h
@@ -34,7 +34,6 @@ typedef struct _ARKRec {
 #endif
 	EntityInfoPtr		pEnt;
 	CARD32			IOAddress;
-	CARD32			FBAddress;
 	unsigned char *		FBBase;
 	unsigned char *		MMIOBase;
 	unsigned long		videoRam;
diff --git a/src/ark_driver.c b/src/ark_driver.c
index 5de3b9a..fec3e1a 100644
--- a/src/ark_driver.c
+++ b/src/ark_driver.c
@@ -363,14 +363,14 @@ static Bool ARKPreInit(ScrnInfoPtr pScrn, int flags)
 	outb(hwp->PIOOffset + hwp->IOBase + 5, tmp & 0x7f);
 	modinx(hwp->PIOOffset + 0x3c4, 0x1d, 0x01, 0x01);
 
-	/* use membase's later on ??? */
-	pARK->FBAddress = (rdinx(hwp->PIOOffset + 0x3c4, 0x13) << 16) +
-			  (rdinx(hwp->PIOOffset + 0x3c4, 0x14) << 24);
-
-	pScrn->memPhysBase = pARK->FBAddress;
+#ifndef XSERVER_LIBPCIACCESS
+	pScrn->memPhysBase = pARK->PciInfo->memBase[0];
+#else
+	pScrn->memPhysBase = pARK->PciInfo->regions[0].base_addr;
+#endif
 
 	xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Framebuffer @ 0x%lx\n",
-		   (unsigned long)pARK->FBAddress);
+		   (unsigned long)pScrn->memPhysBase);
 
 	if (!xf86SetGamma(pScrn, gzeros))
 		return FALSE;
@@ -748,8 +748,13 @@ static Bool ARKModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
 	new->sr10 = rdinx(isaIOBase + 0x3c4, 0x10) & ~0x1f;
 	new->sr10 |= 0x1f;
 
-	new->sr13 = pARK->FBAddress >> 16;
-	new->sr14 = pARK->FBAddress >> 24;
+#ifndef XSERVER_LIBPCIACCESS
+	new->sr13 = pARK->PciInfo->memBase[0] >> 16;
+	new->sr14 = pARK->PciInfo->memBase[0] >> 24;
+#else
+	new->sr13 = pARK->PciInfo->regions[0].base_addr >> 16;
+	new->sr14 = pARK->PciInfo->regions[0].base_addr >> 24;
+#endif
 
 	new->sr12 = rdinx(isaIOBase + 0x3c4, 0x12) & ~0x03;
 	switch (pScrn->videoRam) {
@@ -1022,7 +1027,7 @@ static Bool ARKMapMem(ScrnInfoPtr pScrn)
 					     pARK->PciTag, 0xb8000, 0x8000);
 
 	pARK->FBBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER,
-				     pARK->PciTag, pARK->FBAddress,
+				     pARK->PciTag, pARK->PciInfo->memBase[0],
 				     pScrn->videoRam * 1024);
 #else
 
@@ -1032,14 +1037,17 @@ static Bool ARKMapMem(ScrnInfoPtr pScrn)
 	{
 		void** result = (void**)&pARK->FBBase;
 		int err = pci_device_map_range(pARK->PciInfo,
-					       pARK->FBAddress,
+					       pARK->PciInfo->regions[0].base_addr,
 					       pScrn->videoRam * 1024,
 					       PCI_DEV_MAP_FLAG_WRITABLE |
 					       PCI_DEV_MAP_FLAG_WRITE_COMBINE,
 					       result);
 		
-		if (err) 
+		if (err) {
+			xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+			   "Cound not map framebuffer: %d\n", err);
 			return FALSE;
+		}
 	}
 #endif
 
--
cgit v0.9.0.2-2-gbebe