1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Heikki Hannikainen
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
26 #include "debug_menu.h"
32 #include "powermgmt.h"
36 #include "mp3_playback.h"
39 #include "statusbar.h"
49 #include "lcd-remote.h"
61 #include "eeprom_24cxx.h"
62 #if defined(HAVE_MMC) || defined(HAVE_HOTSWAP)
71 #ifdef HAVE_LCD_BITMAP
72 #include "scrollbar.h"
73 #include "peakmeter.h"
76 #if CONFIG_CODEC == SWCODEC
78 #include "pcm_playback.h"
79 #if defined(HAVE_SPDIF_OUT) || defined(HAVE_SPDIF_IN)
83 #ifdef IRIVER_H300_SERIES
84 #include "pcf50606.h" /* for pcf50606_read */
91 #if defined(HAVE_DIRCACHE) || defined(HAVE_TAGCACHE) || CONFIG_TUNER
92 #define MAX_DEBUG_MESSAGES 16
93 #define DEBUG_MSG_LEN 32
94 int debug_listmessage_lines
;
95 char debug_list_messages
[MAX_DEBUG_MESSAGES
][DEBUG_MSG_LEN
];
96 static void dbg_listmessage_setlines(int lines
)
100 else if (lines
> MAX_DEBUG_MESSAGES
)
101 lines
= MAX_DEBUG_MESSAGES
;
102 debug_listmessage_lines
= lines
;
105 static int dbg_listmessage_getlines(void)
107 return debug_listmessage_lines
;
110 static void dbg_listmessage_addline(const char *fmt
, ...)
114 if (debug_listmessage_lines
>= MAX_DEBUG_MESSAGES
)
118 vsnprintf(debug_list_messages
[debug_listmessage_lines
++], DEBUG_MSG_LEN
, fmt
, ap
);
121 static char* dbg_listmessage_getname(int item
, void * data
, char *buffer
)
123 (void)buffer
; (void)data
;
124 return debug_list_messages
[item
];
128 struct action_callback_info
;
129 struct action_callback_info
134 int (*action_callback
)(int btn
, struct action_callback_info
*info
);
135 char* (*dbg_getname
)(int item
, void * data
, char *buffer
);
136 intptr_t cbdata
; /* extra callback data (pointer, int, whatever) */
137 struct gui_synclist
*lists
; /* passed back to the callback */
140 static char* dbg_menu_getname(int item
, void * data
, char *buffer
);
141 static bool dbg_list(struct action_callback_info
*info
)
143 struct gui_synclist lists
;
146 info
->lists
= &lists
;
148 gui_synclist_init(&lists
, info
->dbg_getname
, NULL
, false,
149 info
->selection_size
);
150 gui_synclist_set_title(&lists
, info
->title
, NOICON
);
151 gui_synclist_set_icon_callback(&lists
, NULL
);
152 gui_synclist_set_nb_items(&lists
, info
->count
*info
->selection_size
);
153 if (info
->dbg_getname
!= dbg_menu_getname
)
154 gui_synclist_hide_selection_marker(&lists
, true);
156 if (info
->action_callback
)
157 info
->action_callback(ACTION_REDRAW
, info
);
159 gui_synclist_draw(&lists
);
163 gui_syncstatusbar_draw(&statusbars
, true);
164 action
= get_action(CONTEXT_STD
, HZ
/5);
165 if (gui_synclist_do_button(&lists
, action
, LIST_WRAP_UNLESS_HELD
))
167 if (info
->action_callback
)
168 action
= info
->action_callback(action
, info
);
169 if (action
== ACTION_STD_CANCEL
)
171 else if (action
== ACTION_REDRAW
)
172 gui_synclist_draw(&lists
);
173 else if(default_event_handler(action
) == SYS_USB_CONNECTED
)
178 /*---------------------------------------------------*/
179 /* SPECIAL DEBUG STUFF */
180 /*---------------------------------------------------*/
181 extern struct thread_entry threads
[MAXTHREADS
];
185 static char thread_status_char(int status
)
189 case STATE_RUNNING
: return 'R';
190 case STATE_BLOCKED
: return 'B';
191 case STATE_SLEEPING
: return 'S';
192 case STATE_BLOCKED_W_TMO
: return 'T';
198 #define IF_COP2(...) __VA_ARGS__
202 static char* threads_getname(int selected_item
, void * data
, char *buffer
)
205 struct thread_entry
*thread
= NULL
;
207 thread
= &threads
[selected_item
];
209 if (thread
->name
== NULL
)
211 snprintf(buffer
, MAX_PATH
, "%2d: ---", selected_item
);
215 usage
= thread_stack_usage(thread
);
216 status
= thread_get_status(thread
);
217 #ifdef HAVE_PRIORITY_SCHEDULING
218 snprintf(buffer
, MAX_PATH
, "%2d: " IF_COP2("(%d) ") "%c%c %d %2d%% %s",
220 IF_COP2(thread
->core
,)
221 (status
== STATE_RUNNING
) ? '*' : ' ',
222 thread_status_char(status
),
224 usage
, thread
->name
);
226 snprintf(buffer
, MAX_PATH
, "%2d: " IF_COP2("(%d) ") "%c%c %2d%% %s",
228 IF_COP2(thread
->core
,)
229 (status
== STATE_RUNNING
) ? '*' : ' ',
230 thread_status_char(status
),
231 usage
, thread
->name
);
235 static int dbg_threads_action_callback(int action
, struct action_callback_info
*info
)
237 #ifdef ROCKBOX_HAS_LOGF
238 if (action
== ACTION_STD_OK
)
240 struct thread_entry
*thread
= &threads
[gui_synclist_get_sel_pos(info
->lists
)];
241 if (thread
->name
!= NULL
)
242 remove_thread(thread
);
245 gui_synclist_draw(info
->lists
);
249 static bool dbg_os(void)
251 struct action_callback_info info
;
252 info
.title
= IF_COP2("Core and ") "Stack usage:";
253 info
.count
= MAXTHREADS
;
254 info
.selection_size
= 1;
255 info
.action_callback
= dbg_threads_action_callback
;
256 info
.dbg_getname
= threads_getname
;
257 return dbg_list(&info
);
259 #endif /* !SIMULATOR */
261 #ifdef HAVE_LCD_BITMAP
262 #if CONFIG_CODEC != SWCODEC
264 static bool dbg_audio_thread(void)
267 struct audio_debug d
;
269 lcd_setmargins(0, 0);
270 lcd_setfont(FONT_SYSFIXED
);
274 if (action_userabort(HZ
/5))
277 audio_get_debugdata(&d
);
281 snprintf(buf
, sizeof(buf
), "read: %x", d
.audiobuf_read
);
283 snprintf(buf
, sizeof(buf
), "write: %x", d
.audiobuf_write
);
285 snprintf(buf
, sizeof(buf
), "swap: %x", d
.audiobuf_swapwrite
);
287 snprintf(buf
, sizeof(buf
), "playing: %d", d
.playing
);
289 snprintf(buf
, sizeof(buf
), "playable: %x", d
.playable_space
);
291 snprintf(buf
, sizeof(buf
), "unswapped: %x", d
.unswapped_space
);
294 /* Playable space left */
295 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8, 112, 4, d
.audiobuflen
, 0,
296 d
.playable_space
, HORIZONTAL
);
298 /* Show the watermark limit */
299 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8+4, 112, 4, d
.audiobuflen
, 0,
300 d
.low_watermark_level
, HORIZONTAL
);
302 snprintf(buf
, sizeof(buf
), "wm: %x - %x",
303 d
.low_watermark_level
, d
.lowest_watermark_level
);
310 #endif /* !SIMULATOR */
311 #else /* CONFIG_CODEC == SWCODEC */
312 extern size_t filebuflen
;
313 /* This is a size_t, but call it a long so it puts a - when it's bad. */
315 static unsigned int ticks
, boost_ticks
;
317 static void dbg_audio_task(void)
320 if(FREQ
> CPUFREQ_NORMAL
)
327 static bool dbg_audio_thread(void)
334 size_t bufsize
= pcmbuf_get_bufsize();
335 int pcmbufdescs
= pcmbuf_descs();
337 ticks
= boost_ticks
= 0;
339 tick_add_task(dbg_audio_task
);
341 lcd_setmargins(0, 0);
342 lcd_setfont(FONT_SYSFIXED
);
345 button
= get_action(CONTEXT_STD
,HZ
/5);
348 case ACTION_STD_NEXT
:
351 case ACTION_STD_PREV
:
354 case ACTION_STD_CANCEL
:
361 bufused
= bufsize
- pcmbuf_free();
363 snprintf(buf
, sizeof(buf
), "pcm: %7ld/%7ld", (long) bufused
, (long) bufsize
);
364 lcd_puts(0, line
++, buf
);
366 /* Playable space left */
367 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6, bufsize
, 0, bufused
, HORIZONTAL
);
370 snprintf(buf
, sizeof(buf
), "codec: %8ld/%8ld", audio_filebufused(), (long) filebuflen
);
371 lcd_puts(0, line
++, buf
);
373 /* Playable space left */
374 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6, filebuflen
, 0,
375 audio_filebufused(), HORIZONTAL
);
378 snprintf(buf
, sizeof(buf
), "track count: %2d", audio_track_count());
379 lcd_puts(0, line
++, buf
);
382 snprintf(buf
, sizeof(buf
), "cpu freq: %3dMHz",
383 (int)((FREQ
+ 500000) / 1000000));
384 lcd_puts(0, line
++, buf
);
389 snprintf(buf
, sizeof(buf
), "boost ratio: %3d%%",
390 boost_ticks
* 100 / ticks
);
391 lcd_puts(0, line
++, buf
);
394 snprintf(buf
, sizeof(buf
), "pcmbufdesc: %2d/%2d",
395 pcmbuf_used_descs(), pcmbufdescs
);
396 lcd_puts(0, line
++, buf
);
401 tick_remove_task(dbg_audio_task
);
405 #endif /* CONFIG_CODEC */
406 #endif /* HAVE_LCD_BITMAP */
409 #if (CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE))
410 /* Tool function to read the flash manufacturer and type, if available.
411 Only chips which could be reprogrammed in system will return values.
412 (The mode switch addresses vary between flash manufacturers, hence addr1/2) */
413 /* In IRAM to avoid problems when running directly from Flash */
414 static bool dbg_flash_id(unsigned* p_manufacturer
, unsigned* p_device
,
415 unsigned addr1
, unsigned addr2
)
416 ICODE_ATTR
__attribute__((noinline
));
417 static bool dbg_flash_id(unsigned* p_manufacturer
, unsigned* p_device
,
418 unsigned addr1
, unsigned addr2
)
421 unsigned not_manu
, not_id
; /* read values before switching to ID mode */
422 unsigned manu
, id
; /* read values when in ID mode */
424 #if CONFIG_CPU == SH7034
425 volatile unsigned char* flash
= (unsigned char*)0x2000000; /* flash mapping */
426 #elif defined(CPU_COLDFIRE)
427 volatile unsigned short* flash
= (unsigned short*)0; /* flash mapping */
429 int old_level
; /* saved interrupt level */
431 not_manu
= flash
[0]; /* read the normal content */
432 not_id
= flash
[1]; /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */
434 /* disable interrupts, prevent any stray flash access */
435 old_level
= set_irq_level(HIGHEST_IRQ_LEVEL
);
437 flash
[addr1
] = 0xAA; /* enter command mode */
439 flash
[addr1
] = 0x90; /* ID command */
440 /* Atmel wants 20ms pause here */
441 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
443 manu
= flash
[0]; /* read the IDs */
446 flash
[0] = 0xF0; /* reset flash (back to normal read mode) */
447 /* Atmel wants 20ms pause here */
448 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
450 set_irq_level(old_level
); /* enable interrupts again */
452 /* I assume success if the obtained values are different from
453 the normal flash content. This is not perfectly bulletproof, they
454 could theoretically be the same by chance, causing us to fail. */
455 if (not_manu
!= manu
|| not_id
!= id
) /* a value has changed */
457 *p_manufacturer
= manu
; /* return the results */
459 return true; /* success */
461 return false; /* fail */
463 #endif /* (CONFIG_CPU == SH7034 || CPU_COLDFIRE) */
467 static int perfcheck(void)
473 "orr r0, r2, #0xc0 \n" /* disable IRQ and FIQ */
476 "ldr r0, [%[timr]] \n"
477 "add r0, r0, %[tmo] \n"
479 "add %[res], %[res], #1 \n"
480 "ldr r1, [%[timr]] \n"
483 "msr CPSR_c, r2 \n" /* reset IRQ and FIQ state */
487 [timr
]"r"(&USEC_TIMER
),
489 #if CONFIG_CPU == PP5002
491 #else /* PP5020/5022/5024 */
502 #ifdef HAVE_LCD_BITMAP
503 static bool dbg_hw_info(void)
505 #if CONFIG_CPU == SH7034
507 int bitmask
= HW_MASK
;
508 int rom_version
= ROM_VERSION
;
509 unsigned manu
, id
; /* flash IDs */
510 bool got_id
; /* flag if we managed to get the flash IDs */
511 unsigned rom_crc
= 0xffffffff; /* CRC32 of the boot ROM */
512 bool has_bootrom
; /* flag for boot ROM present */
513 int oldmode
; /* saved memory guard mode */
515 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
517 /* get flash ROM type */
518 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
520 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
522 /* check if the boot ROM area is a flash mirror */
523 has_bootrom
= (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
524 if (has_bootrom
) /* if ROM and Flash different */
526 /* calculate CRC16 checksum of boot ROM */
527 rom_crc
= crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
530 system_memory_guard(oldmode
); /* re-enable memory guard */
532 lcd_setmargins(0, 0);
533 lcd_setfont(FONT_SYSFIXED
);
536 lcd_puts(0, 0, "[Hardware info]");
538 snprintf(buf
, 32, "ROM: %d.%02d", rom_version
/100, rom_version
%100);
541 snprintf(buf
, 32, "Mask: 0x%04x", bitmask
);
545 snprintf(buf
, 32, "Flash: M=%02x D=%02x", manu
, id
);
547 snprintf(buf
, 32, "Flash: M=?? D=??"); /* unknown, sorry */
552 if (rom_crc
== 0x56DBA4EE) /* known Version 1 */
553 snprintf(buf
, 32, "Boot ROM: V1");
555 snprintf(buf
, 32, "ROMcrc: 0x%08x", rom_crc
);
559 snprintf(buf
, 32, "Boot ROM: none");
565 while (!(action_userabort(TIMEOUT_BLOCK
)));
567 #elif CONFIG_CPU == MCF5249 || CONFIG_CPU == MCF5250
569 unsigned manu
, id
; /* flash IDs */
570 int got_id
; /* flag if we managed to get the flash IDs */
571 int oldmode
; /* saved memory guard mode */
574 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
576 /* get flash ROM type */
577 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
579 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
581 system_memory_guard(oldmode
); /* re-enable memory guard */
583 lcd_setmargins(0, 0);
584 lcd_setfont(FONT_SYSFIXED
);
587 lcd_puts(0, line
++, "[Hardware info]");
590 snprintf(buf
, 32, "Flash: M=%04x D=%04x", manu
, id
);
592 snprintf(buf
, 32, "Flash: M=???? D=????"); /* unknown, sorry */
593 lcd_puts(0, line
++, buf
);
599 lcd_puts(0, ++line
, "Serial Number:");
601 got_id
= ds2411_read_id(&id
);
603 if (got_id
== DS2411_OK
)
605 snprintf(buf
, 32, " FC=%02x", (unsigned)id
.family_code
);
606 lcd_puts(0, ++line
, buf
);
607 snprintf(buf
, 32, " ID=%02X %02X %02X %02X %02X %02X",
608 (unsigned)id
.uid
[0], (unsigned)id
.uid
[1], (unsigned)id
.uid
[2],
609 (unsigned)id
.uid
[3], (unsigned)id
.uid
[4], (unsigned)id
.uid
[5]);
610 lcd_puts(0, ++line
, buf
);
611 snprintf(buf
, 32, " CRC=%02X", (unsigned)id
.crc
);
615 snprintf(buf
, 32, "READ ERR=%d", got_id
);
618 lcd_puts(0, ++line
, buf
);
624 while (!(action_userabort(TIMEOUT_BLOCK
)));
626 #elif defined(CPU_PP502x)
629 char pp_version
[] = { (PP_VER2
>> 24) & 0xff, (PP_VER2
>> 16) & 0xff,
630 (PP_VER2
>> 8) & 0xff, (PP_VER2
) & 0xff,
631 (PP_VER1
>> 24) & 0xff, (PP_VER1
>> 16) & 0xff,
632 (PP_VER1
>> 8) & 0xff, (PP_VER1
) & 0xff, '\0' };
634 lcd_setmargins(0, 0);
635 lcd_setfont(FONT_SYSFIXED
);
638 lcd_puts(0, line
++, "[Hardware info]");
641 snprintf(buf
, sizeof(buf
), "HW rev: 0x%08lx", IPOD_HW_REVISION
);
642 lcd_puts(0, line
++, buf
);
646 extern int lcd_type
; /* Defined in lcd-colornano.c */
648 snprintf(buf
, sizeof(buf
), "LCD type: %d", lcd_type
);
649 lcd_puts(0, line
++, buf
);
652 snprintf(buf
, sizeof(buf
), "PP version: %s", pp_version
);
653 lcd_puts(0, line
++, buf
);
655 snprintf(buf
, sizeof(buf
), "Est. clock (kHz): %d", perfcheck());
656 lcd_puts(0, line
++, buf
);
660 while (!(action_userabort(TIMEOUT_BLOCK
)));
662 #elif CONFIG_CPU == PP5002
666 lcd_setmargins(0, 0);
667 lcd_setfont(FONT_SYSFIXED
);
670 lcd_puts(0, line
++, "[Hardware info]");
673 snprintf(buf
, sizeof(buf
), "HW rev: 0x%08lx", IPOD_HW_REVISION
);
674 lcd_puts(0, line
++, buf
);
677 snprintf(buf
, sizeof(buf
), "Est. clock (kHz): %d", perfcheck());
678 lcd_puts(0, line
++, buf
);
682 while (!(action_userabort(TIMEOUT_BLOCK
)));
684 #endif /* CONFIG_CPU */
687 #else /* !HAVE_LCD_BITMAP */
688 static bool dbg_hw_info(void)
693 int rom_version
= ROM_VERSION
;
694 unsigned manu
, id
; /* flash IDs */
695 bool got_id
; /* flag if we managed to get the flash IDs */
696 unsigned rom_crc
= 0xffffffff; /* CRC32 of the boot ROM */
697 bool has_bootrom
; /* flag for boot ROM present */
698 int oldmode
; /* saved memory guard mode */
700 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
702 /* get flash ROM type */
703 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
705 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
707 /* check if the boot ROM area is a flash mirror */
708 has_bootrom
= (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
709 if (has_bootrom
) /* if ROM and Flash different */
711 /* calculate CRC16 checksum of boot ROM */
712 rom_crc
= crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
715 system_memory_guard(oldmode
); /* re-enable memory guard */
719 lcd_puts(0, 0, "[HW Info]");
725 snprintf(buf
, 32, "ROM: %d.%02d",
726 rom_version
/100, rom_version
%100);
730 snprintf(buf
, 32, "Flash:%02x,%02x", manu
, id
);
732 snprintf(buf
, 32, "Flash:??,??"); /* unknown, sorry */
737 if (rom_crc
== 0x56DBA4EE) /* known Version 1 */
738 snprintf(buf
, 32, "BootROM: V1");
739 else if (rom_crc
== 0x358099E8)
740 snprintf(buf
, 32, "BootROM: V2");
741 /* alternative boot ROM found in one single player so far */
743 snprintf(buf
, 32, "R: %08x", rom_crc
);
746 snprintf(buf
, 32, "BootROM: no");
752 button
= get_action(CONTEXT_SETTINGS
,TIMEOUT_BLOCK
);
756 case ACTION_STD_CANCEL
:
759 case ACTION_SETTINGS_DEC
:
765 case ACTION_SETTINGS_INC
:
774 #endif /* !HAVE_LCD_BITMAP */
775 #endif /* !SIMULATOR */
778 static char* dbg_partitions_getname(int selected_item
, void * data
, char *buffer
)
781 int partition
= selected_item
/2;
782 struct partinfo
* p
= disk_partinfo(partition
);
785 snprintf(buffer
, MAX_PATH
, " T:%x %ld MB", p
->type
, p
->size
/ 2048);
789 snprintf(buffer
, MAX_PATH
, "P%d: S:%lx", partition
, p
->start
);
794 bool dbg_partitions(void)
796 struct action_callback_info info
;
797 info
.title
= "Partition Info";
799 info
.selection_size
= 2;
800 info
.action_callback
= NULL
;
801 info
.dbg_getname
= dbg_partitions_getname
;
807 #if defined(CPU_COLDFIRE) && defined(HAVE_SPDIF_OUT)
808 static bool dbg_spdif(void)
812 unsigned int control
;
817 unsigned int interruptstat
;
818 bool valnogood
, symbolerr
, parityerr
;
821 int spdif_source
= spdif_get_output_source(&spdif_src_on
);
822 spdif_set_output_source(AUDIO_SRC_SPDIF
IF_SPDIF_POWER_(, true));
824 lcd_setmargins(0, 0);
826 lcd_setfont(FONT_SYSFIXED
);
828 #ifdef HAVE_SPDIF_POWER
829 spdif_power_enable(true); /* We need SPDIF power for both sending & receiving */
836 control
= EBU1RCVCCHANNEL1
;
837 interruptstat
= INTERRUPTSTAT
;
838 INTERRUPTCLEAR
= 0x03c00000;
840 valnogood
= (interruptstat
& 0x01000000)?true:false;
841 symbolerr
= (interruptstat
& 0x00800000)?true:false;
842 parityerr
= (interruptstat
& 0x00400000)?true:false;
844 snprintf(buf
, sizeof(buf
), "Val: %s Sym: %s Par: %s",
847 parityerr
?"--":"OK");
848 lcd_puts(0, line
++, buf
);
850 snprintf(buf
, sizeof(buf
), "Status word: %08x", (int)control
);
851 lcd_puts(0, line
++, buf
);
856 snprintf(buf
, sizeof(buf
), "PRO: %d (%s)",
857 x
, x
?"Professional":"Consumer");
858 lcd_puts(0, line
++, buf
);
860 x
= (control
>> 30) & 1;
861 snprintf(buf
, sizeof(buf
), "Audio: %d (%s)",
862 x
, x
?"Non-PCM":"PCM");
863 lcd_puts(0, line
++, buf
);
865 x
= (control
>> 29) & 1;
866 snprintf(buf
, sizeof(buf
), "Copy: %d (%s)",
867 x
, x
?"Permitted":"Inhibited");
868 lcd_puts(0, line
++, buf
);
870 x
= (control
>> 27) & 7;
883 snprintf(buf
, sizeof(buf
), "Preemphasis: %d (%s)", x
, s
);
884 lcd_puts(0, line
++, buf
);
886 x
= (control
>> 24) & 3;
887 snprintf(buf
, sizeof(buf
), "Mode: %d", x
);
888 lcd_puts(0, line
++, buf
);
890 category
= (control
>> 17) & 127;
902 snprintf(buf
, sizeof(buf
), "Category: 0x%02x (%s)", category
, s
);
903 lcd_puts(0, line
++, buf
);
905 x
= (control
>> 16) & 1;
907 if(((category
& 0x70) == 0x10) ||
908 ((category
& 0x70) == 0x40) ||
909 ((category
& 0x78) == 0x38))
911 generation
= !generation
;
913 snprintf(buf
, sizeof(buf
), "Generation: %d (%s)",
914 x
, generation
?"Original":"No ind.");
915 lcd_puts(0, line
++, buf
);
917 x
= (control
>> 12) & 15;
918 snprintf(buf
, sizeof(buf
), "Source: %d", x
);
919 lcd_puts(0, line
++, buf
);
921 x
= (control
>> 8) & 15;
937 snprintf(buf
, sizeof(buf
), "Channel: %d (%s)", x
, s
);
938 lcd_puts(0, line
++, buf
);
940 x
= (control
>> 4) & 15;
953 snprintf(buf
, sizeof(buf
), "Frequency: %d (%s)", x
, s
);
954 lcd_puts(0, line
++, buf
);
956 x
= (control
>> 2) & 3;
957 snprintf(buf
, sizeof(buf
), "Clock accuracy: %d", x
);
958 lcd_puts(0, line
++, buf
);
962 snprintf(buf
, sizeof(buf
), "Measured freq: %ldHz",
963 spdif_measure_frequency());
964 lcd_puts(0, line
++, buf
);
969 if (action_userabort(HZ
/10))
973 spdif_set_output_source(spdif_source
IF_SPDIF_POWER_(, spdif_src_on
));
975 #ifdef HAVE_SPDIF_POWER
976 spdif_power_enable(global_settings
.spdif_enable
);
981 #endif /* CPU_COLDFIRE */
984 #ifdef HAVE_LCD_BITMAP
985 /* button definitions */
986 #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
987 (CONFIG_KEYPAD == IRIVER_H300_PAD)
988 # define DEBUG_CANCEL BUTTON_OFF
990 #elif CONFIG_KEYPAD == RECORDER_PAD
991 # define DEBUG_CANCEL BUTTON_OFF
993 #elif CONFIG_KEYPAD == ONDIO_PAD
994 # define DEBUG_CANCEL BUTTON_MENU
996 #elif (CONFIG_KEYPAD == IPOD_1G2G_PAD) || \
997 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
998 (CONFIG_KEYPAD == IPOD_4G_PAD)
999 # define DEBUG_CANCEL BUTTON_MENU
1001 #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
1002 # define DEBUG_CANCEL BUTTON_PLAY
1004 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
1005 # define DEBUG_CANCEL BUTTON_REC
1007 #elif CONFIG_KEYPAD == GIGABEAT_PAD
1008 # define DEBUG_CANCEL BUTTON_A
1010 #elif CONFIG_KEYPAD == IRIVER_H10_PAD
1011 # define DEBUG_CANCEL BUTTON_REW
1013 #elif CONFIG_KEYPAD == SANSA_E200_PAD
1014 # define DEBUG_CANCEL BUTTON_LEFT
1015 #endif /* key definitios */
1018 bool dbg_ports(void)
1020 #if CONFIG_CPU == SH7034
1021 unsigned short porta
;
1022 unsigned short portb
;
1023 unsigned char portc
;
1025 int adc_battery_voltage
, adc_battery_level
;
1027 lcd_setfont(FONT_SYSFIXED
);
1028 lcd_setmargins(0, 0);
1029 lcd_clear_display();
1037 snprintf(buf
, 32, "PADR: %04x", porta
);
1038 lcd_puts(0, 0, buf
);
1039 snprintf(buf
, 32, "PBDR: %04x", portb
);
1040 lcd_puts(0, 1, buf
);
1042 snprintf(buf
, 32, "AN0: %03x AN4: %03x", adc_read(0), adc_read(4));
1043 lcd_puts(0, 2, buf
);
1044 snprintf(buf
, 32, "AN1: %03x AN5: %03x", adc_read(1), adc_read(5));
1045 lcd_puts(0, 3, buf
);
1046 snprintf(buf
, 32, "AN2: %03x AN6: %03x", adc_read(2), adc_read(6));
1047 lcd_puts(0, 4, buf
);
1048 snprintf(buf
, 32, "AN3: %03x AN7: %03x", adc_read(3), adc_read(7));
1049 lcd_puts(0, 5, buf
);
1051 battery_read_info(&adc_battery_voltage
, &adc_battery_level
);
1052 snprintf(buf
, 32, "Batt: %d.%03dV %d%% ", adc_battery_voltage
/ 1000,
1053 adc_battery_voltage
% 1000, adc_battery_level
);
1054 lcd_puts(0, 6, buf
);
1057 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1060 #elif defined(CPU_COLDFIRE)
1061 unsigned int gpio_out
;
1062 unsigned int gpio1_out
;
1063 unsigned int gpio_read
;
1064 unsigned int gpio1_read
;
1065 unsigned int gpio_function
;
1066 unsigned int gpio1_function
;
1067 unsigned int gpio_enable
;
1068 unsigned int gpio1_enable
;
1069 int adc_buttons
, adc_remote
;
1070 int adc_battery_voltage
, adc_battery_level
;
1074 lcd_setmargins(0, 0);
1075 lcd_clear_display();
1076 lcd_setfont(FONT_SYSFIXED
);
1081 gpio_read
= GPIO_READ
;
1082 gpio1_read
= GPIO1_READ
;
1083 gpio_out
= GPIO_OUT
;
1084 gpio1_out
= GPIO1_OUT
;
1085 gpio_function
= GPIO_FUNCTION
;
1086 gpio1_function
= GPIO1_FUNCTION
;
1087 gpio_enable
= GPIO_ENABLE
;
1088 gpio1_enable
= GPIO1_ENABLE
;
1090 snprintf(buf
, sizeof(buf
), "GPIO_READ: %08x", gpio_read
);
1091 lcd_puts(0, line
++, buf
);
1092 snprintf(buf
, sizeof(buf
), "GPIO_OUT: %08x", gpio_out
);
1093 lcd_puts(0, line
++, buf
);
1094 snprintf(buf
, sizeof(buf
), "GPIO_FUNCTION: %08x", gpio_function
);
1095 lcd_puts(0, line
++, buf
);
1096 snprintf(buf
, sizeof(buf
), "GPIO_ENABLE: %08x", gpio_enable
);
1097 lcd_puts(0, line
++, buf
);
1099 snprintf(buf
, sizeof(buf
), "GPIO1_READ: %08x", gpio1_read
);
1100 lcd_puts(0, line
++, buf
);
1101 snprintf(buf
, sizeof(buf
), "GPIO1_OUT: %08x", gpio1_out
);
1102 lcd_puts(0, line
++, buf
);
1103 snprintf(buf
, sizeof(buf
), "GPIO1_FUNCTION: %08x", gpio1_function
);
1104 lcd_puts(0, line
++, buf
);
1105 snprintf(buf
, sizeof(buf
), "GPIO1_ENABLE: %08x", gpio1_enable
);
1106 lcd_puts(0, line
++, buf
);
1108 adc_buttons
= adc_read(ADC_BUTTONS
);
1109 adc_remote
= adc_read(ADC_REMOTE
);
1110 battery_read_info(&adc_battery_voltage
, &adc_battery_level
);
1111 #if defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IRIVER_H300_SERIES)
1112 snprintf(buf
, sizeof(buf
), "ADC_BUTTONS (%c): %02x",
1113 button_scan_enabled() ? '+' : '-', adc_buttons
);
1115 snprintf(buf
, sizeof(buf
), "ADC_BUTTONS: %02x", adc_buttons
);
1117 lcd_puts(0, line
++, buf
);
1118 #if defined(IAUDIO_X5) || defined(IAUDIO_M5)
1119 snprintf(buf
, sizeof(buf
), "ADC_REMOTE (%c): %02x",
1120 remote_detect() ? '+' : '-', adc_remote
);
1122 snprintf(buf
, sizeof(buf
), "ADC_REMOTE: %02x", adc_remote
);
1124 lcd_puts(0, line
++, buf
);
1125 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1126 snprintf(buf
, sizeof(buf
), "ADC_REMOTEDETECT: %02x",
1127 adc_read(ADC_REMOTEDETECT
));
1128 lcd_puts(0, line
++, buf
);
1131 snprintf(buf
, 32, "Batt: %d.%03dV %d%% ", adc_battery_voltage
/ 1000,
1132 adc_battery_voltage
% 1000, adc_battery_level
);
1133 lcd_puts(0, line
++, buf
);
1135 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1136 snprintf(buf
, sizeof(buf
), "remotetype: %d", remote_type());
1137 lcd_puts(0, line
++, buf
);
1141 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1145 #elif defined(CPU_PP502x)
1147 unsigned int gpio_a
, gpio_b
, gpio_c
, gpio_d
;
1148 unsigned int gpio_e
, gpio_f
, gpio_g
, gpio_h
;
1149 unsigned int gpio_i
, gpio_j
, gpio_k
, gpio_l
;
1154 lcd_setmargins(0, 0);
1155 lcd_clear_display();
1156 lcd_setfont(FONT_SYSFIXED
);
1160 gpio_a
= GPIOA_INPUT_VAL
;
1161 gpio_b
= GPIOB_INPUT_VAL
;
1162 gpio_c
= GPIOC_INPUT_VAL
;
1164 gpio_g
= GPIOG_INPUT_VAL
;
1165 gpio_h
= GPIOH_INPUT_VAL
;
1166 gpio_i
= GPIOI_INPUT_VAL
;
1169 snprintf(buf
, sizeof(buf
), "GPIO_A: %02x GPIO_G: %02x", gpio_a
, gpio_g
);
1170 lcd_puts(0, line
++, buf
);
1171 snprintf(buf
, sizeof(buf
), "GPIO_B: %02x GPIO_H: %02x", gpio_b
, gpio_h
);
1172 lcd_puts(0, line
++, buf
);
1173 snprintf(buf
, sizeof(buf
), "GPIO_C: %02x GPIO_I: %02x", gpio_c
, gpio_i
);
1174 lcd_puts(0, line
++, buf
);
1176 gpio_d
= GPIOD_INPUT_VAL
;
1177 gpio_e
= GPIOE_INPUT_VAL
;
1178 gpio_f
= GPIOF_INPUT_VAL
;
1180 gpio_j
= GPIOJ_INPUT_VAL
;
1181 gpio_k
= GPIOK_INPUT_VAL
;
1182 gpio_l
= GPIOL_INPUT_VAL
;
1184 snprintf(buf
, sizeof(buf
), "GPIO_D: %02x GPIO_J: %02x", gpio_d
, gpio_j
);
1185 lcd_puts(0, line
++, buf
);
1186 snprintf(buf
, sizeof(buf
), "GPIO_E: %02x GPIO_K: %02x", gpio_e
, gpio_k
);
1187 lcd_puts(0, line
++, buf
);
1188 snprintf(buf
, sizeof(buf
), "GPIO_F: %02x GPIO_L: %02x", gpio_f
, gpio_l
);
1189 lcd_puts(0, line
++, buf
);
1192 snprintf(buf
, sizeof(buf
), "DEV_EN: %08lx", DEV_EN
);
1193 lcd_puts(0, line
++, buf
);
1194 snprintf(buf
, sizeof(buf
), "CLOCK_SRC: %08lx", CLOCK_SOURCE
);
1195 lcd_puts(0, line
++, buf
);
1196 snprintf(buf
, sizeof(buf
), "CLCD_CLK_SRC: %08lx", CLCD_CLOCK_SRC
);
1197 lcd_puts(0, line
++, buf
);
1198 snprintf(buf
, sizeof(buf
), "PLL_CONTROL: %08lx", PLL_CONTROL
);
1199 lcd_puts(0, line
++, buf
);
1200 snprintf(buf
, sizeof(buf
), "PLL_STATUS: %08lx", PLL_STATUS
);
1201 lcd_puts(0, line
++, buf
);
1202 snprintf(buf
, sizeof(buf
), "DEV_TIMING1: %08lx", DEV_TIMING1
);
1203 lcd_puts(0, line
++, buf
);
1205 #if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
1207 snprintf(buf
, sizeof(buf
), "BATT: %03x UNK1: %03x", adc_read(ADC_BATTERY
),
1208 adc_read(ADC_UNKNOWN_1
));
1209 lcd_puts(0, line
++, buf
);
1210 snprintf(buf
, sizeof(buf
), "REM: %03x PAD: %03x", adc_read(ADC_REMOTE
),
1211 adc_read(ADC_SCROLLPAD
));
1212 lcd_puts(0, line
++, buf
);
1213 #elif defined(SANSA_E200)
1215 snprintf(buf
, sizeof(buf
), "ADC_BVDD: %02x", adc_read(ADC_BVDD
));
1216 lcd_puts(0, line
++, buf
);
1217 snprintf(buf
, sizeof(buf
), "ADC_RTCSUP: %02x", adc_read(ADC_RTCSUP
));
1218 lcd_puts(0, line
++, buf
);
1219 snprintf(buf
, sizeof(buf
), "ADC_UVDD: %02x", adc_read(ADC_UVDD
));
1220 lcd_puts(0, line
++, buf
);
1221 snprintf(buf
, sizeof(buf
), "ADC_CHG_IN: %02x", adc_read(ADC_CHG_IN
));
1222 lcd_puts(0, line
++, buf
);
1223 snprintf(buf
, sizeof(buf
), "ADC_CVDD: %02x", adc_read(ADC_CVDD
));
1224 lcd_puts(0, line
++, buf
);
1225 snprintf(buf
, sizeof(buf
), "ADC_BATTEMP: %02x", adc_read(ADC_BATTEMP
));
1226 lcd_puts(0, line
++, buf
);
1227 snprintf(buf
, sizeof(buf
), "ADC_MICSUP1: %02x", adc_read(ADC_MICSUP1
));
1228 lcd_puts(0, line
++, buf
);
1229 snprintf(buf
, sizeof(buf
), "ADC_MICSUP2: %02x", adc_read(ADC_MICSUP2
));
1230 lcd_puts(0, line
++, buf
);
1231 snprintf(buf
, sizeof(buf
), "ADC_VBE1: %02x", adc_read(ADC_VBE1
));
1232 lcd_puts(0, line
++, buf
);
1233 snprintf(buf
, sizeof(buf
), "ADC_VBE2: %02x", adc_read(ADC_VBE2
));
1234 lcd_puts(0, line
++, buf
);
1235 snprintf(buf
, sizeof(buf
), "ADC_I_MICSUP1: %02x", adc_read(ADC_I_MICSUP1
));
1236 lcd_puts(0, line
++, buf
);
1237 snprintf(buf
, sizeof(buf
), "ADC_I_MICSUP2: %02x", adc_read(ADC_I_MICSUP2
));
1238 lcd_puts(0, line
++, buf
);
1239 snprintf(buf
, sizeof(buf
), "ADC_VBAT: %02x", adc_read(ADC_VBAT
));
1240 lcd_puts(0, line
++, buf
);
1243 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1247 #elif CONFIG_CPU == PP5002
1248 unsigned int gpio_a
, gpio_b
, gpio_c
, gpio_d
;
1253 lcd_setmargins(0, 0);
1254 lcd_clear_display();
1255 lcd_setfont(FONT_SYSFIXED
);
1259 gpio_a
= GPIOA_INPUT_VAL
;
1260 gpio_b
= GPIOB_INPUT_VAL
;
1261 gpio_c
= GPIOC_INPUT_VAL
;
1262 gpio_d
= GPIOD_INPUT_VAL
;
1265 snprintf(buf
, sizeof(buf
), "GPIO_A: %02x GPIO_B: %02x", gpio_a
, gpio_b
);
1266 lcd_puts(0, line
++, buf
);
1267 snprintf(buf
, sizeof(buf
), "GPIO_C: %02x GPIO_D: %02x", gpio_c
, gpio_d
);
1268 lcd_puts(0, line
++, buf
);
1270 snprintf(buf
, sizeof(buf
), "DEV_EN: %08lx", DEV_EN
);
1271 lcd_puts(0, line
++, buf
);
1272 snprintf(buf
, sizeof(buf
), "CLOCK_ENABLE: %08lx", CLOCK_ENABLE
);
1273 lcd_puts(0, line
++, buf
);
1274 snprintf(buf
, sizeof(buf
), "CLOCK_SOURCE: %08lx", CLOCK_SOURCE
);
1275 lcd_puts(0, line
++, buf
);
1276 snprintf(buf
, sizeof(buf
), "PLL_CONTROL: %08lx", PLL_CONTROL
);
1277 lcd_puts(0, line
++, buf
);
1278 snprintf(buf
, sizeof(buf
), "PLL_DIV: %08lx", PLL_DIV
);
1279 lcd_puts(0, line
++, buf
);
1280 snprintf(buf
, sizeof(buf
), "PLL_MULT: %08lx", PLL_MULT
);
1281 lcd_puts(0, line
++, buf
);
1282 snprintf(buf
, sizeof(buf
), "TIMING1_CTL: %08lx", TIMING1_CTL
);
1283 lcd_puts(0, line
++, buf
);
1284 snprintf(buf
, sizeof(buf
), "TIMING2_CTL: %08lx", TIMING2_CTL
);
1285 lcd_puts(0, line
++, buf
);
1288 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1291 #elif CONFIG_CPU == S3C2440
1295 lcd_setmargins(0, 0);
1296 lcd_clear_display();
1297 lcd_setfont(FONT_SYSFIXED
);
1302 snprintf(buf
, sizeof(buf
), "[Ports and Registers]"); lcd_puts(0, line
++, buf
);
1304 snprintf(buf
, sizeof(buf
), "GPACON: %08x GPBCON: %08x", GPACON
, GPBCON
); lcd_puts(0, line
++, buf
);
1305 snprintf(buf
, sizeof(buf
), "GPADAT: %08x GPBDAT: %08x", GPADAT
, GPBDAT
); lcd_puts(0, line
++, buf
);
1306 snprintf(buf
, sizeof(buf
), "GPAUP: %08x GPBUP: %08x", 0, GPBUP
); lcd_puts(0, line
++, buf
);
1307 snprintf(buf
, sizeof(buf
), "GPCCON: %08x GPDCON: %08x", GPCCON
, GPDCON
); lcd_puts(0, line
++, buf
);
1308 snprintf(buf
, sizeof(buf
), "GPCDAT: %08x GPDDAT: %08x", GPCDAT
, GPDDAT
); lcd_puts(0, line
++, buf
);
1309 snprintf(buf
, sizeof(buf
), "GPCUP: %08x GPDUP: %08x", GPCUP
, GPDUP
); lcd_puts(0, line
++, buf
);
1311 snprintf(buf
, sizeof(buf
), "GPCCON: %08x GPDCON: %08x", GPCCON
, GPDCON
); lcd_puts(0, line
++, buf
);
1312 snprintf(buf
, sizeof(buf
), "GPCDAT: %08x GPDDAT: %08x", GPCDAT
, GPDDAT
); lcd_puts(0, line
++, buf
);
1313 snprintf(buf
, sizeof(buf
), "GPCUP: %08x GPDUP: %08x", GPCUP
, GPDUP
); lcd_puts(0, line
++, buf
);
1315 snprintf(buf
, sizeof(buf
), "GPECON: %08x GPFCON: %08x", GPECON
, GPFCON
); lcd_puts(0, line
++, buf
);
1316 snprintf(buf
, sizeof(buf
), "GPEDAT: %08x GPFDAT: %08x", GPEDAT
, GPFDAT
); lcd_puts(0, line
++, buf
);
1317 snprintf(buf
, sizeof(buf
), "GPEUP: %08x GPFUP: %08x", GPEUP
, GPFUP
); lcd_puts(0, line
++, buf
);
1319 snprintf(buf
, sizeof(buf
), "GPGCON: %08x GPHCON: %08x", GPGCON
, GPHCON
); lcd_puts(0, line
++, buf
);
1320 snprintf(buf
, sizeof(buf
), "GPGDAT: %08x GPHDAT: %08x", GPGDAT
, GPHDAT
); lcd_puts(0, line
++, buf
);
1321 snprintf(buf
, sizeof(buf
), "GPGUP: %08x GPHUP: %08x", GPGUP
, GPHUP
); lcd_puts(0, line
++, buf
);
1323 snprintf(buf
, sizeof(buf
), "GPJCON: %08x", GPJCON
); lcd_puts(0, line
++, buf
);
1324 snprintf(buf
, sizeof(buf
), "GPJDAT: %08x", GPJDAT
); lcd_puts(0, line
++, buf
);
1325 snprintf(buf
, sizeof(buf
), "GPJUP: %08x", GPJUP
); lcd_puts(0, line
++, buf
);
1329 snprintf(buf
, sizeof(buf
), "SRCPND: %08x INTMOD: %08x", SRCPND
, INTMOD
); lcd_puts(0, line
++, buf
);
1330 snprintf(buf
, sizeof(buf
), "INTMSK: %08x INTPND: %08x", INTMSK
, INTPND
); lcd_puts(0, line
++, buf
);
1331 snprintf(buf
, sizeof(buf
), "CLKCON: %08x CLKSLOW: %08x", CLKCON
, CLKSLOW
); lcd_puts(0, line
++, buf
);
1332 snprintf(buf
, sizeof(buf
), "MPLLCON: %08x UPLLCON: %08x", MPLLCON
, UPLLCON
); lcd_puts(0, line
++, buf
);
1333 snprintf(buf
, sizeof(buf
), "CLKDIVN: %08x", CLKDIVN
); lcd_puts(0, line
++, buf
);
1336 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1342 #else /* !HAVE_LCD_BITMAP */
1343 bool dbg_ports(void)
1345 unsigned short porta
;
1346 unsigned short portb
;
1347 unsigned char portc
;
1350 int adc_battery_voltage
;
1353 lcd_clear_display();
1364 snprintf(buf
, 32, "PADR: %04x", porta
);
1367 snprintf(buf
, 32, "PBDR: %04x", portb
);
1370 snprintf(buf
, 32, "AN0: %03x", adc_read(0));
1373 snprintf(buf
, 32, "AN1: %03x", adc_read(1));
1376 snprintf(buf
, 32, "AN2: %03x", adc_read(2));
1379 snprintf(buf
, 32, "AN3: %03x", adc_read(3));
1382 snprintf(buf
, 32, "AN4: %03x", adc_read(4));
1385 snprintf(buf
, 32, "AN5: %03x", adc_read(5));
1388 snprintf(buf
, 32, "AN6: %03x", adc_read(6));
1391 snprintf(buf
, 32, "AN7: %03x", adc_read(7));
1395 lcd_puts(0, 0, buf
);
1397 battery_read_info(&adc_battery_voltage
, NULL
);
1398 snprintf(buf
, 32, "Batt: %d.%03dV", adc_battery_voltage
/ 1000,
1399 adc_battery_voltage
% 1000);
1400 lcd_puts(0, 1, buf
);
1403 button
= get_action(CONTEXT_SETTINGS
,HZ
/5);
1407 case ACTION_STD_CANCEL
:
1410 case ACTION_SETTINGS_DEC
:
1416 case ACTION_SETTINGS_INC
:
1425 #endif /* !HAVE_LCD_BITMAP */
1426 #endif /* !SIMULATOR */
1428 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
1429 static bool dbg_cpufreq(void)
1435 #ifdef HAVE_LCD_BITMAP
1436 lcd_setmargins(0, 0);
1437 lcd_setfont(FONT_SYSFIXED
);
1439 lcd_clear_display();
1445 snprintf(buf
, sizeof(buf
), "Frequency: %ld", FREQ
);
1446 lcd_puts(0, line
++, buf
);
1448 snprintf(buf
, sizeof(buf
), "boost_counter: %d", get_cpu_boost_counter());
1449 lcd_puts(0, line
++, buf
);
1452 button
= get_action(CONTEXT_STD
,HZ
/10);
1456 case ACTION_STD_PREV
:
1460 case ACTION_STD_NEXT
:
1465 while (get_cpu_boost_counter() > 0)
1467 set_cpu_frequency(CPUFREQ_DEFAULT
);
1470 case ACTION_STD_CANCEL
:
1477 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
1480 #ifdef HAVE_LCD_BITMAP
1482 * view_battery() shows a automatically scaled graph of the battery voltage
1483 * over time. Usable for estimating battery life / charging rate.
1484 * The power_history array is updated in power_thread of powermgmt.c.
1487 #define BAT_LAST_VAL MIN(LCD_WIDTH, POWER_HISTORY_LEN)
1488 #define BAT_YSPACE (LCD_HEIGHT - 20)
1490 static bool view_battery(void)
1494 unsigned short maxv
, minv
;
1497 lcd_setmargins(0, 0);
1498 lcd_setfont(FONT_SYSFIXED
);
1502 lcd_clear_display();
1504 case 0: /* voltage history graph */
1505 /* Find maximum and minimum voltage for scaling */
1506 minv
= power_history
[0];
1508 for (i
= 1; i
< BAT_LAST_VAL
&& power_history
[i
]; i
++) {
1509 if (power_history
[i
] > maxv
)
1510 maxv
= power_history
[i
];
1511 if (power_history
[i
] < minv
)
1512 minv
= power_history
[i
];
1515 snprintf(buf
, 30, "Battery %d.%03d", power_history
[0] / 1000,
1516 power_history
[0] % 1000);
1517 lcd_puts(0, 0, buf
);
1518 snprintf(buf
, 30, "scale %d.%03d-%d.%03dV",
1519 minv
/ 1000, minv
% 1000, maxv
/ 1000, maxv
% 1000);
1520 lcd_puts(0, 1, buf
);
1523 for (i
= BAT_LAST_VAL
- 1; i
>= 0; i
--) {
1524 y
= (power_history
[i
] - minv
) * BAT_YSPACE
/ (maxv
- minv
);
1525 lcd_set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
1526 lcd_vline(x
, LCD_HEIGHT
-1, 20);
1527 lcd_set_drawmode(DRMODE_SOLID
);
1528 lcd_vline(x
, LCD_HEIGHT
-1,
1529 MIN(MAX(LCD_HEIGHT
-1 - y
, 20), LCD_HEIGHT
-1));
1535 case 1: /* status: */
1536 lcd_puts(0, 0, "Power status:");
1538 battery_read_info(&y
, NULL
);
1539 snprintf(buf
, 30, "Battery: %d.%03d V", y
/ 1000, y
% 1000);
1540 lcd_puts(0, 1, buf
);
1541 #ifdef ADC_EXT_POWER
1542 y
= (adc_read(ADC_EXT_POWER
) * EXT_SCALE_FACTOR
) / 1000;
1543 snprintf(buf
, 30, "External: %d.%03d V", y
/ 1000, y
% 1000);
1544 lcd_puts(0, 2, buf
);
1547 #if CONFIG_CHARGING == CHARGING_CONTROL
1548 snprintf(buf
, 30, "Chgr: %s %s",
1549 charger_inserted() ? "present" : "absent",
1550 charger_enabled
? "on" : "off");
1551 lcd_puts(0, 3, buf
);
1552 snprintf(buf
, 30, "short delta: %d", short_delta
);
1553 lcd_puts(0, 5, buf
);
1554 snprintf(buf
, 30, "long delta: %d", long_delta
);
1555 lcd_puts(0, 6, buf
);
1556 lcd_puts(0, 7, power_message
);
1557 snprintf(buf
, 30, "USB Inserted: %s",
1558 usb_inserted() ? "yes" : "no");
1559 lcd_puts(0, 8, buf
);
1560 #if defined IRIVER_H300_SERIES
1561 snprintf(buf
, 30, "USB Charging Enabled: %s",
1562 usb_charging_enabled() ? "yes" : "no");
1563 lcd_puts(0, 9, buf
);
1565 #else /* CONFIG_CHARGING != CHARGING_CONTROL */
1566 #if defined IPOD_NANO || defined IPOD_VIDEO
1567 int usb_pwr
= (GPIOL_INPUT_VAL
& 0x10)?true:false;
1568 int ext_pwr
= (GPIOL_INPUT_VAL
& 0x08)?false:true;
1569 int dock
= (GPIOA_INPUT_VAL
& 0x10)?true:false;
1570 int charging
= (GPIOB_INPUT_VAL
& 0x01)?false:true;
1571 int headphone
= (GPIOA_INPUT_VAL
& 0x80)?true:false;
1573 snprintf(buf
, 30, "USB pwr: %s",
1574 usb_pwr
? "present" : "absent");
1575 lcd_puts(0, 3, buf
);
1576 snprintf(buf
, 30, "EXT pwr: %s",
1577 ext_pwr
? "present" : "absent");
1578 lcd_puts(0, 4, buf
);
1579 snprintf(buf
, 30, "Battery: %s",
1580 charging
? "charging" : (usb_pwr
||ext_pwr
) ? "charged" : "discharging");
1581 lcd_puts(0, 5, buf
);
1582 snprintf(buf
, 30, "Dock mode: %s",
1583 dock
? "enabled" : "disabled");
1584 lcd_puts(0, 6, buf
);
1585 snprintf(buf
, 30, "Headphone: %s",
1586 headphone
? "connected" : "disconnected");
1587 lcd_puts(0, 7, buf
);
1589 snprintf(buf
, 30, "Charger: %s",
1590 charger_inserted() ? "present" : "absent");
1591 lcd_puts(0, 3, buf
);
1593 #endif /* CONFIG_CHARGING != CHARGING_CONTROL */
1594 #endif /* CONFIG_CHARGING */
1597 case 2: /* voltage deltas: */
1598 lcd_puts(0, 0, "Voltage deltas:");
1600 for (i
= 0; i
<= 6; i
++) {
1601 y
= power_history
[i
] - power_history
[i
+1];
1602 snprintf(buf
, 30, "-%d min: %s%d.%03d V", i
,
1603 (y
< 0) ? "-" : "", ((y
< 0) ? y
* -1 : y
) / 1000,
1604 ((y
< 0) ? y
* -1 : y
) % 1000);
1605 lcd_puts(0, i
+1, buf
);
1609 case 3: /* remaining time estimation: */
1611 #if CONFIG_CHARGING == CHARGING_CONTROL
1612 snprintf(buf
, 30, "charge_state: %d", charge_state
);
1613 lcd_puts(0, 0, buf
);
1615 snprintf(buf
, 30, "Cycle time: %d m", powermgmt_last_cycle_startstop_min
);
1616 lcd_puts(0, 1, buf
);
1618 snprintf(buf
, 30, "Lvl@cyc st: %d%%", powermgmt_last_cycle_level
);
1619 lcd_puts(0, 2, buf
);
1621 snprintf(buf
, 30, "P=%2d I=%2d", pid_p
, pid_i
);
1622 lcd_puts(0, 3, buf
);
1624 snprintf(buf
, 30, "Trickle sec: %d/60", trickle_sec
);
1625 lcd_puts(0, 4, buf
);
1626 #endif /* CONFIG_CHARGING == CHARGING_CONTROL */
1628 snprintf(buf
, 30, "Last PwrHist: %d.%03dV",
1629 power_history
[0] / 1000,
1630 power_history
[0] % 1000);
1631 lcd_puts(0, 5, buf
);
1633 snprintf(buf
, 30, "battery level: %d%%", battery_level());
1634 lcd_puts(0, 6, buf
);
1636 snprintf(buf
, 30, "Est. remain: %d m", battery_time());
1637 lcd_puts(0, 7, buf
);
1643 switch(get_action(CONTEXT_SETTINGS
,HZ
/2))
1645 case ACTION_SETTINGS_DEC
:
1650 case ACTION_SETTINGS_INC
:
1655 case ACTION_STD_CANCEL
:
1662 #endif /* HAVE_LCD_BITMAP */
1666 #if defined(HAVE_MMC) || defined(HAVE_HOTSWAP)
1667 #if defined(HAVE_MMC)
1668 #define CARDTYPE "MMC"
1670 #define CARDTYPE "microSD"
1672 static int cardinfo_callback(int btn
, struct action_callback_info
*info
)
1675 unsigned char card_name
[7];
1676 unsigned char pbuf
[32];
1677 static const unsigned char i_vmin
[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
1678 static const unsigned char i_vmax
[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
1679 static const unsigned char *kbit_units
[] = { "kBit/s", "MBit/s", "GBit/s" };
1680 static const unsigned char *nsec_units
[] = { "ns", "µs", "ms" };
1681 static const char *spec_vers
[] = { "1.0-1.2", "1.4", "2.0-2.2",
1682 "3.1-3.31", "4.0" };
1683 if ((btn
== ACTION_STD_OK
) || (btn
== SYS_FS_CHANGED
) || (btn
== ACTION_REDRAW
))
1685 if (btn
== ACTION_STD_OK
)
1686 info
->cbdata
^= 0x1; /* change cards */
1688 dbg_listmessage_setlines(0);
1690 card
= card_get_info(info
->cbdata
);
1692 if (card
->initialized
> 0)
1694 card_name
[6] = '\0';
1695 strncpy(card_name
, ((unsigned char*)card
->cid
) + 3, 6);
1696 dbg_listmessage_addline(
1697 "%s Rev %d.%d", card_name
,
1698 (int) card_extract_bits(card
->cid
, 72, 4),
1699 (int) card_extract_bits(card
->cid
, 76, 4));
1700 dbg_listmessage_addline(
1702 (int) card_extract_bits(card
->cid
, 112, 4),
1703 (int) card_extract_bits(card
->cid
, 116, 4) + 1997);
1704 dbg_listmessage_addline(
1706 card_extract_bits(card
->cid
, 80, 32));
1707 dbg_listmessage_addline(
1709 (int) card_extract_bits(card
->cid
, 0, 8),
1710 (int) card_extract_bits(card
->cid
, 8, 16));
1711 int temp
= card_extract_bits(card
->csd
, 2, 4);
1712 dbg_listmessage_addline(
1713 CARDTYPE
" v%s", temp
< 5 ?
1714 spec_vers
[temp
] : "?.?");
1715 dbg_listmessage_addline(
1716 "Blocks: 0x%06lx", card
->numblocks
);
1717 dbg_listmessage_addline(
1718 "Blksz.: %d P:%c%c", card
->blocksize
,
1719 card_extract_bits(card
->csd
, 48, 1) ? 'R' : '-',
1720 card_extract_bits(card
->csd
, 106, 1) ? 'W' : '-');
1721 output_dyn_value(pbuf
, sizeof pbuf
, card
->speed
/ 1000,
1723 dbg_listmessage_addline(
1725 output_dyn_value(pbuf
, sizeof pbuf
, card
->tsac
,
1727 dbg_listmessage_addline(
1729 dbg_listmessage_addline(
1730 "Nsac: %d clk", card
->nsac
);
1731 dbg_listmessage_addline(
1732 "R2W: *%d", card
->r2w_factor
);
1733 dbg_listmessage_addline(
1735 i_vmin
[card_extract_bits(card
->csd
, 66, 3)],
1736 i_vmax
[card_extract_bits(card
->csd
, 69, 3)]);
1737 dbg_listmessage_addline(
1739 i_vmin
[card_extract_bits(card
->csd
, 72, 3)],
1740 i_vmax
[card_extract_bits(card
->csd
, 75, 3)]);
1742 else if (card
->initialized
== 0)
1744 dbg_listmessage_addline("Not Found!");
1747 else /* card->initialized < 0 */
1749 dbg_listmessage_addline("Init Error! (%d)", card
->initialized
);
1752 snprintf(info
->title
, 16, "[" CARDTYPE
" %d]", (int)info
->cbdata
);
1753 gui_synclist_set_nb_items(info
->lists
, dbg_listmessage_getlines());
1754 gui_synclist_select_item(info
->lists
, 0);
1755 btn
= ACTION_REDRAW
;
1759 static bool dbg_disk_info(void)
1762 struct action_callback_info info
;
1763 info
.title
= listtitle
;
1765 info
.selection_size
= 1;
1766 info
.action_callback
= cardinfo_callback
;
1767 info
.dbg_getname
= dbg_listmessage_getname
;
1772 #else /* !defined(HAVE_MMC) && !defined(HAVE_HOTSWAP) */
1773 static int disk_callback(int btn
, struct action_callback_info
*info
)
1777 unsigned short* identify_info
= ata_get_identify();
1778 bool timing_info_present
= false;
1781 dbg_listmessage_setlines(0);
1783 for (i
=0; i
< 20; i
++)
1784 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+27]);
1786 /* kill trailing space */
1787 for (i
=39; i
&& buf
[i
]==' '; i
--)
1789 dbg_listmessage_addline(
1791 for (i
=0; i
< 4; i
++)
1792 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+23]);
1794 dbg_listmessage_addline(
1795 "Firmware: %s", buf
);
1796 snprintf(buf
, sizeof buf
, "%ld MB",
1797 ((unsigned long)identify_info
[61] << 16 |
1798 (unsigned long)identify_info
[60]) / 2048 );
1799 dbg_listmessage_addline(
1802 fat_size( IF_MV2(0,) NULL
, &free
);
1803 dbg_listmessage_addline(
1804 "Free: %ld MB", free
/ 1024);
1805 dbg_listmessage_addline(
1806 "Spinup time: %d ms", ata_spinup_time
* (1000/HZ
));
1807 i
= identify_info
[83] & (1<<3);
1808 dbg_listmessage_addline(
1809 "Power mgmt: %s", i
? "enabled" : "unsupported");
1810 i
= identify_info
[83] & (1<<9);
1811 dbg_listmessage_addline(
1812 "Noise mgmt: %s", i
? "enabled" : "unsupported");
1813 i
= identify_info
[82] & (1<<6);
1814 dbg_listmessage_addline(
1815 "Read-ahead: %s", i
? "enabled" : "unsupported");
1816 timing_info_present
= identify_info
[53] & (1<<1);
1817 if(timing_info_present
) {
1818 char pio3
[2], pio4
[2];pio3
[1] = 0;
1820 pio3
[0] = (identify_info
[64] & (1<<0)) ? '3' : 0;
1821 pio4
[0] = (identify_info
[64] & (1<<1)) ? '4' : 0;
1822 dbg_listmessage_addline(
1823 "PIO modes: 0 1 2 %s %s", pio3
, pio4
);
1826 dbg_listmessage_addline(
1827 "No PIO mode info");
1829 timing_info_present
= identify_info
[53] & (1<<1);
1830 if(timing_info_present
) {
1831 dbg_listmessage_addline(
1832 "Cycle times %dns/%dns",
1834 identify_info
[68] );
1836 dbg_listmessage_addline(
1839 timing_info_present
= identify_info
[53] & (1<<1);
1840 if(timing_info_present
) {
1841 i
= identify_info
[49] & (1<<11);
1842 dbg_listmessage_addline(
1843 "IORDY support: %s", i
? "yes" : "no");
1844 i
= identify_info
[49] & (1<<10);
1845 dbg_listmessage_addline(
1846 "IORDY disable: %s", i
? "yes" : "no");
1848 dbg_listmessage_addline(
1851 dbg_listmessage_addline(
1852 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
1853 gui_synclist_set_nb_items(info
->lists
, dbg_listmessage_getlines());
1856 static bool dbg_disk_info(void)
1858 struct action_callback_info info
;
1859 info
.title
= "Disk Info";
1861 info
.selection_size
= 1;
1862 info
.action_callback
= disk_callback
;
1863 info
.dbg_getname
= dbg_listmessage_getname
;
1867 #endif /* !defined(HAVE_MMC) && !defined(HAVE_HOTSWAP) */
1868 #endif /* !SIMULATOR */
1870 #ifdef HAVE_DIRCACHE
1871 static int dircache_callback(int btn
, struct action_callback_info
*info
)
1873 (void)btn
; (void)info
;
1874 dbg_listmessage_setlines(0);
1875 dbg_listmessage_addline("Cache initialized: %s",
1876 dircache_is_enabled() ? "Yes" : "No");
1877 dbg_listmessage_addline("Cache size: %d B",
1878 dircache_get_cache_size());
1879 dbg_listmessage_addline("Last size: %d B",
1880 global_status
.dircache_size
);
1881 dbg_listmessage_addline("Limit: %d B",
1883 dbg_listmessage_addline("Reserve: %d/%d B",
1884 dircache_get_reserve_used(), DIRCACHE_RESERVE
);
1885 dbg_listmessage_addline("Scanning took: %d s",
1886 dircache_get_build_ticks() / HZ
);
1887 dbg_listmessage_addline("Entry count: %d",
1888 dircache_get_entry_count());
1892 static bool dbg_dircache_info(void)
1894 struct action_callback_info info
;
1895 info
.title
= "Dircache Info";
1897 info
.selection_size
= 1;
1898 info
.action_callback
= dircache_callback
;
1899 info
.dbg_getname
= dbg_listmessage_getname
;
1904 #endif /* HAVE_DIRCACHE */
1906 #ifdef HAVE_TAGCACHE
1907 static int database_callback(int btn
, struct action_callback_info
*info
)
1909 (void)btn
; (void)info
;
1910 struct tagcache_stat
*stat
= tagcache_get_stat();
1911 dbg_listmessage_setlines(0);
1912 dbg_listmessage_addline("Initialized: %s",
1913 stat
->initialized
? "Yes" : "No");
1914 dbg_listmessage_addline("DB Ready: %s",
1915 stat
->ready
? "Yes" : "No");
1916 dbg_listmessage_addline("RAM Cache: %s",
1917 stat
->ramcache
? "Yes" : "No");
1918 dbg_listmessage_addline("RAM: %d/%d B",
1919 stat
->ramcache_used
, stat
->ramcache_allocated
);
1920 dbg_listmessage_addline("Progress: %d%% (%d entries)",
1921 stat
->progress
, stat
->processed_entries
);
1922 dbg_listmessage_addline("Commit step: %d",
1924 dbg_listmessage_addline("Commit delayed: %s",
1925 stat
->commit_delayed
? "Yes" : "No");
1928 static bool dbg_tagcache_info(void)
1930 struct action_callback_info info
;
1931 info
.title
= "Database Info";
1933 info
.selection_size
= 1;
1934 info
.action_callback
= database_callback
;
1935 info
.dbg_getname
= dbg_listmessage_getname
;
1941 #if CONFIG_CPU == SH7034
1942 static bool dbg_save_roms(void)
1945 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
1947 fd
= creat("/internal_rom_0000-FFFF.bin");
1950 write(fd
, (void *)0, 0x10000);
1954 fd
= creat("/internal_rom_2000000-203FFFF.bin");
1957 write(fd
, (void *)0x2000000, 0x40000);
1961 system_memory_guard(oldmode
);
1964 #elif defined CPU_COLDFIRE
1965 static bool dbg_save_roms(void)
1968 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
1970 #if defined(IRIVER_H100_SERIES)
1971 fd
= creat("/internal_rom_000000-1FFFFF.bin");
1972 #elif defined(IRIVER_H300_SERIES)
1973 fd
= creat("/internal_rom_000000-3FFFFF.bin");
1974 #elif defined(IAUDIO_X5) || defined(IAUDIO_M5)
1975 fd
= creat("/internal_rom_000000-3FFFFF.bin");
1979 write(fd
, (void *)0, FLASH_SIZE
);
1982 system_memory_guard(oldmode
);
1985 fd
= creat("/internal_eeprom.bin");
1989 char buf
[EEPROM_SIZE
];
1992 old_irq_level
= set_irq_level(HIGHEST_IRQ_LEVEL
);
1994 err
= eeprom_24cxx_read(0, buf
, sizeof buf
);
1996 gui_syncsplash(HZ
*3, "Eeprom read failure (%d)",err
);
1999 write(fd
, buf
, sizeof buf
);
2002 set_irq_level(old_irq_level
);
2010 #elif defined(CPU_PP) && !defined(SANSA_E200)
2011 static bool dbg_save_roms(void)
2015 fd
= creat("/internal_rom_000000-0FFFFF.bin");
2018 write(fd
, (void *)0x20000000, FLASH_SIZE
);
2028 static int radio_callback(int btn
, struct action_callback_info
*info
)
2030 dbg_listmessage_setlines(1);
2032 #if (CONFIG_TUNER & LV24020LP)
2033 dbg_listmessage_addline("CTRL_STAT: %02X", lv24020lp_get(LV24020LP_CTRL_STAT
) );
2034 dbg_listmessage_addline("RADIO_STAT: %02X", lv24020lp_get(LV24020LP_REG_STAT
) );
2035 dbg_listmessage_addline("MSS_FM: %d kHz", lv24020lp_get(LV24020LP_MSS_FM
) );
2036 dbg_listmessage_addline("MSS_IF: %d Hz", lv24020lp_get(LV24020LP_MSS_IF
) );
2037 dbg_listmessage_addline("MSS_SD: %d Hz", lv24020lp_get(LV24020LP_MSS_SD
) );
2038 dbg_listmessage_addline("if_set: %d Hz", lv24020lp_get(LV24020LP_IF_SET
) );
2039 dbg_listmessage_addline("sd_set: %d Hz", lv24020lp_get(LV24020LP_SD_SET
) );
2041 #if (CONFIG_TUNER & S1A0903X01)
2042 dbg_listmessage_addline("Samsung regs: %08X", s1a0903x01_get(RADIO_ALL
));
2043 /* This one doesn't return dynamic data atm */
2045 #if (CONFIG_TUNER & TEA5767)
2046 struct tea5767_dbg_info nfo
;
2047 tea5767_dbg_info(&nfo
);
2048 dbg_listmessage_addline("Philips regs:");
2049 dbg_listmessage_addline(
2050 " Read: %02X %02X %02X %02X %02X",
2051 (unsigned)nfo
.read_regs
[0], (unsigned)nfo
.read_regs
[1],
2052 (unsigned)nfo
.read_regs
[2], (unsigned)nfo
.read_regs
[3],
2053 (unsigned)nfo
.read_regs
[4]);
2054 dbg_listmessage_addline(
2055 " Write: %02X %02X %02X %02X %02X",
2056 (unsigned)nfo
.write_regs
[0], (unsigned)nfo
.write_regs
[1],
2057 (unsigned)nfo
.write_regs
[2], (unsigned)nfo
.write_regs
[3],
2058 (unsigned)nfo
.write_regs
[4]);
2061 if (btn
!= ACTION_STD_CANCEL
)
2062 btn
= ACTION_REDRAW
;
2064 gui_synclist_set_nb_items(info
->lists
, dbg_listmessage_getlines());
2067 static bool dbg_fm_radio(void)
2069 struct action_callback_info info
;
2071 info
.title
= "FM Radio";
2073 info
.selection_size
= 1;
2074 info
.cbdata
= radio_hardware_present();
2075 info
.action_callback
= info
.cbdata
? radio_callback
: NULL
;
2076 info
.dbg_getname
= dbg_listmessage_getname
;
2078 dbg_listmessage_setlines(0);
2079 dbg_listmessage_addline("HW detected: %s", info
.cbdata
? "yes" : "no");
2084 #endif /* CONFIG_TUNER */
2085 #endif /* !SIMULATOR */
2087 #ifdef HAVE_LCD_BITMAP
2088 extern bool do_screendump_instead_of_usb
;
2090 static bool dbg_screendump(void)
2092 do_screendump_instead_of_usb
= !do_screendump_instead_of_usb
;
2093 gui_syncsplash(HZ
, "Screendump %s",
2094 do_screendump_instead_of_usb
?"enabled":"disabled");
2097 #endif /* HAVE_LCD_BITMAP */
2099 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2100 static bool dbg_set_memory_guard(void)
2102 static const struct opt_items names
[MAXMEMGUARD
] = {
2104 { "Flash ROM writes", -1 },
2105 { "Zero area (all)", -1 }
2107 int mode
= system_memory_guard(MEMGUARD_KEEP
);
2109 set_option( "Catch mem accesses", &mode
, INT
, names
, MAXMEMGUARD
, NULL
);
2110 system_memory_guard(mode
);
2114 #endif /* CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) */
2116 #if defined(TOSHIBA_GIGABEAT_F) && !defined(SIMULATOR)
2118 extern volatile bool lcd_poweroff
;
2120 static bool dbg_lcd_power_off(void)
2122 lcd_setmargins(0, 0);
2128 lcd_clear_display();
2129 lcd_puts(0, 0, "LCD Power Off");
2131 lcd_puts(1, 1, "Yes");
2133 lcd_puts(1, 1, "No");
2137 button
= get_action(CONTEXT_STD
,HZ
/5);
2140 case ACTION_STD_PREV
:
2141 case ACTION_STD_NEXT
:
2142 lcd_poweroff
= !lcd_poweroff
;
2145 case ACTION_STD_CANCEL
:
2156 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2157 static bool dbg_write_eeprom(void)
2162 char buf
[EEPROM_SIZE
];
2165 fd
= open("/internal_eeprom.bin", O_RDONLY
);
2169 rc
= read(fd
, buf
, EEPROM_SIZE
);
2171 if(rc
== EEPROM_SIZE
)
2173 old_irq_level
= set_irq_level(HIGHEST_IRQ_LEVEL
);
2175 err
= eeprom_24cxx_write(0, buf
, sizeof buf
);
2177 gui_syncsplash(HZ
*3, "Eeprom write failure (%d)",err
);
2179 gui_syncsplash(HZ
*3, "Eeprom written successfully");
2181 set_irq_level(old_irq_level
);
2185 gui_syncsplash(HZ
*3, "File read error (%d)",rc
);
2191 gui_syncsplash(HZ
*3, "Failed to open 'internal_eeprom.bin'");
2196 #endif /* defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS) */
2197 #ifdef CPU_BOOST_LOGGING
2198 static bool cpu_boost_log(void)
2201 int count
= cpu_boost_log_getcount();
2202 int lines
= LCD_HEIGHT
/SYSFONT_HEIGHT
;
2205 lcd_setmargins(0, 0);
2206 lcd_setfont(FONT_SYSFIXED
);
2207 str
= cpu_boost_log_getlog_first();
2210 lcd_clear_display();
2211 for(j
=0; j
<lines
; j
++,i
++)
2214 str
= cpu_boost_log_getlog_next();
2225 switch(get_action(CONTEXT_STD
,TIMEOUT_BLOCK
))
2228 case ACTION_STD_PREV
:
2229 case ACTION_STD_NEXT
:
2232 case ACTION_STD_CANCEL
:
2239 get_action(CONTEXT_STD
,TIMEOUT_BLOCK
);
2240 lcd_setfont(FONT_UI
);
2247 /****** The menu *********/
2248 struct the_menu_item
{
2249 unsigned char *desc
; /* string or ID */
2250 bool (*function
) (void); /* return true if USB was connected */
2252 static const struct the_menu_item menuitems
[] = {
2253 #if defined(TOSHIBA_GIGABEAT_F) && !defined(SIMULATOR)
2254 { "LCD Power Off", dbg_lcd_power_off
},
2256 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || \
2257 (defined(CPU_PP) && !defined(SANSA_E200))
2258 { "Dump ROM contents", dbg_save_roms
},
2260 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || defined(CPU_PP) || CONFIG_CPU == S3C2440
2261 { "View I/O ports", dbg_ports
},
2263 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
2264 { "CPU frequency", dbg_cpufreq
},
2266 #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR)
2267 { "S/PDIF analyzer", dbg_spdif
},
2269 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2270 { "Catch mem accesses", dbg_set_memory_guard
},
2273 { "View OS stacks", dbg_os
},
2275 #ifdef HAVE_LCD_BITMAP
2277 { "View battery", view_battery
},
2279 { "Screendump", dbg_screendump
},
2282 { "View HW info", dbg_hw_info
},
2285 { "View partitions", dbg_partitions
},
2288 { "View disk info", dbg_disk_info
},
2290 #ifdef HAVE_DIRCACHE
2291 { "View dircache info", dbg_dircache_info
},
2293 #ifdef HAVE_TAGCACHE
2294 { "View database info", dbg_tagcache_info
},
2296 #ifdef HAVE_LCD_BITMAP
2297 #if CONFIG_CODEC == SWCODEC || !defined(SIMULATOR)
2298 { "View audio thread", dbg_audio_thread
},
2301 { "pm histogram", peak_meter_histogram
},
2302 #endif /* PM_DEBUG */
2303 #endif /* HAVE_LCD_BITMAP */
2306 { "FM Radio", dbg_fm_radio
},
2309 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2310 { "Write back EEPROM", dbg_write_eeprom
},
2312 #ifdef ROCKBOX_HAS_LOGF
2313 {"logf", logfdisplay
},
2314 {"logfdump", logfdump
},
2316 #ifdef CPU_BOOST_LOGGING
2317 {"cpu_boost log",cpu_boost_log
},
2320 static int menu_action_callback(int btn
, struct action_callback_info
*info
)
2322 if (btn
== ACTION_STD_OK
)
2324 menuitems
[gui_synclist_get_sel_pos(info
->lists
)].function();
2325 gui_synclist_draw(info
->lists
);
2329 static char* dbg_menu_getname(int item
, void * data
, char *buffer
)
2331 (void)data
; (void)buffer
;
2332 return menuitems
[item
].desc
;
2334 bool debug_menu(void)
2336 struct action_callback_info info
;
2337 info
.title
= "Debug Menu";
2338 info
.count
= ARRAYLEN(menuitems
);
2339 info
.selection_size
= 1;
2340 info
.action_callback
= menu_action_callback
;
2341 info
.dbg_getname
= dbg_menu_getname
;