From 5f037ac015e6d76d030a163753db5ff58cdff49b Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Tue, 8 Feb 2011 20:05:25 +0000 Subject: Initial maemo platform support Adds Nokia N900, N810 and N800 support. Features: - Introduce maemo specific platform defines - Play audio in silent mode - Stop playback on incoming calls - Battery level readout - Bluetooth headset support - Save CPU by disabling screen updates if the display is off or the app doesn't have input focus - N900: GStreamer audio backend Kudos to kugel for the code review. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29248 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/hosted/sdl/system-sdl.c | 50 ++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) (limited to 'firmware/target/hosted/sdl/system-sdl.c') diff --git a/firmware/target/hosted/sdl/system-sdl.c b/firmware/target/hosted/sdl/system-sdl.c index b900d38b43..9ea25c1014 100644 --- a/firmware/target/hosted/sdl/system-sdl.c +++ b/firmware/target/hosted/sdl/system-sdl.c @@ -40,6 +40,13 @@ #include "panic.h" #include "debug.h" +#if (CONFIG_PLATFORM & PLATFORM_MAEMO) +#include +#include +#include "maemo-thread.h" + +#endif + SDL_Surface *gui_surface; bool background = true; /* use backgrounds by default */ @@ -82,9 +89,13 @@ static int sdl_event_thread(void * param) { SDL_InitSubSystem(SDL_INIT_VIDEO); +#if (CONFIG_PLATFORM & PLATFORM_MAEMO) + SDL_sem *wait_for_maemo_startup; +#endif SDL_Surface *picture_surface = NULL; int width, height; int depth; + Uint32 flags; /* Try and load the background image. If it fails go without */ if (background) { @@ -121,10 +132,21 @@ static int sdl_event_thread(void * param) if (depth < 8) depth = 16; - if ((gui_surface = SDL_SetVideoMode(width * display_zoom, height * display_zoom, depth, SDL_HWSURFACE|SDL_DOUBLEBUF)) == NULL) { + flags = SDL_HWSURFACE|SDL_DOUBLEBUF; +#if (CONFIG_PLATFORM & PLATFORM_MAEMO) + /* Fullscreen mode for maemo app */ + flags |= SDL_FULLSCREEN; +#endif + + if ((gui_surface = SDL_SetVideoMode(width * display_zoom, height * display_zoom, depth, flags)) == NULL) { panicf("%s", SDL_GetError()); } +#if (CONFIG_PLATFORM & PLATFORM_MAEMO) + /* Hide mouse cursor on real touchscreen device */ + SDL_ShowCursor(SDL_DISABLE); +#endif + SDL_WM_SetCaption(UI_TITLE, NULL); if (background && picture_surface != NULL) @@ -133,10 +155,30 @@ static int sdl_event_thread(void * param) /* let system_init proceed */ SDL_SemPost((SDL_sem *)param); +#if (CONFIG_PLATFORM & PLATFORM_MAEMO) + /* Start maemo thread: Listen to display on/off events and battery monitoring */ + wait_for_maemo_startup = SDL_CreateSemaphore(0); /* 0-count so it blocks */ + SDL_Thread *maemo_thread = SDL_CreateThread(maemo_thread_func, wait_for_maemo_startup); +#endif + /* * finally enter the button loop */ gui_message_loop(); +#if (CONFIG_PLATFORM & PLATFORM_MAEMO) + /* Ensure maemo thread is up and running */ + SDL_SemWait(wait_for_maemo_startup); + SDL_DestroySemaphore(wait_for_maemo_startup); + +#if (CONFIG_PLATFORM & PLATFORM_MAEMO5) + pcm_shutdown_gstreamer(); +#endif + + g_main_loop_quit (maemo_main_loop); + g_main_loop_unref(maemo_main_loop); + SDL_WaitThread(maemo_thread, NULL); +#endif + if(picture_surface) SDL_FreeSurface(picture_surface); @@ -161,6 +203,12 @@ void system_init(void) { SDL_sem *s; +#if (CONFIG_PLATFORM & PLATFORM_MAEMO) + /* Make glib thread safe */ + g_thread_init(NULL); + g_type_init(); +#endif + if (SDL_Init(SDL_INIT_TIMER)) panicf("%s", SDL_GetError()); -- cgit v1.2.3