Expanded the iMX6 video driver into a general Vivante video driver that works across multiple SoCs
authorSam Lantinga <slouken@libsdl.org>
Wed, 15 Oct 2014 09:18:17 -0700
changeset 9164494876610c49
parent 9163 d05b5b2775ae
child 9165 9cd9e1491227
Expanded the iMX6 video driver into a general Vivante video driver that works across multiple SoCs
CMakeLists.txt
cmake/sdlchecks.cmake
configure.in
include/SDL_config.h.cmake
include/SDL_config.h.in
src/video/SDL_egl.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/mx6/SDL_mx6events.c
src/video/mx6/SDL_mx6events_c.h
src/video/mx6/SDL_mx6opengles.c
src/video/mx6/SDL_mx6opengles.h
src/video/mx6/SDL_mx6video.c
src/video/mx6/SDL_mx6video.h
src/video/vivante/SDL_vivanteopengles.c
src/video/vivante/SDL_vivanteopengles.h
src/video/vivante/SDL_vivanteplatform.c
src/video/vivante/SDL_vivanteplatform.h
src/video/vivante/SDL_vivantevideo.c
src/video/vivante/SDL_vivantevideo.h
     1.1 --- a/CMakeLists.txt	Wed Oct 15 09:14:09 2014 -0700
     1.2 +++ b/CMakeLists.txt	Wed Oct 15 09:18:17 2014 -0700
     1.3 @@ -247,7 +247,7 @@
     1.4  set_option(VIDEO_COCOA         "Use Cocoa video driver" ${APPLE})
     1.5  set_option(DIRECTX             "Use DirectX for Windows audio/video" ${WINDOWS})
     1.6  set_option(RENDER_D3D          "Enable the Direct3D render driver" ${WINDOWS})
     1.7 -set_option(VIDEO_MX6           "Use Freescale i.MX6 video driver" OFF)
     1.8 +set_option(VIDEO_VIVANTE       "Use Vivante EGL video driver" ${UNIX_SYS})
     1.9  
    1.10  # TODO: We should (should we?) respect cmake's ${BUILD_SHARED_LIBS} flag here
    1.11  # The options below are for compatibility to configure's default behaviour.
    1.12 @@ -679,7 +679,7 @@
    1.13      CheckOpenGLX11()
    1.14      CheckOpenGLESX11()
    1.15      CheckWayland()
    1.16 -    CheckMX6()
    1.17 +    CheckVivante()
    1.18    endif()
    1.19  
    1.20    if(LINUX)
     2.1 --- a/cmake/sdlchecks.cmake	Wed Oct 15 09:14:09 2014 -0700
     2.2 +++ b/cmake/sdlchecks.cmake	Wed Oct 15 09:18:17 2014 -0700
     2.3 @@ -602,22 +602,33 @@
     2.4  
     2.5  # Requires:
     2.6  # - n/a
     2.7 -macro(CheckMX6)
     2.8 -  if(VIDEO_MX6)
     2.9 +macro(CheckVivante)
    2.10 +  if(VIDEO_VIVANTE)
    2.11      check_c_source_compiles("
    2.12 +        #include <gc_vdk.h>
    2.13 +        int main(int argc, char** argv) {}" HAVE_VIDEO_VIVANTE_VDK)
    2.14 +    check_c_source_compiles("
    2.15 +        #define LINUX
    2.16          #define EGL_API_FB
    2.17          #include <EGL/eglvivante.h>
    2.18 -        int main(int argc, char** argv) {}" HAVE_VIDEO_OPENGL_EGL_VIVANTE)
    2.19 -    if(HAVE_VIDEO_OPENGL_EGL_VIVANTE)
    2.20 -      set(HAVE_VIDEO_MX6 TRUE)
    2.21 +        int main(int argc, char** argv) {}" HAVE_VIDEO_VIVANTE_EGL_FB)
    2.22 +    if(HAVE_VIDEO_VIVANTE_VDK OR HAVE_VIDEO_VIVANTE_EGL_FB)
    2.23 +      set(HAVE_VIDEO_VIVANTE TRUE)
    2.24        set(HAVE_SDL_VIDEO TRUE)
    2.25  
    2.26 -      file(GLOB MX6_SOURCES ${SDL2_SOURCE_DIR}/src/video/mx6/*.c)
    2.27 -      set(SOURCE_FILES ${SOURCE_FILES} ${MX6_SOURCES})
    2.28 -      set(SDL_VIDEO_DRIVER_MX6 1)
    2.29 -    endif(HAVE_VIDEO_OPENGL_EGL_VIVANTE)
    2.30 -  endif(VIDEO_MX6)
    2.31 -endmacro(CheckMX6)
    2.32 +      file(GLOB VIVANTE_SOURCES ${SDL2_SOURCE_DIR}/src/video/vivante/*.c)
    2.33 +      set(SOURCE_FILES ${SOURCE_FILES} ${VIVANTE_SOURCES})
    2.34 +      set(SDL_VIDEO_DRIVER_VIVANTE 1)
    2.35 +      if(HAVE_VIDEO_VIVANTE_VDK)
    2.36 +        set(SDL_VIDEO_DRIVER_VIVANTE_VDK 1)
    2.37 +        list(APPEND EXTRA_LIBS VDK VIVANTE)
    2.38 +      else
    2.39 +        set(SDL_CFLAGS "${SDL_CFLAGS} -DLINUX -DEGL_API_FB")
    2.40 +        list(APPEND EXTRA_LIBS EGL)
    2.41 +      endif(HAVE_VIDEO_VIVANTE_VDK)
    2.42 +    endif(HAVE_VIDEO_VIVANTE_VDK OR HAVE_VIDEO_VIVANTE_EGL_FB)
    2.43 +  endif(VIDEO_VIVANTE)
    2.44 +endmacro(CheckVivante)
    2.45  
    2.46  # Requires:
    2.47  # - nada
     3.1 --- a/configure.in	Wed Oct 15 09:14:09 2014 -0700
     3.2 +++ b/configure.in	Wed Oct 15 09:18:17 2014 -0700
     3.3 @@ -1729,27 +1729,46 @@
     3.4      fi
     3.5  }
     3.6  
     3.7 -dnl Set up the MX6 video driver if enabled
     3.8 -CheckMX6Video()
     3.9 +dnl Set up the Vivante video driver if enabled
    3.10 +CheckVivanteVideo()
    3.11  {
    3.12 -    AC_ARG_ENABLE(video-mx6,
    3.13 -AC_HELP_STRING([--enable-video-mx6], [use Freescale i.MX6 video driver [[default=no]]]),
    3.14 -                  , enable_video_mx6=no)
    3.15 -    if test x$enable_video = xyes -a x$enable_video_mx6 = xyes; then
    3.16 -        AC_MSG_CHECKING(for Vivante GPU SDK)
    3.17 -        have_viv_sdk=no
    3.18 +    AC_ARG_ENABLE(video-vivante,
    3.19 +AC_HELP_STRING([--enable-video-vivante], [use Vivante EGL video driver [[default=yes]]]),
    3.20 +                  , enable_video_vivante=yes)
    3.21 +    if test x$enable_video = xyes -a x$enable_video_vivante = xyes; then
    3.22 +        AC_MSG_CHECKING(for Vivante VDK API)
    3.23 +        have_vivante_vdk=no
    3.24          AC_TRY_COMPILE([
    3.25 +          #define LINUX
    3.26 +          #define EGL_API_FB
    3.27 +          #include <gc_vdk.h>
    3.28 +        ],[
    3.29 +        ],[
    3.30 +        have_vivante_vdk=yes
    3.31 +        ])
    3.32 +        AC_MSG_RESULT($have_vivante_vdk)
    3.33 +
    3.34 +        AC_MSG_CHECKING(for Vivante FB API)
    3.35 +        have_vivante_egl=no
    3.36 +        AC_TRY_COMPILE([
    3.37 +          #define LINUX
    3.38            #define EGL_API_FB
    3.39            #include <EGL/eglvivante.h>
    3.40          ],[
    3.41          ],[
    3.42 -        have_viv_sdk=yes
    3.43 +        have_vivante_egl=yes
    3.44          ])
    3.45 -        AC_MSG_RESULT($have_viv_sdk)
    3.46 -        if test x$have_viv_sdk = xyes; then
    3.47 -            AC_DEFINE(SDL_VIDEO_DRIVER_MX6, 1, [ ])
    3.48 -            SOURCES="$SOURCES $srcdir/src/video/mx6/*.c"
    3.49 -            SUMMARY_video="${SUMMARY_video} mx6"
    3.50 +        AC_MSG_RESULT($have_vivante_egl)
    3.51 +
    3.52 +        if test x$have_vivante_vdk = xyes -o x$have_vivante_egl = xyes; then
    3.53 +            AC_DEFINE(SDL_VIDEO_DRIVER_VIVANTE, 1, [ ])
    3.54 +            EXTRA_CFLAGS="$EXTRA_CFLAGS -DLINUX -DEGL_API_FB"
    3.55 +            if test x$have_vivante_vdk = xyes; then
    3.56 +                AC_DEFINE(SDL_VIDEO_DRIVER_VIVANTE_VDK, 1, [ ])
    3.57 +                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lVDK"
    3.58 +            fi
    3.59 +            SOURCES="$SOURCES $srcdir/src/video/vivante/*.c"
    3.60 +            SUMMARY_video="${SUMMARY_video} vivante"
    3.61              have_video=yes
    3.62          fi
    3.63      fi
    3.64 @@ -1987,9 +2006,10 @@
    3.65          AC_MSG_CHECKING(for EGL support)
    3.66          video_opengl_egl=no
    3.67          AC_TRY_COMPILE([
    3.68 -         #define EGL_API_FB
    3.69 -         #include <EGL/egl.h>
    3.70 -         #include <EGL/eglext.h>
    3.71 +          #define LINUX
    3.72 +          #define EGL_API_FB
    3.73 +          #include <EGL/egl.h>
    3.74 +          #include <EGL/eglext.h>
    3.75          ],[
    3.76          ],[
    3.77          video_opengl_egl=yes
    3.78 @@ -2268,10 +2288,10 @@
    3.79  AC_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]]),
    3.80                    , enable_pthread_sem=yes)
    3.81      case "$host" in
    3.82 -	 *-*-androideabi*)
    3.83 +         *-*-androideabi*)
    3.84              pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
    3.85              pthread_lib=""
    3.86 -	    ;;
    3.87 +            ;;
    3.88          *-*-linux*|*-*-uclinux*)
    3.89              pthread_cflags="-D_REENTRANT"
    3.90              pthread_lib="-lpthread"
    3.91 @@ -2846,7 +2866,7 @@
    3.92          CheckClockGettime
    3.93          CheckLinuxVersion
    3.94          CheckRPATH
    3.95 -        CheckMX6Video
    3.96 +        CheckVivanteVideo
    3.97          # Set up files for the audio library
    3.98          if test x$enable_audio = xyes; then
    3.99            case $ARCH in
     4.1 --- a/include/SDL_config.h.cmake	Wed Oct 15 09:14:09 2014 -0700
     4.2 +++ b/include/SDL_config.h.cmake	Wed Oct 15 09:18:17 2014 -0700
     4.3 @@ -264,7 +264,8 @@
     4.4  #cmakedefine SDL_VIDEO_DRIVER_WINDOWS @SDL_VIDEO_DRIVER_WINDOWS@
     4.5  #cmakedefine SDL_VIDEO_DRIVER_WAYLAND @SDL_VIDEO_DRIVER_WAYLAND@
     4.6  #cmakedefine SDL_VIDEO_DRIVER_RPI @SDL_VIDEO_DRIVER_RPI@
     4.7 -#cmakedefine SDL_VIDEO_DRIVER_MX6 @SDL_VIDEO_DRIVER_MX6@
     4.8 +#cmakedefine SDL_VIDEO_DRIVER_VIVANTE @SDL_VIDEO_DRIVER_VIVANTE@
     4.9 +#cmakedefine SDL_VIDEO_DRIVER_VIVANTE_VDK @SDL_VIDEO_DRIVER_VIVANTE_VDK@
    4.10  
    4.11  #if 0
    4.12  /* !!! FIXME: in configure script version, missing here: */
     5.1 --- a/include/SDL_config.h.in	Wed Oct 15 09:14:09 2014 -0700
     5.2 +++ b/include/SDL_config.h.in	Wed Oct 15 09:18:17 2014 -0700
     5.3 @@ -308,7 +308,8 @@
     5.4  #undef SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY
     5.5  #undef SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
     5.6  #undef SDL_VIDEO_DRIVER_NACL
     5.7 -#undef SDL_VIDEO_DRIVER_MX6
     5.8 +#undef SDL_VIDEO_DRIVER_VIVANTE
     5.9 +#undef SDL_VIDEO_DRIVER_VIVANTE_VDK
    5.10  
    5.11  #undef SDL_VIDEO_RENDER_D3D
    5.12  #undef SDL_VIDEO_RENDER_D3D11
     6.1 --- a/src/video/SDL_egl.c	Wed Oct 15 09:14:09 2014 -0700
     6.2 +++ b/src/video/SDL_egl.c	Wed Oct 15 09:18:17 2014 -0700
     6.3 @@ -38,7 +38,7 @@
     6.4  #define DEFAULT_OGL_ES_PVR "/opt/vc/lib/libGLES_CM.so"
     6.5  #define DEFAULT_OGL_ES "/opt/vc/lib/libGLESv1_CM.so"
     6.6  
     6.7 -#elif SDL_VIDEO_DRIVER_ANDROID
     6.8 +#elif SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_VIVANTE
     6.9  /* Android */
    6.10  #define DEFAULT_EGL "libEGL.so"
    6.11  #define DEFAULT_OGL_ES2 "libGLESv2.so"
     7.1 --- a/src/video/SDL_sysvideo.h	Wed Oct 15 09:14:09 2014 -0700
     7.2 +++ b/src/video/SDL_sysvideo.h	Wed Oct 15 09:18:17 2014 -0700
     7.3 @@ -391,8 +391,8 @@
     7.4  #if SDL_VIDEO_DRIVER_NACL
     7.5  extern VideoBootStrap NACL_bootstrap;
     7.6  #endif
     7.7 -#if SDL_VIDEO_DRIVER_MX6
     7.8 -extern VideoBootStrap MX6_bootstrap;
     7.9 +#if SDL_VIDEO_DRIVER_VIVANTE
    7.10 +extern VideoBootStrap VIVANTE_bootstrap;
    7.11  #endif
    7.12  
    7.13  extern SDL_VideoDevice *SDL_GetVideoDevice(void);
     8.1 --- a/src/video/SDL_video.c	Wed Oct 15 09:14:09 2014 -0700
     8.2 +++ b/src/video/SDL_video.c	Wed Oct 15 09:18:17 2014 -0700
     8.3 @@ -62,6 +62,12 @@
     8.4  #if SDL_VIDEO_DRIVER_MIR
     8.5      &MIR_bootstrap,
     8.6  #endif
     8.7 +#if SDL_VIDEO_DRIVER_WAYLAND
     8.8 +    &Wayland_bootstrap,
     8.9 +#endif
    8.10 +#if SDL_VIDEO_DRIVER_VIVANTE
    8.11 +    &VIVANTE_bootstrap,
    8.12 +#endif
    8.13  #if SDL_VIDEO_DRIVER_DIRECTFB
    8.14      &DirectFB_bootstrap,
    8.15  #endif
    8.16 @@ -89,15 +95,9 @@
    8.17  #if SDL_VIDEO_DRIVER_RPI
    8.18      &RPI_bootstrap,
    8.19  #endif 
    8.20 -#if SDL_VIDEO_DRIVER_WAYLAND
    8.21 -    &Wayland_bootstrap,
    8.22 -#endif
    8.23  #if SDL_VIDEO_DRIVER_NACL
    8.24      &NACL_bootstrap,
    8.25  #endif
    8.26 -#if SDL_VIDEO_DRIVER_MX6
    8.27 -    &MX6_bootstrap,
    8.28 -#endif
    8.29  #if SDL_VIDEO_DRIVER_DUMMY
    8.30      &DUMMY_bootstrap,
    8.31  #endif
     9.1 --- a/src/video/mx6/SDL_mx6events.c	Wed Oct 15 09:14:09 2014 -0700
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,45 +0,0 @@
     9.4 -/*
     9.5 -  Simple DirectMedia Layer
     9.6 -  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
     9.7 -
     9.8 -  This software is provided 'as-is', without any express or implied
     9.9 -  warranty.  In no event will the authors be held liable for any damages
    9.10 -  arising from the use of this software.
    9.11 -
    9.12 -  Permission is granted to anyone to use this software for any purpose,
    9.13 -  including commercial applications, and to alter it and redistribute it
    9.14 -  freely, subject to the following restrictions:
    9.15 -
    9.16 -  1. The origin of this software must not be misrepresented; you must not
    9.17 -     claim that you wrote the original software. If you use this software
    9.18 -     in a product, an acknowledgment in the product documentation would be
    9.19 -     appreciated but is not required.
    9.20 -  2. Altered source versions must be plainly marked as such, and must not be
    9.21 -     misrepresented as being the original software.
    9.22 -  3. This notice may not be removed or altered from any source distribution.
    9.23 -*/
    9.24 -
    9.25 -#include "../../SDL_internal.h"
    9.26 -
    9.27 -#if SDL_VIDEO_DRIVER_MX6
    9.28 -
    9.29 -#include "../../events/SDL_sysevents.h"
    9.30 -#include "../../events/SDL_events_c.h"
    9.31 -#include "../../events/SDL_keyboard_c.h"
    9.32 -#include "SDL_mx6video.h"
    9.33 -#include "SDL_mx6events_c.h"
    9.34 -
    9.35 -#ifdef SDL_INPUT_LINUXEV
    9.36 -#include "../../core/linux/SDL_evdev.h"
    9.37 -#endif
    9.38 -
    9.39 -void MX6_PumpEvents(_THIS)
    9.40 -{
    9.41 -#ifdef SDL_INPUT_LINUXEV
    9.42 -    SDL_EVDEV_Poll();
    9.43 -#endif
    9.44 -    
    9.45 -}
    9.46 -
    9.47 -#endif /* SDL_VIDEO_DRIVER_MX6 */
    9.48 -
    10.1 --- a/src/video/mx6/SDL_mx6events_c.h	Wed Oct 15 09:14:09 2014 -0700
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,31 +0,0 @@
    10.4 -/*
    10.5 -  Simple DirectMedia Layer
    10.6 -  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
    10.7 -
    10.8 -  This software is provided 'as-is', without any express or implied
    10.9 -  warranty.  In no event will the authors be held liable for any damages
   10.10 -  arising from the use of this software.
   10.11 -
   10.12 -  Permission is granted to anyone to use this software for any purpose,
   10.13 -  including commercial applications, and to alter it and redistribute it
   10.14 -  freely, subject to the following restrictions:
   10.15 -
   10.16 -  1. The origin of this software must not be misrepresented; you must not
   10.17 -     claim that you wrote the original software. If you use this software
   10.18 -     in a product, an acknowledgment in the product documentation would be
   10.19 -     appreciated but is not required.
   10.20 -  2. Altered source versions must be plainly marked as such, and must not be
   10.21 -     misrepresented as being the original software.
   10.22 -  3. This notice may not be removed or altered from any source distribution.
   10.23 -*/
   10.24 -
   10.25 -#ifndef _SDL_mx6events_c_h
   10.26 -#define _SDL_mx6events_c_h
   10.27 -
   10.28 -#include "SDL_mx6video.h"
   10.29 -
   10.30 -void MX6_PumpEvents(_THIS);
   10.31 -void MX6_EventInit(_THIS);
   10.32 -void MX6_EventQuit(_THIS);
   10.33 -
   10.34 -#endif /* _SDL_mx6events_c_h */
    11.1 --- a/src/video/mx6/SDL_mx6opengles.c	Wed Oct 15 09:14:09 2014 -0700
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,205 +0,0 @@
    11.4 -/*
    11.5 -  Simple DirectMedia Layer
    11.6 -  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
    11.7 -
    11.8 -  This software is provided 'as-is', without any express or implied
    11.9 -  warranty.  In no event will the authors be held liable for any damages
   11.10 -  arising from the use of this software.
   11.11 -
   11.12 -  Permission is granted to anyone to use this software for any purpose,
   11.13 -  including commercial applications, and to alter it and redistribute it
   11.14 -  freely, subject to the following restrictions:
   11.15 -
   11.16 -  1. The origin of this software must not be misrepresented; you must not
   11.17 -     claim that you wrote the original software. If you use this software
   11.18 -     in a product, an acknowledgment in the product documentation would be
   11.19 -     appreciated but is not required.
   11.20 -  2. Altered source versions must be plainly marked as such, and must not be
   11.21 -     misrepresented as being the original software.
   11.22 -  3. This notice may not be removed or altered from any source distribution.
   11.23 -*/
   11.24 -#include "../../SDL_internal.h"
   11.25 -
   11.26 -#if SDL_VIDEO_DRIVER_MX6 && SDL_VIDEO_OPENGL_EGL
   11.27 -
   11.28 -#include "SDL_mx6opengles.h"
   11.29 -#include "SDL_loadso.h"
   11.30 -#include "SDL_mx6video.h"
   11.31 -
   11.32 -#define DEFAULT_OGL "libGL.so.1"
   11.33 -#define DEFAULT_EGL "libEGL.so.1"
   11.34 -#define DEFAULT_OGL_ES2 "libGLESv2.so.2"
   11.35 -#define DEFAULT_OGL_ES "libGLESv1_CM.so.1"
   11.36 -
   11.37 -#define LOAD_FUNC(NAME) \
   11.38 -*((void**)&_this->egl_data->NAME) = SDL_LoadFunction(_this->egl_data->dll_handle, #NAME); \
   11.39 -if (!_this->egl_data->NAME) \
   11.40 -{ \
   11.41 -    return SDL_SetError("Could not retrieve EGL function " #NAME); \
   11.42 -}
   11.43 -
   11.44 -#define LOAD_VIV_FUNC(NAME) \
   11.45 -*((void**)&egl_viv_data->NAME) = SDL_LoadFunction(_this->egl_data->dll_handle, #NAME); \
   11.46 -if (!egl_viv_data->NAME) \
   11.47 -{ \
   11.48 -    return SDL_SetError("Could not retrieve EGL function " #NAME); \
   11.49 -}
   11.50 -
   11.51 -/* EGL implementation of SDL OpenGL support */
   11.52 -
   11.53 -int
   11.54 -MX6_GLES_LoadLibrary(_THIS, const char *egl_path)
   11.55 -{
   11.56 -    /* The definitions of egl_dll_handle and dll_handle were interchanged for some reason.
   11.57 -       Just left them as is for compatibility */
   11.58 -    void *dll_handle = NULL, *egl_dll_handle = NULL;
   11.59 -    char *path = NULL;
   11.60 -
   11.61 -    if (_this->egl_data) {
   11.62 -        return SDL_SetError("OpenGL ES context already created");
   11.63 -    }
   11.64 -
   11.65 -    _this->egl_data = (struct SDL_EGL_VideoData *) SDL_calloc(1, sizeof(SDL_EGL_VideoData));
   11.66 -    if (!_this->egl_data) {
   11.67 -        return SDL_OutOfMemory();
   11.68 -    }
   11.69 -
   11.70 -    egl_viv_data = (struct MX6_EGL_VivanteData *) SDL_calloc(1, sizeof(MX6_EGL_VivanteData));
   11.71 -    if (!egl_viv_data) {
   11.72 -        return SDL_OutOfMemory();
   11.73 -    }
   11.74 -
   11.75 -    path = SDL_getenv("SDL_VIDEO_GL_DRIVER");
   11.76 -    if (path != NULL) {
   11.77 -        egl_dll_handle = SDL_LoadObject(path);
   11.78 -    }
   11.79 -
   11.80 -    if (egl_dll_handle == NULL) {
   11.81 -        if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
   11.82 -            if (_this->gl_config.major_version > 1) {
   11.83 -                path = DEFAULT_OGL_ES2;
   11.84 -                egl_dll_handle = SDL_LoadObject(path);
   11.85 -            }
   11.86 -            else {
   11.87 -                path = DEFAULT_OGL_ES;
   11.88 -                egl_dll_handle = SDL_LoadObject(path);
   11.89 -            }
   11.90 -        }
   11.91 -        else {
   11.92 -            path = DEFAULT_OGL;
   11.93 -            egl_dll_handle = SDL_LoadObject(path);
   11.94 -        }
   11.95 -    }
   11.96 -    _this->egl_data->egl_dll_handle = egl_dll_handle;
   11.97 -
   11.98 -    if (egl_dll_handle == NULL) {
   11.99 -        return SDL_SetError("Could not initialize OpenGL / GLES library");
  11.100 -    }
  11.101 -
  11.102 -    if (egl_path != NULL) {
  11.103 -        dll_handle = SDL_LoadObject(egl_path);
  11.104 -    }
  11.105 -
  11.106 -    if (SDL_LoadFunction(dll_handle, "eglChooseConfig") == NULL) {
  11.107 -        if (dll_handle != NULL) {
  11.108 -            SDL_UnloadObject(dll_handle);
  11.109 -        }
  11.110 -        path = SDL_getenv("SDL_VIDEO_EGL_DRIVER");
  11.111 -        if (path == NULL) {
  11.112 -            path = DEFAULT_EGL;
  11.113 -        }
  11.114 -        dll_handle = SDL_LoadObject(path);
  11.115 -        if (dll_handle == NULL) {
  11.116 -            return SDL_SetError("Could not load EGL library");
  11.117 -        }
  11.118 -    }
  11.119 -
  11.120 -    _this->egl_data->dll_handle = dll_handle;
  11.121 -
  11.122 -    /* Load new function pointers */
  11.123 -    LOAD_FUNC(eglGetDisplay);
  11.124 -    LOAD_FUNC(eglInitialize);
  11.125 -    LOAD_FUNC(eglTerminate);
  11.126 -    LOAD_FUNC(eglGetProcAddress);
  11.127 -    LOAD_FUNC(eglChooseConfig);
  11.128 -    LOAD_FUNC(eglGetConfigAttrib);
  11.129 -    LOAD_FUNC(eglCreateContext);
  11.130 -    LOAD_FUNC(eglDestroyContext);
  11.131 -    LOAD_FUNC(eglCreateWindowSurface);
  11.132 -    LOAD_FUNC(eglDestroySurface);
  11.133 -    LOAD_FUNC(eglMakeCurrent);
  11.134 -    LOAD_FUNC(eglSwapBuffers);
  11.135 -    LOAD_FUNC(eglSwapInterval);
  11.136 -    LOAD_FUNC(eglWaitNative);
  11.137 -    LOAD_FUNC(eglWaitGL);
  11.138 -    LOAD_FUNC(eglBindAPI);
  11.139 -    /* Functions from Vivante GPU SDK */
  11.140 -    LOAD_VIV_FUNC(fbGetDisplay);
  11.141 -    LOAD_VIV_FUNC(fbGetDisplayByIndex);
  11.142 -    LOAD_VIV_FUNC(fbGetDisplayGeometry);
  11.143 -    LOAD_VIV_FUNC(fbGetDisplayInfo);
  11.144 -    LOAD_VIV_FUNC(fbDestroyDisplay);
  11.145 -    LOAD_VIV_FUNC(fbCreateWindow);
  11.146 -    LOAD_VIV_FUNC(fbGetWindowGeometry);
  11.147 -    LOAD_VIV_FUNC(fbGetWindowInfo);
  11.148 -    LOAD_VIV_FUNC(fbDestroyWindow);
  11.149 -    LOAD_VIV_FUNC(fbCreatePixmap);
  11.150 -    LOAD_VIV_FUNC(fbCreatePixmapWithBpp);
  11.151 -    LOAD_VIV_FUNC(fbGetPixmapGeometry);
  11.152 -    LOAD_VIV_FUNC(fbGetPixmapInfo);
  11.153 -    LOAD_VIV_FUNC(fbDestroyPixmap);
  11.154 -
  11.155 -    _this->egl_data->egl_display = _this->egl_data->eglGetDisplay(egl_viv_data->fbGetDisplayByIndex(0));
  11.156 -    if (!_this->egl_data->egl_display) {
  11.157 -        return SDL_SetError("Could not get EGL display");
  11.158 -    }
  11.159 -
  11.160 -    if (_this->egl_data->eglInitialize(_this->egl_data->egl_display, NULL, NULL) != EGL_TRUE) {
  11.161 -        return SDL_SetError("Could not initialize EGL");
  11.162 -    }
  11.163 -
  11.164 -    _this->gl_config.driver_loaded = 1;
  11.165 -
  11.166 -    if (path) {
  11.167 -        SDL_strlcpy(_this->gl_config.driver_path, path, sizeof(_this->gl_config.driver_path) - 1);
  11.168 -    } else {
  11.169 -        *_this->gl_config.driver_path = '\0';
  11.170 -    }
  11.171 -
  11.172 -    return 0;
  11.173 -}
  11.174 -
  11.175 -void
  11.176 -MX6_GLES_UnloadLibrary(_THIS)
  11.177 -{
  11.178 -    if (_this->egl_data) {
  11.179 -        if (_this->egl_data->egl_display) {
  11.180 -            _this->egl_data->eglTerminate(_this->egl_data->egl_display);
  11.181 -            _this->egl_data->egl_display = NULL;
  11.182 -        }
  11.183 -
  11.184 -        if (_this->egl_data->dll_handle) {
  11.185 -            SDL_UnloadObject(_this->egl_data->dll_handle);
  11.186 -            _this->egl_data->dll_handle = NULL;
  11.187 -        }
  11.188 -        if (_this->egl_data->egl_dll_handle) {
  11.189 -            SDL_UnloadObject(_this->egl_data->egl_dll_handle);
  11.190 -            _this->egl_data->egl_dll_handle = NULL;
  11.191 -        }
  11.192 -
  11.193 -        SDL_free(_this->egl_data);
  11.194 -        _this->egl_data = NULL;
  11.195 -
  11.196 -        SDL_free(egl_viv_data);
  11.197 -        egl_viv_data = NULL;
  11.198 -    }
  11.199 -}
  11.200 -
  11.201 -SDL_EGL_CreateContext_impl(MX6)
  11.202 -SDL_EGL_SwapWindow_impl(MX6)
  11.203 -SDL_EGL_MakeCurrent_impl(MX6)
  11.204 -
  11.205 -#endif /* SDL_VIDEO_DRIVER_MX6 && SDL_VIDEO_OPENGL_EGL */
  11.206 -
  11.207 -/* vi: set ts=4 sw=4 expandtab: */
  11.208 -
    12.1 --- a/src/video/mx6/SDL_mx6opengles.h	Wed Oct 15 09:14:09 2014 -0700
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,68 +0,0 @@
    12.4 -/*
    12.5 -  Simple DirectMedia Layer
    12.6 -  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
    12.7 -
    12.8 -  This software is provided 'as-is', without any express or implied
    12.9 -  warranty.  In no event will the authors be held liable for any damages
   12.10 -  arising from the use of this software.
   12.11 -
   12.12 -  Permission is granted to anyone to use this software for any purpose,
   12.13 -  including commercial applications, and to alter it and redistribute it
   12.14 -  freely, subject to the following restrictions:
   12.15 -
   12.16 -  1. The origin of this software must not be misrepresented; you must not
   12.17 -     claim that you wrote the original software. If you use this software
   12.18 -     in a product, an acknowledgment in the product documentation would be
   12.19 -     appreciated but is not required.
   12.20 -  2. Altered source versions must be plainly marked as such, and must not be
   12.21 -     misrepresented as being the original software.
   12.22 -  3. This notice may not be removed or altered from any source distribution.
   12.23 -*/
   12.24 -#include "../../SDL_internal.h"
   12.25 -
   12.26 -#ifndef _SDL_mx6opengles_h
   12.27 -#define _SDL_mx6opengles_h
   12.28 -
   12.29 -#if SDL_VIDEO_DRIVER_MX6 && SDL_VIDEO_OPENGL_EGL
   12.30 -
   12.31 -#include "../SDL_sysvideo.h"
   12.32 -#include "../SDL_egl_c.h"
   12.33 -
   12.34 -typedef struct MX6_EGL_VivanteData
   12.35 -{
   12.36 -    EGLNativeDisplayType(EGLAPIENTRY *fbGetDisplay) (void *context);
   12.37 -    EGLNativeDisplayType(EGLAPIENTRY *fbGetDisplayByIndex) (int DisplayIndex);
   12.38 -    void(EGLAPIENTRY *fbGetDisplayGeometry) (EGLNativeDisplayType Display, int *Width, int *Height);
   12.39 -    void(EGLAPIENTRY *fbGetDisplayInfo) (EGLNativeDisplayType Display, int *Width, int *Height, unsigned long *Physical, int *Stride, int *BitsPerPixel);
   12.40 -    void(EGLAPIENTRY *fbDestroyDisplay) (EGLNativeDisplayType Display);
   12.41 -    EGLNativeWindowType(EGLAPIENTRY *fbCreateWindow) (EGLNativeDisplayType Display, int X, int Y, int Width, int Height);
   12.42 -    void(EGLAPIENTRY *fbGetWindowGeometry) (EGLNativeWindowType Window, int *X, int *Y, int *Width, int *Height);
   12.43 -    void(EGLAPIENTRY *fbGetWindowInfo) (EGLNativeWindowType Window, int *X, int *Y, int *Width, int *Height, int *BitsPerPixel, unsigned int *Offset);
   12.44 -    void(EGLAPIENTRY *fbDestroyWindow) (EGLNativeWindowType Window);
   12.45 -    EGLNativePixmapType(EGLAPIENTRY *fbCreatePixmap) (EGLNativeDisplayType Display, int Width, int Height);
   12.46 -    EGLNativePixmapType(EGLAPIENTRY *fbCreatePixmapWithBpp) (EGLNativeDisplayType Display, int Width, int Height, int BitsPerPixel);
   12.47 -    void(EGLAPIENTRY *fbGetPixmapGeometry) (EGLNativePixmapType Pixmap, int *Width, int *Height);
   12.48 -    void(EGLAPIENTRY *fbGetPixmapInfo) (EGLNativePixmapType Pixmap, int *Width, int *Height, int *BitsPerPixel, int *Stride, void **Bits);
   12.49 -    void(EGLAPIENTRY *fbDestroyPixmap) (EGLNativePixmapType Pixmap);
   12.50 -} MX6_EGL_VivanteData;
   12.51 -
   12.52 -struct MX6_EGL_VivanteData *egl_viv_data;
   12.53 -
   12.54 -/* OpenGLES functions */
   12.55 -#define MX6_GLES_GetAttribute SDL_EGL_GetAttribute
   12.56 -#define MX6_GLES_GetProcAddress SDL_EGL_GetProcAddress
   12.57 -#define MX6_GLES_SetSwapInterval SDL_EGL_SetSwapInterval
   12.58 -#define MX6_GLES_GetSwapInterval SDL_EGL_GetSwapInterval
   12.59 -#define MX6_GLES_DeleteContext SDL_EGL_DeleteContext
   12.60 -
   12.61 -extern int MX6_GLES_LoadLibrary(_THIS, const char *path);
   12.62 -extern void MX6_GLES_UnloadLibrary(_THIS);
   12.63 -extern SDL_GLContext MX6_GLES_CreateContext(_THIS, SDL_Window * window);
   12.64 -extern void MX6_GLES_SwapWindow(_THIS, SDL_Window * window);
   12.65 -extern int MX6_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context);
   12.66 -
   12.67 -#endif /* SDL_VIDEO_DRIVER_MX6 && SDL_VIDEO_OPENGL_EGL */
   12.68 -
   12.69 -#endif /* _SDL_mx6opengles_h */
   12.70 -
   12.71 -/* vi: set ts=4 sw=4 expandtab: */
    13.1 --- a/src/video/mx6/SDL_mx6video.c	Wed Oct 15 09:14:09 2014 -0700
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,331 +0,0 @@
    13.4 -/*
    13.5 -  Simple DirectMedia Layer
    13.6 -  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
    13.7 -
    13.8 -  This software is provided 'as-is', without any express or implied
    13.9 -  warranty.  In no event will the authors be held liable for any damages
   13.10 -  arising from the use of this software.
   13.11 -
   13.12 -  Permission is granted to anyone to use this software for any purpose,
   13.13 -  including commercial applications, and to alter it and redistribute it
   13.14 -  freely, subject to the following restrictions:
   13.15 -
   13.16 -  1. The origin of this software must not be misrepresented; you must not
   13.17 -     claim that you wrote the original software. If you use this software
   13.18 -     in a product, an acknowledgment in the product documentation would be
   13.19 -     appreciated but is not required.
   13.20 -  2. Altered source versions must be plainly marked as such, and must not be
   13.21 -     misrepresented as being the original software.
   13.22 -  3. This notice may not be removed or altered from any source distribution.
   13.23 -*/
   13.24 -
   13.25 -#include "../../SDL_internal.h"
   13.26 -
   13.27 -#if SDL_VIDEO_DRIVER_MX6
   13.28 -
   13.29 -/* SDL internals */
   13.30 -#include "../SDL_sysvideo.h"
   13.31 -#include "SDL_version.h"
   13.32 -#include "SDL_syswm.h"
   13.33 -#include "SDL_loadso.h"
   13.34 -#include "SDL_events.h"
   13.35 -
   13.36 -#ifdef SDL_INPUT_LINUXEV
   13.37 -#include "../../core/linux/SDL_evdev.h"
   13.38 -#endif
   13.39 -
   13.40 -#include "SDL_mx6video.h"
   13.41 -#include "SDL_mx6events_c.h"
   13.42 -#include "SDL_mx6opengles.h"
   13.43 -
   13.44 -static int
   13.45 -MX6_Available(void)
   13.46 -{
   13.47 -    return 1;
   13.48 -}
   13.49 -
   13.50 -static void
   13.51 -MX6_Destroy(SDL_VideoDevice * device)
   13.52 -{
   13.53 -    if (device->driverdata != NULL) {
   13.54 -        SDL_free(device->driverdata);
   13.55 -        device->driverdata = NULL;
   13.56 -    }
   13.57 -}
   13.58 -
   13.59 -static SDL_VideoDevice *
   13.60 -MX6_Create()
   13.61 -{
   13.62 -    SDL_VideoDevice *device;
   13.63 -    SDL_VideoData *data;
   13.64 -
   13.65 -    /* Initialize SDL_VideoDevice structure */
   13.66 -    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
   13.67 -    if (device == NULL) {
   13.68 -        SDL_OutOfMemory();
   13.69 -        return NULL;
   13.70 -    }
   13.71 -
   13.72 -    /* Initialize internal data */
   13.73 -    data = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
   13.74 -    if (data == NULL) {
   13.75 -        SDL_OutOfMemory();
   13.76 -        SDL_free(device);
   13.77 -        return NULL;
   13.78 -    }
   13.79 -
   13.80 -    device->driverdata = data;
   13.81 -
   13.82 -    /* Setup amount of available displays and current display */
   13.83 -    device->num_displays = 0;
   13.84 -
   13.85 -    /* Set device free function */
   13.86 -    device->free = MX6_Destroy;
   13.87 -
   13.88 -    /* Setup all functions which we can handle */
   13.89 -    device->VideoInit = MX6_VideoInit;
   13.90 -    device->VideoQuit = MX6_VideoQuit;
   13.91 -    device->GetDisplayModes = MX6_GetDisplayModes;
   13.92 -    device->SetDisplayMode = MX6_SetDisplayMode;
   13.93 -    device->CreateWindow = MX6_CreateWindow;
   13.94 -    device->CreateWindowFrom = MX6_CreateWindowFrom;
   13.95 -    device->SetWindowTitle = MX6_SetWindowTitle;
   13.96 -    device->SetWindowIcon = MX6_SetWindowIcon;
   13.97 -    device->SetWindowPosition = MX6_SetWindowPosition;
   13.98 -    device->SetWindowSize = MX6_SetWindowSize;
   13.99 -    device->ShowWindow = MX6_ShowWindow;
  13.100 -    device->HideWindow = MX6_HideWindow;
  13.101 -    device->RaiseWindow = MX6_RaiseWindow;
  13.102 -    device->MaximizeWindow = MX6_MaximizeWindow;
  13.103 -    device->MinimizeWindow = MX6_MinimizeWindow;
  13.104 -    device->RestoreWindow = MX6_RestoreWindow;
  13.105 -    device->SetWindowGrab = MX6_SetWindowGrab;
  13.106 -    device->DestroyWindow = MX6_DestroyWindow;
  13.107 -    device->GetWindowWMInfo = MX6_GetWindowWMInfo;
  13.108 -
  13.109 -    device->GL_LoadLibrary = MX6_GLES_LoadLibrary;
  13.110 -    device->GL_GetProcAddress = MX6_GLES_GetProcAddress;
  13.111 -    device->GL_UnloadLibrary = MX6_GLES_UnloadLibrary;
  13.112 -    device->GL_CreateContext = MX6_GLES_CreateContext;
  13.113 -    device->GL_MakeCurrent = MX6_GLES_MakeCurrent;
  13.114 -    device->GL_SetSwapInterval = MX6_GLES_SetSwapInterval;
  13.115 -    device->GL_GetSwapInterval = MX6_GLES_GetSwapInterval;
  13.116 -    device->GL_SwapWindow = MX6_GLES_SwapWindow;
  13.117 -    device->GL_DeleteContext = MX6_GLES_DeleteContext;
  13.118 -
  13.119 -    device->PumpEvents = MX6_PumpEvents;
  13.120 -
  13.121 -    return device;
  13.122 -}
  13.123 -
  13.124 -VideoBootStrap MX6_bootstrap = {
  13.125 -    "MX6",
  13.126 -    "Freescale i.MX6 Video Driver",
  13.127 -    MX6_Available,
  13.128 -    MX6_Create
  13.129 -};
  13.130 -
  13.131 -static void
  13.132 -MX6_UpdateDisplay(_THIS)
  13.133 -{
  13.134 -    SDL_VideoDisplay *display = &_this->displays[0];
  13.135 -    SDL_DisplayData *data = (SDL_DisplayData*)display->driverdata;
  13.136 -    EGLNativeDisplayType native_display = egl_viv_data->fbGetDisplayByIndex(0);
  13.137 -    SDL_DisplayMode current_mode;
  13.138 -    int pitch, bpp;
  13.139 -    unsigned long pixels;
  13.140 -
  13.141 -    /* Store the native EGL display */
  13.142 -    data->native_display = native_display;
  13.143 -
  13.144 -    SDL_zero(current_mode);
  13.145 -    egl_viv_data->fbGetDisplayInfo(native_display, &current_mode.w, &current_mode.h, &pixels, &pitch, &bpp);
  13.146 -    /* FIXME: How do we query refresh rate? */
  13.147 -    current_mode.refresh_rate = 60;
  13.148 -
  13.149 -    switch (bpp)
  13.150 -    {
  13.151 -    default: /* Is another format used? */
  13.152 -    case 16:
  13.153 -        current_mode.format = SDL_PIXELFORMAT_RGB565;
  13.154 -        break;
  13.155 -    }
  13.156 -
  13.157 -    display->desktop_mode = current_mode;
  13.158 -    display->current_mode = current_mode;
  13.159 -}
  13.160 -
  13.161 -/*****************************************************************************/
  13.162 -/* SDL Video and Display initialization/handling functions                   */
  13.163 -/*****************************************************************************/
  13.164 -int
  13.165 -MX6_VideoInit(_THIS)
  13.166 -{
  13.167 -    SDL_VideoDisplay display;
  13.168 -    SDL_DisplayMode current_mode;
  13.169 -    SDL_DisplayData *data;
  13.170 -
  13.171 -    data = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData));
  13.172 -    if (data == NULL) {
  13.173 -        return SDL_OutOfMemory();
  13.174 -    }
  13.175 -
  13.176 -    SDL_zero(display);
  13.177 -    SDL_zero(current_mode);
  13.178 -    display.desktop_mode = current_mode;
  13.179 -    display.current_mode = current_mode;
  13.180 -    display.driverdata = data;
  13.181 -    SDL_AddVideoDisplay(&display);
  13.182 -
  13.183 -    if (SDL_GL_LoadLibrary(NULL) < 0) {
  13.184 -        return -1;
  13.185 -    }
  13.186 -    MX6_UpdateDisplay(_this);
  13.187 -
  13.188 -#ifdef SDL_INPUT_LINUXEV
  13.189 -    SDL_EVDEV_Init();
  13.190 -#endif
  13.191 -
  13.192 -    return 0;
  13.193 -}
  13.194 -
  13.195 -void
  13.196 -MX6_VideoQuit(_THIS)
  13.197 -{
  13.198 -#ifdef SDL_INPUT_LINUXEV
  13.199 -    SDL_EVDEV_Quit();
  13.200 -#endif
  13.201 -}
  13.202 -
  13.203 -void
  13.204 -MX6_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
  13.205 -{
  13.206 -    /* Only one display mode available, the current one */
  13.207 -    SDL_AddDisplayMode(display, &display->current_mode);
  13.208 -}
  13.209 -
  13.210 -int
  13.211 -MX6_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
  13.212 -{
  13.213 -    return 0;
  13.214 -}
  13.215 -
  13.216 -int
  13.217 -MX6_CreateWindow(_THIS, SDL_Window * window)
  13.218 -{
  13.219 -    SDL_DisplayData *displaydata;
  13.220 -    SDL_WindowData *data;
  13.221 -
  13.222 -    displaydata = SDL_GetDisplayDriverData(0);
  13.223 -
  13.224 -    /* Allocate window internal data */
  13.225 -    data = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
  13.226 -    if (data == NULL) {
  13.227 -        return SDL_OutOfMemory();
  13.228 -    }
  13.229 -
  13.230 -    /* Setup driver data for this window */
  13.231 -    window->driverdata = data;
  13.232 -    window->flags |= SDL_WINDOW_OPENGL;
  13.233 -
  13.234 -    if (!_this->egl_data) {
  13.235 -        return -1;
  13.236 -    }
  13.237 -
  13.238 -    data->native_window = egl_viv_data->fbCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h);
  13.239 -    if (!data->native_window) {
  13.240 -        return SDL_SetError("MX6: Can't create native window");
  13.241 -    }
  13.242 -
  13.243 -    data->egl_surface = SDL_EGL_CreateSurface(_this, data->native_window);
  13.244 -    if (data->egl_surface == EGL_NO_SURFACE) {
  13.245 -        return SDL_SetError("MX6: Can't create EGL surface");
  13.246 -    }
  13.247 -
  13.248 -    /* Window has been successfully created */
  13.249 -    return 0;
  13.250 -}
  13.251 -
  13.252 -void
  13.253 -MX6_DestroyWindow(_THIS, SDL_Window * window)
  13.254 -{
  13.255 -    SDL_WindowData *data;
  13.256 -
  13.257 -    data = window->driverdata;
  13.258 -    if (data) {
  13.259 -        if (data->egl_surface != EGL_NO_SURFACE) {
  13.260 -            SDL_EGL_DestroySurface(_this, data->egl_surface);
  13.261 -        }
  13.262 -
  13.263 -        if (data->native_window) {
  13.264 -            egl_viv_data->fbDestroyWindow(data->native_window);
  13.265 -        }
  13.266 -
  13.267 -        SDL_free(data);
  13.268 -    }
  13.269 -    window->driverdata = NULL;
  13.270 -}
  13.271 -
  13.272 -int
  13.273 -MX6_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
  13.274 -{
  13.275 -    return SDL_Unsupported();
  13.276 -}
  13.277 -
  13.278 -void
  13.279 -MX6_SetWindowTitle(_THIS, SDL_Window * window)
  13.280 -{
  13.281 -}
  13.282 -void
  13.283 -MX6_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
  13.284 -{
  13.285 -}
  13.286 -void
  13.287 -MX6_SetWindowPosition(_THIS, SDL_Window * window)
  13.288 -{
  13.289 -}
  13.290 -void
  13.291 -MX6_SetWindowSize(_THIS, SDL_Window * window)
  13.292 -{
  13.293 -}
  13.294 -void
  13.295 -MX6_ShowWindow(_THIS, SDL_Window * window)
  13.296 -{
  13.297 -}
  13.298 -void
  13.299 -MX6_HideWindow(_THIS, SDL_Window * window)
  13.300 -{
  13.301 -}
  13.302 -void
  13.303 -MX6_RaiseWindow(_THIS, SDL_Window * window)
  13.304 -{
  13.305 -}
  13.306 -void
  13.307 -MX6_MaximizeWindow(_THIS, SDL_Window * window)
  13.308 -{
  13.309 -}
  13.310 -void
  13.311 -MX6_MinimizeWindow(_THIS, SDL_Window * window)
  13.312 -{
  13.313 -}
  13.314 -void
  13.315 -MX6_RestoreWindow(_THIS, SDL_Window * window)
  13.316 -{
  13.317 -}
  13.318 -void
  13.319 -MX6_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
  13.320 -{
  13.321 -}
  13.322 -
  13.323 -/*****************************************************************************/
  13.324 -/* SDL Window Manager function                                               */
  13.325 -/*****************************************************************************/
  13.326 -SDL_bool
  13.327 -MX6_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
  13.328 -{
  13.329 -    return SDL_TRUE;
  13.330 -}
  13.331 -
  13.332 -#endif /* SDL_VIDEO_DRIVER_MX6 */
  13.333 -
  13.334 -/* vi: set ts=4 sw=4 expandtab: */
    14.1 --- a/src/video/mx6/SDL_mx6video.h	Wed Oct 15 09:14:09 2014 -0700
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,75 +0,0 @@
    14.4 -/*
    14.5 -  Simple DirectMedia Layer
    14.6 -  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
    14.7 -
    14.8 -  This software is provided 'as-is', without any express or implied
    14.9 -  warranty.  In no event will the authors be held liable for any damages
   14.10 -  arising from the use of this software.
   14.11 -
   14.12 -  Permission is granted to anyone to use this software for any purpose,
   14.13 -  including commercial applications, and to alter it and redistribute it
   14.14 -  freely, subject to the following restrictions:
   14.15 -
   14.16 -  1. The origin of this software must not be misrepresented; you must not
   14.17 -     claim that you wrote the original software. If you use this software
   14.18 -     in a product, an acknowledgment in the product documentation would be
   14.19 -     appreciated but is not required.
   14.20 -  2. Altered source versions must be plainly marked as such, and must not be
   14.21 -     misrepresented as being the original software.
   14.22 -  3. This notice may not be removed or altered from any source distribution.
   14.23 -*/
   14.24 -
   14.25 -#ifndef __SDL_MX6VIDEO_H__
   14.26 -#define __SDL_MX6VIDEO_H__
   14.27 -
   14.28 -#include "../../SDL_internal.h"
   14.29 -#include "../SDL_sysvideo.h"
   14.30 -
   14.31 -#include "SDL_egl.h"
   14.32 -
   14.33 -typedef struct SDL_VideoData
   14.34 -{
   14.35 -} SDL_VideoData;
   14.36 -
   14.37 -typedef struct SDL_DisplayData
   14.38 -{
   14.39 -    EGLNativeDisplayType native_display;
   14.40 -} SDL_DisplayData;
   14.41 -
   14.42 -typedef struct SDL_WindowData
   14.43 -{
   14.44 -    EGLNativeWindowType native_window;
   14.45 -    EGLSurface egl_surface;
   14.46 -} SDL_WindowData;
   14.47 -
   14.48 -/****************************************************************************/
   14.49 -/* SDL_VideoDevice functions declaration                                    */
   14.50 -/****************************************************************************/
   14.51 -
   14.52 -/* Display and window functions */
   14.53 -int MX6_VideoInit(_THIS);
   14.54 -void MX6_VideoQuit(_THIS);
   14.55 -void MX6_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
   14.56 -int MX6_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
   14.57 -int MX6_CreateWindow(_THIS, SDL_Window * window);
   14.58 -int MX6_CreateWindowFrom(_THIS, SDL_Window * window, const void *data);
   14.59 -void MX6_SetWindowTitle(_THIS, SDL_Window * window);
   14.60 -void MX6_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon);
   14.61 -void MX6_SetWindowPosition(_THIS, SDL_Window * window);
   14.62 -void MX6_SetWindowSize(_THIS, SDL_Window * window);
   14.63 -void MX6_ShowWindow(_THIS, SDL_Window * window);
   14.64 -void MX6_HideWindow(_THIS, SDL_Window * window);
   14.65 -void MX6_RaiseWindow(_THIS, SDL_Window * window);
   14.66 -void MX6_MaximizeWindow(_THIS, SDL_Window * window);
   14.67 -void MX6_MinimizeWindow(_THIS, SDL_Window * window);
   14.68 -void MX6_RestoreWindow(_THIS, SDL_Window * window);
   14.69 -void MX6_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
   14.70 -void MX6_DestroyWindow(_THIS, SDL_Window * window);
   14.71 -
   14.72 -/* Window manager function */
   14.73 -SDL_bool MX6_GetWindowWMInfo(_THIS, SDL_Window * window,
   14.74 -                             struct SDL_SysWMinfo *info);
   14.75 -
   14.76 -#endif /* __SDL_MX6VIDEO_H__ */
   14.77 -
   14.78 -/* vi: set ts=4 sw=4 expandtab: */
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/src/video/vivante/SDL_vivanteopengles.c	Wed Oct 15 09:18:17 2014 -0700
    15.3 @@ -0,0 +1,47 @@
    15.4 +/*
    15.5 +  Simple DirectMedia Layer
    15.6 +  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
    15.7 +
    15.8 +  This software is provided 'as-is', without any express or implied
    15.9 +  warranty.  In no event will the authors be held liable for any damages
   15.10 +  arising from the use of this software.
   15.11 +
   15.12 +  Permission is granted to anyone to use this software for any purpose,
   15.13 +  including commercial applications, and to alter it and redistribute it
   15.14 +  freely, subject to the following restrictions:
   15.15 +
   15.16 +  1. The origin of this software must not be misrepresented; you must not
   15.17 +     claim that you wrote the original software. If you use this software
   15.18 +     in a product, an acknowledgment in the product documentation would be
   15.19 +     appreciated but is not required.
   15.20 +  2. Altered source versions must be plainly marked as such, and must not be
   15.21 +     misrepresented as being the original software.
   15.22 +  3. This notice may not be removed or altered from any source distribution.
   15.23 +*/
   15.24 +#include "../../SDL_internal.h"
   15.25 +
   15.26 +#if SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL
   15.27 +
   15.28 +#include "SDL_vivanteopengles.h"
   15.29 +#include "SDL_vivantevideo.h"
   15.30 +
   15.31 +/* EGL implementation of SDL OpenGL support */
   15.32 +
   15.33 +int
   15.34 +VIVANTE_GLES_LoadLibrary(_THIS, const char *path)
   15.35 +{
   15.36 +    SDL_DisplayData *displaydata;
   15.37 +
   15.38 +    displaydata = SDL_GetDisplayDriverData(0);
   15.39 +
   15.40 +    return SDL_EGL_LoadLibrary(_this, path, displaydata->native_display);
   15.41 +}
   15.42 +
   15.43 +SDL_EGL_CreateContext_impl(VIVANTE)
   15.44 +SDL_EGL_SwapWindow_impl(VIVANTE)
   15.45 +SDL_EGL_MakeCurrent_impl(VIVANTE)
   15.46 +
   15.47 +#endif /* SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL */
   15.48 +
   15.49 +/* vi: set ts=4 sw=4 expandtab: */
   15.50 +
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/src/video/vivante/SDL_vivanteopengles.h	Wed Oct 15 09:18:17 2014 -0700
    16.3 @@ -0,0 +1,48 @@
    16.4 +/*
    16.5 +  Simple DirectMedia Layer
    16.6 +  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
    16.7 +
    16.8 +  This software is provided 'as-is', without any express or implied
    16.9 +  warranty.  In no event will the authors be held liable for any damages
   16.10 +  arising from the use of this software.
   16.11 +
   16.12 +  Permission is granted to anyone to use this software for any purpose,
   16.13 +  including commercial applications, and to alter it and redistribute it
   16.14 +  freely, subject to the following restrictions:
   16.15 +
   16.16 +  1. The origin of this software must not be misrepresented; you must not
   16.17 +     claim that you wrote the original software. If you use this software
   16.18 +     in a product, an acknowledgment in the product documentation would be
   16.19 +     appreciated but is not required.
   16.20 +  2. Altered source versions must be plainly marked as such, and must not be
   16.21 +     misrepresented as being the original software.
   16.22 +  3. This notice may not be removed or altered from any source distribution.
   16.23 +*/
   16.24 +#include "../../SDL_internal.h"
   16.25 +
   16.26 +#ifndef _SDL_vivanteopengles_h
   16.27 +#define _SDL_vivanteopengles_h
   16.28 +
   16.29 +#if SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL
   16.30 +
   16.31 +#include "../SDL_sysvideo.h"
   16.32 +#include "../SDL_egl_c.h"
   16.33 +
   16.34 +/* OpenGLES functions */
   16.35 +#define VIVANTE_GLES_GetAttribute SDL_EGL_GetAttribute
   16.36 +#define VIVANTE_GLES_GetProcAddress SDL_EGL_GetProcAddress
   16.37 +#define VIVANTE_GLES_UnloadLibrary SDL_EGL_UnloadLibrary
   16.38 +#define VIVANTE_GLES_SetSwapInterval SDL_EGL_SetSwapInterval
   16.39 +#define VIVANTE_GLES_GetSwapInterval SDL_EGL_GetSwapInterval
   16.40 +#define VIVANTE_GLES_DeleteContext SDL_EGL_DeleteContext
   16.41 +
   16.42 +extern int VIVANTE_GLES_LoadLibrary(_THIS, const char *path);
   16.43 +extern SDL_GLContext VIVANTE_GLES_CreateContext(_THIS, SDL_Window * window);
   16.44 +extern void VIVANTE_GLES_SwapWindow(_THIS, SDL_Window * window);
   16.45 +extern int VIVANTE_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context);
   16.46 +
   16.47 +#endif /* SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL */
   16.48 +
   16.49 +#endif /* _SDL_vivanteopengles_h */
   16.50 +
   16.51 +/* vi: set ts=4 sw=4 expandtab: */
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/src/video/vivante/SDL_vivanteplatform.c	Wed Oct 15 09:18:17 2014 -0700
    17.3 @@ -0,0 +1,38 @@
    17.4 +/*
    17.5 +  Simple DirectMedia Layer
    17.6 +  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
    17.7 +
    17.8 +  This software is provided 'as-is', without any express or implied
    17.9 +  warranty.  In no event will the authors be held liable for any damages
   17.10 +  arising from the use of this software.
   17.11 +
   17.12 +  Permission is granted to anyone to use this software for any purpose,
   17.13 +  including commercial applications, and to alter it and redistribute it
   17.14 +  freely, subject to the following restrictions:
   17.15 +
   17.16 +  1. The origin of this software must not be misrepresented; you must not
   17.17 +     claim that you wrote the original software. If you use this software
   17.18 +     in a product, an acknowledgment in the product documentation would be
   17.19 +     appreciated but is not required.
   17.20 +  2. Altered source versions must be plainly marked as such, and must not be
   17.21 +     misrepresented as being the original software.
   17.22 +  3. This notice may not be removed or altered from any source distribution.
   17.23 +*/
   17.24 +#include "../../SDL_internal.h"
   17.25 +
   17.26 +#if SDL_VIDEO_DRIVER_VIVANTE
   17.27 +
   17.28 +#include "SDL_vivanteplatform.h"
   17.29 +
   17.30 +#ifdef VIVANTE_PLATFORM_GENERIC
   17.31 +
   17.32 +int VIVANTE_SetupPlatform(_THIS)
   17.33 +{
   17.34 +    return 0;
   17.35 +}
   17.36 +
   17.37 +#endif /* VIVANTE_PLATFORM_GENERIC */
   17.38 +
   17.39 +#endif /* SDL_VIDEO_DRIVER_VIVANTE */
   17.40 +
   17.41 +/* vi: set ts=4 sw=4 expandtab: */
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/src/video/vivante/SDL_vivanteplatform.h	Wed Oct 15 09:18:17 2014 -0700
    18.3 @@ -0,0 +1,44 @@
    18.4 +/*
    18.5 +  Simple DirectMedia Layer
    18.6 +  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
    18.7 +
    18.8 +  This software is provided 'as-is', without any express or implied
    18.9 +  warranty.  In no event will the authors be held liable for any damages
   18.10 +  arising from the use of this software.
   18.11 +
   18.12 +  Permission is granted to anyone to use this software for any purpose,
   18.13 +  including commercial applications, and to alter it and redistribute it
   18.14 +  freely, subject to the following restrictions:
   18.15 +
   18.16 +  1. The origin of this software must not be misrepresented; you must not
   18.17 +     claim that you wrote the original software. If you use this software
   18.18 +     in a product, an acknowledgment in the product documentation would be
   18.19 +     appreciated but is not required.
   18.20 +  2. Altered source versions must be plainly marked as such, and must not be
   18.21 +     misrepresented as being the original software.
   18.22 +  3. This notice may not be removed or altered from any source distribution.
   18.23 +*/
   18.24 +#include "../../SDL_internal.h"
   18.25 +
   18.26 +#ifndef _SDL_vivanteplatform_h
   18.27 +#define _SDL_vivanteplatform_h
   18.28 +
   18.29 +#if SDL_VIDEO_DRIVER_VIVANTE
   18.30 +
   18.31 +#include "SDL_vivantevideo.h"
   18.32 +
   18.33 +#if defined(CAVIUM)
   18.34 +#define VIVANTE_PLATFORM_CAVIUM
   18.35 +#elif defined(MARVELL)
   18.36 +#define VIVANTE_PLATFORM_MARVELL
   18.37 +#else
   18.38 +#define VIVANTE_PLATFORM_GENERIC
   18.39 +#endif
   18.40 +
   18.41 +extern int VIVANTE_SetupPlatform(_THIS);
   18.42 +
   18.43 +#endif /* SDL_VIDEO_DRIVER_VIVANTE */
   18.44 +
   18.45 +#endif /* _SDL_vivanteplatform_h */
   18.46 +
   18.47 +/* vi: set ts=4 sw=4 expandtab: */
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/src/video/vivante/SDL_vivantevideo.c	Wed Oct 15 09:18:17 2014 -0700
    19.3 @@ -0,0 +1,397 @@
    19.4 +/*
    19.5 +  Simple DirectMedia Layer
    19.6 +  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
    19.7 +
    19.8 +  This software is provided 'as-is', without any express or implied
    19.9 +  warranty.  In no event will the authors be held liable for any damages
   19.10 +  arising from the use of this software.
   19.11 +
   19.12 +  Permission is granted to anyone to use this software for any purpose,
   19.13 +  including commercial applications, and to alter it and redistribute it
   19.14 +  freely, subject to the following restrictions:
   19.15 +
   19.16 +  1. The origin of this software must not be misrepresented; you must not
   19.17 +     claim that you wrote the original software. If you use this software
   19.18 +     in a product, an acknowledgment in the product documentation would be
   19.19 +     appreciated but is not required.
   19.20 +  2. Altered source versions must be plainly marked as such, and must not be
   19.21 +     misrepresented as being the original software.
   19.22 +  3. This notice may not be removed or altered from any source distribution.
   19.23 +*/
   19.24 +#include "../../SDL_internal.h"
   19.25 +
   19.26 +#if SDL_VIDEO_DRIVER_VIVANTE
   19.27 +
   19.28 +/* SDL internals */
   19.29 +#include "../SDL_sysvideo.h"
   19.30 +#include "SDL_version.h"
   19.31 +#include "SDL_syswm.h"
   19.32 +#include "SDL_loadso.h"
   19.33 +#include "SDL_events.h"
   19.34 +#include "../../events/SDL_events_c.h"
   19.35 +
   19.36 +#ifdef SDL_INPUT_LINUXEV
   19.37 +#include "../../core/linux/SDL_evdev.h"
   19.38 +#endif
   19.39 +
   19.40 +#include "SDL_vivantevideo.h"
   19.41 +#include "SDL_vivanteplatform.h"
   19.42 +#include "SDL_vivanteopengles.h"
   19.43 +
   19.44 +
   19.45 +static int
   19.46 +VIVANTE_Available(void)
   19.47 +{
   19.48 +    return 1;
   19.49 +}
   19.50 +
   19.51 +static void
   19.52 +VIVANTE_Destroy(SDL_VideoDevice * device)
   19.53 +{
   19.54 +    if (device->driverdata != NULL) {
   19.55 +        SDL_free(device->driverdata);
   19.56 +        device->driverdata = NULL;
   19.57 +    }
   19.58 +}
   19.59 +
   19.60 +static SDL_VideoDevice *
   19.61 +VIVANTE_Create()
   19.62 +{
   19.63 +    SDL_VideoDevice *device;
   19.64 +    SDL_VideoData *data;
   19.65 +
   19.66 +    /* Initialize SDL_VideoDevice structure */
   19.67 +    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
   19.68 +    if (device == NULL) {
   19.69 +        SDL_OutOfMemory();
   19.70 +        return NULL;
   19.71 +    }
   19.72 +
   19.73 +    /* Initialize internal data */
   19.74 +    data = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
   19.75 +    if (data == NULL) {
   19.76 +        SDL_OutOfMemory();
   19.77 +        SDL_free(device);
   19.78 +        return NULL;
   19.79 +    }
   19.80 +
   19.81 +    device->driverdata = data;
   19.82 +
   19.83 +    /* Setup amount of available displays and current display */
   19.84 +    device->num_displays = 0;
   19.85 +
   19.86 +    /* Set device free function */
   19.87 +    device->free = VIVANTE_Destroy;
   19.88 +
   19.89 +    /* Setup all functions which we can handle */
   19.90 +    device->VideoInit = VIVANTE_VideoInit;
   19.91 +    device->VideoQuit = VIVANTE_VideoQuit;
   19.92 +    device->GetDisplayModes = VIVANTE_GetDisplayModes;
   19.93 +    device->SetDisplayMode = VIVANTE_SetDisplayMode;
   19.94 +    device->CreateWindow = VIVANTE_CreateWindow;
   19.95 +    device->SetWindowTitle = VIVANTE_SetWindowTitle;
   19.96 +    device->SetWindowPosition = VIVANTE_SetWindowPosition;
   19.97 +    device->SetWindowSize = VIVANTE_SetWindowSize;
   19.98 +    device->ShowWindow = VIVANTE_ShowWindow;
   19.99 +    device->HideWindow = VIVANTE_HideWindow;
  19.100 +    device->DestroyWindow = VIVANTE_DestroyWindow;
  19.101 +    device->GetWindowWMInfo = VIVANTE_GetWindowWMInfo;
  19.102 +
  19.103 +    device->GL_LoadLibrary = VIVANTE_GLES_LoadLibrary;
  19.104 +    device->GL_GetProcAddress = VIVANTE_GLES_GetProcAddress;
  19.105 +    device->GL_UnloadLibrary = VIVANTE_GLES_UnloadLibrary;
  19.106 +    device->GL_CreateContext = VIVANTE_GLES_CreateContext;
  19.107 +    device->GL_MakeCurrent = VIVANTE_GLES_MakeCurrent;
  19.108 +    device->GL_SetSwapInterval = VIVANTE_GLES_SetSwapInterval;
  19.109 +    device->GL_GetSwapInterval = VIVANTE_GLES_GetSwapInterval;
  19.110 +    device->GL_SwapWindow = VIVANTE_GLES_SwapWindow;
  19.111 +    device->GL_DeleteContext = VIVANTE_GLES_DeleteContext;
  19.112 +
  19.113 +    device->PumpEvents = VIVANTE_PumpEvents;
  19.114 +
  19.115 +    return device;
  19.116 +}
  19.117 +
  19.118 +VideoBootStrap VIVANTE_bootstrap = {
  19.119 +    "vivante",
  19.120 +    "Vivante EGL Video Driver",
  19.121 +    VIVANTE_Available,
  19.122 +    VIVANTE_Create
  19.123 +};
  19.124 +
  19.125 +/*****************************************************************************/
  19.126 +/* SDL Video and Display initialization/handling functions                   */
  19.127 +/*****************************************************************************/
  19.128 +
  19.129 +static int
  19.130 +VIVANTE_AddVideoDisplays(_THIS)
  19.131 +{
  19.132 +    SDL_VideoData *videodata = _this->driverdata;
  19.133 +    SDL_VideoDisplay display;
  19.134 +    SDL_DisplayMode current_mode;
  19.135 +    SDL_DisplayData *data;
  19.136 +    int pitch = 0, bpp = 0;
  19.137 +    unsigned long pixels = 0;
  19.138 +
  19.139 +    data = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData));
  19.140 +    if (data == NULL) {
  19.141 +        return SDL_OutOfMemory();
  19.142 +    }
  19.143 +
  19.144 +    SDL_zero(current_mode);
  19.145 +#if SDL_VIDEO_DRIVER_VIVANTE_VDK
  19.146 +    data->native_display = vdkGetDisplay(videodata->vdk_private);
  19.147 +
  19.148 +    vdkGetDisplayInfo(data->native_display, &current_mode.w, &current_mode.h, &pixels, &pitch, &bpp);
  19.149 +#else
  19.150 +    data->native_display = videodata->fbGetDisplayByIndex(0);
  19.151 +
  19.152 +    videodata->fbGetDisplayInfo(data->native_display, &current_mode.w, &current_mode.h, &pixels, &pitch, &bpp);
  19.153 +#endif /* SDL_VIDEO_DRIVER_VIVANTE_VDK */
  19.154 +
  19.155 +    switch (bpp)
  19.156 +    {
  19.157 +    default: /* Is another format used? */
  19.158 +    case 16:
  19.159 +        current_mode.format = SDL_PIXELFORMAT_RGB565;
  19.160 +        break;
  19.161 +    }
  19.162 +    /* FIXME: How do we query refresh rate? */
  19.163 +    current_mode.refresh_rate = 60;
  19.164 +
  19.165 +    SDL_zero(display);
  19.166 +    display.desktop_mode = current_mode;
  19.167 +    display.current_mode = current_mode;
  19.168 +    display.driverdata = data;
  19.169 +    SDL_AddVideoDisplay(&display);
  19.170 +    return 0;
  19.171 +}
  19.172 +
  19.173 +int
  19.174 +VIVANTE_VideoInit(_THIS)
  19.175 +{
  19.176 +    SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
  19.177 +
  19.178 +#if SDL_VIDEO_DRIVER_VIVANTE_VDK
  19.179 +    videodata->vdk_private = vdkInitialize();
  19.180 +    if (!videodata->vdk_private) {
  19.181 +        return SDL_SetError("vdkInitialize() failed");
  19.182 +    }
  19.183 +#else
  19.184 +    videodata->egl_handle = SDL_LoadObject("libEGL.so.1");
  19.185 +    if (!videodata->egl_handle) {
  19.186 +        videodata->egl_handle = SDL_LoadObject("libEGL.so");
  19.187 +        if (!videodata->egl_handle) {
  19.188 +            return -1;
  19.189 +        }
  19.190 +    }
  19.191 +#define LOAD_FUNC(NAME) \
  19.192 +    videodata->NAME = SDL_LoadFunction(videodata->egl_handle, #NAME); \
  19.193 +    if (!videodata->NAME) return -1;
  19.194 +
  19.195 +    LOAD_FUNC(fbGetDisplay);
  19.196 +    LOAD_FUNC(fbGetDisplayByIndex);
  19.197 +    LOAD_FUNC(fbGetDisplayGeometry);
  19.198 +    LOAD_FUNC(fbGetDisplayInfo);
  19.199 +    LOAD_FUNC(fbDestroyDisplay);
  19.200 +    LOAD_FUNC(fbCreateWindow);
  19.201 +    LOAD_FUNC(fbGetWindowGeometry);
  19.202 +    LOAD_FUNC(fbGetWindowInfo);
  19.203 +    LOAD_FUNC(fbDestroyWindow);
  19.204 +#endif
  19.205 +
  19.206 +    if (VIVANTE_SetupPlatform(_this) < 0) {
  19.207 +        return -1;
  19.208 +    }
  19.209 +
  19.210 +    if (VIVANTE_AddVideoDisplays(_this) < 0) {
  19.211 +        return -1;
  19.212 +    }
  19.213 +
  19.214 +#ifdef SDL_INPUT_LINUXEV
  19.215 +    if (SDL_EVDEV_Init() < 0) {
  19.216 +        return -1;
  19.217 +    }
  19.218 +#endif
  19.219 +
  19.220 +    return 0;
  19.221 +}
  19.222 +
  19.223 +void
  19.224 +VIVANTE_VideoQuit(_THIS)
  19.225 +{
  19.226 +    SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
  19.227 +
  19.228 +#ifdef SDL_INPUT_LINUXEV
  19.229 +    SDL_EVDEV_Quit();
  19.230 +#endif
  19.231 +
  19.232 +#if SDL_VIDEO_DRIVER_VIVANTE_VDK
  19.233 +    if (videodata->vdk_private) {
  19.234 +        vdkExit(videodata->vdk_private);
  19.235 +        videodata->vdk_private = NULL;
  19.236 +    }
  19.237 +#else
  19.238 +    if (videodata->egl_handle) {
  19.239 +        SDL_UnloadObject(videodata->egl_handle);
  19.240 +        videodata->egl_handle = NULL;
  19.241 +    }
  19.242 +#endif
  19.243 +}
  19.244 +
  19.245 +void
  19.246 +VIVANTE_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
  19.247 +{
  19.248 +    /* Only one display mode available, the current one */
  19.249 +    SDL_AddDisplayMode(display, &display->current_mode);
  19.250 +}
  19.251 +
  19.252 +int
  19.253 +VIVANTE_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
  19.254 +{
  19.255 +    return 0;
  19.256 +}
  19.257 +
  19.258 +int
  19.259 +VIVANTE_CreateWindow(_THIS, SDL_Window * window)
  19.260 +{
  19.261 +    SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
  19.262 +    SDL_DisplayData *displaydata;
  19.263 +    SDL_WindowData *data;
  19.264 +
  19.265 +    displaydata = SDL_GetDisplayDriverData(0);
  19.266 +
  19.267 +    /* Allocate window internal data */
  19.268 +    data = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
  19.269 +    if (data == NULL) {
  19.270 +        return SDL_OutOfMemory();
  19.271 +    }
  19.272 +
  19.273 +    /* Setup driver data for this window */
  19.274 +    window->driverdata = data;
  19.275 +
  19.276 +#if SDL_VIDEO_DRIVER_VIVANTE_VDK
  19.277 +    data->native_window = vdkCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h);
  19.278 +#else
  19.279 +    data->native_window = videodata->fbCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h);
  19.280 +#endif
  19.281 +    if (!data->native_window) {
  19.282 +        return SDL_SetError("VIVANTE: Can't create native window");
  19.283 +    }
  19.284 +
  19.285 +    if (window->flags & SDL_WINDOW_OPENGL) {
  19.286 +        data->egl_surface = SDL_EGL_CreateSurface(_this, data->native_window);
  19.287 +        if (data->egl_surface == EGL_NO_SURFACE) {
  19.288 +            return SDL_SetError("VIVANTE: Can't create EGL surface");
  19.289 +        }
  19.290 +    } else {
  19.291 +        data->egl_surface = EGL_NO_SURFACE;
  19.292 +    }
  19.293 +
  19.294 +    /* Window has been successfully created */
  19.295 +    return 0;
  19.296 +}
  19.297 +
  19.298 +void
  19.299 +VIVANTE_DestroyWindow(_THIS, SDL_Window * window)
  19.300 +{
  19.301 +    SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
  19.302 +    SDL_WindowData *data;
  19.303 +
  19.304 +    data = window->driverdata;
  19.305 +    if (data) {
  19.306 +        if (data->egl_surface != EGL_NO_SURFACE) {
  19.307 +            SDL_EGL_DestroySurface(_this, data->egl_surface);
  19.308 +        }
  19.309 +
  19.310 +        if (data->native_window) {
  19.311 +#if SDL_VIDEO_DRIVER_VIVANTE_VDK
  19.312 +            vdkDestroyWindow(data->native_window);
  19.313 +#else
  19.314 +            videodata->fbDestroyWindow(data->native_window);
  19.315 +#endif
  19.316 +        }
  19.317 +
  19.318 +        SDL_free(data);
  19.319 +    }
  19.320 +    window->driverdata = NULL;
  19.321 +}
  19.322 +
  19.323 +void
  19.324 +VIVANTE_SetWindowTitle(_THIS, SDL_Window * window)
  19.325 +{
  19.326 +#if SDL_VIDEO_DRIVER_VIVANTE_VDK
  19.327 +    SDL_WindowData *data = window->driverdata;
  19.328 +    vdkSetWindowTitle(data->native_window, window->title);
  19.329 +#endif
  19.330 +}
  19.331 +
  19.332 +void
  19.333 +VIVANTE_SetWindowPosition(_THIS, SDL_Window * window)
  19.334 +{
  19.335 +    /* FIXME */
  19.336 +}
  19.337 +
  19.338 +void
  19.339 +VIVANTE_SetWindowSize(_THIS, SDL_Window * window)
  19.340 +{
  19.341 +    /* FIXME */
  19.342 +}
  19.343 +
  19.344 +void
  19.345 +VIVANTE_ShowWindow(_THIS, SDL_Window * window)
  19.346 +{
  19.347 +#if SDL_VIDEO_DRIVER_VIVANTE_VDK
  19.348 +    SDL_WindowData *data = window->driverdata;
  19.349 +    vdkShowWindow(data->native_window);
  19.350 +#endif
  19.351 +    SDL_SetMouseFocus(window);
  19.352 +    SDL_SetKeyboardFocus(window);
  19.353 +}
  19.354 +
  19.355 +void
  19.356 +VIVANTE_HideWindow(_THIS, SDL_Window * window)
  19.357 +{
  19.358 +#if SDL_VIDEO_DRIVER_VIVANTE_VDK
  19.359 +    SDL_WindowData *data = window->driverdata;
  19.360 +    vdkHideWindow(data->native_window);
  19.361 +#endif
  19.362 +}
  19.363 +
  19.364 +/*****************************************************************************/
  19.365 +/* SDL Window Manager function                                               */
  19.366 +/*****************************************************************************/
  19.367 +SDL_bool
  19.368 +VIVANTE_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
  19.369 +{
  19.370 +/*
  19.371 +    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
  19.372 +
  19.373 +    if (info->version.major == SDL_MAJOR_VERSION &&
  19.374 +        info->version.minor == SDL_MINOR_VERSION) {
  19.375 +        info->subsystem = SDL_SYSWM_VIVANTE;
  19.376 +        info->info.vivante.window = data->native_window;
  19.377 +        return SDL_TRUE;
  19.378 +    } else {
  19.379 +        SDL_SetError("Application not compiled with SDL %d.%d\n",
  19.380 +                     SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
  19.381 +        return SDL_FALSE;
  19.382 +    }
  19.383 +*/
  19.384 +    SDL_Unsupported();
  19.385 +    return SDL_FALSE;
  19.386 +}
  19.387 +
  19.388 +/*****************************************************************************/
  19.389 +/* SDL event functions                                                       */
  19.390 +/*****************************************************************************/
  19.391 +void VIVANTE_PumpEvents(_THIS)
  19.392 +{
  19.393 +#ifdef SDL_INPUT_LINUXEV
  19.394 +    SDL_EVDEV_Poll();
  19.395 +#endif
  19.396 +}
  19.397 +
  19.398 +#endif /* SDL_VIDEO_DRIVER_VIVANTE */
  19.399 +
  19.400 +/* vi: set ts=4 sw=4 expandtab: */
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/src/video/vivante/SDL_vivantevideo.h	Wed Oct 15 09:18:17 2014 -0700
    20.3 @@ -0,0 +1,91 @@
    20.4 +/*
    20.5 +  Simple DirectMedia Layer
    20.6 +  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
    20.7 +
    20.8 +  This software is provided 'as-is', without any express or implied
    20.9 +  warranty.  In no event will the authors be held liable for any damages
   20.10 +  arising from the use of this software.
   20.11 +
   20.12 +  Permission is granted to anyone to use this software for any purpose,
   20.13 +  including commercial applications, and to alter it and redistribute it
   20.14 +  freely, subject to the following restrictions:
   20.15 +
   20.16 +  1. The origin of this software must not be misrepresented; you must not
   20.17 +     claim that you wrote the original software. If you use this software
   20.18 +     in a product, an acknowledgment in the product documentation would be
   20.19 +     appreciated but is not required.
   20.20 +  2. Altered source versions must be plainly marked as such, and must not be
   20.21 +     misrepresented as being the original software.
   20.22 +  3. This notice may not be removed or altered from any source distribution.
   20.23 +*/
   20.24 +
   20.25 +#ifndef _SDL_vivantevideo_h
   20.26 +#define _SDL_vivantevideo_h
   20.27 +
   20.28 +#include "../../SDL_internal.h"
   20.29 +#include "../SDL_sysvideo.h"
   20.30 +
   20.31 +#include "SDL_egl.h"
   20.32 +
   20.33 +#if SDL_VIDEO_DRIVER_VIVANTE_VDK
   20.34 +#include <gc_vdk.h>
   20.35 +#else
   20.36 +#include <EGL/egl.h>
   20.37 +#endif
   20.38 +
   20.39 +typedef struct SDL_VideoData
   20.40 +{
   20.41 +#if SDL_VIDEO_DRIVER_VIVANTE_VDK
   20.42 +    vdkPrivate vdk_private;
   20.43 +#else
   20.44 +    void *egl_handle; /* EGL shared library handle */
   20.45 +    EGLNativeDisplayType (EGLAPIENTRY *fbGetDisplay)(void *context);
   20.46 +    EGLNativeDisplayType (EGLAPIENTRY *fbGetDisplayByIndex)(int DisplayIndex);
   20.47 +    void (EGLAPIENTRY *fbGetDisplayGeometry)(EGLNativeDisplayType Display, int *Width, int *Height);
   20.48 +    void (EGLAPIENTRY *fbGetDisplayInfo)(EGLNativeDisplayType Display, int *Width, int *Height, unsigned long *Physical, int *Stride, int *BitsPerPixel);
   20.49 +    void (EGLAPIENTRY *fbDestroyDisplay)(EGLNativeDisplayType Display);
   20.50 +    EGLNativeWindowType (EGLAPIENTRY *fbCreateWindow)(EGLNativeDisplayType Display, int X, int Y, int Width, int Height);
   20.51 +    void (EGLAPIENTRY *fbGetWindowGeometry)(EGLNativeWindowType Window, int *X, int *Y, int *Width, int *Height);
   20.52 +    void (EGLAPIENTRY *fbGetWindowInfo)(EGLNativeWindowType Window, int *X, int *Y, int *Width, int *Height, int *BitsPerPixel, unsigned int *Offset);
   20.53 +    void (EGLAPIENTRY *fbDestroyWindow)(EGLNativeWindowType Window);
   20.54 +#endif
   20.55 +} SDL_VideoData;
   20.56 +
   20.57 +typedef struct SDL_DisplayData
   20.58 +{
   20.59 +    EGLNativeDisplayType native_display;
   20.60 +} SDL_DisplayData;
   20.61 +
   20.62 +typedef struct SDL_WindowData
   20.63 +{
   20.64 +    EGLNativeWindowType native_window;
   20.65 +    EGLSurface egl_surface;
   20.66 +} SDL_WindowData;
   20.67 +
   20.68 +/****************************************************************************/
   20.69 +/* SDL_VideoDevice functions declaration                                    */
   20.70 +/****************************************************************************/
   20.71 +
   20.72 +/* Display and window functions */
   20.73 +int VIVANTE_VideoInit(_THIS);
   20.74 +void VIVANTE_VideoQuit(_THIS);
   20.75 +void VIVANTE_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
   20.76 +int VIVANTE_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
   20.77 +int VIVANTE_CreateWindow(_THIS, SDL_Window * window);
   20.78 +void VIVANTE_SetWindowTitle(_THIS, SDL_Window * window);
   20.79 +void VIVANTE_SetWindowPosition(_THIS, SDL_Window * window);
   20.80 +void VIVANTE_SetWindowSize(_THIS, SDL_Window * window);
   20.81 +void VIVANTE_ShowWindow(_THIS, SDL_Window * window);
   20.82 +void VIVANTE_HideWindow(_THIS, SDL_Window * window);
   20.83 +void VIVANTE_DestroyWindow(_THIS, SDL_Window * window);
   20.84 +
   20.85 +/* Window manager function */
   20.86 +SDL_bool VIVANTE_GetWindowWMInfo(_THIS, SDL_Window * window,
   20.87 +                             struct SDL_SysWMinfo *info);
   20.88 +
   20.89 +/* Event functions */
   20.90 +void VIVANTE_PumpEvents(_THIS);
   20.91 +
   20.92 +#endif /* _SDL_vivantevideo_h */
   20.93 +
   20.94 +/* vi: set ts=4 sw=4 expandtab: */