diff --git a/CMakeLists.txt b/CMakeLists.txt index 75a89378b..e861773d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -246,6 +246,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_MALI "Use Mali 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. @@ -663,6 +664,7 @@ if(UNIX AND NOT APPLE) CheckOpenGLX11() CheckOpenGLESX11() CheckWayland() + CheckMali() endif() if(LINUX) diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake index 2cd09e6ff..8e3685022 100644 --- a/cmake/sdlchecks.cmake +++ b/cmake/sdlchecks.cmake @@ -600,6 +600,29 @@ macro(CheckDirectFB) endif(VIDEO_DIRECTFB) endmacro(CheckDirectFB) +# Requires: +# - n/a +macro(CheckMali) + if(VIDEO_MALI) + check_c_source_compiles(" + #define LINUX + #define EGL_API_FB + #include + int main(int argc, char** argv) {}" HAVE_VIDEO_MALI_EGL_FB) + if(HAVE_VIDEO_MALI_EGL_FB) + set(HAVE_VIDEO_MALI TRUE) + set(HAVE_SDL_VIDEO TRUE) + + file(GLOB MALI_SOURCES ${SDL2_SOURCE_DIR}/src/video/mali-fbdev/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${MALI_SOURCES}) + set(SDL_VIDEO_DRIVER_MALI 1) + set(SDL_CFLAGS "${SDL_CFLAGS} -DLINUX -DEGL_API_FB") + list(APPEND EXTRA_LIBS EGL) + endif(HAVE_VIDEO_MALI_EGL_MALI) + endif(VIDEO_MALI) +endmacro(CheckMali) + + # Requires: # - nada macro(CheckOpenGLX11) diff --git a/configure b/configure index 1999cf9a2..7e7af624a 100755 --- a/configure +++ b/configure @@ -832,6 +832,7 @@ enable_video_x11_xrandr enable_video_x11_scrnsaver enable_video_x11_xshape enable_video_x11_vm +enable_video_mali enable_video_cocoa enable_video_directfb enable_directfb_shared @@ -1560,6 +1561,7 @@ Optional Features: --enable-video-x11-xshape enable X11 XShape support [[default=yes]] --enable-video-x11-vm use X11 VM extension for fullscreen [[default=yes]] + --enable-video-mali use Mali EGL video driver [[default=yes]] --enable-video-cocoa use Cocoa video driver [[default=yes]] --enable-video-directfb use DirectFB video driver [[default=no]] --enable-directfb-shared @@ -20477,6 +20479,56 @@ $as_echo "#define SDL_VIDEO_DRIVER_X11_XVIDMODE 1" >>confdefs.h fi } +CheckMaliVideo() +{ + # Check whether --enable-video-mali was given. +if test "${enable_video_mali+set}" = set; then : + enableval=$enable_video_mali; +else + enable_video_mali=yes +fi + + if test x$enable_video = xyes -a x$enable_video_mali = xyes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Mali FB API" >&5 +$as_echo_n "checking for Mali FB API... " >&6; } + have_mali_egl=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #define LINUX + #define EGL_API_FB + #include + +int +main () +{ + + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + have_mali_egl=yes + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_mali_egl" >&5 +$as_echo "$have_mali_egl" >&6; } + + if test x$have_mali_egl = xyes; then + +$as_echo "#define SDL_VIDEO_DRIVER_MALI 1" >>confdefs.h + + EXTRA_CFLAGS="$EXTRA_CFLAGS -DLINUX -DEGL_API_FB" + SOURCES="$SOURCES $srcdir/src/video/mali-fbdev/*.c" + SUMMARY_video="${SUMMARY_video} mali" + have_video=yes + fi + fi +} + CheckHaikuVideo() { if test x$enable_video = xyes; then @@ -22593,6 +22645,7 @@ case "$host" in CheckClockGettime CheckLinuxVersion CheckRPATH + CheckMaliVideo # Set up files for the audio library if test x$enable_audio = xyes; then case $ARCH in diff --git a/configure.in b/configure.in index 3d8a2de23..271111ad7 100644 --- a/configure.in +++ b/configure.in @@ -1668,6 +1668,35 @@ AC_HELP_STRING([--enable-video-x11-vm], [use X11 VM extension for fullscreen [[d fi } +dnl Set up the Mali video driver if enabled +CheckMaliVideo() +{ + AC_ARG_ENABLE(video-mali, +AC_HELP_STRING([--enable-video-mali], [use Mali EGL video driver [[default=yes]]]), + , enable_video_mali=yes) + if test x$enable_video = xyes -a x$enable_video_mali = xyes; then + AC_MSG_CHECKING(for Mali FB API) + have_mali_egl=no + AC_TRY_COMPILE([ + #define LINUX + #define EGL_API_FB + #include + ],[ + ],[ + have_mali_egl=yes + ]) + AC_MSG_RESULT($have_mali_egl) + + if test x$have_mali_egl = xyes; then + AC_DEFINE(SDL_VIDEO_DRIVER_MALI, 1, [ ]) + EXTRA_CFLAGS="$EXTRA_CFLAGS -DLINUX -DEGL_API_FB" + SOURCES="$SOURCES $srcdir/src/video/mali-fbdev/*.c" + SUMMARY_video="${SUMMARY_video} mali" + have_video=yes + fi + fi +} + dnl Set up the Haiku video driver if enabled CheckHaikuVideo() { @@ -2686,6 +2715,7 @@ case "$host" in CheckClockGettime CheckLinuxVersion CheckRPATH + CheckMaliVideo # Set up files for the audio library if test x$enable_audio = xyes; then case $ARCH in diff --git a/debian/control b/debian/control index e116e9b34..e4959485d 100644 --- a/debian/control +++ b/debian/control @@ -12,8 +12,6 @@ Build-Depends: debhelper (>= 9), dh-autoreconf, dpkg-dev (>= 1.16.1~), libasound2-dev [linux-any], - libgl1-mesa-dev, - libpulse-dev, libudev-dev [linux-any], libdbus-1-dev [linux-any], libusb2-dev [kfreebsd-any], @@ -29,16 +27,16 @@ Build-Depends: debhelper (>= 9), libxxf86vm-dev Homepage: http://www.libsdl.org/ -Package: libsdl2 +Package: libsdl2-2.0-0 Architecture: any Multi-Arch: same Pre-Depends: ${misc:Pre-Depends} Depends: ${misc:Depends}, ${shlibs:Depends}, - libudev0 [linux-any], + libudev0 | libudev1 [linux-any], libdbus-1-3 [linux-any] -Conflicts: libsdl-1.3-0 -Replaces: libsdl-1.3-0 +Conflicts: libsdl-1.3-0, libsdl2 +Replaces: libsdl-1.3-0, libsdl2 Description: Simple DirectMedia Layer SDL is a library that allows programs portable low level access to a video framebuffer, audio output, mouse, and keyboard. @@ -50,9 +48,9 @@ Section: libdevel Architecture: any Multi-Arch: same Depends: ${misc:Depends}, - libsdl2 (= ${binary:Version}), + libsdl2-2.0-0 (= ${binary:Version}), libc6-dev, - libgl1-mesa-dev + libx11-dev Conflicts: libsdl-1.3-dev Replaces: libsdl-1.3-dev Description: Simple DirectMedia Layer development files @@ -67,7 +65,7 @@ Section: debug Architecture: any Multi-Arch: same Depends: ${misc:Depends}, - libsdl2 (= ${binary:Version}), + libsdl2-2.0-0 (= ${binary:Version}), Description: Simple DirectMedia Layer debug files SDL is a library that allows programs portable low level access to a video framebuffer, audio output, mouse, and keyboard. diff --git a/debian/libsdl2.install b/debian/libsdl2-2.0-0.install similarity index 100% rename from debian/libsdl2.install rename to debian/libsdl2-2.0-0.install diff --git a/debian/rules b/debian/rules index 4bde8f325..149ff04d4 100755 --- a/debian/rules +++ b/debian/rules @@ -6,7 +6,9 @@ DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) confflags = --disable-rpath --disable-video-directfb \ --disable-nas --disable-esd --disable-arts \ --disable-alsa-shared --disable-pulseaudio-shared \ - --disable-x11-shared + --disable-x11-shared --disable-video-opengl --enable-video-gles --enable-video-mali \ + --disable-esd --disable-pulseaudio \ + --disable-input-tslib %: dh $@ --parallel diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake index b6fb53aa2..0a4bb1dea 100644 --- a/include/SDL_config.h.cmake +++ b/include/SDL_config.h.cmake @@ -259,6 +259,7 @@ #cmakedefine SDL_VIDEO_DRIVER_DUMMY @SDL_VIDEO_DRIVER_DUMMY@ #cmakedefine SDL_VIDEO_DRIVER_WINDOWS @SDL_VIDEO_DRIVER_WINDOWS@ #cmakedefine SDL_VIDEO_DRIVER_WAYLAND @SDL_VIDEO_DRIVER_WAYLAND@ +#cmakedefine SDL_VIDEO_DRIVER_MALI @SDL_VIDEO_DRIVER_MALI@ #if 0 /* !!! FIXME: in configure script version, missing here: */ diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index 689dcf839..33e9c57a3 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -272,6 +272,7 @@ #undef SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON #undef SDL_VIDEO_DRIVER_X11 #undef SDL_VIDEO_DRIVER_RPI +#undef SDL_VIDEO_DRIVER_MALI #undef SDL_VIDEO_DRIVER_X11_DYNAMIC #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c index cfba20071..64cbabc36 100644 --- a/src/video/SDL_egl.c +++ b/src/video/SDL_egl.c @@ -34,8 +34,8 @@ #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 -/* Android */ +#elif SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_MALI +/* Android and Mali-fbdev */ #define DEFAULT_EGL "libEGL.so" #define DEFAULT_OGL_ES2 "libGLESv2.so" #define DEFAULT_OGL_ES_PVR "libGLES_CM.so" @@ -303,7 +303,7 @@ SDL_EGL_ChooseConfig(_THIS) attribs[i++] = EGL_OPENGL_BIT; _this->egl_data->eglBindAPI(EGL_OPENGL_API); } - + attribs[i++] = EGL_NONE; if (_this->egl_data->eglChooseConfig(_this->egl_data->egl_display, diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 32b5d77a2..8beedb067 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -375,6 +375,9 @@ extern VideoBootStrap PSP_bootstrap; #if SDL_VIDEO_DRIVER_RPI extern VideoBootStrap RPI_bootstrap; #endif +#if SDL_VIDEO_DRIVER_MALI +extern VideoBootStrap MALI_bootstrap; +#endif #if SDL_VIDEO_DRIVER_DUMMY extern VideoBootStrap DUMMY_bootstrap; #endif diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index a97051a8f..aa7d9a579 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -88,6 +88,9 @@ static VideoBootStrap *bootstrap[] = { #endif #if SDL_VIDEO_DRIVER_RPI &RPI_bootstrap, +#endif +#if SDL_VIDEO_DRIVER_MALI + &MALI_bootstrap, #endif #if SDL_VIDEO_DRIVER_WAYLAND &Wayland_bootstrap, diff --git a/src/video/mali-fbdev/SDL_maliopengles.c b/src/video/mali-fbdev/SDL_maliopengles.c new file mode 100644 index 000000000..d64231a3f --- /dev/null +++ b/src/video/mali-fbdev/SDL_maliopengles.c @@ -0,0 +1,43 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_DRIVER_MALI && SDL_VIDEO_OPENGL_EGL + +#include "SDL_maliopengles.h" +#include "SDL_malivideo.h" + +/* EGL implementation of SDL OpenGL support */ + +int +MALI_GLES_LoadLibrary(_THIS, const char *path) +{ + return SDL_EGL_LoadLibrary(_this, path, EGL_DEFAULT_DISPLAY); +} + +SDL_EGL_CreateContext_impl(MALI) +SDL_EGL_SwapWindow_impl(MALI) +SDL_EGL_MakeCurrent_impl(MALI) + +#endif /* SDL_VIDEO_DRIVER_MALI && SDL_VIDEO_OPENGL_EGL */ + +/* vi: set ts=4 sw=4 expandtab: */ + diff --git a/src/video/mali-fbdev/SDL_maliopengles.h b/src/video/mali-fbdev/SDL_maliopengles.h new file mode 100644 index 000000000..e9568e36b --- /dev/null +++ b/src/video/mali-fbdev/SDL_maliopengles.h @@ -0,0 +1,48 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifndef _SDL_maliopengles_h +#define _SDL_maliopengles_h + +#if SDL_VIDEO_DRIVER_MALI && SDL_VIDEO_OPENGL_EGL + +#include "../SDL_sysvideo.h" +#include "../SDL_egl_c.h" + +/* OpenGLES functions */ +#define MALI_GLES_GetAttribute SDL_EGL_GetAttribute +#define MALI_GLES_GetProcAddress SDL_EGL_GetProcAddress +#define MALI_GLES_UnloadLibrary SDL_EGL_UnloadLibrary +#define MALI_GLES_SetSwapInterval SDL_EGL_SetSwapInterval +#define MALI_GLES_GetSwapInterval SDL_EGL_GetSwapInterval +#define MALI_GLES_DeleteContext SDL_EGL_DeleteContext + +extern int MALI_GLES_LoadLibrary(_THIS, const char *path); +extern SDL_GLContext MALI_GLES_CreateContext(_THIS, SDL_Window * window); +extern void MALI_GLES_SwapWindow(_THIS, SDL_Window * window); +extern int MALI_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); + +#endif /* SDL_VIDEO_DRIVER_MALI && SDL_VIDEO_OPENGL_EGL */ + +#endif /* _SDL_maliopengles_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/mali-fbdev/SDL_malivideo.c b/src/video/mali-fbdev/SDL_malivideo.c new file mode 100644 index 000000000..9802b5134 --- /dev/null +++ b/src/video/mali-fbdev/SDL_malivideo.c @@ -0,0 +1,321 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_DRIVER_MALI + +/* 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_malivideo.h" +#include "SDL_maliopengles.h" + + +static int +MALI_Available(void) +{ + return 1; +} + +static void +MALI_Destroy(SDL_VideoDevice * device) +{ + if (device->driverdata != NULL) { + SDL_free(device->driverdata); + device->driverdata = NULL; + } +} + +static SDL_VideoDevice * +MALI_Create() +{ + SDL_VideoDevice *device; + + /* Initialize SDL_VideoDevice structure */ + device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (device == NULL) { + SDL_OutOfMemory(); + return NULL; + } + + device->driverdata = NULL; + + /* Setup amount of available displays and current display */ + device->num_displays = 0; + + /* Set device free function */ + device->free = MALI_Destroy; + + /* Setup all functions which we can handle */ + device->VideoInit = MALI_VideoInit; + device->VideoQuit = MALI_VideoQuit; + device->GetDisplayModes = MALI_GetDisplayModes; + device->SetDisplayMode = MALI_SetDisplayMode; + device->CreateWindow = MALI_CreateWindow; + device->SetWindowTitle = MALI_SetWindowTitle; + device->SetWindowPosition = MALI_SetWindowPosition; + device->SetWindowSize = MALI_SetWindowSize; + device->ShowWindow = MALI_ShowWindow; + device->HideWindow = MALI_HideWindow; + device->DestroyWindow = MALI_DestroyWindow; + device->GetWindowWMInfo = MALI_GetWindowWMInfo; + + device->GL_LoadLibrary = MALI_GLES_LoadLibrary; + device->GL_GetProcAddress = MALI_GLES_GetProcAddress; + device->GL_UnloadLibrary = MALI_GLES_UnloadLibrary; + device->GL_CreateContext = MALI_GLES_CreateContext; + device->GL_MakeCurrent = MALI_GLES_MakeCurrent; + device->GL_SetSwapInterval = MALI_GLES_SetSwapInterval; + device->GL_GetSwapInterval = MALI_GLES_GetSwapInterval; + device->GL_SwapWindow = MALI_GLES_SwapWindow; + device->GL_DeleteContext = MALI_GLES_DeleteContext; + + device->PumpEvents = MALI_PumpEvents; + + return device; +} + +VideoBootStrap MALI_bootstrap = { + "mali", + "Mali EGL Video Driver", + MALI_Available, + MALI_Create +}; + +/*****************************************************************************/ +/* SDL Video and Display initialization/handling functions */ +/*****************************************************************************/ + +int +MALI_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(); + } + + int fd = open("/dev/fb0", O_RDWR, 0); + if (fd < 0) { + return SDL_SetError("mali-fbdev: Could not open framebuffer device"); + } + struct fb_var_screeninfo vinfo; + if (ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) < 0) { + MALI_VideoQuit(_this); + return SDL_SetError("mali-fbdev: Could not get framebuffer information"); + } + /* Enable triple buffering */ + /* + vinfo.yres_virtual = vinfo.yres * 3; + if (ioctl(fd, FBIOPUT_VSCREENINFO, vinfo) == -1) { + printf("mali-fbdev: Error setting VSCREENINFO\n"); + } + */ + close(fd); + system("setterm -cursor off"); + + data->native_display.width = vinfo.xres; + data->native_display.height = vinfo.yres; + + SDL_zero(current_mode); + current_mode.w = vinfo.xres; + current_mode.h = vinfo.yres; + /* FIXME: Is there a way to tell the actual refresh rate? */ + current_mode.refresh_rate = 60; + /* 32 bpp for default */ + //current_mode.format = SDL_PIXELFORMAT_ABGR8888; + current_mode.format = SDL_PIXELFORMAT_RGBX8888; + + current_mode.driverdata = NULL; + + SDL_zero(display); + display.desktop_mode = current_mode; + display.current_mode = current_mode; + display.driverdata = data; + + SDL_AddVideoDisplay(&display); + +#ifdef SDL_INPUT_LINUXEV + if (SDL_EVDEV_Init() < 0) { + return -1; + } +#endif + + return 0; +} + +void +MALI_VideoQuit(_THIS) +{ + /* Clear the framebuffer and ser cursor on again */ + int fd = open("/dev/tty", O_RDWR); + ioctl(fd, VT_ACTIVATE, 5); + ioctl(fd, VT_ACTIVATE, 1); + close(fd); + system("setterm -cursor on"); + +#ifdef SDL_INPUT_LINUXEV + SDL_EVDEV_Quit(); +#endif + +} + +void +MALI_GetDisplayModes(_THIS, SDL_VideoDisplay * display) +{ + /* Only one display mode available, the current one */ + SDL_AddDisplayMode(display, &display->current_mode); +} + +int +MALI_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) +{ + return 0; +} + +int +MALI_CreateWindow(_THIS, SDL_Window * window) +{ + SDL_WindowData *windowdata; + SDL_DisplayData *displaydata; + + displaydata = SDL_GetDisplayDriverData(0); + + /* Allocate window internal data */ + windowdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData)); + if (windowdata == NULL) { + return SDL_OutOfMemory(); + } + + /* Windows have one size for now */ + window->w = displaydata->native_display.width; + window->h = displaydata->native_display.height; + + /* OpenGL ES is the law here */ + window->flags |= SDL_WINDOW_OPENGL; + + if (!_this->egl_data) { + if (SDL_GL_LoadLibrary(NULL) < 0) { + return -1; + } + } + windowdata->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) &displaydata->native_display); + + if (windowdata->egl_surface == EGL_NO_SURFACE) { + MALI_VideoQuit(_this); + return SDL_SetError("mali-fbdev: Can't create EGL window surface"); + } + + /* Setup driver data for this window */ + window->driverdata = windowdata; + + /* One window, it always has focus */ + SDL_SetMouseFocus(window); + SDL_SetKeyboardFocus(window); + + /* Window has been successfully created */ + return 0; +} + +void +MALI_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); + data->egl_surface = EGL_NO_SURFACE; + } + SDL_free(data); + } + window->driverdata = NULL; +} + +void +MALI_SetWindowTitle(_THIS, SDL_Window * window) +{ +} + +void +MALI_SetWindowPosition(_THIS, SDL_Window * window) +{ +} + +void +MALI_SetWindowSize(_THIS, SDL_Window * window) +{ +} + +void +MALI_ShowWindow(_THIS, SDL_Window * window) +{ +} + +void +MALI_HideWindow(_THIS, SDL_Window * window) +{ +} + +/*****************************************************************************/ +/* SDL Window Manager function */ +/*****************************************************************************/ +SDL_bool +MALI_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info) +{ + if (info->version.major <= SDL_MAJOR_VERSION) { + return SDL_TRUE; + } else { + SDL_SetError("application not compiled with SDL %d.%d\n", + SDL_MAJOR_VERSION, SDL_MINOR_VERSION); + } + + /* Failed to get window manager information */ + return SDL_FALSE; +} + +/*****************************************************************************/ +/* SDL event functions */ +/*****************************************************************************/ +void MALI_PumpEvents(_THIS) +{ +#ifdef SDL_INPUT_LINUXEV + SDL_EVDEV_Poll(); +#endif +} + +#endif /* SDL_VIDEO_DRIVER_MALI */ + +/* vi: set ts=4 sw=4 expandtab: */ + diff --git a/src/video/mali-fbdev/SDL_malivideo.h b/src/video/mali-fbdev/SDL_malivideo.h new file mode 100644 index 000000000..62a29205e --- /dev/null +++ b/src/video/mali-fbdev/SDL_malivideo.h @@ -0,0 +1,77 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef _SDL_malivideo_h +#define _SDL_malivideo_h + +#include "../../SDL_internal.h" +#include "../SDL_sysvideo.h" + +#include "SDL_egl.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef struct SDL_DisplayData +{ + struct fbdev_window native_display; +} SDL_DisplayData; + +typedef struct SDL_WindowData +{ + EGLSurface egl_surface; +} SDL_WindowData; + +/****************************************************************************/ +/* SDL_VideoDevice functions declaration */ +/****************************************************************************/ + +/* Display and window functions */ +int MALI_VideoInit(_THIS); +void MALI_VideoQuit(_THIS); +void MALI_GetDisplayModes(_THIS, SDL_VideoDisplay * display); +int MALI_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); +int MALI_CreateWindow(_THIS, SDL_Window * window); +void MALI_SetWindowTitle(_THIS, SDL_Window * window); +void MALI_SetWindowPosition(_THIS, SDL_Window * window); +void MALI_SetWindowSize(_THIS, SDL_Window * window); +void MALI_ShowWindow(_THIS, SDL_Window * window); +void MALI_HideWindow(_THIS, SDL_Window * window); +void MALI_DestroyWindow(_THIS, SDL_Window * window); + +/* Window manager function */ +SDL_bool MALI_GetWindowWMInfo(_THIS, SDL_Window * window, + struct SDL_SysWMinfo *info); + +/* Event functions */ +void MALI_PumpEvents(_THIS); + +#endif /* _SDL_malivideo_h */ + +/* vi: set ts=4 sw=4 expandtab: */ +