Added
Link Here
|
1 |
--- src/mga_driver.c.orig 2007-11-02 23:07:21.000000000 +0300 |
2 |
+++ src/mga_driver.c 2007-11-02 23:08:19.000000000 +0300 |
3 |
@@ -2775,30 +2775,31 @@ |
4 |
MGAPtr pMga = MGAPTR(pScrn); |
5 |
#ifdef XSERVER_LIBPCIACCESS |
6 |
struct pci_device *const dev = pMga->PciInfo; |
7 |
- int err; |
8 |
+ struct pci_mem_region *region; |
9 |
+ void **memory[2]; |
10 |
+ int i, err; |
11 |
#endif |
12 |
|
13 |
|
14 |
if (!pMga->FBDev) { |
15 |
#ifdef XSERVER_LIBPCIACCESS |
16 |
- err = pci_device_map_region(dev, 0, TRUE); |
17 |
- if (err) { |
18 |
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
19 |
- "Unable to map BAR 0. %s (%d)\n", |
20 |
- strerror(err), err); |
21 |
- return FALSE; |
22 |
- } |
23 |
+ memory[pMga->io_bar] = &pMga->IOBase; |
24 |
+ memory[pMga->framebuffer_bar] = &pMga->FbBase; |
25 |
|
26 |
- err = pci_device_map_region(dev, 1, TRUE); |
27 |
- if (err) { |
28 |
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
29 |
- "Unable to map BAR 1. %s (%d)\n", |
30 |
- strerror(err), err); |
31 |
- return FALSE; |
32 |
- } |
33 |
+ for (i = 0; i < 2; i++) { |
34 |
+ region = &dev->regions[i]; |
35 |
+ err = pci_device_map_range(dev, |
36 |
+ region->base_addr, region->size, |
37 |
+ PCI_DEV_MAP_FLAG_WRITABLE, |
38 |
+ memory[i]); |
39 |
|
40 |
- pMga->IOBase = dev->regions[ pMga->io_bar ].memory; |
41 |
- pMga->FbBase = dev->regions[ pMga->framebuffer_bar ].memory; |
42 |
+ if (err) { |
43 |
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
44 |
+ "Unable to map BAR %i. %s (%d)\n", |
45 |
+ i, strerror(err), err); |
46 |
+ return FALSE; |
47 |
+ } |
48 |
+ } |
49 |
#else |
50 |
/* |
51 |
* For Alpha, we need to map SPARSE memory, since we need |
52 |
@@ -2839,15 +2840,17 @@ |
53 |
pMga->ILOADBase = NULL; |
54 |
if (pMga->iload_bar != -1) { |
55 |
#ifdef XSERVER_LIBPCIACCESS |
56 |
- err = pci_device_map_region(dev, pMga->iload_bar, TRUE); |
57 |
+ region = &dev->regions[pMga->iload_bar]; |
58 |
+ err = pci_device_map_range(dev, |
59 |
+ region->base_addr, region->size, |
60 |
+ PCI_DEV_MAP_FLAG_WRITABLE, |
61 |
+ (void *) &pMga->ILOADBase); |
62 |
if (err) { |
63 |
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
64 |
"Unable to map BAR 2 (ILOAD region). %s (%d)\n", |
65 |
strerror(err), err); |
66 |
return FALSE; |
67 |
} |
68 |
- |
69 |
- pMga->ILOADBase = dev->regions[pMga->iload_bar].memory; |
70 |
#else |
71 |
pMga->ILOADBase = xf86MapPciMem(pScrn->scrnIndex, |
72 |
VIDMEM_MMIO | VIDMEM_MMIO_32BIT | |
73 |
@@ -2877,8 +2880,10 @@ |
74 |
|
75 |
if (!pMga->FBDev) { |
76 |
#ifdef XSERVER_LIBPCIACCESS |
77 |
- pci_device_unmap_region(dev, 0); |
78 |
- pci_device_unmap_region(dev, 1); |
79 |
+ pci_device_unmap_range(dev, pMga->IOBase, |
80 |
+ dev->regions[pMga->io_bar].size); |
81 |
+ pci_device_unmap_range(dev, pMga->FbBase, |
82 |
+ dev->regions[pMga->framebuffer_bar].size); |
83 |
#else |
84 |
xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pMga->IOBase, 0x4000); |
85 |
xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pMga->FbBase, pMga->FbMapSize); |
86 |
@@ -2889,15 +2894,10 @@ |
87 |
fbdevHWUnmapMMIO(pScrn); |
88 |
} |
89 |
|
90 |
- if ((pMga->iload_bar != -1) |
91 |
-#ifdef XSERVER_LIBPCIACCESS |
92 |
- && (dev->regions[pMga->iload_bar].memory != NULL) |
93 |
-#else |
94 |
- && (pMga->ILOADBase != NULL) |
95 |
-#endif |
96 |
- ) { |
97 |
+ if ((pMga->iload_bar != -1) && (pMga->ILOADBase != NULL)) { |
98 |
#ifdef XSERVER_LIBPCIACCESS |
99 |
- pci_device_unmap_region(dev, pMga->iload_bar); |
100 |
+ pci_device_unmap_range(dev, pMga->ILOADBase, |
101 |
+ dev->regions[pMga->iload_bar].size); |
102 |
#else |
103 |
xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pMga->ILOADBase, 0x800000); |
104 |
#endif |