hook into SDL
authornotaz <notasas@gmail.com>
Sat, 13 Nov 2010 21:00:37 +0000 (23:00 +0200)
committernotaz <notasas@gmail.com>
Sat, 13 Nov 2010 21:00:37 +0000 (23:00 +0200)
configure.in
include/SDL_config.h.in
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/omapdss/sdlif.c [new file with mode: 0644]

index a7e9b18..478014b 100644 (file)
@@ -1606,6 +1606,24 @@ AC_HELP_STRING([--enable-video-gem], [use Atari Gem video driver [[default=yes]]
     fi
 }
 
+dnl OMAP
+CheckOMAPDSS()
+{
+    AC_ARG_ENABLE(video-omapdss,
+AC_HELP_STRING([--enable-video-omapdss], [use OMAP DSS2 video driver [[default=yes]]]),
+        , enable_video_omapdss=yes)
+
+    if test x$enable_video_omapdss = xyes; then
+        AC_DEFINE(SDL_VIDEO_DRIVER_OMAPDSS)
+        SOURCES="$SOURCES $srcdir/src/video/omapdss/sdlif.c"
+        SOURCES="$SOURCES $srcdir/src/video/omapdss/osdl_input.c"
+        SOURCES="$SOURCES $srcdir/src/video/omapdss/config.c"
+        SOURCES="$SOURCES $srcdir/src/video/omapdss/linux/fbdev.c"
+        SOURCES="$SOURCES $srcdir/src/video/omapdss/linux/oshide.c"
+        have_video=yes
+    fi
+}
+
 dnl rcg04172001 Set up the Null video driver.
 CheckDummyVideo()
 {
@@ -2341,6 +2359,7 @@ case "$host" in
         CheckClockGettime
         CheckLinuxVersion
         CheckRPATH
+        CheckOMAPDSS
         # Set up files for the audio library
         if test x$enable_audio = xyes; then
           case $ARCH in
index 58593ca..361c3ef 100644 (file)
 #undef SDL_VIDEO_DRIVER_GGI
 #undef SDL_VIDEO_DRIVER_IPOD
 #undef SDL_VIDEO_DRIVER_NANOX
+#undef SDL_VIDEO_DRIVER_OMAPDSS
 #undef SDL_VIDEO_DRIVER_OS2FS
 #undef SDL_VIDEO_DRIVER_PHOTON
 #undef SDL_VIDEO_DRIVER_PICOGUI
index 1c72e09..b02acde 100644 (file)
@@ -410,6 +410,9 @@ extern VideoBootStrap AALIB_bootstrap;
 #if SDL_VIDEO_DRIVER_CACA
 extern VideoBootStrap CACA_bootstrap;
 #endif
+#if SDL_VIDEO_DRIVER_OMAPDSS
+extern VideoBootStrap omapdss_bootstrap;
+#endif
 #if SDL_VIDEO_DRIVER_DUMMY
 extern VideoBootStrap DUMMY_bootstrap;
 #endif
index e84ef35..9efab7a 100644 (file)
@@ -126,6 +126,9 @@ static VideoBootStrap *bootstrap[] = {
 #if SDL_VIDEO_DRIVER_CACA
        &CACA_bootstrap,
 #endif
+#if SDL_VIDEO_DRIVER_OMAPDSS
+       &omapdss_bootstrap,
+#endif
 #if SDL_VIDEO_DRIVER_DUMMY
        &DUMMY_bootstrap,
 #endif
diff --git a/src/video/omapdss/sdlif.c b/src/video/omapdss/sdlif.c
new file mode 100644 (file)
index 0000000..dc97a0a
--- /dev/null
@@ -0,0 +1,227 @@
+/*
+ * (C) GraÅžvydas "notaz" Ignotas, 2010
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include <stdlib.h>
+
+#include "../SDL_sysvideo.h"
+#include "../SDL_pixels_c.h"
+#include "../../events/SDL_events_c.h"
+#include "linux/fbdev.h"
+#include "linux/oshide.h"
+#include "omapsdl.h"
+
+
+struct SDL_PrivateVideoData {
+       struct vout_fbdev *fbdev;
+//     void *fbmem;
+};
+
+static int omap_available(void) 
+{
+       trace();
+       return 1;
+}
+
+static void omap_free(SDL_VideoDevice *device)
+{
+       trace();
+       free(device);
+}
+
+static int omap_VideoInit(SDL_VideoDevice *this, SDL_PixelFormat *vformat)
+{
+       trace();
+
+       // default to 16bpp
+       vformat->BitsPerPixel = 16;
+
+       omapsdl_input_init();
+       omapsdl_config();
+
+       return 0;
+}
+
+static void omap_VideoQuit(SDL_VideoDevice *this)
+{
+       trace();
+
+       if (this->hidden->fbdev != NULL) {
+               vout_fbdev_finish(this->hidden->fbdev);
+               this->hidden->fbdev = NULL;
+
+               oshide_finish();
+       }
+       this->screen->pixels = NULL;
+}
+
+static SDL_Rect **omap_ListModes(SDL_VideoDevice *this, SDL_PixelFormat *format, Uint32 flags)
+{
+       static SDL_Rect omap_mode_list[] = {
+               // XXX: we are not really restricted to fixed modes
+               // FIXME: should really check the display for max supported
+               { 0, 0, 800, 480 },
+               { 0, 0, 720, 480 },
+               { 0, 0, 640, 480 },
+               { 0, 0, 640, 400 },
+               { 0, 0, 512, 384 },
+               { 0, 0, 320, 240 },
+               { 0, 0, 320, 200 },
+       };
+       // broken API needs this
+       static SDL_Rect *omap_modes[] = {
+               &omap_mode_list[0],
+               &omap_mode_list[1],
+               &omap_mode_list[2],
+               &omap_mode_list[3],
+               &omap_mode_list[4],
+               &omap_mode_list[5],
+               &omap_mode_list[6],
+               NULL
+       };
+
+       trace();
+
+       if (format->BitsPerPixel <= 8)
+               // not (yet?) supported
+               return NULL;
+
+       return omap_modes;
+}
+
+static SDL_Surface *omap_SetVideoMode(SDL_VideoDevice *this, SDL_Surface *current, int width,
+                                       int height, int bpp, Uint32 flags)
+{
+       trace("%d, %d, %d, %08x", width, height, bpp, flags);
+
+       if (this->hidden->fbdev == NULL) {
+               this->hidden->fbdev = vout_fbdev_init("/dev/fb0", &width, &height, 0);
+               if (this->hidden->fbdev == NULL)
+                       return NULL;
+
+               oshide_init();
+       }
+       else {
+               if (vout_fbdev_resize(this->hidden->fbdev, width, height, 0, 0, 0, 0, 0) < 0)
+                       return NULL;
+       }
+
+       if (!SDL_ReallocFormat(current, 16, 0xf800, 0x07e0, 0x001f, 0))
+               return NULL;
+
+       current->flags = SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWSURFACE;
+       current->w = width;
+       current->h = height;
+       current->pitch = SDL_CalculatePitch(current);
+
+       current->pixels = vout_fbdev_flip(this->hidden->fbdev);
+
+       return current;
+}
+
+static void *flip_it(struct vout_fbdev *fbdev)
+{
+       if (gcfg_force_vsync)
+               vout_fbdev_wait_vsync(fbdev);
+
+       return vout_fbdev_flip(fbdev);
+}
+
+static int omap_LockHWSurface(SDL_VideoDevice *this, SDL_Surface *surface)
+{
+       trace("%p", surface);
+
+       return 0;
+}
+
+static void omap_UnlockHWSurface(SDL_VideoDevice *this, SDL_Surface *surface)
+{
+       trace("%p", surface);
+}
+
+static int omap_FlipHWSurface(SDL_VideoDevice *this, SDL_Surface *surface)
+{
+       trace("%p", surface);
+
+       surface->pixels = flip_it(this->hidden->fbdev);
+
+       return 0;
+}
+
+static int omap_SetColors(SDL_VideoDevice *this, int firstcolor, int ncolors, SDL_Color *colors)
+{
+       trace("%d, %d, %p", firstcolor, ncolors, colors);
+       return 0;
+}
+
+static void omap_UpdateRects(SDL_VideoDevice *this, int nrects, SDL_Rect *rects)
+{
+       trace("%d, %p", nrects, rects);
+
+       if (nrects != 1 || rects->x != 0 || rects->y != 0 ||
+                       rects->w != this->screen->w || rects->h != this->screen->h) {
+               static int warned = 0;
+               if (!warned) {
+                       not_supported();
+                       warned = 1;
+               }
+       }
+
+       if (this->hidden->fbdev)
+               this->screen->pixels = flip_it(this->hidden->fbdev);
+}
+
+static void omap_InitOSKeymap(SDL_VideoDevice *this)
+{
+       trace();
+}
+
+static int event_cb(void *cb_arg, int sdl_kc, int is_pressed)
+{
+       SDL_keysym keysym = { 0, };
+
+       keysym.sym = sdl_kc;
+       SDL_PrivateKeyboard(is_pressed, &keysym);
+}
+
+static void omap_PumpEvents(SDL_VideoDevice *this) 
+{
+       trace();
+
+       omapsdl_input_get_events(0, event_cb, NULL);
+}
+
+static SDL_VideoDevice *omap_create(int devindex)
+{
+       SDL_VideoDevice *this;
+
+       this = calloc(1, sizeof(*this) + sizeof(*this->hidden));
+       if (this == NULL) {
+               SDL_OutOfMemory();
+               return 0;
+       }
+       this->hidden = (void *)(this + 1);
+       this->VideoInit = omap_VideoInit;
+       this->ListModes = omap_ListModes;
+       this->SetVideoMode = omap_SetVideoMode;
+       this->LockHWSurface = omap_LockHWSurface;
+       this->UnlockHWSurface = omap_UnlockHWSurface;
+       this->FlipHWSurface = omap_FlipHWSurface;
+       this->SetColors = omap_SetColors;
+       this->UpdateRects = omap_UpdateRects;
+       this->VideoQuit = omap_VideoQuit;
+       this->InitOSKeymap = omap_InitOSKeymap;
+       this->PumpEvents = omap_PumpEvents;
+       this->free = omap_free;
+
+       return this;
+}
+
+VideoBootStrap omapdss_bootstrap = {
+       "omapdss", "OMAP DSS2 Framebuffer Driver",
+       omap_available, omap_create
+};
+