Index: apps/screens.c
===================================================================
--- apps/screens.c (revision 14056)
+++ apps/screens.c (working copy)
@@ -1125,7 +1125,7 @@
switch(button)
{
case ACTION_STD_CANCEL:
- sys_poweroff();
+ sys_poweroff(false);
break;
/* do nothing here, because ACTION_NONE might be caused
Index: apps/lang/english.lang
===================================================================
--- apps/lang/english.lang (revision 14056)
+++ apps/lang/english.lang (working copy)
@@ -11054,3 +11054,45 @@
*: "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"
+
+
+
+ id: LANG_REBOOTING
+ desc: reboot splash
+ user:
+
+ *: "Rebooting..."
+
+
+ *: "Rebooting..."
+
+
+ *: ""
+
+
Index: apps/menus/power_menu.c
===================================================================
--- apps/menus/power_menu.c (revision 0)
+++ apps/menus/power_menu.c (revision 0)
@@ -0,0 +1,102 @@
+
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id: $
+ *
+ * Copyright (C) 2007 Jonathan Gordon
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include
+#include
+#include
+#include
+#include "sprintf.h"
+#include "config.h"
+#include "lang.h"
+#include "action.h"
+#include "settings.h"
+#include "menu.h"
+#include "exported_menus.h"
+#include "screens.h"
+#include "powermgmt.h"
+#include "power.h"
+#include "talk.h"
+
+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);
+}
+
+static int do_shutdown(void)
+{
+#if CONFIG_CHARGING
+ if (charger_inserted())
+ charging_splash();
+ else
+#endif
+ sys_poweroff(false);
+ return 0;
+}
+
+static int do_reboot(void)
+{
+#if CONFIG_CHARGING
+ if (charger_inserted())
+ charging_splash();
+ else
+#endif
+ sys_poweroff(true);
+ return 0;
+}
+
+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(do_reboot_item, 0, ID2P(LANG_REBOOT),
+ do_reboot, NULL, NULL, Icon_NOICON);
+
+MENUITEM_FUNCTION(do_shutdown_item, 0, ID2P(LANG_SHUTDOWN),
+ do_shutdown, NULL, NULL, Icon_NOICON);
+
+MAKE_MENU(power_options, ID2P(LANG_POWER), 0, Icon_NOICON,
+ &sleep_timer_call, &do_reboot_item, &do_shutdown_item);
+
+bool power_menu(void)
+{
+ return do_menu(&power_options, NULL);
+}
Index: apps/menus/exported_menus.h
===================================================================
--- apps/menus/exported_menus.h (revision 14056)
+++ 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 14056)
+++ apps/menus/main_menu.c (working copy)
@@ -362,39 +362,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),
@@ -408,7 +375,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 14056)
+++ 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 14056)
+++ 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 14056)
+++ 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);
@@ -630,7 +631,12 @@
}
#endif
if (battery_level() > 10)
- gui_syncsplash(0, str(LANG_SHUTTINGDOWN));
+ {
+ if (reboot)
+ gui_syncsplash(0, str(LANG_REBOOTING));
+ else
+ gui_syncsplash(0, str(LANG_SHUTTINGDOWN));
+ }
else
gui_syncsplash(0, "%s %s",
str(LANG_WARNING_BATTERY_LOW),
@@ -690,7 +696,7 @@
dircache_disable();
#endif
- shutdown_hw();
+ shutdown_hw(reboot);
}
#endif
return false;
@@ -856,9 +862,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 14056)
+++ firmware/export/kernel.h (working copy)
@@ -59,8 +59,9 @@
#define SYS_USB_DISCONNECTED MAKE_SYS_EVENT(SYS_EVENT_CLS_USB, 2)
#define SYS_USB_DISCONNECTED_ACK MAKE_SYS_EVENT(SYS_EVENT_CLS_USB, 3)
#define SYS_POWEROFF MAKE_SYS_EVENT(SYS_EVENT_CLS_POWER, 0)
-#define SYS_CHARGER_CONNECTED MAKE_SYS_EVENT(SYS_EVENT_CLS_POWER, 1)
-#define SYS_CHARGER_DISCONNECTED MAKE_SYS_EVENT(SYS_EVENT_CLS_POWER, 2)
+#define SYS_REBOOT MAKE_SYS_EVENT(SYS_EVENT_CLS_POWER, 1)
+#define SYS_CHARGER_CONNECTED MAKE_SYS_EVENT(SYS_EVENT_CLS_POWER, 2)
+#define SYS_CHARGER_DISCONNECTED MAKE_SYS_EVENT(SYS_EVENT_CLS_POWER, 3)
#define SYS_FS_CHANGED MAKE_SYS_EVENT(SYS_EVENT_CLS_FILESYS, 0)
#define SYS_HOTSWAP_INSERTED MAKE_SYS_EVENT(SYS_EVENT_CLS_PLUG, 0)
#define SYS_HOTSWAP_EXTRACTED MAKE_SYS_EVENT(SYS_EVENT_CLS_PLUG, 1)
Index: firmware/export/powermgmt.h
===================================================================
--- firmware/export/powermgmt.h (revision 14056)
+++ 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 14056)
+++ 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 14056)
+++ 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 14056)
+++ firmware/drivers/button.c (working copy)
@@ -181,7 +181,7 @@
{
/* Tell the main thread that it's time to
power off */
- sys_poweroff();
+ sys_poweroff(false);
/* Safety net for players without hardware
poweroff */