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 #if defined(SAMSUNG_YPR0) && defined(CONFIG_TUNER)
86 #ifdef HAVE_LCD_BITMAP
87 #include "scrollbar.h"
88 #include "peakmeter.h"
91 #include "core_alloc.h"
92 #if CONFIG_CODEC == SWCODEC
94 #include "buffering.h"
96 #if defined(HAVE_SPDIF_OUT) || defined(HAVE_SPDIF_IN)
100 #ifdef IRIVER_H300_SERIES
101 #include "pcf50606.h" /* for pcf50606_read */
106 #include "hwcompat.h"
108 #if CONFIG_RTC == RTC_PCF50605
109 #include "pcf50605.h"
111 #include "appevents.h"
113 #if defined(HAVE_AS3514) && defined(CONFIG_CHARGING)
118 #include "pmu-target.h"
122 #include "usb_core.h"
125 #if defined(IPOD_ACCESSORY_PROTOCOL)
133 /*---------------------------------------------------*/
134 /* SPECIAL DEBUG STUFF */
135 /*---------------------------------------------------*/
136 extern struct thread_entry threads
[MAXTHREADS
];
138 static char thread_status_char(unsigned status
)
140 static const char thread_status_chars
[THREAD_NUM_STATES
+1] =
142 [0 ... THREAD_NUM_STATES
] = '?',
143 [STATE_RUNNING
] = 'R',
144 [STATE_BLOCKED
] = 'B',
145 [STATE_SLEEPING
] = 'S',
146 [STATE_BLOCKED_W_TMO
] = 'T',
147 [STATE_FROZEN
] = 'F',
148 [STATE_KILLED
] = 'K',
151 if (status
> THREAD_NUM_STATES
)
152 status
= THREAD_NUM_STATES
;
154 return thread_status_chars
[status
];
157 static const char* threads_getname(int selected_item
, void *data
,
158 char *buffer
, size_t buffer_len
)
161 struct thread_entry
*thread
;
165 if (selected_item
< (int)NUM_CORES
)
167 snprintf(buffer
, buffer_len
, "Idle (%d): %2d%%", selected_item
,
168 idle_stack_usage(selected_item
));
172 selected_item
-= NUM_CORES
;
175 thread
= &threads
[selected_item
];
177 if (thread
->state
== STATE_KILLED
)
179 snprintf(buffer
, buffer_len
, "%2d: ---", selected_item
);
183 thread_get_name(name
, 32, thread
);
185 snprintf(buffer
, buffer_len
,
186 "%2d: " IF_COP("(%d) ") "%c%c " IF_PRIO("%d %d ") "%2d%% %s",
188 IF_COP(thread
->core
,)
189 #ifdef HAVE_SCHEDULER_BOOSTCTRL
190 (thread
->cpu_boost
) ? '+' :
192 ((thread
->state
== STATE_RUNNING
) ? '*' : ' '),
193 thread_status_char(thread
->state
),
194 IF_PRIO(thread
->base_priority
, thread
->priority
, )
195 thread_stack_usage(thread
), name
);
200 static int dbg_threads_action_callback(int action
, struct gui_synclist
*lists
)
203 #ifdef ROCKBOX_HAS_LOGF
204 if (action
== ACTION_STD_OK
)
206 int selpos
= gui_synclist_get_sel_pos(lists
);
208 if (selpos
>= NUM_CORES
)
209 remove_thread(threads
[selpos
- NUM_CORES
].id
);
211 remove_thread(threads
[selpos
].id
);
213 return ACTION_REDRAW
;
215 #endif /* ROCKBOX_HAS_LOGF */
216 if (action
== ACTION_NONE
)
217 action
= ACTION_REDRAW
;
221 static bool dbg_os(void)
223 struct simplelist_info info
;
224 simplelist_info_init(&info
, IF_COP("Core and ") "Stack usage:",
228 MAXTHREADS
+NUM_CORES
,
231 #ifndef ROCKBOX_HAS_LOGF
232 info
.hide_selection
= true;
233 info
.scroll_all
= true;
235 info
.action_callback
= dbg_threads_action_callback
;
236 info
.get_name
= threads_getname
;
237 return simplelist_show_list(&info
);
241 #include "cpuinfo-linux.h"
243 #define MAX_STATES 16
244 static struct time_state states
[MAX_STATES
];
246 static const char* get_cpuinfo(int selected_item
, void *data
,
247 char *buffer
, size_t buffer_len
)
249 (void)data
;(void)buffer_len
;
253 static struct cpuusage last_us
;
254 int state_count
= *(int*)data
;
256 if (cpuusage_linux(&us
) != 0)
259 switch(selected_item
)
262 diff
= abs(last_us
.usage
- us
.usage
);
263 sprintf(buffer
, "Usage: %ld.%02ld%% (%c %ld.%02ld)",
264 us
.usage
/100, us
.usage
%100,
265 (us
.usage
>= last_us
.usage
) ? '+':'-',
267 last_us
.usage
= us
.usage
;
272 diff
= us
.utime
- last_us
.utime
;
273 last_us
.utime
= us
.utime
;
278 diff
= us
.stime
- last_us
.stime
;
279 last_us
.stime
= us
.stime
;
284 diff
= us
.rtime
- last_us
.rtime
;
285 last_us
.rtime
= us
.rtime
;
288 return "*** Per CPU freq stats ***";
291 int cpu
= (selected_item
- 5) / (state_count
+ 1);
292 int cpu_line
= (selected_item
- 5) % (state_count
+ 1);
293 int freq1
= frequency_linux(cpu
, false);
294 int freq2
= frequency_linux(cpu
, true);
297 sprintf(buffer
, " CPU%d: Cur/Scal freq: %d/%d MHz", cpu
,
298 freq1
> 0 ? freq1
/1000 : -1,
299 freq2
> 0 ? freq2
/1000 : -1);
303 cpustatetimes_linux(cpu
, states
, ARRAYLEN(states
));
304 snprintf(buffer
, buffer_len
, " %ld %ld",
305 states
[cpu_line
-1].frequency
,
306 states
[cpu_line
-1].time
);
311 sprintf(buffer
, "%s: %ld.%02lds (+ %ld.%02ld)", text
,
312 time
/ us
.hz
, time
% us
.hz
,
313 diff
/ us
.hz
, diff
% us
.hz
);
317 static int cpuinfo_cb(int action
, struct gui_synclist
*lists
)
320 if (action
== ACTION_NONE
)
321 action
= ACTION_REDRAW
;
325 static bool dbg_cpuinfo(void)
327 struct simplelist_info info
;
328 int cpu_count
= MAX(cpucount_linux(), 1);
329 int state_count
= cpustatetimes_linux(0, states
, ARRAYLEN(states
));
330 printf("%s(): %d %d\n", __func__
, cpu_count
, state_count
);
331 simplelist_info_init(&info
, "CPU info:", 5 + cpu_count
*(state_count
+1), &state_count
);
332 info
.get_name
= get_cpuinfo
;
333 info
.action_callback
= cpuinfo_cb
;
335 info
.hide_selection
= true;
336 info
.scroll_all
= true;
337 return simplelist_show_list(&info
);
342 #ifdef HAVE_LCD_BITMAP
343 #if CONFIG_CODEC != SWCODEC
345 static bool dbg_audio_thread(void)
347 struct audio_debug d
;
349 lcd_setfont(FONT_SYSFIXED
);
353 if (action_userabort(HZ
/5))
356 audio_get_debugdata(&d
);
360 lcd_putsf(0, 0, "read: %x", d
.audiobuf_read
);
361 lcd_putsf(0, 1, "write: %x", d
.audiobuf_write
);
362 lcd_putsf(0, 2, "swap: %x", d
.audiobuf_swapwrite
);
363 lcd_putsf(0, 3, "playing: %d", d
.playing
);
364 lcd_putsf(0, 4, "playable: %x", d
.playable_space
);
365 lcd_putsf(0, 5, "unswapped: %x", d
.unswapped_space
);
367 /* Playable space left */
368 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8, 112, 4, d
.audiobuflen
, 0,
369 d
.playable_space
, HORIZONTAL
);
371 /* Show the watermark limit */
372 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8+4, 112, 4, d
.audiobuflen
, 0,
373 d
.low_watermark_level
, HORIZONTAL
);
375 lcd_putsf(0, 7, "wm: %x - %x",
376 d
.low_watermark_level
, d
.lowest_watermark_level
);
380 lcd_setfont(FONT_UI
);
383 #endif /* !SIMULATOR */
384 #else /* CONFIG_CODEC == SWCODEC */
385 static unsigned int ticks
, freq_sum
;
386 #ifndef CPU_MULTI_FREQUENCY
387 static unsigned int boost_ticks
;
390 static void dbg_audio_task(void)
392 #ifdef CPUFREQ_NORMAL
393 #ifndef CPU_MULTI_FREQUENCY
394 if(FREQ
> CPUFREQ_NORMAL
)
397 freq_sum
+= FREQ
/1000000; /* in MHz */
402 static bool dbg_buffering_thread(void)
408 size_t bufsize
= pcmbuf_get_bufsize();
409 int pcmbufdescs
= pcmbuf_descs();
410 struct buffering_debug d
;
411 size_t filebuflen
= audio_get_filebuflen();
412 /* This is a size_t, but call it a long so it puts a - when it's bad. */
414 #ifndef CPU_MULTI_FREQUENCY
417 ticks
= freq_sum
= 0;
419 tick_add_task(dbg_audio_task
);
422 screens
[i
].setfont(FONT_SYSFIXED
);
426 button
= get_action(CONTEXT_STD
,HZ
/5);
429 case ACTION_STD_NEXT
:
432 case ACTION_STD_PREV
:
435 case ACTION_STD_CANCEL
:
440 buffering_get_debugdata(&d
);
441 bufused
= bufsize
- pcmbuf_free();
446 screens
[i
].clear_display();
449 screens
[i
].putsf(0, line
++, "pcm: %6ld/%ld", (long) bufused
, (long) bufsize
);
451 gui_scrollbar_draw(&screens
[i
],0, line
*8, screens
[i
].lcdwidth
, 6,
452 bufsize
, 0, bufused
, HORIZONTAL
);
455 screens
[i
].putsf(0, line
++, "alloc: %6ld/%ld", audio_filebufused(),
458 #if LCD_HEIGHT > 80 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_HEIGHT > 80)
459 if (screens
[i
].lcdheight
> 80)
461 gui_scrollbar_draw(&screens
[i
],0, line
*8, screens
[i
].lcdwidth
, 6,
462 filebuflen
, 0, audio_filebufused(), HORIZONTAL
);
465 screens
[i
].putsf(0, line
++, "real: %6ld/%ld", (long)d
.buffered_data
,
468 gui_scrollbar_draw(&screens
[i
],0, line
*8, screens
[i
].lcdwidth
, 6,
469 filebuflen
, 0, (long)d
.buffered_data
, HORIZONTAL
);
474 screens
[i
].putsf(0, line
++, "usefl: %6ld/%ld", (long)(d
.useful_data
),
477 #if LCD_HEIGHT > 80 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_HEIGHT > 80)
478 if (screens
[i
].lcdheight
> 80)
480 gui_scrollbar_draw(&screens
[i
],0, line
*8, screens
[i
].lcdwidth
, 6,
481 filebuflen
, 0, d
.useful_data
, HORIZONTAL
);
486 screens
[i
].putsf(0, line
++, "data_rem: %ld", (long)d
.data_rem
);
488 screens
[i
].putsf(0, line
++, "track count: %2d", audio_track_count());
490 screens
[i
].putsf(0, line
++, "handle count: %d", (int)d
.num_handles
);
492 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
493 screens
[i
].putsf(0, line
++, "cpu freq: %3dMHz",
494 (int)((FREQ
+ 500000) / 1000000));
499 int avgclock
= freq_sum
* 10 / ticks
; /* in 100 kHz */
500 #ifdef CPU_MULTI_FREQUENCY
501 int boostquota
= (avgclock
* 100 - CPUFREQ_NORMAL
/1000) /
502 ((CPUFREQ_MAX
- CPUFREQ_NORMAL
) / 1000000); /* in 0.1 % */
504 int boostquota
= boost_ticks
* 1000 / ticks
; /* in 0.1 % */
506 screens
[i
].putsf(0, line
++, "boost:%3d.%d%% (%d.%dMHz)",
507 boostquota
/10, boostquota
%10, avgclock
/10, avgclock
%10);
510 screens
[i
].putsf(0, line
++, "pcmbufdesc: %2d/%2d",
511 pcmbuf_used_descs(), pcmbufdescs
);
512 screens
[i
].putsf(0, line
++, "watermark: %6d",
519 tick_remove_task(dbg_audio_task
);
522 screens
[i
].setfont(FONT_UI
);
526 #endif /* CONFIG_CODEC */
527 #endif /* HAVE_LCD_BITMAP */
529 static const char* bf_getname(int selected_item
, void *data
,
530 char *buffer
, size_t buffer_len
)
533 core_print_block_at(selected_item
, buffer
, buffer_len
);
537 static int bf_action_cb(int action
, struct gui_synclist
* list
)
539 if (action
== ACTION_STD_OK
)
541 if (gui_synclist_get_sel_pos(list
) == 0 && core_test_free())
543 splash(HZ
, "Freed test handle. New alloc should trigger compact");
547 splash(HZ
/1, "Attempting a 64k allocation");
548 int handle
= core_alloc("test", 64<<10);
549 splash(HZ
/2, (handle
> 0) ? "Success":"Fail");
550 /* for some reason simplelist doesn't allow adding items here if
551 * info.get_name is given, so use normal list api */
552 gui_synclist_set_nb_items(list
, core_get_num_blocks());
556 action
= ACTION_REDRAW
;
558 else if (action
== ACTION_NONE
)
559 action
= ACTION_REDRAW
;
563 static bool dbg_buflib_allocs(void)
565 struct simplelist_info info
;
566 simplelist_info_init(&info
, "mem allocs", core_get_num_blocks(), NULL
);
567 info
.get_name
= bf_getname
;
568 info
.action_callback
= bf_action_cb
;
569 info
.timeout
= TIMEOUT_BLOCK
;
570 return simplelist_show_list(&info
);
573 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
574 static const char* dbg_partitions_getname(int selected_item
, void *data
,
575 char *buffer
, size_t buffer_len
)
578 int partition
= selected_item
/2;
579 struct partinfo
* p
= disk_partinfo(partition
);
582 snprintf(buffer
, buffer_len
, " T:%x %ld MB", p
->type
, p
->size
/ ( 2048 / ( SECTOR_SIZE
/ 512 )));
586 snprintf(buffer
, buffer_len
, "P%d: S:%lx", partition
, p
->start
);
591 static bool dbg_partitions(void)
593 struct simplelist_info info
;
594 simplelist_info_init(&info
, "Partition Info", 4, NULL
);
595 info
.selection_size
= 2;
596 info
.hide_selection
= true;
597 info
.scroll_all
= true;
598 info
.get_name
= dbg_partitions_getname
;
599 return simplelist_show_list(&info
);
601 #endif /* PLATFORM_NATIVE */
603 #if defined(CPU_COLDFIRE) && defined(HAVE_SPDIF_OUT)
604 static bool dbg_spdif(void)
607 unsigned int control
;
612 unsigned int interruptstat
;
613 bool valnogood
, symbolerr
, parityerr
;
616 int spdif_source
= spdif_get_output_source(&spdif_src_on
);
617 spdif_set_output_source(AUDIO_SRC_SPDIF
IF_SPDIF_POWER_(, true));
620 lcd_setfont(FONT_SYSFIXED
);
622 #ifdef HAVE_SPDIF_POWER
623 spdif_power_enable(true); /* We need SPDIF power for both sending & receiving */
630 control
= EBU1RCVCCHANNEL1
;
631 interruptstat
= INTERRUPTSTAT
;
632 INTERRUPTCLEAR
= 0x03c00000;
634 valnogood
= (interruptstat
& 0x01000000)?true:false;
635 symbolerr
= (interruptstat
& 0x00800000)?true:false;
636 parityerr
= (interruptstat
& 0x00400000)?true:false;
638 lcd_putsf(0, line
++, "Val: %s Sym: %s Par: %s",
641 parityerr
?"--":"OK");
643 lcd_putsf(0, line
++, "Status word: %08x", (int)control
);
648 lcd_putsf(0, line
++, "PRO: %d (%s)",
649 x
, x
?"Professional":"Consumer");
651 x
= (control
>> 30) & 1;
652 lcd_putsf(0, line
++, "Audio: %d (%s)",
653 x
, x
?"Non-PCM":"PCM");
655 x
= (control
>> 29) & 1;
656 lcd_putsf(0, line
++, "Copy: %d (%s)",
657 x
, x
?"Permitted":"Inhibited");
659 x
= (control
>> 27) & 7;
672 lcd_putsf(0, line
++, "Preemphasis: %d (%s)", x
, s
);
674 x
= (control
>> 24) & 3;
675 lcd_putsf(0, line
++, "Mode: %d", x
);
677 category
= (control
>> 17) & 127;
689 lcd_putsf(0, line
++, "Category: 0x%02x (%s)", category
, s
);
691 x
= (control
>> 16) & 1;
693 if(((category
& 0x70) == 0x10) ||
694 ((category
& 0x70) == 0x40) ||
695 ((category
& 0x78) == 0x38))
697 generation
= !generation
;
699 lcd_putsf(0, line
++, "Generation: %d (%s)",
700 x
, generation
?"Original":"No ind.");
702 x
= (control
>> 12) & 15;
703 lcd_putsf(0, line
++, "Source: %d", x
);
706 x
= (control
>> 8) & 15;
722 lcd_putsf(0, line
++, "Channel: %d (%s)", x
, s
);
724 x
= (control
>> 4) & 15;
737 lcd_putsf(0, line
++, "Frequency: %d (%s)", x
, s
);
739 x
= (control
>> 2) & 3;
740 lcd_putsf(0, line
++, "Clock accuracy: %d", x
);
743 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
744 lcd_putsf(0, line
++, "Measured freq: %ldHz",
745 spdif_measure_frequency());
750 if (action_userabort(HZ
/10))
754 spdif_set_output_source(spdif_source
IF_SPDIF_POWER_(, spdif_src_on
));
756 #ifdef HAVE_SPDIF_POWER
757 spdif_power_enable(global_settings
.spdif_enable
);
760 lcd_setfont(FONT_UI
);
763 #endif /* CPU_COLDFIRE */
765 #if (CONFIG_RTC == RTC_PCF50605) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
766 static bool dbg_pcf(void)
770 #ifdef HAVE_LCD_BITMAP
771 lcd_setfont(FONT_SYSFIXED
);
779 lcd_putsf(0, line
++, "DCDC1: %02x", pcf50605_read(0x1b));
780 lcd_putsf(0, line
++, "DCDC2: %02x", pcf50605_read(0x1c));
781 lcd_putsf(0, line
++, "DCDC3: %02x", pcf50605_read(0x1d));
782 lcd_putsf(0, line
++, "DCDC4: %02x", pcf50605_read(0x1e));
783 lcd_putsf(0, line
++, "DCDEC1: %02x", pcf50605_read(0x1f));
784 lcd_putsf(0, line
++, "DCDEC2: %02x", pcf50605_read(0x20));
785 lcd_putsf(0, line
++, "DCUDC1: %02x", pcf50605_read(0x21));
786 lcd_putsf(0, line
++, "DCUDC2: %02x", pcf50605_read(0x22));
787 lcd_putsf(0, line
++, "IOREGC: %02x", pcf50605_read(0x23));
788 lcd_putsf(0, line
++, "D1REGC: %02x", pcf50605_read(0x24));
789 lcd_putsf(0, line
++, "D2REGC: %02x", pcf50605_read(0x25));
790 lcd_putsf(0, line
++, "D3REGC: %02x", pcf50605_read(0x26));
791 lcd_putsf(0, line
++, "LPREG1: %02x", pcf50605_read(0x27));
793 if (action_userabort(HZ
/10))
795 lcd_setfont(FONT_UI
);
800 lcd_setfont(FONT_UI
);
805 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
806 static bool dbg_cpufreq(void)
811 #ifdef HAVE_LCD_BITMAP
812 lcd_setfont(FONT_SYSFIXED
);
820 lcd_putsf(0, line
++, "Frequency: %ld", FREQ
);
821 lcd_putsf(0, line
++, "boost_counter: %d", get_cpu_boost_counter());
824 button
= get_action(CONTEXT_STD
,HZ
/10);
828 case ACTION_STD_PREV
:
832 case ACTION_STD_NEXT
:
837 while (get_cpu_boost_counter() > 0)
839 set_cpu_frequency(CPUFREQ_DEFAULT
);
842 case ACTION_STD_CANCEL
:
843 lcd_setfont(FONT_UI
);
847 lcd_setfont(FONT_UI
);
850 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
852 #if defined(HAVE_TSC2100) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
854 static const char* tsc2100_debug_getname(int selected_item
, void * data
,
855 char *buffer
, size_t buffer_len
)
857 int *page
= (int*)data
;
858 bool reserved
= false;
862 if ((selected_item
> 0x0a) ||
863 (selected_item
== 0x04) ||
864 (selected_item
== 0x08))
868 if ((selected_item
> 0x05) ||
869 (selected_item
== 0x02))
873 if (selected_item
> 0x1e)
878 snprintf(buffer
, buffer_len
, "%02x: RSVD", selected_item
);
880 snprintf(buffer
, buffer_len
, "%02x: %04x", selected_item
,
881 tsc2100_readreg(*page
, selected_item
)&0xffff);
884 static int tsc2100debug_action_callback(int action
, struct gui_synclist
*lists
)
886 int *page
= (int*)lists
->data
;
887 if (action
== ACTION_STD_OK
)
890 snprintf(lists
->title
, 32,
891 "tsc2100 registers - Page %d", *page
);
892 return ACTION_REDRAW
;
896 static bool tsc2100_debug(void)
899 char title
[32] = "tsc2100 registers - Page 0";
900 struct simplelist_info info
;
901 simplelist_info_init(&info
, title
, 32, &page
);
902 info
.timeout
= HZ
/100;
903 info
.get_name
= tsc2100_debug_getname
;
904 info
.action_callback
= tsc2100debug_action_callback
;
905 return simplelist_show_list(&info
);
908 #if (CONFIG_BATTERY_MEASURE != 0) && defined(HAVE_LCD_BITMAP) && !defined(SIMULATOR)
910 * view_battery() shows a automatically scaled graph of the battery voltage
911 * over time. Usable for estimating battery life / charging rate.
912 * The power_history array is updated in power_thread of powermgmt.c.
915 #define BAT_LAST_VAL MIN(LCD_WIDTH, POWER_HISTORY_LEN)
916 #define BAT_TSPACE 20
917 #define BAT_YSPACE (LCD_HEIGHT - BAT_TSPACE)
920 static bool view_battery(void)
923 int i
, x
, y
, z
, y1
, y2
, grid
, graph
;
924 unsigned short maxv
, minv
;
926 lcd_setfont(FONT_SYSFIXED
);
932 case 0: /* voltage history graph */
933 /* Find maximum and minimum voltage for scaling */
934 minv
= power_history
[0];
936 for (i
= 1; i
< BAT_LAST_VAL
&& power_history
[i
]; i
++) {
937 if (power_history
[i
] > maxv
)
938 maxv
= power_history
[i
];
939 if (power_history
[i
] < minv
)
940 minv
= power_history
[i
];
943 #if (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE)
944 /* adjust grid scale */
945 if ((maxv
- minv
) > 50)
950 lcd_putsf(0, 0, "battery %d.%03dV", power_history
[0] / 1000,
951 power_history
[0] % 1000);
952 lcd_putsf(0, 1, "%d.%03d-%d.%03dV (%2dmV)",
953 minv
/ 1000, minv
% 1000, maxv
/ 1000, maxv
% 1000,
955 #elif (CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE)
956 /* adjust grid scale */
957 if ((maxv
- minv
) > 10)
961 lcd_putsf(0, 0, "battery %d%%", power_history
[0]);
962 lcd_putsf(0, 1, "%d%%-%d%% (%d %%)", minv
, maxv
, grid
);
966 while ((y
= (minv
- (minv
% grid
)+i
*grid
)) < maxv
)
968 graph
= ((y
-minv
)*BAT_YSPACE
)/(maxv
-minv
);
969 graph
= LCD_HEIGHT
-1 - graph
;
971 /* draw dotted horizontal grid line */
972 for (x
=0; x
<LCD_WIDTH
;x
=x
+2)
973 lcd_drawpixel(x
,graph
);
979 /* draw plot of power history
982 for (i
= BAT_LAST_VAL
- 1; i
> 0; i
--)
984 if (power_history
[i
] && power_history
[i
-1])
986 y1
= (power_history
[i
] - minv
) * BAT_YSPACE
/
988 y1
= MIN(MAX(LCD_HEIGHT
-1 - y1
, BAT_TSPACE
),
990 y2
= (power_history
[i
-1] - minv
) * BAT_YSPACE
/
992 y2
= MIN(MAX(LCD_HEIGHT
-1 - y2
, BAT_TSPACE
),
995 lcd_set_drawmode(DRMODE_SOLID
);
997 /* make line thicker */
998 lcd_drawline(((x
*LCD_WIDTH
)/(BAT_LAST_VAL
)),
1000 (((x
+1)*LCD_WIDTH
)/(BAT_LAST_VAL
)),
1002 lcd_drawline(((x
*LCD_WIDTH
)/(BAT_LAST_VAL
))+1,
1004 (((x
+1)*LCD_WIDTH
)/(BAT_LAST_VAL
))+1,
1011 case 1: /* status: */
1012 #if CONFIG_CHARGING >= CHARGING_MONITOR
1013 lcd_putsf(0, 0, "Pwr status: %s",
1014 charging_state() ? "charging" : "discharging");
1016 lcd_puts(0, 0, "Power status: unknown");
1018 battery_read_info(&y
, &z
);
1020 lcd_putsf(0, 1, "Battery: %d.%03d V (%d %%)", y
/ 1000, y
% 1000, z
);
1022 lcd_putsf(0, 1, "Battery: %d %%", z
);
1023 #ifdef ADC_EXT_POWER
1024 y
= (adc_read(ADC_EXT_POWER
) * EXT_SCALE_FACTOR
) / 1000;
1025 lcd_putsf(0, 2, "External: %d.%03d V", y
/ 1000, y
% 1000);
1028 #if defined ARCHOS_RECORDER
1029 lcd_putsf(0, 3, "Chgr: %s %s",
1030 charger_inserted() ? "present" : "absent",
1031 charger_enabled() ? "on" : "off");
1032 lcd_putsf(0, 5, "short delta: %d", short_delta
);
1033 lcd_putsf(0, 6, "long delta: %d", long_delta
);
1034 lcd_puts(0, 7, power_message
);
1035 lcd_putsf(0, 8, "USB Inserted: %s",
1036 usb_inserted() ? "yes" : "no");
1037 #elif defined IPOD_NANO || defined IPOD_VIDEO
1038 int usb_pwr
= (GPIOL_INPUT_VAL
& 0x10)?true:false;
1039 int ext_pwr
= (GPIOL_INPUT_VAL
& 0x08)?false:true;
1040 int dock
= (GPIOA_INPUT_VAL
& 0x10)?true:false;
1041 int charging
= (GPIOB_INPUT_VAL
& 0x01)?false:true;
1042 int headphone
= (GPIOA_INPUT_VAL
& 0x80)?true:false;
1044 lcd_putsf(0, 3, "USB pwr: %s",
1045 usb_pwr
? "present" : "absent");
1046 lcd_putsf(0, 4, "EXT pwr: %s",
1047 ext_pwr
? "present" : "absent");
1048 lcd_putsf(0, 5, "Battery: %s",
1049 charging
? "charging" : (usb_pwr
||ext_pwr
) ? "charged" : "discharging");
1050 lcd_putsf(0, 6, "Dock mode: %s",
1051 dock
? "enabled" : "disabled");
1052 lcd_putsf(0, 7, "Headphone: %s",
1053 headphone
? "connected" : "disconnected");
1055 if(probed_ramsize
== 64)
1056 x
= (adc_read(ADC_4066_ISTAT
) * 2400) / (1024 * 2);
1059 x
= (adc_read(ADC_4066_ISTAT
) * 2400) / (1024 * 3);
1060 lcd_putsf(0, 8, "Ibat: %d mA", x
);
1061 lcd_putsf(0, 9, "Vbat * Ibat: %d mW", x
* y
/ 1000);
1062 #elif defined TOSHIBA_GIGABEAT_S
1066 static const unsigned char * const chrgstate_strings
[] =
1077 lcd_putsf(0, line
++, "Charger: %s",
1078 charger_inserted() ? "present" : "absent");
1080 st
= power_input_status() &
1081 (POWER_INPUT_CHARGER
| POWER_INPUT_BATTERY
);
1082 lcd_putsf(0, line
++, "%s%s",
1083 (st
& POWER_INPUT_MAIN_CHARGER
) ? " Main" : "",
1084 (st
& POWER_INPUT_USB_CHARGER
) ? " USB" : "");
1086 y
= ARRAYLEN(chrgstate_strings
) - 1;
1088 switch (charge_state
)
1090 case CHARGE_STATE_DISABLED
: y
--;
1091 case CHARGE_STATE_ERROR
: y
--;
1092 case DISCHARGING
: y
--;
1099 lcd_putsf(0, line
++, "State: %s", chrgstate_strings
[y
]);
1101 lcd_putsf(0, line
++, "Battery Switch: %s",
1102 (st
& POWER_INPUT_BATTERY
) ? "On" : "Off");
1104 y
= chrgraw_adc_voltage();
1105 lcd_putsf(0, line
++, "CHRGRAW: %d.%03d V",
1106 y
/ 1000, y
% 1000);
1108 y
= application_supply_adc_voltage();
1109 lcd_putsf(0, line
++, "BP : %d.%03d V",
1110 y
/ 1000, y
% 1000);
1112 y
= battery_adc_charge_current();
1113 if (y
< 0) x
= '-', y
= -y
;
1115 lcd_putsf(0, line
++, "CHRGISN:%c%d mA", x
, y
);
1117 y
= cccv_regulator_dissipation();
1118 lcd_putsf(0, line
++, "P CCCV : %d mW", y
);
1120 y
= battery_charge_current();
1121 if (y
< 0) x
= '-', y
= -y
;
1123 lcd_putsf(0, line
++, "I Charge:%c%d mA", x
, y
);
1125 y
= battery_adc_temp();
1128 lcd_putsf(0, line
++, "T Battery: %dC (%dF)", y
,
1131 /* Conversion disabled */
1132 lcd_puts(0, line
++, "T Battery: ?");
1135 #elif defined(HAVE_AS3514) && defined(CONFIG_CHARGING)
1136 static const char * const chrgstate_strings
[] =
1138 [CHARGE_STATE_DISABLED
- CHARGE_STATE_DISABLED
]= "Disabled",
1139 [CHARGE_STATE_ERROR
- CHARGE_STATE_DISABLED
] = "Error",
1140 [DISCHARGING
- CHARGE_STATE_DISABLED
] = "Discharging",
1141 [CHARGING
- CHARGE_STATE_DISABLED
] = "Charging",
1143 const char *str
= NULL
;
1145 lcd_putsf(0, 3, "Charger: %s",
1146 charger_inserted() ? "present" : "absent");
1148 y
= charge_state
- CHARGE_STATE_DISABLED
;
1149 if ((unsigned)y
< ARRAYLEN(chrgstate_strings
))
1150 str
= chrgstate_strings
[y
];
1152 lcd_putsf(0, 4, "State: %s",
1153 str
? str
: "<unknown>");
1155 lcd_putsf(0, 5, "CHARGER: %02X", ascodec_read_charger());
1156 #elif defined(IPOD_NANO2G)
1157 y
= pmu_read_battery_voltage();
1158 lcd_putsf(17, 1, "RAW: %d.%03d V", y
/ 1000, y
% 1000);
1159 y
= pmu_read_battery_current();
1160 lcd_putsf(0, 2, "Battery current: %d mA", y
);
1161 lcd_putsf(0, 3, "PWRCON: %08x %08x", PWRCON
, PWRCONEXT
);
1162 lcd_putsf(0, 4, "CLKCON: %08x %03x %03x", CLKCON
, CLKCON2
, CLKCON3
);
1163 lcd_putsf(0, 5, "PLL: %06x %06x %06x", PLL0PMS
, PLL1PMS
, PLL2PMS
);
1164 x
= pmu_read(0x1b) & 0xf;
1165 y
= pmu_read(0x1a) * 25 + 625;
1166 lcd_putsf(0, 6, "AUTO: %x / %d mV", x
, y
);
1167 x
= pmu_read(0x1f) & 0xf;
1168 y
= pmu_read(0x1e) * 25 + 625;
1169 lcd_putsf(0, 7, "DOWN1: %x / %d mV", x
, y
);
1170 x
= pmu_read(0x23) & 0xf;
1171 y
= pmu_read(0x22) * 25 + 625;
1172 lcd_putsf(0, 8, "DOWN2: %x / %d mV", x
, y
);
1173 x
= pmu_read(0x27) & 0xf;
1174 y
= pmu_read(0x26) * 100 + 900;
1175 lcd_putsf(0, 9, "MEMLDO: %x / %d mV", x
, y
);
1176 for (i
= 0; i
< 6; i
++)
1178 x
= pmu_read(0x2e + (i
<< 1)) & 0xf;
1179 y
= pmu_read(0x2d + (i
<< 1)) * 100 + 900;
1180 lcd_putsf(0, 10 + i
, "LDO%d: %x / %d mV", i
+ 1, x
, y
);
1183 lcd_putsf(0, 3, "Charger: %s",
1184 charger_inserted() ? "present" : "absent");
1185 #endif /* target type */
1186 #endif /* CONFIG_CHARGING */
1188 case 2: /* voltage deltas: */
1189 #if (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE)
1190 lcd_puts(0, 0, "Voltage deltas:");
1191 for (i
= 0; i
< POWER_HISTORY_LEN
-1; i
++) {
1192 y
= power_history
[i
] - power_history
[i
+1];
1193 lcd_putsf(0, i
+1, "-%d min: %c%d.%03d V", i
,
1194 (y
< 0) ? '-' : ' ', ((y
< 0) ? y
* -1 : y
) / 1000,
1195 ((y
< 0) ? y
* -1 : y
) % 1000);
1197 #elif (CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE)
1198 lcd_puts(0, 0, "Percentage deltas:");
1199 for (i
= 0; i
< POWER_HISTORY_LEN
-1; i
++) {
1200 y
= power_history
[i
] - power_history
[i
+1];
1201 lcd_putsf(0, i
+1, "-%d min: %c%d%%", i
,
1202 (y
< 0) ? '-' : ' ', ((y
< 0) ? y
* -1 : y
));
1207 case 3: /* remaining time estimation: */
1209 #ifdef ARCHOS_RECORDER
1210 lcd_putsf(0, 0, "charge_state: %d", charge_state
);
1212 lcd_putsf(0, 1, "Cycle time: %d m", powermgmt_last_cycle_startstop_min
);
1214 lcd_putsf(0, 2, "Lvl@cyc st: %d%%", powermgmt_last_cycle_level
);
1216 lcd_putsf(0, 3, "P=%2d I=%2d", pid_p
, pid_i
);
1218 lcd_putsf(0, 4, "Trickle sec: %d/60", trickle_sec
);
1219 #endif /* ARCHOS_RECORDER */
1221 #if (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE)
1222 lcd_putsf(0, 5, "Last PwrHist: %d.%03dV",
1223 power_history
[0] / 1000,
1224 power_history
[0] % 1000);
1227 lcd_putsf(0, 6, "battery level: %d%%", battery_level());
1229 int time_left
= battery_time();
1231 lcd_putsf(0, 7, "Est. remain: %d m", time_left
);
1233 lcd_puts(0, 7, "Estimation n/a");
1239 switch(get_action(CONTEXT_STD
,HZ
/2))
1241 case ACTION_STD_PREV
:
1246 case ACTION_STD_NEXT
:
1251 case ACTION_STD_CANCEL
:
1252 lcd_setfont(FONT_UI
);
1256 lcd_setfont(FONT_UI
);
1260 #endif /* (CONFIG_BATTERY_MEASURE != 0) && HAVE_LCD_BITMAP */
1262 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
1263 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
1265 #if (CONFIG_STORAGE & STORAGE_MMC)
1266 #define CARDTYPE "MMC"
1267 #elif (CONFIG_STORAGE & STORAGE_SD)
1268 #define CARDTYPE "microSD"
1271 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1274 int *cardnum
= (int*)lists
->data
;
1275 unsigned char card_name
[6];
1276 unsigned char pbuf
[32];
1277 char *title
= lists
->title
;
1278 static const unsigned char i_vmin
[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
1279 static const unsigned char i_vmax
[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
1280 static const unsigned char * const kbit_units
[] = { "kBit/s", "MBit/s", "GBit/s" };
1281 static const unsigned char * const nsec_units
[] = { "ns", "µs", "ms" };
1282 #if (CONFIG_STORAGE & STORAGE_MMC)
1283 static const char * const mmc_spec_vers
[] = { "1.0-1.2", "1.4", "2.0-2.2",
1284 "3.1-3.31", "4.0" };
1287 if ((btn
== ACTION_STD_OK
) || (btn
== SYS_FS_CHANGED
) || (btn
== ACTION_REDRAW
))
1290 if (btn
== ACTION_STD_OK
)
1292 *cardnum
^= 0x1; /* change cards */
1296 simplelist_set_line_count(0);
1298 card
= card_get_info(*cardnum
);
1300 if (card
->initialized
> 0)
1303 for (i
=0; i
<sizeof(card_name
); i
++)
1305 card_name
[i
] = card_extract_bits(card
->cid
, (103-8*i
), 8);
1307 strlcpy(card_name
, card_name
, sizeof(card_name
));
1308 simplelist_addline(SIMPLELIST_ADD_LINE
,
1309 "%s Rev %d.%d", card_name
,
1310 (int) card_extract_bits(card
->cid
, 63, 4),
1311 (int) card_extract_bits(card
->cid
, 59, 4));
1312 simplelist_addline(SIMPLELIST_ADD_LINE
,
1314 #if (CONFIG_STORAGE & STORAGE_SD)
1315 (int) card_extract_bits(card
->cid
, 11, 4),
1316 (int) card_extract_bits(card
->cid
, 19, 8) + 2000
1317 #elif (CONFIG_STORAGE & STORAGE_MMC)
1318 (int) card_extract_bits(card
->cid
, 15, 4),
1319 (int) card_extract_bits(card
->cid
, 11, 4) + 1997
1322 simplelist_addline(SIMPLELIST_ADD_LINE
,
1323 #if (CONFIG_STORAGE & STORAGE_SD)
1325 card_extract_bits(card
->cid
, 55, 32)
1326 #elif (CONFIG_STORAGE & STORAGE_MMC)
1328 card_extract_bits(card
->cid
, 47, 16)
1332 simplelist_addline(SIMPLELIST_ADD_LINE
, "M=%02x, "
1333 #if (CONFIG_STORAGE & STORAGE_SD)
1335 (int) card_extract_bits(card
->cid
, 127, 8),
1336 card_extract_bits(card
->cid
, 119, 8),
1337 card_extract_bits(card
->cid
, 111, 8)
1338 #elif (CONFIG_STORAGE & STORAGE_MMC)
1340 (int) card_extract_bits(card
->cid
, 127, 8),
1341 (int) card_extract_bits(card
->cid
, 119, 16)
1345 #if (CONFIG_STORAGE & STORAGE_MMC)
1346 int temp
= card_extract_bits(card
->csd
, 125, 4);
1347 simplelist_addline(SIMPLELIST_ADD_LINE
,
1348 "MMC v%s", temp
< 5 ?
1349 mmc_spec_vers
[temp
] : "?.?");
1351 simplelist_addline(SIMPLELIST_ADD_LINE
,
1352 "Blocks: 0x%08lx", card
->numblocks
);
1353 output_dyn_value(pbuf
, sizeof pbuf
, card
->speed
/ 1000,
1355 simplelist_addline(SIMPLELIST_ADD_LINE
,
1357 output_dyn_value(pbuf
, sizeof pbuf
, card
->taac
,
1359 simplelist_addline(SIMPLELIST_ADD_LINE
,
1361 simplelist_addline(SIMPLELIST_ADD_LINE
,
1362 "Nsac: %d clk", card
->nsac
);
1363 simplelist_addline(SIMPLELIST_ADD_LINE
,
1364 "R2W: *%d", card
->r2w_factor
);
1365 #if (CONFIG_STORAGE & STORAGE_SD)
1366 int csd_structure
= card_extract_bits(card
->csd
, 127, 2);
1367 if (csd_structure
== 0) /* CSD version 1.0 */
1370 simplelist_addline(SIMPLELIST_ADD_LINE
,
1372 i_vmin
[card_extract_bits(card
->csd
, 61, 3)],
1373 i_vmax
[card_extract_bits(card
->csd
, 58, 3)]);
1374 simplelist_addline(SIMPLELIST_ADD_LINE
,
1376 i_vmin
[card_extract_bits(card
->csd
, 55, 3)],
1377 i_vmax
[card_extract_bits(card
->csd
, 52, 3)]);
1380 else if (card
->initialized
== 0)
1382 simplelist_addline(SIMPLELIST_ADD_LINE
, "Not Found!");
1384 #if (CONFIG_STORAGE & STORAGE_SD)
1385 else /* card->initialized < 0 */
1387 simplelist_addline(SIMPLELIST_ADD_LINE
, "Init Error! (%d)", card
->initialized
);
1390 snprintf(title
, 16, "[" CARDTYPE
" %d]", *cardnum
);
1391 gui_synclist_set_title(lists
, title
, Icon_NOICON
);
1392 gui_synclist_set_nb_items(lists
, simplelist_get_line_count());
1393 gui_synclist_select_item(lists
, 0);
1394 btn
= ACTION_REDRAW
;
1398 #elif (CONFIG_STORAGE & STORAGE_ATA)
1399 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1404 unsigned short* identify_info
= ata_get_identify();
1405 bool timing_info_present
= false;
1408 simplelist_set_line_count(0);
1410 for (i
=0; i
< 20; i
++)
1411 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+27]);
1413 /* kill trailing space */
1414 for (i
=39; i
&& buf
[i
]==' '; i
--)
1416 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", buf
);
1417 for (i
=0; i
< 4; i
++)
1418 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+23]);
1420 simplelist_addline(SIMPLELIST_ADD_LINE
,
1421 "Firmware: %s", buf
);
1422 snprintf(buf
, sizeof buf
, "%ld MB",
1423 ((unsigned long)identify_info
[61] << 16 |
1424 (unsigned long)identify_info
[60]) / 2048 );
1425 simplelist_addline(SIMPLELIST_ADD_LINE
,
1428 fat_size( IF_MV2(0,) NULL
, &free
);
1429 simplelist_addline(SIMPLELIST_ADD_LINE
,
1430 "Free: %ld MB", free
/ 1024);
1431 simplelist_addline(SIMPLELIST_ADD_LINE
,
1432 "Spinup time: %d ms", storage_spinup_time() * (1000/HZ
));
1433 i
= identify_info
[83] & (1<<3);
1434 simplelist_addline(SIMPLELIST_ADD_LINE
,
1435 "Power mgmt: %s", i
? "enabled" : "unsupported");
1436 i
= identify_info
[83] & (1<<9);
1437 simplelist_addline(SIMPLELIST_ADD_LINE
,
1438 "Noise mgmt: %s", i
? "enabled" : "unsupported");
1439 i
= identify_info
[82] & (1<<6);
1440 simplelist_addline(SIMPLELIST_ADD_LINE
,
1441 "Read-ahead: %s", i
? "enabled" : "unsupported");
1442 timing_info_present
= identify_info
[53] & (1<<1);
1443 if(timing_info_present
) {
1444 char pio3
[2], pio4
[2];pio3
[1] = 0;
1446 pio3
[0] = (identify_info
[64] & (1<<0)) ? '3' : 0;
1447 pio4
[0] = (identify_info
[64] & (1<<1)) ? '4' : 0;
1448 simplelist_addline(SIMPLELIST_ADD_LINE
,
1449 "PIO modes: 0 1 2 %s %s", pio3
, pio4
);
1452 simplelist_addline(SIMPLELIST_ADD_LINE
,
1453 "No PIO mode info");
1455 timing_info_present
= identify_info
[53] & (1<<1);
1456 if(timing_info_present
) {
1457 simplelist_addline(SIMPLELIST_ADD_LINE
,
1458 "Cycle times %dns/%dns",
1460 identify_info
[68] );
1462 simplelist_addline(SIMPLELIST_ADD_LINE
,
1465 int sector_size
= 512;
1466 if((identify_info
[106] & 0xe000) == 0x6000)
1467 sector_size
*= BIT_N(identify_info
[106] & 0x000f);
1468 simplelist_addline(SIMPLELIST_ADD_LINE
,
1469 "Physical sector size: %d", sector_size
);
1471 if (identify_info
[63] & (1<<0)) {
1472 char mdma0
[2], mdma1
[2], mdma2
[2];
1473 mdma0
[1] = mdma1
[1] = mdma2
[1] = 0;
1474 mdma0
[0] = (identify_info
[63] & (1<<0)) ? '0' : 0;
1475 mdma1
[0] = (identify_info
[63] & (1<<1)) ? '1' : 0;
1476 mdma2
[0] = (identify_info
[63] & (1<<2)) ? '2' : 0;
1477 simplelist_addline(SIMPLELIST_ADD_LINE
,
1478 "MDMA modes: %s %s %s", mdma0
, mdma1
, mdma2
);
1479 simplelist_addline(SIMPLELIST_ADD_LINE
,
1480 "MDMA Cycle times %dns/%dns",
1482 identify_info
[66] );
1485 simplelist_addline(SIMPLELIST_ADD_LINE
,
1486 "No MDMA mode info");
1488 if (identify_info
[53] & (1<<2)) {
1489 char udma0
[2], udma1
[2], udma2
[2], udma3
[2], udma4
[2], udma5
[2], udma6
[2];
1490 udma0
[1] = udma1
[1] = udma2
[1] = udma3
[1] = udma4
[1] = udma5
[1] = udma6
[1] = 0;
1491 udma0
[0] = (identify_info
[88] & (1<<0)) ? '0' : 0;
1492 udma1
[0] = (identify_info
[88] & (1<<1)) ? '1' : 0;
1493 udma2
[0] = (identify_info
[88] & (1<<2)) ? '2' : 0;
1494 udma3
[0] = (identify_info
[88] & (1<<3)) ? '3' : 0;
1495 udma4
[0] = (identify_info
[88] & (1<<4)) ? '4' : 0;
1496 udma5
[0] = (identify_info
[88] & (1<<5)) ? '5' : 0;
1497 udma6
[0] = (identify_info
[88] & (1<<6)) ? '6' : 0;
1498 simplelist_addline(SIMPLELIST_ADD_LINE
,
1499 "UDMA modes: %s %s %s %s %s %s %s", udma0
, udma1
, udma2
,
1500 udma3
, udma4
, udma5
, udma6
);
1503 simplelist_addline(SIMPLELIST_ADD_LINE
,
1504 "No UDMA mode info");
1506 #endif /* HAVE_ATA_DMA */
1507 timing_info_present
= identify_info
[53] & (1<<1);
1508 if(timing_info_present
) {
1509 i
= identify_info
[49] & (1<<11);
1510 simplelist_addline(SIMPLELIST_ADD_LINE
,
1511 "IORDY support: %s", i
? "yes" : "no");
1512 i
= identify_info
[49] & (1<<10);
1513 simplelist_addline(SIMPLELIST_ADD_LINE
,
1514 "IORDY disable: %s", i
? "yes" : "no");
1516 simplelist_addline(SIMPLELIST_ADD_LINE
,
1519 simplelist_addline(SIMPLELIST_ADD_LINE
,
1520 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
1522 i
= ata_get_dma_mode();
1524 simplelist_addline(SIMPLELIST_ADD_LINE
,
1527 simplelist_addline(SIMPLELIST_ADD_LINE
,
1529 (i
& 0x40) ? "UDMA" : "MDMA",
1532 #endif /* HAVE_ATA_DMA */
1535 #else /* No SD, MMC or ATA */
1536 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1539 struct storage_info info
;
1540 storage_get_info(0,&info
);
1541 simplelist_addline(SIMPLELIST_ADD_LINE
, "Vendor: %s", info
.vendor
);
1542 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", info
.product
);
1543 simplelist_addline(SIMPLELIST_ADD_LINE
, "Firmware: %s", info
.revision
);
1544 simplelist_addline(SIMPLELIST_ADD_LINE
,
1545 "Size: %ld MB", info
.num_sectors
*(info
.sector_size
/512)/2024);
1547 fat_size( IF_MV2(0,) NULL
, &free
);
1548 simplelist_addline(SIMPLELIST_ADD_LINE
,
1549 "Free: %ld MB", free
/ 1024);
1550 simplelist_addline(SIMPLELIST_ADD_LINE
,
1551 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
1556 #if (CONFIG_STORAGE & STORAGE_ATA)
1557 static bool dbg_identify_info(void)
1559 int fd
= creat("/identify_info.bin", 0666);
1562 #ifdef ROCKBOX_LITTLE_ENDIAN
1563 ecwrite(fd
, ata_get_identify(), SECTOR_SIZE
/2, "s", true);
1565 write(fd
, ata_get_identify(), SECTOR_SIZE
);
1573 static bool dbg_disk_info(void)
1575 struct simplelist_info info
;
1576 simplelist_info_init(&info
, "Disk Info", 1, NULL
);
1577 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
1580 info
.callback_data
= (void*)&card
;
1583 info
.action_callback
= disk_callback
;
1584 info
.hide_selection
= true;
1585 info
.scroll_all
= true;
1586 return simplelist_show_list(&info
);
1588 #endif /* PLATFORM_NATIVE */
1590 #ifdef HAVE_DIRCACHE
1591 static int dircache_callback(int btn
, struct gui_synclist
*lists
)
1594 simplelist_set_line_count(0);
1595 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache initialized: %s",
1596 dircache_is_enabled() ? "Yes" : "No");
1597 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache size: %d B",
1598 dircache_get_cache_size());
1599 simplelist_addline(SIMPLELIST_ADD_LINE
, "Last size: %d B",
1600 global_status
.dircache_size
);
1601 simplelist_addline(SIMPLELIST_ADD_LINE
, "Limit: %d B",
1603 simplelist_addline(SIMPLELIST_ADD_LINE
, "Reserve: %d/%d B",
1604 dircache_get_reserve_used(), DIRCACHE_RESERVE
);
1605 simplelist_addline(SIMPLELIST_ADD_LINE
, "Scanning took: %d s",
1606 dircache_get_build_ticks() / HZ
);
1607 simplelist_addline(SIMPLELIST_ADD_LINE
, "Entry count: %d",
1608 dircache_get_entry_count());
1612 static bool dbg_dircache_info(void)
1614 struct simplelist_info info
;
1615 simplelist_info_init(&info
, "Dircache Info", 7, NULL
);
1616 info
.action_callback
= dircache_callback
;
1617 info
.hide_selection
= true;
1618 info
.scroll_all
= true;
1619 return simplelist_show_list(&info
);
1622 #endif /* HAVE_DIRCACHE */
1624 #ifdef HAVE_TAGCACHE
1625 static int database_callback(int btn
, struct gui_synclist
*lists
)
1628 struct tagcache_stat
*stat
= tagcache_get_stat();
1629 static bool synced
= false;
1631 simplelist_set_line_count(0);
1633 simplelist_addline(SIMPLELIST_ADD_LINE
, "Initialized: %s",
1634 stat
->initialized
? "Yes" : "No");
1635 simplelist_addline(SIMPLELIST_ADD_LINE
, "DB Ready: %s",
1636 stat
->ready
? "Yes" : "No");
1637 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM Cache: %s",
1638 stat
->ramcache
? "Yes" : "No");
1639 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM: %d/%d B",
1640 stat
->ramcache_used
, stat
->ramcache_allocated
);
1641 simplelist_addline(SIMPLELIST_ADD_LINE
, "Progress: %d%% (%d entries)",
1642 stat
->progress
, stat
->processed_entries
);
1643 simplelist_addline(SIMPLELIST_ADD_LINE
, "Curfile: %s",
1644 stat
->curentry
? stat
->curentry
: "---");
1645 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit step: %d",
1647 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit delayed: %s",
1648 stat
->commit_delayed
? "Yes" : "No");
1650 simplelist_addline(SIMPLELIST_ADD_LINE
, "Queue length: %d",
1651 stat
->queue_length
);
1656 tagcache_screensync_event();
1659 if (!btn
&& stat
->curentry
)
1662 return ACTION_REDRAW
;
1665 if (btn
== ACTION_STD_CANCEL
)
1666 tagcache_screensync_enable(false);
1670 static bool dbg_tagcache_info(void)
1672 struct simplelist_info info
;
1673 simplelist_info_init(&info
, "Database Info", 8, NULL
);
1674 info
.action_callback
= database_callback
;
1675 info
.hide_selection
= true;
1676 info
.scroll_all
= true;
1678 /* Don't do nonblock here, must give enough processing time
1679 for tagcache thread. */
1680 /* info.timeout = TIMEOUT_NOBLOCK; */
1682 tagcache_screensync_enable(true);
1683 return simplelist_show_list(&info
);
1687 #if CONFIG_CPU == SH7034
1688 static bool dbg_save_roms(void)
1691 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
1693 fd
= creat("/internal_rom_0000-FFFF.bin", 0666);
1696 write(fd
, (void *)0, 0x10000);
1700 fd
= creat("/internal_rom_2000000-203FFFF.bin", 0666);
1703 write(fd
, (void *)0x2000000, 0x40000);
1707 system_memory_guard(oldmode
);
1710 #elif defined CPU_COLDFIRE
1711 static bool dbg_save_roms(void)
1714 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
1716 #if defined(IRIVER_H100_SERIES)
1717 fd
= creat("/internal_rom_000000-1FFFFF.bin", 0666);
1718 #elif defined(IRIVER_H300_SERIES)
1719 fd
= creat("/internal_rom_000000-3FFFFF.bin", 0666);
1720 #elif defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IAUDIO_M3)
1721 fd
= creat("/internal_rom_000000-3FFFFF.bin", 0666);
1722 #elif defined(MPIO_HD200) || defined(MPIO_HD300)
1723 fd
= creat("/internal_rom_000000-1FFFFF.bin", 0666);
1727 write(fd
, (void *)0, FLASH_SIZE
);
1730 system_memory_guard(oldmode
);
1733 fd
= creat("/internal_eeprom.bin", 0666);
1737 char buf
[EEPROM_SIZE
];
1740 old_irq_level
= disable_irq_save();
1742 err
= eeprom_24cxx_read(0, buf
, sizeof buf
);
1744 restore_irq(old_irq_level
);
1747 splashf(HZ
*3, "Eeprom read failure (%d)", err
);
1750 write(fd
, buf
, sizeof buf
);
1759 #elif defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD)
1760 static bool dbg_save_roms(void)
1762 int fd
= creat("/internal_rom_000000-0FFFFF.bin", 0666);
1765 write(fd
, (void *)0x20000000, FLASH_SIZE
);
1771 #elif CONFIG_CPU == IMX31L
1772 bool __dbg_dvfs_dptc(void);
1773 static bool dbg_save_roms(void)
1775 int fd
= creat("/flash_rom_A0000000-A01FFFFF.bin", 0666);
1778 write(fd
, (void*)0xa0000000, FLASH_SIZE
);
1784 #elif defined(CPU_TCC780X)
1785 static bool dbg_save_roms(void)
1787 int fd
= creat("/eeprom_E0000000-E0001FFF.bin", 0666);
1790 write(fd
, (void*)0xe0000000, 0x2000);
1801 #ifdef CONFIG_TUNER_MULTI
1802 static int tuner_type
= 0;
1803 #define IF_TUNER_TYPE(type) if(tuner_type==type)
1805 #define IF_TUNER_TYPE(type)
1808 static int radio_callback(int btn
, struct gui_synclist
*lists
)
1811 if (btn
== ACTION_STD_CANCEL
)
1813 simplelist_set_line_count(1);
1815 #if (CONFIG_TUNER & LV24020LP)
1816 simplelist_addline(SIMPLELIST_ADD_LINE
,
1817 "CTRL_STAT: %02X", lv24020lp_get(LV24020LP_CTRL_STAT
) );
1818 simplelist_addline(SIMPLELIST_ADD_LINE
,
1819 "RADIO_STAT: %02X", lv24020lp_get(LV24020LP_REG_STAT
) );
1820 simplelist_addline(SIMPLELIST_ADD_LINE
,
1821 "MSS_FM: %d kHz", lv24020lp_get(LV24020LP_MSS_FM
) );
1822 simplelist_addline(SIMPLELIST_ADD_LINE
,
1823 "MSS_IF: %d Hz", lv24020lp_get(LV24020LP_MSS_IF
) );
1824 simplelist_addline(SIMPLELIST_ADD_LINE
,
1825 "MSS_SD: %d Hz", lv24020lp_get(LV24020LP_MSS_SD
) );
1826 simplelist_addline(SIMPLELIST_ADD_LINE
,
1827 "if_set: %d Hz", lv24020lp_get(LV24020LP_IF_SET
) );
1828 simplelist_addline(SIMPLELIST_ADD_LINE
,
1829 "sd_set: %d Hz", lv24020lp_get(LV24020LP_SD_SET
) );
1830 #endif /* LV24020LP */
1831 #if (CONFIG_TUNER & S1A0903X01)
1832 simplelist_addline(SIMPLELIST_ADD_LINE
,
1833 "Samsung regs: %08X", s1a0903x01_get(RADIO_ALL
));
1834 /* This one doesn't return dynamic data atm */
1835 #endif /* S1A0903X01 */
1836 #if (CONFIG_TUNER & TEA5767)
1837 struct tea5767_dbg_info nfo
;
1838 tea5767_dbg_info(&nfo
);
1839 simplelist_addline(SIMPLELIST_ADD_LINE
, "Philips regs:");
1840 simplelist_addline(SIMPLELIST_ADD_LINE
,
1841 " Read: %02X %02X %02X %02X %02X",
1842 (unsigned)nfo
.read_regs
[0], (unsigned)nfo
.read_regs
[1],
1843 (unsigned)nfo
.read_regs
[2], (unsigned)nfo
.read_regs
[3],
1844 (unsigned)nfo
.read_regs
[4]);
1845 simplelist_addline(SIMPLELIST_ADD_LINE
,
1846 " Write: %02X %02X %02X %02X %02X",
1847 (unsigned)nfo
.write_regs
[0], (unsigned)nfo
.write_regs
[1],
1848 (unsigned)nfo
.write_regs
[2], (unsigned)nfo
.write_regs
[3],
1849 (unsigned)nfo
.write_regs
[4]);
1850 #endif /* TEA5767 */
1851 #if (CONFIG_TUNER & SI4700)
1852 IF_TUNER_TYPE(SI4700
)
1854 struct si4700_dbg_info nfo
;
1855 si4700_dbg_info(&nfo
);
1856 simplelist_addline(SIMPLELIST_ADD_LINE
, "SI4700 regs:");
1857 for (int i
= 0; i
< 16; i
+= 4) {
1858 simplelist_addline(SIMPLELIST_ADD_LINE
,"%02X: %04X %04X %04X %04X",
1859 i
, nfo
.regs
[i
], nfo
.regs
[i
+1], nfo
.regs
[i
+2], nfo
.regs
[i
+3]);
1863 #if (CONFIG_TUNER & RDA5802)
1864 IF_TUNER_TYPE(RDA5802
)
1866 struct rda5802_dbg_info nfo
;
1867 rda5802_dbg_info(&nfo
);
1868 simplelist_addline(SIMPLELIST_ADD_LINE
, "RDA5802 regs:");
1869 for (int i
= 0; i
< 16; i
+= 4) {
1870 simplelist_addline(SIMPLELIST_ADD_LINE
,"%02X: %04X %04X %04X %04X",
1871 i
, nfo
.regs
[i
], nfo
.regs
[i
+1], nfo
.regs
[i
+2], nfo
.regs
[i
+3]);
1874 #endif /* RDA55802 */
1875 #if (CONFIG_TUNER & STFM1000)
1876 IF_TUNER_TYPE(STFM1000
)
1878 struct stfm1000_dbg_info nfo
;
1879 stfm1000_dbg_info(&nfo
);
1880 simplelist_addline(SIMPLELIST_ADD_LINE
, "STFM1000 regs:");
1881 simplelist_addline(SIMPLELIST_ADD_LINE
,"chipid: 0x%x", nfo
.chipid
);
1883 #endif /* STFM1000 */
1886 simplelist_addline(SIMPLELIST_ADD_LINE
, "PI:%04X PS:'%8s'",
1887 rds_get_pi(), rds_get_ps());
1888 simplelist_addline(SIMPLELIST_ADD_LINE
, "RT:%s",
1890 time_t seconds
= rds_get_ct();
1891 struct tm
* time
= gmtime(&seconds
);
1892 simplelist_addline(SIMPLELIST_ADD_LINE
,
1893 "CT:%4d-%02d-%02d %02d:%02d",
1894 time
->tm_year
+ 1900, time
->tm_mon
+ 1, time
->tm_mday
,
1895 time
->tm_hour
, time
->tm_min
, time
->tm_sec
);
1897 return ACTION_REDRAW
;
1899 static bool dbg_fm_radio(void)
1901 struct simplelist_info info
;
1902 #ifdef CONFIG_TUNER_MULTI
1903 tuner_type
= tuner_detect_type();
1905 info
.scroll_all
= true;
1906 simplelist_info_init(&info
, "FM Radio", 1, NULL
);
1907 simplelist_set_line_count(0);
1908 simplelist_addline(SIMPLELIST_ADD_LINE
, "HW detected: %s",
1909 radio_hardware_present() ? "yes" : "no");
1911 info
.action_callback
= radio_hardware_present()?radio_callback
: NULL
;
1912 info
.hide_selection
= true;
1913 return simplelist_show_list(&info
);
1915 #endif /* CONFIG_TUNER */
1916 #endif /* !SIMULATOR */
1918 #if defined(HAVE_LCD_BITMAP) && !defined(APPLICATION)
1919 extern bool do_screendump_instead_of_usb
;
1921 static bool dbg_screendump(void)
1923 do_screendump_instead_of_usb
= !do_screendump_instead_of_usb
;
1924 splashf(HZ
, "Screendump %sabled", do_screendump_instead_of_usb
?"en":"dis");
1927 #endif /* HAVE_LCD_BITMAP */
1929 extern bool write_metadata_log
;
1931 static bool dbg_metadatalog(void)
1933 write_metadata_log
= !write_metadata_log
;
1934 splashf(HZ
, "Metadata log %sabled", write_metadata_log
? "en" : "dis");
1938 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
1939 static bool dbg_set_memory_guard(void)
1941 static const struct opt_items names
[MAXMEMGUARD
] = {
1943 { "Flash ROM writes", -1 },
1944 { "Zero area (all)", -1 }
1946 int mode
= system_memory_guard(MEMGUARD_KEEP
);
1948 set_option( "Catch mem accesses", &mode
, INT
, names
, MAXMEMGUARD
, NULL
);
1949 system_memory_guard(mode
);
1953 #endif /* CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) */
1955 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
1956 static bool dbg_write_eeprom(void)
1958 int fd
= open("/internal_eeprom.bin", O_RDONLY
);
1962 char buf
[EEPROM_SIZE
];
1963 int rc
= read(fd
, buf
, EEPROM_SIZE
);
1965 if(rc
== EEPROM_SIZE
)
1967 int old_irq_level
= disable_irq_save();
1969 int err
= eeprom_24cxx_write(0, buf
, sizeof buf
);
1971 splashf(HZ
*3, "Eeprom write failure (%d)", err
);
1973 splash(HZ
*3, "Eeprom written successfully");
1975 restore_irq(old_irq_level
);
1979 splashf(HZ
*3, "File read error (%d)",rc
);
1985 splash(HZ
*3, "Failed to open 'internal_eeprom.bin'");
1990 #endif /* defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS) */
1991 #ifdef CPU_BOOST_LOGGING
1992 static bool cpu_boost_log(void)
1994 int count
= cpu_boost_log_getcount();
1995 char *str
= cpu_boost_log_getlog_first();
1997 lcd_setfont(FONT_SYSFIXED
);
1998 for (int i
= 0; i
< count
;)
2000 lcd_clear_display();
2001 for(int j
=0; j
<LCD_HEIGHT
/SYSFONT_HEIGHT
; j
++,i
++)
2004 str
= cpu_boost_log_getlog_next();
2007 if(strlen(str
) > LCD_WIDTH
/SYSFONT_WIDTH
)
2008 lcd_puts_scroll(0, j
, str
);
2018 switch(get_action(CONTEXT_STD
,TIMEOUT_BLOCK
))
2021 case ACTION_STD_PREV
:
2022 case ACTION_STD_NEXT
:
2025 case ACTION_STD_CANCEL
:
2033 get_action(CONTEXT_STD
,TIMEOUT_BLOCK
);
2034 lcd_setfont(FONT_UI
);
2039 #if (defined(HAVE_WHEEL_ACCELERATION) && (CONFIG_KEYPAD==IPOD_4G_PAD) \
2040 && !defined(IPOD_MINI) && !defined(SIMULATOR))
2041 extern bool wheel_is_touched
;
2042 extern int old_wheel_value
;
2043 extern int new_wheel_value
;
2044 extern int wheel_delta
;
2045 extern unsigned int accumulated_wheel_delta
;
2046 extern unsigned int wheel_velocity
;
2048 static bool dbg_scrollwheel(void)
2050 lcd_setfont(FONT_SYSFIXED
);
2054 if (action_userabort(HZ
/10))
2057 lcd_clear_display();
2059 /* show internal variables of scrollwheel driver */
2060 lcd_putsf(0, 0, "wheel touched: %s", (wheel_is_touched
) ? "true" : "false");
2061 lcd_putsf(0, 1, "new position: %2d", new_wheel_value
);
2062 lcd_putsf(0, 2, "old position: %2d", old_wheel_value
);
2063 lcd_putsf(0, 3, "wheel delta: %2d", wheel_delta
);
2064 lcd_putsf(0, 4, "accumulated delta: %2d", accumulated_wheel_delta
);
2065 lcd_putsf(0, 5, "velo [deg/s]: %4d", (int)wheel_velocity
);
2067 /* show effective accelerated scrollspeed */
2068 lcd_putsf(0, 6, "accel. speed: %4d",
2069 button_apply_acceleration((1<<31)|(1<<24)|wheel_velocity
) );
2073 lcd_setfont(FONT_UI
);
2078 #ifdef HAVE_USBSTACK
2079 #if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL)
2080 static bool toggle_usb_serial(void)
2082 bool enabled
= !usb_core_driver_enabled(USB_DRIVER_SERIAL
);
2084 usb_core_enable_driver(USB_DRIVER_SERIAL
, enabled
);
2085 splashf(HZ
, "USB Serial %sabled", enabled
? "en" : "dis");
2092 #if CONFIG_USBOTG == USBOTG_ISP1583
2093 extern int dbg_usb_num_items(void);
2094 extern const char* dbg_usb_item(int selected_item
, void *data
,
2095 char *buffer
, size_t buffer_len
);
2097 static int isp1583_action_callback(int action
, struct gui_synclist
*lists
)
2100 if (action
== ACTION_NONE
)
2101 action
= ACTION_REDRAW
;
2105 static bool dbg_isp1583(void)
2107 struct simplelist_info isp1583
;
2108 isp1583
.scroll_all
= true;
2109 simplelist_info_init(&isp1583
, "ISP1583", dbg_usb_num_items(), NULL
);
2110 isp1583
.timeout
= HZ
/100;
2111 isp1583
.hide_selection
= true;
2112 isp1583
.get_name
= dbg_usb_item
;
2113 isp1583
.action_callback
= isp1583_action_callback
;
2114 return simplelist_show_list(&isp1583
);
2118 #if defined(CREATIVE_ZVx) && !defined(SIMULATOR)
2119 extern int pic_dbg_num_items(void);
2120 extern const char* pic_dbg_item(int selected_item
, void *data
,
2121 char *buffer
, size_t buffer_len
);
2123 static int pic_action_callback(int action
, struct gui_synclist
*lists
)
2126 if (action
== ACTION_NONE
)
2127 action
= ACTION_REDRAW
;
2131 static bool dbg_pic(void)
2133 struct simplelist_info pic
;
2134 pic
.scroll_all
= true;
2135 simplelist_info_init(&pic
, "PIC", pic_dbg_num_items(), NULL
);
2136 pic
.timeout
= HZ
/100;
2137 pic
.hide_selection
= true;
2138 pic
.get_name
= pic_dbg_item
;
2139 pic
.action_callback
= pic_action_callback
;
2140 return simplelist_show_list(&pic
);
2145 /****** The menu *********/
2146 static const struct {
2147 unsigned char *desc
; /* string or ID */
2148 bool (*function
) (void); /* return true if USB was connected */
2150 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || \
2151 (defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD)) || \
2152 CONFIG_CPU == IMX31L || defined(CPU_TCC780X)
2153 { "Dump ROM contents", dbg_save_roms
},
2155 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || defined(CPU_PP) \
2156 || CONFIG_CPU == S3C2440 || CONFIG_CPU == IMX31L || CONFIG_CPU == AS3525 \
2157 || CONFIG_CPU == DM320 || defined(CPU_S5L870X) || CONFIG_CPU == AS3525v2 \
2158 || CONFIG_CPU == RK27XX
2159 { "View I/O ports", dbg_ports
},
2161 #if (CONFIG_RTC == RTC_PCF50605) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
2162 { "View PCF registers", dbg_pcf
},
2164 #if defined(HAVE_TSC2100) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
2165 { "TSC2100 debug", tsc2100_debug
},
2167 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
2168 { "CPU frequency", dbg_cpufreq
},
2170 #if CONFIG_CPU == IMX31L
2171 { "DVFS/DPTC", __dbg_dvfs_dptc
},
2173 #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR)
2174 { "S/PDIF analyzer", dbg_spdif
},
2176 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2177 { "Catch mem accesses", dbg_set_memory_guard
},
2179 { "View OS stacks", dbg_os
},
2181 { "View CPU stats", dbg_cpuinfo
},
2183 #ifdef HAVE_LCD_BITMAP
2184 #if (CONFIG_BATTERY_MEASURE != 0) && !defined(SIMULATOR)
2185 { "View battery", view_battery
},
2188 { "Screendump", dbg_screendump
},
2191 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
2192 { "View HW info", dbg_hw_info
},
2194 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
2195 { "View partitions", dbg_partitions
},
2197 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
2198 { "View disk info", dbg_disk_info
},
2199 #if (CONFIG_STORAGE & STORAGE_ATA)
2200 { "Dump ATA identify info", dbg_identify_info
},
2203 { "Metadata log", dbg_metadatalog
},
2204 #ifdef HAVE_DIRCACHE
2205 { "View dircache info", dbg_dircache_info
},
2207 #ifdef HAVE_TAGCACHE
2208 { "View database info", dbg_tagcache_info
},
2210 #ifdef HAVE_LCD_BITMAP
2211 #if CONFIG_CODEC == SWCODEC
2212 { "View buffering thread", dbg_buffering_thread
},
2213 #elif !defined(SIMULATOR)
2214 { "View audio thread", dbg_audio_thread
},
2217 { "pm histogram", peak_meter_histogram
},
2218 #endif /* PM_DEBUG */
2219 #endif /* HAVE_LCD_BITMAP */
2220 { "View buflib allocs", dbg_buflib_allocs
},
2223 { "FM Radio", dbg_fm_radio
},
2226 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2227 { "Write back EEPROM", dbg_write_eeprom
},
2229 #if CONFIG_USBOTG == USBOTG_ISP1583
2230 { "View ISP1583 info", dbg_isp1583
},
2232 #if defined(CREATIVE_ZVx) && !defined(SIMULATOR)
2233 { "View PIC info", dbg_pic
},
2235 #ifdef ROCKBOX_HAS_LOGF
2236 {"Show Log File", logfdisplay
},
2237 {"Dump Log File", logfdump
},
2239 #if defined(HAVE_USBSTACK)
2240 #if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL)
2241 {"USB Serial driver (logf)", toggle_usb_serial
},
2243 #endif /* HAVE_USBSTACK */
2244 #ifdef CPU_BOOST_LOGGING
2245 {"cpu_boost log",cpu_boost_log
},
2247 #if (defined(HAVE_WHEEL_ACCELERATION) && (CONFIG_KEYPAD==IPOD_4G_PAD) \
2248 && !defined(IPOD_MINI) && !defined(SIMULATOR))
2249 {"Debug scrollwheel", dbg_scrollwheel
},
2253 static int menu_action_callback(int btn
, struct gui_synclist
*lists
)
2255 int selection
= gui_synclist_get_sel_pos(lists
);
2256 if (btn
== ACTION_STD_OK
)
2259 viewportmanager_theme_enable(i
, false, NULL
);
2260 menuitems
[selection
].function();
2261 btn
= ACTION_REDRAW
;
2263 viewportmanager_theme_undo(i
, false);
2265 else if (btn
== ACTION_STD_CONTEXT
)
2267 MENUITEM_STRINGLIST(menu_items
, "Debug Menu", NULL
, ID2P(LANG_ADD_TO_FAVES
));
2268 if (do_menu(&menu_items
, NULL
, NULL
, false) == 0)
2269 shortcuts_add(SHORTCUT_DEBUGITEM
, menuitems
[selection
].desc
);
2270 return ACTION_STD_CANCEL
;
2275 static const char* menu_get_name(int item
, void * data
,
2276 char *buffer
, size_t buffer_len
)
2278 (void)data
; (void)buffer
; (void)buffer_len
;
2279 return menuitems
[item
].desc
;
2282 bool debug_menu(void)
2284 struct simplelist_info info
;
2286 simplelist_info_init(&info
, "Debug Menu", ARRAYLEN(menuitems
), NULL
);
2287 info
.action_callback
= menu_action_callback
;
2288 info
.get_name
= menu_get_name
;
2289 return simplelist_show_list(&info
);
2292 bool run_debug_screen(char* screen
)
2294 for (unsigned i
=0; i
<ARRAYLEN(menuitems
); i
++)
2295 if (!strcmp(screen
, menuitems
[i
].desc
))
2298 viewportmanager_theme_enable(j
, false, NULL
);
2299 menuitems
[i
].function();
2301 viewportmanager_theme_undo(j
, false);