Expanded the iMX6 video driver into a general Vivante video driver that works across multiple SoCs

main
Sam Lantinga 2014-10-15 09:18:17 -07:00
parent f7abb7c4e2
commit 251ca855f7
18 changed files with 690 additions and 747 deletions

View File

@ -247,7 +247,7 @@ endforeach()
set_option(VIDEO_COCOA "Use Cocoa video driver" ${APPLE})
set_option(DIRECTX "Use DirectX for Windows audio/video" ${WINDOWS})
set_option(RENDER_D3D "Enable the Direct3D render driver" ${WINDOWS})
set_option(VIDEO_MX6 "Use Freescale i.MX6 video driver" OFF)
set_option(VIDEO_VIVANTE "Use Vivante EGL video driver" ${UNIX_SYS})
# TODO: We should (should we?) respect cmake's ${BUILD_SHARED_LIBS} flag here
# The options below are for compatibility to configure's default behaviour.
@ -679,7 +679,7 @@ if(UNIX AND NOT APPLE)
CheckOpenGLX11()
CheckOpenGLESX11()
CheckWayland()
CheckMX6()
CheckVivante()
endif()
if(LINUX)

View File

@ -602,22 +602,33 @@ endmacro(CheckDirectFB)
# Requires:
# - n/a
macro(CheckMX6)
if(VIDEO_MX6)
macro(CheckVivante)
if(VIDEO_VIVANTE)
check_c_source_compiles("
#include <gc_vdk.h>
int main(int argc, char** argv) {}" HAVE_VIDEO_VIVANTE_VDK)
check_c_source_compiles("
#define LINUX
#define EGL_API_FB
#include <EGL/eglvivante.h>
int main(int argc, char** argv) {}" HAVE_VIDEO_OPENGL_EGL_VIVANTE)
if(HAVE_VIDEO_OPENGL_EGL_VIVANTE)
set(HAVE_VIDEO_MX6 TRUE)
int main(int argc, char** argv) {}" HAVE_VIDEO_VIVANTE_EGL_FB)
if(HAVE_VIDEO_VIVANTE_VDK OR HAVE_VIDEO_VIVANTE_EGL_FB)
set(HAVE_VIDEO_VIVANTE TRUE)
set(HAVE_SDL_VIDEO TRUE)
file(GLOB MX6_SOURCES ${SDL2_SOURCE_DIR}/src/video/mx6/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${MX6_SOURCES})
set(SDL_VIDEO_DRIVER_MX6 1)
endif(HAVE_VIDEO_OPENGL_EGL_VIVANTE)
endif(VIDEO_MX6)
endmacro(CheckMX6)
file(GLOB VIVANTE_SOURCES ${SDL2_SOURCE_DIR}/src/video/vivante/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${VIVANTE_SOURCES})
set(SDL_VIDEO_DRIVER_VIVANTE 1)
if(HAVE_VIDEO_VIVANTE_VDK)
set(SDL_VIDEO_DRIVER_VIVANTE_VDK 1)
list(APPEND EXTRA_LIBS VDK VIVANTE)
else
set(SDL_CFLAGS "${SDL_CFLAGS} -DLINUX -DEGL_API_FB")
list(APPEND EXTRA_LIBS EGL)
endif(HAVE_VIDEO_VIVANTE_VDK)
endif(HAVE_VIDEO_VIVANTE_VDK OR HAVE_VIDEO_VIVANTE_EGL_FB)
endif(VIDEO_VIVANTE)
endmacro(CheckVivante)
# Requires:
# - nada

View File

@ -1729,27 +1729,46 @@ AC_HELP_STRING([--enable-video-x11-vm], [use X11 VM extension for fullscreen [[d
fi
}
dnl Set up the MX6 video driver if enabled
CheckMX6Video()
dnl Set up the Vivante video driver if enabled
CheckVivanteVideo()
{
AC_ARG_ENABLE(video-mx6,
AC_HELP_STRING([--enable-video-mx6], [use Freescale i.MX6 video driver [[default=no]]]),
, enable_video_mx6=no)
if test x$enable_video = xyes -a x$enable_video_mx6 = xyes; then
AC_MSG_CHECKING(for Vivante GPU SDK)
have_viv_sdk=no
AC_ARG_ENABLE(video-vivante,
AC_HELP_STRING([--enable-video-vivante], [use Vivante EGL video driver [[default=yes]]]),
, enable_video_vivante=yes)
if test x$enable_video = xyes -a x$enable_video_vivante = xyes; then
AC_MSG_CHECKING(for Vivante VDK API)
have_vivante_vdk=no
AC_TRY_COMPILE([
#define LINUX
#define EGL_API_FB
#include <gc_vdk.h>
],[
],[
have_vivante_vdk=yes
])
AC_MSG_RESULT($have_vivante_vdk)
AC_MSG_CHECKING(for Vivante FB API)
have_vivante_egl=no
AC_TRY_COMPILE([
#define LINUX
#define EGL_API_FB
#include <EGL/eglvivante.h>
],[
],[
have_viv_sdk=yes
have_vivante_egl=yes
])
AC_MSG_RESULT($have_viv_sdk)
if test x$have_viv_sdk = xyes; then
AC_DEFINE(SDL_VIDEO_DRIVER_MX6, 1, [ ])
SOURCES="$SOURCES $srcdir/src/video/mx6/*.c"
SUMMARY_video="${SUMMARY_video} mx6"
AC_MSG_RESULT($have_vivante_egl)
if test x$have_vivante_vdk = xyes -o x$have_vivante_egl = xyes; then
AC_DEFINE(SDL_VIDEO_DRIVER_VIVANTE, 1, [ ])
EXTRA_CFLAGS="$EXTRA_CFLAGS -DLINUX -DEGL_API_FB"
if test x$have_vivante_vdk = xyes; then
AC_DEFINE(SDL_VIDEO_DRIVER_VIVANTE_VDK, 1, [ ])
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lVDK"
fi
SOURCES="$SOURCES $srcdir/src/video/vivante/*.c"
SUMMARY_video="${SUMMARY_video} vivante"
have_video=yes
fi
fi
@ -1987,9 +2006,10 @@ CheckOpenGLESX11()
AC_MSG_CHECKING(for EGL support)
video_opengl_egl=no
AC_TRY_COMPILE([
#define EGL_API_FB
#include <EGL/egl.h>
#include <EGL/eglext.h>
#define LINUX
#define EGL_API_FB
#include <EGL/egl.h>
#include <EGL/eglext.h>
],[
],[
video_opengl_egl=yes
@ -2268,10 +2288,10 @@ AC_HELP_STRING([--enable-pthreads], [use POSIX threads for multi-threading [[def
AC_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]]),
, enable_pthread_sem=yes)
case "$host" in
*-*-androideabi*)
*-*-androideabi*)
pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
pthread_lib=""
;;
;;
*-*-linux*|*-*-uclinux*)
pthread_cflags="-D_REENTRANT"
pthread_lib="-lpthread"
@ -2846,7 +2866,7 @@ case "$host" in
CheckClockGettime
CheckLinuxVersion
CheckRPATH
CheckMX6Video
CheckVivanteVideo
# Set up files for the audio library
if test x$enable_audio = xyes; then
case $ARCH in

View File

@ -264,7 +264,8 @@
#cmakedefine SDL_VIDEO_DRIVER_WINDOWS @SDL_VIDEO_DRIVER_WINDOWS@
#cmakedefine SDL_VIDEO_DRIVER_WAYLAND @SDL_VIDEO_DRIVER_WAYLAND@
#cmakedefine SDL_VIDEO_DRIVER_RPI @SDL_VIDEO_DRIVER_RPI@
#cmakedefine SDL_VIDEO_DRIVER_MX6 @SDL_VIDEO_DRIVER_MX6@
#cmakedefine SDL_VIDEO_DRIVER_VIVANTE @SDL_VIDEO_DRIVER_VIVANTE@
#cmakedefine SDL_VIDEO_DRIVER_VIVANTE_VDK @SDL_VIDEO_DRIVER_VIVANTE_VDK@
#if 0
/* !!! FIXME: in configure script version, missing here: */

View File

@ -308,7 +308,8 @@
#undef SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY
#undef SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
#undef SDL_VIDEO_DRIVER_NACL
#undef SDL_VIDEO_DRIVER_MX6
#undef SDL_VIDEO_DRIVER_VIVANTE
#undef SDL_VIDEO_DRIVER_VIVANTE_VDK
#undef SDL_VIDEO_RENDER_D3D
#undef SDL_VIDEO_RENDER_D3D11

View File

@ -38,7 +38,7 @@
#define DEFAULT_OGL_ES_PVR "/opt/vc/lib/libGLES_CM.so"
#define DEFAULT_OGL_ES "/opt/vc/lib/libGLESv1_CM.so"
#elif SDL_VIDEO_DRIVER_ANDROID
#elif SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_VIVANTE
/* Android */
#define DEFAULT_EGL "libEGL.so"
#define DEFAULT_OGL_ES2 "libGLESv2.so"

View File

@ -391,8 +391,8 @@ extern VideoBootStrap Wayland_bootstrap;
#if SDL_VIDEO_DRIVER_NACL
extern VideoBootStrap NACL_bootstrap;
#endif
#if SDL_VIDEO_DRIVER_MX6
extern VideoBootStrap MX6_bootstrap;
#if SDL_VIDEO_DRIVER_VIVANTE
extern VideoBootStrap VIVANTE_bootstrap;
#endif
extern SDL_VideoDevice *SDL_GetVideoDevice(void);

View File

@ -62,6 +62,12 @@ static VideoBootStrap *bootstrap[] = {
#if SDL_VIDEO_DRIVER_MIR
&MIR_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_WAYLAND
&Wayland_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_VIVANTE
&VIVANTE_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_DIRECTFB
&DirectFB_bootstrap,
#endif
@ -89,15 +95,9 @@ static VideoBootStrap *bootstrap[] = {
#if SDL_VIDEO_DRIVER_RPI
&RPI_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_WAYLAND
&Wayland_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_NACL
&NACL_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_MX6
&MX6_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_DUMMY
&DUMMY_bootstrap,
#endif

View File

@ -1,205 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
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_internal.h"
#if SDL_VIDEO_DRIVER_MX6 && SDL_VIDEO_OPENGL_EGL
#include "SDL_mx6opengles.h"
#include "SDL_loadso.h"
#include "SDL_mx6video.h"
#define DEFAULT_OGL "libGL.so.1"
#define DEFAULT_EGL "libEGL.so.1"
#define DEFAULT_OGL_ES2 "libGLESv2.so.2"
#define DEFAULT_OGL_ES "libGLESv1_CM.so.1"
#define LOAD_FUNC(NAME) \
*((void**)&_this->egl_data->NAME) = SDL_LoadFunction(_this->egl_data->dll_handle, #NAME); \
if (!_this->egl_data->NAME) \
{ \
return SDL_SetError("Could not retrieve EGL function " #NAME); \
}
#define LOAD_VIV_FUNC(NAME) \
*((void**)&egl_viv_data->NAME) = SDL_LoadFunction(_this->egl_data->dll_handle, #NAME); \
if (!egl_viv_data->NAME) \
{ \
return SDL_SetError("Could not retrieve EGL function " #NAME); \
}
/* EGL implementation of SDL OpenGL support */
int
MX6_GLES_LoadLibrary(_THIS, const char *egl_path)
{
/* The definitions of egl_dll_handle and dll_handle were interchanged for some reason.
Just left them as is for compatibility */
void *dll_handle = NULL, *egl_dll_handle = NULL;
char *path = NULL;
if (_this->egl_data) {
return SDL_SetError("OpenGL ES context already created");
}
_this->egl_data = (struct SDL_EGL_VideoData *) SDL_calloc(1, sizeof(SDL_EGL_VideoData));
if (!_this->egl_data) {
return SDL_OutOfMemory();
}
egl_viv_data = (struct MX6_EGL_VivanteData *) SDL_calloc(1, sizeof(MX6_EGL_VivanteData));
if (!egl_viv_data) {
return SDL_OutOfMemory();
}
path = SDL_getenv("SDL_VIDEO_GL_DRIVER");
if (path != NULL) {
egl_dll_handle = SDL_LoadObject(path);
}
if (egl_dll_handle == NULL) {
if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
if (_this->gl_config.major_version > 1) {
path = DEFAULT_OGL_ES2;
egl_dll_handle = SDL_LoadObject(path);
}
else {
path = DEFAULT_OGL_ES;
egl_dll_handle = SDL_LoadObject(path);
}
}
else {
path = DEFAULT_OGL;
egl_dll_handle = SDL_LoadObject(path);
}
}
_this->egl_data->egl_dll_handle = egl_dll_handle;
if (egl_dll_handle == NULL) {
return SDL_SetError("Could not initialize OpenGL / GLES library");
}
if (egl_path != NULL) {
dll_handle = SDL_LoadObject(egl_path);
}
if (SDL_LoadFunction(dll_handle, "eglChooseConfig") == NULL) {
if (dll_handle != NULL) {
SDL_UnloadObject(dll_handle);
}
path = SDL_getenv("SDL_VIDEO_EGL_DRIVER");
if (path == NULL) {
path = DEFAULT_EGL;
}
dll_handle = SDL_LoadObject(path);
if (dll_handle == NULL) {
return SDL_SetError("Could not load EGL library");
}
}
_this->egl_data->dll_handle = dll_handle;
/* Load new function pointers */
LOAD_FUNC(eglGetDisplay);
LOAD_FUNC(eglInitialize);
LOAD_FUNC(eglTerminate);
LOAD_FUNC(eglGetProcAddress);
LOAD_FUNC(eglChooseConfig);
LOAD_FUNC(eglGetConfigAttrib);
LOAD_FUNC(eglCreateContext);
LOAD_FUNC(eglDestroyContext);
LOAD_FUNC(eglCreateWindowSurface);
LOAD_FUNC(eglDestroySurface);
LOAD_FUNC(eglMakeCurrent);
LOAD_FUNC(eglSwapBuffers);
LOAD_FUNC(eglSwapInterval);
LOAD_FUNC(eglWaitNative);
LOAD_FUNC(eglWaitGL);
LOAD_FUNC(eglBindAPI);
/* Functions from Vivante GPU SDK */
LOAD_VIV_FUNC(fbGetDisplay);
LOAD_VIV_FUNC(fbGetDisplayByIndex);
LOAD_VIV_FUNC(fbGetDisplayGeometry);
LOAD_VIV_FUNC(fbGetDisplayInfo);
LOAD_VIV_FUNC(fbDestroyDisplay);
LOAD_VIV_FUNC(fbCreateWindow);
LOAD_VIV_FUNC(fbGetWindowGeometry);
LOAD_VIV_FUNC(fbGetWindowInfo);
LOAD_VIV_FUNC(fbDestroyWindow);
LOAD_VIV_FUNC(fbCreatePixmap);
LOAD_VIV_FUNC(fbCreatePixmapWithBpp);
LOAD_VIV_FUNC(fbGetPixmapGeometry);
LOAD_VIV_FUNC(fbGetPixmapInfo);
LOAD_VIV_FUNC(fbDestroyPixmap);
_this->egl_data->egl_display = _this->egl_data->eglGetDisplay(egl_viv_data->fbGetDisplayByIndex(0));
if (!_this->egl_data->egl_display) {
return SDL_SetError("Could not get EGL display");
}
if (_this->egl_data->eglInitialize(_this->egl_data->egl_display, NULL, NULL) != EGL_TRUE) {
return SDL_SetError("Could not initialize EGL");
}
_this->gl_config.driver_loaded = 1;
if (path) {
SDL_strlcpy(_this->gl_config.driver_path, path, sizeof(_this->gl_config.driver_path) - 1);
} else {
*_this->gl_config.driver_path = '\0';
}
return 0;
}
void
MX6_GLES_UnloadLibrary(_THIS)
{
if (_this->egl_data) {
if (_this->egl_data->egl_display) {
_this->egl_data->eglTerminate(_this->egl_data->egl_display);
_this->egl_data->egl_display = NULL;
}
if (_this->egl_data->dll_handle) {
SDL_UnloadObject(_this->egl_data->dll_handle);
_this->egl_data->dll_handle = NULL;
}
if (_this->egl_data->egl_dll_handle) {
SDL_UnloadObject(_this->egl_data->egl_dll_handle);
_this->egl_data->egl_dll_handle = NULL;
}
SDL_free(_this->egl_data);
_this->egl_data = NULL;
SDL_free(egl_viv_data);
egl_viv_data = NULL;
}
}
SDL_EGL_CreateContext_impl(MX6)
SDL_EGL_SwapWindow_impl(MX6)
SDL_EGL_MakeCurrent_impl(MX6)
#endif /* SDL_VIDEO_DRIVER_MX6 && SDL_VIDEO_OPENGL_EGL */
/* vi: set ts=4 sw=4 expandtab: */

View File

@ -1,68 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
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_internal.h"
#ifndef _SDL_mx6opengles_h
#define _SDL_mx6opengles_h
#if SDL_VIDEO_DRIVER_MX6 && SDL_VIDEO_OPENGL_EGL
#include "../SDL_sysvideo.h"
#include "../SDL_egl_c.h"
typedef struct MX6_EGL_VivanteData
{
EGLNativeDisplayType(EGLAPIENTRY *fbGetDisplay) (void *context);
EGLNativeDisplayType(EGLAPIENTRY *fbGetDisplayByIndex) (int DisplayIndex);
void(EGLAPIENTRY *fbGetDisplayGeometry) (EGLNativeDisplayType Display, int *Width, int *Height);
void(EGLAPIENTRY *fbGetDisplayInfo) (EGLNativeDisplayType Display, int *Width, int *Height, unsigned long *Physical, int *Stride, int *BitsPerPixel);
void(EGLAPIENTRY *fbDestroyDisplay) (EGLNativeDisplayType Display);
EGLNativeWindowType(EGLAPIENTRY *fbCreateWindow) (EGLNativeDisplayType Display, int X, int Y, int Width, int Height);
void(EGLAPIENTRY *fbGetWindowGeometry) (EGLNativeWindowType Window, int *X, int *Y, int *Width, int *Height);
void(EGLAPIENTRY *fbGetWindowInfo) (EGLNativeWindowType Window, int *X, int *Y, int *Width, int *Height, int *BitsPerPixel, unsigned int *Offset);
void(EGLAPIENTRY *fbDestroyWindow) (EGLNativeWindowType Window);
EGLNativePixmapType(EGLAPIENTRY *fbCreatePixmap) (EGLNativeDisplayType Display, int Width, int Height);
EGLNativePixmapType(EGLAPIENTRY *fbCreatePixmapWithBpp) (EGLNativeDisplayType Display, int Width, int Height, int BitsPerPixel);
void(EGLAPIENTRY *fbGetPixmapGeometry) (EGLNativePixmapType Pixmap, int *Width, int *Height);
void(EGLAPIENTRY *fbGetPixmapInfo) (EGLNativePixmapType Pixmap, int *Width, int *Height, int *BitsPerPixel, int *Stride, void **Bits);
void(EGLAPIENTRY *fbDestroyPixmap) (EGLNativePixmapType Pixmap);
} MX6_EGL_VivanteData;
struct MX6_EGL_VivanteData *egl_viv_data;
/* OpenGLES functions */
#define MX6_GLES_GetAttribute SDL_EGL_GetAttribute
#define MX6_GLES_GetProcAddress SDL_EGL_GetProcAddress
#define MX6_GLES_SetSwapInterval SDL_EGL_SetSwapInterval
#define MX6_GLES_GetSwapInterval SDL_EGL_GetSwapInterval
#define MX6_GLES_DeleteContext SDL_EGL_DeleteContext
extern int MX6_GLES_LoadLibrary(_THIS, const char *path);
extern void MX6_GLES_UnloadLibrary(_THIS);
extern SDL_GLContext MX6_GLES_CreateContext(_THIS, SDL_Window * window);
extern void MX6_GLES_SwapWindow(_THIS, SDL_Window * window);
extern int MX6_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context);
#endif /* SDL_VIDEO_DRIVER_MX6 && SDL_VIDEO_OPENGL_EGL */
#endif /* _SDL_mx6opengles_h */
/* vi: set ts=4 sw=4 expandtab: */

View File

@ -1,331 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
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_internal.h"
#if SDL_VIDEO_DRIVER_MX6
/* SDL internals */
#include "../SDL_sysvideo.h"
#include "SDL_version.h"
#include "SDL_syswm.h"
#include "SDL_loadso.h"
#include "SDL_events.h"
#ifdef SDL_INPUT_LINUXEV
#include "../../core/linux/SDL_evdev.h"
#endif
#include "SDL_mx6video.h"
#include "SDL_mx6events_c.h"
#include "SDL_mx6opengles.h"
static int
MX6_Available(void)
{
return 1;
}
static void
MX6_Destroy(SDL_VideoDevice * device)
{
if (device->driverdata != NULL) {
SDL_free(device->driverdata);
device->driverdata = NULL;
}
}
static SDL_VideoDevice *
MX6_Create()
{
SDL_VideoDevice *device;
SDL_VideoData *data;
/* Initialize SDL_VideoDevice structure */
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
if (device == NULL) {
SDL_OutOfMemory();
return NULL;
}
/* Initialize internal data */
data = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
if (data == NULL) {
SDL_OutOfMemory();
SDL_free(device);
return NULL;
}
device->driverdata = data;
/* Setup amount of available displays and current display */
device->num_displays = 0;
/* Set device free function */
device->free = MX6_Destroy;
/* Setup all functions which we can handle */
device->VideoInit = MX6_VideoInit;
device->VideoQuit = MX6_VideoQuit;
device->GetDisplayModes = MX6_GetDisplayModes;
device->SetDisplayMode = MX6_SetDisplayMode;
device->CreateWindow = MX6_CreateWindow;
device->CreateWindowFrom = MX6_CreateWindowFrom;
device->SetWindowTitle = MX6_SetWindowTitle;
device->SetWindowIcon = MX6_SetWindowIcon;
device->SetWindowPosition = MX6_SetWindowPosition;
device->SetWindowSize = MX6_SetWindowSize;
device->ShowWindow = MX6_ShowWindow;
device->HideWindow = MX6_HideWindow;
device->RaiseWindow = MX6_RaiseWindow;
device->MaximizeWindow = MX6_MaximizeWindow;
device->MinimizeWindow = MX6_MinimizeWindow;
device->RestoreWindow = MX6_RestoreWindow;
device->SetWindowGrab = MX6_SetWindowGrab;
device->DestroyWindow = MX6_DestroyWindow;
device->GetWindowWMInfo = MX6_GetWindowWMInfo;
device->GL_LoadLibrary = MX6_GLES_LoadLibrary;
device->GL_GetProcAddress = MX6_GLES_GetProcAddress;
device->GL_UnloadLibrary = MX6_GLES_UnloadLibrary;
device->GL_CreateContext = MX6_GLES_CreateContext;
device->GL_MakeCurrent = MX6_GLES_MakeCurrent;
device->GL_SetSwapInterval = MX6_GLES_SetSwapInterval;
device->GL_GetSwapInterval = MX6_GLES_GetSwapInterval;
device->GL_SwapWindow = MX6_GLES_SwapWindow;
device->GL_DeleteContext = MX6_GLES_DeleteContext;
device->PumpEvents = MX6_PumpEvents;
return device;
}
VideoBootStrap MX6_bootstrap = {
"MX6",
"Freescale i.MX6 Video Driver",
MX6_Available,
MX6_Create
};
static void
MX6_UpdateDisplay(_THIS)
{
SDL_VideoDisplay *display = &_this->displays[0];
SDL_DisplayData *data = (SDL_DisplayData*)display->driverdata;
EGLNativeDisplayType native_display = egl_viv_data->fbGetDisplayByIndex(0);
SDL_DisplayMode current_mode;
int pitch, bpp;
unsigned long pixels;
/* Store the native EGL display */
data->native_display = native_display;
SDL_zero(current_mode);
egl_viv_data->fbGetDisplayInfo(native_display, &current_mode.w, &current_mode.h, &pixels, &pitch, &bpp);
/* FIXME: How do we query refresh rate? */
current_mode.refresh_rate = 60;
switch (bpp)
{
default: /* Is another format used? */
case 16:
current_mode.format = SDL_PIXELFORMAT_RGB565;
break;
}
display->desktop_mode = current_mode;
display->current_mode = current_mode;
}
/*****************************************************************************/
/* SDL Video and Display initialization/handling functions */
/*****************************************************************************/
int
MX6_VideoInit(_THIS)
{
SDL_VideoDisplay display;
SDL_DisplayMode current_mode;
SDL_DisplayData *data;
data = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData));
if (data == NULL) {
return SDL_OutOfMemory();
}
SDL_zero(display);
SDL_zero(current_mode);
display.desktop_mode = current_mode;
display.current_mode = current_mode;
display.driverdata = data;
SDL_AddVideoDisplay(&display);
if (SDL_GL_LoadLibrary(NULL) < 0) {
return -1;
}
MX6_UpdateDisplay(_this);
#ifdef SDL_INPUT_LINUXEV
SDL_EVDEV_Init();
#endif
return 0;
}
void
MX6_VideoQuit(_THIS)
{
#ifdef SDL_INPUT_LINUXEV
SDL_EVDEV_Quit();
#endif
}
void
MX6_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
{
/* Only one display mode available, the current one */
SDL_AddDisplayMode(display, &display->current_mode);
}
int
MX6_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
{
return 0;
}
int
MX6_CreateWindow(_THIS, SDL_Window * window)
{
SDL_DisplayData *displaydata;
SDL_WindowData *data;
displaydata = SDL_GetDisplayDriverData(0);
/* Allocate window internal data */
data = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
if (data == NULL) {
return SDL_OutOfMemory();
}
/* Setup driver data for this window */
window->driverdata = data;
window->flags |= SDL_WINDOW_OPENGL;
if (!_this->egl_data) {
return -1;
}
data->native_window = egl_viv_data->fbCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h);
if (!data->native_window) {
return SDL_SetError("MX6: Can't create native window");
}
data->egl_surface = SDL_EGL_CreateSurface(_this, data->native_window);
if (data->egl_surface == EGL_NO_SURFACE) {
return SDL_SetError("MX6: Can't create EGL surface");
}
/* Window has been successfully created */
return 0;
}
void
MX6_DestroyWindow(_THIS, SDL_Window * window)
{
SDL_WindowData *data;
data = window->driverdata;
if (data) {
if (data->egl_surface != EGL_NO_SURFACE) {
SDL_EGL_DestroySurface(_this, data->egl_surface);
}
if (data->native_window) {
egl_viv_data->fbDestroyWindow(data->native_window);
}
SDL_free(data);
}
window->driverdata = NULL;
}
int
MX6_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
{
return SDL_Unsupported();
}
void
MX6_SetWindowTitle(_THIS, SDL_Window * window)
{
}
void
MX6_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
{
}
void
MX6_SetWindowPosition(_THIS, SDL_Window * window)
{
}
void
MX6_SetWindowSize(_THIS, SDL_Window * window)
{
}
void
MX6_ShowWindow(_THIS, SDL_Window * window)
{
}
void
MX6_HideWindow(_THIS, SDL_Window * window)
{
}
void
MX6_RaiseWindow(_THIS, SDL_Window * window)
{
}
void
MX6_MaximizeWindow(_THIS, SDL_Window * window)
{
}
void
MX6_MinimizeWindow(_THIS, SDL_Window * window)
{
}
void
MX6_RestoreWindow(_THIS, SDL_Window * window)
{
}
void
MX6_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
{
}
/*****************************************************************************/
/* SDL Window Manager function */
/*****************************************************************************/
SDL_bool
MX6_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
{
return SDL_TRUE;
}
#endif /* SDL_VIDEO_DRIVER_MX6 */
/* vi: set ts=4 sw=4 expandtab: */

View File

@ -1,75 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
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_MX6VIDEO_H__
#define __SDL_MX6VIDEO_H__
#include "../../SDL_internal.h"
#include "../SDL_sysvideo.h"
#include "SDL_egl.h"
typedef struct SDL_VideoData
{
} SDL_VideoData;
typedef struct SDL_DisplayData
{
EGLNativeDisplayType native_display;
} SDL_DisplayData;
typedef struct SDL_WindowData
{
EGLNativeWindowType native_window;
EGLSurface egl_surface;
} SDL_WindowData;
/****************************************************************************/
/* SDL_VideoDevice functions declaration */
/****************************************************************************/
/* Display and window functions */
int MX6_VideoInit(_THIS);
void MX6_VideoQuit(_THIS);
void MX6_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
int MX6_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
int MX6_CreateWindow(_THIS, SDL_Window * window);
int MX6_CreateWindowFrom(_THIS, SDL_Window * window, const void *data);
void MX6_SetWindowTitle(_THIS, SDL_Window * window);
void MX6_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon);
void MX6_SetWindowPosition(_THIS, SDL_Window * window);
void MX6_SetWindowSize(_THIS, SDL_Window * window);
void MX6_ShowWindow(_THIS, SDL_Window * window);
void MX6_HideWindow(_THIS, SDL_Window * window);
void MX6_RaiseWindow(_THIS, SDL_Window * window);
void MX6_MaximizeWindow(_THIS, SDL_Window * window);
void MX6_MinimizeWindow(_THIS, SDL_Window * window);
void MX6_RestoreWindow(_THIS, SDL_Window * window);
void MX6_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
void MX6_DestroyWindow(_THIS, SDL_Window * window);
/* Window manager function */
SDL_bool MX6_GetWindowWMInfo(_THIS, SDL_Window * window,
struct SDL_SysWMinfo *info);
#endif /* __SDL_MX6VIDEO_H__ */
/* vi: set ts=4 sw=4 expandtab: */

View File

@ -0,0 +1,47 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
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_internal.h"
#if SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL
#include "SDL_vivanteopengles.h"
#include "SDL_vivantevideo.h"
/* EGL implementation of SDL OpenGL support */
int
VIVANTE_GLES_LoadLibrary(_THIS, const char *path)
{
SDL_DisplayData *displaydata;
displaydata = SDL_GetDisplayDriverData(0);
return SDL_EGL_LoadLibrary(_this, path, displaydata->native_display);
}
SDL_EGL_CreateContext_impl(VIVANTE)
SDL_EGL_SwapWindow_impl(VIVANTE)
SDL_EGL_MakeCurrent_impl(VIVANTE)
#endif /* SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL */
/* vi: set ts=4 sw=4 expandtab: */

View File

@ -0,0 +1,48 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
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_internal.h"
#ifndef _SDL_vivanteopengles_h
#define _SDL_vivanteopengles_h
#if SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL
#include "../SDL_sysvideo.h"
#include "../SDL_egl_c.h"
/* OpenGLES functions */
#define VIVANTE_GLES_GetAttribute SDL_EGL_GetAttribute
#define VIVANTE_GLES_GetProcAddress SDL_EGL_GetProcAddress
#define VIVANTE_GLES_UnloadLibrary SDL_EGL_UnloadLibrary
#define VIVANTE_GLES_SetSwapInterval SDL_EGL_SetSwapInterval
#define VIVANTE_GLES_GetSwapInterval SDL_EGL_GetSwapInterval
#define VIVANTE_GLES_DeleteContext SDL_EGL_DeleteContext
extern int VIVANTE_GLES_LoadLibrary(_THIS, const char *path);
extern SDL_GLContext VIVANTE_GLES_CreateContext(_THIS, SDL_Window * window);
extern void VIVANTE_GLES_SwapWindow(_THIS, SDL_Window * window);
extern int VIVANTE_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context);
#endif /* SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL */
#endif /* _SDL_vivanteopengles_h */
/* vi: set ts=4 sw=4 expandtab: */

View File

@ -18,14 +18,21 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#ifndef _SDL_mx6events_c_h
#define _SDL_mx6events_c_h
#if SDL_VIDEO_DRIVER_VIVANTE
#include "SDL_mx6video.h"
#include "SDL_vivanteplatform.h"
void MX6_PumpEvents(_THIS);
void MX6_EventInit(_THIS);
void MX6_EventQuit(_THIS);
#ifdef VIVANTE_PLATFORM_GENERIC
#endif /* _SDL_mx6events_c_h */
int VIVANTE_SetupPlatform(_THIS)
{
return 0;
}
#endif /* VIVANTE_PLATFORM_GENERIC */
#endif /* SDL_VIDEO_DRIVER_VIVANTE */
/* vi: set ts=4 sw=4 expandtab: */

View File

@ -18,28 +18,27 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_MX6
#ifndef _SDL_vivanteplatform_h
#define _SDL_vivanteplatform_h
#include "../../events/SDL_sysevents.h"
#include "../../events/SDL_events_c.h"
#include "../../events/SDL_keyboard_c.h"
#include "SDL_mx6video.h"
#include "SDL_mx6events_c.h"
#if SDL_VIDEO_DRIVER_VIVANTE
#ifdef SDL_INPUT_LINUXEV
#include "../../core/linux/SDL_evdev.h"
#include "SDL_vivantevideo.h"
#if defined(CAVIUM)
#define VIVANTE_PLATFORM_CAVIUM
#elif defined(MARVELL)
#define VIVANTE_PLATFORM_MARVELL
#else
#define VIVANTE_PLATFORM_GENERIC
#endif
void MX6_PumpEvents(_THIS)
{
#ifdef SDL_INPUT_LINUXEV
SDL_EVDEV_Poll();
#endif
}
extern int VIVANTE_SetupPlatform(_THIS);
#endif /* SDL_VIDEO_DRIVER_MX6 */
#endif /* SDL_VIDEO_DRIVER_VIVANTE */
#endif /* _SDL_vivanteplatform_h */
/* vi: set ts=4 sw=4 expandtab: */

View File

@ -0,0 +1,397 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
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_internal.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_events_c.h"
#ifdef SDL_INPUT_LINUXEV
#include "../../core/linux/SDL_evdev.h"
#endif
#include "SDL_vivantevideo.h"
#include "SDL_vivanteplatform.h"
#include "SDL_vivanteopengles.h"
static int
VIVANTE_Available(void)
{
return 1;
}
static void
VIVANTE_Destroy(SDL_VideoDevice * device)
{
if (device->driverdata != NULL) {
SDL_free(device->driverdata);
device->driverdata = NULL;
}
}
static SDL_VideoDevice *
VIVANTE_Create()
{
SDL_VideoDevice *device;
SDL_VideoData *data;
/* Initialize SDL_VideoDevice structure */
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
if (device == NULL) {
SDL_OutOfMemory();
return NULL;
}
/* Initialize internal data */
data = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
if (data == NULL) {
SDL_OutOfMemory();
SDL_free(device);
return NULL;
}
device->driverdata = data;
/* Setup amount of available displays and current display */
device->num_displays = 0;
/* Set device free function */
device->free = VIVANTE_Destroy;
/* Setup all functions which we can handle */
device->VideoInit = VIVANTE_VideoInit;
device->VideoQuit = VIVANTE_VideoQuit;
device->GetDisplayModes = VIVANTE_GetDisplayModes;
device->SetDisplayMode = VIVANTE_SetDisplayMode;
device->CreateWindow = VIVANTE_CreateWindow;
device->SetWindowTitle = VIVANTE_SetWindowTitle;
device->SetWindowPosition = VIVANTE_SetWindowPosition;
device->SetWindowSize = VIVANTE_SetWindowSize;
device->ShowWindow = VIVANTE_ShowWindow;
device->HideWindow = VIVANTE_HideWindow;
device->DestroyWindow = VIVANTE_DestroyWindow;
device->GetWindowWMInfo = VIVANTE_GetWindowWMInfo;
device->GL_LoadLibrary = VIVANTE_GLES_LoadLibrary;
device->GL_GetProcAddress = VIVANTE_GLES_GetProcAddress;
device->GL_UnloadLibrary = VIVANTE_GLES_UnloadLibrary;
device->GL_CreateContext = VIVANTE_GLES_CreateContext;
device->GL_MakeCurrent = VIVANTE_GLES_MakeCurrent;
device->GL_SetSwapInterval = VIVANTE_GLES_SetSwapInterval;
device->GL_GetSwapInterval = VIVANTE_GLES_GetSwapInterval;
device->GL_SwapWindow = VIVANTE_GLES_SwapWindow;
device->GL_DeleteContext = VIVANTE_GLES_DeleteContext;
device->PumpEvents = VIVANTE_PumpEvents;
return device;
}
VideoBootStrap VIVANTE_bootstrap = {
"vivante",
"Vivante EGL Video Driver",
VIVANTE_Available,
VIVANTE_Create
};
/*****************************************************************************/
/* SDL Video and Display initialization/handling functions */
/*****************************************************************************/
static int
VIVANTE_AddVideoDisplays(_THIS)
{
SDL_VideoData *videodata = _this->driverdata;
SDL_VideoDisplay display;
SDL_DisplayMode current_mode;
SDL_DisplayData *data;
int pitch = 0, bpp = 0;
unsigned long pixels = 0;
data = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData));
if (data == NULL) {
return SDL_OutOfMemory();
}
SDL_zero(current_mode);
#if SDL_VIDEO_DRIVER_VIVANTE_VDK
data->native_display = vdkGetDisplay(videodata->vdk_private);
vdkGetDisplayInfo(data->native_display, &current_mode.w, &current_mode.h, &pixels, &pitch, &bpp);
#else
data->native_display = videodata->fbGetDisplayByIndex(0);
videodata->fbGetDisplayInfo(data->native_display, &current_mode.w, &current_mode.h, &pixels, &pitch, &bpp);
#endif /* SDL_VIDEO_DRIVER_VIVANTE_VDK */
switch (bpp)
{
default: /* Is another format used? */
case 16:
current_mode.format = SDL_PIXELFORMAT_RGB565;
break;
}
/* FIXME: How do we query refresh rate? */
current_mode.refresh_rate = 60;
SDL_zero(display);
display.desktop_mode = current_mode;
display.current_mode = current_mode;
display.driverdata = data;
SDL_AddVideoDisplay(&display);
return 0;
}
int
VIVANTE_VideoInit(_THIS)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
#if SDL_VIDEO_DRIVER_VIVANTE_VDK
videodata->vdk_private = vdkInitialize();
if (!videodata->vdk_private) {
return SDL_SetError("vdkInitialize() failed");
}
#else
videodata->egl_handle = SDL_LoadObject("libEGL.so.1");
if (!videodata->egl_handle) {
videodata->egl_handle = SDL_LoadObject("libEGL.so");
if (!videodata->egl_handle) {
return -1;
}
}
#define LOAD_FUNC(NAME) \
videodata->NAME = SDL_LoadFunction(videodata->egl_handle, #NAME); \
if (!videodata->NAME) return -1;
LOAD_FUNC(fbGetDisplay);
LOAD_FUNC(fbGetDisplayByIndex);
LOAD_FUNC(fbGetDisplayGeometry);
LOAD_FUNC(fbGetDisplayInfo);
LOAD_FUNC(fbDestroyDisplay);
LOAD_FUNC(fbCreateWindow);
LOAD_FUNC(fbGetWindowGeometry);
LOAD_FUNC(fbGetWindowInfo);
LOAD_FUNC(fbDestroyWindow);
#endif
if (VIVANTE_SetupPlatform(_this) < 0) {
return -1;
}
if (VIVANTE_AddVideoDisplays(_this) < 0) {
return -1;
}
#ifdef SDL_INPUT_LINUXEV
if (SDL_EVDEV_Init() < 0) {
return -1;
}
#endif
return 0;
}
void
VIVANTE_VideoQuit(_THIS)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
#ifdef SDL_INPUT_LINUXEV
SDL_EVDEV_Quit();
#endif
#if SDL_VIDEO_DRIVER_VIVANTE_VDK
if (videodata->vdk_private) {
vdkExit(videodata->vdk_private);
videodata->vdk_private = NULL;
}
#else
if (videodata->egl_handle) {
SDL_UnloadObject(videodata->egl_handle);
videodata->egl_handle = NULL;
}
#endif
}
void
VIVANTE_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
{
/* Only one display mode available, the current one */
SDL_AddDisplayMode(display, &display->current_mode);
}
int
VIVANTE_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
{
return 0;
}
int
VIVANTE_CreateWindow(_THIS, SDL_Window * window)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
SDL_DisplayData *displaydata;
SDL_WindowData *data;
displaydata = SDL_GetDisplayDriverData(0);
/* Allocate window internal data */
data = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
if (data == NULL) {
return SDL_OutOfMemory();
}
/* Setup driver data for this window */
window->driverdata = data;
#if SDL_VIDEO_DRIVER_VIVANTE_VDK
data->native_window = vdkCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h);
#else
data->native_window = videodata->fbCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h);
#endif
if (!data->native_window) {
return SDL_SetError("VIVANTE: Can't create native window");
}
if (window->flags & SDL_WINDOW_OPENGL) {
data->egl_surface = SDL_EGL_CreateSurface(_this, data->native_window);
if (data->egl_surface == EGL_NO_SURFACE) {
return SDL_SetError("VIVANTE: Can't create EGL surface");
}
} else {
data->egl_surface = EGL_NO_SURFACE;
}
/* Window has been successfully created */
return 0;
}
void
VIVANTE_DestroyWindow(_THIS, SDL_Window * window)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
SDL_WindowData *data;
data = window->driverdata;
if (data) {
if (data->egl_surface != EGL_NO_SURFACE) {
SDL_EGL_DestroySurface(_this, data->egl_surface);
}
if (data->native_window) {
#if SDL_VIDEO_DRIVER_VIVANTE_VDK
vdkDestroyWindow(data->native_window);
#else
videodata->fbDestroyWindow(data->native_window);
#endif
}
SDL_free(data);
}
window->driverdata = NULL;
}
void
VIVANTE_SetWindowTitle(_THIS, SDL_Window * window)
{
#if SDL_VIDEO_DRIVER_VIVANTE_VDK
SDL_WindowData *data = window->driverdata;
vdkSetWindowTitle(data->native_window, window->title);
#endif
}
void
VIVANTE_SetWindowPosition(_THIS, SDL_Window * window)
{
/* FIXME */
}
void
VIVANTE_SetWindowSize(_THIS, SDL_Window * window)
{
/* FIXME */
}
void
VIVANTE_ShowWindow(_THIS, SDL_Window * window)
{
#if SDL_VIDEO_DRIVER_VIVANTE_VDK
SDL_WindowData *data = window->driverdata;
vdkShowWindow(data->native_window);
#endif
SDL_SetMouseFocus(window);
SDL_SetKeyboardFocus(window);
}
void
VIVANTE_HideWindow(_THIS, SDL_Window * window)
{
#if SDL_VIDEO_DRIVER_VIVANTE_VDK
SDL_WindowData *data = window->driverdata;
vdkHideWindow(data->native_window);
#endif
}
/*****************************************************************************/
/* SDL Window Manager function */
/*****************************************************************************/
SDL_bool
VIVANTE_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
{
/*
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
if (info->version.major == SDL_MAJOR_VERSION &&
info->version.minor == SDL_MINOR_VERSION) {
info->subsystem = SDL_SYSWM_VIVANTE;
info->info.vivante.window = data->native_window;
return SDL_TRUE;
} else {
SDL_SetError("Application not compiled with SDL %d.%d\n",
SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
return SDL_FALSE;
}
*/
SDL_Unsupported();
return SDL_FALSE;
}
/*****************************************************************************/
/* SDL event functions */
/*****************************************************************************/
void VIVANTE_PumpEvents(_THIS)
{
#ifdef SDL_INPUT_LINUXEV
SDL_EVDEV_Poll();
#endif
}
#endif /* SDL_VIDEO_DRIVER_VIVANTE */
/* vi: set ts=4 sw=4 expandtab: */

