summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-08-26 13:21:14 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-08-26 13:21:14 +0000
commit457b8a0a6743b7bee72d90e484055b7635861612 (patch)
treee3256d74445f89d6a89df31255eb59a179ee3d11
parent006c46675e5677fc483c0a9e36a8bd65e488cf8b (diff)
downloadrockbox-457b8a0a6743b7bee72d90e484055b7635861612.zip
rockbox-457b8a0a6743b7bee72d90e484055b7635861612.tar.gz
rockbox-457b8a0a6743b7bee72d90e484055b7635861612.tar.bz2
rockbox-457b8a0a6743b7bee72d90e484055b7635861612.tar.xz
Added configurable disk spindown. The disk will also now not spin down while you are running around in the dir browser or pressing buttons in the wps.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1987 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/settings.c8
-rw-r--r--apps/settings.h4
-rw-r--r--apps/settings_menu.c11
-rw-r--r--apps/tree.c4
-rw-r--r--apps/wps.c3
-rw-r--r--firmware/drivers/ata.c40
-rw-r--r--firmware/drivers/ata.h1
-rw-r--r--uisimulator/common/stubs.c9
8 files changed, 61 insertions, 19 deletions
diff --git a/apps/settings.c b/apps/settings.c
index 11a4647..441abb5 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -268,7 +268,8 @@ int settings_save( void )
config_block[0x10] = (unsigned char)global_settings.ff_rewind;
config_block[0x11] = (unsigned char)global_settings.avc;
-
+ config_block[0x1a] = (unsigned char)global_settings.disk_spindown;
+
memcpy(&config_block[0x12], &global_settings.resume_index, 4);
memcpy(&config_block[0x16], &global_settings.resume_offset, 4);
memcpy(&config_block[0xF8], &global_settings.resume_seed, 4);
@@ -369,6 +370,9 @@ void settings_load(void)
if (config_block[0x16] != 0xFF)
memcpy(&global_settings.resume_offset, &config_block[0x16], 4);
+ if (config_block[0x1a] != 0xFF)
+ global_settings.disk_spindown = config_block[0x1a];
+
memcpy(&global_settings.resume_seed, &config_block[0xF8], 4);
if (config_block[0x24] != 0xFF)
@@ -380,6 +384,7 @@ void settings_load(void)
lcd_set_contrast(global_settings.contrast);
lcd_scroll_speed(global_settings.scroll_speed);
backlight_time(global_settings.backlight);
+ ata_spindown(global_settings.disk_spindown);
#ifdef HAVE_CHARGE_CTRL
charge_restart_level = global_settings.discharge ? CHARGE_RESTART_LO : CHARGE_RESTART_HI;
#endif
@@ -416,6 +421,7 @@ void settings_reset(void) {
global_settings.ff_rewind = DEFAULT_FF_REWIND_SETTING;
global_settings.resume_index = -1;
global_settings.resume_offset = -1;
+ global_settings.disk_spindown = 5;
}
diff --git a/apps/settings.h b/apps/settings.h
index 36cf493..91ffb3e 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -63,6 +63,8 @@ struct user_settings
bool sort_case; /* dir sort order: 0=case insensitive, 1=sensitive */
int scroll_speed; /* long texts scrolling speed: 1-20 */
bool playlist_shuffle;
+ int ff_rewind; /* FF/Rewind step size (in seconds) */
+ int disk_spindown; /* time until disk spindown, in seconds (0=off) */
/* while playing screen settings */
int wps_display; /* 0=id3, 1=file, 2=parse */
@@ -77,8 +79,6 @@ struct user_settings
/* geeky persistent statistics */
unsigned int total_uptime; /* total uptime since rockbox was first booted */
- /* FF/Rewind step size (in seconds) */
- int ff_rewind;
};
/* prototypes */
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index c3f3bcc..9f36d3b 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -35,6 +35,7 @@
#include "fat.h" /* For dotfile settings */
#include "powermgmt.h"
#include "rtc.h"
+#include "ata.h"
static Menu show_hidden_files(void)
{
@@ -167,7 +168,14 @@ static Menu timedate_set(void)
static Menu ff_rewind(void)
{
set_int("[FF/Rewind Step Size]", "s", &global_settings.ff_rewind,
- NULL, 1, 1, 255 );
+ NULL, 1, 1, 254 );
+ return MENU_OK;
+}
+
+static Menu spindown(void)
+{
+ set_int("[Disk spindown]", "s", &global_settings.disk_spindown,
+ ata_spindown, 1, 1, 254 );
return MENU_OK;
}
@@ -193,6 +201,7 @@ Menu settings_menu(void)
{ "Show hidden files", show_hidden_files },
{ "FF/Rewind", ff_rewind },
{ "Resume", resume },
+ { "Disk spindown", spindown },
};
bool old_shuffle = global_settings.playlist_shuffle;
diff --git a/apps/tree.c b/apps/tree.c
index 9dae322..e47452f 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -39,6 +39,7 @@
#include "settings.h"
#include "status.h"
#include "debug.h"
+#include "ata.h"
#ifdef HAVE_LCD_BITMAP
#include "icons.h"
@@ -718,6 +719,9 @@ bool dirbrowse(char *root)
#endif
}
+ if ( button )
+ ata_spin();
+
if ( restore ) {
/* restore display */
/* We need to adjust if the number of lines on screen have
diff --git a/apps/wps.c b/apps/wps.c
index bdad325..571b356 100644
--- a/apps/wps.c
+++ b/apps/wps.c
@@ -1185,6 +1185,9 @@ int wps_show(void)
break;
}
+ if ( button )
+ ata_spin();
+
if(restore) {
restore = false;
draw_screen(id3);
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index 700e403..e867ac2 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -84,7 +84,6 @@ static volatile unsigned char* ata_control;
bool old_recorder = false;
static bool sleeping = false;
-static int sleep_timer = 0;
static int sleep_timeout = 5*HZ;
static char ata_stack[DEFAULT_STACK_SIZE];
static char ata_thread_name[] = "ata";
@@ -94,6 +93,9 @@ static bool delayed_write = false;
static unsigned char delayed_sector[SECTOR_SIZE];
static int delayed_sector_num;
+static long last_user_activity = -1;
+static long last_disk_activity = -1;
+
#ifdef USE_POWEROFF
static int ata_power_on(void);
#endif
@@ -149,6 +151,7 @@ int ata_read_sectors(unsigned long start,
int i;
int ret = 0;
+ last_disk_activity = current_tick;
#ifndef USE_STANDBY
if ( sleeping ) {
#ifdef USE_POWEROFF
@@ -163,7 +166,6 @@ int ata_read_sectors(unsigned long start,
}
#endif
mutex_lock(&ata_mtx);
- sleep_timer = sleep_timeout;
if (!wait_for_rdy())
{
@@ -223,6 +225,8 @@ int ata_read_sectors(unsigned long start,
if ( delayed_write )
ata_flush();
+ last_disk_activity = current_tick;
+
return ret;
}
@@ -232,6 +236,8 @@ int ata_write_sectors(unsigned long start,
{
int i;
+ last_disk_activity = current_tick;
+
#ifndef USE_STANDBY
#ifdef USE_POWEROFF
if (ata_power_on()) {
@@ -244,7 +250,6 @@ int ata_write_sectors(unsigned long start,
#endif
#endif
mutex_lock(&ata_mtx);
- sleep_timer = sleep_timeout;
if (!wait_for_rdy())
{
@@ -291,6 +296,8 @@ int ata_write_sectors(unsigned long start,
if ( delayed_write )
ata_flush();
+ last_disk_activity = current_tick;
+
return i;
}
@@ -379,7 +386,6 @@ static int ata_perform_sleep(void)
ret = -1;
#endif
sleeping = true;
- sleep_timer = 0;
mutex_unlock(&ata_mtx);
return ret;
}
@@ -390,11 +396,25 @@ int ata_sleep(void)
return 0;
}
+void ata_spin(void)
+{
+ last_user_activity = current_tick;
+}
+
static void ata_thread(void)
{
struct event ev;
while (1) {
+ while ( queue_empty( &ata_queue ) ) {
+ if ( sleep_timeout &&
+ TIME_AFTER( current_tick,
+ last_user_activity + sleep_timeout ) &&
+ TIME_AFTER( current_tick,
+ last_disk_activity + sleep_timeout ) )
+ ata_perform_sleep();
+ sleep(HZ/4);
+ }
queue_wait(&ata_queue, &ev);
switch ( ev.id ) {
case SYS_USB_CONNECTED:
@@ -407,21 +427,12 @@ static void ata_thread(void)
break;
case Q_SLEEP:
- ata_perform_sleep();
+ last_disk_activity = current_tick - sleep_timeout;
break;
}
}
}
-static void ata_tick(void)
-{
- if (sleep_timer) {
- sleep_timer--;
- if (!sleep_timer)
- queue_post(&ata_queue, 0, NULL);
- }
-}
-
int ata_hard_reset(void)
{
int ret;
@@ -597,7 +608,6 @@ int ata_init(void)
queue_init(&ata_queue);
create_thread(ata_thread, ata_stack,
sizeof(ata_stack), ata_thread_name);
- tick_add_task(ata_tick);
initialized = true;
}
diff --git a/firmware/drivers/ata.h b/firmware/drivers/ata.h
index 244ec63..da5c5e3 100644
--- a/firmware/drivers/ata.h
+++ b/firmware/drivers/ata.h
@@ -43,5 +43,6 @@ extern int ata_read_sectors(unsigned long start, int count, void* buf);
extern int ata_write_sectors(unsigned long start, int count, void* buf);
extern void ata_delayed_write(unsigned long sector, void* buf);
extern void ata_flush(void);
+extern void ata_spin(void);
#endif
diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c
index 7dc329f..18e7f8c 100644
--- a/uisimulator/common/stubs.c
+++ b/uisimulator/common/stubs.c
@@ -89,6 +89,15 @@ void ata_flush(void)
{
}
+void ata_spin(void)
+{
+}
+
+void ata_spindown(int s)
+{
+ (void)s;
+}
+
Menu simulate_usb(void)
{
usb_display_info();