summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Bavin <pondlife@pondlife.me>2006-10-05 10:07:03 +0000
committerSteve Bavin <pondlife@pondlife.me>2006-10-05 10:07:03 +0000
commitd49c810ec9c6010bf41e0ef7ebad101a79373438 (patch)
tree26755e1026276ed7f88071a7739497f93dd3ef6a
parent3eb9e70b6467becb2aa88cc8d24a82a7c288f1fd (diff)
downloadrockbox-d49c810ec9c6010bf41e0ef7ebad101a79373438.tar.gz
rockbox-d49c810ec9c6010bf41e0ef7ebad101a79373438.zip
Add CPU boost tracker to see where boosts are coming from
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11125 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/debug_menu.c16
-rw-r--r--apps/main.c4
-rw-r--r--apps/pcmbuf.c2
-rw-r--r--apps/playback.c10
-rw-r--r--apps/playlist.c12
-rw-r--r--apps/tagcache.c14
-rw-r--r--apps/tagtree.c16
-rw-r--r--apps/talk.c4
-rw-r--r--apps/tree.c8
-rw-r--r--firmware/backlight.c6
-rw-r--r--firmware/common/dircache.c6
-rw-r--r--firmware/export/system.h30
-rw-r--r--firmware/pcm_record.c4
-rw-r--r--firmware/system.c48
14 files changed, 125 insertions, 55 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 70fc3ac46e..fa650739f5 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -1258,7 +1258,6 @@ bool dbg_ports(void)
1258#endif /* !SIMULATOR */ 1258#endif /* !SIMULATOR */
1259 1259
1260#ifdef HAVE_ADJUSTABLE_CPU_FREQ 1260#ifdef HAVE_ADJUSTABLE_CPU_FREQ
1261extern int boost_counter;
1262bool dbg_cpufreq(void) 1261bool dbg_cpufreq(void)
1263{ 1262{
1264 char buf[128]; 1263 char buf[128];
@@ -1278,7 +1277,11 @@ bool dbg_cpufreq(void)
1278 snprintf(buf, sizeof(buf), "Frequency: %ld", FREQ); 1277 snprintf(buf, sizeof(buf), "Frequency: %ld", FREQ);
1279 lcd_puts(0, line++, buf); 1278 lcd_puts(0, line++, buf);
1280 1279
1281 snprintf(buf, sizeof(buf), "boost_counter: %d", boost_counter); 1280#ifdef CPU_BOOST_TRACKING
1281 snprintf(buf, sizeof(buf), "boost_counter: %d %s", get_cpu_boost_counter(), get_cpu_boost_tracker());
1282#else
1283 snprintf(buf, sizeof(buf), "boost_counter: %d", get_cpu_boost_counter());
1284#endif
1282 lcd_puts(0, line++, buf); 1285 lcd_puts(0, line++, buf);
1283 1286
1284 lcd_update(); 1287 lcd_update();
@@ -1287,15 +1290,16 @@ bool dbg_cpufreq(void)
1287 switch(button) 1290 switch(button)
1288 { 1291 {
1289 case ACTION_STD_PREV: 1292 case ACTION_STD_PREV:
1290 cpu_boost(true); 1293 cpu_boost_id(true, CPUBOOSTID_DEBUGMENU_MANUAL);
1291 break; 1294 break;
1295
1292 case ACTION_STD_NEXT: 1296 case ACTION_STD_NEXT:
1293 cpu_boost(false); 1297 cpu_boost_id(false, CPUBOOSTID_DEBUGMENU_MANUAL);
1294 break; 1298 break;
1295 1299
1296 case ACTION_STD_OK: 1300 case ACTION_STD_OK:
1297 set_cpu_frequency(CPUFREQ_DEFAULT); 1301 while (get_cpu_boost_counter() > 0)
1298 boost_counter = 0; 1302 cpu_boost_id(false, CPUBOOSTID_DEBUGMENU_MANUAL);
1299 break; 1303 break;
1300 1304
1301 case ACTION_STD_CANCEL: 1305 case ACTION_STD_CANCEL:
diff --git a/apps/main.c b/apps/main.c
index a2bbe73e65..bd1dd7b03c 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -276,7 +276,7 @@ void init(void)
276 276
277#ifdef HAVE_ADJUSTABLE_CPU_FREQ 277#ifdef HAVE_ADJUSTABLE_CPU_FREQ
278 set_cpu_frequency(CPUFREQ_NORMAL); 278 set_cpu_frequency(CPUFREQ_NORMAL);
279 cpu_boost(true); 279 cpu_boost_id(true, CPUBOOSTID_MAININIT);
280#endif 280#endif
281 281
282 buffer_init(); 282 buffer_init();
@@ -482,7 +482,7 @@ void init(void)
482#endif 482#endif
483 483
484 /* runtime database has to be initialized after audio_init() */ 484 /* runtime database has to be initialized after audio_init() */
485 cpu_boost(false); 485 cpu_boost_id(false, CPUBOOSTID_MAININIT);
486 486
487#ifdef AUTOROCK 487#ifdef AUTOROCK
488 { 488 {
diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c
index b4d9bcec4e..6d2f68a238 100644
--- a/apps/pcmbuf.c
+++ b/apps/pcmbuf.c
@@ -121,7 +121,7 @@ void pcmbuf_boost(bool state)
121 121
122 if (state != boost_state) 122 if (state != boost_state)
123 { 123 {
124 cpu_boost(state); 124 cpu_boost_id(state, CPUBOOSTID_PCMBUF);
125 boost_state = state; 125 boost_state = state;
126 } 126 }
127 127
diff --git a/apps/playback.c b/apps/playback.c
index 76f0788583..cb4900e1ae 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -822,7 +822,7 @@ static void voice_boost_cpu(bool state)
822 if (state != voice_cpu_boosted) 822 if (state != voice_cpu_boosted)
823 { 823 {
824 voice_cpu_boosted = state; 824 voice_cpu_boosted = state;
825 cpu_boost(state); 825 cpu_boost_id(state, CPUBOOSTID_PLAYBACK_VOICE);
826 } 826 }
827} 827}
828#endif 828#endif
@@ -1676,7 +1676,7 @@ static bool codec_load_next_track(void)
1676 automatic_skip = true; 1676 automatic_skip = true;
1677 } 1677 }
1678 1678
1679 cpu_boost(true); 1679 cpu_boost_id(true, CPUBOOSTID_PLAYBACK_CODEC);
1680 LOGFQUEUE("codec > audio Q_AUDIO_CHECK_NEW_TRACK"); 1680 LOGFQUEUE("codec > audio Q_AUDIO_CHECK_NEW_TRACK");
1681 queue_post(&audio_queue, Q_AUDIO_CHECK_NEW_TRACK, 0); 1681 queue_post(&audio_queue, Q_AUDIO_CHECK_NEW_TRACK, 0);
1682 while (1) 1682 while (1)
@@ -1690,7 +1690,7 @@ static bool codec_load_next_track(void)
1690 else 1690 else
1691 break; 1691 break;
1692 } 1692 }
1693 cpu_boost(false); 1693 cpu_boost_id(false, CPUBOOSTID_PLAYBACK_CODEC);
1694 switch (ev.id) 1694 switch (ev.id)
1695 { 1695 {
1696 case Q_CODEC_REQUEST_COMPLETE: 1696 case Q_CODEC_REQUEST_COMPLETE:
@@ -2177,7 +2177,7 @@ static void audio_read_file(bool quick)
2177 return ; 2177 return ;
2178 } 2178 }
2179 2179
2180 cpu_boost(true); 2180 cpu_boost_id(true, CPUBOOSTID_PLAYBACK_AUDIO);
2181 while (tracks[track_widx].filerem > 0) 2181 while (tracks[track_widx].filerem > 0)
2182 { 2182 {
2183 int overlap; 2183 int overlap;
@@ -2245,7 +2245,7 @@ static void audio_read_file(bool quick)
2245 logf("Partially buf:%dB", 2245 logf("Partially buf:%dB",
2246 tracks[track_widx].filesize - tracks[track_widx].filerem); 2246 tracks[track_widx].filesize - tracks[track_widx].filerem);
2247 } 2247 }
2248 cpu_boost(false); 2248 cpu_boost_id(false, CPUBOOSTID_PLAYBACK_AUDIO);
2249} 2249}
2250 2250
2251static bool audio_loadcodec(bool start_play) 2251static bool audio_loadcodec(bool start_play)
diff --git a/apps/playlist.c b/apps/playlist.c
index 6648d4462e..9d844e3b84 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -2812,14 +2812,14 @@ int playlist_insert_directory(struct playlist_info* playlist,
2812 context.queue = queue; 2812 context.queue = queue;
2813 context.count = 0; 2813 context.count = 0;
2814 2814
2815 cpu_boost(true); 2815 cpu_boost_id(true, CPUBOOSTID_PLAYLIST);
2816 2816
2817 result = playlist_directory_tracksearch(dirname, recurse, 2817 result = playlist_directory_tracksearch(dirname, recurse,
2818 directory_search_callback, &context); 2818 directory_search_callback, &context);
2819 2819
2820 sync_control(playlist, false); 2820 sync_control(playlist, false);
2821 2821
2822 cpu_boost(false); 2822 cpu_boost_id(false, CPUBOOSTID_PLAYLIST);
2823 2823
2824 display_playlist_count(context.count, count_str); 2824 display_playlist_count(context.count, count_str);
2825 2825
@@ -2881,7 +2881,7 @@ int playlist_insert_playlist(struct playlist_info* playlist, char *filename,
2881 2881
2882 display_playlist_count(count, count_str); 2882 display_playlist_count(count, count_str);
2883 2883
2884 cpu_boost(true); 2884 cpu_boost_id(true, CPUBOOSTID_PLAYLIST);
2885 2885
2886 while ((max = read_line(fd, temp_buf, sizeof(temp_buf))) > 0) 2886 while ((max = read_line(fd, temp_buf, sizeof(temp_buf))) > 0)
2887 { 2887 {
@@ -2940,7 +2940,7 @@ int playlist_insert_playlist(struct playlist_info* playlist, char *filename,
2940 2940
2941 sync_control(playlist, false); 2941 sync_control(playlist, false);
2942 2942
2943 cpu_boost(false); 2943 cpu_boost_id(false, CPUBOOSTID_PLAYLIST);
2944 2944
2945 display_playlist_count(count, count_str); 2945 display_playlist_count(count, count_str);
2946 2946
@@ -3287,7 +3287,7 @@ int playlist_save(struct playlist_info* playlist, char *filename)
3287 3287
3288 display_playlist_count(count, str(LANG_PLAYLIST_SAVE_COUNT)); 3288 display_playlist_count(count, str(LANG_PLAYLIST_SAVE_COUNT));
3289 3289
3290 cpu_boost(true); 3290 cpu_boost_id(true, CPUBOOSTID_PLAYLIST);
3291 3291
3292 index = playlist->first_index; 3292 index = playlist->first_index;
3293 for (i=0; i<playlist->amount; i++) 3293 for (i=0; i<playlist->amount; i++)
@@ -3380,7 +3380,7 @@ int playlist_save(struct playlist_info* playlist, char *filename)
3380 3380
3381 } 3381 }
3382 3382
3383 cpu_boost(false); 3383 cpu_boost_id(false, CPUBOOSTID_PLAYLIST);
3384 3384
3385 return result; 3385 return result;
3386} 3386}
diff --git a/apps/tagcache.c b/apps/tagcache.c
index 70934b4f36..1c180b7f43 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -3459,7 +3459,7 @@ static void build_tagcache(void)
3459 3459
3460 filenametag_fd = open_tag_fd(&header, tag_filename, false); 3460 filenametag_fd = open_tag_fd(&header, tag_filename, false);
3461 3461
3462 cpu_boost(true); 3462 cpu_boost_id(true, CPUBOOSTID_TAGCACHE);
3463 3463
3464 /* Scan for new files. */ 3464 /* Scan for new files. */
3465 memset(&header, 0, sizeof(struct tagcache_header)); 3465 memset(&header, 0, sizeof(struct tagcache_header));
@@ -3485,7 +3485,7 @@ static void build_tagcache(void)
3485 if (!ret) 3485 if (!ret)
3486 { 3486 {
3487 logf("Aborted."); 3487 logf("Aborted.");
3488 cpu_boost(false); 3488 cpu_boost_id(false, CPUBOOSTID_TAGCACHE);
3489 return ; 3489 return ;
3490 } 3490 }
3491 3491
@@ -3505,7 +3505,7 @@ static void build_tagcache(void)
3505 } 3505 }
3506#endif 3506#endif
3507 3507
3508 cpu_boost(false); 3508 cpu_boost_id(false, CPUBOOSTID_TAGCACHE);
3509} 3509}
3510 3510
3511#ifdef HAVE_TC_RAMCACHE 3511#ifdef HAVE_TC_RAMCACHE
@@ -3514,7 +3514,7 @@ static void load_ramcache(void)
3514 if (!hdr) 3514 if (!hdr)
3515 return ; 3515 return ;
3516 3516
3517 cpu_boost(true); 3517 cpu_boost_id(true, CPUBOOSTID_TAGCACHE);
3518 3518
3519 /* At first we should load the cache (if exists). */ 3519 /* At first we should load the cache (if exists). */
3520 stat.ramcache = load_tagcache(); 3520 stat.ramcache = load_tagcache();
@@ -3527,7 +3527,7 @@ static void load_ramcache(void)
3527 hdr = NULL; 3527 hdr = NULL;
3528 } 3528 }
3529 3529
3530 cpu_boost(false); 3530 cpu_boost_id(false, CPUBOOSTID_TAGCACHE);
3531} 3531}
3532 3532
3533void tagcache_unload_ramcache(void) 3533void tagcache_unload_ramcache(void)
@@ -3572,7 +3572,7 @@ static void tagcache_thread(void)
3572 3572
3573 /* If the previous cache build/update was interrupted, commit 3573 /* If the previous cache build/update was interrupted, commit
3574 * the changes first in foreground. */ 3574 * the changes first in foreground. */
3575 cpu_boost(true); 3575 cpu_boost_id(true, CPUBOOSTID_TAGCACHE);
3576 allocate_tempbuf(); 3576 allocate_tempbuf();
3577 commit(); 3577 commit();
3578 free_tempbuf(); 3578 free_tempbuf();
@@ -3590,7 +3590,7 @@ static void tagcache_thread(void)
3590 allocate_tagcache(); 3590 allocate_tagcache();
3591#endif 3591#endif
3592 3592
3593 cpu_boost(false); 3593 cpu_boost_id(false, CPUBOOSTID_TAGCACHE);
3594 stat.initialized = true; 3594 stat.initialized = true;
3595 3595
3596 /* Don't delay bootup with the header check but do it on background. */ 3596 /* Don't delay bootup with the header check but do it on background. */
diff --git a/apps/tagtree.c b/apps/tagtree.c
index 377cc27ec0..f9542821d8 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -1121,9 +1121,9 @@ int tagtree_load(struct tree_context* c)
1121 case allsubentries: 1121 case allsubentries:
1122 case navibrowse: 1122 case navibrowse:
1123 logf("navibrowse..."); 1123 logf("navibrowse...");
1124 cpu_boost(true); 1124 cpu_boost_id(true, CPUBOOSTID_TAGTREE);
1125 count = retrieve_entries(c, &tcs, 0, true); 1125 count = retrieve_entries(c, &tcs, 0, true);
1126 cpu_boost(false); 1126 cpu_boost_id(false, CPUBOOSTID_TAGTREE);
1127 break; 1127 break;
1128 1128
1129 default: 1129 default:
@@ -1297,11 +1297,11 @@ bool insert_all_playlist(struct tree_context *c, int position, bool queue)
1297 char buf[MAX_PATH]; 1297 char buf[MAX_PATH];
1298 int from, to, direction; 1298 int from, to, direction;
1299 1299
1300 cpu_boost(true); 1300 cpu_boost_id(true, CPUBOOSTID_TAGTREE);
1301 if (!tagcache_search(&tcs, tag_filename)) 1301 if (!tagcache_search(&tcs, tag_filename))
1302 { 1302 {
1303 gui_syncsplash(HZ, true, str(LANG_TAGCACHE_BUSY)); 1303 gui_syncsplash(HZ, true, str(LANG_TAGCACHE_BUSY));
1304 cpu_boost(false); 1304 cpu_boost_id(false, CPUBOOSTID_TAGTREE);
1305 return false; 1305 return false;
1306 } 1306 }
1307 1307
@@ -1338,7 +1338,7 @@ bool insert_all_playlist(struct tree_context *c, int position, bool queue)
1338 } 1338 }
1339 playlist_sync(NULL); 1339 playlist_sync(NULL);
1340 tagcache_search_finish(&tcs); 1340 tagcache_search_finish(&tcs);
1341 cpu_boost(false); 1341 cpu_boost_id(false, CPUBOOSTID_TAGTREE);
1342 1342
1343 return true; 1343 return true;
1344} 1344}
@@ -1442,16 +1442,16 @@ struct tagentry* tagtree_get_entry(struct tree_context *c, int id)
1442 /* Load the next chunk if necessary. */ 1442 /* Load the next chunk if necessary. */
1443 if (realid >= current_entry_count || realid < 0) 1443 if (realid >= current_entry_count || realid < 0)
1444 { 1444 {
1445 cpu_boost(true); 1445 cpu_boost_id(true, CPUBOOSTID_TAGTREE);
1446 if (retrieve_entries(c, &tcs2, MAX(0, id - (current_entry_count / 2)), 1446 if (retrieve_entries(c, &tcs2, MAX(0, id - (current_entry_count / 2)),
1447 false) < 0) 1447 false) < 0)
1448 { 1448 {
1449 logf("retrieve failed"); 1449 logf("retrieve failed");
1450 cpu_boost(false); 1450 cpu_boost_id(false, CPUBOOSTID_TAGTREE);
1451 return NULL; 1451 return NULL;
1452 } 1452 }
1453 realid = id - current_offset; 1453 realid = id - current_offset;
1454 cpu_boost(false); 1454 cpu_boost_id(false, CPUBOOSTID_TAGTREE);
1455 } 1455 }
1456 1456
1457 return &entry[realid]; 1457 return &entry[realid];
diff --git a/apps/talk.c b/apps/talk.c
index a92425d439..d03fead233 100644
--- a/apps/talk.c
+++ b/apps/talk.c
@@ -215,7 +215,7 @@ static void load_voicefile(void)
215 /* Do a bitswap as necessary. */ 215 /* Do a bitswap as necessary. */
216#if CONFIG_CODEC == SWCODEC 216#if CONFIG_CODEC == SWCODEC
217 logf("Bitswapping voice file."); 217 logf("Bitswapping voice file.");
218 cpu_boost(true); 218 cpu_boost_id(true, CPUBOOSTID_TALK);
219 buf = (unsigned char *)(&p_voicefile->index) + 219 buf = (unsigned char *)(&p_voicefile->index) +
220 (p_voicefile->id1_max + p_voicefile->id2_max) * sizeof(struct clip_entry); 220 (p_voicefile->id1_max + p_voicefile->id2_max) * sizeof(struct clip_entry);
221 length = file_size - (buf - (unsigned char *) p_voicefile); 221 length = file_size - (buf - (unsigned char *) p_voicefile);
@@ -227,7 +227,7 @@ static void load_voicefile(void)
227 temp = ((temp >> 2) & 0x33) | ((temp & 0x33) << 2); 227 temp = ((temp >> 2) & 0x33) | ((temp & 0x33) << 2);
228 buf[i] = ((temp >> 1) & 0x55) | ((temp & 0x55) << 1); 228 buf[i] = ((temp >> 1) & 0x55) | ((temp & 0x55) << 1);
229 } 229 }
230 cpu_boost(false); 230 cpu_boost_id(false, CPUBOOSTID_TALK);
231 231
232#endif 232#endif
233 233
diff --git a/apps/tree.c b/apps/tree.c
index b5673e681c..70b83f8934 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -1177,9 +1177,7 @@ bool create_playlist(void)
1177 if (fd < 0) 1177 if (fd < 0)
1178 return false; 1178 return false;
1179 1179
1180#ifdef HAVE_ADJUSTABLE_CPU_FREQ 1180 cpu_boost_id(true, CPUBOOSTID_TREE);
1181 cpu_boost(true);
1182#endif
1183 1181
1184 snprintf(filename, sizeof(filename), "%s", 1182 snprintf(filename, sizeof(filename), "%s",
1185 tc.currdir[1] ? tc.currdir : "/"); 1183 tc.currdir[1] ? tc.currdir : "/");
@@ -1187,9 +1185,7 @@ bool create_playlist(void)
1187 add_dir(filename, sizeof(filename), fd); 1185 add_dir(filename, sizeof(filename), fd);
1188 close(fd); 1186 close(fd);
1189 1187
1190#ifdef HAVE_ADJUSTABLE_CPU_FREQ 1188 cpu_boost_id(false, CPUBOOSTID_TREE);
1191 cpu_boost(false);
1192#endif
1193 1189
1194 sleep(HZ); 1190 sleep(HZ);
1195 1191
diff --git a/firmware/backlight.c b/firmware/backlight.c
index cbd15ee46b..5e1f5922cd 100644
--- a/firmware/backlight.c
+++ b/firmware/backlight.c
@@ -288,7 +288,7 @@ static void backlight_switch(void)
288static void backlight_release_timer(void) 288static void backlight_release_timer(void)
289{ 289{
290#ifdef CPU_COLDFIRE 290#ifdef CPU_COLDFIRE
291 cpu_boost(false); 291 cpu_boost_id(false, CPUBOOSTID_BACKLIGHT);
292#endif 292#endif
293 timer_unregister(); 293 timer_unregister();
294 bl_timer_active = false; 294 bl_timer_active = false;
@@ -310,7 +310,7 @@ static void backlight_dim(int value)
310 { 310 {
311#ifdef CPU_COLDFIRE 311#ifdef CPU_COLDFIRE
312 /* Prevent cpu frequency changes while dimming. */ 312 /* Prevent cpu frequency changes while dimming. */
313 cpu_boost(true); 313 cpu_boost_id(true, CPUBOOSTID_BACKLIGHT);
314#endif 314#endif
315 bl_timer_active = true; 315 bl_timer_active = true;
316 } 316 }
@@ -547,7 +547,7 @@ void backlight_thread(void)
547#if defined(HAVE_BACKLIGHT_PWM_FADING) && defined(CPU_COLDFIRE) \ 547#if defined(HAVE_BACKLIGHT_PWM_FADING) && defined(CPU_COLDFIRE) \
548 && !defined(SIMULATOR) 548 && !defined(SIMULATOR)
549 case BACKLIGHT_UNBOOST_CPU: 549 case BACKLIGHT_UNBOOST_CPU:
550 cpu_boost(false); 550 cpu_boost_id(false, CPUBOOSTID_BACKLIGHT);
551 break; 551 break;
552#endif 552#endif
553 553
diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c
index 0bdd0657bd..7222a41221 100644
--- a/firmware/common/dircache.c
+++ b/firmware/common/dircache.c
@@ -546,16 +546,16 @@ static int dircache_do_rebuild(void)
546 memset(dircache_cur_path, 0, MAX_PATH); 546 memset(dircache_cur_path, 0, MAX_PATH);
547 dircache_size = sizeof(struct dircache_entry); 547 dircache_size = sizeof(struct dircache_entry);
548 548
549 cpu_boost(true); 549 cpu_boost_id(true, CPUBOOSTID_DIRCACHE);
550 if (dircache_travel(pdir, dircache_root) < 0) 550 if (dircache_travel(pdir, dircache_root) < 0)
551 { 551 {
552 logf("dircache_travel failed"); 552 logf("dircache_travel failed");
553 cpu_boost(false); 553 cpu_boost_id(false, CPUBOOSTID_DIRCACHE);
554 dircache_size = 0; 554 dircache_size = 0;
555 dircache_initializing = false; 555 dircache_initializing = false;
556 return -2; 556 return -2;
557 } 557 }
558 cpu_boost(false); 558 cpu_boost_id(false, CPUBOOSTID_DIRCACHE);
559 559
560 logf("Done, %d KiB used", dircache_size / 1024); 560 logf("Done, %d KiB used", dircache_size / 1024);
561 561
diff --git a/firmware/export/system.h b/firmware/export/system.h
index d13b27c529..cc2d166c62 100644
--- a/firmware/export/system.h
+++ b/firmware/export/system.h
@@ -60,11 +60,41 @@ bool detect_flashed_rockbox(void);
60void set_cpu_frequency(long frequency); 60void set_cpu_frequency(long frequency);
61void cpu_boost(bool on_off); 61void cpu_boost(bool on_off);
62void cpu_idle_mode(bool on_off); 62void cpu_idle_mode(bool on_off);
63int get_cpu_boost_counter(void);
64
65#if MEM > 1
66#define CPU_BOOST_TRACKING
67#endif
68
69#ifdef CPU_BOOST_TRACKING
70void cpu_boost_id(bool on_off, char id);
71const char *get_cpu_boost_tracker(void);
72/* CPU boost ID chars, in alphabetical order */
73#define CPUBOOSTID_PLAYBACK_AUDIO 'A'
74#define CPUBOOSTID_TAGTREE 'a'
75#define CPUBOOSTID_BACKLIGHT 'b'
76#define CPUBOOSTID_PLAYBACK_CODEC 'c'
77#define CPUBOOSTID_DIRCACHE 'd'
78#define CPUBOOSTID_MAININIT 'i'
79#define CPUBOOSTID_DEBUGMENU_MANUAL 'm'
80#define CPUBOOSTID_PLAYLIST 'P'
81#define CPUBOOSTID_PCMRECORD 'R'
82#define CPUBOOSTID_TREE 'r'
83#define CPUBOOSTID_TREE 'r'
84#define CPUBOOSTID_TALK 'T'
85#define CPUBOOSTID_TAGCACHE 't'
86#define CPUBOOSTID_PLAYBACK_VOICE 'v'
87#else
88#define cpu_boost_id(on_off,id) cpu_boost(on_off)
89#endif
63#else 90#else
64#define FREQ CPU_FREQ 91#define FREQ CPU_FREQ
65#define set_cpu_frequency(frequency) 92#define set_cpu_frequency(frequency)
66#define cpu_boost(on_off) 93#define cpu_boost(on_off)
94#define cpu_boost_id(on_off, id)
67#define cpu_idle_mode(on_off) 95#define cpu_idle_mode(on_off)
96#define get_cpu_boost_counter()
97#define get_cpu_boost_tracker()
68#endif 98#endif
69 99
70#define BAUDRATE 9600 100#define BAUDRATE 9600
diff --git a/firmware/pcm_record.c b/firmware/pcm_record.c
index 544ecb378d..2785d4b1b1 100644
--- a/firmware/pcm_record.c
+++ b/firmware/pcm_record.c
@@ -541,7 +541,7 @@ static void pcmrec_callback(bool flush)
541 { 541 {
542 logf("writing: %d (%d)", num_ready, flush); 542 logf("writing: %d (%d)", num_ready, flush);
543 543
544 cpu_boost(true); 544 cpu_boost_id(true, CPUBOOSTID_PCMRECORD);
545 545
546 size_yield = 0; 546 size_yield = 0;
547 for (i=0; i<num_ready; i++) 547 for (i=0; i<num_ready; i++)
@@ -581,7 +581,7 @@ static void pcmrec_callback(bool flush)
581 /* sync file */ 581 /* sync file */
582 fsync(wav_file); 582 fsync(wav_file);
583 583
584 cpu_boost(false); 584 cpu_boost_id(false, CPUBOOSTID_PCMRECORD);
585 585
586 logf("done"); 586 logf("done");
587 } 587 }
diff --git a/firmware/system.c b/firmware/system.c
index 81c5a36917..9699fe8559 100644
--- a/firmware/system.c
+++ b/firmware/system.c
@@ -32,16 +32,38 @@ long cpu_frequency = CPU_FREQ;
32#endif 32#endif
33 33
34#ifdef HAVE_ADJUSTABLE_CPU_FREQ 34#ifdef HAVE_ADJUSTABLE_CPU_FREQ
35int boost_counter = 0; 35static int boost_counter = 0;
36bool cpu_idle = false; 36static bool cpu_idle = false;
37void cpu_boost(bool on_off) 37#ifdef CPU_BOOST_TRACKING
38#define CPU_BOOST_TRACKER_MAX 15
39static char cpu_boost_tracker[CPU_BOOST_TRACKER_MAX+1] = "";
40#endif
41
42int get_cpu_boost_counter(void)
43{
44 return boost_counter;
45}
46
47#ifdef CPU_BOOST_TRACKING
48const char *get_cpu_boost_tracker()
49{
50 return cpu_boost_tracker;
51}
52
53void cpu_boost_id(bool on_off, char id)
38{ 54{
39 if(on_off) 55 if(on_off)
40 { 56 {
41 /* Boost the frequency if not already boosted */ 57 /* Boost the frequency if not already boosted */
42 if(boost_counter++ == 0) 58 if(boost_counter++ == 0)
43 {
44 set_cpu_frequency(CPUFREQ_MAX); 59 set_cpu_frequency(CPUFREQ_MAX);
60
61 /* Add to the boost tracker for debugging */
62 int l = strlen(cpu_boost_tracker);
63 if (l < CPU_BOOST_TRACKER_MAX)
64 {
65 cpu_boost_tracker[l] = id;
66 cpu_boost_tracker[l+1] = '\0';
45 } 67 }
46 } 68 }
47 else 69 else
@@ -58,8 +80,26 @@ void cpu_boost(bool on_off)
58 /* Safety measure */ 80 /* Safety measure */
59 if(boost_counter < 0) 81 if(boost_counter < 0)
60 boost_counter = 0; 82 boost_counter = 0;
83
84 /* Remove an entry from the boost tracker */
85 int l = strlen(cpu_boost_tracker);
86 while (l >= 0 && cpu_boost_tracker[l] != id)
87 l--;
88 if (cpu_boost_tracker[l] != id) /* No match found? */
89 l = strlen(cpu_boost_tracker)-1; /* Just remove last one */
90 while (l < CPU_BOOST_TRACKER_MAX)
91 {
92 cpu_boost_tracker[l] = cpu_boost_tracker[l+1];
93 l++;
94 }
61 } 95 }
62} 96}
97#endif
98
99void cpu_boost(bool on_off)
100{
101 cpu_boost_id(on_off, '?');
102}
63 103
64void cpu_idle_mode(bool on_off) 104void cpu_idle_mode(bool on_off)
65{ 105{