1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Heikki Hannikainen
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
30 #include "debug_menu.h"
36 #include "powermgmt.h"
40 #include "mp3_playback.h"
43 #include "statusbar.h"
49 #include "shortcuts.h"
55 #ifdef HAVE_REMOTE_LCD
56 #include "lcd-remote.h"
60 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
67 #include "eeprom_24cxx.h"
68 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
71 #if (CONFIG_STORAGE & STORAGE_ATA)
81 #ifdef HAVE_LCD_BITMAP
82 #include "scrollbar.h"
83 #include "peakmeter.h"
86 #include "core_alloc.h"
87 #if CONFIG_CODEC == SWCODEC
89 #include "buffering.h"
91 #if defined(HAVE_SPDIF_OUT) || defined(HAVE_SPDIF_IN)
95 #ifdef IRIVER_H300_SERIES
96 #include "pcf50606.h" /* for pcf50606_read */
101 #include "hwcompat.h"
103 #if CONFIG_RTC == RTC_PCF50605
104 #include "pcf50605.h"
106 #include "appevents.h"
107 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
108 #include "debug-target.h"
111 #if defined(HAVE_AS3514) && defined(CONFIG_CHARGING)
116 #include "pmu-target.h"
120 #include "usb_core.h"
123 #if defined(IPOD_ACCESSORY_PROTOCOL)
131 /*---------------------------------------------------*/
132 /* SPECIAL DEBUG STUFF */
133 /*---------------------------------------------------*/
134 extern struct thread_entry threads
[MAXTHREADS
];
136 static char thread_status_char(unsigned status
)
138 static const char thread_status_chars
[THREAD_NUM_STATES
+1] =
140 [0 ... THREAD_NUM_STATES
] = '?',
141 [STATE_RUNNING
] = 'R',
142 [STATE_BLOCKED
] = 'B',
143 [STATE_SLEEPING
] = 'S',
144 [STATE_BLOCKED_W_TMO
] = 'T',
145 [STATE_FROZEN
] = 'F',
146 [STATE_KILLED
] = 'K',
149 if (status
> THREAD_NUM_STATES
)
150 status
= THREAD_NUM_STATES
;
152 return thread_status_chars
[status
];
155 static const char* threads_getname(int selected_item
, void *data
,
156 char *buffer
, size_t buffer_len
)
159 struct thread_entry
*thread
;
163 if (selected_item
< (int)NUM_CORES
)
165 snprintf(buffer
, buffer_len
, "Idle (%d): %2d%%", selected_item
,
166 idle_stack_usage(selected_item
));
170 selected_item
-= NUM_CORES
;
173 thread
= &threads
[selected_item
];
175 if (thread
->state
== STATE_KILLED
)
177 snprintf(buffer
, buffer_len
, "%2d: ---", selected_item
);
181 thread_get_name(name
, 32, thread
);
183 snprintf(buffer
, buffer_len
,
184 "%2d: " IF_COP("(%d) ") "%c%c " IF_PRIO("%d %d ") "%2d%% %s",
186 IF_COP(thread
->core
,)
187 #ifdef HAVE_SCHEDULER_BOOSTCTRL
188 (thread
->cpu_boost
) ? '+' :
190 ((thread
->state
== STATE_RUNNING
) ? '*' : ' '),
191 thread_status_char(thread
->state
),
192 IF_PRIO(thread
->base_priority
, thread
->priority
, )
193 thread_stack_usage(thread
), name
);
198 static int dbg_threads_action_callback(int action
, struct gui_synclist
*lists
)
201 #ifdef ROCKBOX_HAS_LOGF
202 if (action
== ACTION_STD_OK
)
204 int selpos
= gui_synclist_get_sel_pos(lists
);
206 if (selpos
>= NUM_CORES
)
207 remove_thread(threads
[selpos
- NUM_CORES
].id
);
209 remove_thread(threads
[selpos
].id
);
211 return ACTION_REDRAW
;
213 #endif /* ROCKBOX_HAS_LOGF */
214 if (action
== ACTION_NONE
)
215 action
= ACTION_REDRAW
;
219 static bool dbg_os(void)
221 struct simplelist_info info
;
222 simplelist_info_init(&info
, IF_COP("Core and ") "Stack usage:",
226 MAXTHREADS
+NUM_CORES
,
229 #ifndef ROCKBOX_HAS_LOGF
230 info
.hide_selection
= true;
231 info
.scroll_all
= true;
233 info
.action_callback
= dbg_threads_action_callback
;
234 info
.get_name
= threads_getname
;
235 return simplelist_show_list(&info
);
239 #include "cpuinfo-linux.h"
241 #define MAX_STATES 16
242 static struct time_state states
[MAX_STATES
];
244 static const char* get_cpuinfo(int selected_item
, void *data
,
245 char *buffer
, size_t buffer_len
)
247 (void)data
;(void)buffer_len
;
251 static struct cpuusage last_us
;
252 int state_count
= *(int*)data
;
254 if (cpuusage_linux(&us
) != 0)
257 switch(selected_item
)
260 diff
= abs(last_us
.usage
- us
.usage
);
261 sprintf(buffer
, "Usage: %ld.%02ld%% (%c %ld.%02ld)",
262 us
.usage
/100, us
.usage
%100,
263 (us
.usage
>= last_us
.usage
) ? '+':'-',
265 last_us
.usage
= us
.usage
;
270 diff
= us
.utime
- last_us
.utime
;
271 last_us
.utime
= us
.utime
;
276 diff
= us
.stime
- last_us
.stime
;
277 last_us
.stime
= us
.stime
;
282 diff
= us
.rtime
- last_us
.rtime
;
283 last_us
.rtime
= us
.rtime
;
286 return "*** Per CPU freq stats ***";
289 int cpu
= (selected_item
- 5) / (state_count
+ 1);
290 int cpu_line
= (selected_item
- 5) % (state_count
+ 1);
291 int freq1
= frequency_linux(cpu
, false);
292 int freq2
= frequency_linux(cpu
, true);
295 sprintf(buffer
, " CPU%d: Cur/Scal freq: %d/%d MHz", cpu
,
296 freq1
> 0 ? freq1
/1000 : -1,
297 freq2
> 0 ? freq2
/1000 : -1);
301 cpustatetimes_linux(cpu
, states
, ARRAYLEN(states
));
302 snprintf(buffer
, buffer_len
, " %ld %ld",
303 states
[cpu_line
-1].frequency
,
304 states
[cpu_line
-1].time
);
309 sprintf(buffer
, "%s: %ld.%02lds (+ %ld.%02ld)", text
,
310 time
/ us
.hz
, time
% us
.hz
,
311 diff
/ us
.hz
, diff
% us
.hz
);
315 static int cpuinfo_cb(int action
, struct gui_synclist
*lists
)
318 if (action
== ACTION_NONE
)
319 action
= ACTION_REDRAW
;
323 static bool dbg_cpuinfo(void)
325 struct simplelist_info info
;
326 int cpu_count
= MAX(cpucount_linux(), 1);
327 int state_count
= cpustatetimes_linux(0, states
, ARRAYLEN(states
));
328 printf("%s(): %d %d\n", __func__
, cpu_count
, state_count
);
329 simplelist_info_init(&info
, "CPU info:", 5 + cpu_count
*(state_count
+1), &state_count
);
330 info
.get_name
= get_cpuinfo
;
331 info
.action_callback
= cpuinfo_cb
;
333 info
.hide_selection
= true;
334 info
.scroll_all
= true;
335 return simplelist_show_list(&info
);
340 #ifdef HAVE_LCD_BITMAP
341 #if CONFIG_CODEC != SWCODEC
343 static bool dbg_audio_thread(void)
345 struct audio_debug d
;
347 lcd_setfont(FONT_SYSFIXED
);
351 if (action_userabort(HZ
/5))
354 audio_get_debugdata(&d
);
358 lcd_putsf(0, 0, "read: %x", d
.audiobuf_read
);
359 lcd_putsf(0, 1, "write: %x", d
.audiobuf_write
);
360 lcd_putsf(0, 2, "swap: %x", d
.audiobuf_swapwrite
);
361 lcd_putsf(0, 3, "playing: %d", d
.playing
);
362 lcd_putsf(0, 4, "playable: %x", d
.playable_space
);
363 lcd_putsf(0, 5, "unswapped: %x", d
.unswapped_space
);
365 /* Playable space left */
366 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8, 112, 4, d
.audiobuflen
, 0,
367 d
.playable_space
, HORIZONTAL
);
369 /* Show the watermark limit */
370 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8+4, 112, 4, d
.audiobuflen
, 0,
371 d
.low_watermark_level
, HORIZONTAL
);
373 lcd_putsf(0, 7, "wm: %x - %x",
374 d
.low_watermark_level
, d
.lowest_watermark_level
);
378 lcd_setfont(FONT_UI
);
381 #endif /* !SIMULATOR */
382 #else /* CONFIG_CODEC == SWCODEC */
383 static unsigned int ticks
, freq_sum
;
384 #ifndef CPU_MULTI_FREQUENCY
385 static unsigned int boost_ticks
;
388 static void dbg_audio_task(void)
390 #ifdef CPUFREQ_NORMAL
391 #ifndef CPU_MULTI_FREQUENCY
392 if(FREQ
> CPUFREQ_NORMAL
)
395 freq_sum
+= FREQ
/1000000; /* in MHz */
400 static bool dbg_buffering_thread(void)
406 size_t bufsize
= pcmbuf_get_bufsize();
407 int pcmbufdescs
= pcmbuf_descs();
408 struct buffering_debug d
;
409 size_t filebuflen
= audio_get_filebuflen();
410 /* This is a size_t, but call it a long so it puts a - when it's bad. */
412 #ifndef CPU_MULTI_FREQUENCY
415 ticks
= freq_sum
= 0;
417 tick_add_task(dbg_audio_task
);
420 screens
[i
].setfont(FONT_SYSFIXED
);
424 button
= get_action(CONTEXT_STD
,HZ
/5);
427 case ACTION_STD_NEXT
:
430 case ACTION_STD_PREV
:
433 case ACTION_STD_CANCEL
:
438 buffering_get_debugdata(&d
);
439 bufused
= bufsize
- pcmbuf_free();
444 screens
[i
].clear_display();
447 screens
[i
].putsf(0, line
++, "pcm: %6ld/%ld", (long) bufused
, (long) bufsize
);
449 gui_scrollbar_draw(&screens
[i
],0, line
*8, screens
[i
].lcdwidth
, 6,
450 bufsize
, 0, bufused
, HORIZONTAL
);
453 screens
[i
].putsf(0, line
++, "alloc: %6ld/%ld", audio_filebufused(),
456 #if LCD_HEIGHT > 80 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_HEIGHT > 80)
457 if (screens
[i
].lcdheight
> 80)
459 gui_scrollbar_draw(&screens
[i
],0, line
*8, screens
[i
].lcdwidth
, 6,
460 filebuflen
, 0, audio_filebufused(), HORIZONTAL
);
463 screens
[i
].putsf(0, line
++, "real: %6ld/%ld", (long)d
.buffered_data
,
466 gui_scrollbar_draw(&screens
[i
],0, line
*8, screens
[i
].lcdwidth
, 6,
467 filebuflen
, 0, (long)d
.buffered_data
, HORIZONTAL
);
472 screens
[i
].putsf(0, line
++, "usefl: %6ld/%ld", (long)(d
.useful_data
),
475 #if LCD_HEIGHT > 80 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_HEIGHT > 80)
476 if (screens
[i
].lcdheight
> 80)
478 gui_scrollbar_draw(&screens
[i
],0, line
*8, screens
[i
].lcdwidth
, 6,
479 filebuflen
, 0, d
.useful_data
, HORIZONTAL
);
484 screens
[i
].putsf(0, line
++, "data_rem: %ld", (long)d
.data_rem
);
486 screens
[i
].putsf(0, line
++, "track count: %2d", audio_track_count());
488 screens
[i
].putsf(0, line
++, "handle count: %d", (int)d
.num_handles
);
490 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
491 screens
[i
].putsf(0, line
++, "cpu freq: %3dMHz",
492 (int)((FREQ
+ 500000) / 1000000));
497 int avgclock
= freq_sum
* 10 / ticks
; /* in 100 kHz */
498 #ifdef CPU_MULTI_FREQUENCY
499 int boostquota
= (avgclock
* 100 - CPUFREQ_NORMAL
/1000) /
500 ((CPUFREQ_MAX
- CPUFREQ_NORMAL
) / 1000000); /* in 0.1 % */
502 int boostquota
= boost_ticks
* 1000 / ticks
; /* in 0.1 % */
504 screens
[i
].putsf(0, line
++, "boost:%3d.%d%% (%d.%dMHz)",
505 boostquota
/10, boostquota
%10, avgclock
/10, avgclock
%10);
508 screens
[i
].putsf(0, line
++, "pcmbufdesc: %2d/%2d",
509 pcmbuf_used_descs(), pcmbufdescs
);
510 screens
[i
].putsf(0, line
++, "watermark: %6d",
517 tick_remove_task(dbg_audio_task
);
520 screens
[i
].setfont(FONT_UI
);
524 #endif /* CONFIG_CODEC */
525 #endif /* HAVE_LCD_BITMAP */
527 static const char* bf_getname(int selected_item
, void *data
,
528 char *buffer
, size_t buffer_len
)
531 core_print_block_at(selected_item
, buffer
, buffer_len
);
535 static int bf_action_cb(int action
, struct gui_synclist
* list
)
537 if (action
== ACTION_STD_OK
)
539 if (gui_synclist_get_sel_pos(list
) == 0 && core_test_free())
541 splash(HZ
, "Freed test handle. New alloc should trigger compact");
545 splash(HZ
/1, "Attempting a 64k allocation");
546 int handle
= core_alloc("test", 64<<10);
547 splash(HZ
/2, (handle
> 0) ? "Success":"Fail");
548 /* for some reason simplelist doesn't allow adding items here if
549 * info.get_name is given, so use normal list api */
550 gui_synclist_set_nb_items(list
, core_get_num_blocks());
554 action
= ACTION_REDRAW
;
556 else if (action
== ACTION_NONE
)
557 action
= ACTION_REDRAW
;
561 static bool dbg_buflib_allocs(void)
563 struct simplelist_info info
;
564 simplelist_info_init(&info
, "mem allocs", core_get_num_blocks(), NULL
);
565 info
.get_name
= bf_getname
;
566 info
.action_callback
= bf_action_cb
;
567 info
.timeout
= TIMEOUT_BLOCK
;
568 return simplelist_show_list(&info
);
571 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
572 static const char* dbg_partitions_getname(int selected_item
, void *data
,
573 char *buffer
, size_t buffer_len
)
576 int partition
= selected_item
/2;
577 struct partinfo
* p
= disk_partinfo(partition
);
580 snprintf(buffer
, buffer_len
, " T:%x %ld MB", p
->type
, p
->size
/ ( 2048 / ( SECTOR_SIZE
/ 512 )));
584 snprintf(buffer
, buffer_len
, "P%d: S:%lx", partition
, p
->start
);
589 static bool dbg_partitions(void)
591 struct simplelist_info info
;
592 simplelist_info_init(&info
, "Partition Info", 4, NULL
);
593 info
.selection_size
= 2;
594 info
.hide_selection
= true;
595 info
.scroll_all
= true;
596 info
.get_name
= dbg_partitions_getname
;
597 return simplelist_show_list(&info
);
599 #endif /* PLATFORM_NATIVE */
601 #if defined(CPU_COLDFIRE) && defined(HAVE_SPDIF_OUT)
602 static bool dbg_spdif(void)
605 unsigned int control
;
610 unsigned int interruptstat
;
611 bool valnogood
, symbolerr
, parityerr
;
614 int spdif_source
= spdif_get_output_source(&spdif_src_on
);
615 spdif_set_output_source(AUDIO_SRC_SPDIF
IF_SPDIF_POWER_(, true));
618 lcd_setfont(FONT_SYSFIXED
);
620 #ifdef HAVE_SPDIF_POWER
621 spdif_power_enable(true); /* We need SPDIF power for both sending & receiving */
628 control
= EBU1RCVCCHANNEL1
;
629 interruptstat
= INTERRUPTSTAT
;
630 INTERRUPTCLEAR
= 0x03c00000;
632 valnogood
= (interruptstat
& 0x01000000)?true:false;
633 symbolerr
= (interruptstat
& 0x00800000)?true:false;
634 parityerr
= (interruptstat
& 0x00400000)?true:false;
636 lcd_putsf(0, line
++, "Val: %s Sym: %s Par: %s",
639 parityerr
?"--":"OK");
641 lcd_putsf(0, line
++, "Status word: %08x", (int)control
);
646 lcd_putsf(0, line
++, "PRO: %d (%s)",
647 x
, x
?"Professional":"Consumer");
649 x
= (control
>> 30) & 1;
650 lcd_putsf(0, line
++, "Audio: %d (%s)",
651 x
, x
?"Non-PCM":"PCM");
653 x
= (control
>> 29) & 1;
654 lcd_putsf(0, line
++, "Copy: %d (%s)",
655 x
, x
?"Permitted":"Inhibited");
657 x
= (control
>> 27) & 7;
670 lcd_putsf(0, line
++, "Preemphasis: %d (%s)", x
, s
);
672 x
= (control
>> 24) & 3;
673 lcd_putsf(0, line
++, "Mode: %d", x
);
675 category
= (control
>> 17) & 127;
687 lcd_putsf(0, line
++, "Category: 0x%02x (%s)", category
, s
);
689 x
= (control
>> 16) & 1;
691 if(((category
& 0x70) == 0x10) ||
692 ((category
& 0x70) == 0x40) ||
693 ((category
& 0x78) == 0x38))
695 generation
= !generation
;
697 lcd_putsf(0, line
++, "Generation: %d (%s)",
698 x
, generation
?"Original":"No ind.");
700 x
= (control
>> 12) & 15;
701 lcd_putsf(0, line
++, "Source: %d", x
);
704 x
= (control
>> 8) & 15;
720 lcd_putsf(0, line
++, "Channel: %d (%s)", x
, s
);
722 x
= (control
>> 4) & 15;
735 lcd_putsf(0, line
++, "Frequency: %d (%s)", x
, s
);
737 x
= (control
>> 2) & 3;
738 lcd_putsf(0, line
++, "Clock accuracy: %d", x
);
741 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
742 lcd_putsf(0, line
++, "Measured freq: %ldHz",
743 spdif_measure_frequency());
748 if (action_userabort(HZ
/10))
752 spdif_set_output_source(spdif_source
IF_SPDIF_POWER_(, spdif_src_on
));
754 #ifdef HAVE_SPDIF_POWER
755 spdif_power_enable(global_settings
.spdif_enable
);
758 lcd_setfont(FONT_UI
);
761 #endif /* CPU_COLDFIRE */
763 #if (CONFIG_RTC == RTC_PCF50605) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
764 static bool dbg_pcf(void)
768 #ifdef HAVE_LCD_BITMAP
769 lcd_setfont(FONT_SYSFIXED
);
777 lcd_putsf(0, line
++, "DCDC1: %02x", pcf50605_read(0x1b));
778 lcd_putsf(0, line
++, "DCDC2: %02x", pcf50605_read(0x1c));
779 lcd_putsf(0, line
++, "DCDC3: %02x", pcf50605_read(0x1d));
780 lcd_putsf(0, line
++, "DCDC4: %02x", pcf50605_read(0x1e));
781 lcd_putsf(0, line
++, "DCDEC1: %02x", pcf50605_read(0x1f));
782 lcd_putsf(0, line
++, "DCDEC2: %02x", pcf50605_read(0x20));
783 lcd_putsf(0, line
++, "DCUDC1: %02x", pcf50605_read(0x21));
784 lcd_putsf(0, line
++, "DCUDC2: %02x", pcf50605_read(0x22));
785 lcd_putsf(0, line
++, "IOREGC: %02x", pcf50605_read(0x23));
786 lcd_putsf(0, line
++, "D1REGC: %02x", pcf50605_read(0x24));
787 lcd_putsf(0, line
++, "D2REGC: %02x", pcf50605_read(0x25));
788 lcd_putsf(0, line
++, "D3REGC: %02x", pcf50605_read(0x26));
789 lcd_putsf(0, line
++, "LPREG1: %02x", pcf50605_read(0x27));
791 if (action_userabort(HZ
/10))
793 lcd_setfont(FONT_UI
);
798 lcd_setfont(FONT_UI
);
803 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
804 static bool dbg_cpufreq(void)
809 #ifdef HAVE_LCD_BITMAP
810 lcd_setfont(FONT_SYSFIXED
);
818 lcd_putsf(0, line
++, "Frequency: %ld", FREQ
);
819 lcd_putsf(0, line
++, "boost_counter: %d", get_cpu_boost_counter());
822 button
= get_action(CONTEXT_STD
,HZ
/10);
826 case ACTION_STD_PREV
:
830 case ACTION_STD_NEXT
:
835 while (get_cpu_boost_counter() > 0)
837 set_cpu_frequency(CPUFREQ_DEFAULT
);
840 case ACTION_STD_CANCEL
:
841 lcd_setfont(FONT_UI
);
845 lcd_setfont(FONT_UI
);
848 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
850 #if defined(HAVE_TSC2100) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
852 static const char* tsc2100_debug_getname(int selected_item
, void * data
,
853 char *buffer
, size_t buffer_len
)
855 int *page
= (int*)data
;
856 bool reserved
= false;
860 if ((selected_item
> 0x0a) ||
861 (selected_item
== 0x04) ||
862 (selected_item
== 0x08))
866 if ((selected_item
> 0x05) ||
867 (selected_item
== 0x02))
871 if (selected_item
> 0x1e)
876 snprintf(buffer
, buffer_len
, "%02x: RSVD", selected_item
);
878 snprintf(buffer
, buffer_len
, "%02x: %04x", selected_item
,
879 tsc2100_readreg(*page
, selected_item
)&0xffff);
882 static int tsc2100debug_action_callback(int action
, struct gui_synclist
*lists
)
884 int *page
= (int*)lists
->data
;
885 if (action
== ACTION_STD_OK
)
888 snprintf(lists
->title
, 32,
889 "tsc2100 registers - Page %d", *page
);
890 return ACTION_REDRAW
;
894 static bool tsc2100_debug(void)
897 char title
[32] = "tsc2100 registers - Page 0";
898 struct simplelist_info info
;
899 simplelist_info_init(&info
, title
, 32, &page
);
900 info
.timeout
= HZ
/100;
901 info
.get_name
= tsc2100_debug_getname
;
902 info
.action_callback
= tsc2100debug_action_callback
;
903 return simplelist_show_list(&info
);
906 #if (CONFIG_BATTERY_MEASURE != 0) && defined(HAVE_LCD_BITMAP) && !defined(SIMULATOR)
908 * view_battery() shows a automatically scaled graph of the battery voltage
909 * over time. Usable for estimating battery life / charging rate.
910 * The power_history array is updated in power_thread of powermgmt.c.
913 #define BAT_LAST_VAL MIN(LCD_WIDTH, POWER_HISTORY_LEN)
914 #define BAT_TSPACE 20
915 #define BAT_YSPACE (LCD_HEIGHT - BAT_TSPACE)
918 static bool view_battery(void)
921 int i
, x
, y
, z
, y1
, y2
, grid
, graph
;
922 unsigned short maxv
, minv
;
924 lcd_setfont(FONT_SYSFIXED
);
930 case 0: /* voltage history graph */
931 /* Find maximum and minimum voltage for scaling */
932 minv
= power_history
[0];
934 for (i
= 1; i
< BAT_LAST_VAL
&& power_history
[i
]; i
++) {
935 if (power_history
[i
] > maxv
)
936 maxv
= power_history
[i
];
937 if (power_history
[i
] < minv
)
938 minv
= power_history
[i
];
941 #if (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE)
942 /* adjust grid scale */
943 if ((maxv
- minv
) > 50)
948 lcd_putsf(0, 0, "battery %d.%03dV", power_history
[0] / 1000,
949 power_history
[0] % 1000);
950 lcd_putsf(0, 1, "%d.%03d-%d.%03dV (%2dmV)",
951 minv
/ 1000, minv
% 1000, maxv
/ 1000, maxv
% 1000,
953 #elif (CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE)
954 /* adjust grid scale */
955 if ((maxv
- minv
) > 10)
959 lcd_putsf(0, 0, "battery %d%%", power_history
[0]);
960 lcd_putsf(0, 1, "%d%%-%d%% (%d %%)", minv
, maxv
, grid
);
964 while ((y
= (minv
- (minv
% grid
)+i
*grid
)) < maxv
)
966 graph
= ((y
-minv
)*BAT_YSPACE
)/(maxv
-minv
);
967 graph
= LCD_HEIGHT
-1 - graph
;
969 /* draw dotted horizontal grid line */
970 for (x
=0; x
<LCD_WIDTH
;x
=x
+2)
971 lcd_drawpixel(x
,graph
);
977 /* draw plot of power history
980 for (i
= BAT_LAST_VAL
- 1; i
> 0; i
--)
982 if (power_history
[i
] && power_history
[i
-1])
984 y1
= (power_history
[i
] - minv
) * BAT_YSPACE
/
986 y1
= MIN(MAX(LCD_HEIGHT
-1 - y1
, BAT_TSPACE
),
988 y2
= (power_history
[i
-1] - minv
) * BAT_YSPACE
/
990 y2
= MIN(MAX(LCD_HEIGHT
-1 - y2
, BAT_TSPACE
),
993 lcd_set_drawmode(DRMODE_SOLID
);
995 /* make line thicker */
996 lcd_drawline(((x
*LCD_WIDTH
)/(BAT_LAST_VAL
)),
998 (((x
+1)*LCD_WIDTH
)/(BAT_LAST_VAL
)),
1000 lcd_drawline(((x
*LCD_WIDTH
)/(BAT_LAST_VAL
))+1,
1002 (((x
+1)*LCD_WIDTH
)/(BAT_LAST_VAL
))+1,
1009 case 1: /* status: */
1010 #if CONFIG_CHARGING >= CHARGING_MONITOR
1011 lcd_putsf(0, 0, "Pwr status: %s",
1012 charging_state() ? "charging" : "discharging");
1014 lcd_puts(0, 0, "Power status: unknown");
1016 battery_read_info(&y
, &z
);
1018 lcd_putsf(0, 1, "Battery: %d.%03d V (%d %%)", y
/ 1000, y
% 1000, z
);
1020 lcd_putsf(0, 1, "Battery: %d %%", z
);
1021 #ifdef ADC_EXT_POWER
1022 y
= (adc_read(ADC_EXT_POWER
) * EXT_SCALE_FACTOR
) / 1000;
1023 lcd_putsf(0, 2, "External: %d.%03d V", y
/ 1000, y
% 1000);
1026 #if defined ARCHOS_RECORDER
1027 lcd_putsf(0, 3, "Chgr: %s %s",
1028 charger_inserted() ? "present" : "absent",
1029 charger_enabled() ? "on" : "off");
1030 lcd_putsf(0, 5, "short delta: %d", short_delta
);
1031 lcd_putsf(0, 6, "long delta: %d", long_delta
);
1032 lcd_puts(0, 7, power_message
);
1033 lcd_putsf(0, 8, "USB Inserted: %s",
1034 usb_inserted() ? "yes" : "no");
1035 #elif defined IPOD_NANO || defined IPOD_VIDEO
1036 int usb_pwr
= (GPIOL_INPUT_VAL
& 0x10)?true:false;
1037 int ext_pwr
= (GPIOL_INPUT_VAL
& 0x08)?false:true;
1038 int dock
= (GPIOA_INPUT_VAL
& 0x10)?true:false;
1039 int charging
= (GPIOB_INPUT_VAL
& 0x01)?false:true;
1040 int headphone
= (GPIOA_INPUT_VAL
& 0x80)?true:false;
1042 lcd_putsf(0, 3, "USB pwr: %s",
1043 usb_pwr
? "present" : "absent");
1044 lcd_putsf(0, 4, "EXT pwr: %s",
1045 ext_pwr
? "present" : "absent");
1046 lcd_putsf(0, 5, "Battery: %s",
1047 charging
? "charging" : (usb_pwr
||ext_pwr
) ? "charged" : "discharging");
1048 lcd_putsf(0, 6, "Dock mode: %s",
1049 dock
? "enabled" : "disabled");
1050 lcd_putsf(0, 7, "Headphone: %s",
1051 headphone
? "connected" : "disconnected");
1053 if(probed_ramsize
== 64)
1054 x
= (adc_read(ADC_4066_ISTAT
) * 2400) / (1024 * 2);
1057 x
= (adc_read(ADC_4066_ISTAT
) * 2400) / (1024 * 3);
1058 lcd_putsf(0, 8, "Ibat: %d mA", x
);
1059 lcd_putsf(0, 9, "Vbat * Ibat: %d mW", x
* y
/ 1000);
1060 #elif defined TOSHIBA_GIGABEAT_S
1064 static const unsigned char * const chrgstate_strings
[] =
1075 lcd_putsf(0, line
++, "Charger: %s",
1076 charger_inserted() ? "present" : "absent");
1078 st
= power_input_status() &
1079 (POWER_INPUT_CHARGER
| POWER_INPUT_BATTERY
);
1080 lcd_putsf(0, line
++, "%s%s",
1081 (st
& POWER_INPUT_MAIN_CHARGER
) ? " Main" : "",
1082 (st
& POWER_INPUT_USB_CHARGER
) ? " USB" : "");
1084 y
= ARRAYLEN(chrgstate_strings
) - 1;
1086 switch (charge_state
)
1088 case CHARGE_STATE_DISABLED
: y
--;
1089 case CHARGE_STATE_ERROR
: y
--;
1090 case DISCHARGING
: y
--;
1097 lcd_putsf(0, line
++, "State: %s", chrgstate_strings
[y
]);
1099 lcd_putsf(0, line
++, "Battery Switch: %s",
1100 (st
& POWER_INPUT_BATTERY
) ? "On" : "Off");
1102 y
= chrgraw_adc_voltage();
1103 lcd_putsf(0, line
++, "CHRGRAW: %d.%03d V",
1104 y
/ 1000, y
% 1000);
1106 y
= application_supply_adc_voltage();
1107 lcd_putsf(0, line
++, "BP : %d.%03d V",
1108 y
/ 1000, y
% 1000);
1110 y
= battery_adc_charge_current();
1111 if (y
< 0) x
= '-', y
= -y
;
1113 lcd_putsf(0, line
++, "CHRGISN:%c%d mA", x
, y
);
1115 y
= cccv_regulator_dissipation();
1116 lcd_putsf(0, line
++, "P CCCV : %d mW", y
);
1118 y
= battery_charge_current();
1119 if (y
< 0) x
= '-', y
= -y
;
1121 lcd_putsf(0, line
++, "I Charge:%c%d mA", x
, y
);
1123 y
= battery_adc_temp();
1126 lcd_putsf(0, line
++, "T Battery: %dC (%dF)", y
,
1129 /* Conversion disabled */
1130 lcd_puts(0, line
++, "T Battery: ?");
1133 #elif defined(HAVE_AS3514) && defined(CONFIG_CHARGING)
1134 static const char * const chrgstate_strings
[] =
1136 [CHARGE_STATE_DISABLED
- CHARGE_STATE_DISABLED
]= "Disabled",
1137 [CHARGE_STATE_ERROR
- CHARGE_STATE_DISABLED
] = "Error",
1138 [DISCHARGING
- CHARGE_STATE_DISABLED
] = "Discharging",
1139 [CHARGING
- CHARGE_STATE_DISABLED
] = "Charging",
1141 const char *str
= NULL
;
1143 lcd_putsf(0, 3, "Charger: %s",
1144 charger_inserted() ? "present" : "absent");
1146 y
= charge_state
- CHARGE_STATE_DISABLED
;
1147 if ((unsigned)y
< ARRAYLEN(chrgstate_strings
))
1148 str
= chrgstate_strings
[y
];
1150 lcd_putsf(0, 4, "State: %s",
1151 str
? str
: "<unknown>");
1153 lcd_putsf(0, 5, "CHARGER: %02X", ascodec_read_charger());
1154 #elif defined(IPOD_NANO2G)
1155 y
= pmu_read_battery_voltage();
1156 lcd_putsf(17, 1, "RAW: %d.%03d V", y
/ 1000, y
% 1000);
1157 y
= pmu_read_battery_current();
1158 lcd_putsf(0, 2, "Battery current: %d mA", y
);
1159 lcd_putsf(0, 3, "PWRCON: %08x %08x", PWRCON
, PWRCONEXT
);
1160 lcd_putsf(0, 4, "CLKCON: %08x %03x %03x", CLKCON
, CLKCON2
, CLKCON3
);
1161 lcd_putsf(0, 5, "PLL: %06x %06x %06x", PLL0PMS
, PLL1PMS
, PLL2PMS
);
1162 x
= pmu_read(0x1b) & 0xf;
1163 y
= pmu_read(0x1a) * 25 + 625;
1164 lcd_putsf(0, 6, "AUTO: %x / %d mV", x
, y
);
1165 x
= pmu_read(0x1f) & 0xf;
1166 y
= pmu_read(0x1e) * 25 + 625;
1167 lcd_putsf(0, 7, "DOWN1: %x / %d mV", x
, y
);
1168 x
= pmu_read(0x23) & 0xf;
1169 y
= pmu_read(0x22) * 25 + 625;
1170 lcd_putsf(0, 8, "DOWN2: %x / %d mV", x
, y
);
1171 x
= pmu_read(0x27) & 0xf;
1172 y
= pmu_read(0x26) * 100 + 900;
1173 lcd_putsf(0, 9, "MEMLDO: %x / %d mV", x
, y
);
1174 for (i
= 0; i
< 6; i
++)
1176 x
= pmu_read(0x2e + (i
<< 1)) & 0xf;
1177 y
= pmu_read(0x2d + (i
<< 1)) * 100 + 900;
1178 lcd_putsf(0, 10 + i
, "LDO%d: %x / %d mV", i
+ 1, x
, y
);
1181 lcd_putsf(0, 3, "Charger: %s",
1182 charger_inserted() ? "present" : "absent");
1183 #endif /* target type */
1184 #endif /* CONFIG_CHARGING */
1186 case 2: /* voltage deltas: */
1187 #if (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE)
1188 lcd_puts(0, 0, "Voltage deltas:");
1189 for (i
= 0; i
< POWER_HISTORY_LEN
-1; i
++) {
1190 y
= power_history
[i
] - power_history
[i
+1];
1191 lcd_putsf(0, i
+1, "-%d min: %c%d.%03d V", i
,
1192 (y
< 0) ? '-' : ' ', ((y
< 0) ? y
* -1 : y
) / 1000,
1193 ((y
< 0) ? y
* -1 : y
) % 1000);
1195 #elif (CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE)
1196 lcd_puts(0, 0, "Percentage deltas:");
1197 for (i
= 0; i
< POWER_HISTORY_LEN
-1; i
++) {
1198 y
= power_history
[i
] - power_history
[i
+1];
1199 lcd_putsf(0, i
+1, "-%d min: %c%d%%", i
,
1200 (y
< 0) ? '-' : ' ', ((y
< 0) ? y
* -1 : y
));
1205 case 3: /* remaining time estimation: */
1207 #ifdef ARCHOS_RECORDER
1208 lcd_putsf(0, 0, "charge_state: %d", charge_state
);
1210 lcd_putsf(0, 1, "Cycle time: %d m", powermgmt_last_cycle_startstop_min
);
1212 lcd_putsf(0, 2, "Lvl@cyc st: %d%%", powermgmt_last_cycle_level
);
1214 lcd_putsf(0, 3, "P=%2d I=%2d", pid_p
, pid_i
);
1216 lcd_putsf(0, 4, "Trickle sec: %d/60", trickle_sec
);
1217 #endif /* ARCHOS_RECORDER */
1219 #if (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE)
1220 lcd_putsf(0, 5, "Last PwrHist: %d.%03dV",
1221 power_history
[0] / 1000,
1222 power_history
[0] % 1000);
1225 lcd_putsf(0, 6, "battery level: %d%%", battery_level());
1227 int time_left
= battery_time();
1229 lcd_putsf(0, 7, "Est. remain: %d m", time_left
);
1231 lcd_puts(0, 7, "Estimation n/a");
1237 switch(get_action(CONTEXT_STD
,HZ
/2))
1239 case ACTION_STD_PREV
:
1244 case ACTION_STD_NEXT
:
1249 case ACTION_STD_CANCEL
:
1250 lcd_setfont(FONT_UI
);
1254 lcd_setfont(FONT_UI
);
1258 #endif /* (CONFIG_BATTERY_MEASURE != 0) && HAVE_LCD_BITMAP */
1260 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
1261 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
1263 #if (CONFIG_STORAGE & STORAGE_MMC)
1264 #define CARDTYPE "MMC"
1265 #elif (CONFIG_STORAGE & STORAGE_SD)
1266 #define CARDTYPE "microSD"
1269 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1272 int *cardnum
= (int*)lists
->data
;
1273 unsigned char card_name
[6];
1274 unsigned char pbuf
[32];
1275 char *title
= lists
->title
;
1276 static const unsigned char i_vmin
[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
1277 static const unsigned char i_vmax
[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
1278 static const unsigned char * const kbit_units
[] = { "kBit/s", "MBit/s", "GBit/s" };
1279 static const unsigned char * const nsec_units
[] = { "ns", "µs", "ms" };
1280 #if (CONFIG_STORAGE & STORAGE_MMC)
1281 static const char * const mmc_spec_vers
[] = { "1.0-1.2", "1.4", "2.0-2.2",
1282 "3.1-3.31", "4.0" };
1285 if ((btn
== ACTION_STD_OK
) || (btn
== SYS_FS_CHANGED
) || (btn
== ACTION_REDRAW
))
1288 if (btn
== ACTION_STD_OK
)
1290 *cardnum
^= 0x1; /* change cards */
1294 simplelist_set_line_count(0);
1296 card
= card_get_info(*cardnum
);
1298 if (card
->initialized
> 0)
1301 for (i
=0; i
<sizeof(card_name
); i
++)
1303 card_name
[i
] = card_extract_bits(card
->cid
, (103-8*i
), 8);
1305 strlcpy(card_name
, card_name
, sizeof(card_name
));
1306 simplelist_addline(SIMPLELIST_ADD_LINE
,
1307 "%s Rev %d.%d", card_name
,
1308 (int) card_extract_bits(card
->cid
, 63, 4),
1309 (int) card_extract_bits(card
->cid
, 59, 4));
1310 simplelist_addline(SIMPLELIST_ADD_LINE
,
1312 #if (CONFIG_STORAGE & STORAGE_SD)
1313 (int) card_extract_bits(card
->cid
, 11, 4),
1314 (int) card_extract_bits(card
->cid
, 19, 8) + 2000
1315 #elif (CONFIG_STORAGE & STORAGE_MMC)
1316 (int) card_extract_bits(card
->cid
, 15, 4),
1317 (int) card_extract_bits(card
->cid
, 11, 4) + 1997
1320 simplelist_addline(SIMPLELIST_ADD_LINE
,
1321 #if (CONFIG_STORAGE & STORAGE_SD)
1323 card_extract_bits(card
->cid
, 55, 32)
1324 #elif (CONFIG_STORAGE & STORAGE_MMC)
1326 card_extract_bits(card
->cid
, 47, 16)
1330 simplelist_addline(SIMPLELIST_ADD_LINE
, "M=%02x, "
1331 #if (CONFIG_STORAGE & STORAGE_SD)
1333 (int) card_extract_bits(card
->cid
, 127, 8),
1334 card_extract_bits(card
->cid
, 119, 8),
1335 card_extract_bits(card
->cid
, 111, 8)
1336 #elif (CONFIG_STORAGE & STORAGE_MMC)
1338 (int) card_extract_bits(card
->cid
, 127, 8),
1339 (int) card_extract_bits(card
->cid
, 119, 16)
1343 #if (CONFIG_STORAGE & STORAGE_MMC)
1344 int temp
= card_extract_bits(card
->csd
, 125, 4);
1345 simplelist_addline(SIMPLELIST_ADD_LINE
,
1346 "MMC v%s", temp
< 5 ?
1347 mmc_spec_vers
[temp
] : "?.?");
1349 simplelist_addline(SIMPLELIST_ADD_LINE
,
1350 "Blocks: 0x%08lx", card
->numblocks
);
1351 output_dyn_value(pbuf
, sizeof pbuf
, card
->speed
/ 1000,
1353 simplelist_addline(SIMPLELIST_ADD_LINE
,
1355 output_dyn_value(pbuf
, sizeof pbuf
, card
->taac
,
1357 simplelist_addline(SIMPLELIST_ADD_LINE
,
1359 simplelist_addline(SIMPLELIST_ADD_LINE
,
1360 "Nsac: %d clk", card
->nsac
);
1361 simplelist_addline(SIMPLELIST_ADD_LINE
,
1362 "R2W: *%d", card
->r2w_factor
);
1363 #if (CONFIG_STORAGE & STORAGE_SD)
1364 int csd_structure
= card_extract_bits(card
->csd
, 127, 2);
1365 if (csd_structure
== 0) /* CSD version 1.0 */
1368 simplelist_addline(SIMPLELIST_ADD_LINE
,
1370 i_vmin
[card_extract_bits(card
->csd
, 61, 3)],
1371 i_vmax
[card_extract_bits(card
->csd
, 58, 3)]);
1372 simplelist_addline(SIMPLELIST_ADD_LINE
,
1374 i_vmin
[card_extract_bits(card
->csd
, 55, 3)],
1375 i_vmax
[card_extract_bits(card
->csd
, 52, 3)]);
1378 else if (card
->initialized
== 0)
1380 simplelist_addline(SIMPLELIST_ADD_LINE
, "Not Found!");
1382 #if (CONFIG_STORAGE & STORAGE_SD)
1383 else /* card->initialized < 0 */
1385 simplelist_addline(SIMPLELIST_ADD_LINE
, "Init Error! (%d)", card
->initialized
);
1388 snprintf(title
, 16, "[" CARDTYPE
" %d]", *cardnum
);
1389 gui_synclist_set_title(lists
, title
, Icon_NOICON
);
1390 gui_synclist_set_nb_items(lists
, simplelist_get_line_count());
1391 gui_synclist_select_item(lists
, 0);
1392 btn
= ACTION_REDRAW
;
1396 #elif (CONFIG_STORAGE & STORAGE_ATA)
1397 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1402 unsigned short* identify_info
= ata_get_identify();
1403 bool timing_info_present
= false;
1406 simplelist_set_line_count(0);
1408 for (i
=0; i
< 20; i
++)
1409 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+27]);
1411 /* kill trailing space */
1412 for (i
=39; i
&& buf
[i
]==' '; i
--)
1414 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", buf
);
1415 for (i
=0; i
< 4; i
++)
1416 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+23]);
1418 simplelist_addline(SIMPLELIST_ADD_LINE
,
1419 "Firmware: %s", buf
);
1420 snprintf(buf
, sizeof buf
, "%ld MB",
1421 ((unsigned long)identify_info
[61] << 16 |
1422 (unsigned long)identify_info
[60]) / 2048 );
1423 simplelist_addline(SIMPLELIST_ADD_LINE
,
1426 fat_size( IF_MV2(0,) NULL
, &free
);
1427 simplelist_addline(SIMPLELIST_ADD_LINE
,
1428 "Free: %ld MB", free
/ 1024);
1429 simplelist_addline(SIMPLELIST_ADD_LINE
,
1430 "Spinup time: %d ms", storage_spinup_time() * (1000/HZ
));
1431 i
= identify_info
[83] & (1<<3);
1432 simplelist_addline(SIMPLELIST_ADD_LINE
,
1433 "Power mgmt: %s", i
? "enabled" : "unsupported");
1434 i
= identify_info
[83] & (1<<9);
1435 simplelist_addline(SIMPLELIST_ADD_LINE
,
1436 "Noise mgmt: %s", i
? "enabled" : "unsupported");
1437 i
= identify_info
[82] & (1<<6);
1438 simplelist_addline(SIMPLELIST_ADD_LINE
,
1439 "Read-ahead: %s", i
? "enabled" : "unsupported");
1440 timing_info_present
= identify_info
[53] & (1<<1);
1441 if(timing_info_present
) {
1442 char pio3
[2], pio4
[2];pio3
[1] = 0;
1444 pio3
[0] = (identify_info
[64] & (1<<0)) ? '3' : 0;
1445 pio4
[0] = (identify_info
[64] & (1<<1)) ? '4' : 0;
1446 simplelist_addline(SIMPLELIST_ADD_LINE
,
1447 "PIO modes: 0 1 2 %s %s", pio3
, pio4
);
1450 simplelist_addline(SIMPLELIST_ADD_LINE
,
1451 "No PIO mode info");
1453 timing_info_present
= identify_info
[53] & (1<<1);
1454 if(timing_info_present
) {
1455 simplelist_addline(SIMPLELIST_ADD_LINE
,
1456 "Cycle times %dns/%dns",
1458 identify_info
[68] );
1460 simplelist_addline(SIMPLELIST_ADD_LINE
,
1463 int sector_size
= 512;
1464 if((identify_info
[106] & 0xe000) == 0x6000)
1465 sector_size
*= BIT_N(identify_info
[106] & 0x000f);
1466 simplelist_addline(SIMPLELIST_ADD_LINE
,
1467 "Physical sector size: %d", sector_size
);
1469 if (identify_info
[63] & (1<<0)) {
1470 char mdma0
[2], mdma1
[2], mdma2
[2];
1471 mdma0
[1] = mdma1
[1] = mdma2
[1] = 0;
1472 mdma0
[0] = (identify_info
[63] & (1<<0)) ? '0' : 0;
1473 mdma1
[0] = (identify_info
[63] & (1<<1)) ? '1' : 0;
1474 mdma2
[0] = (identify_info
[63] & (1<<2)) ? '2' : 0;
1475 simplelist_addline(SIMPLELIST_ADD_LINE
,
1476 "MDMA modes: %s %s %s", mdma0
, mdma1
, mdma2
);
1477 simplelist_addline(SIMPLELIST_ADD_LINE
,
1478 "MDMA Cycle times %dns/%dns",
1480 identify_info
[66] );
1483 simplelist_addline(SIMPLELIST_ADD_LINE
,
1484 "No MDMA mode info");
1486 if (identify_info
[53] & (1<<2)) {
1487 char udma0
[2], udma1
[2], udma2
[2], udma3
[2], udma4
[2], udma5
[2], udma6
[2];
1488 udma0
[1] = udma1
[1] = udma2
[1] = udma3
[1] = udma4
[1] = udma5
[1] = udma6
[1] = 0;
1489 udma0
[0] = (identify_info
[88] & (1<<0)) ? '0' : 0;
1490 udma1
[0] = (identify_info
[88] & (1<<1)) ? '1' : 0;
1491 udma2
[0] = (identify_info
[88] & (1<<2)) ? '2' : 0;
1492 udma3
[0] = (identify_info
[88] & (1<<3)) ? '3' : 0;
1493 udma4
[0] = (identify_info
[88] & (1<<4)) ? '4' : 0;
1494 udma5
[0] = (identify_info
[88] & (1<<5)) ? '5' : 0;
1495 udma6
[0] = (identify_info
[88] & (1<<6)) ? '6' : 0;
1496 simplelist_addline(SIMPLELIST_ADD_LINE
,
1497 "UDMA modes: %s %s %s %s %s %s %s", udma0
, udma1
, udma2
,
1498 udma3
, udma4
, udma5
, udma6
);
1501 simplelist_addline(SIMPLELIST_ADD_LINE
,
1502 "No UDMA mode info");
1504 #endif /* HAVE_ATA_DMA */
1505 timing_info_present
= identify_info
[53] & (1<<1);
1506 if(timing_info_present
) {
1507 i
= identify_info
[49] & (1<<11);
1508 simplelist_addline(SIMPLELIST_ADD_LINE
,
1509 "IORDY support: %s", i
? "yes" : "no");
1510 i
= identify_info
[49] & (1<<10);
1511 simplelist_addline(SIMPLELIST_ADD_LINE
,
1512 "IORDY disable: %s", i
? "yes" : "no");
1514 simplelist_addline(SIMPLELIST_ADD_LINE
,
1517 simplelist_addline(SIMPLELIST_ADD_LINE
,
1518 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
1520 i
= ata_get_dma_mode();
1522 simplelist_addline(SIMPLELIST_ADD_LINE
,
1525 simplelist_addline(SIMPLELIST_ADD_LINE
,
1527 (i
& 0x40) ? "UDMA" : "MDMA",
1530 #endif /* HAVE_ATA_DMA */
1533 #else /* No SD, MMC or ATA */
1534 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1537 struct storage_info info
;
1538 storage_get_info(0,&info
);
1539 simplelist_addline(SIMPLELIST_ADD_LINE
, "Vendor: %s", info
.vendor
);
1540 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", info
.product
);
1541 simplelist_addline(SIMPLELIST_ADD_LINE
, "Firmware: %s", info
.revision
);
1542 simplelist_addline(SIMPLELIST_ADD_LINE
,
1543 "Size: %ld MB", info
.num_sectors
*(info
.sector_size
/512)/2024);
1545 fat_size( IF_MV2(0,) NULL
, &free
);
1546 simplelist_addline(SIMPLELIST_ADD_LINE
,
1547 "Free: %ld MB", free
/ 1024);
1548 simplelist_addline(SIMPLELIST_ADD_LINE
,
1549 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
1554 #if (CONFIG_STORAGE & STORAGE_ATA)
1555 static bool dbg_identify_info(void)
1557 int fd
= creat("/identify_info.bin", 0666);
1560 #ifdef ROCKBOX_LITTLE_ENDIAN
1561 ecwrite(fd
, ata_get_identify(), SECTOR_SIZE
/2, "s", true);
1563 write(fd
, ata_get_identify(), SECTOR_SIZE
);
1571 static bool dbg_disk_info(void)
1573 struct simplelist_info info
;
1574 simplelist_info_init(&info
, "Disk Info", 1, NULL
);
1575 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
1578 info
.callback_data
= (void*)&card
;
1581 info
.action_callback
= disk_callback
;
1582 info
.hide_selection
= true;
1583 info
.scroll_all
= true;
1584 return simplelist_show_list(&info
);
1586 #endif /* PLATFORM_NATIVE */
1588 #ifdef HAVE_DIRCACHE
1589 static int dircache_callback(int btn
, struct gui_synclist
*lists
)
1592 simplelist_set_line_count(0);
1593 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache initialized: %s",
1594 dircache_is_enabled() ? "Yes" : "No");
1595 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache size: %d B",
1596 dircache_get_cache_size());
1597 simplelist_addline(SIMPLELIST_ADD_LINE
, "Last size: %d B",
1598 global_status
.dircache_size
);
1599 simplelist_addline(SIMPLELIST_ADD_LINE
, "Limit: %d B",
1601 simplelist_addline(SIMPLELIST_ADD_LINE
, "Reserve: %d/%d B",
1602 dircache_get_reserve_used(), DIRCACHE_RESERVE
);
1603 simplelist_addline(SIMPLELIST_ADD_LINE
, "Scanning took: %d s",
1604 dircache_get_build_ticks() / HZ
);
1605 simplelist_addline(SIMPLELIST_ADD_LINE
, "Entry count: %d",
1606 dircache_get_entry_count());
1610 static bool dbg_dircache_info(void)
1612 struct simplelist_info info
;
1613 simplelist_info_init(&info
, "Dircache Info", 7, NULL
);
1614 info
.action_callback
= dircache_callback
;
1615 info
.hide_selection
= true;
1616 info
.scroll_all
= true;
1617 return simplelist_show_list(&info
);
1620 #endif /* HAVE_DIRCACHE */
1622 #ifdef HAVE_TAGCACHE
1623 static int database_callback(int btn
, struct gui_synclist
*lists
)
1626 struct tagcache_stat
*stat
= tagcache_get_stat();
1627 static bool synced
= false;
1629 simplelist_set_line_count(0);
1631 simplelist_addline(SIMPLELIST_ADD_LINE
, "Initialized: %s",
1632 stat
->initialized
? "Yes" : "No");
1633 simplelist_addline(SIMPLELIST_ADD_LINE
, "DB Ready: %s",
1634 stat
->ready
? "Yes" : "No");
1635 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM Cache: %s",
1636 stat
->ramcache
? "Yes" : "No");
1637 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM: %d/%d B",
1638 stat
->ramcache_used
, stat
->ramcache_allocated
);
1639 simplelist_addline(SIMPLELIST_ADD_LINE
, "Progress: %d%% (%d entries)",
1640 stat
->progress
, stat
->processed_entries
);
1641 simplelist_addline(SIMPLELIST_ADD_LINE
, "Curfile: %s",
1642 stat
->curentry
? stat
->curentry
: "---");
1643 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit step: %d",
1645 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit delayed: %s",
1646 stat
->commit_delayed
? "Yes" : "No");
1648 simplelist_addline(SIMPLELIST_ADD_LINE
, "Queue length: %d",
1649 stat
->queue_length
);
1654 tagcache_screensync_event();
1657 if (!btn
&& stat
->curentry
)
1660 return ACTION_REDRAW
;
1663 if (btn
== ACTION_STD_CANCEL
)
1664 tagcache_screensync_enable(false);
1668 static bool dbg_tagcache_info(void)
1670 struct simplelist_info info
;
1671 simplelist_info_init(&info
, "Database Info", 8, NULL
);
1672 info
.action_callback
= database_callback
;
1673 info
.hide_selection
= true;
1674 info
.scroll_all
= true;
1676 /* Don't do nonblock here, must give enough processing time
1677 for tagcache thread. */
1678 /* info.timeout = TIMEOUT_NOBLOCK; */
1680 tagcache_screensync_enable(true);
1681 return simplelist_show_list(&info
);
1685 #if CONFIG_CPU == SH7034
1686 static bool dbg_save_roms(void)
1689 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
1691 fd
= creat("/internal_rom_0000-FFFF.bin", 0666);
1694 write(fd
, (void *)0, 0x10000);
1698 fd
= creat("/internal_rom_2000000-203FFFF.bin", 0666);
1701 write(fd
, (void *)0x2000000, 0x40000);
1705 system_memory_guard(oldmode
);
1708 #elif defined CPU_COLDFIRE
1709 static bool dbg_save_roms(void)
1712 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
1714 #if defined(IRIVER_H100_SERIES)
1715 fd
= creat("/internal_rom_000000-1FFFFF.bin", 0666);
1716 #elif defined(IRIVER_H300_SERIES)
1717 fd
= creat("/internal_rom_000000-3FFFFF.bin", 0666);
1718 #elif defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IAUDIO_M3)
1719 fd
= creat("/internal_rom_000000-3FFFFF.bin", 0666);
1720 #elif defined(MPIO_HD200) || defined(MPIO_HD300)
1721 fd
= creat("/internal_rom_000000-1FFFFF.bin", 0666);
1725 write(fd
, (void *)0, FLASH_SIZE
);
1728 system_memory_guard(oldmode
);
1731 fd
= creat("/internal_eeprom.bin", 0666);
1735 char buf
[EEPROM_SIZE
];
1738 old_irq_level
= disable_irq_save();
1740 err
= eeprom_24cxx_read(0, buf
, sizeof buf
);
1742 restore_irq(old_irq_level
);
1745 splashf(HZ
*3, "Eeprom read failure (%d)", err
);
1748 write(fd
, buf
, sizeof buf
);
1757 #elif defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD)
1758 static bool dbg_save_roms(void)
1760 int fd
= creat("/internal_rom_000000-0FFFFF.bin", 0666);
1763 write(fd
, (void *)0x20000000, FLASH_SIZE
);
1769 #elif CONFIG_CPU == IMX31L
1770 static bool dbg_save_roms(void)
1772 int fd
= creat("/flash_rom_A0000000-A01FFFFF.bin", 0666);
1775 write(fd
, (void*)0xa0000000, FLASH_SIZE
);
1781 #elif defined(CPU_TCC780X)
1782 static bool dbg_save_roms(void)
1784 int fd
= creat("/eeprom_E0000000-E0001FFF.bin", 0666);
1787 write(fd
, (void*)0xe0000000, 0x2000);
1798 #ifdef CONFIG_TUNER_MULTI
1799 static int tuner_type
= 0;
1800 #define IF_TUNER_TYPE(type) if(tuner_type==type)
1802 #define IF_TUNER_TYPE(type)
1805 static int radio_callback(int btn
, struct gui_synclist
*lists
)
1808 if (btn
== ACTION_STD_CANCEL
)
1810 simplelist_set_line_count(1);
1812 #if (CONFIG_TUNER & LV24020LP)
1813 simplelist_addline(SIMPLELIST_ADD_LINE
,
1814 "CTRL_STAT: %02X", lv24020lp_get(LV24020LP_CTRL_STAT
) );
1815 simplelist_addline(SIMPLELIST_ADD_LINE
,
1816 "RADIO_STAT: %02X", lv24020lp_get(LV24020LP_REG_STAT
) );
1817 simplelist_addline(SIMPLELIST_ADD_LINE
,
1818 "MSS_FM: %d kHz", lv24020lp_get(LV24020LP_MSS_FM
) );
1819 simplelist_addline(SIMPLELIST_ADD_LINE
,
1820 "MSS_IF: %d Hz", lv24020lp_get(LV24020LP_MSS_IF
) );
1821 simplelist_addline(SIMPLELIST_ADD_LINE
,
1822 "MSS_SD: %d Hz", lv24020lp_get(LV24020LP_MSS_SD
) );
1823 simplelist_addline(SIMPLELIST_ADD_LINE
,
1824 "if_set: %d Hz", lv24020lp_get(LV24020LP_IF_SET
) );
1825 simplelist_addline(SIMPLELIST_ADD_LINE
,
1826 "sd_set: %d Hz", lv24020lp_get(LV24020LP_SD_SET
) );
1827 #endif /* LV24020LP */
1828 #if (CONFIG_TUNER & S1A0903X01)
1829 simplelist_addline(SIMPLELIST_ADD_LINE
,
1830 "Samsung regs: %08X", s1a0903x01_get(RADIO_ALL
));
1831 /* This one doesn't return dynamic data atm */
1832 #endif /* S1A0903X01 */
1833 #if (CONFIG_TUNER & TEA5767)
1834 struct tea5767_dbg_info nfo
;
1835 tea5767_dbg_info(&nfo
);
1836 simplelist_addline(SIMPLELIST_ADD_LINE
, "Philips regs:");
1837 simplelist_addline(SIMPLELIST_ADD_LINE
,
1838 " Read: %02X %02X %02X %02X %02X",
1839 (unsigned)nfo
.read_regs
[0], (unsigned)nfo
.read_regs
[1],
1840 (unsigned)nfo
.read_regs
[2], (unsigned)nfo
.read_regs
[3],
1841 (unsigned)nfo
.read_regs
[4]);
1842 simplelist_addline(SIMPLELIST_ADD_LINE
,
1843 " Write: %02X %02X %02X %02X %02X",
1844 (unsigned)nfo
.write_regs
[0], (unsigned)nfo
.write_regs
[1],
1845 (unsigned)nfo
.write_regs
[2], (unsigned)nfo
.write_regs
[3],
1846 (unsigned)nfo
.write_regs
[4]);
1847 #endif /* TEA5767 */
1848 #if (CONFIG_TUNER & SI4700)
1849 IF_TUNER_TYPE(SI4700
)
1851 struct si4700_dbg_info nfo
;
1852 si4700_dbg_info(&nfo
);
1853 simplelist_addline(SIMPLELIST_ADD_LINE
, "SI4700 regs:");
1854 for (int i
= 0; i
< 16; i
+= 4) {
1855 simplelist_addline(SIMPLELIST_ADD_LINE
,"%02X: %04X %04X %04X %04X",
1856 i
, nfo
.regs
[i
], nfo
.regs
[i
+1], nfo
.regs
[i
+2], nfo
.regs
[i
+3]);
1860 #if (CONFIG_TUNER & RDA5802)
1861 IF_TUNER_TYPE(RDA5802
)
1863 struct rda5802_dbg_info nfo
;
1864 rda5802_dbg_info(&nfo
);
1865 simplelist_addline(SIMPLELIST_ADD_LINE
, "RDA5802 regs:");
1866 for (int i
= 0; i
< 16; i
+= 4) {
1867 simplelist_addline(SIMPLELIST_ADD_LINE
,"%02X: %04X %04X %04X %04X",
1868 i
, nfo
.regs
[i
], nfo
.regs
[i
+1], nfo
.regs
[i
+2], nfo
.regs
[i
+3]);
1871 #endif /* RDA55802 */
1874 simplelist_addline(SIMPLELIST_ADD_LINE
, "PI:%04X PS:'%8s'",
1875 rds_get_pi(), rds_get_ps());
1876 simplelist_addline(SIMPLELIST_ADD_LINE
, "RT:%s",
1878 time_t seconds
= rds_get_ct();
1879 struct tm
* time
= gmtime(&seconds
);
1880 simplelist_addline(SIMPLELIST_ADD_LINE
,
1881 "CT:%4d-%02d-%02d %02d:%02d",
1882 time
->tm_year
+ 1900, time
->tm_mon
+ 1, time
->tm_mday
,
1883 time
->tm_hour
, time
->tm_min
, time
->tm_sec
);
1885 return ACTION_REDRAW
;
1887 static bool dbg_fm_radio(void)
1889 struct simplelist_info info
;
1890 #ifdef CONFIG_TUNER_MULTI
1891 tuner_type
= tuner_detect_type();
1893 info
.scroll_all
= true;
1894 simplelist_info_init(&info
, "FM Radio", 1, NULL
);
1895 simplelist_set_line_count(0);
1896 simplelist_addline(SIMPLELIST_ADD_LINE
, "HW detected: %s",
1897 radio_hardware_present() ? "yes" : "no");
1899 info
.action_callback
= radio_hardware_present()?radio_callback
: NULL
;
1900 info
.hide_selection
= true;
1901 return simplelist_show_list(&info
);
1903 #endif /* CONFIG_TUNER */
1904 #endif /* !SIMULATOR */
1906 #if defined(HAVE_LCD_BITMAP) && !defined(APPLICATION)
1907 extern bool do_screendump_instead_of_usb
;
1909 static bool dbg_screendump(void)
1911 do_screendump_instead_of_usb
= !do_screendump_instead_of_usb
;
1912 splashf(HZ
, "Screendump %sabled", do_screendump_instead_of_usb
?"en":"dis");
1915 #endif /* HAVE_LCD_BITMAP */
1917 extern bool write_metadata_log
;
1919 static bool dbg_metadatalog(void)
1921 write_metadata_log
= !write_metadata_log
;
1922 splashf(HZ
, "Metadata log %sabled", write_metadata_log
? "en" : "dis");
1926 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
1927 static bool dbg_set_memory_guard(void)
1929 static const struct opt_items names
[MAXMEMGUARD
] = {
1931 { "Flash ROM writes", -1 },
1932 { "Zero area (all)", -1 }
1934 int mode
= system_memory_guard(MEMGUARD_KEEP
);
1936 set_option( "Catch mem accesses", &mode
, INT
, names
, MAXMEMGUARD
, NULL
);
1937 system_memory_guard(mode
);
1941 #endif /* CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) */
1943 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
1944 static bool dbg_write_eeprom(void)
1946 int fd
= open("/internal_eeprom.bin", O_RDONLY
);
1950 char buf
[EEPROM_SIZE
];
1951 int rc
= read(fd
, buf
, EEPROM_SIZE
);
1953 if(rc
== EEPROM_SIZE
)
1955 int old_irq_level
= disable_irq_save();
1957 int err
= eeprom_24cxx_write(0, buf
, sizeof buf
);
1959 splashf(HZ
*3, "Eeprom write failure (%d)", err
);
1961 splash(HZ
*3, "Eeprom written successfully");
1963 restore_irq(old_irq_level
);
1967 splashf(HZ
*3, "File read error (%d)",rc
);
1973 splash(HZ
*3, "Failed to open 'internal_eeprom.bin'");
1978 #endif /* defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS) */
1979 #ifdef CPU_BOOST_LOGGING
1980 static bool cpu_boost_log(void)
1982 int count
= cpu_boost_log_getcount();
1983 char *str
= cpu_boost_log_getlog_first();
1985 lcd_setfont(FONT_SYSFIXED
);
1986 for (int i
= 0; i
< count
;)
1988 lcd_clear_display();
1989 for(int j
=0; j
<LCD_HEIGHT
/SYSFONT_HEIGHT
; j
++,i
++)
1992 str
= cpu_boost_log_getlog_next();
1995 if(strlen(str
) > LCD_WIDTH
/SYSFONT_WIDTH
)
1996 lcd_puts_scroll(0, j
, str
);
2006 switch(get_action(CONTEXT_STD
,TIMEOUT_BLOCK
))
2009 case ACTION_STD_PREV
:
2010 case ACTION_STD_NEXT
:
2013 case ACTION_STD_CANCEL
:
2021 get_action(CONTEXT_STD
,TIMEOUT_BLOCK
);
2022 lcd_setfont(FONT_UI
);
2027 #if (defined(HAVE_WHEEL_ACCELERATION) && (CONFIG_KEYPAD==IPOD_4G_PAD) \
2028 && !defined(IPOD_MINI) && !defined(SIMULATOR))
2029 extern bool wheel_is_touched
;
2030 extern int old_wheel_value
;
2031 extern int new_wheel_value
;
2032 extern int wheel_delta
;
2033 extern unsigned int accumulated_wheel_delta
;
2034 extern unsigned int wheel_velocity
;
2036 static bool dbg_scrollwheel(void)
2038 lcd_setfont(FONT_SYSFIXED
);
2042 if (action_userabort(HZ
/10))
2045 lcd_clear_display();
2047 /* show internal variables of scrollwheel driver */
2048 lcd_putsf(0, 0, "wheel touched: %s", (wheel_is_touched
) ? "true" : "false");
2049 lcd_putsf(0, 1, "new position: %2d", new_wheel_value
);
2050 lcd_putsf(0, 2, "old position: %2d", old_wheel_value
);
2051 lcd_putsf(0, 3, "wheel delta: %2d", wheel_delta
);
2052 lcd_putsf(0, 4, "accumulated delta: %2d", accumulated_wheel_delta
);
2053 lcd_putsf(0, 5, "velo [deg/s]: %4d", (int)wheel_velocity
);
2055 /* show effective accelerated scrollspeed */
2056 lcd_putsf(0, 6, "accel. speed: %4d",
2057 button_apply_acceleration((1<<31)|(1<<24)|wheel_velocity
) );
2061 lcd_setfont(FONT_UI
);
2066 #ifdef HAVE_USBSTACK
2067 #if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL)
2068 static bool toggle_usb_serial(void)
2070 bool enabled
= !usb_core_driver_enabled(USB_DRIVER_SERIAL
);
2072 usb_core_enable_driver(USB_DRIVER_SERIAL
, enabled
);
2073 splashf(HZ
, "USB Serial %sabled", enabled
? "en" : "dis");
2080 #if CONFIG_USBOTG == USBOTG_ISP1583
2081 extern int dbg_usb_num_items(void);
2082 extern const char* dbg_usb_item(int selected_item
, void *data
,
2083 char *buffer
, size_t buffer_len
);
2085 static int isp1583_action_callback(int action
, struct gui_synclist
*lists
)
2088 if (action
== ACTION_NONE
)
2089 action
= ACTION_REDRAW
;
2093 static bool dbg_isp1583(void)
2095 struct simplelist_info isp1583
;
2096 isp1583
.scroll_all
= true;
2097 simplelist_info_init(&isp1583
, "ISP1583", dbg_usb_num_items(), NULL
);
2098 isp1583
.timeout
= HZ
/100;
2099 isp1583
.hide_selection
= true;
2100 isp1583
.get_name
= dbg_usb_item
;
2101 isp1583
.action_callback
= isp1583_action_callback
;
2102 return simplelist_show_list(&isp1583
);
2106 #if defined(CREATIVE_ZVx) && !defined(SIMULATOR)
2107 extern int pic_dbg_num_items(void);
2108 extern const char* pic_dbg_item(int selected_item
, void *data
,
2109 char *buffer
, size_t buffer_len
);
2111 static int pic_action_callback(int action
, struct gui_synclist
*lists
)
2114 if (action
== ACTION_NONE
)
2115 action
= ACTION_REDRAW
;
2119 static bool dbg_pic(void)
2121 struct simplelist_info pic
;
2122 pic
.scroll_all
= true;
2123 simplelist_info_init(&pic
, "PIC", pic_dbg_num_items(), NULL
);
2124 pic
.timeout
= HZ
/100;
2125 pic
.hide_selection
= true;
2126 pic
.get_name
= pic_dbg_item
;
2127 pic
.action_callback
= pic_action_callback
;
2128 return simplelist_show_list(&pic
);
2133 /****** The menu *********/
2134 static const struct {
2135 unsigned char *desc
; /* string or ID */
2136 bool (*function
) (void); /* return true if USB was connected */
2138 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || \
2139 (defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD)) || \
2140 CONFIG_CPU == IMX31L || defined(CPU_TCC780X)
2141 { "Dump ROM contents", dbg_save_roms
},
2143 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || defined(CPU_PP) \
2144 || CONFIG_CPU == S3C2440 || CONFIG_CPU == IMX31L || CONFIG_CPU == AS3525 \
2145 || CONFIG_CPU == DM320 || defined(CPU_S5L870X) || CONFIG_CPU == AS3525v2 \
2146 || CONFIG_CPU == RK27XX
2147 { "View I/O ports", dbg_ports
},
2149 #if (CONFIG_RTC == RTC_PCF50605) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
2150 { "View PCF registers", dbg_pcf
},
2152 #if defined(HAVE_TSC2100) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
2153 { "TSC2100 debug", tsc2100_debug
},
2155 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
2156 { "CPU frequency", dbg_cpufreq
},
2158 #if CONFIG_CPU == IMX31L
2159 { "DVFS/DPTC", __dbg_dvfs_dptc
},
2161 #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR)
2162 { "S/PDIF analyzer", dbg_spdif
},
2164 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2165 { "Catch mem accesses", dbg_set_memory_guard
},
2167 { "View OS stacks", dbg_os
},
2169 { "View CPU stats", dbg_cpuinfo
},
2171 #ifdef HAVE_LCD_BITMAP
2172 #if (CONFIG_BATTERY_MEASURE != 0) && !defined(SIMULATOR)
2173 { "View battery", view_battery
},
2176 { "Screendump", dbg_screendump
},
2179 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
2180 { "View HW info", dbg_hw_info
},
2182 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
2183 { "View partitions", dbg_partitions
},
2185 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
2186 { "View disk info", dbg_disk_info
},
2187 #if (CONFIG_STORAGE & STORAGE_ATA)
2188 { "Dump ATA identify info", dbg_identify_info
},
2191 { "Metadata log", dbg_metadatalog
},
2192 #ifdef HAVE_DIRCACHE
2193 { "View dircache info", dbg_dircache_info
},
2195 #ifdef HAVE_TAGCACHE
2196 { "View database info", dbg_tagcache_info
},
2198 #ifdef HAVE_LCD_BITMAP
2199 #if CONFIG_CODEC == SWCODEC
2200 { "View buffering thread", dbg_buffering_thread
},
2201 #elif !defined(SIMULATOR)
2202 { "View audio thread", dbg_audio_thread
},
2205 { "pm histogram", peak_meter_histogram
},
2206 #endif /* PM_DEBUG */
2207 #endif /* HAVE_LCD_BITMAP */
2208 { "View buflib allocs", dbg_buflib_allocs
},
2211 { "FM Radio", dbg_fm_radio
},
2214 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2215 { "Write back EEPROM", dbg_write_eeprom
},
2217 #if CONFIG_USBOTG == USBOTG_ISP1583
2218 { "View ISP1583 info", dbg_isp1583
},
2220 #if defined(CREATIVE_ZVx) && !defined(SIMULATOR)
2221 { "View PIC info", dbg_pic
},
2223 #ifdef ROCKBOX_HAS_LOGF
2224 {"Show Log File", logfdisplay
},
2225 {"Dump Log File", logfdump
},
2227 #if defined(HAVE_USBSTACK)
2228 #if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL)
2229 {"USB Serial driver (logf)", toggle_usb_serial
},
2231 #endif /* HAVE_USBSTACK */
2232 #ifdef CPU_BOOST_LOGGING
2233 {"cpu_boost log",cpu_boost_log
},
2235 #if (defined(HAVE_WHEEL_ACCELERATION) && (CONFIG_KEYPAD==IPOD_4G_PAD) \
2236 && !defined(IPOD_MINI) && !defined(SIMULATOR))
2237 {"Debug scrollwheel", dbg_scrollwheel
},
2241 static int menu_action_callback(int btn
, struct gui_synclist
*lists
)
2243 int selection
= gui_synclist_get_sel_pos(lists
);
2244 if (btn
== ACTION_STD_OK
)
2247 viewportmanager_theme_enable(i
, false, NULL
);
2248 menuitems
[selection
].function();
2249 btn
= ACTION_REDRAW
;
2251 viewportmanager_theme_undo(i
, false);
2253 else if (btn
== ACTION_STD_CONTEXT
)
2255 MENUITEM_STRINGLIST(menu_items
, "Debug Menu", NULL
, ID2P(LANG_ADD_TO_FAVES
));
2256 if (do_menu(&menu_items
, NULL
, NULL
, false) == 0)
2257 shortcuts_add(SHORTCUT_DEBUGITEM
, menuitems
[selection
].desc
);
2258 return ACTION_STD_CANCEL
;
2263 static const char* menu_get_name(int item
, void * data
,
2264 char *buffer
, size_t buffer_len
)
2266 (void)data
; (void)buffer
; (void)buffer_len
;
2267 return menuitems
[item
].desc
;
2270 bool debug_menu(void)
2272 struct simplelist_info info
;
2274 simplelist_info_init(&info
, "Debug Menu", ARRAYLEN(menuitems
), NULL
);
2275 info
.action_callback
= menu_action_callback
;
2276 info
.get_name
= menu_get_name
;
2277 return simplelist_show_list(&info
);
2280 bool run_debug_screen(char* screen
)
2282 for (unsigned 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);