8c8ba52c3564ce0c8f949db4a78760752a735caf
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / x11r7 / xdriver_xf86-video-geode / 0001-xserver_1_17.patch
1 Downloaded from upstream commit
2 http://cgit.freedesktop.org/xorg/driver/xf86-video-geode/patch/?id=f98301ad73b84915358ce6f6d2522b36c4b603d9
3
4 Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
5
6
7 From f98301ad73b84915358ce6f6d2522b36c4b603d9 Mon Sep 17 00:00:00 2001
8 From: Maarten Lankhorst <maarten.lankhorst@ubuntu.com>
9 Date: Thu, 12 Mar 2015 10:50:57 +0100
10 Subject: Fix building Geode against xserver 1.17
11
12 The xf86MapVidMem API is gone. Use pciaccess calls where applicable and mmap for XpressROMPtr.
13
14 Signed-off-by: Maarten Lankhorst <maarten.lankhorst@ubuntu.com>
15
16 diff --git a/src/gx_driver.c b/src/gx_driver.c
17 index 7f44e19..ab57df1 100644
18 --- a/src/gx_driver.c
19 +++ b/src/gx_driver.c
20 @@ -32,6 +32,9 @@
21  #endif
22  
23  #include <stdio.h>
24 +#include <fcntl.h>
25 +#include <unistd.h>
26 +#include <sys/mman.h>
27  
28  #include "xf86.h"
29  #include "xf86_OSproc.h"
30 @@ -322,7 +325,6 @@ map_pci_mem(ScrnInfoPtr pScrni, int vram,
31              struct pci_device *dev, int bar, int size)
32  {
33      void *ptr;
34 -    void **result = (void **) &ptr;
35      int map_size = size ? size : dev->regions[bar].size;
36  
37      int err = pci_device_map_range(dev,
38 @@ -330,12 +332,18 @@ map_pci_mem(ScrnInfoPtr pScrni, int vram,
39                                     map_size,
40                                     PCI_DEV_MAP_FLAG_WRITABLE |
41                                     (vram ? PCI_DEV_MAP_FLAG_WRITE_COMBINE : 0),
42 -                                   result);
43 +                                   &ptr);
44  
45      if (err)
46          return NULL;
47      return ptr;
48  }
49 +
50 +static inline int
51 +unmap_pci_mem(ScrnInfoPtr pScrni, struct pci_device *dev, void *ptr, int size)
52 +{
53 +    return pci_device_unmap_range(dev, ptr, size);
54 +}
55  #endif
56  
57  extern unsigned long gfx_gx2_scratch_base;
58 @@ -373,8 +381,19 @@ GXMapMem(ScrnInfoPtr pScrni)
59  
60      gfx_gx2_scratch_base = pGeode->FBAvail - 0x4000;
61  
62 +#ifndef XSERVER_LIBPCIACCESS
63      XpressROMPtr = xf86MapVidMem(index, VIDMEM_FRAMEBUFFER, 0xF0000, 0x10000);
64 -
65 +#else
66 +    {
67 +        int fd = open("/dev/mem", O_RDWR);
68 +        if (fd < 0) {
69 +            xf86DrvMsg(index, X_ERROR, "Failed to open /dev/mem: %m\n");
70 +            return FALSE;
71 +        }
72 +        XpressROMPtr = mmap(NULL, 0x10000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0xF0000);
73 +        close(fd);
74 +    }
75 +#endif
76      pGeode->FBBase = gfx_virt_fbptr;
77  
78      if ((!gfx_virt_regptr) || (!gfx_virt_gpptr) ||
79 @@ -395,9 +414,9 @@ GXMapMem(ScrnInfoPtr pScrni)
80  */
81  
82  static Bool
83 -GXCheckVGA(ScrnInfoPtr pScrni)
84 +GXCheckVGA(ScrnInfoPtr pScrni, EntityInfoPtr pEnt)
85  {
86 -
87 +#ifndef XSERVER_LIBPCIACCESS
88      unsigned char *ptr;
89      const char *vgasig = "IBM VGA Compatible";
90      int ret;
91 @@ -413,6 +432,11 @@ GXCheckVGA(ScrnInfoPtr pScrni)
92      xf86UnMapVidMem(pScrni->scrnIndex, (pointer) ptr, strlen(vgasig));
93  
94      return ret ? FALSE : TRUE;
95 +#else
96 +    pciVideoPtr pci = xf86GetPciInfoForEntity(pEnt->index);
97 +
98 +    return pci_device_is_boot_vga(pci);
99 +#endif
100  }
101  
102  static Bool
103 @@ -443,7 +467,7 @@ GXPreInit(ScrnInfoPtr pScrni, int flags)
104      if (pGeode == NULL)
105          return FALSE;
106  
107 -    useVGA = GXCheckVGA(pScrni);
108 +    useVGA = GXCheckVGA(pScrni, pEnt);
109  
110      if (flags & PROBE_DETECT) {
111          GeodeProbeDDC(pScrni, pEnt->index);
112 @@ -591,12 +615,18 @@ GXPreInit(ScrnInfoPtr pScrni, int flags)
113      panelgeo = xf86GetOptValString(GeodeOptions, GX_OPTION_PANEL_GEOMETRY);
114  
115      if ((s = xf86GetOptValString(GeodeOptions, GX_OPTION_ACCEL_METHOD))) {
116 +#if defined(XF86XAA) && defined(XF86EXA)
117          if (!xf86NameCmp(s, "XAA"))
118              pGeode->useEXA = FALSE;
119          else if (xf86NameCmp(s, "EXA"))
120              xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
121                         "Unknown accleration method %s.  Defaulting to XAA.\n",
122                         s);
123 +#elif defined(XF86EXA)
124 +        pGeode->useEXA = TRUE;
125 +#else
126 +        pGeode->useEXA = FALSE;
127 +#endif
128      }
129  
130      xf86DrvMsg(pScrni->scrnIndex, X_INFO,
131 @@ -752,11 +782,21 @@ GXUnmapMem(ScrnInfoPtr pScrni)
132      GeodeRec *pGeode = GEODEPTR(pScrni);
133  
134      /* unmap all the memory map's */
135 -
136 +#ifndef XSERVER_LIBPCIACCESS
137      xf86UnMapVidMem(pScrni->scrnIndex, gfx_virt_regptr, GX_CPU_REG_SIZE);
138      xf86UnMapVidMem(pScrni->scrnIndex, gfx_virt_gpptr, GX_GP_REG_SIZE);
139      xf86UnMapVidMem(pScrni->scrnIndex, gfx_virt_vidptr, GX_VID_REG_SIZE);
140      xf86UnMapVidMem(pScrni->scrnIndex, gfx_virt_fbptr, pGeode->FBAvail);
141 +#else
142 +    pciVideoPtr pci = xf86GetPciInfoForEntity(pGeode->pEnt->index);
143 +
144 +    unmap_pci_mem(pScrni, pci, gfx_virt_regptr, GX_CPU_REG_SIZE);
145 +    unmap_pci_mem(pScrni, pci, gfx_virt_gpptr, GX_GP_REG_SIZE);
146 +    unmap_pci_mem(pScrni, pci, gfx_virt_vidptr, GX_VID_REG_SIZE);
147 +    unmap_pci_mem(pScrni, pci, gfx_virt_fbptr, pGeode->FBAvail);
148 +
149 +    munmap(XpressROMPtr, 0x10000);
150 +#endif
151      return TRUE;
152  }
153  
154 diff --git a/src/lx_driver.c b/src/lx_driver.c
155 index 146578e..c68f715 100644
156 --- a/src/lx_driver.c
157 +++ b/src/lx_driver.c
158 @@ -33,6 +33,9 @@
159  
160  #include <stdio.h>
161  #include <string.h>
162 +#include <fcntl.h>
163 +#include <unistd.h>
164 +#include <sys/mman.h>
165  
166  #include "xf86.h"
167  #include "xf86_OSproc.h"
168 @@ -155,7 +158,6 @@ map_pci_mem(ScrnInfoPtr pScrni, int vram,
169              struct pci_device *dev, int bar, int size)
170  {
171      void *ptr;
172 -    void **result = (void **) &ptr;
173      int map_size = size ? size : dev->regions[bar].size;
174  
175      int err = pci_device_map_range(dev,
176 @@ -163,7 +165,7 @@ map_pci_mem(ScrnInfoPtr pScrni, int vram,
177                                     map_size,
178                                     PCI_DEV_MAP_FLAG_WRITABLE |
179                                     (vram ? PCI_DEV_MAP_FLAG_WRITE_COMBINE : 0),
180 -                                   result);
181 +                                   &ptr);
182  
183      if (err)
184          return NULL;
185 @@ -235,7 +237,19 @@ LXMapMem(ScrnInfoPtr pScrni)
186                               pGeode->FBAvail);
187      gp_set_command_buffer_base(cmd_bfr_phys, 0, pGeode->CmdBfrSize);
188  
189 +#ifndef XSERVER_LIBPCIACCESS
190      XpressROMPtr = xf86MapVidMem(index, VIDMEM_FRAMEBUFFER, 0xF0000, 0x10000);
191 +#else
192 +    {
193 +        int fd = open("/dev/mem", O_RDWR);
194 +        if (fd < 0) {
195 +            xf86DrvMsg(index, X_ERROR, "Failed to open /dev/mem: %m\n");
196 +            return FALSE;
197 +        }
198 +        XpressROMPtr = mmap(NULL, 0x10000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0xF0000);
199 +        close(fd);
200 +    }
201 +#endif
202  
203      pGeode->FBBase = cim_fb_ptr;
204  
205 @@ -253,9 +267,9 @@ LXMapMem(ScrnInfoPtr pScrni)
206  */
207  
208  static Bool
209 -LXCheckVGA(ScrnInfoPtr pScrni)
210 +LXCheckVGA(ScrnInfoPtr pScrni, EntityInfoPtr pEnt)
211  {
212 -
213 +#ifndef XSERVER_LIBPCIACCESS
214      unsigned char *ptr;
215      const char *vgasig = "IBM VGA Compatible";
216      int ret;
217 @@ -271,6 +285,11 @@ LXCheckVGA(ScrnInfoPtr pScrni)
218      xf86UnMapVidMem(pScrni->scrnIndex, (pointer) ptr, strlen(vgasig));
219  
220      return ret ? FALSE : TRUE;
221 +#else
222 +    pciVideoPtr pci = xf86GetPciInfoForEntity(pEnt->index);
223 +
224 +    return pci_device_is_boot_vga(pci);
225 +#endif
226  }
227  
228  static Bool
229 @@ -310,7 +329,7 @@ LXPreInit(ScrnInfoPtr pScrni, int flags)
230      if (pGeode == NULL)
231          return FALSE;
232  
233 -    pGeode->useVGA = LXCheckVGA(pScrni);
234 +    pGeode->useVGA = LXCheckVGA(pScrni, pEnt);
235      pGeode->VGAActive = FALSE;
236      pGeode->pEnt = pEnt;
237  
238 @@ -611,6 +630,8 @@ LXUnmapMem(ScrnInfoPtr pScrni)
239      xf86UnMapVidMem(pScrni->scrnIndex, (pointer) cim_vg_ptr, LX_VG_REG_SIZE);
240      xf86UnMapVidMem(pScrni->scrnIndex, (pointer) cim_vid_ptr, LX_VID_REG_SIZE);
241      xf86UnMapVidMem(pScrni->scrnIndex, (pointer) cim_vip_ptr, LX_VIP_REG_SIZE);
242 +
243 +    xf86UnMapVidMem(pScrni->scrnIndex, XpressROMPtr, 0x10000);
244  #else
245      GeodeRec *pGeode = GEODEPTR(pScrni);
246      pciVideoPtr pci = xf86GetPciInfoForEntity(pGeode->pEnt->index);
247 @@ -620,9 +641,9 @@ LXUnmapMem(ScrnInfoPtr pScrni)
248      unmap_pci_mem(pScrni, pci, cim_vid_ptr, LX_VID_REG_SIZE);
249      unmap_pci_mem(pScrni, pci, cim_vip_ptr, LX_VIP_REG_SIZE);
250      unmap_pci_mem(pScrni, pci, cim_fb_ptr, pGeode->FBAvail + CIM_CMD_BFR_SZ);
251 -#endif
252  
253 -    xf86UnMapVidMem(pScrni->scrnIndex, XpressROMPtr, 0x10000);
254 +    munmap(XpressROMPtr, 0x10000);
255 +#endif
256  
257      return TRUE;
258  }
259 -- 
260 cgit v0.10.2
261