diff options
author | Thomas Jarosch <tomj@simonv.com> | 2011-03-02 19:12:55 +0000 |
---|---|---|
committer | Thomas Jarosch <tomj@simonv.com> | 2011-03-02 19:12:55 +0000 |
commit | 15a358099cf62cd8c4e5110b6a240f1423270ee3 (patch) | |
tree | d123d23239c0ca4ac6bc197d4d4fe49867651a30 /firmware | |
parent | 7ad78222c45e2056edd29c16034bb6109ebef45b (diff) | |
download | rockbox-15a358099cf62cd8c4e5110b6a240f1423270ee3.tar.gz rockbox-15a358099cf62cd8c4e5110b6a240f1423270ee3.zip |
Introduce "power" thread for RaaA
I tried to move the #ifdefs and the code
in firmware/powermgmt.c around and it was still
a big mess for hosted applications (RaaA/sim builds).
Create our own "power" thread as recently discussed on IRC.
Fixes the sleep timer for RaaA.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29501 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/SOURCES | 3 | ||||
-rw-r--r-- | firmware/export/powermgmt.h | 6 | ||||
-rw-r--r-- | firmware/target/hosted/android/system-android.c | 6 | ||||
-rw-r--r-- | firmware/target/hosted/powermgmt.c | 56 |
4 files changed, 63 insertions, 8 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES index 2952ad71d2..32d2a4edfe 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -5,6 +5,9 @@ buffer.c | |||
5 | general.c | 5 | general.c |
6 | load_code.c | 6 | load_code.c |
7 | powermgmt.c | 7 | powermgmt.c |
8 | #if (CONFIG_PLATFORM & PLATFORM_HOSTED) | ||
9 | target/hosted/powermgmt.c | ||
10 | #endif | ||
8 | system.c | 11 | system.c |
9 | usb.c | 12 | usb.c |
10 | #ifdef ROCKBOX_HAS_LOGF | 13 | #ifdef ROCKBOX_HAS_LOGF |
diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h index b22518f07d..1194432830 100644 --- a/firmware/export/powermgmt.h +++ b/firmware/export/powermgmt.h | |||
@@ -75,6 +75,9 @@ extern unsigned int power_thread_inputs; | |||
75 | #include "powermgmt-target.h" | 75 | #include "powermgmt-target.h" |
76 | #endif | 76 | #endif |
77 | 77 | ||
78 | /* Start up power management thread */ | ||
79 | void powermgmt_init(void) INIT_ATTR; | ||
80 | |||
78 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) | 81 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) |
79 | 82 | ||
80 | /* Generic current values that are intentionally meaningless - config header | 83 | /* Generic current values that are intentionally meaningless - config header |
@@ -127,9 +130,6 @@ extern const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11]; | |||
127 | extern const unsigned short percent_to_volt_charge[11]; | 130 | extern const unsigned short percent_to_volt_charge[11]; |
128 | #endif | 131 | #endif |
129 | 132 | ||
130 | /* Start up power management thread */ | ||
131 | void powermgmt_init(void) INIT_ATTR; | ||
132 | |||
133 | #endif /* PLATFORM_NATIVE */ | 133 | #endif /* PLATFORM_NATIVE */ |
134 | 134 | ||
135 | /* Returns battery statust */ | 135 | /* Returns battery statust */ |
diff --git a/firmware/target/hosted/android/system-android.c b/firmware/target/hosted/android/system-android.c index 009630eeaa..92c2d7cf5d 100644 --- a/firmware/target/hosted/android/system-android.c +++ b/firmware/target/hosted/android/system-android.c | |||
@@ -35,7 +35,6 @@ uintptr_t *stackbegin; | |||
35 | uintptr_t *stackend; | 35 | uintptr_t *stackend; |
36 | 36 | ||
37 | extern int main(void); | 37 | extern int main(void); |
38 | extern void powermgmt_init_target(void); | ||
39 | extern void telephony_init_device(void); | 38 | extern void telephony_init_device(void); |
40 | 39 | ||
41 | void system_exception_wait(void) { } | 40 | void system_exception_wait(void) { } |
@@ -44,10 +43,7 @@ void power_off(void) { } | |||
44 | 43 | ||
45 | void system_init(void) | 44 | void system_init(void) |
46 | { | 45 | { |
47 | /* no better place yet, most of powermgmt.c is #ifdef'd out for non-native | 46 | /* no better place yet */ |
48 | * builds */ | ||
49 | powermgmt_init_target(); | ||
50 | /* also no better place yet */ | ||
51 | telephony_init_device(); | 47 | telephony_init_device(); |
52 | } | 48 | } |
53 | 49 | ||
diff --git a/firmware/target/hosted/powermgmt.c b/firmware/target/hosted/powermgmt.c new file mode 100644 index 0000000000..d4103a0c00 --- /dev/null +++ b/firmware/target/hosted/powermgmt.c | |||
@@ -0,0 +1,56 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2011 by Thomas Jarosch | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include "config.h" | ||
22 | #include "powermgmt.h" | ||
23 | #include "thread.h" | ||
24 | #include "kernel.h" | ||
25 | |||
26 | static char power_stack[DEFAULT_STACK_SIZE]; | ||
27 | static const char power_thread_name[] = "power"; | ||
28 | |||
29 | void powermgmt_init_target(void); | ||
30 | |||
31 | #if !(CONFIG_PLATFORM & PLATFORM_ANDROID) | ||
32 | void powermgmt_init_target(void) | ||
33 | { | ||
34 | /* Nothing to do */ | ||
35 | } | ||
36 | #endif | ||
37 | |||
38 | static void power_thread(void) | ||
39 | { | ||
40 | powermgmt_init_target(); | ||
41 | |||
42 | while (1) | ||
43 | { | ||
44 | /* Sleep two seconds */ | ||
45 | sleep(HZ*2); | ||
46 | |||
47 | handle_sleep_timer(); | ||
48 | } | ||
49 | } /* power_thread */ | ||
50 | |||
51 | void powermgmt_init(void) | ||
52 | { | ||
53 | create_thread(power_thread, power_stack, sizeof(power_stack), 0, | ||
54 | power_thread_name IF_PRIO(, PRIORITY_SYSTEM) | ||
55 | IF_COP(, CPU)); | ||
56 | } | ||