mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-08 12:45:26 -05:00
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
This commit is contained in:
parent
006c46675e
commit
457b8a0a67
8 changed files with 61 additions and 19 deletions
|
|
@ -268,7 +268,8 @@ int settings_save( void )
|
||||||
|
|
||||||
config_block[0x10] = (unsigned char)global_settings.ff_rewind;
|
config_block[0x10] = (unsigned char)global_settings.ff_rewind;
|
||||||
config_block[0x11] = (unsigned char)global_settings.avc;
|
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[0x12], &global_settings.resume_index, 4);
|
||||||
memcpy(&config_block[0x16], &global_settings.resume_offset, 4);
|
memcpy(&config_block[0x16], &global_settings.resume_offset, 4);
|
||||||
memcpy(&config_block[0xF8], &global_settings.resume_seed, 4);
|
memcpy(&config_block[0xF8], &global_settings.resume_seed, 4);
|
||||||
|
|
@ -369,6 +370,9 @@ void settings_load(void)
|
||||||
if (config_block[0x16] != 0xFF)
|
if (config_block[0x16] != 0xFF)
|
||||||
memcpy(&global_settings.resume_offset, &config_block[0x16], 4);
|
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);
|
memcpy(&global_settings.resume_seed, &config_block[0xF8], 4);
|
||||||
|
|
||||||
if (config_block[0x24] != 0xFF)
|
if (config_block[0x24] != 0xFF)
|
||||||
|
|
@ -380,6 +384,7 @@ void settings_load(void)
|
||||||
lcd_set_contrast(global_settings.contrast);
|
lcd_set_contrast(global_settings.contrast);
|
||||||
lcd_scroll_speed(global_settings.scroll_speed);
|
lcd_scroll_speed(global_settings.scroll_speed);
|
||||||
backlight_time(global_settings.backlight);
|
backlight_time(global_settings.backlight);
|
||||||
|
ata_spindown(global_settings.disk_spindown);
|
||||||
#ifdef HAVE_CHARGE_CTRL
|
#ifdef HAVE_CHARGE_CTRL
|
||||||
charge_restart_level = global_settings.discharge ? CHARGE_RESTART_LO : CHARGE_RESTART_HI;
|
charge_restart_level = global_settings.discharge ? CHARGE_RESTART_LO : CHARGE_RESTART_HI;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -416,6 +421,7 @@ void settings_reset(void) {
|
||||||
global_settings.ff_rewind = DEFAULT_FF_REWIND_SETTING;
|
global_settings.ff_rewind = DEFAULT_FF_REWIND_SETTING;
|
||||||
global_settings.resume_index = -1;
|
global_settings.resume_index = -1;
|
||||||
global_settings.resume_offset = -1;
|
global_settings.resume_offset = -1;
|
||||||
|
global_settings.disk_spindown = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,8 @@ struct user_settings
|
||||||
bool sort_case; /* dir sort order: 0=case insensitive, 1=sensitive */
|
bool sort_case; /* dir sort order: 0=case insensitive, 1=sensitive */
|
||||||
int scroll_speed; /* long texts scrolling speed: 1-20 */
|
int scroll_speed; /* long texts scrolling speed: 1-20 */
|
||||||
bool playlist_shuffle;
|
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 */
|
/* while playing screen settings */
|
||||||
int wps_display; /* 0=id3, 1=file, 2=parse */
|
int wps_display; /* 0=id3, 1=file, 2=parse */
|
||||||
|
|
@ -77,8 +79,6 @@ struct user_settings
|
||||||
/* geeky persistent statistics */
|
/* geeky persistent statistics */
|
||||||
unsigned int total_uptime; /* total uptime since rockbox was first booted */
|
unsigned int total_uptime; /* total uptime since rockbox was first booted */
|
||||||
|
|
||||||
/* FF/Rewind step size (in seconds) */
|
|
||||||
int ff_rewind;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* prototypes */
|
/* prototypes */
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@
|
||||||
#include "fat.h" /* For dotfile settings */
|
#include "fat.h" /* For dotfile settings */
|
||||||
#include "powermgmt.h"
|
#include "powermgmt.h"
|
||||||
#include "rtc.h"
|
#include "rtc.h"
|
||||||
|
#include "ata.h"
|
||||||
|
|
||||||
static Menu show_hidden_files(void)
|
static Menu show_hidden_files(void)
|
||||||
{
|
{
|
||||||
|
|
@ -167,7 +168,14 @@ static Menu timedate_set(void)
|
||||||
static Menu ff_rewind(void)
|
static Menu ff_rewind(void)
|
||||||
{
|
{
|
||||||
set_int("[FF/Rewind Step Size]", "s", &global_settings.ff_rewind,
|
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;
|
return MENU_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -193,6 +201,7 @@ Menu settings_menu(void)
|
||||||
{ "Show hidden files", show_hidden_files },
|
{ "Show hidden files", show_hidden_files },
|
||||||
{ "FF/Rewind", ff_rewind },
|
{ "FF/Rewind", ff_rewind },
|
||||||
{ "Resume", resume },
|
{ "Resume", resume },
|
||||||
|
{ "Disk spindown", spindown },
|
||||||
};
|
};
|
||||||
bool old_shuffle = global_settings.playlist_shuffle;
|
bool old_shuffle = global_settings.playlist_shuffle;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "status.h"
|
#include "status.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
#include "ata.h"
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
#include "icons.h"
|
#include "icons.h"
|
||||||
|
|
@ -718,6 +719,9 @@ bool dirbrowse(char *root)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( button )
|
||||||
|
ata_spin();
|
||||||
|
|
||||||
if ( restore ) {
|
if ( restore ) {
|
||||||
/* restore display */
|
/* restore display */
|
||||||
/* We need to adjust if the number of lines on screen have
|
/* We need to adjust if the number of lines on screen have
|
||||||
|
|
|
||||||
|
|
@ -1185,6 +1185,9 @@ int wps_show(void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( button )
|
||||||
|
ata_spin();
|
||||||
|
|
||||||
if(restore) {
|
if(restore) {
|
||||||
restore = false;
|
restore = false;
|
||||||
draw_screen(id3);
|
draw_screen(id3);
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,6 @@ static volatile unsigned char* ata_control;
|
||||||
|
|
||||||
bool old_recorder = false;
|
bool old_recorder = false;
|
||||||
static bool sleeping = false;
|
static bool sleeping = false;
|
||||||
static int sleep_timer = 0;
|
|
||||||
static int sleep_timeout = 5*HZ;
|
static int sleep_timeout = 5*HZ;
|
||||||
static char ata_stack[DEFAULT_STACK_SIZE];
|
static char ata_stack[DEFAULT_STACK_SIZE];
|
||||||
static char ata_thread_name[] = "ata";
|
static char ata_thread_name[] = "ata";
|
||||||
|
|
@ -94,6 +93,9 @@ static bool delayed_write = false;
|
||||||
static unsigned char delayed_sector[SECTOR_SIZE];
|
static unsigned char delayed_sector[SECTOR_SIZE];
|
||||||
static int delayed_sector_num;
|
static int delayed_sector_num;
|
||||||
|
|
||||||
|
static long last_user_activity = -1;
|
||||||
|
static long last_disk_activity = -1;
|
||||||
|
|
||||||
#ifdef USE_POWEROFF
|
#ifdef USE_POWEROFF
|
||||||
static int ata_power_on(void);
|
static int ata_power_on(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -149,6 +151,7 @@ int ata_read_sectors(unsigned long start,
|
||||||
int i;
|
int i;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
last_disk_activity = current_tick;
|
||||||
#ifndef USE_STANDBY
|
#ifndef USE_STANDBY
|
||||||
if ( sleeping ) {
|
if ( sleeping ) {
|
||||||
#ifdef USE_POWEROFF
|
#ifdef USE_POWEROFF
|
||||||
|
|
@ -163,7 +166,6 @@ int ata_read_sectors(unsigned long start,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
mutex_lock(&ata_mtx);
|
mutex_lock(&ata_mtx);
|
||||||
sleep_timer = sleep_timeout;
|
|
||||||
|
|
||||||
if (!wait_for_rdy())
|
if (!wait_for_rdy())
|
||||||
{
|
{
|
||||||
|
|
@ -223,6 +225,8 @@ int ata_read_sectors(unsigned long start,
|
||||||
if ( delayed_write )
|
if ( delayed_write )
|
||||||
ata_flush();
|
ata_flush();
|
||||||
|
|
||||||
|
last_disk_activity = current_tick;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -232,6 +236,8 @@ int ata_write_sectors(unsigned long start,
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
last_disk_activity = current_tick;
|
||||||
|
|
||||||
#ifndef USE_STANDBY
|
#ifndef USE_STANDBY
|
||||||
#ifdef USE_POWEROFF
|
#ifdef USE_POWEROFF
|
||||||
if (ata_power_on()) {
|
if (ata_power_on()) {
|
||||||
|
|
@ -244,7 +250,6 @@ int ata_write_sectors(unsigned long start,
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
mutex_lock(&ata_mtx);
|
mutex_lock(&ata_mtx);
|
||||||
sleep_timer = sleep_timeout;
|
|
||||||
|
|
||||||
if (!wait_for_rdy())
|
if (!wait_for_rdy())
|
||||||
{
|
{
|
||||||
|
|
@ -291,6 +296,8 @@ int ata_write_sectors(unsigned long start,
|
||||||
if ( delayed_write )
|
if ( delayed_write )
|
||||||
ata_flush();
|
ata_flush();
|
||||||
|
|
||||||
|
last_disk_activity = current_tick;
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -379,7 +386,6 @@ static int ata_perform_sleep(void)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
#endif
|
#endif
|
||||||
sleeping = true;
|
sleeping = true;
|
||||||
sleep_timer = 0;
|
|
||||||
mutex_unlock(&ata_mtx);
|
mutex_unlock(&ata_mtx);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -390,11 +396,25 @@ int ata_sleep(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ata_spin(void)
|
||||||
|
{
|
||||||
|
last_user_activity = current_tick;
|
||||||
|
}
|
||||||
|
|
||||||
static void ata_thread(void)
|
static void ata_thread(void)
|
||||||
{
|
{
|
||||||
struct event ev;
|
struct event ev;
|
||||||
|
|
||||||
while (1) {
|
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);
|
queue_wait(&ata_queue, &ev);
|
||||||
switch ( ev.id ) {
|
switch ( ev.id ) {
|
||||||
case SYS_USB_CONNECTED:
|
case SYS_USB_CONNECTED:
|
||||||
|
|
@ -407,21 +427,12 @@ static void ata_thread(void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Q_SLEEP:
|
case Q_SLEEP:
|
||||||
ata_perform_sleep();
|
last_disk_activity = current_tick - sleep_timeout;
|
||||||
break;
|
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 ata_hard_reset(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
@ -597,7 +608,6 @@ int ata_init(void)
|
||||||
queue_init(&ata_queue);
|
queue_init(&ata_queue);
|
||||||
create_thread(ata_thread, ata_stack,
|
create_thread(ata_thread, ata_stack,
|
||||||
sizeof(ata_stack), ata_thread_name);
|
sizeof(ata_stack), ata_thread_name);
|
||||||
tick_add_task(ata_tick);
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 int ata_write_sectors(unsigned long start, int count, void* buf);
|
||||||
extern void ata_delayed_write(unsigned long sector, void* buf);
|
extern void ata_delayed_write(unsigned long sector, void* buf);
|
||||||
extern void ata_flush(void);
|
extern void ata_flush(void);
|
||||||
|
extern void ata_spin(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,15 @@ void ata_flush(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ata_spin(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ata_spindown(int s)
|
||||||
|
{
|
||||||
|
(void)s;
|
||||||
|
}
|
||||||
|
|
||||||
Menu simulate_usb(void)
|
Menu simulate_usb(void)
|
||||||
{
|
{
|
||||||
usb_display_info();
|
usb_display_info();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue