Index: apps/screens.c
===================================================================
--- apps/screens.c (revision 13905)
+++ apps/screens.c (working copy)
@@ -1135,7 +1135,7 @@
switch(button)
{
case ACTION_STD_CANCEL:
- sys_poweroff();
+ sys_poweroff(false);
break;
/* do nothing here, because ACTION_UNKNOWN might be caused
Index: apps/lang/english.lang
===================================================================
--- apps/lang/english.lang (revision 13905)
+++ apps/lang/english.lang (working copy)
@@ -11048,3 +11048,31 @@
*: "Can't write to recording directory"
+
+ id: LANG_POWER
+ desc: in root menu
+ user:
+
+ *: "Power"
+
+
+ *: "Power"
+
+
+ *: "Power"
+
+
+
+ id: LANG_REBOOT
+ desc: in power menu
+ user:
+
+ *: "Reboot"
+
+
+ *: "Reboot"
+
+
+ *: "Reboot"
+
+
Index: apps/menus/exported_menus.h
===================================================================
--- apps/menus/exported_menus.h (revision 13905)
+++ apps/menus/exported_menus.h (working copy)
@@ -34,8 +34,9 @@
settings_menu_item, /* settings_menu.c */
playlist_settings, /* playlist_menu.c */
playlist_options, /* playlist_menu.c */
- equalizer_menu, /* eq_menu.c */
- info_menu; /* info_menu.c */
+ equalizer_menu, /* eq_menu.c */
+ info_menu, /* info_menu.c */
+ power_options; /* power_menu.c */
#ifdef HAVE_WM8758
extern const struct menu_item_ex hw_eq_menu; /* eq_menu.c */
Index: apps/menus/main_menu.c
===================================================================
--- apps/menus/main_menu.c (revision 13905)
+++ apps/menus/main_menu.c (working copy)
@@ -365,39 +365,6 @@
MENUITEM_FUNCTION(show_info_item, 0, ID2P(LANG_INFO_MENU),
(menu_function)show_info, NULL, NULL, Icon_NOICON);
-
-/* sleep Menu */
-static void sleep_timer_formatter(char* buffer, int buffer_size, int value,
- const char* unit)
-{
- int minutes, hours;
-
- (void) unit;
-
- if (value) {
- hours = value / 60;
- minutes = value - (hours * 60);
- snprintf(buffer, buffer_size, "%d:%02d", hours, minutes);
- } else {
- snprintf(buffer, buffer_size, "%s", str(LANG_OFF));
- }
-}
-
-static void sleep_timer_set(int minutes)
-{
- set_sleep_timer(minutes * 60);
-}
-
-static int sleep_timer(void)
-{
- int minutes = (get_sleep_timer() + 59) / 60; /* round up */
- return (int)set_int(str(LANG_SLEEP_TIMER), "", UNIT_MIN, &minutes,
- &sleep_timer_set, -5, 300, 0, sleep_timer_formatter);
-}
-
-MENUITEM_FUNCTION(sleep_timer_call, 0, ID2P(LANG_SLEEP_TIMER), sleep_timer,
- NULL, NULL, Icon_Menu_setting); /* make it look like a
- setting to the user */
MENUITEM_FUNCTION(show_credits_item, 0, ID2P(LANG_VERSION),
(menu_function)show_credits, NULL, NULL, Icon_NOICON);
MENUITEM_FUNCTION(show_runtime_item, 0, ID2P(LANG_RUNNING_TIME),
@@ -411,7 +378,7 @@
MAKE_MENU(info_menu, ID2P(LANG_INFO), 0, Icon_Questionmark,
&show_info_item, &show_credits_item, &show_runtime_item,
- &sleep_timer_call, &debug_menu_item
+ &debug_menu_item
#ifdef SIMULATOR
,&simulate_usb_item
#endif
Index: apps/SOURCES
===================================================================
--- apps/SOURCES (revision 13905)
+++ apps/SOURCES (working copy)
@@ -22,6 +22,7 @@
#endif
menus/settings_menu.c
menus/sound_menu.c
+menus/power_menu.c
misc.c
onplay.c
playlist.c
Index: apps/root_menu.c
===================================================================
--- apps/root_menu.c (revision 13905)
+++ apps/root_menu.c (working copy)
@@ -25,13 +25,11 @@
#include "root_menu.h"
#include "lang.h"
#include "settings.h"
-#include "screens.h"
#include "kernel.h"
#include "debug.h"
#include "misc.h"
#include "rolo.h"
#include "powermgmt.h"
-#include "power.h"
#include "talk.h"
#include "audio.h"
#include "hotswap.h"
@@ -327,20 +325,7 @@
MENUITEM_RETURNVALUE(bookmarks, ID2P(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS),
GO_TO_RECENTBMARKS, item_callback,
Icon_Bookmark);
-#ifdef HAVE_LCD_CHARCELLS
-static int do_shutdown(void)
-{
-#if CONFIG_CHARGING
- if (charger_inserted())
- charging_splash();
- else
-#endif
- sys_poweroff();
- return 0;
-}
-MENUITEM_FUNCTION(do_shutdown_item, 0, ID2P(LANG_SHUTDOWN),
- do_shutdown, NULL, NULL, Icon_NOICON);
-#endif
+
MAKE_MENU(root_menu_, ID2P(LANG_ROCKBOX_TITLE),
item_callback, Icon_Rockbox,
&bookmarks, &file_browser,
@@ -354,11 +339,7 @@
#if CONFIG_TUNER
&fm,
#endif
- &playlist_options, &rocks_browser, &info_menu
-
-#ifdef HAVE_LCD_CHARCELLS
- ,&do_shutdown_item
-#endif
+ &playlist_options, &rocks_browser, &info_menu, &power_options
);
int item_callback(int action, const struct menu_item_ex *this_item)
Index: apps/misc.c
===================================================================
--- apps/misc.c (revision 13905)
+++ apps/misc.c (working copy)
@@ -595,9 +595,10 @@
tree_restore();
}
-static bool clean_shutdown(void (*callback)(void *), void *parameter)
+static bool clean_shutdown(bool reboot, void (*callback)(void *), void *parameter)
{
#ifdef SIMULATOR
+ (void)reboot;
(void)callback;
(void)parameter;
call_ata_idle_notifys(true);
@@ -683,7 +684,7 @@
dircache_disable();
#endif
- shutdown_hw();
+ shutdown_hw(reboot);
}
#endif
return false;
@@ -849,9 +850,13 @@
}
return SYS_USB_CONNECTED;
case SYS_POWEROFF:
- if (!clean_shutdown(callback, parameter))
+ if (clean_shutdown(false, callback, parameter))
return SYS_POWEROFF;
break;
+ case SYS_REBOOT:
+ if (clean_shutdown(true, callback, parameter))
+ return SYS_REBOOT;
+ break;
#if CONFIG_CHARGING
case SYS_CHARGER_CONNECTED:
car_adapter_mode_processing(true);
Index: firmware/export/kernel.h
===================================================================
--- firmware/export/kernel.h (revision 13905)
+++ firmware/export/kernel.h (working copy)
@@ -44,11 +44,12 @@
#define SYS_HOTSWAP_INSERTED ((SYS_EVENT | ((long)6 << 27)))
#define SYS_HOTSWAP_EXTRACTED ((SYS_EVENT | ((long)7 << 27)))
#define SYS_POWEROFF ((SYS_EVENT | ((long)8 << 27)))
-#define SYS_FS_CHANGED ((SYS_EVENT | ((long)9 << 27)))
-#define SYS_CHARGER_CONNECTED ((SYS_EVENT | ((long)10 << 27)))
-#define SYS_CHARGER_DISCONNECTED ((SYS_EVENT | ((long)11 << 27)))
-#define SYS_PHONE_PLUGGED ((SYS_EVENT | ((long)12 << 27)))
-#define SYS_PHONE_UNPLUGGED ((SYS_EVENT | ((long)13 << 27)))
+#define SYS_REBOOT ((SYS_EVENT | ((long)9 << 27)))
+#define SYS_FS_CHANGED ((SYS_EVENT | ((long)10 << 27)))
+#define SYS_CHARGER_CONNECTED ((SYS_EVENT | ((long)11 << 27)))
+#define SYS_CHARGER_DISCONNECTED ((SYS_EVENT | ((long)12 << 27)))
+#define SYS_PHONE_PLUGGED ((SYS_EVENT | ((long)13 << 27)))
+#define SYS_PHONE_UNPLUGGED ((SYS_EVENT | ((long)14 << 27)))
struct event
{
Index: firmware/export/powermgmt.h
===================================================================
--- firmware/export/powermgmt.h (revision 13905)
+++ firmware/export/powermgmt.h (working copy)
@@ -165,7 +165,7 @@
void set_car_adapter_mode(bool setting);
void reset_poweroff_timer(void);
void cancel_shutdown(void);
-void shutdown_hw(void);
-void sys_poweroff(void);
+void shutdown_hw(bool reboot);
+void sys_poweroff(bool reboot);
#endif
Index: firmware/target/coldfire/iaudio/pcf50606-iaudio.c
===================================================================
--- firmware/target/coldfire/iaudio/pcf50606-iaudio.c (revision 13905)
+++ firmware/target/coldfire/iaudio/pcf50606-iaudio.c (working copy)
@@ -115,7 +115,7 @@
{
/* ONKEY1S */
if (GPIO_READ & 0x02000000)
- sys_poweroff(); /* main ONKEY */
+ sys_poweroff(false); /* main ONKEY */
else
pcf50606_reset_timeout(); /* remote ONKEY */
}
Index: firmware/powermgmt.c
===================================================================
--- firmware/powermgmt.c (revision 13905)
+++ firmware/powermgmt.c (working copy)
@@ -633,7 +633,7 @@
if(battery_centivolts < battery_level_shutoff[battery_type]) {
if(!shutdown_timeout) {
backlight_on();
- sys_poweroff();
+ sys_poweroff(false);
}
}
#endif
@@ -650,7 +650,7 @@
if(TIME_AFTER(current_tick, last_event_tick + timeout) &&
TIME_AFTER(current_tick, last_disk_activity + timeout))
{
- sys_poweroff();
+ sys_poweroff(false);
}
}
else
@@ -673,7 +673,7 @@
#endif
{
DEBUGF("Sleep timer timeout. Shutting off...\n");
- sys_poweroff();
+ sys_poweroff(false);
}
}
}
@@ -863,7 +863,7 @@
(CONFIG_BATTERY!=BATT_1AA)
if (!shutdown_timeout &&
(battery_centivolts < battery_level_shutoff[battery_type]))
- sys_poweroff();
+ sys_poweroff(false);
else
#endif
avgbat += battery_centivolts * 10000
@@ -1256,7 +1256,7 @@
#endif /* SIMULATOR */
-void sys_poweroff(void)
+void sys_poweroff(bool reboot)
{
logf("sys_poweroff()");
/* If the main thread fails to shut down the system, we will force a
@@ -1273,7 +1273,10 @@
shutdown_timeout += HZ*20;
}
- queue_post(&button_queue, SYS_POWEROFF, 0);
+ if (reboot)
+ queue_post(&button_queue, SYS_REBOOT, 0);
+ else
+ queue_post(&button_queue, SYS_POWEROFF, 0);
}
void cancel_shutdown(void)
@@ -1290,9 +1293,11 @@
}
/* Various hardware housekeeping tasks relating to shutting down the jukebox */
-void shutdown_hw(void)
+void shutdown_hw(bool reboot)
{
-#ifndef SIMULATOR
+#ifdef SIMULATOR
+(void)reboot;
+#else
#if defined(DEBUG_FILE) && (CONFIG_CHARGING == CHARGING_CONTROL)
if(fd >= 0) {
close(fd);
@@ -1341,6 +1346,9 @@
eeprom chips are quite slow and might be still writing the last
byte. */
sleep(HZ/4);
- power_off();
-#endif /* #ifndef SIMULATOR */
+ if (reboot)
+ system_reboot();
+ else
+ power_off();
+#endif /* #ifdef SIMULATOR */
}
Index: firmware/drivers/button.c
===================================================================
--- firmware/drivers/button.c (revision 13905)
+++ firmware/drivers/button.c (working copy)
@@ -180,7 +180,7 @@
{
/* Tell the main thread that it's time to
power off */
- sys_poweroff();
+ sys_poweroff(false);
/* Safety net for players without hardware
poweroff */