summaryrefslogtreecommitdiff
path: root/apps/plugins/plasma.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-08-23 16:56:49 +0000
committerThomas Martitz <kugel@rockbox.org>2010-08-23 16:56:49 +0000
commitabdc5935beb7dc3fa63bffeec584921ad2a4c8bd (patch)
tree3eb3ca86063d0fff58ca8ed2c49dbb0af0792570 /apps/plugins/plasma.c
parent8106c9dc646bbb26131896eb12d23edb26cba476 (diff)
downloadrockbox-abdc5935beb7dc3fa63bffeec584921ad2a4c8bd.tar.gz
rockbox-abdc5935beb7dc3fa63bffeec584921ad2a4c8bd.zip
Introduce plugin_crt0.c that every plugin links.
It handles exit() properly, calling the handler also when the plugin returns normally (also it makes exit() more standard compliant while at it). It also holds PLUGIN_HEADER, so that it doesn't need to be in each plugin anymore. To work better together with callbacks passed to rb->default_event_handler_ex introduce exit_on_usb() which will call the exit handler before showing the usb screen and exit() after it. In most cases it was passed a callback which was manually called at all other return points. This can now be done via atexit(). In future plugin_crt0.c could also handle clearing bss, initializing iram and more. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27862 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/plasma.c')
-rw-r--r--apps/plugins/plasma.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/apps/plugins/plasma.c b/apps/plugins/plasma.c
index 637d948f3d..35bc03ba1f 100644
--- a/apps/plugins/plasma.c
+++ b/apps/plugins/plasma.c
@@ -27,6 +27,7 @@
27#include "plugin.h" 27#include "plugin.h"
28#include "lib/helper.h" 28#include "lib/helper.h"
29#include "lib/pluginlib_actions.h" 29#include "lib/pluginlib_actions.h"
30#include "lib/pluginlib_exit.h"
30 31
31#ifdef HAVE_LCD_BITMAP 32#ifdef HAVE_LCD_BITMAP
32 33
@@ -35,7 +36,6 @@
35#endif 36#endif
36#include "lib/fixedpoint.h" 37#include "lib/fixedpoint.h"
37 38
38PLUGIN_HEADER
39 39
40/******************************* Globals ***********************************/ 40/******************************* Globals ***********************************/
41 41
@@ -131,10 +131,8 @@ static void shades_generate(void)
131} 131}
132#endif 132#endif
133 133
134void cleanup(void *parameter) 134void cleanup(void)
135{ 135{
136 (void)parameter;
137
138#ifdef HAVE_ADJUSTABLE_CPU_FREQ 136#ifdef HAVE_ADJUSTABLE_CPU_FREQ
139 if (boosted) 137 if (boosted)
140 rb->cpu_boost(false); 138 rb->cpu_boost(false);
@@ -144,6 +142,9 @@ void cleanup(void *parameter)
144#endif 142#endif
145 /* Turn on backlight timeout (revert to settings) */ 143 /* Turn on backlight timeout (revert to settings) */
146 backlight_use_settings(); /* backlight control in lib/helper.c */ 144 backlight_use_settings(); /* backlight control in lib/helper.c */
145#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
146 rb->lcd_set_mode(LCD_MODE_RGB565);
147#endif
147} 148}
148 149
149/* 150/*
@@ -180,10 +181,15 @@ int main(void)
180 /* get the remainder of the plugin buffer */ 181 /* get the remainder of the plugin buffer */
181 gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size); 182 gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size);
182 183
183 grey_init(gbuf, gbuf_size, GREY_ON_COP, LCD_WIDTH, LCD_HEIGHT, NULL); 184 if (!grey_init(gbuf, gbuf_size, GREY_ON_COP, LCD_WIDTH, LCD_HEIGHT, NULL))
185 {
186 rb->splash(HZ, "Couldn't init greyscale display");
187 return PLUGIN_ERROR;
188 }
184 /* switch on greyscale overlay */ 189 /* switch on greyscale overlay */
185 grey_show(true); 190 grey_show(true);
186#endif 191#endif
192 atexit(cleanup);
187 sp1 = 4; 193 sp1 = 4;
188 sp2 = 2; 194 sp2 = 2;
189 sp3 = 4; 195 sp3 = 4;
@@ -261,7 +267,6 @@ int main(void)
261 { 267 {
262 case PLA_EXIT: 268 case PLA_EXIT:
263 case PLA_CANCEL: 269 case PLA_CANCEL:
264 cleanup(NULL);
265 return PLUGIN_OK; 270 return PLUGIN_OK;
266 break; 271 break;
267 272
@@ -299,9 +304,7 @@ int main(void)
299#endif 304#endif
300 305
301 default: 306 default:
302 if (rb->default_event_handler_ex(action, cleanup, NULL) 307 exit_on_usb(action);
303 == SYS_USB_CONNECTED)
304 return PLUGIN_USB_CONNECTED;
305 break; 308 break;
306 } 309 }
307 } 310 }
@@ -311,8 +314,6 @@ int main(void)
311 314
312enum plugin_status plugin_start(const void* parameter) 315enum plugin_status plugin_start(const void* parameter)
313{ 316{
314 int ret;
315
316 (void)parameter; 317 (void)parameter;
317#if LCD_DEPTH > 1 318#if LCD_DEPTH > 1
318 rb->lcd_set_backdrop(NULL); 319 rb->lcd_set_backdrop(NULL);
@@ -323,14 +324,7 @@ enum plugin_status plugin_start(const void* parameter)
323#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256) 324#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
324 rb->lcd_set_mode(LCD_MODE_PAL256); 325 rb->lcd_set_mode(LCD_MODE_PAL256);
325#endif 326#endif
326 327 return main();
327 ret = main();
328
329#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
330 rb->lcd_set_mode(LCD_MODE_RGB565);
331#endif
332
333 return ret;
334} 328}
335 329
336#endif /* HAVE_LCD_BITMAP */ 330#endif /* HAVE_LCD_BITMAP */