Mercurial > sdl-ios-xcode
comparison src/video/Xext/Xxf86dga/XF86DGA2.c @ 1668:4da1ee79c9af SDL-1.3
more tweaking indent options
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 29 May 2006 04:04:35 +0000 |
parents | 782fd950bd46 |
children |
comparison
equal
deleted
inserted
replaced
1667:1fddae038bc8 | 1668:4da1ee79c9af |
---|---|
30 #endif | 30 #endif |
31 | 31 |
32 /* If you change this, change the Bases[] array below as well */ | 32 /* If you change this, change the Bases[] array below as well */ |
33 #define MAX_HEADS 16 | 33 #define MAX_HEADS 16 |
34 | 34 |
35 char *SDL_NAME (xdga_extension_name) = XF86DGANAME; | 35 char *SDL_NAME(xdga_extension_name) = XF86DGANAME; |
36 | 36 |
37 static XExtensionInfo _xdga_info_data; | 37 static XExtensionInfo _xdga_info_data; |
38 static XExtensionInfo *xdga_info = &_xdga_info_data; | 38 static XExtensionInfo *xdga_info = &_xdga_info_data; |
39 | 39 |
40 | 40 |
41 Bool SDL_NAME (XDGAMapFramebuffer) (int, char *, unsigned char *, CARD32, | 41 Bool SDL_NAME(XDGAMapFramebuffer) (int, char *, unsigned char *, CARD32, |
42 CARD32, CARD32); | 42 CARD32, CARD32); |
43 void SDL_NAME (XDGAUnmapFramebuffer) (int); | 43 void SDL_NAME(XDGAUnmapFramebuffer) (int); |
44 unsigned char *SDL_NAME (XDGAGetMappedMemory) (int); | 44 unsigned char *SDL_NAME(XDGAGetMappedMemory) (int); |
45 | 45 |
46 #define XDGACheckExtension(dpy,i,val) \ | 46 #define XDGACheckExtension(dpy,i,val) \ |
47 XextCheckExtension (dpy, i, SDL_NAME(xdga_extension_name), val) | 47 XextCheckExtension (dpy, i, SDL_NAME(xdga_extension_name), val) |
48 | 48 |
49 /***************************************************************************** | 49 /***************************************************************************** |
50 * * | 50 * * |
51 * private utility routines * | 51 * private utility routines * |
52 * * | 52 * * |
53 *****************************************************************************/ | 53 *****************************************************************************/ |
54 | 54 |
55 static int xdga_close_display (Display * dpy, XExtCodes * codes); | 55 static int xdga_close_display(Display * dpy, XExtCodes * codes); |
56 static Bool xdga_wire_to_event (Display * dpy, XEvent * event, | 56 static Bool xdga_wire_to_event(Display * dpy, XEvent * event, |
57 xEvent * wire_ev); | 57 xEvent * wire_ev); |
58 static Status xdga_event_to_wire (Display * dpy, XEvent * event, | 58 static Status xdga_event_to_wire(Display * dpy, XEvent * event, |
59 xEvent * wire_ev); | 59 xEvent * wire_ev); |
60 | 60 |
61 static XExtensionHooks xdga_extension_hooks = { | 61 static XExtensionHooks xdga_extension_hooks = { |
62 NULL, /* create_gc */ | 62 NULL, /* create_gc */ |
63 NULL, /* copy_gc */ | 63 NULL, /* copy_gc */ |
64 NULL, /* flush_gc */ | 64 NULL, /* flush_gc */ |
71 NULL, /* error */ | 71 NULL, /* error */ |
72 NULL, /* error_string */ | 72 NULL, /* error_string */ |
73 }; | 73 }; |
74 | 74 |
75 static | 75 static |
76 XEXT_GENERATE_CLOSE_DISPLAY (xdga_close_display, xdga_info) | 76 XEXT_GENERATE_CLOSE_DISPLAY(xdga_close_display, xdga_info) |
77 XEXT_GENERATE_FIND_DISPLAY (SDL_NAME (xdga_find_display), xdga_info, | 77 XEXT_GENERATE_FIND_DISPLAY(SDL_NAME(xdga_find_display), xdga_info, |
78 "XFree86-DGA", &xdga_extension_hooks, 0, NULL) | 78 "XFree86-DGA", &xdga_extension_hooks, 0, NULL) |
79 static Status | 79 static Status |
80 xdga_event_to_wire (Display * dpy, XEvent * event, xEvent * wire_ev) | 80 xdga_event_to_wire(Display * dpy, XEvent * event, xEvent * wire_ev) |
81 { | 81 { |
82 return True; | 82 return True; |
83 } | 83 } |
84 | 84 |
85 static Bool | 85 static Bool |
86 xdga_wire_to_event (Display * dpy, XEvent * event, xEvent * wire_ev) | 86 xdga_wire_to_event(Display * dpy, XEvent * event, xEvent * wire_ev) |
87 { | 87 { |
88 dgaEvent *wire = (dgaEvent *) wire_ev; | 88 dgaEvent *wire = (dgaEvent *) wire_ev; |
89 SDL_NAME (XDGAButtonEvent) * bevent; | 89 SDL_NAME(XDGAButtonEvent) * bevent; |
90 SDL_NAME (XDGAKeyEvent) * kevent; | 90 SDL_NAME(XDGAKeyEvent) * kevent; |
91 SDL_NAME (XDGAMotionEvent) * mevent; | 91 SDL_NAME(XDGAMotionEvent) * mevent; |
92 XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); | 92 XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); |
93 | 93 |
94 XDGACheckExtension (dpy, info, False); | 94 XDGACheckExtension(dpy, info, False); |
95 | 95 |
96 switch ((wire->u.u.type & 0x7f) - info->codes->first_event) { | 96 switch ((wire->u.u.type & 0x7f) - info->codes->first_event) { |
97 case MotionNotify: | 97 case MotionNotify: |
98 mevent = (SDL_NAME (XDGAMotionEvent) *) event; | 98 mevent = (SDL_NAME(XDGAMotionEvent) *) event; |
99 mevent->type = wire->u.u.type & 0x7F; | 99 mevent->type = wire->u.u.type & 0x7F; |
100 mevent->serial = _XSetLastRequestRead (dpy, (xGenericReply *) wire); | 100 mevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire); |
101 mevent->display = dpy; | 101 mevent->display = dpy; |
102 mevent->screen = wire->u.event.screen; | 102 mevent->screen = wire->u.event.screen; |
103 mevent->time = wire->u.event.time; | 103 mevent->time = wire->u.event.time; |
104 mevent->state = wire->u.event.state; | 104 mevent->state = wire->u.event.state; |
105 mevent->dx = wire->u.event.dx; | 105 mevent->dx = wire->u.event.dx; |
106 mevent->dy = wire->u.event.dy; | 106 mevent->dy = wire->u.event.dy; |
107 return True; | 107 return True; |
108 case ButtonPress: | 108 case ButtonPress: |
109 case ButtonRelease: | 109 case ButtonRelease: |
110 bevent = (SDL_NAME (XDGAButtonEvent) *) event; | 110 bevent = (SDL_NAME(XDGAButtonEvent) *) event; |
111 bevent->type = wire->u.u.type & 0x7F; | 111 bevent->type = wire->u.u.type & 0x7F; |
112 bevent->serial = _XSetLastRequestRead (dpy, (xGenericReply *) wire); | 112 bevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire); |
113 bevent->display = dpy; | 113 bevent->display = dpy; |
114 bevent->screen = wire->u.event.screen; | 114 bevent->screen = wire->u.event.screen; |
115 bevent->time = wire->u.event.time; | 115 bevent->time = wire->u.event.time; |
116 bevent->state = wire->u.event.state; | 116 bevent->state = wire->u.event.state; |
117 bevent->button = wire->u.u.detail; | 117 bevent->button = wire->u.u.detail; |
118 return True; | 118 return True; |
119 case KeyPress: | 119 case KeyPress: |
120 case KeyRelease: | 120 case KeyRelease: |
121 kevent = (SDL_NAME (XDGAKeyEvent) *) event; | 121 kevent = (SDL_NAME(XDGAKeyEvent) *) event; |
122 kevent->type = wire->u.u.type & 0x7F; | 122 kevent->type = wire->u.u.type & 0x7F; |
123 kevent->serial = _XSetLastRequestRead (dpy, (xGenericReply *) wire); | 123 kevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire); |
124 kevent->display = dpy; | 124 kevent->display = dpy; |
125 kevent->screen = wire->u.event.screen; | 125 kevent->screen = wire->u.event.screen; |
126 kevent->time = wire->u.event.time; | 126 kevent->time = wire->u.event.time; |
127 kevent->state = wire->u.event.state; | 127 kevent->state = wire->u.event.state; |
128 kevent->keycode = wire->u.u.detail; | 128 kevent->keycode = wire->u.u.detail; |
131 | 131 |
132 return False; | 132 return False; |
133 } | 133 } |
134 | 134 |
135 | 135 |
136 Bool SDL_NAME (XDGAQueryExtension) (Display * dpy, | 136 Bool SDL_NAME(XDGAQueryExtension) (Display * dpy, |
137 int *event_basep, int *error_basep) | 137 int *event_basep, int *error_basep) |
138 { | 138 { |
139 XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); | 139 XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); |
140 | 140 |
141 if (XextHasExtension (info)) { | 141 if (XextHasExtension(info)) { |
142 *event_basep = info->codes->first_event; | 142 *event_basep = info->codes->first_event; |
143 *error_basep = info->codes->first_error; | 143 *error_basep = info->codes->first_error; |
144 return True; | 144 return True; |
145 } else { | 145 } else { |
146 return False; | 146 return False; |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 | 150 |
151 Bool SDL_NAME (XDGAQueryVersion) (Display * dpy, | 151 Bool SDL_NAME(XDGAQueryVersion) (Display * dpy, |
152 int *majorVersion, int *minorVersion) | 152 int *majorVersion, int *minorVersion) |
153 { | 153 { |
154 XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); | 154 XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); |
155 xXDGAQueryVersionReply rep; | 155 xXDGAQueryVersionReply rep; |
156 xXDGAQueryVersionReq *req; | 156 xXDGAQueryVersionReq *req; |
157 | 157 |
158 XDGACheckExtension (dpy, info, False); | 158 XDGACheckExtension(dpy, info, False); |
159 | 159 |
160 LockDisplay (dpy); | 160 LockDisplay(dpy); |
161 GetReq (XDGAQueryVersion, req); | 161 GetReq(XDGAQueryVersion, req); |
162 req->reqType = info->codes->major_opcode; | 162 req->reqType = info->codes->major_opcode; |
163 req->dgaReqType = X_XDGAQueryVersion; | 163 req->dgaReqType = X_XDGAQueryVersion; |
164 if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) { | 164 if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { |
165 UnlockDisplay (dpy); | 165 UnlockDisplay(dpy); |
166 SyncHandle (); | 166 SyncHandle(); |
167 return False; | 167 return False; |
168 } | 168 } |
169 *majorVersion = rep.majorVersion; | 169 *majorVersion = rep.majorVersion; |
170 *minorVersion = rep.minorVersion; | 170 *minorVersion = rep.minorVersion; |
171 UnlockDisplay (dpy); | 171 UnlockDisplay(dpy); |
172 SyncHandle (); | 172 SyncHandle(); |
173 if (*majorVersion >= 2) { | 173 if (*majorVersion >= 2) { |
174 int i, j; | 174 int i, j; |
175 | 175 |
176 for (i = 0, j = info->codes->first_event; | 176 for (i = 0, j = info->codes->first_event; |
177 i < XF86DGANumberEvents; i++, j++) { | 177 i < XF86DGANumberEvents; i++, j++) { |
178 XESetWireToEvent (dpy, j, xdga_wire_to_event); | 178 XESetWireToEvent(dpy, j, xdga_wire_to_event); |
179 XESetEventToWire (dpy, j, xdga_event_to_wire); | 179 XESetEventToWire(dpy, j, xdga_event_to_wire); |
180 } | 180 } |
181 SDL_NAME (XDGASetClientVersion) (dpy); | 181 SDL_NAME(XDGASetClientVersion) (dpy); |
182 } | 182 } |
183 return True; | 183 return True; |
184 } | 184 } |
185 | 185 |
186 Bool SDL_NAME (XDGASetClientVersion) (Display * dpy) | 186 Bool SDL_NAME(XDGASetClientVersion) (Display * dpy) |
187 { | 187 { |
188 XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); | 188 XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); |
189 xXDGASetClientVersionReq *req; | 189 xXDGASetClientVersionReq *req; |
190 | 190 |
191 XDGACheckExtension (dpy, info, False); | 191 XDGACheckExtension(dpy, info, False); |
192 | 192 |
193 LockDisplay (dpy); | 193 LockDisplay(dpy); |
194 GetReq (XDGASetClientVersion, req); | 194 GetReq(XDGASetClientVersion, req); |
195 req->reqType = info->codes->major_opcode; | 195 req->reqType = info->codes->major_opcode; |
196 req->dgaReqType = X_XDGASetClientVersion; | 196 req->dgaReqType = X_XDGASetClientVersion; |
197 req->major = XDGA_MAJOR_VERSION; | 197 req->major = XDGA_MAJOR_VERSION; |
198 req->minor = XDGA_MINOR_VERSION; | 198 req->minor = XDGA_MINOR_VERSION; |
199 UnlockDisplay (dpy); | 199 UnlockDisplay(dpy); |
200 SyncHandle (); | 200 SyncHandle(); |
201 return True; | 201 return True; |
202 } | 202 } |
203 | 203 |
204 Bool SDL_NAME (XDGAOpenFramebuffer) (Display * dpy, int screen) | 204 Bool SDL_NAME(XDGAOpenFramebuffer) (Display * dpy, int screen) |
205 { | 205 { |
206 XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); | 206 XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); |
207 xXDGAOpenFramebufferReply rep; | 207 xXDGAOpenFramebufferReply rep; |
208 xXDGAOpenFramebufferReq *req; | 208 xXDGAOpenFramebufferReq *req; |
209 char *deviceName = NULL; | 209 char *deviceName = NULL; |
210 Bool ret; | 210 Bool ret; |
211 | 211 |
212 XDGACheckExtension (dpy, info, False); | 212 XDGACheckExtension(dpy, info, False); |
213 | 213 |
214 LockDisplay (dpy); | 214 LockDisplay(dpy); |
215 GetReq (XDGAOpenFramebuffer, req); | 215 GetReq(XDGAOpenFramebuffer, req); |
216 req->reqType = info->codes->major_opcode; | 216 req->reqType = info->codes->major_opcode; |
217 req->dgaReqType = X_XDGAOpenFramebuffer; | 217 req->dgaReqType = X_XDGAOpenFramebuffer; |
218 req->screen = screen; | 218 req->screen = screen; |
219 if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) { | 219 if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { |
220 UnlockDisplay (dpy); | 220 UnlockDisplay(dpy); |
221 SyncHandle (); | 221 SyncHandle(); |
222 return False; | 222 return False; |
223 } | 223 } |
224 | 224 |
225 if (rep.length) { | 225 if (rep.length) { |
226 deviceName = Xmalloc (rep.length << 2); | 226 deviceName = Xmalloc(rep.length << 2); |
227 _XRead (dpy, deviceName, rep.length << 2); | 227 _XRead(dpy, deviceName, rep.length << 2); |
228 } | 228 } |
229 | 229 |
230 ret = SDL_NAME (XDGAMapFramebuffer) (screen, deviceName, | 230 ret = SDL_NAME(XDGAMapFramebuffer) (screen, deviceName, |
231 (unsigned char *) (long) rep.mem1, | 231 (unsigned char *) (long) rep.mem1, |
232 rep.size, rep.offset, rep.extra); | 232 rep.size, rep.offset, rep.extra); |
233 | 233 |
234 if (deviceName) | 234 if (deviceName) |
235 Xfree (deviceName); | 235 Xfree(deviceName); |
236 | 236 |
237 UnlockDisplay (dpy); | 237 UnlockDisplay(dpy); |
238 SyncHandle (); | 238 SyncHandle(); |
239 return ret; | 239 return ret; |
240 } | 240 } |
241 | 241 |
242 void SDL_NAME (XDGACloseFramebuffer) (Display * dpy, int screen) | 242 void SDL_NAME(XDGACloseFramebuffer) (Display * dpy, int screen) |
243 { | 243 { |
244 XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); | 244 XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); |
245 xXDGACloseFramebufferReq *req; | 245 xXDGACloseFramebufferReq *req; |
246 | 246 |
247 XextSimpleCheckExtension (dpy, info, SDL_NAME (xdga_extension_name)); | 247 XextSimpleCheckExtension(dpy, info, SDL_NAME(xdga_extension_name)); |
248 | 248 |
249 SDL_NAME (XDGAUnmapFramebuffer) (screen); | 249 SDL_NAME(XDGAUnmapFramebuffer) (screen); |
250 | 250 |
251 LockDisplay (dpy); | 251 LockDisplay(dpy); |
252 GetReq (XDGACloseFramebuffer, req); | 252 GetReq(XDGACloseFramebuffer, req); |
253 req->reqType = info->codes->major_opcode; | 253 req->reqType = info->codes->major_opcode; |
254 req->dgaReqType = X_XDGACloseFramebuffer; | 254 req->dgaReqType = X_XDGACloseFramebuffer; |
255 req->screen = screen; | 255 req->screen = screen; |
256 UnlockDisplay (dpy); | 256 UnlockDisplay(dpy); |
257 SyncHandle (); | 257 SyncHandle(); |
258 } | 258 } |
259 | 259 |
260 | 260 |
261 | 261 |
262 SDL_NAME (XDGAMode) * SDL_NAME (XDGAQueryModes) (Display * dpy, | 262 SDL_NAME(XDGAMode) * SDL_NAME(XDGAQueryModes) (Display * dpy, |
263 int screen, int *num) | 263 int screen, int *num) |
264 { | 264 { |
265 XExtDisplayInfo *dinfo = SDL_NAME (xdga_find_display) (dpy); | 265 XExtDisplayInfo *dinfo = SDL_NAME(xdga_find_display) (dpy); |
266 xXDGAQueryModesReply rep; | 266 xXDGAQueryModesReply rep; |
267 xXDGAQueryModesReq *req; | 267 xXDGAQueryModesReq *req; |
268 SDL_NAME (XDGAMode) * modes = NULL; | 268 SDL_NAME(XDGAMode) * modes = NULL; |
269 | 269 |
270 *num = 0; | 270 *num = 0; |
271 | 271 |
272 XDGACheckExtension (dpy, dinfo, NULL); | 272 XDGACheckExtension(dpy, dinfo, NULL); |
273 | 273 |
274 LockDisplay (dpy); | 274 LockDisplay(dpy); |
275 GetReq (XDGAQueryModes, req); | 275 GetReq(XDGAQueryModes, req); |
276 req->reqType = dinfo->codes->major_opcode; | 276 req->reqType = dinfo->codes->major_opcode; |
277 req->dgaReqType = X_XDGAQueryModes; | 277 req->dgaReqType = X_XDGAQueryModes; |
278 req->screen = screen; | 278 req->screen = screen; |
279 | 279 |
280 if (_XReply (dpy, (xReply *) & rep, 0, xFalse)) { | 280 if (_XReply(dpy, (xReply *) & rep, 0, xFalse)) { |
281 if (rep.length) { | 281 if (rep.length) { |
282 xXDGAModeInfo info; | 282 xXDGAModeInfo info; |
283 int i, size; | 283 int i, size; |
284 char *offset; | 284 char *offset; |
285 | 285 |
286 size = rep.length << 2; | 286 size = rep.length << 2; |
287 size -= rep.number * sz_xXDGAModeInfo; /* find text size */ | 287 size -= rep.number * sz_xXDGAModeInfo; /* find text size */ |
288 modes = (SDL_NAME (XDGAMode) *) | 288 modes = (SDL_NAME(XDGAMode) *) |
289 Xmalloc ((rep.number * sizeof (SDL_NAME (XDGAMode))) + size); | 289 Xmalloc((rep.number * sizeof(SDL_NAME(XDGAMode))) + size); |
290 offset = (char *) (&modes[rep.number]); /* start of text */ | 290 offset = (char *) (&modes[rep.number]); /* start of text */ |
291 | 291 |
292 | 292 |
293 if (modes) { | 293 if (modes) { |
294 for (i = 0; i < rep.number; i++) { | 294 for (i = 0; i < rep.number; i++) { |
295 _XRead (dpy, (char *) (&info), sz_xXDGAModeInfo); | 295 _XRead(dpy, (char *) (&info), sz_xXDGAModeInfo); |
296 | 296 |
297 modes[i].num = info.num; | 297 modes[i].num = info.num; |
298 modes[i].verticalRefresh = | 298 modes[i].verticalRefresh = |
299 (float) info.vsync_num / (float) info.vsync_den; | 299 (float) info.vsync_num / (float) info.vsync_den; |
300 modes[i].flags = info.flags; | 300 modes[i].flags = info.flags; |
318 modes[i].maxViewportY = info.viewport_ymax; | 318 modes[i].maxViewportY = info.viewport_ymax; |
319 modes[i].viewportFlags = info.viewport_flags; | 319 modes[i].viewportFlags = info.viewport_flags; |
320 modes[i].reserved1 = info.reserved1; | 320 modes[i].reserved1 = info.reserved1; |
321 modes[i].reserved2 = info.reserved2; | 321 modes[i].reserved2 = info.reserved2; |
322 | 322 |
323 _XRead (dpy, offset, info.name_size); | 323 _XRead(dpy, offset, info.name_size); |
324 modes[i].name = offset; | 324 modes[i].name = offset; |
325 offset += info.name_size; | 325 offset += info.name_size; |
326 } | 326 } |
327 *num = rep.number; | 327 *num = rep.number; |
328 } else | 328 } else |
329 _XEatData (dpy, rep.length << 2); | 329 _XEatData(dpy, rep.length << 2); |
330 } | 330 } |
331 } | 331 } |
332 | 332 |
333 UnlockDisplay (dpy); | 333 UnlockDisplay(dpy); |
334 SyncHandle (); | 334 SyncHandle(); |
335 | 335 |
336 return modes; | 336 return modes; |
337 } | 337 } |
338 | 338 |
339 | 339 |
340 SDL_NAME (XDGADevice) * | 340 SDL_NAME(XDGADevice) * |
341 SDL_NAME (XDGASetMode) (Display * dpy, int screen, int mode) | 341 SDL_NAME(XDGASetMode) (Display * dpy, int screen, int mode) |
342 { | 342 { |
343 XExtDisplayInfo *dinfo = SDL_NAME (xdga_find_display) (dpy); | 343 XExtDisplayInfo *dinfo = SDL_NAME(xdga_find_display) (dpy); |
344 xXDGASetModeReply rep; | 344 xXDGASetModeReply rep; |
345 xXDGASetModeReq *req; | 345 xXDGASetModeReq *req; |
346 SDL_NAME (XDGADevice) * dev = NULL; | 346 SDL_NAME(XDGADevice) * dev = NULL; |
347 Pixmap pid; | 347 Pixmap pid; |
348 | 348 |
349 XDGACheckExtension (dpy, dinfo, NULL); | 349 XDGACheckExtension(dpy, dinfo, NULL); |
350 | 350 |
351 LockDisplay (dpy); | 351 LockDisplay(dpy); |
352 GetReq (XDGASetMode, req); | 352 GetReq(XDGASetMode, req); |
353 req->reqType = dinfo->codes->major_opcode; | 353 req->reqType = dinfo->codes->major_opcode; |
354 req->dgaReqType = X_XDGASetMode; | 354 req->dgaReqType = X_XDGASetMode; |
355 req->screen = screen; | 355 req->screen = screen; |
356 req->mode = mode; | 356 req->mode = mode; |
357 req->pid = pid = XAllocID (dpy); | 357 req->pid = pid = XAllocID(dpy); |
358 | 358 |
359 if (_XReply (dpy, (xReply *) & rep, 0, xFalse)) { | 359 if (_XReply(dpy, (xReply *) & rep, 0, xFalse)) { |
360 if (rep.length) { | 360 if (rep.length) { |
361 xXDGAModeInfo info; | 361 xXDGAModeInfo info; |
362 int size; | 362 int size; |
363 | 363 |
364 size = rep.length << 2; | 364 size = rep.length << 2; |
365 size -= sz_xXDGAModeInfo; /* get text size */ | 365 size -= sz_xXDGAModeInfo; /* get text size */ |
366 | 366 |
367 dev = (SDL_NAME (XDGADevice) *) | 367 dev = (SDL_NAME(XDGADevice) *) |
368 Xmalloc (sizeof (SDL_NAME (XDGADevice)) + size); | 368 Xmalloc(sizeof(SDL_NAME(XDGADevice)) + size); |
369 | 369 |
370 if (dev) { | 370 if (dev) { |
371 _XRead (dpy, (char *) (&info), sz_xXDGAModeInfo); | 371 _XRead(dpy, (char *) (&info), sz_xXDGAModeInfo); |
372 | 372 |
373 dev->mode.num = info.num; | 373 dev->mode.num = info.num; |
374 dev->mode.verticalRefresh = | 374 dev->mode.verticalRefresh = |
375 (float) info.vsync_num / (float) info.vsync_den; | 375 (float) info.vsync_num / (float) info.vsync_den; |
376 dev->mode.flags = info.flags; | 376 dev->mode.flags = info.flags; |
395 dev->mode.viewportFlags = info.viewport_flags; | 395 dev->mode.viewportFlags = info.viewport_flags; |
396 dev->mode.reserved1 = info.reserved1; | 396 dev->mode.reserved1 = info.reserved1; |
397 dev->mode.reserved2 = info.reserved2; | 397 dev->mode.reserved2 = info.reserved2; |
398 | 398 |
399 dev->mode.name = (char *) (&dev[1]); | 399 dev->mode.name = (char *) (&dev[1]); |
400 _XRead (dpy, dev->mode.name, info.name_size); | 400 _XRead(dpy, dev->mode.name, info.name_size); |
401 | 401 |
402 dev->pixmap = (rep.flags & XDGAPixmap) ? pid : 0; | 402 dev->pixmap = (rep.flags & XDGAPixmap) ? pid : 0; |
403 dev->data = SDL_NAME (XDGAGetMappedMemory) (screen); | 403 dev->data = SDL_NAME(XDGAGetMappedMemory) (screen); |
404 | 404 |
405 if (dev->data) | 405 if (dev->data) |
406 dev->data += rep.offset; | 406 dev->data += rep.offset; |
407 } | 407 } |
408 /* not sure what to do if the allocation fails */ | 408 /* not sure what to do if the allocation fails */ |
409 } | 409 } |
410 } | 410 } |
411 | 411 |
412 UnlockDisplay (dpy); | 412 UnlockDisplay(dpy); |
413 SyncHandle (); | 413 SyncHandle(); |
414 | 414 |
415 return dev; | 415 return dev; |
416 } | 416 } |
417 | 417 |
418 | 418 |
419 void SDL_NAME (XDGASetViewport) (Display * dpy, | 419 void SDL_NAME(XDGASetViewport) (Display * dpy, |
420 int screen, int x, int y, int flags) | 420 int screen, int x, int y, int flags) |
421 { | 421 { |
422 XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); | 422 XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); |
423 xXDGASetViewportReq *req; | 423 xXDGASetViewportReq *req; |
424 | 424 |
425 XextSimpleCheckExtension (dpy, info, SDL_NAME (xdga_extension_name)); | 425 XextSimpleCheckExtension(dpy, info, SDL_NAME(xdga_extension_name)); |
426 | 426 |
427 LockDisplay (dpy); | 427 LockDisplay(dpy); |
428 GetReq (XDGASetViewport, req); | 428 GetReq(XDGASetViewport, req); |
429 req->reqType = info->codes->major_opcode; | 429 req->reqType = info->codes->major_opcode; |
430 req->dgaReqType = X_XDGASetViewport; | 430 req->dgaReqType = X_XDGASetViewport; |
431 req->screen = screen; | 431 req->screen = screen; |
432 req->x = x; | 432 req->x = x; |
433 req->y = y; | 433 req->y = y; |
434 req->flags = flags; | 434 req->flags = flags; |
435 UnlockDisplay (dpy); | 435 UnlockDisplay(dpy); |
436 SyncHandle (); | 436 SyncHandle(); |
437 } | 437 } |
438 | 438 |
439 | 439 |
440 void SDL_NAME (XDGAInstallColormap) (Display * dpy, int screen, Colormap cmap) | 440 void SDL_NAME(XDGAInstallColormap) (Display * dpy, int screen, Colormap cmap) |
441 { | 441 { |
442 XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); | 442 XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); |
443 xXDGAInstallColormapReq *req; | 443 xXDGAInstallColormapReq *req; |
444 | 444 |
445 XextSimpleCheckExtension (dpy, info, SDL_NAME (xdga_extension_name)); | 445 XextSimpleCheckExtension(dpy, info, SDL_NAME(xdga_extension_name)); |
446 | 446 |
447 LockDisplay (dpy); | 447 LockDisplay(dpy); |
448 GetReq (XDGAInstallColormap, req); | 448 GetReq(XDGAInstallColormap, req); |
449 req->reqType = info->codes->major_opcode; | 449 req->reqType = info->codes->major_opcode; |
450 req->dgaReqType = X_XDGAInstallColormap; | 450 req->dgaReqType = X_XDGAInstallColormap; |
451 req->screen = screen; | 451 req->screen = screen; |
452 req->cmap = cmap; | 452 req->cmap = cmap; |
453 UnlockDisplay (dpy); | 453 UnlockDisplay(dpy); |
454 SyncHandle (); | 454 SyncHandle(); |
455 } | 455 } |
456 | 456 |
457 void SDL_NAME (XDGASelectInput) (Display * dpy, int screen, long mask) | 457 void SDL_NAME(XDGASelectInput) (Display * dpy, int screen, long mask) |
458 { | 458 { |
459 XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); | 459 XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); |
460 xXDGASelectInputReq *req; | 460 xXDGASelectInputReq *req; |
461 | 461 |
462 XextSimpleCheckExtension (dpy, info, SDL_NAME (xdga_extension_name)); | 462 XextSimpleCheckExtension(dpy, info, SDL_NAME(xdga_extension_name)); |
463 | 463 |
464 LockDisplay (dpy); | 464 LockDisplay(dpy); |
465 GetReq (XDGASelectInput, req); | 465 GetReq(XDGASelectInput, req); |
466 req->reqType = info->codes->major_opcode; | 466 req->reqType = info->codes->major_opcode; |
467 req->dgaReqType = X_XDGASelectInput; | 467 req->dgaReqType = X_XDGASelectInput; |
468 req->screen = screen; | 468 req->screen = screen; |
469 req->mask = mask; | 469 req->mask = mask; |
470 UnlockDisplay (dpy); | 470 UnlockDisplay(dpy); |
471 SyncHandle (); | 471 SyncHandle(); |
472 } | 472 } |
473 | 473 |
474 void SDL_NAME (XDGAFillRectangle) (Display * dpy, | 474 void SDL_NAME(XDGAFillRectangle) (Display * dpy, |
475 int screen, | 475 int screen, |
476 int x, | 476 int x, |
477 int y, | 477 int y, |
478 unsigned int width, | 478 unsigned int width, |
479 unsigned int height, unsigned long color) | 479 unsigned int height, unsigned long color) |
480 { | 480 { |
481 XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); | 481 XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); |
482 xXDGAFillRectangleReq *req; | 482 xXDGAFillRectangleReq *req; |
483 | 483 |
484 XextSimpleCheckExtension (dpy, info, SDL_NAME (xdga_extension_name)); | 484 XextSimpleCheckExtension(dpy, info, SDL_NAME(xdga_extension_name)); |
485 | 485 |
486 LockDisplay (dpy); | 486 LockDisplay(dpy); |
487 GetReq (XDGAFillRectangle, req); | 487 GetReq(XDGAFillRectangle, req); |
488 req->reqType = info->codes->major_opcode; | 488 req->reqType = info->codes->major_opcode; |
489 req->dgaReqType = X_XDGAFillRectangle; | 489 req->dgaReqType = X_XDGAFillRectangle; |
490 req->screen = screen; | 490 req->screen = screen; |
491 req->x = x; | 491 req->x = x; |
492 req->y = y; | 492 req->y = y; |
493 req->width = width; | 493 req->width = width; |
494 req->height = height; | 494 req->height = height; |
495 req->color = color; | 495 req->color = color; |
496 UnlockDisplay (dpy); | 496 UnlockDisplay(dpy); |
497 SyncHandle (); | 497 SyncHandle(); |
498 } | 498 } |
499 | 499 |
500 void SDL_NAME (XDGACopyArea) (Display * dpy, | 500 void SDL_NAME(XDGACopyArea) (Display * dpy, |
501 int screen, | 501 int screen, |
502 int srcx, | 502 int srcx, |
503 int srcy, | 503 int srcy, |
504 unsigned int width, | 504 unsigned int width, |
505 unsigned int height, int dstx, int dsty) | 505 unsigned int height, int dstx, int dsty) |
506 { | 506 { |
507 XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); | 507 XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); |
508 xXDGACopyAreaReq *req; | 508 xXDGACopyAreaReq *req; |
509 | 509 |
510 XextSimpleCheckExtension (dpy, info, SDL_NAME (xdga_extension_name)); | 510 XextSimpleCheckExtension(dpy, info, SDL_NAME(xdga_extension_name)); |
511 | 511 |
512 LockDisplay (dpy); | 512 LockDisplay(dpy); |
513 GetReq (XDGACopyArea, req); | 513 GetReq(XDGACopyArea, req); |
514 req->reqType = info->codes->major_opcode; | 514 req->reqType = info->codes->major_opcode; |
515 req->dgaReqType = X_XDGACopyArea; | 515 req->dgaReqType = X_XDGACopyArea; |
516 req->screen = screen; | 516 req->screen = screen; |
517 req->srcx = srcx; | 517 req->srcx = srcx; |
518 req->srcy = srcy; | 518 req->srcy = srcy; |
519 req->width = width; | 519 req->width = width; |
520 req->height = height; | 520 req->height = height; |
521 req->dstx = dstx; | 521 req->dstx = dstx; |
522 req->dsty = dsty; | 522 req->dsty = dsty; |
523 UnlockDisplay (dpy); | 523 UnlockDisplay(dpy); |
524 SyncHandle (); | 524 SyncHandle(); |
525 } | 525 } |
526 | 526 |
527 void SDL_NAME (XDGACopyTransparentArea) (Display * dpy, | 527 void SDL_NAME(XDGACopyTransparentArea) (Display * dpy, |
528 int screen, | 528 int screen, |
529 int srcx, | 529 int srcx, |
530 int srcy, | 530 int srcy, |
531 unsigned int width, | 531 unsigned int width, |
532 unsigned int height, | 532 unsigned int height, |
533 int dstx, | 533 int dstx, int dsty, unsigned long key) |
534 int dsty, unsigned long key) | 534 { |
535 { | 535 XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); |
536 XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); | |
537 xXDGACopyTransparentAreaReq *req; | 536 xXDGACopyTransparentAreaReq *req; |
538 | 537 |
539 XextSimpleCheckExtension (dpy, info, SDL_NAME (xdga_extension_name)); | 538 XextSimpleCheckExtension(dpy, info, SDL_NAME(xdga_extension_name)); |
540 | 539 |
541 LockDisplay (dpy); | 540 LockDisplay(dpy); |
542 GetReq (XDGACopyTransparentArea, req); | 541 GetReq(XDGACopyTransparentArea, req); |
543 req->reqType = info->codes->major_opcode; | 542 req->reqType = info->codes->major_opcode; |
544 req->dgaReqType = X_XDGACopyTransparentArea; | 543 req->dgaReqType = X_XDGACopyTransparentArea; |
545 req->screen = screen; | 544 req->screen = screen; |
546 req->srcx = srcx; | 545 req->srcx = srcx; |
547 req->srcy = srcy; | 546 req->srcy = srcy; |
548 req->width = width; | 547 req->width = width; |
549 req->height = height; | 548 req->height = height; |
550 req->dstx = dstx; | 549 req->dstx = dstx; |
551 req->dsty = dsty; | 550 req->dsty = dsty; |
552 req->key = key; | 551 req->key = key; |
553 UnlockDisplay (dpy); | 552 UnlockDisplay(dpy); |
554 SyncHandle (); | 553 SyncHandle(); |
555 } | 554 } |
556 | 555 |
557 | 556 |
558 int SDL_NAME (XDGAGetViewportStatus) (Display * dpy, int screen) | 557 int SDL_NAME(XDGAGetViewportStatus) (Display * dpy, int screen) |
559 { | 558 { |
560 XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); | 559 XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); |
561 xXDGAGetViewportStatusReply rep; | 560 xXDGAGetViewportStatusReply rep; |
562 xXDGAGetViewportStatusReq *req; | 561 xXDGAGetViewportStatusReq *req; |
563 int status = 0; | 562 int status = 0; |
564 | 563 |
565 XDGACheckExtension (dpy, info, 0); | 564 XDGACheckExtension(dpy, info, 0); |
566 | 565 |
567 LockDisplay (dpy); | 566 LockDisplay(dpy); |
568 GetReq (XDGAGetViewportStatus, req); | 567 GetReq(XDGAGetViewportStatus, req); |
569 req->reqType = info->codes->major_opcode; | 568 req->reqType = info->codes->major_opcode; |
570 req->dgaReqType = X_XDGAGetViewportStatus; | 569 req->dgaReqType = X_XDGAGetViewportStatus; |
571 req->screen = screen; | 570 req->screen = screen; |
572 if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) | 571 if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) |
573 status = rep.status; | 572 status = rep.status; |
574 UnlockDisplay (dpy); | 573 UnlockDisplay(dpy); |
575 SyncHandle (); | 574 SyncHandle(); |
576 return status; | 575 return status; |
577 } | 576 } |
578 | 577 |
579 void SDL_NAME (XDGASync) (Display * dpy, int screen) | 578 void SDL_NAME(XDGASync) (Display * dpy, int screen) |
580 { | 579 { |
581 XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); | 580 XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); |
582 xXDGASyncReply rep; | 581 xXDGASyncReply rep; |
583 xXDGASyncReq *req; | 582 xXDGASyncReq *req; |
584 | 583 |
585 XextSimpleCheckExtension (dpy, info, SDL_NAME (xdga_extension_name)); | 584 XextSimpleCheckExtension(dpy, info, SDL_NAME(xdga_extension_name)); |
586 | 585 |
587 LockDisplay (dpy); | 586 LockDisplay(dpy); |
588 GetReq (XDGASync, req); | 587 GetReq(XDGASync, req); |
589 req->reqType = info->codes->major_opcode; | 588 req->reqType = info->codes->major_opcode; |
590 req->dgaReqType = X_XDGASync; | 589 req->dgaReqType = X_XDGASync; |
591 req->screen = screen; | 590 req->screen = screen; |
592 _XReply (dpy, (xReply *) & rep, 0, xFalse); | 591 _XReply(dpy, (xReply *) & rep, 0, xFalse); |
593 UnlockDisplay (dpy); | 592 UnlockDisplay(dpy); |
594 SyncHandle (); | 593 SyncHandle(); |
595 } | 594 } |
596 | 595 |
597 | 596 |
598 void SDL_NAME (XDGAChangePixmapMode) (Display * dpy, | 597 void SDL_NAME(XDGAChangePixmapMode) (Display * dpy, |
599 int screen, int *x, int *y, int mode) | 598 int screen, int *x, int *y, int mode) |
600 { | 599 { |
601 XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); | 600 XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); |
602 xXDGAChangePixmapModeReq *req; | 601 xXDGAChangePixmapModeReq *req; |
603 xXDGAChangePixmapModeReply rep; | 602 xXDGAChangePixmapModeReply rep; |
604 | 603 |
605 XextSimpleCheckExtension (dpy, info, SDL_NAME (xdga_extension_name)); | 604 XextSimpleCheckExtension(dpy, info, SDL_NAME(xdga_extension_name)); |
606 | 605 |
607 LockDisplay (dpy); | 606 LockDisplay(dpy); |
608 GetReq (XDGAChangePixmapMode, req); | 607 GetReq(XDGAChangePixmapMode, req); |
609 req->reqType = info->codes->major_opcode; | 608 req->reqType = info->codes->major_opcode; |
610 req->dgaReqType = X_XDGAChangePixmapMode; | 609 req->dgaReqType = X_XDGAChangePixmapMode; |
611 req->screen = screen; | 610 req->screen = screen; |
612 req->x = *x; | 611 req->x = *x; |
613 req->y = *y; | 612 req->y = *y; |
614 req->flags = mode; | 613 req->flags = mode; |
615 _XReply (dpy, (xReply *) & rep, 0, xFalse); | 614 _XReply(dpy, (xReply *) & rep, 0, xFalse); |
616 *x = rep.x; | 615 *x = rep.x; |
617 *y = rep.y; | 616 *y = rep.y; |
618 UnlockDisplay (dpy); | 617 UnlockDisplay(dpy); |
619 SyncHandle (); | 618 SyncHandle(); |
620 } | 619 } |
621 | 620 |
622 Colormap SDL_NAME (XDGACreateColormap) (Display * dpy, | 621 Colormap SDL_NAME(XDGACreateColormap) (Display * dpy, |
623 int screen, | 622 int screen, |
624 SDL_NAME (XDGADevice) * dev, | 623 SDL_NAME(XDGADevice) * dev, int alloc) |
625 int alloc) | 624 { |
626 { | 625 XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); |
627 XExtDisplayInfo *info = SDL_NAME (xdga_find_display) (dpy); | |
628 xXDGACreateColormapReq *req; | 626 xXDGACreateColormapReq *req; |
629 Colormap cid; | 627 Colormap cid; |
630 | 628 |
631 XDGACheckExtension (dpy, info, -1); | 629 XDGACheckExtension(dpy, info, -1); |
632 | 630 |
633 LockDisplay (dpy); | 631 LockDisplay(dpy); |
634 GetReq (XDGACreateColormap, req); | 632 GetReq(XDGACreateColormap, req); |
635 req->reqType = info->codes->major_opcode; | 633 req->reqType = info->codes->major_opcode; |
636 req->dgaReqType = X_XDGACreateColormap; | 634 req->dgaReqType = X_XDGACreateColormap; |
637 req->screen = screen; | 635 req->screen = screen; |
638 req->mode = dev->mode.num; | 636 req->mode = dev->mode.num; |
639 req->alloc = alloc; | 637 req->alloc = alloc; |
640 cid = req->id = XAllocID (dpy); | 638 cid = req->id = XAllocID(dpy); |
641 UnlockDisplay (dpy); | 639 UnlockDisplay(dpy); |
642 SyncHandle (); | 640 SyncHandle(); |
643 | 641 |
644 return cid; | 642 return cid; |
645 } | 643 } |
646 | 644 |
647 | 645 |
648 void SDL_NAME (XDGAKeyEventToXKeyEvent) (SDL_NAME (XDGAKeyEvent) * dk, | 646 void SDL_NAME(XDGAKeyEventToXKeyEvent) (SDL_NAME(XDGAKeyEvent) * dk, |
649 XKeyEvent * xk) | 647 XKeyEvent * xk) |
650 { | 648 { |
651 xk->type = dk->type; | 649 xk->type = dk->type; |
652 xk->serial = dk->serial; | 650 xk->serial = dk->serial; |
653 xk->send_event = False; | 651 xk->send_event = False; |
654 xk->display = dk->display; | 652 xk->display = dk->display; |
655 xk->window = RootWindow (dk->display, dk->screen); | 653 xk->window = RootWindow(dk->display, dk->screen); |
656 xk->root = xk->window; | 654 xk->root = xk->window; |
657 xk->subwindow = None; | 655 xk->subwindow = None; |
658 xk->time = dk->time; | 656 xk->time = dk->time; |
659 xk->x = xk->y = xk->x_root = xk->y_root = 0; | 657 xk->x = xk->y = xk->x_root = xk->y_root = 0; |
660 xk->state = dk->state; | 658 xk->state = dk->state; |
713 int screen; | 711 int screen; |
714 struct _DGAMapRec *next; | 712 struct _DGAMapRec *next; |
715 } DGAMapRec, *DGAMapPtr; | 713 } DGAMapRec, *DGAMapPtr; |
716 | 714 |
717 static Bool | 715 static Bool |
718 DGAMapPhysical (int, char *, unsigned char *, CARD32, CARD32, CARD32, | 716 DGAMapPhysical(int, char *, unsigned char *, CARD32, CARD32, CARD32, |
719 DGAMapPtr); | 717 DGAMapPtr); |
720 static void DGAUnmapPhysical (DGAMapPtr); | 718 static void DGAUnmapPhysical(DGAMapPtr); |
721 | 719 |
722 static DGAMapPtr _Maps = NULL; | 720 static DGAMapPtr _Maps = NULL; |
723 | 721 |
724 | 722 |
725 unsigned char *SDL_NAME (XDGAGetMappedMemory) (int screen) | 723 unsigned char *SDL_NAME(XDGAGetMappedMemory) (int screen) |
726 { | 724 { |
727 DGAMapPtr pMap = _Maps; | 725 DGAMapPtr pMap = _Maps; |
728 unsigned char *pntr = NULL; | 726 unsigned char *pntr = NULL; |
729 | 727 |
730 while (pMap != NULL) { | 728 while (pMap != NULL) { |
736 } | 734 } |
737 | 735 |
738 return pntr; | 736 return pntr; |
739 } | 737 } |
740 | 738 |
741 Bool SDL_NAME (XDGAMapFramebuffer) (int screen, char *name, /* optional device name */ | 739 Bool SDL_NAME(XDGAMapFramebuffer) (int screen, char *name, /* optional device name */ |
742 unsigned char *base, /* physical memory */ | 740 unsigned char *base, /* physical memory */ |
743 CARD32 size, /* size */ | 741 CARD32 size, /* size */ |
744 CARD32 offset, /* optional offset */ | 742 CARD32 offset, /* optional offset */ |
745 CARD32 extra /* optional extra data */ | 743 CARD32 extra /* optional extra data */ |
746 ) | 744 ) |
747 { | 745 { |
748 DGAMapPtr pMap = _Maps; | 746 DGAMapPtr pMap = _Maps; |
749 Bool result; | 747 Bool result; |
750 | 748 |
759 /* we should probably check if we have root permissions and | 757 /* we should probably check if we have root permissions and |
760 return False here */ | 758 return False here */ |
761 | 759 |
762 } | 760 } |
763 | 761 |
764 pMap = (DGAMapPtr) Xmalloc (sizeof (DGAMapRec)); | 762 pMap = (DGAMapPtr) Xmalloc(sizeof(DGAMapRec)); |
765 | 763 |
766 result = DGAMapPhysical (screen, name, base, size, offset, extra, pMap); | 764 result = DGAMapPhysical(screen, name, base, size, offset, extra, pMap); |
767 | 765 |
768 if (result) { | 766 if (result) { |
769 pMap->next = _Maps; | 767 pMap->next = _Maps; |
770 _Maps = pMap; | 768 _Maps = pMap; |
771 } else | 769 } else |
772 Xfree (pMap); | 770 Xfree(pMap); |
773 | 771 |
774 return result; | 772 return result; |
775 } | 773 } |
776 | 774 |
777 void SDL_NAME (XDGAUnmapFramebuffer) (int screen) | 775 void SDL_NAME(XDGAUnmapFramebuffer) (int screen) |
778 { | 776 { |
779 DGAMapPtr pMap = _Maps; | 777 DGAMapPtr pMap = _Maps; |
780 DGAMapPtr pPrev = NULL; | 778 DGAMapPtr pPrev = NULL; |
781 | 779 |
782 /* is it already mapped */ | 780 /* is it already mapped */ |
788 } | 786 } |
789 | 787 |
790 if (!pMap) | 788 if (!pMap) |
791 return; | 789 return; |
792 | 790 |
793 DGAUnmapPhysical (pMap); | 791 DGAUnmapPhysical(pMap); |
794 | 792 |
795 if (!pPrev) | 793 if (!pPrev) |
796 _Maps = pMap->next; | 794 _Maps = pMap->next; |
797 else | 795 else |
798 pPrev->next = pMap->next; | 796 pPrev->next = pMap->next; |
799 | 797 |
800 Xfree (pMap); | 798 Xfree(pMap); |
801 } | 799 } |
802 | 800 |
803 | 801 |
804 static Bool | 802 static Bool |
805 DGAMapPhysical (int screen, char *name, /* optional device name */ | 803 DGAMapPhysical(int screen, char *name, /* optional device name */ |
806 unsigned char *base, /* physical memory */ | 804 unsigned char *base, /* physical memory */ |
807 CARD32 size, /* size */ | 805 CARD32 size, /* size */ |
808 CARD32 offset, /* optional offset */ | 806 CARD32 offset, /* optional offset */ |
809 CARD32 extra, /* optional extra data */ | 807 CARD32 extra, /* optional extra data */ |
810 DGAMapPtr pMap) | 808 DGAMapPtr pMap) |
811 { | 809 { |
812 #if defined(ISC) && defined(HAS_SVR3_MMAP) | 810 #if defined(ISC) && defined(HAS_SVR3_MMAP) |
813 struct kd_memloc mloc; | 811 struct kd_memloc mloc; |
814 #elif defined(__EMX__) | 812 #elif defined(__EMX__) |
815 APIRET rc; | 813 APIRET rc; |
822 pMap->screen = screen; | 820 pMap->screen = screen; |
823 pMap->physical = base; | 821 pMap->physical = base; |
824 pMap->size = size; | 822 pMap->size = size; |
825 | 823 |
826 #if defined(ISC) && defined(HAS_SVR3_MMAP) | 824 #if defined(ISC) && defined(HAS_SVR3_MMAP) |
827 if ((pMap->fd = open ("/dev/mmap", O_RDWR)) < 0) | 825 if ((pMap->fd = open("/dev/mmap", O_RDWR)) < 0) |
828 return False; | 826 return False; |
829 mloc.vaddr = (char *) 0; | 827 mloc.vaddr = (char *) 0; |
830 mloc.physaddr = (char *) base; | 828 mloc.physaddr = (char *) base; |
831 mloc.length = size; | 829 mloc.length = size; |
832 mloc.ioflg = 1; | 830 mloc.ioflg = 1; |
833 | 831 |
834 if ((pMap->virtual = | 832 if ((pMap->virtual = (void *) ioctl(pMap->fd, MAP, &mloc)) == (void *) -1) |
835 (void *) ioctl (pMap->fd, MAP, &mloc)) == (void *) -1) | |
836 return False; | 833 return False; |
837 #elif defined (__EMX__) | 834 #elif defined (__EMX__) |
838 /* | 835 /* |
839 * Dragon warning here! /dev/pmap$ is never closed, except on progam exit. | 836 * Dragon warning here! /dev/pmap$ is never closed, except on progam exit. |
840 * Consecutive calling of this routine will make PMAP$ driver run out | 837 * Consecutive calling of this routine will make PMAP$ driver run out |
841 * of memory handles. Some umap/close mechanism should be provided | 838 * of memory handles. Some umap/close mechanism should be provided |
842 */ | 839 */ |
843 | 840 |
844 rc = DosOpen ("/dev/pmap$", &hfd, &action, 0, FILE_NORMAL, FILE_OPEN, | 841 rc = DosOpen("/dev/pmap$", &hfd, &action, 0, FILE_NORMAL, FILE_OPEN, |
845 OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE, (PEAOP2) NULL); | 842 OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE, (PEAOP2) NULL); |
846 if (rc != 0) | 843 if (rc != 0) |
847 return False; | 844 return False; |
848 { | 845 { |
849 struct map_ioctl | 846 struct map_ioctl |
850 { | 847 { |
859 #define XFREE86_PMAP 0x76 | 856 #define XFREE86_PMAP 0x76 |
860 #define PMAP_MAP 0x44 | 857 #define PMAP_MAP 0x44 |
861 | 858 |
862 pmap.a.phys = base; | 859 pmap.a.phys = base; |
863 pmap.size = size; | 860 pmap.size = size; |
864 rc = DosDevIOCtl (hfd, XFREE86_PMAP, PMAP_MAP, | 861 rc = DosDevIOCtl(hfd, XFREE86_PMAP, PMAP_MAP, |
865 (PULONG) & pmap, sizeof (pmap), &plen, | 862 (PULONG) & pmap, sizeof(pmap), &plen, |
866 (PULONG) & dmap, sizeof (dmap), &dlen); | 863 (PULONG) & dmap, sizeof(dmap), &dlen); |
867 if (rc == 0) { | 864 if (rc == 0) { |
868 pMap->virtual = dmap.a.user; | 865 pMap->virtual = dmap.a.user; |
869 } | 866 } |
870 } | 867 } |
871 if (rc != 0) | 868 if (rc != 0) |
872 return False; | 869 return False; |
873 #elif defined (Lynx) | 870 #elif defined (Lynx) |
874 pMap->virtual = | 871 pMap->virtual = |
875 smem_create ("XF86DGA", (char *) base, size, SM_READ | SM_WRITE); | 872 smem_create("XF86DGA", (char *) base, size, SM_READ | SM_WRITE); |
876 #else | 873 #else |
877 #ifndef MAP_FILE | 874 #ifndef MAP_FILE |
878 #define MAP_FILE 0 | 875 #define MAP_FILE 0 |
879 #endif | 876 #endif |
880 if (!name) | 877 if (!name) |
881 name = DEV_MEM; | 878 name = DEV_MEM; |
882 if ((pMap->fd = open (name, O_RDWR)) < 0) | 879 if ((pMap->fd = open(name, O_RDWR)) < 0) |
883 #if defined(ENABLE_FBCON) | 880 #if defined(ENABLE_FBCON) |
884 { /* /dev/fb0 fallback added by Sam Lantinga <hercules@lokigames.com> */ | 881 { /* /dev/fb0 fallback added by Sam Lantinga <hercules@lokigames.com> */ |
885 /* Try to fall back to /dev/fb on Linux - FIXME: verify the device */ | 882 /* Try to fall back to /dev/fb on Linux - FIXME: verify the device */ |
886 struct fb_fix_screeninfo finfo; | 883 struct fb_fix_screeninfo finfo; |
887 | 884 |
888 if ((pMap->fd = open ("/dev/fb0", O_RDWR)) < 0) { | 885 if ((pMap->fd = open("/dev/fb0", O_RDWR)) < 0) { |
889 return False; | 886 return False; |
890 } | 887 } |
891 /* The useable framebuffer console memory may not be the whole | 888 /* The useable framebuffer console memory may not be the whole |
892 framebuffer that X has access to. :-( | 889 framebuffer that X has access to. :-( |
893 */ | 890 */ |
894 if (ioctl (pMap->fd, FBIOGET_FSCREENINFO, &finfo) < 0) { | 891 if (ioctl(pMap->fd, FBIOGET_FSCREENINFO, &finfo) < 0) { |
895 close (pMap->fd); | 892 close(pMap->fd); |
896 return False; | 893 return False; |
897 } | 894 } |
898 /* Warning: On PPC, the size and virtual need to be offset by: | 895 /* Warning: On PPC, the size and virtual need to be offset by: |
899 (((long)finfo.smem_start) - | 896 (((long)finfo.smem_start) - |
900 (((long)finfo.smem_start)&~(PAGE_SIZE-1))) | 897 (((long)finfo.smem_start)&~(PAGE_SIZE-1))) |
903 size = pMap->size = finfo.smem_len; | 900 size = pMap->size = finfo.smem_len; |
904 } | 901 } |
905 #else | 902 #else |
906 return False; | 903 return False; |
907 #endif | 904 #endif |
908 pMap->virtual = mmap (NULL, size, PROT_READ | PROT_WRITE, | 905 pMap->virtual = mmap(NULL, size, PROT_READ | PROT_WRITE, |
909 MAP_FILE | MAP_SHARED, pMap->fd, (off_t) base); | 906 MAP_FILE | MAP_SHARED, pMap->fd, (off_t) base); |
910 if (pMap->virtual == (void *) -1) | 907 if (pMap->virtual == (void *) -1) |
911 return False; | 908 return False; |
912 #endif | 909 #endif |
913 | 910 |
914 #if !defined(ISC) && !defined(HAS_SVR3_MMAP) && !defined(Lynx) \ | 911 #if !defined(ISC) && !defined(HAS_SVR3_MMAP) && !defined(Lynx) \ |
915 && !defined(__EMX__) | 912 && !defined(__EMX__) |
916 mprotect (pMap->virtual, size, PROT_READ | PROT_WRITE); | 913 mprotect(pMap->virtual, size, PROT_READ | PROT_WRITE); |
917 #endif | 914 #endif |
918 | 915 |
919 return True; | 916 return True; |
920 } | 917 } |
921 | 918 |
922 | 919 |
923 | 920 |
924 static void | 921 static void |
925 DGAUnmapPhysical (DGAMapPtr pMap) | 922 DGAUnmapPhysical(DGAMapPtr pMap) |
926 { | 923 { |
927 #if !defined(ISC) && !defined(HAS_SVR3_MMAP) && !defined(Lynx) \ | 924 #if !defined(ISC) && !defined(HAS_SVR3_MMAP) && !defined(Lynx) \ |
928 && !defined(__EMX__) | 925 && !defined(__EMX__) |
929 mprotect (pMap->virtual, pMap->size, PROT_READ); | 926 mprotect(pMap->virtual, pMap->size, PROT_READ); |
930 #elif defined(Lynx) | 927 #elif defined(Lynx) |
931 /* XXX this doesn't allow enable after disable */ | 928 /* XXX this doesn't allow enable after disable */ |
932 smem_create (NULL, pMap->virtual, pMap->size, SM_DETACH); | 929 smem_create(NULL, pMap->virtual, pMap->size, SM_DETACH); |
933 smem_remove ("XF86DGA"); | 930 smem_remove("XF86DGA"); |
934 #endif | 931 #endif |
935 | 932 |
936 | 933 |
937 /* We need to unmap and close too !!!!!!!!!! */ | 934 /* We need to unmap and close too !!!!!!!!!! */ |
938 } | 935 } |