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.tar.gz
rockbox-457b8a0a6743b7bee72d90e484055b7635861612.zip
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 11a4647447..441abb585d 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -268,7 +268,8 @@ int settings_save( void )
268 268
269 config_block[0x10] = (unsigned char)global_settings.ff_rewind; 269 config_block[0x10] = (unsigned char)global_settings.ff_rewind;
270 config_block[0x11] = (unsigned char)global_settings.avc; 270 config_block[0x11] = (unsigned char)global_settings.avc;
271 271 config_block[0x1a] = (unsigned char)global_settings.disk_spindown;
272
272 memcpy(&config_block[0x12], &global_settings.resume_index, 4); 273 memcpy(&config_block[0x12], &global_settings.resume_index, 4);
273 memcpy(&config_block[0x16], &global_settings.resume_offset, 4); 274 memcpy(&config_block[0x16], &global_settings.resume_offset, 4);
274 memcpy(&config_block[0xF8], &global_settings.resume_seed, 4); 275 memcpy(&config_block[0xF8], &global_settings.resume_seed, 4);
@@ -369,6 +370,9 @@ void settings_load(void)
369 if (config_block[0x16] != 0xFF) 370 if (config_block[0x16] != 0xFF)
370 memcpy(&global_settings.resume_offset, &config_block[0x16], 4); 371 memcpy(&global_settings.resume_offset, &config_block[0x16], 4);
371 372
373 if (config_block[0x1a] != 0xFF)
374 global_settings.disk_spindown = config_block[0x1a];
375
372 memcpy(&global_settings.resume_seed, &config_block[0xF8], 4); 376 memcpy(&global_settings.resume_seed, &config_block[0xF8], 4);
373 377
374 if (config_block[0x24] != 0xFF) 378 if (config_block[0x24] != 0xFF)
@@ -380,6 +384,7 @@ void settings_load(void)
380 lcd_set_contrast(global_settings.contrast); 384 lcd_set_contrast(global_settings.contrast);
381 lcd_scroll_speed(global_settings.scroll_speed); 385 lcd_scroll_speed(global_settings.scroll_speed);
382 backlight_time(global_settings.backlight); 386 backlight_time(global_settings.backlight);
387 ata_spindown(global_settings.disk_spindown);
383#ifdef HAVE_CHARGE_CTRL 388#ifdef HAVE_CHARGE_CTRL
384 charge_restart_level = global_settings.discharge ? CHARGE_RESTART_LO : CHARGE_RESTART_HI; 389 charge_restart_level = global_settings.discharge ? CHARGE_RESTART_LO : CHARGE_RESTART_HI;
385#endif 390#endif
@@ -416,6 +421,7 @@ void settings_reset(void) {
416 global_settings.ff_rewind = DEFAULT_FF_REWIND_SETTING; 421 global_settings.ff_rewind = DEFAULT_FF_REWIND_SETTING;
417 global_settings.resume_index = -1; 422 global_settings.resume_index = -1;
418 global_settings.resume_offset = -1; 423 global_settings.resume_offset = -1;
424 global_settings.disk_spindown = 5;
419} 425}
420 426
421 427
diff --git a/apps/settings.h b/apps/settings.h
index 36cf4930e1..91ffb3ed90 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -63,6 +63,8 @@ struct user_settings
63 bool sort_case; /* dir sort order: 0=case insensitive, 1=sensitive */ 63 bool sort_case; /* dir sort order: 0=case insensitive, 1=sensitive */
64 int scroll_speed; /* long texts scrolling speed: 1-20 */ 64 int scroll_speed; /* long texts scrolling speed: 1-20 */
65 bool playlist_shuffle; 65 bool playlist_shuffle;
66 int ff_rewind; /* FF/Rewind step size (in seconds) */
67 int disk_spindown; /* time until disk spindown, in seconds (0=off) */
66 68
67 /* while playing screen settings */ 69 /* while playing screen settings */
68 int wps_display; /* 0=id3, 1=file, 2=parse */ 70 int wps_display; /* 0=id3, 1=file, 2=parse */
@@ -77,8 +79,6 @@ struct user_settings
77 /* geeky persistent statistics */ 79 /* geeky persistent statistics */
78 unsigned int total_uptime; /* total uptime since rockbox was first booted */ 80 unsigned int total_uptime; /* total uptime since rockbox was first booted */
79 81
80 /* FF/Rewind step size (in seconds) */
81 int ff_rewind;
82}; 82};
83 83
84/* prototypes */ 84/* prototypes */
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index c3f3bccb61..9f36d3be2b 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -35,6 +35,7 @@
35#include "fat.h" /* For dotfile settings */ 35#include "fat.h" /* For dotfile settings */
36#include "powermgmt.h" 36#include "powermgmt.h"
37#include "rtc.h" 37#include "rtc.h"
38#include "ata.h"
38 39
39static Menu show_hidden_files(void) 40static Menu show_hidden_files(void)
40{ 41{
@@ -167,7 +168,14 @@ static Menu timedate_set(void)
167static Menu ff_rewind(void) 168static Menu ff_rewind(void)
168{ 169{
169 set_int("[FF/Rewind Step Size]", "s", &global_settings.ff_rewind, 170 set_int("[FF/Rewind Step Size]", "s", &global_settings.ff_rewind,
170 NULL, 1, 1, 255 ); 171 NULL, 1, 1, 254 );
172 return MENU_OK;
173}
174
175static Menu spindown(void)
176{
177 set_int("[Disk spindown]", "s", &global_settings.disk_spindown,
178 ata_spindown, 1, 1, 254 );
171 return MENU_OK; 179 return MENU_OK;
172} 180}
173 181
@@ -193,6 +201,7 @@ Menu settings_menu(void)
193 { "Show hidden files", show_hidden_files }, 201 { "Show hidden files", show_hidden_files },
194 { "FF/Rewind", ff_rewind }, 202 { "FF/Rewind", ff_rewind },
195 { "Resume", resume }, 203 { "Resume", resume },
204 { "Disk spindown", spindown },
196 }; 205 };
197 bool old_shuffle = global_settings.playlist_shuffle; 206 bool old_shuffle = global_settings.playlist_shuffle;
198 207
diff --git a/apps/tree.c b/apps/tree.c
index 9dae3229e2..e47452fe54 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -39,6 +39,7 @@
39#include "settings.h" 39#include "settings.h"
40#include "status.h" 40#include "status.h"
41#include "debug.h" 41#include "debug.h"
42#include "ata.h"
42 43
43#ifdef HAVE_LCD_BITMAP 44#ifdef HAVE_LCD_BITMAP
44#include "icons.h" 45#include "icons.h"
@@ -718,6 +719,9 @@ bool dirbrowse(char *root)
718#endif 719#endif
719 } 720 }
720 721
722 if ( button )
723 ata_spin();
724
721 if ( restore ) { 725 if ( restore ) {
722 /* restore display */ 726 /* restore display */
723 /* We need to adjust if the number of lines on screen have 727 /* We need to adjust if the number of lines on screen have
diff --git a/apps/wps.c b/apps/wps.c
index bdad325434..571b35675d 100644
--- a/apps/wps.c
+++ b/apps/wps.c
@@ -1185,6 +1185,9 @@ int wps_show(void)
1185 break; 1185 break;
1186 } 1186 }
1187 1187
1188 if ( button )
1189 ata_spin();
1190
1188 if(restore) { 1191 if(restore) {
1189 restore = false; 1192 restore = false;
1190 draw_screen(id3); 1193 draw_screen(id3);
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index 700e403b9f..e867ac2f50 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -84,7 +84,6 @@ static volatile unsigned char* ata_control;
84 84
85bool old_recorder = false; 85bool old_recorder = false;
86static bool sleeping = false; 86static bool sleeping = false;
87static int sleep_timer = 0;
88static int sleep_timeout = 5*HZ; 87static int sleep_timeout = 5*HZ;
89static char ata_stack[DEFAULT_STACK_SIZE]; 88static char ata_stack[DEFAULT_STACK_SIZE];
90static char ata_thread_name[] = "ata"; 89static char ata_thread_name[] = "ata";
@@ -94,6 +93,9 @@ static bool delayed_write = false;
94static unsigned char delayed_sector[SECTOR_SIZE]; 93static unsigned char delayed_sector[SECTOR_SIZE];
95static int delayed_sector_num; 94static int delayed_sector_num;
96 95
96static long last_user_activity = -1;
97static long last_disk_activity = -1;
98
97#ifdef USE_POWEROFF 99#ifdef USE_POWEROFF
98static int ata_power_on(void); 100static int ata_power_on(void);
99#endif 101#endif
@@ -149,6 +151,7 @@ int ata_read_sectors(unsigned long start,
149 int i; 151 int i;
150 int ret = 0; 152 int ret = 0;
151 153
154 last_disk_activity = current_tick;
152#ifndef USE_STANDBY 155#ifndef USE_STANDBY
153 if ( sleeping ) { 156 if ( sleeping ) {
154#ifdef USE_POWEROFF 157#ifdef USE_POWEROFF
@@ -163,7 +166,6 @@ int ata_read_sectors(unsigned long start,
163 } 166 }
164#endif 167#endif
165 mutex_lock(&ata_mtx); 168 mutex_lock(&ata_mtx);
166 sleep_timer = sleep_timeout;
167 169
168 if (!wait_for_rdy()) 170 if (!wait_for_rdy())
169 { 171 {
@@ -223,6 +225,8 @@ int ata_read_sectors(unsigned long start,
223 if ( delayed_write ) 225 if ( delayed_write )
224 ata_flush(); 226 ata_flush();
225 227
228 last_disk_activity = current_tick;
229
226 return ret; 230 return ret;
227} 231}
228 232
@@ -232,6 +236,8 @@ int ata_write_sectors(unsigned long start,
232{ 236{
233 int i; 237 int i;
234 238
239 last_disk_activity = current_tick;
240
235#ifndef USE_STANDBY 241#ifndef USE_STANDBY
236#ifdef USE_POWEROFF 242#ifdef USE_POWEROFF
237 if (ata_power_on()) { 243 if (ata_power_on()) {
@@ -244,7 +250,6 @@ int ata_write_sectors(unsigned long start,
244#endif 250#endif
245#endif 251#endif
246 mutex_lock(&ata_mtx); 252 mutex_lock(&ata_mtx);
247 sleep_timer = sleep_timeout;
248 253
249 if (!wait_for_rdy()) 254 if (!wait_for_rdy())
250 { 255 {
@@ -291,6 +296,8 @@ int ata_write_sectors(unsigned long start,
291 if ( delayed_write ) 296 if ( delayed_write )
292 ata_flush(); 297 ata_flush();
293 298
299 last_disk_activity = current_tick;
300
294 return i; 301 return i;
295} 302}
296 303
@@ -379,7 +386,6 @@ static int ata_perform_sleep(void)
379 ret = -1; 386 ret = -1;
380#endif 387#endif
381 sleeping = true; 388 sleeping = true;
382 sleep_timer = 0;
383 mutex_unlock(&ata_mtx); 389 mutex_unlock(&ata_mtx);
384 return ret; 390 return ret;
385} 391}
@@ -390,11 +396,25 @@ int ata_sleep(void)
390 return 0; 396 return 0;
391} 397}
392 398
399void ata_spin(void)
400{
401 last_user_activity = current_tick;
402}
403
393static void ata_thread(void) 404static void ata_thread(void)
394{ 405{
395 struct event ev; 406 struct event ev;
396 407
397 while (1) { 408 while (1) {
409 while ( queue_empty( &ata_queue ) ) {
410 if ( sleep_timeout &&
411 TIME_AFTER( current_tick,
412 last_user_activity + sleep_timeout ) &&
413 TIME_AFTER( current_tick,
414 last_disk_activity + sleep_timeout ) )
415 ata_perform_sleep();
416 sleep(HZ/4);
417 }
398 queue_wait(&ata_queue, &ev); 418 queue_wait(&ata_queue, &ev);
399 switch ( ev.id ) { 419 switch ( ev.id ) {
400 case SYS_USB_CONNECTED: 420 case SYS_USB_CONNECTED:
@@ -407,21 +427,12 @@ static void ata_thread(void)
407 break; 427 break;
408 428
409 case Q_SLEEP: 429 case Q_SLEEP:
410 ata_perform_sleep(); 430 last_disk_activity = current_tick - sleep_timeout;
411 break; 431 break;
412 } 432 }
413 } 433 }
414} 434}
415 435
416static void ata_tick(void)
417{
418 if (sleep_timer) {
419 sleep_timer--;
420 if (!sleep_timer)
421 queue_post(&ata_queue, 0, NULL);
422 }
423}
424
425int ata_hard_reset(void) 436int ata_hard_reset(void)
426{ 437{
427 int ret; 438 int ret;
@@ -597,7 +608,6 @@ int ata_init(void)
597 queue_init(&ata_queue); 608 queue_init(&ata_queue);
598 create_thread(ata_thread, ata_stack, 609 create_thread(ata_thread, ata_stack,
599 sizeof(ata_stack), ata_thread_name); 610 sizeof(ata_stack), ata_thread_name);
600 tick_add_task(ata_tick);
601 initialized = true; 611 initialized = true;
602 } 612 }
603 613
diff --git a/firmware/drivers/ata.h b/firmware/drivers/ata.h
index 244ec63777..da5c5e3e58 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);
43extern int ata_write_sectors(unsigned long start, int count, void* buf); 43extern int ata_write_sectors(unsigned long start, int count, void* buf);
44extern void ata_delayed_write(unsigned long sector, void* buf); 44extern void ata_delayed_write(unsigned long sector, void* buf);
45extern void ata_flush(void); 45extern void ata_flush(void);
46extern void ata_spin(void);
46 47
47#endif 48#endif
diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c
index 7dc329f9fe..18e7f8cfe7 100644
--- a/uisimulator/common/stubs.c
+++ b/uisimulator/common/stubs.c
@@ -89,6 +89,15 @@ void ata_flush(void)
89{ 89{
90} 90}
91 91
92void ata_spin(void)
93{
94}
95
96void ata_spindown(int s)
97{
98 (void)s;
99}
100
92Menu simulate_usb(void) 101Menu simulate_usb(void)
93{ 102{
94 usb_display_info(); 103 usb_display_info();