1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Heikki Hannikainen
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
30 #include "debug_menu.h"
36 #include "powermgmt.h"
40 #include "mp3_playback.h"
43 #include "statusbar.h"
49 #include "shortcuts.h"
55 #ifdef HAVE_REMOTE_LCD
56 #include "lcd-remote.h"
60 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
67 #include "eeprom_24cxx.h"
68 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
71 #if (CONFIG_STORAGE & STORAGE_ATA)
81 #ifdef HAVE_LCD_BITMAP
82 #include "scrollbar.h"
83 #include "peakmeter.h"
86 #include "core_alloc.h"
87 #if CONFIG_CODEC == SWCODEC
89 #include "buffering.h"
91 #if defined(HAVE_SPDIF_OUT) || defined(HAVE_SPDIF_IN)
95 #ifdef IRIVER_H300_SERIES
96 #include "pcf50606.h" /* for pcf50606_read */
101 #include "hwcompat.h"
103 #if CONFIG_RTC == RTC_PCF50605
104 #include "pcf50605.h"
106 #include "appevents.h"
108 #if defined(HAVE_AS3514) && defined(CONFIG_CHARGING)
113 #include "pmu-target.h"
117 #include "usb_core.h"
120 #if defined(IPOD_ACCESSORY_PROTOCOL)
128 /*---------------------------------------------------*/
129 /* SPECIAL DEBUG STUFF */
130 /*---------------------------------------------------*/
131 extern struct thread_entry threads
[MAXTHREADS
];
133 static char thread_status_char(unsigned status
)
135 static const char thread_status_chars
[THREAD_NUM_STATES
+1] =
137 [0 ... THREAD_NUM_STATES
] = '?',
138 [STATE_RUNNING
] = 'R',
139 [STATE_BLOCKED
] = 'B',
140 [STATE_SLEEPING
] = 'S',
141 [STATE_BLOCKED_W_TMO
] = 'T',
142 [STATE_FROZEN
] = 'F',
143 [STATE_KILLED
] = 'K',
146 if (status
> THREAD_NUM_STATES
)
147 status
= THREAD_NUM_STATES
;
149 return thread_status_chars
[status
];
152 static const char* threads_getname(int selected_item
, void *data
,
153 char *buffer
, size_t buffer_len
)
156 struct thread_entry
*thread
;
160 if (selected_item
< (int)NUM_CORES
)
162 snprintf(buffer
, buffer_len
, "Idle (%d): %2d%%", selected_item
,
163 idle_stack_usage(selected_item
));
167 selected_item
-= NUM_CORES
;
170 thread
= &threads
[selected_item
];
172 if (thread
->state
== STATE_KILLED
)
174 snprintf(buffer
, buffer_len
, "%2d: ---", selected_item
);
178 thread_get_name(name
, 32, thread
);
180 snprintf(buffer
, buffer_len
,
181 "%2d: " IF_COP("(%d) ") "%c%c " IF_PRIO("%d %d ") "%2d%% %s",
183 IF_COP(thread
->core
,)
184 #ifdef HAVE_SCHEDULER_BOOSTCTRL
185 (thread
->cpu_boost
) ? '+' :
187 ((thread
->state
== STATE_RUNNING
) ? '*' : ' '),
188 thread_status_char(thread
->state
),
189 IF_PRIO(thread
->base_priority
, thread
->priority
, )
190 thread_stack_usage(thread
), name
);
195 static int dbg_threads_action_callback(int action
, struct gui_synclist
*lists
)
198 #ifdef ROCKBOX_HAS_LOGF
199 if (action
== ACTION_STD_OK
)
201 int selpos
= gui_synclist_get_sel_pos(lists
);
203 if (selpos
>= NUM_CORES
)
204 remove_thread(threads
[selpos
- NUM_CORES
].id
);
206 remove_thread(threads
[selpos
].id
);
208 return ACTION_REDRAW
;
210 #endif /* ROCKBOX_HAS_LOGF */
211 if (action
== ACTION_NONE
)
212 action
= ACTION_REDRAW
;
216 static bool dbg_os(void)
218 struct simplelist_info info
;
219 simplelist_info_init(&info
, IF_COP("Core and ") "Stack usage:",
223 MAXTHREADS
+NUM_CORES
,
226 #ifndef ROCKBOX_HAS_LOGF
227 info
.hide_selection
= true;
228 info
.scroll_all
= true;
230 info
.action_callback
= dbg_threads_action_callback
;
231 info
.get_name
= threads_getname
;
232 return simplelist_show_list(&info
);
236 #include "cpuinfo-linux.h"
238 #define MAX_STATES 16
239 static struct time_state states
[MAX_STATES
];
241 static const char* get_cpuinfo(int selected_item
, void *data
,
242 char *buffer
, size_t buffer_len
)
244 (void)data
;(void)buffer_len
;
248 static struct cpuusage last_us
;
249 int state_count
= *(int*)data
;
251 if (cpuusage_linux(&us
) != 0)
254 switch(selected_item
)
257 diff
= abs(last_us
.usage
- us
.usage
);
258 sprintf(buffer
, "Usage: %ld.%02ld%% (%c %ld.%02ld)",
259 us
.usage
/100, us
.usage
%100,
260 (us
.usage
>= last_us
.usage
) ? '+':'-',
262 last_us
.usage
= us
.usage
;
267 diff
= us
.utime
- last_us
.utime
;
268 last_us
.utime
= us
.utime
;
273 diff
= us
.stime
- last_us
.stime
;
274 last_us
.stime
= us
.stime
;
279 diff
= us
.rtime
- last_us
.rtime
;
280 last_us
.rtime
= us
.rtime
;
283 return "*** Per CPU freq stats ***";
286 int cpu
= (selected_item
- 5) / (state_count
+ 1);
287 int cpu_line
= (selected_item
- 5) % (state_count
+ 1);
288 int freq1
= frequency_linux(cpu
, false);
289 int freq2
= frequency_linux(cpu
, true);
292 sprintf(buffer
, " CPU%d: Cur/Scal freq: %d/%d MHz", cpu
,
293 freq1
> 0 ? freq1
/1000 : -1,
294 freq2
> 0 ? freq2
/1000 : -1);
298 cpustatetimes_linux(cpu
, states
, ARRAYLEN(states
));
299 snprintf(buffer
, buffer_len
, " %ld %ld",
300 states
[cpu_line
-1].frequency
,
301 states
[cpu_line
-1].time
);
306 sprintf(buffer
, "%s: %ld.%02lds (+ %ld.%02ld)", text
,
307 time
/ us
.hz
, time
% us
.hz
,
308 diff
/ us
.hz
, diff
% us
.hz
);
312 static int cpuinfo_cb(int action
, struct gui_synclist
*lists
)
315 if (action
== ACTION_NONE
)
316 action
= ACTION_REDRAW
;
320 static bool dbg_cpuinfo(void)
322 struct simplelist_info info
;
323 int cpu_count
= MAX(cpucount_linux(), 1);
324 int state_count
= cpustatetimes_linux(0, states
, ARRAYLEN(states
));
325 printf("%s(): %d %d\n", __func__
, cpu_count
, state_count
);
326 simplelist_info_init(&info
, "CPU info:", 5 + cpu_count
*(state_count
+1), &state_count
);
327 info
.get_name
= get_cpuinfo
;
328 info
.action_callback
= cpuinfo_cb
;
330 info
.hide_selection
= true;
331 info
.scroll_all
= true;
332 return simplelist_show_list(&info
);
337 #ifdef HAVE_LCD_BITMAP
338 #if CONFIG_CODEC != SWCODEC
340 static bool dbg_audio_thread(void)
342 struct audio_debug d
;
344 lcd_setfont(FONT_SYSFIXED
);
348 if (action_userabort(HZ
/5))
351 audio_get_debugdata(&d
);
355 lcd_putsf(0, 0, "read: %x", d
.audiobuf_read
);
356 lcd_putsf(0, 1, "write: %x", d
.audiobuf_write
);
357 lcd_putsf(0, 2, "swap: %x", d
.audiobuf_swapwrite
);
358 lcd_putsf(0, 3, "playing: %d", d
.playing
);
359 lcd_putsf(0, 4, "playable: %x", d
.playable_space
);
360 lcd_putsf(0, 5, "unswapped: %x", d
.unswapped_space
);
362 /* Playable space left */
363 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8, 112, 4, d
.audiobuflen
, 0,
364 d
.playable_space
, HORIZONTAL
);
366 /* Show the watermark limit */
367 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8+4, 112, 4, d
.audiobuflen
, 0,
368 d
.low_watermark_level
, HORIZONTAL
);
370 lcd_putsf(0, 7, "wm: %x - %x",
371 d
.low_watermark_level
, d
.lowest_watermark_level
);
375 lcd_setfont(FONT_UI
);
378 #endif /* !SIMULATOR */
379 #else /* CONFIG_CODEC == SWCODEC */
380 static unsigned int ticks
, freq_sum
;
381 #ifndef CPU_MULTI_FREQUENCY
382 static unsigned int boost_ticks
;
385 static void dbg_audio_task(void)
387 #ifdef CPUFREQ_NORMAL
388 #ifndef CPU_MULTI_FREQUENCY
389 if(FREQ
> CPUFREQ_NORMAL
)
392 freq_sum
+= FREQ
/1000000; /* in MHz */
397 static bool dbg_buffering_thread(void)
403 size_t bufsize
= pcmbuf_get_bufsize();
404 int pcmbufdescs
= pcmbuf_descs();
405 struct buffering_debug d
;
406 size_t filebuflen
= audio_get_filebuflen();
407 /* This is a size_t, but call it a long so it puts a - when it's bad. */
409 #ifndef CPU_MULTI_FREQUENCY
412 ticks
= freq_sum
= 0;
414 tick_add_task(dbg_audio_task
);
417 screens
[i
].setfont(FONT_SYSFIXED
);
421 button
= get_action(CONTEXT_STD
,HZ
/5);
424 case ACTION_STD_NEXT
:
427 case ACTION_STD_PREV
:
430 case ACTION_STD_CANCEL
:
435 buffering_get_debugdata(&d
);
436 bufused
= bufsize
- pcmbuf_free();
441 screens
[i
].clear_display();
444 screens
[i
].putsf(0, line
++, "pcm: %6ld/%ld", (long) bufused
, (long) bufsize
);
446 gui_scrollbar_draw(&screens
[i
],0, line
*8, screens
[i
].lcdwidth
, 6,
447 bufsize
, 0, bufused
, HORIZONTAL
);
450 screens
[i
].putsf(0, line
++, "alloc: %6ld/%ld", audio_filebufused(),
453 #if LCD_HEIGHT > 80 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_HEIGHT > 80)
454 if (screens
[i
].lcdheight
> 80)
456 gui_scrollbar_draw(&screens
[i
],0, line
*8, screens
[i
].lcdwidth
, 6,
457 filebuflen
, 0, audio_filebufused(), HORIZONTAL
);
460 screens
[i
].putsf(0, line
++, "real: %6ld/%ld", (long)d
.buffered_data
,
463 gui_scrollbar_draw(&screens
[i
],0, line
*8, screens
[i
].lcdwidth
, 6,
464 filebuflen
, 0, (long)d
.buffered_data
, HORIZONTAL
);
469 screens
[i
].putsf(0, line
++, "usefl: %6ld/%ld", (long)(d
.useful_data
),
472 #if LCD_HEIGHT > 80 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_HEIGHT > 80)
473 if (screens
[i
].lcdheight
> 80)
475 gui_scrollbar_draw(&screens
[i
],0, line
*8, screens
[i
].lcdwidth
, 6,
476 filebuflen
, 0, d
.useful_data
, HORIZONTAL
);
481 screens
[i
].putsf(0, line
++, "data_rem: %ld", (long)d
.data_rem
);
483 screens
[i
].putsf(0, line
++, "track count: %2d", audio_track_count());
485 screens
[i
].putsf(0, line
++, "handle count: %d", (int)d
.num_handles
);
487 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
488 screens
[i
].putsf(0, line
++, "cpu freq: %3dMHz",
489 (int)((FREQ
+ 500000) / 1000000));
494 int avgclock
= freq_sum
* 10 / ticks
; /* in 100 kHz */
495 #ifdef CPU_MULTI_FREQUENCY
496 int boostquota
= (avgclock
* 100 - CPUFREQ_NORMAL
/1000) /
497 ((CPUFREQ_MAX
- CPUFREQ_NORMAL
) / 1000000); /* in 0.1 % */
499 int boostquota
= boost_ticks
* 1000 / ticks
; /* in 0.1 % */
501 screens
[i
].putsf(0, line
++, "boost:%3d.%d%% (%d.%dMHz)",
502 boostquota
/10, boostquota
%10, avgclock
/10, avgclock
%10);
505 screens
[i
].putsf(0, line
++, "pcmbufdesc: %2d/%2d",
506 pcmbuf_used_descs(), pcmbufdescs
);
507 screens
[i
].putsf(0, line
++, "watermark: %6d",
514 tick_remove_task(dbg_audio_task
);
517 screens
[i
].setfont(FONT_UI
);
521 #endif /* CONFIG_CODEC */
522 #endif /* HAVE_LCD_BITMAP */
524 static const char* bf_getname(int selected_item
, void *data
,
525 char *buffer
, size_t buffer_len
)
528 core_print_block_at(selected_item
, buffer
, buffer_len
);
532 static int bf_action_cb(int action
, struct gui_synclist
* list
)
534 if (action
== ACTION_STD_OK
)
536 if (gui_synclist_get_sel_pos(list
) == 0 && core_test_free())
538 splash(HZ
, "Freed test handle. New alloc should trigger compact");
542 splash(HZ
/1, "Attempting a 64k allocation");
543 int handle
= core_alloc("test", 64<<10);
544 splash(HZ
/2, (handle
> 0) ? "Success":"Fail");
545 /* for some reason simplelist doesn't allow adding items here if
546 * info.get_name is given, so use normal list api */
547 gui_synclist_set_nb_items(list
, core_get_num_blocks());
551 action
= ACTION_REDRAW
;
553 else if (action
== ACTION_NONE
)
554 action
= ACTION_REDRAW
;
558 static bool dbg_buflib_allocs(void)
560 struct simplelist_info info
;
561 simplelist_info_init(&info
, "mem allocs", core_get_num_blocks(), NULL
);
562 info
.get_name
= bf_getname
;
563 info
.action_callback
= bf_action_cb
;
564 info
.timeout
= TIMEOUT_BLOCK
;
565 return simplelist_show_list(&info
);
568 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
569 static const char* dbg_partitions_getname(int selected_item
, void *data
,
570 char *buffer
, size_t buffer_len
)
573 int partition
= selected_item
/2;
574 struct partinfo
* p
= disk_partinfo(partition
);
577 snprintf(buffer
, buffer_len
, " T:%x %ld MB", p
->type
, p
->size
/ ( 2048 / ( SECTOR_SIZE
/ 512 )));
581 snprintf(buffer
, buffer_len
, "P%d: S:%lx", partition
, p
->start
);
586 static bool dbg_partitions(void)
588 struct simplelist_info info
;
589 simplelist_info_init(&info
, "Partition Info", 4, NULL
);
590 info
.selection_size
= 2;
591 info
.hide_selection
= true;
592 info
.scroll_all
= true;
593 info
.get_name
= dbg_partitions_getname
;
594 return simplelist_show_list(&info
);
596 #endif /* PLATFORM_NATIVE */
598 #if defined(CPU_COLDFIRE) && defined(HAVE_SPDIF_OUT)
599 static bool dbg_spdif(void)
602 unsigned int control
;
607 unsigned int interruptstat
;
608 bool valnogood
, symbolerr
, parityerr
;
611 int spdif_source
= spdif_get_output_source(&spdif_src_on
);
612 spdif_set_output_source(AUDIO_SRC_SPDIF
IF_SPDIF_POWER_(, true));
615 lcd_setfont(FONT_SYSFIXED
);
617 #ifdef HAVE_SPDIF_POWER
618 spdif_power_enable(true); /* We need SPDIF power for both sending & receiving */
625 control
= EBU1RCVCCHANNEL1
;
626 interruptstat
= INTERRUPTSTAT
;
627 INTERRUPTCLEAR
= 0x03c00000;
629 valnogood
= (interruptstat
& 0x01000000)?true:false;
630 symbolerr
= (interruptstat
& 0x00800000)?true:false;
631 parityerr
= (interruptstat
& 0x00400000)?true:false;
633 lcd_putsf(0, line
++, "Val: %s Sym: %s Par: %s",
636 parityerr
?"--":"OK");
638 lcd_putsf(0, line
++, "Status word: %08x", (int)control
);
643 lcd_putsf(0, line
++, "PRO: %d (%s)",
644 x
, x
?"Professional":"Consumer");
646 x
= (control
>> 30) & 1;
647 lcd_putsf(0, line
++, "Audio: %d (%s)",
648 x
, x
?"Non-PCM":"PCM");
650 x
= (control
>> 29) & 1;
651 lcd_putsf(0, line
++, "Copy: %d (%s)",
652 x
, x
?"Permitted":"Inhibited");
654 x
= (control
>> 27) & 7;
667 lcd_putsf(0, line
++, "Preemphasis: %d (%s)", x
, s
);
669 x
= (control
>> 24) & 3;
670 lcd_putsf(0, line
++, "Mode: %d", x
);
672 category
= (control
>> 17) & 127;
684 lcd_putsf(0, line
++, "Category: 0x%02x (%s)", category
, s
);
686 x
= (control
>> 16) & 1;
688 if(((category
& 0x70) == 0x10) ||
689 ((category
& 0x70) == 0x40) ||
690 ((category
& 0x78) == 0x38))
692 generation
= !generation
;
694 lcd_putsf(0, line
++, "Generation: %d (%s)",
695 x
, generation
?"Original":"No ind.");
697 x
= (control
>> 12) & 15;
698 lcd_putsf(0, line
++, "Source: %d", x
);
701 x
= (control
>> 8) & 15;
717 lcd_putsf(0, line
++, "Channel: %d (%s)", x
, s
);
719 x
= (control
>> 4) & 15;
732 lcd_putsf(0, line
++, "Frequency: %d (%s)", x
, s
);
734 x
= (control
>> 2) & 3;
735 lcd_putsf(0, line
++, "Clock accuracy: %d", x
);
738 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
739 lcd_putsf(0, line
++, "Measured freq: %ldHz",
740 spdif_measure_frequency());
745 if (action_userabort(HZ
/10))
749 spdif_set_output_source(spdif_source
IF_SPDIF_POWER_(, spdif_src_on
));
751 #ifdef HAVE_SPDIF_POWER
752 spdif_power_enable(global_settings
.spdif_enable
);
755 lcd_setfont(FONT_UI
);
758 #endif /* CPU_COLDFIRE */
760 #if (CONFIG_RTC == RTC_PCF50605) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
761 static bool dbg_pcf(void)
765 #ifdef HAVE_LCD_BITMAP
766 lcd_setfont(FONT_SYSFIXED
);
774 lcd_putsf(0, line
++, "DCDC1: %02x", pcf50605_read(0x1b));
775 lcd_putsf(0, line
++, "DCDC2: %02x", pcf50605_read(0x1c));
776 lcd_putsf(0, line
++, "DCDC3: %02x", pcf50605_read(0x1d));
777 lcd_putsf(0, line
++, "DCDC4: %02x", pcf50605_read(0x1e));
778 lcd_putsf(0, line
++, "DCDEC1: %02x", pcf50605_read(0x1f));
779 lcd_putsf(0, line
++, "DCDEC2: %02x", pcf50605_read(0x20));
780 lcd_putsf(0, line
++, "DCUDC1: %02x", pcf50605_read(0x21));
781 lcd_putsf(0, line
++, "DCUDC2: %02x", pcf50605_read(0x22));
782 lcd_putsf(0, line
++, "IOREGC: %02x", pcf50605_read(0x23));
783 lcd_putsf(0, line
++, "D1REGC: %02x", pcf50605_read(0x24));
784 lcd_putsf(0, line
++, "D2REGC: %02x", pcf50605_read(0x25));
785 lcd_putsf(0, line
++, "D3REGC: %02x", pcf50605_read(0x26));
786 lcd_putsf(0, line
++, "LPREG1: %02x", pcf50605_read(0x27));
788 if (action_userabort(HZ
/10))
790 lcd_setfont(FONT_UI
);
795 lcd_setfont(FONT_UI
);
800 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
801 static bool dbg_cpufreq(void)
806 #ifdef HAVE_LCD_BITMAP
807 lcd_setfont(FONT_SYSFIXED
);
815 lcd_putsf(0, line
++, "Frequency: %ld", FREQ
);
816 lcd_putsf(0, line
++, "boost_counter: %d", get_cpu_boost_counter());
819 button
= get_action(CONTEXT_STD
,HZ
/10);
823 case ACTION_STD_PREV
:
827 case ACTION_STD_NEXT
:
832 while (get_cpu_boost_counter() > 0)
834 set_cpu_frequency(CPUFREQ_DEFAULT
);
837 case ACTION_STD_CANCEL
:
838 lcd_setfont(FONT_UI
);
842 lcd_setfont(FONT_UI
);
845 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
847 #if defined(HAVE_TSC2100) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
849 static const char* tsc2100_debug_getname(int selected_item
, void * data
,
850 char *buffer
, size_t buffer_len
)
852 int *page
= (int*)data
;
853 bool reserved
= false;
857 if ((selected_item
> 0x0a) ||
858 (selected_item
== 0x04) ||
859 (selected_item
== 0x08))
863 if ((selected_item
> 0x05) ||
864 (selected_item
== 0x02))
868 if (selected_item
> 0x1e)
873 snprintf(buffer
, buffer_len
, "%02x: RSVD", selected_item
);
875 snprintf(buffer
, buffer_len
, "%02x: %04x", selected_item
,
876 tsc2100_readreg(*page
, selected_item
)&0xffff);
879 static int tsc2100debug_action_callback(int action
, struct gui_synclist
*lists
)
881 int *page
= (int*)lists
->data
;
882 if (action
== ACTION_STD_OK
)
885 snprintf(lists
->title
, 32,
886 "tsc2100 registers - Page %d", *page
);
887 return ACTION_REDRAW
;
891 static bool tsc2100_debug(void)
894 char title
[32] = "tsc2100 registers - Page 0";
895 struct simplelist_info info
;
896 simplelist_info_init(&info
, title
, 32, &page
);
897 info
.timeout
= HZ
/100;
898 info
.get_name
= tsc2100_debug_getname
;
899 info
.action_callback
= tsc2100debug_action_callback
;
900 return simplelist_show_list(&info
);
903 #if (CONFIG_BATTERY_MEASURE != 0) && defined(HAVE_LCD_BITMAP) && !defined(SIMULATOR)
905 * view_battery() shows a automatically scaled graph of the battery voltage
906 * over time. Usable for estimating battery life / charging rate.
907 * The power_history array is updated in power_thread of powermgmt.c.
910 #define BAT_LAST_VAL MIN(LCD_WIDTH, POWER_HISTORY_LEN)
911 #define BAT_TSPACE 20
912 #define BAT_YSPACE (LCD_HEIGHT - BAT_TSPACE)
915 static bool view_battery(void)
918 int i
, x
, y
, z
, y1
, y2
, grid
, graph
;
919 unsigned short maxv
, minv
;
921 lcd_setfont(FONT_SYSFIXED
);
927 case 0: /* voltage history graph */
928 /* Find maximum and minimum voltage for scaling */
929 minv
= power_history
[0];
931 for (i
= 1; i
< BAT_LAST_VAL
&& power_history
[i
]; i
++) {
932 if (power_history
[i
] > maxv
)
933 maxv
= power_history
[i
];
934 if (power_history
[i
] < minv
)
935 minv
= power_history
[i
];
938 #if (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE)
939 /* adjust grid scale */
940 if ((maxv
- minv
) > 50)
945 lcd_putsf(0, 0, "battery %d.%03dV", power_history
[0] / 1000,
946 power_history
[0] % 1000);
947 lcd_putsf(0, 1, "%d.%03d-%d.%03dV (%2dmV)",
948 minv
/ 1000, minv
% 1000, maxv
/ 1000, maxv
% 1000,
950 #elif (CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE)
951 /* adjust grid scale */
952 if ((maxv
- minv
) > 10)
956 lcd_putsf(0, 0, "battery %d%%", power_history
[0]);
957 lcd_putsf(0, 1, "%d%%-%d%% (%d %%)", minv
, maxv
, grid
);
961 while ((y
= (minv
- (minv
% grid
)+i
*grid
)) < maxv
)
963 graph
= ((y
-minv
)*BAT_YSPACE
)/(maxv
-minv
);
964 graph
= LCD_HEIGHT
-1 - graph
;
966 /* draw dotted horizontal grid line */
967 for (x
=0; x
<LCD_WIDTH
;x
=x
+2)
968 lcd_drawpixel(x
,graph
);
974 /* draw plot of power history
977 for (i
= BAT_LAST_VAL
- 1; i
> 0; i
--)
979 if (power_history
[i
] && power_history
[i
-1])
981 y1
= (power_history
[i
] - minv
) * BAT_YSPACE
/
983 y1
= MIN(MAX(LCD_HEIGHT
-1 - y1
, BAT_TSPACE
),
985 y2
= (power_history
[i
-1] - minv
) * BAT_YSPACE
/
987 y2
= MIN(MAX(LCD_HEIGHT
-1 - y2
, BAT_TSPACE
),
990 lcd_set_drawmode(DRMODE_SOLID
);
992 /* make line thicker */
993 lcd_drawline(((x
*LCD_WIDTH
)/(BAT_LAST_VAL
)),
995 (((x
+1)*LCD_WIDTH
)/(BAT_LAST_VAL
)),
997 lcd_drawline(((x
*LCD_WIDTH
)/(BAT_LAST_VAL
))+1,
999 (((x
+1)*LCD_WIDTH
)/(BAT_LAST_VAL
))+1,
1006 case 1: /* status: */
1007 #if CONFIG_CHARGING >= CHARGING_MONITOR
1008 lcd_putsf(0, 0, "Pwr status: %s",
1009 charging_state() ? "charging" : "discharging");
1011 lcd_puts(0, 0, "Power status: unknown");
1013 battery_read_info(&y
, &z
);
1015 lcd_putsf(0, 1, "Battery: %d.%03d V (%d %%)", y
/ 1000, y
% 1000, z
);
1017 lcd_putsf(0, 1, "Battery: %d %%", z
);
1018 #ifdef ADC_EXT_POWER
1019 y
= (adc_read(ADC_EXT_POWER
) * EXT_SCALE_FACTOR
) / 1000;
1020 lcd_putsf(0, 2, "External: %d.%03d V", y
/ 1000, y
% 1000);
1023 #if defined ARCHOS_RECORDER
1024 lcd_putsf(0, 3, "Chgr: %s %s",
1025 charger_inserted() ? "present" : "absent",
1026 charger_enabled() ? "on" : "off");
1027 lcd_putsf(0, 5, "short delta: %d", short_delta
);
1028 lcd_putsf(0, 6, "long delta: %d", long_delta
);
1029 lcd_puts(0, 7, power_message
);
1030 lcd_putsf(0, 8, "USB Inserted: %s",
1031 usb_inserted() ? "yes" : "no");
1032 #elif defined IPOD_NANO || defined IPOD_VIDEO
1033 int usb_pwr
= (GPIOL_INPUT_VAL
& 0x10)?true:false;
1034 int ext_pwr
= (GPIOL_INPUT_VAL
& 0x08)?false:true;
1035 int dock
= (GPIOA_INPUT_VAL
& 0x10)?true:false;
1036 int charging
= (GPIOB_INPUT_VAL
& 0x01)?false:true;
1037 int headphone
= (GPIOA_INPUT_VAL
& 0x80)?true:false;
1039 lcd_putsf(0, 3, "USB pwr: %s",
1040 usb_pwr
? "present" : "absent");
1041 lcd_putsf(0, 4, "EXT pwr: %s",
1042 ext_pwr
? "present" : "absent");
1043 lcd_putsf(0, 5, "Battery: %s",
1044 charging
? "charging" : (usb_pwr
||ext_pwr
) ? "charged" : "discharging");
1045 lcd_putsf(0, 6, "Dock mode: %s",
1046 dock
? "enabled" : "disabled");
1047 lcd_putsf(0, 7, "Headphone: %s",
1048 headphone
? "connected" : "disconnected");
1050 if(probed_ramsize
== 64)
1051 x
= (adc_read(ADC_4066_ISTAT
) * 2400) / (1024 * 2);
1054 x
= (adc_read(ADC_4066_ISTAT
) * 2400) / (1024 * 3);
1055 lcd_putsf(0, 8, "Ibat: %d mA", x
);
1056 lcd_putsf(0, 9, "Vbat * Ibat: %d mW", x
* y
/ 1000);
1057 #elif defined TOSHIBA_GIGABEAT_S
1061 static const unsigned char * const chrgstate_strings
[] =
1072 lcd_putsf(0, line
++, "Charger: %s",
1073 charger_inserted() ? "present" : "absent");
1075 st
= power_input_status() &
1076 (POWER_INPUT_CHARGER
| POWER_INPUT_BATTERY
);
1077 lcd_putsf(0, line
++, "%s%s",
1078 (st
& POWER_INPUT_MAIN_CHARGER
) ? " Main" : "",
1079 (st
& POWER_INPUT_USB_CHARGER
) ? " USB" : "");
1081 y
= ARRAYLEN(chrgstate_strings
) - 1;
1083 switch (charge_state
)
1085 case CHARGE_STATE_DISABLED
: y
--;
1086 case CHARGE_STATE_ERROR
: y
--;
1087 case DISCHARGING
: y
--;
1094 lcd_putsf(0, line
++, "State: %s", chrgstate_strings
[y
]);
1096 lcd_putsf(0, line
++, "Battery Switch: %s",
1097 (st
& POWER_INPUT_BATTERY
) ? "On" : "Off");
1099 y
= chrgraw_adc_voltage();
1100 lcd_putsf(0, line
++, "CHRGRAW: %d.%03d V",
1101 y
/ 1000, y
% 1000);
1103 y
= application_supply_adc_voltage();
1104 lcd_putsf(0, line
++, "BP : %d.%03d V",
1105 y
/ 1000, y
% 1000);
1107 y
= battery_adc_charge_current();
1108 if (y
< 0) x
= '-', y
= -y
;
1110 lcd_putsf(0, line
++, "CHRGISN:%c%d mA", x
, y
);
1112 y
= cccv_regulator_dissipation();
1113 lcd_putsf(0, line
++, "P CCCV : %d mW", y
);
1115 y
= battery_charge_current();
1116 if (y
< 0) x
= '-', y
= -y
;
1118 lcd_putsf(0, line
++, "I Charge:%c%d mA", x
, y
);
1120 y
= battery_adc_temp();
1123 lcd_putsf(0, line
++, "T Battery: %dC (%dF)", y
,
1126 /* Conversion disabled */
1127 lcd_puts(0, line
++, "T Battery: ?");
1130 #elif defined(HAVE_AS3514) && defined(CONFIG_CHARGING)
1131 static const char * const chrgstate_strings
[] =
1133 [CHARGE_STATE_DISABLED
- CHARGE_STATE_DISABLED
]= "Disabled",
1134 [CHARGE_STATE_ERROR
- CHARGE_STATE_DISABLED
] = "Error",
1135 [DISCHARGING
- CHARGE_STATE_DISABLED
] = "Discharging",
1136 [CHARGING
- CHARGE_STATE_DISABLED
] = "Charging",
1138 const char *str
= NULL
;
1140 lcd_putsf(0, 3, "Charger: %s",
1141 charger_inserted() ? "present" : "absent");
1143 y
= charge_state
- CHARGE_STATE_DISABLED
;
1144 if ((unsigned)y
< ARRAYLEN(chrgstate_strings
))
1145 str
= chrgstate_strings
[y
];
1147 lcd_putsf(0, 4, "State: %s",
1148 str
? str
: "<unknown>");
1150 lcd_putsf(0, 5, "CHARGER: %02X", ascodec_read_charger());
1151 #elif defined(IPOD_NANO2G)
1152 y
= pmu_read_battery_voltage();
1153 lcd_putsf(17, 1, "RAW: %d.%03d V", y
/ 1000, y
% 1000);
1154 y
= pmu_read_battery_current();
1155 lcd_putsf(0, 2, "Battery current: %d mA", y
);
1156 lcd_putsf(0, 3, "PWRCON: %08x %08x", PWRCON
, PWRCONEXT
);
1157 lcd_putsf(0, 4, "CLKCON: %08x %03x %03x", CLKCON
, CLKCON2
, CLKCON3
);
1158 lcd_putsf(0, 5, "PLL: %06x %06x %06x", PLL0PMS
, PLL1PMS
, PLL2PMS
);
1159 x
= pmu_read(0x1b) & 0xf;
1160 y
= pmu_read(0x1a) * 25 + 625;
1161 lcd_putsf(0, 6, "AUTO: %x / %d mV", x
, y
);
1162 x
= pmu_read(0x1f) & 0xf;
1163 y
= pmu_read(0x1e) * 25 + 625;
1164 lcd_putsf(0, 7, "DOWN1: %x / %d mV", x
, y
);
1165 x
= pmu_read(0x23) & 0xf;
1166 y
= pmu_read(0x22) * 25 + 625;
1167 lcd_putsf(0, 8, "DOWN2: %x / %d mV", x
, y
);
1168 x
= pmu_read(0x27) & 0xf;
1169 y
= pmu_read(0x26) * 100 + 900;
1170 lcd_putsf(0, 9, "MEMLDO: %x / %d mV", x
, y
);
1171 for (i
= 0; i
< 6; i
++)
1173 x
= pmu_read(0x2e + (i
<< 1)) & 0xf;
1174 y
= pmu_read(0x2d + (i
<< 1)) * 100 + 900;
1175 lcd_putsf(0, 10 + i
, "LDO%d: %x / %d mV", i
+ 1, x
, y
);
1178 lcd_putsf(0, 3, "Charger: %s",
1179 charger_inserted() ? "present" : "absent");
1180 #endif /* target type */
1181 #endif /* CONFIG_CHARGING */
1183 case 2: /* voltage deltas: */
1184 #if (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE)
1185 lcd_puts(0, 0, "Voltage deltas:");
1186 for (i
= 0; i
< POWER_HISTORY_LEN
-1; i
++) {
1187 y
= power_history
[i
] - power_history
[i
+1];
1188 lcd_putsf(0, i
+1, "-%d min: %c%d.%03d V", i
,
1189 (y
< 0) ? '-' : ' ', ((y
< 0) ? y
* -1 : y
) / 1000,
1190 ((y
< 0) ? y
* -1 : y
) % 1000);
1192 #elif (CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE)
1193 lcd_puts(0, 0, "Percentage deltas:");
1194 for (i
= 0; i
< POWER_HISTORY_LEN
-1; i
++) {
1195 y
= power_history
[i
] - power_history
[i
+1];
1196 lcd_putsf(0, i
+1, "-%d min: %c%d%%", i
,
1197 (y
< 0) ? '-' : ' ', ((y
< 0) ? y
* -1 : y
));
1202 case 3: /* remaining time estimation: */
1204 #ifdef ARCHOS_RECORDER
1205 lcd_putsf(0, 0, "charge_state: %d", charge_state
);
1207 lcd_putsf(0, 1, "Cycle time: %d m", powermgmt_last_cycle_startstop_min
);
1209 lcd_putsf(0, 2, "Lvl@cyc st: %d%%", powermgmt_last_cycle_level
);
1211 lcd_putsf(0, 3, "P=%2d I=%2d", pid_p
, pid_i
);
1213 lcd_putsf(0, 4, "Trickle sec: %d/60", trickle_sec
);
1214 #endif /* ARCHOS_RECORDER */
1216 #if (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE)
1217 lcd_putsf(0, 5, "Last PwrHist: %d.%03dV",
1218 power_history
[0] / 1000,
1219 power_history
[0] % 1000);
1222 lcd_putsf(0, 6, "battery level: %d%%", battery_level());
1224 int time_left
= battery_time();
1226 lcd_putsf(0, 7, "Est. remain: %d m", time_left
);
1228 lcd_puts(0, 7, "Estimation n/a");
1234 switch(get_action(CONTEXT_STD
,HZ
/2))
1236 case ACTION_STD_PREV
:
1241 case ACTION_STD_NEXT
:
1246 case ACTION_STD_CANCEL
:
1247 lcd_setfont(FONT_UI
);
1251 lcd_setfont(FONT_UI
);
1255 #endif /* (CONFIG_BATTERY_MEASURE != 0) && HAVE_LCD_BITMAP */
1257 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
1258 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
1260 #if (CONFIG_STORAGE & STORAGE_MMC)
1261 #define CARDTYPE "MMC"
1262 #elif (CONFIG_STORAGE & STORAGE_SD)
1263 #define CARDTYPE "microSD"
1266 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1269 int *cardnum
= (int*)lists
->data
;
1270 unsigned char card_name
[6];
1271 unsigned char pbuf
[32];
1272 char *title
= lists
->title
;
1273 static const unsigned char i_vmin
[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
1274 static const unsigned char i_vmax
[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
1275 static const unsigned char * const kbit_units
[] = { "kBit/s", "MBit/s", "GBit/s" };
1276 static const unsigned char * const nsec_units
[] = { "ns", "µs", "ms" };
1277 #if (CONFIG_STORAGE & STORAGE_MMC)
1278 static const char * const mmc_spec_vers
[] = { "1.0-1.2", "1.4", "2.0-2.2",
1279 "3.1-3.31", "4.0" };
1282 if ((btn
== ACTION_STD_OK
) || (btn
== SYS_FS_CHANGED
) || (btn
== ACTION_REDRAW
))
1285 if (btn
== ACTION_STD_OK
)
1287 *cardnum
^= 0x1; /* change cards */
1291 simplelist_set_line_count(0);
1293 card
= card_get_info(*cardnum
);
1295 if (card
->initialized
> 0)
1298 for (i
=0; i
<sizeof(card_name
); i
++)
1300 card_name
[i
] = card_extract_bits(card
->cid
, (103-8*i
), 8);
1302 strlcpy(card_name
, card_name
, sizeof(card_name
));
1303 simplelist_addline(SIMPLELIST_ADD_LINE
,
1304 "%s Rev %d.%d", card_name
,
1305 (int) card_extract_bits(card
->cid
, 63, 4),
1306 (int) card_extract_bits(card
->cid
, 59, 4));
1307 simplelist_addline(SIMPLELIST_ADD_LINE
,
1309 #if (CONFIG_STORAGE & STORAGE_SD)
1310 (int) card_extract_bits(card
->cid
, 11, 4),
1311 (int) card_extract_bits(card
->cid
, 19, 8) + 2000
1312 #elif (CONFIG_STORAGE & STORAGE_MMC)
1313 (int) card_extract_bits(card
->cid
, 15, 4),
1314 (int) card_extract_bits(card
->cid
, 11, 4) + 1997
1317 simplelist_addline(SIMPLELIST_ADD_LINE
,
1318 #if (CONFIG_STORAGE & STORAGE_SD)
1320 card_extract_bits(card
->cid
, 55, 32)
1321 #elif (CONFIG_STORAGE & STORAGE_MMC)
1323 card_extract_bits(card
->cid
, 47, 16)
1327 simplelist_addline(SIMPLELIST_ADD_LINE
, "M=%02x, "
1328 #if (CONFIG_STORAGE & STORAGE_SD)
1330 (int) card_extract_bits(card
->cid
, 127, 8),
1331 card_extract_bits(card
->cid
, 119, 8),
1332 card_extract_bits(card
->cid
, 111, 8)
1333 #elif (CONFIG_STORAGE & STORAGE_MMC)
1335 (int) card_extract_bits(card
->cid
, 127, 8),
1336 (int) card_extract_bits(card
->cid
, 119, 16)
1340 #if (CONFIG_STORAGE & STORAGE_MMC)
1341 int temp
= card_extract_bits(card
->csd
, 125, 4);
1342 simplelist_addline(SIMPLELIST_ADD_LINE
,
1343 "MMC v%s", temp
< 5 ?
1344 mmc_spec_vers
[temp
] : "?.?");
1346 simplelist_addline(SIMPLELIST_ADD_LINE
,
1347 "Blocks: 0x%08lx", card
->numblocks
);
1348 output_dyn_value(pbuf
, sizeof pbuf
, card
->speed
/ 1000,
1350 simplelist_addline(SIMPLELIST_ADD_LINE
,
1352 output_dyn_value(pbuf
, sizeof pbuf
, card
->taac
,
1354 simplelist_addline(SIMPLELIST_ADD_LINE
,
1356 simplelist_addline(SIMPLELIST_ADD_LINE
,
1357 "Nsac: %d clk", card
->nsac
);
1358 simplelist_addline(SIMPLELIST_ADD_LINE
,
1359 "R2W: *%d", card
->r2w_factor
);
1360 #if (CONFIG_STORAGE & STORAGE_SD)
1361 int csd_structure
= card_extract_bits(card
->csd
, 127, 2);
1362 if (csd_structure
== 0) /* CSD version 1.0 */
1365 simplelist_addline(SIMPLELIST_ADD_LINE
,
1367 i_vmin
[card_extract_bits(card
->csd
, 61, 3)],
1368 i_vmax
[card_extract_bits(card
->csd
, 58, 3)]);
1369 simplelist_addline(SIMPLELIST_ADD_LINE
,
1371 i_vmin
[card_extract_bits(card
->csd
, 55, 3)],
1372 i_vmax
[card_extract_bits(card
->csd
, 52, 3)]);
1375 else if (card
->initialized
== 0)
1377 simplelist_addline(SIMPLELIST_ADD_LINE
, "Not Found!");
1379 #if (CONFIG_STORAGE & STORAGE_SD)
1380 else /* card->initialized < 0 */
1382 simplelist_addline(SIMPLELIST_ADD_LINE
, "Init Error! (%d)", card
->initialized
);
1385 snprintf(title
, 16, "[" CARDTYPE
" %d]", *cardnum
);
1386 gui_synclist_set_title(lists
, title
, Icon_NOICON
);
1387 gui_synclist_set_nb_items(lists
, simplelist_get_line_count());
1388 gui_synclist_select_item(lists
, 0);
1389 btn
= ACTION_REDRAW
;
1393 #elif (CONFIG_STORAGE & STORAGE_ATA)
1394 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1399 unsigned short* identify_info
= ata_get_identify();
1400 bool timing_info_present
= false;
1403 simplelist_set_line_count(0);
1405 for (i
=0; i
< 20; i
++)
1406 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+27]);
1408 /* kill trailing space */
1409 for (i
=39; i
&& buf
[i
]==' '; i
--)
1411 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", buf
);
1412 for (i
=0; i
< 4; i
++)
1413 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+23]);
1415 simplelist_addline(SIMPLELIST_ADD_LINE
,
1416 "Firmware: %s", buf
);
1417 snprintf(buf
, sizeof buf
, "%ld MB",
1418 ((unsigned long)identify_info
[61] << 16 |
1419 (unsigned long)identify_info
[60]) / 2048 );
1420 simplelist_addline(SIMPLELIST_ADD_LINE
,
1423 fat_size( IF_MV2(0,) NULL
, &free
);
1424 simplelist_addline(SIMPLELIST_ADD_LINE
,
1425 "Free: %ld MB", free
/ 1024);
1426 simplelist_addline(SIMPLELIST_ADD_LINE
,
1427 "Spinup time: %d ms", storage_spinup_time() * (1000/HZ
));
1428 i
= identify_info
[83] & (1<<3);
1429 simplelist_addline(SIMPLELIST_ADD_LINE
,
1430 "Power mgmt: %s", i
? "enabled" : "unsupported");
1431 i
= identify_info
[83] & (1<<9);
1432 simplelist_addline(SIMPLELIST_ADD_LINE
,
1433 "Noise mgmt: %s", i
? "enabled" : "unsupported");
1434 i
= identify_info
[82] & (1<<6);
1435 simplelist_addline(SIMPLELIST_ADD_LINE
,
1436 "Read-ahead: %s", i
? "enabled" : "unsupported");
1437 timing_info_present
= identify_info
[53] & (1<<1);
1438 if(timing_info_present
) {
1439 char pio3
[2], pio4
[2];pio3
[1] = 0;
1441 pio3
[0] = (identify_info
[64] & (1<<0)) ? '3' : 0;
1442 pio4
[0] = (identify_info
[64] & (1<<1)) ? '4' : 0;
1443 simplelist_addline(SIMPLELIST_ADD_LINE
,
1444 "PIO modes: 0 1 2 %s %s", pio3
, pio4
);
1447 simplelist_addline(SIMPLELIST_ADD_LINE
,
1448 "No PIO mode info");
1450 timing_info_present
= identify_info
[53] & (1<<1);
1451 if(timing_info_present
) {
1452 simplelist_addline(SIMPLELIST_ADD_LINE
,
1453 "Cycle times %dns/%dns",
1455 identify_info
[68] );
1457 simplelist_addline(SIMPLELIST_ADD_LINE
,
1460 int sector_size
= 512;
1461 if((identify_info
[106] & 0xe000) == 0x6000)
1462 sector_size
*= BIT_N(identify_info
[106] & 0x000f);
1463 simplelist_addline(SIMPLELIST_ADD_LINE
,
1464 "Physical sector size: %d", sector_size
);
1466 if (identify_info
[63] & (1<<0)) {
1467 char mdma0
[2], mdma1
[2], mdma2
[2];
1468 mdma0
[1] = mdma1
[1] = mdma2
[1] = 0;
1469 mdma0
[0] = (identify_info
[63] & (1<<0)) ? '0' : 0;
1470 mdma1
[0] = (identify_info
[63] & (1<<1)) ? '1' : 0;
1471 mdma2
[0] = (identify_info
[63] & (1<<2)) ? '2' : 0;
1472 simplelist_addline(SIMPLELIST_ADD_LINE
,
1473 "MDMA modes: %s %s %s", mdma0
, mdma1
, mdma2
);
1474 simplelist_addline(SIMPLELIST_ADD_LINE
,
1475 "MDMA Cycle times %dns/%dns",
1477 identify_info
[66] );
1480 simplelist_addline(SIMPLELIST_ADD_LINE
,
1481 "No MDMA mode info");
1483 if (identify_info
[53] & (1<<2)) {
1484 char udma0
[2], udma1
[2], udma2
[2], udma3
[2], udma4
[2], udma5
[2], udma6
[2];
1485 udma0
[1] = udma1
[1] = udma2
[1] = udma3
[1] = udma4
[1] = udma5
[1] = udma6
[1] = 0;
1486 udma0
[0] = (identify_info
[88] & (1<<0)) ? '0' : 0;
1487 udma1
[0] = (identify_info
[88] & (1<<1)) ? '1' : 0;
1488 udma2
[0] = (identify_info
[88] & (1<<2)) ? '2' : 0;
1489 udma3
[0] = (identify_info
[88] & (1<<3)) ? '3' : 0;
1490 udma4
[0] = (identify_info
[88] & (1<<4)) ? '4' : 0;
1491 udma5
[0] = (identify_info
[88] & (1<<5)) ? '5' : 0;
1492 udma6
[0] = (identify_info
[88] & (1<<6)) ? '6' : 0;
1493 simplelist_addline(SIMPLELIST_ADD_LINE
,
1494 "UDMA modes: %s %s %s %s %s %s %s", udma0
, udma1
, udma2
,
1495 udma3
, udma4
, udma5
, udma6
);
1498 simplelist_addline(SIMPLELIST_ADD_LINE
,
1499 "No UDMA mode info");
1501 #endif /* HAVE_ATA_DMA */
1502 timing_info_present
= identify_info
[53] & (1<<1);
1503 if(timing_info_present
) {
1504 i
= identify_info
[49] & (1<<11);
1505 simplelist_addline(SIMPLELIST_ADD_LINE
,
1506 "IORDY support: %s", i
? "yes" : "no");
1507 i
= identify_info
[49] & (1<<10);
1508 simplelist_addline(SIMPLELIST_ADD_LINE
,
1509 "IORDY disable: %s", i
? "yes" : "no");
1511 simplelist_addline(SIMPLELIST_ADD_LINE
,
1514 simplelist_addline(SIMPLELIST_ADD_LINE
,
1515 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
1517 i
= ata_get_dma_mode();
1519 simplelist_addline(SIMPLELIST_ADD_LINE
,
1522 simplelist_addline(SIMPLELIST_ADD_LINE
,
1524 (i
& 0x40) ? "UDMA" : "MDMA",
1527 #endif /* HAVE_ATA_DMA */
1530 #else /* No SD, MMC or ATA */
1531 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1534 struct storage_info info
;
1535 storage_get_info(0,&info
);
1536 simplelist_addline(SIMPLELIST_ADD_LINE
, "Vendor: %s", info
.vendor
);
1537 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", info
.product
);
1538 simplelist_addline(SIMPLELIST_ADD_LINE
, "Firmware: %s", info
.revision
);
1539 simplelist_addline(SIMPLELIST_ADD_LINE
,
1540 "Size: %ld MB", info
.num_sectors
*(info
.sector_size
/512)/2024);
1542 fat_size( IF_MV2(0,) NULL
, &free
);
1543 simplelist_addline(SIMPLELIST_ADD_LINE
,
1544 "Free: %ld MB", free
/ 1024);
1545 simplelist_addline(SIMPLELIST_ADD_LINE
,
1546 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
1551 #if (CONFIG_STORAGE & STORAGE_ATA)
1552 static bool dbg_identify_info(void)
1554 int fd
= creat("/identify_info.bin", 0666);
1557 #ifdef ROCKBOX_LITTLE_ENDIAN
1558 ecwrite(fd
, ata_get_identify(), SECTOR_SIZE
/2, "s", true);
1560 write(fd
, ata_get_identify(), SECTOR_SIZE
);
1568 static bool dbg_disk_info(void)
1570 struct simplelist_info info
;
1571 simplelist_info_init(&info
, "Disk Info", 1, NULL
);
1572 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
1575 info
.callback_data
= (void*)&card
;
1578 info
.action_callback
= disk_callback
;
1579 info
.hide_selection
= true;
1580 info
.scroll_all
= true;
1581 return simplelist_show_list(&info
);
1583 #endif /* PLATFORM_NATIVE */
1585 #ifdef HAVE_DIRCACHE
1586 static int dircache_callback(int btn
, struct gui_synclist
*lists
)
1589 simplelist_set_line_count(0);
1590 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache initialized: %s",
1591 dircache_is_enabled() ? "Yes" : "No");
1592 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache size: %d B",
1593 dircache_get_cache_size());
1594 simplelist_addline(SIMPLELIST_ADD_LINE
, "Last size: %d B",
1595 global_status
.dircache_size
);
1596 simplelist_addline(SIMPLELIST_ADD_LINE
, "Limit: %d B",
1598 simplelist_addline(SIMPLELIST_ADD_LINE
, "Reserve: %d/%d B",
1599 dircache_get_reserve_used(), DIRCACHE_RESERVE
);
1600 simplelist_addline(SIMPLELIST_ADD_LINE
, "Scanning took: %d s",
1601 dircache_get_build_ticks() / HZ
);
1602 simplelist_addline(SIMPLELIST_ADD_LINE
, "Entry count: %d",
1603 dircache_get_entry_count());
1607 static bool dbg_dircache_info(void)
1609 struct simplelist_info info
;
1610 simplelist_info_init(&info
, "Dircache Info", 7, NULL
);
1611 info
.action_callback
= dircache_callback
;
1612 info
.hide_selection
= true;
1613 info
.scroll_all
= true;
1614 return simplelist_show_list(&info
);
1617 #endif /* HAVE_DIRCACHE */
1619 #ifdef HAVE_TAGCACHE
1620 static int database_callback(int btn
, struct gui_synclist
*lists
)
1623 struct tagcache_stat
*stat
= tagcache_get_stat();
1624 static bool synced
= false;
1626 simplelist_set_line_count(0);
1628 simplelist_addline(SIMPLELIST_ADD_LINE
, "Initialized: %s",
1629 stat
->initialized
? "Yes" : "No");
1630 simplelist_addline(SIMPLELIST_ADD_LINE
, "DB Ready: %s",
1631 stat
->ready
? "Yes" : "No");
1632 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM Cache: %s",
1633 stat
->ramcache
? "Yes" : "No");
1634 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM: %d/%d B",
1635 stat
->ramcache_used
, stat
->ramcache_allocated
);
1636 simplelist_addline(SIMPLELIST_ADD_LINE
, "Progress: %d%% (%d entries)",
1637 stat
->progress
, stat
->processed_entries
);
1638 simplelist_addline(SIMPLELIST_ADD_LINE
, "Curfile: %s",
1639 stat
->curentry
? stat
->curentry
: "---");
1640 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit step: %d",
1642 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit delayed: %s",
1643 stat
->commit_delayed
? "Yes" : "No");
1645 simplelist_addline(SIMPLELIST_ADD_LINE
, "Queue length: %d",
1646 stat
->queue_length
);
1651 tagcache_screensync_event();
1654 if (!btn
&& stat
->curentry
)
1657 return ACTION_REDRAW
;
1660 if (btn
== ACTION_STD_CANCEL
)
1661 tagcache_screensync_enable(false);
1665 static bool dbg_tagcache_info(void)
1667 struct simplelist_info info
;
1668 simplelist_info_init(&info
, "Database Info", 8, NULL
);
1669 info
.action_callback
= database_callback
;
1670 info
.hide_selection
= true;
1671 info
.scroll_all
= true;
1673 /* Don't do nonblock here, must give enough processing time
1674 for tagcache thread. */
1675 /* info.timeout = TIMEOUT_NOBLOCK; */
1677 tagcache_screensync_enable(true);
1678 return simplelist_show_list(&info
);
1682 #if CONFIG_CPU == SH7034
1683 static bool dbg_save_roms(void)
1686 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
1688 fd
= creat("/internal_rom_0000-FFFF.bin", 0666);
1691 write(fd
, (void *)0, 0x10000);
1695 fd
= creat("/internal_rom_2000000-203FFFF.bin", 0666);
1698 write(fd
, (void *)0x2000000, 0x40000);
1702 system_memory_guard(oldmode
);
1705 #elif defined CPU_COLDFIRE
1706 static bool dbg_save_roms(void)
1709 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
1711 #if defined(IRIVER_H100_SERIES)
1712 fd
= creat("/internal_rom_000000-1FFFFF.bin", 0666);
1713 #elif defined(IRIVER_H300_SERIES)
1714 fd
= creat("/internal_rom_000000-3FFFFF.bin", 0666);
1715 #elif defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IAUDIO_M3)
1716 fd
= creat("/internal_rom_000000-3FFFFF.bin", 0666);
1717 #elif defined(MPIO_HD200) || defined(MPIO_HD300)
1718 fd
= creat("/internal_rom_000000-1FFFFF.bin", 0666);
1722 write(fd
, (void *)0, FLASH_SIZE
);
1725 system_memory_guard(oldmode
);
1728 fd
= creat("/internal_eeprom.bin", 0666);
1732 char buf
[EEPROM_SIZE
];
1735 old_irq_level
= disable_irq_save();
1737 err
= eeprom_24cxx_read(0, buf
, sizeof buf
);
1739 restore_irq(old_irq_level
);
1742 splashf(HZ
*3, "Eeprom read failure (%d)", err
);
1745 write(fd
, buf
, sizeof buf
);
1754 #elif defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD)
1755 static bool dbg_save_roms(void)
1757 int fd
= creat("/internal_rom_000000-0FFFFF.bin", 0666);
1760 write(fd
, (void *)0x20000000, FLASH_SIZE
);
1766 #elif CONFIG_CPU == IMX31L
1767 bool __dbg_dvfs_dptc(void);
1768 static bool dbg_save_roms(void)
1770 int fd
= creat("/flash_rom_A0000000-A01FFFFF.bin", 0666);
1773 write(fd
, (void*)0xa0000000, FLASH_SIZE
);
1779 #elif defined(CPU_TCC780X)
1780 static bool dbg_save_roms(void)
1782 int fd
= creat("/eeprom_E0000000-E0001FFF.bin", 0666);
1785 write(fd
, (void*)0xe0000000, 0x2000);
1796 #ifdef CONFIG_TUNER_MULTI
1797 static int tuner_type
= 0;
1798 #define IF_TUNER_TYPE(type) if(tuner_type==type)
1800 #define IF_TUNER_TYPE(type)
1803 static int radio_callback(int btn
, struct gui_synclist
*lists
)
1806 if (btn
== ACTION_STD_CANCEL
)
1808 simplelist_set_line_count(1);
1810 #if (CONFIG_TUNER & LV24020LP)
1811 simplelist_addline(SIMPLELIST_ADD_LINE
,
1812 "CTRL_STAT: %02X", lv24020lp_get(LV24020LP_CTRL_STAT
) );
1813 simplelist_addline(SIMPLELIST_ADD_LINE
,
1814 "RADIO_STAT: %02X", lv24020lp_get(LV24020LP_REG_STAT
) );
1815 simplelist_addline(SIMPLELIST_ADD_LINE
,
1816 "MSS_FM: %d kHz", lv24020lp_get(LV24020LP_MSS_FM
) );
1817 simplelist_addline(SIMPLELIST_ADD_LINE
,
1818 "MSS_IF: %d Hz", lv24020lp_get(LV24020LP_MSS_IF
) );
1819 simplelist_addline(SIMPLELIST_ADD_LINE
,
1820 "MSS_SD: %d Hz", lv24020lp_get(LV24020LP_MSS_SD
) );
1821 simplelist_addline(SIMPLELIST_ADD_LINE
,
1822 "if_set: %d Hz", lv24020lp_get(LV24020LP_IF_SET
) );
1823 simplelist_addline(SIMPLELIST_ADD_LINE
,
1824 "sd_set: %d Hz", lv24020lp_get(LV24020LP_SD_SET
) );
1825 #endif /* LV24020LP */
1826 #if (CONFIG_TUNER & S1A0903X01)
1827 simplelist_addline(SIMPLELIST_ADD_LINE
,
1828 "Samsung regs: %08X", s1a0903x01_get(RADIO_ALL
));
1829 /* This one doesn't return dynamic data atm */
1830 #endif /* S1A0903X01 */
1831 #if (CONFIG_TUNER & TEA5767)
1832 struct tea5767_dbg_info nfo
;
1833 tea5767_dbg_info(&nfo
);
1834 simplelist_addline(SIMPLELIST_ADD_LINE
, "Philips regs:");
1835 simplelist_addline(SIMPLELIST_ADD_LINE
,
1836 " Read: %02X %02X %02X %02X %02X",
1837 (unsigned)nfo
.read_regs
[0], (unsigned)nfo
.read_regs
[1],
1838 (unsigned)nfo
.read_regs
[2], (unsigned)nfo
.read_regs
[3],
1839 (unsigned)nfo
.read_regs
[4]);
1840 simplelist_addline(SIMPLELIST_ADD_LINE
,
1841 " Write: %02X %02X %02X %02X %02X",
1842 (unsigned)nfo
.write_regs
[0], (unsigned)nfo
.write_regs
[1],
1843 (unsigned)nfo
.write_regs
[2], (unsigned)nfo
.write_regs
[3],
1844 (unsigned)nfo
.write_regs
[4]);
1845 #endif /* TEA5767 */
1846 #if (CONFIG_TUNER & SI4700)
1847 IF_TUNER_TYPE(SI4700
)
1849 struct si4700_dbg_info nfo
;
1850 si4700_dbg_info(&nfo
);
1851 simplelist_addline(SIMPLELIST_ADD_LINE
, "SI4700 regs:");
1852 for (int i
= 0; i
< 16; i
+= 4) {
1853 simplelist_addline(SIMPLELIST_ADD_LINE
,"%02X: %04X %04X %04X %04X",
1854 i
, nfo
.regs
[i
], nfo
.regs
[i
+1], nfo
.regs
[i
+2], nfo
.regs
[i
+3]);
1858 #if (CONFIG_TUNER & RDA5802)
1859 IF_TUNER_TYPE(RDA5802
)
1861 struct rda5802_dbg_info nfo
;
1862 rda5802_dbg_info(&nfo
);
1863 simplelist_addline(SIMPLELIST_ADD_LINE
, "RDA5802 regs:");
1864 for (int i
= 0; i
< 16; i
+= 4) {
1865 simplelist_addline(SIMPLELIST_ADD_LINE
,"%02X: %04X %04X %04X %04X",
1866 i
, nfo
.regs
[i
], nfo
.regs
[i
+1], nfo
.regs
[i
+2], nfo
.regs
[i
+3]);
1869 #endif /* RDA55802 */
1872 simplelist_addline(SIMPLELIST_ADD_LINE
, "PI:%04X PS:'%8s'",
1873 rds_get_pi(), rds_get_ps());
1874 simplelist_addline(SIMPLELIST_ADD_LINE
, "RT:%s",
1876 time_t seconds
= rds_get_ct();
1877 struct tm
* time
= gmtime(&seconds
);
1878 simplelist_addline(SIMPLELIST_ADD_LINE
,
1879 "CT:%4d-%02d-%02d %02d:%02d",
1880 time
->tm_year
+ 1900, time
->tm_mon
+ 1, time
->tm_mday
,
1881 time
->tm_hour
, time
->tm_min
, time
->tm_sec
);
1883 return ACTION_REDRAW
;
1885 static bool dbg_fm_radio(void)
1887 struct simplelist_info info
;
1888 #ifdef CONFIG_TUNER_MULTI
1889 tuner_type
= tuner_detect_type();
1891 info
.scroll_all
= true;
1892 simplelist_info_init(&info
, "FM Radio", 1, NULL
);
1893 simplelist_set_line_count(0);
1894 simplelist_addline(SIMPLELIST_ADD_LINE
, "HW detected: %s",
1895 radio_hardware_present() ? "yes" : "no");
1897 info
.action_callback
= radio_hardware_present()?radio_callback
: NULL
;
1898 info
.hide_selection
= true;
1899 return simplelist_show_list(&info
);
1901 #endif /* CONFIG_TUNER */
1902 #endif /* !SIMULATOR */
1904 #if defined(HAVE_LCD_BITMAP) && !defined(APPLICATION)
1905 extern bool do_screendump_instead_of_usb
;
1907 static bool dbg_screendump(void)
1909 do_screendump_instead_of_usb
= !do_screendump_instead_of_usb
;
1910 splashf(HZ
, "Screendump %sabled", do_screendump_instead_of_usb
?"en":"dis");
1913 #endif /* HAVE_LCD_BITMAP */
1915 extern bool write_metadata_log
;
1917 static bool dbg_metadatalog(void)
1919 write_metadata_log
= !write_metadata_log
;
1920 splashf(HZ
, "Metadata log %sabled", write_metadata_log
? "en" : "dis");
1924 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
1925 static bool dbg_set_memory_guard(void)
1927 static const struct opt_items names
[MAXMEMGUARD
] = {
1929 { "Flash ROM writes", -1 },
1930 { "Zero area (all)", -1 }
1932 int mode
= system_memory_guard(MEMGUARD_KEEP
);
1934 set_option( "Catch mem accesses", &mode
, INT
, names
, MAXMEMGUARD
, NULL
);
1935 system_memory_guard(mode
);
1939 #endif /* CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) */
1941 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
1942 static bool dbg_write_eeprom(void)
1944 int fd
= open("/internal_eeprom.bin", O_RDONLY
);
1948 char buf
[EEPROM_SIZE
];
1949 int rc
= read(fd
, buf
, EEPROM_SIZE
);
1951 if(rc
== EEPROM_SIZE
)
1953 int old_irq_level
= disable_irq_save();
1955 int err
= eeprom_24cxx_write(0, buf
, sizeof buf
);
1957 splashf(HZ
*3, "Eeprom write failure (%d)", err
);
1959 splash(HZ
*3, "Eeprom written successfully");
1961 restore_irq(old_irq_level
);
1965 splashf(HZ
*3, "File read error (%d)",rc
);
1971 splash(HZ
*3, "Failed to open 'internal_eeprom.bin'");
1976 #endif /* defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS) */
1977 #ifdef CPU_BOOST_LOGGING
1978 static bool cpu_boost_log(void)
1980 int count
= cpu_boost_log_getcount();
1981 char *str
= cpu_boost_log_getlog_first();
1983 lcd_setfont(FONT_SYSFIXED
);
1984 for (int i
= 0; i
< count
;)
1986 lcd_clear_display();
1987 for(int j
=0; j
<LCD_HEIGHT
/SYSFONT_HEIGHT
; j
++,i
++)
1990 str
= cpu_boost_log_getlog_next();
1993 if(strlen(str
) > LCD_WIDTH
/SYSFONT_WIDTH
)
1994 lcd_puts_scroll(0, j
, str
);
2004 switch(get_action(CONTEXT_STD
,TIMEOUT_BLOCK
))
2007 case ACTION_STD_PREV
:
2008 case ACTION_STD_NEXT
:
2011 case ACTION_STD_CANCEL
:
2019 get_action(CONTEXT_STD
,TIMEOUT_BLOCK
);
2020 lcd_setfont(FONT_UI
);
2025 #if (defined(HAVE_WHEEL_ACCELERATION) && (CONFIG_KEYPAD==IPOD_4G_PAD) \
2026 && !defined(IPOD_MINI) && !defined(SIMULATOR))
2027 extern bool wheel_is_touched
;
2028 extern int old_wheel_value
;
2029 extern int new_wheel_value
;
2030 extern int wheel_delta
;
2031 extern unsigned int accumulated_wheel_delta
;
2032 extern unsigned int wheel_velocity
;
2034 static bool dbg_scrollwheel(void)
2036 lcd_setfont(FONT_SYSFIXED
);
2040 if (action_userabort(HZ
/10))
2043 lcd_clear_display();
2045 /* show internal variables of scrollwheel driver */
2046 lcd_putsf(0, 0, "wheel touched: %s", (wheel_is_touched
) ? "true" : "false");
2047 lcd_putsf(0, 1, "new position: %2d", new_wheel_value
);
2048 lcd_putsf(0, 2, "old position: %2d", old_wheel_value
);
2049 lcd_putsf(0, 3, "wheel delta: %2d", wheel_delta
);
2050 lcd_putsf(0, 4, "accumulated delta: %2d", accumulated_wheel_delta
);
2051 lcd_putsf(0, 5, "velo [deg/s]: %4d", (int)wheel_velocity
);
2053 /* show effective accelerated scrollspeed */
2054 lcd_putsf(0, 6, "accel. speed: %4d",
2055 button_apply_acceleration((1<<31)|(1<<24)|wheel_velocity
) );
2059 lcd_setfont(FONT_UI
);
2064 #ifdef HAVE_USBSTACK
2065 #if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL)
2066 static bool toggle_usb_serial(void)
2068 bool enabled
= !usb_core_driver_enabled(USB_DRIVER_SERIAL
);
2070 usb_core_enable_driver(USB_DRIVER_SERIAL
, enabled
);
2071 splashf(HZ
, "USB Serial %sabled", enabled
? "en" : "dis");
2078 #if CONFIG_USBOTG == USBOTG_ISP1583
2079 extern int dbg_usb_num_items(void);
2080 extern const char* dbg_usb_item(int selected_item
, void *data
,
2081 char *buffer
, size_t buffer_len
);
2083 static int isp1583_action_callback(int action
, struct gui_synclist
*lists
)
2086 if (action
== ACTION_NONE
)
2087 action
= ACTION_REDRAW
;
2091 static bool dbg_isp1583(void)
2093 struct simplelist_info isp1583
;
2094 isp1583
.scroll_all
= true;
2095 simplelist_info_init(&isp1583
, "ISP1583", dbg_usb_num_items(), NULL
);
2096 isp1583
.timeout
= HZ
/100;
2097 isp1583
.hide_selection
= true;
2098 isp1583
.get_name
= dbg_usb_item
;
2099 isp1583
.action_callback
= isp1583_action_callback
;
2100 return simplelist_show_list(&isp1583
);
2104 #if defined(CREATIVE_ZVx) && !defined(SIMULATOR)
2105 extern int pic_dbg_num_items(void);
2106 extern const char* pic_dbg_item(int selected_item
, void *data
,
2107 char *buffer
, size_t buffer_len
);
2109 static int pic_action_callback(int action
, struct gui_synclist
*lists
)
2112 if (action
== ACTION_NONE
)
2113 action
= ACTION_REDRAW
;
2117 static bool dbg_pic(void)
2119 struct simplelist_info pic
;
2120 pic
.scroll_all
= true;
2121 simplelist_info_init(&pic
, "PIC", pic_dbg_num_items(), NULL
);
2122 pic
.timeout
= HZ
/100;
2123 pic
.hide_selection
= true;
2124 pic
.get_name
= pic_dbg_item
;
2125 pic
.action_callback
= pic_action_callback
;
2126 return simplelist_show_list(&pic
);
2131 /****** The menu *********/
2132 static const struct {
2133 unsigned char *desc
; /* string or ID */
2134 bool (*function
) (void); /* return true if USB was connected */
2136 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || \
2137 (defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD)) || \
2138 CONFIG_CPU == IMX31L || defined(CPU_TCC780X)
2139 { "Dump ROM contents", dbg_save_roms
},
2141 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || defined(CPU_PP) \
2142 || CONFIG_CPU == S3C2440 || CONFIG_CPU == IMX31L || CONFIG_CPU == AS3525 \
2143 || CONFIG_CPU == DM320 || defined(CPU_S5L870X) || CONFIG_CPU == AS3525v2 \
2144 || CONFIG_CPU == RK27XX
2145 { "View I/O ports", dbg_ports
},
2147 #if (CONFIG_RTC == RTC_PCF50605) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
2148 { "View PCF registers", dbg_pcf
},
2150 #if defined(HAVE_TSC2100) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
2151 { "TSC2100 debug", tsc2100_debug
},
2153 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
2154 { "CPU frequency", dbg_cpufreq
},
2156 #if CONFIG_CPU == IMX31L
2157 { "DVFS/DPTC", __dbg_dvfs_dptc
},
2159 #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR)
2160 { "S/PDIF analyzer", dbg_spdif
},
2162 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2163 { "Catch mem accesses", dbg_set_memory_guard
},
2165 { "View OS stacks", dbg_os
},
2167 { "View CPU stats", dbg_cpuinfo
},
2169 #ifdef HAVE_LCD_BITMAP
2170 #if (CONFIG_BATTERY_MEASURE != 0) && !defined(SIMULATOR)
2171 { "View battery", view_battery
},
2174 { "Screendump", dbg_screendump
},
2177 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
2178 { "View HW info", dbg_hw_info
},
2180 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
2181 { "View partitions", dbg_partitions
},
2183 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
2184 { "View disk info", dbg_disk_info
},
2185 #if (CONFIG_STORAGE & STORAGE_ATA)
2186 { "Dump ATA identify info", dbg_identify_info
},
2189 { "Metadata log", dbg_metadatalog
},
2190 #ifdef HAVE_DIRCACHE
2191 { "View dircache info", dbg_dircache_info
},
2193 #ifdef HAVE_TAGCACHE
2194 { "View database info", dbg_tagcache_info
},
2196 #ifdef HAVE_LCD_BITMAP
2197 #if CONFIG_CODEC == SWCODEC
2198 { "View buffering thread", dbg_buffering_thread
},
2199 #elif !defined(SIMULATOR)
2200 { "View audio thread", dbg_audio_thread
},
2203 { "pm histogram", peak_meter_histogram
},
2204 #endif /* PM_DEBUG */
2205 #endif /* HAVE_LCD_BITMAP */
2206 { "View buflib allocs", dbg_buflib_allocs
},
2209 { "FM Radio", dbg_fm_radio
},
2212 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2213 { "Write back EEPROM", dbg_write_eeprom
},
2215 #if CONFIG_USBOTG == USBOTG_ISP1583
2216 { "View ISP1583 info", dbg_isp1583
},
2218 #if defined(CREATIVE_ZVx) && !defined(SIMULATOR)
2219 { "View PIC info", dbg_pic
},
2221 #ifdef ROCKBOX_HAS_LOGF
2222 {"Show Log File", logfdisplay
},
2223 {"Dump Log File", logfdump
},
2225 #if defined(HAVE_USBSTACK)
2226 #if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL)
2227 {"USB Serial driver (logf)", toggle_usb_serial
},
2229 #endif /* HAVE_USBSTACK */
2230 #ifdef CPU_BOOST_LOGGING
2231 {"cpu_boost log",cpu_boost_log
},
2233 #if (defined(HAVE_WHEEL_ACCELERATION) && (CONFIG_KEYPAD==IPOD_4G_PAD) \
2234 && !defined(IPOD_MINI) && !defined(SIMULATOR))
2235 {"Debug scrollwheel", dbg_scrollwheel
},
2239 static int menu_action_callback(int btn
, struct gui_synclist
*lists
)
2241 int selection
= gui_synclist_get_sel_pos(lists
);
2242 if (btn
== ACTION_STD_OK
)
2245 viewportmanager_theme_enable(i
, false, NULL
);
2246 menuitems
[selection
].function();
2247 btn
= ACTION_REDRAW
;
2249 viewportmanager_theme_undo(i
, false);
2251 else if (btn
== ACTION_STD_CONTEXT
)
2253 MENUITEM_STRINGLIST(menu_items
, "Debug Menu", NULL
, ID2P(LANG_ADD_TO_FAVES
));
2254 if (do_menu(&menu_items
, NULL
, NULL
, false) == 0)
2255 shortcuts_add(SHORTCUT_DEBUGITEM
, menuitems
[selection
].desc
);
2256 return ACTION_STD_CANCEL
;
2261 static const char* menu_get_name(int item
, void * data
,
2262 char *buffer
, size_t buffer_len
)
2264 (void)data
; (void)buffer
; (void)buffer_len
;
2265 return menuitems
[item
].desc
;
2268 bool debug_menu(void)
2270 struct simplelist_info info
;
2272 simplelist_info_init(&info
, "Debug Menu", ARRAYLEN(menuitems
), NULL
);
2273 info
.action_callback
= menu_action_callback
;
2274 info
.get_name
= menu_get_name
;
2275 return simplelist_show_list(&info
);
2278 bool run_debug_screen(char* screen
)
2280 for (unsigned i
=0; i
<ARRAYLEN(menuitems
); i
++)
2281 if (!strcmp(screen
, menuitems
[i
].desc
))
2284 viewportmanager_theme_enable(j
, false, NULL
);
2285 menuitems
[i
].function();
2287 viewportmanager_theme_undo(j
, false);