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)
127 /*---------------------------------------------------*/
128 /* SPECIAL DEBUG STUFF */
129 /*---------------------------------------------------*/
130 extern struct thread_entry threads
[MAXTHREADS
];
132 static char thread_status_char(unsigned status
)
134 static const char thread_status_chars
[THREAD_NUM_STATES
+1] =
136 [0 ... THREAD_NUM_STATES
] = '?',
137 [STATE_RUNNING
] = 'R',
138 [STATE_BLOCKED
] = 'B',
139 [STATE_SLEEPING
] = 'S',
140 [STATE_BLOCKED_W_TMO
] = 'T',
141 [STATE_FROZEN
] = 'F',
142 [STATE_KILLED
] = 'K',
145 if (status
> THREAD_NUM_STATES
)
146 status
= THREAD_NUM_STATES
;
148 return thread_status_chars
[status
];
151 static const char* threads_getname(int selected_item
, void *data
,
152 char *buffer
, size_t buffer_len
)
155 struct thread_entry
*thread
;
159 if (selected_item
< (int)NUM_CORES
)
161 snprintf(buffer
, buffer_len
, "Idle (%d): %2d%%", selected_item
,
162 idle_stack_usage(selected_item
));
166 selected_item
-= NUM_CORES
;
169 thread
= &threads
[selected_item
];
171 if (thread
->state
== STATE_KILLED
)
173 snprintf(buffer
, buffer_len
, "%2d: ---", selected_item
);
177 thread_get_name(name
, 32, thread
);
179 snprintf(buffer
, buffer_len
,
180 "%2d: " IF_COP("(%d) ") "%c%c " IF_PRIO("%d %d ") "%2d%% %s",
182 IF_COP(thread
->core
,)
183 #ifdef HAVE_SCHEDULER_BOOSTCTRL
184 (thread
->cpu_boost
) ? '+' :
186 ((thread
->state
== STATE_RUNNING
) ? '*' : ' '),
187 thread_status_char(thread
->state
),
188 IF_PRIO(thread
->base_priority
, thread
->priority
, )
189 thread_stack_usage(thread
), name
);
194 static int dbg_threads_action_callback(int action
, struct gui_synclist
*lists
)
197 #ifdef ROCKBOX_HAS_LOGF
198 if (action
== ACTION_STD_OK
)
200 int selpos
= gui_synclist_get_sel_pos(lists
);
202 if (selpos
>= NUM_CORES
)
203 remove_thread(threads
[selpos
- NUM_CORES
].id
);
205 remove_thread(threads
[selpos
].id
);
207 return ACTION_REDRAW
;
209 #endif /* ROCKBOX_HAS_LOGF */
210 if (action
== ACTION_NONE
)
211 action
= ACTION_REDRAW
;
215 static bool dbg_os(void)
217 struct simplelist_info info
;
218 simplelist_info_init(&info
, IF_COP("Core and ") "Stack usage:",
222 MAXTHREADS
+NUM_CORES
,
225 #ifndef ROCKBOX_HAS_LOGF
226 info
.hide_selection
= true;
227 info
.scroll_all
= true;
229 info
.action_callback
= dbg_threads_action_callback
;
230 info
.get_name
= threads_getname
;
231 return simplelist_show_list(&info
);
235 #include "cpuinfo-linux.h"
237 #define MAX_STATES 16
238 static struct time_state states
[MAX_STATES
];
240 static const char* get_cpuinfo(int selected_item
, void *data
,
241 char *buffer
, size_t buffer_len
)
243 (void)data
;(void)buffer_len
;
247 static struct cpuusage last_us
;
248 int state_count
= *(int*)data
;
250 if (cpuusage_linux(&us
) != 0)
253 switch(selected_item
)
256 diff
= abs(last_us
.usage
- us
.usage
);
257 sprintf(buffer
, "Usage: %ld.%02ld%% (%c %ld.%02ld)",
258 us
.usage
/100, us
.usage
%100,
259 (us
.usage
>= last_us
.usage
) ? '+':'-',
261 last_us
.usage
= us
.usage
;
266 diff
= us
.utime
- last_us
.utime
;
267 last_us
.utime
= us
.utime
;
272 diff
= us
.stime
- last_us
.stime
;
273 last_us
.stime
= us
.stime
;
278 diff
= us
.rtime
- last_us
.rtime
;
279 last_us
.rtime
= us
.rtime
;
282 return "*** Per CPU freq stats ***";
285 int cpu
= (selected_item
- 5) / (state_count
+ 1);
286 int cpu_line
= (selected_item
- 5) % (state_count
+ 1);
287 int freq1
= frequency_linux(cpu
, false);
288 int freq2
= frequency_linux(cpu
, true);
291 sprintf(buffer
, " CPU%d: Cur/Scal freq: %d/%d MHz", cpu
,
292 freq1
> 0 ? freq1
/1000 : -1,
293 freq2
> 0 ? freq2
/1000 : -1);
297 cpustatetimes_linux(cpu
, states
, ARRAYLEN(states
));
298 snprintf(buffer
, buffer_len
, " %ld %ld",
299 states
[cpu_line
-1].frequency
,
300 states
[cpu_line
-1].time
);
305 sprintf(buffer
, "%s: %ld.%02lds (+ %ld.%02ld)", text
,
306 time
/ us
.hz
, time
% us
.hz
,
307 diff
/ us
.hz
, diff
% us
.hz
);
311 static int cpuinfo_cb(int action
, struct gui_synclist
*lists
)
314 if (action
== ACTION_NONE
)
315 action
= ACTION_REDRAW
;
319 static bool dbg_cpuinfo(void)
321 struct simplelist_info info
;
322 int cpu_count
= MAX(cpucount_linux(), 1);
323 int state_count
= cpustatetimes_linux(0, states
, ARRAYLEN(states
));
324 printf("%s(): %d %d\n", __func__
, cpu_count
, state_count
);
325 simplelist_info_init(&info
, "CPU info:", 5 + cpu_count
*(state_count
+1), &state_count
);
326 info
.get_name
= get_cpuinfo
;
327 info
.action_callback
= cpuinfo_cb
;
329 info
.hide_selection
= true;
330 info
.scroll_all
= true;
331 return simplelist_show_list(&info
);
336 #ifdef HAVE_LCD_BITMAP
337 #if CONFIG_CODEC != SWCODEC
339 static bool dbg_audio_thread(void)
341 struct audio_debug d
;
343 lcd_setfont(FONT_SYSFIXED
);
347 if (action_userabort(HZ
/5))
350 audio_get_debugdata(&d
);
354 lcd_putsf(0, 0, "read: %x", d
.audiobuf_read
);
355 lcd_putsf(0, 1, "write: %x", d
.audiobuf_write
);
356 lcd_putsf(0, 2, "swap: %x", d
.audiobuf_swapwrite
);
357 lcd_putsf(0, 3, "playing: %d", d
.playing
);
358 lcd_putsf(0, 4, "playable: %x", d
.playable_space
);
359 lcd_putsf(0, 5, "unswapped: %x", d
.unswapped_space
);
361 /* Playable space left */
362 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8, 112, 4, d
.audiobuflen
, 0,
363 d
.playable_space
, HORIZONTAL
);
365 /* Show the watermark limit */
366 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8+4, 112, 4, d
.audiobuflen
, 0,
367 d
.low_watermark_level
, HORIZONTAL
);
369 lcd_putsf(0, 7, "wm: %x - %x",
370 d
.low_watermark_level
, d
.lowest_watermark_level
);
374 lcd_setfont(FONT_UI
);
377 #endif /* !SIMULATOR */
378 #else /* CONFIG_CODEC == SWCODEC */
379 static unsigned int ticks
, freq_sum
;
380 #ifndef CPU_MULTI_FREQUENCY
381 static unsigned int boost_ticks
;
384 static void dbg_audio_task(void)
386 #ifdef CPUFREQ_NORMAL
387 #ifndef CPU_MULTI_FREQUENCY
388 if(FREQ
> CPUFREQ_NORMAL
)
391 freq_sum
+= FREQ
/1000000; /* in MHz */
396 static bool dbg_buffering_thread(void)
402 size_t bufsize
= pcmbuf_get_bufsize();
403 int pcmbufdescs
= pcmbuf_descs();
404 struct buffering_debug d
;
405 size_t filebuflen
= audio_get_filebuflen();
406 /* This is a size_t, but call it a long so it puts a - when it's bad. */
408 #ifndef CPU_MULTI_FREQUENCY
411 ticks
= freq_sum
= 0;
413 tick_add_task(dbg_audio_task
);
416 screens
[i
].setfont(FONT_SYSFIXED
);
420 button
= get_action(CONTEXT_STD
,HZ
/5);
423 case ACTION_STD_NEXT
:
426 case ACTION_STD_PREV
:
429 case ACTION_STD_CANCEL
:
434 buffering_get_debugdata(&d
);
435 bufused
= bufsize
- pcmbuf_free();
440 screens
[i
].clear_display();
443 screens
[i
].putsf(0, line
++, "pcm: %6ld/%ld", (long) bufused
, (long) bufsize
);
445 gui_scrollbar_draw(&screens
[i
],0, line
*8, screens
[i
].lcdwidth
, 6,
446 bufsize
, 0, bufused
, HORIZONTAL
);
449 screens
[i
].putsf(0, line
++, "alloc: %6ld/%ld", audio_filebufused(),
452 #if LCD_HEIGHT > 80 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_HEIGHT > 80)
453 if (screens
[i
].lcdheight
> 80)
455 gui_scrollbar_draw(&screens
[i
],0, line
*8, screens
[i
].lcdwidth
, 6,
456 filebuflen
, 0, audio_filebufused(), HORIZONTAL
);
459 screens
[i
].putsf(0, line
++, "real: %6ld/%ld", (long)d
.buffered_data
,
462 gui_scrollbar_draw(&screens
[i
],0, line
*8, screens
[i
].lcdwidth
, 6,
463 filebuflen
, 0, (long)d
.buffered_data
, HORIZONTAL
);
468 screens
[i
].putsf(0, line
++, "usefl: %6ld/%ld", (long)(d
.useful_data
),
471 #if LCD_HEIGHT > 80 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_HEIGHT > 80)
472 if (screens
[i
].lcdheight
> 80)
474 gui_scrollbar_draw(&screens
[i
],0, line
*8, screens
[i
].lcdwidth
, 6,
475 filebuflen
, 0, d
.useful_data
, HORIZONTAL
);
480 screens
[i
].putsf(0, line
++, "data_rem: %ld", (long)d
.data_rem
);
482 screens
[i
].putsf(0, line
++, "track count: %2d", audio_track_count());
484 screens
[i
].putsf(0, line
++, "handle count: %d", (int)d
.num_handles
);
486 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
487 screens
[i
].putsf(0, line
++, "cpu freq: %3dMHz",
488 (int)((FREQ
+ 500000) / 1000000));
493 int avgclock
= freq_sum
* 10 / ticks
; /* in 100 kHz */
494 #ifdef CPU_MULTI_FREQUENCY
495 int boostquota
= (avgclock
* 100 - CPUFREQ_NORMAL
/1000) /
496 ((CPUFREQ_MAX
- CPUFREQ_NORMAL
) / 1000000); /* in 0.1 % */
498 int boostquota
= boost_ticks
* 1000 / ticks
; /* in 0.1 % */
500 screens
[i
].putsf(0, line
++, "boost:%3d.%d%% (%d.%dMHz)",
501 boostquota
/10, boostquota
%10, avgclock
/10, avgclock
%10);
504 screens
[i
].putsf(0, line
++, "pcmbufdesc: %2d/%2d",
505 pcmbuf_used_descs(), pcmbufdescs
);
506 screens
[i
].putsf(0, line
++, "watermark: %6d",
513 tick_remove_task(dbg_audio_task
);
516 screens
[i
].setfont(FONT_UI
);
520 #endif /* CONFIG_CODEC */
521 #endif /* HAVE_LCD_BITMAP */
523 static const char* bf_getname(int selected_item
, void *data
,
524 char *buffer
, size_t buffer_len
)
527 core_print_block_at(selected_item
, buffer
, buffer_len
);
531 static int bf_action_cb(int action
, struct gui_synclist
* list
)
533 if (action
== ACTION_STD_OK
)
535 if (gui_synclist_get_sel_pos(list
) == 0 && core_test_free())
537 splash(HZ
, "Freed test handle. New alloc should trigger compact");
541 splash(HZ
/1, "Attempting a 64k allocation");
542 int handle
= core_alloc("test", 64<<10);
543 splash(HZ
/2, (handle
> 0) ? "Success":"Fail");
544 /* for some reason simplelist doesn't allow adding items here if
545 * info.get_name is given, so use normal list api */
546 gui_synclist_set_nb_items(list
, core_get_num_blocks());
550 action
= ACTION_REDRAW
;
552 else if (action
== ACTION_NONE
)
553 action
= ACTION_REDRAW
;
557 static bool dbg_buflib_allocs(void)
559 struct simplelist_info info
;
560 simplelist_info_init(&info
, "mem allocs", core_get_num_blocks(), NULL
);
561 info
.get_name
= bf_getname
;
562 info
.action_callback
= bf_action_cb
;
563 info
.timeout
= TIMEOUT_BLOCK
;
564 return simplelist_show_list(&info
);
567 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
568 static const char* dbg_partitions_getname(int selected_item
, void *data
,
569 char *buffer
, size_t buffer_len
)
572 int partition
= selected_item
/2;
573 struct partinfo
* p
= disk_partinfo(partition
);
576 snprintf(buffer
, buffer_len
, " T:%x %ld MB", p
->type
, p
->size
/ ( 2048 / ( SECTOR_SIZE
/ 512 )));
580 snprintf(buffer
, buffer_len
, "P%d: S:%lx", partition
, p
->start
);
585 static bool dbg_partitions(void)
587 struct simplelist_info info
;
588 simplelist_info_init(&info
, "Partition Info", 4, NULL
);
589 info
.selection_size
= 2;
590 info
.hide_selection
= true;
591 info
.scroll_all
= true;
592 info
.get_name
= dbg_partitions_getname
;
593 return simplelist_show_list(&info
);
595 #endif /* PLATFORM_NATIVE */
597 #if defined(CPU_COLDFIRE) && defined(HAVE_SPDIF_OUT)
598 static bool dbg_spdif(void)
601 unsigned int control
;
606 unsigned int interruptstat
;
607 bool valnogood
, symbolerr
, parityerr
;
610 int spdif_source
= spdif_get_output_source(&spdif_src_on
);
611 spdif_set_output_source(AUDIO_SRC_SPDIF
IF_SPDIF_POWER_(, true));
614 lcd_setfont(FONT_SYSFIXED
);
616 #ifdef HAVE_SPDIF_POWER
617 spdif_power_enable(true); /* We need SPDIF power for both sending & receiving */
624 control
= EBU1RCVCCHANNEL1
;
625 interruptstat
= INTERRUPTSTAT
;
626 INTERRUPTCLEAR
= 0x03c00000;
628 valnogood
= (interruptstat
& 0x01000000)?true:false;
629 symbolerr
= (interruptstat
& 0x00800000)?true:false;
630 parityerr
= (interruptstat
& 0x00400000)?true:false;
632 lcd_putsf(0, line
++, "Val: %s Sym: %s Par: %s",
635 parityerr
?"--":"OK");
637 lcd_putsf(0, line
++, "Status word: %08x", (int)control
);
642 lcd_putsf(0, line
++, "PRO: %d (%s)",
643 x
, x
?"Professional":"Consumer");
645 x
= (control
>> 30) & 1;
646 lcd_putsf(0, line
++, "Audio: %d (%s)",
647 x
, x
?"Non-PCM":"PCM");
649 x
= (control
>> 29) & 1;
650 lcd_putsf(0, line
++, "Copy: %d (%s)",
651 x
, x
?"Permitted":"Inhibited");
653 x
= (control
>> 27) & 7;
666 lcd_putsf(0, line
++, "Preemphasis: %d (%s)", x
, s
);
668 x
= (control
>> 24) & 3;
669 lcd_putsf(0, line
++, "Mode: %d", x
);
671 category
= (control
>> 17) & 127;
683 lcd_putsf(0, line
++, "Category: 0x%02x (%s)", category
, s
);
685 x
= (control
>> 16) & 1;
687 if(((category
& 0x70) == 0x10) ||
688 ((category
& 0x70) == 0x40) ||
689 ((category
& 0x78) == 0x38))
691 generation
= !generation
;
693 lcd_putsf(0, line
++, "Generation: %d (%s)",
694 x
, generation
?"Original":"No ind.");
696 x
= (control
>> 12) & 15;
697 lcd_putsf(0, line
++, "Source: %d", x
);
700 x
= (control
>> 8) & 15;
716 lcd_putsf(0, line
++, "Channel: %d (%s)", x
, s
);
718 x
= (control
>> 4) & 15;
731 lcd_putsf(0, line
++, "Frequency: %d (%s)", x
, s
);
733 x
= (control
>> 2) & 3;
734 lcd_putsf(0, line
++, "Clock accuracy: %d", x
);
737 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
738 lcd_putsf(0, line
++, "Measured freq: %ldHz",
739 spdif_measure_frequency());
744 if (action_userabort(HZ
/10))
748 spdif_set_output_source(spdif_source
IF_SPDIF_POWER_(, spdif_src_on
));
750 #ifdef HAVE_SPDIF_POWER
751 spdif_power_enable(global_settings
.spdif_enable
);
754 lcd_setfont(FONT_UI
);
757 #endif /* CPU_COLDFIRE */
759 #if (CONFIG_RTC == RTC_PCF50605) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
760 static bool dbg_pcf(void)
764 #ifdef HAVE_LCD_BITMAP
765 lcd_setfont(FONT_SYSFIXED
);
773 lcd_putsf(0, line
++, "DCDC1: %02x", pcf50605_read(0x1b));
774 lcd_putsf(0, line
++, "DCDC2: %02x", pcf50605_read(0x1c));
775 lcd_putsf(0, line
++, "DCDC3: %02x", pcf50605_read(0x1d));
776 lcd_putsf(0, line
++, "DCDC4: %02x", pcf50605_read(0x1e));
777 lcd_putsf(0, line
++, "DCDEC1: %02x", pcf50605_read(0x1f));
778 lcd_putsf(0, line
++, "DCDEC2: %02x", pcf50605_read(0x20));
779 lcd_putsf(0, line
++, "DCUDC1: %02x", pcf50605_read(0x21));
780 lcd_putsf(0, line
++, "DCUDC2: %02x", pcf50605_read(0x22));
781 lcd_putsf(0, line
++, "IOREGC: %02x", pcf50605_read(0x23));
782 lcd_putsf(0, line
++, "D1REGC: %02x", pcf50605_read(0x24));
783 lcd_putsf(0, line
++, "D2REGC: %02x", pcf50605_read(0x25));
784 lcd_putsf(0, line
++, "D3REGC: %02x", pcf50605_read(0x26));
785 lcd_putsf(0, line
++, "LPREG1: %02x", pcf50605_read(0x27));
787 if (action_userabort(HZ
/10))
789 lcd_setfont(FONT_UI
);
794 lcd_setfont(FONT_UI
);
799 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
800 static bool dbg_cpufreq(void)
805 #ifdef HAVE_LCD_BITMAP
806 lcd_setfont(FONT_SYSFIXED
);
814 lcd_putsf(0, line
++, "Frequency: %ld", FREQ
);
815 lcd_putsf(0, line
++, "boost_counter: %d", get_cpu_boost_counter());
818 button
= get_action(CONTEXT_STD
,HZ
/10);
822 case ACTION_STD_PREV
:
826 case ACTION_STD_NEXT
:
831 while (get_cpu_boost_counter() > 0)
833 set_cpu_frequency(CPUFREQ_DEFAULT
);
836 case ACTION_STD_CANCEL
:
837 lcd_setfont(FONT_UI
);
841 lcd_setfont(FONT_UI
);
844 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
846 #if defined(HAVE_TSC2100) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
848 static const char* tsc2100_debug_getname(int selected_item
, void * data
,
849 char *buffer
, size_t buffer_len
)
851 int *page
= (int*)data
;
852 bool reserved
= false;
856 if ((selected_item
> 0x0a) ||
857 (selected_item
== 0x04) ||
858 (selected_item
== 0x08))
862 if ((selected_item
> 0x05) ||
863 (selected_item
== 0x02))
867 if (selected_item
> 0x1e)
872 snprintf(buffer
, buffer_len
, "%02x: RSVD", selected_item
);
874 snprintf(buffer
, buffer_len
, "%02x: %04x", selected_item
,
875 tsc2100_readreg(*page
, selected_item
)&0xffff);
878 static int tsc2100debug_action_callback(int action
, struct gui_synclist
*lists
)
880 int *page
= (int*)lists
->data
;
881 if (action
== ACTION_STD_OK
)
884 snprintf(lists
->title
, 32,
885 "tsc2100 registers - Page %d", *page
);
886 return ACTION_REDRAW
;
890 static bool tsc2100_debug(void)
893 char title
[32] = "tsc2100 registers - Page 0";
894 struct simplelist_info info
;
895 simplelist_info_init(&info
, title
, 32, &page
);
896 info
.timeout
= HZ
/100;
897 info
.get_name
= tsc2100_debug_getname
;
898 info
.action_callback
= tsc2100debug_action_callback
;
899 return simplelist_show_list(&info
);
902 #if (CONFIG_BATTERY_MEASURE != 0) && defined(HAVE_LCD_BITMAP) && !defined(SIMULATOR)
904 * view_battery() shows a automatically scaled graph of the battery voltage
905 * over time. Usable for estimating battery life / charging rate.
906 * The power_history array is updated in power_thread of powermgmt.c.
909 #define BAT_LAST_VAL MIN(LCD_WIDTH, POWER_HISTORY_LEN)
910 #define BAT_TSPACE 20
911 #define BAT_YSPACE (LCD_HEIGHT - BAT_TSPACE)
914 static bool view_battery(void)
917 int i
, x
, y
, z
, y1
, y2
, grid
, graph
;
918 unsigned short maxv
, minv
;
920 lcd_setfont(FONT_SYSFIXED
);
926 case 0: /* voltage history graph */
927 /* Find maximum and minimum voltage for scaling */
928 minv
= power_history
[0];
930 for (i
= 1; i
< BAT_LAST_VAL
&& power_history
[i
]; i
++) {
931 if (power_history
[i
] > maxv
)
932 maxv
= power_history
[i
];
933 if (power_history
[i
] < minv
)
934 minv
= power_history
[i
];
937 #if (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE)
938 /* adjust grid scale */
939 if ((maxv
- minv
) > 50)
944 lcd_putsf(0, 0, "battery %d.%03dV", power_history
[0] / 1000,
945 power_history
[0] % 1000);
946 lcd_putsf(0, 1, "%d.%03d-%d.%03dV (%2dmV)",
947 minv
/ 1000, minv
% 1000, maxv
/ 1000, maxv
% 1000,
949 #elif (CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE)
950 /* adjust grid scale */
951 if ((maxv
- minv
) > 10)
955 lcd_putsf(0, 0, "battery %d%%", power_history
[0]);
956 lcd_putsf(0, 1, "%d%%-%d%% (%d %%)", minv
, maxv
, grid
);
960 while ((y
= (minv
- (minv
% grid
)+i
*grid
)) < maxv
)
962 graph
= ((y
-minv
)*BAT_YSPACE
)/(maxv
-minv
);
963 graph
= LCD_HEIGHT
-1 - graph
;
965 /* draw dotted horizontal grid line */
966 for (x
=0; x
<LCD_WIDTH
;x
=x
+2)
967 lcd_drawpixel(x
,graph
);
973 /* draw plot of power history
976 for (i
= BAT_LAST_VAL
- 1; i
> 0; i
--)
978 if (power_history
[i
] && power_history
[i
-1])
980 y1
= (power_history
[i
] - minv
) * BAT_YSPACE
/
982 y1
= MIN(MAX(LCD_HEIGHT
-1 - y1
, BAT_TSPACE
),
984 y2
= (power_history
[i
-1] - minv
) * BAT_YSPACE
/
986 y2
= MIN(MAX(LCD_HEIGHT
-1 - y2
, BAT_TSPACE
),
989 lcd_set_drawmode(DRMODE_SOLID
);
991 /* make line thicker */
992 lcd_drawline(((x
*LCD_WIDTH
)/(BAT_LAST_VAL
)),
994 (((x
+1)*LCD_WIDTH
)/(BAT_LAST_VAL
)),
996 lcd_drawline(((x
*LCD_WIDTH
)/(BAT_LAST_VAL
))+1,
998 (((x
+1)*LCD_WIDTH
)/(BAT_LAST_VAL
))+1,
1005 case 1: /* status: */
1006 #if CONFIG_CHARGING >= CHARGING_MONITOR
1007 lcd_putsf(0, 0, "Pwr status: %s",
1008 charging_state() ? "charging" : "discharging");
1010 lcd_puts(0, 0, "Power status: unknown");
1012 battery_read_info(&y
, &z
);
1014 lcd_putsf(0, 1, "Battery: %d.%03d V (%d %%)", y
/ 1000, y
% 1000, z
);
1016 lcd_putsf(0, 1, "Battery: %d %%", z
);
1017 #ifdef ADC_EXT_POWER
1018 y
= (adc_read(ADC_EXT_POWER
) * EXT_SCALE_FACTOR
) / 1000;
1019 lcd_putsf(0, 2, "External: %d.%03d V", y
/ 1000, y
% 1000);
1022 #if defined ARCHOS_RECORDER
1023 lcd_putsf(0, 3, "Chgr: %s %s",
1024 charger_inserted() ? "present" : "absent",
1025 charger_enabled() ? "on" : "off");
1026 lcd_putsf(0, 5, "short delta: %d", short_delta
);
1027 lcd_putsf(0, 6, "long delta: %d", long_delta
);
1028 lcd_puts(0, 7, power_message
);
1029 lcd_putsf(0, 8, "USB Inserted: %s",
1030 usb_inserted() ? "yes" : "no");
1031 #elif defined IPOD_NANO || defined IPOD_VIDEO
1032 int usb_pwr
= (GPIOL_INPUT_VAL
& 0x10)?true:false;
1033 int ext_pwr
= (GPIOL_INPUT_VAL
& 0x08)?false:true;
1034 int dock
= (GPIOA_INPUT_VAL
& 0x10)?true:false;
1035 int charging
= (GPIOB_INPUT_VAL
& 0x01)?false:true;
1036 int headphone
= (GPIOA_INPUT_VAL
& 0x80)?true:false;
1038 lcd_putsf(0, 3, "USB pwr: %s",
1039 usb_pwr
? "present" : "absent");
1040 lcd_putsf(0, 4, "EXT pwr: %s",
1041 ext_pwr
? "present" : "absent");
1042 lcd_putsf(0, 5, "Battery: %s",
1043 charging
? "charging" : (usb_pwr
||ext_pwr
) ? "charged" : "discharging");
1044 lcd_putsf(0, 6, "Dock mode: %s",
1045 dock
? "enabled" : "disabled");
1046 lcd_putsf(0, 7, "Headphone: %s",
1047 headphone
? "connected" : "disconnected");
1049 if(probed_ramsize
== 64)
1050 x
= (adc_read(ADC_4066_ISTAT
) * 2400) / (1024 * 2);
1053 x
= (adc_read(ADC_4066_ISTAT
) * 2400) / (1024 * 3);
1054 lcd_putsf(0, 8, "Ibat: %d mA", x
);
1055 lcd_putsf(0, 9, "Vbat * Ibat: %d mW", x
* y
/ 1000);
1056 #elif defined TOSHIBA_GIGABEAT_S
1060 static const unsigned char * const chrgstate_strings
[] =
1071 lcd_putsf(0, line
++, "Charger: %s",
1072 charger_inserted() ? "present" : "absent");
1074 st
= power_input_status() &
1075 (POWER_INPUT_CHARGER
| POWER_INPUT_BATTERY
);
1076 lcd_putsf(0, line
++, "%s%s",
1077 (st
& POWER_INPUT_MAIN_CHARGER
) ? " Main" : "",
1078 (st
& POWER_INPUT_USB_CHARGER
) ? " USB" : "");
1080 y
= ARRAYLEN(chrgstate_strings
) - 1;
1082 switch (charge_state
)
1084 case CHARGE_STATE_DISABLED
: y
--;
1085 case CHARGE_STATE_ERROR
: y
--;
1086 case DISCHARGING
: y
--;
1093 lcd_putsf(0, line
++, "State: %s", chrgstate_strings
[y
]);
1095 lcd_putsf(0, line
++, "Battery Switch: %s",
1096 (st
& POWER_INPUT_BATTERY
) ? "On" : "Off");
1098 y
= chrgraw_adc_voltage();
1099 lcd_putsf(0, line
++, "CHRGRAW: %d.%03d V",
1100 y
/ 1000, y
% 1000);
1102 y
= application_supply_adc_voltage();
1103 lcd_putsf(0, line
++, "BP : %d.%03d V",
1104 y
/ 1000, y
% 1000);
1106 y
= battery_adc_charge_current();
1107 if (y
< 0) x
= '-', y
= -y
;
1109 lcd_putsf(0, line
++, "CHRGISN:%c%d mA", x
, y
);
1111 y
= cccv_regulator_dissipation();
1112 lcd_putsf(0, line
++, "P CCCV : %d mW", y
);
1114 y
= battery_charge_current();
1115 if (y
< 0) x
= '-', y
= -y
;
1117 lcd_putsf(0, line
++, "I Charge:%c%d mA", x
, y
);
1119 y
= battery_adc_temp();
1122 lcd_putsf(0, line
++, "T Battery: %dC (%dF)", y
,
1125 /* Conversion disabled */
1126 lcd_puts(0, line
++, "T Battery: ?");
1129 #elif defined(HAVE_AS3514) && defined(CONFIG_CHARGING)
1130 static const char * const chrgstate_strings
[] =
1132 [CHARGE_STATE_DISABLED
- CHARGE_STATE_DISABLED
]= "Disabled",
1133 [CHARGE_STATE_ERROR
- CHARGE_STATE_DISABLED
] = "Error",
1134 [DISCHARGING
- CHARGE_STATE_DISABLED
] = "Discharging",
1135 [CHARGING
- CHARGE_STATE_DISABLED
] = "Charging",
1137 const char *str
= NULL
;
1139 lcd_putsf(0, 3, "Charger: %s",
1140 charger_inserted() ? "present" : "absent");
1142 y
= charge_state
- CHARGE_STATE_DISABLED
;
1143 if ((unsigned)y
< ARRAYLEN(chrgstate_strings
))
1144 str
= chrgstate_strings
[y
];
1146 lcd_putsf(0, 4, "State: %s",
1147 str
? str
: "<unknown>");
1149 lcd_putsf(0, 5, "CHARGER: %02X", ascodec_read_charger());
1150 #elif defined(IPOD_NANO2G)
1151 y
= pmu_read_battery_voltage();
1152 lcd_putsf(17, 1, "RAW: %d.%03d V", y
/ 1000, y
% 1000);
1153 y
= pmu_read_battery_current();
1154 lcd_putsf(0, 2, "Battery current: %d mA", y
);
1155 lcd_putsf(0, 3, "PWRCON: %08x %08x", PWRCON
, PWRCONEXT
);
1156 lcd_putsf(0, 4, "CLKCON: %08x %03x %03x", CLKCON
, CLKCON2
, CLKCON3
);
1157 lcd_putsf(0, 5, "PLL: %06x %06x %06x", PLL0PMS
, PLL1PMS
, PLL2PMS
);
1158 x
= pmu_read(0x1b) & 0xf;
1159 y
= pmu_read(0x1a) * 25 + 625;
1160 lcd_putsf(0, 6, "AUTO: %x / %d mV", x
, y
);
1161 x
= pmu_read(0x1f) & 0xf;
1162 y
= pmu_read(0x1e) * 25 + 625;
1163 lcd_putsf(0, 7, "DOWN1: %x / %d mV", x
, y
);
1164 x
= pmu_read(0x23) & 0xf;
1165 y
= pmu_read(0x22) * 25 + 625;
1166 lcd_putsf(0, 8, "DOWN2: %x / %d mV", x
, y
);
1167 x
= pmu_read(0x27) & 0xf;
1168 y
= pmu_read(0x26) * 100 + 900;
1169 lcd_putsf(0, 9, "MEMLDO: %x / %d mV", x
, y
);
1170 for (i
= 0; i
< 6; i
++)
1172 x
= pmu_read(0x2e + (i
<< 1)) & 0xf;
1173 y
= pmu_read(0x2d + (i
<< 1)) * 100 + 900;
1174 lcd_putsf(0, 10 + i
, "LDO%d: %x / %d mV", i
+ 1, x
, y
);
1177 lcd_putsf(0, 3, "Charger: %s",
1178 charger_inserted() ? "present" : "absent");
1179 #endif /* target type */
1180 #endif /* CONFIG_CHARGING */
1182 case 2: /* voltage deltas: */
1183 #if (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE)
1184 lcd_puts(0, 0, "Voltage deltas:");
1185 for (i
= 0; i
< POWER_HISTORY_LEN
-1; i
++) {
1186 y
= power_history
[i
] - power_history
[i
+1];
1187 lcd_putsf(0, i
+1, "-%d min: %c%d.%03d V", i
,
1188 (y
< 0) ? '-' : ' ', ((y
< 0) ? y
* -1 : y
) / 1000,
1189 ((y
< 0) ? y
* -1 : y
) % 1000);
1191 #elif (CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE)
1192 lcd_puts(0, 0, "Percentage deltas:");
1193 for (i
= 0; i
< POWER_HISTORY_LEN
-1; i
++) {
1194 y
= power_history
[i
] - power_history
[i
+1];
1195 lcd_putsf(0, i
+1, "-%d min: %c%d%%", i
,
1196 (y
< 0) ? '-' : ' ', ((y
< 0) ? y
* -1 : y
));
1201 case 3: /* remaining time estimation: */
1203 #ifdef ARCHOS_RECORDER
1204 lcd_putsf(0, 0, "charge_state: %d", charge_state
);
1206 lcd_putsf(0, 1, "Cycle time: %d m", powermgmt_last_cycle_startstop_min
);
1208 lcd_putsf(0, 2, "Lvl@cyc st: %d%%", powermgmt_last_cycle_level
);
1210 lcd_putsf(0, 3, "P=%2d I=%2d", pid_p
, pid_i
);
1212 lcd_putsf(0, 4, "Trickle sec: %d/60", trickle_sec
);
1213 #endif /* ARCHOS_RECORDER */
1215 #if (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE)
1216 lcd_putsf(0, 5, "Last PwrHist: %d.%03dV",
1217 power_history
[0] / 1000,
1218 power_history
[0] % 1000);
1221 lcd_putsf(0, 6, "battery level: %d%%", battery_level());
1223 int time_left
= battery_time();
1225 lcd_putsf(0, 7, "Est. remain: %d m", time_left
);
1227 lcd_puts(0, 7, "Estimation n/a");
1233 switch(get_action(CONTEXT_STD
,HZ
/2))
1235 case ACTION_STD_PREV
:
1240 case ACTION_STD_NEXT
:
1245 case ACTION_STD_CANCEL
:
1246 lcd_setfont(FONT_UI
);
1250 lcd_setfont(FONT_UI
);
1254 #endif /* (CONFIG_BATTERY_MEASURE != 0) && HAVE_LCD_BITMAP */
1256 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
1257 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
1259 #if (CONFIG_STORAGE & STORAGE_MMC)
1260 #define CARDTYPE "MMC"
1261 #elif (CONFIG_STORAGE & STORAGE_SD)
1262 #define CARDTYPE "microSD"
1265 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1268 int *cardnum
= (int*)lists
->data
;
1269 unsigned char card_name
[6];
1270 unsigned char pbuf
[32];
1271 char *title
= lists
->title
;
1272 static const unsigned char i_vmin
[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
1273 static const unsigned char i_vmax
[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
1274 static const unsigned char * const kbit_units
[] = { "kBit/s", "MBit/s", "GBit/s" };
1275 static const unsigned char * const nsec_units
[] = { "ns", "µs", "ms" };
1276 #if (CONFIG_STORAGE & STORAGE_MMC)
1277 static const char * const mmc_spec_vers
[] = { "1.0-1.2", "1.4", "2.0-2.2",
1278 "3.1-3.31", "4.0" };
1281 if ((btn
== ACTION_STD_OK
) || (btn
== SYS_FS_CHANGED
) || (btn
== ACTION_REDRAW
))
1284 if (btn
== ACTION_STD_OK
)
1286 *cardnum
^= 0x1; /* change cards */
1290 simplelist_set_line_count(0);
1292 card
= card_get_info(*cardnum
);
1294 if (card
->initialized
> 0)
1297 for (i
=0; i
<sizeof(card_name
); i
++)
1299 card_name
[i
] = card_extract_bits(card
->cid
, (103-8*i
), 8);
1301 strlcpy(card_name
, card_name
, sizeof(card_name
));
1302 simplelist_addline(SIMPLELIST_ADD_LINE
,
1303 "%s Rev %d.%d", card_name
,
1304 (int) card_extract_bits(card
->cid
, 63, 4),
1305 (int) card_extract_bits(card
->cid
, 59, 4));
1306 simplelist_addline(SIMPLELIST_ADD_LINE
,
1308 #if (CONFIG_STORAGE & STORAGE_SD)
1309 (int) card_extract_bits(card
->cid
, 11, 4),
1310 (int) card_extract_bits(card
->cid
, 19, 8) + 2000
1311 #elif (CONFIG_STORAGE & STORAGE_MMC)
1312 (int) card_extract_bits(card
->cid
, 15, 4),
1313 (int) card_extract_bits(card
->cid
, 11, 4) + 1997
1316 simplelist_addline(SIMPLELIST_ADD_LINE
,
1317 #if (CONFIG_STORAGE & STORAGE_SD)
1319 card_extract_bits(card
->cid
, 55, 32)
1320 #elif (CONFIG_STORAGE & STORAGE_MMC)
1322 card_extract_bits(card
->cid
, 47, 16)
1326 simplelist_addline(SIMPLELIST_ADD_LINE
, "M=%02x, "
1327 #if (CONFIG_STORAGE & STORAGE_SD)
1329 (int) card_extract_bits(card
->cid
, 127, 8),
1330 card_extract_bits(card
->cid
, 119, 8),
1331 card_extract_bits(card
->cid
, 111, 8)
1332 #elif (CONFIG_STORAGE & STORAGE_MMC)
1334 (int) card_extract_bits(card
->cid
, 127, 8),
1335 (int) card_extract_bits(card
->cid
, 119, 16)
1339 #if (CONFIG_STORAGE & STORAGE_MMC)
1340 int temp
= card_extract_bits(card
->csd
, 125, 4);
1341 simplelist_addline(SIMPLELIST_ADD_LINE
,
1342 "MMC v%s", temp
< 5 ?
1343 mmc_spec_vers
[temp
] : "?.?");
1345 simplelist_addline(SIMPLELIST_ADD_LINE
,
1346 "Blocks: 0x%08lx", card
->numblocks
);
1347 output_dyn_value(pbuf
, sizeof pbuf
, card
->speed
/ 1000,
1349 simplelist_addline(SIMPLELIST_ADD_LINE
,
1351 output_dyn_value(pbuf
, sizeof pbuf
, card
->taac
,
1353 simplelist_addline(SIMPLELIST_ADD_LINE
,
1355 simplelist_addline(SIMPLELIST_ADD_LINE
,
1356 "Nsac: %d clk", card
->nsac
);
1357 simplelist_addline(SIMPLELIST_ADD_LINE
,
1358 "R2W: *%d", card
->r2w_factor
);
1359 #if (CONFIG_STORAGE & STORAGE_SD)
1360 int csd_structure
= card_extract_bits(card
->csd
, 127, 2);
1361 if (csd_structure
== 0) /* CSD version 1.0 */
1364 simplelist_addline(SIMPLELIST_ADD_LINE
,
1366 i_vmin
[card_extract_bits(card
->csd
, 61, 3)],
1367 i_vmax
[card_extract_bits(card
->csd
, 58, 3)]);
1368 simplelist_addline(SIMPLELIST_ADD_LINE
,
1370 i_vmin
[card_extract_bits(card
->csd
, 55, 3)],
1371 i_vmax
[card_extract_bits(card
->csd
, 52, 3)]);
1374 else if (card
->initialized
== 0)
1376 simplelist_addline(SIMPLELIST_ADD_LINE
, "Not Found!");
1378 #if (CONFIG_STORAGE & STORAGE_SD)
1379 else /* card->initialized < 0 */
1381 simplelist_addline(SIMPLELIST_ADD_LINE
, "Init Error! (%d)", card
->initialized
);
1384 snprintf(title
, 16, "[" CARDTYPE
" %d]", *cardnum
);
1385 gui_synclist_set_title(lists
, title
, Icon_NOICON
);
1386 gui_synclist_set_nb_items(lists
, simplelist_get_line_count());
1387 gui_synclist_select_item(lists
, 0);
1388 btn
= ACTION_REDRAW
;
1392 #elif (CONFIG_STORAGE & STORAGE_ATA)
1393 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1398 unsigned short* identify_info
= ata_get_identify();
1399 bool timing_info_present
= false;
1402 simplelist_set_line_count(0);
1404 for (i
=0; i
< 20; i
++)
1405 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+27]);
1407 /* kill trailing space */
1408 for (i
=39; i
&& buf
[i
]==' '; i
--)
1410 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", buf
);
1411 for (i
=0; i
< 4; i
++)
1412 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+23]);
1414 simplelist_addline(SIMPLELIST_ADD_LINE
,
1415 "Firmware: %s", buf
);
1416 snprintf(buf
, sizeof buf
, "%ld MB",
1417 ((unsigned long)identify_info
[61] << 16 |
1418 (unsigned long)identify_info
[60]) / 2048 );
1419 simplelist_addline(SIMPLELIST_ADD_LINE
,
1422 fat_size( IF_MV2(0,) NULL
, &free
);
1423 simplelist_addline(SIMPLELIST_ADD_LINE
,
1424 "Free: %ld MB", free
/ 1024);
1425 simplelist_addline(SIMPLELIST_ADD_LINE
,
1426 "Spinup time: %d ms", storage_spinup_time() * (1000/HZ
));
1427 i
= identify_info
[83] & (1<<3);
1428 simplelist_addline(SIMPLELIST_ADD_LINE
,
1429 "Power mgmt: %s", i
? "enabled" : "unsupported");
1430 i
= identify_info
[83] & (1<<9);
1431 simplelist_addline(SIMPLELIST_ADD_LINE
,
1432 "Noise mgmt: %s", i
? "enabled" : "unsupported");
1433 i
= identify_info
[82] & (1<<6);
1434 simplelist_addline(SIMPLELIST_ADD_LINE
,
1435 "Read-ahead: %s", i
? "enabled" : "unsupported");
1436 timing_info_present
= identify_info
[53] & (1<<1);
1437 if(timing_info_present
) {
1438 char pio3
[2], pio4
[2];pio3
[1] = 0;
1440 pio3
[0] = (identify_info
[64] & (1<<0)) ? '3' : 0;
1441 pio4
[0] = (identify_info
[64] & (1<<1)) ? '4' : 0;
1442 simplelist_addline(SIMPLELIST_ADD_LINE
,
1443 "PIO modes: 0 1 2 %s %s", pio3
, pio4
);
1446 simplelist_addline(SIMPLELIST_ADD_LINE
,
1447 "No PIO mode info");
1449 timing_info_present
= identify_info
[53] & (1<<1);
1450 if(timing_info_present
) {
1451 simplelist_addline(SIMPLELIST_ADD_LINE
,
1452 "Cycle times %dns/%dns",
1454 identify_info
[68] );
1456 simplelist_addline(SIMPLELIST_ADD_LINE
,
1459 int sector_size
= 512;
1460 if((identify_info
[106] & 0xe000) == 0x6000)
1461 sector_size
*= BIT_N(identify_info
[106] & 0x000f);
1462 simplelist_addline(SIMPLELIST_ADD_LINE
,
1463 "Physical sector size: %d", sector_size
);
1465 if (identify_info
[63] & (1<<0)) {
1466 char mdma0
[2], mdma1
[2], mdma2
[2];
1467 mdma0
[1] = mdma1
[1] = mdma2
[1] = 0;
1468 mdma0
[0] = (identify_info
[63] & (1<<0)) ? '0' : 0;
1469 mdma1
[0] = (identify_info
[63] & (1<<1)) ? '1' : 0;
1470 mdma2
[0] = (identify_info
[63] & (1<<2)) ? '2' : 0;
1471 simplelist_addline(SIMPLELIST_ADD_LINE
,
1472 "MDMA modes: %s %s %s", mdma0
, mdma1
, mdma2
);
1473 simplelist_addline(SIMPLELIST_ADD_LINE
,
1474 "MDMA Cycle times %dns/%dns",
1476 identify_info
[66] );
1479 simplelist_addline(SIMPLELIST_ADD_LINE
,
1480 "No MDMA mode info");
1482 if (identify_info
[53] & (1<<2)) {
1483 char udma0
[2], udma1
[2], udma2
[2], udma3
[2], udma4
[2], udma5
[2], udma6
[2];
1484 udma0
[1] = udma1
[1] = udma2
[1] = udma3
[1] = udma4
[1] = udma5
[1] = udma6
[1] = 0;
1485 udma0
[0] = (identify_info
[88] & (1<<0)) ? '0' : 0;
1486 udma1
[0] = (identify_info
[88] & (1<<1)) ? '1' : 0;
1487 udma2
[0] = (identify_info
[88] & (1<<2)) ? '2' : 0;
1488 udma3
[0] = (identify_info
[88] & (1<<3)) ? '3' : 0;
1489 udma4
[0] = (identify_info
[88] & (1<<4)) ? '4' : 0;
1490 udma5
[0] = (identify_info
[88] & (1<<5)) ? '5' : 0;
1491 udma6
[0] = (identify_info
[88] & (1<<6)) ? '6' : 0;
1492 simplelist_addline(SIMPLELIST_ADD_LINE
,
1493 "UDMA modes: %s %s %s %s %s %s %s", udma0
, udma1
, udma2
,
1494 udma3
, udma4
, udma5
, udma6
);
1497 simplelist_addline(SIMPLELIST_ADD_LINE
,
1498 "No UDMA mode info");
1500 #endif /* HAVE_ATA_DMA */
1501 timing_info_present
= identify_info
[53] & (1<<1);
1502 if(timing_info_present
) {
1503 i
= identify_info
[49] & (1<<11);
1504 simplelist_addline(SIMPLELIST_ADD_LINE
,
1505 "IORDY support: %s", i
? "yes" : "no");
1506 i
= identify_info
[49] & (1<<10);
1507 simplelist_addline(SIMPLELIST_ADD_LINE
,
1508 "IORDY disable: %s", i
? "yes" : "no");
1510 simplelist_addline(SIMPLELIST_ADD_LINE
,
1513 simplelist_addline(SIMPLELIST_ADD_LINE
,
1514 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
1516 i
= ata_get_dma_mode();
1518 simplelist_addline(SIMPLELIST_ADD_LINE
,
1521 simplelist_addline(SIMPLELIST_ADD_LINE
,
1523 (i
& 0x40) ? "UDMA" : "MDMA",
1526 #endif /* HAVE_ATA_DMA */
1529 #else /* No SD, MMC or ATA */
1530 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1533 struct storage_info info
;
1534 storage_get_info(0,&info
);
1535 simplelist_addline(SIMPLELIST_ADD_LINE
, "Vendor: %s", info
.vendor
);
1536 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", info
.product
);
1537 simplelist_addline(SIMPLELIST_ADD_LINE
, "Firmware: %s", info
.revision
);
1538 simplelist_addline(SIMPLELIST_ADD_LINE
,
1539 "Size: %ld MB", info
.num_sectors
*(info
.sector_size
/512)/2024);
1541 fat_size( IF_MV2(0,) NULL
, &free
);
1542 simplelist_addline(SIMPLELIST_ADD_LINE
,
1543 "Free: %ld MB", free
/ 1024);
1544 simplelist_addline(SIMPLELIST_ADD_LINE
,
1545 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
1550 #if (CONFIG_STORAGE & STORAGE_ATA)
1551 static bool dbg_identify_info(void)
1553 int fd
= creat("/identify_info.bin", 0666);
1556 #ifdef ROCKBOX_LITTLE_ENDIAN
1557 ecwrite(fd
, ata_get_identify(), SECTOR_SIZE
/2, "s", true);
1559 write(fd
, ata_get_identify(), SECTOR_SIZE
);
1567 static bool dbg_disk_info(void)
1569 struct simplelist_info info
;
1570 simplelist_info_init(&info
, "Disk Info", 1, NULL
);
1571 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
1574 info
.callback_data
= (void*)&card
;
1577 info
.action_callback
= disk_callback
;
1578 info
.hide_selection
= true;
1579 info
.scroll_all
= true;
1580 return simplelist_show_list(&info
);
1582 #endif /* PLATFORM_NATIVE */
1584 #ifdef HAVE_DIRCACHE
1585 static int dircache_callback(int btn
, struct gui_synclist
*lists
)
1588 simplelist_set_line_count(0);
1589 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache initialized: %s",
1590 dircache_is_enabled() ? "Yes" : "No");
1591 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache size: %d B",
1592 dircache_get_cache_size());
1593 simplelist_addline(SIMPLELIST_ADD_LINE
, "Last size: %d B",
1594 global_status
.dircache_size
);
1595 simplelist_addline(SIMPLELIST_ADD_LINE
, "Limit: %d B",
1597 simplelist_addline(SIMPLELIST_ADD_LINE
, "Reserve: %d/%d B",
1598 dircache_get_reserve_used(), DIRCACHE_RESERVE
);
1599 simplelist_addline(SIMPLELIST_ADD_LINE
, "Scanning took: %d s",
1600 dircache_get_build_ticks() / HZ
);
1601 simplelist_addline(SIMPLELIST_ADD_LINE
, "Entry count: %d",
1602 dircache_get_entry_count());
1606 static bool dbg_dircache_info(void)
1608 struct simplelist_info info
;
1609 simplelist_info_init(&info
, "Dircache Info", 7, NULL
);
1610 info
.action_callback
= dircache_callback
;
1611 info
.hide_selection
= true;
1612 info
.scroll_all
= true;
1613 return simplelist_show_list(&info
);
1616 #endif /* HAVE_DIRCACHE */
1618 #ifdef HAVE_TAGCACHE
1619 static int database_callback(int btn
, struct gui_synclist
*lists
)
1622 struct tagcache_stat
*stat
= tagcache_get_stat();
1623 static bool synced
= false;
1625 simplelist_set_line_count(0);
1627 simplelist_addline(SIMPLELIST_ADD_LINE
, "Initialized: %s",
1628 stat
->initialized
? "Yes" : "No");
1629 simplelist_addline(SIMPLELIST_ADD_LINE
, "DB Ready: %s",
1630 stat
->ready
? "Yes" : "No");
1631 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM Cache: %s",
1632 stat
->ramcache
? "Yes" : "No");
1633 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM: %d/%d B",
1634 stat
->ramcache_used
, stat
->ramcache_allocated
);
1635 simplelist_addline(SIMPLELIST_ADD_LINE
, "Progress: %d%% (%d entries)",
1636 stat
->progress
, stat
->processed_entries
);
1637 simplelist_addline(SIMPLELIST_ADD_LINE
, "Curfile: %s",
1638 stat
->curentry
? stat
->curentry
: "---");
1639 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit step: %d",
1641 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit delayed: %s",
1642 stat
->commit_delayed
? "Yes" : "No");
1644 simplelist_addline(SIMPLELIST_ADD_LINE
, "Queue length: %d",
1645 stat
->queue_length
);
1650 tagcache_screensync_event();
1653 if (!btn
&& stat
->curentry
)
1656 return ACTION_REDRAW
;
1659 if (btn
== ACTION_STD_CANCEL
)
1660 tagcache_screensync_enable(false);
1664 static bool dbg_tagcache_info(void)
1666 struct simplelist_info info
;
1667 simplelist_info_init(&info
, "Database Info", 8, NULL
);
1668 info
.action_callback
= database_callback
;
1669 info
.hide_selection
= true;
1670 info
.scroll_all
= true;
1672 /* Don't do nonblock here, must give enough processing time
1673 for tagcache thread. */
1674 /* info.timeout = TIMEOUT_NOBLOCK; */
1676 tagcache_screensync_enable(true);
1677 return simplelist_show_list(&info
);
1681 #if CONFIG_CPU == SH7034
1682 static bool dbg_save_roms(void)
1685 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
1687 fd
= creat("/internal_rom_0000-FFFF.bin", 0666);
1690 write(fd
, (void *)0, 0x10000);
1694 fd
= creat("/internal_rom_2000000-203FFFF.bin", 0666);
1697 write(fd
, (void *)0x2000000, 0x40000);
1701 system_memory_guard(oldmode
);
1704 #elif defined CPU_COLDFIRE
1705 static bool dbg_save_roms(void)
1708 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
1710 #if defined(IRIVER_H100_SERIES)
1711 fd
= creat("/internal_rom_000000-1FFFFF.bin", 0666);
1712 #elif defined(IRIVER_H300_SERIES)
1713 fd
= creat("/internal_rom_000000-3FFFFF.bin", 0666);
1714 #elif defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IAUDIO_M3)
1715 fd
= creat("/internal_rom_000000-3FFFFF.bin", 0666);
1716 #elif defined(MPIO_HD200) || defined(MPIO_HD300)
1717 fd
= creat("/internal_rom_000000-1FFFFF.bin", 0666);
1721 write(fd
, (void *)0, FLASH_SIZE
);
1724 system_memory_guard(oldmode
);
1727 fd
= creat("/internal_eeprom.bin", 0666);
1731 char buf
[EEPROM_SIZE
];
1734 old_irq_level
= disable_irq_save();
1736 err
= eeprom_24cxx_read(0, buf
, sizeof buf
);
1738 restore_irq(old_irq_level
);
1741 splashf(HZ
*3, "Eeprom read failure (%d)", err
);
1744 write(fd
, buf
, sizeof buf
);
1753 #elif defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD)
1754 static bool dbg_save_roms(void)
1756 int fd
= creat("/internal_rom_000000-0FFFFF.bin", 0666);
1759 write(fd
, (void *)0x20000000, FLASH_SIZE
);
1765 #elif CONFIG_CPU == IMX31L
1766 static bool dbg_save_roms(void)
1768 int fd
= creat("/flash_rom_A0000000-A01FFFFF.bin", 0666);
1771 write(fd
, (void*)0xa0000000, FLASH_SIZE
);
1777 #elif defined(CPU_TCC780X)
1778 static bool dbg_save_roms(void)
1780 int fd
= creat("/eeprom_E0000000-E0001FFF.bin", 0666);
1783 write(fd
, (void*)0xe0000000, 0x2000);
1794 #ifdef CONFIG_TUNER_MULTI
1795 static int tuner_type
= 0;
1796 #define IF_TUNER_TYPE(type) if(tuner_type==type)
1798 #define IF_TUNER_TYPE(type)
1801 static int radio_callback(int btn
, struct gui_synclist
*lists
)
1804 if (btn
== ACTION_STD_CANCEL
)
1806 simplelist_set_line_count(1);
1808 #if (CONFIG_TUNER & LV24020LP)
1809 simplelist_addline(SIMPLELIST_ADD_LINE
,
1810 "CTRL_STAT: %02X", lv24020lp_get(LV24020LP_CTRL_STAT
) );
1811 simplelist_addline(SIMPLELIST_ADD_LINE
,
1812 "RADIO_STAT: %02X", lv24020lp_get(LV24020LP_REG_STAT
) );
1813 simplelist_addline(SIMPLELIST_ADD_LINE
,
1814 "MSS_FM: %d kHz", lv24020lp_get(LV24020LP_MSS_FM
) );
1815 simplelist_addline(SIMPLELIST_ADD_LINE
,
1816 "MSS_IF: %d Hz", lv24020lp_get(LV24020LP_MSS_IF
) );
1817 simplelist_addline(SIMPLELIST_ADD_LINE
,
1818 "MSS_SD: %d Hz", lv24020lp_get(LV24020LP_MSS_SD
) );
1819 simplelist_addline(SIMPLELIST_ADD_LINE
,
1820 "if_set: %d Hz", lv24020lp_get(LV24020LP_IF_SET
) );
1821 simplelist_addline(SIMPLELIST_ADD_LINE
,
1822 "sd_set: %d Hz", lv24020lp_get(LV24020LP_SD_SET
) );
1823 #endif /* LV24020LP */
1824 #if (CONFIG_TUNER & S1A0903X01)
1825 simplelist_addline(SIMPLELIST_ADD_LINE
,
1826 "Samsung regs: %08X", s1a0903x01_get(RADIO_ALL
));
1827 /* This one doesn't return dynamic data atm */
1828 #endif /* S1A0903X01 */
1829 #if (CONFIG_TUNER & TEA5767)
1830 struct tea5767_dbg_info nfo
;
1831 tea5767_dbg_info(&nfo
);
1832 simplelist_addline(SIMPLELIST_ADD_LINE
, "Philips regs:");
1833 simplelist_addline(SIMPLELIST_ADD_LINE
,
1834 " Read: %02X %02X %02X %02X %02X",
1835 (unsigned)nfo
.read_regs
[0], (unsigned)nfo
.read_regs
[1],
1836 (unsigned)nfo
.read_regs
[2], (unsigned)nfo
.read_regs
[3],
1837 (unsigned)nfo
.read_regs
[4]);
1838 simplelist_addline(SIMPLELIST_ADD_LINE
,
1839 " Write: %02X %02X %02X %02X %02X",
1840 (unsigned)nfo
.write_regs
[0], (unsigned)nfo
.write_regs
[1],
1841 (unsigned)nfo
.write_regs
[2], (unsigned)nfo
.write_regs
[3],
1842 (unsigned)nfo
.write_regs
[4]);
1843 #endif /* TEA5767 */
1844 #if (CONFIG_TUNER & SI4700)
1845 IF_TUNER_TYPE(SI4700
)
1847 struct si4700_dbg_info nfo
;
1848 si4700_dbg_info(&nfo
);
1849 simplelist_addline(SIMPLELIST_ADD_LINE
, "SI4700 regs:");
1850 for (int i
= 0; i
< 16; i
+= 4) {
1851 simplelist_addline(SIMPLELIST_ADD_LINE
,"%02X: %04X %04X %04X %04X",
1852 i
, nfo
.regs
[i
], nfo
.regs
[i
+1], nfo
.regs
[i
+2], nfo
.regs
[i
+3]);
1855 simplelist_addline(SIMPLELIST_ADD_LINE
, "");
1856 simplelist_addline(SIMPLELIST_ADD_LINE
, "RDS Info:");
1857 simplelist_addline(SIMPLELIST_ADD_LINE
,
1858 si4700_get_rds_info(RADIO_RDS_NAME
));
1860 simplelist_addline(SIMPLELIST_ADD_LINE
,
1861 si4700_get_rds_info(RADIO_RDS_TEXT
));
1865 #if (CONFIG_TUNER & RDA5802)
1866 IF_TUNER_TYPE(RDA5802
)
1868 struct rda5802_dbg_info nfo
;
1869 rda5802_dbg_info(&nfo
);
1870 simplelist_addline(SIMPLELIST_ADD_LINE
, "RDA5802 regs:");
1871 for (int i
= 0; i
< 16; i
+= 4) {
1872 simplelist_addline(SIMPLELIST_ADD_LINE
,"%02X: %04X %04X %04X %04X",
1873 i
, nfo
.regs
[i
], nfo
.regs
[i
+1], nfo
.regs
[i
+2], nfo
.regs
[i
+3]);
1876 #endif /* RDA55802 */
1877 return ACTION_REDRAW
;
1879 static bool dbg_fm_radio(void)
1881 struct simplelist_info info
;
1882 #ifdef CONFIG_TUNER_MULTI
1883 tuner_type
= tuner_detect_type();
1885 info
.scroll_all
= true;
1886 simplelist_info_init(&info
, "FM Radio", 1, NULL
);
1887 simplelist_set_line_count(0);
1888 simplelist_addline(SIMPLELIST_ADD_LINE
, "HW detected: %s",
1889 radio_hardware_present() ? "yes" : "no");
1891 info
.action_callback
= radio_hardware_present()?radio_callback
: NULL
;
1892 info
.hide_selection
= true;
1893 return simplelist_show_list(&info
);
1895 #endif /* CONFIG_TUNER */
1896 #endif /* !SIMULATOR */
1898 #if defined(HAVE_LCD_BITMAP) && !defined(APPLICATION)
1899 extern bool do_screendump_instead_of_usb
;
1901 static bool dbg_screendump(void)
1903 do_screendump_instead_of_usb
= !do_screendump_instead_of_usb
;
1904 splashf(HZ
, "Screendump %sabled", do_screendump_instead_of_usb
?"en":"dis");
1907 #endif /* HAVE_LCD_BITMAP */
1909 extern bool write_metadata_log
;
1911 static bool dbg_metadatalog(void)
1913 write_metadata_log
= !write_metadata_log
;
1914 splashf(HZ
, "Metadata log %sabled", write_metadata_log
? "en" : "dis");
1918 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
1919 static bool dbg_set_memory_guard(void)
1921 static const struct opt_items names
[MAXMEMGUARD
] = {
1923 { "Flash ROM writes", -1 },
1924 { "Zero area (all)", -1 }
1926 int mode
= system_memory_guard(MEMGUARD_KEEP
);
1928 set_option( "Catch mem accesses", &mode
, INT
, names
, MAXMEMGUARD
, NULL
);
1929 system_memory_guard(mode
);
1933 #endif /* CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) */
1935 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
1936 static bool dbg_write_eeprom(void)
1938 int fd
= open("/internal_eeprom.bin", O_RDONLY
);
1942 char buf
[EEPROM_SIZE
];
1943 int rc
= read(fd
, buf
, EEPROM_SIZE
);
1945 if(rc
== EEPROM_SIZE
)
1947 int old_irq_level
= disable_irq_save();
1949 int err
= eeprom_24cxx_write(0, buf
, sizeof buf
);
1951 splashf(HZ
*3, "Eeprom write failure (%d)", err
);
1953 splash(HZ
*3, "Eeprom written successfully");
1955 restore_irq(old_irq_level
);
1959 splashf(HZ
*3, "File read error (%d)",rc
);
1965 splash(HZ
*3, "Failed to open 'internal_eeprom.bin'");
1970 #endif /* defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS) */
1971 #ifdef CPU_BOOST_LOGGING
1972 static bool cpu_boost_log(void)
1974 int count
= cpu_boost_log_getcount();
1975 char *str
= cpu_boost_log_getlog_first();
1977 lcd_setfont(FONT_SYSFIXED
);
1978 for (int i
= 0; i
< count
;)
1980 lcd_clear_display();
1981 for(int j
=0; j
<LCD_HEIGHT
/SYSFONT_HEIGHT
; j
++,i
++)
1984 str
= cpu_boost_log_getlog_next();
1987 if(strlen(str
) > LCD_WIDTH
/SYSFONT_WIDTH
)
1988 lcd_puts_scroll(0, j
, str
);
1998 switch(get_action(CONTEXT_STD
,TIMEOUT_BLOCK
))
2001 case ACTION_STD_PREV
:
2002 case ACTION_STD_NEXT
:
2005 case ACTION_STD_CANCEL
:
2013 get_action(CONTEXT_STD
,TIMEOUT_BLOCK
);
2014 lcd_setfont(FONT_UI
);
2019 #if (defined(HAVE_WHEEL_ACCELERATION) && (CONFIG_KEYPAD==IPOD_4G_PAD) \
2020 && !defined(IPOD_MINI) && !defined(SIMULATOR))
2021 extern bool wheel_is_touched
;
2022 extern int old_wheel_value
;
2023 extern int new_wheel_value
;
2024 extern int wheel_delta
;
2025 extern unsigned int accumulated_wheel_delta
;
2026 extern unsigned int wheel_velocity
;
2028 static bool dbg_scrollwheel(void)
2030 lcd_setfont(FONT_SYSFIXED
);
2034 if (action_userabort(HZ
/10))
2037 lcd_clear_display();
2039 /* show internal variables of scrollwheel driver */
2040 lcd_putsf(0, 0, "wheel touched: %s", (wheel_is_touched
) ? "true" : "false");
2041 lcd_putsf(0, 1, "new position: %2d", new_wheel_value
);
2042 lcd_putsf(0, 2, "old position: %2d", old_wheel_value
);
2043 lcd_putsf(0, 3, "wheel delta: %2d", wheel_delta
);
2044 lcd_putsf(0, 4, "accumulated delta: %2d", accumulated_wheel_delta
);
2045 lcd_putsf(0, 5, "velo [deg/s]: %4d", (int)wheel_velocity
);
2047 /* show effective accelerated scrollspeed */
2048 lcd_putsf(0, 6, "accel. speed: %4d",
2049 button_apply_acceleration((1<<31)|(1<<24)|wheel_velocity
) );
2053 lcd_setfont(FONT_UI
);
2058 #ifdef HAVE_USBSTACK
2059 #if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL)
2060 static bool toggle_usb_serial(void)
2062 bool enabled
= !usb_core_driver_enabled(USB_DRIVER_SERIAL
);
2064 usb_core_enable_driver(USB_DRIVER_SERIAL
, enabled
);
2065 splashf(HZ
, "USB Serial %sabled", enabled
? "en" : "dis");
2072 #if CONFIG_USBOTG == USBOTG_ISP1583
2073 extern int dbg_usb_num_items(void);
2074 extern const char* dbg_usb_item(int selected_item
, void *data
,
2075 char *buffer
, size_t buffer_len
);
2077 static int isp1583_action_callback(int action
, struct gui_synclist
*lists
)
2080 if (action
== ACTION_NONE
)
2081 action
= ACTION_REDRAW
;
2085 static bool dbg_isp1583(void)
2087 struct simplelist_info isp1583
;
2088 isp1583
.scroll_all
= true;
2089 simplelist_info_init(&isp1583
, "ISP1583", dbg_usb_num_items(), NULL
);
2090 isp1583
.timeout
= HZ
/100;
2091 isp1583
.hide_selection
= true;
2092 isp1583
.get_name
= dbg_usb_item
;
2093 isp1583
.action_callback
= isp1583_action_callback
;
2094 return simplelist_show_list(&isp1583
);
2098 #if defined(CREATIVE_ZVx) && !defined(SIMULATOR)
2099 extern int pic_dbg_num_items(void);
2100 extern const char* pic_dbg_item(int selected_item
, void *data
,
2101 char *buffer
, size_t buffer_len
);
2103 static int pic_action_callback(int action
, struct gui_synclist
*lists
)
2106 if (action
== ACTION_NONE
)
2107 action
= ACTION_REDRAW
;
2111 static bool dbg_pic(void)
2113 struct simplelist_info pic
;
2114 pic
.scroll_all
= true;
2115 simplelist_info_init(&pic
, "PIC", pic_dbg_num_items(), NULL
);
2116 pic
.timeout
= HZ
/100;
2117 pic
.hide_selection
= true;
2118 pic
.get_name
= pic_dbg_item
;
2119 pic
.action_callback
= pic_action_callback
;
2120 return simplelist_show_list(&pic
);
2125 /****** The menu *********/
2126 static const struct {
2127 unsigned char *desc
; /* string or ID */
2128 bool (*function
) (void); /* return true if USB was connected */
2130 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || \
2131 (defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD)) || \
2132 CONFIG_CPU == IMX31L || defined(CPU_TCC780X)
2133 { "Dump ROM contents", dbg_save_roms
},
2135 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || defined(CPU_PP) \
2136 || CONFIG_CPU == S3C2440 || CONFIG_CPU == IMX31L || CONFIG_CPU == AS3525 \
2137 || CONFIG_CPU == DM320 || defined(CPU_S5L870X) || CONFIG_CPU == AS3525v2 \
2138 || CONFIG_CPU == RK27XX
2139 { "View I/O ports", dbg_ports
},
2141 #if (CONFIG_RTC == RTC_PCF50605) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
2142 { "View PCF registers", dbg_pcf
},
2144 #if defined(HAVE_TSC2100) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
2145 { "TSC2100 debug", tsc2100_debug
},
2147 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
2148 { "CPU frequency", dbg_cpufreq
},
2150 #if CONFIG_CPU == IMX31L
2151 { "DVFS/DPTC", __dbg_dvfs_dptc
},
2153 #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR)
2154 { "S/PDIF analyzer", dbg_spdif
},
2156 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2157 { "Catch mem accesses", dbg_set_memory_guard
},
2159 { "View OS stacks", dbg_os
},
2161 { "View CPU stats", dbg_cpuinfo
},
2163 #ifdef HAVE_LCD_BITMAP
2164 #if (CONFIG_BATTERY_MEASURE != 0) && !defined(SIMULATOR)
2165 { "View battery", view_battery
},
2168 { "Screendump", dbg_screendump
},
2171 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
2172 { "View HW info", dbg_hw_info
},
2174 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
2175 { "View partitions", dbg_partitions
},
2177 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
2178 { "View disk info", dbg_disk_info
},
2179 #if (CONFIG_STORAGE & STORAGE_ATA)
2180 { "Dump ATA identify info", dbg_identify_info
},
2183 { "Metadata log", dbg_metadatalog
},
2184 #ifdef HAVE_DIRCACHE
2185 { "View dircache info", dbg_dircache_info
},
2187 #ifdef HAVE_TAGCACHE
2188 { "View database info", dbg_tagcache_info
},
2190 #ifdef HAVE_LCD_BITMAP
2191 #if CONFIG_CODEC == SWCODEC
2192 { "View buffering thread", dbg_buffering_thread
},
2193 #elif !defined(SIMULATOR)
2194 { "View audio thread", dbg_audio_thread
},
2197 { "pm histogram", peak_meter_histogram
},
2198 #endif /* PM_DEBUG */
2199 #endif /* HAVE_LCD_BITMAP */
2200 { "View buflib allocs", dbg_buflib_allocs
},
2203 { "FM Radio", dbg_fm_radio
},
2206 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2207 { "Write back EEPROM", dbg_write_eeprom
},
2209 #if CONFIG_USBOTG == USBOTG_ISP1583
2210 { "View ISP1583 info", dbg_isp1583
},
2212 #if defined(CREATIVE_ZVx) && !defined(SIMULATOR)
2213 { "View PIC info", dbg_pic
},
2215 #ifdef ROCKBOX_HAS_LOGF
2216 {"Show Log File", logfdisplay
},
2217 {"Dump Log File", logfdump
},
2219 #if defined(HAVE_USBSTACK)
2220 #if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL)
2221 {"USB Serial driver (logf)", toggle_usb_serial
},
2223 #endif /* HAVE_USBSTACK */
2224 #ifdef CPU_BOOST_LOGGING
2225 {"cpu_boost log",cpu_boost_log
},
2227 #if (defined(HAVE_WHEEL_ACCELERATION) && (CONFIG_KEYPAD==IPOD_4G_PAD) \
2228 && !defined(IPOD_MINI) && !defined(SIMULATOR))
2229 {"Debug scrollwheel", dbg_scrollwheel
},
2233 static int menu_action_callback(int btn
, struct gui_synclist
*lists
)
2235 int selection
= gui_synclist_get_sel_pos(lists
);
2236 if (btn
== ACTION_STD_OK
)
2239 viewportmanager_theme_enable(i
, false, NULL
);
2240 menuitems
[selection
].function();
2241 btn
= ACTION_REDRAW
;
2243 viewportmanager_theme_undo(i
, false);
2245 else if (btn
== ACTION_STD_CONTEXT
)
2247 MENUITEM_STRINGLIST(menu_items
, "Debug Menu", NULL
, ID2P(LANG_ADD_TO_FAVES
));
2248 if (do_menu(&menu_items
, NULL
, NULL
, false) == 0)
2249 shortcuts_add(SHORTCUT_DEBUGITEM
, menuitems
[selection
].desc
);
2250 return ACTION_STD_CANCEL
;
2255 static const char* menu_get_name(int item
, void * data
,
2256 char *buffer
, size_t buffer_len
)
2258 (void)data
; (void)buffer
; (void)buffer_len
;
2259 return menuitems
[item
].desc
;
2262 bool debug_menu(void)
2264 struct simplelist_info info
;
2266 simplelist_info_init(&info
, "Debug Menu", ARRAYLEN(menuitems
), NULL
);
2267 info
.action_callback
= menu_action_callback
;
2268 info
.get_name
= menu_get_name
;
2269 return simplelist_show_list(&info
);
2272 bool run_debug_screen(char* screen
)
2274 for (unsigned i
=0; i
<ARRAYLEN(menuitems
); i
++)
2275 if (!strcmp(screen
, menuitems
[i
].desc
))
2278 viewportmanager_theme_enable(j
, false, NULL
);
2279 menuitems
[i
].function();
2281 viewportmanager_theme_undo(j
, false);