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 315830f3b987fec3
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
     1.1 --- a/Makefile.in	Thu Aug 27 11:33:56 2009 +0000
     1.2 +++ b/Makefile.in	Sat Nov 07 11:35:19 2009 +0000
     1.3 @@ -43,7 +43,7 @@
     1.4  # SPU programs
     1.5  SPU_GCC = @SPU_GCC@
     1.6  EMBEDSPU = @EMBEDSPU@
     1.7 -include $(srcdir)/src/video/ps3/spulibs/Makefile
     1.8 +#include $(srcdir)/src/video/ps3/spulibs/Makefile
     1.9  
    1.10  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
    1.11  
     2.1 --- a/configure.in	Thu Aug 27 11:33:56 2009 +0000
     2.2 +++ b/configure.in	Sat Nov 07 11:35:19 2009 +0000
     2.3 @@ -936,18 +936,18 @@
     2.4  
     2.5  
     2.6  dnl Do the iPod thing
     2.7 -CheckIPod()
     2.8 -{
     2.9 -    AC_ARG_ENABLE(ipod,
    2.10 -AC_HELP_STRING([--enable-ipod], [configure SDL to work with iPodLinux [default=yes on arm-elf]]),
    2.11 -        , enable_ipod=yes)
    2.12 -
    2.13 -    if test x$enable_ipod = xyes; then
    2.14 -        EXTRA_CFLAGS="$EXTRA_CFLAGS -DIPOD"
    2.15 -        AC_DEFINE(SDL_VIDEO_DRIVER_IPOD)
    2.16 -        SOURCES="$SOURCES $srcdir/src/video/ipod/*.c"
    2.17 -    fi
    2.18 -}
    2.19 +#CheckIPod()
    2.20 +#{
    2.21 +#    AC_ARG_ENABLE(ipod,
    2.22 +#AC_HELP_STRING([--enable-ipod], [configure SDL to work with iPodLinux [default=yes on arm-elf]]),
    2.23 +#        , enable_ipod=yes)
    2.24 +#
    2.25 +#    if test x$enable_ipod = xyes; then
    2.26 +#        EXTRA_CFLAGS="$EXTRA_CFLAGS -DIPOD"
    2.27 +#        AC_DEFINE(SDL_VIDEO_DRIVER_IPOD)
    2.28 +#        SOURCES="$SOURCES $srcdir/src/video/ipod/*.c"
    2.29 +#    fi
    2.30 +#}
    2.31  
    2.32  dnl Find the nanox include and library directories
    2.33  CheckNANOX()
    2.34 @@ -1349,7 +1349,7 @@
    2.35          if test x$video_fbcon = xyes; then
    2.36              AC_CHECK_FUNCS(getpagesize)
    2.37              AC_DEFINE(SDL_VIDEO_DRIVER_FBCON)
    2.38 -            SOURCES="$SOURCES $srcdir/src/video/fbcon/*.c"
    2.39 +            SOURCES="$SOURCES $srcdir/src/video/fbcon-1.3/*.c"
    2.40              have_video=yes
    2.41          fi
    2.42      fi
    2.43 @@ -2372,7 +2372,7 @@
    2.44      arm-*-elf*) # FIXME: Can we get more specific for iPodLinux?
    2.45          ARCH=linux
    2.46          CheckDummyVideo
    2.47 -        CheckIPod
    2.48 +        #CheckIPod
    2.49          # Set up files for the timer library
    2.50          if test x$enable_timers = xyes; then
    2.51              AC_DEFINE(SDL_TIMER_UNIX)
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/src/video/fbcon-1.3/SDL_fbevents.c	Sat Nov 07 11:35:19 2009 +0000
     3.3 @@ -0,0 +1,36 @@
     3.4 +/*
     3.5 +    SDL - Simple DirectMedia Layer
     3.6 +    Copyright (C) 1997-2009 Sam Lantinga
     3.7 +
     3.8 +    This library is free software; you can redistribute it and/or
     3.9 +    modify it under the terms of the GNU Lesser General Public
    3.10 +    License as published by the Free Software Foundation; either
    3.11 +    version 2.1 of the License, or (at your option) any later version.
    3.12 +
    3.13 +    This library is distributed in the hope that it will be useful,
    3.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    3.16 +    Lesser General Public License for more details.
    3.17 +
    3.18 +    You should have received a copy of the GNU Lesser General Public
    3.19 +    License along with this library; if not, write to the Free Software
    3.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    3.21 +
    3.22 +    Sam Lantinga
    3.23 +    slouken@libsdl.org
    3.24 +*/
    3.25 +#include "SDL_config.h"
    3.26 +
    3.27 +#include "../../events/SDL_sysevents.h"
    3.28 +#include "../../events/SDL_events_c.h"
    3.29 +
    3.30 +#include "SDL_fbvideo.h"
    3.31 +#include "SDL_fbevents_c.h"
    3.32 +
    3.33 +void
    3.34 +FB_PumpEvents(_THIS)
    3.35 +{
    3.36 +    /* do nothing. */
    3.37 +}
    3.38 +
    3.39 +/* vi: set ts=4 sw=4 expandtab: */
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/video/fbcon-1.3/SDL_fbevents_c.h	Sat Nov 07 11:35:19 2009 +0000
     4.3 @@ -0,0 +1,28 @@
     4.4 +/*
     4.5 +    SDL - Simple DirectMedia Layer
     4.6 +    Copyright (C) 1997-2009 Sam Lantinga
     4.7 +
     4.8 +    This library is free software; you can redistribute it and/or
     4.9 +    modify it under the terms of the GNU Lesser General Public
    4.10 +    License as published by the Free Software Foundation; either
    4.11 +    version 2.1 of the License, or (at your option) any later version.
    4.12 +
    4.13 +    This library is distributed in the hope that it will be useful,
    4.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    4.16 +    Lesser General Public License for more details.
    4.17 +
    4.18 +    You should have received a copy of the GNU Lesser General Public
    4.19 +    License along with this library; if not, write to the Free Software
    4.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    4.21 +
    4.22 +    Sam Lantinga
    4.23 +    slouken@libsdl.org
    4.24 +*/
    4.25 +#include "SDL_config.h"
    4.26 +
    4.27 +#include "SDL_fbvideo.h"
    4.28 +
    4.29 +extern void FB_PumpEvents(_THIS);
    4.30 +
    4.31 +/* vi: set ts=4 sw=4 expandtab: */
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/video/fbcon-1.3/SDL_fbmodes.c	Sat Nov 07 11:35:19 2009 +0000
     5.3 @@ -0,0 +1,141 @@
     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 +#include "SDL_ps3video.h"
    5.28 +
    5.29 +void
    5.30 +PS3_InitModes(_THIS)
    5.31 +{
    5.32 +    deprintf(1, "+PS3_InitModes()\n");
    5.33 +    SDL_VideoDisplay display;
    5.34 +    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    5.35 +    SDL_DisplayMode mode;
    5.36 +    PS3_DisplayModeData *modedata;
    5.37 +    unsigned long vid = 0;
    5.38 +
    5.39 +    modedata = (PS3_DisplayModeData *) SDL_malloc(sizeof(*modedata));
    5.40 +    if (!modedata) {
    5.41 +        return;
    5.42 +    }
    5.43 +
    5.44 +    /* Setting up the DisplayMode based on current settings */
    5.45 +    struct ps3fb_ioctl_res res;
    5.46 +    if (ioctl(data->fbdev, PS3FB_IOCTL_SCREENINFO, &res)) {
    5.47 +        SDL_SetError("Can't get PS3FB_IOCTL_SCREENINFO");
    5.48 +    }
    5.49 +    mode.format = SDL_PIXELFORMAT_RGB888;
    5.50 +    mode.refresh_rate = 0;
    5.51 +    mode.w = res.xres;
    5.52 +    mode.h = res.yres;
    5.53 +
    5.54 +    /* Setting up driver specific mode data,
    5.55 +     * Get the current ps3 specific videmode number */
    5.56 +    if (ioctl(data->fbdev, PS3FB_IOCTL_GETMODE, (unsigned long)&vid)) {
    5.57 +        SDL_SetError("Can't get PS3FB_IOCTL_GETMODE");
    5.58 +    }
    5.59 +    deprintf(2, "PS3FB_IOCTL_GETMODE = %u\n", vid);
    5.60 +    modedata->mode = vid;
    5.61 +    mode.driverdata = modedata;
    5.62 +
    5.63 +    /* Set display's videomode and add it */
    5.64 +    SDL_zero(display);
    5.65 +    display.desktop_mode = mode;
    5.66 +    display.current_mode = mode;
    5.67 +
    5.68 +    SDL_AddVideoDisplay(&display);
    5.69 +    deprintf(1, "-PS3_InitModes()\n");
    5.70 +}
    5.71 +
    5.72 +/* DisplayModes available on the PS3 */
    5.73 +static SDL_DisplayMode ps3fb_modedb[] = {
    5.74 +    /* VESA */
    5.75 +    {SDL_PIXELFORMAT_RGB888, 1280, 768, 0, NULL}, // WXGA
    5.76 +    {SDL_PIXELFORMAT_RGB888, 1280, 1024, 0, NULL}, // SXGA
    5.77 +    {SDL_PIXELFORMAT_RGB888, 1920, 1200, 0, NULL}, // WUXGA
    5.78 +    /* Native resolutions (progressive, "fullscreen") */
    5.79 +    {SDL_PIXELFORMAT_RGB888, 720, 480, 0, NULL}, // 480p
    5.80 +    {SDL_PIXELFORMAT_RGB888, 1280, 720, 0, NULL}, // 720p
    5.81 +    {SDL_PIXELFORMAT_RGB888, 1920, 1080, 0, NULL} // 1080p
    5.82 +};
    5.83 +
    5.84 +/* PS3 videomode number according to ps3fb_modedb */
    5.85 +static PS3_DisplayModeData ps3fb_data[] = {
    5.86 +    {11}, {12}, {13}, {130}, {131}, {133}, 
    5.87 +};
    5.88 +
    5.89 +void
    5.90 +PS3_GetDisplayModes(_THIS) {
    5.91 +    deprintf(1, "+PS3_GetDisplayModes()\n");
    5.92 +    SDL_DisplayMode mode;
    5.93 +    unsigned int nummodes;
    5.94 +
    5.95 +    nummodes = sizeof(ps3fb_modedb) / sizeof(SDL_DisplayMode);
    5.96 +
    5.97 +    int n;
    5.98 +    for (n=0; n<nummodes; ++n) {
    5.99 +        /* Get driver specific mode data */
   5.100 +        ps3fb_modedb[n].driverdata = &ps3fb_data[n];
   5.101 +
   5.102 +        /* Add DisplayMode to list */
   5.103 +        deprintf(2, "Adding resolution %u x %u\n", ps3fb_modedb[n].w, ps3fb_modedb[n].h);
   5.104 +        SDL_AddDisplayMode(_this->current_display, &ps3fb_modedb[n]);
   5.105 +    }
   5.106 +    deprintf(1, "-PS3_GetDisplayModes()\n");
   5.107 +}
   5.108 +
   5.109 +int
   5.110 +PS3_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
   5.111 +{
   5.112 +    deprintf(1, "+PS3_SetDisplayMode()\n");
   5.113 +    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   5.114 +    PS3_DisplayModeData *dispdata = (PS3_DisplayModeData *) mode->driverdata;
   5.115 +
   5.116 +    /* Set the new DisplayMode */
   5.117 +    deprintf(2, "Setting PS3FB_MODE to %u\n", dispdata->mode);
   5.118 +    if (ioctl(data->fbdev, PS3FB_IOCTL_SETMODE, (unsigned long)&dispdata->mode)) {
   5.119 +        deprintf(2, "Could not set PS3FB_MODE\n");
   5.120 +        SDL_SetError("Could not set PS3FB_MODE\n");
   5.121 +        return -1;
   5.122 +    }
   5.123 +
   5.124 +    deprintf(1, "-PS3_SetDisplayMode()\n");
   5.125 +    return 0;
   5.126 +}
   5.127 +
   5.128 +void
   5.129 +PS3_QuitModes(_THIS) {
   5.130 +    deprintf(1, "+PS3_QuitModes()\n");
   5.131 +
   5.132 +    /* There was no mem allocated for driverdata */
   5.133 +    int i, j;
   5.134 +    for (i = _this->num_displays; i--;) {
   5.135 +        SDL_VideoDisplay *display = &_this->displays[i];
   5.136 +        for (j = display->num_display_modes; j--;) {
   5.137 +            display->display_modes[j].driverdata = NULL;
   5.138 +        }
   5.139 +    }
   5.140 +
   5.141 +    deprintf(1, "-PS3_QuitModes()\n");
   5.142 +}
   5.143 +
   5.144 +/* vi: set ts=4 sw=4 expandtab: */
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/src/video/fbcon-1.3/SDL_fbmodes_c.h	Sat Nov 07 11:35:19 2009 +0000
     6.3 @@ -0,0 +1,34 @@
     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 +#ifndef _SDL_ps3modes_h
    6.28 +#define _SDL_ps3modes_h
    6.29 +
    6.30 +extern void PS3_InitModes(_THIS);
    6.31 +extern void PS3_GetDisplayModes(_THIS);
    6.32 +extern int PS3_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
    6.33 +extern void PS3_QuitModes(_THIS);
    6.34 +
    6.35 +#endif /* SDL_ps3modes_h */
    6.36 +
    6.37 +/* vi: set ts=4 sw=4 expandtab: */
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/src/video/fbcon-1.3/SDL_fbrender.c	Sat Nov 07 11:35:19 2009 +0000
     7.3 @@ -0,0 +1,269 @@
     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 "SDL_video.h"
    7.28 +#include "../SDL_sysvideo.h"
    7.29 +#include "../SDL_yuv_sw_c.h"
    7.30 +#include "../SDL_renderer_sw.h"
    7.31 +
    7.32 +
    7.33 +/* SDL surface based renderer implementation */
    7.34 +
    7.35 +static SDL_Renderer *SDL_FB_CreateRenderer(SDL_Window * window,
    7.36 +                                              Uint32 flags);
    7.37 +static int SDL_FB_RenderPoint(SDL_Renderer * renderer, int x, int y);
    7.38 +static int SDL_FB_RenderLine(SDL_Renderer * renderer, int x1, int y1,
    7.39 +                                int x2, int y2);
    7.40 +static int SDL_FB_RenderFill(SDL_Renderer * renderer,
    7.41 +                                const SDL_Rect * rect);
    7.42 +static int SDL_FB_RenderCopy(SDL_Renderer * renderer,
    7.43 +                                SDL_Texture * texture,
    7.44 +                                const SDL_Rect * srcrect,
    7.45 +                                const SDL_Rect * dstrect);
    7.46 +static void SDL_FB_RenderPresent(SDL_Renderer * renderer);
    7.47 +static void SDL_FB_DestroyRenderer(SDL_Renderer * renderer);
    7.48 +
    7.49 +
    7.50 +SDL_RenderDriver SDL_FB_RenderDriver = {
    7.51 +    SDL_FB_CreateRenderer,
    7.52 +    {
    7.53 +     "fbcon",
    7.54 +     (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
    7.55 +      SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
    7.56 +      SDL_RENDERER_PRESENTDISCARD),
    7.57 +     }
    7.58 +};
    7.59 +
    7.60 +typedef struct
    7.61 +{
    7.62 +    int current_screen;
    7.63 +    SDL_Surface *screens[3];
    7.64 +} SDL_FB_RenderData;
    7.65 +
    7.66 +SDL_Renderer *
    7.67 +SDL_FB_CreateRenderer(SDL_Window * window, Uint32 flags)
    7.68 +{
    7.69 +    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
    7.70 +    SDL_DisplayMode *displayMode = &display->current_mode;
    7.71 +    SDL_Renderer *renderer;
    7.72 +    SDL_FB_RenderData *data;
    7.73 +    int i, n;
    7.74 +    int bpp;
    7.75 +    Uint32 Rmask, Gmask, Bmask, Amask;
    7.76 +
    7.77 +    if (!SDL_PixelFormatEnumToMasks
    7.78 +        (displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
    7.79 +        SDL_SetError("Unknown display format");
    7.80 +        return NULL;
    7.81 +    }
    7.82 +
    7.83 +    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
    7.84 +    if (!renderer) {
    7.85 +        SDL_OutOfMemory();
    7.86 +        return NULL;
    7.87 +    }
    7.88 +
    7.89 +    data = (SDL_FB_RenderData *) SDL_malloc(sizeof(*data));
    7.90 +    if (!data) {
    7.91 +        SDL_FB_DestroyRenderer(renderer);
    7.92 +        SDL_OutOfMemory();
    7.93 +        return NULL;
    7.94 +    }
    7.95 +    SDL_zerop(data);
    7.96 +
    7.97 +    renderer->RenderPoint = SDL_FB_RenderPoint;
    7.98 +    renderer->RenderLine = SDL_FB_RenderLine;
    7.99 +    renderer->RenderFill = SDL_FB_RenderFill;
   7.100 +    renderer->RenderCopy = SDL_FB_RenderCopy;
   7.101 +    renderer->RenderPresent = SDL_FB_RenderPresent;
   7.102 +    renderer->DestroyRenderer = SDL_FB_DestroyRenderer;
   7.103 +    renderer->info.name = SDL_FB_RenderDriver.info.name;
   7.104 +    renderer->info.flags = 0;
   7.105 +    renderer->window = window->id;
   7.106 +    renderer->driverdata = data;
   7.107 +    Setup_SoftwareRenderer(renderer);
   7.108 +
   7.109 +    if (flags & SDL_RENDERER_PRESENTFLIP2) {
   7.110 +        renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
   7.111 +        n = 2;
   7.112 +    } else if (flags & SDL_RENDERER_PRESENTFLIP3) {
   7.113 +        renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
   7.114 +        n = 3;
   7.115 +    } else {
   7.116 +        renderer->info.flags |= SDL_RENDERER_PRESENTCOPY;
   7.117 +        n = 1;
   7.118 +    }
   7.119 +    for (i = 0; i < n; ++i) {
   7.120 +        data->screens[i] =
   7.121 +            SDL_CreateRGBSurface(0, window->w, window->h, bpp, Rmask, Gmask,
   7.122 +                                 Bmask, Amask);
   7.123 +        if (!data->screens[i]) {
   7.124 +            SDL_FB_DestroyRenderer(renderer);
   7.125 +            return NULL;
   7.126 +        }
   7.127 +        SDL_SetSurfacePalette(data->screens[i], display->palette);
   7.128 +    }
   7.129 +    data->current_screen = 0;
   7.130 +
   7.131 +    return renderer;
   7.132 +}
   7.133 +
   7.134 +static int
   7.135 +SDL_FB_RenderPoint(SDL_Renderer * renderer, int x, int y)
   7.136 +{
   7.137 +    SDL_FB_RenderData *data =
   7.138 +        (SDL_FB_RenderData *) renderer->driverdata;
   7.139 +    SDL_Surface *target = data->screens[data->current_screen];
   7.140 +    int status;
   7.141 +
   7.142 +    if (renderer->blendMode == SDL_BLENDMODE_NONE ||
   7.143 +        renderer->blendMode == SDL_BLENDMODE_MASK) {
   7.144 +        Uint32 color =
   7.145 +            SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b,
   7.146 +                        renderer->a);
   7.147 +
   7.148 +        status = SDL_DrawPoint(target, x, y, color);
   7.149 +    } else {
   7.150 +        status =
   7.151 +            SDL_BlendPoint(target, x, y, renderer->blendMode, renderer->r,
   7.152 +                           renderer->g, renderer->b, renderer->a);
   7.153 +    }
   7.154 +    return status;
   7.155 +}
   7.156 +
   7.157 +static int
   7.158 +SDL_FB_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
   7.159 +{
   7.160 +    SDL_FB_RenderData *data =
   7.161 +        (SDL_FB_RenderData *) renderer->driverdata;
   7.162 +    SDL_Surface *target = data->screens[data->current_screen];
   7.163 +    int status;
   7.164 +
   7.165 +    if (renderer->blendMode == SDL_BLENDMODE_NONE ||
   7.166 +        renderer->blendMode == SDL_BLENDMODE_MASK) {
   7.167 +        Uint32 color =
   7.168 +            SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b,
   7.169 +                        renderer->a);
   7.170 +
   7.171 +        status = SDL_DrawLine(target, x1, y1, x2, y2, color);
   7.172 +    } else {
   7.173 +        status =
   7.174 +            SDL_BlendLine(target, x1, y1, x2, y2, renderer->blendMode,
   7.175 +                          renderer->r, renderer->g, renderer->b, renderer->a);
   7.176 +    }
   7.177 +    return status;
   7.178 +}
   7.179 +
   7.180 +static int
   7.181 +SDL_FB_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect)
   7.182 +{
   7.183 +    SDL_FB_RenderData *data =
   7.184 +        (SDL_FB_RenderData *) renderer->driverdata;
   7.185 +    SDL_Surface *target = data->screens[data->current_screen];
   7.186 +    SDL_Rect real_rect = *rect;
   7.187 +    int status;
   7.188 +
   7.189 +    if (renderer->blendMode == SDL_BLENDMODE_NONE) {
   7.190 +        Uint32 color =
   7.191 +            SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b,
   7.192 +                        renderer->a);
   7.193 +
   7.194 +        status = SDL_FillRect(target, &real_rect, color);
   7.195 +    } else {
   7.196 +        status =
   7.197 +            SDL_BlendRect(target, &real_rect, renderer->blendMode,
   7.198 +                          renderer->r, renderer->g, renderer->b, renderer->a);
   7.199 +    }
   7.200 +    return status;
   7.201 +}
   7.202 +
   7.203 +static int
   7.204 +SDL_FB_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
   7.205 +                     const SDL_Rect * srcrect, const SDL_Rect * dstrect)
   7.206 +{
   7.207 +    SDL_FB_RenderData *data =
   7.208 +        (SDL_FB_RenderData *) renderer->driverdata;
   7.209 +    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
   7.210 +    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
   7.211 +
   7.212 +    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
   7.213 +        SDL_Surface *target = data->screens[data->current_screen];
   7.214 +        void *pixels =
   7.215 +            (Uint8 *) target->pixels + dstrect->y * target->pitch +
   7.216 +            dstrect->x * target->format->BytesPerPixel;
   7.217 +        return SDL_SW_CopyYUVToRGB((SDL_SW_YUVTexture *) texture->driverdata,
   7.218 +                                   srcrect, display->current_mode.format,
   7.219 +                                   dstrect->w, dstrect->h, pixels,
   7.220 +                                   target->pitch);
   7.221 +    } else {
   7.222 +        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
   7.223 +        SDL_Surface *target = data->screens[data->current_screen];
   7.224 +        SDL_Rect real_srcrect = *srcrect;
   7.225 +        SDL_Rect real_dstrect = *dstrect;
   7.226 +
   7.227 +        return SDL_LowerBlit(surface, &real_srcrect, target, &real_dstrect);
   7.228 +    }
   7.229 +}
   7.230 +
   7.231 +static void
   7.232 +SDL_FB_RenderPresent(SDL_Renderer * renderer)
   7.233 +{
   7.234 +    static int frame_number;
   7.235 +    SDL_FB_RenderData *data =
   7.236 +        (SDL_FB_RenderData *) renderer->driverdata;
   7.237 +
   7.238 +    /* Send the data to the display */
   7.239 +    if (SDL_getenv("SDL_VIDEO_FB_SAVE_FRAMES")) {
   7.240 +        char file[128];
   7.241 +        SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp",
   7.242 +                     renderer->window, ++frame_number);
   7.243 +        SDL_SaveBMP(data->screens[data->current_screen], file);
   7.244 +    }
   7.245 +
   7.246 +    /* Update the flipping chain, if any */
   7.247 +    if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) {
   7.248 +        data->current_screen = (data->current_screen + 1) % 2;
   7.249 +    } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) {
   7.250 +        data->current_screen = (data->current_screen + 1) % 3;
   7.251 +    }
   7.252 +}
   7.253 +
   7.254 +static void
   7.255 +SDL_FB_DestroyRenderer(SDL_Renderer * renderer)
   7.256 +{
   7.257 +    SDL_FB_RenderData *data =
   7.258 +        (SDL_FB_RenderData *) renderer->driverdata;
   7.259 +    int i;
   7.260 +
   7.261 +    if (data) {
   7.262 +        for (i = 0; i < SDL_arraysize(data->screens); ++i) {
   7.263 +            if (data->screens[i]) {
   7.264 +                SDL_FreeSurface(data->screens[i]);
   7.265 +            }
   7.266 +        }
   7.267 +        SDL_free(data);
   7.268 +    }
   7.269 +    SDL_free(renderer);
   7.270 +}
   7.271 +
   7.272 +/* vi: set ts=4 sw=4 expandtab: */
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/src/video/fbcon-1.3/SDL_fbrender_c.h	Sat Nov 07 11:35:19 2009 +0000
     8.3 @@ -0,0 +1,28 @@
     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 +/* SDL surface based renderer implementation */
    8.28 +
    8.29 +extern SDL_RenderDriver SDL_FB_RenderDriver;
    8.30 +
    8.31 +/* vi: set ts=4 sw=4 expandtab: */
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/src/video/fbcon-1.3/SDL_fbvideo.c	Sat Nov 07 11:35:19 2009 +0000
     9.3 @@ -0,0 +1,208 @@
     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 +
    9.26 +#include "SDL_config.h"
    9.27 +
    9.28 +/* SDL fbcon video driver implementation based on dummy, ps3 video driver
    9.29 + * and sourcecode of the fbcon implementation in sdl-1.2
    9.30 + *
    9.31 + * Initial work by Ryan C. Gordon (icculus@icculus.org). A good portion
    9.32 + *  of this was cut-and-pasted from Stephane Peter's work in the AAlib
    9.33 + *  SDL video driver.  Renamed to "DUMMY" by Sam Lantinga.
    9.34 + */
    9.35 +
    9.36 +#include "SDL_video.h"
    9.37 +#include "../SDL_sysvideo.h"
    9.38 +
    9.39 +#include "SDL_fbvideo.h"
    9.40 +#include "SDL_fbevents_c.h"
    9.41 +#include "SDL_fbrender_c.h"
    9.42 +#include "SDL_fbmodes_c.h"
    9.43 +
    9.44 +#include <stdio.h>
    9.45 +#include <fcntl.h>
    9.46 +#include <unistd.h>
    9.47 +#include <sys/ioctl.h>
    9.48 +#include <sys/mman.h>
    9.49 +
    9.50 +#ifndef HAVE_GETPAGESIZE
    9.51 +	#include <asm/page.h>           /* For definition of PAGE_SIZE */
    9.52 +#endif
    9.53 +
    9.54 +#include <linux/vt.h>
    9.55 +
    9.56 +#define FBVID_DRIVER_NAME "fbcon"
    9.57 +
    9.58 +/* Initialization/Query functions */
    9.59 +static int FB_VideoInit(_THIS);
    9.60 +static int FB_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
    9.61 +static void FB_VideoQuit(_THIS);
    9.62 +
    9.63 +/* bootstrap functions */
    9.64 +static int
    9.65 +FB_Available(void)
    9.66 +{
    9.67 +	deprintf(1, "+FB_Available()\n");
    9.68 +	const char *envr = SDL_getenv("SDL_VIDEODRIVER");
    9.69 +	if ((envr) && (SDL_strcmp(envr, FBVID_DRIVER_NAME) == 0)) {
    9.70 +		return (1);
    9.71 +	}
    9.72 +
    9.73 +    int console = -1;
    9.74 +    /* Added check for /fb/0 (devfs) */
    9.75 +    /* but - use environment variable first... if it fails, still check defaults */
    9.76 +    int idx = 0;
    9.77 +    const char *SDL_fbdevs[4] = { NULL, "/dev/fb0", "/dev/fb/0", NULL };
    9.78 +
    9.79 +    SDL_fbdevs[0] = SDL_getenv("SDL_FBDEV");
    9.80 +    if (!SDL_fbdevs[0]) {
    9.81 +        idx++;
    9.82 +	}
    9.83 +    for (; SDL_fbdevs[idx]; idx++) {
    9.84 +        console = open(SDL_fbdevs[idx], O_RDWR, 0);
    9.85 +        if (console >= 0) {
    9.86 +            close(console);
    9.87 +            break;
    9.88 +        }
    9.89 +    }
    9.90 +	deprintf(1, "-FB_Available()\n");
    9.91 +    return (console >= 0);
    9.92 +}
    9.93 +
    9.94 +static void
    9.95 +FB_DeleteDevice(SDL_VideoDevice * device)
    9.96 +{
    9.97 +	deprintf(1, "+FB_DeleteDevice()\n");
    9.98 +	SDL_free(device->driverdata);
    9.99 +	SDL_free(device);
   9.100 +	deprintf(1, "-FB_DeleteDevice()\n");
   9.101 +}
   9.102 +
   9.103 +static SDL_VideoDevice *
   9.104 +FB_CreateDevice(int devindex)
   9.105 +{
   9.106 +	deprintf(1, "+FB_CreateDevice()\n");
   9.107 +    SDL_VideoDevice *device;
   9.108 +    SDL_VideoData *data;
   9.109 +
   9.110 +    /* Initialize all variables that we clean on shutdown */
   9.111 +    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
   9.112 +    if (!device) {
   9.113 +        SDL_OutOfMemory();
   9.114 +        if (device) {
   9.115 +            SDL_free(device);
   9.116 +        }
   9.117 +        return (0);
   9.118 +    }
   9.119 +    data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
   9.120 +    if (!data) {
   9.121 +        SDL_OutOfMemory();
   9.122 +        SDL_free(device);
   9.123 +        return (0);
   9.124 +    }
   9.125 +    device->driverdata = data;
   9.126 +
   9.127 +    /* Set the function pointers */
   9.128 +    device->VideoInit = FB_VideoInit;
   9.129 +    device->VideoQuit = FB_VideoQuit;
   9.130 +    device->SetDisplayMode = FB_SetDisplayMode;
   9.131 +    device->PumpEvents = FB_PumpEvents;
   9.132 +
   9.133 +    device->free = FB_DeleteDevice;
   9.134 +
   9.135 +    deprintf(1, "-FB_CreateDevice()\n");
   9.136 +    return device;
   9.137 +}
   9.138 +
   9.139 +VideoBootStrap FB_bootstrap = {
   9.140 +	FBVID_DRIVER_NAME, "Linux framebuffer video driver",
   9.141 +	FB_Available, FB_CreateDevice
   9.142 +};
   9.143 +
   9.144 +int
   9.145 +FB_VideoInit(_THIS)
   9.146 +{
   9.147 +    deprintf(1, "+FB_VideoInit()\n");
   9.148 +    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   9.149 +	SDL_DisplayMode mode;
   9.150 +    struct fb_fix_screeninfo finfo;
   9.151 +    const char *SDL_fbdev;
   9.152 +
   9.153 +    /* Initialize the library */
   9.154 +    SDL_fbdev = SDL_getenv("SDL_FBDEV");
   9.155 +    if (SDL_fbdev == NULL) {
   9.156 +        SDL_fbdev = "/dev/fb0";
   9.157 +    }
   9.158 +    data->console_fd = open(SDL_fbdev, O_RDWR, 0);
   9.159 +    if (data->console_fd < 0) {
   9.160 +        SDL_SetError("Unable to open %s", SDL_fbdev);
   9.161 +        return -1;
   9.162 +    }
   9.163 +#if !SDL_THREADS_DISABLED
   9.164 +    /* Create the hardware surface lock mutex */
   9.165 +    data->hw_lock = SDL_CreateMutex();
   9.166 +    if (data->hw_lock == NULL) {
   9.167 +        SDL_SetError("Unable to create lock mutex");
   9.168 +        FB_VideoQuit(_this);
   9.169 +        return -1;
   9.170 +    }
   9.171 +#endif
   9.172 +
   9.173 +    /* Get the type of video hardware */
   9.174 +    if (ioctl(data->console_fd, FBIOGET_FSCREENINFO, &finfo) < 0) {
   9.175 +        SDL_SetError("Couldn't get console hardware info");
   9.176 +        FB_VideoQuit(_this);
   9.177 +        return -1;
   9.178 +    }
   9.179 +
   9.180 +	/* Use a fake 32-bpp desktop mode */
   9.181 +	mode.format = SDL_PIXELFORMAT_RGB888;
   9.182 +	mode.w = 1024;
   9.183 +	mode.h = 768;
   9.184 +	mode.refresh_rate = 0;
   9.185 +	mode.driverdata = NULL;
   9.186 +	SDL_AddBasicVideoDisplay(&mode);
   9.187 +	SDL_AddRenderDriver(0, &SDL_FB_RenderDriver);
   9.188 +
   9.189 +	SDL_zero(mode);
   9.190 +	SDL_AddDisplayMode(0, &mode);
   9.191 +
   9.192 +	/* We're done! */
   9.193 +    deprintf(1, "-FB_VideoInit()\n");
   9.194 +	return 0;
   9.195 +}
   9.196 +
   9.197 +static int
   9.198 +FB_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
   9.199 +{
   9.200 +    deprintf(1, "+FB_SetDisplayMode()\n");
   9.201 +    deprintf(1, "-FB_SetDisplayMode()\n");
   9.202 +	return 0;
   9.203 +}
   9.204 +
   9.205 +void
   9.206 +FB_VideoQuit(_THIS)
   9.207 +{
   9.208 +    deprintf(1, "+FB_VideoQuit()\n");
   9.209 +    deprintf(1, "-FB_VideoQuit()\n");
   9.210 +}
   9.211 +
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/src/video/fbcon-1.3/SDL_fbvideo.h	Sat Nov 07 11:35:19 2009 +0000
    10.3 @@ -0,0 +1,65 @@
    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 +
   10.26 +#ifndef _SDL_fbvideo_h
   10.27 +#define _SDL_fbvideo_h
   10.28 +
   10.29 +#include <sys/types.h>
   10.30 +#include <termios.h>
   10.31 +#include <linux/fb.h>
   10.32 +
   10.33 +#include "SDL_mutex.h"
   10.34 +#include "../SDL_sysvideo.h"
   10.35 +
   10.36 +/* Debugging
   10.37 + * 0: No debug messages
   10.38 + * 1: Video debug messages
   10.39 + */
   10.40 +#define DEBUG_LEVEL 1
   10.41 +
   10.42 +#ifdef DEBUG_LEVEL
   10.43 +#define deprintf( level, fmt, args... ) \
   10.44 +	do \
   10.45 +{ \
   10.46 +	if ( (unsigned)(level) <= DEBUG_LEVEL ) \
   10.47 +	{ \
   10.48 +		fprintf( stdout, fmt, ##args ); \
   10.49 +		fflush( stdout ); \
   10.50 +	} \
   10.51 +} while ( 0 )
   10.52 +#else
   10.53 +	#define deprintf( level, fmt, args... )
   10.54 +#endif
   10.55 +
   10.56 +
   10.57 +/* Private display data */
   10.58 +typedef struct SDL_VideoData
   10.59 +{
   10.60 +    /* Framebuffer device descriptor */
   10.61 +    int console_fd;
   10.62 +    /* hardware surface lock mutex */
   10.63 +    SDL_mutex *hw_lock;
   10.64 +} SDL_VideoData;
   10.65 +
   10.66 +#endif /* _SDL_fbvideo_h */
   10.67 +
   10.68 +/* vi: set ts=4 sw=4 expandtab: */