summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2007-01-24 02:19:22 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2007-01-24 02:19:22 +0000
commit228d62dd18906eaef814ec63cf888b30a94cd1c8 (patch)
treea15e27e0e52222e4514e2b163e726869b33b5397
parentcdcffd988372606abea31fad4a815f0b4968b21c (diff)
downloadrockbox-228d62dd18906eaef814ec63cf888b30a94cd1c8.tar.gz
rockbox-228d62dd18906eaef814ec63cf888b30a94cd1c8.zip
Split the system status variables out of global_settings and put them into a new struct global_status. Use status_save() if these need
saving. Added car_adapter_mode to the nvram settings, so nvram settings will be reset. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12101 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/debug_menu.c2
-rw-r--r--apps/filetree.c6
-rw-r--r--apps/gui/gwps-common.c2
-rw-r--r--apps/main.c12
-rw-r--r--apps/playlist.c62
-rw-r--r--apps/plugin.h4
-rw-r--r--apps/recorder/radio.c6
-rw-r--r--apps/screens.c12
-rw-r--r--apps/settings.c32
-rw-r--r--apps/settings.h32
-rw-r--r--apps/settings_list.c4
-rw-r--r--apps/settings_list.h2
-rw-r--r--apps/tree.c22
13 files changed, 115 insertions, 83 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 22db43d272..c5240d0de8 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -1830,7 +1830,7 @@ static bool dbg_dircache_info(void)
1830 lcd_puts(0, line++, buf); 1830 lcd_puts(0, line++, buf);
1831 1831
1832 snprintf(buf, sizeof(buf), "Last size: %d B", 1832 snprintf(buf, sizeof(buf), "Last size: %d B",
1833 global_settings.dircache_size); 1833 global_status.dircache_size);
1834 lcd_puts(0, line++, buf); 1834 lcd_puts(0, line++, buf);
1835 1835
1836 snprintf(buf, sizeof(buf), "Limit: %d B", DIRCACHE_LIMIT); 1836 snprintf(buf, sizeof(buf), "Limit: %d B", DIRCACHE_LIMIT);
diff --git a/apps/filetree.c b/apps/filetree.c
index cd020d0a51..10174dbb31 100644
--- a/apps/filetree.c
+++ b/apps/filetree.c
@@ -572,9 +572,9 @@ int ft_enter(struct tree_context* c)
572 if ( play ) { 572 if ( play ) {
573 /* the resume_index must always be the index in the 573 /* the resume_index must always be the index in the
574 shuffled list in case shuffle is enabled */ 574 shuffled list in case shuffle is enabled */
575 global_settings.resume_index = start_index; 575 global_status.resume_index = start_index;
576 global_settings.resume_offset = 0; 576 global_status.resume_offset = 0;
577 settings_save(); 577 status_save();
578 578
579 start_wps = true; 579 start_wps = true;
580 } 580 }
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c
index f2aa497703..41edc0002b 100644
--- a/apps/gui/gwps-common.c
+++ b/apps/gui/gwps-common.c
@@ -2483,7 +2483,7 @@ bool gui_wps_display(void)
2483 int i; 2483 int i;
2484 if (!wps_state.id3 && !(audio_status() & AUDIO_STATUS_PLAY)) 2484 if (!wps_state.id3 && !(audio_status() & AUDIO_STATUS_PLAY))
2485 { 2485 {
2486 global_settings.resume_index = -1; 2486 global_status.resume_index = -1;
2487#ifdef HAVE_LCD_CHARCELLS 2487#ifdef HAVE_LCD_CHARCELLS
2488 gui_syncsplash(HZ, true, str(LANG_END_PLAYLIST_PLAYER)); 2488 gui_syncsplash(HZ, true, str(LANG_END_PLAYLIST_PLAYER));
2489#else 2489#else
diff --git a/apps/main.c b/apps/main.c
index 5137ff9fa6..dac7ac755d 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -140,7 +140,7 @@ static int init_dircache(bool preinit)
140 if (result < 0) 140 if (result < 0)
141 { 141 {
142 firmware_settings.disk_clean = false; 142 firmware_settings.disk_clean = false;
143 if (global_settings.dircache_size <= 0) 143 if (global_status.dircache_size <= 0)
144 { 144 {
145 /* This will be in default language, settings are not 145 /* This will be in default language, settings are not
146 applied yet. Not really any easy way to fix that. */ 146 applied yet. Not really any easy way to fix that. */
@@ -148,7 +148,7 @@ static int init_dircache(bool preinit)
148 clear = true; 148 clear = true;
149 } 149 }
150 150
151 dircache_build(global_settings.dircache_size); 151 dircache_build(global_status.dircache_size);
152 } 152 }
153 } 153 }
154 else 154 else
@@ -160,12 +160,12 @@ static int init_dircache(bool preinit)
160 if (!dircache_is_enabled() 160 if (!dircache_is_enabled()
161 && !dircache_is_initializing()) 161 && !dircache_is_initializing())
162 { 162 {
163 if (global_settings.dircache_size <= 0) 163 if (global_status.dircache_size <= 0)
164 { 164 {
165 gui_syncsplash(0, true, str(LANG_DIRCACHE_BUILDING)); 165 gui_syncsplash(0, true, str(LANG_DIRCACHE_BUILDING));
166 clear = true; 166 clear = true;
167 } 167 }
168 result = dircache_build(global_settings.dircache_size); 168 result = dircache_build(global_status.dircache_size);
169 } 169 }
170 170
171 if (result < 0) 171 if (result < 0)
@@ -176,8 +176,8 @@ static int init_dircache(bool preinit)
176 { 176 {
177 backlight_on(); 177 backlight_on();
178 show_logo(); 178 show_logo();
179 global_settings.dircache_size = dircache_get_cache_size(); 179 global_status.dircache_size = dircache_get_cache_size();
180 settings_save(); 180 status_save();
181 } 181 }
182 182
183 return result; 183 return result;
diff --git a/apps/playlist.c b/apps/playlist.c
index 2928db8a4f..56ffccc474 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -243,8 +243,8 @@ static void empty_playlist(struct playlist_info* playlist, bool resume)
243 create_control(playlist); 243 create_control(playlist);
244 244
245 /* Reset resume settings */ 245 /* Reset resume settings */
246 global_settings.resume_first_index = 0; 246 global_status.resume_first_index = 0;
247 global_settings.resume_seed = -1; 247 global_status.resume_seed = -1;
248 } 248 }
249} 249}
250 250
@@ -386,8 +386,8 @@ static int recreate_control(struct playlist_info* playlist)
386 386
387 if (playlist->current) 387 if (playlist->current)
388 { 388 {
389 global_settings.resume_seed = -1; 389 global_status.resume_seed = -1;
390 settings_save(); 390 status_save();
391 } 391 }
392 392
393 for (i=0; i<playlist->amount; i++) 393 for (i=0; i<playlist->amount; i++)
@@ -710,8 +710,8 @@ static int add_track_to_playlist(struct playlist_info* playlist,
710 710
711 if (seek_pos < 0 && playlist->current) 711 if (seek_pos < 0 && playlist->current)
712 { 712 {
713 global_settings.resume_first_index = playlist->first_index; 713 global_status.resume_first_index = playlist->first_index;
714 settings_save(); 714 status_save();
715 } 715 }
716 } 716 }
717 717
@@ -826,8 +826,8 @@ static int remove_track_from_playlist(struct playlist_info* playlist,
826 826
827 if (write) 827 if (write)
828 { 828 {
829 global_settings.resume_first_index = playlist->first_index; 829 global_status.resume_first_index = playlist->first_index;
830 settings_save(); 830 status_save();
831 } 831 }
832 } 832 }
833 833
@@ -902,8 +902,8 @@ static int randomise_playlist(struct playlist_info* playlist,
902 { 902 {
903 update_control(playlist, PLAYLIST_COMMAND_SHUFFLE, seed, 903 update_control(playlist, PLAYLIST_COMMAND_SHUFFLE, seed,
904 playlist->first_index, NULL, NULL, NULL); 904 playlist->first_index, NULL, NULL, NULL);
905 global_settings.resume_seed = seed; 905 global_status.resume_seed = seed;
906 settings_save(); 906 status_save();
907 } 907 }
908 908
909 return 0; 909 return 0;
@@ -942,8 +942,8 @@ static int sort_playlist(struct playlist_info* playlist, bool start_current,
942 { 942 {
943 update_control(playlist, PLAYLIST_COMMAND_UNSHUFFLE, 943 update_control(playlist, PLAYLIST_COMMAND_UNSHUFFLE,
944 playlist->first_index, -1, NULL, NULL, NULL); 944 playlist->first_index, -1, NULL, NULL, NULL);
945 global_settings.resume_seed = 0; 945 global_status.resume_seed = 0;
946 settings_save(); 946 status_save();
947 } 947 }
948 948
949 return 0; 949 return 0;
@@ -1117,8 +1117,8 @@ static void find_and_set_playlist_index(struct playlist_info* playlist,
1117 1117
1118 if (playlist->current) 1118 if (playlist->current)
1119 { 1119 {
1120 global_settings.resume_first_index = i; 1120 global_status.resume_first_index = i;
1121 settings_save(); 1121 status_save();
1122 } 1122 }
1123 1123
1124 break; 1124 break;
@@ -1742,10 +1742,10 @@ static int flush_cached_control(struct playlist_info* playlist)
1742 1742
1743 if (result > 0) 1743 if (result > 0)
1744 { 1744 {
1745 if (global_settings.resume_seed >= 0) 1745 if (global_status.resume_seed >= 0)
1746 { 1746 {
1747 global_settings.resume_seed = -1; 1747 global_status.resume_seed = -1;
1748 settings_save(); 1748 status_save();
1749 } 1749 }
1750 1750
1751 playlist->num_cached = 0; 1751 playlist->num_cached = 0;
@@ -2294,22 +2294,22 @@ int playlist_resume(void)
2294 /* Terminate on EOF */ 2294 /* Terminate on EOF */
2295 if(nread <= 0) 2295 if(nread <= 0)
2296 { 2296 {
2297 if (global_settings.resume_seed >= 0) 2297 if (global_status.resume_seed >= 0)
2298 { 2298 {
2299 /* Apply shuffle command saved in settings */ 2299 /* Apply shuffle command saved in settings */
2300 if (global_settings.resume_seed == 0) 2300 if (global_status.resume_seed == 0)
2301 sort_playlist(playlist, false, true); 2301 sort_playlist(playlist, false, true);
2302 else 2302 else
2303 { 2303 {
2304 if (!sorted) 2304 if (!sorted)
2305 sort_playlist(playlist, false, false); 2305 sort_playlist(playlist, false, false);
2306 2306
2307 randomise_playlist(playlist, global_settings.resume_seed, 2307 randomise_playlist(playlist, global_status.resume_seed,
2308 false, true); 2308 false, true);
2309 } 2309 }
2310 } 2310 }
2311 2311
2312 playlist->first_index = global_settings.resume_first_index; 2312 playlist->first_index = global_status.resume_first_index;
2313 break; 2313 break;
2314 } 2314 }
2315 } 2315 }
@@ -2361,7 +2361,7 @@ int playlist_shuffle(int random_seed, int start_index)
2361 { 2361 {
2362 /* store the seek position before the shuffle */ 2362 /* store the seek position before the shuffle */
2363 seek_pos = playlist->indices[start_index]; 2363 seek_pos = playlist->indices[start_index];
2364 playlist->index = global_settings.resume_first_index = 2364 playlist->index = global_status.resume_first_index =
2365 playlist->first_index = start_index; 2365 playlist->first_index = start_index;
2366 start_current = true; 2366 start_current = true;
2367 } 2367 }
@@ -2508,7 +2508,7 @@ int playlist_next(int steps)
2508 playlist->amount > 1) 2508 playlist->amount > 1)
2509 { 2509 {
2510 /* Repeat shuffle mode. Re-shuffle playlist and resume play */ 2510 /* Repeat shuffle mode. Re-shuffle playlist and resume play */
2511 playlist->first_index = global_settings.resume_first_index = 0; 2511 playlist->first_index = global_status.resume_first_index = 0;
2512 sort_playlist(playlist, false, false); 2512 sort_playlist(playlist, false, false);
2513 randomise_playlist(playlist, current_tick, false, true); 2513 randomise_playlist(playlist, current_tick, false, true);
2514#if CONFIG_CODEC != SWCODEC 2514#if CONFIG_CODEC != SWCODEC
@@ -2651,19 +2651,19 @@ int playlist_update_resume_info(const struct mp3entry* id3)
2651 2651
2652 if (id3) 2652 if (id3)
2653 { 2653 {
2654 if (global_settings.resume_index != playlist->index || 2654 if (global_status.resume_index != playlist->index ||
2655 global_settings.resume_offset != id3->offset) 2655 global_status.resume_offset != id3->offset)
2656 { 2656 {
2657 global_settings.resume_index = playlist->index; 2657 global_status.resume_index = playlist->index;
2658 global_settings.resume_offset = id3->offset; 2658 global_status.resume_offset = id3->offset;
2659 settings_save(); 2659 status_save();
2660 } 2660 }
2661 } 2661 }
2662 else 2662 else
2663 { 2663 {
2664 global_settings.resume_index = -1; 2664 global_status.resume_index = -1;
2665 global_settings.resume_offset = -1; 2665 global_status.resume_offset = -1;
2666 settings_save(); 2666 status_save();
2667 } 2667 }
2668 2668
2669 return 0; 2669 return 0;
diff --git a/apps/plugin.h b/apps/plugin.h
index 64cc208aae..70b5ebf354 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -110,12 +110,12 @@
110#define PLUGIN_MAGIC 0x526F634B /* RocK */ 110#define PLUGIN_MAGIC 0x526F634B /* RocK */
111 111
112/* increase this every time the api struct changes */ 112/* increase this every time the api struct changes */
113#define PLUGIN_API_VERSION 40 113#define PLUGIN_API_VERSION 41
114 114
115/* update this to latest version if a change to the api struct breaks 115/* update this to latest version if a change to the api struct breaks
116 backwards compatibility (and please take the opportunity to sort in any 116 backwards compatibility (and please take the opportunity to sort in any
117 new function which are "waiting" at the end of the function table) */ 117 new function which are "waiting" at the end of the function table) */
118#define PLUGIN_MIN_API_VERSION 38 118#define PLUGIN_MIN_API_VERSION 41
119 119
120/* plugin return codes */ 120/* plugin return codes */
121enum plugin_status { 121enum plugin_status {
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c
index 2fba14f7e2..45ddd3e0ad 100644
--- a/apps/recorder/radio.c
+++ b/apps/recorder/radio.c
@@ -212,7 +212,7 @@ void radio_start(void)
212 if(radio_status == FMRADIO_OFF) 212 if(radio_status == FMRADIO_OFF)
213 radio_power(true); 213 radio_power(true);
214 214
215 curr_freq = global_settings.last_frequency 215 curr_freq = global_status.last_frequency
216 * fm_region[global_settings.fm_region].freq_step 216 * fm_region[global_settings.fm_region].freq_step
217 + fm_region[global_settings.fm_region].freq_min; 217 + fm_region[global_settings.fm_region].freq_min;
218 218
@@ -332,10 +332,10 @@ static int find_closest_preset(int freq)
332 332
333static void remember_frequency(void) 333static void remember_frequency(void)
334{ 334{
335 global_settings.last_frequency = (curr_freq 335 global_status.last_frequency = (curr_freq
336 - fm_region[global_settings.fm_region].freq_min) 336 - fm_region[global_settings.fm_region].freq_min)
337 / fm_region[global_settings.fm_region].freq_step; 337 / fm_region[global_settings.fm_region].freq_step;
338 settings_save(); 338 status_save();
339} 339}
340 340
341static void next_preset(int direction) 341static void next_preset(int direction)
diff --git a/apps/screens.c b/apps/screens.c
index ab4c5dab60..4cf56b8192 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -1337,21 +1337,21 @@ bool view_runtime(void)
1337#endif 1337#endif
1338 ) 1338 )
1339 { 1339 {
1340 global_settings.runtime = 0; 1340 global_status.runtime = 0;
1341 } 1341 }
1342 else 1342 else
1343#endif 1343#endif
1344 { 1344 {
1345 global_settings.runtime += ((current_tick - lasttime) / HZ); 1345 global_status.runtime += ((current_tick - lasttime) / HZ);
1346 } 1346 }
1347 lasttime = current_tick; 1347 lasttime = current_tick;
1348 1348
1349 t = global_settings.runtime; 1349 t = global_status.runtime;
1350 FOR_NB_SCREENS(i) 1350 FOR_NB_SCREENS(i)
1351 screens[i].puts(0, y[i]++, str(LANG_CURRENT_TIME)); 1351 screens[i].puts(0, y[i]++, str(LANG_CURRENT_TIME));
1352 } 1352 }
1353 else { 1353 else {
1354 t = global_settings.topruntime; 1354 t = global_status.topruntime;
1355 FOR_NB_SCREENS(i) 1355 FOR_NB_SCREENS(i)
1356 screens[i].puts(0, y[i]++, str(LANG_TOP_TIME)); 1356 screens[i].puts(0, y[i]++, str(LANG_TOP_TIME));
1357 } 1357 }
@@ -1382,9 +1382,9 @@ bool view_runtime(void)
1382 if(gui_syncyesno_run(&message, NULL, NULL)==YESNO_YES) 1382 if(gui_syncyesno_run(&message, NULL, NULL)==YESNO_YES)
1383 { 1383 {
1384 if ( state == 1 ) 1384 if ( state == 1 )
1385 global_settings.runtime = 0; 1385 global_status.runtime = 0;
1386 else 1386 else
1387 global_settings.topruntime = 0; 1387 global_status.topruntime = 0;
1388 } 1388 }
1389 break; 1389 break;
1390 default: 1390 default:
diff --git a/apps/settings.c b/apps/settings.c
index 1a7d159666..4280ff9f7a 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -86,6 +86,7 @@
86void dac_line_in(bool enable); 86void dac_line_in(bool enable);
87#endif 87#endif
88struct user_settings global_settings; 88struct user_settings global_settings;
89struct system_status global_status;
89#ifdef HAVE_RECORDING 90#ifdef HAVE_RECORDING
90const char rec_base_directory[] = REC_BASE_DIR; 91const char rec_base_directory[] = REC_BASE_DIR;
91#endif 92#endif
@@ -346,6 +347,12 @@ bool settings_write_config(char* filename)
346 close(fd); 347 close(fd);
347 return true; 348 return true;
348} 349}
350#ifndef HAVE_RTC_RAM
351static bool flush_global_status_callback(void)
352{
353 return write_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE);
354}
355#endif
349static bool flush_config_block_callback(void) 356static bool flush_config_block_callback(void)
350{ 357{
351 bool r1, r2; 358 bool r1, r2;
@@ -357,16 +364,33 @@ static bool flush_config_block_callback(void)
357/* 364/*
358 * persist all runtime user settings to disk or RTC RAM 365 * persist all runtime user settings to disk or RTC RAM
359 */ 366 */
360int settings_save( void ) 367static void update_runtime(void)
361{ 368{
362 int elapsed_secs; 369 int elapsed_secs;
363 370
364 elapsed_secs = (current_tick - lasttime) / HZ; 371 elapsed_secs = (current_tick - lasttime) / HZ;
365 global_settings.runtime += elapsed_secs; 372 global_status.runtime += elapsed_secs;
366 lasttime += (elapsed_secs * HZ); 373 lasttime += (elapsed_secs * HZ);
367 374
368 if ( global_settings.runtime > global_settings.topruntime ) 375 if ( global_status.runtime > global_status.topruntime )
369 global_settings.topruntime = global_settings.runtime; 376 global_status.topruntime = global_status.runtime;
377}
378
379void status_save( void )
380{
381 update_runtime();
382#ifdef HAVE_RTC_RAM
383 /* this will be done in the ata_callback if
384 target doesnt have rtc ram */
385 write_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE);
386#else
387 register_ata_idle_func(flush_global_status_callback);
388#endif
389}
390
391int settings_save( void )
392{
393 update_runtime();
370#ifdef HAVE_RTC_RAM 394#ifdef HAVE_RTC_RAM
371 /* this will be done in the ata_callback if 395 /* this will be done in the ata_callback if
372 target doesnt have rtc ram */ 396 target doesnt have rtc ram */
diff --git a/apps/settings.h b/apps/settings.h
index 3ff3fe6244..8a495a0fee 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -128,7 +128,23 @@ extern unsigned char vp_dummy[VIRT_SIZE];
128#if !defined(HAVE_LCD_COLOR) 128#if !defined(HAVE_LCD_COLOR)
129#define HAVE_LCD_CONTRAST 129#define HAVE_LCD_CONTRAST
130#endif 130#endif
131 131struct system_status
132{
133 int resume_index; /* index in playlist (-1 for no active resume) */
134 int resume_first_index; /* index of first track in playlist */
135 uint32_t resume_offset; /* byte offset in mp3 file */
136 int resume_seed; /* shuffle seed (-1=no resume shuffle 0=sorted
137 >0=shuffled) */
138 int runtime; /* current runtime since last charge */
139 int topruntime; /* top known runtime */
140#ifdef HAVE_DIRCACHE
141 int dircache_size; /* directory cache structure last size, 22 bits */
142#endif
143#ifdef CONFIG_TUNER
144 int last_frequency; /* Last frequency for resuming, in FREQ_STEP units,
145 relative to MIN_FREQ */
146#endif
147};
132struct user_settings 148struct user_settings
133{ 149{
134 /* audio settings */ 150 /* audio settings */
@@ -254,11 +270,6 @@ struct user_settings
254 /* resume settings */ 270 /* resume settings */
255 271
256 bool resume; /* resume option: 0=off, 1=on */ 272 bool resume; /* resume option: 0=off, 1=on */
257 int resume_index; /* index in playlist (-1 for no active resume) */
258 int resume_first_index; /* index of first track in playlist */
259 uint32_t resume_offset; /* byte offset in mp3 file */
260 int resume_seed; /* shuffle seed (-1=no resume shuffle 0=sorted
261 >0=shuffled) */
262 273
263#ifdef CONFIG_TUNER 274#ifdef CONFIG_TUNER
264 unsigned char fmr_file[MAX_FILENAME+1]; /* last fmr preset */ 275 unsigned char fmr_file[MAX_FILENAME+1]; /* last fmr preset */
@@ -304,8 +315,6 @@ struct user_settings
304 bool browse_current; /* 1=goto current song, 315 bool browse_current; /* 1=goto current song,
305 0=goto previous location */ 316 0=goto previous location */
306 317
307 int runtime; /* current runtime since last charge */
308 int topruntime; /* top known runtime */
309 318
310 int scroll_speed; /* long texts scrolling speed: 1-30 */ 319 int scroll_speed; /* long texts scrolling speed: 1-30 */
311 int bidir_limit; /* bidir scroll length limit */ 320 int bidir_limit; /* bidir scroll length limit */
@@ -339,8 +348,6 @@ struct user_settings
339 bool fm_force_mono; /* Forces Mono mode if true */ 348 bool fm_force_mono; /* Forces Mono mode if true */
340 bool fm_full_range; /* Enables full 10MHz-160MHz range if true, else 349 bool fm_full_range; /* Enables full 10MHz-160MHz range if true, else
341 only 88MHz-108MHz */ 350 only 88MHz-108MHz */
342 int last_frequency; /* Last frequency for resuming, in FREQ_STEP units,
343 relative to MIN_FREQ */
344#endif 351#endif
345 352
346 int max_files_in_dir; /* Max entries in directory (file browser) */ 353 int max_files_in_dir; /* Max entries in directory (file browser) */
@@ -406,7 +413,6 @@ struct user_settings
406#endif 413#endif
407#ifdef HAVE_DIRCACHE 414#ifdef HAVE_DIRCACHE
408 bool dircache; /* enable directory cache */ 415 bool dircache; /* enable directory cache */
409 int dircache_size; /* directory cache structure last size, 22 bits */
410#endif 416#endif
411#ifdef HAVE_TAGCACHE 417#ifdef HAVE_TAGCACHE
412#ifdef HAVE_TC_RAMCACHE 418#ifdef HAVE_TC_RAMCACHE
@@ -548,7 +554,7 @@ struct opt_items {
548}; 554};
549 555
550/* prototypes */ 556/* prototypes */
551 557void status_save( void );
552int settings_save(void); 558int settings_save(void);
553void settings_load(int which); 559void settings_load(int which);
554void settings_reset(void); 560void settings_reset(void);
@@ -581,6 +587,8 @@ void settings_apply_trigger(void);
581 587
582/* global settings */ 588/* global settings */
583extern struct user_settings global_settings; 589extern struct user_settings global_settings;
590/* global status */
591extern struct system_status global_status;
584/* name of directory where configuration, fonts and other data 592/* name of directory where configuration, fonts and other data
585 * files are stored */ 593 * files are stored */
586extern long lasttime; 594extern long lasttime;
diff --git a/apps/settings_list.c b/apps/settings_list.c
index bffee257d1..861c3df6ff 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -104,7 +104,7 @@ static const char backlight_times_conf [] =
104 {{cb,LANG_SET_BOOL_YES,LANG_SET_BOOL_NO}}} } 104 {{cb,LANG_SET_BOOL_YES,LANG_SET_BOOL_NO}}} }
105 105
106#define SYSTEM_SETTING(flags,var,default) \ 106#define SYSTEM_SETTING(flags,var,default) \
107 {flags|F_T_INT, GS(var), INT(default), NULL, NULL, UNUSED} 107 {flags|F_T_INT, &global_status.var, INT(default), NULL, NULL, UNUSED}
108 108
109#define FILENAME_SETTING(flags,var,name,default,prefix,suffix,len) \ 109#define FILENAME_SETTING(flags,var,name,default,prefix,suffix,len) \
110 {flags|F_T_UCHARPTR, GS(var), CHARPTR(default),name,NULL,\ 110 {flags|F_T_UCHARPTR, GS(var), CHARPTR(default),name,NULL,\
@@ -179,7 +179,7 @@ const struct settings_list settings[] = {
179 {F_T_INT,GS(battery_capacity),INT(BATTERY_CAPACITY_DEFAULT), 179 {F_T_INT,GS(battery_capacity),INT(BATTERY_CAPACITY_DEFAULT),
180 "battery capacity",NULL,UNUSED}, 180 "battery capacity",NULL,UNUSED},
181#ifdef CONFIG_CHARGING 181#ifdef CONFIG_CHARGING
182 OFFON_SETTING(0,car_adapter_mode,false,"car adapter mode", NULL), 182 OFFON_SETTING(NVRAM(1),car_adapter_mode,false,"car adapter mode", NULL),
183#endif 183#endif
184 /* tuner */ 184 /* tuner */
185#ifdef CONFIG_TUNER 185#ifdef CONFIG_TUNER
diff --git a/apps/settings_list.h b/apps/settings_list.h
index 01e8cea1e7..d76d10aea1 100644
--- a/apps/settings_list.h
+++ b/apps/settings_list.h
@@ -61,7 +61,7 @@ struct int_setting {
61}; 61};
62#define F_NVRAM_BYTES_MASK 0xE00 /*0-4 bytes can be stored */ 62#define F_NVRAM_BYTES_MASK 0xE00 /*0-4 bytes can be stored */
63#define F_NVRAM_MASK_SHIFT 9 63#define F_NVRAM_MASK_SHIFT 9
64#define NVRAM_CONFIG_VERSION 1 64#define NVRAM_CONFIG_VERSION 2
65/* Above define should be bumped if 65/* Above define should be bumped if
66- a new NVRAM setting is added between 2 other NVRAM settings 66- a new NVRAM setting is added between 2 other NVRAM settings
67- number of bytes for a NVRAM setting is changed 67- number of bytes for a NVRAM setting is changed
diff --git a/apps/tree.c b/apps/tree.c
index e9ac6b5aa7..edd238a3b0 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -474,10 +474,10 @@ void reload_directory(void)
474static void start_resume(bool just_powered_on) 474static void start_resume(bool just_powered_on)
475{ 475{
476 bool do_resume = false; 476 bool do_resume = false;
477 if ( global_settings.resume_index != -1 ) { 477 if ( global_status.resume_index != -1 ) {
478 DEBUGF("Resume index %X offset %X\n", 478 DEBUGF("Resume index %X offset %X\n",
479 global_settings.resume_index, 479 global_status.resume_index,
480 global_settings.resume_offset); 480 global_status.resume_offset);
481 481
482#ifdef HAVE_ALARM_MOD 482#ifdef HAVE_ALARM_MOD
483 if ( rtc_check_alarm_started(true) ) { 483 if ( rtc_check_alarm_started(true) ) {
@@ -507,8 +507,8 @@ static void start_resume(bool just_powered_on)
507 507
508 if (playlist_resume() != -1) 508 if (playlist_resume() != -1)
509 { 509 {
510 playlist_start(global_settings.resume_index, 510 playlist_start(global_status.resume_index,
511 global_settings.resume_offset); 511 global_status.resume_offset);
512 512
513 start_wps = true; 513 start_wps = true;
514 } 514 }
@@ -1439,10 +1439,10 @@ void tree_flush(void)
1439 1439
1440#ifdef HAVE_DIRCACHE 1440#ifdef HAVE_DIRCACHE
1441 { 1441 {
1442 int old_val = global_settings.dircache_size; 1442 int old_val = global_status.dircache_size;
1443 if (global_settings.dircache) 1443 if (global_settings.dircache)
1444 { 1444 {
1445 global_settings.dircache_size = dircache_get_cache_size(); 1445 global_status.dircache_size = dircache_get_cache_size();
1446# ifdef HAVE_EEPROM_SETTINGS 1446# ifdef HAVE_EEPROM_SETTINGS
1447 dircache_save(); 1447 dircache_save();
1448# endif 1448# endif
@@ -1450,10 +1450,10 @@ void tree_flush(void)
1450 } 1450 }
1451 else 1451 else
1452 { 1452 {
1453 global_settings.dircache_size = 0; 1453 global_status.dircache_size = 0;
1454 } 1454 }
1455 if (old_val != global_settings.dircache_size) 1455 if (old_val != global_status.dircache_size)
1456 settings_save(); 1456 status_save();
1457 } 1457 }
1458#endif 1458#endif
1459} 1459}
@@ -1484,7 +1484,7 @@ void tree_restore(void)
1484 gui_textarea_update(&screens[i]); 1484 gui_textarea_update(&screens[i]);
1485 } 1485 }
1486 1486
1487 dircache_build(global_settings.dircache_size); 1487 dircache_build(global_status.dircache_size);
1488 1488
1489 /* Clean the text when we are done. */ 1489 /* Clean the text when we are done. */
1490 FOR_NB_SCREENS(i) 1490 FOR_NB_SCREENS(i)