created env (fbcon-1.3) and added basic files gsoc2009_ps3
authorMartin Lowinski <martin@goldtopf.org>
Sat, 07 Nov 2009 11:35:19 +0000
branchgsoc2009_ps3
changeset 3158 30f3b987fec3
parent 3157 cce01ba54174
child 3159 2632b7453516
created env (fbcon-1.3) and added basic files
Makefile.in
configure.in
src/video/fbcon-1.3/SDL_fbevents.c
src/video/fbcon-1.3/SDL_fbevents_c.h
src/video/fbcon-1.3/SDL_fbmodes.c
src/video/fbcon-1.3/SDL_fbmodes_c.h
src/video/fbcon-1.3/SDL_fbrender.c
src/video/fbcon-1.3/SDL_fbrender_c.h
src/video/fbcon-1.3/SDL_fbvideo.c
src/video/fbcon-1.3/SDL_fbvideo.h
--- a/Makefile.in	Thu Aug 27 11:33:56 2009 +0000
+++ b/Makefile.in	Sat Nov 07 11:35:19 2009 +0000
@@ -43,7 +43,7 @@
 # SPU programs
 SPU_GCC = @SPU_GCC@
 EMBEDSPU = @EMBEDSPU@
-include $(srcdir)/src/video/ps3/spulibs/Makefile
+#include $(srcdir)/src/video/ps3/spulibs/Makefile
 
 DIST = acinclude.m4 autogen.sh Borland.html Borland.zip BUGS build-scripts configure configure.in COPYING CREDITS docs docs.html include INSTALL Makefile.dc Makefile.minimal Makefile.in README* sdl-config.in sdl.m4 sdl.pc.in SDL.qpg.in SDL.spec SDL.spec.in src test TODO VisualC.html VisualC VisualCE Watcom-OS2.zip Watcom-Win32.zip WhatsNew Xcode
 
--- a/configure.in	Thu Aug 27 11:33:56 2009 +0000
+++ b/configure.in	Sat Nov 07 11:35:19 2009 +0000
@@ -936,18 +936,18 @@
 
 
 dnl Do the iPod thing
-CheckIPod()
-{
-    AC_ARG_ENABLE(ipod,
-AC_HELP_STRING([--enable-ipod], [configure SDL to work with iPodLinux [default=yes on arm-elf]]),
-        , enable_ipod=yes)
-
-    if test x$enable_ipod = xyes; then
-        EXTRA_CFLAGS="$EXTRA_CFLAGS -DIPOD"
-        AC_DEFINE(SDL_VIDEO_DRIVER_IPOD)
-        SOURCES="$SOURCES $srcdir/src/video/ipod/*.c"
-    fi
-}
+#CheckIPod()
+#{
+#    AC_ARG_ENABLE(ipod,
+#AC_HELP_STRING([--enable-ipod], [configure SDL to work with iPodLinux [default=yes on arm-elf]]),
+#        , enable_ipod=yes)
+#
+#    if test x$enable_ipod = xyes; then
+#        EXTRA_CFLAGS="$EXTRA_CFLAGS -DIPOD"
+#        AC_DEFINE(SDL_VIDEO_DRIVER_IPOD)
+#        SOURCES="$SOURCES $srcdir/src/video/ipod/*.c"
+#    fi
+#}
 
 dnl Find the nanox include and library directories
 CheckNANOX()
@@ -1349,7 +1349,7 @@
         if test x$video_fbcon = xyes; then
             AC_CHECK_FUNCS(getpagesize)
             AC_DEFINE(SDL_VIDEO_DRIVER_FBCON)
-            SOURCES="$SOURCES $srcdir/src/video/fbcon/*.c"
+            SOURCES="$SOURCES $srcdir/src/video/fbcon-1.3/*.c"
             have_video=yes
         fi
     fi
@@ -2372,7 +2372,7 @@
     arm-*-elf*) # FIXME: Can we get more specific for iPodLinux?
         ARCH=linux
         CheckDummyVideo
