diff options
author | Thomas Jarosch <tomj@simonv.com> | 2011-02-08 20:05:25 +0000 |
---|---|---|
committer | Thomas Jarosch <tomj@simonv.com> | 2011-02-08 20:05:25 +0000 |
commit | 5f037ac015e6d76d030a163753db5ff58cdff49b (patch) | |
tree | f5eb7dcdc0e0c3e373227e45061c1d99a14a0819 /firmware/target/hosted/sdl/system-sdl.c | |
parent | 4d129044390a087b6193b6ce63e035b2550b3ce4 (diff) | |
download | rockbox-5f037ac015e6d76d030a163753db5ff58cdff49b.tar.gz rockbox-5f037ac015e6d76d030a163753db5ff58cdff49b.zip |
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
Diffstat (limited to 'firmware/target/hosted/sdl/system-sdl.c')
-rw-r--r-- | firmware/target/hosted/sdl/system-sdl.c | 50 |
1 files changed, 49 insertions, 1 deletions
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 @@ | |||
40 | #include "panic.h" | 40 | #include "panic.h" |
41 | #include "debug.h" | 41 | #include "debug.h" |
42 | 42 | ||
43 | #if (CONFIG_PLATFORM & PLATFORM_MAEMO) | ||
44 | #include <glib.h> | ||
45 | #include <glib-object.h> | ||
46 | #include "maemo-thread.h" | ||
47 | |||
48 | #endif | ||
49 | |||
43 | SDL_Surface *gui_surface; | 50 | SDL_Surface *gui_surface; |
44 | 51 | ||
45 | bool background = true; /* use backgrounds by default */ | 52 | bool background = true; /* use backgrounds by default */ |
@@ -82,9 +89,13 @@ static int sdl_event_thread(void * param) | |||
82 | { | 89 | { |
83 | SDL_InitSubSystem(SDL_INIT_VIDEO); | 90 | SDL_InitSubSystem(SDL_INIT_VIDEO); |
84 | 91 | ||
92 | #if (CONFIG_PLATFORM & PLATFORM_MAEMO) | ||
93 | SDL_sem *wait_for_maemo_startup; | ||
94 | #endif | ||
85 | SDL_Surface *picture_surface = NULL; | 95 | SDL_Surface *picture_surface = NULL; |
86 | int width, height; | 96 | int width, height; |
87 | int depth; | 97 | int depth; |
98 | Uint32 flags; | ||
88 | 99 | ||
89 | /* Try and load the background image. If it fails go without */ | 100 | /* Try and load the background image. If it fails go without */ |
90 | if (background) { | 101 | if (background) { |
@@ -121,10 +132,21 @@ static int sdl_event_thread(void * param) | |||
121 | if (depth < 8) | 132 | if (depth < 8) |
122 | depth = 16; | 133 | depth = 16; |
123 | 134 | ||
124 | if ((gui_surface = SDL_SetVideoMode(width * display_zoom, height * display_zoom, depth, SDL_HWSURFACE|SDL_DOUBLEBUF)) == NULL) { | 135 | flags = SDL_HWSURFACE|SDL_DOUBLEBUF; |
136 | #if (CONFIG_PLATFORM & PLATFORM_MAEMO) | ||
137 | /* Fullscreen mode for maemo app */ | ||
138 | flags |= SDL_FULLSCREEN; | ||
139 | #endif | ||
140 | |||
141 | if ((gui_surface = SDL_SetVideoMode(width * display_zoom, height * display_zoom, depth, flags)) == NULL) { | ||
125 | panicf("%s", SDL_GetError()); | 142 | panicf("%s", SDL_GetError()); |
126 | } | 143 | } |
127 | 144 | ||
145 | #if (CONFIG_PLATFORM & PLATFORM_MAEMO) | ||
146 | /* Hide mouse cursor on real touchscreen device */ | ||
147 | SDL_ShowCursor(SDL_DISABLE); | ||
148 | #endif | ||
149 | |||
128 | SDL_WM_SetCaption(UI_TITLE, NULL); | 150 | SDL_WM_SetCaption(UI_TITLE, NULL); |
129 | 151 | ||
130 | if (background && picture_surface != NULL) | 152 | if (background && picture_surface != NULL) |
@@ -133,10 +155,30 @@ static int sdl_event_thread(void * param) | |||
133 | /* let system_init proceed */ | 155 | /* let system_init proceed */ |
134 | SDL_SemPost((SDL_sem *)param); | 156 | SDL_SemPost((SDL_sem *)param); |
135 | 157 | ||
158 | #if (CONFIG_PLATFORM & PLATFORM_MAEMO) | ||
159 | /* Start maemo thread: Listen to display on/off events and battery monitoring */ | ||
160 | wait_for_maemo_startup = SDL_CreateSemaphore(0); /* 0-count so it blocks */ | ||
161 | SDL_Thread *maemo_thread = SDL_CreateThread(maemo_thread_func, wait_for_maemo_startup); | ||
162 | #endif | ||
163 | |||
136 | /* | 164 | /* |
137 | * finally enter the button loop */ | 165 | * finally enter the button loop */ |
138 | gui_message_loop(); | 166 | gui_message_loop(); |
139 | 167 | ||
168 | #if (CONFIG_PLATFORM & PLATFORM_MAEMO) | ||
169 | /* Ensure maemo thread is up and running */ | ||
170 | SDL_SemWait(wait_for_maemo_startup); | ||
171 | SDL_DestroySemaphore(wait_for_maemo_startup); | ||
172 | |||
173 | #if (CONFIG_PLATFORM & PLATFORM_MAEMO5) | ||
174 | pcm_shutdown_gstreamer(); | ||
175 | #endif | ||
176 | |||
177 | g_main_loop_quit (maemo_main_loop); | ||
178 | g_main_loop_unref(maemo_main_loop); | ||
179 | SDL_WaitThread(maemo_thread, NULL); | ||
180 | #endif | ||
181 | |||
140 | if(picture_surface) | 182 | if(picture_surface) |
141 | SDL_FreeSurface(picture_surface); | 183 | SDL_FreeSurface(picture_surface); |
142 | 184 | ||
@@ -161,6 +203,12 @@ void system_init(void) | |||
161 | { | 203 | { |
162 | SDL_sem *s; | 204 | SDL_sem *s; |
163 | 205 | ||
206 | #if (CONFIG_PLATFORM & PLATFORM_MAEMO) | ||
207 | /* Make glib thread safe */ | ||
208 | g_thread_init(NULL); | ||
209 | g_type_init(); | ||
210 | #endif | ||
211 | |||
164 | if (SDL_Init(SDL_INIT_TIMER)) | 212 | if (SDL_Init(SDL_INIT_TIMER)) |
165 | panicf("%s", SDL_GetError()); | 213 | panicf("%s", SDL_GetError()); |
166 | 214 | ||