1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Jörg Hohensohn 2004-06-19 15:50:02 +00:00
parent 75e7e501d5
commit 6ff6d21d13
3 changed files with 76 additions and 61 deletions

View file

@ -55,6 +55,9 @@
#include "screens.h"
#include "power.h"
#include "talk.h"
#include "plugin.h"
/*#define AUTOROCK*/ /* define this to check for "autostart.rock" on boot */
char appsversion[]=APPSVERSION;
@ -76,7 +79,8 @@ void init(void)
font_init();
show_logo();
settings_reset();
settings_load();
settings_load(SETTINGS_ALL);
settings_apply();
sleep(HZ/2);
tree_init();
playlist_init();
@ -129,6 +133,7 @@ void init(void)
#ifdef HAVE_RTC
rtc_init();
settings_load(SETTINGS_RTC); /* early load parts of global_settings */
#endif
adc_init();
@ -142,7 +147,7 @@ void init(void)
powermgmt_init();
#ifdef HAVE_BATTERIES
if (coldstart && charger_inserted())
if (coldstart && charger_inserted() && !global_settings.car_adapter_mode)
{
rc = charging_screen(); /* display a "charging" screen */
if (rc == 1 || rc == 2) /* charger removed or "Off/Stop" pressed */
@ -196,7 +201,8 @@ void init(void)
}
}
settings_load();
settings_load(SETTINGS_ALL);
settings_apply();
status_init();
playlist_init();
@ -215,24 +221,20 @@ void init(void)
mpeg_init();
talk_init();
/* no auto-rolo on startup any more, but I leave it here for reference */
#if 0
if (coldstart && !usb_detect())
{ /* when starting from flash, this time _we_ have to yield */
#ifdef AUTOROCK
if (!usb_detect())
{
int fd;
#ifdef ARCHOS_PLAYER
static const char filename[] = "/archos.mod";
#else
static const char filename[] = "/ajbrec.ajz";
#endif
static const char filename[] = PLUGIN_DIR "/autostart.rock";
fd = open(filename, O_RDONLY);
if(fd >= 0) /* no complaint if it doesn't exit */
{
close(fd);
rolo_load((char*)filename); /* start if it does */
plugin_load((char*)filename, NULL); /* start if it does */
}
}
#endif // #if 0
#endif /* #ifdef AUTOROCK */
}
int main(void)

View file