-        CheckIPod
+        #CheckIPod
         # Set up files for the timer library
         if test x$enable_timers = xyes; then
             AC_DEFINE(SDL_TIMER_UNIX)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/fbcon-1.3/SDL_fbevents.c	Sat Nov 07 11:35:19 2009 +0000
@@ -0,0 +1,36 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2009 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include "../../events/SDL_sysevents.h"
+#include "../../events/SDL_events_c.h"
+
+#include "SDL_fbvideo.h"
+#include "SDL_fbevents_c.h"
+
+void
+FB_PumpEvents(_THIS)
+{
+    /* do nothing. */
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/fbcon-1.3/SDL_fbevents_c.h	Sat Nov 07 11:35:19 2009 +0000
@@ -0,0 +1,28 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2009 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include "SDL_fbvideo.h"
+
+extern void FB_PumpEvents(_THIS);
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/fbcon-1.3/SDL_fbmodes.c	Sat Nov 07 11:35:19 2009 +0000
@@ -0,0 +1,141 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2009 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include "SDL_ps3video.h"
+
+void
+PS3_InitModes(_THIS)
+{
+    deprintf(1, "+PS3_InitModes()\n");
+    SDL_VideoDisplay display;
+    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
+    SDL_DisplayMode mode;
+    PS3_DisplayModeData *modedata;
+    unsigned long vid = 0;
+
+    modedata = (PS3_DisplayModeData *) SDL_malloc(sizeof(*modedata));
+    if (!modedata) {
+        return;
+    }
+
+    /* Setting up the DisplayMode based on current settings */
+    struct ps3fb_ioctl_res res;
+    if (ioctl(data->fbdev, PS3FB_IOCTL_SCREENINFO, &res)) {
+        SDL_SetError("Can't get PS3FB_IOCTL_SCREENINFO");
+    }
+    mode.format = SDL_PIXELFORMAT_RGB888;
+    mode.refresh_rate = 0;
+    mode.w = res.xres;
+    mode.h = res.yres;
+
+    /* Setting up driver specific mode data,
+     * Get the current ps3 specific videmode number */
+    if (ioctl(data->fbdev, PS3FB_IOCTL_GETMODE, (unsigned long)&vid)) {
+        SDL_SetError("Can't get PS3FB_IOCTL_GETMODE");
+    }
+    deprintf(2, "PS3FB_IOCTL_GETMODE = %u\n", vid);
+    modedata->mode = vid;
+    mode.driverdata = modedata;
+
+    /* Set display's videomode and add it */
+    SDL_zero(display);
+    display.desktop_mode = mode;
+    display.current_mode = mode;
+
+    SDL_AddVideoDisplay(&display);
+    deprintf(1, "-PS3_InitModes()\n");
+}
+
+/* DisplayModes available on the PS3 */
+static SDL_DisplayMode ps3fb_modedb[] = {
+    /* VESA */
+    {SDL_PIXELFORMAT_RGB888, 1280, 768, 0, NULL}, // WXGA
+    {SDL_PIXELFORMAT_RGB888, 1280, 1024, 0, NULL}, // SXGA
+    {SDL_PIXELFORMAT_RGB888, 1920, 1200, 0, NULL}, // WUXGA
+    /* Native resolutions (progressive, "fullscreen") */
+    {SDL_PIXELFORMAT_RGB888, 720, 480, 0, NULL}, // 480p
+    {SDL_PIXELFORMAT_RGB888, 1280, 720, 0, NULL}, // 720p
+    {SDL_PIXELFORMAT_RGB888, 1920, 1080, 0, NULL} // 1080p
+};
+
+/* PS3 videomode number according to ps3fb_modedb */
+static PS3_DisplayModeData ps3fb_data[] = {
+    {11}, {12}, {13}, {130}, {131}, {133}, 
+};
+
+void
+PS3_GetDisplayModes(_THIS) {
+    deprintf(1, "+PS3_GetDisplayModes()\n");
+    SDL_DisplayMode mode;
+    unsigned int nummodes;
+
+    nummodes = sizeof(ps3fb_modedb) / sizeof(SDL_DisplayMode);
+
+    int n;
+    for (n=0; n<nummodes; ++n) {
+        /* Get driver specific mode data */
+        ps3fb_modedb[n].driverdata = &ps3fb_data[n];
+
+        /* Add DisplayMode to list */
+        deprintf(2, "Adding resolution %u x %u\n", ps3fb_modedb[n].w, ps3fb_modedb[n].h);
+        SDL_AddDisplayMode(_this->current_display, &ps3fb_modedb[n]);
+    }
+    deprintf(1, "-PS3_GetDisplayModes()\n");
+}
+
+int
+PS3_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
+{
+    deprintf(1, "+PS3_SetDisplayMode()\n");
+    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
+    PS3_DisplayModeData *dispdata = (PS3_DisplayModeData *) mode->driverdata;
+
+    /* Set the new DisplayMode */
+    deprintf(2, "Setting PS3FB_MODE to %u\n", dispdata->mode);
+    if (ioctl(data->fbdev, PS3FB_IOCTL_SETMODE, (unsigned long)&dispdata->mode)) {
+        deprintf(2, "Could not set PS3FB_MODE\n");
+        SDL_SetError("Could not set PS3FB_MODE\n");
+        return -1;
+    }
+
+    deprintf(1, "-PS3_SetDisplayMode()\n");
+    return 0;
+}
+
+void
+PS3_QuitModes(_THIS) {
+    deprintf(1, "+PS3_QuitModes()\n");
+
+    /* There was no mem allocated for driverdata */
+    int i, j;
+    for (i = _this->num_displays; i--;) {
+        SDL_VideoDisplay *display = &_this->displays[i];
+        for (j = display->num_display_modes; j--;) {
+            display->display_modes[j].driverdata = NULL;
+        }
+    }
+
+    deprintf(1, "-PS3_QuitModes()\n");
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/fbcon-1.3/SDL_fbmodes_c.h	Sat Nov 07 11:35:19 2009 +0000
@@ -0,0 +1,34 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2009 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#ifndef _SDL_ps3modes_h
+#define _SDL_ps3modes_h
+
+extern void PS3_InitModes(_THIS);
+extern void PS3_GetDisplayModes(_THIS);
+extern int PS3_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
+extern void PS3_QuitModes(_THIS);
+
+#endif /* SDL_ps3modes_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/fbcon-1.3/SDL_fbrender.c	Sat Nov 07 11:35:19 2009 +0000
@@ -0,0 +1,269 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2009 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include "SDL_video.h"
+#include "../SDL_sysvideo.h"
+#include "../SDL_yuv_sw_c.h"
+#include "../SDL_renderer_sw.h"
+
+
+/* SDL surface based renderer implementation */
+
+static SDL_Renderer *SDL_FB_CreateRenderer(SDL_Window * window,
+                                              Uint32 flags);
+static int SDL_FB_RenderPoint(SDL_Renderer * renderer, int x, int y);
+static int SDL_FB_RenderLine(SDL_Renderer * renderer, int x1, int y1,
+                                int x2, int y2);
+static int SDL_FB_RenderFill(SDL_Renderer * renderer,
+                                const SDL_Rect * rect);
+static int SDL_FB_RenderCopy(SDL_Renderer * renderer,
+                                SDL_Texture * texture,
+                                const SDL_Rect * srcrect,
+                                const SDL_Rect * dstrect);
+static void SDL_FB_RenderPresent(SDL_Renderer * renderer);
+static void SDL_FB_DestroyRenderer(SDL_Renderer * renderer);
+
+
+SDL_RenderDriver SDL_FB_RenderDriver = {
+    SDL_FB_CreateRenderer,
+    {
+     "fbcon",
+     (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
+      SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
+      SDL_RENDERER_PRESENTDISCARD),
+     }
+};
+
+typedef struct
+{
+    int current_screen;
+    SDL_Surface *screens[3];
+} SDL_FB_RenderData;
+
+SDL_Renderer *
+SDL_FB_CreateRenderer(SDL_Window * window, Uint32 flags)
+{
+    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
+    SDL_DisplayMode *displayMode = &display->current_mode;
+    SDL_Renderer *renderer;
+    SDL_FB_RenderData *data;
+    int i, n;
+    int bpp;
+    Uint32 Rmask, Gmask, Bmask, Amask;
+
+    if (!SDL_PixelFormatEnumToMasks
+        (displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
+        SDL_SetError("Unknown display format");
+        return NULL;
+    }
+
+    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
+    if (!renderer) {
+        SDL_OutOfMemory();
+        return NULL;
+    }
+
+    data = (SDL_FB_RenderData *) SDL_malloc(sizeof(*data));
+    if (!data) {
+        SDL_FB_DestroyRenderer(renderer);
+        SDL_OutOfMemory();
+        return NULL;
+    }
+    SDL_zerop(data);
+
+    renderer->RenderPoint = SDL_FB_RenderPoint;
+    renderer->RenderLine = SDL_FB_RenderLine;
+    renderer->RenderFill = SDL_FB_RenderFill;
+    renderer->RenderCopy = SDL_FB_RenderCopy;
+    renderer->RenderPresent = SDL_FB_RenderPresent;
+    renderer->DestroyRenderer = SDL_FB_DestroyRenderer;
+    renderer->info.name = SDL_FB_RenderDriver.info.name;
+    renderer->info.flags = 0;
+    renderer->window = window->id;
+    renderer->driverdata = data;
+    Setup_SoftwareRenderer(renderer);
+
+    if (flags & SDL_RENDERER_PRESENTFLIP2) {
+        renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
+        n = 2;
+    } else if (flags & SDL_RENDERER_PRESENTFLIP3) {
+        renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
+        n = 3;
+    } else {
+        renderer->info.flags |= SDL_RENDERER_PRESENTCOPY;
+        n = 1;
+    }
+    for (i = 0; i < n; ++i) {
+        data->screens[i] =
+            SDL_CreateRGBSurface(0, window->w, window->h, bpp, Rmask, Gmask,
+                                 Bmask, Amask);
+        if (!data->screens[i]) {
+            SDL_FB_DestroyRenderer(renderer);
+            return NULL;
+        }
+        SDL_SetSurfacePalette(data->screens[i], display->palette);
+    }
+    data->current_screen = 0;
+
+    return renderer;
+}
+
+static int
+SDL_FB_RenderPoint(SDL_Renderer * renderer, int x, int y)
+{
+    SDL_FB_RenderData *data =
+        (SDL_FB_RenderData *) renderer->driverdata;
+    SDL_Surface *target = data->screens[data->current_screen];
+    int status;
+
+    if (renderer->blendMode == SDL_BLENDMODE_NONE ||
+        renderer->blendMode == SDL_BLENDMODE_MASK) {
+        Uint32 color =
+            SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b,
+                        renderer->a);
+
+        status = SDL_DrawPoint(target, x, y, color);
+    } else {
+        status =
+            SDL_BlendPoint(target, x, y, renderer->blendMode, renderer->r,
+                           renderer->g, renderer->b, renderer->a);
+    }
+    return status;
+}
+
+static int
+SDL_FB_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
+{
+    SDL_FB_RenderData *data =
+        (SDL_FB_RenderData *) renderer->driverdata;
+    SDL_Surface *target = data->screens[data->current_screen];
+    int status;
+
+    if (renderer->blendMode == SDL_BLENDMODE_NONE ||
+        renderer->blendMode == SDL_BLENDMODE_MASK) {
+        Uint32 color =
+            SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b,
+                        renderer->a);
+
+        status = SDL_DrawLine(target, x1, y1, x2, y2, color);
+    } else {
+        status =
+            SDL_BlendLine(target, x1, y1, x2, y2, renderer->blendMode,
+                          renderer->r, renderer->g, renderer->b, renderer->a);
+    }
+    return status;
+}
+
+static int
+SDL_FB_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect)
+{
+    SDL_FB_RenderData *data =
+        (SDL_FB_RenderData *) renderer->driverdata;
+    SDL_Surface *target = data->screens[data->current_screen];
+    SDL_Rect real_rect = *rect;
+    int status;
+
+    if (renderer->blendMode == SDL_BLENDMODE_NONE) {
+        Uint32 color =
+            SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b,
+                        renderer->a);
+
+        status = SDL_FillRect(target, &real_rect, color);
+    } else {
+        status =
+            SDL_BlendRect(target, &real_rect, renderer->blendMode,
+                          renderer->r, renderer->g, renderer->b, renderer->a);
+    }
+    return status;
+}
+
+static int
+SDL_FB_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
+                     const SDL_Rect * srcrect, const SDL_Rect * dstrect)
+{
+    SDL_FB_RenderData *data =
+        (SDL_FB_RenderData *) renderer->driverdata;
+    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
+    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
+
+    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
+        SDL_Surface *target = data->screens[data->current_screen];
+        void *pixels =
+            (Uint8 *) target->pixels + dstrect->y * target->pitch +
+            dstrect->x * target->format->BytesPerPixel;
+        return SDL_SW_CopyYUVToRGB((SDL_SW_YUVTexture *) texture->driverdata,
+                                   srcrect, display->current_mode.format,
+                                   dstrect->w, dstrect->h, pixels,
+                                   target->pitch);
+    } else {
+        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
+        SDL_Surface *target = data->screens[data->current_screen];
+        SDL_Rect real_srcrect = *srcrect;
+        SDL_Rect real_dstrect = *dstrect;
+
+        return SDL_LowerBlit(surface, &real_srcrect, target, &real_dstrect);
+    }
+}
+
+static void
+SDL_FB_RenderPresent(SDL_Renderer * renderer)
+{
+    static int frame_number;
+    SDL_FB_RenderData *data =
+        (SDL_FB_RenderData *) renderer->driverdata;
+
+    /* Send the data to the display */
+    if (SDL_getenv("SDL_VIDEO_FB_SAVE_FRAMES")) {
+        char file[128];
+        SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp",
+                     renderer->window, ++frame_number);
+        SDL_SaveBMP(data->screens[data->current_screen], file);
+    }
+
+    /* Update the flipping chain, if any */
+    if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) {
+        data->current_screen = (data->current_screen + 1) % 2;
+    } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) {
+        data->current_screen = (data->current_screen + 1) % 3;
+    }
+}
+
+static void
+SDL_FB_DestroyRenderer(SDL_Renderer * renderer)
+{
+    SDL_FB_RenderData *data =
+        (SDL_FB_RenderData *) renderer->driverdata;
+    int i;
+
+    if (data) {
+        for (i = 0; i < SDL_arraysize(data->screens); ++i) {
+            if (data->screens[i]) {
+                SDL_FreeSurface(data->screens[i]);
+            }
+        }
+        SDL_free(data);
+    }
+    SDL_free(renderer);
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/fbcon-1.3/SDL_fbrender_c.h	Sat Nov 07 11:35:19 2009 +0000
@@ -0,0 +1,28 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2009 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/* SDL surface based renderer implementation */
+
+extern SDL_RenderDriver SDL_FB_RenderDriver;
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/fbcon-1.3/SDL_fbvideo.c	Sat Nov 07 11:35:19 2009 +0000
@@ -0,0 +1,208 @@
+/*
+	SDL - Simple DirectMedia Layer
+	Copyright (C) 1997-2009 Sam Lantinga
+
+	This library is free software; you can redistribute it and/or
+	modify it under the terms of the GNU Lesser General Public
+	License as published by the Free Software Foundation; either
+	version 2.1 of the License, or (at your option) any later version.
+
+	This library is distributed in the hope that it will be useful,
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+	Lesser General Public License for more details.
+
+	You should have received a copy of the GNU Lesser General Public
+	License along with this library; if not, write to the Free Software
+	Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+	Sam Lantinga
+	slouken@libsdl.org
+*/
+
+#include "SDL_config.h"
+
+/* SDL fbcon video driver implementation based on dummy, ps3 video driver
+ * and sourcecode of the fbcon implementation in sdl-1.2
+ *
+ * Initial work by Ryan C. Gordon (icculus@icculus.org). A good portion
+ *  of this was cut-and-pasted from Stephane Peter's work in the AAlib
+ *  SDL video driver.  Renamed to "DUMMY" by Sam Lantinga.
+ */
+
+#include "SDL_video.h"
+#include "../SDL_sysvideo.h"
+
+#include "SDL_fbvideo.h"
+#include "SDL_fbevents_c.h"
+#include "SDL_fbrender_c.h"
+#include "SDL_fbmodes_c.h"
+
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+
+#ifndef HAVE_GETPAGESIZE
+	#include <asm/page.h>           /* For definition of PAGE_SIZE */
+#endif
+
+#include <linux/vt.h>
+
+#define FBVID_DRIVER_NAME "fbcon"
+
+/* Initialization/Query functions */
+static int FB_VideoInit(_THIS);
+static int FB_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
+static void FB_VideoQuit(_THIS);
+
+/* bootstrap functions */
+static int
+FB_Available(void)
+{
+	deprintf(1, "+FB_Available()\n");
+	const char *envr = SDL_getenv("SDL_VIDEODRIVER");
+	if ((envr) && (SDL_strcmp(envr, FBVID_DRIVER_NAME) == 0)) {
+		return (1);
+	}
+
+    int console = -1;
+    /* Added check for /fb/0 (devfs) */
+    /* but - use environment variable first... if it fails, still check defaults */
+    int idx = 0;
+    const char *SDL_fbdevs[4] = { NULL, "/dev/fb0", "/dev/fb/0", NULL };
+
+    SDL_fbdevs[0] = SDL_getenv("SDL_FBDEV");
+    if (!SDL_fbdevs[0]) {
+        idx++;
+	}
+    for (; SDL_fbdevs[idx]; idx++) {
+        console = open(SDL_fbdevs[idx], O_RDWR, 0);
+        if (console >= 0) {
+            close(console);
+            break;
+        }
+    }
+	deprintf(1, "-FB_Available()\n");
+    return (console >= 0);
+}
+
+static void
+FB_DeleteDevice(SDL_VideoDevice * device)
+{
+	deprintf(1, "+FB_DeleteDevice()\n");
+	SDL_free(device->driverdata);
+	SDL_free(device);
+	deprintf(1, "-FB_DeleteDevice()\n");
+}
+
+static SDL_VideoDevice *
+FB_CreateDevice(int devindex)
+{
+	deprintf(1, "+FB_CreateDevice()\n");
+    SDL_VideoDevice *device;
+    SDL_VideoData *data;
+
+    /* Initialize all variables that we clean on shutdown */
+    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
+    if (!device) {
+        SDL_OutOfMemory();
+        if (device) {
+            SDL_free(device);
+        }
+        return (0);
+    }
+    data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
+    if (!data) {
+        SDL_OutOfMemory();
+        SDL_free(device);
+        return (0);
+    }
+    device->driverdata = data;
+
+    /* Set the function pointers */
+    device->VideoInit = FB_VideoInit;
+    device->VideoQuit = FB_VideoQuit;
+    device->SetDisplayMode = FB_SetDisplayMode;
+    device->PumpEvents = FB_PumpEvents;
+
+    device->free = FB_DeleteDevice;
+
+    deprintf(1, "-FB_CreateDevice()\n");
+    return device;
+}
+
+VideoBootStrap FB_bootstrap = {
+	FBVID_DRIVER_NAME, "Linux framebuffer video driver",
+	FB_Available, FB_CreateDevice
+};
+
+int
+FB_VideoInit(_THIS)
+{
+    deprintf(1, "+FB_VideoInit()\n");
+    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
+	SDL_DisplayMode mode;
+    struct fb_fix_screeninfo finfo;
+    const char *SDL_fbdev;
+
+    /* Initialize the library */
+    SDL_fbdev = SDL_getenv("SDL_FBDEV");
+    if (SDL_fbdev == NULL) {
+        SDL_fbdev = "/dev/fb0";
+    }
+    data->console_fd = open(SDL_fbdev, O_RDWR, 0);
+    if (data->console_fd < 0) {
+        SDL_SetError("Unable to open %s", SDL_fbdev);
+        return -1;
+    }
+#if !SDL_THREADS_DISABLED
+    /* Create the hardware surface lock mutex */
+    data->hw_lock = SDL_CreateMutex();
+    if (data->hw_lock == NULL) {
+        SDL_SetError("Unable to create lock mutex");
+        FB_VideoQuit(_this);
+        return -1;
+    }
+#endif
+
+    /* Get the type of video hardware */
+    if (ioctl(data->console_fd, FBIOGET_FSCREENINFO, &finfo) < 0) {
+        SDL_SetError("Couldn't get console hardware info");
+        FB_VideoQuit(_this);
+        return -1;
+    }
+
+	/* Use a fake 32-bpp desktop mode */
+	mode.format = SDL_PIXELFORMAT_RGB888;
+	mode.w = 1024;
+	mode.h = 768;
+	mode.refresh_rate = 0;
+	mode.driverdata = NULL;
+	SDL_AddBasicVideoDisplay(&mode);
+	SDL_AddRenderDriver(0, &SDL_FB_RenderDriver);
+
+	SDL_zero(mode);
+	SDL_AddDisplayMode(0, &mode);
+
+	/* We're done! */
+    deprintf(1, "-FB_VideoInit()\n");
+	return 0;
+}
+
+static int
+FB_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
+{
+    deprintf(1, "+FB_SetDisplayMode()\n");
+    deprintf(1, "-FB_SetDisplayMode()\n");
+	return 0;
+}
+
+void
+FB_VideoQuit(_THIS)
+{
+    deprintf(1, "+FB_VideoQuit()\n");
+    deprintf(1, "-FB_VideoQuit()\n");
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/fbcon-1.3/SDL_fbvideo.h	Sat Nov 07 11:35:19 2009 +0000
@@ -0,0 +1,65 @@
+/*
+	SDL - Simple DirectMedia Layer
+	Copyright (C) 1997-2009 Sam Lantinga
+
+	This library is free software; you can redistribute it and/or
+	modify it under the terms of the GNU Lesser General Public
+	License as published by the Free Software Foundation; either
+	version 2.1 of the License, or (at your option) any later version.
+
+	This library is distributed in the hope that it will be useful,
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+	Lesser General Public License for more details.
+
+	You should have received a copy of the GNU Lesser General Public
+	License along with this library; if not, write to the Free Software
+	Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+	Sam Lantinga
+	slouken@libsdl.org
+*/
+
+#ifndef _SDL_fbvideo_h
+#define _SDL_fbvideo_h
+
+#include <sys/types.h>
+#include <termios.h>
+#include <linux/fb.h>
+
+#include "SDL_mutex.h"
+#include "../SDL_sysvideo.h"
+
+/* Debugging
+ * 0: No debug messages
+ * 1: Video debug messages
+ */
+#define DEBUG_LEVEL 1
+
+#ifdef DEBUG_LEVEL
+#define deprintf( level, fmt, args... ) \
+	do \
+{ \
+	if ( (unsigned)(level) <= DEBUG_LEVEL ) \
+	{ \
+		fprintf( stdout, fmt, ##args ); \
+		fflush( stdout ); \
+	} \
+} while ( 0 )
+#else
+	#define deprintf( level, fmt, args... )
+#endif
+
+
+/* Private display data */
+typedef struct SDL_VideoData
+{
+    /* Framebuffer device descriptor */
+    int console_fd;
+    /* hardware surface lock mutex */
+    SDL_mutex *hw_lock;
+} SDL_VideoData;
+
+#endif /* _SDL_fbvideo_h */
+
+/* vi: set ts=4 sw=4 expandtab: */