diff options
Diffstat (limited to 'firmware/system.c')
-rw-r--r-- | firmware/system.c | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/firmware/system.c b/firmware/system.c index 81c5a36917..9699fe8559 100644 --- a/firmware/system.c +++ b/firmware/system.c | |||
@@ -32,16 +32,38 @@ long cpu_frequency = CPU_FREQ; | |||
32 | #endif | 32 | #endif |
33 | 33 | ||
34 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 34 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
35 | int boost_counter = 0; | 35 | static int boost_counter = 0; |
36 | bool cpu_idle = false; | 36 | static bool cpu_idle = false; |
37 | void cpu_boost(bool on_off) | 37 | #ifdef CPU_BOOST_TRACKING |
38 | #define CPU_BOOST_TRACKER_MAX 15 | ||
39 | static char cpu_boost_tracker[CPU_BOOST_TRACKER_MAX+1] = ""; | ||
40 | #endif | ||
41 | |||
42 | int get_cpu_boost_counter(void) | ||
43 | { | ||
44 | return boost_counter; | ||
45 | } | ||
46 | |||
47 | #ifdef CPU_BOOST_TRACKING | ||
48 | const char *get_cpu_boost_tracker() | ||
49 | { | ||
50 | return cpu_boost_tracker; | ||
51 | } | ||
52 | |||
53 | void cpu_boost_id(bool on_off, char id) | ||
38 | { | 54 | { |
39 | if(on_off) | 55 | if(on_off) |
40 | { | 56 | { |
41 | /* Boost the frequency if not already boosted */ | 57 | /* Boost the frequency if not already boosted */ |
42 | if(boost_counter++ == 0) | 58 | if(boost_counter++ == 0) |
43 | { | ||
44 | set_cpu_frequency(CPUFREQ_MAX); | 59 | set_cpu_frequency(CPUFREQ_MAX); |
60 | |||
61 | /* Add to the boost tracker for debugging */ | ||
62 | int l = strlen(cpu_boost_tracker); | ||
63 | if (l < CPU_BOOST_TRACKER_MAX) | ||
64 | { | ||
65 | cpu_boost_tracker[l] = id; | ||
66 | cpu_boost_tracker[l+1] = '\0'; | ||
45 | } | 67 | } |
46 | } | 68 | } |
47 | else | 69 | else |
@@ -58,8 +80,26 @@ void cpu_boost(bool on_off) | |||
58 | /* Safety measure */ | 80 | /* Safety measure */ |
59 | if(boost_counter < 0) | 81 | if(boost_counter < 0) |
60 | boost_counter = 0; | 82 | boost_counter = 0; |
83 | |||
84 | /* Remove an entry from the boost tracker */ | ||
85 | int l = strlen(cpu_boost_tracker); | ||
86 | while (l >= 0 && cpu_boost_tracker[l] != id) | ||
87 | l--; | ||
88 | if (cpu_boost_tracker[l] != id) /* No match found? */ | ||
89 | l = strlen(cpu_boost_tracker)-1; /* Just remove last one */ | ||
90 | while (l < CPU_BOOST_TRACKER_MAX) | ||
91 | { | ||
92 | cpu_boost_tracker[l] = cpu_boost_tracker[l+1]; | ||
93 | l++; | ||
94 | } | ||
61 | } | 95 | } |
62 | } | 96 | } |
97 | #endif | ||
98 | |||
99 | void cpu_boost(bool on_off) | ||
100 | { | ||
101 | cpu_boost_id(on_off, '?'); | ||
102 | } | ||
63 | 103 | ||
64 | void cpu_idle_mode(bool on_off) | 104 | void cpu_idle_mode(bool on_off) |
65 | { | 105 | { |