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 ****************************************************************************/
29 #include "debug_menu.h"
36 #include "powermgmt.h"
40 #include "mp3_playback.h"
43 #include "statusbar.h"
54 #include "lcd-remote.h"
66 #include "eeprom_24cxx.h"
67 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
70 #if (CONFIG_STORAGE & STORAGE_ATA)
79 #ifdef HAVE_LCD_BITMAP
80 #include "scrollbar.h"
81 #include "peakmeter.h"
84 #if CONFIG_CODEC == SWCODEC
86 #include "buffering.h"
88 #if defined(HAVE_SPDIF_OUT) || defined(HAVE_SPDIF_IN)
92 #ifdef IRIVER_H300_SERIES
93 #include "pcf50606.h" /* for pcf50606_read */
100 #if CONFIG_RTC == RTC_PCF50605
101 #include "pcf50605.h"
104 #if CONFIG_CPU == DM320 || CONFIG_CPU == S3C2440 || CONFIG_CPU == TCC7801 \
105 || CONFIG_CPU == IMX31L || CONFIG_CPU == AS3525 || CONFIG_CPU == JZ4732
106 #include "debug-target.h"
109 #if defined(SANSA_E200) || defined(SANSA_C200) || defined(PHILIPS_SA9200) \
110 || defined(SANSA_CLIP) || defined(SANSA_FUZE)
116 #include "usb_core.h"
119 /*---------------------------------------------------*/
120 /* SPECIAL DEBUG STUFF */
121 /*---------------------------------------------------*/
122 extern struct thread_entry threads
[MAXTHREADS
];
124 static char thread_status_char(unsigned status
)
126 static const char thread_status_chars
[THREAD_NUM_STATES
+1] =
128 [0 ... THREAD_NUM_STATES
] = '?',
129 [STATE_RUNNING
] = 'R',
130 [STATE_BLOCKED
] = 'B',
131 [STATE_SLEEPING
] = 'S',
132 [STATE_BLOCKED_W_TMO
] = 'T',
133 [STATE_FROZEN
] = 'F',
134 [STATE_KILLED
] = 'K',
137 if (status
> THREAD_NUM_STATES
)
138 status
= THREAD_NUM_STATES
;
140 return thread_status_chars
[status
];
143 static char* threads_getname(int selected_item
, void *data
,
144 char *buffer
, size_t buffer_len
)
147 struct thread_entry
*thread
;
151 if (selected_item
< (int)NUM_CORES
)
153 snprintf(buffer
, buffer_len
, "Idle (%d): %2d%%", selected_item
,
154 idle_stack_usage(selected_item
));
158 selected_item
-= NUM_CORES
;
161 thread
= &threads
[selected_item
];
163 if (thread
->state
== STATE_KILLED
)
165 snprintf(buffer
, buffer_len
, "%2d: ---", selected_item
);
169 thread_get_name(name
, 32, thread
);
171 snprintf(buffer
, buffer_len
,
172 "%2d: " IF_COP("(%d) ") "%c%c " IF_PRIO("%d %d ") "%2d%% %s",
174 IF_COP(thread
->core
,)
175 #ifdef HAVE_SCHEDULER_BOOSTCTRL
176 (thread
->cpu_boost
) ? '+' :
178 ((thread
->state
== STATE_RUNNING
) ? '*' : ' '),
179 thread_status_char(thread
->state
),
180 IF_PRIO(thread
->base_priority
, thread
->priority
, )
181 thread_stack_usage(thread
), name
);
185 static int dbg_threads_action_callback(int action
, struct gui_synclist
*lists
)
188 #ifdef ROCKBOX_HAS_LOGF
189 if (action
== ACTION_STD_OK
)
191 int selpos
= gui_synclist_get_sel_pos(lists
);
193 if (selpos
>= NUM_CORES
)
194 remove_thread(threads
[selpos
- NUM_CORES
].id
);
196 remove_thread(threads
[selpos
].id
);
198 return ACTION_REDRAW
;
200 #endif /* ROCKBOX_HAS_LOGF */
201 if (action
== ACTION_NONE
)
202 action
= ACTION_REDRAW
;
206 static bool dbg_os(void)
208 struct simplelist_info info
;
209 simplelist_info_init(&info
, IF_COP("Core and ") "Stack usage:",
213 MAXTHREADS
+NUM_CORES
,
216 #ifndef ROCKBOX_HAS_LOGF
217 info
.hide_selection
= true;
218 info
.scroll_all
= true;
220 info
.action_callback
= dbg_threads_action_callback
;
221 info
.get_name
= threads_getname
;
222 return simplelist_show_list(&info
);
225 #ifdef HAVE_LCD_BITMAP
226 #if CONFIG_CODEC != SWCODEC
228 static bool dbg_audio_thread(void)
231 struct audio_debug d
;
233 lcd_setfont(FONT_SYSFIXED
);
237 if (action_userabort(HZ
/5))
240 audio_get_debugdata(&d
);
244 snprintf(buf
, sizeof(buf
), "read: %x", d
.audiobuf_read
);
246 snprintf(buf
, sizeof(buf
), "write: %x", d
.audiobuf_write
);
248 snprintf(buf
, sizeof(buf
), "swap: %x", d
.audiobuf_swapwrite
);
250 snprintf(buf
, sizeof(buf
), "playing: %d", d
.playing
);
252 snprintf(buf
, sizeof(buf
), "playable: %x", d
.playable_space
);
254 snprintf(buf
, sizeof(buf
), "unswapped: %x", d
.unswapped_space
);
257 /* Playable space left */
258 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8, 112, 4, d
.audiobuflen
, 0,
259 d
.playable_space
, HORIZONTAL
);
261 /* Show the watermark limit */
262 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8+4, 112, 4, d
.audiobuflen
, 0,
263 d
.low_watermark_level
, HORIZONTAL
);
265 snprintf(buf
, sizeof(buf
), "wm: %x - %x",
266 d
.low_watermark_level
, d
.lowest_watermark_level
);
271 lcd_setfont(FONT_UI
);
274 #endif /* !SIMULATOR */
275 #else /* CONFIG_CODEC == SWCODEC */
276 extern size_t filebuflen
;
277 /* This is a size_t, but call it a long so it puts a - when it's bad. */
279 static unsigned int ticks
, boost_ticks
, freq_sum
;
281 static void dbg_audio_task(void)
284 if(FREQ
> CPUFREQ_NORMAL
)
286 freq_sum
+= FREQ
/1000000; /* in MHz */
291 static bool dbg_buffering_thread(void)
298 size_t bufsize
= pcmbuf_get_bufsize();
299 int pcmbufdescs
= pcmbuf_descs();
300 struct buffering_debug d
;
302 ticks
= boost_ticks
= freq_sum
= 0;
304 tick_add_task(dbg_audio_task
);
306 lcd_setfont(FONT_SYSFIXED
);
309 button
= get_action(CONTEXT_STD
,HZ
/5);
312 case ACTION_STD_NEXT
:
315 case ACTION_STD_PREV
:
318 case ACTION_STD_CANCEL
:
323 buffering_get_debugdata(&d
);
328 bufused
= bufsize
- pcmbuf_free();
330 snprintf(buf
, sizeof(buf
), "pcm: %6ld/%ld", (long) bufused
, (long) bufsize
);
331 lcd_puts(0, line
++, buf
);
333 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
334 bufsize
, 0, bufused
, HORIZONTAL
);
337 snprintf(buf
, sizeof(buf
), "alloc: %6ld/%ld", audio_filebufused(),
339 lcd_puts(0, line
++, buf
);
342 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
343 filebuflen
, 0, audio_filebufused(), HORIZONTAL
);
346 snprintf(buf
, sizeof(buf
), "real: %6ld/%ld", (long)d
.buffered_data
,
348 lcd_puts(0, line
++, buf
);
350 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
351 filebuflen
, 0, (long)d
.buffered_data
, HORIZONTAL
);
355 snprintf(buf
, sizeof(buf
), "usefl: %6ld/%ld", (long)(d
.useful_data
),
357 lcd_puts(0, line
++, buf
);
360 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
361 filebuflen
, 0, d
.useful_data
, HORIZONTAL
);
365 snprintf(buf
, sizeof(buf
), "data_rem: %ld", (long)d
.data_rem
);
366 lcd_puts(0, line
++, buf
);
368 snprintf(buf
, sizeof(buf
), "track count: %2d", audio_track_count());
369 lcd_puts(0, line
++, buf
);
371 snprintf(buf
, sizeof(buf
), "handle count: %d", (int)d
.num_handles
);
372 lcd_puts(0, line
++, buf
);
375 snprintf(buf
, sizeof(buf
), "cpu freq: %3dMHz",
376 (int)((FREQ
+ 500000) / 1000000));
377 lcd_puts(0, line
++, buf
);
382 int boostquota
= boost_ticks
* 1000 / ticks
; /* in 0.1 % */
383 int avgclock
= freq_sum
* 10 / ticks
; /* in 100 kHz */
384 snprintf(buf
, sizeof(buf
), "boost:%3d.%d%% (%d.%dMHz)",
385 boostquota
/10, boostquota
%10, avgclock
/10, avgclock
%10);
386 lcd_puts(0, line
++, buf
);
389 snprintf(buf
, sizeof(buf
), "pcmbufdesc: %2d/%2d",
390 pcmbuf_used_descs(), pcmbufdescs
);
391 lcd_puts(0, line
++, buf
);
392 snprintf(buf
, sizeof(buf
), "watermark: %6d",
394 lcd_puts(0, line
++, buf
);
399 tick_remove_task(dbg_audio_task
);
400 lcd_setfont(FONT_UI
);
404 #endif /* CONFIG_CODEC */
405 #endif /* HAVE_LCD_BITMAP */
408 #if (CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE))
409 /* Tool function to read the flash manufacturer and type, if available.
410 Only chips which could be reprogrammed in system will return values.
411 (The mode switch addresses vary between flash manufacturers, hence addr1/2) */
412 /* In IRAM to avoid problems when running directly from Flash */
413 static bool dbg_flash_id(unsigned* p_manufacturer
, unsigned* p_device
,
414 unsigned addr1
, unsigned addr2
)
415 ICODE_ATTR
__attribute__((noinline
));
416 static bool dbg_flash_id(unsigned* p_manufacturer
, unsigned* p_device
,
417 unsigned addr1
, unsigned addr2
)
420 unsigned not_manu
, not_id
; /* read values before switching to ID mode */
421 unsigned manu
, id
; /* read values when in ID mode */
423 #if CONFIG_CPU == SH7034
424 volatile unsigned char* flash
= (unsigned char*)0x2000000; /* flash mapping */
425 #elif defined(CPU_COLDFIRE)
426 volatile unsigned short* flash
= (unsigned short*)0; /* flash mapping */
428 int old_level
; /* saved interrupt level */
430 not_manu
= flash
[0]; /* read the normal content */
431 not_id
= flash
[1]; /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */
433 /* disable interrupts, prevent any stray flash access */
434 old_level
= disable_irq_save();
436 flash
[addr1
] = 0xAA; /* enter command mode */
438 flash
[addr1
] = 0x90; /* ID command */
439 /* Atmel wants 20ms pause here */
440 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
442 manu
= flash
[0]; /* read the IDs */
445 flash
[0] = 0xF0; /* reset flash (back to normal read mode) */
446 /* Atmel wants 20ms pause here */
447 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
449 restore_irq(old_level
); /* enable interrupts again */
451 /* I assume success if the obtained values are different from
452 the normal flash content. This is not perfectly bulletproof, they
453 could theoretically be the same by chance, causing us to fail. */
454 if (not_manu
!= manu
|| not_id
!= id
) /* a value has changed */
456 *p_manufacturer
= manu
; /* return the results */
458 return true; /* success */
460 return false; /* fail */
462 #endif /* (CONFIG_CPU == SH7034 || CPU_COLDFIRE) */
466 static int perfcheck(void)
472 "orr r0, r2, #0xc0 \n" /* disable IRQ and FIQ */
475 "ldr r0, [%[timr]] \n"
476 "add r0, r0, %[tmo] \n"
478 "add %[res], %[res], #1 \n"
479 "ldr r1, [%[timr]] \n"
482 "msr CPSR_c, r2 \n" /* reset IRQ and FIQ state */
486 [timr
]"r"(&USEC_TIMER
),
488 #if CONFIG_CPU == PP5002
490 #else /* PP5020/5022/5024 */
501 #ifdef HAVE_LCD_BITMAP
502 static bool dbg_hw_info(void)
504 #if CONFIG_CPU == SH7034
506 int bitmask
= HW_MASK
;
507 int rom_version
= ROM_VERSION
;
508 unsigned manu
, id
; /* flash IDs */
509 bool got_id
; /* flag if we managed to get the flash IDs */
510 unsigned rom_crc
= 0xffffffff; /* CRC32 of the boot ROM */
511 bool has_bootrom
; /* flag for boot ROM present */
512 int oldmode
; /* saved memory guard mode */
514 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
516 /* get flash ROM type */
517 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
519 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
521 /* check if the boot ROM area is a flash mirror */
522 has_bootrom
= (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
523 if (has_bootrom
) /* if ROM and Flash different */
525 /* calculate CRC16 checksum of boot ROM */
526 rom_crc
= crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
529 system_memory_guard(oldmode
); /* re-enable memory guard */
531 lcd_setfont(FONT_SYSFIXED
);
534 lcd_puts(0, 0, "[Hardware info]");
536 snprintf(buf
, 32, "ROM: %d.%02d", rom_version
/100, rom_version
%100);
539 snprintf(buf
, 32, "Mask: 0x%04x", bitmask
);
543 snprintf(buf
, 32, "Flash: M=%02x D=%02x", manu
, id
);
545 snprintf(buf
, 32, "Flash: M=?? D=??"); /* unknown, sorry */
550 if (rom_crc
== 0x56DBA4EE) /* known Version 1 */
551 snprintf(buf
, 32, "Boot ROM: V1");
553 snprintf(buf
, 32, "ROMcrc: 0x%08x", rom_crc
);
557 snprintf(buf
, 32, "Boot ROM: none");
563 while (!(action_userabort(TIMEOUT_BLOCK
)));
565 #elif CONFIG_CPU == MCF5249 || CONFIG_CPU == MCF5250
567 unsigned manu
, id
; /* flash IDs */
568 int got_id
; /* flag if we managed to get the flash IDs */
569 int oldmode
; /* saved memory guard mode */
572 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
574 /* get flash ROM type */
575 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
577 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
579 system_memory_guard(oldmode
); /* re-enable memory guard */
581 lcd_setfont(FONT_SYSFIXED
);
584 lcd_puts(0, line
++, "[Hardware info]");
587 snprintf(buf
, 32, "Flash: M=%04x D=%04x", manu
, id
);
589 snprintf(buf
, 32, "Flash: M=???? D=????"); /* unknown, sorry */
590 lcd_puts(0, line
++, buf
);
596 lcd_puts(0, ++line
, "Serial Number:");
598 got_id
= ds2411_read_id(&id
);
600 if (got_id
== DS2411_OK
)
602 snprintf(buf
, 32, " FC=%02x", (unsigned)id
.family_code
);
603 lcd_puts(0, ++line
, buf
);
604 snprintf(buf
, 32, " ID=%02X %02X %02X %02X %02X %02X",
605 (unsigned)id
.uid
[0], (unsigned)id
.uid
[1], (unsigned)id
.uid
[2],
606 (unsigned)id
.uid
[3], (unsigned)id
.uid
[4], (unsigned)id
.uid
[5]);
607 lcd_puts(0, ++line
, buf
);
608 snprintf(buf
, 32, " CRC=%02X", (unsigned)id
.crc
);
612 snprintf(buf
, 32, "READ ERR=%d", got_id
);
615 lcd_puts(0, ++line
, buf
);
621 while (!(action_userabort(TIMEOUT_BLOCK
)));
623 #elif defined(CPU_PP502x)
626 char pp_version
[] = { (PP_VER2
>> 24) & 0xff, (PP_VER2
>> 16) & 0xff,
627 (PP_VER2
>> 8) & 0xff, (PP_VER2
) & 0xff,
628 (PP_VER1
>> 24) & 0xff, (PP_VER1
>> 16) & 0xff,
629 (PP_VER1
>> 8) & 0xff, (PP_VER1
) & 0xff, '\0' };
631 lcd_setfont(FONT_SYSFIXED
);
634 lcd_puts(0, line
++, "[Hardware info]");
637 snprintf(buf
, sizeof(buf
), "HW rev: 0x%08lx", IPOD_HW_REVISION
);
638 lcd_puts(0, line
++, buf
);
642 extern int lcd_type
; /* Defined in lcd-colornano.c */
644 snprintf(buf
, sizeof(buf
), "LCD type: %d", lcd_type
);
645 lcd_puts(0, line
++, buf
);
648 snprintf(buf
, sizeof(buf
), "PP version: %s", pp_version
);
649 lcd_puts(0, line
++, buf
);
651 snprintf(buf
, sizeof(buf
), "Est. clock (kHz): %d", perfcheck());
652 lcd_puts(0, line
++, buf
);
656 while (!(action_userabort(TIMEOUT_BLOCK
)));
658 #elif CONFIG_CPU == PP5002
661 char pp_version
[] = { (PP_VER4
>> 8) & 0xff, PP_VER4
& 0xff,
662 (PP_VER3
>> 8) & 0xff, PP_VER3
& 0xff,
663 (PP_VER2
>> 8) & 0xff, PP_VER2
& 0xff,
664 (PP_VER1
>> 8) & 0xff, PP_VER1
& 0xff, '\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
), "PP version: %s", pp_version
);
678 lcd_puts(0, line
++, buf
);
680 snprintf(buf
, sizeof(buf
), "Est. clock (kHz): %d", perfcheck());
681 lcd_puts(0, line
++, buf
);
685 while (!(action_userabort(TIMEOUT_BLOCK
)));
688 /* Define this function in your target tree */
689 return __dbg_hw_info();
690 #endif /* CONFIG_CPU */
691 lcd_setfont(FONT_UI
);
694 #else /* !HAVE_LCD_BITMAP */
695 static bool dbg_hw_info(void)
700 int rom_version
= ROM_VERSION
;
701 unsigned manu
, id
; /* flash IDs */
702 bool got_id
; /* flag if we managed to get the flash IDs */
703 unsigned rom_crc
= 0xffffffff; /* CRC32 of the boot ROM */
704 bool has_bootrom
; /* flag for boot ROM present */
705 int oldmode
; /* saved memory guard mode */
707 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
709 /* get flash ROM type */
710 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
712 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
714 /* check if the boot ROM area is a flash mirror */
715 has_bootrom
= (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
716 if (has_bootrom
) /* if ROM and Flash different */
718 /* calculate CRC16 checksum of boot ROM */
719 rom_crc
= crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
722 system_memory_guard(oldmode
); /* re-enable memory guard */
726 lcd_puts(0, 0, "[HW Info]");
732 snprintf(buf
, 32, "ROM: %d.%02d",
733 rom_version
/100, rom_version
%100);
737 snprintf(buf
, 32, "Flash:%02x,%02x", manu
, id
);
739 snprintf(buf
, 32, "Flash:??,??"); /* unknown, sorry */
744 if (rom_crc
== 0x56DBA4EE) /* known Version 1 */
745 snprintf(buf
, 32, "BootROM: V1");
746 else if (rom_crc
== 0x358099E8)
747 snprintf(buf
, 32, "BootROM: V2");
748 /* alternative boot ROM found in one single player so far */
750 snprintf(buf
, 32, "R: %08x", rom_crc
);
753 snprintf(buf
, 32, "BootROM: no");
759 button
= get_action(CONTEXT_SETTINGS
,TIMEOUT_BLOCK
);
763 case ACTION_STD_CANCEL
:
766 case ACTION_SETTINGS_DEC
:
772 case ACTION_SETTINGS_INC
:
781 #endif /* !HAVE_LCD_BITMAP */
782 #endif /* !SIMULATOR */
785 static char* dbg_partitions_getname(int selected_item
, void *data
,
786 char *buffer
, size_t buffer_len
)
789 int partition
= selected_item
/2;
790 struct partinfo
* p
= disk_partinfo(partition
);
793 snprintf(buffer
, buffer_len
, " T:%x %ld MB", p
->type
, p
->size
/ 2048);
797 snprintf(buffer
, buffer_len
, "P%d: S:%lx", partition
, p
->start
);
802 bool dbg_partitions(void)
804 struct simplelist_info info
;
805 simplelist_info_init(&info
, "Partition Info", 4, NULL
);
806 info
.selection_size
= 2;
807 info
.hide_selection
= true;
808 info
.scroll_all
= true;
809 info
.get_name
= dbg_partitions_getname
;
810 return simplelist_show_list(&info
);
814 #if defined(CPU_COLDFIRE) && defined(HAVE_SPDIF_OUT)
815 static bool dbg_spdif(void)
819 unsigned int control
;
824 unsigned int interruptstat
;
825 bool valnogood
, symbolerr
, parityerr
;
828 int spdif_source
= spdif_get_output_source(&spdif_src_on
);
829 spdif_set_output_source(AUDIO_SRC_SPDIF
IF_SPDIF_POWER_(, true));
832 lcd_setfont(FONT_SYSFIXED
);
834 #ifdef HAVE_SPDIF_POWER
835 spdif_power_enable(true); /* We need SPDIF power for both sending & receiving */
842 control
= EBU1RCVCCHANNEL1
;
843 interruptstat
= INTERRUPTSTAT
;
844 INTERRUPTCLEAR
= 0x03c00000;
846 valnogood
= (interruptstat
& 0x01000000)?true:false;
847 symbolerr
= (interruptstat
& 0x00800000)?true:false;
848 parityerr
= (interruptstat
& 0x00400000)?true:false;
850 snprintf(buf
, sizeof(buf
), "Val: %s Sym: %s Par: %s",
853 parityerr
?"--":"OK");
854 lcd_puts(0, line
++, buf
);
856 snprintf(buf
, sizeof(buf
), "Status word: %08x", (int)control
);
857 lcd_puts(0, line
++, buf
);
862 snprintf(buf
, sizeof(buf
), "PRO: %d (%s)",
863 x
, x
?"Professional":"Consumer");
864 lcd_puts(0, line
++, buf
);
866 x
= (control
>> 30) & 1;
867 snprintf(buf
, sizeof(buf
), "Audio: %d (%s)",
868 x
, x
?"Non-PCM":"PCM");
869 lcd_puts(0, line
++, buf
);
871 x
= (control
>> 29) & 1;
872 snprintf(buf
, sizeof(buf
), "Copy: %d (%s)",
873 x
, x
?"Permitted":"Inhibited");
874 lcd_puts(0, line
++, buf
);
876 x
= (control
>> 27) & 7;
889 snprintf(buf
, sizeof(buf
), "Preemphasis: %d (%s)", x
, s
);
890 lcd_puts(0, line
++, buf
);
892 x
= (control
>> 24) & 3;
893 snprintf(buf
, sizeof(buf
), "Mode: %d", x
);
894 lcd_puts(0, line
++, buf
);
896 category
= (control
>> 17) & 127;
908 snprintf(buf
, sizeof(buf
), "Category: 0x%02x (%s)", category
, s
);
909 lcd_puts(0, line
++, buf
);
911 x
= (control
>> 16) & 1;
913 if(((category
& 0x70) == 0x10) ||
914 ((category
& 0x70) == 0x40) ||
915 ((category
& 0x78) == 0x38))
917 generation
= !generation
;
919 snprintf(buf
, sizeof(buf
), "Generation: %d (%s)",
920 x
, generation
?"Original":"No ind.");
921 lcd_puts(0, line
++, buf
);
923 x
= (control
>> 12) & 15;
924 snprintf(buf
, sizeof(buf
), "Source: %d", x
);
925 lcd_puts(0, line
++, buf
);
927 x
= (control
>> 8) & 15;
943 snprintf(buf
, sizeof(buf
), "Channel: %d (%s)", x
, s
);
944 lcd_puts(0, line
++, buf
);
946 x
= (control
>> 4) & 15;
959 snprintf(buf
, sizeof(buf
), "Frequency: %d (%s)", x
, s
);
960 lcd_puts(0, line
++, buf
);
962 x
= (control
>> 2) & 3;
963 snprintf(buf
, sizeof(buf
), "Clock accuracy: %d", x
);
964 lcd_puts(0, line
++, buf
);
968 snprintf(buf
, sizeof(buf
), "Measured freq: %ldHz",
969 spdif_measure_frequency());
970 lcd_puts(0, line
++, buf
);
975 if (action_userabort(HZ
/10))
979 spdif_set_output_source(spdif_source
IF_SPDIF_POWER_(, spdif_src_on
));
981 #ifdef HAVE_SPDIF_POWER
982 spdif_power_enable(global_settings
.spdif_enable
);
985 lcd_setfont(FONT_UI
);
988 #endif /* CPU_COLDFIRE */
991 #ifdef HAVE_LCD_BITMAP
992 /* button definitions */
993 #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
994 (CONFIG_KEYPAD == IRIVER_H300_PAD)
995 # define DEBUG_CANCEL BUTTON_OFF
997 #elif CONFIG_KEYPAD == RECORDER_PAD
998 # define DEBUG_CANCEL BUTTON_OFF
1000 #elif CONFIG_KEYPAD == ONDIO_PAD
1001 # define DEBUG_CANCEL BUTTON_MENU
1003 #elif (CONFIG_KEYPAD == IPOD_1G2G_PAD) || \
1004 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
1005 (CONFIG_KEYPAD == IPOD_4G_PAD)
1006 # define DEBUG_CANCEL BUTTON_MENU
1008 #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
1009 # define DEBUG_CANCEL BUTTON_PLAY
1011 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
1012 # define DEBUG_CANCEL BUTTON_REC
1014 #elif (CONFIG_KEYPAD == IAUDIO_M3_PAD)
1015 # define DEBUG_CANCEL BUTTON_RC_REC
1017 #elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
1018 # define DEBUG_CANCEL BUTTON_REW
1020 #elif (CONFIG_KEYPAD == MROBE100_PAD)
1021 # define DEBUG_CANCEL BUTTON_MENU
1023 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
1024 (CONFIG_KEYPAD == SANSA_C200_PAD) || \
1025 (CONFIG_KEYPAD == SANSA_FUZE_PAD)
1026 # define DEBUG_CANCEL BUTTON_LEFT
1028 /* This is temporary until the SA9200 touchpad works */
1029 #elif (CONFIG_KEYPAD == PHILIPS_SA9200_PAD) || \
1030 (CONFIG_KEYPAD == PHILIPS_HDD1630_PAD)
1031 # define DEBUG_CANCEL BUTTON_POWER
1033 #elif (CONFIG_KEYPAD == SAMSUNG_YH_PAD)
1034 # define DEBUG_CANCEL BUTTON_PLAY
1036 #endif /* key definitions */
1039 bool dbg_ports(void)
1041 #if CONFIG_CPU == SH7034
1043 int adc_battery_voltage
, adc_battery_level
;
1045 lcd_setfont(FONT_SYSFIXED
);
1046 lcd_clear_display();
1050 snprintf(buf
, 32, "PADR: %04x", (unsigned short)PADR
);
1051 lcd_puts(0, 0, buf
);
1052 snprintf(buf
, 32, "PBDR: %04x", (unsigned short)PBDR
);
1053 lcd_puts(0, 1, buf
);
1055 snprintf(buf
, 32, "AN0: %03x AN4: %03x", adc_read(0), adc_read(4));
1056 lcd_puts(0, 2, buf
);
1057 snprintf(buf
, 32, "AN1: %03x AN5: %03x", adc_read(1), adc_read(5));
1058 lcd_puts(0, 3, buf
);
1059 snprintf(buf
, 32, "AN2: %03x AN6: %03x", adc_read(2), adc_read(6));
1060 lcd_puts(0, 4, buf
);
1061 snprintf(buf
, 32, "AN3: %03x AN7: %03x", adc_read(3), adc_read(7));
1062 lcd_puts(0, 5, buf
);
1064 battery_read_info(&adc_battery_voltage
, &adc_battery_level
);
1065 snprintf(buf
, 32, "Batt: %d.%03dV %d%% ", adc_battery_voltage
/ 1000,
1066 adc_battery_voltage
% 1000, adc_battery_level
);
1067 lcd_puts(0, 6, buf
);
1070 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1072 lcd_setfont(FONT_UI
);
1076 #elif defined(CPU_COLDFIRE)
1077 unsigned int gpio_out
;
1078 unsigned int gpio1_out
;
1079 unsigned int gpio_read
;
1080 unsigned int gpio1_read
;
1081 unsigned int gpio_function
;
1082 unsigned int gpio1_function
;
1083 unsigned int gpio_enable
;
1084 unsigned int gpio1_enable
;
1085 int adc_buttons
, adc_remote
;
1086 int adc_battery_voltage
, adc_battery_level
;
1090 lcd_clear_display();
1091 lcd_setfont(FONT_SYSFIXED
);
1096 gpio_read
= GPIO_READ
;
1097 gpio1_read
= GPIO1_READ
;
1098 gpio_out
= GPIO_OUT
;
1099 gpio1_out
= GPIO1_OUT
;
1100 gpio_function
= GPIO_FUNCTION
;
1101 gpio1_function
= GPIO1_FUNCTION
;
1102 gpio_enable
= GPIO_ENABLE
;
1103 gpio1_enable
= GPIO1_ENABLE
;
1105 snprintf(buf
, sizeof(buf
), "GPIO_READ: %08x", gpio_read
);
1106 lcd_puts(0, line
++, buf
);
1107 snprintf(buf
, sizeof(buf
), "GPIO_OUT: %08x", gpio_out
);
1108 lcd_puts(0, line
++, buf
);
1109 snprintf(buf
, sizeof(buf
), "GPIO_FUNC: %08x", gpio_function
);
1110 lcd_puts(0, line
++, buf
);
1111 snprintf(buf
, sizeof(buf
), "GPIO_ENA: %08x", gpio_enable
);
1112 lcd_puts(0, line
++, buf
);
1114 snprintf(buf
, sizeof(buf
), "GPIO1_READ: %08x", gpio1_read
);
1115 lcd_puts(0, line
++, buf
);
1116 snprintf(buf
, sizeof(buf
), "GPIO1_OUT: %08x", gpio1_out
);
1117 lcd_puts(0, line
++, buf
);
1118 snprintf(buf
, sizeof(buf
), "GPIO1_FUNC: %08x", gpio1_function
);
1119 lcd_puts(0, line
++, buf
);
1120 snprintf(buf
, sizeof(buf
), "GPIO1_ENA: %08x", gpio1_enable
);
1121 lcd_puts(0, line
++, buf
);
1123 adc_buttons
= adc_read(ADC_BUTTONS
);
1124 adc_remote
= adc_read(ADC_REMOTE
);
1125 battery_read_info(&adc_battery_voltage
, &adc_battery_level
);
1126 #if defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IRIVER_H300_SERIES)
1127 snprintf(buf
, sizeof(buf
), "ADC_BUTTONS (%c): %02x",
1128 button_scan_enabled() ? '+' : '-', adc_buttons
);
1130 snprintf(buf
, sizeof(buf
), "ADC_BUTTONS: %02x", adc_buttons
);
1132 lcd_puts(0, line
++, buf
);
1133 #if defined(IAUDIO_X5) || defined(IAUDIO_M5)
1134 snprintf(buf
, sizeof(buf
), "ADC_REMOTE (%c): %02x",
1135 remote_detect() ? '+' : '-', adc_remote
);
1137 snprintf(buf
, sizeof(buf
), "ADC_REMOTE: %02x", adc_remote
);
1139 lcd_puts(0, line
++, buf
);
1140 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1141 snprintf(buf
, sizeof(buf
), "ADC_REMOTEDETECT: %02x",
1142 adc_read(ADC_REMOTEDETECT
));
1143 lcd_puts(0, line
++, buf
);
1146 snprintf(buf
, 32, "Batt: %d.%03dV %d%% ", adc_battery_voltage
/ 1000,
1147 adc_battery_voltage
% 1000, adc_battery_level
);
1148 lcd_puts(0, line
++, buf
);
1150 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1151 snprintf(buf
, sizeof(buf
), "remotetype: %d", remote_type());
1152 lcd_puts(0, line
++, buf
);
1156 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1158 lcd_setfont(FONT_UI
);
1163 #elif defined(CPU_PP502x)
1168 lcd_clear_display();
1169 lcd_setfont(FONT_SYSFIXED
);
1174 lcd_puts(0, line
++, "GPIO STATES:");
1175 snprintf(buf
, sizeof(buf
), "A: %02x E: %02x I: %02x",
1176 (unsigned int)GPIOA_INPUT_VAL
,
1177 (unsigned int)GPIOE_INPUT_VAL
,
1178 (unsigned int)GPIOI_INPUT_VAL
);
1179 lcd_puts(0, line
++, buf
);
1180 snprintf(buf
, sizeof(buf
), "B: %02x F: %02x J: %02x",
1181 (unsigned int)GPIOB_INPUT_VAL
,
1182 (unsigned int)GPIOF_INPUT_VAL
,
1183 (unsigned int)GPIOJ_INPUT_VAL
);
1184 lcd_puts(0, line
++, buf
);
1185 snprintf(buf
, sizeof(buf
), "C: %02x G: %02x K: %02x",
1186 (unsigned int)GPIOC_INPUT_VAL
,
1187 (unsigned int)GPIOG_INPUT_VAL
,
1188 (unsigned int)GPIOK_INPUT_VAL
);
1189 lcd_puts(0, line
++, buf
);
1190 snprintf(buf
, sizeof(buf
), "D: %02x H: %02x L: %02x",
1191 (unsigned int)GPIOD_INPUT_VAL
,
1192 (unsigned int)GPIOH_INPUT_VAL
,
1193 (unsigned int)GPIOL_INPUT_VAL
);
1194 lcd_puts(0, line
++, buf
);
1196 snprintf(buf
, sizeof(buf
), "GPO32_VAL: %08lx", GPO32_VAL
);
1197 lcd_puts(0, line
++, buf
);
1198 snprintf(buf
, sizeof(buf
), "GPO32_EN: %08lx", GPO32_ENABLE
);
1199 lcd_puts(0, line
++, buf
);
1200 snprintf(buf
, sizeof(buf
), "DEV_EN: %08lx", DEV_EN
);
1201 lcd_puts(0, line
++, buf
);
1202 snprintf(buf
, sizeof(buf
), "DEV_EN2: %08lx", DEV_EN2
);
1203 lcd_puts(0, line
++, buf
);
1204 snprintf(buf
, sizeof(buf
), "DEV_EN3: %08lx", inl(0x60006044));
1205 lcd_puts(0, line
++, buf
); /* to be verified */
1206 snprintf(buf
, sizeof(buf
), "DEV_INIT1: %08lx", DEV_INIT1
);
1207 lcd_puts(0, line
++, buf
);
1208 snprintf(buf
, sizeof(buf
), "DEV_INIT2: %08lx", DEV_INIT2
);
1209 lcd_puts(0, line
++, buf
);
1210 #ifdef ADC_ACCESSORY
1211 snprintf(buf
, sizeof(buf
), "ACCESSORY: %d", adc_read(ADC_ACCESSORY
));
1212 lcd_puts(0, line
++, buf
);
1215 #if defined(IPOD_ACCESSORY_PROTOCOL)
1216 extern unsigned char serbuf
[];
1217 snprintf(buf
, sizeof(buf
), "IAP PACKET: %02x %02x %02x %02x %02x %02x %02x %02x",
1218 serbuf
[0], serbuf
[1], serbuf
[2], serbuf
[3], serbuf
[4], serbuf
[5],
1219 serbuf
[6], serbuf
[7]);
1220 lcd_puts(0, line
++, buf
);
1223 #if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
1225 snprintf(buf
, sizeof(buf
), "BATT: %03x UNK1: %03x",
1226 adc_read(ADC_BATTERY
), adc_read(ADC_UNKNOWN_1
));
1227 lcd_puts(0, line
++, buf
);
1228 snprintf(buf
, sizeof(buf
), "REM: %03x PAD: %03x",
1229 adc_read(ADC_REMOTE
), adc_read(ADC_SCROLLPAD
));
1230 lcd_puts(0, line
++, buf
);
1231 #elif defined(PHILIPS_HDD1630)
1233 snprintf(buf
, sizeof(buf
), "BATT: %03x UNK1: %03x",
1234 adc_read(ADC_BATTERY
), adc_read(ADC_UNKNOWN_1
));
1235 lcd_puts(0, line
++, buf
);
1236 #elif defined(SANSA_E200) || defined(PHILIPS_SA9200)
1237 snprintf(buf
, sizeof(buf
), "ADC_BVDD: %4d", adc_read(ADC_BVDD
));
1238 lcd_puts(0, line
++, buf
);
1239 snprintf(buf
, sizeof(buf
), "ADC_RTCSUP: %4d", adc_read(ADC_RTCSUP
));
1240 lcd_puts(0, line
++, buf
);
1241 snprintf(buf
, sizeof(buf
), "ADC_UVDD: %4d", adc_read(ADC_UVDD
));
1242 lcd_puts(0, line
++, buf
);
1243 snprintf(buf
, sizeof(buf
), "ADC_CHG_IN: %4d", adc_read(ADC_CHG_IN
));
1244 lcd_puts(0, line
++, buf
);
1245 snprintf(buf
, sizeof(buf
), "ADC_CVDD: %4d", adc_read(ADC_CVDD
));
1246 lcd_puts(0, line
++, buf
);
1247 snprintf(buf
, sizeof(buf
), "ADC_BATTEMP: %4d", adc_read(ADC_BATTEMP
));
1248 lcd_puts(0, line
++, buf
);
1249 snprintf(buf
, sizeof(buf
), "ADC_MICSUP1: %4d", adc_read(ADC_MICSUP1
));
1250 lcd_puts(0, line
++, buf
);
1251 snprintf(buf
, sizeof(buf
), "ADC_MICSUP2: %4d", adc_read(ADC_MICSUP2
));
1252 lcd_puts(0, line
++, buf
);
1253 snprintf(buf
, sizeof(buf
), "ADC_VBE1: %4d", adc_read(ADC_VBE1
));
1254 lcd_puts(0, line
++, buf
);
1255 snprintf(buf
, sizeof(buf
), "ADC_VBE2: %4d", adc_read(ADC_VBE2
));
1256 lcd_puts(0, line
++, buf
);
1257 snprintf(buf
, sizeof(buf
), "ADC_I_MICSUP1:%4d", adc_read(ADC_I_MICSUP1
));
1258 lcd_puts(0, line
++, buf
);
1259 #if !defined(PHILIPS_SA9200)
1260 snprintf(buf
, sizeof(buf
), "ADC_I_MICSUP2:%4d", adc_read(ADC_I_MICSUP2
));
1261 lcd_puts(0, line
++, buf
);
1262 snprintf(buf
, sizeof(buf
), "ADC_VBAT: %4d", adc_read(ADC_VBAT
));
1263 lcd_puts(0, line
++, buf
);
1267 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1269 lcd_setfont(FONT_UI
);
1274 #elif CONFIG_CPU == PP5002
1278 lcd_clear_display();
1279 lcd_setfont(FONT_SYSFIXED
);
1284 snprintf(buf
, sizeof(buf
), "GPIO_A: %02x GPIO_B: %02x",
1285 (unsigned int)GPIOA_INPUT_VAL
, (unsigned int)GPIOB_INPUT_VAL
);
1286 lcd_puts(0, line
++, buf
);
1287 snprintf(buf
, sizeof(buf
), "GPIO_C: %02x GPIO_D: %02x",
1288 (unsigned int)GPIOC_INPUT_VAL
, (unsigned int)GPIOD_INPUT_VAL
);
1289 lcd_puts(0, line
++, buf
);
1291 snprintf(buf
, sizeof(buf
), "DEV_EN: %08lx", DEV_EN
);
1292 lcd_puts(0, line
++, buf
);
1293 snprintf(buf
, sizeof(buf
), "CLOCK_ENABLE: %08lx", CLOCK_ENABLE
);
1294 lcd_puts(0, line
++, buf
);
1295 snprintf(buf
, sizeof(buf
), "CLOCK_SOURCE: %08lx", CLOCK_SOURCE
);
1296 lcd_puts(0, line
++, buf
);
1297 snprintf(buf
, sizeof(buf
), "PLL_CONTROL: %08lx", PLL_CONTROL
);
1298 lcd_puts(0, line
++, buf
);
1299 snprintf(buf
, sizeof(buf
), "PLL_DIV: %08lx", PLL_DIV
);
1300 lcd_puts(0, line
++, buf
);
1301 snprintf(buf
, sizeof(buf
), "PLL_MULT: %08lx", PLL_MULT
);
1302 lcd_puts(0, line
++, buf
);
1303 snprintf(buf
, sizeof(buf
), "TIMING1_CTL: %08lx", TIMING1_CTL
);
1304 lcd_puts(0, line
++, buf
);
1305 snprintf(buf
, sizeof(buf
), "TIMING2_CTL: %08lx", TIMING2_CTL
);
1306 lcd_puts(0, line
++, buf
);
1309 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1311 lcd_setfont(FONT_UI
);
1315 lcd_setfont(FONT_UI
);
1317 return __dbg_ports();
1321 #else /* !HAVE_LCD_BITMAP */
1322 bool dbg_ports(void)
1326 int adc_battery_voltage
;
1329 lcd_clear_display();
1336 snprintf(buf
, 32, "PADR: %04x", (unsigned short)PADR
);
1339 snprintf(buf
, 32, "PBDR: %04x", (unsigned short)PBDR
);
1342 snprintf(buf
, 32, "AN0: %03x", adc_read(0));
1345 snprintf(buf
, 32, "AN1: %03x", adc_read(1));
1348 snprintf(buf
, 32, "AN2: %03x", adc_read(2));
1351 snprintf(buf
, 32, "AN3: %03x", adc_read(3));
1354 snprintf(buf
, 32, "AN4: %03x", adc_read(4));
1357 snprintf(buf
, 32, "AN5: %03x", adc_read(5));
1360 snprintf(buf
, 32, "AN6: %03x", adc_read(6));
1363 snprintf(buf
, 32, "AN7: %03x", adc_read(7));
1366 lcd_puts(0, 0, buf
);
1368 battery_read_info(&adc_battery_voltage
, NULL
);
1369 snprintf(buf
, 32, "Batt: %d.%03dV", adc_battery_voltage
/ 1000,
1370 adc_battery_voltage
% 1000);
1371 lcd_puts(0, 1, buf
);
1374 button
= get_action(CONTEXT_SETTINGS
,HZ
/5);
1378 case ACTION_STD_CANCEL
:
1381 case ACTION_SETTINGS_DEC
:
1387 case ACTION_SETTINGS_INC
:
1396 #endif /* !HAVE_LCD_BITMAP */
1397 #endif /* !SIMULATOR */
1399 #if (CONFIG_RTC == RTC_PCF50605) && !defined(SIMULATOR)
1400 static bool dbg_pcf(void)
1405 #ifdef HAVE_LCD_BITMAP
1406 lcd_setfont(FONT_SYSFIXED
);
1408 lcd_clear_display();
1414 snprintf(buf
, sizeof(buf
), "DCDC1: %02x", pcf50605_read(0x1b));
1415 lcd_puts(0, line
++, buf
);
1416 snprintf(buf
, sizeof(buf
), "DCDC2: %02x", pcf50605_read(0x1c));
1417 lcd_puts(0, line
++, buf
);
1418 snprintf(buf
, sizeof(buf
), "DCDC3: %02x", pcf50605_read(0x1d));
1419 lcd_puts(0, line
++, buf
);
1420 snprintf(buf
, sizeof(buf
), "DCDC4: %02x", pcf50605_read(0x1e));
1421 lcd_puts(0, line
++, buf
);
1422 snprintf(buf
, sizeof(buf
), "DCDEC1: %02x", pcf50605_read(0x1f));
1423 lcd_puts(0, line
++, buf
);
1424 snprintf(buf
, sizeof(buf
), "DCDEC2: %02x", pcf50605_read(0x20));
1425 lcd_puts(0, line
++, buf
);
1426 snprintf(buf
, sizeof(buf
), "DCUDC1: %02x", pcf50605_read(0x21));
1427 lcd_puts(0, line
++, buf
);
1428 snprintf(buf
, sizeof(buf
), "DCUDC2: %02x", pcf50605_read(0x22));
1429 lcd_puts(0, line
++, buf
);
1430 snprintf(buf
, sizeof(buf
), "IOREGC: %02x", pcf50605_read(0x23));
1431 lcd_puts(0, line
++, buf
);
1432 snprintf(buf
, sizeof(buf
), "D1REGC: %02x", pcf50605_read(0x24));
1433 lcd_puts(0, line
++, buf
);
1434 snprintf(buf
, sizeof(buf
), "D2REGC: %02x", pcf50605_read(0x25));
1435 lcd_puts(0, line
++, buf
);
1436 snprintf(buf
, sizeof(buf
), "D3REGC: %02x", pcf50605_read(0x26));
1437 lcd_puts(0, line
++, buf
);
1438 snprintf(buf
, sizeof(buf
), "LPREG1: %02x", pcf50605_read(0x27));
1439 lcd_puts(0, line
++, buf
);
1442 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1444 lcd_setfont(FONT_UI
);
1449 lcd_setfont(FONT_UI
);
1454 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
1455 static bool dbg_cpufreq(void)
1461 #ifdef HAVE_LCD_BITMAP
1462 lcd_setfont(FONT_SYSFIXED
);
1464 lcd_clear_display();
1470 snprintf(buf
, sizeof(buf
), "Frequency: %ld", FREQ
);
1471 lcd_puts(0, line
++, buf
);
1473 snprintf(buf
, sizeof(buf
), "boost_counter: %d", get_cpu_boost_counter());
1474 lcd_puts(0, line
++, buf
);
1477 button
= get_action(CONTEXT_STD
,HZ
/10);
1481 case ACTION_STD_PREV
:
1485 case ACTION_STD_NEXT
:
1490 while (get_cpu_boost_counter() > 0)
1492 set_cpu_frequency(CPUFREQ_DEFAULT
);
1495 case ACTION_STD_CANCEL
:
1496 lcd_setfont(FONT_UI
);
1500 lcd_setfont(FONT_UI
);
1503 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
1505 #if defined(HAVE_TSC2100) && !defined(SIMULATOR)
1506 #include "tsc2100.h"
1507 static char *itob(int n
, int len
)
1509 static char binary
[64];
1511 for (i
=1, j
=0;i
<=len
;i
++)
1513 binary
[j
++] = n
&(1<<(len
-i
))?'1':'0';
1520 static char* tsc2100_debug_getname(int selected_item
, void * data
,
1521 char *buffer
, size_t buffer_len
)
1523 int *page
= (int*)data
;
1524 bool reserved
= false;
1528 if ((selected_item
> 0x0a) ||
1529 (selected_item
== 0x04) ||
1530 (selected_item
== 0x08))
1534 if ((selected_item
> 0x05) ||
1535 (selected_item
== 0x02))
1539 if (selected_item
> 0x1e)
1544 snprintf(buffer
, buffer_len
, "%02x: RESERVED", selected_item
);
1546 snprintf(buffer
, buffer_len
, "%02x: %s", selected_item
,
1547 itob(tsc2100_readreg(*page
, selected_item
)&0xffff,16));
1550 static int tsc2100debug_action_callback(int action
, struct gui_synclist
*lists
)
1552 int *page
= (int*)lists
->data
;
1553 if (action
== ACTION_STD_OK
)
1555 *page
= (*page
+1)%3;
1556 snprintf(lists
->title
, 32,
1557 "tsc2100 registers - Page %d", *page
);
1558 return ACTION_REDRAW
;
1562 static bool tsc2100_debug(void)
1565 char title
[32] = "tsc2100 registers - Page 0";
1566 struct simplelist_info info
;
1567 simplelist_info_init(&info
, title
, 32, &page
);
1568 info
.timeout
= HZ
/100;
1569 info
.get_name
= tsc2100_debug_getname
;
1570 info
.action_callback
= tsc2100debug_action_callback
;
1571 return simplelist_show_list(&info
);
1575 #ifdef HAVE_LCD_BITMAP
1577 * view_battery() shows a automatically scaled graph of the battery voltage
1578 * over time. Usable for estimating battery life / charging rate.
1579 * The power_history array is updated in power_thread of powermgmt.c.
1582 #define BAT_LAST_VAL MIN(LCD_WIDTH, POWER_HISTORY_LEN)
1583 #define BAT_YSPACE (LCD_HEIGHT - 20)
1585 static bool view_battery(void)
1589 unsigned short maxv
, minv
;
1592 lcd_setfont(FONT_SYSFIXED
);
1596 lcd_clear_display();
1598 case 0: /* voltage history graph */
1599 /* Find maximum and minimum voltage for scaling */
1600 minv
= power_history
[0];
1602 for (i
= 1; i
< BAT_LAST_VAL
&& power_history
[i
]; i
++) {
1603 if (power_history
[i
] > maxv
)
1604 maxv
= power_history
[i
];
1605 if (power_history
[i
] < minv
)
1606 minv
= power_history
[i
];
1609 snprintf(buf
, 30, "Battery %d.%03d", power_history
[0] / 1000,
1610 power_history
[0] % 1000);
1611 lcd_puts(0, 0, buf
);
1612 snprintf(buf
, 30, "scale %d.%03d-%d.%03dV",
1613 minv
/ 1000, minv
% 1000, maxv
/ 1000, maxv
% 1000);
1614 lcd_puts(0, 1, buf
);
1617 for (i
= BAT_LAST_VAL
- 1; i
>= 0; i
--) {
1618 y
= (power_history
[i
] - minv
) * BAT_YSPACE
/ (maxv
- minv
);
1619 lcd_set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
1620 lcd_vline(x
, LCD_HEIGHT
-1, 20);
1621 lcd_set_drawmode(DRMODE_SOLID
);
1622 lcd_vline(x
, LCD_HEIGHT
-1,
1623 MIN(MAX(LCD_HEIGHT
-1 - y
, 20), LCD_HEIGHT
-1));
1629 case 1: /* status: */
1630 lcd_puts(0, 0, "Power status:");
1632 battery_read_info(&y
, NULL
);
1633 snprintf(buf
, 30, "Battery: %d.%03d V", y
/ 1000, y
% 1000);
1634 lcd_puts(0, 1, buf
);
1635 #ifdef ADC_EXT_POWER
1636 y
= (adc_read(ADC_EXT_POWER
) * EXT_SCALE_FACTOR
) / 1000;
1637 snprintf(buf
, 30, "External: %d.%03d V", y
/ 1000, y
% 1000);
1638 lcd_puts(0, 2, buf
);
1641 #if defined ARCHOS_RECORDER
1642 snprintf(buf
, 30, "Chgr: %s %s",
1643 charger_inserted() ? "present" : "absent",
1644 charger_enabled() ? "on" : "off");
1645 lcd_puts(0, 3, buf
);
1646 snprintf(buf
, 30, "short delta: %d", short_delta
);
1647 lcd_puts(0, 5, buf
);
1648 snprintf(buf
, 30, "long delta: %d", long_delta
);
1649 lcd_puts(0, 6, buf
);
1650 lcd_puts(0, 7, power_message
);
1651 snprintf(buf
, 30, "USB Inserted: %s",
1652 usb_inserted() ? "yes" : "no");
1653 lcd_puts(0, 8, buf
);
1654 #elif defined IRIVER_H300_SERIES
1655 snprintf(buf
, 30, "USB Charging Enabled: %s",
1656 usb_charging_enabled() ? "yes" : "no");
1657 lcd_puts(0, 9, buf
);
1658 #elif defined IPOD_NANO || defined IPOD_VIDEO
1659 int usb_pwr
= (GPIOL_INPUT_VAL
& 0x10)?true:false;
1660 int ext_pwr
= (GPIOL_INPUT_VAL
& 0x08)?false:true;
1661 int dock
= (GPIOA_INPUT_VAL
& 0x10)?true:false;
1662 int charging
= (GPIOB_INPUT_VAL
& 0x01)?false:true;
1663 int headphone
= (GPIOA_INPUT_VAL
& 0x80)?true:false;
1665 snprintf(buf
, 30, "USB pwr: %s",
1666 usb_pwr
? "present" : "absent");
1667 lcd_puts(0, 3, buf
);
1668 snprintf(buf
, 30, "EXT pwr: %s",
1669 ext_pwr
? "present" : "absent");
1670 lcd_puts(0, 4, buf
);
1671 snprintf(buf
, 30, "Battery: %s",
1672 charging
? "charging" : (usb_pwr
||ext_pwr
) ? "charged" : "discharging");
1673 lcd_puts(0, 5, buf
);
1674 snprintf(buf
, 30, "Dock mode: %s",
1675 dock
? "enabled" : "disabled");
1676 lcd_puts(0, 6, buf
);
1677 snprintf(buf
, 30, "Headphone: %s",
1678 headphone
? "connected" : "disconnected");
1679 lcd_puts(0, 7, buf
);
1680 #elif defined TOSHIBA_GIGABEAT_S
1684 static const unsigned char * const chrgstate_strings
[] =
1695 snprintf(buf
, 30, "Charger: %s",
1696 charger_inserted() ? "present" : "absent");
1697 lcd_puts(0, line
++, buf
);
1699 st
= power_input_status() &
1700 (POWER_INPUT_CHARGER
| POWER_INPUT_BATTERY
);
1701 snprintf(buf
, 30, "%s%s",
1702 (st
& POWER_INPUT_MAIN_CHARGER
) ? " Main" : "",
1703 (st
& POWER_INPUT_USB_CHARGER
) ? " USB" : "");
1704 lcd_puts(0, line
++, buf
);
1706 snprintf(buf
, 30, "IUSB Max: %d", usb_allowed_current());
1707 lcd_puts(0, line
++, buf
);
1709 y
= ARRAYLEN(chrgstate_strings
) - 1;
1711 switch (charge_state
)
1713 case CHARGE_STATE_DISABLED
: y
--;
1714 case CHARGE_STATE_ERROR
: y
--;
1715 case DISCHARGING
: y
--;
1722 snprintf(buf
, 30, "State: %s", chrgstate_strings
[y
]);
1723 lcd_puts(0, line
++, buf
);
1725 snprintf(buf
, 30, "Battery Switch: %s",
1726 (st
& POWER_INPUT_BATTERY
) ? "On" : "Off");
1727 lcd_puts(0, line
++, buf
);
1729 y
= chrgraw_adc_voltage();
1730 snprintf(buf
, 30, "CHRGRAW: %d.%03d V",
1731 y
/ 1000, y
% 1000);
1732 lcd_puts(0, line
++, buf
);
1734 y
= application_supply_adc_voltage();
1735 snprintf(buf
, 30, "BP : %d.%03d V",
1736 y
/ 1000, y
% 1000);
1737 lcd_puts(0, line
++, buf
);
1739 y
= battery_adc_charge_current();
1740 if (y
< 0) x
= '-', y
= -y
;
1742 snprintf(buf
, 30, "CHRGISN:%c%d mA", x
, y
);
1743 lcd_puts(0, line
++, buf
);
1745 y
= cccv_regulator_dissipation();
1746 snprintf(buf
, 30, "P CCCV : %d mW", y
);
1747 lcd_puts(0, line
++, buf
);
1749 y
= battery_charge_current();
1750 if (y
< 0) x
= '-', y
= -y
;
1752 snprintf(buf
, 30, "I Charge:%c%d mA", x
, y
);
1753 lcd_puts(0, line
++, buf
);
1755 y
= battery_adc_temp();
1758 snprintf(buf
, 30, "T Battery: %dC (%dF)", y
,
1761 /* Conversion disabled */
1762 snprintf(buf
, 30, "T Battery: ?");
1765 lcd_puts(0, line
++, buf
);
1766 #elif defined(SANSA_E200) || defined(SANSA_C200) || defined(SANSA_CLIP) || defined(SANSA_FUZE)
1767 const int first
= CHARGE_STATE_DISABLED
;
1768 static const char * const chrgstate_strings
[] =
1770 [CHARGE_STATE_DISABLED
-first
] = "Disabled",
1771 [CHARGE_STATE_ERROR
-first
] = "Error",
1772 [DISCHARGING
-first
] = "Discharging",
1773 [CHARGING
-first
] = "Charging",
1775 const char *str
= NULL
;
1777 snprintf(buf
, 30, "Charger: %s",
1778 charger_inserted() ? "present" : "absent");
1779 lcd_puts(0, 3, buf
);
1781 y
= charge_state
- first
;
1782 if ((unsigned)y
< ARRAYLEN(chrgstate_strings
))
1783 str
= chrgstate_strings
[y
];
1785 snprintf(buf
, sizeof(buf
), "State: %s",
1786 str
? str
: "<unknown>");
1787 lcd_puts(0, 4, buf
);
1789 snprintf(buf
, sizeof(buf
), "CHARGER: %02X",
1790 ascodec_read(AS3514_CHARGER
));
1791 lcd_puts(0, 5, buf
);
1793 snprintf(buf
, 30, "Charger: %s",
1794 charger_inserted() ? "present" : "absent");
1795 lcd_puts(0, 3, buf
);
1796 #endif /* target type */
1797 #endif /* CONFIG_CHARGING */
1800 case 2: /* voltage deltas: */
1801 lcd_puts(0, 0, "Voltage deltas:");
1803 for (i
= 0; i
<= 6; i
++) {
1804 y
= power_history
[i
] - power_history
[i
+1];
1805 snprintf(buf
, 30, "-%d min: %s%d.%03d V", i
,
1806 (y
< 0) ? "-" : "", ((y
< 0) ? y
* -1 : y
) / 1000,
1807 ((y
< 0) ? y
* -1 : y
) % 1000);
1808 lcd_puts(0, i
+1, buf
);
1812 case 3: /* remaining time estimation: */
1814 #ifdef ARCHOS_RECORDER
1815 snprintf(buf
, 30, "charge_state: %d", charge_state
);
1816 lcd_puts(0, 0, buf
);
1818 snprintf(buf
, 30, "Cycle time: %d m", powermgmt_last_cycle_startstop_min
);
1819 lcd_puts(0, 1, buf
);
1821 snprintf(buf
, 30, "Lvl@cyc st: %d%%", powermgmt_last_cycle_level
);
1822 lcd_puts(0, 2, buf
);
1824 snprintf(buf
, 30, "P=%2d I=%2d", pid_p
, pid_i
);
1825 lcd_puts(0, 3, buf
);
1827 snprintf(buf
, 30, "Trickle sec: %d/60", trickle_sec
);
1828 lcd_puts(0, 4, buf
);
1829 #endif /* ARCHOS_RECORDER */
1831 snprintf(buf
, 30, "Last PwrHist: %d.%03dV",
1832 power_history
[0] / 1000,
1833 power_history
[0] % 1000);
1834 lcd_puts(0, 5, buf
);
1836 snprintf(buf
, 30, "battery level: %d%%", battery_level());
1837 lcd_puts(0, 6, buf
);
1839 snprintf(buf
, 30, "Est. remain: %d m", battery_time());
1840 lcd_puts(0, 7, buf
);
1846 switch(get_action(CONTEXT_STD
,HZ
/2))
1848 case ACTION_STD_PREV
:
1853 case ACTION_STD_NEXT
:
1858 case ACTION_STD_CANCEL
:
1859 lcd_setfont(FONT_UI
);
1863 lcd_setfont(FONT_UI
);
1867 #endif /* HAVE_LCD_BITMAP */
1871 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
1873 #if (CONFIG_STORAGE & STORAGE_MMC)
1874 #define CARDTYPE "MMC"
1875 #elif (CONFIG_STORAGE & STORAGE_SD)
1876 #define CARDTYPE "microSD"
1879 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1882 int *cardnum
= (int*)lists
->data
;
1883 unsigned char card_name
[7];
1884 unsigned char pbuf
[32];
1885 char *title
= lists
->title
;
1886 static const unsigned char i_vmin
[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
1887 static const unsigned char i_vmax
[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
1888 static const unsigned char *kbit_units
[] = { "kBit/s", "MBit/s", "GBit/s" };
1889 static const unsigned char *nsec_units
[] = { "ns", "µs", "ms" };
1890 #if (CONFIG_STORAGE & STORAGE_MMC)
1891 static const char *mmc_spec_vers
[] = { "1.0-1.2", "1.4", "2.0-2.2",
1892 "3.1-3.31", "4.0" };
1895 if ((btn
== ACTION_STD_OK
) || (btn
== SYS_FS_CHANGED
) || (btn
== ACTION_REDRAW
))
1898 if (btn
== ACTION_STD_OK
)
1900 *cardnum
^= 0x1; /* change cards */
1904 simplelist_set_line_count(0);
1906 card
= card_get_info(*cardnum
);
1908 if (card
->initialized
> 0)
1910 strlcpy(card_name
, ((unsigned char*)card
->cid
) + 3, sizeof(card_name
));
1911 simplelist_addline(SIMPLELIST_ADD_LINE
,
1912 "%s Rev %d.%d", card_name
,
1913 (int) card_extract_bits(card
->cid
, 55, 4),
1914 (int) card_extract_bits(card
->cid
, 51, 4));
1915 simplelist_addline(SIMPLELIST_ADD_LINE
,
1917 #if (CONFIG_STORAGE & STORAGE_SD)
1918 (int) card_extract_bits(card
->cid
, 11, 3),
1919 (int) card_extract_bits(card
->cid
, 19, 8) + 2000
1920 #elif (CONFIG_STORAGE & STORAGE_MMC)
1921 (int) card_extract_bits(card
->cid
, 15, 4),
1922 (int) card_extract_bits(card
->cid
, 11, 4) + 1997
1925 simplelist_addline(SIMPLELIST_ADD_LINE
,
1926 #if (CONFIG_STORAGE & STORAGE_SD)
1928 card_extract_bits(card
->cid
, 55, 32)
1929 #elif (CONFIG_STORAGE & STORAGE_MMC)
1931 card_extract_bits(card
->cid
, 47, 16)
1935 simplelist_addline(SIMPLELIST_ADD_LINE
, "M=%02x, "
1936 #if (CONFIG_STORAGE & STORAGE_SD)
1938 (int) card_extract_bits(card
->cid
, 127, 8),
1939 card_extract_bits(card
->cid
, 119, 8),
1940 card_extract_bits(card
->cid
, 111, 8)
1941 #elif (CONFIG_STORAGE & STORAGE_MMC)
1943 (int) card_extract_bits(card
->cid
, 127, 8),
1944 (int) card_extract_bits(card
->cid
, 119, 16)
1948 #if (CONFIG_STORAGE & STORAGE_MMC)
1949 int temp
= card_extract_bits(card
->csd
, 125, 4);
1950 simplelist_addline(SIMPLELIST_ADD_LINE
,
1951 "MMC v%s", temp
< 5 ?
1952 mmc_spec_vers
[temp
] : "?.?");
1954 simplelist_addline(SIMPLELIST_ADD_LINE
,
1955 "Blocks: 0x%08lx", card
->numblocks
);
1956 output_dyn_value(pbuf
, sizeof pbuf
, card
->speed
/ 1000,
1958 simplelist_addline(SIMPLELIST_ADD_LINE
,
1960 output_dyn_value(pbuf
, sizeof pbuf
, card
->taac
,
1962 simplelist_addline(SIMPLELIST_ADD_LINE
,
1964 simplelist_addline(SIMPLELIST_ADD_LINE
,
1965 "Nsac: %d clk", card
->nsac
);
1966 simplelist_addline(SIMPLELIST_ADD_LINE
,
1967 "R2W: *%d", card
->r2w_factor
);
1968 simplelist_addline(SIMPLELIST_ADD_LINE
,
1970 i_vmin
[card_extract_bits(card
->csd
, 61, 3)],
1971 i_vmax
[card_extract_bits(card
->csd
, 58, 3)]);
1972 simplelist_addline(SIMPLELIST_ADD_LINE
,
1974 i_vmin
[card_extract_bits(card
->csd
, 55, 3)],
1975 i_vmax
[card_extract_bits(card
->csd
, 52, 3)]);
1977 else if (card
->initialized
== 0)
1979 simplelist_addline(SIMPLELIST_ADD_LINE
, "Not Found!");
1981 #if (CONFIG_STORAGE & STORAGE_SD)
1982 else /* card->initialized < 0 */
1984 simplelist_addline(SIMPLELIST_ADD_LINE
, "Init Error! (%d)", card
->initialized
);
1987 snprintf(title
, 16, "[" CARDTYPE
" %d]", *cardnum
);
1988 gui_synclist_set_title(lists
, title
, Icon_NOICON
);
1989 gui_synclist_set_nb_items(lists
, simplelist_get_line_count());
1990 gui_synclist_select_item(lists
, 0);
1991 btn
= ACTION_REDRAW
;
1995 #elif (CONFIG_STORAGE & STORAGE_ATA)
1996 static int disk_callback(int btn
, struct gui_synclist
*lists
)
2001 unsigned short* identify_info
= ata_get_identify();
2002 bool timing_info_present
= false;
2005 simplelist_set_line_count(0);
2007 for (i
=0; i
< 20; i
++)
2008 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+27]);
2010 /* kill trailing space */
2011 for (i
=39; i
&& buf
[i
]==' '; i
--)
2013 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", buf
);
2014 for (i
=0; i
< 4; i
++)
2015 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+23]);
2017 simplelist_addline(SIMPLELIST_ADD_LINE
,
2018 "Firmware: %s", buf
);
2019 snprintf(buf
, sizeof buf
, "%ld MB",
2020 ((unsigned long)identify_info
[61] << 16 |
2021 (unsigned long)identify_info
[60]) / 2048 );
2022 simplelist_addline(SIMPLELIST_ADD_LINE
,
2025 fat_size( IF_MV2(0,) NULL
, &free
);
2026 simplelist_addline(SIMPLELIST_ADD_LINE
,
2027 "Free: %ld MB", free
/ 1024);
2028 simplelist_addline(SIMPLELIST_ADD_LINE
,
2029 "Spinup time: %d ms", storage_spinup_time() * (1000/HZ
));
2030 i
= identify_info
[83] & (1<<3);
2031 simplelist_addline(SIMPLELIST_ADD_LINE
,
2032 "Power mgmt: %s", i
? "enabled" : "unsupported");
2033 i
= identify_info
[83] & (1<<9);
2034 simplelist_addline(SIMPLELIST_ADD_LINE
,
2035 "Noise mgmt: %s", i
? "enabled" : "unsupported");
2036 i
= identify_info
[82] & (1<<6);
2037 simplelist_addline(SIMPLELIST_ADD_LINE
,
2038 "Read-ahead: %s", i
? "enabled" : "unsupported");
2039 timing_info_present
= identify_info
[53] & (1<<1);
2040 if(timing_info_present
) {
2041 char pio3
[2], pio4
[2];pio3
[1] = 0;
2043 pio3
[0] = (identify_info
[64] & (1<<0)) ? '3' : 0;
2044 pio4
[0] = (identify_info
[64] & (1<<1)) ? '4' : 0;
2045 simplelist_addline(SIMPLELIST_ADD_LINE
,
2046 "PIO modes: 0 1 2 %s %s", pio3
, pio4
);
2049 simplelist_addline(SIMPLELIST_ADD_LINE
,
2050 "No PIO mode info");
2052 timing_info_present
= identify_info
[53] & (1<<1);
2053 if(timing_info_present
) {
2054 simplelist_addline(SIMPLELIST_ADD_LINE
,
2055 "Cycle times %dns/%dns",
2057 identify_info
[68] );
2059 simplelist_addline(SIMPLELIST_ADD_LINE
,
2063 if (identify_info
[63] & (1<<0)) {
2064 char mdma0
[2], mdma1
[2], mdma2
[2];
2065 mdma0
[1] = mdma1
[1] = mdma2
[1] = 0;
2066 mdma0
[0] = (identify_info
[63] & (1<<0)) ? '0' : 0;
2067 mdma1
[0] = (identify_info
[63] & (1<<1)) ? '1' : 0;
2068 mdma2
[0] = (identify_info
[63] & (1<<2)) ? '2' : 0;
2069 simplelist_addline(SIMPLELIST_ADD_LINE
,
2070 "MDMA modes: %s %s %s", mdma0
, mdma1
, mdma2
);
2071 simplelist_addline(SIMPLELIST_ADD_LINE
,
2072 "MDMA Cycle times %dns/%dns",
2074 identify_info
[66] );
2077 simplelist_addline(SIMPLELIST_ADD_LINE
,
2078 "No MDMA mode info");
2080 if (identify_info
[53] & (1<<2)) {
2081 char udma0
[2], udma1
[2], udma2
[2], udma3
[2], udma4
[2], udma5
[2], udma6
[2];
2082 udma0
[1] = udma1
[1] = udma2
[1] = udma3
[1] = udma4
[1] = udma5
[1] = udma6
[1] = 0;
2083 udma0
[0] = (identify_info
[88] & (1<<0)) ? '0' : 0;
2084 udma1
[0] = (identify_info
[88] & (1<<1)) ? '1' : 0;
2085 udma2
[0] = (identify_info
[88] & (1<<2)) ? '2' : 0;
2086 udma3
[0] = (identify_info
[88] & (1<<3)) ? '3' : 0;
2087 udma4
[0] = (identify_info
[88] & (1<<4)) ? '4' : 0;
2088 udma5
[0] = (identify_info
[88] & (1<<5)) ? '5' : 0;
2089 udma6
[0] = (identify_info
[88] & (1<<6)) ? '6' : 0;
2090 simplelist_addline(SIMPLELIST_ADD_LINE
,
2091 "UDMA modes: %s %s %s %s %s %s %s", udma0
, udma1
, udma2
,
2092 udma3
, udma4
, udma5
, udma6
);
2095 simplelist_addline(SIMPLELIST_ADD_LINE
,
2096 "No UDMA mode info");
2098 #endif /* HAVE_ATA_DMA */
2099 timing_info_present
= identify_info
[53] & (1<<1);
2100 if(timing_info_present
) {
2101 i
= identify_info
[49] & (1<<11);
2102 simplelist_addline(SIMPLELIST_ADD_LINE
,
2103 "IORDY support: %s", i
? "yes" : "no");
2104 i
= identify_info
[49] & (1<<10);
2105 simplelist_addline(SIMPLELIST_ADD_LINE
,
2106 "IORDY disable: %s", i
? "yes" : "no");
2108 simplelist_addline(SIMPLELIST_ADD_LINE
,
2111 simplelist_addline(SIMPLELIST_ADD_LINE
,
2112 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
2114 i
= ata_get_dma_mode();
2116 simplelist_addline(SIMPLELIST_ADD_LINE
,
2119 simplelist_addline(SIMPLELIST_ADD_LINE
,
2121 (i
& 0x40) ? "UDMA" : "MDMA",
2124 #endif /* HAVE_ATA_DMA */
2127 #else /* No SD, MMC or ATA */
2128 static int disk_callback(int btn
, struct gui_synclist
*lists
)
2132 struct storage_info info
;
2133 storage_get_info(0,&info
);
2134 simplelist_addline(SIMPLELIST_ADD_LINE
, "Vendor: %s", info
.vendor
);
2135 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", info
.product
);
2136 simplelist_addline(SIMPLELIST_ADD_LINE
, "Firmware: %s", info
.revision
);
2137 simplelist_addline(SIMPLELIST_ADD_LINE
,
2138 "Size: %ld MB", info
.num_sectors
*(info
.sector_size
/512)/2024);
2140 fat_size( IF_MV2(0,) NULL
, &free
);
2141 simplelist_addline(SIMPLELIST_ADD_LINE
,
2142 "Free: %ld MB", free
/ 1024);
2143 simplelist_addline(SIMPLELIST_ADD_LINE
,
2144 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
2149 #if (CONFIG_STORAGE & STORAGE_ATA)
2150 static bool dbg_identify_info(void)
2152 int fd
= creat("/identify_info.bin");
2155 #ifdef ROCKBOX_LITTLE_ENDIAN
2156 ecwrite(fd
, ata_get_identify(), SECTOR_SIZE
/2, "s", true);
2158 write(fd
, ata_get_identify(), SECTOR_SIZE
);
2166 static bool dbg_disk_info(void)
2168 struct simplelist_info info
;
2169 simplelist_info_init(&info
, "Disk Info", 1, NULL
);
2170 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
2173 info
.callback_data
= (void*)&card
;
2176 info
.action_callback
= disk_callback
;
2177 info
.hide_selection
= true;
2178 info
.scroll_all
= true;
2179 return simplelist_show_list(&info
);
2181 #endif /* !SIMULATOR */
2183 #ifdef HAVE_DIRCACHE
2184 static int dircache_callback(int btn
, struct gui_synclist
*lists
)
2186 (void)btn
; (void)lists
;
2187 simplelist_set_line_count(0);
2188 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache initialized: %s",
2189 dircache_is_enabled() ? "Yes" : "No");
2190 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache size: %d B",
2191 dircache_get_cache_size());
2192 simplelist_addline(SIMPLELIST_ADD_LINE
, "Last size: %d B",
2193 global_status
.dircache_size
);
2194 simplelist_addline(SIMPLELIST_ADD_LINE
, "Limit: %d B",
2196 simplelist_addline(SIMPLELIST_ADD_LINE
, "Reserve: %d/%d B",
2197 dircache_get_reserve_used(), DIRCACHE_RESERVE
);
2198 simplelist_addline(SIMPLELIST_ADD_LINE
, "Scanning took: %d s",
2199 dircache_get_build_ticks() / HZ
);
2200 simplelist_addline(SIMPLELIST_ADD_LINE
, "Entry count: %d",
2201 dircache_get_entry_count());
2205 static bool dbg_dircache_info(void)
2207 struct simplelist_info info
;
2208 simplelist_info_init(&info
, "Dircache Info", 7, NULL
);
2209 info
.action_callback
= dircache_callback
;
2210 info
.hide_selection
= true;
2211 info
.scroll_all
= true;
2212 return simplelist_show_list(&info
);
2215 #endif /* HAVE_DIRCACHE */
2217 #ifdef HAVE_TAGCACHE
2218 static int database_callback(int btn
, struct gui_synclist
*lists
)
2221 struct tagcache_stat
*stat
= tagcache_get_stat();
2222 static bool synced
= false;
2224 simplelist_set_line_count(0);
2226 simplelist_addline(SIMPLELIST_ADD_LINE
, "Initialized: %s",
2227 stat
->initialized
? "Yes" : "No");
2228 simplelist_addline(SIMPLELIST_ADD_LINE
, "DB Ready: %s",
2229 stat
->ready
? "Yes" : "No");
2230 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM Cache: %s",
2231 stat
->ramcache
? "Yes" : "No");
2232 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM: %d/%d B",
2233 stat
->ramcache_used
, stat
->ramcache_allocated
);
2234 simplelist_addline(SIMPLELIST_ADD_LINE
, "Progress: %d%% (%d entries)",
2235 stat
->progress
, stat
->processed_entries
);
2236 simplelist_addline(SIMPLELIST_ADD_LINE
, "Curfile: %s",
2237 stat
->curentry
? stat
->curentry
: "---");
2238 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit step: %d",
2240 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit delayed: %s",
2241 stat
->commit_delayed
? "Yes" : "No");
2243 simplelist_addline(SIMPLELIST_ADD_LINE
, "Queue length: %d",
2244 stat
->queue_length
);
2249 tagcache_screensync_event();
2252 if (!btn
&& stat
->curentry
)
2255 return ACTION_REDRAW
;
2258 if (btn
== ACTION_STD_CANCEL
)
2259 tagcache_screensync_enable(false);
2263 static bool dbg_tagcache_info(void)
2265 struct simplelist_info info
;
2266 simplelist_info_init(&info
, "Database Info", 8, NULL
);
2267 info
.action_callback
= database_callback
;
2268 info
.hide_selection
= true;
2269 info
.scroll_all
= true;
2271 /* Don't do nonblock here, must give enough processing time
2272 for tagcache thread. */
2273 /* info.timeout = TIMEOUT_NOBLOCK; */
2275 tagcache_screensync_enable(true);
2276 return simplelist_show_list(&info
);
2280 #if CONFIG_CPU == SH7034
2281 static bool dbg_save_roms(void)
2284 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
2286 fd
= creat("/internal_rom_0000-FFFF.bin");
2289 write(fd
, (void *)0, 0x10000);
2293 fd
= creat("/internal_rom_2000000-203FFFF.bin");
2296 write(fd
, (void *)0x2000000, 0x40000);
2300 system_memory_guard(oldmode
);
2303 #elif defined CPU_COLDFIRE
2304 static bool dbg_save_roms(void)
2307 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
2309 #if defined(IRIVER_H100_SERIES)
2310 fd
= creat("/internal_rom_000000-1FFFFF.bin");
2311 #elif defined(IRIVER_H300_SERIES)
2312 fd
= creat("/internal_rom_000000-3FFFFF.bin");
2313 #elif defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IAUDIO_M3)
2314 fd
= creat("/internal_rom_000000-3FFFFF.bin");
2318 write(fd
, (void *)0, FLASH_SIZE
);
2321 system_memory_guard(oldmode
);
2324 fd
= creat("/internal_eeprom.bin");
2328 char buf
[EEPROM_SIZE
];
2331 old_irq_level
= disable_irq_save();
2333 err
= eeprom_24cxx_read(0, buf
, sizeof buf
);
2335 restore_irq(old_irq_level
);
2338 splashf(HZ
*3, "Eeprom read failure (%d)", err
);
2341 write(fd
, buf
, sizeof buf
);
2350 #elif defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD)
2351 static bool dbg_save_roms(void)
2355 fd
= creat("/internal_rom_000000-0FFFFF.bin");
2358 write(fd
, (void *)0x20000000, FLASH_SIZE
);
2368 static int radio_callback(int btn
, struct gui_synclist
*lists
)
2371 if (btn
== ACTION_STD_CANCEL
)
2373 simplelist_set_line_count(1);
2375 #if (CONFIG_TUNER & LV24020LP)
2376 simplelist_addline(SIMPLELIST_ADD_LINE
,
2377 "CTRL_STAT: %02X", lv24020lp_get(LV24020LP_CTRL_STAT
) );
2378 simplelist_addline(SIMPLELIST_ADD_LINE
,
2379 "RADIO_STAT: %02X", lv24020lp_get(LV24020LP_REG_STAT
) );
2380 simplelist_addline(SIMPLELIST_ADD_LINE
,
2381 "MSS_FM: %d kHz", lv24020lp_get(LV24020LP_MSS_FM
) );
2382 simplelist_addline(SIMPLELIST_ADD_LINE
,
2383 "MSS_IF: %d Hz", lv24020lp_get(LV24020LP_MSS_IF
) );
2384 simplelist_addline(SIMPLELIST_ADD_LINE
,
2385 "MSS_SD: %d Hz", lv24020lp_get(LV24020LP_MSS_SD
) );
2386 simplelist_addline(SIMPLELIST_ADD_LINE
,
2387 "if_set: %d Hz", lv24020lp_get(LV24020LP_IF_SET
) );
2388 simplelist_addline(SIMPLELIST_ADD_LINE
,
2389 "sd_set: %d Hz", lv24020lp_get(LV24020LP_SD_SET
) );
2390 #endif /* LV24020LP */
2391 #if (CONFIG_TUNER & S1A0903X01)
2392 simplelist_addline(SIMPLELIST_ADD_LINE
,
2393 "Samsung regs: %08X", s1a0903x01_get(RADIO_ALL
));
2394 /* This one doesn't return dynamic data atm */
2395 #endif /* S1A0903X01 */
2396 #if (CONFIG_TUNER & TEA5767)
2397 struct tea5767_dbg_info nfo
;
2398 tea5767_dbg_info(&nfo
);
2399 simplelist_addline(SIMPLELIST_ADD_LINE
, "Philips regs:");
2400 simplelist_addline(SIMPLELIST_ADD_LINE
,
2401 " Read: %02X %02X %02X %02X %02X",
2402 (unsigned)nfo
.read_regs
[0], (unsigned)nfo
.read_regs
[1],
2403 (unsigned)nfo
.read_regs
[2], (unsigned)nfo
.read_regs
[3],
2404 (unsigned)nfo
.read_regs
[4]);
2405 simplelist_addline(SIMPLELIST_ADD_LINE
,
2406 " Write: %02X %02X %02X %02X %02X",
2407 (unsigned)nfo
.write_regs
[0], (unsigned)nfo
.write_regs
[1],
2408 (unsigned)nfo
.write_regs
[2], (unsigned)nfo
.write_regs
[3],
2409 (unsigned)nfo
.write_regs
[4]);
2410 #endif /* TEA5767 */
2411 #if (CONFIG_TUNER & SI4700)
2412 struct si4700_dbg_info nfo
;
2413 si4700_dbg_info(&nfo
);
2414 simplelist_addline(SIMPLELIST_ADD_LINE
, "SI4700 regs:");
2416 simplelist_addline(SIMPLELIST_ADD_LINE
,
2417 "%04X %04X %04X %04X",
2418 (unsigned)nfo
.regs
[0], (unsigned)nfo
.regs
[1],
2419 (unsigned)nfo
.regs
[2], (unsigned)nfo
.regs
[3]);
2420 simplelist_addline(SIMPLELIST_ADD_LINE
,
2421 "%04X %04X %04X %04X",
2422 (unsigned)nfo
.regs
[4], (unsigned)nfo
.regs
[5],
2423 (unsigned)nfo
.regs
[6], (unsigned)nfo
.regs
[7]);
2424 simplelist_addline(SIMPLELIST_ADD_LINE
,
2425 "%04X %04X %04X %04X",
2426 (unsigned)nfo
.regs
[8], (unsigned)nfo
.regs
[9],
2427 (unsigned)nfo
.regs
[10], (unsigned)nfo
.regs
[11]);
2428 simplelist_addline(SIMPLELIST_ADD_LINE
,
2429 "%04X %04X %04X %04X",
2430 (unsigned)nfo
.regs
[12], (unsigned)nfo
.regs
[13],
2431 (unsigned)nfo
.regs
[14], (unsigned)nfo
.regs
[15]);
2433 return ACTION_REDRAW
;
2435 static bool dbg_fm_radio(void)
2437 struct simplelist_info info
;
2438 info
.scroll_all
= true;
2439 simplelist_info_init(&info
, "FM Radio", 1, NULL
);
2440 simplelist_set_line_count(0);
2441 simplelist_addline(SIMPLELIST_ADD_LINE
, "HW detected: %s",
2442 radio_hardware_present() ? "yes" : "no");
2444 info
.action_callback
= radio_hardware_present()?radio_callback
: NULL
;
2445 info
.hide_selection
= true;
2446 return simplelist_show_list(&info
);
2448 #endif /* CONFIG_TUNER */
2449 #endif /* !SIMULATOR */
2451 #ifdef HAVE_LCD_BITMAP
2452 extern bool do_screendump_instead_of_usb
;
2454 static bool dbg_screendump(void)
2456 do_screendump_instead_of_usb
= !do_screendump_instead_of_usb
;
2457 splashf(HZ
, "Screendump %s",
2458 do_screendump_instead_of_usb
?"enabled":"disabled");
2461 #endif /* HAVE_LCD_BITMAP */
2463 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2464 static bool dbg_set_memory_guard(void)
2466 static const struct opt_items names
[MAXMEMGUARD
] = {
2468 { "Flash ROM writes", -1 },
2469 { "Zero area (all)", -1 }
2471 int mode
= system_memory_guard(MEMGUARD_KEEP
);
2473 set_option( "Catch mem accesses", &mode
, INT
, names
, MAXMEMGUARD
, NULL
);
2474 system_memory_guard(mode
);
2478 #endif /* CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) */
2480 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2481 static bool dbg_write_eeprom(void)
2486 char buf
[EEPROM_SIZE
];
2489 fd
= open("/internal_eeprom.bin", O_RDONLY
);
2493 rc
= read(fd
, buf
, EEPROM_SIZE
);
2495 if(rc
== EEPROM_SIZE
)
2497 old_irq_level
= disable_irq_save();
2499 err
= eeprom_24cxx_write(0, buf
, sizeof buf
);
2501 splashf(HZ
*3, "Eeprom write failure (%d)", err
);
2503 splash(HZ
*3, "Eeprom written successfully");
2505 restore_irq(old_irq_level
);
2509 splashf(HZ
*3, "File read error (%d)",rc
);
2515 splash(HZ
*3, "Failed to open 'internal_eeprom.bin'");
2520 #endif /* defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS) */
2521 #ifdef CPU_BOOST_LOGGING
2522 static bool cpu_boost_log(void)
2525 int count
= cpu_boost_log_getcount();
2526 int lines
= LCD_HEIGHT
/SYSFONT_HEIGHT
;
2529 lcd_setfont(FONT_SYSFIXED
);
2530 str
= cpu_boost_log_getlog_first();
2533 lcd_clear_display();
2534 for(j
=0; j
<lines
; j
++,i
++)
2537 str
= cpu_boost_log_getlog_next();
2540 if(strlen(str
) > LCD_WIDTH
/SYSFONT_WIDTH
)
2541 lcd_puts_scroll(0, j
, str
);
2551 switch(get_action(CONTEXT_STD
,TIMEOUT_BLOCK
))
2554 case ACTION_STD_PREV
:
2555 case ACTION_STD_NEXT
:
2558 case ACTION_STD_CANCEL
:
2565 get_action(CONTEXT_STD
,TIMEOUT_BLOCK
);
2566 lcd_setfont(FONT_UI
);
2571 #if (defined(HAVE_WHEEL_ACCELERATION) && (CONFIG_KEYPAD==IPOD_4G_PAD) && !defined(SIMULATOR))
2572 extern bool wheel_is_touched
;
2573 extern int old_wheel_value
;
2574 extern int new_wheel_value
;
2575 extern int wheel_delta
;
2576 extern unsigned int accumulated_wheel_delta
;
2577 extern unsigned int wheel_velocity
;
2579 static bool dbg_scrollwheel(void)
2584 lcd_setfont(FONT_SYSFIXED
);
2588 if (action_userabort(HZ
/10))
2591 lcd_clear_display();
2593 /* show internal variables of scrollwheel driver */
2594 snprintf(buf
, sizeof(buf
), "wheel touched: %s", (wheel_is_touched
) ? "true" : "false");
2595 lcd_puts(0, 0, buf
);
2596 snprintf(buf
, sizeof(buf
), "new position: %2d", new_wheel_value
);
2597 lcd_puts(0, 1, buf
);
2598 snprintf(buf
, sizeof(buf
), "old position: %2d", old_wheel_value
);
2599 lcd_puts(0, 2, buf
);
2600 snprintf(buf
, sizeof(buf
), "wheel delta: %2d", wheel_delta
);
2601 lcd_puts(0, 3, buf
);
2602 snprintf(buf
, sizeof(buf
), "accumulated delta: %2d", accumulated_wheel_delta
);
2603 lcd_puts(0, 4, buf
);
2604 snprintf(buf
, sizeof(buf
), "velo [deg/s]: %4d", (int)wheel_velocity
);
2605 lcd_puts(0, 5, buf
);
2607 /* show effective accelerated scrollspeed */
2608 speed
= button_apply_acceleration( (1<<31)|(1<<24)|wheel_velocity
);
2609 snprintf(buf
, sizeof(buf
), "accel. speed: %4d", speed
);
2610 lcd_puts(0, 6, buf
);
2614 lcd_setfont(FONT_UI
);
2619 #if defined (HAVE_USBSTACK)
2621 #if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL)
2622 static bool toggle_usb_core_driver(int driver
, char *msg
)
2624 bool enabled
= !usb_core_driver_enabled(driver
);
2626 usb_core_enable_driver(driver
,enabled
);
2627 splashf(HZ
, "%s %s", msg
, enabled
?"enabled":"disabled");
2632 static bool toggle_usb_serial(void)
2634 return toggle_usb_core_driver(USB_DRIVER_SERIAL
,"USB Serial");
2640 #if CONFIG_USBOTG == USBOTG_ISP1583
2641 extern int dbg_usb_num_items(void);
2642 extern char* dbg_usb_item(int selected_item
, void *data
, char *buffer
, size_t buffer_len
);
2644 static int isp1583_action_callback(int action
, struct gui_synclist
*lists
)
2647 if (action
== ACTION_NONE
)
2648 action
= ACTION_REDRAW
;
2652 static bool dbg_isp1583(void)
2654 struct simplelist_info isp1583
;
2655 isp1583
.scroll_all
= true;
2656 simplelist_info_init(&isp1583
, "ISP1583", dbg_usb_num_items(), NULL
);
2657 isp1583
.timeout
= HZ
/100;
2658 isp1583
.hide_selection
= true;
2659 isp1583
.get_name
= dbg_usb_item
;
2660 isp1583
.action_callback
= isp1583_action_callback
;
2661 return simplelist_show_list(&isp1583
);
2665 #if defined(CREATIVE_ZVx) && !defined(SIMULATOR)
2666 extern int pic_dbg_num_items(void);
2667 extern char* pic_dbg_item(int selected_item
, void *data
, char *buffer
, size_t buffer_len
);
2669 static int pic_action_callback(int action
, struct gui_synclist
*lists
)
2672 if (action
== ACTION_NONE
)
2673 action
= ACTION_REDRAW
;
2677 static bool dbg_pic(void)
2679 struct simplelist_info pic
;
2680 pic
.scroll_all
= true;
2681 simplelist_info_init(&pic
, "PIC", pic_dbg_num_items(), NULL
);
2682 pic
.timeout
= HZ
/100;
2683 pic
.hide_selection
= true;
2684 pic
.get_name
= pic_dbg_item
;
2685 pic
.action_callback
= pic_action_callback
;
2686 return simplelist_show_list(&pic
);
2691 /****** The menu *********/
2692 struct the_menu_item
{
2693 unsigned char *desc
; /* string or ID */
2694 bool (*function
) (void); /* return true if USB was connected */
2696 static const struct the_menu_item menuitems
[] = {
2697 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || \
2698 (defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD))
2699 { "Dump ROM contents", dbg_save_roms
},
2701 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || defined(CPU_PP) \
2702 || CONFIG_CPU == S3C2440 || CONFIG_CPU == IMX31L || CONFIG_CPU == AS3525 \
2703 || CONFIG_CPU == DM320
2704 { "View I/O ports", dbg_ports
},
2706 #if (CONFIG_RTC == RTC_PCF50605) && !defined(SIMULATOR)
2707 { "View PCF registers", dbg_pcf
},
2709 #if defined(HAVE_TSC2100) && !defined(SIMULATOR)
2710 { "TSC2100 debug", tsc2100_debug
},
2712 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
2713 { "CPU frequency", dbg_cpufreq
},
2715 #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR)
2716 { "S/PDIF analyzer", dbg_spdif
},
2718 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2719 { "Catch mem accesses", dbg_set_memory_guard
},
2721 { "View OS stacks", dbg_os
},
2722 #ifdef HAVE_LCD_BITMAP
2724 { "View battery", view_battery
},
2726 { "Screendump", dbg_screendump
},
2729 { "View HW info", dbg_hw_info
},
2732 { "View partitions", dbg_partitions
},
2735 { "View disk info", dbg_disk_info
},
2736 #if (CONFIG_STORAGE & STORAGE_ATA)
2737 { "Dump ATA identify info", dbg_identify_info
},
2740 #ifdef HAVE_DIRCACHE
2741 { "View dircache info", dbg_dircache_info
},
2743 #ifdef HAVE_TAGCACHE
2744 { "View database info", dbg_tagcache_info
},
2746 #ifdef HAVE_LCD_BITMAP
2747 #if CONFIG_CODEC == SWCODEC
2748 { "View buffering thread", dbg_buffering_thread
},
2749 #elif !defined(SIMULATOR)
2750 { "View audio thread", dbg_audio_thread
},
2753 { "pm histogram", peak_meter_histogram
},
2754 #endif /* PM_DEBUG */
2755 #endif /* HAVE_LCD_BITMAP */
2758 { "FM Radio", dbg_fm_radio
},
2761 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2762 { "Write back EEPROM", dbg_write_eeprom
},
2764 #if CONFIG_USBOTG == USBOTG_ISP1583
2765 { "View ISP1583 info", dbg_isp1583
},
2767 #if defined(CREATIVE_ZVx) && !defined(SIMULATOR)
2768 { "View PIC info", dbg_pic
},
2770 #ifdef ROCKBOX_HAS_LOGF
2771 {"logf", logfdisplay
},
2772 {"logfdump", logfdump
},
2774 #if defined(HAVE_USBSTACK)
2775 #if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL)
2776 {"USB Serial driver (logf)", toggle_usb_serial
},
2778 #endif /* HAVE_USBSTACK */
2779 #ifdef CPU_BOOST_LOGGING
2780 {"cpu_boost log",cpu_boost_log
},
2782 #if (defined(HAVE_WHEEL_ACCELERATION) && (CONFIG_KEYPAD==IPOD_4G_PAD) && !defined(SIMULATOR))
2783 {"Debug scrollwheel", dbg_scrollwheel
},
2786 static int menu_action_callback(int btn
, struct gui_synclist
*lists
)
2788 if (btn
== ACTION_STD_OK
)
2790 int oldbars
= viewportmanager_set_statusbar(VP_SB_HIDE_ALL
);
2791 menuitems
[gui_synclist_get_sel_pos(lists
)].function();
2792 btn
= ACTION_REDRAW
;
2793 viewportmanager_set_statusbar(oldbars
);
2797 static char* dbg_menu_getname(int item
, void * data
,
2798 char *buffer
, size_t buffer_len
)
2800 (void)data
; (void)buffer
; (void)buffer_len
;
2801 return menuitems
[item
].desc
;
2803 bool debug_menu(void)
2805 struct simplelist_info info
;
2807 simplelist_info_init(&info
, "Debug Menu", ARRAYLEN(menuitems
), NULL
);
2808 info
.action_callback
= menu_action_callback
;
2809 info
.get_name
= dbg_menu_getname
;
2810 return simplelist_show_list(&info
);