diff -urN SDL2-2.0.1/configure.in SDL2-2.0.1-patch//configure.in --- SDL2-2.0.1/configure.in 2013-10-24 05:05:29.000000000 +0100 +++ SDL2-2.0.1-patch//configure.in 2014-02-04 20:03:10.000000000 +0000 @@ -1589,6 +1589,43 @@ fi } +dnl Find Vivante EGL +CheckVivante() +{ + AC_ARG_ENABLE(video-vivante, +AC_HELP_STRING([--enable-video-vivante], [use Vivante framebuffer EGL video driver [[default=no]]]), + , enable_video_vivante=no) + if test x$enable_video = xyes -a x$enable_video_vivante = xyes; then + video_vivante=no + + AC_PATH_PROG(PKG_CONFIG, pkg-config, no) + if test x$PKG_CONFIG != xno; then + if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG egl; then + VIVANTE_CFLAGS=`$PKG_CONFIG --cflags egl` + VIVANTE_LIBS="`$PKG_CONFIG --libs egl` -DLINUX -DEGL_FB_API" + VIVANTE_PREFIX=`$PKG_CONFIG --variable=prefix egl` + + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $VIVANTE_CFLAGS" + AC_CHECK_LIB(EGL, fbGetDisplay, video_vivante=yes) + CFLAGS="$save_CFLAGS" + fi + fi + AC_MSG_CHECKING(for Vivante EGL-fb support) + AC_MSG_RESULT($video_vivante) + + if test x$video_vivante = xyes; then + AC_DEFINE(SDL_VIDEO_DRIVER_VIVANTE, 1, [ ]) + SOURCES="$SOURCES $srcdir/src/video/vivante/*.c" + EXTRA_CFLAGS="$EXTRA_CFLAGS $VIVANTE_CFLAGS" + # This is needed for the OpenGLES tests to pass. + CFLAGS="$CFLAGS $VIVANTE_CFLAGS" + + have_video=yes + fi + fi +} + dnl Find FusionSound CheckFusionSound() { @@ -2416,6 +2453,7 @@ CheckX11 CheckDirectFB CheckFusionSound + CheckVivante CheckOpenGLX11 CheckOpenGLESX11 CheckLibUDev diff -urN SDL2-2.0.1/include/SDL_config.h.in SDL2-2.0.1-patch//include/SDL_config.h.in --- SDL2-2.0.1/include/SDL_config.h.in 2013-10-24 05:05:29.000000000 +0100 +++ SDL2-2.0.1-patch//include/SDL_config.h.in 2014-02-04 20:02:23.000000000 +0000 @@ -261,6 +261,7 @@ #undef SDL_VIDEO_DRIVER_WINDOWS #undef SDL_VIDEO_DRIVER_X11 #undef SDL_VIDEO_DRIVER_RPI +#undef SDL_VIDEO_DRIVER_VIVANTE #undef SDL_VIDEO_DRIVER_X11_DYNAMIC #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR diff -urN SDL2-2.0.1/src/video/SDL_sysvideo.h SDL2-2.0.1-patch//src/video/SDL_sysvideo.h --- SDL2-2.0.1/src/video/SDL_sysvideo.h 2013-10-24 05:05:29.000000000 +0100 +++ SDL2-2.0.1-patch//src/video/SDL_sysvideo.h 2014-02-04 21:05:03.000000000 +0000 @@ -366,6 +366,9 @@ #if SDL_VIDEO_DRIVER_RPI extern VideoBootStrap RPI_bootstrap; #endif +#if SDL_VIDEO_DRIVER_VIVANTE +extern VideoBootStrap VIV_bootstrap; +#endif #if SDL_VIDEO_DRIVER_DUMMY extern VideoBootStrap DUMMY_bootstrap; #endif diff -urN SDL2-2.0.1/src/video/SDL_video.c SDL2-2.0.1-patch//src/video/SDL_video.c --- SDL2-2.0.1/src/video/SDL_video.c 2013-10-24 05:05:29.000000000 +0100 +++ SDL2-2.0.1-patch//src/video/SDL_video.c 2014-02-04 21:40:42.000000000 +0000 @@ -83,6 +83,9 @@ #if SDL_VIDEO_DRIVER_RPI &RPI_bootstrap, #endif +#if SDL_VIDEO_DRIVER_VIVANTE + &VIV_bootstrap, +#endif #if SDL_VIDEO_DRIVER_DUMMY &DUMMY_bootstrap, #endif diff -urN SDL2-2.0.1/src/video/vivante/SDL_vivevents.c SDL2-2.0.1-patch//src/video/vivante/SDL_vivevents.c --- SDL2-2.0.1/src/video/vivante/SDL_vivevents.c 1970-01-01 01:00:00.000000000 +0100 +++ SDL2-2.0.1-patch//src/video/vivante/SDL_vivevents.c 2014-02-04 20:46:14.000000000 +0000 @@ -0,0 +1,45 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_VIVANTE + +#include "../../events/SDL_sysevents.h" +#include "../../events/SDL_events_c.h" +#include "../../events/SDL_keyboard_c.h" +#include "SDL_vivvideo.h" +#include "SDL_vivevents_c.h" + +#ifdef SDL_INPUT_LINUXEV +#include "../../input/evdev/SDL_evdev.h" +#endif + +void VIV_PumpEvents(_THIS) +{ +#ifdef SDL_INPUT_LINUXEV + SDL_EVDEV_Poll(); +#endif + +} + +#endif /* SDL_VIDEO_DRIVER_VIVANTE */ + diff -urN SDL2-2.0.1/src/video/vivante/SDL_vivevents_c.h SDL2-2.0.1-patch//src/video/vivante/SDL_vivevents_c.h --- SDL2-2.0.1/src/video/vivante/SDL_vivevents_c.h 1970-01-01 01:00:00.000000000 +0100 +++ SDL2-2.0.1-patch//src/video/vivante/SDL_vivevents_c.h 2014-02-04 20:26:44.000000000 +0000 @@ -0,0 +1,31 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef _SDL_vivevents_c_h +#define _SDL_vivevents_c_h + +#include "SDL_vivvideo.h" + +void VIV_PumpEvents(_THIS); +void VIV_EventInit(_THIS); +void VIV_EventQuit(_THIS); + +#endif /* _SDL_vivevents_c_h */ diff -urN SDL2-2.0.1/src/video/vivante/SDL_vivmouse.c SDL2-2.0.1-patch//src/video/vivante/SDL_vivmouse.c --- SDL2-2.0.1/src/video/vivante/SDL_vivmouse.c 1970-01-01 01:00:00.000000000 +0100 +++ SDL2-2.0.1-patch//src/video/vivante/SDL_vivmouse.c 2014-02-04 20:26:02.000000000 +0000 @@ -0,0 +1,204 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_VIVANTE + +#include "SDL_assert.h" +#include "SDL_surface.h" + +#include "SDL_vivvideo.h" +#include "SDL_vivmouse.h" + +#include "../SDL_sysvideo.h" +#include "../../events/SDL_mouse_c.h" +#include "../../events/default_cursor.h" + +/* Copied from vc_vchi_dispmanx.h which is bugged and tries to include a non existing file */ +/* Attributes changes flag mask */ +#define ELEMENT_CHANGE_LAYER (1<<0) +#define ELEMENT_CHANGE_OPACITY (1<<1) +#define ELEMENT_CHANGE_DEST_RECT (1<<2) +#define ELEMENT_CHANGE_SRC_RECT (1<<3) +#define ELEMENT_CHANGE_MASK_RESOURCE (1<<4) +#define ELEMENT_CHANGE_TRANSFORM (1<<5) +/* End copied from vc_vchi_dispmanx.h */ + +static SDL_Cursor *VIV_CreateDefaultCursor(void); +static SDL_Cursor *VIV_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y); +static int VIV_ShowCursor(SDL_Cursor * cursor); +static void VIV_MoveCursor(SDL_Cursor * cursor); +static void VIV_FreeCursor(SDL_Cursor * cursor); +static void VIV_WarpMouse(SDL_Window * window, int x, int y); + +static SDL_Cursor * +VIV_CreateDefaultCursor(void) +{ + return SDL_CreateCursor(default_cdata, default_cmask, DEFAULT_CWIDTH, DEFAULT_CHEIGHT, DEFAULT_CHOTX, DEFAULT_CHOTY); +} + +/* Create a cursor from a surface */ +static SDL_Cursor * +VIV_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) +{ + VIV_CursorData *curdata; + SDL_Cursor *cursor; + + SDL_assert(surface->format->format == SDL_PIXELFORMAT_ARGB8888); + SDL_assert(surface->pitch == surface->w * 4); + + cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(*cursor)); + curdata = (VIV_CursorData *) SDL_calloc(1, sizeof(*curdata)); + + curdata->hot_x = hot_x; + curdata->hot_y = hot_y; + curdata->w = surface->w; + curdata->h = surface->h; + + /* TODO create cursor using Vivante APIs */ + cursor->driverdata = curdata; + + return cursor; + +} + +/* Show the specified cursor, or hide if cursor is NULL */ +static int +VIV_ShowCursor(SDL_Cursor * cursor) +{ + VIV_CursorData *curdata; + SDL_Mouse *mouse; + SDL_VideoDisplay *display; + SDL_DisplayData *data; + + mouse = SDL_GetMouse(); + if (mouse == NULL) { + return -1; + } + + if (cursor == NULL) { + /* FIXME: We hide the current mouse's cursor, what we actually need is *_HideCursor */ + + if ( mouse->cur_cursor != NULL && mouse->cur_cursor->driverdata != NULL) { + curdata = (VIV_CursorData *) mouse->cur_cursor->driverdata; +#if 0 + /* TODO hide the cursor */ + if (curdata->element > DISPMANX_NO_HANDLE) { + update = vc_dispmanx_update_start( 10 ); + SDL_assert( update ); + ret = vc_dispmanx_element_remove( update, curdata->element ); + SDL_assert( ret == DISPMANX_SUCCESS ); + ret = vc_dispmanx_update_submit_sync( update ); + SDL_assert( ret == DISPMANX_SUCCESS ); + curdata->element = DISPMANX_NO_HANDLE; + } +#endif + } + return 0; + } + + curdata = (VIV_CursorData *) cursor->driverdata; + if (curdata == NULL) { + return -1; + } + + if (mouse->focus == NULL) { + return -1; + } + + display = SDL_GetDisplayForWindow(mouse->focus); + if (display == NULL) { + return -1; + } + + data = (SDL_DisplayData*) display->driverdata; + if (data == NULL) { + return -1; + } + + /* TODO show the cursor, uning Vivante APIs */ + + return 0; +} + +/* Free a window manager cursor */ +static void +VIV_FreeCursor(SDL_Cursor * cursor) +{ + VIV_CursorData *curdata; + + if (cursor != NULL) { + curdata = (VIV_CursorData *) cursor->driverdata; + + if (curdata != NULL) { + /* TODO release memory allocated for Vivante cursor */ + + SDL_free(cursor->driverdata); + } + SDL_free(cursor); + } +} + +/* Warp the mouse to (x,y) */ +static void +VIV_WarpMouse(SDL_Window * window, int x, int y) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + + if (mouse != NULL && mouse->cur_cursor != NULL && mouse->cur_cursor->driverdata != NULL) { + /* TODO move the Vivante cursor */ + } +} + +void +VIV_InitMouse(_THIS) +{ + /* FIXME: Using UDEV it should be possible to scan all mice + * but there's no point in doing so as there's no multimice support...yet! + */ + SDL_Mouse *mouse = SDL_GetMouse(); + + mouse->CreateCursor = VIV_CreateCursor; + mouse->ShowCursor = VIV_ShowCursor; + mouse->MoveCursor = VIV_MoveCursor; + mouse->FreeCursor = VIV_FreeCursor; + mouse->WarpMouse = VIV_WarpMouse; + + SDL_SetDefaultCursor(VIV_CreateDefaultCursor()); +} + +void +VIV_QuitMouse(_THIS) +{ + +} + +/* This is called when a mouse motion event occurs */ +static void +VIV_MoveCursor(SDL_Cursor * cursor) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + VIV_WarpMouse(mouse->focus, mouse->x, mouse->y); +} + +#endif /* SDL_VIDEO_DRIVER_VIVANTE */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -urN SDL2-2.0.1/src/video/vivante/SDL_vivmouse.h SDL2-2.0.1-patch//src/video/vivante/SDL_vivmouse.h --- SDL2-2.0.1/src/video/vivante/SDL_vivmouse.h 1970-01-01 01:00:00.000000000 +0100 +++ SDL2-2.0.1-patch//src/video/vivante/SDL_vivmouse.h 2014-02-04 20:13:27.000000000 +0000 @@ -0,0 +1,41 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef _SDL_VIV_mouse_h +#define _SDL_VIV_mouse_h + +#include "../SDL_sysvideo.h" + +typedef struct _VIV_CursorData VIV_CursorData; +struct _VIV_CursorData +{ + int hot_x, hot_y; + int w, h; +}; + +#define SDL_VIV_CURSORDATA(curs) VIV_CursorData *curdata = (VIV_CursorData *) ((curs) ? (curs)->driverdata : NULL) + +extern void VIV_InitMouse(_THIS); +extern void VIV_QuitMouse(_THIS); + +#endif /* _SDL_VIV_mouse_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -urN SDL2-2.0.1/src/video/vivante/SDL_vivopengles.c SDL2-2.0.1-patch//src/video/vivante/SDL_vivopengles.c --- SDL2-2.0.1/src/video/vivante/SDL_vivopengles.c 1970-01-01 01:00:00.000000000 +0100 +++ SDL2-2.0.1-patch//src/video/vivante/SDL_vivopengles.c 2014-02-04 20:45:54.000000000 +0000 @@ -0,0 +1,42 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL + +#include "SDL_vivvideo.h" +#include "SDL_vivopengles.h" + +/* EGL implementation of SDL OpenGL support */ + +int +VIV_GLES_LoadLibrary(_THIS, const char *path) { + return SDL_EGL_LoadLibrary(_this, path, EGL_DEFAULT_DISPLAY); +} + +SDL_EGL_CreateContext_impl(VIV) +SDL_EGL_SwapWindow_impl(VIV) +SDL_EGL_MakeCurrent_impl(VIV) + +#endif /* SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL */ + +/* vi: set ts=4 sw=4 expandtab: */ + diff -urN SDL2-2.0.1/src/video/vivante/SDL_vivopengles.h SDL2-2.0.1-patch//src/video/vivante/SDL_vivopengles.h --- SDL2-2.0.1/src/video/vivante/SDL_vivopengles.h 1970-01-01 01:00:00.000000000 +0100 +++ SDL2-2.0.1-patch//src/video/vivante/SDL_vivopengles.h 2014-02-04 20:45:29.000000000 +0000 @@ -0,0 +1,48 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifndef _SDL_vivopengles_h +#define _SDL_vivopengles_h + +#if SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL + +#include "../SDL_sysvideo.h" +#include "../SDL_egl.h" + +/* OpenGLES functions */ +#define VIV_GLES_GetAttribute SDL_EGL_GetAttribute +#define VIV_GLES_GetProcAddress SDL_EGL_GetProcAddress +#define VIV_GLES_UnloadLibrary SDL_EGL_UnloadLibrary +#define VIV_GLES_SetSwapInterval SDL_EGL_SetSwapInterval +#define VIV_GLES_GetSwapInterval SDL_EGL_GetSwapInterval +#define VIV_GLES_DeleteContext SDL_EGL_DeleteContext + +extern int VIV_GLES_LoadLibrary(_THIS, const char *path); +extern SDL_GLContext VIV_GLES_CreateContext(_THIS, SDL_Window * window); +extern void VIV_GLES_SwapWindow(_THIS, SDL_Window * window); +extern int VIV_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); + +#endif /* SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL */ + +#endif /* _SDL_vivopengles_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -urN SDL2-2.0.1/src/video/vivante/SDL_vivvideo.c SDL2-2.0.1-patch//src/video/vivante/SDL_vivvideo.c --- SDL2-2.0.1/src/video/vivante/SDL_vivvideo.c 1970-01-01 01:00:00.000000000 +0100 +++ SDL2-2.0.1-patch//src/video/vivante/SDL_vivvideo.c 2014-02-04 21:43:22.000000000 +0000 @@ -0,0 +1,343 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_VIVANTE + +/* SDL internals */ +#include "../SDL_sysvideo.h" +#include "SDL_version.h" +#include "SDL_syswm.h" +#include "SDL_loadso.h" +#include "SDL_events.h" +#include "../../events/SDL_mouse_c.h" +#include "../../events/SDL_keyboard_c.h" + +#ifdef SDL_INPUT_LINUXEV +#include "../../input/evdev/SDL_evdev.h" +#endif + +/* Vivante declarations */ +#include "SDL_vivvideo.h" +#include "SDL_vivevents_c.h" +#include "SDL_vivopengles.h" +#include "SDL_vivmouse.h" + +static int +VIV_Available(void) +{ + return 1; +} + +static void +VIV_Destroy(SDL_VideoDevice * device) +{ + /* SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata; */ + + if (device->driverdata != NULL) { + device->driverdata = NULL; + } +} + +static SDL_VideoDevice * +VIV_Create() +{ + SDL_VideoDevice *device; + SDL_VideoData *phdata; + + /* Initialize SDL_VideoDevice structure */ + device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (device == NULL) { + SDL_OutOfMemory(); + return NULL; + } + + /* Initialize internal data */ + phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); + if (phdata == NULL) { + SDL_OutOfMemory(); + SDL_free(device); + return NULL; + } + + device->driverdata = phdata; + + /* Setup amount of available displays and current display */ + device->num_displays = 0; + + /* Set device free function */ + device->free = VIV_Destroy; + + /* Setup all functions which we can handle */ + device->VideoInit = VIV_VideoInit; + device->VideoQuit = VIV_VideoQuit; + device->GetDisplayModes = VIV_GetDisplayModes; + device->SetDisplayMode = VIV_SetDisplayMode; + device->CreateWindow = VIV_CreateWindow; + device->CreateWindowFrom = VIV_CreateWindowFrom; + device->SetWindowTitle = VIV_SetWindowTitle; + device->SetWindowIcon = VIV_SetWindowIcon; + device->SetWindowPosition = VIV_SetWindowPosition; + device->SetWindowSize = VIV_SetWindowSize; + device->ShowWindow = VIV_ShowWindow; + device->HideWindow = VIV_HideWindow; + device->RaiseWindow = VIV_RaiseWindow; + device->MaximizeWindow = VIV_MaximizeWindow; + device->MinimizeWindow = VIV_MinimizeWindow; + device->RestoreWindow = VIV_RestoreWindow; + device->SetWindowGrab = VIV_SetWindowGrab; + device->DestroyWindow = VIV_DestroyWindow; + device->GetWindowWMInfo = VIV_GetWindowWMInfo; + device->GL_LoadLibrary = VIV_GLES_LoadLibrary; + device->GL_GetProcAddress = VIV_GLES_GetProcAddress; + device->GL_UnloadLibrary = VIV_GLES_UnloadLibrary; + device->GL_CreateContext = VIV_GLES_CreateContext; + device->GL_MakeCurrent = VIV_GLES_MakeCurrent; + device->GL_SetSwapInterval = VIV_GLES_SetSwapInterval; + device->GL_GetSwapInterval = VIV_GLES_GetSwapInterval; + device->GL_SwapWindow = VIV_GLES_SwapWindow; + device->GL_DeleteContext = VIV_GLES_DeleteContext; + + device->PumpEvents = VIV_PumpEvents; + + return device; +} + +VideoBootStrap VIV_bootstrap = { + "Vivante", + "Vivante Video Driver", + VIV_Available, + VIV_Create +}; + +/*****************************************************************************/ +/* SDL Video and Display initialization/handling functions */ +/*****************************************************************************/ +int +VIV_VideoInit(_THIS) +{ + SDL_VideoDisplay display; + SDL_DisplayMode current_mode; + SDL_DisplayData *data; + int w = 0,h = 0; + unsigned long physical; + int stride, bpp; + + SDL_zero(current_mode); + + EGLNativeDisplayType vivante_display = fbGetDisplayByIndex(0); + fbGetDisplayInfo(vivante_display, &w, &h, &physical, &stride, &bpp); + + if (w <= 0 || h <= 0) { + fbDestroyDisplay(vivante_display); + return -1; + } + + current_mode.w = w; + current_mode.h = h; + /* FIXME: Is there a way to tell the actual refresh rate? */ + current_mode.refresh_rate = 60; + /* 32 bpp for default */ + switch(bpp) { + case 32: + default: + current_mode.format = SDL_PIXELFORMAT_ABGR8888; + break; + case 16: + current_mode.format = SDL_PIXELFORMAT_RGB565; + break; + } + + current_mode.driverdata = NULL; + + SDL_zero(display); + display.desktop_mode = current_mode; + display.current_mode = current_mode; + + /* Allocate display internal data */ + data = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData)); + if (data == NULL) { + return SDL_OutOfMemory(); + } + + data->dispman_display = vivante_display; + + display.driverdata = data; + + SDL_AddVideoDisplay(&display); + +#ifdef SDL_INPUT_LINUXEV + SDL_EVDEV_Init(); +#endif + + VIV_InitMouse(_this); + + return 1; +} + +void +VIV_VideoQuit(_THIS) +{ + /* TODO free the vivante display */ +#ifdef SDL_INPUT_LINUXEV + SDL_EVDEV_Quit(); +#endif +} + +void +VIV_GetDisplayModes(_THIS, SDL_VideoDisplay * display) +{ + /* Only one display mode available, the current one */ + SDL_AddDisplayMode(display, &display->current_mode); +} + +int +VIV_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) +{ + return 0; +} + +int +VIV_CreateWindow(_THIS, SDL_Window * window) +{ + SDL_WindowData *wdata; + SDL_VideoDisplay *display; + SDL_DisplayData *displaydata; + + /* Allocate window internal data */ + wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData)); + if (wdata == NULL) { + return SDL_OutOfMemory(); + } + display = SDL_GetDisplayForWindow(window); + displaydata = (SDL_DisplayData *) display->driverdata; + + /* OpenGL ES is the law here, buddy */ + window->flags |= SDL_WINDOW_OPENGL; + + /* Create a dispman element and associate a window to it */ + wdata->dispman_window = fbCreateWindow(displaydata->dispman_display, window->x, window->y, window->w, window->h); + + if (wdata->dispman_window == NULL) { + return SDL_SetError("Could not open rendering window"); + } + + if (!_this->egl_data) { + if (SDL_GL_LoadLibrary(NULL) < 0) { + return -1; + } + } + wdata->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType)wdata->dispman_window); + + if (wdata->egl_surface == EGL_NO_SURFACE) { + return SDL_SetError("Could not create GLES window surface"); + } + + /* Setup driver data for this window */ + window->driverdata = wdata; + + /* One window, it always has focus */ + SDL_SetMouseFocus(window); + SDL_SetKeyboardFocus(window); + + /* Window has been successfully created */ + return 0; +} + +int +VIV_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) +{ + return -1; +} + +void +VIV_SetWindowTitle(_THIS, SDL_Window * window) +{ +} +void +VIV_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) +{ +} +void +VIV_SetWindowPosition(_THIS, SDL_Window * window) +{ +} +void +VIV_SetWindowSize(_THIS, SDL_Window * window) +{ +} +void +VIV_ShowWindow(_THIS, SDL_Window * window) +{ +} +void +VIV_HideWindow(_THIS, SDL_Window * window) +{ +} +void +VIV_RaiseWindow(_THIS, SDL_Window * window) +{ +} +void +VIV_MaximizeWindow(_THIS, SDL_Window * window) +{ +} +void +VIV_MinimizeWindow(_THIS, SDL_Window * window) +{ +} +void +VIV_RestoreWindow(_THIS, SDL_Window * window) +{ +} +void +VIV_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) +{ + +} +void +VIV_DestroyWindow(_THIS, SDL_Window * window) +{ + fbDestroyWindow(((SDL_WindowData*)window->driverdata)->dispman_window); +} + +/*****************************************************************************/ +/* SDL Window Manager function */ +/*****************************************************************************/ +SDL_bool +VIV_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info) +{ + if (info->version.major <= SDL_MAJOR_VERSION) { + return SDL_TRUE; + } else { + SDL_SetError("application not compiled with SDL %d.%d\n", + SDL_MAJOR_VERSION, SDL_MINOR_VERSION); + return SDL_FALSE; + } + + /* Failed to get window manager information */ + return SDL_FALSE; +} + +#endif /* SDL_VIDEO_DRIVER_VIVANTE */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -urN SDL2-2.0.1/src/video/vivante/SDL_vivvideo.h SDL2-2.0.1-patch//src/video/vivante/SDL_vivvideo.h --- SDL2-2.0.1/src/video/vivante/SDL_vivvideo.h 1970-01-01 01:00:00.000000000 +0100 +++ SDL2-2.0.1-patch//src/video/vivante/SDL_vivvideo.h 2014-02-04 20:29:36.000000000 +0000 @@ -0,0 +1,97 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef __SDL_VIVVIDEO_H__ +#define __SDL_VIVVIDEO_H__ + +#include "SDL_config.h" +#include "../SDL_sysvideo.h" + +#include "GLES/gl.h" +#include "EGL/egl.h" +#include "EGL/eglext.h" + +typedef struct SDL_VideoData +{ + uint32_t egl_refcount; /* OpenGL ES reference count */ +} SDL_VideoData; + + +typedef struct SDL_DisplayData +{ + EGLNativeDisplayType dispman_display; +} SDL_DisplayData; + + +typedef struct SDL_WindowData +{ + EGLNativeWindowType dispman_window; +#if SDL_VIDEO_OPENGL_EGL + EGLSurface egl_surface; +#endif +} SDL_WindowData; + +#define SDL_VIV_VIDEOLAYER 10000 /* High enough so to occlude everything */ +#define SDL_VIV_MOUSELAYER SDLVIV_VIDEOLAYER + 1 + + +/****************************************************************************/ +/* SDL_VideoDevice functions declaration */ +/****************************************************************************/ + +/* Display and window functions */ +int VIV_VideoInit(_THIS); +void VIV_VideoQuit(_THIS); +void VIV_GetDisplayModes(_THIS, SDL_VideoDisplay * display); +int VIV_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); +int VIV_CreateWindow(_THIS, SDL_Window * window); +int VIV_CreateWindowFrom(_THIS, SDL_Window * window, const void *data); +void VIV_SetWindowTitle(_THIS, SDL_Window * window); +void VIV_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon); +void VIV_SetWindowPosition(_THIS, SDL_Window * window); +void VIV_SetWindowSize(_THIS, SDL_Window * window); +void VIV_ShowWindow(_THIS, SDL_Window * window); +void VIV_HideWindow(_THIS, SDL_Window * window); +void VIV_RaiseWindow(_THIS, SDL_Window * window); +void VIV_MaximizeWindow(_THIS, SDL_Window * window); +void VIV_MinimizeWindow(_THIS, SDL_Window * window); +void VIV_RestoreWindow(_THIS, SDL_Window * window); +void VIV_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed); +void VIV_DestroyWindow(_THIS, SDL_Window * window); + +/* Window manager function */ +SDL_bool VIV_GetWindowWMInfo(_THIS, SDL_Window * window, + struct SDL_SysWMinfo *info); + +/* OpenGL/OpenGL ES functions */ +int VIV_GLES_LoadLibrary(_THIS, const char *path); +void *VIV_GLES_GetProcAddress(_THIS, const char *proc); +void VIV_GLES_UnloadLibrary(_THIS); +SDL_GLContext VIV_GLES_CreateContext(_THIS, SDL_Window * window); +int VIV_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); +int VIV_GLES_SetSwapInterval(_THIS, int interval); +int VIV_GLES_GetSwapInterval(_THIS); +void VIV_GLES_SwapWindow(_THIS, SDL_Window * window); +void VIV_GLES_DeleteContext(_THIS, SDL_GLContext context); + +#endif /* __SDL_VIVVIDEO_H__ */ + +/* vi: set ts=4 sw=4 expandtab: */