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 #include "lcd-remote.h"
58 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
66 #include "eeprom_24cxx.h"
67 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
70 #if (CONFIG_STORAGE & STORAGE_ATA)
79 #ifdef HAVE_LCD_BITMAP
80 #include "scrollbar.h"
81 #include "peakmeter.h"
84 #include "core_alloc.h"
85 #if CONFIG_CODEC == SWCODEC
87 #include "buffering.h"
89 #if defined(HAVE_SPDIF_OUT) || defined(HAVE_SPDIF_IN)
93 #ifdef IRIVER_H300_SERIES
94 #include "pcf50606.h" /* for pcf50606_read */
101 #if CONFIG_RTC == RTC_PCF50605
102 #include "pcf50605.h"
104 #include "appevents.h"
105 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
106 #include "debug-target.h"
109 #if defined(SANSA_E200) || defined(SANSA_C200) || defined(PHILIPS_SA9200) \
110 || (CONFIG_CPU == AS3525 && defined(CONFIG_CHARGING)) \
111 || CONFIG_CPU == AS3525v2
117 #include "pmu-target.h"
121 #include "usb_core.h"
124 #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
= cpufrequency_linux(cpu
);
289 int freq2
= scalingfrequency_linux(cpu
);
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 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 (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
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_PLATFORM & PLATFORM_NATIVE)
904 #ifdef HAVE_LCD_BITMAP
906 * view_battery() shows a automatically scaled graph of the battery voltage
907 * over time. Usable for estimating battery life / charging rate.
908 * The power_history array is updated in power_thread of powermgmt.c.
911 #define BAT_LAST_VAL MIN(LCD_WIDTH, POWER_HISTORY_LEN)
912 #define BAT_YSPACE (LCD_HEIGHT - 20)
915 static bool view_battery(void)
918 int i
, x
, y
, 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 /* adjust grid scale */
939 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,
952 while ((y
= (minv
- (minv
% grid
)+i
*grid
)) < maxv
)
954 graph
= ((y
-minv
)*BAT_YSPACE
)/(maxv
-minv
);
955 graph
= LCD_HEIGHT
-1 - graph
;
957 /* draw dotted horizontal grid line */
958 for (x
=0; x
<LCD_WIDTH
;x
=x
+2)
959 lcd_drawpixel(x
,graph
);
965 /* draw plot of power history
968 for (i
= BAT_LAST_VAL
- 1; i
> 0; i
--)
970 if (power_history
[i
] && power_history
[i
-1])
972 y1
= (power_history
[i
] - minv
) * BAT_YSPACE
/
974 y1
= MIN(MAX(LCD_HEIGHT
-1 - y1
, 20),
976 y2
= (power_history
[i
-1] - minv
) * BAT_YSPACE
/
978 y2
= MIN(MAX(LCD_HEIGHT
-1 - y2
, 20),
981 lcd_set_drawmode(DRMODE_SOLID
);
983 /* make line thicker */
984 lcd_drawline(((x
*LCD_WIDTH
)/(BAT_LAST_VAL
)),
986 (((x
+1)*LCD_WIDTH
)/(BAT_LAST_VAL
)),
988 lcd_drawline(((x
*LCD_WIDTH
)/(BAT_LAST_VAL
))+1,
990 (((x
+1)*LCD_WIDTH
)/(BAT_LAST_VAL
))+1,
997 case 1: /* status: */
998 #if CONFIG_CHARGING >= CHARGING_MONITOR
999 lcd_putsf(0, 0, "Pwr status: %s",
1000 charging_state() ? "charging" : "discharging");
1002 lcd_puts(0, 0, "Power status:");
1004 battery_read_info(&y
, NULL
);
1005 lcd_putsf(0, 1, "Battery: %d.%03d V", y
/ 1000, y
% 1000);
1006 #ifdef ADC_EXT_POWER
1007 y
= (adc_read(ADC_EXT_POWER
) * EXT_SCALE_FACTOR
) / 1000;
1008 lcd_putsf(0, 2, "External: %d.%03d V", y
/ 1000, y
% 1000);
1011 #if defined ARCHOS_RECORDER
1012 lcd_putsf(0, 3, "Chgr: %s %s",
1013 charger_inserted() ? "present" : "absent",
1014 charger_enabled() ? "on" : "off");
1015 lcd_putsf(0, 5, "short delta: %d", short_delta
);
1016 lcd_putsf(0, 6, "long delta: %d", long_delta
);
1017 lcd_puts(0, 7, power_message
);
1018 lcd_putsf(0, 8, "USB Inserted: %s",
1019 usb_inserted() ? "yes" : "no");
1020 #elif defined IPOD_NANO || defined IPOD_VIDEO
1021 int usb_pwr
= (GPIOL_INPUT_VAL
& 0x10)?true:false;
1022 int ext_pwr
= (GPIOL_INPUT_VAL
& 0x08)?false:true;
1023 int dock
= (GPIOA_INPUT_VAL
& 0x10)?true:false;
1024 int charging
= (GPIOB_INPUT_VAL
& 0x01)?false:true;
1025 int headphone
= (GPIOA_INPUT_VAL
& 0x80)?true:false;
1027 lcd_putsf(0, 3, "USB pwr: %s",
1028 usb_pwr
? "present" : "absent");
1029 lcd_putsf(0, 4, "EXT pwr: %s",
1030 ext_pwr
? "present" : "absent");
1031 lcd_putsf(0, 5, "Battery: %s",
1032 charging
? "charging" : (usb_pwr
||ext_pwr
) ? "charged" : "discharging");
1033 lcd_putsf(0, 6, "Dock mode: %s",
1034 dock
? "enabled" : "disabled");
1035 lcd_putsf(0, 7, "Headphone: %s",
1036 headphone
? "connected" : "disconnected");
1038 if(probed_ramsize
== 64)
1039 x
= (adc_read(ADC_4066_ISTAT
) * 2400) / (1024 * 2);
1042 x
= (adc_read(ADC_4066_ISTAT
) * 2400) / (1024 * 3);
1043 lcd_putsf(0, 8, "Ibat: %d mA", x
);
1044 lcd_putsf(0, 9, "Vbat * Ibat: %d mW", x
* y
/ 1000);
1045 #elif defined TOSHIBA_GIGABEAT_S
1049 static const unsigned char * const chrgstate_strings
[] =
1060 lcd_putsf(0, line
++, "Charger: %s",
1061 charger_inserted() ? "present" : "absent");
1063 st
= power_input_status() &
1064 (POWER_INPUT_CHARGER
| POWER_INPUT_BATTERY
);
1065 lcd_putsf(0, line
++, "%s%s",
1066 (st
& POWER_INPUT_MAIN_CHARGER
) ? " Main" : "",
1067 (st
& POWER_INPUT_USB_CHARGER
) ? " USB" : "");
1069 y
= ARRAYLEN(chrgstate_strings
) - 1;
1071 switch (charge_state
)
1073 case CHARGE_STATE_DISABLED
: y
--;
1074 case CHARGE_STATE_ERROR
: y
--;
1075 case DISCHARGING
: y
--;
1082 lcd_putsf(0, line
++, "State: %s", chrgstate_strings
[y
]);
1084 lcd_putsf(0, line
++, "Battery Switch: %s",
1085 (st
& POWER_INPUT_BATTERY
) ? "On" : "Off");
1087 y
= chrgraw_adc_voltage();
1088 lcd_putsf(0, line
++, "CHRGRAW: %d.%03d V",
1089 y
/ 1000, y
% 1000);
1091 y
= application_supply_adc_voltage();
1092 lcd_putsf(0, line
++, "BP : %d.%03d V",
1093 y
/ 1000, y
% 1000);
1095 y
= battery_adc_charge_current();
1096 if (y
< 0) x
= '-', y
= -y
;
1098 lcd_putsf(0, line
++, "CHRGISN:%c%d mA", x
, y
);
1100 y
= cccv_regulator_dissipation();
1101 lcd_putsf(0, line
++, "P CCCV : %d mW", y
);
1103 y
= battery_charge_current();
1104 if (y
< 0) x
= '-', y
= -y
;
1106 lcd_putsf(0, line
++, "I Charge:%c%d mA", x
, y
);
1108 y
= battery_adc_temp();
1111 lcd_putsf(0, line
++, "T Battery: %dC (%dF)", y
,
1114 /* Conversion disabled */
1115 lcd_puts(0, line
++, "T Battery: ?");
1118 #elif defined(SANSA_E200) || defined(SANSA_C200) || CONFIG_CPU == AS3525 || \
1119 CONFIG_CPU == AS3525v2
1120 static const char * const chrgstate_strings
[] =
1122 [CHARGE_STATE_DISABLED
- CHARGE_STATE_DISABLED
]= "Disabled",
1123 [CHARGE_STATE_ERROR
- CHARGE_STATE_DISABLED
] = "Error",
1124 [DISCHARGING
- CHARGE_STATE_DISABLED
] = "Discharging",
1125 [CHARGING
- CHARGE_STATE_DISABLED
] = "Charging",
1127 const char *str
= NULL
;
1129 lcd_putsf(0, 3, "Charger: %s",
1130 charger_inserted() ? "present" : "absent");
1132 y
= charge_state
- CHARGE_STATE_DISABLED
;
1133 if ((unsigned)y
< ARRAYLEN(chrgstate_strings
))
1134 str
= chrgstate_strings
[y
];
1136 lcd_putsf(0, 4, "State: %s",
1137 str
? str
: "<unknown>");
1139 lcd_putsf(0, 5, "CHARGER: %02X", ascodec_read_charger());
1140 #elif defined(IPOD_NANO2G)
1141 y
= pmu_read_battery_voltage();
1142 lcd_putsf(17, 1, "RAW: %d.%03d V", y
/ 1000, y
% 1000);
1143 y
= pmu_read_battery_current();
1144 lcd_putsf(0, 2, "Battery current: %d mA", y
);
1145 lcd_putsf(0, 3, "PWRCON: %08x %08x", PWRCON
, PWRCONEXT
);
1146 lcd_putsf(0, 4, "CLKCON: %08x %03x %03x", CLKCON
, CLKCON2
, CLKCON3
);
1147 lcd_putsf(0, 5, "PLL: %06x %06x %06x", PLL0PMS
, PLL1PMS
, PLL2PMS
);
1148 x
= pmu_read(0x1b) & 0xf;
1149 y
= pmu_read(0x1a) * 25 + 625;
1150 lcd_putsf(0, 6, "AUTO: %x / %d mV", x
, y
);
1151 x
= pmu_read(0x1f) & 0xf;
1152 y
= pmu_read(0x1e) * 25 + 625;
1153 lcd_putsf(0, 7, "DOWN1: %x / %d mV", x
, y
);
1154 x
= pmu_read(0x23) & 0xf;
1155 y
= pmu_read(0x22) * 25 + 625;
1156 lcd_putsf(0, 8, "DOWN2: %x / %d mV", x
, y
);
1157 x
= pmu_read(0x27) & 0xf;
1158 y
= pmu_read(0x26) * 100 + 900;
1159 lcd_putsf(0, 9, "MEMLDO: %x / %d mV", x
, y
);
1160 for (i
= 0; i
< 6; i
++)
1162 x
= pmu_read(0x2e + (i
<< 1)) & 0xf;
1163 y
= pmu_read(0x2d + (i
<< 1)) * 100 + 900;
1164 lcd_putsf(0, 10 + i
, "LDO%d: %x / %d mV", i
+ 1, x
, y
);
1167 lcd_putsf(0, 3, "Charger: %s",
1168 charger_inserted() ? "present" : "absent");
1169 #endif /* target type */
1170 #endif /* CONFIG_CHARGING */
1173 case 2: /* voltage deltas: */
1174 lcd_puts(0, 0, "Voltage deltas:");
1176 for (i
= 0; i
<= 6; i
++) {
1177 y
= power_history
[i
] - power_history
[i
+1];
1178 lcd_putsf(0, i
+1, "-%d min: %s%d.%03d V", i
,
1179 (y
< 0) ? "-" : "", ((y
< 0) ? y
* -1 : y
) / 1000,
1180 ((y
< 0) ? y
* -1 : y
) % 1000);
1184 case 3: /* remaining time estimation: */
1186 #ifdef ARCHOS_RECORDER
1187 lcd_putsf(0, 0, "charge_state: %d", charge_state
);
1189 lcd_putsf(0, 1, "Cycle time: %d m", powermgmt_last_cycle_startstop_min
);
1191 lcd_putsf(0, 2, "Lvl@cyc st: %d%%", powermgmt_last_cycle_level
);
1193 lcd_putsf(0, 3, "P=%2d I=%2d", pid_p
, pid_i
);
1195 lcd_putsf(0, 4, "Trickle sec: %d/60", trickle_sec
);
1196 #endif /* ARCHOS_RECORDER */
1198 lcd_putsf(0, 5, "Last PwrHist: %d.%03dV",
1199 power_history
[0] / 1000,
1200 power_history
[0] % 1000);
1202 lcd_putsf(0, 6, "battery level: %d%%", battery_level());
1204 lcd_putsf(0, 7, "Est. remain: %d m", battery_time());
1210 switch(get_action(CONTEXT_STD
,HZ
/2))
1212 case ACTION_STD_PREV
:
1217 case ACTION_STD_NEXT
:
1222 case ACTION_STD_CANCEL
:
1223 lcd_setfont(FONT_UI
);
1227 lcd_setfont(FONT_UI
);
1231 #endif /* HAVE_LCD_BITMAP */
1234 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
1235 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
1237 #if (CONFIG_STORAGE & STORAGE_MMC)
1238 #define CARDTYPE "MMC"
1239 #elif (CONFIG_STORAGE & STORAGE_SD)
1240 #define CARDTYPE "microSD"
1243 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1246 int *cardnum
= (int*)lists
->data
;
1247 unsigned char card_name
[6];
1248 unsigned char pbuf
[32];
1249 char *title
= lists
->title
;
1250 static const unsigned char i_vmin
[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
1251 static const unsigned char i_vmax
[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
1252 static const unsigned char * const kbit_units
[] = { "kBit/s", "MBit/s", "GBit/s" };
1253 static const unsigned char * const nsec_units
[] = { "ns", "µs", "ms" };
1254 #if (CONFIG_STORAGE & STORAGE_MMC)
1255 static const char * const mmc_spec_vers
[] = { "1.0-1.2", "1.4", "2.0-2.2",
1256 "3.1-3.31", "4.0" };
1259 if ((btn
== ACTION_STD_OK
) || (btn
== SYS_FS_CHANGED
) || (btn
== ACTION_REDRAW
))
1262 if (btn
== ACTION_STD_OK
)
1264 *cardnum
^= 0x1; /* change cards */
1268 simplelist_set_line_count(0);
1270 card
= card_get_info(*cardnum
);
1272 if (card
->initialized
> 0)
1275 for (i
=0; i
<sizeof(card_name
); i
++)
1277 card_name
[i
] = card_extract_bits(card
->cid
, (103-8*i
), 8);
1279 strlcpy(card_name
, card_name
, sizeof(card_name
));
1280 simplelist_addline(SIMPLELIST_ADD_LINE
,
1281 "%s Rev %d.%d", card_name
,
1282 (int) card_extract_bits(card
->cid
, 63, 4),
1283 (int) card_extract_bits(card
->cid
, 59, 4));
1284 simplelist_addline(SIMPLELIST_ADD_LINE
,
1286 #if (CONFIG_STORAGE & STORAGE_SD)
1287 (int) card_extract_bits(card
->cid
, 11, 4),
1288 (int) card_extract_bits(card
->cid
, 19, 8) + 2000
1289 #elif (CONFIG_STORAGE & STORAGE_MMC)
1290 (int) card_extract_bits(card
->cid
, 15, 4),
1291 (int) card_extract_bits(card
->cid
, 11, 4) + 1997
1294 simplelist_addline(SIMPLELIST_ADD_LINE
,
1295 #if (CONFIG_STORAGE & STORAGE_SD)
1297 card_extract_bits(card
->cid
, 55, 32)
1298 #elif (CONFIG_STORAGE & STORAGE_MMC)
1300 card_extract_bits(card
->cid
, 47, 16)
1304 simplelist_addline(SIMPLELIST_ADD_LINE
, "M=%02x, "
1305 #if (CONFIG_STORAGE & STORAGE_SD)
1307 (int) card_extract_bits(card
->cid
, 127, 8),
1308 card_extract_bits(card
->cid
, 119, 8),
1309 card_extract_bits(card
->cid
, 111, 8)
1310 #elif (CONFIG_STORAGE & STORAGE_MMC)
1312 (int) card_extract_bits(card
->cid
, 127, 8),
1313 (int) card_extract_bits(card
->cid
, 119, 16)
1317 #if (CONFIG_STORAGE & STORAGE_MMC)
1318 int temp
= card_extract_bits(card
->csd
, 125, 4);
1319 simplelist_addline(SIMPLELIST_ADD_LINE
,
1320 "MMC v%s", temp
< 5 ?
1321 mmc_spec_vers
[temp
] : "?.?");
1323 simplelist_addline(SIMPLELIST_ADD_LINE
,
1324 "Blocks: 0x%08lx", card
->numblocks
);
1325 output_dyn_value(pbuf
, sizeof pbuf
, card
->speed
/ 1000,
1327 simplelist_addline(SIMPLELIST_ADD_LINE
,
1329 output_dyn_value(pbuf
, sizeof pbuf
, card
->taac
,
1331 simplelist_addline(SIMPLELIST_ADD_LINE
,
1333 simplelist_addline(SIMPLELIST_ADD_LINE
,
1334 "Nsac: %d clk", card
->nsac
);
1335 simplelist_addline(SIMPLELIST_ADD_LINE
,
1336 "R2W: *%d", card
->r2w_factor
);
1337 #if (CONFIG_STORAGE & STORAGE_SD)
1338 int csd_structure
= card_extract_bits(card
->csd
, 127, 2);
1339 if (csd_structure
== 0) /* CSD version 1.0 */
1342 simplelist_addline(SIMPLELIST_ADD_LINE
,
1344 i_vmin
[card_extract_bits(card
->csd
, 61, 3)],
1345 i_vmax
[card_extract_bits(card
->csd
, 58, 3)]);
1346 simplelist_addline(SIMPLELIST_ADD_LINE
,
1348 i_vmin
[card_extract_bits(card
->csd
, 55, 3)],
1349 i_vmax
[card_extract_bits(card
->csd
, 52, 3)]);
1352 else if (card
->initialized
== 0)
1354 simplelist_addline(SIMPLELIST_ADD_LINE
, "Not Found!");
1356 #if (CONFIG_STORAGE & STORAGE_SD)
1357 else /* card->initialized < 0 */
1359 simplelist_addline(SIMPLELIST_ADD_LINE
, "Init Error! (%d)", card
->initialized
);
1362 snprintf(title
, 16, "[" CARDTYPE
" %d]", *cardnum
);
1363 gui_synclist_set_title(lists
, title
, Icon_NOICON
);
1364 gui_synclist_set_nb_items(lists
, simplelist_get_line_count());
1365 gui_synclist_select_item(lists
, 0);
1366 btn
= ACTION_REDRAW
;
1370 #elif (CONFIG_STORAGE & STORAGE_ATA)
1371 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1376 unsigned short* identify_info
= ata_get_identify();
1377 bool timing_info_present
= false;
1380 simplelist_set_line_count(0);
1382 for (i
=0; i
< 20; i
++)
1383 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+27]);
1385 /* kill trailing space */
1386 for (i
=39; i
&& buf
[i
]==' '; i
--)
1388 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", buf
);
1389 for (i
=0; i
< 4; i
++)
1390 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+23]);
1392 simplelist_addline(SIMPLELIST_ADD_LINE
,
1393 "Firmware: %s", buf
);
1394 snprintf(buf
, sizeof buf
, "%ld MB",
1395 ((unsigned long)identify_info
[61] << 16 |
1396 (unsigned long)identify_info
[60]) / 2048 );
1397 simplelist_addline(SIMPLELIST_ADD_LINE
,
1400 fat_size( IF_MV2(0,) NULL
, &free
);
1401 simplelist_addline(SIMPLELIST_ADD_LINE
,
1402 "Free: %ld MB", free
/ 1024);
1403 simplelist_addline(SIMPLELIST_ADD_LINE
,
1404 "Spinup time: %d ms", storage_spinup_time() * (1000/HZ
));
1405 i
= identify_info
[83] & (1<<3);
1406 simplelist_addline(SIMPLELIST_ADD_LINE
,
1407 "Power mgmt: %s", i
? "enabled" : "unsupported");
1408 i
= identify_info
[83] & (1<<9);
1409 simplelist_addline(SIMPLELIST_ADD_LINE
,
1410 "Noise mgmt: %s", i
? "enabled" : "unsupported");
1411 i
= identify_info
[82] & (1<<6);
1412 simplelist_addline(SIMPLELIST_ADD_LINE
,
1413 "Read-ahead: %s", i
? "enabled" : "unsupported");
1414 timing_info_present
= identify_info
[53] & (1<<1);
1415 if(timing_info_present
) {
1416 char pio3
[2], pio4
[2];pio3
[1] = 0;
1418 pio3
[0] = (identify_info
[64] & (1<<0)) ? '3' : 0;
1419 pio4
[0] = (identify_info
[64] & (1<<1)) ? '4' : 0;
1420 simplelist_addline(SIMPLELIST_ADD_LINE
,
1421 "PIO modes: 0 1 2 %s %s", pio3
, pio4
);
1424 simplelist_addline(SIMPLELIST_ADD_LINE
,
1425 "No PIO mode info");
1427 timing_info_present
= identify_info
[53] & (1<<1);
1428 if(timing_info_present
) {
1429 simplelist_addline(SIMPLELIST_ADD_LINE
,
1430 "Cycle times %dns/%dns",
1432 identify_info
[68] );
1434 simplelist_addline(SIMPLELIST_ADD_LINE
,
1437 int sector_size
= 512;
1438 if((identify_info
[106] & 0xe000) == 0x6000)
1439 sector_size
*= BIT_N(identify_info
[106] & 0x000f);
1440 simplelist_addline(SIMPLELIST_ADD_LINE
,
1441 "Physical sector size: %d", sector_size
);
1443 if (identify_info
[63] & (1<<0)) {
1444 char mdma0
[2], mdma1
[2], mdma2
[2];
1445 mdma0
[1] = mdma1
[1] = mdma2
[1] = 0;
1446 mdma0
[0] = (identify_info
[63] & (1<<0)) ? '0' : 0;
1447 mdma1
[0] = (identify_info
[63] & (1<<1)) ? '1' : 0;
1448 mdma2
[0] = (identify_info
[63] & (1<<2)) ? '2' : 0;
1449 simplelist_addline(SIMPLELIST_ADD_LINE
,
1450 "MDMA modes: %s %s %s", mdma0
, mdma1
, mdma2
);
1451 simplelist_addline(SIMPLELIST_ADD_LINE
,
1452 "MDMA Cycle times %dns/%dns",
1454 identify_info
[66] );
1457 simplelist_addline(SIMPLELIST_ADD_LINE
,
1458 "No MDMA mode info");
1460 if (identify_info
[53] & (1<<2)) {
1461 char udma0
[2], udma1
[2], udma2
[2], udma3
[2], udma4
[2], udma5
[2], udma6
[2];
1462 udma0
[1] = udma1
[1] = udma2
[1] = udma3
[1] = udma4
[1] = udma5
[1] = udma6
[1] = 0;
1463 udma0
[0] = (identify_info
[88] & (1<<0)) ? '0' : 0;
1464 udma1
[0] = (identify_info
[88] & (1<<1)) ? '1' : 0;
1465 udma2
[0] = (identify_info
[88] & (1<<2)) ? '2' : 0;
1466 udma3
[0] = (identify_info
[88] & (1<<3)) ? '3' : 0;
1467 udma4
[0] = (identify_info
[88] & (1<<4)) ? '4' : 0;
1468 udma5
[0] = (identify_info
[88] & (1<<5)) ? '5' : 0;
1469 udma6
[0] = (identify_info
[88] & (1<<6)) ? '6' : 0;
1470 simplelist_addline(SIMPLELIST_ADD_LINE
,
1471 "UDMA modes: %s %s %s %s %s %s %s", udma0
, udma1
, udma2
,
1472 udma3
, udma4
, udma5
, udma6
);
1475 simplelist_addline(SIMPLELIST_ADD_LINE
,
1476 "No UDMA mode info");
1478 #endif /* HAVE_ATA_DMA */
1479 timing_info_present
= identify_info
[53] & (1<<1);
1480 if(timing_info_present
) {
1481 i
= identify_info
[49] & (1<<11);
1482 simplelist_addline(SIMPLELIST_ADD_LINE
,
1483 "IORDY support: %s", i
? "yes" : "no");
1484 i
= identify_info
[49] & (1<<10);
1485 simplelist_addline(SIMPLELIST_ADD_LINE
,
1486 "IORDY disable: %s", i
? "yes" : "no");
1488 simplelist_addline(SIMPLELIST_ADD_LINE
,
1491 simplelist_addline(SIMPLELIST_ADD_LINE
,
1492 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
1494 i
= ata_get_dma_mode();
1496 simplelist_addline(SIMPLELIST_ADD_LINE
,
1499 simplelist_addline(SIMPLELIST_ADD_LINE
,
1501 (i
& 0x40) ? "UDMA" : "MDMA",
1504 #endif /* HAVE_ATA_DMA */
1507 #else /* No SD, MMC or ATA */
1508 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1512 struct storage_info info
;
1513 storage_get_info(0,&info
);
1514 simplelist_addline(SIMPLELIST_ADD_LINE
, "Vendor: %s", info
.vendor
);
1515 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", info
.product
);
1516 simplelist_addline(SIMPLELIST_ADD_LINE
, "Firmware: %s", info
.revision
);
1517 simplelist_addline(SIMPLELIST_ADD_LINE
,
1518 "Size: %ld MB", info
.num_sectors
*(info
.sector_size
/512)/2024);
1520 fat_size( IF_MV2(0,) NULL
, &free
);
1521 simplelist_addline(SIMPLELIST_ADD_LINE
,
1522 "Free: %ld MB", free
/ 1024);
1523 simplelist_addline(SIMPLELIST_ADD_LINE
,
1524 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
1529 #if (CONFIG_STORAGE & STORAGE_ATA)
1530 static bool dbg_identify_info(void)
1532 int fd
= creat("/identify_info.bin", 0666);
1535 #ifdef ROCKBOX_LITTLE_ENDIAN
1536 ecwrite(fd
, ata_get_identify(), SECTOR_SIZE
/2, "s", true);
1538 write(fd
, ata_get_identify(), SECTOR_SIZE
);
1546 static bool dbg_disk_info(void)
1548 struct simplelist_info info
;
1549 simplelist_info_init(&info
, "Disk Info", 1, NULL
);
1550 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
1553 info
.callback_data
= (void*)&card
;
1556 info
.action_callback
= disk_callback
;
1557 info
.hide_selection
= true;
1558 info
.scroll_all
= true;
1559 return simplelist_show_list(&info
);
1561 #endif /* PLATFORM_NATIVE */
1563 #ifdef HAVE_DIRCACHE
1564 static int dircache_callback(int btn
, struct gui_synclist
*lists
)
1566 (void)btn
; (void)lists
;
1567 simplelist_set_line_count(0);
1568 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache initialized: %s",
1569 dircache_is_enabled() ? "Yes" : "No");
1570 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache size: %d B",
1571 dircache_get_cache_size());
1572 simplelist_addline(SIMPLELIST_ADD_LINE
, "Last size: %d B",
1573 global_status
.dircache_size
);
1574 simplelist_addline(SIMPLELIST_ADD_LINE
, "Limit: %d B",
1576 simplelist_addline(SIMPLELIST_ADD_LINE
, "Reserve: %d/%d B",
1577 dircache_get_reserve_used(), DIRCACHE_RESERVE
);
1578 simplelist_addline(SIMPLELIST_ADD_LINE
, "Scanning took: %d s",
1579 dircache_get_build_ticks() / HZ
);
1580 simplelist_addline(SIMPLELIST_ADD_LINE
, "Entry count: %d",
1581 dircache_get_entry_count());
1585 static bool dbg_dircache_info(void)
1587 struct simplelist_info info
;
1588 simplelist_info_init(&info
, "Dircache Info", 7, NULL
);
1589 info
.action_callback
= dircache_callback
;
1590 info
.hide_selection
= true;
1591 info
.scroll_all
= true;
1592 return simplelist_show_list(&info
);
1595 #endif /* HAVE_DIRCACHE */
1597 #ifdef HAVE_TAGCACHE
1598 static int database_callback(int btn
, struct gui_synclist
*lists
)
1601 struct tagcache_stat
*stat
= tagcache_get_stat();
1602 static bool synced
= false;
1604 simplelist_set_line_count(0);
1606 simplelist_addline(SIMPLELIST_ADD_LINE
, "Initialized: %s",
1607 stat
->initialized
? "Yes" : "No");
1608 simplelist_addline(SIMPLELIST_ADD_LINE
, "DB Ready: %s",
1609 stat
->ready
? "Yes" : "No");
1610 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM Cache: %s",
1611 stat
->ramcache
? "Yes" : "No");
1612 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM: %d/%d B",
1613 stat
->ramcache_used
, stat
->ramcache_allocated
);
1614 simplelist_addline(SIMPLELIST_ADD_LINE
, "Progress: %d%% (%d entries)",
1615 stat
->progress
, stat
->processed_entries
);
1616 simplelist_addline(SIMPLELIST_ADD_LINE
, "Curfile: %s",
1617 stat
->curentry
? stat
->curentry
: "---");
1618 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit step: %d",
1620 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit delayed: %s",
1621 stat
->commit_delayed
? "Yes" : "No");
1623 simplelist_addline(SIMPLELIST_ADD_LINE
, "Queue length: %d",
1624 stat
->queue_length
);
1629 tagcache_screensync_event();
1632 if (!btn
&& stat
->curentry
)
1635 return ACTION_REDRAW
;
1638 if (btn
== ACTION_STD_CANCEL
)
1639 tagcache_screensync_enable(false);
1643 static bool dbg_tagcache_info(void)
1645 struct simplelist_info info
;
1646 simplelist_info_init(&info
, "Database Info", 8, NULL
);
1647 info
.action_callback
= database_callback
;
1648 info
.hide_selection
= true;
1649 info
.scroll_all
= true;
1651 /* Don't do nonblock here, must give enough processing time
1652 for tagcache thread. */
1653 /* info.timeout = TIMEOUT_NOBLOCK; */
1655 tagcache_screensync_enable(true);
1656 return simplelist_show_list(&info
);
1660 #if CONFIG_CPU == SH7034
1661 static bool dbg_save_roms(void)
1664 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
1666 fd
= creat("/internal_rom_0000-FFFF.bin", 0666);
1669 write(fd
, (void *)0, 0x10000);
1673 fd
= creat("/internal_rom_2000000-203FFFF.bin", 0666);
1676 write(fd
, (void *)0x2000000, 0x40000);
1680 system_memory_guard(oldmode
);
1683 #elif defined CPU_COLDFIRE
1684 static bool dbg_save_roms(void)
1687 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
1689 #if defined(IRIVER_H100_SERIES)
1690 fd
= creat("/internal_rom_000000-1FFFFF.bin", 0666);
1691 #elif defined(IRIVER_H300_SERIES)
1692 fd
= creat("/internal_rom_000000-3FFFFF.bin", 0666);
1693 #elif defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IAUDIO_M3)
1694 fd
= creat("/internal_rom_000000-3FFFFF.bin", 0666);
1695 #elif defined(MPIO_HD200) || defined(MPIO_HD300)
1696 fd
= creat("/internal_rom_000000-1FFFFF.bin", 0666);
1700 write(fd
, (void *)0, FLASH_SIZE
);
1703 system_memory_guard(oldmode
);
1706 fd
= creat("/internal_eeprom.bin", 0666);
1710 char buf
[EEPROM_SIZE
];
1713 old_irq_level
= disable_irq_save();
1715 err
= eeprom_24cxx_read(0, buf
, sizeof buf
);
1717 restore_irq(old_irq_level
);
1720 splashf(HZ
*3, "Eeprom read failure (%d)", err
);
1723 write(fd
, buf
, sizeof buf
);
1732 #elif defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD)
1733 static bool dbg_save_roms(void)
1737 fd
= creat("/internal_rom_000000-0FFFFF.bin", 0666);
1740 write(fd
, (void *)0x20000000, FLASH_SIZE
);
1746 #elif CONFIG_CPU == IMX31L
1747 static bool dbg_save_roms(void)
1751 fd
= creat("/flash_rom_A0000000-A01FFFFF.bin", 0666);
1754 write(fd
, (void*)0xa0000000, FLASH_SIZE
);
1760 #elif defined(CPU_TCC780X)
1761 static bool dbg_save_roms(void)
1765 fd
= creat("/eeprom_E0000000-E0001FFF.bin", 0666);
1768 write(fd
, (void*)0xe0000000, 0x2000);
1779 #ifdef CONFIG_TUNER_MULTI
1780 static int tuner_type
= 0;
1781 #define IF_TUNER_TYPE(type) if(tuner_type==type)
1783 #define IF_TUNER_TYPE(type)
1786 static int radio_callback(int btn
, struct gui_synclist
*lists
)
1789 if (btn
== ACTION_STD_CANCEL
)
1791 simplelist_set_line_count(1);
1793 #if (CONFIG_TUNER & LV24020LP)
1794 simplelist_addline(SIMPLELIST_ADD_LINE
,
1795 "CTRL_STAT: %02X", lv24020lp_get(LV24020LP_CTRL_STAT
) );
1796 simplelist_addline(SIMPLELIST_ADD_LINE
,
1797 "RADIO_STAT: %02X", lv24020lp_get(LV24020LP_REG_STAT
) );
1798 simplelist_addline(SIMPLELIST_ADD_LINE
,
1799 "MSS_FM: %d kHz", lv24020lp_get(LV24020LP_MSS_FM
) );
1800 simplelist_addline(SIMPLELIST_ADD_LINE
,
1801 "MSS_IF: %d Hz", lv24020lp_get(LV24020LP_MSS_IF
) );
1802 simplelist_addline(SIMPLELIST_ADD_LINE
,
1803 "MSS_SD: %d Hz", lv24020lp_get(LV24020LP_MSS_SD
) );
1804 simplelist_addline(SIMPLELIST_ADD_LINE
,
1805 "if_set: %d Hz", lv24020lp_get(LV24020LP_IF_SET
) );
1806 simplelist_addline(SIMPLELIST_ADD_LINE
,
1807 "sd_set: %d Hz", lv24020lp_get(LV24020LP_SD_SET
) );
1808 #endif /* LV24020LP */
1809 #if (CONFIG_TUNER & S1A0903X01)
1810 simplelist_addline(SIMPLELIST_ADD_LINE
,
1811 "Samsung regs: %08X", s1a0903x01_get(RADIO_ALL
));
1812 /* This one doesn't return dynamic data atm */
1813 #endif /* S1A0903X01 */
1814 #if (CONFIG_TUNER & TEA5767)
1815 struct tea5767_dbg_info nfo
;
1816 tea5767_dbg_info(&nfo
);
1817 simplelist_addline(SIMPLELIST_ADD_LINE
, "Philips regs:");
1818 simplelist_addline(SIMPLELIST_ADD_LINE
,
1819 " Read: %02X %02X %02X %02X %02X",
1820 (unsigned)nfo
.read_regs
[0], (unsigned)nfo
.read_regs
[1],
1821 (unsigned)nfo
.read_regs
[2], (unsigned)nfo
.read_regs
[3],
1822 (unsigned)nfo
.read_regs
[4]);
1823 simplelist_addline(SIMPLELIST_ADD_LINE
,
1824 " Write: %02X %02X %02X %02X %02X",
1825 (unsigned)nfo
.write_regs
[0], (unsigned)nfo
.write_regs
[1],
1826 (unsigned)nfo
.write_regs
[2], (unsigned)nfo
.write_regs
[3],
1827 (unsigned)nfo
.write_regs
[4]);
1828 #endif /* TEA5767 */
1829 #if (CONFIG_TUNER & SI4700)
1830 IF_TUNER_TYPE(SI4700
)
1832 struct si4700_dbg_info nfo
;
1834 si4700_dbg_info(&nfo
);
1835 simplelist_addline(SIMPLELIST_ADD_LINE
, "SI4700 regs:");
1836 for (i
= 0; i
< 16; i
+= 4) {
1837 simplelist_addline(SIMPLELIST_ADD_LINE
,"%02X: %04X %04X %04X %04X",
1838 i
, nfo
.regs
[i
], nfo
.regs
[i
+1], nfo
.regs
[i
+2], nfo
.regs
[i
+3]);
1841 simplelist_addline(SIMPLELIST_ADD_LINE
, "");
1842 simplelist_addline(SIMPLELIST_ADD_LINE
, "RDS Info:");
1843 simplelist_addline(SIMPLELIST_ADD_LINE
,
1844 si4700_get_rds_info(RADIO_RDS_NAME
));
1846 simplelist_addline(SIMPLELIST_ADD_LINE
,
1847 si4700_get_rds_info(RADIO_RDS_TEXT
));
1851 #if (CONFIG_TUNER & RDA5802)
1852 IF_TUNER_TYPE(RDA5802
)
1854 struct rda5802_dbg_info nfo
;
1856 rda5802_dbg_info(&nfo
);
1857 simplelist_addline(SIMPLELIST_ADD_LINE
, "RDA5802 regs:");
1858 for (i
= 0; i
< 16; i
+= 4) {
1859 simplelist_addline(SIMPLELIST_ADD_LINE
,"%02X: %04X %04X %04X %04X",
1860 i
, nfo
.regs
[i
], nfo
.regs
[i
+1], nfo
.regs
[i
+2], nfo
.regs
[i
+3]);
1863 #endif /* RDA55802 */
1864 return ACTION_REDRAW
;
1866 static bool dbg_fm_radio(void)
1868 struct simplelist_info info
;
1869 #ifdef CONFIG_TUNER_MULTI
1870 tuner_type
= tuner_detect_type();
1872 info
.scroll_all
= true;
1873 simplelist_info_init(&info
, "FM Radio", 1, NULL
);
1874 simplelist_set_line_count(0);
1875 simplelist_addline(SIMPLELIST_ADD_LINE
, "HW detected: %s",
1876 radio_hardware_present() ? "yes" : "no");
1878 info
.action_callback
= radio_hardware_present()?radio_callback
: NULL
;
1879 info
.hide_selection
= true;
1880 return simplelist_show_list(&info
);
1882 #endif /* CONFIG_TUNER */
1883 #endif /* !SIMULATOR */
1885 #if defined(HAVE_LCD_BITMAP) && !defined(APPLICATION)
1886 extern bool do_screendump_instead_of_usb
;
1888 static bool dbg_screendump(void)
1890 do_screendump_instead_of_usb
= !do_screendump_instead_of_usb
;
1891 splashf(HZ
, "Screendump %s",
1892 do_screendump_instead_of_usb
?"enabled":"disabled");
1895 #endif /* HAVE_LCD_BITMAP */
1897 extern bool write_metadata_log
;
1899 static bool dbg_metadatalog(void)
1901 write_metadata_log
= !write_metadata_log
;
1902 splashf(HZ
, "Metadata log %s",
1903 write_metadata_log
?"enabled":"disabled");
1907 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
1908 static bool dbg_set_memory_guard(void)
1910 static const struct opt_items names
[MAXMEMGUARD
] = {
1912 { "Flash ROM writes", -1 },
1913 { "Zero area (all)", -1 }
1915 int mode
= system_memory_guard(MEMGUARD_KEEP
);
1917 set_option( "Catch mem accesses", &mode
, INT
, names
, MAXMEMGUARD
, NULL
);
1918 system_memory_guard(mode
);
1922 #endif /* CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) */
1924 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
1925 static bool dbg_write_eeprom(void)
1930 char buf
[EEPROM_SIZE
];
1933 fd
= open("/internal_eeprom.bin", O_RDONLY
);
1937 rc
= read(fd
, buf
, EEPROM_SIZE
);
1939 if(rc
== EEPROM_SIZE
)
1941 old_irq_level
= disable_irq_save();
1943 err
= eeprom_24cxx_write(0, buf
, sizeof buf
);
1945 splashf(HZ
*3, "Eeprom write failure (%d)", err
);
1947 splash(HZ
*3, "Eeprom written successfully");
1949 restore_irq(old_irq_level
);
1953 splashf(HZ
*3, "File read error (%d)",rc
);
1959 splash(HZ
*3, "Failed to open 'internal_eeprom.bin'");
1964 #endif /* defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS) */
1965 #ifdef CPU_BOOST_LOGGING
1966 static bool cpu_boost_log(void)
1969 int count
= cpu_boost_log_getcount();
1970 int lines
= LCD_HEIGHT
/SYSFONT_HEIGHT
;
1973 lcd_setfont(FONT_SYSFIXED
);
1974 str
= cpu_boost_log_getlog_first();
1977 lcd_clear_display();
1978 for(j
=0; j
<lines
; j
++,i
++)
1981 str
= cpu_boost_log_getlog_next();
1984 if(strlen(str
) > LCD_WIDTH
/SYSFONT_WIDTH
)
1985 lcd_puts_scroll(0, j
, str
);
1995 switch(get_action(CONTEXT_STD
,TIMEOUT_BLOCK
))
1998 case ACTION_STD_PREV
:
1999 case ACTION_STD_NEXT
:
2002 case ACTION_STD_CANCEL
:
2010 get_action(CONTEXT_STD
,TIMEOUT_BLOCK
);
2011 lcd_setfont(FONT_UI
);
2016 #if (defined(HAVE_WHEEL_ACCELERATION) && (CONFIG_KEYPAD==IPOD_4G_PAD) \
2017 && !defined(IPOD_MINI) && !defined(SIMULATOR))
2018 extern bool wheel_is_touched
;
2019 extern int old_wheel_value
;
2020 extern int new_wheel_value
;
2021 extern int wheel_delta
;
2022 extern unsigned int accumulated_wheel_delta
;
2023 extern unsigned int wheel_velocity
;
2025 static bool dbg_scrollwheel(void)
2029 lcd_setfont(FONT_SYSFIXED
);
2033 if (action_userabort(HZ
/10))
2036 lcd_clear_display();
2038 /* show internal variables of scrollwheel driver */
2039 lcd_putsf(0, 0, "wheel touched: %s", (wheel_is_touched
) ? "true" : "false");
2040 lcd_putsf(0, 1, "new position: %2d", new_wheel_value
);
2041 lcd_putsf(0, 2, "old position: %2d", old_wheel_value
);
2042 lcd_putsf(0, 3, "wheel delta: %2d", wheel_delta
);
2043 lcd_putsf(0, 4, "accumulated delta: %2d", accumulated_wheel_delta
);
2044 lcd_putsf(0, 5, "velo [deg/s]: %4d", (int)wheel_velocity
);
2046 /* show effective accelerated scrollspeed */
2047 speed
= button_apply_acceleration( (1<<31)|(1<<24)|wheel_velocity
);
2048 lcd_putsf(0, 6, "accel. speed: %4d", speed
);
2052 lcd_setfont(FONT_UI
);
2057 #if defined (HAVE_USBSTACK)
2059 #if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL)
2060 static bool toggle_usb_core_driver(int driver
, char *msg
)
2062 bool enabled
= !usb_core_driver_enabled(driver
);
2064 usb_core_enable_driver(driver
,enabled
);
2065 splashf(HZ
, "%s %s", msg
, enabled
?"enabled":"disabled");
2070 static bool toggle_usb_serial(void)
2072 return toggle_usb_core_driver(USB_DRIVER_SERIAL
,"USB Serial");
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 struct the_menu_item
{
2133 unsigned char *desc
; /* string or ID */
2134 bool (*function
) (void); /* return true if USB was connected */
2136 static const struct the_menu_item menuitems
[] = {
2137 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || \
2138 (defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD)) || \
2139 CONFIG_CPU == IMX31L || defined(CPU_TCC780X)
2140 { "Dump ROM contents", dbg_save_roms
},
2142 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || defined(CPU_PP) \
2143 || CONFIG_CPU == S3C2440 || CONFIG_CPU == IMX31L || CONFIG_CPU == AS3525 \
2144 || CONFIG_CPU == DM320 || defined(CPU_S5L870X) || CONFIG_CPU == AS3525v2 \
2145 || CONFIG_CPU == RK27XX
2146 { "View I/O ports", dbg_ports
},
2148 #if (CONFIG_RTC == RTC_PCF50605) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
2149 { "View PCF registers", dbg_pcf
},
2151 #if defined(HAVE_TSC2100) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
2152 { "TSC2100 debug", tsc2100_debug
},
2154 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
2155 { "CPU frequency", dbg_cpufreq
},
2157 #if CONFIG_CPU == IMX31L
2158 { "DVFS/DPTC", __dbg_dvfs_dptc
},
2160 #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR)
2161 { "S/PDIF analyzer", dbg_spdif
},
2163 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2164 { "Catch mem accesses", dbg_set_memory_guard
},
2166 { "View OS stacks", dbg_os
},
2168 { "View CPU stats", dbg_cpuinfo
},
2170 #ifdef HAVE_LCD_BITMAP
2171 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
2172 { "View battery", view_battery
},
2175 { "Screendump", dbg_screendump
},
2178 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
2179 { "View HW info", dbg_hw_info
},
2181 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
2182 { "View partitions", dbg_partitions
},
2184 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
2185 { "View disk info", dbg_disk_info
},
2186 #if (CONFIG_STORAGE & STORAGE_ATA)
2187 { "Dump ATA identify info", dbg_identify_info
},
2190 { "Metadata log", dbg_metadatalog
},
2191 #ifdef HAVE_DIRCACHE
2192 { "View dircache info", dbg_dircache_info
},
2194 #ifdef HAVE_TAGCACHE
2195 { "View database info", dbg_tagcache_info
},
2197 #ifdef HAVE_LCD_BITMAP
2198 #if CONFIG_CODEC == SWCODEC
2199 { "View buffering thread", dbg_buffering_thread
},
2200 #elif !defined(SIMULATOR)
2201 { "View audio thread", dbg_audio_thread
},
2204 { "pm histogram", peak_meter_histogram
},
2205 #endif /* PM_DEBUG */
2206 #endif /* HAVE_LCD_BITMAP */
2207 { "View buflib allocs", dbg_buflib_allocs
},
2210 { "FM Radio", dbg_fm_radio
},
2213 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2214 { "Write back EEPROM", dbg_write_eeprom
},
2216 #if CONFIG_USBOTG == USBOTG_ISP1583
2217 { "View ISP1583 info", dbg_isp1583
},
2219 #if defined(CREATIVE_ZVx) && !defined(SIMULATOR)
2220 { "View PIC info", dbg_pic
},
2222 #ifdef ROCKBOX_HAS_LOGF
2223 {"Show Log File", logfdisplay
},
2224 {"Dump Log File", logfdump
},
2226 #if defined(HAVE_USBSTACK)
2227 #if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL)
2228 {"USB Serial driver (logf)", toggle_usb_serial
},
2230 #endif /* HAVE_USBSTACK */
2231 #ifdef CPU_BOOST_LOGGING
2232 {"cpu_boost log",cpu_boost_log
},
2234 #if (defined(HAVE_WHEEL_ACCELERATION) && (CONFIG_KEYPAD==IPOD_4G_PAD) \
2235 && !defined(IPOD_MINI) && !defined(SIMULATOR))
2236 {"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* dbg_menu_getname(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
= dbg_menu_getname
;
2275 return simplelist_show_list(&info
);
2278 bool run_debug_screen(char* screen
)
2281 for (i
=0; i
<ARRAYLEN(menuitems
); i
++)
2283 if (!strcmp(screen
, menuitems
[i
].desc
))
2286 viewportmanager_theme_enable(j
, false, NULL
);
2287 menuitems
[i
].function();
2289 viewportmanager_theme_undo(j
, false);