summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2009-02-20 17:13:08 +0000
committerJens Arnold <amiconn@rockbox.org>2009-02-20 17:13:08 +0000
commit3e67e3b1f06488f67d2ebbf844ff40893cc16bf0 (patch)
treea066891b9a91f8eaf84b2eb0501ce0a09000b765
parent2c3517d67a5387f422c7fcccf3c70f43a386b729 (diff)
downloadrockbox-3e67e3b1f06488f67d2ebbf844ff40893cc16bf0.tar.gz
rockbox-3e67e3b1f06488f67d2ebbf844ff40893cc16bf0.zip
Add a rockbox kernel thread for simulator specific tasks, and use that for calling the screendump function(s). Fixes screendump in simulators for backlight-less targets (Ondio), and reduces mixing of unrelated functionality a bit (screendump was called from backlight thread, triggered by a sim-only system wide event).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20065 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/main.c2
-rw-r--r--firmware/backlight.c10
-rw-r--r--firmware/export/kernel.h7
-rw-r--r--uisimulator/common/SOURCES1
-rw-r--r--uisimulator/common/sim_tasks.c70
-rw-r--r--uisimulator/common/sim_tasks.h25
-rw-r--r--uisimulator/sdl/button.c3
7 files changed, 103 insertions, 15 deletions
diff --git a/apps/main.c b/apps/main.c
index 24a89eca56..20cec9bbfa 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -112,6 +112,7 @@
112#include "cuesheet.h" 112#include "cuesheet.h"
113 113
114#ifdef SIMULATOR 114#ifdef SIMULATOR
115#include "sim_tasks.h"
115#include "system-sdl.h" 116#include "system-sdl.h"
116#endif 117#endif
117 118
@@ -294,6 +295,7 @@ static void init(void)
294 show_logo(); 295 show_logo();
295 button_init(); 296 button_init();
296 backlight_init(); 297 backlight_init();
298 sim_tasks_init();
297 lang_init(); 299 lang_init();
298#ifdef DEBUG 300#ifdef DEBUG
299 debug_init(); 301 debug_init();
diff --git a/firmware/backlight.c b/firmware/backlight.c
index 513f643171..588867f1a5 100644
--- a/firmware/backlight.c
+++ b/firmware/backlight.c
@@ -597,16 +597,6 @@ void backlight_thread(void)
597 break; 597 break;
598#endif /* HAVE_REMOTE_LCD/ HAVE_REMOTE_LCD_AS_MAIN */ 598#endif /* HAVE_REMOTE_LCD/ HAVE_REMOTE_LCD_AS_MAIN */
599#endif /* !SIMULATOR */ 599#endif /* !SIMULATOR */
600#ifdef SIMULATOR
601 /* TODO: find a better way to do it but we need
602 * a kernel thread somewhere to handle this */
603 case SYS_SCREENDUMP:
604 screen_dump();
605#ifdef HAVE_REMOTE_LCD
606 remote_screen_dump();
607#endif
608 break;
609#endif
610 case SYS_USB_CONNECTED: 600 case SYS_USB_CONNECTED:
611 /* Tell the USB thread that we are safe */ 601 /* Tell the USB thread that we are safe */
612 DEBUGF("backlight_thread got SYS_USB_CONNECTED\n"); 602 DEBUGF("backlight_thread got SYS_USB_CONNECTED\n");
diff --git a/firmware/export/kernel.h b/firmware/export/kernel.h
index 90a21630ed..63cc174cb6 100644
--- a/firmware/export/kernel.h
+++ b/firmware/export/kernel.h
@@ -76,10 +76,9 @@
76#define SYS_PHONE_UNPLUGGED MAKE_SYS_EVENT(SYS_EVENT_CLS_PLUG, 3) 76#define SYS_PHONE_UNPLUGGED MAKE_SYS_EVENT(SYS_EVENT_CLS_PLUG, 3)
77#define SYS_REMOTE_PLUGGED MAKE_SYS_EVENT(SYS_EVENT_CLS_PLUG, 4) 77#define SYS_REMOTE_PLUGGED MAKE_SYS_EVENT(SYS_EVENT_CLS_PLUG, 4)
78#define SYS_REMOTE_UNPLUGGED MAKE_SYS_EVENT(SYS_EVENT_CLS_PLUG, 5) 78#define SYS_REMOTE_UNPLUGGED MAKE_SYS_EVENT(SYS_EVENT_CLS_PLUG, 5)
79#define SYS_SCREENDUMP MAKE_SYS_EVENT(SYS_EVENT_CLS_MISC, 0) 79#define SYS_CAR_ADAPTER_RESUME MAKE_SYS_EVENT(SYS_EVENT_CLS_MISC, 0)
80#define SYS_CAR_ADAPTER_RESUME MAKE_SYS_EVENT(SYS_EVENT_CLS_MISC, 1) 80#define SYS_IAP_PERIODIC MAKE_SYS_EVENT(SYS_EVENT_CLS_MISC, 1)
81#define SYS_IAP_PERIODIC MAKE_SYS_EVENT(SYS_EVENT_CLS_MISC, 2) 81#define SYS_IAP_HANDLEPKT MAKE_SYS_EVENT(SYS_EVENT_CLS_MISC, 2)
82#define SYS_IAP_HANDLEPKT MAKE_SYS_EVENT(SYS_EVENT_CLS_MISC, 3)
83 82
84#define IS_SYSEVENT(ev) ((ev & SYS_EVENT) == SYS_EVENT) 83#define IS_SYSEVENT(ev) ((ev & SYS_EVENT) == SYS_EVENT)
85 84
diff --git a/uisimulator/common/SOURCES b/uisimulator/common/SOURCES
index 881049ec59..bda79b66b9 100644
--- a/uisimulator/common/SOURCES
+++ b/uisimulator/common/SOURCES
@@ -6,6 +6,7 @@ font-player.c
6lcd-playersim.c 6lcd-playersim.c
7#endif 7#endif
8sim_icons.c 8sim_icons.c
9sim_tasks.c
9stubs.c 10stubs.c
10powermgmt-sim.c 11powermgmt-sim.c
11 12
diff --git a/uisimulator/common/sim_tasks.c b/uisimulator/common/sim_tasks.c
new file mode 100644
index 0000000000..2fc887cc37
--- /dev/null
+++ b/uisimulator/common/sim_tasks.c
@@ -0,0 +1,70 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2009 by Jens Arnold
11 *
12 * Rockbox simulator specific tasks
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
18 *
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
21 *
22 ****************************************************************************/
23
24#include "config.h"
25#include "kernel.h"
26#include "screendump.h"
27#include "thread.h"
28
29static void sim_thread(void);
30static long sim_thread_stack[DEFAULT_STACK_SIZE/sizeof(long)];
31 /* stack isn't actually used in the sim */
32static const char sim_thread_name[] = "sim";
33static struct event_queue sim_queue;
34
35/* possible events for the sim thread */
36enum {
37 SIM_SCREENDUMP,
38};
39
40void sim_thread(void)
41{
42 struct queue_event ev;
43
44 while (1)
45 {
46 queue_wait(&sim_queue, &ev);
47 switch(ev.id)
48 {
49 case SIM_SCREENDUMP:
50 screen_dump();
51#ifdef HAVE_REMOTE_LCD
52 remote_screen_dump();
53#endif
54 break;
55 }
56 }
57}
58
59void sim_tasks_init(void)
60{
61 queue_init(&sim_queue, false);
62
63 create_thread(sim_thread, sim_thread_stack, sizeof(sim_thread_stack), 0,
64 sim_thread_name IF_PRIO(,PRIORITY_BACKGROUND) IF_COP(,CPU));
65}
66
67void sim_trigger_screendump(void)
68{
69 queue_post(&sim_queue, SIM_SCREENDUMP, 0);
70}
diff --git a/uisimulator/common/sim_tasks.h b/uisimulator/common/sim_tasks.h
new file mode 100644
index 0000000000..fe42deeb97
--- /dev/null
+++ b/uisimulator/common/sim_tasks.h
@@ -0,0 +1,25 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2009 by Jens Arnold
11 *
12 * Rockbox simulator specific tasks
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
18 *
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
21 *
22 ****************************************************************************/
23
24void sim_tasks_init(void);
25void sim_trigger_screendump(void);
diff --git a/uisimulator/sdl/button.c b/uisimulator/sdl/button.c
index 765bc0608e..6402c75d55 100644
--- a/uisimulator/sdl/button.c
+++ b/uisimulator/sdl/button.c
@@ -27,6 +27,7 @@
27#include "kernel.h" 27#include "kernel.h"
28#include "backlight.h" 28#include "backlight.h"
29#include "misc.h" 29#include "misc.h"
30#include "sim_tasks.h"
30 31
31#include "debug.h" 32#include "debug.h"
32 33
@@ -1097,7 +1098,7 @@ void button_event(int key, bool pressed)
1097 case SDLK_F5: 1098 case SDLK_F5:
1098 if(pressed) 1099 if(pressed)
1099 { 1100 {
1100 queue_broadcast(SYS_SCREENDUMP, 0); 1101 sim_trigger_screendump();
1101 return; 1102 return;
1102 } 1103 }
1103 break; 1104 break;