@ -428,8 +428,8 @@ static void init_config_buffer( void )
{
DEBUGF( "init_config_buffer()\n" );
/* reset to 0xff - all unused */
memset(config_block, 0xff, CONFIG_BLOCK_SIZE);
/* reset to 0 - all unused */
memset(config_block, 0, CONFIG_BLOCK_SIZE);
/* insert header */
config_block[0] = 'R';
config_block[1] = 'o';
@ -480,33 +480,32 @@ static int save_config_buffer( void )
/*
* load the config block buffer from disk or RTC RAM
*/
static int load_config_buffer( void )
static int load_config_buffer(int which)
{
unsigned short chksum;
bool correct = false;
#ifdef HAVE_RTC
unsigned int i;
unsigned char rtc_block[RTC_BLOCK_SIZE];
#endif
DEBUGF( "load_config_buffer()\n" );
if (fat_startsector() != 0) {
ata_read_sectors( 61, 1, config_block);
if (which & SETTINGS_HD)
{
if (fat_startsector() != 0) {
ata_read_sectors( 61, 1, config_block);
/* calculate the checksum, check it and the header */
chksum = calculate_config_checksum(config_block);
/* calculate the checksum, check it and the header */
chksum = calculate_config_checksum(config_block);
if (config_block[0] == 'R' &&
config_block[1] == 'o' &&
config_block[2] == 'c' &&
config_block[3] == CONFIG_BLOCK_VERSION &&
(chksum >> 8) == config_block[RTC_BLOCK_SIZE - 2] &&
(chksum & 0xff) == config_block[RTC_BLOCK_SIZE - 1])
{
DEBUGF( "load_config_buffer: header & checksum test ok\n" );
correct = true;
if (config_block[0] == 'R' &&
config_block[1] == 'o' &&
config_block[2] == 'c' &&
config_block[3] == CONFIG_BLOCK_VERSION &&
(chksum >> 8) == config_block[RTC_BLOCK_SIZE - 2] &&
(chksum & 0xff) == config_block[RTC_BLOCK_SIZE - 1])
{
DEBUGF( "load_config_buffer: header & checksum test ok\n" );
correct = true;
}
}
}
@ -514,24 +513,31 @@ static int load_config_buffer( void )
if(!correct)
{
/* If the disk sector was incorrect, reinit the buffer */
memset(config_block, 0xff, CONFIG_BLOCK_SIZE);
memset(config_block, 0, CONFIG_BLOCK_SIZE);
}
/* read rtc block */
for (i=0; i < RTC_BLOCK_SIZE; i++ )
rtc_block[i] = rtc_read(0x14+i);
chksum = calculate_config_checksum(rtc_block);
/* if rtc block is ok, use that */
if (rtc_block[0] == 'R' &&
rtc_block[1] == 'o' &&
rtc_block[2] == 'c' &&
rtc_block[3] == CONFIG_BLOCK_VERSION &&
(chksum >> 8) == rtc_block[RTC_BLOCK_SIZE - 2] &&
(chksum & 0xff) == rtc_block[RTC_BLOCK_SIZE - 1])
if (which & SETTINGS_RTC)
{
memcpy(config_block, rtc_block, RTC_BLOCK_SIZE);
correct = true;
unsigned int i;
unsigned char rtc_block[RTC_BLOCK_SIZE];
/* read rtc block */
for (i=0; i < RTC_BLOCK_SIZE; i++ )
rtc_block[i] = rtc_read(0x14+i);
chksum = calculate_config_checksum(rtc_block);
/* if rtc block is ok, use that */
if (rtc_block[0] == 'R' &&
rtc_block[1] == 'o' &&
rtc_block[2] == 'c' &&
rtc_block[3] == CONFIG_BLOCK_VERSION &&
(chksum >> 8) == rtc_block[RTC_BLOCK_SIZE - 2] &&
(chksum & 0xff) == rtc_block[RTC_BLOCK_SIZE - 1])
{
memcpy(config_block, rtc_block, RTC_BLOCK_SIZE);
correct = true;
}
}
#endif
@ -831,18 +837,15 @@ static void load_bit_table(const struct bit_entry* p_table, int count, int bitst
/*
* load settings from disk or RTC RAM
*/
void settings_load(void)
void settings_load(int which)
{
int restore[6]; /* recover, FIXME: get rid of this */
DEBUGF( "reload_all_settings()\n" );
/* populate settings with default values */
settings_reset();
/* load the buffer from the RTC (resets it to all-unused if the block
is invalid) and decode the settings which are set in the block */
if (!load_config_buffer())
if (!load_config_buffer(which))
{
/* While the mpeg_val2phys business still exists: ( FIXME: to be removed) */
/* temporarily put markers into the values to detect if they got loaded */
@ -862,8 +865,15 @@ void settings_load(void)
#endif
/* load scalar values from RTC and HD sector, specified via table */
load_bit_table(rtc_bits, sizeof(rtc_bits)/sizeof(rtc_bits[0]), 4*8);
load_bit_table(hd_bits, sizeof(hd_bits)/sizeof(hd_bits[0]), RTC_BLOCK_SIZE*8);
if (which & SETTINGS_RTC)
{
load_bit_table(rtc_bits, sizeof(rtc_bits)/sizeof(rtc_bits[0]), 4*8);
}
if (which & SETTINGS_HD)
{
load_bit_table(hd_bits, sizeof(hd_bits)/sizeof(hd_bits[0]),
RTC_BLOCK_SIZE*8);
}
/* FIXME, to be removed with mpeg_val2phys: */
/* if a value got loaded, convert it, else restore it */
@ -888,9 +898,7 @@ void settings_load(void)
strncpy(global_settings.wps_file, &config_block[0xb8], MAX_FILENAME);
strncpy(global_settings.lang_file, &config_block[0xcc], MAX_FILENAME);
strncpy(global_settings.font_file, &config_block[0xe0], MAX_FILENAME);
}
settings_apply();
}
}
/* parse a line from a configuration file. the line format is:

View file

@ -220,7 +220,7 @@ struct opt_items {
/* prototypes */
int settings_save(void);
void settings_load(void);
void settings_load(int which);
void settings_reset(void);
void settings_apply(void);
void settings_apply_pm_range(void);
@ -267,6 +267,11 @@ extern char rec_base_directory[];
#endif
#define MIN_CONTRAST_SETTING 5
/* argument bits for settings_load() */
#define SETTINGS_RTC 1 /* only the settings from the RTC nonvolatile RAM */
#define SETTINGS_HD 2 /* only the settings fron the disk sector */
#define SETTINGS_ALL 3 /* both */
/* repeat mode options */
enum { REPEAT_OFF, REPEAT_ALL, REPEAT_ONE, NUM_REPEAT_MODES };