Removing DGA support for SDL 1.3 - it's still buggy years later, and now
authorSam Lantinga
Wed, 26 Jul 2006 03:06:07 +0000
changeset 1940255fb6feae0d
parent 1939 37a7580357d1
child 1941 bf09d535e014
Removing DGA support for SDL 1.3 - it's still buggy years later, and now
it's deprecated by the developers in favor of the render APIs.
configure.in
include/SDL_config.h.in
src/video/Xext/Xxf86dga/XF86DGA.c
src/video/Xext/Xxf86dga/XF86DGA2.c
src/video/dga/SDL_dgaevents.c
src/video/dga/SDL_dgaevents_c.h
src/video/dga/SDL_dgamouse.c
src/video/dga/SDL_dgamouse_c.h
src/video/dga/SDL_dgavideo.c
src/video/dga/SDL_dgavideo.h
     1.1 --- a/configure.in	Tue Jul 25 07:25:51 2006 +0000
     1.2 +++ b/configure.in	Wed Jul 26 03:06:07 2006 +0000
     1.3 @@ -911,25 +911,6 @@
     1.4              fi
     1.5              have_video=yes
     1.6  
     1.7 -            AC_ARG_ENABLE(dga,
     1.8 -AC_HELP_STRING([--enable-dga], [allow use of X11 DGA code [[default=yes]]]),
     1.9 -                          , enable_dga=yes)
    1.10 -            if test x$enable_dga = xyes; then
    1.11 -                SOURCES="$SOURCES $srcdir/src/video/Xext/Xxf86dga/*.c"
    1.12 -            fi
    1.13 -            AC_ARG_ENABLE(video-dga,
    1.14 -AC_HELP_STRING([--enable-video-dga], [use DGA 2.0 video driver [[default=yes]]]),
    1.15 -                  , enable_video_dga=yes)
    1.16 -            if test x$enable_dga = xyes -a x$enable_video_dga = xyes; then
    1.17 -                AC_DEFINE(SDL_VIDEO_DRIVER_DGA)
    1.18 -                SOURCES="$SOURCES $srcdir/src/video/dga/*.c"
    1.19 -            fi
    1.20 -            AC_ARG_ENABLE(video-x11-dgamouse,
    1.21 -AC_HELP_STRING([--enable-video-x11-dgamouse], [use X11 DGA for mouse events [[default=yes]]]),
    1.22 -                          , enable_video_x11_dgamouse=yes)
    1.23 -            if test x$enable_dga = xyes -a x$enable_video_x11_dgamouse = xyes; then
    1.24 -                AC_DEFINE(SDL_VIDEO_DRIVER_X11_DGAMOUSE)
    1.25 -            fi
    1.26              AC_ARG_ENABLE(video-x11-vm,
    1.27  AC_HELP_STRING([--enable-video-x11-vm], [use X11 VM extension for fullscreen [[default=yes]]]),
    1.28                            , enable_video_x11_vm=yes)
     2.1 --- a/include/SDL_config.h.in	Tue Jul 25 07:25:51 2006 +0000
     2.2 +++ b/include/SDL_config.h.in	Wed Jul 26 03:06:07 2006 +0000
     2.3 @@ -254,7 +254,6 @@
     2.4  #undef SDL_VIDEO_DRIVER_COCOA
     2.5  #undef SDL_VIDEO_DRIVER_CYBERGRAPHICS
     2.6  #undef SDL_VIDEO_DRIVER_DC
     2.7 -#undef SDL_VIDEO_DRIVER_DGA
     2.8  #undef SDL_VIDEO_DRIVER_DIRECTFB
     2.9  #undef SDL_VIDEO_DRIVER_DRAWSPROCKET
    2.10  #undef SDL_VIDEO_DRIVER_DUMMY
    2.11 @@ -278,7 +277,6 @@
    2.12  #undef SDL_VIDEO_DRIVER_WIN32
    2.13  #undef SDL_VIDEO_DRIVER_WSCONS
    2.14  #undef SDL_VIDEO_DRIVER_X11
    2.15 -#undef SDL_VIDEO_DRIVER_X11_DGAMOUSE
    2.16  #undef SDL_VIDEO_DRIVER_X11_DPMS
    2.17  #undef SDL_VIDEO_DRIVER_X11_DYNAMIC
    2.18  #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT
     3.1 --- a/src/video/Xext/Xxf86dga/XF86DGA.c	Tue Jul 25 07:25:51 2006 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,679 +0,0 @@
     3.4 -/* $XFree86: xc/lib/Xxf86dga/XF86DGA.c,v 3.19 2001/08/18 02:41:30 dawes Exp $ */
     3.5 -/*
     3.6 -
     3.7 -Copyright (c) 1995  Jon Tombs
     3.8 -Copyright (c) 1995,1996  The XFree86 Project, Inc
     3.9 -
    3.10 -*/
    3.11 -
    3.12 -/* THIS IS NOT AN X CONSORTIUM STANDARD */
    3.13 -
    3.14 -#ifdef __EMX__                  /* needed here to override certain constants in X headers */
    3.15 -#define INCL_DOS
    3.16 -#define INCL_DOSIOCTL
    3.17 -#include <os2.h>
    3.18 -#endif
    3.19 -
    3.20 -#if defined(linux)
    3.21 -#define HAS_MMAP_ANON
    3.22 -#include <sys/types.h>
    3.23 -#include <sys/mman.h>
    3.24 -#include <asm/page.h>           /* PAGE_SIZE */
    3.25 -#define HAS_SC_PAGESIZE         /* _SC_PAGESIZE may be an enum for Linux */
    3.26 -#define HAS_GETPAGESIZE
    3.27 -#endif /* linux */
    3.28 -
    3.29 -#if defined(CSRG_BASED)
    3.30 -#define HAS_MMAP_ANON
    3.31 -#define HAS_GETPAGESIZE
    3.32 -#include <sys/types.h>
    3.33 -#include <sys/mman.h>
    3.34 -#endif /* CSRG_BASED */
    3.35 -
    3.36 -#if defined(DGUX)
    3.37 -#define HAS_GETPAGESIZE
    3.38 -#define MMAP_DEV_ZERO
    3.39 -#include <sys/types.h>
    3.40 -#include <sys/mman.h>
    3.41 -#include <unistd.h>
    3.42 -#endif /* DGUX */
    3.43 -
    3.44 -#if defined(SVR4) && !defined(DGUX)
    3.45 -#define MMAP_DEV_ZERO
    3.46 -#include <sys/types.h>
    3.47 -#include <sys/mman.h>
    3.48 -#include <unistd.h>
    3.49 -#endif /* SVR4 && !DGUX */
    3.50 -
    3.51 -#if defined(sun) && !defined(SVR4)      /* SunOS */
    3.52 -#define MMAP_DEV_ZERO           /* doesn't SunOS have MAP_ANON ?? */
    3.53 -#define HAS_GETPAGESIZE
    3.54 -#include <sys/types.h>
    3.55 -#include <sys/mman.h>
    3.56 -#endif /* sun && !SVR4 */
    3.57 -
    3.58 -#ifdef XNO_SYSCONF
    3.59 -#undef _SC_PAGESIZE
    3.60 -#endif
    3.61 -
    3.62 -#define NEED_EVENTS
    3.63 -#define NEED_REPLIES
    3.64 -
    3.65 -#include <X11/Xlibint.h>
    3.66 -#include "../extensions/xf86dga.h"
    3.67 -#include "../extensions/xf86dgastr.h"
    3.68 -#include "../extensions/Xext.h"
    3.69 -#include "../extensions/extutil.h"
    3.70 -
    3.71 -extern XExtDisplayInfo *SDL_NAME(xdga_find_display) (Display *);
    3.72 -extern char *SDL_NAME(xdga_extension_name);
    3.73 -
    3.74 -#define XF86DGACheckExtension(dpy,i,val) \
    3.75 -  XextCheckExtension (dpy, i, SDL_NAME(xdga_extension_name), val)
    3.76 -
    3.77 -/*****************************************************************************
    3.78 - *                                                                           *
    3.79 - *		    public XFree86-DGA Extension routines                    *
    3.80 - *                                                                           *
    3.81 - *****************************************************************************/
    3.82 -
    3.83 -Bool SDL_NAME(XF86DGAQueryExtension) (Display * dpy,
    3.84 -                                      int *event_basep, int *error_basep)
    3.85 -{
    3.86 -    return SDL_NAME(XDGAQueryExtension) (dpy, event_basep, error_basep);
    3.87 -}
    3.88 -
    3.89 -Bool SDL_NAME(XF86DGAQueryVersion) (Display * dpy,
    3.90 -                                    int *majorVersion, int *minorVersion)
    3.91 -{
    3.92 -    return SDL_NAME(XDGAQueryVersion) (dpy, majorVersion, minorVersion);
    3.93 -}
    3.94 -
    3.95 -Bool SDL_NAME(XF86DGAGetVideoLL) (Display * dpy,
    3.96 -                                  int screen,
    3.97 -                                  int *offset,
    3.98 -                                  int *width, int *bank_size, int *ram_size)
    3.99 -{
   3.100 -    XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy);
   3.101 -    xXF86DGAGetVideoLLReply rep;
   3.102 -    xXF86DGAGetVideoLLReq *req;
   3.103 -
   3.104 -    XF86DGACheckExtension(dpy, info, False);
   3.105 -
   3.106 -    LockDisplay(dpy);
   3.107 -    GetReq(XF86DGAGetVideoLL, req);
   3.108 -    req->reqType = info->codes->major_opcode;
   3.109 -    req->dgaReqType = X_XF86DGAGetVideoLL;
   3.110 -    req->screen = screen;
   3.111 -    if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
   3.112 -        UnlockDisplay(dpy);
   3.113 -        SyncHandle();
   3.114 -        return False;
   3.115 -    }
   3.116 -
   3.117 -    *offset = /*(char *) */ rep.offset;
   3.118 -    *width = rep.width;
   3.119 -    *bank_size = rep.bank_size;
   3.120 -    *ram_size = rep.ram_size;
   3.121 -
   3.122 -    UnlockDisplay(dpy);
   3.123 -    SyncHandle();
   3.124 -    return True;
   3.125 -}
   3.126 -
   3.127 -
   3.128 -Bool SDL_NAME(XF86DGADirectVideoLL) (Display * dpy, int screen, int enable)
   3.129 -{
   3.130 -    XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy);
   3.131 -    xXF86DGADirectVideoReq *req;
   3.132 -
   3.133 -    XF86DGACheckExtension(dpy, info, False);
   3.134 -
   3.135 -    LockDisplay(dpy);
   3.136 -    GetReq(XF86DGADirectVideo, req);
   3.137 -    req->reqType = info->codes->major_opcode;
   3.138 -    req->dgaReqType = X_XF86DGADirectVideo;
   3.139 -    req->screen = screen;
   3.140 -    req->enable = enable;
   3.141 -    UnlockDisplay(dpy);
   3.142 -    SyncHandle();
   3.143 -    XSync(dpy, False);
   3.144 -    return True;
   3.145 -}
   3.146 -
   3.147 -Bool SDL_NAME(XF86DGAGetViewPortSize) (Display * dpy,
   3.148 -                                       int screen, int *width, int *height)
   3.149 -{
   3.150 -    XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy);
   3.151 -    xXF86DGAGetViewPortSizeReply rep;
   3.152 -    xXF86DGAGetViewPortSizeReq *req;
   3.153 -
   3.154 -    XF86DGACheckExtension(dpy, info, False);
   3.155 -
   3.156 -    LockDisplay(dpy);
   3.157 -    GetReq(XF86DGAGetViewPortSize, req);
   3.158 -    req->reqType = info->codes->major_opcode;
   3.159 -    req->dgaReqType = X_XF86DGAGetViewPortSize;
   3.160 -    req->screen = screen;
   3.161 -    if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
   3.162 -        UnlockDisplay(dpy);
   3.163 -        SyncHandle();
   3.164 -        return False;
   3.165 -    }
   3.166 -
   3.167 -    *width = rep.width;
   3.168 -    *height = rep.height;
   3.169 -
   3.170 -    UnlockDisplay(dpy);
   3.171 -    SyncHandle();
   3.172 -    return True;
   3.173 -}
   3.174 -
   3.175 -
   3.176 -Bool SDL_NAME(XF86DGASetViewPort) (Display * dpy, int screen, int x, int y)
   3.177 -{
   3.178 -    XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy);
   3.179 -    xXF86DGASetViewPortReq *req;
   3.180 -
   3.181 -    XF86DGACheckExtension(dpy, info, False);
   3.182 -
   3.183 -    LockDisplay(dpy);
   3.184 -    GetReq(XF86DGASetViewPort, req);
   3.185 -    req->reqType = info->codes->major_opcode;
   3.186 -    req->dgaReqType = X_XF86DGASetViewPort;
   3.187 -    req->screen = screen;
   3.188 -    req->x = x;
   3.189 -    req->y = y;
   3.190 -    UnlockDisplay(dpy);
   3.191 -    SyncHandle();
   3.192 -    XSync(dpy, False);
   3.193 -    return True;
   3.194 -}
   3.195 -
   3.196 -
   3.197 -Bool SDL_NAME(XF86DGAGetVidPage) (Display * dpy, int screen, int *vpage)
   3.198 -{
   3.199 -    XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy);
   3.200 -    xXF86DGAGetVidPageReply rep;
   3.201 -    xXF86DGAGetVidPageReq *req;
   3.202 -
   3.203 -    XF86DGACheckExtension(dpy, info, False);
   3.204 -
   3.205 -    LockDisplay(dpy);
   3.206 -    GetReq(XF86DGAGetVidPage, req);
   3.207 -    req->reqType = info->codes->major_opcode;
   3.208 -    req->dgaReqType = X_XF86DGAGetVidPage;
   3.209 -    req->screen = screen;
   3.210 -    if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
   3.211 -        UnlockDisplay(dpy);
   3.212 -        SyncHandle();
   3.213 -        return False;
   3.214 -    }
   3.215 -
   3.216 -    *vpage = rep.vpage;
   3.217 -    UnlockDisplay(dpy);
   3.218 -    SyncHandle();
   3.219 -    return True;
   3.220 -}
   3.221 -
   3.222 -
   3.223 -Bool SDL_NAME(XF86DGASetVidPage) (Display * dpy, int screen, int vpage)
   3.224 -{
   3.225 -    XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy);
   3.226 -    xXF86DGASetVidPageReq *req;
   3.227 -
   3.228 -    XF86DGACheckExtension(dpy, info, False);
   3.229 -
   3.230 -    LockDisplay(dpy);
   3.231 -    GetReq(XF86DGASetVidPage, req);
   3.232 -    req->reqType = info->codes->major_opcode;
   3.233 -    req->dgaReqType = X_XF86DGASetVidPage;
   3.234 -    req->screen = screen;
   3.235 -    req->vpage = vpage;
   3.236 -    UnlockDisplay(dpy);
   3.237 -    SyncHandle();
   3.238 -    XSync(dpy, False);
   3.239 -    return True;
   3.240 -}
   3.241 -
   3.242 -Bool SDL_NAME(XF86DGAInstallColormap) (Display * dpy,
   3.243 -                                       int screen, Colormap cmap)
   3.244 -{
   3.245 -    XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy);
   3.246 -    xXF86DGAInstallColormapReq *req;
   3.247 -
   3.248 -    XF86DGACheckExtension(dpy, info, False);
   3.249 -
   3.250 -    LockDisplay(dpy);
   3.251 -    GetReq(XF86DGAInstallColormap, req);
   3.252 -    req->reqType = info->codes->major_opcode;
   3.253 -    req->dgaReqType = X_XF86DGAInstallColormap;
   3.254 -    req->screen = screen;
   3.255 -    req->id = cmap;
   3.256 -    UnlockDisplay(dpy);
   3.257 -    SyncHandle();
   3.258 -    XSync(dpy, False);
   3.259 -    return True;
   3.260 -}
   3.261 -
   3.262 -Bool SDL_NAME(XF86DGAQueryDirectVideo) (Display * dpy, int screen, int *flags)
   3.263 -{
   3.264 -    XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy);
   3.265 -    xXF86DGAQueryDirectVideoReply rep;
   3.266 -    xXF86DGAQueryDirectVideoReq *req;
   3.267 -
   3.268 -    XF86DGACheckExtension(dpy, info, False);
   3.269 -
   3.270 -    LockDisplay(dpy);
   3.271 -    GetReq(XF86DGAQueryDirectVideo, req);
   3.272 -    req->reqType = info->codes->major_opcode;
   3.273 -    req->dgaReqType = X_XF86DGAQueryDirectVideo;
   3.274 -    req->screen = screen;
   3.275 -    if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
   3.276 -        UnlockDisplay(dpy);
   3.277 -        SyncHandle();
   3.278 -        return False;
   3.279 -    }
   3.280 -    *flags = rep.flags;
   3.281 -    UnlockDisplay(dpy);
   3.282 -    SyncHandle();
   3.283 -    return True;
   3.284 -}
   3.285 -
   3.286 -Bool SDL_NAME(XF86DGAViewPortChanged) (Display * dpy, int screen, int n)
   3.287 -{
   3.288 -    XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy);
   3.289 -    xXF86DGAViewPortChangedReply rep;
   3.290 -    xXF86DGAViewPortChangedReq *req;
   3.291 -
   3.292 -    XF86DGACheckExtension(dpy, info, False);
   3.293 -
   3.294 -    LockDisplay(dpy);
   3.295 -    GetReq(XF86DGAViewPortChanged, req);
   3.296 -    req->reqType = info->codes->major_opcode;
   3.297 -    req->dgaReqType = X_XF86DGAViewPortChanged;
   3.298 -    req->screen = screen;
   3.299 -    req->n = n;
   3.300 -    if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
   3.301 -        UnlockDisplay(dpy);
   3.302 -        SyncHandle();
   3.303 -        return False;
   3.304 -    }
   3.305 -    UnlockDisplay(dpy);
   3.306 -    SyncHandle();
   3.307 -    return rep.result;
   3.308 -}
   3.309 -
   3.310 -
   3.311 -
   3.312 -/* Helper functions */
   3.313 -
   3.314 -#include <X11/Xmd.h>
   3.315 -#include "../extensions/xf86dga.h"
   3.316 -#include <stdlib.h>
   3.317 -#include <stdio.h>
   3.318 -#include <fcntl.h>
   3.319 -#if defined(ISC)
   3.320 -# define HAS_SVR3_MMAP
   3.321 -# include <sys/types.h>
   3.322 -# include <errno.h>
   3.323 -
   3.324 -# include <sys/at_ansi.h>
   3.325 -# include <sys/kd.h>
   3.326 -
   3.327 -# include <sys/sysmacros.h>
   3.328 -# include <sys/immu.h>
   3.329 -# include <sys/region.h>
   3.330 -
   3.331 -# include <sys/mmap.h>
   3.332 -#else
   3.333 -# if !defined(Lynx)
   3.334 -#  if !defined(__EMX__)
   3.335 -#   include <sys/mman.h>
   3.336 -#  endif
   3.337 -# else
   3.338 -#  include <sys/types.h>
   3.339 -#  include <errno.h>
   3.340 -#  include <smem.h>
   3.341 -# endif
   3.342 -#endif
   3.343 -#include <sys/wait.h>
   3.344 -#include <signal.h>
   3.345 -#include <unistd.h>
   3.346 -
   3.347 -#if defined(SVR4) && !defined(sun) && !defined(SCO325)
   3.348 -#define DEV_MEM "/dev/pmem"
   3.349 -#elif defined(SVR4) && defined(sun)
   3.350 -#define DEV_MEM "/dev/xsvc"
   3.351 -#else
   3.352 -#define DEV_MEM "/dev/mem"
   3.353 -#endif
   3.354 -
   3.355 -typedef struct
   3.356 -{
   3.357 -    unsigned long physaddr;     /* actual requested physical address */
   3.358 -    unsigned long size;         /* actual requested map size */
   3.359 -    unsigned long delta;        /* delta to account for page alignment */
   3.360 -    void *vaddr;                /* mapped address, without the delta */
   3.361 -    int refcount;               /* reference count */
   3.362 -} MapRec, *MapPtr;
   3.363 -
   3.364 -typedef struct
   3.365 -{
   3.366 -    Display *display;
   3.367 -    int screen;
   3.368 -    MapPtr map;
   3.369 -} ScrRec, *ScrPtr;
   3.370 -
   3.371 -static int mapFd = -1;
   3.372 -static int numMaps = 0;
   3.373 -static int numScrs = 0;
   3.374 -static MapPtr *mapList = NULL;
   3.375 -static ScrPtr *scrList = NULL;
   3.376 -
   3.377 -static MapPtr
   3.378 -AddMap(void)
   3.379 -{
   3.380 -    MapPtr *old;
   3.381 -
   3.382 -    old = mapList;
   3.383 -    mapList = realloc(mapList, sizeof(MapPtr) * (numMaps + 1));
   3.384 -    if (!mapList) {
   3.385 -        mapList = old;
   3.386 -        return NULL;
   3.387 -    }
   3.388 -    mapList[numMaps] = malloc(sizeof(MapRec));
   3.389 -    if (!mapList[numMaps])
   3.390 -        return NULL;
   3.391 -    return mapList[numMaps++];
   3.392 -}
   3.393 -
   3.394 -static ScrPtr
   3.395 -AddScr(void)
   3.396 -{
   3.397 -    ScrPtr *old;
   3.398 -
   3.399 -    old = scrList;
   3.400 -    scrList = realloc(scrList, sizeof(ScrPtr) * (numScrs + 1));
   3.401 -    if (!scrList) {
   3.402 -        scrList = old;
   3.403 -        return NULL;
   3.404 -    }
   3.405 -    scrList[numScrs] = malloc(sizeof(ScrRec));
   3.406 -    if (!scrList[numScrs])
   3.407 -        return NULL;
   3.408 -    return scrList[numScrs++];
   3.409 -}
   3.410 -
   3.411 -static MapPtr
   3.412 -FindMap(unsigned long address, unsigned long size)
   3.413 -{
   3.414 -    int i;
   3.415 -
   3.416 -    for (i = 0; i < numMaps; i++) {
   3.417 -        if (mapList[i]->physaddr == address && mapList[i]->size == size)
   3.418 -            return mapList[i];
   3.419 -    }
   3.420 -    return NULL;
   3.421 -}
   3.422 -
   3.423 -static ScrPtr
   3.424 -FindScr(Display * display, int screen)
   3.425 -{
   3.426 -    int i;
   3.427 -
   3.428 -    for (i = 0; i < numScrs; i++) {
   3.429 -        if (scrList[i]->display == display && scrList[i]->screen == screen)
   3.430 -            return scrList[i];
   3.431 -    }
   3.432 -    return NULL;
   3.433 -}
   3.434 -
   3.435 -static void *
   3.436 -MapPhysAddress(unsigned long address, unsigned long size)
   3.437 -{
   3.438 -    unsigned long offset, delta;
   3.439 -    int pagesize = -1;
   3.440 -    void *vaddr;
   3.441 -    MapPtr mp;
   3.442 -#if defined(ISC) && defined(HAS_SVR3_MMAP)
   3.443 -    struct kd_memloc mloc;
   3.444 -#elif defined(__EMX__)
   3.445 -    APIRET rc;
   3.446 -    ULONG action;
   3.447 -    HFILE hfd;
   3.448 -#endif
   3.449 -
   3.450 -    if ((mp = FindMap(address, size))) {
   3.451 -        mp->refcount++;
   3.452 -        return (void *) ((unsigned long) mp->vaddr + mp->delta);
   3.453 -    }
   3.454 -#if defined(_SC_PAGESIZE) && defined(HAS_SC_PAGESIZE)
   3.455 -    pagesize = sysconf(_SC_PAGESIZE);
   3.456 -#endif
   3.457 -#ifdef _SC_PAGE_SIZE
   3.458 -    if (pagesize == -1)
   3.459 -        pagesize = sysconf(_SC_PAGE_SIZE);
   3.460 -#endif
   3.461 -#ifdef HAS_GETPAGESIZE
   3.462 -    if (pagesize == -1)
   3.463 -        pagesize = getpagesize();
   3.464 -#endif
   3.465 -#ifdef PAGE_SIZE
   3.466 -    if (pagesize == -1)
   3.467 -        pagesize = PAGE_SIZE;
   3.468 -#endif
   3.469 -    if (pagesize == -1)
   3.470 -        pagesize = 4096;
   3.471 -
   3.472 -    delta = address % pagesize;
   3.473 -    offset = address - delta;
   3.474 -
   3.475 -#if defined(ISC) && defined(HAS_SVR3_MMAP)
   3.476 -    if (mapFd < 0) {
   3.477 -        if ((mapFd = open("/dev/mmap", O_RDWR)) < 0)
   3.478 -            return NULL;
   3.479 -    }
   3.480 -    mloc.vaddr = (char *) 0;
   3.481 -    mloc.physaddr = (char *) offset;
   3.482 -    mloc.length = size + delta;
   3.483 -    mloc.ioflg = 1;
   3.484 -
   3.485 -    if ((vaddr = (void *) ioctl(mapFd, MAP, &mloc)) == (void *) -1)
   3.486 -        return NULL;
   3.487 -#elif defined (__EMX__)
   3.488 -    /*
   3.489 -     * Dragon warning here! /dev/pmap$ is never closed, except on progam exit.
   3.490 -     * Consecutive calling of this routine will make PMAP$ driver run out
   3.491 -     * of memory handles. Some umap/close mechanism should be provided
   3.492 -     */
   3.493 -
   3.494 -    rc = DosOpen("/dev/pmap$", &hfd, &action, 0, FILE_NORMAL, FILE_OPEN,
   3.495 -                 OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE, (PEAOP2) NULL);
   3.496 -    if (rc != 0)
   3.497 -        return NULL;
   3.498 -    {
   3.499 -        struct map_ioctl
   3.500 -        {
   3.501 -            union
   3.502 -            {
   3.503 -                ULONG phys;
   3.504 -                void *user;
   3.505 -            } a;
   3.506 -            ULONG size;
   3.507 -        } pmap, dmap;
   3.508 -        ULONG plen, dlen;
   3.509 -#define XFREE86_PMAP	0x76
   3.510 -#define PMAP_MAP	0x44
   3.511 -
   3.512 -        pmap.a.phys = offset;
   3.513 -        pmap.size = size + delta;
   3.514 -        rc = DosDevIOCtl(hfd, XFREE86_PMAP, PMAP_MAP,
   3.515 -                         (PULONG) & pmap, sizeof(pmap), &plen,
   3.516 -                         (PULONG) & dmap, sizeof(dmap), &dlen);
   3.517 -        if (rc == 0) {
   3.518 -            vaddr = dmap.a.user;
   3.519 -        }
   3.520 -    }
   3.521 -    if (rc != 0)
   3.522 -        return NULL;
   3.523 -#elif defined (Lynx)
   3.524 -    vaddr = (void *) smem_create("XF86DGA", (char *) offset,
   3.525 -                                 size + delta, SM_READ | SM_WRITE);
   3.526 -#else
   3.527 -#ifndef MAP_FILE
   3.528 -#define MAP_FILE 0
   3.529 -#endif
   3.530 -    if (mapFd < 0) {
   3.531 -        if ((mapFd = open(DEV_MEM, O_RDWR)) < 0)
   3.532 -            return NULL;
   3.533 -    }
   3.534 -    vaddr = (void *) mmap(NULL, size + delta, PROT_READ | PROT_WRITE,
   3.535 -                          MAP_FILE | MAP_SHARED, mapFd, (off_t) offset);
   3.536 -    if (vaddr == (void *) -1)
   3.537 -        return NULL;
   3.538 -#endif
   3.539 -
   3.540 -    if (!vaddr) {
   3.541 -        if (!(mp = AddMap()))
   3.542 -            return NULL;
   3.543 -        mp->physaddr = address;
   3.544 -        mp->size = size;
   3.545 -        mp->delta = delta;
   3.546 -        mp->vaddr = vaddr;
   3.547 -        mp->refcount = 1;
   3.548 -    }
   3.549 -    return (void *) ((unsigned long) vaddr + delta);
   3.550 -}
   3.551 -
   3.552 -/*
   3.553 - * Still need to find a clean way of detecting the death of a DGA app
   3.554 - * and returning things to normal - Jon
   3.555 - * This is here to help debugging without rebooting... Also C-A-BS
   3.556 - * should restore text mode.
   3.557 - */
   3.558 -
   3.559 -int SDL_NAME(XF86DGAForkApp) (int screen)
   3.560 -{
   3.561 -    pid_t pid;
   3.562 -    int status;
   3.563 -    int i;
   3.564 -
   3.565 -    /* fork the app, parent hangs around to clean up */
   3.566 -    if ((pid = fork()) > 0) {
   3.567 -        ScrPtr sp;
   3.568 -
   3.569 -        waitpid(pid, &status, 0);
   3.570 -        for (i = 0; i < numScrs; i++) {
   3.571 -            sp = scrList[i];
   3.572 -            SDL_NAME(XF86DGADirectVideoLL) (sp->display, sp->screen, 0);
   3.573 -            XSync(sp->display, False);
   3.574 -        }
   3.575 -        if (WIFEXITED(status))
   3.576 -            _exit(0);
   3.577 -        else
   3.578 -            _exit(-1);
   3.579 -    }
   3.580 -    return pid;
   3.581 -}
   3.582 -
   3.583 -
   3.584 -Bool SDL_NAME(XF86DGADirectVideo) (Display * dis, int screen, int enable)
   3.585 -{
   3.586 -    ScrPtr sp;
   3.587 -    MapPtr mp = NULL;
   3.588 -
   3.589 -    if ((sp = FindScr(dis, screen)))
   3.590 -        mp = sp->map;
   3.591 -
   3.592 -    if (enable & XF86DGADirectGraphics) {
   3.593 -#if !defined(ISC) && !defined(HAS_SVR3_MMAP) && !defined(Lynx) \
   3.594 -	&& !defined(__EMX__)
   3.595 -        if (mp && mp->vaddr)
   3.596 -            mprotect(mp->vaddr, mp->size + mp->delta, PROT_READ | PROT_WRITE);
   3.597 -#endif
   3.598 -    } else {
   3.599 -#if !defined(ISC) && !defined(HAS_SVR3_MMAP) && !defined(Lynx) \
   3.600 -	&& !defined(__EMX__)
   3.601 -        if (mp && mp->vaddr)
   3.602 -            mprotect(mp->vaddr, mp->size + mp->delta, PROT_READ);
   3.603 -#elif defined(Lynx)
   3.604 -        /* XXX this doesn't allow enable after disable */
   3.605 -        smem_create(NULL, mp->vaddr, mp->size + mp->delta, SM_DETACH);
   3.606 -        smem_remove("XF86DGA");
   3.607 -#endif
   3.608 -    }
   3.609 -
   3.610 -    SDL_NAME(XF86DGADirectVideoLL) (dis, screen, enable);
   3.611 -    return 1;
   3.612 -}
   3.613 -
   3.614 -
   3.615 -static void
   3.616 -XF86cleanup(int sig)
   3.617 -{
   3.618 -    ScrPtr sp;
   3.619 -    int i;
   3.620 -    static char beenhere = 0;
   3.621 -
   3.622 -    if (beenhere)
   3.623 -        _exit(3);
   3.624 -    beenhere = 1;
   3.625 -
   3.626 -    for (i = 0; i < numScrs; i++) {
   3.627 -        sp = scrList[i];
   3.628 -        SDL_NAME(XF86DGADirectVideo) (sp->display, sp->screen, 0);
   3.629 -        XSync(sp->display, False);
   3.630 -    }
   3.631 -    _exit(3);
   3.632 -}
   3.633 -
   3.634 -Bool
   3.635 -SDL_NAME(XF86DGAGetVideo) (Display * dis,
   3.636 -                           int screen,
   3.637 -                           char **addr, int *width, int *bank, int *ram)
   3.638 -{
   3.639 -    /*unsigned long */ int offset;
   3.640 -    static int beenHere = 0;
   3.641 -    ScrPtr sp;
   3.642 -    MapPtr mp;
   3.643 -
   3.644 -    if (!(sp = FindScr(dis, screen))) {
   3.645 -        if (!(sp = AddScr())) {
   3.646 -            fprintf(stderr, "XF86DGAGetVideo: malloc failure\n");
   3.647 -            exit(-2);
   3.648 -        }
   3.649 -        sp->display = dis;
   3.650 -        sp->screen = screen;
   3.651 -        sp->map = NULL;
   3.652 -    }
   3.653 -
   3.654 -    SDL_NAME(XF86DGAGetVideoLL) (dis, screen, &offset, width, bank, ram);
   3.655 -
   3.656 -    *addr = MapPhysAddress(offset, *bank);
   3.657 -    if (*addr == NULL) {
   3.658 -        fprintf(stderr,
   3.659 -                "XF86DGAGetVideo: failed to map video memory (%s)\n",
   3.660 -                strerror(errno));
   3.661 -        exit(-2);
   3.662 -    }
   3.663 -
   3.664 -    if ((mp = FindMap(offset, *bank)))
   3.665 -        sp->map = mp;
   3.666 -
   3.667 -    if (!beenHere) {
   3.668 -        beenHere = 1;
   3.669 -        atexit((void (*)(void)) XF86cleanup);
   3.670 -        /* one shot XF86cleanup attempts */
   3.671 -        signal(SIGSEGV, XF86cleanup);
   3.672 -#ifdef SIGBUS
   3.673 -        signal(SIGBUS, XF86cleanup);
   3.674 -#endif
   3.675 -        signal(SIGHUP, XF86cleanup);
   3.676 -        signal(SIGFPE, XF86cleanup);
   3.677 -    }
   3.678 -
   3.679 -    return 1;
   3.680 -}
   3.681 -
   3.682 -/* vi: set ts=4 sw=4 expandtab: */
     4.1 --- a/src/video/Xext/Xxf86dga/XF86DGA2.c	Tue Jul 25 07:25:51 2006 +0000
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,937 +0,0 @@
     4.4 -/* $XFree86: xc/lib/Xxf86dga/XF86DGA2.c,v 1.18 2001/08/17 13:27:51 dawes Exp $ */
     4.5 -/*
     4.6 -
     4.7 -Copyright (c) 1995  Jon Tombs
     4.8 -Copyright (c) 1995,1996  The XFree86 Project, Inc
     4.9 -
    4.10 -*/
    4.11 -
    4.12 -/* THIS IS NOT AN X CONSORTIUM STANDARD */
    4.13 -
    4.14 -#ifdef __EMX__                  /* needed here to override certain constants in X headers */
    4.15 -#define INCL_DOS
    4.16 -#define INCL_DOSIOCTL
    4.17 -#include <os2.h>
    4.18 -#endif
    4.19 -
    4.20 -#define NEED_EVENTS
    4.21 -#define NEED_REPLIES
    4.22 -
    4.23 -#include <X11/Xlibint.h>
    4.24 -#include "../extensions/xf86dga.h"
    4.25 -#include "../extensions/xf86dgastr.h"
    4.26 -#include "../extensions/Xext.h"
    4.27 -#include "../extensions/extutil.h"
    4.28 -#include <stdio.h>
    4.29 -
    4.30 -#if defined(ENABLE_FBCON)       /* Needed for framebuffer console support */
    4.31 -#include <sys/ioctl.h>
    4.32 -#include <linux/fb.h>
    4.33 -#endif
    4.34 -
    4.35 -/* If you change this, change the Bases[] array below as well */
    4.36 -#define MAX_HEADS 16
    4.37 -
    4.38 -char *SDL_NAME(xdga_extension_name) = XF86DGANAME;
    4.39 -
    4.40 -static XExtensionInfo _xdga_info_data;
    4.41 -static XExtensionInfo *xdga_info = &_xdga_info_data;
    4.42 -
    4.43 -
    4.44 -Bool SDL_NAME(XDGAMapFramebuffer) (int, char *, unsigned char *, CARD32,
    4.45 -                                   CARD32, CARD32);
    4.46 -void SDL_NAME(XDGAUnmapFramebuffer) (int);
    4.47 -unsigned char *SDL_NAME(XDGAGetMappedMemory) (int);
    4.48 -
    4.49 -#define XDGACheckExtension(dpy,i,val) \
    4.50 -  XextCheckExtension (dpy, i, SDL_NAME(xdga_extension_name), val)
    4.51 -
    4.52 -/*****************************************************************************
    4.53 - *                                                                           *
    4.54 - *			   private utility routines                          *
    4.55 - *                                                                           *
    4.56 - *****************************************************************************/
    4.57 -
    4.58 -static int xdga_close_display(Display * dpy, XExtCodes * codes);
    4.59 -static Bool xdga_wire_to_event(Display * dpy, XEvent * event,
    4.60 -                               xEvent * wire_ev);
    4.61 -static Status xdga_event_to_wire(Display * dpy, XEvent * event,
    4.62 -                                 xEvent * wire_ev);
    4.63 -
    4.64 -static XExtensionHooks xdga_extension_hooks = {
    4.65 -    NULL,                       /* create_gc */
    4.66 -    NULL,                       /* copy_gc */
    4.67 -    NULL,                       /* flush_gc */
    4.68 -    NULL,                       /* free_gc */
    4.69 -    NULL,                       /* create_font */
    4.70 -    NULL,                       /* free_font */
    4.71 -    xdga_close_display,         /* close_display */
    4.72 -    xdga_wire_to_event,         /* wire_to_event */
    4.73 -    xdga_event_to_wire,         /* event_to_wire */
    4.74 -    NULL,                       /* error */
    4.75 -    NULL,                       /* error_string */
    4.76 -};
    4.77 -
    4.78 -static
    4.79 -XEXT_GENERATE_CLOSE_DISPLAY(xdga_close_display, xdga_info)
    4.80 -XEXT_GENERATE_FIND_DISPLAY(SDL_NAME(xdga_find_display), xdga_info,
    4.81 -                           "XFree86-DGA", &xdga_extension_hooks, 0, NULL)
    4.82 -     static Status
    4.83 -         xdga_event_to_wire(Display * dpy, XEvent * event, xEvent * wire_ev)
    4.84 -{
    4.85 -    return True;
    4.86 -}
    4.87 -
    4.88 -static Bool
    4.89 -xdga_wire_to_event(Display * dpy, XEvent * event, xEvent * wire_ev)
    4.90 -{
    4.91 -    dgaEvent *wire = (dgaEvent *) wire_ev;
    4.92 -    SDL_NAME(XDGAButtonEvent) * bevent;
    4.93 -    SDL_NAME(XDGAKeyEvent) * kevent;
    4.94 -    SDL_NAME(XDGAMotionEvent) * mevent;
    4.95 -    XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy);
    4.96 -
    4.97 -    XDGACheckExtension(dpy, info, False);
    4.98 -
    4.99 -    switch ((wire->u.u.type & 0x7f) - info->codes->first_event) {
   4.100 -    case MotionNotify:
   4.101 -        mevent = (SDL_NAME(XDGAMotionEvent) *) event;
   4.102 -        mevent->type = wire->u.u.type & 0x7F;
   4.103 -        mevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire);
   4.104 -        mevent->display = dpy;
   4.105 -        mevent->screen = wire->u.event.screen;
   4.106 -        mevent->time = wire->u.event.time;
   4.107 -        mevent->state = wire->u.event.state;
   4.108 -        mevent->dx = wire->u.event.dx;
   4.109 -        mevent->dy = wire->u.event.dy;
   4.110 -        return True;
   4.111 -    case ButtonPress:
   4.112 -    case ButtonRelease:
   4.113 -        bevent = (SDL_NAME(XDGAButtonEvent) *) event;
   4.114 -        bevent->type = wire->u.u.type & 0x7F;
   4.115 -        bevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire);
   4.116 -        bevent->display = dpy;
   4.117 -        bevent->screen = wire->u.event.screen;
   4.118 -        bevent->time = wire->u.event.time;
   4.119 -        bevent->state = wire->u.event.state;
   4.120 -        bevent->button = wire->u.u.detail;
   4.121 -        return True;
   4.122 -    case KeyPress:
   4.123 -    case KeyRelease:
   4.124 -        kevent = (SDL_NAME(XDGAKeyEvent) *) event;
   4.125 -        kevent->type = wire->u.u.type & 0x7F;
   4.126 -        kevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire);
   4.127 -        kevent->display = dpy;
   4.128 -        kevent->screen = wire->u.event.screen;
   4.129 -        kevent->time = wire->u.event.time;
   4.130 -        kevent->state = wire->u.event.state;
   4.131 -        kevent->keycode = wire->u.u.detail;
   4.132 -        return True;
   4.133 -    }
   4.134 -
   4.135 -    return False;
   4.136 -}
   4.137 -
   4.138 -
   4.139 -Bool SDL_NAME(XDGAQueryExtension) (Display * dpy,
   4.140 -                                   int *event_basep, int *error_basep)
   4.141 -{
   4.142 -    XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy);
   4.143 -
   4.144 -    if (XextHasExtension(info)) {
   4.145 -        *event_basep = info->codes->first_event;
   4.146 -        *error_basep = info->codes->first_error;
   4.147 -        return True;
   4.148 -    } else {
   4.149 -        return False;
   4.150 -    }
   4.151 -}
   4.152 -
   4.153 -
   4.154 -Bool SDL_NAME(XDGAQueryVersion) (Display * dpy,
   4.155 -                                 int *majorVersion, int *minorVersion)
   4.156 -{
   4.157 -    XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy);
   4.158 -    xXDGAQueryVersionReply rep;
   4.159 -    xXDGAQueryVersionReq *req;
   4.160 -
   4.161 -    XDGACheckExtension(dpy, info, False);
   4.162 -
   4.163 -    LockDisplay(dpy);
   4.164 -    GetReq(XDGAQueryVersion, req);
   4.165 -    req->reqType = info->codes->major_opcode;
   4.166 -    req->dgaReqType = X_XDGAQueryVersion;
   4.167 -    if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
   4.168 -        UnlockDisplay(dpy);
   4.169 -        SyncHandle();
   4.170 -        return False;
   4.171 -    }
   4.172 -    *majorVersion = rep.majorVersion;
   4.173 -    *minorVersion = rep.minorVersion;
   4.174 -    UnlockDisplay(dpy);
   4.175 -    SyncHandle();
   4.176 -    if (*majorVersion >= 2) {
   4.177 -        int i, j;
   4.178 -
   4.179 -        for (i = 0, j = info->codes->first_event;
   4.180 -             i < XF86DGANumberEvents; i++, j++) {
   4.181 -            XESetWireToEvent(dpy, j, xdga_wire_to_event);
   4.182 -            XESetEventToWire(dpy, j, xdga_event_to_wire);
   4.183 -        }
   4.184 -        SDL_NAME(XDGASetClientVersion) (dpy);
   4.185 -    }
   4.186 -    return True;
   4.187 -}
   4.188 -
   4.189 -Bool SDL_NAME(XDGASetClientVersion) (Display * dpy)
   4.190 -{
   4.191 -    XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy);
   4.192 -    xXDGASetClientVersionReq *req;
   4.193 -
   4.194 -    XDGACheckExtension(dpy, info, False);
   4.195 -
   4.196 -    LockDisplay(dpy);
   4.197 -    GetReq(XDGASetClientVersion, req);
   4.198 -    req->reqType = info->codes->major_opcode;
   4.199 -    req->dgaReqType = X_XDGASetClientVersion;
   4.200 -    req->major = XDGA_MAJOR_VERSION;
   4.201 -    req->minor = XDGA_MINOR_VERSION;
   4.202 -    UnlockDisplay(dpy);
   4.203 -    SyncHandle();
   4.204 -    return True;
   4.205 -}
   4.206 -
   4.207 -Bool SDL_NAME(XDGAOpenFramebuffer) (Display * dpy, int screen)
   4.208 -{
   4.209 -    XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy);
   4.210 -    xXDGAOpenFramebufferReply rep;
   4.211 -    xXDGAOpenFramebufferReq *req;
   4.212 -    char *deviceName = NULL;
   4.213 -    Bool ret;
   4.214 -
   4.215 -    XDGACheckExtension(dpy, info, False);
   4.216 -
   4.217 -    LockDisplay(dpy);
   4.218 -    GetReq(XDGAOpenFramebuffer, req);
   4.219 -    req->reqType = info->codes->major_opcode;
   4.220 -    req->dgaReqType = X_XDGAOpenFramebuffer;
   4.221 -    req->screen = screen;
   4.222 -    if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
   4.223 -        UnlockDisplay(dpy);
   4.224 -        SyncHandle();
   4.225 -        return False;
   4.226 -    }
   4.227 -
   4.228 -    if (rep.length) {
   4.229 -        deviceName = Xmalloc(rep.length << 2);
   4.230 -        _XRead(dpy, deviceName, rep.length << 2);
   4.231 -    }
   4.232 -
   4.233 -    ret = SDL_NAME(XDGAMapFramebuffer) (screen, deviceName,
   4.234 -                                        (unsigned char *) (long) rep.mem1,
   4.235 -                                        rep.size, rep.offset, rep.extra);
   4.236 -
   4.237 -    if (deviceName)
   4.238 -        Xfree(deviceName);
   4.239 -
   4.240 -    UnlockDisplay(dpy);
   4.241 -    SyncHandle();
   4.242 -    return ret;
   4.243 -}
   4.244 -
   4.245 -void SDL_NAME(XDGACloseFramebuffer) (Display * dpy, int screen)
   4.246 -{
   4.247 -    XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy);
   4.248 -    xXDGACloseFramebufferReq *req;
   4.249 -
   4.250 -    XextSimpleCheckExtension(dpy, info, SDL_NAME(xdga_extension_name));
   4.251 -
   4.252 -    SDL_NAME(XDGAUnmapFramebuffer) (screen);
   4.253 -
   4.254 -    LockDisplay(dpy);
   4.255 -    GetReq(XDGACloseFramebuffer, req);
   4.256 -    req->reqType = info->codes->major_opcode;
   4.257 -    req->dgaReqType = X_XDGACloseFramebuffer;
   4.258 -    req->screen = screen;
   4.259 -    UnlockDisplay(dpy);
   4.260 -    SyncHandle();
   4.261 -}
   4.262 -
   4.263 -
   4.264 -
   4.265 -SDL_NAME(XDGAMode) * SDL_NAME(XDGAQueryModes) (Display * dpy,
   4.266 -                                               int screen, int *num)
   4.267 -{
   4.268 -    XExtDisplayInfo *dinfo = SDL_NAME(xdga_find_display) (dpy);
   4.269 -    xXDGAQueryModesReply rep;
   4.270 -    xXDGAQueryModesReq *req;
   4.271 -    SDL_NAME(XDGAMode) * modes = NULL;
   4.272 -
   4.273 -    *num = 0;
   4.274 -
   4.275 -    XDGACheckExtension(dpy, dinfo, NULL);
   4.276 -
   4.277 -    LockDisplay(dpy);
   4.278 -    GetReq(XDGAQueryModes, req);
   4.279 -    req->reqType = dinfo->codes->major_opcode;
   4.280 -    req->dgaReqType = X_XDGAQueryModes;
   4.281 -    req->screen = screen;
   4.282 -
   4.283 -    if (_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
   4.284 -        if (rep.length) {
   4.285 -            xXDGAModeInfo info;
   4.286 -            int i, size;
   4.287 -            char *offset;
   4.288 -
   4.289 -            size = rep.length << 2;
   4.290 -            size -= rep.number * sz_xXDGAModeInfo;      /* find text size */
   4.291 -            modes = (SDL_NAME(XDGAMode) *)
   4.292 -                Xmalloc((rep.number * sizeof(SDL_NAME(XDGAMode))) + size);
   4.293 -            offset = (char *) (&modes[rep.number]);     /* start of text */
   4.294 -
   4.295 -
   4.296 -            if (modes) {
   4.297 -                for (i = 0; i < rep.number; i++) {
   4.298 -                    _XRead(dpy, (char *) (&info), sz_xXDGAModeInfo);
   4.299 -
   4.300 -                    modes[i].num = info.num;
   4.301 -                    modes[i].verticalRefresh =
   4.302 -                        (float) info.vsync_num / (float) info.vsync_den;
   4.303 -                    modes[i].flags = info.flags;
   4.304 -                    modes[i].imageWidth = info.image_width;
   4.305 -                    modes[i].imageHeight = info.image_height;
   4.306 -                    modes[i].pixmapWidth = info.pixmap_width;
   4.307 -                    modes[i].pixmapHeight = info.pixmap_height;
   4.308 -                    modes[i].bytesPerScanline = info.bytes_per_scanline;
   4.309 -                    modes[i].byteOrder = info.byte_order;
   4.310 -                    modes[i].depth = info.depth;
   4.311 -                    modes[i].bitsPerPixel = info.bpp;
   4.312 -                    modes[i].redMask = info.red_mask;
   4.313 -                    modes[i].greenMask = info.green_mask;
   4.314 -                    modes[i].blueMask = info.blue_mask;
   4.315 -                    modes[i].visualClass = info.visual_class;
   4.316 -                    modes[i].viewportWidth = info.viewport_width;
   4.317 -                    modes[i].viewportHeight = info.viewport_height;
   4.318 -                    modes[i].xViewportStep = info.viewport_xstep;
   4.319 -                    modes[i].yViewportStep = info.viewport_ystep;
   4.320 -                    modes[i].maxViewportX = info.viewport_xmax;
   4.321 -                    modes[i].maxViewportY = info.viewport_ymax;
   4.322 -                    modes[i].viewportFlags = info.viewport_flags;
   4.323 -                    modes[i].reserved1 = info.reserved1;
   4.324 -                    modes[i].reserved2 = info.reserved2;
   4.325 -
   4.326 -                    _XRead(dpy, offset, info.name_size);
   4.327 -                    modes[i].name = offset;
   4.328 -                    offset += info.name_size;
   4.329 -                }
   4.330 -                *num = rep.number;
   4.331 -            } else
   4.332 -                _XEatData(dpy, rep.length << 2);
   4.333 -        }
   4.334 -    }
   4.335 -
   4.336 -    UnlockDisplay(dpy);
   4.337 -    SyncHandle();
   4.338 -
   4.339 -    return modes;
   4.340 -}
   4.341 -
   4.342 -
   4.343 -SDL_NAME(XDGADevice) *
   4.344 -SDL_NAME(XDGASetMode) (Display * dpy, int screen, int mode)
   4.345 -{
   4.346 -    XExtDisplayInfo *dinfo = SDL_NAME(xdga_find_display) (dpy);
   4.347 -    xXDGASetModeReply rep;
   4.348 -    xXDGASetModeReq *req;
   4.349 -    SDL_NAME(XDGADevice) * dev = NULL;
   4.350 -    Pixmap pid;
   4.351 -
   4.352 -    XDGACheckExtension(dpy, dinfo, NULL);
   4.353 -
   4.354 -    LockDisplay(dpy);
   4.355 -    GetReq(XDGASetMode, req);
   4.356 -    req->reqType = dinfo->codes->major_opcode;
   4.357 -    req->dgaReqType = X_XDGASetMode;
   4.358 -    req->screen = screen;
   4.359 -    req->mode = mode;
   4.360 -    req->pid = pid = XAllocID(dpy);
   4.361 -
   4.362 -    if (_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
   4.363 -        if (rep.length) {
   4.364 -            xXDGAModeInfo info;
   4.365 -            int size;
   4.366 -
   4.367 -            size = rep.length << 2;
   4.368 -            size -= sz_xXDGAModeInfo;   /* get text size */
   4.369 -
   4.370 -            dev = (SDL_NAME(XDGADevice) *)
   4.371 -                Xmalloc(sizeof(SDL_NAME(XDGADevice)) + size);
   4.372 -
   4.373 -            if (dev) {
   4.374 -                _XRead(dpy, (char *) (&info), sz_xXDGAModeInfo);
   4.375 -
   4.376 -                dev->mode.num = info.num;
   4.377 -                dev->mode.verticalRefresh =
   4.378 -                    (float) info.vsync_num / (float) info.vsync_den;
   4.379 -                dev->mode.flags = info.flags;
   4.380 -                dev->mode.imageWidth = info.image_width;
   4.381 -                dev->mode.imageHeight = info.image_height;
   4.382 -                dev->mode.pixmapWidth = info.pixmap_width;
   4.383 -                dev->mode.pixmapHeight = info.pixmap_height;
   4.384 -                dev->mode.bytesPerScanline = info.bytes_per_scanline;
   4.385 -                dev->mode.byteOrder = info.byte_order;
   4.386 -                dev->mode.depth = info.depth;
   4.387 -                dev->mode.bitsPerPixel = info.bpp;
   4.388 -                dev->mode.redMask = info.red_mask;
   4.389 -                dev->mode.greenMask = info.green_mask;
   4.390 -                dev->mode.blueMask = info.blue_mask;
   4.391 -                dev->mode.visualClass = info.visual_class;
   4.392 -                dev->mode.viewportWidth = info.viewport_width;
   4.393 -                dev->mode.viewportHeight = info.viewport_height;
   4.394 -                dev->mode.xViewportStep = info.viewport_xstep;
   4.395 -                dev->mode.yViewportStep = info.viewport_ystep;
   4.396 -                dev->mode.maxViewportX = info.viewport_xmax;
   4.397 -                dev->mode.maxViewportY = info.viewport_ymax;
   4.398 -                dev->mode.viewportFlags = info.viewport_flags;
   4.399 -                dev->mode.reserved1 = info.reserved1;
   4.400 -                dev->mode.reserved2 = info.reserved2;
   4.401 -
   4.402 -                dev->mode.name = (char *) (&dev[1]);
   4.403 -                _XRead(dpy, dev->mode.name, info.name_size);
   4.404 -
   4.405 -                dev->pixmap = (rep.flags & XDGAPixmap) ? pid : 0;
   4.406 -                dev->data = SDL_NAME(XDGAGetMappedMemory) (screen);
   4.407 -
   4.408 -                if (dev->data)
   4.409 -                    dev->data += rep.offset;
   4.410 -            }
   4.411 -            /* not sure what to do if the allocation fails */
   4.412 -        }
   4.413 -    }
   4.414 -
   4.415 -    UnlockDisplay(dpy);
   4.416 -    SyncHandle();
   4.417 -
   4.418 -    return dev;
   4.419 -}
   4.420 -
   4.421 -
   4.422 -void SDL_NAME(XDGASetViewport) (Display * dpy,
   4.423 -                                int screen, int x, int y, int flags)
   4.424 -{
   4.425 -    XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy);
   4.426 -    xXDGASetViewportReq *req;
   4.427 -
   4.428 -    XextSimpleCheckExtension(dpy, info, SDL_NAME(xdga_extension_name));
   4.429 -
   4.430 -    LockDisplay(dpy);
   4.431 -    GetReq(XDGASetViewport, req);
   4.432 -    req->reqType = info->codes->major_opcode;
   4.433 -    req->dgaReqType = X_XDGASetViewport;
   4.434 -    req->screen = screen;
   4.435 -    req->x = x;
   4.436 -    req->y = y;
   4.437 -    req->flags = flags;
   4.438 -    UnlockDisplay(dpy);
   4.439 -    SyncHandle();
   4.440 -}
   4.441 -
   4.442 -
   4.443 -void SDL_NAME(XDGAInstallColormap) (Display * dpy, int screen, Colormap cmap)
   4.444 -{
   4.445 -    XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy);
   4.446 -    xXDGAInstallColormapReq *req;
   4.447 -
   4.448 -    XextSimpleCheckExtension(dpy, info, SDL_NAME(xdga_extension_name));
   4.449 -
   4.450 -    LockDisplay(dpy);
   4.451 -    GetReq(XDGAInstallColormap, req);
   4.452 -    req->reqType = info->codes->major_opcode;
   4.453 -    req->dgaReqType = X_XDGAInstallColormap;
   4.454 -    req->screen = screen;
   4.455 -    req->cmap = cmap;
   4.456 -    UnlockDisplay(dpy);
   4.457 -    SyncHandle();
   4.458 -}
   4.459 -
   4.460 -void SDL_NAME(XDGASelectInput) (Display * dpy, int screen, long mask)
   4.461 -{
   4.462 -    XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy);
   4.463 -    xXDGASelectInputReq *req;
   4.464 -
   4.465 -    XextSimpleCheckExtension(dpy, info, SDL_NAME(xdga_extension_name));
   4.466 -
   4.467 -    LockDisplay(dpy);
   4.468 -    GetReq(XDGASelectInput, req);
   4.469 -    req->reqType = info->codes->major_opcode;
   4.470 -    req->dgaReqType = X_XDGASelectInput;
   4.471 -    req->screen = screen;
   4.472 -    req->mask = mask;
   4.473 -    UnlockDisplay(dpy);
   4.474 -    SyncHandle();
   4.475 -}
   4.476 -
   4.477 -void SDL_NAME(XDGAFillRectangle) (Display * dpy,
   4.478 -                                  int screen,
   4.479 -                                  int x,
   4.480 -                                  int y,
   4.481 -                                  unsigned int width,
   4.482 -                                  unsigned int height, unsigned long color)
   4.483 -{
   4.484 -    XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy);
   4.485 -    xXDGAFillRectangleReq *req;
   4.486 -
   4.487 -    XextSimpleCheckExtension(dpy, info, SDL_NAME(xdga_extension_name));
   4.488 -
   4.489 -    LockDisplay(dpy);
   4.490 -    GetReq(XDGAFillRectangle, req);
   4.491 -    req->reqType = info->codes->major_opcode;
   4.492 -    req->dgaReqType = X_XDGAFillRectangle;
   4.493 -    req->screen = screen;
   4.494 -    req->x = x;
   4.495 -    req->y = y;
   4.496 -    req->width = width;
   4.497 -    req->height = height;
   4.498 -    req->color = color;
   4.499 -    UnlockDisplay(dpy);
   4.500 -    SyncHandle();
   4.501 -}
   4.502 -
   4.503 -void SDL_NAME(XDGACopyArea) (Display * dpy,
   4.504 -                             int screen,
   4.505 -                             int srcx,
   4.506 -                             int srcy,
   4.507 -                             unsigned int width,
   4.508 -                             unsigned int height, int dstx, int dsty)
   4.509 -{
   4.510 -    XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy);
   4.511 -    xXDGACopyAreaReq *req;
   4.512 -
   4.513 -    XextSimpleCheckExtension(dpy, info, SDL_NAME(xdga_extension_name));
   4.514 -
   4.515 -    LockDisplay(dpy);
   4.516 -    GetReq(XDGACopyArea, req);
   4.517 -    req->reqType = info->codes->major_opcode;
   4.518 -    req->dgaReqType = X_XDGACopyArea;
   4.519 -    req->screen = screen;
   4.520 -    req->srcx = srcx;
   4.521 -    req->srcy = srcy;
   4.522 -    req->width = width;
   4.523 -    req->height = height;
   4.524 -    req->dstx = dstx;
   4.525 -    req->dsty = dsty;
   4.526 -    UnlockDisplay(dpy);
   4.527 -    SyncHandle();
   4.528 -}
   4.529 -
   4.530 -void SDL_NAME(XDGACopyTransparentArea) (Display * dpy,
   4.531 -                                        int screen,
   4.532 -                                        int srcx,
   4.533 -                                        int srcy,
   4.534 -                                        unsigned int width,
   4.535 -                                        unsigned int height,
   4.536 -                                        int dstx, int dsty, unsigned long key)
   4.537 -{
   4.538 -    XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy);
   4.539 -    xXDGACopyTransparentAreaReq *req;
   4.540 -
   4.541 -    XextSimpleCheckExtension(dpy, info, SDL_NAME(xdga_extension_name));
   4.542 -
   4.543 -    LockDisplay(dpy);
   4.544 -    GetReq(XDGACopyTransparentArea, req);
   4.545 -    req->reqType = info->codes->major_opcode;
   4.546 -    req->dgaReqType = X_XDGACopyTransparentArea;
   4.547 -    req->screen = screen;
   4.548 -    req->srcx = srcx;
   4.549 -    req->srcy = srcy;
   4.550 -    req->width = width;
   4.551 -    req->height = height;
   4.552 -    req->dstx = dstx;
   4.553 -    req->dsty = dsty;
   4.554 -    req->key = key;
   4.555 -    UnlockDisplay(dpy);
   4.556 -    SyncHandle();
   4.557 -}
   4.558 -
   4.559 -
   4.560 -int SDL_NAME(XDGAGetViewportStatus) (Display * dpy, int screen)
   4.561 -{
   4.562 -    XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy);
   4.563 -    xXDGAGetViewportStatusReply rep;
   4.564 -    xXDGAGetViewportStatusReq *req;
   4.565 -    int status = 0;
   4.566 -
   4.567 -    XDGACheckExtension(dpy, info, 0);
   4.568 -
   4.569 -    LockDisplay(dpy);
   4.570 -    GetReq(XDGAGetViewportStatus, req);
   4.571 -    req->reqType = info->codes->major_opcode;
   4.572 -    req->dgaReqType = X_XDGAGetViewportStatus;
   4.573 -    req->screen = screen;
   4.574 -    if (!_XReply(dpy, (xReply *) & rep, 0, xFalse))
   4.575 -        status = rep.status;
   4.576 -    UnlockDisplay(dpy);
   4.577 -    SyncHandle();
   4.578 -    return status;
   4.579 -}
   4.580 -
   4.581 -void SDL_NAME(XDGASync) (Display * dpy, int screen)
   4.582 -{
   4.583 -    XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy);
   4.584 -    xXDGASyncReply rep;
   4.585 -    xXDGASyncReq *req;
   4.586 -
   4.587 -    XextSimpleCheckExtension(dpy, info, SDL_NAME(xdga_extension_name));
   4.588 -
   4.589 -    LockDisplay(dpy);
   4.590 -    GetReq(XDGASync, req);
   4.591 -    req->reqType = info->codes->major_opcode;
   4.592 -    req->dgaReqType = X_XDGASync;
   4.593 -    req->screen = screen;
   4.594 -    _XReply(dpy, (xReply *) & rep, 0, xFalse);
   4.595 -    UnlockDisplay(dpy);
   4.596 -    SyncHandle();
   4.597 -}
   4.598 -
   4.599 -
   4.600 -void SDL_NAME(XDGAChangePixmapMode) (Display * dpy,
   4.601 -                                     int screen, int *x, int *y, int mode)
   4.602 -{
   4.603 -    XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy);
   4.604 -    xXDGAChangePixmapModeReq *req;
   4.605 -    xXDGAChangePixmapModeReply rep;
   4.606 -
   4.607 -    XextSimpleCheckExtension(dpy, info, SDL_NAME(xdga_extension_name));
   4.608 -
   4.609 -    LockDisplay(dpy);
   4.610 -    GetReq(XDGAChangePixmapMode, req);
   4.611 -    req->reqType = info->codes->major_opcode;
   4.612 -    req->dgaReqType = X_XDGAChangePixmapMode;
   4.613 -    req->screen = screen;
   4.614 -    req->x = *x;
   4.615 -    req->y = *y;
   4.616 -    req->flags = mode;
   4.617 -    _XReply(dpy, (xReply *) & rep, 0, xFalse);
   4.618 -    *x = rep.x;
   4.619 -    *y = rep.y;
   4.620 -    UnlockDisplay(dpy);
   4.621 -    SyncHandle();
   4.622 -}
   4.623 -
   4.624 -Colormap SDL_NAME(XDGACreateColormap) (Display * dpy,
   4.625 -                                       int screen,
   4.626 -                                       SDL_NAME(XDGADevice) * dev, int alloc)
   4.627 -{
   4.628 -    XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy);
   4.629 -    xXDGACreateColormapReq *req;
   4.630 -    Colormap cid;
   4.631 -
   4.632 -    XDGACheckExtension(dpy, info, -1);
   4.633 -
   4.634 -    LockDisplay(dpy);
   4.635 -    GetReq(XDGACreateColormap, req);
   4.636 -    req->reqType = info->codes->major_opcode;
   4.637 -    req->dgaReqType = X_XDGACreateColormap;
   4.638 -    req->screen = screen;
   4.639 -    req->mode = dev->mode.num;
   4.640 -    req->alloc = alloc;
   4.641 -    cid = req->id = XAllocID(dpy);
   4.642 -    UnlockDisplay(dpy);
   4.643 -    SyncHandle();
   4.644 -
   4.645 -    return cid;
   4.646 -}
   4.647 -
   4.648 -
   4.649 -void SDL_NAME(XDGAKeyEventToXKeyEvent) (SDL_NAME(XDGAKeyEvent) * dk,
   4.650 -                                        XKeyEvent * xk)
   4.651 -{
   4.652 -    xk->type = dk->type;
   4.653 -    xk->serial = dk->serial;
   4.654 -    xk->send_event = False;
   4.655 -    xk->display = dk->display;
   4.656 -    xk->window = RootWindow(dk->display, dk->screen);
   4.657 -    xk->root = xk->window;
   4.658 -    xk->subwindow = None;
   4.659 -    xk->time = dk->time;
   4.660 -    xk->x = xk->y = xk->x_root = xk->y_root = 0;
   4.661 -    xk->state = dk->state;
   4.662 -    xk->keycode = dk->keycode;
   4.663 -    xk->same_screen = True;
   4.664 -}
   4.665 -
   4.666 -#include <X11/Xmd.h>
   4.667 -#include <stdlib.h>
   4.668 -#include <stdio.h>
   4.669 -#include <fcntl.h>
   4.670 -#if defined(ISC)
   4.671 -# define HAS_SVR3_MMAP
   4.672 -# include <sys/types.h>
   4.673 -# include <errno.h>
   4.674 -
   4.675 -# include <sys/at_ansi.h>
   4.676 -# include <sys/kd.h>
   4.677 -
   4.678 -# include <sys/sysmacros.h>
   4.679 -# include <sys/immu.h>
   4.680 -# include <sys/region.h>
   4.681 -
   4.682 -# include <sys/mmap.h>
   4.683 -#else
   4.684 -# if !defined(Lynx)
   4.685 -#  if !defined(__EMX__)
   4.686 -#   include <sys/mman.h>
   4.687 -#  endif
   4.688 -# else
   4.689 -#  include <sys/types.h>
   4.690 -#  include <errno.h>
   4.691 -#  include <smem.h>
   4.692 -# endif
   4.693 -#endif
   4.694 -#include <sys/wait.h>
   4.695 -#include <signal.h>
   4.696 -#include <unistd.h>
   4.697 -
   4.698 -#if defined(SVR4) && !defined(sun) && !defined(SCO325)
   4.699 -#define DEV_MEM "/dev/pmem"
   4.700 -#elif defined(SVR4) && defined(sun)
   4.701 -#define DEV_MEM "/dev/xsvc"
   4.702 -#else
   4.703 -#define DEV_MEM "/dev/mem"
   4.704 -#endif
   4.705 -
   4.706 -
   4.707 -
   4.708 -typedef struct _DGAMapRec
   4.709 -{
   4.710 -    unsigned char *physical;
   4.711 -    unsigned char *virtual;
   4.712 -    CARD32 size;
   4.713 -    int fd;
   4.714 -    int screen;
   4.715 -    struct _DGAMapRec *next;
   4.716 -} DGAMapRec, *DGAMapPtr;
   4.717 -
   4.718 -static Bool
   4.719 -DGAMapPhysical(int, char *, unsigned char *, CARD32, CARD32, CARD32,
   4.720 -               DGAMapPtr);
   4.721 -static void DGAUnmapPhysical(DGAMapPtr);
   4.722 -
   4.723 -static DGAMapPtr _Maps = NULL;
   4.724 -
   4.725 -
   4.726 -unsigned char *SDL_NAME(XDGAGetMappedMemory) (int screen)
   4.727 -{
   4.728 -    DGAMapPtr pMap = _Maps;
   4.729 -    unsigned char *pntr = NULL;
   4.730 -
   4.731 -    while (pMap != NULL) {
   4.732 -        if (pMap->screen == screen) {
   4.733 -            pntr = pMap->virtual;
   4.734 -            break;
   4.735 -        }
   4.736 -        pMap = pMap->next;
   4.737 -    }
   4.738 -
   4.739 -    return pntr;
   4.740 -}
   4.741 -
   4.742 -Bool SDL_NAME(XDGAMapFramebuffer) (int screen, char *name,      /* optional device name */
   4.743 -                                   unsigned char *base, /* physical memory */
   4.744 -                                   CARD32 size, /* size */
   4.745 -                                   CARD32 offset,       /* optional offset */
   4.746 -                                   CARD32 extra /* optional extra data */
   4.747 -    )
   4.748 -{
   4.749 -    DGAMapPtr pMap = _Maps;
   4.750 -    Bool result;
   4.751 -
   4.752 -    /* is it already mapped ? */
   4.753 -    while (pMap != NULL) {
   4.754 -        if (pMap->screen == screen)
   4.755 -            return True;
   4.756 -        pMap = pMap->next;
   4.757 -    }
   4.758 -
   4.759 -    if (extra & XDGANeedRoot) {
   4.760 -        /* we should probably check if we have root permissions and
   4.761 -           return False here */
   4.762 -
   4.763 -    }
   4.764 -
   4.765 -    pMap = (DGAMapPtr) Xmalloc(sizeof(DGAMapRec));
   4.766 -
   4.767 -    result = DGAMapPhysical(screen, name, base, size, offset, extra, pMap);
   4.768 -
   4.769 -    if (result) {
   4.770 -        pMap->next = _Maps;
   4.771 -        _Maps = pMap;
   4.772 -    } else
   4.773 -        Xfree(pMap);
   4.774 -
   4.775 -    return result;
   4.776 -}
   4.777 -
   4.778 -void SDL_NAME(XDGAUnmapFramebuffer) (int screen)
   4.779 -{
   4.780 -    DGAMapPtr pMap = _Maps;
   4.781 -    DGAMapPtr pPrev = NULL;
   4.782 -
   4.783 -    /* is it already mapped */
   4.784 -    while (pMap != NULL) {
   4.785 -        if (pMap->screen == screen)
   4.786 -            break;
   4.787 -        pPrev = pMap;
   4.788 -        pMap = pMap->next;
   4.789 -    }
   4.790 -
   4.791 -    if (!pMap)
   4.792 -        return;
   4.793 -
   4.794 -    DGAUnmapPhysical(pMap);
   4.795 -
   4.796 -    if (!pPrev)
   4.797 -        _Maps = pMap->next;
   4.798 -    else
   4.799 -        pPrev->next = pMap->next;
   4.800 -
   4.801 -    Xfree(pMap);
   4.802 -}
   4.803 -
   4.804 -
   4.805 -static Bool
   4.806 -DGAMapPhysical(int screen, char *name,  /* optional device name */
   4.807 -               unsigned char *base,     /* physical memory */
   4.808 -               CARD32 size,     /* size */
   4.809 -               CARD32 offset,   /* optional offset */
   4.810 -               CARD32 extra,    /* optional extra data */
   4.811 -               DGAMapPtr pMap)
   4.812 -{
   4.813 -#if defined(ISC) && defined(HAS_SVR3_MMAP)
   4.814 -    struct kd_memloc mloc;
   4.815 -#elif defined(__EMX__)
   4.816 -    APIRET rc;
   4.817 -    ULONG action;
   4.818 -    HFILE hfd;
   4.819 -#endif
   4.820 -
   4.821 -    base += offset;
   4.822 -
   4.823 -    pMap->screen = screen;
   4.824 -    pMap->physical = base;
   4.825 -    pMap->size = size;
   4.826 -
   4.827 -#if defined(ISC) && defined(HAS_SVR3_MMAP)
   4.828 -    if ((pMap->fd = open("/dev/mmap", O_RDWR)) < 0)
   4.829 -        return False;
   4.830 -    mloc.vaddr = (char *) 0;
   4.831 -    mloc.physaddr = (char *) base;
   4.832 -    mloc.length = size;
   4.833 -    mloc.ioflg = 1;
   4.834 -
   4.835 -    if ((pMap->virtual = (void *) ioctl(pMap->fd, MAP, &mloc)) == (void *) -1)
   4.836 -        return False;
   4.837 -#elif defined (__EMX__)
   4.838 -    /*
   4.839 -     * Dragon warning here! /dev/pmap$ is never closed, except on progam exit.
   4.840 -     * Consecutive calling of this routine will make PMAP$ driver run out
   4.841 -     * of memory handles. Some umap/close mechanism should be provided
   4.842 -     */
   4.843 -
   4.844 -    rc = DosOpen("/dev/pmap$", &hfd, &action, 0, FILE_NORMAL, FILE_OPEN,
   4.845 -                 OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE, (PEAOP2) NULL);
   4.846 -    if (rc != 0)
   4.847 -        return False;
   4.848 -    {
   4.849 -        struct map_ioctl
   4.850 -        {
   4.851 -            union
   4.852 -            {
   4.853 -                ULONG phys;
   4.854 -                void *user;
   4.855 -            } a;
   4.856 -            ULONG size;
   4.857 -        } pmap, dmap;
   4.858 -        ULONG plen, dlen;
   4.859 -#define XFREE86_PMAP	0x76
   4.860 -#define PMAP_MAP	0x44
   4.861 -
   4.862 -        pmap.a.phys = base;
   4.863 -        pmap.size = size;
   4.864 -        rc = DosDevIOCtl(hfd, XFREE86_PMAP, PMAP_MAP,
   4.865 -                         (PULONG) & pmap, sizeof(pmap), &plen,
   4.866 -                         (PULONG) & dmap, sizeof(dmap), &dlen);
   4.867 -        if (rc == 0) {
   4.868 -            pMap->virtual = dmap.a.user;
   4.869 -        }
   4.870 -    }
   4.871 -    if (rc != 0)
   4.872 -        return False;
   4.873 -#elif defined (Lynx)
   4.874 -    pMap->virtual =
   4.875 -        smem_create("XF86DGA", (char *) base, size, SM_READ | SM_WRITE);
   4.876 -#else
   4.877 -#ifndef MAP_FILE
   4.878 -#define MAP_FILE 0
   4.879 -#endif
   4.880 -    if (!name)
   4.881 -        name = DEV_MEM;
   4.882 -    if ((pMap->fd = open(name, O_RDWR)) < 0)
   4.883 -#if defined(ENABLE_FBCON)
   4.884 -    {                           /* /dev/fb0 fallback added by Sam Lantinga <hercules@lokigames.com> */
   4.885 -        /* Try to fall back to /dev/fb on Linux - FIXME: verify the device */
   4.886 -        struct fb_fix_screeninfo finfo;
   4.887 -
   4.888 -        if ((pMap->fd = open("/dev/fb0", O_RDWR)) < 0) {
   4.889 -            return False;
   4.890 -        }
   4.891 -        /* The useable framebuffer console memory may not be the whole
   4.892 -           framebuffer that X has access to. :-(
   4.893 -         */
   4.894 -        if (ioctl(pMap->fd, FBIOGET_FSCREENINFO, &finfo) < 0) {
   4.895 -            close(pMap->fd);
   4.896 -            return False;
   4.897 -        }
   4.898 -        /* Warning: On PPC, the size and virtual need to be offset by:
   4.899 -           (((long)finfo.smem_start) -
   4.900 -           (((long)finfo.smem_start)&~(PAGE_SIZE-1)))
   4.901 -         */
   4.902 -        base = 0;
   4.903 -        size = pMap->size = finfo.smem_len;
   4.904 -    }
   4.905 -#else
   4.906 -        return False;
   4.907 -#endif
   4.908 -    pMap->virtual = mmap(NULL, size, PROT_READ | PROT_WRITE,
   4.909 -                         MAP_FILE | MAP_SHARED, pMap->fd, (off_t) base);
   4.910 -    if (pMap->virtual == (void *) -1)
   4.911 -        return False;
   4.912 -#endif
   4.913 -
   4.914 -#if !defined(ISC) && !defined(HAS_SVR3_MMAP) && !defined(Lynx) \
   4.915 -	&& !defined(__EMX__)
   4.916 -    mprotect(pMap->virtual, size, PROT_READ | PROT_WRITE);
   4.917 -#endif
   4.918 -
   4.919 -    return True;
   4.920 -}
   4.921 -
   4.922 -
   4.923 -
   4.924 -static void
   4.925 -DGAUnmapPhysical(DGAMapPtr pMap)
   4.926 -{
   4.927 -#if !defined(ISC) && !defined(HAS_SVR3_MMAP) && !defined(Lynx) \
   4.928 -	&& !defined(__EMX__)
   4.929 -    mprotect(pMap->virtual, pMap->size, PROT_READ);
   4.930 -#elif defined(Lynx)
   4.931 -    /* XXX this doesn't allow enable after disable */
   4.932 -    smem_create(NULL, pMap->virtual, pMap->size, SM_DETACH);
   4.933 -    smem_remove("XF86DGA");
   4.934 -#endif
   4.935 -
   4.936 -
   4.937 -    /* We need to unmap and close too !!!!!!!!!! */
   4.938 -}
   4.939 -
   4.940 -/* vi: set ts=4 sw=4 expandtab: */
     5.1 --- a/src/video/dga/SDL_dgaevents.c	Tue Jul 25 07:25:51 2006 +0000
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,164 +0,0 @@
     5.4 -/*
     5.5 -    SDL - Simple DirectMedia Layer
     5.6 -    Copyright (C) 1997-2006 Sam Lantinga
     5.7 -
     5.8 -    This library is free software; you can redistribute it and/or
     5.9 -    modify it under the terms of the GNU Lesser General Public
    5.10 -    License as published by the Free Software Foundation; either
    5.11 -    version 2.1 of the License, or (at your option) any later version.
    5.12 -
    5.13 -    This library is distributed in the hope that it will be useful,
    5.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    5.16 -    Lesser General Public License for more details.
    5.17 -
    5.18 -    You should have received a copy of the GNU Lesser General Public
    5.19 -    License along with this library; if not, write to the Free Software
    5.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    5.21 -
    5.22 -    Sam Lantinga
    5.23 -    slouken@libsdl.org
    5.24 -*/
    5.25 -#include "SDL_config.h"
    5.26 -
    5.27 -/* Handle the event stream, converting DGA events into SDL events */
    5.28 -
    5.29 -#include <stdio.h>
    5.30 -#include <X11/Xlib.h>
    5.31 -#include "../Xext/extensions/xf86dga.h"
    5.32 -
    5.33 -#include "../SDL_sysvideo.h"
    5.34 -#include "../../events/SDL_events_c.h"
    5.35 -#include "SDL_dgavideo.h"
    5.36 -#include "SDL_dgaevents_c.h"
    5.37 -
    5.38 -/* get function pointers... */
    5.39 -#include "../x11/SDL_x11dyn.h"
    5.40 -
    5.41 -/* Heheh we're using X11 event code */
    5.42 -extern int X11_Pending(Display * display);
    5.43 -extern void X11_InitKeymap(void);
    5.44 -extern SDLKey X11_TranslateKeycode(Display * display, KeyCode kc);
    5.45 -
    5.46 -static int
    5.47 -DGA_DispatchEvent(_THIS)
    5.48 -{
    5.49 -    int posted;
    5.50 -    SDL_NAME(XDGAEvent) xevent;
    5.51 -
    5.52 -    XNextEvent(DGA_Display, (XEvent *) & xevent);
    5.53 -
    5.54 -    posted = 0;
    5.55 -    xevent.type -= DGA_event_base;
    5.56 -    switch (xevent.type) {
    5.57 -
    5.58 -        /* Mouse motion? */
    5.59 -    case MotionNotify:
    5.60 -        {
    5.61 -            if (SDL_VideoSurface) {
    5.62 -                posted = SDL_PrivateMouseMotion(0, 1,
    5.63 -                                                xevent.xmotion.dx,
    5.64 -                                                xevent.xmotion.dy);
    5.65 -            }
    5.66 -        }
    5.67 -        break;
    5.68 -
    5.69 -        /* Mouse button press? */
    5.70 -    case ButtonPress:
    5.71 -        {
    5.72 -            posted = SDL_PrivateMouseButton(SDL_PRESSED,
    5.73 -                                            xevent.xbutton.button, 0, 0);
    5.74 -        }
    5.75 -        break;
    5.76 -
    5.77 -        /* Mouse button release? */
    5.78 -    case ButtonRelease:
    5.79 -        {
    5.80 -            posted = SDL_PrivateMouseButton(SDL_RELEASED,
    5.81 -                                            xevent.xbutton.button, 0, 0);
    5.82 -        }
    5.83 -        break;
    5.84 -
    5.85 -        /* Key press? */
    5.86 -    case KeyPress:
    5.87 -        {
    5.88 -            SDL_keysym keysym;
    5.89 -            KeyCode keycode;
    5.90 -            XKeyEvent xkey;
    5.91 -
    5.92 -            SDL_NAME(XDGAKeyEventToXKeyEvent) (&xevent.xkey, &xkey);
    5.93 -            keycode = xkey.keycode;
    5.94 -#ifdef DEBUG_XEVENTS
    5.95 -            printf("KeyPress (X11 keycode = 0x%X)\n", xkey.keycode);
    5.96 -#endif
    5.97 -            /* Get the translated SDL virtual keysym */
    5.98 -            keysym.scancode = keycode;
    5.99 -            keysym.sym = X11_TranslateKeycode(DGA_Display, keycode);
   5.100 -            keysym.mod = KMOD_NONE;
   5.101 -            keysym.unicode = 0;
   5.102 -
   5.103 -            /* Look up the translated value for the key event */
   5.104 -            if (SDL_TranslateUNICODE) {
   5.105 -                static XComposeStatus state;
   5.106 -                char keybuf[32];
   5.107 -
   5.108 -                if (XLookupString
   5.109 -                    (&xkey, keybuf, sizeof(keybuf), NULL, &state)) {
   5.110 -                    /*
   5.111 -                     * FIXME: XLookupString() may yield more than one
   5.112 -                     * character, so we need a mechanism to allow for
   5.113 -                     * this (perhaps null keypress events with a
   5.114 -                     * unicode value)
   5.115 -                     */
   5.116 -                    keysym.unicode = (Uint8) keybuf[0];
   5.117 -                }
   5.118 -            }
   5.119 -            posted = SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
   5.120 -        }
   5.121 -        break;
   5.122 -
   5.123 -        /* Key release? */
   5.124 -    case KeyRelease:
   5.125 -        {
   5.126 -            SDL_keysym keysym;
   5.127 -            KeyCode keycode;
   5.128 -            XKeyEvent xkey;
   5.129 -
   5.130 -            SDL_NAME(XDGAKeyEventToXKeyEvent) (&xevent.xkey, &xkey);
   5.131 -            keycode = xkey.keycode;
   5.132 -#ifdef DEBUG_XEVENTS
   5.133 -            printf("KeyRelease (X11 keycode = 0x%X)\n", xkey.keycode);
   5.134 -#endif
   5.135 -            /* Get the translated SDL virtual keysym */
   5.136 -            keysym.scancode = keycode;
   5.137 -            keysym.sym = X11_TranslateKeycode(DGA_Display, keycode);
   5.138 -            keysym.mod = KMOD_NONE;
   5.139 -            keysym.unicode = 0;
   5.140 -            posted = SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
   5.141 -        }
   5.142 -        break;
   5.143 -
   5.144 -        break;
   5.145 -
   5.146 -    }
   5.147 -    return (posted);
   5.148 -}
   5.149 -
   5.150 -void
   5.151 -DGA_PumpEvents(_THIS)
   5.152 -{
   5.153 -    /* Keep processing pending events */
   5.154 -    LOCK_DISPLAY();
   5.155 -    while (X11_Pending(DGA_Display)) {
   5.156 -        DGA_DispatchEvent(this);
   5.157 -    }
   5.158 -    UNLOCK_DISPLAY();
   5.159 -}
   5.160 -
   5.161 -void
   5.162 -DGA_InitOSKeymap(_THIS)
   5.163 -{
   5.164 -    X11_InitKeymap();
   5.165 -}
   5.166 -
   5.167 -/* vi: set ts=4 sw=4 expandtab: */
     6.1 --- a/src/video/dga/SDL_dgaevents_c.h	Tue Jul 25 07:25:51 2006 +0000
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,29 +0,0 @@
     6.4 -/*
     6.5 -    SDL - Simple DirectMedia Layer
     6.6 -    Copyright (C) 1997-2006 Sam Lantinga
     6.7 -
     6.8 -    This library is free software; you can redistribute it and/or
     6.9 -    modify it under the terms of the GNU Lesser General Public
    6.10 -    License as published by the Free Software Foundation; either
    6.11 -    version 2.1 of the License, or (at your option) any later version.
    6.12 -
    6.13 -    This library is distributed in the hope that it will be useful,
    6.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    6.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    6.16 -    Lesser General Public License for more details.
    6.17 -
    6.18 -    You should have received a copy of the GNU Lesser General Public
    6.19 -    License along with this library; if not, write to the Free Software
    6.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    6.21 -
    6.22 -    Sam Lantinga
    6.23 -    slouken@libsdl.org
    6.24 -*/
    6.25 -#include "SDL_config.h"
    6.26 -
    6.27 -#include "SDL_dgavideo.h"
    6.28 -
    6.29 -/* Functions to be exported */
    6.30 -extern void DGA_PumpEvents(_THIS);
    6.31 -extern void DGA_InitOSKeymap(_THIS);
    6.32 -/* vi: set ts=4 sw=4 expandtab: */
     7.1 --- a/src/video/dga/SDL_dgamouse.c	Tue Jul 25 07:25:51 2006 +0000
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,37 +0,0 @@
     7.4 -/*
     7.5 -    SDL - Simple DirectMedia Layer
     7.6 -    Copyright (C) 1997-2006 Sam Lantinga
     7.7 -
     7.8 -    This library is free software; you can redistribute it and/or
     7.9 -    modify it under the terms of the GNU Lesser General Public
    7.10 -    License as published by the Free Software Foundation; either
    7.11 -    version 2.1 of the License, or (at your option) any later version.
    7.12 -
    7.13 -    This library is distributed in the hope that it will be useful,
    7.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    7.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    7.16 -    Lesser General Public License for more details.
    7.17 -
    7.18 -    You should have received a copy of the GNU Lesser General Public
    7.19 -    License along with this library; if not, write to the Free Software
    7.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    7.21 -
    7.22 -    Sam Lantinga
    7.23 -    slouken@libsdl.org
    7.24 -*/
    7.25 -#include "SDL_config.h"
    7.26 -
    7.27 -#include <stdio.h>
    7.28 -
    7.29 -#include "SDL_mouse.h"
    7.30 -#include "../../events/SDL_events_c.h"
    7.31 -#include "SDL_dgavideo.h"
    7.32 -#include "SDL_dgamouse_c.h"
    7.33 -
    7.34 -
    7.35 -/* The implementation dependent data for the window manager cursor */
    7.36 -struct WMcursor
    7.37 -{
    7.38 -    int unused;
    7.39 -};
    7.40 -/* vi: set ts=4 sw=4 expandtab: */
     8.1 --- a/src/video/dga/SDL_dgamouse_c.h	Tue Jul 25 07:25:51 2006 +0000
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,27 +0,0 @@
     8.4 -/*
     8.5 -    SDL - Simple DirectMedia Layer
     8.6 -    Copyright (C) 1997-2006 Sam Lantinga
     8.7 -
     8.8 -    This library is free software; you can redistribute it and/or
     8.9 -    modify it under the terms of the GNU Lesser General Public
    8.10 -    License as published by the Free Software Foundation; either
    8.11 -    version 2.1 of the License, or (at your option) any later version.
    8.12 -
    8.13 -    This library is distributed in the hope that it will be useful,
    8.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    8.16 -    Lesser General Public License for more details.
    8.17 -
    8.18 -    You should have received a copy of the GNU Lesser General Public
    8.19 -    License along with this library; if not, write to the Free Software
    8.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    8.21 -
    8.22 -    Sam Lantinga
    8.23 -    slouken@libsdl.org
    8.24 -*/
    8.25 -#include "SDL_config.h"
    8.26 -
    8.27 -#include "SDL_dgavideo.h"
    8.28 -
    8.29 -/* Functions to be exported */
    8.30 -/* vi: set ts=4 sw=4 expandtab: */
     9.1 --- a/src/video/dga/SDL_dgavideo.c	Tue Jul 25 07:25:51 2006 +0000
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,1150 +0,0 @@
     9.4 -/*
     9.5 -    SDL - Simple DirectMedia Layer
     9.6 -    Copyright (C) 1997-2006 Sam Lantinga
     9.7 -
     9.8 -    This library is free software; you can redistribute it and/or
     9.9 -    modify it under the terms of the GNU Lesser General Public
    9.10 -    License as published by the Free Software Foundation; either
    9.11 -    version 2.1 of the License, or (at your option) any later version.
    9.12 -
    9.13 -    This library is distributed in the hope that it will be useful,
    9.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    9.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    9.16 -    Lesser General Public License for more details.
    9.17 -
    9.18 -    You should have received a copy of the GNU Lesser General Public
    9.19 -    License along with this library; if not, write to the Free Software
    9.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    9.21 -
    9.22 -    Sam Lantinga
    9.23 -    slouken@libsdl.org
    9.24 -*/
    9.25 -#include "SDL_config.h"
    9.26 -
    9.27 -/* DGA 2.0 based SDL video driver implementation.
    9.28 -*/
    9.29 -
    9.30 -#include <stdio.h>
    9.31 -
    9.32 -#include <X11/Xlib.h>
    9.33 -#include "../Xext/extensions/xf86dga.h"
    9.34 -
    9.35 -#include "SDL_video.h"
    9.36 -#include "SDL_mouse.h"
    9.37 -#include "../SDL_sysvideo.h"
    9.38 -#include "../SDL_pixels_c.h"
    9.39 -#include "../../events/SDL_events_c.h"
    9.40 -#include "SDL_dgavideo.h"
    9.41 -#include "SDL_dgamouse_c.h"
    9.42 -#include "SDL_dgaevents_c.h"
    9.43 -
    9.44 -/* get function pointers... */
    9.45 -#include "../x11/SDL_x11dyn.h"
    9.46 -
    9.47 -/*#define DGA_DEBUG*/
    9.48 -
    9.49 -/* Heheh we're using X11 event code */
    9.50 -extern void X11_SaveScreenSaver(Display * display, int *saved_timeout,
    9.51 -                                BOOL * dpms);
    9.52 -extern void X11_DisableScreenSaver(Display * display);
    9.53 -extern void X11_RestoreScreenSaver(Display * display, int saved_timeout,
    9.54 -                                   BOOL dpms);
    9.55 -
    9.56 -/* Initialization/Query functions */
    9.57 -static int DGA_VideoInit(_THIS, SDL_PixelFormat * vformat);
    9.58 -static SDL_Rect **DGA_ListModes(_THIS, SDL_PixelFormat * format,
    9.59 -                                Uint32 flags);
    9.60 -static SDL_Surface *DGA_SetVideoMode(_THIS, SDL_Surface * current, int width,
    9.61 -                                     int height, int bpp, Uint32 flags);
    9.62 -static int DGA_SetColors(_THIS, int firstcolor, int ncolors,
    9.63 -                         SDL_Color * colors);
    9.64 -static int DGA_SetGammaRamp(_THIS, Uint16 * ramp);
    9.65 -static void DGA_VideoQuit(_THIS);
    9.66 -
    9.67 -/* Hardware surface functions */
    9.68 -static int DGA_InitHWSurfaces(_THIS, SDL_Surface * screen, Uint8 * base,
    9.69 -                              int size);
    9.70 -static void DGA_FreeHWSurfaces(_THIS);
    9.71 -static int DGA_AllocHWSurface(_THIS, SDL_Surface * surface);
    9.72 -static int DGA_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect,
    9.73 -                          Uint32 color);
    9.74 -static int DGA_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst);
    9.75 -static int DGA_LockHWSurface(_THIS, SDL_Surface * surface);
    9.76 -static void DGA_UnlockHWSurface(_THIS, SDL_Surface * surface);
    9.77 -static void DGA_FreeHWSurface(_THIS, SDL_Surface * surface);
    9.78 -static int DGA_FlipHWSurface(_THIS, SDL_Surface * surface);
    9.79 -
    9.80 -/* DGA driver bootstrap functions */
    9.81 -
    9.82 -static int
    9.83 -DGA_Available(void)
    9.84 -{
    9.85 -    const char *display = NULL;
    9.86 -    Display *dpy = NULL;
    9.87 -    int available = 0;
    9.88 -
    9.89 -    /* The driver is available is available if the display is local
    9.90 -       and the DGA 2.0+ extension is available, and we can map mem.
    9.91 -     */
    9.92 -    if (SDL_X11_LoadSymbols()) {
    9.93 -        if ((SDL_strncmp(XDisplayName(display), ":", 1) == 0) ||
    9.94 -            (SDL_strncmp(XDisplayName(display), "unix:", 5) == 0)) {
    9.95 -            dpy = XOpenDisplay(display);
    9.96 -            if (dpy) {
    9.97 -                int events, errors, major, minor;
    9.98 -
    9.99 -                if (SDL_NAME(XDGAQueryExtension)
   9.100 -                    (dpy, &events, &errors)
   9.101 -                    && SDL_NAME(XDGAQueryVersion) (dpy, &major, &minor)) {
   9.102 -                    int screen;
   9.103 -
   9.104 -                    screen = DefaultScreen(dpy);
   9.105 -                    if ((major >= 2) &&
   9.106 -                        SDL_NAME(XDGAOpenFramebuffer) (dpy, screen)) {
   9.107 -                        available = 1;
   9.108 -                        SDL_NAME(XDGACloseFramebuffer) (dpy, screen);
   9.109 -                    }
   9.110 -                }
   9.111 -                XCloseDisplay(dpy);
   9.112 -            }
   9.113 -        }
   9.114 -        SDL_X11_UnloadSymbols();
   9.115 -    }
   9.116 -    return (available);
   9.117 -}
   9.118 -
   9.119 -static void
   9.120 -DGA_DeleteDevice(SDL_VideoDevice * device)
   9.121 -{
   9.122 -    if (device != NULL) {
   9.123 -        SDL_free(device->hidden);
   9.124 -        SDL_free(device);
   9.125 -        SDL_X11_UnloadSymbols();
   9.126 -    }
   9.127 -}
   9.128 -
   9.129 -static SDL_VideoDevice *
   9.130 -DGA_CreateDevice(int devindex)
   9.131 -{
   9.132 -    SDL_VideoDevice *device = NULL;
   9.133 -
   9.134 -    /* Initialize all variables that we clean on shutdown */
   9.135 -    if (SDL_X11_LoadSymbols()) {
   9.136 -        device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice));
   9.137 -        if (device) {
   9.138 -            SDL_memset(device, 0, (sizeof *device));
   9.139 -            device->hidden = (struct SDL_PrivateVideoData *)
   9.140 -                SDL_malloc((sizeof *device->hidden));
   9.141 -        }
   9.142 -        if ((device == NULL) || (device->hidden == NULL)) {
   9.143 -            SDL_OutOfMemory();
   9.144 -            if (device) {
   9.145 -                SDL_free(device);
   9.146 -            }
   9.147 -            SDL_X11_UnloadSymbols();
   9.148 -            return (0);
   9.149 -        }
   9.150 -        SDL_memset(device->hidden, 0, (sizeof *device->hidden));
   9.151 -
   9.152 -        /* Set the function pointers */
   9.153 -        device->VideoInit = DGA_VideoInit;
   9.154 -        device->ListModes = DGA_ListModes;
   9.155 -        device->SetVideoMode = DGA_SetVideoMode;
   9.156 -        device->SetColors = DGA_SetColors;
   9.157 -        device->UpdateRects = NULL;
   9.158 -        device->VideoQuit = DGA_VideoQuit;
   9.159 -        device->AllocHWSurface = DGA_AllocHWSurface;
   9.160 -        device->CheckHWBlit = DGA_CheckHWBlit;
   9.161 -        device->FillHWRect = DGA_FillHWRect;
   9.162 -        device->SetHWColorKey = NULL;
   9.163 -        device->SetHWAlpha = NULL;
   9.164 -        device->LockHWSurface = DGA_LockHWSurface;
   9.165 -        device->UnlockHWSurface = DGA_UnlockHWSurface;
   9.166 -        device->FlipHWSurface = DGA_FlipHWSurface;
   9.167 -        device->FreeHWSurface = DGA_FreeHWSurface;
   9.168 -        device->SetGammaRamp = DGA_SetGammaRamp;
   9.169 -        device->GetGammaRamp = NULL;
   9.170 -        device->SetCaption = NULL;
   9.171 -        device->SetIcon = NULL;
   9.172 -        device->IconifyWindow = NULL;
   9.173 -        device->GrabInput = NULL;
   9.174 -        device->GetWMInfo = NULL;
   9.175 -        device->InitOSKeymap = DGA_InitOSKeymap;
   9.176 -        device->PumpEvents = DGA_PumpEvents;
   9.177 -
   9.178 -        device->free = DGA_DeleteDevice;
   9.179 -    }
   9.180 -
   9.181 -    return device;
   9.182 -}
   9.183 -
   9.184 -VideoBootStrap DGA_bootstrap = {
   9.185 -    "dga", "XFree86 DGA 2.0",
   9.186 -    DGA_Available, DGA_CreateDevice
   9.187 -};
   9.188 -
   9.189 -static int
   9.190 -DGA_AddMode(_THIS, int bpp, int w, int h)
   9.191 -{
   9.192 -    SDL_Rect *mode;
   9.193 -    int index;
   9.194 -    int next_mode;
   9.195 -
   9.196 -    /* Check to see if we already have this mode */
   9.197 -    if (bpp < 8) {              /* Not supported */
   9.198 -        return (0);
   9.199 -    }
   9.200 -    index = ((bpp + 7) / 8) - 1;
   9.201 -    if (SDL_nummodes[index] > 0) {
   9.202 -        mode = SDL_modelist[index][SDL_nummodes[index] - 1];
   9.203 -        if ((mode->w == w) && (mode->h == h)) {
   9.204 -            return (0);
   9.205 -        }
   9.206 -    }
   9.207 -
   9.208 -    /* Set up the new video mode rectangle */
   9.209 -    mode = (SDL_Rect *) SDL_malloc(sizeof *mode);
   9.210 -    if (mode == NULL) {
   9.211 -        SDL_OutOfMemory();
   9.212 -        return (-1);
   9.213 -    }
   9.214 -    mode->x = 0;
   9.215 -    mode->y = 0;
   9.216 -    mode->w = w;
   9.217 -    mode->h = h;
   9.218 -
   9.219 -    /* Allocate the new list of modes, and fill in the new mode */
   9.220 -    next_mode = SDL_nummodes[index];
   9.221 -    SDL_modelist[index] = (SDL_Rect **)
   9.222 -        SDL_realloc(SDL_modelist[index],
   9.223 -                    (1 + next_mode + 1) * sizeof(SDL_Rect *));
   9.224 -    if (SDL_modelist[index] == NULL) {
   9.225 -        SDL_OutOfMemory();
   9.226 -        SDL_nummodes[index] = 0;
   9.227 -        SDL_free(mode);
   9.228 -        return (-1);
   9.229 -    }
   9.230 -    SDL_modelist[index][next_mode] = mode;
   9.231 -    SDL_modelist[index][next_mode + 1] = NULL;
   9.232 -    SDL_nummodes[index]++;
   9.233 -
   9.234 -    return (0);
   9.235 -}
   9.236 -
   9.237 -/* This whole function is a hack. :) */
   9.238 -static Uint32
   9.239 -get_video_size(_THIS)
   9.240 -{
   9.241 -    /* This is a non-exported function from libXxf86dga.a */
   9.242 -    extern unsigned char *SDL_NAME(XDGAGetMappedMemory) (int screen);
   9.243 -    FILE *proc;
   9.244 -    unsigned long mem;
   9.245 -    unsigned start, stop;
   9.246 -    char line[BUFSIZ];
   9.247 -    Uint32 size;
   9.248 -
   9.249 -    mem = (unsigned long) SDL_NAME(XDGAGetMappedMemory) (DGA_Screen);
   9.250 -    size = 0;
   9.251 -    proc = fopen("/proc/self/maps", "r");
   9.252 -    if (proc) {
   9.253 -        while (fgets(line, sizeof(line) - 1, proc)) {
   9.254 -            SDL_sscanf(line, "%x-%x", &start, &stop);
   9.255 -            if (start == mem) {
   9.256 -                size = (Uint32) ((stop - start) / 1024);
   9.257 -                break;
   9.258 -            }
   9.259 -        }
   9.260 -        fclose(proc);
   9.261 -    }
   9.262 -    return (size);
   9.263 -}
   9.264 -
   9.265 -#ifdef DGA_DEBUG
   9.266 -static void
   9.267 -PrintMode(SDL_NAME(XDGAMode) * mode)
   9.268 -{
   9.269 -    printf("Mode: %s (%dx%d) at %d bpp (%f refresh, %d pitch) num: %d\n",
   9.270 -           mode->name,
   9.271 -           mode->viewportWidth, mode->viewportHeight,
   9.272 -           mode->depth == 24 ? mode->bitsPerPixel : mode->depth,
   9.273 -           mode->verticalRefresh, mode->bytesPerScanline, mode->num);
   9.274 -    printf("\tRGB: 0x%8.8x 0x%8.8x 0x%8.8x (%d - %s)\n",
   9.275 -           mode->redMask, mode->greenMask, mode->blueMask,
   9.276 -           mode->visualClass,
   9.277 -           mode->visualClass == TrueColor ? "truecolor" :
   9.278 -           mode->visualClass == DirectColor ? "directcolor" :
   9.279 -           mode->visualClass == PseudoColor ? "pseudocolor" : "unknown");
   9.280 -    printf("\tFlags: ");
   9.281 -    if (mode->flags & XDGAConcurrentAccess)
   9.282 -        printf(" XDGAConcurrentAccess");
   9.283 -    if (mode->flags & XDGASolidFillRect)
   9.284 -        printf(" XDGASolidFillRect");
   9.285 -    if (mode->flags & XDGABlitRect)
   9.286 -        printf(" XDGABlitRect");
   9.287 -    if (mode->flags & XDGABlitTransRect)
   9.288 -        printf(" XDGABlitTransRect");
   9.289 -    if (mode->flags & XDGAPixmap)
   9.290 -        printf(" XDGAPixmap");
   9.291 -    if (mode->flags & XDGAInterlaced)
   9.292 -        printf(" XDGAInterlaced");
   9.293 -    if (mode->flags & XDGADoublescan)
   9.294 -        printf(" XDGADoublescan");
   9.295 -    if (mode->viewportFlags & XDGAFlipRetrace)
   9.296 -        printf(" XDGAFlipRetrace");
   9.297 -    if (mode->viewportFlags & XDGAFlipImmediate)
   9.298 -        printf(" XDGAFlipImmediate");
   9.299 -    printf("\n");
   9.300 -}
   9.301 -#endif /* DGA_DEBUG */
   9.302 -
   9.303 -static int
   9.304 -cmpmodes(const void *va, const void *vb)
   9.305 -{
   9.306 -    const SDL_NAME(XDGAMode) * a = (const SDL_NAME(XDGAMode) *) va;
   9.307 -    const SDL_NAME(XDGAMode) * b = (const SDL_NAME(XDGAMode) *) vb;
   9.308 -
   9.309 -    if ((a->viewportWidth == b->viewportWidth) &&
   9.310 -        (b->viewportHeight == a->viewportHeight)) {
   9.311 -        /* Prefer 32 bpp over 24 bpp, 16 bpp over 15 bpp */
   9.312 -        int a_bpp = a->depth == 24 ? a->bitsPerPixel : a->depth;
   9.313 -        int b_bpp = b->depth == 24 ? b->bitsPerPixel : b->depth;
   9.314 -        if (a_bpp != b_bpp) {
   9.315 -            return b_bpp - a_bpp;
   9.316 -        }
   9.317 -        /* Prefer DirectColor visuals, for gamma support */
   9.318 -        if (a->visualClass == DirectColor && b->visualClass != DirectColor)
   9.319 -            return -1;
   9.320 -        if (b->visualClass == DirectColor && a->visualClass != DirectColor)
   9.321 -            return 1;
   9.322 -        /* Maintain server refresh rate sorting */
   9.323 -        return a->num - b->num;
   9.324 -    } else if (a->viewportWidth == b->viewportWidth) {
   9.325 -        return b->viewportHeight - a->viewportHeight;
   9.326 -    } else {
   9.327 -        return b->viewportWidth - a->viewportWidth;
   9.328 -    }
   9.329 -}
   9.330 -static void
   9.331 -UpdateHWInfo(_THIS, SDL_NAME(XDGAMode) * mode)
   9.332 -{
   9.333 -    this->info.wm_available = 0;
   9.334 -    this->info.hw_available = 1;
   9.335 -    if (mode->flags & XDGABlitRect) {
   9.336 -        this->info.blit_hw = 1;
   9.337 -    } else {
   9.338 -        this->info.blit_hw = 0;
   9.339 -    }
   9.340 -    if (mode->flags & XDGABlitTransRect) {
   9.341 -        this->info.blit_hw_CC = 1;
   9.342 -    } else {
   9.343 -        this->info.blit_hw_CC = 0;
   9.344 -    }
   9.345 -    if (mode->flags & XDGASolidFillRect) {
   9.346 -        this->info.blit_fill = 1;
   9.347 -    } else {
   9.348 -        this->info.blit_fill = 0;
   9.349 -    }
   9.350 -    this->info.video_mem = get_video_size(this);
   9.351 -}
   9.352 -
   9.353 -static int
   9.354 -DGA_VideoInit(_THIS, SDL_PixelFormat * vformat)
   9.355 -{
   9.356 -    const char *display;
   9.357 -    int event_base, error_base;
   9.358 -    int major_version, minor_version;
   9.359 -    Visual *visual;
   9.360 -    SDL_NAME(XDGAMode) * modes;
   9.361 -    int i, num_modes;
   9.362 -
   9.363 -    /* Open the X11 display */
   9.364 -    display = NULL;             /* Get it from DISPLAY environment variable */
   9.365 -
   9.366 -    DGA_Display = XOpenDisplay(display);
   9.367 -    if (DGA_Display == NULL) {
   9.368 -        SDL_SetError("Couldn't open X11 display");
   9.369 -        return (-1);
   9.370 -    }
   9.371 -
   9.372 -    /* Check for the DGA extension */
   9.373 -    if (!SDL_NAME(XDGAQueryExtension) (DGA_Display, &event_base, &error_base)
   9.374 -        || !SDL_NAME(XDGAQueryVersion) (DGA_Display, &major_version,
   9.375 -                                        &minor_version)) {
   9.376 -        SDL_SetError("DGA extension not available");
   9.377 -        XCloseDisplay(DGA_Display);
   9.378 -        return (-1);
   9.379 -    }
   9.380 -    if (major_version < 2) {
   9.381 -        SDL_SetError("DGA driver requires DGA 2.0 or newer");
   9.382 -        XCloseDisplay(DGA_Display);
   9.383 -        return (-1);
   9.384 -    }
   9.385 -    DGA_event_base = event_base;
   9.386 -
   9.387 -    /* Determine the current screen size */
   9.388 -    this->info.current_w = DisplayWidth(DGA_Display, DGA_Screen);
   9.389 -    this->info.current_h = DisplayHeight(DGA_Display, DGA_Screen);
   9.390 -
   9.391 -    /* Determine the current screen depth */
   9.392 -    visual = DefaultVisual(DGA_Display, DGA_Screen);
   9.393 -    {
   9.394 -        XPixmapFormatValues *pix_format;
   9.395 -        int i, num_formats;
   9.396 -
   9.397 -        vformat->BitsPerPixel = DefaultDepth(DGA_Display, DGA_Screen);
   9.398 -        pix_format = XListPixmapFormats(DGA_Display, &num_formats);
   9.399 -        if (pix_format == NULL) {
   9.400 -            SDL_SetError("Couldn't determine screen formats");
   9.401 -            XCloseDisplay(DGA_Display);
   9.402 -            return (-1);
   9.403 -        }
   9.404 -        for (i = 0; i < num_formats; ++i) {
   9.405 -            if (vformat->BitsPerPixel == pix_format[i].depth)
   9.406 -                break;
   9.407 -        }
   9.408 -        if (i != num_formats)
   9.409 -            vformat->BitsPerPixel = pix_format[i].bits_per_pixel;
   9.410 -        XFree((char *) pix_format);
   9.411 -    }
   9.412 -    if (vformat->BitsPerPixel > 8) {
   9.413 -        vformat->Rmask = visual->red_mask;
   9.414 -        vformat->Gmask = visual->green_mask;
   9.415 -        vformat->Bmask = visual->blue_mask;
   9.416 -    }
   9.417 -
   9.418 -    /* Open access to the framebuffer */
   9.419 -    if (!SDL_NAME(XDGAOpenFramebuffer) (DGA_Display, DGA_Screen)) {
   9.420 -        SDL_SetError("Unable to map the video memory");
   9.421 -        XCloseDisplay(DGA_Display);
   9.422 -        return (-1);
   9.423 -    }
   9.424 -
   9.425 -    /* Save DPMS and screensaver settings */
   9.426 -    X11_SaveScreenSaver(DGA_Display, &screensaver_timeout, &dpms_enabled);
   9.427 -    X11_DisableScreenSaver(DGA_Display);
   9.428 -
   9.429 -    /* Query for the list of available video modes */
   9.430 -    modes = SDL_NAME(XDGAQueryModes) (DGA_Display, DGA_Screen, &num_modes);
   9.431 -    SDL_qsort(modes, num_modes, sizeof *modes, cmpmodes);
   9.432 -    for (i = 0; i < num_modes; ++i) {
   9.433 -        if (((modes[i].visualClass == PseudoColor) ||
   9.434 -             (modes[i].visualClass == DirectColor) ||
   9.435 -             (modes[i].visualClass == TrueColor)) &&
   9.436 -            !(modes[i].flags & (XDGAInterlaced | XDGADoublescan))) {
   9.437 -#ifdef DGA_DEBUG
   9.438 -            PrintMode(&modes[i]);
   9.439 -#endif
   9.440 -            DGA_AddMode(this, modes[i].bitsPerPixel,
   9.441 -                        modes[i].viewportWidth, modes[i].viewportHeight);
   9.442 -        }
   9.443 -    }
   9.444 -    UpdateHWInfo(this, modes);
   9.445 -    XFree(modes);
   9.446 -
   9.447 -    /* Create the hardware surface lock mutex */
   9.448 -    hw_lock = SDL_CreateMutex();
   9.449 -    if (hw_lock == NULL) {
   9.450 -        SDL_SetError("Unable to create lock mutex");
   9.451 -        DGA_VideoQuit(this);
   9.452 -        return (-1);
   9.453 -    }
   9.454 -#ifdef LOCK_DGA_DISPLAY
   9.455 -    /* Create the event lock so we're thread-safe.. :-/ */
   9.456 -    event_lock = SDL_CreateMutex();
   9.457 -#endif /* LOCK_DGA_DISPLAY */
   9.458 -
   9.459 -    /* We're done! */
   9.460 -    return (0);
   9.461 -}
   9.462 -
   9.463 -SDL_Rect **
   9.464 -DGA_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
   9.465 -{
   9.466 -    return (SDL_modelist[((format->BitsPerPixel + 7) / 8) - 1]);
   9.467 -}
   9.468 -
   9.469 -/* Various screen update functions available */
   9.470 -static void DGA_DirectUpdate(_THIS, int numrects, SDL_Rect * rects);
   9.471 -
   9.472 -SDL_Surface *
   9.473 -DGA_SetVideoMode(_THIS, SDL_Surface * current,
   9.474 -                 int width, int height, int bpp, Uint32 flags)
   9.475 -{
   9.476 -    SDL_NAME(XDGAMode) * modes;
   9.477 -    int i, num_modes;
   9.478 -    SDL_NAME(XDGADevice) * mode;
   9.479 -    int screen_len;
   9.480 -    Uint8 *surfaces_mem;
   9.481 -    int surfaces_len;
   9.482 -
   9.483 -    /* Free any previous colormap */
   9.484 -    if (DGA_colormap) {
   9.485 -        XFreeColormap(DGA_Display, DGA_colormap);
   9.486 -        DGA_colormap = 0;
   9.487 -    }
   9.488 -
   9.489 -    /* Search for a matching video mode */
   9.490 -    modes = SDL_NAME(XDGAQueryModes) (DGA_Display, DGA_Screen, &num_modes);
   9.491 -    SDL_qsort(modes, num_modes, sizeof *modes, cmpmodes);
   9.492 -    for (i = 0; i < num_modes; ++i) {
   9.493 -        int depth;
   9.494 -
   9.495 -        depth = modes[i].depth;
   9.496 -        if (depth == 24) {      /* Distinguish between 24 and 32 bpp */
   9.497 -            depth = modes[i].bitsPerPixel;
   9.498 -        }
   9.499 -        if ((depth == bpp) &&
   9.500 -            (modes[i].viewportWidth == width) &&
   9.501 -            (modes[i].viewportHeight == height) &&
   9.502 -            ((modes[i].visualClass == PseudoColor) ||
   9.503 -             (modes[i].visualClass == DirectColor) ||
   9.504 -             (modes[i].visualClass == TrueColor)) &&
   9.505 -            !(modes[i].flags & (XDGAInterlaced | XDGADoublescan))) {
   9.506 -            break;
   9.507 -        }
   9.508 -    }
   9.509 -    if (i == num_modes) {
   9.510 -        SDL_SetError("No matching video mode found");
   9.511 -        return (NULL);
   9.512 -    }
   9.513 -#ifdef DGA_DEBUG
   9.514 -    PrintMode(&modes[i]);
   9.515 -#endif
   9.516 -
   9.517 -    /* Set the video mode */
   9.518 -    mode = SDL_NAME(XDGASetMode) (DGA_Display, DGA_Screen, modes[i].num);
   9.519 -    XFree(modes);
   9.520 -    if (mode == NULL) {
   9.521 -        SDL_SetError("Unable to switch to requested mode");
   9.522 -        return (NULL);
   9.523 -    }
   9.524 -    DGA_visualClass = mode->mode.visualClass;
   9.525 -    memory_base = (Uint8 *) mode->data;
   9.526 -    memory_pitch = mode->mode.bytesPerScanline;
   9.527 -
   9.528 -    /* Set up the new mode framebuffer */
   9.529 -    current->flags = (SDL_FULLSCREEN | SDL_HWSURFACE);
   9.530 -    current->w = mode->mode.viewportWidth;
   9.531 -    current->h = mode->mode.viewportHeight;
   9.532 -    current->pitch = memory_pitch;
   9.533 -    current->pixels = memory_base;
   9.534 -    if (!SDL_ReallocFormat(current, mode->mode.bitsPerPixel,
   9.535 -                           mode->mode.redMask,
   9.536 -                           mode->mode.greenMask, mode->mode.blueMask, 0)) {
   9.537 -        return (NULL);
   9.538 -    }
   9.539 -    screen_len = current->h * current->pitch;
   9.540 -
   9.541 -    /* Create a colormap if necessary */
   9.542 -    if ((DGA_visualClass == PseudoColor) || (DGA_visualClass == DirectColor)) {
   9.543 -        DGA_colormap =
   9.544 -            SDL_NAME(XDGACreateColormap) (DGA_Display, DGA_Screen, mode,
   9.545 -                                          AllocAll);
   9.546 -        if (DGA_visualClass == PseudoColor) {
   9.547 -            current->flags |= SDL_HWPALETTE;
   9.548 -        } else {
   9.549 -            /* Initialize the colormap to the identity mapping */
   9.550 -            SDL_GetGammaRamp(0, 0, 0);
   9.551 -            this->screen = current;
   9.552 -            DGA_SetGammaRamp(this, this->gamma);
   9.553 -            this->screen = NULL;
   9.554 -        }
   9.555 -    } else {
   9.556 -        DGA_colormap =
   9.557 -            SDL_NAME(XDGACreateColormap) (DGA_Display, DGA_Screen, mode,
   9.558 -                                          AllocNone);
   9.559 -    }
   9.560 -    SDL_NAME(XDGAInstallColormap) (DGA_Display, DGA_Screen, DGA_colormap);
   9.561 -
   9.562 -    /* Update the hardware capabilities */
   9.563 -    UpdateHWInfo(this, &mode->mode);
   9.564 -
   9.565 -    /* Set up the information for hardware surfaces */
   9.566 -    surfaces_mem = (Uint8 *) current->pixels + screen_len;
   9.567 -    surfaces_len = (mode->mode.imageHeight * current->pitch - screen_len);
   9.568 -
   9.569 -    /* Update for double-buffering, if we can */
   9.570 -    SDL_NAME(XDGASetViewport) (DGA_Display, DGA_Screen, 0, 0,
   9.571 -                               XDGAFlipRetrace);
   9.572 -    if (flags & SDL_DOUBLEBUF) {
   9.573 -        if (mode->mode.imageHeight >= (current->h * 2)) {
   9.574 -            current->flags |= SDL_DOUBLEBUF;
   9.575 -            flip_page = 0;
   9.576 -            flip_yoffset[0] = 0;
   9.577 -            flip_yoffset[1] = current->h;
   9.578 -            flip_address[0] = memory_base;
   9.579 -            flip_address[1] = memory_base + screen_len;
   9.580 -            surfaces_mem += screen_len;
   9.581 -            surfaces_len -= screen_len;
   9.582 -        }
   9.583 -    }
   9.584 -
   9.585 -    /* Allocate memory tracking for hardware surfaces */
   9.586 -    DGA_FreeHWSurfaces(this);
   9.587 -    if (surfaces_len < 0) {
   9.588 -        surfaces_len = 0;
   9.589 -    }
   9.590 -    DGA_InitHWSurfaces(this, current, surfaces_mem, surfaces_len);
   9.591 -
   9.592 -    /* Expose the back buffer as surface memory */
   9.593 -    if (current->flags & SDL_DOUBLEBUF) {
   9.594 -        this->screen = current;
   9.595 -        DGA_FlipHWSurface(this, current);
   9.596 -        this->screen = NULL;
   9.597 -    }
   9.598 -
   9.599 -    /* Set the update rectangle function */
   9.600 -    this->UpdateRects = DGA_DirectUpdate;
   9.601 -
   9.602 -    /* Enable mouse and keyboard support */
   9.603 -    {
   9.604 -        long input_mask;
   9.605 -        input_mask = (KeyPressMask | KeyReleaseMask);
   9.606 -        input_mask |= (ButtonPressMask | ButtonReleaseMask);
   9.607 -        input_mask |= PointerMotionMask;
   9.608 -        SDL_NAME(XDGASelectInput) (DGA_Display, DGA_Screen, input_mask);
   9.609 -    }
   9.610 -
   9.611 -    /* We're done */
   9.612 -    return (current);
   9.613 -}
   9.614 -
   9.615 -#ifdef DGA_DEBUG
   9.616 -static void
   9.617 -DGA_DumpHWSurfaces(_THIS)
   9.618 -{
   9.619 -    vidmem_bucket *bucket;
   9.620 -
   9.621 -    printf("Memory left: %d (%d total)\n", surfaces_memleft,
   9.622 -           surfaces_memtotal);
   9.623 -    printf("\n");
   9.624 -    printf("         Base  Size\n");
   9.625 -    for (bucket = &surfaces; bucket; bucket = bucket->next) {
   9.626 -        printf("Bucket:  %p, %d (%s)\n", bucket->base, bucket->size,
   9.627 -               bucket->used ? "used" : "free");
   9.628 -        if (bucket->prev) {
   9.629 -            if (bucket->base != bucket->prev->base + bucket->prev->size) {
   9.630 -                printf("Warning, corrupt bucket list! (prev)\n");
   9.631 -            }
   9.632 -        } else {
   9.633 -            if (bucket != &surfaces) {
   9.634 -                printf("Warning, corrupt bucket list! (!prev)\n");
   9.635 -            }
   9.636 -        }
   9.637 -        if (bucket->next) {
   9.638 -            if (bucket->next->base != bucket->base + bucket->size) {
   9.639 -                printf("Warning, corrupt bucket list! (next)\n");
   9.640 -            }
   9.641 -        }
   9.642 -    }
   9.643 -    printf("\n");
   9.644 -}
   9.645 -#endif
   9.646 -
   9.647 -static int
   9.648 -DGA_InitHWSurfaces(_THIS, SDL_Surface * screen, Uint8 * base, int size)
   9.649 -{
   9.650 -    vidmem_bucket *bucket;
   9.651 -
   9.652 -    surfaces_memtotal = size;
   9.653 -    surfaces_memleft = size;
   9.654 -
   9.655 -    if (surfaces_memleft > 0) {
   9.656 -        bucket = (vidmem_bucket *) SDL_malloc(sizeof(*bucket));
   9.657 -        if (bucket == NULL) {
   9.658 -            SDL_OutOfMemory();
   9.659 -            return (-1);
   9.660 -        }
   9.661 -        bucket->prev = &surfaces;
   9.662 -        bucket->used = 0;
   9.663 -        bucket->dirty = 0;
   9.664 -        bucket->base = base;
   9.665 -        bucket->size = size;
   9.666 -        bucket->next = NULL;
   9.667 -    } else {
   9.668 -        bucket = NULL;
   9.669 -    }
   9.670 -
   9.671 -    surfaces.prev = NULL;
   9.672 -    surfaces.used = 1;
   9.673 -    surfaces.dirty = 0;
   9.674 -    surfaces.base = screen->pixels;
   9.675 -    surfaces.size = (unsigned int) ((long) base - (long) surfaces.base);
   9.676 -    surfaces.next = bucket;
   9.677 -    screen->hwdata = (struct private_hwdata *) &surfaces;
   9.678 -    return (0);
   9.679 -}
   9.680 -static void
   9.681 -DGA_FreeHWSurfaces(_THIS)
   9.682 -{
   9.683 -    vidmem_bucket *bucket, *freeable;
   9.684 -
   9.685 -    bucket = surfaces.next;
   9.686 -    while (bucket) {
   9.687 -        freeable = bucket;
   9.688 -        bucket = bucket->next;
   9.689 -        SDL_free(freeable);
   9.690 -    }
   9.691 -    surfaces.next = NULL;
   9.692 -}
   9.693 -
   9.694 -static __inline__ void
   9.695 -DGA_AddBusySurface(SDL_Surface * surface)
   9.696 -{
   9.697 -    ((vidmem_bucket *) surface->hwdata)->dirty = 1;
   9.698 -}
   9.699 -
   9.700 -static __inline__ int
   9.701 -DGA_IsSurfaceBusy(SDL_Surface * surface)
   9.702 -{
   9.703 -    return ((vidmem_bucket *) surface->hwdata)->dirty;
   9.704 -}
   9.705 -
   9.706 -static __inline__ void
   9.707 -DGA_WaitBusySurfaces(_THIS)
   9.708 -{
   9.709 -    vidmem_bucket *bucket;
   9.710 -
   9.711 -    /* Wait for graphic operations to complete */
   9.712 -    SDL_NAME(XDGASync) (DGA_Display, DGA_Screen);
   9.713 -
   9.714 -    /* Clear all surface dirty bits */
   9.715 -    for (bucket = &surfaces; bucket; bucket = bucket->next) {
   9.716 -        bucket->dirty = 0;
   9.717 -    }
   9.718 -}
   9.719 -
   9.720 -static int
   9.721 -DGA_AllocHWSurface(_THIS, SDL_Surface * surface)
   9.722 -{
   9.723 -    vidmem_bucket *bucket;
   9.724 -    int size;
   9.725 -    int extra;
   9.726 -    int retval = 0;
   9.727 -
   9.728 -/* Temporarily, we only allow surfaces the same width as display.
   9.729 -   Some blitters require the pitch between two hardware surfaces
   9.730 -   to be the same.  Others have interesting alignment restrictions.
   9.731 -*/
   9.732 -    if (surface->pitch > SDL_VideoSurface->pitch) {
   9.733 -        SDL_SetError("Surface requested wider than screen");
   9.734 -        return (-1);
   9.735 -    }
   9.736 -    surface->pitch = SDL_VideoSurface->pitch;
   9.737 -    size = surface->h * surface->pitch;
   9.738 -#ifdef DGA_DEBUG
   9.739 -    fprintf(stderr, "Allocating bucket of %d bytes\n", size);
   9.740 -#endif
   9.741 -    LOCK_DISPLAY();
   9.742 -
   9.743 -    /* Quick check for available mem */
   9.744 -    if (size > surfaces_memleft) {
   9.745 -        SDL_SetError("Not enough video memory");
   9.746 -        retval = -1;
   9.747 -        goto done;
   9.748 -    }
   9.749 -
   9.750 -    /* Search for an empty bucket big enough */
   9.751 -    for (bucket = &surfaces; bucket; bucket = bucket->next) {
   9.752 -        if (!bucket->used && (size <= bucket->size)) {
   9.753 -            break;
   9.754 -        }
   9.755 -    }
   9.756 -    if (bucket == NULL) {
   9.757 -        SDL_SetError("Video memory too fragmented");
   9.758 -        retval = -1;
   9.759 -        goto done;
   9.760 -    }
   9.761 -
   9.762 -    /* Create a new bucket for left-over memory */
   9.763 -    extra = (bucket->size - size);
   9.764 -    if (extra) {
   9.765 -        vidmem_bucket *newbucket;
   9.766 -
   9.767 -#ifdef DGA_DEBUG
   9.768 -        fprintf(stderr, "Adding new free bucket of %d bytes\n", extra);
   9.769 -#endif
   9.770 -        newbucket = (vidmem_bucket *) SDL_malloc(sizeof(*newbucket));
   9.771 -        if (newbucket == NULL) {
   9.772 -            SDL_OutOfMemory();
   9.773 -            retval = -1;
   9.774 -            goto done;
   9.775 -        }
   9.776 -        newbucket->prev = bucket;
   9.777 -        newbucket->used = 0;
   9.778 -        newbucket->base = bucket->base + size;
   9.779 -        newbucket->size = extra;
   9.780 -        newbucket->next = bucket->next;
   9.781 -        if (bucket->next) {
   9.782 -            bucket->next->prev = newbucket;
   9.783 -        }
   9.784 -        bucket->next = newbucket;
   9.785 -    }
   9.786 -
   9.787 -    /* Set the current bucket values and return it! */
   9.788 -    bucket->used = 1;
   9.789 -    bucket->size = size;
   9.790 -    bucket->dirty = 0;
   9.791 -#ifdef DGA_DEBUG
   9.792 -    fprintf(stderr, "Allocated %d bytes at %p\n", bucket->size, bucket->base);
   9.793 -#endif
   9.794 -    surfaces_memleft -= size;
   9.795 -    surface->flags |= SDL_HWSURFACE;
   9.796 -    surface->pixels = bucket->base;
   9.797 -    surface->hwdata = (struct private_hwdata *) bucket;
   9.798 -  done:
   9.799 -    UNLOCK_DISPLAY();
   9.800 -    return (retval);
   9.801 -}
   9.802 -static void
   9.803 -DGA_FreeHWSurface(_THIS, SDL_Surface * surface)
   9.804 -{
   9.805 -    vidmem_bucket *bucket, *freeable;
   9.806 -
   9.807 -    /* Wait for any pending operations involving this surface */
   9.808 -    if (DGA_IsSurfaceBusy(surface)) {
   9.809 -        LOCK_DISPLAY();
   9.810 -        DGA_WaitBusySurfaces(this);
   9.811 -        UNLOCK_DISPLAY();
   9.812 -    }
   9.813 -
   9.814 -    /* Look for the bucket in the current list */
   9.815 -    for (bucket = &surfaces; bucket; bucket = bucket->next) {
   9.816 -        if (bucket == (vidmem_bucket *) surface->hwdata) {
   9.817 -            break;
   9.818 -        }
   9.819 -    }
   9.820 -    if (bucket && bucket->used) {
   9.821 -        /* Add the memory back to the total */
   9.822 -#ifdef DGA_DEBUG
   9.823 -        printf("Freeing bucket of %d bytes\n", bucket->size);
   9.824 -#endif
   9.825 -        surfaces_memleft += bucket->size;
   9.826 -
   9.827 -        /* Can we merge the space with surrounding buckets? */
   9.828 -        bucket->used = 0;
   9.829 -        if (bucket->next && !bucket->next->used) {
   9.830 -#ifdef DGA_DEBUG
   9.831 -            printf("Merging with next bucket, for %d total bytes\n",
   9.832 -                   bucket->size + bucket->next->size);
   9.833 -#endif
   9.834 -            freeable = bucket->next;
   9.835 -            bucket->size += bucket->next->size;
   9.836 -            bucket->next = bucket->next->next;
   9.837 -            if (bucket->next) {
   9.838 -                bucket->next->prev = bucket;
   9.839 -            }
   9.840 -            SDL_free(freeable);
   9.841 -        }
   9.842 -        if (bucket->prev && !bucket->prev->used) {
   9.843 -#ifdef DGA_DEBUG
   9.844 -            printf("Merging with previous bucket, for %d total bytes\n",
   9.845 -                   bucket->prev->size + bucket->size);
   9.846 -#endif
   9.847 -            freeable = bucket;
   9.848 -            bucket->prev->size += bucket->size;
   9.849 -            bucket->prev->next = bucket->next;
   9.850 -            if (bucket->next) {
   9.851 -                bucket->next->prev = bucket->prev;
   9.852 -            }
   9.853 -            SDL_free(freeable);
   9.854 -        }
   9.855 -    }
   9.856 -    surface->pixels = NULL;
   9.857 -    surface->hwdata = NULL;
   9.858 -}
   9.859 -
   9.860 -static __inline__ void
   9.861 -DGA_dst_to_xy(_THIS, SDL_Surface * dst, int *x, int *y)
   9.862 -{
   9.863 -    *x = (long) ((Uint8 *) dst->pixels - memory_base) % memory_pitch;
   9.864 -    *y = (long) ((Uint8 *) dst->pixels - memory_base) / memory_pitch;
   9.865 -}
   9.866 -
   9.867 -static int
   9.868 -DGA_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color)
   9.869 -{
   9.870 -    int x, y;
   9.871 -    unsigned int w, h;
   9.872 -
   9.873 -    /* Don't fill the visible part of the screen, wait until flipped */
   9.874 -    LOCK_DISPLAY();
   9.875 -    if (was_flipped && (dst == this->screen)) {
   9.876 -        while (SDL_NAME(XDGAGetViewportStatus) (DGA_Display, DGA_Screen))
   9.877 -            /* Keep waiting for the hardware ... */ ;
   9.878 -        was_flipped = 0;
   9.879 -    }
   9.880 -    DGA_dst_to_xy(this, dst, &x, &y);
   9.881 -    x += rect->x;
   9.882 -    y += rect->y;
   9.883 -    w = rect->w;
   9.884 -    h = rect->h;
   9.885 -#if 0
   9.886 -    printf("Hardware accelerated rectangle fill: %dx%d at %d,%d\n", w, h, x,
   9.887 -           y);
   9.888 -#endif
   9.889 -    SDL_NAME(XDGAFillRectangle) (DGA_Display, DGA_Screen, x, y, w, h, color);
   9.890 -    if (!(this->screen->flags & SDL_DOUBLEBUF)) {
   9.891 -        XFlush(DGA_Display);
   9.892 -    }
   9.893 -    DGA_AddBusySurface(dst);
   9.894 -    UNLOCK_DISPLAY();
   9.895 -    return (0);
   9.896 -}
   9.897 -
   9.898 -static int
   9.899 -HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect,
   9.900 -            SDL_Surface * dst, SDL_Rect * dstrect)
   9.901 -{
   9.902 -    SDL_VideoDevice *this;
   9.903 -    int srcx, srcy;
   9.904 -    int dstx, dsty;
   9.905 -    unsigned int w, h;
   9.906 -
   9.907 -    this = current_video;
   9.908 -    /* Don't blit to the visible part of the screen, wait until flipped */
   9.909 -    LOCK_DISPLAY();
   9.910 -    if (was_flipped && (dst == this->screen)) {
   9.911 -        while (SDL_NAME(XDGAGetViewportStatus) (DGA_Display, DGA_Screen))
   9.912 -            /* Keep waiting for the hardware ... */ ;
   9.913 -        was_flipped = 0;
   9.914 -    }
   9.915 -    DGA_dst_to_xy(this, src, &srcx, &srcy);
   9.916 -    srcx += srcrect->x;
   9.917 -    srcy += srcrect->y;
   9.918 -    DGA_dst_to_xy(this, dst, &dstx, &dsty);
   9.919 -    dstx += dstrect->x;
   9.920 -    dsty += dstrect->y;
   9.921 -    w = srcrect->w;
   9.922 -    h = srcrect->h;
   9.923 -#if 0
   9.924 -    printf("Blitting %dx%d from %d,%d to %d,%d\n", w, h, srcx, srcy, dstx,
   9.925 -           dsty);
   9.926 -#endif
   9.927 -    if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) {
   9.928 -        SDL_NAME(XDGACopyTransparentArea) (DGA_Display, DGA_Screen,
   9.929 -                                           srcx, srcy, w, h, dstx, dsty,
   9.930 -                                           src->format->colorkey);
   9.931 -    } else {
   9.932 -        SDL_NAME(XDGACopyArea) (DGA_Display, DGA_Screen,
   9.933 -                                srcx, srcy, w, h, dstx, dsty);
   9.934 -    }
   9.935 -    if (!(this->screen->flags & SDL_DOUBLEBUF)) {
   9.936 -        XFlush(DGA_Display);
   9.937 -    }
   9.938 -    DGA_AddBusySurface(src);
   9.939 -    DGA_AddBusySurface(dst);
   9.940 -    UNLOCK_DISPLAY();
   9.941 -    return (0);
   9.942 -}
   9.943 -
   9.944 -static int
   9.945 -DGA_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst)
   9.946 -{
   9.947 -    int accelerated;
   9.948 -
   9.949 -    /* Set initial acceleration on */
   9.950 -    src->flags |= SDL_HWACCEL;
   9.951 -
   9.952 -    /* Set the surface attributes */
   9.953 -    if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) {
   9.954 -        if (!this->info.blit_hw_A) {
   9.955 -            src->flags &= ~SDL_HWACCEL;
   9.956 -        }
   9.957 -    }
   9.958 -    if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) {
   9.959 -        if (!this->info.blit_hw_CC) {
   9.960 -            src->flags &= ~SDL_HWACCEL;
   9.961 -        }
   9.962 -    }
   9.963 -
   9.964 -    /* Check to see if final surface blit is accelerated */
   9.965 -    accelerated = !!(src->flags & SDL_HWACCEL);
   9.966 -    if (accelerated) {
   9.967 -        src->map->hw_blit = HWAccelBlit;
   9.968 -    }
   9.969 -    return (accelerated);
   9.970 -}
   9.971 -
   9.972 -static __inline__ void
   9.973 -DGA_WaitFlip(_THIS)
   9.974 -{
   9.975 -    if (was_flipped) {
   9.976 -        while (SDL_NAME(XDGAGetViewportStatus) (DGA_Display, DGA_Screen))
   9.977 -            /* Keep waiting for the hardware ... */ ;
   9.978 -        was_flipped = 0;
   9.979 -    }
   9.980 -}
   9.981 -
   9.982 -static int
   9.983 -DGA_LockHWSurface(_THIS, SDL_Surface * surface)
   9.984 -{
   9.985 -    if (surface == this->screen) {
   9.986 -        SDL_mutexP(hw_lock);
   9.987 -        LOCK_DISPLAY();
   9.988 -        if (DGA_IsSurfaceBusy(surface)) {
   9.989 -            DGA_WaitBusySurfaces(this);
   9.990 -        }
   9.991 -        DGA_WaitFlip(this);
   9.992 -        UNLOCK_DISPLAY();
   9.993 -    } else {
   9.994 -        if (DGA_IsSurfaceBusy(surface)) {
   9.995 -            LOCK_DISPLAY();
   9.996 -            DGA_WaitBusySurfaces(this);
   9.997 -            UNLOCK_DISPLAY();
   9.998 -        }
   9.999 -    }
  9.1000 -    return (0);
  9.1001 -}
  9.1002 -static void
  9.1003 -DGA_UnlockHWSurface(_THIS, SDL_Surface * surface)
  9.1004 -{
  9.1005 -    if (surface == this->screen) {
  9.1006 -        SDL_mutexV(hw_lock);
  9.1007 -    }
  9.1008 -}
  9.1009 -
  9.1010 -static int
  9.1011 -DGA_FlipHWSurface(_THIS, SDL_Surface * surface)
  9.1012 -{
  9.1013 -    /* Wait for vertical retrace and then flip display */
  9.1014 -    LOCK_DISPLAY();
  9.1015 -    if (DGA_IsSurfaceBusy(this->screen)) {
  9.1016 -        DGA_WaitBusySurfaces(this);
  9.1017 -    }
  9.1018 -    DGA_WaitFlip(this);
  9.1019 -    SDL_NAME(XDGASetViewport) (DGA_Display, DGA_Screen,
  9.1020 -                               0, flip_yoffset[flip_page], XDGAFlipRetrace);
  9.1021 -    XFlush(DGA_Display);
  9.1022 -    UNLOCK_DISPLAY();
  9.1023 -    was_flipped = 1;
  9.1024 -    flip_page = !flip_page;
  9.1025 -
  9.1026 -    surface->pixels = flip_address[flip_page];
  9.1027 -    return (0);
  9.1028 -}
  9.1029 -
  9.1030 -static void
  9.1031 -DGA_DirectUpdate(_THIS, int numrects, SDL_Rect * rects)
  9.1032 -{
  9.1033 -    /* The application is already updating the visible video memory */
  9.1034 -    return;
  9.1035 -}
  9.1036 -
  9.1037 -static int
  9.1038 -DGA_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors)
  9.1039 -{
  9.1040 -    int i;
  9.1041 -    XColor *xcmap;
  9.1042 -
  9.1043 -    /* This happens on initialization */
  9.1044 -    if (!DGA_colormap) {
  9.1045 -        return (0);
  9.1046 -    }
  9.1047 -    xcmap = SDL_stack_alloc(XColor, ncolors);
  9.1048 -    for (i = 0; i < ncolors; ++i) {
  9.1049 -        xcmap[i].pixel = firstcolor + i;
  9.1050 -        xcmap[i].red = (colors[i].r << 8) | colors[i].r;
  9.1051 -        xcmap[i].green = (colors[i].g << 8) | colors[i].g;
  9.1052 -        xcmap[i].blue = (colors[i].b << 8) | colors[i].b;
  9.1053 -        xcmap[i].flags = (DoRed | DoGreen | DoBlue);
  9.1054 -    }
  9.1055 -    LOCK_DISPLAY();
  9.1056 -    XStoreColors(DGA_Display, DGA_colormap, xcmap, ncolors);
  9.1057 -    XSync(DGA_Display, False);
  9.1058 -    UNLOCK_DISPLAY();
  9.1059 -    SDL_stack_free(xcmap);
  9.1060 -
  9.1061 -    /* That was easy. :) */
  9.1062 -    return (1);
  9.1063 -}
  9.1064 -
  9.1065 -int
  9.1066 -DGA_SetGammaRamp(_THIS, Uint16 * ramp)
  9.1067 -{
  9.1068 -    int i, ncolors;
  9.1069 -    XColor xcmap[256];
  9.1070 -
  9.1071 -    /* See if actually setting the gamma is supported */
  9.1072 -    if (DGA_visualClass != DirectColor) {
  9.1073 -        SDL_SetError("Gamma correction not supported on this visual");
  9.1074 -        return (-1);
  9.1075 -    }
  9.1076 -
  9.1077 -    /* Calculate the appropriate palette for the given gamma ramp */
  9.1078 -    if (this->screen->format->BitsPerPixel <= 16) {
  9.1079 -        ncolors = 64;           /* Is this right? */
  9.1080 -    } else {
  9.1081 -        ncolors = 256;
  9.1082 -    }
  9.1083 -    for (i = 0; i < ncolors; ++i) {
  9.1084 -        Uint8 c = (256 * i / ncolors);
  9.1085 -        xcmap[i].pixel = SDL_MapRGB(this->screen->format, c, c, c);
  9.1086 -        xcmap[i].red = ramp[0 * 256 + c];
  9.1087 -        xcmap[i].green = ramp[1 * 256 + c];
  9.1088 -        xcmap[i].blue = ramp[2 * 256 + c];
  9.1089 -        xcmap[i].flags = (DoRed | DoGreen | DoBlue);
  9.1090 -    }
  9.1091 -    LOCK_DISPLAY();
  9.1092 -    XStoreColors(DGA_Display, DGA_colormap, xcmap, ncolors);
  9.1093 -    XSync(DGA_Display, False);
  9.1094 -    UNLOCK_DISPLAY();
  9.1095 -    return (0);
  9.1096 -}
  9.1097 -
  9.1098 -void
  9.1099 -DGA_VideoQuit(_THIS)
  9.1100 -{
  9.1101 -    int i, j;
  9.1102 -
  9.1103 -    if (DGA_Display) {
  9.1104 -        /* Free colormap, if necessary */
  9.1105 -        if (DGA_colormap) {
  9.1106 -            XFreeColormap(DGA_Display, DGA_colormap);
  9.1107 -            DGA_colormap = 0;
  9.1108 -        }
  9.1109 -
  9.1110 -        /* Unmap memory and reset video mode */
  9.1111 -        SDL_NAME(XDGACloseFramebuffer) (DGA_Display, DGA_Screen);
  9.1112 -        if (this->screen) {
  9.1113 -            /* Tell SDL not to free the pixels */
  9.1114 -            DGA_FreeHWSurface(this, this->screen);
  9.1115 -        }
  9.1116 -        SDL_NAME(XDGASetMode) (DGA_Display, DGA_Screen, 0);
  9.1117 -
  9.1118 -        /* Clear the lock mutex */
  9.1119 -        if (hw_lock != NULL) {
  9.1120 -            SDL_DestroyMutex(hw_lock);
  9.1121 -            hw_lock = NULL;
  9.1122 -        }
  9.1123 -#ifdef LOCK_DGA_DISPLAY
  9.1124 -        if (event_lock != NULL) {
  9.1125 -            SDL_DestroyMutex(event_lock);
  9.1126 -            event_lock = NULL;
  9.1127 -        }
  9.1128 -#endif /* LOCK_DGA_DISPLAY */
  9.1129 -
  9.1130 -        /* Clean up defined video modes */
  9.1131 -        for (i = 0; i < NUM_MODELISTS; ++i) {
  9.1132 -            if (SDL_modelist[i] != NULL) {
  9.1133 -                for (j = 0; SDL_modelist[i][j]; ++j) {
  9.1134 -                    SDL_free(SDL_modelist[i][j]);
  9.1135 -                }
  9.1136 -                SDL_free(SDL_modelist[i]);
  9.1137 -                SDL_modelist[i] = NULL;
  9.1138 -            }
  9.1139 -        }
  9.1140 -
  9.1141 -        /* Clean up the memory bucket list */
  9.1142 -        DGA_FreeHWSurfaces(this);
  9.1143 -
  9.1144 -        /* Restore DPMS and screensaver settings */
  9.1145 -        X11_RestoreScreenSaver(DGA_Display, screensaver_timeout,
  9.1146 -                               dpms_enabled);
  9.1147 -
  9.1148 -        /* Close up the display */
  9.1149 -        XCloseDisplay(DGA_Display);
  9.1150 -    }
  9.1151 -}
  9.1152 -
  9.1153 -/* vi: set ts=4 sw=4 expandtab: */
    10.1 --- a/src/video/dga/SDL_dgavideo.h	Tue Jul 25 07:25:51 2006 +0000
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,125 +0,0 @@
    10.4 -/*
    10.5 -    SDL - Simple DirectMedia Layer
    10.6 -    Copyright (C) 1997-2006 Sam Lantinga
    10.7 -
    10.8 -    This library is free software; you can redistribute it and/or
    10.9 -    modify it under the terms of the GNU Lesser General Public
   10.10 -    License as published by the Free Software Foundation; either
   10.11 -    version 2.1 of the License, or (at your option) any later version.
   10.12 -
   10.13 -    This library is distributed in the hope that it will be useful,
   10.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   10.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   10.16 -    Lesser General Public License for more details.
   10.17 -
   10.18 -    You should have received a copy of the GNU Lesser General Public
   10.19 -    License along with this library; if not, write to the Free Software
   10.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   10.21 -
   10.22 -    Sam Lantinga
   10.23 -    slouken@libsdl.org
   10.24 -*/
   10.25 -#include "SDL_config.h"
   10.26 -
   10.27 -#ifndef _SDL_dgavideo_h
   10.28 -#define _SDL_dgavideo_h
   10.29 -
   10.30 -#include <X11/Xlib.h>
   10.31 -#include <X11/Xproto.h>
   10.32 -
   10.33 -#include "SDL_mouse.h"
   10.34 -#include "SDL_mutex.h"
   10.35 -#include "../SDL_sysvideo.h"
   10.36 -
   10.37 -#if SDL_VIDEO_DRIVER_X11_DPMS
   10.38 -#include <X11/extensions/dpms.h>
   10.39 -#endif
   10.40 -
   10.41 -/* Hidden "this" pointer for the video functions */
   10.42 -#define _THIS	SDL_VideoDevice *this
   10.43 -
   10.44 -/* Define this if you need the DGA driver to be thread-safe */
   10.45 -#define LOCK_DGA_DISPLAY
   10.46 -#ifdef LOCK_DGA_DISPLAY
   10.47 -#define LOCK_DISPLAY()		SDL_mutexP(event_lock)
   10.48 -#define UNLOCK_DISPLAY()	SDL_mutexV(event_lock)
   10.49 -#else
   10.50 -#define LOCK_DISPLAY()
   10.51 -#define UNLOCK_DISPLAY()
   10.52 -#endif
   10.53 -
   10.54 -
   10.55 -/* This is the structure we use to keep track of video memory */
   10.56 -typedef struct vidmem_bucket
   10.57 -{
   10.58 -    struct vidmem_bucket *prev;
   10.59 -    int used;
   10.60 -    int dirty;
   10.61 -    Uint8 *base;
   10.62 -    unsigned int size;
   10.63 -    struct vidmem_bucket *next;
   10.64 -} vidmem_bucket;
   10.65 -
   10.66 -/* Private display data */
   10.67 -struct SDL_PrivateVideoData
   10.68 -{
   10.69 -    Display *DGA_Display;
   10.70 -    Colormap DGA_colormap;
   10.71 -    int visualClass;
   10.72 -
   10.73 -#define NUM_MODELISTS	4       /* 8, 16, 24, and 32 bits-per-pixel */
   10.74 -    int SDL_nummodes[NUM_MODELISTS];
   10.75 -    SDL_Rect **SDL_modelist[NUM_MODELISTS];
   10.76 -
   10.77 -    /* Information for the video surface */
   10.78 -    Uint8 *memory_base;
   10.79 -    int memory_pitch;
   10.80 -    SDL_mutex *hw_lock;
   10.81 -    int sync_needed;
   10.82 -    int was_flipped;
   10.83 -
   10.84 -    /* Information for hardware surfaces */
   10.85 -    vidmem_bucket surfaces;
   10.86 -    int surfaces_memtotal;
   10.87 -    int surfaces_memleft;
   10.88 -
   10.89 -    /* Information for double-buffering */
   10.90 -    int flip_page;
   10.91 -    int flip_yoffset[2];
   10.92 -    Uint8 *flip_address[2];
   10.93 -
   10.94 -    /* Used to handle DGA events */
   10.95 -    int event_base;
   10.96 -#ifdef LOCK_DGA_DISPLAY
   10.97 -    SDL_mutex *event_lock;
   10.98 -#endif
   10.99 -
  10.100 -    /* Screensaver settings */
  10.101 -    int screensaver_timeout;
  10.102 -    BOOL dpms_enabled;
  10.103 -};
  10.104 -/* Old variable names */
  10.105 -#define DGA_Display		(this->hidden->DGA_Display)
  10.106 -#define DGA_Screen		DefaultScreen(DGA_Display)
  10.107 -#define DGA_colormap		(this->hidden->DGA_colormap)
  10.108 -#define DGA_visualClass		(this->hidden->visualClass)
  10.109 -#define memory_base		(this->hidden->memory_base)
  10.110 -#define memory_pitch		(this->hidden->memory_pitch)
  10.111 -#define flip_page		(this->hidden->flip_page)
  10.112 -#define flip_yoffset		(this->hidden->flip_yoffset)
  10.113 -#define flip_address		(this->hidden->flip_address)
  10.114 -#define sync_needed		(this->hidden->sync_needed)
  10.115 -#define was_flipped		(this->hidden->was_flipped)
  10.116 -#define SDL_nummodes		(this->hidden->SDL_nummodes)
  10.117 -#define SDL_modelist		(this->hidden->SDL_modelist)
  10.118 -#define surfaces		(this->hidden->surfaces)
  10.119 -#define surfaces_memtotal	(this->hidden->surfaces_memtotal)
  10.120 -#define surfaces_memleft	(this->hidden->surfaces_memleft)
  10.121 -#define hw_lock			(this->hidden->hw_lock)
  10.122 -#define DGA_event_base		(this->hidden->event_base)
  10.123 -#define event_lock		(this->hidden->event_lock)
  10.124 -#define screensaver_timeout	(this->hidden->screensaver_timeout)
  10.125 -#define dpms_enabled		(this->hidden->dpms_enabled)
  10.126 -
  10.127 -#endif /* _SDL_dgavideo_h */
  10.128 -/* vi: set ts=4 sw=4 expandtab: */