Fixed bug #930
authorSam Lantinga <slouken@libsdl.org>
Mon, 18 Jan 2010 14:27:30 +0000
changeset 36788e961ef35d4b
parent 3677 cec9ea711294
child 3679 ce290de32f2a
Fixed bug #930

The PS2 video driver is obsolete and not going to be updated unless someone wants to maintain it.
configure.in
include/SDL_config.h.in
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/ps2gs/SDL_gsevents.c
src/video/ps2gs/SDL_gsevents_c.h
src/video/ps2gs/SDL_gskeys.h
src/video/ps2gs/SDL_gsmouse.c
src/video/ps2gs/SDL_gsmouse_c.h
src/video/ps2gs/SDL_gsvideo.c
src/video/ps2gs/SDL_gsvideo.h
src/video/ps2gs/SDL_gsyuv.c
src/video/ps2gs/SDL_gsyuv_c.h
     1.1 --- a/configure.in	Mon Jan 18 14:16:47 2010 +0000
     1.2 +++ b/configure.in	Mon Jan 18 14:27:30 2010 +0000
     1.3 @@ -1438,31 +1438,6 @@
     1.4      fi
     1.5  }
     1.6  
     1.7 -dnl See if we're running on PlayStation 2 hardware
     1.8 -CheckPS2GS()
     1.9 -{
    1.10 -    AC_ARG_ENABLE(video-ps2gs,
    1.11 -AC_HELP_STRING([--enable-video-ps2gs], [use PlayStation 2 GS video driver [[default=no]]]),
    1.12 -                  , enable_video_ps2gs=no)
    1.13 -    if test x$enable_video = xyes -a x$enable_video_ps2gs = xyes; then
    1.14 -        AC_MSG_CHECKING(for PlayStation 2 GS support)
    1.15 -        video_ps2gs=no
    1.16 -        AC_TRY_COMPILE([
    1.17 -         #include <linux/ps2/dev.h>
    1.18 -         #include <linux/ps2/gs.h>
    1.19 -        ],[
    1.20 -        ],[
    1.21 -        video_ps2gs=yes
    1.22 -        ])
    1.23 -        AC_MSG_RESULT($video_ps2gs)
    1.24 -        if test x$video_ps2gs = xyes; then
    1.25 -            AC_DEFINE(SDL_VIDEO_DRIVER_PS2GS)
    1.26 -            SOURCES="$SOURCES $srcdir/src/video/ps2gs/*.c"
    1.27 -            have_video=yes
    1.28 -        fi
    1.29 -    fi
    1.30 -}
    1.31 -
    1.32  dnl See if we're running on PlayStation 3 Cell hardware
    1.33  CheckPS3()
    1.34  {
    1.35 @@ -2233,7 +2208,6 @@
    1.36          CheckFBCON
    1.37          CheckDirectFB
    1.38          CheckFusionSound
    1.39 -        CheckPS2GS
    1.40          CheckPS3
    1.41          CheckSVGA
    1.42          CheckOpenGLX11
     2.1 --- a/include/SDL_config.h.in	Mon Jan 18 14:16:47 2010 +0000
     2.2 +++ b/include/SDL_config.h.in	Mon Jan 18 14:27:30 2010 +0000
     2.3 @@ -262,7 +262,6 @@
     2.4  #undef SDL_VIDEO_DRIVER_NDS
     2.5  #undef SDL_VIDEO_DRIVER_PHOTON
     2.6  #undef SDL_VIDEO_DRIVER_QNXGF
     2.7 -#undef SDL_VIDEO_DRIVER_PS2GS
     2.8  #undef SDL_VIDEO_DRIVER_PS3
     2.9  #undef SDL_VIDEO_DRIVER_RISCOS
    2.10  #undef SDL_VIDEO_DRIVER_SVGALIB
     3.1 --- a/src/video/SDL_sysvideo.h	Mon Jan 18 14:16:47 2010 +0000
     3.2 +++ b/src/video/SDL_sysvideo.h	Mon Jan 18 14:27:30 2010 +0000
     3.3 @@ -373,9 +373,6 @@
     3.4  #if SDL_VIDEO_DRIVER_DIRECTFB
     3.5  extern VideoBootStrap DirectFB_bootstrap;
     3.6  #endif
     3.7 -#if SDL_VIDEO_DRIVER_PS2GS
     3.8 -extern VideoBootStrap PS2GS_bootstrap;
     3.9 -#endif
    3.10  #if SDL_VIDEO_DRIVER_PS3
    3.11  extern VideoBootStrap PS3_bootstrap;
    3.12  #endif
     4.1 --- a/src/video/SDL_video.c	Mon Jan 18 14:16:47 2010 +0000
     4.2 +++ b/src/video/SDL_video.c	Mon Jan 18 14:27:30 2010 +0000
     4.3 @@ -61,9 +61,6 @@
     4.4  #if SDL_VIDEO_DRIVER_DIRECTFB
     4.5      &DirectFB_bootstrap,
     4.6  #endif
     4.7 -#if SDL_VIDEO_DRIVER_PS2GS
     4.8 -    &PS2GS_bootstrap,
     4.9 -#endif
    4.10  #if SDL_VIDEO_DRIVER_PS3
    4.11      &PS3_bootstrap,
    4.12  #endif
     5.1 --- a/src/video/ps2gs/SDL_gsevents.c	Mon Jan 18 14:16:47 2010 +0000
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,1103 +0,0 @@
     5.4 -/*
     5.5 -    SDL - Simple DirectMedia Layer
     5.6 -    Copyright (C) 1997-2009 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 console events into SDL events */
    5.28 -
    5.29 -#include <sys/types.h>
    5.30 -#include <sys/time.h>
    5.31 -#include <sys/ioctl.h>
    5.32 -#include <unistd.h>
    5.33 -#include <fcntl.h>
    5.34 -#include <errno.h>
    5.35 -#include <limits.h>
    5.36 -
    5.37 -/* For parsing /proc */
    5.38 -#include <dirent.h>
    5.39 -#include <ctype.h>
    5.40 -
    5.41 -#include <linux/vt.h>
    5.42 -#include <linux/kd.h>
    5.43 -#include <linux/keyboard.h>
    5.44 -
    5.45 -#include "SDL_mutex.h"
    5.46 -#include "../SDL_sysvideo.h"
    5.47 -#include "../../events/SDL_sysevents.h"
    5.48 -#include "../../events/SDL_events_c.h"
    5.49 -#include "SDL_gsvideo.h"
    5.50 -#include "SDL_gsevents_c.h"
    5.51 -#include "SDL_gskeys.h"
    5.52 -
    5.53 -#ifndef GPM_NODE_FIFO
    5.54 -#define GPM_NODE_FIFO	"/dev/gpmdata"
    5.55 -#endif
    5.56 -
    5.57 -/* The translation tables from a console scancode to a SDL keysym */
    5.58 -#define NUM_VGAKEYMAPS	(1<<KG_CAPSSHIFT)
    5.59 -static Uint16 vga_keymap[NUM_VGAKEYMAPS][NR_KEYS];
    5.60 -static SDLKey keymap[128];
    5.61 -static Uint16 keymap_temp[128]; /* only used at startup */
    5.62 -static SDL_keysym *TranslateKey(int scancode, SDL_keysym * keysym);
    5.63 -
    5.64 -/* Ugh, we have to duplicate the kernel's keysym mapping code...
    5.65 -   Oh, it's not so bad. :-)
    5.66 -
    5.67 -   FIXME: Add keyboard LED handling code
    5.68 - */
    5.69 -static void
    5.70 -GS_vgainitkeymaps(int fd)
    5.71 -{
    5.72 -    struct kbentry entry;
    5.73 -    int map, i;
    5.74 -
    5.75 -    /* Don't do anything if we are passed a closed keyboard */
    5.76 -    if (fd < 0) {
    5.77 -        return;
    5.78 -    }
    5.79 -
    5.80 -    /* Load all the keysym mappings */
    5.81 -    for (map = 0; map < NUM_VGAKEYMAPS; ++map) {
    5.82 -        SDL_memset(vga_keymap[map], 0, NR_KEYS * sizeof(Uint16));
    5.83 -        for (i = 0; i < NR_KEYS; ++i) {
    5.84 -            entry.kb_table = map;
    5.85 -            entry.kb_index = i;
    5.86 -            if (ioctl(fd, KDGKBENT, &entry) == 0) {
    5.87 -                /* fill keytemp. This replaces SDL_fbkeys.h */
    5.88 -                if ((map == 0) && (i < 128)) {
    5.89 -                    keymap_temp[i] = entry.kb_value;
    5.90 -                }
    5.91 -                /* The "Enter" key is a special case */
    5.92 -                if (entry.kb_value == K_ENTER) {
    5.93 -                    entry.kb_value = K(KT_ASCII, 13);
    5.94 -                }
    5.95 -                /* Handle numpad specially as well */
    5.96 -                if (KTYP(entry.kb_value) == KT_PAD) {
    5.97 -                    switch (entry.kb_value) {
    5.98 -                    case K_P0:
    5.99 -                    case K_P1:
   5.100 -                    case K_P2:
   5.101 -                    case K_P3:
   5.102 -                    case K_P4:
   5.103 -                    case K_P5:
   5.104 -                    case K_P6:
   5.105 -                    case K_P7:
   5.106 -                    case K_P8:
   5.107 -                    case K_P9:
   5.108 -                        vga_keymap[map][i] = entry.kb_value;
   5.109 -                        vga_keymap[map][i] += '0';
   5.110 -                        break;
   5.111 -                    case K_PPLUS:
   5.112 -                        vga_keymap[map][i] = K(KT_ASCII, '+');
   5.113 -                        break;
   5.114 -                    case K_PMINUS:
   5.115 -                        vga_keymap[map][i] = K(KT_ASCII, '-');
   5.116 -                        break;
   5.117 -                    case K_PSTAR:
   5.118 -                        vga_keymap[map][i] = K(KT_ASCII, '*');
   5.119 -                        break;
   5.120 -                    case K_PSLASH:
   5.121 -                        vga_keymap[map][i] = K(KT_ASCII, '/');
   5.122 -                        break;
   5.123 -                    case K_PENTER:
   5.124 -                        vga_keymap[map][i] = K(KT_ASCII, '\r');
   5.125 -                        break;
   5.126 -                    case K_PCOMMA:
   5.127 -                        vga_keymap[map][i] = K(KT_ASCII, ',');
   5.128 -                        break;
   5.129 -                    case K_PDOT:
   5.130 -                        vga_keymap[map][i] = K(KT_ASCII, '.');
   5.131 -                        break;
   5.132 -                    default:
   5.133 -                        break;
   5.134 -                    }
   5.135 -                }
   5.136 -                /* Do the normal key translation */
   5.137 -                if ((KTYP(entry.kb_value) == KT_LATIN) ||
   5.138 -                    (KTYP(entry.kb_value) == KT_ASCII) ||
   5.139 -                    (KTYP(entry.kb_value) == KT_LETTER)) {
   5.140 -                    vga_keymap[map][i] = entry.kb_value;
   5.141 -                }
   5.142 -            }
   5.143 -        }
   5.144 -    }
   5.145 -}
   5.146 -
   5.147 -int
   5.148 -GS_InGraphicsMode(_THIS)
   5.149 -{
   5.150 -    return ((keyboard_fd >= 0) && (saved_kbd_mode >= 0));
   5.151 -}
   5.152 -
   5.153 -int
   5.154 -GS_EnterGraphicsMode(_THIS)
   5.155 -{
   5.156 -    struct termios keyboard_termios;
   5.157 -
   5.158 -    /* Set medium-raw keyboard mode */
   5.159 -    if ((keyboard_fd >= 0) && !GS_InGraphicsMode(this)) {
   5.160 -
   5.161 -        /* Switch to the correct virtual terminal */
   5.162 -        if (current_vt > 0) {
   5.163 -            struct vt_stat vtstate;
   5.164 -
   5.165 -            if (ioctl(keyboard_fd, VT_GETSTATE, &vtstate) == 0) {
   5.166 -                saved_vt = vtstate.v_active;
   5.167 -            }
   5.168 -            if (ioctl(keyboard_fd, VT_ACTIVATE, current_vt) == 0) {
   5.169 -                ioctl(keyboard_fd, VT_WAITACTIVE, current_vt);
   5.170 -            }
   5.171 -        }
   5.172 -
   5.173 -        /* Set the terminal input mode */
   5.174 -        if (tcgetattr(keyboard_fd, &saved_kbd_termios) < 0) {
   5.175 -            SDL_SetError("Unable to get terminal attributes");
   5.176 -            if (keyboard_fd > 0) {
   5.177 -                close(keyboard_fd);
   5.178 -            }
   5.179 -            keyboard_fd = -1;
   5.180 -            return (-1);
   5.181 -        }
   5.182 -        if (ioctl(keyboard_fd, KDGKBMODE, &saved_kbd_mode) < 0) {
   5.183 -            SDL_SetError("Unable to get current keyboard mode");
   5.184 -            if (keyboard_fd > 0) {
   5.185 -                close(keyboard_fd);
   5.186 -            }
   5.187 -            keyboard_fd = -1;
   5.188 -            return (-1);
   5.189 -        }
   5.190 -        keyboard_termios = saved_kbd_termios;
   5.191 -        keyboard_termios.c_lflag &= ~(ICANON | ECHO | ISIG);
   5.192 -        keyboard_termios.c_iflag &=
   5.193 -            ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON);
   5.194 -        keyboard_termios.c_cc[VMIN] = 0;
   5.195 -        keyboard_termios.c_cc[VTIME] = 0;
   5.196 -        if (tcsetattr(keyboard_fd, TCSAFLUSH, &keyboard_termios) < 0) {
   5.197 -            GS_CloseKeyboard(this);
   5.198 -            SDL_SetError("Unable to set terminal attributes");
   5.199 -            return (-1);
   5.200 -        }
   5.201 -        /* This will fail if we aren't root or this isn't our tty */
   5.202 -        if (ioctl(keyboard_fd, KDSKBMODE, K_MEDIUMRAW) < 0) {
   5.203 -            GS_CloseKeyboard(this);
   5.204 -            SDL_SetError("Unable to set keyboard in raw mode");
   5.205 -            return (-1);
   5.206 -        }
   5.207 -        if (ioctl(keyboard_fd, KDSETMODE, KD_GRAPHICS) < 0) {
   5.208 -            GS_CloseKeyboard(this);
   5.209 -            SDL_SetError("Unable to set keyboard in graphics mode");
   5.210 -            return (-1);
   5.211 -        }
   5.212 -    }
   5.213 -    return (keyboard_fd);
   5.214 -}
   5.215 -
   5.216 -void
   5.217 -GS_LeaveGraphicsMode(_THIS)
   5.218 -{
   5.219 -    if (GS_InGraphicsMode(this)) {
   5.220 -        ioctl(keyboard_fd, KDSETMODE, KD_TEXT);
   5.221 -        ioctl(keyboard_fd, KDSKBMODE, saved_kbd_mode);
   5.222 -        tcsetattr(keyboard_fd, TCSAFLUSH, &saved_kbd_termios);
   5.223 -        saved_kbd_mode = -1;
   5.224 -
   5.225 -        /* Head back over to the original virtual terminal */
   5.226 -        if (saved_vt > 0) {
   5.227 -            ioctl(keyboard_fd, VT_ACTIVATE, saved_vt);
   5.228 -        }
   5.229 -    }
   5.230 -}
   5.231 -
   5.232 -void
   5.233 -GS_CloseKeyboard(_THIS)
   5.234 -{
   5.235 -    if (keyboard_fd >= 0) {
   5.236 -        GS_LeaveGraphicsMode(this);
   5.237 -        if (keyboard_fd > 0) {
   5.238 -            close(keyboard_fd);
   5.239 -        }
   5.240 -    }
   5.241 -    keyboard_fd = -1;
   5.242 -}
   5.243 -
   5.244 -int
   5.245 -GS_OpenKeyboard(_THIS)
   5.246 -{
   5.247 -    /* Open only if not already opened */
   5.248 -    if (keyboard_fd < 0) {
   5.249 -        char *tty0[] = { "/dev/tty0", "/dev/vc/0", NULL };
   5.250 -        char *vcs[] = { "/dev/vc/%d", "/dev/tty%d", NULL };
   5.251 -        int i, tty0_fd;
   5.252 -
   5.253 -        /* Try to query for a free virtual terminal */
   5.254 -        tty0_fd = -1;
   5.255 -        for (i = 0; tty0[i] && (tty0_fd < 0); ++i) {
   5.256 -            tty0_fd = open(tty0[i], O_WRONLY, 0);
   5.257 -        }
   5.258 -        if (tty0_fd < 0) {
   5.259 -            tty0_fd = dup(0);   /* Maybe stdin is a VT? */
   5.260 -        }
   5.261 -        ioctl(tty0_fd, VT_OPENQRY, &current_vt);
   5.262 -        close(tty0_fd);
   5.263 -        if ((geteuid() == 0) && (current_vt > 0)) {
   5.264 -            for (i = 0; vcs[i] && (keyboard_fd < 0); ++i) {
   5.265 -                char vtpath[12];
   5.266 -
   5.267 -                SDL_snprintf(vtpath, SDL_arraysize(vtpath), vcs[i],
   5.268 -                             current_vt);
   5.269 -                keyboard_fd = open(vtpath, O_RDWR, 0);
   5.270 -#ifdef DEBUG_KEYBOARD
   5.271 -                fprintf(stderr, "vtpath = %s, fd = %d\n",
   5.272 -                        vtpath, keyboard_fd);
   5.273 -#endif /* DEBUG_KEYBOARD */
   5.274 -
   5.275 -                /* This needs to be our controlling tty
   5.276 -                   so that the kernel ioctl() calls work
   5.277 -                 */
   5.278 -                if (keyboard_fd >= 0) {
   5.279 -                    tty0_fd = open("/dev/tty", O_RDWR, 0);
   5.280 -                    if (tty0_fd >= 0) {
   5.281 -                        ioctl(tty0_fd, TIOCNOTTY, 0);
   5.282 -                        close(tty0_fd);
   5.283 -                    }
   5.284 -                }
   5.285 -            }
   5.286 -        }
   5.287 -        if (keyboard_fd < 0) {
   5.288 -            /* Last resort, maybe our tty is a usable VT */
   5.289 -            current_vt = 0;
   5.290 -            keyboard_fd = open("/dev/tty", O_RDWR);
   5.291 -        }
   5.292 -#ifdef DEBUG_KEYBOARD
   5.293 -        fprintf(stderr, "Current VT: %d\n", current_vt);
   5.294 -#endif
   5.295 -        saved_kbd_mode = -1;
   5.296 -
   5.297 -        /* Make sure that our input is a console terminal */
   5.298 -        {
   5.299 -            int dummy;
   5.300 -            if (ioctl(keyboard_fd, KDGKBMODE, &dummy) < 0) {
   5.301 -                close(keyboard_fd);
   5.302 -                keyboard_fd = -1;
   5.303 -                SDL_SetError("Unable to open a console terminal");
   5.304 -            }
   5.305 -        }
   5.306 -
   5.307 -        /* Set up keymap */
   5.308 -        GS_vgainitkeymaps(keyboard_fd);
   5.309 -    }
   5.310 -    return (keyboard_fd);
   5.311 -}
   5.312 -
   5.313 -static enum
   5.314 -{
   5.315 -    MOUSE_NONE = -1,
   5.316 -    MOUSE_GPM,                  /* Note: GPM uses the MSC protocol */
   5.317 -    MOUSE_PS2,
   5.318 -    MOUSE_IMPS2,
   5.319 -    MOUSE_MS,
   5.320 -    MOUSE_BM,
   5.321 -    NUM_MOUSE_DRVS
   5.322 -} mouse_drv = MOUSE_NONE;
   5.323 -
   5.324 -void
   5.325 -GS_CloseMouse(_THIS)
   5.326 -{
   5.327 -    if (mouse_fd > 0) {
   5.328 -        close(mouse_fd);
   5.329 -    }
   5.330 -    mouse_fd = -1;
   5.331 -}
   5.332 -
   5.333 -/* Returns processes listed in /proc with the desired name */
   5.334 -static int
   5.335 -find_pid(DIR * proc, const char *wanted_name)
   5.336 -{
   5.337 -    struct dirent *entry;
   5.338 -    int pid;
   5.339 -
   5.340 -    /* First scan proc for the gpm process */
   5.341 -    pid = 0;
   5.342 -    while ((pid == 0) && ((entry = readdir(proc)) != NULL)) {
   5.343 -        if (isdigit(entry->d_name[0])) {
   5.344 -            FILE *status;
   5.345 -            char path[PATH_MAX];
   5.346 -            char name[PATH_MAX];
   5.347 -
   5.348 -            SDL_snprintf(path, SDL_arraysize(path), "/proc/%s/status",
   5.349 -                         entry->d_name);
   5.350 -            status = fopen(path, "r");
   5.351 -            if (status) {
   5.352 -                name[0] = '\0';
   5.353 -                fscanf(status, "Name: %s", name);
   5.354 -                if (SDL_strcmp(name, wanted_name) == 0) {
   5.355 -                    pid = atoi(entry->d_name);
   5.356 -                }
   5.357 -                fclose(status);
   5.358 -            }
   5.359 -        }
   5.360 -    }
   5.361 -    return pid;
   5.362 -}
   5.363 -
   5.364 -/* Returns true if /dev/gpmdata is being written to by gpm */
   5.365 -static int
   5.366 -gpm_available(void)
   5.367 -{
   5.368 -    int available;
   5.369 -    DIR *proc;
   5.370 -    int pid;
   5.371 -    int cmdline, len, arglen;
   5.372 -    char path[PATH_MAX];
   5.373 -    char args[PATH_MAX], *arg;
   5.374 -
   5.375 -    /* Don't bother looking if the fifo isn't there */
   5.376 -    if (access(GPM_NODE_FIFO, F_OK) < 0) {
   5.377 -        return (0);
   5.378 -    }
   5.379 -
   5.380 -    available = 0;
   5.381 -    proc = opendir("/proc");
   5.382 -    if (proc) {
   5.383 -        while ((pid = find_pid(proc, "gpm")) > 0) {
   5.384 -            SDL_snprintf(path, SDL_arraysize(path), "/proc/%d/cmdline", pid);
   5.385 -            cmdline = open(path, O_RDONLY, 0);
   5.386 -            if (cmdline >= 0) {
   5.387 -                len = read(cmdline, args, sizeof(args));
   5.388 -                arg = args;
   5.389 -                while (len > 0) {
   5.390 -                    if (SDL_strcmp(arg, "-R") == 0) {
   5.391 -                        available = 1;
   5.392 -                    }
   5.393 -                    arglen = SDL_strlen(arg) + 1;
   5.394 -                    len -= arglen;
   5.395 -                    arg += arglen;
   5.396 -                }
   5.397 -                close(cmdline);
   5.398 -            }
   5.399 -        }
   5.400 -        closedir(proc);
   5.401 -    }
   5.402 -    return available;
   5.403 -}
   5.404 -
   5.405 -
   5.406 -/* rcg06112001 Set up IMPS/2 mode, if possible. This gives
   5.407 - *  us access to the mousewheel, etc. Returns zero if
   5.408 - *  writes to device failed, but you still need to query the
   5.409 - *  device to see which mode it's actually in.
   5.410 - */
   5.411 -static int
   5.412 -set_imps2_mode(int fd)
   5.413 -{
   5.414 -    /* If you wanted to control the mouse mode (and we do :)  ) ...
   5.415 -       Set IMPS/2 protocol:
   5.416 -       {0xf3,200,0xf3,100,0xf3,80}
   5.417 -       Reset mouse device:
   5.418 -       {0xFF}
   5.419 -     */
   5.420 -    Uint8 set_imps2[] = { 0xf3, 200, 0xf3, 100, 0xf3, 80 };
   5.421 -    Uint8 reset = 0xff;
   5.422 -    fd_set fdset;
   5.423 -    struct timeval tv;
   5.424 -    int retval = 0;
   5.425 -
   5.426 -    if (write(fd, &set_imps2, sizeof(set_imps2)) == sizeof(set_imps2)) {
   5.427 -        if (write(fd, &reset, sizeof(reset)) == sizeof(reset)) {
   5.428 -            retval = 1;
   5.429 -        }
   5.430 -    }
   5.431 -
   5.432 -    /* Get rid of any chatter from the above */
   5.433 -    FD_ZERO(&fdset);
   5.434 -    FD_SET(fd, &fdset);
   5.435 -    tv.tv_sec = 0;
   5.436 -    tv.tv_usec = 0;
   5.437 -    while (select(fd + 1, &fdset, 0, 0, &tv) > 0) {
   5.438 -        char temp[32];
   5.439 -        read(fd, temp, sizeof(temp));
   5.440 -    }
   5.441 -
   5.442 -    return retval;
   5.443 -}
   5.444 -
   5.445 -
   5.446 -/* Returns true if the mouse uses the IMPS/2 protocol */
   5.447 -static int
   5.448 -detect_imps2(int fd)
   5.449 -{
   5.450 -    int imps2;
   5.451 -
   5.452 -    imps2 = 0;
   5.453 -
   5.454 -    if (SDL_getenv("SDL_MOUSEDEV_IMPS2")) {
   5.455 -        imps2 = 1;
   5.456 -    }
   5.457 -    if (!imps2) {
   5.458 -        Uint8 query_ps2 = 0xF2;
   5.459 -        fd_set fdset;
   5.460 -        struct timeval tv;
   5.461 -
   5.462 -        /* Get rid of any mouse motion noise */
   5.463 -        FD_ZERO(&fdset);
   5.464 -        FD_SET(fd, &fdset);
   5.465 -        tv.tv_sec = 0;
   5.466 -        tv.tv_usec = 0;
   5.467 -        while (select(fd + 1, &fdset, 0, 0, &tv) > 0) {
   5.468 -            char temp[32];
   5.469 -            read(fd, temp, sizeof(temp));
   5.470 -        }
   5.471 -
   5.472 -        /* Query for the type of mouse protocol */
   5.473 -        if (write(fd, &query_ps2, sizeof(query_ps2)) == sizeof(query_ps2)) {
   5.474 -            Uint8 ch = 0;
   5.475 -
   5.476 -            /* Get the mouse protocol response */
   5.477 -            do {
   5.478 -                FD_ZERO(&fdset);
   5.479 -                FD_SET(fd, &fdset);
   5.480 -                tv.tv_sec = 1;
   5.481 -                tv.tv_usec = 0;
   5.482 -                if (select(fd + 1, &fdset, 0, 0, &tv) < 1) {
   5.483 -                    break;
   5.484 -                }
   5.485 -            } while ((read(fd, &ch, sizeof(ch)) == sizeof(ch)) &&
   5.486 -                     ((ch == 0xFA) || (ch == 0xAA)));
   5.487 -
   5.488 -            /* Experimental values (Logitech wheelmouse) */
   5.489 -#ifdef DEBUG_MOUSE
   5.490 -            fprintf(stderr, "Last mouse mode: 0x%x\n", ch);
   5.491 -#endif
   5.492 -            if (ch == 3) {
   5.493 -                imps2 = 1;
   5.494 -            }
   5.495 -        }
   5.496 -    }
   5.497 -    return imps2;
   5.498 -}
   5.499 -
   5.500 -int
   5.501 -GS_OpenMouse(_THIS)
   5.502 -{
   5.503 -    int i;
   5.504 -    const char *mousedev;
   5.505 -    const char *mousedrv;
   5.506 -
   5.507 -    mousedrv = SDL_getenv("SDL_MOUSEDRV");
   5.508 -    mousedev = SDL_getenv("SDL_MOUSEDEV");
   5.509 -    mouse_fd = -1;
   5.510 -
   5.511 -    /* STD MICE */
   5.512 -
   5.513 -    if (mousedev == NULL) {
   5.514 -        /* FIXME someday... allow multiple mice in this driver */
   5.515 -        char *ps2mice[] = {
   5.516 -            "/dev/input/mice", "/dev/usbmouse", "/dev/psaux", NULL
   5.517 -        };
   5.518 -        /* First try to use GPM in repeater mode */
   5.519 -        if (mouse_fd < 0) {
   5.520 -            if (gpm_available()) {
   5.521 -                mouse_fd = open(GPM_NODE_FIFO, O_RDONLY, 0);
   5.522 -                if (mouse_fd >= 0) {
   5.523 -#ifdef DEBUG_MOUSE
   5.524 -                    fprintf(stderr, "Using GPM mouse\n");
   5.525 -#endif
   5.526 -                    mouse_drv = MOUSE_GPM;
   5.527 -                }
   5.528 -            }
   5.529 -        }
   5.530 -        /* Now try to use a modern PS/2 mouse */
   5.531 -        for (i = 0; (mouse_fd < 0) && ps2mice[i]; ++i) {
   5.532 -            mouse_fd = open(ps2mice[i], O_RDWR, 0);
   5.533 -            if (mouse_fd < 0) {
   5.534 -                mouse_fd = open(ps2mice[i], O_RDONLY, 0);
   5.535 -            }
   5.536 -            if (mouse_fd >= 0) {
   5.537 -                /* rcg06112001 Attempt to set IMPS/2 mode */
   5.538 -                if (i == 0) {
   5.539 -                    set_imps2_mode(mouse_fd);
   5.540 -                }
   5.541 -                if (detect_imps2(mouse_fd)) {
   5.542 -#ifdef DEBUG_MOUSE
   5.543 -                    fprintf(stderr, "Using IMPS2 mouse\n");
   5.544 -#endif
   5.545 -                    mouse_drv = MOUSE_IMPS2;
   5.546 -                } else {
   5.547 -                    mouse_drv = MOUSE_PS2;
   5.548 -#ifdef DEBUG_MOUSE
   5.549 -                    fprintf(stderr, "Using PS2 mouse\n");
   5.550 -#endif
   5.551 -                }
   5.552 -            }
   5.553 -        }
   5.554 -        /* Next try to use a PPC ADB port mouse */
   5.555 -        if (mouse_fd < 0) {
   5.556 -            mouse_fd = open("/dev/adbmouse", O_RDONLY, 0);
   5.557 -            if (mouse_fd >= 0) {
   5.558 -#ifdef DEBUG_MOUSE
   5.559 -                fprintf(stderr, "Using ADB mouse\n");
   5.560 -#endif
   5.561 -                mouse_drv = MOUSE_BM;
   5.562 -            }
   5.563 -        }
   5.564 -    }
   5.565 -    /* Default to a serial Microsoft mouse */
   5.566 -    if (mouse_fd < 0) {
   5.567 -        if (mousedev == NULL) {
   5.568 -            mousedev = "/dev/mouse";
   5.569 -        }
   5.570 -        mouse_fd = open(mousedev, O_RDONLY, 0);
   5.571 -        if (mouse_fd >= 0) {
   5.572 -            struct termios mouse_termios;
   5.573 -
   5.574 -            /* Set the sampling speed to 1200 baud */
   5.575 -            tcgetattr(mouse_fd, &mouse_termios);
   5.576 -            mouse_termios.c_iflag = IGNBRK | IGNPAR;
   5.577 -            mouse_termios.c_oflag = 0;
   5.578 -            mouse_termios.c_lflag = 0;
   5.579 -            mouse_termios.c_line = 0;
   5.580 -            mouse_termios.c_cc[VTIME] = 0;
   5.581 -            mouse_termios.c_cc[VMIN] = 1;
   5.582 -            mouse_termios.c_cflag = CREAD | CLOCAL | HUPCL;
   5.583 -            mouse_termios.c_cflag |= CS8;
   5.584 -            mouse_termios.c_cflag |= B1200;
   5.585 -            tcsetattr(mouse_fd, TCSAFLUSH, &mouse_termios);
   5.586 -#ifdef DEBUG_MOUSE
   5.587 -            fprintf(stderr, "Using Microsoft mouse on %s\n", mousedev);
   5.588 -#endif
   5.589 -            mouse_drv = MOUSE_MS;
   5.590 -        }
   5.591 -    }
   5.592 -    if (mouse_fd < 0) {
   5.593 -        mouse_drv = MOUSE_NONE;
   5.594 -    }
   5.595 -    return (mouse_fd);
   5.596 -}
   5.597 -
   5.598 -static int posted = 0;
   5.599 -
   5.600 -void
   5.601 -GS_vgamousecallback(int button, int dx, int dy)
   5.602 -{
   5.603 -    int button_1, button_3;
   5.604 -    int button_state;
   5.605 -    int state_changed;
   5.606 -    int i;
   5.607 -    Uint8 state;
   5.608 -
   5.609 -    if (dx || dy) {
   5.610 -        posted += SDL_PrivateMouseMotion(0, 1, dx, dy);
   5.611 -    }
   5.612 -
   5.613 -    /* Swap button 1 and 3 */
   5.614 -    button_1 = (button & 0x04) >> 2;
   5.615 -    button_3 = (button & 0x01) << 2;
   5.616 -    button &= ~0x05;
   5.617 -    button |= (button_1 | button_3);
   5.618 -
   5.619 -    /* See what changed */
   5.620 -    button_state = SDL_GetMouseState(NULL, NULL);
   5.621 -    state_changed = button_state ^ button;
   5.622 -    for (i = 0; i < 8; ++i) {
   5.623 -        if (state_changed & (1 << i)) {
   5.624 -            if (button & (1 << i)) {
   5.625 -                state = SDL_PRESSED;
   5.626 -            } else {
   5.627 -                state = SDL_RELEASED;
   5.628 -            }
   5.629 -            posted += SDL_PrivateMouseButton(state, i + 1, 0, 0);
   5.630 -        }
   5.631 -    }
   5.632 -}
   5.633 -
   5.634 -/* For now, use GPM, PS/2, and MS protocols
   5.635 -   Driver adapted from the SVGAlib mouse driver code (taken from gpm, etc.)
   5.636 - */
   5.637 -static void
   5.638 -handle_mouse(_THIS)
   5.639 -{
   5.640 -    static int start = 0;
   5.641 -    static unsigned char mousebuf[BUFSIZ];
   5.642 -    int i, nread;
   5.643 -    int button = 0;
   5.644 -    int dx = 0, dy = 0;
   5.645 -    int packetsize = 0;
   5.646 -
   5.647 -    /* Figure out the mouse packet size */
   5.648 -    switch (mouse_drv) {
   5.649 -    case MOUSE_NONE:
   5.650 -        /* Ack! */
   5.651 -        read(mouse_fd, mousebuf, BUFSIZ);
   5.652 -        return;
   5.653 -    case MOUSE_GPM:
   5.654 -        packetsize = 5;
   5.655 -        break;
   5.656 -    case MOUSE_IMPS2:
   5.657 -        packetsize = 4;
   5.658 -        break;
   5.659 -    case MOUSE_PS2:
   5.660 -    case MOUSE_MS:
   5.661 -    case MOUSE_BM:
   5.662 -        packetsize = 3;
   5.663 -        break;
   5.664 -    case NUM_MOUSE_DRVS:
   5.665 -        /* Uh oh.. */
   5.666 -        packetsize = 0;
   5.667 -        break;
   5.668 -    }
   5.669 -
   5.670 -    /* Read as many packets as possible */
   5.671 -    nread = read(mouse_fd, &mousebuf[start], BUFSIZ - start);
   5.672 -    if (nread < 0) {
   5.673 -        return;
   5.674 -    }
   5.675 -    nread += start;
   5.676 -#ifdef DEBUG_MOUSE
   5.677 -    fprintf(stderr, "Read %d bytes from mouse, start = %d\n", nread, start);
   5.678 -#endif
   5.679 -    for (i = 0; i < (nread - (packetsize - 1)); i += packetsize) {
   5.680 -        switch (mouse_drv) {
   5.681 -        case MOUSE_NONE:
   5.682 -            break;
   5.683 -        case MOUSE_GPM:
   5.684 -            /* GPM protocol has 0x80 in high byte */
   5.685 -            if ((mousebuf[i] & 0xF8) != 0x80) {
   5.686 -                /* Go to next byte */
   5.687 -                i -= (packetsize - 1);
   5.688 -                continue;
   5.689 -            }
   5.690 -            /* Get current mouse state */
   5.691 -            button = (~mousebuf[i]) & 0x07;
   5.692 -            dx = (signed char) (mousebuf[i + 1]) +
   5.693 -                (signed char) (mousebuf[i + 3]);
   5.694 -            dy = -((signed char) (mousebuf[i + 2]) +
   5.695 -                   (signed char) (mousebuf[i + 4]));
   5.696 -            break;
   5.697 -        case MOUSE_PS2:
   5.698 -            /* PS/2 protocol has nothing in high byte */
   5.699 -            if ((mousebuf[i] & 0xC0) != 0) {
   5.700 -                /* Go to next byte */
   5.701 -                i -= (packetsize - 1);
   5.702 -                continue;
   5.703 -            }
   5.704 -            /* Get current mouse state */
   5.705 -            button = (mousebuf[i] & 0x04) >> 1 |        /*Middle */
   5.706 -                (mousebuf[i] & 0x02) >> 1 |     /*Right */
   5.707 -                (mousebuf[i] & 0x01) << 2;      /*Left */
   5.708 -            dx = (mousebuf[i] & 0x10) ?
   5.709 -                mousebuf[i + 1] - 256 : mousebuf[i + 1];
   5.710 -            dy = (mousebuf[i] & 0x20) ?
   5.711 -                -(mousebuf[i + 2] - 256) : -mousebuf[i + 2];
   5.712 -            break;
   5.713 -        case MOUSE_IMPS2:
   5.714 -            /* Get current mouse state */
   5.715 -            button = (mousebuf[i] & 0x04) >> 1 |        /*Middle */
   5.716 -                (mousebuf[i] & 0x02) >> 1 |     /*Right */
   5.717 -                (mousebuf[i] & 0x01) << 2 |     /*Left */
   5.718 -                (mousebuf[i] & 0x40) >> 3 |     /* 4 */
   5.719 -                (mousebuf[i] & 0x80) >> 3;      /* 5 */
   5.720 -            dx = (mousebuf[i] & 0x10) ?
   5.721 -                mousebuf[i + 1] - 256 : mousebuf[i + 1];
   5.722 -            dy = (mousebuf[i] & 0x20) ?
   5.723 -                -(mousebuf[i + 2] - 256) : -mousebuf[i + 2];
   5.724 -            switch (mousebuf[i + 3] & 0x0F) {
   5.725 -            case 0x0E:         /* DX = +1 */
   5.726 -            case 0x02:         /* DX = -1 */
   5.727 -                break;
   5.728 -            case 0x0F:         /* DY = +1 (map button 4) */
   5.729 -                FB_vgamousecallback(button | (1 << 3), 1, 0, 0);
   5.730 -                break;
   5.731 -            case 0x01:         /* DY = -1 (map button 5) */
   5.732 -                FB_vgamousecallback(button | (1 << 4), 1, 0, 0);
   5.733 -                break;
   5.734 -            }
   5.735 -            break;
   5.736 -        case MOUSE_MS:
   5.737 -            /* Microsoft protocol has 0x40 in high byte */
   5.738 -            if ((mousebuf[i] & 0x40) != 0x40) {
   5.739 -                /* Go to next byte */
   5.740 -                i -= (packetsize - 1);
   5.741 -                continue;
   5.742 -            }
   5.743 -            /* Get current mouse state */
   5.744 -            button = ((mousebuf[i] & 0x20) >> 3) |
   5.745 -                ((mousebuf[i] & 0x10) >> 4);
   5.746 -            dx = (signed char) (((mousebuf[i] & 0x03) << 6) |
   5.747 -                                (mousebuf[i + 1] & 0x3F));
   5.748 -            dy = (signed char) (((mousebuf[i] & 0x0C) << 4) |
   5.749 -                                (mousebuf[i + 2] & 0x3F));
   5.750 -            break;
   5.751 -        case MOUSE_BM:
   5.752 -            /* BusMouse protocol has 0xF8 in high byte */
   5.753 -            if ((mousebuf[i] & 0xF8) != 0x80) {
   5.754 -                /* Go to next byte */
   5.755 -                i -= (packetsize - 1);
   5.756 -                continue;
   5.757 -            }
   5.758 -            /* Get current mouse state */
   5.759 -            button = (~mousebuf[i]) & 0x07;
   5.760 -            dx = (signed char) mousebuf[i + 1];
   5.761 -            dy = -(signed char) mousebuf[i + 2];
   5.762 -            break;
   5.763 -        case NUM_MOUSE_DRVS:
   5.764 -            /* Uh oh.. */
   5.765 -            dx = 0;
   5.766 -            dy = 0;
   5.767 -            break;
   5.768 -        }
   5.769 -        GS_vgamousecallback(button, dx, dy);
   5.770 -    }
   5.771 -    if (i < nread) {
   5.772 -        SDL_memcpy(mousebuf, &mousebuf[i], (nread - i));
   5.773 -        start = (nread - i);
   5.774 -    } else {
   5.775 -        start = 0;
   5.776 -    }
   5.777 -    return;
   5.778 -}
   5.779 -
   5.780 -static void
   5.781 -handle_keyboard(_THIS)
   5.782 -{
   5.783 -    unsigned char keybuf[BUFSIZ];
   5.784 -    int i, nread;
   5.785 -    int pressed;
   5.786 -    int scancode;
   5.787 -    SDL_keysym keysym;
   5.788 -
   5.789 -    nread = read(keyboard_fd, keybuf, BUFSIZ);
   5.790 -    for (i = 0; i < nread; ++i) {
   5.791 -        scancode = keybuf[i] & 0x7F;
   5.792 -        if (keybuf[i] & 0x80) {
   5.793 -            pressed = SDL_RELEASED;
   5.794 -        } else {
   5.795 -            pressed = SDL_PRESSED;
   5.796 -        }
   5.797 -        TranslateKey(scancode, &keysym);
   5.798 -        posted += SDL_PrivateKeyboard(pressed, &keysym);
   5.799 -    }
   5.800 -}
   5.801 -
   5.802 -void
   5.803 -GS_PumpEvents(_THIS)
   5.804 -{
   5.805 -    fd_set fdset;
   5.806 -    int max_fd;
   5.807 -    static struct timeval zero;
   5.808 -
   5.809 -    do {
   5.810 -        posted = 0;
   5.811 -
   5.812 -        FD_ZERO(&fdset);
   5.813 -        max_fd = 0;
   5.814 -        if (keyboard_fd >= 0) {
   5.815 -            FD_SET(keyboard_fd, &fdset);
   5.816 -            if (max_fd < keyboard_fd) {
   5.817 -                max_fd = keyboard_fd;
   5.818 -            }
   5.819 -        }
   5.820 -        if (mouse_fd >= 0) {
   5.821 -            FD_SET(mouse_fd, &fdset);
   5.822 -            if (max_fd < mouse_fd) {
   5.823 -                max_fd = mouse_fd;
   5.824 -            }
   5.825 -        }
   5.826 -        if (select(max_fd + 1, &fdset, NULL, NULL, &zero) > 0) {
   5.827 -            if (keyboard_fd >= 0) {
   5.828 -                if (FD_ISSET(keyboard_fd, &fdset)) {
   5.829 -                    handle_keyboard(this);
   5.830 -                }
   5.831 -            }
   5.832 -            if (mouse_fd >= 0) {
   5.833 -                if (FD_ISSET(mouse_fd, &fdset)) {
   5.834 -                    handle_mouse(this);
   5.835 -                }
   5.836 -            }
   5.837 -        }
   5.838 -    } while (posted);
   5.839 -}
   5.840 -
   5.841 -void
   5.842 -GS_InitOSKeymap(_THIS)
   5.843 -{
   5.844 -    int i;
   5.845 -
   5.846 -    /* Initialize the Linux key translation table */
   5.847 -
   5.848 -    /* First get the ascii keys and others not well handled */
   5.849 -    for (i = 0; i < SDL_arraysize(keymap); ++i) {
   5.850 -        switch (i) {
   5.851 -            /* These aren't handled by the x86 kernel keymapping (?) */
   5.852 -        case SCANCODE_PRINTSCREEN:
   5.853 -            keymap[i] = SDLK_PRINT;
   5.854 -            break;
   5.855 -        case SCANCODE_BREAK:
   5.856 -            keymap[i] = SDLK_BREAK;
   5.857 -            break;
   5.858 -        case SCANCODE_BREAK_ALTERNATIVE:
   5.859 -            keymap[i] = SDLK_PAUSE;
   5.860 -            break;
   5.861 -        case SCANCODE_LEFTSHIFT:
   5.862 -            keymap[i] = SDLK_LSHIFT;
   5.863 -            break;
   5.864 -        case SCANCODE_RIGHTSHIFT:
   5.865 -            keymap[i] = SDLK_RSHIFT;
   5.866 -            break;
   5.867 -        case SCANCODE_LEFTCONTROL:
   5.868 -            keymap[i] = SDLK_LCTRL;
   5.869 -            break;
   5.870 -        case SCANCODE_RIGHTCONTROL:
   5.871 -            keymap[i] = SDLK_RCTRL;
   5.872 -            break;
   5.873 -        case SCANCODE_RIGHTWIN:
   5.874 -            keymap[i] = SDLK_RSUPER;
   5.875 -            break;
   5.876 -        case SCANCODE_LEFTWIN:
   5.877 -            keymap[i] = SDLK_LSUPER;
   5.878 -            break;
   5.879 -        case 127:
   5.880 -            keymap[i] = SDLK_MENU;
   5.881 -            break;
   5.882 -            /* this should take care of all standard ascii keys */
   5.883 -        default:
   5.884 -            keymap[i] = KVAL(vga_keymap[0][i]);
   5.885 -            break;
   5.886 -        }
   5.887 -    }
   5.888 -    for (i = 0; i < SDL_arraysize(keymap); ++i) {
   5.889 -        switch (keymap_temp[i]) {
   5.890 -        case K_F1:
   5.891 -            keymap[i] = SDLK_F1;
   5.892 -            break;
   5.893 -        case K_F2:
   5.894 -            keymap[i] = SDLK_F2;
   5.895 -            break;
   5.896 -        case K_F3:
   5.897 -            keymap[i] = SDLK_F3;
   5.898 -            break;
   5.899 -        case K_F4:
   5.900 -            keymap[i] = SDLK_F4;
   5.901 -            break;
   5.902 -        case K_F5:
   5.903 -            keymap[i] = SDLK_F5;
   5.904 -            break;
   5.905 -        case K_F6:
   5.906 -            keymap[i] = SDLK_F6;
   5.907 -            break;
   5.908 -        case K_F7:
   5.909 -            keymap[i] = SDLK_F7;
   5.910 -            break;
   5.911 -        case K_F8:
   5.912 -            keymap[i] = SDLK_F8;
   5.913 -            break;
   5.914 -        case K_F9:
   5.915 -            keymap[i] = SDLK_F9;
   5.916 -            break;
   5.917 -        case K_F10:
   5.918 -            keymap[i] = SDLK_F10;
   5.919 -            break;
   5.920 -        case K_F11:
   5.921 -            keymap[i] = SDLK_F11;
   5.922 -            break;
   5.923 -        case K_F12:
   5.924 -            keymap[i] = SDLK_F12;
   5.925 -            break;
   5.926 -
   5.927 -        case K_DOWN:
   5.928 -            keymap[i] = SDLK_DOWN;
   5.929 -            break;
   5.930 -        case K_LEFT:
   5.931 -            keymap[i] = SDLK_LEFT;
   5.932 -            break;
   5.933 -        case K_RIGHT:
   5.934 -            keymap[i] = SDLK_RIGHT;
   5.935 -            break;
   5.936 -        case K_UP:
   5.937 -            keymap[i] = SDLK_UP;
   5.938 -            break;
   5.939 -
   5.940 -        case K_P0:
   5.941 -            keymap[i] = SDLK_KP0;
   5.942 -            break;
   5.943 -        case K_P1:
   5.944 -            keymap[i] = SDLK_KP1;
   5.945 -            break;
   5.946 -        case K_P2:
   5.947 -            keymap[i] = SDLK_KP2;
   5.948 -            break;
   5.949 -        case K_P3:
   5.950 -            keymap[i] = SDLK_KP3;
   5.951 -            break;
   5.952 -        case K_P4:
   5.953 -            keymap[i] = SDLK_KP4;
   5.954 -            break;
   5.955 -        case K_P5:
   5.956 -            keymap[i] = SDLK_KP5;
   5.957 -            break;
   5.958 -        case K_P6:
   5.959 -            keymap[i] = SDLK_KP6;
   5.960 -            break;
   5.961 -        case K_P7:
   5.962 -            keymap[i] = SDLK_KP7;
   5.963 -            break;
   5.964 -        case K_P8:
   5.965 -            keymap[i] = SDLK_KP8;
   5.966 -            break;
   5.967 -        case K_P9:
   5.968 -            keymap[i] = SDLK_KP9;
   5.969 -            break;
   5.970 -        case K_PPLUS:
   5.971 -            keymap[i] = SDLK_KP_PLUS;
   5.972 -            break;
   5.973 -        case K_PMINUS:
   5.974 -            keymap[i] = SDLK_KP_MINUS;
   5.975 -            break;
   5.976 -        case K_PSTAR:
   5.977 -            keymap[i] = SDLK_KP_MULTIPLY;
   5.978 -            break;
   5.979 -        case K_PSLASH:
   5.980 -            keymap[i] = SDLK_KP_DIVIDE;
   5.981 -            break;
   5.982 -        case K_PENTER:
   5.983 -            keymap[i] = SDLK_KP_ENTER;
   5.984 -            break;
   5.985 -        case K_PDOT:
   5.986 -            keymap[i] = SDLK_KP_PERIOD;
   5.987 -            break;
   5.988 -
   5.989 -        case K_SHIFT:
   5.990 -            if (keymap[i] != SDLK_RSHIFT)
   5.991 -                keymap[i] = SDLK_LSHIFT;
   5.992 -            break;
   5.993 -        case K_SHIFTL:
   5.994 -            keymap[i] = SDLK_LSHIFT;
   5.995 -            break;
   5.996 -        case K_SHIFTR:
   5.997 -            keymap[i] = SDLK_RSHIFT;
   5.998 -            break;
   5.999 -        case K_CTRL:
  5.1000 -            if (keymap[i] != SDLK_RCTRL)
  5.1001 -                keymap[i] = SDLK_LCTRL;
  5.1002 -            break;
  5.1003 -        case K_CTRLL:
  5.1004 -            keymap[i] = SDLK_LCTRL;
  5.1005 -            break;
  5.1006 -        case K_CTRLR:
  5.1007 -            keymap[i] = SDLK_RCTRL;
  5.1008 -            break;
  5.1009 -        case K_ALT:
  5.1010 -            keymap[i] = SDLK_LALT;
  5.1011 -            break;
  5.1012 -        case K_ALTGR:
  5.1013 -            keymap[i] = SDLK_RALT;
  5.1014 -            break;
  5.1015 -
  5.1016 -        case K_INSERT:
  5.1017 -            keymap[i] = SDLK_INSERT;
  5.1018 -            break;
  5.1019 -        case K_REMOVE:
  5.1020 -            keymap[i] = SDLK_DELETE;
  5.1021 -            break;
  5.1022 -        case K_PGUP:
  5.1023 -            keymap[i] = SDLK_PAGEUP;
  5.1024 -            break;
  5.1025 -        case K_PGDN:
  5.1026 -            keymap[i] = SDLK_PAGEDOWN;
  5.1027 -            break;
  5.1028 -        case K_FIND:
  5.1029 -            keymap[i] = SDLK_HOME;
  5.1030 -            break;
  5.1031 -        case K_SELECT:
  5.1032 -            keymap[i] = SDLK_END;
  5.1033 -            break;
  5.1034 -
  5.1035 -        case K_NUM:
  5.1036 -            keymap[i] = SDLK_NUMLOCK;
  5.1037 -            break;
  5.1038 -        case K_CAPS:
  5.1039 -            keymap[i] = SDLK_CAPSLOCK;
  5.1040 -            break;
  5.1041 -
  5.1042 -        case K_F13:
  5.1043 -            keymap[i] = SDLK_PRINT;
  5.1044 -            break;
  5.1045 -        case K_HOLD:
  5.1046 -            keymap[i] = SDLK_SCROLLOCK;
  5.1047 -            break;
  5.1048 -        case K_PAUSE:
  5.1049 -            keymap[i] = SDLK_PAUSE;
  5.1050 -            break;
  5.1051 -
  5.1052 -        case 127:
  5.1053 -            keymap[i] = SDLK_BACKSPACE;
  5.1054 -            break;
  5.1055 -
  5.1056 -        default:
  5.1057 -            break;
  5.1058 -        }
  5.1059 -    }
  5.1060 -}
  5.1061 -
  5.1062 -static SDL_keysym *
  5.1063 -TranslateKey(int scancode, SDL_keysym * keysym)
  5.1064 -{
  5.1065 -    /* Set the keysym information */
  5.1066 -    keysym->scancode = scancode;
  5.1067 -    keysym->sym = keymap[scancode];
  5.1068 -    keysym->mod = KMOD_NONE;
  5.1069 -
  5.1070 -    /* If UNICODE is on, get the UNICODE value for the key */
  5.1071 -    keysym->unicode = 0;
  5.1072 -    if (SDL_TranslateUNICODE) {
  5.1073 -        int map;
  5.1074 -        SDLMod modstate;
  5.1075 -
  5.1076 -        modstate = SDL_GetModState();
  5.1077 -        map = 0;
  5.1078 -        if (modstate & KMOD_SHIFT) {
  5.1079 -            map |= (1 << KG_SHIFT);
  5.1080 -        }
  5.1081 -        if (modstate & KMOD_CTRL) {
  5.1082 -            map |= (1 << KG_CTRL);
  5.1083 -        }
  5.1084 -        if (modstate & KMOD_ALT) {
  5.1085 -            map |= (1 << KG_ALT);
  5.1086 -        }
  5.1087 -        if (modstate & KMOD_MODE) {
  5.1088 -            map |= (1 << KG_ALTGR);
  5.1089 -        }
  5.1090 -        if (KTYP(vga_keymap[map][scancode]) == KT_LETTER) {
  5.1091 -            if (modstate & KMOD_CAPS) {
  5.1092 -                map ^= (1 << KG_SHIFT);
  5.1093 -            }
  5.1094 -        }
  5.1095 -        if (KTYP(vga_keymap[map][scancode]) == KT_PAD) {
  5.1096 -            if (modstate & KMOD_NUM) {
  5.1097 -                keysym->unicode = KVAL(vga_keymap[map][scancode]);
  5.1098 -            }
  5.1099 -        } else {
  5.1100 -            keysym->unicode = KVAL(vga_keymap[map][scancode]);
  5.1101 -        }
  5.1102 -    }
  5.1103 -    return (keysym);
  5.1104 -}
  5.1105 -
  5.1106 -/* vi: set ts=4 sw=4 expandtab: */
     6.1 --- a/src/video/ps2gs/SDL_gsevents_c.h	Mon Jan 18 14:16:47 2010 +0000
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,39 +0,0 @@
     6.4 -/*
     6.5 -    SDL - Simple DirectMedia Layer
     6.6 -    Copyright (C) 1997-2009 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_gsvideo.h"
    6.28 -
    6.29 -/* Variables and functions exported by SDL_sysevents.c to other parts 
    6.30 -   of the native video subsystem (SDL_sysvideo.c)
    6.31 -*/
    6.32 -extern int GS_OpenKeyboard(_THIS);
    6.33 -extern void GS_CloseKeyboard(_THIS);
    6.34 -extern int GS_OpenMouse(_THIS);
    6.35 -extern void GS_CloseMouse(_THIS);
    6.36 -extern int GS_EnterGraphicsMode(_THIS);
    6.37 -extern int GS_InGraphicsMode(_THIS);
    6.38 -extern void GS_LeaveGraphicsMode(_THIS);
    6.39 -
    6.40 -extern void GS_InitOSKeymap(_THIS);
    6.41 -extern void GS_PumpEvents(_THIS);
    6.42 -/* vi: set ts=4 sw=4 expandtab: */
     7.1 --- a/src/video/ps2gs/SDL_gskeys.h	Mon Jan 18 14:16:47 2010 +0000
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,139 +0,0 @@
     7.4 -
     7.5 -/* Scancodes for the Linux framebuffer console
     7.6 -   - Taken with thanks from SVGAlib 1.4.0
     7.7 -*/
     7.8 -
     7.9 -#define SCANCODE_ESCAPE			1
    7.10 -
    7.11 -#define SCANCODE_1			2
    7.12 -#define SCANCODE_2			3
    7.13 -#define SCANCODE_3			4
    7.14 -#define SCANCODE_4			5
    7.15 -#define SCANCODE_5			6
    7.16 -#define SCANCODE_6			7
    7.17 -#define SCANCODE_7			8
    7.18 -#define SCANCODE_8			9
    7.19 -#define SCANCODE_9			10
    7.20 -#define SCANCODE_0			11
    7.21 -
    7.22 -#define SCANCODE_MINUS			12
    7.23 -#define SCANCODE_EQUAL			13
    7.24 -
    7.25 -#define SCANCODE_BACKSPACE		14
    7.26 -#define SCANCODE_TAB			15
    7.27 -
    7.28 -#define SCANCODE_Q			16
    7.29 -#define SCANCODE_W			17
    7.30 -#define SCANCODE_E			18
    7.31 -#define SCANCODE_R			19
    7.32 -#define SCANCODE_T			20
    7.33 -#define SCANCODE_Y			21
    7.34 -#define SCANCODE_U			22
    7.35 -#define SCANCODE_I			23
    7.36 -#define SCANCODE_O			24
    7.37 -#define SCANCODE_P			25
    7.38 -#define SCANCODE_BRACKET_LEFT		26
    7.39 -#define SCANCODE_BRACKET_RIGHT		27
    7.40 -
    7.41 -#define SCANCODE_ENTER			28
    7.42 -
    7.43 -#define SCANCODE_LEFTCONTROL		29
    7.44 -
    7.45 -#define SCANCODE_A			30
    7.46 -#define SCANCODE_S			31
    7.47 -#define SCANCODE_D			32
    7.48 -#define SCANCODE_F			33
    7.49 -#define SCANCODE_G			34
    7.50 -#define SCANCODE_H			35
    7.51 -#define SCANCODE_J			36
    7.52 -#define SCANCODE_K			37
    7.53 -#define SCANCODE_L			38
    7.54 -#define SCANCODE_SEMICOLON		39
    7.55 -#define SCANCODE_APOSTROPHE		40
    7.56 -#define SCANCODE_GRAVE			41
    7.57 -
    7.58 -#define SCANCODE_LEFTSHIFT		42
    7.59 -#define SCANCODE_BACKSLASH		43
    7.60 -
    7.61 -#define SCANCODE_Z			44
    7.62 -#define SCANCODE_X			45
    7.63 -#define SCANCODE_C			46
    7.64 -#define SCANCODE_V			47
    7.65 -#define SCANCODE_B			48
    7.66 -#define SCANCODE_N			49
    7.67 -#define SCANCODE_M			50
    7.68 -#define SCANCODE_COMMA			51
    7.69 -#define SCANCODE_PERIOD			52
    7.70 -#define SCANCODE_SLASH			53
    7.71 -
    7.72 -#define SCANCODE_RIGHTSHIFT		54
    7.73 -#define SCANCODE_KEYPADMULTIPLY		55
    7.74 -
    7.75 -#define SCANCODE_LEFTALT		56
    7.76 -#define SCANCODE_SPACE			57
    7.77 -#define SCANCODE_CAPSLOCK		58
    7.78 -
    7.79 -#define SCANCODE_F1			59
    7.80 -#define SCANCODE_F2			60
    7.81 -#define SCANCODE_F3			61
    7.82 -#define SCANCODE_F4			62
    7.83 -#define SCANCODE_F5			63
    7.84 -#define SCANCODE_F6			64
    7.85 -#define SCANCODE_F7			65
    7.86 -#define SCANCODE_F8			66
    7.87 -#define SCANCODE_F9			67
    7.88 -#define SCANCODE_F10			68
    7.89 -
    7.90 -#define SCANCODE_NUMLOCK		69
    7.91 -#define SCANCODE_SCROLLLOCK		70
    7.92 -
    7.93 -#define SCANCODE_KEYPAD7		71
    7.94 -#define SCANCODE_CURSORUPLEFT		71
    7.95 -#define SCANCODE_KEYPAD8		72
    7.96 -#define SCANCODE_CURSORUP		72
    7.97 -#define SCANCODE_KEYPAD9		73
    7.98 -#define SCANCODE_CURSORUPRIGHT		73
    7.99 -#define SCANCODE_KEYPADMINUS		74
   7.100 -#define SCANCODE_KEYPAD4		75
   7.101 -#define SCANCODE_CURSORLEFT		75
   7.102 -#define SCANCODE_KEYPAD5		76
   7.103 -#define SCANCODE_KEYPAD6		77
   7.104 -#define SCANCODE_CURSORRIGHT		77
   7.105 -#define SCANCODE_KEYPADPLUS		78
   7.106 -#define SCANCODE_KEYPAD1		79
   7.107 -#define SCANCODE_CURSORDOWNLEFT		79
   7.108 -#define SCANCODE_KEYPAD2		80
   7.109 -#define SCANCODE_CURSORDOWN		80
   7.110 -#define SCANCODE_KEYPAD3		81
   7.111 -#define SCANCODE_CURSORDOWNRIGHT	81
   7.112 -#define SCANCODE_KEYPAD0		82
   7.113 -#define SCANCODE_KEYPADPERIOD		83
   7.114 -
   7.115 -#define SCANCODE_LESS			86
   7.116 -
   7.117 -#define SCANCODE_F11			87
   7.118 -#define SCANCODE_F12			88
   7.119 -
   7.120 -#define SCANCODE_KEYPADENTER		96
   7.121 -#define SCANCODE_RIGHTCONTROL		97
   7.122 -#define SCANCODE_CONTROL		97
   7.123 -#define SCANCODE_KEYPADDIVIDE		98
   7.124 -#define SCANCODE_PRINTSCREEN		99
   7.125 -#define SCANCODE_RIGHTALT		100
   7.126 -#define SCANCODE_BREAK			101     /* Beware: is 119     */
   7.127 -#define SCANCODE_BREAK_ALTERNATIVE	119     /* on some keyboards! */
   7.128 -
   7.129 -#define SCANCODE_HOME			102
   7.130 -#define SCANCODE_CURSORBLOCKUP		103     /* Cursor key block */
   7.131 -#define SCANCODE_PAGEUP			104
   7.132 -#define SCANCODE_CURSORBLOCKLEFT	105     /* Cursor key block */
   7.133 -#define SCANCODE_CURSORBLOCKRIGHT	106     /* Cursor key block */
   7.134 -#define SCANCODE_END			107
   7.135 -#define SCANCODE_CURSORBLOCKDOWN	108     /* Cursor key block */
   7.136 -#define SCANCODE_PAGEDOWN		109
   7.137 -#define SCANCODE_INSERT			110
   7.138 -#define SCANCODE_REMOVE			111
   7.139 -
   7.140 -#define SCANCODE_RIGHTWIN		126
   7.141 -#define SCANCODE_LEFTWIN		125
   7.142 -/* vi: set ts=4 sw=4 expandtab: */
     8.1 --- a/src/video/ps2gs/SDL_gsmouse.c	Mon Jan 18 14:16:47 2010 +0000
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,153 +0,0 @@
     8.4 -/*
     8.5 -    SDL - Simple DirectMedia Layer
     8.6 -    Copyright (C) 1997-2009 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 <sys/ioctl.h>
    8.28 -
    8.29 -#include "SDL_mouse.h"
    8.30 -#include "../../events/SDL_events_c.h"
    8.31 -#include "../SDL_cursor_c.h"
    8.32 -#include "SDL_gsvideo.h"
    8.33 -#include "SDL_gsmouse_c.h"
    8.34 -
    8.35 -
    8.36 -/* The implementation dependent data for the window manager cursor */
    8.37 -struct WMcursor
    8.38 -{
    8.39 -    int unused;
    8.40 -};
    8.41 -
    8.42 -/* There isn't any implementation dependent data */
    8.43 -void
    8.44 -GS_FreeWMCursor(_THIS, WMcursor * cursor)
    8.45 -{
    8.46 -    return;
    8.47 -}
    8.48 -
    8.49 -/* There isn't any implementation dependent data */
    8.50 -WMcursor *
    8.51 -GS_CreateWMCursor(_THIS,
    8.52 -                  Uint8 * data, Uint8 * mask, int w, int h, int hot_x,
    8.53 -                  int hot_y)
    8.54 -{
    8.55 -    return ((WMcursor *) 0x01);
    8.56 -}
    8.57 -
    8.58 -static void
    8.59 -GS_MoveCursor(_THIS, SDL_Cursor * cursor, int x, int y)
    8.60 -{
    8.61 -    SDL_Surface *screen;
    8.62 -    struct ps2_image image;
    8.63 -    SDL_Rect area;
    8.64 -    int mouse_y1, mouse_y2;
    8.65 -    void *saved_pixels;
    8.66 -    int screen_updated;
    8.67 -
    8.68 -    /* Lock so we don't interrupt an update with mouse motion */
    8.69 -    SDL_LockCursor();
    8.70 -
    8.71 -    /* Make sure any pending DMA has completed */
    8.72 -    if (dma_pending) {
    8.73 -        ioctl(console_fd, PS2IOC_SENDQCT, 1);
    8.74 -        dma_pending = 0;
    8.75 -    }
    8.76 -
    8.77 -    /* Remove the cursor image from the DMA area */
    8.78 -    screen = this->screen;
    8.79 -    saved_pixels = screen->pixels;
    8.80 -    screen->pixels = mapped_mem + screen->offset;
    8.81 -    screen_updated = 0;
    8.82 -    if (cursor_drawn) {
    8.83 -        SDL_EraseCursorNoLock(screen);
    8.84 -        cursor_drawn = 0;
    8.85 -        screen_updated = 1;
    8.86 -    }
    8.87 -
    8.88 -    /* Save the current mouse area */
    8.89 -    SDL_MouseRect(&area);
    8.90 -    mouse_y1 = area.y;
    8.91 -    mouse_y2 = area.y + area.h;
    8.92 -
    8.93 -    /* Only draw the new cursor if there was one passed in */
    8.94 -    if (cursor) {
    8.95 -        /* Set the new location */
    8.96 -        cursor->area.x = (x - cursor->hot_x);
    8.97 -        cursor->area.y = (y - cursor->hot_y);
    8.98 -
    8.99 -        /* Draw the cursor at the new location */
   8.100 -        if ((SDL_cursorstate & CURSOR_VISIBLE) && screen->pixels) {
   8.101 -            SDL_DrawCursorNoLock(screen);
   8.102 -            cursor_drawn = 1;
   8.103 -            screen_updated = 1;
   8.104 -        }
   8.105 -    }
   8.106 -    screen->pixels = saved_pixels;
   8.107 -
   8.108 -    /* Update the affected area of the screen */
   8.109 -    if (screen_updated) {
   8.110 -        SDL_MouseRect(&area);
   8.111 -        if (area.y < mouse_y1) {
   8.112 -            mouse_y1 = area.y;
   8.113 -        }
   8.114 -        if ((area.y + area.h) > mouse_y2) {
   8.115 -            mouse_y2 = area.y + area.h;
   8.116 -        }
   8.117 -        image = screen_image;
   8.118 -        image.y += screen->offset / screen->pitch + mouse_y1;
   8.119 -        image.h = mouse_y2 - mouse_y1;
   8.120 -        image.ptr = mapped_mem + (image.y - screen_image.y) * screen->pitch;
   8.121 -        ioctl(console_fd, PS2IOC_LOADIMAGE, &image);
   8.122 -
   8.123 -        /* Need to scale offscreen image to TV output */
   8.124 -        if (image.y > 0) {
   8.125 -            scaleimage_nonblock(console_fd, tex_tags_mem, scale_tags_mem);
   8.126 -        }
   8.127 -    }
   8.128 -
   8.129 -    /* We're finished */
   8.130 -    SDL_UnlockCursor();
   8.131 -}
   8.132 -
   8.133 -void
   8.134 -GS_MoveWMCursor(_THIS, int x, int y)
   8.135 -{
   8.136 -    GS_MoveCursor(this, SDL_cursor, x, y);
   8.137 -}
   8.138 -
   8.139 -int
   8.140 -GS_ShowWMCursor(_THIS, WMcursor * wmcursor)
   8.141 -{
   8.142 -    SDL_Cursor *cursor;
   8.143 -    int x, y;
   8.144 -
   8.145 -    /* Draw the cursor at the appropriate location */
   8.146 -    SDL_GetMouseState(&x, &y);
   8.147 -    if (wmcursor) {
   8.148 -        cursor = SDL_cursor;
   8.149 -    } else {
   8.150 -        cursor = NULL;
   8.151 -    }
   8.152 -    GS_MoveCursor(this, cursor, x, y);
   8.153 -    return (1);
   8.154 -}
   8.155 -
   8.156 -/* vi: set ts=4 sw=4 expandtab: */
     9.1 --- a/src/video/ps2gs/SDL_gsmouse_c.h	Mon Jan 18 14:16:47 2010 +0000
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,39 +0,0 @@
     9.4 -/*
     9.5 -    SDL - Simple DirectMedia Layer
     9.6 -    Copyright (C) 1997-2009 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 -#include "SDL_gsvideo.h"
    9.28 -
    9.29 -/* This is the maximum size of the cursor sprite */
    9.30 -#define CURSOR_W	32
    9.31 -#define CURSOR_H	32
    9.32 -#define CURSOR_W_POW	5       /* 32 = 2^5 */
    9.33 -#define CURSOR_H_POW	5       /* 32 = 2^5 */
    9.34 -
    9.35 -/* Functions to be exported */
    9.36 -extern void GS_FreeWMCursor(_THIS, WMcursor * cursor);
    9.37 -extern WMcursor *GS_CreateWMCursor(_THIS,
    9.38 -                                   Uint8 * data, Uint8 * mask, int w, int h,
    9.39 -                                   int hot_x, int hot_y);
    9.40 -extern void GS_MoveWMCursor(_THIS, int x, int y);
    9.41 -extern int GS_ShowWMCursor(_THIS, WMcursor * cursor);
    9.42 -/* vi: set ts=4 sw=4 expandtab: */
    10.1 --- a/src/video/ps2gs/SDL_gsvideo.c	Mon Jan 18 14:16:47 2010 +0000
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,693 +0,0 @@
    10.4 -/*
    10.5 -    SDL - Simple DirectMedia Layer
    10.6 -    Copyright (C) 1997-2009 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 -/* Framebuffer console based SDL video driver implementation.
   10.28 -*/
   10.29 -
   10.30 -#include <fcntl.h>
   10.31 -#include <unistd.h>
   10.32 -#include <sys/ioctl.h>
   10.33 -#include <sys/mman.h>
   10.34 -
   10.35 -#include "SDL_video.h"
   10.36 -#include "SDL_mouse.h"
   10.37 -#include "../SDL_sysvideo.h"
   10.38 -#include "../SDL_pixels_c.h"
   10.39 -#include "../../events/SDL_events_c.h"
   10.40 -#include "../SDL_cursor_c.h"
   10.41 -#include "SDL_gsvideo.h"
   10.42 -#include "SDL_gsmouse_c.h"
   10.43 -#include "SDL_gsevents_c.h"
   10.44 -#include "SDL_gsyuv_c.h"
   10.45 -
   10.46 -
   10.47 -/* Initialization/Query functions */
   10.48 -static int GS_VideoInit(_THIS, SDL_PixelFormat * vformat);
   10.49 -static SDL_Rect **GS_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags);
   10.50 -static SDL_Surface *GS_SetVideoMode(_THIS, SDL_Surface * current, int width,
   10.51 -                                    int height, int bpp, Uint32 flags);
   10.52 -static int GS_SetColors(_THIS, int firstcolor, int ncolors,
   10.53 -                        SDL_Color * colors);
   10.54 -static void GS_VideoQuit(_THIS);
   10.55 -
   10.56 -/* Hardware surface functions */
   10.57 -static int GS_AllocHWSurface(_THIS, SDL_Surface * surface);
   10.58 -static int GS_LockHWSurface(_THIS, SDL_Surface * surface);
   10.59 -static void GS_UnlockHWSurface(_THIS, SDL_Surface * surface);
   10.60 -static void GS_FreeHWSurface(_THIS, SDL_Surface * surface);
   10.61 -
   10.62 -/* GS driver bootstrap functions */
   10.63 -
   10.64 -static int
   10.65 -GS_Available(void)
   10.66 -{
   10.67 -    int console, memory;
   10.68 -
   10.69 -    console = open(PS2_DEV_GS, O_RDWR, 0);
   10.70 -    if (console >= 0) {
   10.71 -        close(console);
   10.72 -    }
   10.73 -    memory = open(PS2_DEV_MEM, O_RDWR, 0);
   10.74 -    if (memory >= 0) {
   10.75 -        close(memory);
   10.76 -    }
   10.77 -    return ((console >= 0) && (memory >= 0));
   10.78 -}
   10.79 -
   10.80 -static void
   10.81 -GS_DeleteDevice(SDL_VideoDevice * device)
   10.82 -{
   10.83 -    SDL_free(device->hidden);
   10.84 -    SDL_free(device);
   10.85 -}
   10.86 -
   10.87 -static SDL_VideoDevice *
   10.88 -GS_CreateDevice(int devindex)
   10.89 -{
   10.90 -    SDL_VideoDevice *this;
   10.91 -
   10.92 -    /* Initialize all variables that we clean on shutdown */
   10.93 -    this = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice));
   10.94 -    if (this) {
   10.95 -        SDL_memset(this, 0, (sizeof *this));
   10.96 -        this->hidden = (struct SDL_PrivateVideoData *)
   10.97 -            SDL_malloc((sizeof *this->hidden));
   10.98 -    }
   10.99 -    if ((this == NULL) || (this->hidden == NULL)) {
  10.100 -        SDL_OutOfMemory();
  10.101 -        if (this) {
  10.102 -            SDL_free(this);
  10.103 -        }
  10.104 -        return (0);
  10.105 -    }
  10.106 -    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
  10.107 -    mouse_fd = -1;
  10.108 -    keyboard_fd = -1;
  10.109 -
  10.110 -    /* Set the function pointers */
  10.111 -    this->VideoInit = GS_VideoInit;
  10.112 -    this->ListModes = GS_ListModes;
  10.113 -    this->SetVideoMode = GS_SetVideoMode;
  10.114 -    this->CreateYUVOverlay = GS_CreateYUVOverlay;
  10.115 -    this->SetColors = GS_SetColors;
  10.116 -    this->UpdateRects = NULL;
  10.117 -    this->VideoQuit = GS_VideoQuit;
  10.118 -    this->AllocHWSurface = GS_AllocHWSurface;
  10.119 -    this->CheckHWBlit = NULL;
  10.120 -    this->FillHWRect = NULL;
  10.121 -    this->SetHWColorKey = NULL;
  10.122 -    this->SetHWAlpha = NULL;
  10.123 -    this->LockHWSurface = GS_LockHWSurface;
  10.124 -    this->UnlockHWSurface = GS_UnlockHWSurface;
  10.125 -    this->FlipHWSurface = NULL;
  10.126 -    this->FreeHWSurface = GS_FreeHWSurface;
  10.127 -    this->SetIcon = NULL;
  10.128 -    this->SetCaption = NULL;
  10.129 -    this->GetWMInfo = NULL;
  10.130 -    this->FreeWMCursor = GS_FreeWMCursor;
  10.131 -    this->CreateWMCursor = GS_CreateWMCursor;
  10.132 -    this->ShowWMCursor = GS_ShowWMCursor;
  10.133 -    this->MoveWMCursor = GS_MoveWMCursor;
  10.134 -    this->InitOSKeymap = GS_InitOSKeymap;
  10.135 -    this->PumpEvents = GS_PumpEvents;
  10.136 -
  10.137 -    this->free = GS_DeleteDevice;
  10.138 -
  10.139 -    return this;
  10.140 -}
  10.141 -
  10.142 -VideoBootStrap PS2GS_bootstrap = {
  10.143 -    "ps2gs", "PlayStation 2 Graphics Synthesizer",
  10.144 -    GS_Available, GS_CreateDevice
  10.145 -};
  10.146 -
  10.147 -/* These are the pixel formats for the 32, 24, and 16 bit video modes */
  10.148 -static struct
  10.149 -{
  10.150 -    int bpp;
  10.151 -    Uint32 r;
  10.152 -    Uint32 g;
  10.153 -    Uint32 b;
  10.154 -} GS_pixelmasks[] = {
  10.155 -    {
  10.156 -        32, 0x000000FF,         /* RGB little-endian */
  10.157 -    0x0000FF00, 0x00FF0000}, {
  10.158 -        24, 0x000000FF,         /* RGB little-endian */
  10.159 -    0x0000FF00, 0x00FF0000}, {
  10.160 -        16, 0x0000001f,         /* RGB little-endian */
  10.161 -0x000003e0, 0x00007c00},};
  10.162 -
  10.163 -/* This is a mapping from SDL bytes-per-pixel to GS pixel format */
  10.164 -static int GS_formatmap[] = {
  10.165 -    -1,                         /* 0 bpp, not a legal value */
  10.166 -    -1,                         /* 8 bpp, not supported (yet?) */
  10.167 -    PS2_GS_PSMCT16,             /* 16 bpp */
  10.168 -    PS2_GS_PSMCT24,             /* 24 bpp */
  10.169 -    PS2_GS_PSMCT32              /* 32 bpp */
  10.170 -};
  10.171 -
  10.172 -static unsigned long long head_tags[] __attribute__ ((aligned(16))) = {
  10.173 -    4 | (1LL << 60),            /* GIFtag */
  10.174 -        0x0e,                   /* A+D */
  10.175 -        0,                      /* 2 */
  10.176 -        PS2_GS_BITBLTBUF, 0,    /* 4 */
  10.177 -        PS2_GS_TRXPOS, 0,       /* 6 */
  10.178 -        PS2_GS_TRXREG, 0,       /* 8 */
  10.179 -PS2_GS_TRXDIR};
  10.180 -
  10.181 -#define MAXIMG		(32767 * 16)
  10.182 -#define MAXTAGS		8
  10.183 -
  10.184 -static inline int
  10.185 -loadimage_nonblock(int fd, struct ps2_image *image, int size,
  10.186 -                   unsigned long long *hm, unsigned long long *im)
  10.187 -{
  10.188 -    struct ps2_plist plist;
  10.189 -    struct ps2_packet packet[1 + MAXTAGS * 2];
  10.190 -    int isize;
  10.191 -    int pnum, it, eop;
  10.192 -    char *data;
  10.193 -
  10.194 -    /* initialize the variables */
  10.195 -    data = (char *) image->ptr;
  10.196 -    pnum = it = eop = 0;
  10.197 -    plist.packet = packet;
  10.198 -
  10.199 -    /* make BITBLT packet */
  10.200 -    packet[pnum].ptr = hm;
  10.201 -    packet[pnum].len = sizeof(head_tags);
  10.202 -    pnum++;
  10.203 -    hm[2] = ((unsigned long long) image->fbp << 32) |
  10.204 -        ((unsigned long long) image->fbw << 48) |
  10.205 -        ((unsigned long long) image->psm << 56);
  10.206 -    hm[4] = ((unsigned long long) image->x << 32) |
  10.207 -        ((unsigned long long) image->y << 48);
  10.208 -    hm[6] = (unsigned long long) image->w |
  10.209 -        ((unsigned long long) image->h << 32);
  10.210 -
  10.211 -    /* make image mode tags */
  10.212 -    while (!eop) {
  10.213 -        isize = size > MAXIMG ? MAXIMG : size;
  10.214 -        size -= isize;
  10.215 -        eop = (size == 0);
  10.216 -
  10.217 -        packet[pnum].ptr = &im[it];
  10.218 -        packet[pnum].len = sizeof(unsigned long long) * 2;
  10.219 -        pnum++;
  10.220 -        im[it++] = (isize >> 4) | (eop ? (1 << 15) : 0) | (2LL << 58);
  10.221 -        im[it++] = 0;
  10.222 -
  10.223 -        packet[pnum].ptr = (void *) data;
  10.224 -        packet[pnum].len = isize;
  10.225 -        pnum++;
  10.226 -        data += isize;
  10.227 -    }
  10.228 -    plist.num = pnum;
  10.229 -
  10.230 -    return ioctl(fd, PS2IOC_SENDL, &plist);
  10.231 -}
  10.232 -
  10.233 -static unsigned long long tex_tags[] __attribute__ ((aligned(16))) = {
  10.234 -    3 | (1LL << 60),            /* GIFtag */
  10.235 -        0x0e,                   /* A+D */
  10.236 -        0,                      /* 2 */
  10.237 -PS2_GS_TEX0_1, (1 << 5) + (1 << 6), PS2_GS_TEX1_1, 0, PS2_GS_TEXFLUSH};
  10.238 -
  10.239 -static unsigned long long scale_tags[] __attribute__ ((aligned(16))) = {
  10.240 -    5 | (1LL << 60),            /* GIFtag */
  10.241 -        0x0e,                   /* A+D */
  10.242 -        6 + (1 << 4) + (1 << 8), PS2_GS_PRIM, ((unsigned long long) 0 * 16) + (((unsigned long long) 0 * 16) << 16), PS2_GS_UV, ((unsigned long long) 0 * 16) + (((unsigned long long) 0 * 16) << 16), PS2_GS_XYZ2, 0,  /* 8 */
  10.243 -        PS2_GS_UV, 0,           /* 10 */
  10.244 -PS2_GS_XYZ2};
  10.245 -
  10.246 -
  10.247 -int
  10.248 -scaleimage_nonblock(int fd, unsigned long long *tm, unsigned long long *sm)
  10.249 -{
  10.250 -    struct ps2_plist plist;
  10.251 -    struct ps2_packet packet[2];
  10.252 -
  10.253 -    /* initialize the variables */
  10.254 -    plist.num = 2;
  10.255 -    plist.packet = packet;
  10.256 -
  10.257 -    packet[0].ptr = tm;
  10.258 -    packet[0].len = sizeof(tex_tags);
  10.259 -    packet[1].ptr = sm;
  10.260 -    packet[1].len = sizeof(scale_tags);
  10.261 -
  10.262 -    return ioctl(fd, PS2IOC_SENDL, &plist);
  10.263 -}
  10.264 -
  10.265 -static int
  10.266 -power_of_2(int value)
  10.267 -{
  10.268 -    int shift;
  10.269 -
  10.270 -    for (shift = 0; (1 << shift) < value; ++shift) {
  10.271 -        /* Keep looking */ ;
  10.272 -    }
  10.273 -    return (shift);
  10.274 -}
  10.275 -
  10.276 -static int
  10.277 -GS_VideoInit(_THIS, SDL_PixelFormat * vformat)
  10.278 -{
  10.279 -    struct ps2_screeninfo vinfo;
  10.280 -
  10.281 -    /* Initialize the library */
  10.282 -    console_fd = open(PS2_DEV_GS, O_RDWR, 0);
  10.283 -    if (console_fd < 0) {
  10.284 -        SDL_SetError("Unable to open %s", PS2_DEV_GS);
  10.285 -        return (-1);
  10.286 -    }
  10.287 -    memory_fd = open(PS2_DEV_MEM, O_RDWR, 0);
  10.288 -    if (memory_fd < 0) {
  10.289 -        close(console_fd);
  10.290 -        console_fd = -1;
  10.291 -        SDL_SetError("Unable to open %s", PS2_DEV_MEM);
  10.292 -        return (-1);
  10.293 -    }
  10.294 -
  10.295 -    if (ioctl(console_fd, PS2IOC_GSCREENINFO, &vinfo) < 0) {
  10.296 -        close(memory_fd);
  10.297 -        close(console_fd);
  10.298 -        console_fd = -1;
  10.299 -        SDL_SetError("Couldn't get console pixel format");
  10.300 -        return (-1);
  10.301 -    }
  10.302 -
  10.303 -    /* Determine the current screen size */
  10.304 -    this->info.current_w = vinfo.w;
  10.305 -    this->info.current_h = vinfo.h;
  10.306 -
  10.307 -    /* Determine the current screen depth */
  10.308 -    switch (vinfo.psm) {
  10.309 -        /* Supported pixel formats */
  10.310 -    case PS2_GS_PSMCT32:
  10.311 -    case PS2_GS_PSMCT24:
  10.312 -    case PS2_GS_PSMCT16:
  10.313 -        break;
  10.314 -    default:
  10.315 -        GS_VideoQuit(this);
  10.316 -        SDL_SetError("Unknown console pixel format: %d", vinfo.psm);
  10.317 -        return (-1);
  10.318 -    }
  10.319 -    vformat->BitsPerPixel = GS_pixelmasks[vinfo.psm].bpp;
  10.320 -    vformat->Rmask = GS_pixelmasks[vinfo.psm].r;
  10.321 -    vformat->Gmask = GS_pixelmasks[vinfo.psm].g;
  10.322 -    vformat->Bmask = GS_pixelmasks[vinfo.psm].b;
  10.323 -    saved_vinfo = vinfo;
  10.324 -
  10.325 -    /* Enable mouse and keyboard support */
  10.326 -    if (GS_OpenKeyboard(this) < 0) {
  10.327 -        GS_VideoQuit(this);
  10.328 -        SDL_SetError("Unable to open keyboard");
  10.329 -        return (-1);
  10.330 -    }
  10.331 -    if (GS_OpenMouse(this) < 0) {
  10.332 -        const char *sdl_nomouse;
  10.333 -
  10.334 -        sdl_nomouse = SDL_getenv("SDL_NOMOUSE");
  10.335 -        if (!sdl_nomouse) {
  10.336 -            GS_VideoQuit(this);
  10.337 -            SDL_SetError("Unable to open mouse");
  10.338 -            return (-1);
  10.339 -        }
  10.340 -    }
  10.341 -
  10.342 -    /* We're done! */
  10.343 -    return (0);
  10.344 -}
  10.345 -
  10.346 -static SDL_Rect **
  10.347 -GS_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
  10.348 -{
  10.349 -    static SDL_Rect GS_vesa_mode_list[] = {
  10.350 -        {0, 0, 1280, 1024},
  10.351 -        {0, 0, 1024, 768},
  10.352 -        {0, 0, 800, 600},
  10.353 -        {0, 0, 640, 480}
  10.354 -    };
  10.355 -    static SDL_Rect *GS_vesa_modes[] = {
  10.356 -        &GS_vesa_mode_list[0],
  10.357 -        &GS_vesa_mode_list[1],
  10.358 -        &GS_vesa_mode_list[2],
  10.359 -        &GS_vesa_mode_list[3],
  10.360 -        NULL
  10.361 -    };
  10.362 -    static SDL_Rect GS_tvout_stretch;
  10.363 -    static SDL_Rect GS_tvout_mode;
  10.364 -    static SDL_Rect *GS_tvout_modes[3];
  10.365 -    SDL_Rect **modes = NULL;
  10.366 -
  10.367 -    switch (format->BitsPerPixel) {
  10.368 -    case 16:
  10.369 -    case 24:
  10.370 -    case 32:
  10.371 -        if (saved_vinfo.mode == PS2_GS_VESA) {
  10.372 -            modes = GS_vesa_modes;
  10.373 -        } else {
  10.374 -            int i, j = 0;
  10.375 -
  10.376 -// FIXME - what's wrong with the stretch code at 16 bpp?
  10.377 -            if (format->BitsPerPixel != 32)
  10.378 -                break;
  10.379 -            /* Add a mode that we could possibly stretch to */
  10.380 -            for (i = 0; GS_vesa_modes[i]; ++i) {
  10.381 -                if ((GS_vesa_modes[i]->w == saved_vinfo.w) &&
  10.382 -                    (GS_vesa_modes[i]->h != saved_vinfo.h)) {
  10.383 -                    GS_tvout_stretch.w = GS_vesa_modes[i]->w;
  10.384 -                    GS_tvout_stretch.h = GS_vesa_modes[i]->h;
  10.385 -                    GS_tvout_modes[j++] = &GS_tvout_stretch;
  10.386 -                    break;
  10.387 -                }
  10.388 -            }
  10.389 -            /* Add the current TV video mode */
  10.390 -            GS_tvout_mode.w = saved_vinfo.w;
  10.391 -            GS_tvout_mode.h = saved_vinfo.h;
  10.392 -            GS_tvout_modes[j++] = &GS_tvout_mode;
  10.393 -            GS_tvout_modes[j++] = NULL;
  10.394 -
  10.395 -            /* Return the created list of modes */
  10.396 -            modes = GS_tvout_modes;
  10.397 -        }
  10.398 -        break;
  10.399 -    default:
  10.400 -        break;
  10.401 -    }
  10.402 -    return (modes);
  10.403 -}
  10.404 -
  10.405 -/* Various screen update functions available */
  10.406 -static void GS_DMAFullUpdate(_THIS, int numrects, SDL_Rect * rects);
  10.407 -
  10.408 -static SDL_Surface *
  10.409 -GS_SetVideoMode(_THIS, SDL_Surface * current,
  10.410 -                int width, int height, int bpp, Uint32 flags)
  10.411 -{
  10.412 -    struct ps2_screeninfo vinfo;
  10.413 -
  10.414 -    /* Set the terminal into graphics mode */
  10.415 -    if (GS_EnterGraphicsMode(this) < 0) {
  10.416 -        return (NULL);
  10.417 -    }
  10.418 -
  10.419 -    /* Set the video mode and get the final screen format */
  10.420 -    if (ioctl(console_fd, PS2IOC_GSCREENINFO, &vinfo) < 0) {
  10.421 -        SDL_SetError("Couldn't get console screen info");
  10.422 -        return (NULL);
  10.423 -    }
  10.424 -    if ((vinfo.w != width) || (vinfo.h != height) ||
  10.425 -        (GS_pixelmasks[vinfo.psm].bpp != bpp)) {
  10.426 -        /* If we're not in VESA mode, we have to scale resolution */
  10.427 -        if (saved_vinfo.mode == PS2_GS_VESA) {
  10.428 -            switch (width) {
  10.429 -            case 640:
  10.430 -                vinfo.res = PS2_GS_640x480;
  10.431 -                break;
  10.432 -            case 800:
  10.433 -                vinfo.res = PS2_GS_800x600;
  10.434 -                break;
  10.435 -            case 1024:
  10.436 -                vinfo.res = PS2_GS_1024x768;
  10.437 -                break;
  10.438 -            case 1280:
  10.439 -                vinfo.res = PS2_GS_1280x1024;
  10.440 -                break;
  10.441 -            default:
  10.442 -                SDL_SetError("Unsupported resolution: %dx%d\n",
  10.443 -                             width, height);
  10.444 -                return (NULL);
  10.445 -            }
  10.446 -            vinfo.res |= (PS2_GS_75Hz << 8);
  10.447 -            vinfo.w = width;
  10.448 -            vinfo.h = height;
  10.449 -        }
  10.450 -        vinfo.fbp = 0;
  10.451 -        vinfo.psm = GS_formatmap[bpp / 8];
  10.452 -        if (vinfo.psm < 0) {
  10.453 -            SDL_SetError("Unsupported depth: %d bpp\n", bpp);
  10.454 -            return (NULL);
  10.455 -        }
  10.456 -        if (ioctl(console_fd, PS2IOC_SSCREENINFO, &vinfo) < 0) {
  10.457 -            SDL_SetError("Couldn't set console screen info");
  10.458 -            return (NULL);
  10.459 -        }
  10.460 -
  10.461 -        /* Unmap the previous DMA buffer */
  10.462 -        if (mapped_mem) {
  10.463 -            munmap(mapped_mem, mapped_len);
  10.464 -            mapped_mem = NULL;
  10.465 -        }
  10.466 -    }
  10.467 -    if (!SDL_ReallocFormat(current, GS_pixelmasks[vinfo.psm].bpp,
  10.468 -                           GS_pixelmasks[vinfo.psm].r,
  10.469 -                           GS_pixelmasks[vinfo.psm].g,
  10.470 -                           GS_pixelmasks[vinfo.psm].b, 0)) {
  10.471 -        return (NULL);
  10.472 -    }
  10.473 -
  10.474 -    /* Set up the new mode framebuffer */
  10.475 -    current->flags = SDL_FULLSCREEN;
  10.476 -    current->w = width;
  10.477 -    current->h = height;
  10.478 -    current->pitch = SDL_CalculatePitch(current);
  10.479 -
  10.480 -    /* Memory map the DMA area for block memory transfer */
  10.481 -    if (!mapped_mem) {
  10.482 -        pixels_len = height * current->pitch;
  10.483 -        mapped_len = pixels_len +
  10.484 -            /* Screen update DMA command area */
  10.485 -            sizeof(head_tags) + ((2 * MAXTAGS) * 16);
  10.486 -        if (saved_vinfo.mode != PS2_GS_VESA) {
  10.487 -            mapped_len += sizeof(tex_tags) + sizeof(scale_tags);
  10.488 -        }
  10.489 -        mapped_mem = mmap(0, mapped_len, PROT_READ | PROT_WRITE,
  10.490 -                          MAP_SHARED, memory_fd, 0);
  10.491 -        if (mapped_mem == MAP_FAILED) {
  10.492 -            SDL_SetError("Unable to map %d bytes for DMA", mapped_len);
  10.493 -            mapped_mem = NULL;
  10.494 -            return (NULL);
  10.495 -        }
  10.496 -
  10.497 -        /* Set up the entire screen for DMA transfer */
  10.498 -        screen_image.ptr = mapped_mem;
  10.499 -        screen_image.fbp = 0;
  10.500 -        screen_image.fbw = (vinfo.w + 63) / 64;
  10.501 -        screen_image.psm = vinfo.psm;
  10.502 -        screen_image.x = 0;
  10.503 -        if (vinfo.h == height) {
  10.504 -            screen_image.y = 0;
  10.505 -        } else {
  10.506 -            /* Put image offscreen and scale to screen height */
  10.507 -            screen_image.y = vinfo.h;
  10.508 -        }
  10.509 -        screen_image.w = current->w;
  10.510 -        screen_image.h = current->h;
  10.511 -
  10.512 -        /* get screen image data size (qword aligned) */
  10.513 -        screen_image_size = (screen_image.w * screen_image.h);
  10.514 -        switch (screen_image.psm) {
  10.515 -        case PS2_GS_PSMCT32:
  10.516 -            screen_image_size *= 4;
  10.517 -            break;
  10.518 -        case PS2_GS_PSMCT24:
  10.519 -            screen_image_size *= 3;
  10.520 -            break;
  10.521 -        case PS2_GS_PSMCT16:
  10.522 -            screen_image_size *= 2;
  10.523 -            break;
  10.524 -        }
  10.525 -        screen_image_size = (screen_image_size + 15) & ~15;
  10.526 -
  10.527 -        /* Set up the memory for screen update DMA commands */
  10.528 -        head_tags_mem = (unsigned long long *) (mapped_mem + pixels_len);
  10.529 -        image_tags_mem = (unsigned long long *)
  10.530 -            ((caddr_t) head_tags_mem + sizeof(head_tags));
  10.531 -        SDL_memcpy(head_tags_mem, head_tags, sizeof(head_tags));
  10.532 -        if (saved_vinfo.mode != PS2_GS_VESA) {
  10.533 -            tex_tags_mem = (unsigned long long *)
  10.534 -                ((caddr_t) image_tags_mem + ((2 * MAXTAGS) * 16));
  10.535 -            scale_tags_mem = (unsigned long long *)
  10.536 -                ((caddr_t) tex_tags_mem + sizeof(tex_tags));
  10.537 -            SDL_memcpy(tex_tags_mem, tex_tags, sizeof(tex_tags));
  10.538 -            tex_tags_mem[2] =
  10.539 -                (vinfo.h * vinfo.w) / 64 +
  10.540 -                ((unsigned long long) screen_image.fbw << 14) +
  10.541 -                ((unsigned long long) screen_image.psm << 20) +
  10.542 -                ((unsigned long long) power_of_2(screen_image.w) << 26) +
  10.543 -                ((unsigned long long) power_of_2(screen_image.h) << 30) +
  10.544 -                ((unsigned long long) 1 << 34) +
  10.545 -                ((unsigned long long) 1 << 35);
  10.546 -            SDL_memcpy(scale_tags_mem, scale_tags, sizeof(scale_tags));
  10.547 -            scale_tags_mem[8] =
  10.548 -                ((unsigned long long) screen_image.w * 16) +
  10.549 -                (((unsigned long long) screen_image.h * 16) << 16);
  10.550 -            scale_tags_mem[10] =
  10.551 -                ((unsigned long long) vinfo.w * 16) +
  10.552 -                (((unsigned long long) vinfo.h * 16) << 16);
  10.553 -        }
  10.554 -    }
  10.555 -    current->pixels = NULL;
  10.556 -    if (SDL_getenv("SDL_FULLSCREEN_UPDATE")) {
  10.557 -        /* Correct semantics */
  10.558 -        current->flags |= SDL_ASYNCBLIT;
  10.559 -    } else {
  10.560 -        /* We lie here - the screen memory isn't really the visible
  10.561 -           display memory and still requires an update, but this
  10.562 -           has the desired effect for most applications.
  10.563 -         */
  10.564 -        current->flags |= SDL_HWSURFACE;
  10.565 -    }
  10.566 -
  10.567 -    /* Set the update rectangle function */
  10.568 -    this->UpdateRects = GS_DMAFullUpdate;
  10.569 -
  10.570 -    /* We're done */
  10.571 -    return (current);
  10.572 -}
  10.573 -
  10.574 -/* We don't support hardware surfaces yet */
  10.575 -static int
  10.576 -GS_AllocHWSurface(_THIS, SDL_Surface * surface)
  10.577 -{
  10.578 -    return (-1);
  10.579 -}
  10.580 -
  10.581 -static void
  10.582 -GS_FreeHWSurface(_THIS, SDL_Surface * surface)
  10.583 -{
  10.584 -    return;
  10.585 -}
  10.586 -
  10.587 -static int
  10.588 -GS_LockHWSurface(_THIS, SDL_Surface * surface)
  10.589 -{
  10.590 -    if (surface == this->screen) {
  10.591 -        /* Since mouse motion affects 'pixels', lock it */
  10.592 -        SDL_LockCursor();
  10.593 -
  10.594 -        /* Make sure any pending DMA has completed */
  10.595 -        if (dma_pending) {
  10.596 -            ioctl(console_fd, PS2IOC_SENDQCT, 1);
  10.597 -            dma_pending = 0;
  10.598 -        }
  10.599 -
  10.600 -        /* If the cursor is drawn on the DMA area, remove it */
  10.601 -        if (cursor_drawn) {
  10.602 -            surface->pixels = mapped_mem + surface->offset;
  10.603 -            SDL_EraseCursorNoLock(this->screen);
  10.604 -            cursor_drawn = 0;
  10.605 -        }
  10.606 -
  10.607 -        /* Set the surface pixels to the base of the DMA area */
  10.608 -        surface->pixels = mapped_mem;
  10.609 -
  10.610 -        /* We're finished! */
  10.611 -        SDL_UnlockCursor();
  10.612 -    }
  10.613 -    return (0);
  10.614 -}
  10.615 -
  10.616 -static void
  10.617 -GS_UnlockHWSurface(_THIS, SDL_Surface * surface)
  10.618 -{
  10.619 -    if (surface == this->screen) {
  10.620 -        /* Since mouse motion affects 'pixels', lock it */
  10.621 -        SDL_LockCursor();
  10.622 -        surface->pixels = NULL;
  10.623 -        SDL_UnlockCursor();
  10.624 -    }
  10.625 -}
  10.626 -
  10.627 -static void
  10.628 -GS_DMAFullUpdate(_THIS, int numrects, SDL_Rect * rects)
  10.629 -{
  10.630 -    /* Lock so we aren't interrupted by a mouse update */
  10.631 -    SDL_LockCursor();
  10.632 -
  10.633 -    /* Make sure any pending DMA has completed */
  10.634 -    if (dma_pending) {
  10.635 -        ioctl(console_fd, PS2IOC_SENDQCT, 1);
  10.636 -        dma_pending = 0;
  10.637 -    }
  10.638 -
  10.639 -    /* If the mouse is visible, draw it on the DMA area */
  10.640 -    if ((SDL_cursorstate & CURSOR_VISIBLE) && !cursor_drawn) {
  10.641 -        this->screen->pixels = mapped_mem + this->screen->offset;
  10.642 -        SDL_DrawCursorNoLock(this->screen);
  10.643 -        this->screen->pixels = NULL;
  10.644 -        cursor_drawn = 1;
  10.645 -    }
  10.646 -
  10.647 -    /* Put the image onto the screen */
  10.648 -    loadimage_nonblock(console_fd,
  10.649 -                       &screen_image, screen_image_size,
  10.650 -                       head_tags_mem, image_tags_mem);
  10.651 -    if (screen_image.y > 0) {
  10.652 -        /* Need to scale offscreen image to TV output */
  10.653 -        ioctl(console_fd, PS2IOC_SENDQCT, 1);
  10.654 -        dma_pending = 0;
  10.655 -        scaleimage_nonblock(console_fd, tex_tags_mem, scale_tags_mem);
  10.656 -    } else {
  10.657 -        dma_pending = 1;
  10.658 -    }
  10.659 -
  10.660 -    /* We're finished! */
  10.661 -    SDL_UnlockCursor();
  10.662 -}
  10.663 -
  10.664 -static int
  10.665 -GS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors)
  10.666 -{
  10.667 -    return (0);
  10.668 -}
  10.669 -
  10.670 -static void
  10.671 -GS_VideoQuit(_THIS)
  10.672 -{
  10.673 -    /* Close console and input file descriptors */
  10.674 -    if (console_fd > 0) {
  10.675 -        /* Unmap the video framebuffer */
  10.676 -        if (mapped_mem) {
  10.677 -            /* Unmap the video framebuffer */
  10.678 -            munmap(mapped_mem, mapped_len);
  10.679 -            mapped_mem = NULL;
  10.680 -        }
  10.681 -        close(memory_fd);
  10.682 -
  10.683 -        /* Restore the original video mode */
  10.684 -        if (GS_InGraphicsMode(this)) {
  10.685 -            ioctl(console_fd, PS2IOC_SSCREENINFO, &saved_vinfo);
  10.686 -        }
  10.687 -
  10.688 -        /* We're all done with the graphics device */
  10.689 -        close(console_fd);
  10.690 -        console_fd = -1;
  10.691 -    }
  10.692 -    GS_CloseMouse(this);
  10.693 -    GS_CloseKeyboard(this);
  10.694 -}
  10.695 -
  10.696 -/* vi: set ts=4 sw=4 expandtab: */
    11.1 --- a/src/video/ps2gs/SDL_gsvideo.h	Mon Jan 18 14:16:47 2010 +0000
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,98 +0,0 @@
    11.4 -/*
    11.5 -    SDL - Simple DirectMedia Layer
    11.6 -    Copyright (C) 1997-2009 Sam Lantinga
    11.7 -
    11.8 -    This library is free software; you can redistribute it and/or
    11.9 -    modify it under the terms of the GNU Lesser General Public
   11.10 -    License as published by the Free Software Foundation; either
   11.11 -    version 2.1 of the License, or (at your option) any later version.
   11.12 -
   11.13 -    This library is distributed in the hope that it will be useful,
   11.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   11.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   11.16 -    Lesser General Public License for more details.
   11.17 -
   11.18 -    You should have received a copy of the GNU Lesser General Public
   11.19 -    License along with this library; if not, write to the Free Software
   11.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   11.21 -
   11.22 -    Sam Lantinga
   11.23 -    slouken@libsdl.org
   11.24 -*/
   11.25 -#include "SDL_config.h"
   11.26 -
   11.27 -#ifndef _SDL_gsvideo_h
   11.28 -#define _SDL_gsvideo_h
   11.29 -
   11.30 -#include <sys/types.h>
   11.31 -#include <termios.h>
   11.32 -#include <linux/ps2/dev.h>
   11.33 -#include <linux/ps2/gs.h>
   11.34 -
   11.35 -#include "SDL_mouse.h"
   11.36 -#include "SDL_mutex.h"
   11.37 -#include "../SDL_sysvideo.h"
   11.38 -
   11.39 -/* Hidden "this" pointer for the video functions */
   11.40 -#define _THIS	SDL_VideoDevice *this
   11.41 -
   11.42 -
   11.43 -/* Private display data */
   11.44 -struct SDL_PrivateVideoData
   11.45 -{
   11.46 -    /* Gotta love that simple PS2 graphics interface. :) */
   11.47 -    int console_fd;
   11.48 -    int memory_fd;
   11.49 -    struct ps2_screeninfo saved_vinfo;
   11.50 -
   11.51 -    /* Ye olde linux keyboard code */
   11.52 -    int current_vt;
   11.53 -    int saved_vt;
   11.54 -    int keyboard_fd;
   11.55 -    int saved_kbd_mode;
   11.56 -    struct termios saved_kbd_termios;
   11.57 -
   11.58 -    /* Ye olde linux mouse code */
   11.59 -    int mouse_fd;
   11.60 -    int cursor_drawn;
   11.61 -
   11.62 -    /* The memory mapped DMA area and associated variables */
   11.63 -    caddr_t mapped_mem;
   11.64 -    int pixels_len;
   11.65 -    int mapped_len;
   11.66 -    struct ps2_image screen_image;
   11.67 -    int screen_image_size;
   11.68 -    unsigned long long *head_tags_mem;
   11.69 -    unsigned long long *image_tags_mem;
   11.70 -    unsigned long long *tex_tags_mem;
   11.71 -    unsigned long long *scale_tags_mem;
   11.72 -    int dma_pending;
   11.73 -};
   11.74 -/* Old variable names */
   11.75 -#define console_fd		(this->hidden->console_fd)
   11.76 -#define memory_fd		(this->hidden->memory_fd)
   11.77 -#define saved_vinfo		(this->hidden->saved_vinfo)
   11.78 -#define current_vt		(this->hidden->current_vt)
   11.79 -#define saved_vt		(this->hidden->saved_vt)
   11.80 -#define keyboard_fd		(this->hidden->keyboard_fd)
   11.81 -#define saved_kbd_mode		(this->hidden->saved_kbd_mode)
   11.82 -#define saved_kbd_termios	(this->hidden->saved_kbd_termios)
   11.83 -#define mouse_fd		(this->hidden->mouse_fd)
   11.84 -#define cursor_drawn		(this->hidden->cursor_drawn)
   11.85 -#define mapped_mem		(this->hidden->mapped_mem)
   11.86 -#define pixels_len		(this->hidden->pixels_len)
   11.87 -#define mapped_len		(this->hidden->mapped_len)
   11.88 -#define screen_image		(this->hidden->screen_image)
   11.89 -#define screen_image_size	(this->hidden->screen_image_size)
   11.90 -#define head_tags_mem		(this->hidden->head_tags_mem)
   11.91 -#define image_tags_mem		(this->hidden->image_tags_mem)
   11.92 -#define tex_tags_mem		(this->hidden->tex_tags_mem)
   11.93 -#define scale_tags_mem		(this->hidden->scale_tags_mem)
   11.94 -#define dma_pending		(this->hidden->dma_pending)
   11.95 -
   11.96 -/* Shared between the mouse and video code for screen update scaling */
   11.97 -extern int scaleimage_nonblock(int fd,
   11.98 -                               unsigned long long *tm,
   11.99 -                               unsigned long long *sm);
  11.100 -#endif /* _SDL_gsvideo_h */
  11.101 -/* vi: set ts=4 sw=4 expandtab: */
    12.1 --- a/src/video/ps2gs/SDL_gsyuv.c	Mon Jan 18 14:16:47 2010 +0000
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,471 +0,0 @@
    12.4 -/*
    12.5 -    SDL - Simple DirectMedia Layer
    12.6 -    Copyright (C) 1997-2009 Sam Lantinga
    12.7 -
    12.8 -    This library is free software; you can redistribute it and/or
    12.9 -    modify it under the terms of the GNU Lesser General Public
   12.10 -    License as published by the Free Software Foundation; either
   12.11 -    version 2.1 of the License, or (at your option) any later version.
   12.12 -
   12.13 -    This library is distributed in the hope that it will be useful,
   12.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   12.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   12.16 -    Lesser General Public License for more details.
   12.17 -
   12.18 -    You should have received a copy of the GNU Lesser General Public
   12.19 -    License along with this library; if not, write to the Free Software
   12.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   12.21 -
   12.22 -    Sam Lantinga
   12.23 -    slouken@libsdl.org
   12.24 -*/
   12.25 -#include "SDL_config.h"
   12.26 -
   12.27 -/* This is the Playstation 2 implementation of YUV video overlays */
   12.28 -
   12.29 -#include <fcntl.h>
   12.30 -#include <unistd.h>
   12.31 -#include <sys/ioctl.h>
   12.32 -#include <sys/mman.h>
   12.33 -#include <asm/page.h>           /* For definition of PAGE_SIZE */
   12.34 -
   12.35 -#include "SDL_video.h"
   12.36 -#include "SDL_gsyuv_c.h"
   12.37 -#include "../SDL_yuvfuncs.h"
   12.38 -
   12.39 -/* The maximum number of 16x16 pixel block converted at once */
   12.40 -#define MAX_MACROBLOCKS	1024    /* 2^10 macroblocks at once */
   12.41 -
   12.42 -/* The functions used to manipulate video overlays */
   12.43 -static struct private_yuvhwfuncs gs_yuvfuncs = {
   12.44 -    GS_LockYUVOverlay,
   12.45 -    GS_UnlockYUVOverlay,
   12.46 -    GS_DisplayYUVOverlay,
   12.47 -    GS_FreeYUVOverlay
   12.48 -};
   12.49 -
   12.50 -struct private_yuvhwdata
   12.51 -{
   12.52 -    int ipu_fd;
   12.53 -    Uint8 *pixels;
   12.54 -    int macroblocks;
   12.55 -    int dma_len;
   12.56 -    caddr_t dma_mem;
   12.57 -    caddr_t ipu_imem;
   12.58 -    caddr_t ipu_omem;
   12.59 -    caddr_t dma_tags;
   12.60 -    unsigned long long *stretch_x1y1;
   12.61 -    unsigned long long *stretch_x2y2;
   12.62 -    struct ps2_plist plist;
   12.63 -
   12.64 -    /* These are just so we don't have to allocate them separately */
   12.65 -    Uint16 pitches[3];
   12.66 -    Uint8 *planes[3];
   12.67 -};
   12.68 -
   12.69 -static int
   12.70 -power_of_2(int value)
   12.71 -{
   12.72 -    int shift;
   12.73 -
   12.74 -    for (shift = 0; (1 << shift) < value; ++shift) {
   12.75 -        /* Keep looking */ ;
   12.76 -    }
   12.77 -    return (shift);
   12.78 -}
   12.79 -
   12.80 -SDL_Overlay *
   12.81 -GS_CreateYUVOverlay(_THIS, int width, int height, Uint32 format,
   12.82 -                    SDL_Surface * display)
   12.83 -{
   12.84 -    SDL_Overlay *overlay;
   12.85 -    struct private_yuvhwdata *hwdata;
   12.86 -    int map_offset;
   12.87 -    unsigned long long *tags;
   12.88 -    caddr_t base;
   12.89 -    int bpp;
   12.90 -    int fbp, fbw, psm;
   12.91 -    int x, y, w, h;
   12.92 -    int pnum;
   12.93 -    struct ps2_packet *packet;
   12.94 -    struct ps2_packet tex_packet;
   12.95 -
   12.96 -    /* We can only decode blocks of 16x16 pixels */
   12.97 -    if ((width & 15) || (height & 15)) {
   12.98 -        SDL_SetError("Overlay width/height must be multiples of 16");
   12.99 -        return (NULL);
  12.100 -    }
  12.101 -    /* Make sure the image isn't too large for a single DMA transfer */
  12.102 -    if (((width / 16) * (height / 16)) > MAX_MACROBLOCKS) {
  12.103 -        SDL_SetError("Overlay too large (maximum size: %d pixels)",
  12.104 -                     MAX_MACROBLOCKS * 16 * 16);
  12.105 -        return (NULL);
  12.106 -    }
  12.107 -
  12.108 -    /* Double-check the requested format.  For simplicity, we'll only
  12.109 -       support planar YUV formats.
  12.110 -     */
  12.111 -    switch (format) {
  12.112 -    case SDL_YV12_OVERLAY:
  12.113 -    case SDL_IYUV_OVERLAY:
  12.114 -        /* Supported planar YUV format */
  12.115 -        break;
  12.116 -    default:
  12.117 -        SDL_SetError("Unsupported YUV format");
  12.118 -        return (NULL);
  12.119 -    }
  12.120 -
  12.121 -    /* Create the overlay structure */
  12.122 -    overlay = (SDL_Overlay *) SDL_malloc(sizeof *overlay);
  12.123 -    if (overlay == NULL) {
  12.124 -        SDL_OutOfMemory();
  12.125 -        return (NULL);
  12.126 -    }
  12.127 -    SDL_memset(overlay, 0, (sizeof *overlay));
  12.128 -
  12.129 -    /* Fill in the basic members */
  12.130 -    overlay->format = format;
  12.131 -    overlay->w = width;
  12.132 -    overlay->h = height;
  12.133 -
  12.134 -    /* Set up the YUV surface function structure */
  12.135 -    overlay->hwfuncs = &gs_yuvfuncs;
  12.136 -    overlay->hw_overlay = 1;
  12.137 -
  12.138 -    /* Create the pixel data */
  12.139 -    hwdata = (struct private_yuvhwdata *) SDL_malloc(sizeof *hwdata);
  12.140 -    overlay->hwdata = hwdata;
  12.141 -    if (hwdata == NULL) {
  12.142 -        SDL_FreeYUVOverlay(overlay);
  12.143 -        SDL_OutOfMemory();
  12.144 -        return (NULL);
  12.145 -    }
  12.146 -    hwdata->ipu_fd = -1;
  12.147 -    hwdata->pixels = (Uint8 *) SDL_malloc(width * height * 2);
  12.148 -    if (hwdata->pixels == NULL) {
  12.149 -        SDL_FreeYUVOverlay(overlay);
  12.150 -        SDL_OutOfMemory();
  12.151 -        return (NULL);
  12.152 -    }
  12.153 -    hwdata->macroblocks = (width / 16) * (height / 16);
  12.154 -
  12.155 -    /* Find the pitch and offset values for the overlay */
  12.156 -    overlay->pitches = hwdata->pitches;
  12.157 -    overlay->pixels = hwdata->planes;
  12.158 -    switch (format) {
  12.159 -    case SDL_YV12_OVERLAY:
  12.160 -    case SDL_IYUV_OVERLAY:
  12.161 -        overlay->pitches[0] = overlay->w;
  12.162 -        overlay->pitches[1] = overlay->pitches[0] / 2;
  12.163 -        overlay->pitches[2] = overlay->pitches[0] / 2;
  12.164 -        overlay->pixels[0] = hwdata->pixels;
  12.165 -        overlay->pixels[1] = overlay->pixels[0] +
  12.166 -            overlay->pitches[0] * overlay->h;
  12.167 -        overlay->pixels[2] = overlay->pixels[1] +
  12.168 -            overlay->pitches[1] * overlay->h / 2;
  12.169 -        overlay->planes = 3;
  12.170 -        break;
  12.171 -    default:
  12.172 -        /* We should never get here (caught above) */
  12.173 -        break;
  12.174 -    }
  12.175 -
  12.176 -    /* Theoretically we could support several concurrent decode
  12.177 -       streams queueing up on the same file descriptor, but for
  12.178 -       simplicity we'll support only one.  Opening the IPU more
  12.179 -       than once will fail with EBUSY.
  12.180 -     */
  12.181 -    hwdata->ipu_fd = open("/dev/ps2ipu", O_RDWR);
  12.182 -    if (hwdata->ipu_fd < 0) {
  12.183 -        SDL_FreeYUVOverlay(overlay);
  12.184 -        SDL_SetError("Playstation 2 IPU busy");
  12.185 -        return (NULL);
  12.186 -    }
  12.187 -
  12.188 -    /* Allocate a DMA area for pixel conversion */
  12.189 -    bpp = this->screen->format->BytesPerPixel;
  12.190 -    map_offset = (mapped_len + (sysconf(_SC_PAGESIZE) - 1)) & ~(sysconf(_SC_PAGESIZE) - 1);
  12.191 -    hwdata->dma_len = hwdata->macroblocks * (16 * 16 + 8 * 8 + 8 * 8) +
  12.192 -        width * height * bpp +
  12.193 -        hwdata->macroblocks * (16 * sizeof(long long)) +
  12.194 -        12 * sizeof(long long);
  12.195 -    hwdata->dma_mem = mmap(0, hwdata->dma_len, PROT_READ | PROT_WRITE,
  12.196 -                           MAP_SHARED, memory_fd, map_offset);
  12.197 -    if (hwdata->dma_mem == MAP_FAILED) {
  12.198 -        hwdata->ipu_imem = (caddr_t) 0;
  12.199 -        SDL_FreeYUVOverlay(overlay);
  12.200 -        SDL_SetError("Unable to map %d bytes for DMA", hwdata->dma_len);
  12.201 -        return (NULL);
  12.202 -    }
  12.203 -    hwdata->ipu_imem = hwdata->dma_mem;
  12.204 -    hwdata->ipu_omem = hwdata->ipu_imem +
  12.205 -        hwdata->macroblocks * (16 * 16 + 8 * 8 + 8 * 8);
  12.206 -    hwdata->dma_tags = hwdata->ipu_omem + width * height * bpp;
  12.207 -
  12.208 -    /* Allocate memory for the DMA packets */
  12.209 -    hwdata->plist.num = hwdata->macroblocks * 4 + 1;
  12.210 -    hwdata->plist.packet =
  12.211 -        (struct ps2_packet *) SDL_malloc(hwdata->plist.num *
  12.212 -                                         sizeof(struct ps2_packet));
  12.213 -    if (!hwdata->plist.packet) {
  12.214 -        SDL_FreeYUVOverlay(overlay);
  12.215 -        SDL_OutOfMemory();
  12.216 -        return (NULL);
  12.217 -    }
  12.218 -    pnum = 0;
  12.219 -    packet = hwdata->plist.packet;
  12.220 -
  12.221 -    /* Set up the tags to send the image to the screen */
  12.222 -    tags = (unsigned long long *) hwdata->dma_tags;
  12.223 -    base = hwdata->ipu_omem;
  12.224 -    fbp = screen_image.fbp;
  12.225 -    fbw = screen_image.fbw;
  12.226 -    psm = screen_image.psm;
  12.227 -    y = screen_image.y + screen_image.h;        /* Offscreen video memory */
  12.228 -    for (h = height / 16; h; --h) {
  12.229 -        x = 0;                  /* Visible video memory */
  12.230 -        for (w = width / 16; w; --w) {
  12.231 -            /* The head tag */
  12.232 -            packet[pnum].ptr = &tags[0];
  12.233 -            packet[pnum].len = 10 * sizeof(*tags);
  12.234 -            ++pnum;
  12.235 -            tags[0] = 4 | (1LL << 60);  /* GIFtag */
  12.236 -            tags[1] = 0x0e;     /* A+D */
  12.237 -            tags[2] = ((unsigned long long) fbp << 32) |
  12.238 -                ((unsigned long long) fbw << 48) |
  12.239 -                ((unsigned long long) psm << 56);
  12.240 -            tags[3] = PS2_GS_BITBLTBUF;
  12.241 -            tags[4] = ((unsigned long long) x << 32) |
  12.242 -                ((unsigned long long) y << 48);
  12.243 -            tags[5] = PS2_GS_TRXPOS;
  12.244 -            tags[6] = (unsigned long long) 16 |
  12.245 -                ((unsigned long long) 16 << 32);
  12.246 -            tags[7] = PS2_GS_TRXREG;
  12.247 -            tags[8] = 0;
  12.248 -            tags[9] = PS2_GS_TRXDIR;
  12.249 -            /* Now the actual image data */
  12.250 -            packet[pnum].ptr = &tags[10];
  12.251 -            packet[pnum].len = 2 * sizeof(*tags);
  12.252 -            ++pnum;
  12.253 -            tags[10] = ((16 * 16 * bpp) >> 4) | (2LL << 58);
  12.254 -            tags[11] = 0;
  12.255 -            packet[pnum].ptr = (void *) base;
  12.256 -            packet[pnum].len = 16 * 16 * bpp;
  12.257 -            ++pnum;
  12.258 -            packet[pnum].ptr = &tags[12];
  12.259 -            packet[pnum].len = 2 * sizeof(*tags);
  12.260 -            ++pnum;
  12.261 -            tags[12] = (0 >> 4) | (1 << 15) | (2LL << 58);
  12.262 -            tags[13] = 0;
  12.263 -
  12.264 -            tags += 16;
  12.265 -            base += 16 * 16 * bpp;
  12.266 -
  12.267 -            x += 16;
  12.268 -        }
  12.269 -        y += 16;
  12.270 -    }
  12.271 -
  12.272 -    /* Set up the texture memory area for the video */
  12.273 -    tex_packet.ptr = tags;
  12.274 -    tex_packet.len = 8 * sizeof(*tags);
  12.275 -    tags[0] = 3 | (1LL << 60);  /* GIFtag */
  12.276 -    tags[1] = 0x0e;             /* A+D */
  12.277 -    tags[2] = ((screen_image.y + screen_image.h) * screen_image.w) / 64 +
  12.278 -        ((unsigned long long) fbw << 14) +
  12.279 -        ((unsigned long long) psm << 20) +
  12.280 -        ((unsigned long long) power_of_2(width) << 26) +
  12.281 -        ((unsigned long long) power_of_2(height) << 30) +
  12.282 -        ((unsigned long long) 1 << 34) + ((unsigned long long) 1 << 35);
  12.283 -    tags[3] = PS2_GS_TEX0_1;
  12.284 -    tags[4] = (1 << 5) + (1 << 6);
  12.285 -    tags[5] = PS2_GS_TEX1_1;
  12.286 -    tags[6] = 0;
  12.287 -    tags[7] = PS2_GS_TEXFLUSH;
  12.288 -    ioctl(console_fd, PS2IOC_SEND, &tex_packet);
  12.289 -
  12.290 -    /* Set up the tags for scaling the image */
  12.291 -    packet[pnum].ptr = tags;
  12.292 -    packet[pnum].len = 12 * sizeof(*tags);
  12.293 -    ++pnum;
  12.294 -    tags[0] = 5 | (1LL << 60);  /* GIFtag */
  12.295 -    tags[1] = 0x0e;             /* A+D */
  12.296 -    tags[2] = 6 + (1 << 4) + (1 << 8);
  12.297 -    tags[3] = PS2_GS_PRIM;
  12.298 -    tags[4] = ((unsigned long long) 0 * 16) +
  12.299 -        (((unsigned long long) 0 * 16) << 16);
  12.300 -    tags[5] = PS2_GS_UV;
  12.301 -    tags[6] = 0;                /* X1, Y1 */
  12.302 -    tags[7] = PS2_GS_XYZ2;
  12.303 -    hwdata->stretch_x1y1 = &tags[6];
  12.304 -    tags[8] = ((unsigned long long) overlay->w * 16) +
  12.305 -        (((unsigned long long) overlay->h * 16) << 16);
  12.306 -    tags[9] = PS2_GS_UV;
  12.307 -    tags[10] = 0;               /* X2, Y2 */
  12.308 -    tags[11] = PS2_GS_XYZ2;
  12.309 -    hwdata->stretch_x2y2 = &tags[10];
  12.310 -
  12.311 -    /* We're all done.. */
  12.312 -    return (overlay);
  12.313 -}
  12.314 -
  12.315 -int
  12.316 -GS_LockYUVOverlay(_THIS, SDL_Overlay * overlay)
  12.317 -{
  12.318 -    return (0);
  12.319 -}
  12.320 -
  12.321 -void
  12.322 -GS_UnlockYUVOverlay(_THIS, SDL_Overlay * overlay)
  12.323 -{
  12.324 -    return;
  12.325 -}
  12.326 -
  12.327 -int
  12.328 -GS_DisplayYUVOverlay(_THIS, SDL_Overlay * overlay, SDL_Rect * src,
  12.329 -                     SDL_Rect * dst)
  12.330 -{
  12.331 -    struct private_yuvhwdata *hwdata;
  12.332 -    __u32 cmd;
  12.333 -    struct ps2_packet packet;
  12.334 -    int h, w, i;
  12.335 -    Uint32 *lum, *Cr, *Cb;
  12.336 -    int lum_pitch;
  12.337 -    int crb_pitch;
  12.338 -    Uint32 *lum_src, *Cr_src, *Cb_src;
  12.339 -    Uint32 *srcp, *dstp;
  12.340 -    unsigned int x, y;
  12.341 -    SDL_Surface *screen;
  12.342 -
  12.343 -    /* Find out where the various portions of the image are */
  12.344 -    hwdata = overlay->hwdata;
  12.345 -    switch (overlay->format) {
  12.346 -    case SDL_YV12_OVERLAY:
  12.347 -        lum = (Uint32 *) overlay->pixels[0];
  12.348 -        Cr = (Uint32 *) overlay->pixels[1];
  12.349 -        Cb = (Uint32 *) overlay->pixels[2];
  12.350 -        break;
  12.351 -    case SDL_IYUV_OVERLAY:
  12.352 -        lum = (Uint32 *) overlay->pixels[0];
  12.353 -        Cr = (Uint32 *) overlay->pixels[2];
  12.354 -        Cb = (Uint32 *) overlay->pixels[1];
  12.355 -    default:
  12.356 -        SDL_SetError("Unsupported YUV format in blit (?)");
  12.357 -        return (-1);
  12.358 -    }
  12.359 -    dstp = (Uint32 *) hwdata->ipu_imem;
  12.360 -    lum_pitch = overlay->w / 4;
  12.361 -    crb_pitch = (overlay->w / 2) / 4;
  12.362 -
  12.363 -    /* Copy blocks of 16x16 pixels to the DMA area */
  12.364 -    for (h = overlay->h / 16; h; --h) {
  12.365 -        lum_src = lum;
  12.366 -        Cr_src = Cr;
  12.367 -        Cb_src = Cb;
  12.368 -        for (w = overlay->w / 16; w; --w) {
  12.369 -            srcp = lum_src;
  12.370 -            for (i = 0; i < 16; ++i) {
  12.371 -                dstp[0] = srcp[0];
  12.372 -                dstp[1] = srcp[1];
  12.373 -                dstp[2] = srcp[2];
  12.374 -                dstp[3] = srcp[3];
  12.375 -                srcp += lum_pitch;
  12.376 -                dstp += 4;
  12.377 -            }
  12.378 -            srcp = Cb_src;
  12.379 -            for (i = 0; i < 8; ++i) {
  12.380 -                dstp[0] = srcp[0];
  12.381 -                dstp[1] = srcp[1];
  12.382 -                srcp += crb_pitch;
  12.383 -                dstp += 2;
  12.384 -            }
  12.385 -            srcp = Cr_src;
  12.386 -            for (i = 0; i < 8; ++i) {
  12.387 -                dstp[0] = srcp[0];
  12.388 -                dstp[1] = srcp[1];
  12.389 -                srcp += crb_pitch;
  12.390 -                dstp += 2;
  12.391 -            }
  12.392 -            lum_src += 16 / 4;
  12.393 -            Cb_src += 8 / 4;
  12.394 -            Cr_src += 8 / 4;
  12.395 -        }
  12.396 -        lum += lum_pitch * 16;
  12.397 -        Cr += crb_pitch * 8;
  12.398 -        Cb += crb_pitch * 8;
  12.399 -    }
  12.400 -
  12.401 -    /* Send the macroblock data to the IPU */
  12.402 -#ifdef DEBUG_YUV
  12.403 -    fprintf(stderr, "Sending data to IPU..\n");
  12.404 -#endif
  12.405 -    packet.ptr = hwdata->ipu_imem;
  12.406 -    packet.len = hwdata->macroblocks * (16 * 16 + 8 * 8 + 8 * 8);
  12.407 -    ioctl(hwdata->ipu_fd, PS2IOC_SENDA, &packet);
  12.408 -
  12.409 -    /* Trigger the DMA to the IPU for conversion */
  12.410 -#ifdef DEBUG_YUV
  12.411 -    fprintf(stderr, "Trigging conversion command\n");
  12.412 -#endif
  12.413 -    cmd = (7 << 28) + hwdata->macroblocks;
  12.414 -    if (screen_image.psm == PS2_GS_PSMCT16) {
  12.415 -        cmd += (1 << 27) +      /* Output RGB 555 */
  12.416 -            (1 << 26);          /* Dither output */
  12.417 -    }
  12.418 -    ioctl(hwdata->ipu_fd, PS2IOC_SIPUCMD, &cmd);
  12.419 -
  12.420 -    /* Retrieve the converted image from the IPU */
  12.421 -#ifdef DEBUG_YUV
  12.422 -    fprintf(stderr, "Retrieving data from IPU..\n");
  12.423 -#endif
  12.424 -    packet.ptr = hwdata->ipu_omem;
  12.425 -    packet.len = overlay->w * overlay->h *
  12.426 -        this->screen->format->BytesPerPixel;
  12.427 -    ioctl(hwdata->ipu_fd, PS2IOC_RECV, &packet);
  12.428 -
  12.429 -#ifdef DEBUG_YUV
  12.430 -    fprintf(stderr, "Copying image to screen..\n");
  12.431 -#endif
  12.432 -    /* Wait for previous DMA to complete */
  12.433 -    ioctl(console_fd, PS2IOC_SENDQCT, 1);
  12.434 -
  12.435 -    /* Send the current image to the screen and scale it */
  12.436 -    screen = this->screen;
  12.437 -    x = (unsigned int) dst->x;
  12.438 -    y = (unsigned int) dst->y;
  12.439 -    if (screen->offset) {
  12.440 -        x += (screen->offset % screen->pitch) / screen->format->BytesPerPixel;
  12.441 -        y += (screen->offset / screen->pitch);
  12.442 -    }
  12.443 -    y += screen_image.y;
  12.444 -    *hwdata->stretch_x1y1 = (x * 16) + ((y * 16) << 16);
  12.445 -    x += (unsigned int) dst->w;
  12.446 -    y += (unsigned int) dst->h;
  12.447 -    *hwdata->stretch_x2y2 = (x * 16) + ((y * 16) << 16);
  12.448 -    return ioctl(console_fd, PS2IOC_SENDL, &hwdata->plist);
  12.449 -}
  12.450 -
  12.451 -void
  12.452 -GS_FreeYUVOverlay(_THIS, SDL_Overlay * overlay)
  12.453 -{
  12.454 -    struct private_yuvhwdata *hwdata;
  12.455 -
  12.456 -    hwdata = overlay->hwdata;
  12.457 -    if (hwdata) {
  12.458 -        if (hwdata->ipu_fd >= 0) {
  12.459 -            close(hwdata->ipu_fd);
  12.460 -        }
  12.461 -        if (hwdata->dma_mem) {
  12.462 -            munmap(hwdata->dma_mem, hwdata->dma_len);
  12.463 -        }
  12.464 -        if (hwdata->plist.packet) {
  12.465 -            SDL_free(hwdata->plist.packet);
  12.466 -        }
  12.467 -        if (hwdata->pixels) {
  12.468 -            SDL_free(hwdata->pixels);
  12.469 -        }
  12.470 -        SDL_free(hwdata);
  12.471 -    }
  12.472 -}
  12.473 -
  12.474 -/* vi: set ts=4 sw=4 expandtab: */
    13.1 --- a/src/video/ps2gs/SDL_gsyuv_c.h	Mon Jan 18 14:16:47 2010 +0000
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,40 +0,0 @@
    13.4 -/*
    13.5 -    SDL - Simple DirectMedia Layer
    13.6 -    Copyright (C) 1997-2009 Sam Lantinga
    13.7 -
    13.8 -    This library is free software; you can redistribute it and/or
    13.9 -    modify it under the terms of the GNU Lesser General Public
   13.10 -    License as published by the Free Software Foundation; either
   13.11 -    version 2.1 of the License, or (at your option) any later version.
   13.12 -
   13.13 -    This library is distributed in the hope that it will be useful,
   13.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   13.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   13.16 -    Lesser General Public License for more details.
   13.17 -
   13.18 -    You should have received a copy of the GNU Lesser General Public
   13.19 -    License along with this library; if not, write to the Free Software
   13.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   13.21 -
   13.22 -    Sam Lantinga
   13.23 -    slouken@libsdl.org
   13.24 -*/
   13.25 -#include "SDL_config.h"
   13.26 -
   13.27 -/* This is the Playstation 2 implementation of YUV video overlays */
   13.28 -
   13.29 -#include "SDL_video.h"
   13.30 -#include "SDL_gsvideo.h"
   13.31 -
   13.32 -extern SDL_Overlay *GS_CreateYUVOverlay(_THIS, int width, int height,
   13.33 -                                        Uint32 format, SDL_Surface * display);
   13.34 -
   13.35 -extern int GS_LockYUVOverlay(_THIS, SDL_Overlay * overlay);
   13.36 -
   13.37 -extern void GS_UnlockYUVOverlay(_THIS, SDL_Overlay * overlay);
   13.38 -
   13.39 -extern int GS_DisplayYUVOverlay(_THIS, SDL_Overlay * overlay, SDL_Rect * src,
   13.40 -                                SDL_Rect * dst);
   13.41 -
   13.42 -extern void GS_FreeYUVOverlay(_THIS, SDL_Overlay * overlay);
   13.43 -/* vi: set ts=4 sw=4 expandtab: */