summaryrefslogtreecommitdiffstats
path: root/apps/action.c
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2011-11-13 18:00:28 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2011-11-13 18:00:28 +0000
commit169b3048e34c224bb5489572e9f30b3e5379d7aa (patch)
tree2e69e20e4592d477e70b81fc52d9e8deea977656 /apps/action.c
parent36d7bbbb4e605f1df373282fbbcb3cfb0e15b464 (diff)
downloadrockbox-169b3048e34c224bb5489572e9f30b3e5379d7aa.tar.gz
rockbox-169b3048e34c224bb5489572e9f30b3e5379d7aa.tar.bz2
rockbox-169b3048e34c224bb5489572e9f30b3e5379d7aa.zip
Use the timeout api for the gui boost implementation. This ensures that the CPU will be unboosted after the defined timeout, the former implementation could stay boosted in several situations.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30975 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/action.c')
-rw-r--r--apps/action.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/apps/action.c b/apps/action.c
index 0b21a27ea9..e192daae4e 100644
--- a/apps/action.c
+++ b/apps/action.c
@@ -151,6 +151,10 @@ static inline int get_next_context(const struct button_mapping *items, int i)
}
#if defined(HAVE_GUI_BOOST) && defined(HAVE_ADJUSTABLE_CPU_FREQ)
+
+/* Timeout for gui boost in seconds. */
+#define GUI_BOOST_TIMEOUT (HZ)
+
/* Helper function which is called to boost / unboost CPU. This function
* avoids to increase boost_count with each call of gui_boost(). */
static void gui_boost(bool want_to_boost)
@@ -168,6 +172,15 @@ static void gui_boost(bool want_to_boost)
boosted = false;
}
}
+
+/* gui_unboost_callback() is called GUI_BOOST_TIMEOUT seconds after the
+ * last wheel scrolling event. */
+static int gui_unboost_callback(struct timeout *tmo)
+{
+ (void)tmo;
+ gui_boost(false);
+ return 0;
+}
#endif
/*
@@ -194,7 +207,6 @@ static int get_action_worker(int context, int timeout,
int ret = ACTION_UNKNOWN;
static int last_context = CONTEXT_STD;
-
send_event(GUI_EVENT_ACTIONUPDATE, NULL);
if (timeout == TIMEOUT_NOBLOCK)
@@ -205,19 +217,15 @@ static int get_action_worker(int context, int timeout,
button = button_get_w_tmo(timeout);
#if defined(HAVE_GUI_BOOST) && defined(HAVE_ADJUSTABLE_CPU_FREQ)
- /* Boost the CPU in case of wheel scrolling activity in the defined contexts.
- * Unboost the CPU after timeout. */
- static long last_boost_tick;
+ static struct timeout gui_unboost;
+ /* Boost the CPU in case of wheel scrolling activity in the defined contexts.
+ * Call unboost with a timeout of GUI_BOOST_TIMEOUT. */
if ((button&(BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD)) &&
(context == CONTEXT_STD || context == CONTEXT_LIST ||
context == CONTEXT_MAINMENU || context == CONTEXT_TREE))
{
- last_boost_tick = current_tick;
gui_boost(true);
- }
- else if (TIME_AFTER(current_tick, last_boost_tick + HZ))
- {
- gui_boost(false);
+ timeout_register(&gui_unboost, gui_unboost_callback, GUI_BOOST_TIMEOUT, 0);
}
#endif