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)
65 #include "eeprom_24cxx.h"
66 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
69 #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
= 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(SANSA_E200) || defined(SANSA_C200) || CONFIG_CPU == AS3525 || \
1131 CONFIG_CPU == AS3525v2
1132 static const char * const chrgstate_strings
[] =
1134 [CHARGE_STATE_DISABLED
- CHARGE_STATE_DISABLED
]= "Disabled",
1135 [CHARGE_STATE_ERROR
- CHARGE_STATE_DISABLED
] = "Error",
1136 [DISCHARGING
- CHARGE_STATE_DISABLED
] = "Discharging",
1137 [CHARGING
- CHARGE_STATE_DISABLED
] = "Charging",
1139 const char *str
= NULL
;
1141 lcd_putsf(0, 3, "Charger: %s",
1142 charger_inserted() ? "present" : "absent");
1144 y
= charge_state
- CHARGE_STATE_DISABLED
;
1145 if ((unsigned)y
< ARRAYLEN(chrgstate_strings
))
1146 str
= chrgstate_strings
[y
];
1148 lcd_putsf(0, 4, "State: %s",
1149 str
? str
: "<unknown>");
1151 lcd_putsf(0, 5, "CHARGER: %02X", ascodec_read_charger());
1152 #elif defined(IPOD_NANO2G)
1153 y
= pmu_read_battery_voltage();
1154 lcd_putsf(17, 1, "RAW: %d.%03d V", y
/ 1000, y
% 1000);
1155 y
= pmu_read_battery_current();
1156 lcd_putsf(0, 2, "Battery current: %d mA", y
);
1157 lcd_putsf(0, 3, "PWRCON: %08x %08x", PWRCON
, PWRCONEXT
);
1158 lcd_putsf(0, 4, "CLKCON: %08x %03x %03x", CLKCON
, CLKCON2
, CLKCON3
);
1159 lcd_putsf(0, 5, "PLL: %06x %06x %06x", PLL0PMS
, PLL1PMS
, PLL2PMS
);
1160 x
= pmu_read(0x1b) & 0xf;
1161 y
= pmu_read(0x1a) * 25 + 625;
1162 lcd_putsf(0, 6, "AUTO: %x / %d mV", x
, y
);
1163 x
= pmu_read(0x1f) & 0xf;
1164 y
= pmu_read(0x1e) * 25 + 625;
1165 lcd_putsf(0, 7, "DOWN1: %x / %d mV", x
, y
);
1166 x
= pmu_read(0x23) & 0xf;
1167 y
= pmu_read(0x22) * 25 + 625;
1168 lcd_putsf(0, 8, "DOWN2: %x / %d mV", x
, y
);
1169 x
= pmu_read(0x27) & 0xf;
1170 y
= pmu_read(0x26) * 100 + 900;
1171 lcd_putsf(0, 9, "MEMLDO: %x / %d mV", x
, y
);
1172 for (i
= 0; i
< 6; i
++)
1174 x
= pmu_read(0x2e + (i
<< 1)) & 0xf;
1175 y
= pmu_read(0x2d + (i
<< 1)) * 100 + 900;
1176 lcd_putsf(0, 10 + i
, "LDO%d: %x / %d mV", i
+ 1, x
, y
);
1179 lcd_putsf(0, 3, "Charger: %s",
1180 charger_inserted() ? "present" : "absent");
1181 #endif /* target type */
1182 #endif /* CONFIG_CHARGING */
1184 case 2: /* voltage deltas: */
1185 #if (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE)
1186 lcd_puts(0, 0, "Voltage deltas:");
1187 for (i
= 0; i
< POWER_HISTORY_LEN
-1; i
++) {
1188 y
= power_history
[i
] - power_history
[i
+1];
1189 lcd_putsf(0, i
+1, "-%d min: %c%d.%03d V", i
,
1190 (y
< 0) ? '-' : ' ', ((y
< 0) ? y
* -1 : y
) / 1000,
1191 ((y
< 0) ? y
* -1 : y
) % 1000);
1193 #elif (CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE)
1194 lcd_puts(0, 0, "Percentage deltas:");
1195 for (i
= 0; i
< POWER_HISTORY_LEN
-1; i
++) {
1196 y
= power_history
[i
] - power_history
[i
+1];
1197 lcd_putsf(0, i
+1, "-%d min: %c%d%%", i
,
1198 (y
< 0) ? '-' : ' ', ((y
< 0) ? y
* -1 : y
));
1203 case 3: /* remaining time estimation: */
1205 #ifdef ARCHOS_RECORDER
1206 lcd_putsf(0, 0, "charge_state: %d", charge_state
);
1208 lcd_putsf(0, 1, "Cycle time: %d m", powermgmt_last_cycle_startstop_min
);
1210 lcd_putsf(0, 2, "Lvl@cyc st: %d%%", powermgmt_last_cycle_level
);
1212 lcd_putsf(0, 3, "P=%2d I=%2d", pid_p
, pid_i
);
1214 lcd_putsf(0, 4, "Trickle sec: %d/60", trickle_sec
);
1215 #endif /* ARCHOS_RECORDER */
1217 #if (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE)
1218 lcd_putsf(0, 5, "Last PwrHist: %d.%03dV",
1219 power_history
[0] / 1000,
1220 power_history
[0] % 1000);
1223 lcd_putsf(0, 6, "battery level: %d%%", battery_level());
1225 int time_left
= battery_time();
1227 lcd_putsf(0, 7, "Est. remain: %d m", time_left
);
1229 lcd_puts(0, 7, "Estimation n/a");
1235 switch(get_action(CONTEXT_STD
,HZ
/2))
1237 case ACTION_STD_PREV
:
1242 case ACTION_STD_NEXT
:
1247 case ACTION_STD_CANCEL
:
1248 lcd_setfont(FONT_UI
);
1252 lcd_setfont(FONT_UI
);
1256 #endif /* (CONFIG_BATTERY_MEASURE != 0) && HAVE_LCD_BITMAP */
1258 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
1259 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
1261 #if (CONFIG_STORAGE & STORAGE_MMC)
1262 #define CARDTYPE "MMC"
1263 #elif (CONFIG_STORAGE & STORAGE_SD)
1264 #define CARDTYPE "microSD"
1267 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1270 int *cardnum
= (int*)lists
->data
;
1271 unsigned char card_name
[6];
1272 unsigned char pbuf
[32];
1273 char *title
= lists
->title
;
1274 static const unsigned char i_vmin
[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
1275 static const unsigned char i_vmax
[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
1276 static const unsigned char * const kbit_units
[] = { "kBit/s", "MBit/s", "GBit/s" };
1277 static const unsigned char * const nsec_units
[] = { "ns", "µs", "ms" };
1278 #if (CONFIG_STORAGE & STORAGE_MMC)
1279 static const char * const mmc_spec_vers
[] = { "1.0-1.2", "1.4", "2.0-2.2",
1280 "3.1-3.31", "4.0" };
1283 if ((btn
== ACTION_STD_OK
) || (btn
== SYS_FS_CHANGED
) || (btn
== ACTION_REDRAW
))
1286 if (btn
== ACTION_STD_OK
)
1288 *cardnum
^= 0x1; /* change cards */
1292 simplelist_set_line_count(0);
1294 card
= card_get_info(*cardnum
);
1296 if (card
->initialized
> 0)
1299 for (i
=0; i
<sizeof(card_name
); i
++)
1301 card_name
[i
] = card_extract_bits(card
->cid
, (103-8*i
), 8);
1303 strlcpy(card_name
, card_name
, sizeof(card_name
));
1304 simplelist_addline(SIMPLELIST_ADD_LINE
,
1305 "%s Rev %d.%d", card_name
,
1306 (int) card_extract_bits(card
->cid
, 63, 4),
1307 (int) card_extract_bits(card
->cid
, 59, 4));
1308 simplelist_addline(SIMPLELIST_ADD_LINE
,
1310 #if (CONFIG_STORAGE & STORAGE_SD)
1311 (int) card_extract_bits(card
->cid
, 11, 4),
1312 (int) card_extract_bits(card
->cid
, 19, 8) + 2000
1313 #elif (CONFIG_STORAGE & STORAGE_MMC)
1314 (int) card_extract_bits(card
->cid
, 15, 4),
1315 (int) card_extract_bits(card
->cid
, 11, 4) + 1997
1318 simplelist_addline(SIMPLELIST_ADD_LINE
,
1319 #if (CONFIG_STORAGE & STORAGE_SD)
1321 card_extract_bits(card
->cid
, 55, 32)
1322 #elif (CONFIG_STORAGE & STORAGE_MMC)
1324 card_extract_bits(card
->cid
, 47, 16)
1328 simplelist_addline(SIMPLELIST_ADD_LINE
, "M=%02x, "
1329 #if (CONFIG_STORAGE & STORAGE_SD)
1331 (int) card_extract_bits(card
->cid
, 127, 8),
1332 card_extract_bits(card
->cid
, 119, 8),
1333 card_extract_bits(card
->cid
, 111, 8)
1334 #elif (CONFIG_STORAGE & STORAGE_MMC)
1336 (int) card_extract_bits(card
->cid
, 127, 8),
1337 (int) card_extract_bits(card
->cid
, 119, 16)
1341 #if (CONFIG_STORAGE & STORAGE_MMC)
1342 int temp
= card_extract_bits(card
->csd
, 125, 4);
1343 simplelist_addline(SIMPLELIST_ADD_LINE
,
1344 "MMC v%s", temp
< 5 ?
1345 mmc_spec_vers
[temp
] : "?.?");
1347 simplelist_addline(SIMPLELIST_ADD_LINE
,
1348 "Blocks: 0x%08lx", card
->numblocks
);
1349 output_dyn_value(pbuf
, sizeof pbuf
, card
->speed
/ 1000,
1351 simplelist_addline(SIMPLELIST_ADD_LINE
,
1353 output_dyn_value(pbuf
, sizeof pbuf
, card
->taac
,
1355 simplelist_addline(SIMPLELIST_ADD_LINE
,
1357 simplelist_addline(SIMPLELIST_ADD_LINE
,
1358 "Nsac: %d clk", card
->nsac
);
1359 simplelist_addline(SIMPLELIST_ADD_LINE
,
1360 "R2W: *%d", card
->r2w_factor
);
1361 #if (CONFIG_STORAGE & STORAGE_SD)
1362 int csd_structure
= card_extract_bits(card
->csd
, 127, 2);
1363 if (csd_structure
== 0) /* CSD version 1.0 */
1366 simplelist_addline(SIMPLELIST_ADD_LINE
,
1368 i_vmin
[card_extract_bits(card
->csd
, 61, 3)],
1369 i_vmax
[card_extract_bits(card
->csd
, 58, 3)]);
1370 simplelist_addline(SIMPLELIST_ADD_LINE
,
1372 i_vmin
[card_extract_bits(card
->csd
, 55, 3)],
1373 i_vmax
[card_extract_bits(card
->csd
, 52, 3)]);
1376 else if (card
->initialized
== 0)
1378 simplelist_addline(SIMPLELIST_ADD_LINE
, "Not Found!");
1380 #if (CONFIG_STORAGE & STORAGE_SD)
1381 else /* card->initialized < 0 */
1383 simplelist_addline(SIMPLELIST_ADD_LINE
, "Init Error! (%d)", card
->initialized
);
1386 snprintf(title
, 16, "[" CARDTYPE
" %d]", *cardnum
);
1387 gui_synclist_set_title(lists
, title
, Icon_NOICON
);
1388 gui_synclist_set_nb_items(lists
, simplelist_get_line_count());
1389 gui_synclist_select_item(lists
, 0);
1390 btn
= ACTION_REDRAW
;
1394 #elif (CONFIG_STORAGE & STORAGE_ATA)
1395 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1400 unsigned short* identify_info
= ata_get_identify();
1401 bool timing_info_present
= false;
1404 simplelist_set_line_count(0);
1406 for (i
=0; i
< 20; i
++)
1407 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+27]);
1409 /* kill trailing space */
1410 for (i
=39; i
&& buf
[i
]==' '; i
--)
1412 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", buf
);
1413 for (i
=0; i
< 4; i
++)
1414 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+23]);
1416 simplelist_addline(SIMPLELIST_ADD_LINE
,
1417 "Firmware: %s", buf
);
1418 snprintf(buf
, sizeof buf
, "%ld MB",
1419 ((unsigned long)identify_info
[61] << 16 |
1420 (unsigned long)identify_info
[60]) / 2048 );
1421 simplelist_addline(SIMPLELIST_ADD_LINE
,
1424 fat_size( IF_MV2(0,) NULL
, &free
);
1425 simplelist_addline(SIMPLELIST_ADD_LINE
,
1426 "Free: %ld MB", free
/ 1024);
1427 simplelist_addline(SIMPLELIST_ADD_LINE
,
1428 "Spinup time: %d ms", storage_spinup_time() * (1000/HZ
));
1429 i
= identify_info
[83] & (1<<3);
1430 simplelist_addline(SIMPLELIST_ADD_LINE
,
1431 "Power mgmt: %s", i
? "enabled" : "unsupported");
1432 i
= identify_info
[83] & (1<<9);
1433 simplelist_addline(SIMPLELIST_ADD_LINE
,
1434 "Noise mgmt: %s", i
? "enabled" : "unsupported");
1435 i
= identify_info
[82] & (1<<6);
1436 simplelist_addline(SIMPLELIST_ADD_LINE
,
1437 "Read-ahead: %s", i
? "enabled" : "unsupported");
1438 timing_info_present
= identify_info
[53] & (1<<1);
1439 if(timing_info_present
) {
1440 char pio3
[2], pio4
[2];pio3
[1] = 0;
1442 pio3
[0] = (identify_info
[64] & (1<<0)) ? '3' : 0;
1443 pio4
[0] = (identify_info
[64] & (1<<1)) ? '4' : 0;
1444 simplelist_addline(SIMPLELIST_ADD_LINE
,
1445 "PIO modes: 0 1 2 %s %s", pio3
, pio4
);
1448 simplelist_addline(SIMPLELIST_ADD_LINE
,
1449 "No PIO mode info");
1451 timing_info_present
= identify_info
[53] & (1<<1);
1452 if(timing_info_present
) {
1453 simplelist_addline(SIMPLELIST_ADD_LINE
,
1454 "Cycle times %dns/%dns",
1456 identify_info
[68] );
1458 simplelist_addline(SIMPLELIST_ADD_LINE
,
1461 int sector_size
= 512;
1462 if((identify_info
[106] & 0xe000) == 0x6000)
1463 sector_size
*= BIT_N(identify_info
[106] & 0x000f);
1464 simplelist_addline(SIMPLELIST_ADD_LINE
,
1465 "Physical sector size: %d", sector_size
);
1467 if (identify_info
[63] & (1<<0)) {
1468 char mdma0
[2], mdma1
[2], mdma2
[2];
1469 mdma0
[1] = mdma1
[1] = mdma2
[1] = 0;
1470 mdma0
[0] = (identify_info
[63] & (1<<0)) ? '0' : 0;
1471 mdma1
[0] = (identify_info
[63] & (1<<1)) ? '1' : 0;
1472 mdma2
[0] = (identify_info
[63] & (1<<2)) ? '2' : 0;
1473 simplelist_addline(SIMPLELIST_ADD_LINE
,
1474 "MDMA modes: %s %s %s", mdma0
, mdma1
, mdma2
);
1475 simplelist_addline(SIMPLELIST_ADD_LINE
,
1476 "MDMA Cycle times %dns/%dns",
1478 identify_info
[66] );
1481 simplelist_addline(SIMPLELIST_ADD_LINE
,
1482 "No MDMA mode info");
1484 if (identify_info
[53] & (1<<2)) {
1485 char udma0
[2], udma1
[2], udma2
[2], udma3
[2], udma4
[2], udma5
[2], udma6
[2];
1486 udma0
[1] = udma1
[1] = udma2
[1] = udma3
[1] = udma4
[1] = udma5
[1] = udma6
[1] = 0;
1487 udma0
[0] = (identify_info
[88] & (1<<0)) ? '0' : 0;
1488 udma1
[0] = (identify_info
[88] & (1<<1)) ? '1' : 0;
1489 udma2
[0] = (identify_info
[88] & (1<<2)) ? '2' : 0;
1490 udma3
[0] = (identify_info
[88] & (1<<3)) ? '3' : 0;
1491 udma4
[0] = (identify_info
[88] & (1<<4)) ? '4' : 0;
1492 udma5
[0] = (identify_info
[88] & (1<<5)) ? '5' : 0;
1493 udma6
[0] = (identify_info
[88] & (1<<6)) ? '6' : 0;
1494 simplelist_addline(SIMPLELIST_ADD_LINE
,
1495 "UDMA modes: %s %s %s %s %s %s %s", udma0
, udma1
, udma2
,
1496 udma3
, udma4
, udma5
, udma6
);
1499 simplelist_addline(SIMPLELIST_ADD_LINE
,
1500 "No UDMA mode info");
1502 #endif /* HAVE_ATA_DMA */
1503 timing_info_present
= identify_info
[53] & (1<<1);
1504 if(timing_info_present
) {
1505 i
= identify_info
[49] & (1<<11);
1506 simplelist_addline(SIMPLELIST_ADD_LINE
,
1507 "IORDY support: %s", i
? "yes" : "no");
1508 i
= identify_info
[49] & (1<<10);
1509 simplelist_addline(SIMPLELIST_ADD_LINE
,
1510 "IORDY disable: %s", i
? "yes" : "no");
1512 simplelist_addline(SIMPLELIST_ADD_LINE
,
1515 simplelist_addline(SIMPLELIST_ADD_LINE
,
1516 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
1518 i
= ata_get_dma_mode();
1520 simplelist_addline(SIMPLELIST_ADD_LINE
,
1523 simplelist_addline(SIMPLELIST_ADD_LINE
,
1525 (i
& 0x40) ? "UDMA" : "MDMA",
1528 #endif /* HAVE_ATA_DMA */
1531 #else /* No SD, MMC or ATA */
1532 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1535 struct storage_info info
;
1536 storage_get_info(0,&info
);
1537 simplelist_addline(SIMPLELIST_ADD_LINE
, "Vendor: %s", info
.vendor
);
1538 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", info
.product
);
1539 simplelist_addline(SIMPLELIST_ADD_LINE
, "Firmware: %s", info
.revision
);
1540 simplelist_addline(SIMPLELIST_ADD_LINE
,
1541 "Size: %ld MB", info
.num_sectors
*(info
.sector_size
/512)/2024);
1543 fat_size( IF_MV2(0,) NULL
, &free
);
1544 simplelist_addline(SIMPLELIST_ADD_LINE
,
1545 "Free: %ld MB", free
/ 1024);
1546 simplelist_addline(SIMPLELIST_ADD_LINE
,
1547 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
1552 #if (CONFIG_STORAGE & STORAGE_ATA)
1553 static bool dbg_identify_info(void)
1555 int fd
= creat("/identify_info.bin", 0666);
1558 #ifdef ROCKBOX_LITTLE_ENDIAN
1559 ecwrite(fd
, ata_get_identify(), SECTOR_SIZE
/2, "s", true);
1561 write(fd
, ata_get_identify(), SECTOR_SIZE
);
1569 static bool dbg_disk_info(void)
1571 struct simplelist_info info
;
1572 simplelist_info_init(&info
, "Disk Info", 1, NULL
);
1573 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
1576 info
.callback_data
= (void*)&card
;
1579 info
.action_callback
= disk_callback
;
1580 info
.hide_selection
= true;
1581 info
.scroll_all
= true;
1582 return simplelist_show_list(&info
);
1584 #endif /* PLATFORM_NATIVE */
1586 #ifdef HAVE_DIRCACHE
1587 static int dircache_callback(int btn
, struct gui_synclist
*lists
)
1590 simplelist_set_line_count(0);
1591 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache initialized: %s",
1592 dircache_is_enabled() ? "Yes" : "No");
1593 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache size: %d B",
1594 dircache_get_cache_size());
1595 simplelist_addline(SIMPLELIST_ADD_LINE
, "Last size: %d B",
1596 global_status
.dircache_size
);
1597 simplelist_addline(SIMPLELIST_ADD_LINE
, "Limit: %d B",
1599 simplelist_addline(SIMPLELIST_ADD_LINE
, "Reserve: %d/%d B",
1600 dircache_get_reserve_used(), DIRCACHE_RESERVE
);
1601 simplelist_addline(SIMPLELIST_ADD_LINE
, "Scanning took: %d s",
1602 dircache_get_build_ticks() / HZ
);
1603 simplelist_addline(SIMPLELIST_ADD_LINE
, "Entry count: %d",
1604 dircache_get_entry_count());
1608 static bool dbg_dircache_info(void)
1610 struct simplelist_info info
;
1611 simplelist_info_init(&info
, "Dircache Info", 7, NULL
);
1612 info
.action_callback
= dircache_callback
;
1613 info
.hide_selection
= true;
1614 info
.scroll_all
= true;
1615 return simplelist_show_list(&info
);
1618 #endif /* HAVE_DIRCACHE */
1620 #ifdef HAVE_TAGCACHE
1621 static int database_callback(int btn
, struct gui_synclist
*lists
)
1624 struct tagcache_stat
*stat
= tagcache_get_stat();
1625 static bool synced
= false;
1627 simplelist_set_line_count(0);
1629 simplelist_addline(SIMPLELIST_ADD_LINE
, "Initialized: %s",
1630 stat
->initialized
? "Yes" : "No");
1631 simplelist_addline(SIMPLELIST_ADD_LINE
, "DB Ready: %s",
1632 stat
->ready
? "Yes" : "No");
1633 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM Cache: %s",
1634 stat
->ramcache
? "Yes" : "No");
1635 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM: %d/%d B",
1636 stat
->ramcache_used
, stat
->ramcache_allocated
);
1637 simplelist_addline(SIMPLELIST_ADD_LINE
, "Progress: %d%% (%d entries)",
1638 stat
->progress
, stat
->processed_entries
);
1639 simplelist_addline(SIMPLELIST_ADD_LINE
, "Curfile: %s",
1640 stat
->curentry
? stat
->curentry
: "---");
1641 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit step: %d",
1643 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit delayed: %s",
1644 stat
->commit_delayed
? "Yes" : "No");
1646 simplelist_addline(SIMPLELIST_ADD_LINE
, "Queue length: %d",
1647 stat
->queue_length
);
1652 tagcache_screensync_event();
1655 if (!btn
&& stat
->curentry
)
1658 return ACTION_REDRAW
;
1661 if (btn
== ACTION_STD_CANCEL
)
1662 tagcache_screensync_enable(false);
1666 static bool dbg_tagcache_info(void)
1668 struct simplelist_info info
;
1669 simplelist_info_init(&info
, "Database Info", 8, NULL
);
1670 info
.action_callback
= database_callback
;
1671 info
.hide_selection
= true;
1672 info
.scroll_all
= true;
1674 /* Don't do nonblock here, must give enough processing time
1675 for tagcache thread. */
1676 /* info.timeout = TIMEOUT_NOBLOCK; */
1678 tagcache_screensync_enable(true);
1679 return simplelist_show_list(&info
);
1683 #if CONFIG_CPU == SH7034
1684 static bool dbg_save_roms(void)
1687 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
1689 fd
= creat("/internal_rom_0000-FFFF.bin", 0666);
1692 write(fd
, (void *)0, 0x10000);
1696 fd
= creat("/internal_rom_2000000-203FFFF.bin", 0666);
1699 write(fd
, (void *)0x2000000, 0x40000);
1703 system_memory_guard(oldmode
);
1706 #elif defined CPU_COLDFIRE
1707 static bool dbg_save_roms(void)
1710 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
1712 #if defined(IRIVER_H100_SERIES)
1713 fd
= creat("/internal_rom_000000-1FFFFF.bin", 0666);
1714 #elif defined(IRIVER_H300_SERIES)
1715 fd
= creat("/internal_rom_000000-3FFFFF.bin", 0666);
1716 #elif defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IAUDIO_M3)
1717 fd
= creat("/internal_rom_000000-3FFFFF.bin", 0666);
1718 #elif defined(MPIO_HD200) || defined(MPIO_HD300)
1719 fd
= creat("/internal_rom_000000-1FFFFF.bin", 0666);
1723 write(fd
, (void *)0, FLASH_SIZE
);
1726 system_memory_guard(oldmode
);
1729 fd
= creat("/internal_eeprom.bin", 0666);
1733 char buf
[EEPROM_SIZE
];
1736 old_irq_level
= disable_irq_save();
1738 err
= eeprom_24cxx_read(0, buf
, sizeof buf
);
1740 restore_irq(old_irq_level
);
1743 splashf(HZ
*3, "Eeprom read failure (%d)", err
);
1746 write(fd
, buf
, sizeof buf
);
1755 #elif defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD)
1756 static bool dbg_save_roms(void)
1758 int fd
= creat("/internal_rom_000000-0FFFFF.bin", 0666);
1761 write(fd
, (void *)0x20000000, FLASH_SIZE
);
1767 #elif CONFIG_CPU == IMX31L
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]);
1857 simplelist_addline(SIMPLELIST_ADD_LINE
, "");
1858 simplelist_addline(SIMPLELIST_ADD_LINE
, "RDS Info:");
1859 simplelist_addline(SIMPLELIST_ADD_LINE
,
1860 si4700_get_rds_info(RADIO_RDS_NAME
));
1862 simplelist_addline(SIMPLELIST_ADD_LINE
,
1863 si4700_get_rds_info(RADIO_RDS_TEXT
));
1867 #if (CONFIG_TUNER & RDA5802)
1868 IF_TUNER_TYPE(RDA5802
)
1870 struct rda5802_dbg_info nfo
;
1871 rda5802_dbg_info(&nfo
);
1872 simplelist_addline(SIMPLELIST_ADD_LINE
, "RDA5802 regs:");
1873 for (int i
= 0; i
< 16; i
+= 4) {
1874 simplelist_addline(SIMPLELIST_ADD_LINE
,"%02X: %04X %04X %04X %04X",
1875 i
, nfo
.regs
[i
], nfo
.regs
[i
+1], nfo
.regs
[i
+2], nfo
.regs
[i
+3]);
1878 #endif /* RDA55802 */
1879 return ACTION_REDRAW
;
1881 static bool dbg_fm_radio(void)
1883 struct simplelist_info info
;
1884 #ifdef CONFIG_TUNER_MULTI
1885 tuner_type
= tuner_detect_type();
1887 info
.scroll_all
= true;
1888 simplelist_info_init(&info
, "FM Radio", 1, NULL
);
1889 simplelist_set_line_count(0);
1890 simplelist_addline(SIMPLELIST_ADD_LINE
, "HW detected: %s",
1891 radio_hardware_present() ? "yes" : "no");
1893 info
.action_callback
= radio_hardware_present()?radio_callback
: NULL
;
1894 info
.hide_selection
= true;
1895 return simplelist_show_list(&info
);
1897 #endif /* CONFIG_TUNER */
1898 #endif /* !SIMULATOR */
1900 #if defined(HAVE_LCD_BITMAP) && !defined(APPLICATION)
1901 extern bool do_screendump_instead_of_usb
;
1903 static bool dbg_screendump(void)
1905 do_screendump_instead_of_usb
= !do_screendump_instead_of_usb
;
1906 splashf(HZ
, "Screendump %sabled", do_screendump_instead_of_usb
?"en":"dis");
1909 #endif /* HAVE_LCD_BITMAP */
1911 extern bool write_metadata_log
;
1913 static bool dbg_metadatalog(void)
1915 write_metadata_log
= !write_metadata_log
;
1916 splashf(HZ
, "Metadata log %sabled", write_metadata_log
? "en" : "dis");
1920 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
1921 static bool dbg_set_memory_guard(void)
1923 static const struct opt_items names
[MAXMEMGUARD
] = {
1925 { "Flash ROM writes", -1 },
1926 { "Zero area (all)", -1 }
1928 int mode
= system_memory_guard(MEMGUARD_KEEP
);
1930 set_option( "Catch mem accesses", &mode
, INT
, names
, MAXMEMGUARD
, NULL
);
1931 system_memory_guard(mode
);
1935 #endif /* CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) */
1937 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
1938 static bool dbg_write_eeprom(void)
1940 int fd
= open("/internal_eeprom.bin", O_RDONLY
);
1944 char buf
[EEPROM_SIZE
];
1945 int rc
= read(fd
, buf
, EEPROM_SIZE
);
1947 if(rc
== EEPROM_SIZE
)
1949 int old_irq_level
= disable_irq_save();
1951 int err
= eeprom_24cxx_write(0, buf
, sizeof buf
);
1953 splashf(HZ
*3, "Eeprom write failure (%d)", err
);
1955 splash(HZ
*3, "Eeprom written successfully");
1957 restore_irq(old_irq_level
);
1961 splashf(HZ
*3, "File read error (%d)",rc
);
1967 splash(HZ
*3, "Failed to open 'internal_eeprom.bin'");
1972 #endif /* defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS) */
1973 #ifdef CPU_BOOST_LOGGING
1974 static bool cpu_boost_log(void)
1976 int count
= cpu_boost_log_getcount();
1977 char *str
= cpu_boost_log_getlog_first();
1979 lcd_setfont(FONT_SYSFIXED
);
1980 for (int i
= 0; i
< count
;)
1982 lcd_clear_display();
1983 for(int j
=0; j
<LCD_HEIGHT
/SYSFONT_HEIGHT
; j
++,i
++)
1986 str
= cpu_boost_log_getlog_next();
1989 if(strlen(str
) > LCD_WIDTH
/SYSFONT_WIDTH
)
1990 lcd_puts_scroll(0, j
, str
);
2000 switch(get_action(CONTEXT_STD
,TIMEOUT_BLOCK
))
2003 case ACTION_STD_PREV
:
2004 case ACTION_STD_NEXT
:
2007 case ACTION_STD_CANCEL
:
2015 get_action(CONTEXT_STD
,TIMEOUT_BLOCK
);
2016 lcd_setfont(FONT_UI
);
2021 #if (defined(HAVE_WHEEL_ACCELERATION) && (CONFIG_KEYPAD==IPOD_4G_PAD) \
2022 && !defined(IPOD_MINI) && !defined(SIMULATOR))
2023 extern bool wheel_is_touched
;
2024 extern int old_wheel_value
;
2025 extern int new_wheel_value
;
2026 extern int wheel_delta
;
2027 extern unsigned int accumulated_wheel_delta
;
2028 extern unsigned int wheel_velocity
;
2030 static bool dbg_scrollwheel(void)
2032 lcd_setfont(FONT_SYSFIXED
);
2036 if (action_userabort(HZ
/10))
2039 lcd_clear_display();
2041 /* show internal variables of scrollwheel driver */
2042 lcd_putsf(0, 0, "wheel touched: %s", (wheel_is_touched
) ? "true" : "false");
2043 lcd_putsf(0, 1, "new position: %2d", new_wheel_value
);
2044 lcd_putsf(0, 2, "old position: %2d", old_wheel_value
);
2045 lcd_putsf(0, 3, "wheel delta: %2d", wheel_delta
);
2046 lcd_putsf(0, 4, "accumulated delta: %2d", accumulated_wheel_delta
);
2047 lcd_putsf(0, 5, "velo [deg/s]: %4d", (int)wheel_velocity
);
2049 /* show effective accelerated scrollspeed */
2050 lcd_putsf(0, 6, "accel. speed: %4d",
2051 button_apply_acceleration((1<<31)|(1<<24)|wheel_velocity
) );
2055 lcd_setfont(FONT_UI
);
2060 #ifdef HAVE_USBSTACK
2061 #if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL)
2062 static bool toggle_usb_serial(void)
2064 bool enabled
= !usb_core_driver_enabled(USB_DRIVER_SERIAL
);
2066 usb_core_enable_driver(USB_DRIVER_SERIAL
, enabled
);
2067 splashf(HZ
, "USB Serial %sabled", enabled
? "en" : "dis");
2074 #if CONFIG_USBOTG == USBOTG_ISP1583
2075 extern int dbg_usb_num_items(void);
2076 extern const char* dbg_usb_item(int selected_item
, void *data
,
2077 char *buffer
, size_t buffer_len
);
2079 static int isp1583_action_callback(int action
, struct gui_synclist
*lists
)
2082 if (action
== ACTION_NONE
)
2083 action
= ACTION_REDRAW
;
2087 static bool dbg_isp1583(void)
2089 struct simplelist_info isp1583
;
2090 isp1583
.scroll_all
= true;
2091 simplelist_info_init(&isp1583
, "ISP1583", dbg_usb_num_items(), NULL
);
2092 isp1583
.timeout
= HZ
/100;
2093 isp1583
.hide_selection
= true;
2094 isp1583
.get_name
= dbg_usb_item
;
2095 isp1583
.action_callback
= isp1583_action_callback
;
2096 return simplelist_show_list(&isp1583
);
2100 #if defined(CREATIVE_ZVx) && !defined(SIMULATOR)
2101 extern int pic_dbg_num_items(void);
2102 extern const char* pic_dbg_item(int selected_item
, void *data
,
2103 char *buffer
, size_t buffer_len
);
2105 static int pic_action_callback(int action
, struct gui_synclist
*lists
)
2108 if (action
== ACTION_NONE
)
2109 action
= ACTION_REDRAW
;
2113 static bool dbg_pic(void)
2115 struct simplelist_info pic
;
2116 pic
.scroll_all
= true;
2117 simplelist_info_init(&pic
, "PIC", pic_dbg_num_items(), NULL
);
2118 pic
.timeout
= HZ
/100;
2119 pic
.hide_selection
= true;
2120 pic
.get_name
= pic_dbg_item
;
2121 pic
.action_callback
= pic_action_callback
;
2122 return simplelist_show_list(&pic
);
2127 /****** The menu *********/
2128 static const struct {
2129 unsigned char *desc
; /* string or ID */
2130 bool (*function
) (void); /* return true if USB was connected */
2132 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || \
2133 (defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD)) || \
2134 CONFIG_CPU == IMX31L || defined(CPU_TCC780X)
2135 { "Dump ROM contents", dbg_save_roms
},
2137 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || defined(CPU_PP) \
2138 || CONFIG_CPU == S3C2440 || CONFIG_CPU == IMX31L || CONFIG_CPU == AS3525 \
2139 || CONFIG_CPU == DM320 || defined(CPU_S5L870X) || CONFIG_CPU == AS3525v2 \
2140 || CONFIG_CPU == RK27XX
2141 { "View I/O ports", dbg_ports
},
2143 #if (CONFIG_RTC == RTC_PCF50605) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
2144 { "View PCF registers", dbg_pcf
},
2146 #if defined(HAVE_TSC2100) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
2147 { "TSC2100 debug", tsc2100_debug
},
2149 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
2150 { "CPU frequency", dbg_cpufreq
},
2152 #if CONFIG_CPU == IMX31L
2153 { "DVFS/DPTC", __dbg_dvfs_dptc
},
2155 #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR)
2156 { "S/PDIF analyzer", dbg_spdif
},
2158 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2159 { "Catch mem accesses", dbg_set_memory_guard
},
2161 { "View OS stacks", dbg_os
},
2163 { "View CPU stats", dbg_cpuinfo
},
2165 #ifdef HAVE_LCD_BITMAP
2166 #if (CONFIG_BATTERY_MEASURE != 0) && !defined(SIMULATOR)
2167 { "View battery", view_battery
},
2170 { "Screendump", dbg_screendump
},
2173 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
2174 { "View HW info", dbg_hw_info
},
2176 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
2177 { "View partitions", dbg_partitions
},
2179 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
2180 { "View disk info", dbg_disk_info
},
2181 #if (CONFIG_STORAGE & STORAGE_ATA)
2182 { "Dump ATA identify info", dbg_identify_info
},
2185 { "Metadata log", dbg_metadatalog
},
2186 #ifdef HAVE_DIRCACHE
2187 { "View dircache info", dbg_dircache_info
},
2189 #ifdef HAVE_TAGCACHE
2190 { "View database info", dbg_tagcache_info
},
2192 #ifdef HAVE_LCD_BITMAP
2193 #if CONFIG_CODEC == SWCODEC
2194 { "View buffering thread", dbg_buffering_thread
},
2195 #elif !defined(SIMULATOR)
2196 { "View audio thread", dbg_audio_thread
},
2199 { "pm histogram", peak_meter_histogram
},
2200 #endif /* PM_DEBUG */
2201 #endif /* HAVE_LCD_BITMAP */
2202 { "View buflib allocs", dbg_buflib_allocs
},
2205 { "FM Radio", dbg_fm_radio
},
2208 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2209 { "Write back EEPROM", dbg_write_eeprom
},
2211 #if CONFIG_USBOTG == USBOTG_ISP1583
2212 { "View ISP1583 info", dbg_isp1583
},
2214 #if defined(CREATIVE_ZVx) && !defined(SIMULATOR)
2215 { "View PIC info", dbg_pic
},
2217 #ifdef ROCKBOX_HAS_LOGF
2218 {"Show Log File", logfdisplay
},
2219 {"Dump Log File", logfdump
},
2221 #if defined(HAVE_USBSTACK)
2222 #if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL)
2223 {"USB Serial driver (logf)", toggle_usb_serial
},
2225 #endif /* HAVE_USBSTACK */
2226 #ifdef CPU_BOOST_LOGGING
2227 {"cpu_boost log",cpu_boost_log
},
2229 #if (defined(HAVE_WHEEL_ACCELERATION) && (CONFIG_KEYPAD==IPOD_4G_PAD) \
2230 && !defined(IPOD_MINI) && !defined(SIMULATOR))
2231 {"Debug scrollwheel", dbg_scrollwheel
},
2235 static int menu_action_callback(int btn
, struct gui_synclist
*lists
)
2237 int selection
= gui_synclist_get_sel_pos(lists
);
2238 if (btn
== ACTION_STD_OK
)
2241 viewportmanager_theme_enable(i
, false, NULL
);
2242 menuitems
[selection
].function();
2243 btn
= ACTION_REDRAW
;
2245 viewportmanager_theme_undo(i
, false);
2247 else if (btn
== ACTION_STD_CONTEXT
)
2249 MENUITEM_STRINGLIST(menu_items
, "Debug Menu", NULL
, ID2P(LANG_ADD_TO_FAVES
));
2250 if (do_menu(&menu_items
, NULL
, NULL
, false) == 0)
2251 shortcuts_add(SHORTCUT_DEBUGITEM
, menuitems
[selection
].desc
);
2252 return ACTION_STD_CANCEL
;
2257 static const char* menu_get_name(int item
, void * data
,
2258 char *buffer
, size_t buffer_len
)
2260 (void)data
; (void)buffer
; (void)buffer_len
;
2261 return menuitems
[item
].desc
;
2264 bool debug_menu(void)
2266 struct simplelist_info info
;
2268 simplelist_info_init(&info
, "Debug Menu", ARRAYLEN(menuitems
), NULL
);
2269 info
.action_callback
= menu_action_callback
;
2270 info
.get_name
= menu_get_name
;
2271 return simplelist_show_list(&info
);
2274 bool run_debug_screen(char* screen
)
2276 for (unsigned i
=0; i
<ARRAYLEN(menuitems
); i
++)
2277 if (!strcmp(screen
, menuitems
[i
].desc
))
2280 viewportmanager_theme_enable(j
, false, NULL
);
2281 menuitems
[i
].function();
2283 viewportmanager_theme_undo(j
, false);