Removed outdated iPodLinux support
authorSam Lantinga <slouken@libsdl.org>
Sat, 19 Sep 2009 06:24:07 +0000
changeset 326882ce350be859
parent 3267 7690aa2f5b74
child 3269 a67a961e2171
Removed outdated iPodLinux support
configure.in
include/SDL_config.h.in
src/events/SDL_events.c
src/events/SDL_sysevents.h
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/ipod/SDL_ipodvideo.c
src/video/ipod/SDL_ipodvideo.h
     1.1 --- a/configure.in	Sat Sep 19 05:47:54 2009 +0000
     1.2 +++ b/configure.in	Sat Sep 19 06:24:07 2009 +0000
     1.3 @@ -943,20 +943,6 @@
     1.4  }
     1.5  
     1.6  
     1.7 -dnl Do the iPod thing
     1.8 -CheckIPod()
     1.9 -{
    1.10 -    AC_ARG_ENABLE(ipod,
    1.11 -AC_HELP_STRING([--enable-ipod], [configure SDL to work with iPodLinux [default=yes on arm-elf]]),
    1.12 -        , enable_ipod=yes)
    1.13 -
    1.14 -    if test x$enable_ipod = xyes; then
    1.15 -        EXTRA_CFLAGS="$EXTRA_CFLAGS -DIPOD"
    1.16 -        AC_DEFINE(SDL_VIDEO_DRIVER_IPOD)
    1.17 -        SOURCES="$SOURCES $srcdir/src/video/ipod/*.c"
    1.18 -    fi
    1.19 -}
    1.20 -
    1.21  dnl Find the nanox include and library directories
    1.22  CheckNANOX()
    1.23  {
    1.24 @@ -2004,7 +1990,7 @@
    1.25              pthread_lib="-lpthread"
    1.26              ;;
    1.27      esac
    1.28 -    if test x$enable_threads = xyes -a x$enable_pthreads = xyes -a x$enable_ipod != xyes; then
    1.29 +    if test x$enable_threads = xyes -a x$enable_pthreads = xyes; then
    1.30          # Save the original compiler flags and libraries
    1.31          ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
    1.32          # Add the pthread compiler flags and libraries
     2.1 --- a/include/SDL_config.h.in	Sat Sep 19 05:47:54 2009 +0000
     2.2 +++ b/include/SDL_config.h.in	Sat Sep 19 06:24:07 2009 +0000
     2.3 @@ -266,7 +266,6 @@
     2.4  #undef SDL_VIDEO_DRIVER_DUMMY
     2.5  #undef SDL_VIDEO_DRIVER_FBCON
     2.6  #undef SDL_VIDEO_DRIVER_GEM
     2.7 -#undef SDL_VIDEO_DRIVER_IPOD
     2.8  #undef SDL_VIDEO_DRIVER_NANOX
     2.9  #undef SDL_VIDEO_DRIVER_NDS
    2.10  #undef SDL_VIDEO_DRIVER_OS2FS
     3.1 --- a/src/events/SDL_events.c	Sat Sep 19 05:47:54 2009 +0000
     3.2 +++ b/src/events/SDL_events.c	Sat Sep 19 06:24:07 2009 +0000
     3.3 @@ -195,12 +195,10 @@
     3.4          SDL_EventThread = NULL;
     3.5          SDL_DestroyMutex(SDL_EventLock.lock);
     3.6      }
     3.7 -#ifndef IPOD
     3.8      if (SDL_EventQ.lock) {
     3.9          SDL_DestroyMutex(SDL_EventQ.lock);
    3.10          SDL_EventQ.lock = NULL;
    3.11      }
    3.12 -#endif
    3.13  }
    3.14  
    3.15  Uint32
     4.1 --- a/src/events/SDL_sysevents.h	Sat Sep 19 05:47:54 2009 +0000
     4.2 +++ b/src/events/SDL_sysevents.h	Sat Sep 19 06:24:07 2009 +0000
     4.3 @@ -33,10 +33,6 @@
     4.4  #define CANT_THREAD_EVENTS
     4.5  #endif
     4.6  
     4.7 -#ifdef IPOD                     /* iPod doesn't support threading at all */
     4.8 -#define CANT_THREAD_EVENTS
     4.9 -#endif
    4.10 -
    4.11  #ifdef __OS2__                  /* The OS/2 event loop runs in a separate thread */
    4.12  #define MUST_THREAD_EVENTS
    4.13  #endif
     5.1 --- a/src/video/SDL_sysvideo.h	Sat Sep 19 05:47:54 2009 +0000
     5.2 +++ b/src/video/SDL_sysvideo.h	Sat Sep 19 06:24:07 2009 +0000
     5.3 @@ -344,9 +344,6 @@
     5.4  #if SDL_VIDEO_DRIVER_NANOX
     5.5  extern VideoBootStrap NX_bootstrap;
     5.6  #endif
     5.7 -#if SDL_VIDEO_DRIVER_IPOD
     5.8 -extern VideoBootStrap iPod_bootstrap;
     5.9 -#endif
    5.10  #if SDL_VIDEO_DRIVER_WSCONS
    5.11  extern VideoBootStrap WSCONS_bootstrap;
    5.12  #endif
     6.1 --- a/src/video/SDL_video.c	Sat Sep 19 05:47:54 2009 +0000
     6.2 +++ b/src/video/SDL_video.c	Sat Sep 19 06:24:07 2009 +0000
     6.3 @@ -58,9 +58,6 @@
     6.4  #if SDL_VIDEO_DRIVER_NANOX
     6.5      &NX_bootstrap,
     6.6  #endif
     6.7 -#if SDL_VIDEO_DRIVER_IPOD
     6.8 -    &iPod_bootstrap,
     6.9 -#endif
    6.10  #if SDL_VIDEO_DRIVER_WSCONS
    6.11      &WSCONS_bootstrap,
    6.12  #endif
     7.1 --- a/src/video/ipod/SDL_ipodvideo.c	Sat Sep 19 05:47:54 2009 +0000
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,795 +0,0 @@
     7.4 -/*
     7.5 -    SDL - Simple DirectMedia Layer
     7.6 -    Copyright (C) 1997-2009 Sam Lantinga
     7.7 -
     7.8 -    This library is free software; you can redistribute it and/or
     7.9 -    modify it under the terms of the GNU Lesser General Public
    7.10 -    License as published by the Free Software Foundation; either
    7.11 -    version 2.1 of the License, or (at your option) any later version.
    7.12 -
    7.13 -    This library is distributed in the hope that it will be useful,
    7.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    7.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    7.16 -    Lesser General Public License for more details.
    7.17 -
    7.18 -    You should have received a copy of the GNU Lesser General Public
    7.19 -    License along with this library; if not, write to the Free Software
    7.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    7.21 -
    7.22 -    Sam Lantinga
    7.23 -    slouken@libsdl.org
    7.24 -*/
    7.25 -#include "SDL_config.h"
    7.26 -
    7.27 -#include <sys/types.h>
    7.28 -#include <sys/ioctl.h>
    7.29 -
    7.30 -#include <unistd.h>
    7.31 -#include <fcntl.h>
    7.32 -#include <string.h>
    7.33 -#include <termios.h>
    7.34 -#include <ctype.h>
    7.35 -
    7.36 -#include <linux/vt.h>
    7.37 -#include <linux/kd.h>
    7.38 -#include <linux/keyboard.h>
    7.39 -#include <linux/fb.h>
    7.40 -
    7.41 -#include "SDL_video.h"
    7.42 -#include "SDL_mouse.h"
    7.43 -#include "../SDL_sysvideo.h"
    7.44 -#include "../SDL_pixels_c.h"
    7.45 -#include "../../events/SDL_events_c.h"
    7.46 -#include "SDL_sysevents.h"
    7.47 -#include "SDL_ipodvideo.h"
    7.48 -
    7.49 -#define _THIS SDL_VideoDevice *this
    7.50 -
    7.51 -static int iPod_VideoInit(_THIS, SDL_PixelFormat * vformat);
    7.52 -static SDL_Rect **iPod_ListModes(_THIS, SDL_PixelFormat * format,
    7.53 -                                 Uint32 flags);
    7.54 -static SDL_Surface *iPod_SetVideoMode(_THIS, SDL_Surface * current,
    7.55 -                                      int width, int height, int bpp,
    7.56 -                                      Uint32 flags);
    7.57 -static int iPod_SetColors(_THIS, int firstcolor, int ncolors,
    7.58 -                          SDL_Color * colors);
    7.59 -static void iPod_UpdateRects(_THIS, int nrects, SDL_Rect * rects);
    7.60 -static void iPod_VideoQuit(_THIS);
    7.61 -static void iPod_PumpEvents(_THIS);
    7.62 -
    7.63 -static long iPod_GetGeneration();
    7.64 -
    7.65 -static int initd = 0;
    7.66 -static int kbfd = -1;
    7.67 -static int fbfd = -1;
    7.68 -static int oldvt = -1;
    7.69 -static int curvt = -1;
    7.70 -static int old_kbmode = -1;
    7.71 -static long generation = 0;
    7.72 -static struct termios old_termios, cur_termios;
    7.73 -
    7.74 -FILE *dbgout;
    7.75 -
    7.76 -#define LCD_DATA          0x10
    7.77 -#define LCD_CMD           0x08
    7.78 -#define IPOD_OLD_LCD_BASE 0xc0001000
    7.79 -#define IPOD_OLD_LCD_RTC  0xcf001110
    7.80 -#define IPOD_NEW_LCD_BASE 0x70003000
    7.81 -#define IPOD_NEW_LCD_RTC  0x60005010
    7.82 -
    7.83 -static unsigned long lcd_base, lcd_rtc, lcd_width, lcd_height;
    7.84 -
    7.85 -static long
    7.86 -iPod_GetGeneration()
    7.87 -{
    7.88 -    int i;
    7.89 -    char cpuinfo[256];
    7.90 -    char *ptr;
    7.91 -    FILE *file;
    7.92 -
    7.93 -    if ((file = fopen("/proc/cpuinfo", "r")) != NULL) {
    7.94 -        while (fgets(cpuinfo, sizeof(cpuinfo), file) != NULL)
    7.95 -            if (SDL_strncmp(cpuinfo, "Revision", 8) == 0)
    7.96 -                break;
    7.97 -        fclose(file);
    7.98 -    }
    7.99 -    for (i = 0; !isspace(cpuinfo[i]); i++);
   7.100 -    for (; isspace(cpuinfo[i]); i++);
   7.101 -    ptr = cpuinfo + i + 2;
   7.102 -
   7.103 -    return SDL_strtol(ptr, NULL, 10);
   7.104 -}
   7.105 -
   7.106 -static int
   7.107 -iPod_Available()
   7.108 -{
   7.109 -    return 1;
   7.110 -}
   7.111 -
   7.112 -static void
   7.113 -iPod_DeleteDevice(SDL_VideoDevice * device)
   7.114 -{
   7.115 -    free(device->hidden);
   7.116 -    free(device);
   7.117 -}
   7.118 -
   7.119 -void
   7.120 -iPod_InitOSKeymap(_THIS)
   7.121 -{
   7.122 -}
   7.123 -
   7.124 -static SDL_VideoDevice *
   7.125 -iPod_CreateDevice(int devindex)
   7.126 -{
   7.127 -    SDL_VideoDevice *this;
   7.128 -
   7.129 -    this = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice));
   7.130 -    if (this) {
   7.131 -        memset(this, 0, sizeof *this);
   7.132 -        this->hidden = (struct SDL_PrivateVideoData *)
   7.133 -            SDL_malloc(sizeof(struct SDL_PrivateVideoData));
   7.134 -    }
   7.135 -    if (!this || !this->hidden) {
   7.136 -        SDL_OutOfMemory();
   7.137 -        if (this)
   7.138 -            SDL_free(this);
   7.139 -        return 0;
   7.140 -    }
   7.141 -    memset(this->hidden, 0, sizeof(struct SDL_PrivateVideoData));
   7.142 -
   7.143 -    generation = iPod_GetGeneration();
   7.144 -
   7.145 -    this->VideoInit = iPod_VideoInit;
   7.146 -    this->ListModes = iPod_ListModes;
   7.147 -    this->SetVideoMode = iPod_SetVideoMode;
   7.148 -    this->SetColors = iPod_SetColors;
   7.149 -    this->UpdateRects = iPod_UpdateRects;
   7.150 -    this->VideoQuit = iPod_VideoQuit;
   7.151 -    this->AllocHWSurface = 0;
   7.152 -    this->CheckHWBlit = 0;
   7.153 -    this->FillHWRect = 0;
   7.154 -    this->SetHWColorKey = 0;
   7.155 -    this->SetHWAlpha = 0;
   7.156 -    this->LockHWSurface = 0;
   7.157 -    this->UnlockHWSurface = 0;
   7.158 -    this->FlipHWSurface = 0;
   7.159 -    this->FreeHWSurface = 0;
   7.160 -    this->SetCaption = 0;
   7.161 -    this->SetIcon = 0;
   7.162 -    this->IconifyWindow = 0;
   7.163 -    this->GrabInput = 0;
   7.164 -    this->GetWMInfo = 0;
   7.165 -    this->InitOSKeymap = iPod_InitOSKeymap;
   7.166 -    this->PumpEvents = iPod_PumpEvents;
   7.167 -    this->free = iPod_DeleteDevice;
   7.168 -
   7.169 -    return this;
   7.170 -}
   7.171 -
   7.172 -VideoBootStrap iPod_bootstrap = {
   7.173 -    "ipod", "iPod Framebuffer Driver",
   7.174 -    iPod_Available, iPod_CreateDevice
   7.175 -};
   7.176 -
   7.177 -//--//
   7.178 -
   7.179 -static int
   7.180 -iPod_VideoInit(_THIS, SDL_PixelFormat * vformat)
   7.181 -{
   7.182 -    if (!initd) {
   7.183 -        /*** Code adapted/copied from SDL fbcon driver. ***/
   7.184 -
   7.185 -        static const char *const tty0[] = { "/dev/tty0", "/dev/vc/0", 0 };
   7.186 -        static const char *const vcs[] = { "/dev/vc/%d", "/dev/tty%d", 0 };
   7.187 -        int i, tty0_fd;
   7.188 -
   7.189 -        dbgout =
   7.190 -            fdopen(open("/etc/sdlpod.log", O_WRONLY | O_SYNC | O_APPEND),
   7.191 -                   "a");
   7.192 -        if (dbgout) {
   7.193 -            setbuf(dbgout, 0);
   7.194 -            fprintf(dbgout, "--> Started SDL <--\n");
   7.195 -        }
   7.196 -        // Try to query for a free VT
   7.197 -        tty0_fd = -1;
   7.198 -        for (i = 0; tty0[i] && (tty0_fd < 0); ++i) {
   7.199 -            tty0_fd = open(tty0[i], O_WRONLY, 0);
   7.200 -        }
   7.201 -        if (tty0_fd < 0) {
   7.202 -            tty0_fd = dup(0);   /* Maybe stdin is a VT? */
   7.203 -        }
   7.204 -        ioctl(tty0_fd, VT_OPENQRY, &curvt);
   7.205 -        close(tty0_fd);
   7.206 -
   7.207 -        tty0_fd = open("/dev/tty", O_RDWR, 0);
   7.208 -        if (tty0_fd >= 0) {
   7.209 -            ioctl(tty0_fd, TIOCNOTTY, 0);
   7.210 -            close(tty0_fd);
   7.211 -        }
   7.212 -
   7.213 -        if ((geteuid() == 0) && (curvt > 0)) {
   7.214 -            for (i = 0; vcs[i] && (kbfd < 0); ++i) {
   7.215 -                char vtpath[12];
   7.216 -
   7.217 -                SDL_snprintf(vtpath, SDL_arraysize(vtpath), vcs[i], curvt);
   7.218 -                kbfd = open(vtpath, O_RDWR);
   7.219 -            }
   7.220 -        }
   7.221 -        if (kbfd < 0) {
   7.222 -            if (dbgout)
   7.223 -                fprintf(dbgout, "Couldn't open any VC\n");
   7.224 -            return -1;
   7.225 -        }
   7.226 -        if (dbgout)
   7.227 -            fprintf(stderr, "Current VT: %d\n", curvt);
   7.228 -
   7.229 -        if (kbfd >= 0) {
   7.230 -            /* Switch to the correct virtual terminal */
   7.231 -            if (curvt > 0) {
   7.232 -                struct vt_stat vtstate;
   7.233 -
   7.234 -                if (ioctl(kbfd, VT_GETSTATE, &vtstate) == 0) {
   7.235 -                    oldvt = vtstate.v_active;
   7.236 -                }
   7.237 -                if (ioctl(kbfd, VT_ACTIVATE, curvt) == 0) {
   7.238 -                    if (dbgout)
   7.239 -                        fprintf(dbgout, "Waiting for switch to this VT... ");
   7.240 -                    ioctl(kbfd, VT_WAITACTIVE, curvt);
   7.241 -                    if (dbgout)
   7.242 -                        fprintf(dbgout, "done!\n");
   7.243 -                }
   7.244 -            }
   7.245 -            // Set terminal input mode
   7.246 -            if (tcgetattr(kbfd, &old_termios) < 0) {
   7.247 -                if (dbgout)
   7.248 -                    fprintf(dbgout, "Can't get termios\n");
   7.249 -                return -1;
   7.250 -            }
   7.251 -            cur_termios = old_termios;
   7.252 -            //      cur_termios.c_iflag &= ~(ICRNL | INPCK | ISTRIP | IXON);
   7.253 -            //      cur_termios.c_iflag |= (BRKINT);
   7.254 -            //      cur_termios.c_lflag &= ~(ICANON | ECHO | ISIG | IEXTEN);
   7.255 -            //      cur_termios.c_oflag &= ~(OPOST);
   7.256 -            //      cur_termios.c_oflag |= (ONOCR | ONLRET);
   7.257 -            cur_termios.c_lflag &= ~(ICANON | ECHO | ISIG);
   7.258 -            cur_termios.c_iflag &=
   7.259 -                ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON);
   7.260 -            cur_termios.c_cc[VMIN] = 0;
   7.261 -            cur_termios.c_cc[VTIME] = 0;
   7.262 -
   7.263 -            if (tcsetattr(kbfd, TCSAFLUSH, &cur_termios) < 0) {
   7.264 -                if (dbgout)
   7.265 -                    fprintf(dbgout, "Can't set termios\n");
   7.266 -                return -1;
   7.267 -            }
   7.268 -            if (ioctl(kbfd, KDSKBMODE, K_MEDIUMRAW) < 0) {
   7.269 -                if (dbgout)
   7.270 -                    fprintf(dbgout, "Can't set medium-raw mode\n");
   7.271 -                return -1;
   7.272 -            }
   7.273 -            if (ioctl(kbfd, KDSETMODE, KD_GRAPHICS) < 0) {
   7.274 -                if (dbgout)
   7.275 -                    fprintf(dbgout, "Can't set graphics\n");
   7.276 -                return -1;
   7.277 -            }
   7.278 -        }
   7.279 -        // Open the framebuffer
   7.280 -        if ((fbfd = open("/dev/fb0", O_RDWR)) < 0) {
   7.281 -            if (dbgout)
   7.282 -                fprintf(dbgout, "Can't open framebuffer\n");
   7.283 -            return -1;
   7.284 -        } else {
   7.285 -            struct fb_var_screeninfo vinfo;
   7.286 -
   7.287 -            if (dbgout)
   7.288 -                fprintf(dbgout, "Generation: %ld\n", generation);
   7.289 -
   7.290 -            if (generation >= 40000) {
   7.291 -                lcd_base = IPOD_NEW_LCD_BASE;
   7.292 -            } else {
   7.293 -                lcd_base = IPOD_OLD_LCD_BASE;
   7.294 -            }
   7.295 -
   7.296 -            ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo);
   7.297 -            close(fbfd);
   7.298 -
   7.299 -            if (lcd_base == IPOD_OLD_LCD_BASE)
   7.300 -                lcd_rtc = IPOD_OLD_LCD_RTC;
   7.301 -            else if (lcd_base == IPOD_NEW_LCD_BASE)
   7.302 -                lcd_rtc = IPOD_NEW_LCD_RTC;
   7.303 -            else {
   7.304 -                SDL_SetError("Unknown iPod version");
   7.305 -                return -1;
   7.306 -            }
   7.307 -
   7.308 -            lcd_width = vinfo.xres;
   7.309 -            lcd_height = vinfo.yres;
   7.310 -
   7.311 -            if (dbgout)
   7.312 -                fprintf(dbgout, "LCD is %dx%d\n", lcd_width, lcd_height);
   7.313 -        }
   7.314 -
   7.315 -        fcntl(kbfd, F_SETFL, O_RDWR | O_NONBLOCK);
   7.316 -
   7.317 -        /* Determine the current screen size */
   7.318 -        this->info.current_w = lcd_width;
   7.319 -        this->info.current_h = lcd_height;
   7.320 -
   7.321 -        if ((generation >= 60000) && (generation < 70000)) {
   7.322 -            vformat->BitsPerPixel = 16;
   7.323 -            vformat->Rmask = 0xF800;
   7.324 -            vformat->Gmask = 0x07E0;
   7.325 -            vformat->Bmask = 0x001F;
   7.326 -        } else {
   7.327 -            vformat->BitsPerPixel = 8;
   7.328 -            vformat->Rmask = vformat->Gmask = vformat->Bmask = 0;
   7.329 -        }
   7.330 -
   7.331 -        initd = 1;
   7.332 -        if (dbgout)
   7.333 -            fprintf(dbgout, "Initialized.\n\n");
   7.334 -    }
   7.335 -    return 0;
   7.336 -}
   7.337 -
   7.338 -static SDL_Rect **
   7.339 -iPod_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
   7.340 -{
   7.341 -    int width, height, fd;
   7.342 -    static SDL_Rect r;
   7.343 -    static SDL_Rect *rs[2] = { &r, 0 };
   7.344 -
   7.345 -    if ((fd = open("/dev/fb0", O_RDWR)) < 0) {
   7.346 -        return 0;
   7.347 -    } else {
   7.348 -        struct fb_var_screeninfo vinfo;
   7.349 -
   7.350 -        ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo);
   7.351 -        close(fbfd);
   7.352 -
   7.353 -        width = vinfo.xres;
   7.354 -        height = vinfo.yres;
   7.355 -    }
   7.356 -    r.x = r.y = 0;
   7.357 -    r.w = width;
   7.358 -    r.h = height;
   7.359 -    return rs;
   7.360 -}
   7.361 -
   7.362 -
   7.363 -static SDL_Surface *
   7.364 -iPod_SetVideoMode(_THIS, SDL_Surface * current, int width, int height,
   7.365 -                  int bpp, Uint32 flags)
   7.366 -{
   7.367 -    Uint32 Rmask, Gmask, Bmask;
   7.368 -    if (bpp > 8) {
   7.369 -        Rmask = 0xF800;
   7.370 -        Gmask = 0x07E0;
   7.371 -        Bmask = 0x001F;
   7.372 -    } else {
   7.373 -        Rmask = Gmask = Bmask = 0;
   7.374 -    }
   7.375 -
   7.376 -    if (this->hidden->buffer)
   7.377 -        SDL_free(this->hidden->buffer);
   7.378 -    this->hidden->buffer = SDL_malloc(width * height * (bpp / 8));
   7.379 -    if (!this->hidden->buffer) {
   7.380 -        SDL_SetError("Couldn't allocate buffer for requested mode");
   7.381 -        return 0;
   7.382 -    }
   7.383 -
   7.384 -    memset(this->hidden->buffer, 0, width * height * (bpp / 8));
   7.385 -
   7.386 -    if (!SDL_ReallocFormat(current, bpp, Rmask, Gmask, Bmask, 0)) {
   7.387 -        SDL_SetError("Couldn't allocate new pixel format");
   7.388 -        SDL_free(this->hidden->buffer);
   7.389 -        this->hidden->buffer = 0;
   7.390 -        return 0;
   7.391 -    }
   7.392 -
   7.393 -    if (bpp <= 8) {
   7.394 -        int i, j;
   7.395 -        for (i = 0; i < 256; i += 4) {
   7.396 -            for (j = 0; j < 4; j++) {
   7.397 -                current->format->palette->colors[i + j].r = 85 * j;
   7.398 -                current->format->palette->colors[i + j].g = 85 * j;
   7.399 -                current->format->palette->colors[i + j].b = 85 * j;
   7.400 -            }
   7.401 -        }
   7.402 -    }
   7.403 -
   7.404 -    current->flags = flags & SDL_FULLSCREEN;
   7.405 -    this->hidden->w = current->w = width;
   7.406 -    this->hidden->h = current->h = height;
   7.407 -    current->pitch = current->w * (bpp / 8);
   7.408 -    current->pixels = this->hidden->buffer;
   7.409 -
   7.410 -    return current;
   7.411 -}
   7.412 -
   7.413 -static int
   7.414 -iPod_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors)
   7.415 -{
   7.416 -    if (SDL_VideoSurface && SDL_VideoSurface->format
   7.417 -        && SDL_VideoSurface->format->palette) {
   7.418 -        int i, j;
   7.419 -        for (i = 0; i < 256; i += 4) {
   7.420 -            for (j = 0; j < 4; j++) {
   7.421 -                SDL_VideoSurface->format->palette->colors[i + j].r = 85 * j;
   7.422 -                SDL_VideoSurface->format->palette->colors[i + j].g = 85 * j;
   7.423 -                SDL_VideoSurface->format->palette->colors[i + j].b = 85 * j;
   7.424 -            }
   7.425 -        }
   7.426 -    }
   7.427 -    return 0;
   7.428 -}
   7.429 -
   7.430 -static void
   7.431 -iPod_VideoQuit(_THIS)
   7.432 -{
   7.433 -    ioctl(kbfd, KDSETMODE, KD_TEXT);
   7.434 -    tcsetattr(kbfd, TCSAFLUSH, &old_termios);
   7.435 -    old_kbmode = -1;
   7.436 -
   7.437 -    if (oldvt > 0)
   7.438 -        ioctl(kbfd, VT_ACTIVATE, oldvt);
   7.439 -
   7.440 -    if (kbfd > 0)
   7.441 -        close(kbfd);
   7.442 -
   7.443 -    if (dbgout) {
   7.444 -        fprintf(dbgout, "<-- Ended SDL -->\n");
   7.445 -        fclose(dbgout);
   7.446 -    }
   7.447 -
   7.448 -    kbfd = -1;
   7.449 -}
   7.450 -
   7.451 -static char iPod_SC_keymap[] = {
   7.452 -    0,                          /* 0 - no key */
   7.453 -    '[' - 0x40,                 /* ESC (Ctrl+[) */
   7.454 -    '1', '2', '3', '4', '5', '6', '7', '8', '9',
   7.455 -    '-', '=',
   7.456 -    '\b', '\t',                 /* Backspace, Tab (Ctrl+H,Ctrl+I) */
   7.457 -    'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']',
   7.458 -    '\n', 0,                    /* Enter, Left CTRL */
   7.459 -    'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`',
   7.460 -    0, '\\',                    /* left shift, backslash */
   7.461 -    'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/',
   7.462 -    0, '*', 0, ' ', 0,          /* right shift, KP mul, left alt, space, capslock */
   7.463 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,       /* F1-10 */
   7.464 -    0, 0,                       /* numlock, scrollock */
   7.465 -    '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.',    /* numeric keypad */
   7.466 -    0, 0,                       /* padding */
   7.467 -    0, 0, 0,                    /* "less" (?), F11, F12 */
   7.468 -    0, 0, 0, 0, 0, 0, 0,        /* padding */
   7.469 -    '\n', 0, '/', 0, 0,         /* KP enter, Rctrl, Ctrl, KP div, PrtSc, RAlt */
   7.470 -    0, 0, 0, 0, 0, 0, 0, 0, 0,  /* Break, Home, Up, PgUp, Left, Right, End, Down, PgDn */
   7.471 -    0, 0,                       /* Ins, Del */
   7.472 -    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,      /* padding */
   7.473 -    0, 0,                       /* RWin, LWin */
   7.474 -    0                           /* no key */
   7.475 -};
   7.476 -
   7.477 -
   7.478 -static void
   7.479 -iPod_keyboard()
   7.480 -{
   7.481 -    unsigned char keybuf[128];
   7.482 -    int i, nread;
   7.483 -    SDL_keysym keysym;
   7.484 -    SDL_Event ev;
   7.485 -
   7.486 -    keysym.mod = 0;
   7.487 -    keysym.scancode = 0xff;
   7.488 -    memset(&ev, 0, sizeof(SDL_Event));
   7.489 -
   7.490 -    nread = read(kbfd, keybuf, 128);
   7.491 -    for (i = 0; i < nread; i++) {
   7.492 -        char ascii = iPod_SC_keymap[keybuf[i] & 0x7f];
   7.493 -
   7.494 -        if (dbgout)
   7.495 -            fprintf(dbgout, "Key! %02x is %c %s", keybuf[i], ascii,
   7.496 -                    (keybuf[i] & 0x80) ? "up" : "down");
   7.497 -
   7.498 -        keysym.sym = keysym.unicode = ascii;
   7.499 -        ev.type = (keybuf[i] & 0x80) ? SDL_KEYUP : SDL_KEYDOWN;
   7.500 -        ev.key.state = 0;
   7.501 -        ev.key.keysym = keysym;
   7.502 -        SDL_PushEvent(&ev);
   7.503 -    }
   7.504 -}
   7.505 -
   7.506 -static void
   7.507 -iPod_PumpEvents(_THIS)
   7.508 -{
   7.509 -    fd_set fdset;
   7.510 -    int max_fd = 0;
   7.511 -    static struct timeval zero;
   7.512 -    int posted;
   7.513 -
   7.514 -    do {
   7.515 -        posted = 0;
   7.516 -
   7.517 -        FD_ZERO(&fdset);
   7.518 -        if (kbfd >= 0) {
   7.519 -            FD_SET(kbfd, &fdset);
   7.520 -            max_fd = kbfd;
   7.521 -        }
   7.522 -        if (dbgout)
   7.523 -            fprintf(dbgout, "Selecting");
   7.524 -        if (select(max_fd + 1, &fdset, 0, 0, &zero) > 0) {
   7.525 -            if (dbgout)
   7.526 -                fprintf(dbgout, " -> match!\n");
   7.527 -            iPod_keyboard();
   7.528 -            posted++;
   7.529 -        }
   7.530 -        if (dbgout)
   7.531 -            fprintf(dbgout, "\n");
   7.532 -    } while (posted);
   7.533 -}
   7.534 -
   7.535 -// enough space for 160x128x2
   7.536 -static char ipod_scr[160 * (128 / 4)];
   7.537 -
   7.538 -#define outl(datum,addr) (*(volatile unsigned long *)(addr) = (datum))
   7.539 -#define inl(addr) (*(volatile unsigned long *)(addr))
   7.540 -
   7.541 -/*** The following LCD code is taken from Linux kernel uclinux-2.4.24-uc0-ipod2,
   7.542 -     file arch/armnommu/mach-ipod/fb.c. A few modifications have been made. ***/
   7.543 -
   7.544 -/* get current usec counter */
   7.545 -static int
   7.546 -M_timer_get_current(void)
   7.547 -{
   7.548 -    return inl(lcd_rtc);
   7.549 -}
   7.550 -
   7.551 -/* check if number of useconds has past */
   7.552 -static int
   7.553 -M_timer_check(int clock_start, int usecs)
   7.554 -{
   7.555 -    unsigned long clock;
   7.556 -    clock = inl(lcd_rtc);
   7.557 -
   7.558 -    if ((clock - clock_start) >= usecs) {
   7.559 -        return 1;
   7.560 -    } else {
   7.561 -        return 0;
   7.562 -    }
   7.563 -}
   7.564 -
   7.565 -/* wait for LCD with timeout */
   7.566 -static void
   7.567 -M_lcd_wait_write(void)
   7.568 -{
   7.569 -    if ((inl(lcd_base) & 0x8000) != 0) {
   7.570 -        int start = M_timer_get_current();
   7.571 -
   7.572 -        do {
   7.573 -            if ((inl(lcd_base) & (unsigned int) 0x8000) == 0)
   7.574 -                break;
   7.575 -        } while (M_timer_check(start, 1000) == 0);
   7.576 -    }
   7.577 -}
   7.578 -
   7.579 -
   7.580 -/* send LCD data */
   7.581 -static void
   7.582 -M_lcd_send_data(int data_lo, int data_hi)
   7.583 -{
   7.584 -    M_lcd_wait_write();
   7.585 -
   7.586 -    outl(data_lo, lcd_base + LCD_DATA);
   7.587 -
   7.588 -    M_lcd_wait_write();
   7.589 -
   7.590 -    outl(data_hi, lcd_base + LCD_DATA);
   7.591 -
   7.592 -}
   7.593 -
   7.594 -/* send LCD command */
   7.595 -static void
   7.596 -M_lcd_prepare_cmd(int cmd)
   7.597 -{
   7.598 -    M_lcd_wait_write();
   7.599 -
   7.600 -    outl(0x0, lcd_base + LCD_CMD);
   7.601 -
   7.602 -    M_lcd_wait_write();
   7.603 -
   7.604 -    outl(cmd, lcd_base + LCD_CMD);
   7.605 -
   7.606 -}
   7.607 -
   7.608 -/* send LCD command and data */
   7.609 -static void
   7.610 -M_lcd_cmd_and_data(int cmd, int data_lo, int data_hi)
   7.611 -{
   7.612 -    M_lcd_prepare_cmd(cmd);
   7.613 -
   7.614 -    M_lcd_send_data(data_lo, data_hi);
   7.615 -}
   7.616 -
   7.617 -// Copied from uW
   7.618 -static void
   7.619 -M_update_display(int sx, int sy, int mx, int my)
   7.620 -{
   7.621 -    int y;
   7.622 -    unsigned short cursor_pos;
   7.623 -
   7.624 -    sx >>= 3;
   7.625 -    mx >>= 3;
   7.626 -
   7.627 -    cursor_pos = sx + (sy << 5);
   7.628 -
   7.629 -    for (y = sy; y <= my; y++) {
   7.630 -        unsigned char *img_data;
   7.631 -        int x;
   7.632 -
   7.633 -        /* move the cursor */
   7.634 -        M_lcd_cmd_and_data(0x11, cursor_pos >> 8, cursor_pos & 0xff);
   7.635 -
   7.636 -        /* setup for printing */
   7.637 -        M_lcd_prepare_cmd(0x12);
   7.638 -
   7.639 -        img_data = ipod_scr + (sx << 1) + (y * (lcd_width / 4));
   7.640 -
   7.641 -        /* loops up to 160 times */
   7.642 -        for (x = sx; x <= mx; x++) {
   7.643 -            /* display eight pixels */
   7.644 -            M_lcd_send_data(*(img_data + 1), *img_data);
   7.645 -
   7.646 -            img_data += 2;
   7.647 -        }
   7.648 -
   7.649 -        /* update cursor pos counter */
   7.650 -        cursor_pos += 0x20;
   7.651 -    }
   7.652 -}
   7.653 -
   7.654 -/* get current usec counter */
   7.655 -static int
   7.656 -C_timer_get_current(void)
   7.657 -{
   7.658 -    return inl(0x60005010);
   7.659 -}
   7.660 -
   7.661 -/* check if number of useconds has past */
   7.662 -static int
   7.663 -C_timer_check(int clock_start, int usecs)
   7.664 -{
   7.665 -    unsigned long clock;
   7.666 -    clock = inl(0x60005010);
   7.667 -
   7.668 -    if ((clock - clock_start) >= usecs) {
   7.669 -        return 1;
   7.670 -    } else {
   7.671 -        return 0;
   7.672 -    }
   7.673 -}
   7.674 -
   7.675 -/* wait for LCD with timeout */
   7.676 -static void
   7.677 -C_lcd_wait_write(void)
   7.678 -{
   7.679 -    if ((inl(0x70008A0C) & 0x80000000) != 0) {
   7.680 -        int start = C_timer_get_current();
   7.681 -
   7.682 -        do {
   7.683 -            if ((inl(0x70008A0C) & 0x80000000) == 0)
   7.684 -                break;
   7.685 -        } while (C_timer_check(start, 1000) == 0);
   7.686 -    }
   7.687 -}
   7.688 -
   7.689 -static void
   7.690 -C_lcd_cmd_data(int cmd, int data)
   7.691 -{
   7.692 -    C_lcd_wait_write();
   7.693 -    outl(cmd | 0x80000000, 0x70008A0C);
   7.694 -
   7.695 -    C_lcd_wait_write();
   7.696 -    outl(data | 0x80000000, 0x70008A0C);
   7.697 -}
   7.698 -
   7.699 -static void
   7.700 -C_update_display(int sx, int sy, int mx, int my)
   7.701 -{
   7.702 -    int height = (my - sy) + 1;
   7.703 -    int width = (mx - sx) + 1;
   7.704 -
   7.705 -    char *addr = SDL_VideoSurface->pixels;
   7.706 -
   7.707 -    if (width & 1)
   7.708 -        width++;
   7.709 -
   7.710 -    /* start X and Y */
   7.711 -    C_lcd_cmd_data(0x12, (sy & 0xff));
   7.712 -    C_lcd_cmd_data(0x13, (((SDL_VideoSurface->w - 1) - sx) & 0xff));
   7.713 -
   7.714 -    /* max X and Y */
   7.715 -    C_lcd_cmd_data(0x15, (((sy + height) - 1) & 0xff));
   7.716 -    C_lcd_cmd_data(0x16,
   7.717 -                   (((((SDL_VideoSurface->w - 1) - sx) - width) + 1) & 0xff));
   7.718 -
   7.719 -    addr += sx + sy * SDL_VideoSurface->pitch;
   7.720 -
   7.721 -    while (height > 0) {
   7.722 -        int h, x, y, pixels_to_write;
   7.723 -
   7.724 -        pixels_to_write = (width * height) * 2;
   7.725 -
   7.726 -        /* calculate how much we can do in one go */
   7.727 -        h = height;
   7.728 -        if (pixels_to_write > 64000) {
   7.729 -            h = (64000 / 2) / width;
   7.730 -            pixels_to_write = (width * h) * 2;
   7.731 -        }
   7.732 -
   7.733 -        outl(0x10000080, 0x70008A20);
   7.734 -        outl((pixels_to_write - 1) | 0xC0010000, 0x70008A24);
   7.735 -        outl(0x34000000, 0x70008A20);
   7.736 -
   7.737 -        /* for each row */
   7.738 -        for (x = 0; x < h; x++) {
   7.739 -            /* for each column */
   7.740 -            for (y = 0; y < width; y += 2) {
   7.741 -                unsigned two_pixels;
   7.742 -
   7.743 -                two_pixels = addr[0] | (addr[1] << 16);
   7.744 -                addr += 2;
   7.745 -
   7.746 -                while ((inl(0x70008A20) & 0x1000000) == 0);
   7.747 -
   7.748 -                /* output 2 pixels */
   7.749 -                outl(two_pixels, 0x70008B00);
   7.750 -            }
   7.751 -
   7.752 -            addr += SDL_VideoSurface->w - width;
   7.753 -        }
   7.754 -
   7.755 -        while ((inl(0x70008A20) & 0x4000000) == 0);
   7.756 -
   7.757 -        outl(0x0, 0x70008A24);
   7.758 -
   7.759 -        height = height - h;
   7.760 -    }
   7.761 -}
   7.762 -
   7.763 -// Should work with photo. However, I don't have one, so I'm not sure.
   7.764 -static void
   7.765 -iPod_UpdateRects(_THIS, int nrects, SDL_Rect * rects)
   7.766 -{
   7.767 -    if (SDL_VideoSurface->format->BitsPerPixel == 16) {
   7.768 -        C_update_display(0, 0, lcd_width, lcd_height);
   7.769 -    } else {
   7.770 -        int i, y, x;
   7.771 -        for (i = 0; i < nrects; i++) {
   7.772 -            SDL_Rect *r = rects + i;
   7.773 -            if (!r) {
   7.774 -                continue;
   7.775 -            }
   7.776 -
   7.777 -            for (y = r->y; (y < r->y + r->h) && y < lcd_height; y++) {
   7.778 -                for (x = r->x; (x < r->x + r->w) && x < lcd_width; x++) {
   7.779 -                    ipod_scr[y * (lcd_width / 4) + x / 4] &=
   7.780 -                        ~(3 << (2 * (x % 4)));
   7.781 -                    ipod_scr[y * (lcd_width / 4) + x / 4] |=
   7.782 -                        (((Uint8 *) (SDL_VideoSurface->pixels))[y *
   7.783 -                                                                SDL_VideoSurface->
   7.784 -                                                                pitch +
   7.785 -                                                                x] & 3) << (2
   7.786 -                                                                            *
   7.787 -                                                                            (x
   7.788 -                                                                             %
   7.789 -                                                                             4));
   7.790 -                }
   7.791 -            }
   7.792 -        }
   7.793 -
   7.794 -        M_update_display(0, 0, lcd_width, lcd_height);
   7.795 -    }
   7.796 -}
   7.797 -
   7.798 -/* vi: set ts=4 sw=4 expandtab: */
     8.1 --- a/src/video/ipod/SDL_ipodvideo.h	Sat Sep 19 05:47:54 2009 +0000
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,40 +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 -/* iPod SDL framebuffer driver
    8.28 - * Joshua Oreman
    8.29 - * Main header file
    8.30 - */
    8.31 -
    8.32 -#ifndef _SDL_ipodvideo_h
    8.33 -#define _SDL_ipodvideo_h
    8.34 -
    8.35 -struct SDL_PrivateVideoData
    8.36 -{
    8.37 -    char *buffer;
    8.38 -    int w, h;
    8.39 -};
    8.40 -
    8.41 -
    8.42 -#endif
    8.43 -/* vi: set ts=4 sw=4 expandtab: */