View File

@ -0,0 +1,91 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
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_vivantevideo_h
#define _SDL_vivantevideo_h
#include "../../SDL_internal.h"
#include "../SDL_sysvideo.h"
#include "SDL_egl.h"
#if SDL_VIDEO_DRIVER_VIVANTE_VDK
#include <gc_vdk.h>
#else
#include <EGL/egl.h>
#endif
typedef struct SDL_VideoData
{
#if SDL_VIDEO_DRIVER_VIVANTE_VDK
vdkPrivate vdk_private;
#else
void *egl_handle; /* EGL shared library handle */
EGLNativeDisplayType (EGLAPIENTRY *fbGetDisplay)(void *context);
EGLNativeDisplayType (EGLAPIENTRY *fbGetDisplayByIndex)(int DisplayIndex);
void (EGLAPIENTRY *fbGetDisplayGeometry)(EGLNativeDisplayType Display, int *Width, int *Height);
void (EGLAPIENTRY *fbGetDisplayInfo)(EGLNativeDisplayType Display, int *Width, int *Height, unsigned long *Physical, int *Stride, int *BitsPerPixel);
void (EGLAPIENTRY *fbDestroyDisplay)(EGLNativeDisplayType Display);
EGLNativeWindowType (EGLAPIENTRY *fbCreateWindow)(EGLNativeDisplayType Display, int X, int Y, int Width, int Height);
void (EGLAPIENTRY *fbGetWindowGeometry)(EGLNativeWindowType Window, int *X, int *Y, int *Width, int *Height);
void (EGLAPIENTRY *fbGetWindowInfo)(EGLNativeWindowType Window, int *X, int *Y, int *Width, int *Height, int *BitsPerPixel, unsigned int *Offset);
void (EGLAPIENTRY *fbDestroyWindow)(EGLNativeWindowType Window);
#endif
} SDL_VideoData;
typedef struct SDL_DisplayData
{
EGLNativeDisplayType native_display;
} SDL_DisplayData;
typedef struct SDL_WindowData
{
EGLNativeWindowType native_window;
EGLSurface egl_surface;
} SDL_WindowData;
/****************************************************************************/
/* SDL_VideoDevice functions declaration */
/****************************************************************************/
/* Display and window functions */
int VIVANTE_VideoInit(_THIS);
void VIVANTE_VideoQuit(_THIS);
void VIVANTE_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
int VIVANTE_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
int VIVANTE_CreateWindow(_THIS, SDL_Window * window);
void VIVANTE_SetWindowTitle(_THIS, SDL_Window * window);
void VIVANTE_SetWindowPosition(_THIS, SDL_Window * window);
void VIVANTE_SetWindowSize(_THIS, SDL_Window * window);
void VIVANTE_ShowWindow(_THIS, SDL_Window * window);
void VIVANTE_HideWindow(_THIS, SDL_Window * window);
void VIVANTE_DestroyWindow(_THIS, SDL_Window * window);
/* Window manager function */
SDL_bool VIVANTE_GetWindowWMInfo(_THIS, SDL_Window * window,
struct SDL_SysWMinfo *info);
/* Event functions */
void VIVANTE_PumpEvents(_THIS);
#endif /* _SDL_vivantevideo_h */
/* vi: set ts=4 sw=4 expandtab: */