From f1ee740f2b48c8a2da5fa1d33e033a9067fe3843 Mon Sep 17 00:00:00 2001 From: Andree Buschmann Date: Fri, 11 Nov 2011 19:40:32 +0000 Subject: Finally submit GUI boost (FS#8668). With this change the CPU is boosted (with a 1 second timeout) on scrollwheel activity in the list, main menu, tree and std context. For now GUI boost is only enabled on scrollwheel targets. The code can easily be enhanced to work with other targets as well. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30967 a1c6a512-1295-4272-9138-f99709370657 --- apps/action.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'apps') diff --git a/apps/action.c b/apps/action.c index 15b2d8a4c8..0b21a27ea9 100644 --- a/apps/action.c +++ b/apps/action.c @@ -149,6 +149,27 @@ static inline int get_next_context(const struct button_mapping *items, int i) CONTEXT_STD : items[i].action_code; } + +#if defined(HAVE_GUI_BOOST) && defined(HAVE_ADJUSTABLE_CPU_FREQ) +/* 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) +{ + static bool boosted = false; + + if (want_to_boost && !boosted) + { + cpu_boost(true); + boosted = true; + } + else if (!want_to_boost && boosted) + { + cpu_boost(false); + boosted = false; + } +} +#endif + /* * int get_action_worker(int context, struct button_mapping *user_mappings, int timeout) @@ -183,6 +204,23 @@ static int get_action_worker(int context, int timeout, else 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; + 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); + } +#endif + /* Data from sys events can be pulled with button_get_data * multimedia button presses don't go through the action system */ if (button == BUTTON_NONE || button & (SYS_EVENT|BUTTON_MULTIMEDIA)) -- cgit v1.2.3