summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorJörg Hohensohn <hohensoh@rockbox.org>2004-06-19 15:50:02 +0000
committerJörg Hohensohn <hohensoh@rockbox.org>2004-06-19 15:50:02 +0000
commit6ff6d21d138f789e47f0487833475ac99a6f5f16 (patch)
treedfc5e850aae19ca1f80e6063ffa85d5359b072cf /apps
parent75e7e501d5bcc77acad61cb769ebd03e4f3ce983 (diff)
downloadrockbox-6ff6d21d138f789e47f0487833475ac99a6f5f16.tar.gz
rockbox-6ff6d21d138f789e47f0487833475ac99a6f5f16.zip
settings_load() is now split in RTC and HD part, so RTC settings get loaded early (car adapter mode)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4776 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/main.c30
-rw-r--r--apps/settings.c100
-rw-r--r--apps/settings.h7
3 files changed, 76 insertions, 61 deletions
diff --git a/apps/main.c b/apps/main.c
index 042d3a81f3..b98dfadad6 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -55,6 +55,9 @@
55#include "screens.h" 55#include "screens.h"
56#include "power.h" 56#include "power.h"
57#include "talk.h" 57#include "talk.h"
58#include "plugin.h"
59
60/*#define AUTOROCK*/ /* define this to check for "autostart.rock" on boot */
58 61
59char appsversion[]=APPSVERSION; 62char appsversion[]=APPSVERSION;
60 63
@@ -76,7 +79,8 @@ void init(void)
76 font_init(); 79 font_init();
77 show_logo(); 80 show_logo();
78 settings_reset(); 81 settings_reset();
79 settings_load(); 82 settings_load(SETTINGS_ALL);
83 settings_apply();
80 sleep(HZ/2); 84 sleep(HZ/2);
81 tree_init(); 85 tree_init();
82 playlist_init(); 86 playlist_init();
@@ -129,6 +133,7 @@ void init(void)
129 133
130#ifdef HAVE_RTC 134#ifdef HAVE_RTC
131 rtc_init(); 135 rtc_init();
136 settings_load(SETTINGS_RTC); /* early load parts of global_settings */
132#endif 137#endif
133 138
134 adc_init(); 139 adc_init();
@@ -142,7 +147,7 @@ void init(void)
142 powermgmt_init(); 147 powermgmt_init();
143 148
144#ifdef HAVE_BATTERIES 149#ifdef HAVE_BATTERIES
145 if (coldstart && charger_inserted()) 150 if (coldstart && charger_inserted() && !global_settings.car_adapter_mode)
146 { 151 {
147 rc = charging_screen(); /* display a "charging" screen */ 152 rc = charging_screen(); /* display a "charging" screen */
148 if (rc == 1 || rc == 2) /* charger removed or "Off/Stop" pressed */ 153 if (rc == 1 || rc == 2) /* charger removed or "Off/Stop" pressed */
@@ -196,7 +201,8 @@ void init(void)
196 } 201 }
197 } 202 }
198 203
199 settings_load(); 204 settings_load(SETTINGS_ALL);
205 settings_apply();
200 206
201 status_init(); 207 status_init();
202 playlist_init(); 208 playlist_init();
@@ -215,24 +221,20 @@ void init(void)
215 mpeg_init(); 221 mpeg_init();
216 talk_init(); 222 talk_init();
217 223
218 /* no auto-rolo on startup any more, but I leave it here for reference */ 224#ifdef AUTOROCK
219#if 0 225 if (!usb_detect())
220 if (coldstart && !usb_detect()) 226 {
221 { /* when starting from flash, this time _we_ have to yield */
222 int fd; 227 int fd;
223#ifdef ARCHOS_PLAYER 228 static const char filename[] = PLUGIN_DIR "/autostart.rock";
224 static const char filename[] = "/archos.mod"; 229
225#else
226 static const char filename[] = "/ajbrec.ajz";
227#endif
228 fd = open(filename, O_RDONLY); 230 fd = open(filename, O_RDONLY);
229 if(fd >= 0) /* no complaint if it doesn't exit */ 231 if(fd >= 0) /* no complaint if it doesn't exit */
230 { 232 {
231 close(fd); 233 close(fd);
232 rolo_load((char*)filename); /* start if it does */ 234 plugin_load((char*)filename, NULL); /* start if it does */
233 } 235 }
234 } 236 }
235#endif // #if 0 237#endif /* #ifdef AUTOROCK */
236} 238}
237 239
238int main(void) 240int main(void)
diff --git a/apps/settings.c b/apps/settings.c
index f5f46225d2..463fd710be 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -428,8 +428,8 @@ static void init_config_buffer( void )
428{ 428{
429 DEBUGF( "init_config_buffer()\n" ); 429 DEBUGF( "init_config_buffer()\n" );
430 430
431 /* reset to 0xff - all unused */ 431 /* reset to 0 - all unused */
432 memset(config_block, 0xff, CONFIG_BLOCK_SIZE); 432 memset(config_block, 0, CONFIG_BLOCK_SIZE);
433 /* insert header */ 433 /* insert header */
434 config_block[0] = 'R'; 434 config_block[0] = 'R';
435 config_block[1] = 'o'; 435 config_block[1] = 'o';
@@ -480,33 +480,32 @@ static int save_config_buffer( void )
480/* 480/*
481 * load the config block buffer from disk or RTC RAM 481 * load the config block buffer from disk or RTC RAM
482 */ 482 */
483static int load_config_buffer( void ) 483static int load_config_buffer(int which)
484{ 484{
485 unsigned short chksum; 485 unsigned short chksum;
486 bool correct = false; 486 bool correct = false;
487 487
488#ifdef HAVE_RTC 488
489 unsigned int i;
490 unsigned char rtc_block[RTC_BLOCK_SIZE];
491#endif
492
493 DEBUGF( "load_config_buffer()\n" ); 489 DEBUGF( "load_config_buffer()\n" );
494 490
495 if (fat_startsector() != 0) { 491 if (which & SETTINGS_HD)
496 ata_read_sectors( 61, 1, config_block); 492 {
493 if (fat_startsector() != 0) {
494 ata_read_sectors( 61, 1, config_block);
497 495
498 /* calculate the checksum, check it and the header */ 496 /* calculate the checksum, check it and the header */
499 chksum = calculate_config_checksum(config_block); 497 chksum = calculate_config_checksum(config_block);
500 498
501 if (config_block[0] == 'R' && 499 if (config_block[0] == 'R' &&
502 config_block[1] == 'o' && 500 config_block[1] == 'o' &&
503 config_block[2] == 'c' && 501 config_block[2] == 'c' &&
504 config_block[3] == CONFIG_BLOCK_VERSION && 502 config_block[3] == CONFIG_BLOCK_VERSION &&
505 (chksum >> 8) == config_block[RTC_BLOCK_SIZE - 2] && 503 (chksum >> 8) == config_block[RTC_BLOCK_SIZE - 2] &&
506 (chksum & 0xff) == config_block[RTC_BLOCK_SIZE - 1]) 504 (chksum & 0xff) == config_block[RTC_BLOCK_SIZE - 1])
507 { 505 {
508 DEBUGF( "load_config_buffer: header & checksum test ok\n" ); 506 DEBUGF( "load_config_buffer: header & checksum test ok\n" );
509 correct = true; 507 correct = true;
508 }
510 } 509 }
511 } 510 }
512 511
@@ -514,24 +513,31 @@ static int load_config_buffer( void )
514 if(!correct) 513 if(!correct)
515 { 514 {
516 /* If the disk sector was incorrect, reinit the buffer */ 515 /* If the disk sector was incorrect, reinit the buffer */
517 memset(config_block, 0xff, CONFIG_BLOCK_SIZE); 516 memset(config_block, 0, CONFIG_BLOCK_SIZE);
518 } 517 }
519 /* read rtc block */
520 for (i=0; i < RTC_BLOCK_SIZE; i++ )
521 rtc_block[i] = rtc_read(0x14+i);
522 518
523 chksum = calculate_config_checksum(rtc_block); 519 if (which & SETTINGS_RTC)
524
525 /* if rtc block is ok, use that */
526 if (rtc_block[0] == 'R' &&
527 rtc_block[1] == 'o' &&
528 rtc_block[2] == 'c' &&
529 rtc_block[3] == CONFIG_BLOCK_VERSION &&
530 (chksum >> 8) == rtc_block[RTC_BLOCK_SIZE - 2] &&
531 (chksum & 0xff) == rtc_block[RTC_BLOCK_SIZE - 1])
532 { 520 {
533 memcpy(config_block, rtc_block, RTC_BLOCK_SIZE); 521 unsigned int i;
534 correct = true; 522 unsigned char rtc_block[RTC_BLOCK_SIZE];
523
524 /* read rtc block */
525 for (i=0; i < RTC_BLOCK_SIZE; i++ )
526 rtc_block[i] = rtc_read(0x14+i);
527
528 chksum = calculate_config_checksum(rtc_block);
529
530 /* if rtc block is ok, use that */
531 if (rtc_block[0] == 'R' &&
532 rtc_block[1] == 'o' &&
533 rtc_block[2] == 'c' &&
534 rtc_block[3] == CONFIG_BLOCK_VERSION &&
535 (chksum >> 8) == rtc_block[RTC_BLOCK_SIZE - 2] &&
536 (chksum & 0xff) == rtc_block[RTC_BLOCK_SIZE - 1])
537 {
538 memcpy(config_block, rtc_block, RTC_BLOCK_SIZE);
539 correct = true;
540 }
535 } 541 }
536#endif 542#endif
537 543
@@ -831,18 +837,15 @@ static void load_bit_table(const struct bit_entry* p_table, int count, int bitst
831/* 837/*
832 * load settings from disk or RTC RAM 838 * load settings from disk or RTC RAM
833 */ 839 */
834void settings_load(void) 840void settings_load(int which)
835{ 841{
836 int restore[6]; /* recover, FIXME: get rid of this */ 842 int restore[6]; /* recover, FIXME: get rid of this */
837 843
838 DEBUGF( "reload_all_settings()\n" ); 844 DEBUGF( "reload_all_settings()\n" );
839 845
840 /* populate settings with default values */
841 settings_reset();
842
843 /* load the buffer from the RTC (resets it to all-unused if the block 846 /* load the buffer from the RTC (resets it to all-unused if the block
844 is invalid) and decode the settings which are set in the block */ 847 is invalid) and decode the settings which are set in the block */
845 if (!load_config_buffer()) 848 if (!load_config_buffer(which))
846 { 849 {
847 /* While the mpeg_val2phys business still exists: ( FIXME: to be removed) */ 850 /* While the mpeg_val2phys business still exists: ( FIXME: to be removed) */
848 /* temporarily put markers into the values to detect if they got loaded */ 851 /* temporarily put markers into the values to detect if they got loaded */
@@ -862,8 +865,15 @@ void settings_load(void)
862#endif 865#endif
863 866
864 /* load scalar values from RTC and HD sector, specified via table */ 867 /* load scalar values from RTC and HD sector, specified via table */
865 load_bit_table(rtc_bits, sizeof(rtc_bits)/sizeof(rtc_bits[0]), 4*8); 868 if (which & SETTINGS_RTC)
866 load_bit_table(hd_bits, sizeof(hd_bits)/sizeof(hd_bits[0]), RTC_BLOCK_SIZE*8); 869 {
870 load_bit_table(rtc_bits, sizeof(rtc_bits)/sizeof(rtc_bits[0]), 4*8);
871 }
872 if (which & SETTINGS_HD)
873 {
874 load_bit_table(hd_bits, sizeof(hd_bits)/sizeof(hd_bits[0]),
875 RTC_BLOCK_SIZE*8);
876 }
867 877
868 /* FIXME, to be removed with mpeg_val2phys: */ 878 /* FIXME, to be removed with mpeg_val2phys: */
869 /* if a value got loaded, convert it, else restore it */ 879 /* if a value got loaded, convert it, else restore it */
@@ -888,9 +898,7 @@ void settings_load(void)
888 strncpy(global_settings.wps_file, &config_block[0xb8], MAX_FILENAME); 898 strncpy(global_settings.wps_file, &config_block[0xb8], MAX_FILENAME);
889 strncpy(global_settings.lang_file, &config_block[0xcc], MAX_FILENAME); 899 strncpy(global_settings.lang_file, &config_block[0xcc], MAX_FILENAME);
890 strncpy(global_settings.font_file, &config_block[0xe0], MAX_FILENAME); 900 strncpy(global_settings.font_file, &config_block[0xe0], MAX_FILENAME);
891 } 901 }
892
893 settings_apply();
894} 902}
895 903
896/* parse a line from a configuration file. the line format is: 904/* parse a line from a configuration file. the line format is:
diff --git a/apps/settings.h b/apps/settings.h
index f14eb63edf..315824cd9e 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -220,7 +220,7 @@ struct opt_items {
220/* prototypes */ 220/* prototypes */
221 221
222int settings_save(void); 222int settings_save(void);
223void settings_load(void); 223void settings_load(int which);
224void settings_reset(void); 224void settings_reset(void);
225void settings_apply(void); 225void settings_apply(void);
226void settings_apply_pm_range(void); 226void settings_apply_pm_range(void);
@@ -267,6 +267,11 @@ extern char rec_base_directory[];
267#endif 267#endif
268#define MIN_CONTRAST_SETTING 5 268#define MIN_CONTRAST_SETTING 5
269 269
270/* argument bits for settings_load() */
271#define SETTINGS_RTC 1 /* only the settings from the RTC nonvolatile RAM */
272#define SETTINGS_HD 2 /* only the settings fron the disk sector */
273#define SETTINGS_ALL 3 /* both */
274
270/* repeat mode options */ 275/* repeat mode options */
271enum { REPEAT_OFF, REPEAT_ALL, REPEAT_ONE, NUM_REPEAT_MODES }; 276enum { REPEAT_OFF, REPEAT_ALL, REPEAT_ONE, NUM_REPEAT_MODES };
272 277