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 "buffering.h"
79 #if defined(HAVE_SPDIF_OUT) || defined(HAVE_SPDIF_IN)
83 #ifdef IRIVER_H300_SERIES
84 #include "pcf50606.h" /* for pcf50606_read */
91 /*---------------------------------------------------*/
92 /* SPECIAL DEBUG STUFF */
93 /*---------------------------------------------------*/
94 extern struct thread_entry threads
[MAXTHREADS
];
96 static char thread_status_char(unsigned status
)
98 static const char thread_status_chars
[THREAD_NUM_STATES
+1] =
100 [0 ... THREAD_NUM_STATES
] = '?',
101 [STATE_RUNNING
] = 'R',
102 [STATE_BLOCKED
] = 'B',
103 [STATE_SLEEPING
] = 'S',
104 [STATE_BLOCKED_W_TMO
] = 'T',
105 [STATE_FROZEN
] = 'F',
106 [STATE_KILLED
] = 'K',
110 if (status
== STATE_BUSY
) /* Not a state index */
114 if (status
> THREAD_NUM_STATES
)
115 status
= THREAD_NUM_STATES
;
117 return thread_status_chars
[status
];
120 static char* threads_getname(int selected_item
, void * data
, char *buffer
)
124 struct thread_entry
*thread
= NULL
;
129 if (selected_item
< (int)NUM_CORES
)
131 usage
= idle_stack_usage(selected_item
);
132 snprintf(buffer
, MAX_PATH
, "Idle (%d): %2d%%", selected_item
, usage
);
136 selected_item
-= NUM_CORES
;
139 thread
= &threads
[selected_item
];
140 status
= thread_get_status(thread
);
142 if (status
== STATE_KILLED
)
144 snprintf(buffer
, MAX_PATH
, "%2d: ---", selected_item
);
148 thread_get_name(name
, 32, thread
);
149 usage
= thread_stack_usage(thread
);
151 snprintf(buffer
, MAX_PATH
,
152 "%2d: " IF_COP("(%d) ") "%c%c " IF_PRIO("%d ") "%2d%% %s",
154 IF_COP(thread
->core
,)
155 (status
== STATE_RUNNING
) ? '*' : ' ',
156 thread_status_char(status
),
157 IF_PRIO(thread
->priority
,)
162 static int dbg_threads_action_callback(int action
, struct gui_synclist
*lists
)
165 #ifdef ROCKBOX_HAS_LOGF
166 if (action
== ACTION_STD_OK
)
168 int selpos
= gui_synclist_get_sel_pos(lists
);
170 if (selpos
>= NUM_CORES
)
171 remove_thread(&threads
[selpos
- NUM_CORES
]);
173 remove_thread(&threads
[selpos
]);
175 return ACTION_REDRAW
;
177 #endif /* ROCKBOX_HAS_LOGF */
181 static bool dbg_os(void)
183 struct simplelist_info info
;
184 simplelist_info_init(&info
, IF_COP("Core and ") "Stack usage:",
188 MAXTHREADS
+NUM_CORES
,
191 #ifndef ROCKBOX_HAS_LOGF
192 info
.hide_selection
= true;
194 info
.action_callback
= dbg_threads_action_callback
;
195 info
.get_name
= threads_getname
;
196 return simplelist_show_list(&info
);
199 #ifdef HAVE_LCD_BITMAP
200 #if CONFIG_CODEC != SWCODEC
202 static bool dbg_audio_thread(void)
205 struct audio_debug d
;
207 lcd_setmargins(0, 0);
208 lcd_setfont(FONT_SYSFIXED
);
212 if (action_userabort(HZ
/5))
215 audio_get_debugdata(&d
);
219 snprintf(buf
, sizeof(buf
), "read: %x", d
.audiobuf_read
);
221 snprintf(buf
, sizeof(buf
), "write: %x", d
.audiobuf_write
);
223 snprintf(buf
, sizeof(buf
), "swap: %x", d
.audiobuf_swapwrite
);
225 snprintf(buf
, sizeof(buf
), "playing: %d", d
.playing
);
227 snprintf(buf
, sizeof(buf
), "playable: %x", d
.playable_space
);
229 snprintf(buf
, sizeof(buf
), "unswapped: %x", d
.unswapped_space
);
232 /* Playable space left */
233 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8, 112, 4, d
.audiobuflen
, 0,
234 d
.playable_space
, HORIZONTAL
);
236 /* Show the watermark limit */
237 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8+4, 112, 4, d
.audiobuflen
, 0,
238 d
.low_watermark_level
, HORIZONTAL
);
240 snprintf(buf
, sizeof(buf
), "wm: %x - %x",
241 d
.low_watermark_level
, d
.lowest_watermark_level
);
248 #endif /* !SIMULATOR */
249 #else /* CONFIG_CODEC == SWCODEC */
250 extern size_t filebuflen
;
251 /* This is a size_t, but call it a long so it puts a - when it's bad. */
253 static unsigned int ticks
, boost_ticks
;
255 static void dbg_audio_task(void)
258 if(FREQ
> CPUFREQ_NORMAL
)
265 static bool dbg_audio_thread(void)
272 size_t bufsize
= pcmbuf_get_bufsize();
273 int pcmbufdescs
= pcmbuf_descs();
275 ticks
= boost_ticks
= 0;
277 tick_add_task(dbg_audio_task
);
279 lcd_setmargins(0, 0);
280 lcd_setfont(FONT_SYSFIXED
);
283 button
= get_action(CONTEXT_STD
,HZ
/5);
286 case ACTION_STD_NEXT
:
289 case ACTION_STD_PREV
:
292 case ACTION_STD_CANCEL
:
299 bufused
= bufsize
- pcmbuf_free();
301 snprintf(buf
, sizeof(buf
), "pcm: %7ld/%7ld", (long) bufused
, (long) bufsize
);
302 lcd_puts(0, line
++, buf
);
304 /* Playable space left */
305 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6, bufsize
, 0, bufused
, HORIZONTAL
);
308 snprintf(buf
, sizeof(buf
), "codec: %8ld/%8ld", audio_filebufused(), (long) filebuflen
);
309 lcd_puts(0, line
++, buf
);
311 /* Playable space left */
312 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6, filebuflen
, 0,
313 audio_filebufused(), HORIZONTAL
);
316 snprintf(buf
, sizeof(buf
), "track count: %2d", audio_track_count());
317 lcd_puts(0, line
++, buf
);
320 snprintf(buf
, sizeof(buf
), "cpu freq: %3dMHz",
321 (int)((FREQ
+ 500000) / 1000000));
322 lcd_puts(0, line
++, buf
);
327 snprintf(buf
, sizeof(buf
), "boost ratio: %3d%%",
328 boost_ticks
* 100 / ticks
);
329 lcd_puts(0, line
++, buf
);
332 snprintf(buf
, sizeof(buf
), "pcmbufdesc: %2d/%2d",
333 pcmbuf_used_descs(), pcmbufdescs
);
334 lcd_puts(0, line
++, buf
);
339 tick_remove_task(dbg_audio_task
);
344 static bool dbg_buffering_thread(void)
350 struct buffering_debug d
;
352 lcd_setmargins(0, 0);
353 lcd_setfont(FONT_SYSFIXED
);
356 button
= get_action(CONTEXT_STD
,HZ
/5);
359 case ACTION_STD_NEXT
:
362 case ACTION_STD_PREV
:
365 case ACTION_STD_CANCEL
:
370 buffering_get_debugdata(&d
);
375 snprintf(buf
, sizeof(buf
), "handle count: %d", (int)d
.num_handles
);
376 lcd_puts(0, line
++, buf
);
378 snprintf(buf
, sizeof(buf
), "track count: %2d", audio_track_count()-1);
379 lcd_puts(0, line
++, buf
);
381 snprintf(buf
, sizeof(buf
), "data_rem: %8ld", (long)d
.data_rem
);
382 lcd_puts(0, line
++, buf
);
384 snprintf(buf
, sizeof(buf
), "alloc: %8ld/%8ld", audio_filebufused(),
386 lcd_puts(0, line
++, buf
);
388 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
389 filebuflen
, 0, audio_filebufused(), HORIZONTAL
);
392 snprintf(buf
, sizeof(buf
), "real: %8ld/%8ld", (long)d
.buffered_data
,
394 lcd_puts(0, line
++, buf
);
396 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
397 filebuflen
, 0, d
.buffered_data
, HORIZONTAL
);
401 snprintf(buf
, sizeof(buf
), "cpu freq: %3dMHz",
402 (int)((FREQ
+ 500000) / 1000000));
403 lcd_puts(0, line
++, buf
);
411 #endif /* CONFIG_CODEC */
412 #endif /* HAVE_LCD_BITMAP */
415 #if (CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE))
416 /* Tool function to read the flash manufacturer and type, if available.
417 Only chips which could be reprogrammed in system will return values.
418 (The mode switch addresses vary between flash manufacturers, hence addr1/2) */
419 /* In IRAM to avoid problems when running directly from Flash */
420 static bool dbg_flash_id(unsigned* p_manufacturer
, unsigned* p_device
,
421 unsigned addr1
, unsigned addr2
)
422 ICODE_ATTR
__attribute__((noinline
));
423 static bool dbg_flash_id(unsigned* p_manufacturer
, unsigned* p_device
,
424 unsigned addr1
, unsigned addr2
)
427 unsigned not_manu
, not_id
; /* read values before switching to ID mode */
428 unsigned manu
, id
; /* read values when in ID mode */
430 #if CONFIG_CPU == SH7034
431 volatile unsigned char* flash
= (unsigned char*)0x2000000; /* flash mapping */
432 #elif defined(CPU_COLDFIRE)
433 volatile unsigned short* flash
= (unsigned short*)0; /* flash mapping */
435 int old_level
; /* saved interrupt level */
437 not_manu
= flash
[0]; /* read the normal content */
438 not_id
= flash
[1]; /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */
440 /* disable interrupts, prevent any stray flash access */
441 old_level
= set_irq_level(HIGHEST_IRQ_LEVEL
);
443 flash
[addr1
] = 0xAA; /* enter command mode */
445 flash
[addr1
] = 0x90; /* ID command */
446 /* Atmel wants 20ms pause here */
447 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
449 manu
= flash
[0]; /* read the IDs */
452 flash
[0] = 0xF0; /* reset flash (back to normal read mode) */
453 /* Atmel wants 20ms pause here */
454 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
456 set_irq_level(old_level
); /* enable interrupts again */
458 /* I assume success if the obtained values are different from
459 the normal flash content. This is not perfectly bulletproof, they
460 could theoretically be the same by chance, causing us to fail. */
461 if (not_manu
!= manu
|| not_id
!= id
) /* a value has changed */
463 *p_manufacturer
= manu
; /* return the results */
465 return true; /* success */
467 return false; /* fail */
469 #endif /* (CONFIG_CPU == SH7034 || CPU_COLDFIRE) */
473 static int perfcheck(void)
479 "orr r0, r2, #0xc0 \n" /* disable IRQ and FIQ */
482 "ldr r0, [%[timr]] \n"
483 "add r0, r0, %[tmo] \n"
485 "add %[res], %[res], #1 \n"
486 "ldr r1, [%[timr]] \n"
489 "msr CPSR_c, r2 \n" /* reset IRQ and FIQ state */
493 [timr
]"r"(&USEC_TIMER
),
495 #if CONFIG_CPU == PP5002
497 #else /* PP5020/5022/5024 */
508 #ifdef HAVE_LCD_BITMAP
509 static bool dbg_hw_info(void)
511 #if CONFIG_CPU == SH7034
513 int bitmask
= HW_MASK
;
514 int rom_version
= ROM_VERSION
;
515 unsigned manu
, id
; /* flash IDs */
516 bool got_id
; /* flag if we managed to get the flash IDs */
517 unsigned rom_crc
= 0xffffffff; /* CRC32 of the boot ROM */
518 bool has_bootrom
; /* flag for boot ROM present */
519 int oldmode
; /* saved memory guard mode */
521 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
523 /* get flash ROM type */
524 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
526 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
528 /* check if the boot ROM area is a flash mirror */
529 has_bootrom
= (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
530 if (has_bootrom
) /* if ROM and Flash different */
532 /* calculate CRC16 checksum of boot ROM */
533 rom_crc
= crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
536 system_memory_guard(oldmode
); /* re-enable memory guard */
538 lcd_setmargins(0, 0);
539 lcd_setfont(FONT_SYSFIXED
);
542 lcd_puts(0, 0, "[Hardware info]");
544 snprintf(buf
, 32, "ROM: %d.%02d", rom_version
/100, rom_version
%100);
547 snprintf(buf
, 32, "Mask: 0x%04x", bitmask
);
551 snprintf(buf
, 32, "Flash: M=%02x D=%02x", manu
, id
);
553 snprintf(buf
, 32, "Flash: M=?? D=??"); /* unknown, sorry */
558 if (rom_crc
== 0x56DBA4EE) /* known Version 1 */
559 snprintf(buf
, 32, "Boot ROM: V1");
561 snprintf(buf
, 32, "ROMcrc: 0x%08x", rom_crc
);
565 snprintf(buf
, 32, "Boot ROM: none");
571 while (!(action_userabort(TIMEOUT_BLOCK
)));
573 #elif CONFIG_CPU == MCF5249 || CONFIG_CPU == MCF5250
575 unsigned manu
, id
; /* flash IDs */
576 int got_id
; /* flag if we managed to get the flash IDs */
577 int oldmode
; /* saved memory guard mode */
580 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
582 /* get flash ROM type */
583 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
585 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
587 system_memory_guard(oldmode
); /* re-enable memory guard */
589 lcd_setmargins(0, 0);
590 lcd_setfont(FONT_SYSFIXED
);
593 lcd_puts(0, line
++, "[Hardware info]");
596 snprintf(buf
, 32, "Flash: M=%04x D=%04x", manu
, id
);
598 snprintf(buf
, 32, "Flash: M=???? D=????"); /* unknown, sorry */
599 lcd_puts(0, line
++, buf
);
605 lcd_puts(0, ++line
, "Serial Number:");
607 got_id
= ds2411_read_id(&id
);
609 if (got_id
== DS2411_OK
)
611 snprintf(buf
, 32, " FC=%02x", (unsigned)id
.family_code
);
612 lcd_puts(0, ++line
, buf
);
613 snprintf(buf
, 32, " ID=%02X %02X %02X %02X %02X %02X",
614 (unsigned)id
.uid
[0], (unsigned)id
.uid
[1], (unsigned)id
.uid
[2],
615 (unsigned)id
.uid
[3], (unsigned)id
.uid
[4], (unsigned)id
.uid
[5]);
616 lcd_puts(0, ++line
, buf
);
617 snprintf(buf
, 32, " CRC=%02X", (unsigned)id
.crc
);
621 snprintf(buf
, 32, "READ ERR=%d", got_id
);
624 lcd_puts(0, ++line
, buf
);
630 while (!(action_userabort(TIMEOUT_BLOCK
)));
632 #elif defined(CPU_PP502x)
635 char pp_version
[] = { (PP_VER2
>> 24) & 0xff, (PP_VER2
>> 16) & 0xff,
636 (PP_VER2
>> 8) & 0xff, (PP_VER2
) & 0xff,
637 (PP_VER1
>> 24) & 0xff, (PP_VER1
>> 16) & 0xff,
638 (PP_VER1
>> 8) & 0xff, (PP_VER1
) & 0xff, '\0' };
640 lcd_setmargins(0, 0);
641 lcd_setfont(FONT_SYSFIXED
);
644 lcd_puts(0, line
++, "[Hardware info]");
647 snprintf(buf
, sizeof(buf
), "HW rev: 0x%08lx", IPOD_HW_REVISION
);
648 lcd_puts(0, line
++, buf
);
652 extern int lcd_type
; /* Defined in lcd-colornano.c */
654 snprintf(buf
, sizeof(buf
), "LCD type: %d", lcd_type
);
655 lcd_puts(0, line
++, buf
);
658 snprintf(buf
, sizeof(buf
), "PP version: %s", pp_version
);
659 lcd_puts(0, line
++, buf
);
661 snprintf(buf
, sizeof(buf
), "Est. clock (kHz): %d", perfcheck());
662 lcd_puts(0, line
++, buf
);
666 while (!(action_userabort(TIMEOUT_BLOCK
)));
668 #elif CONFIG_CPU == PP5002
672 lcd_setmargins(0, 0);
673 lcd_setfont(FONT_SYSFIXED
);
676 lcd_puts(0, line
++, "[Hardware info]");
679 snprintf(buf
, sizeof(buf
), "HW rev: 0x%08lx", IPOD_HW_REVISION
);
680 lcd_puts(0, line
++, buf
);
683 snprintf(buf
, sizeof(buf
), "Est. clock (kHz): %d", perfcheck());
684 lcd_puts(0, line
++, buf
);
688 while (!(action_userabort(TIMEOUT_BLOCK
)));
690 #endif /* CONFIG_CPU */
693 #else /* !HAVE_LCD_BITMAP */
694 static bool dbg_hw_info(void)
699 int rom_version
= ROM_VERSION
;
700 unsigned manu
, id
; /* flash IDs */
701 bool got_id
; /* flag if we managed to get the flash IDs */
702 unsigned rom_crc
= 0xffffffff; /* CRC32 of the boot ROM */
703 bool has_bootrom
; /* flag for boot ROM present */
704 int oldmode
; /* saved memory guard mode */
706 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
708 /* get flash ROM type */
709 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
711 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
713 /* check if the boot ROM area is a flash mirror */
714 has_bootrom
= (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
715 if (has_bootrom
) /* if ROM and Flash different */
717 /* calculate CRC16 checksum of boot ROM */
718 rom_crc
= crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
721 system_memory_guard(oldmode
); /* re-enable memory guard */
725 lcd_puts(0, 0, "[HW Info]");
731 snprintf(buf
, 32, "ROM: %d.%02d",
732 rom_version
/100, rom_version
%100);
736 snprintf(buf
, 32, "Flash:%02x,%02x", manu
, id
);
738 snprintf(buf
, 32, "Flash:??,??"); /* unknown, sorry */
743 if (rom_crc
== 0x56DBA4EE) /* known Version 1 */
744 snprintf(buf
, 32, "BootROM: V1");
745 else if (rom_crc
== 0x358099E8)
746 snprintf(buf
, 32, "BootROM: V2");
747 /* alternative boot ROM found in one single player so far */
749 snprintf(buf
, 32, "R: %08x", rom_crc
);
752 snprintf(buf
, 32, "BootROM: no");
758 button
= get_action(CONTEXT_SETTINGS
,TIMEOUT_BLOCK
);
762 case ACTION_STD_CANCEL
:
765 case ACTION_SETTINGS_DEC
:
771 case ACTION_SETTINGS_INC
:
780 #endif /* !HAVE_LCD_BITMAP */
781 #endif /* !SIMULATOR */
784 static char* dbg_partitions_getname(int selected_item
, void * data
, char *buffer
)
787 int partition
= selected_item
/2;
788 struct partinfo
* p
= disk_partinfo(partition
);
791 snprintf(buffer
, MAX_PATH
, " T:%x %ld MB", p
->type
, p
->size
/ 2048);
795 snprintf(buffer
, MAX_PATH
, "P%d: S:%lx", partition
, p
->start
);
800 bool dbg_partitions(void)
802 struct simplelist_info info
;
803 simplelist_info_init(&info
, "Partition Info", 4, NULL
);
804 info
.selection_size
= 2;
805 info
.hide_selection
= true;
806 info
.get_name
= dbg_partitions_getname
;
807 return simplelist_show_list(&info
);
811 #if defined(CPU_COLDFIRE) && defined(HAVE_SPDIF_OUT)
812 static bool dbg_spdif(void)
816 unsigned int control
;
821 unsigned int interruptstat
;
822 bool valnogood
, symbolerr
, parityerr
;
825 int spdif_source
= spdif_get_output_source(&spdif_src_on
);
826 spdif_set_output_source(AUDIO_SRC_SPDIF
IF_SPDIF_POWER_(, true));
828 lcd_setmargins(0, 0);
830 lcd_setfont(FONT_SYSFIXED
);
832 #ifdef HAVE_SPDIF_POWER
833 spdif_power_enable(true); /* We need SPDIF power for both sending & receiving */
840 control
= EBU1RCVCCHANNEL1
;
841 interruptstat
= INTERRUPTSTAT
;
842 INTERRUPTCLEAR
= 0x03c00000;
844 valnogood
= (interruptstat
& 0x01000000)?true:false;
845 symbolerr
= (interruptstat
& 0x00800000)?true:false;
846 parityerr
= (interruptstat
& 0x00400000)?true:false;
848 snprintf(buf
, sizeof(buf
), "Val: %s Sym: %s Par: %s",
851 parityerr
?"--":"OK");
852 lcd_puts(0, line
++, buf
);
854 snprintf(buf
, sizeof(buf
), "Status word: %08x", (int)control
);
855 lcd_puts(0, line
++, buf
);
860 snprintf(buf
, sizeof(buf
), "PRO: %d (%s)",
861 x
, x
?"Professional":"Consumer");
862 lcd_puts(0, line
++, buf
);
864 x
= (control
>> 30) & 1;
865 snprintf(buf
, sizeof(buf
), "Audio: %d (%s)",
866 x
, x
?"Non-PCM":"PCM");
867 lcd_puts(0, line
++, buf
);
869 x
= (control
>> 29) & 1;
870 snprintf(buf
, sizeof(buf
), "Copy: %d (%s)",
871 x
, x
?"Permitted":"Inhibited");
872 lcd_puts(0, line
++, buf
);
874 x
= (control
>> 27) & 7;
887 snprintf(buf
, sizeof(buf
), "Preemphasis: %d (%s)", x
, s
);
888 lcd_puts(0, line
++, buf
);
890 x
= (control
>> 24) & 3;
891 snprintf(buf
, sizeof(buf
), "Mode: %d", x
);
892 lcd_puts(0, line
++, buf
);
894 category
= (control
>> 17) & 127;
906 snprintf(buf
, sizeof(buf
), "Category: 0x%02x (%s)", category
, s
);
907 lcd_puts(0, line
++, buf
);
909 x
= (control
>> 16) & 1;
911 if(((category
& 0x70) == 0x10) ||
912 ((category
& 0x70) == 0x40) ||
913 ((category
& 0x78) == 0x38))
915 generation
= !generation
;
917 snprintf(buf
, sizeof(buf
), "Generation: %d (%s)",
918 x
, generation
?"Original":"No ind.");
919 lcd_puts(0, line
++, buf
);
921 x
= (control
>> 12) & 15;
922 snprintf(buf
, sizeof(buf
), "Source: %d", x
);
923 lcd_puts(0, line
++, buf
);
925 x
= (control
>> 8) & 15;
941 snprintf(buf
, sizeof(buf
), "Channel: %d (%s)", x
, s
);
942 lcd_puts(0, line
++, buf
);
944 x
= (control
>> 4) & 15;
957 snprintf(buf
, sizeof(buf
), "Frequency: %d (%s)", x
, s
);
958 lcd_puts(0, line
++, buf
);
960 x
= (control
>> 2) & 3;
961 snprintf(buf
, sizeof(buf
), "Clock accuracy: %d", x
);
962 lcd_puts(0, line
++, buf
);
966 snprintf(buf
, sizeof(buf
), "Measured freq: %ldHz",
967 spdif_measure_frequency());
968 lcd_puts(0, line
++, buf
);
973 if (action_userabort(HZ
/10))
977 spdif_set_output_source(spdif_source
IF_SPDIF_POWER_(, spdif_src_on
));
979 #ifdef HAVE_SPDIF_POWER
980 spdif_power_enable(global_settings
.spdif_enable
);
985 #endif /* CPU_COLDFIRE */
988 #ifdef HAVE_LCD_BITMAP
989 /* button definitions */
990 #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
991 (CONFIG_KEYPAD == IRIVER_H300_PAD)
992 # define DEBUG_CANCEL BUTTON_OFF
994 #elif CONFIG_KEYPAD == RECORDER_PAD
995 # define DEBUG_CANCEL BUTTON_OFF
997 #elif CONFIG_KEYPAD == ONDIO_PAD
998 # define DEBUG_CANCEL BUTTON_MENU
1000 #elif (CONFIG_KEYPAD == IPOD_1G2G_PAD) || \
1001 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
1002 (CONFIG_KEYPAD == IPOD_4G_PAD)
1003 # define DEBUG_CANCEL BUTTON_MENU
1005 #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
1006 # define DEBUG_CANCEL BUTTON_PLAY
1008 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
1009 # define DEBUG_CANCEL BUTTON_REC
1011 #elif CONFIG_KEYPAD == GIGABEAT_PAD
1012 # define DEBUG_CANCEL BUTTON_A
1014 #elif CONFIG_KEYPAD == IRIVER_H10_PAD
1015 # define DEBUG_CANCEL BUTTON_REW
1017 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
1018 (CONFIG_KEYPAD == SANSA_C200_PAD)
1019 # define DEBUG_CANCEL BUTTON_LEFT
1020 #endif /* key definitios */
1023 bool dbg_ports(void)
1025 #if CONFIG_CPU == SH7034
1026 unsigned short porta
;
1027 unsigned short portb
;
1028 unsigned char portc
;
1030 int adc_battery_voltage
, adc_battery_level
;
1032 lcd_setfont(FONT_SYSFIXED
);
1033 lcd_setmargins(0, 0);
1034 lcd_clear_display();
1042 snprintf(buf
, 32, "PADR: %04x", porta
);
1043 lcd_puts(0, 0, buf
);
1044 snprintf(buf
, 32, "PBDR: %04x", portb
);
1045 lcd_puts(0, 1, buf
);
1047 snprintf(buf
, 32, "AN0: %03x AN4: %03x", adc_read(0), adc_read(4));
1048 lcd_puts(0, 2, buf
);
1049 snprintf(buf
, 32, "AN1: %03x AN5: %03x", adc_read(1), adc_read(5));
1050 lcd_puts(0, 3, buf
);
1051 snprintf(buf
, 32, "AN2: %03x AN6: %03x", adc_read(2), adc_read(6));
1052 lcd_puts(0, 4, buf
);
1053 snprintf(buf
, 32, "AN3: %03x AN7: %03x", adc_read(3), adc_read(7));
1054 lcd_puts(0, 5, buf
);
1056 battery_read_info(&adc_battery_voltage
, &adc_battery_level
);
1057 snprintf(buf
, 32, "Batt: %d.%03dV %d%% ", adc_battery_voltage
/ 1000,
1058 adc_battery_voltage
% 1000, adc_battery_level
);
1059 lcd_puts(0, 6, buf
);
1062 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1065 #elif defined(CPU_COLDFIRE)
1066 unsigned int gpio_out
;
1067 unsigned int gpio1_out
;
1068 unsigned int gpio_read
;
1069 unsigned int gpio1_read
;
1070 unsigned int gpio_function
;
1071 unsigned int gpio1_function
;
1072 unsigned int gpio_enable
;
1073 unsigned int gpio1_enable
;
1074 int adc_buttons
, adc_remote
;
1075 int adc_battery_voltage
, adc_battery_level
;
1079 lcd_setmargins(0, 0);
1080 lcd_clear_display();
1081 lcd_setfont(FONT_SYSFIXED
);
1086 gpio_read
= GPIO_READ
;
1087 gpio1_read
= GPIO1_READ
;
1088 gpio_out
= GPIO_OUT
;
1089 gpio1_out
= GPIO1_OUT
;
1090 gpio_function
= GPIO_FUNCTION
;
1091 gpio1_function
= GPIO1_FUNCTION
;
1092 gpio_enable
= GPIO_ENABLE
;
1093 gpio1_enable
= GPIO1_ENABLE
;
1095 snprintf(buf
, sizeof(buf
), "GPIO_READ: %08x", gpio_read
);
1096 lcd_puts(0, line
++, buf
);
1097 snprintf(buf
, sizeof(buf
), "GPIO_OUT: %08x", gpio_out
);
1098 lcd_puts(0, line
++, buf
);
1099 snprintf(buf
, sizeof(buf
), "GPIO_FUNCTION: %08x", gpio_function
);
1100 lcd_puts(0, line
++, buf
);
1101 snprintf(buf
, sizeof(buf
), "GPIO_ENABLE: %08x", gpio_enable
);
1102 lcd_puts(0, line
++, buf
);
1104 snprintf(buf
, sizeof(buf
), "GPIO1_READ: %08x", gpio1_read
);
1105 lcd_puts(0, line
++, buf
);
1106 snprintf(buf
, sizeof(buf
), "GPIO1_OUT: %08x", gpio1_out
);
1107 lcd_puts(0, line
++, buf
);
1108 snprintf(buf
, sizeof(buf
), "GPIO1_FUNCTION: %08x", gpio1_function
);
1109 lcd_puts(0, line
++, buf
);
1110 snprintf(buf
, sizeof(buf
), "GPIO1_ENABLE: %08x", gpio1_enable
);
1111 lcd_puts(0, line
++, buf
);
1113 adc_buttons
= adc_read(ADC_BUTTONS
);
1114 adc_remote
= adc_read(ADC_REMOTE
);
1115 battery_read_info(&adc_battery_voltage
, &adc_battery_level
);
1116 #if defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IRIVER_H300_SERIES)
1117 snprintf(buf
, sizeof(buf
), "ADC_BUTTONS (%c): %02x",
1118 button_scan_enabled() ? '+' : '-', adc_buttons
);
1120 snprintf(buf
, sizeof(buf
), "ADC_BUTTONS: %02x", adc_buttons
);
1122 lcd_puts(0, line
++, buf
);
1123 #if defined(IAUDIO_X5) || defined(IAUDIO_M5)
1124 snprintf(buf
, sizeof(buf
), "ADC_REMOTE (%c): %02x",
1125 remote_detect() ? '+' : '-', adc_remote
);
1127 snprintf(buf
, sizeof(buf
), "ADC_REMOTE: %02x", adc_remote
);
1129 lcd_puts(0, line
++, buf
);
1130 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1131 snprintf(buf
, sizeof(buf
), "ADC_REMOTEDETECT: %02x",
1132 adc_read(ADC_REMOTEDETECT
));
1133 lcd_puts(0, line
++, buf
);
1136 snprintf(buf
, 32, "Batt: %d.%03dV %d%% ", adc_battery_voltage
/ 1000,
1137 adc_battery_voltage
% 1000, adc_battery_level
);
1138 lcd_puts(0, line
++, buf
);
1140 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1141 snprintf(buf
, sizeof(buf
), "remotetype: %d", remote_type());
1142 lcd_puts(0, line
++, buf
);
1146 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1150 #elif defined(CPU_PP502x)
1152 unsigned int gpio_a
, gpio_b
, gpio_c
, gpio_d
;
1153 unsigned int gpio_e
, gpio_f
, gpio_g
, gpio_h
;
1154 unsigned int gpio_i
, gpio_j
, gpio_k
, gpio_l
;
1159 lcd_setmargins(0, 0);
1160 lcd_clear_display();
1161 lcd_setfont(FONT_SYSFIXED
);
1165 gpio_a
= GPIOA_INPUT_VAL
;
1166 gpio_b
= GPIOB_INPUT_VAL
;
1167 gpio_c
= GPIOC_INPUT_VAL
;
1169 gpio_g
= GPIOG_INPUT_VAL
;
1170 gpio_h
= GPIOH_INPUT_VAL
;
1171 gpio_i
= GPIOI_INPUT_VAL
;
1174 snprintf(buf
, sizeof(buf
), "GPIO_A: %02x GPIO_G: %02x", gpio_a
, gpio_g
);
1175 lcd_puts(0, line
++, buf
);
1176 snprintf(buf
, sizeof(buf
), "GPIO_B: %02x GPIO_H: %02x", gpio_b
, gpio_h
);
1177 lcd_puts(0, line
++, buf
);
1178 snprintf(buf
, sizeof(buf
), "GPIO_C: %02x GPIO_I: %02x", gpio_c
, gpio_i
);
1179 lcd_puts(0, line
++, buf
);
1181 gpio_d
= GPIOD_INPUT_VAL
;
1182 gpio_e
= GPIOE_INPUT_VAL
;
1183 gpio_f
= GPIOF_INPUT_VAL
;
1185 gpio_j
= GPIOJ_INPUT_VAL
;
1186 gpio_k
= GPIOK_INPUT_VAL
;
1187 gpio_l
= GPIOL_INPUT_VAL
;
1189 snprintf(buf
, sizeof(buf
), "GPIO_D: %02x GPIO_J: %02x", gpio_d
, gpio_j
);
1190 lcd_puts(0, line
++, buf
);
1191 snprintf(buf
, sizeof(buf
), "GPIO_E: %02x GPIO_K: %02x", gpio_e
, gpio_k
);
1192 lcd_puts(0, line
++, buf
);
1193 snprintf(buf
, sizeof(buf
), "GPIO_F: %02x GPIO_L: %02x", gpio_f
, gpio_l
);
1194 lcd_puts(0, line
++, buf
);
1197 snprintf(buf
, sizeof(buf
), "DEV_EN: %08lx", DEV_EN
);
1198 lcd_puts(0, line
++, buf
);
1199 snprintf(buf
, sizeof(buf
), "CLOCK_SRC: %08lx", CLOCK_SOURCE
);
1200 lcd_puts(0, line
++, buf
);
1201 snprintf(buf
, sizeof(buf
), "CLCD_CLK_SRC: %08lx", CLCD_CLOCK_SRC
);
1202 lcd_puts(0, line
++, buf
);
1203 snprintf(buf
, sizeof(buf
), "PLL_CONTROL: %08lx", PLL_CONTROL
);
1204 lcd_puts(0, line
++, buf
);
1205 snprintf(buf
, sizeof(buf
), "PLL_STATUS: %08lx", PLL_STATUS
);
1206 lcd_puts(0, line
++, buf
);
1207 snprintf(buf
, sizeof(buf
), "DEV_TIMING1: %08lx", DEV_TIMING1
);
1208 lcd_puts(0, line
++, buf
);
1210 #if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
1212 snprintf(buf
, sizeof(buf
), "BATT: %03x UNK1: %03x", adc_read(ADC_BATTERY
),
1213 adc_read(ADC_UNKNOWN_1
));
1214 lcd_puts(0, line
++, buf
);
1215 snprintf(buf
, sizeof(buf
), "REM: %03x PAD: %03x", adc_read(ADC_REMOTE
),
1216 adc_read(ADC_SCROLLPAD
));
1217 lcd_puts(0, line
++, buf
);
1218 #elif defined(SANSA_E200)
1220 snprintf(buf
, sizeof(buf
), "ADC_BVDD: %4d", adc_read(ADC_BVDD
));
1221 lcd_puts(0, line
++, buf
);
1222 snprintf(buf
, sizeof(buf
), "ADC_RTCSUP: %4d", adc_read(ADC_RTCSUP
));
1223 lcd_puts(0, line
++, buf
);
1224 snprintf(buf
, sizeof(buf
), "ADC_UVDD: %4d", adc_read(ADC_UVDD
));
1225 lcd_puts(0, line
++, buf
);
1226 snprintf(buf
, sizeof(buf
), "ADC_CHG_IN: %4d", adc_read(ADC_CHG_IN
));
1227 lcd_puts(0, line
++, buf
);
1228 snprintf(buf
, sizeof(buf
), "ADC_CVDD: %4d", adc_read(ADC_CVDD
));
1229 lcd_puts(0, line
++, buf
);
1230 snprintf(buf
, sizeof(buf
), "ADC_BATTEMP: %4d", adc_read(ADC_BATTEMP
));
1231 lcd_puts(0, line
++, buf
);
1232 snprintf(buf
, sizeof(buf
), "ADC_MICSUP1: %4d", adc_read(ADC_MICSUP1
));
1233 lcd_puts(0, line
++, buf
);
1234 snprintf(buf
, sizeof(buf
), "ADC_MICSUP2: %4d", adc_read(ADC_MICSUP2
));
1235 lcd_puts(0, line
++, buf
);
1236 snprintf(buf
, sizeof(buf
), "ADC_VBE1: %4d", adc_read(ADC_VBE1
));
1237 lcd_puts(0, line
++, buf
);
1238 snprintf(buf
, sizeof(buf
), "ADC_VBE2: %4d", adc_read(ADC_VBE2
));
1239 lcd_puts(0, line
++, buf
);
1240 snprintf(buf
, sizeof(buf
), "ADC_I_MICSUP1:%4d", adc_read(ADC_I_MICSUP1
));
1241 lcd_puts(0, line
++, buf
);
1242 snprintf(buf
, sizeof(buf
), "ADC_I_MICSUP2:%4d", adc_read(ADC_I_MICSUP2
));
1243 lcd_puts(0, line
++, buf
);
1244 snprintf(buf
, sizeof(buf
), "ADC_VBAT: %4d", adc_read(ADC_VBAT
));
1245 lcd_puts(0, line
++, buf
);
1248 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1252 #elif CONFIG_CPU == PP5002
1253 unsigned int gpio_a
, gpio_b
, gpio_c
, gpio_d
;
1258 lcd_setmargins(0, 0);
1259 lcd_clear_display();
1260 lcd_setfont(FONT_SYSFIXED
);
1264 gpio_a
= GPIOA_INPUT_VAL
;
1265 gpio_b
= GPIOB_INPUT_VAL
;
1266 gpio_c
= GPIOC_INPUT_VAL
;
1267 gpio_d
= GPIOD_INPUT_VAL
;
1270 snprintf(buf
, sizeof(buf
), "GPIO_A: %02x GPIO_B: %02x", gpio_a
, gpio_b
);
1271 lcd_puts(0, line
++, buf
);
1272 snprintf(buf
, sizeof(buf
), "GPIO_C: %02x GPIO_D: %02x", gpio_c
, gpio_d
);
1273 lcd_puts(0, line
++, buf
);
1275 snprintf(buf
, sizeof(buf
), "DEV_EN: %08lx", DEV_EN
);
1276 lcd_puts(0, line
++, buf
);
1277 snprintf(buf
, sizeof(buf
), "CLOCK_ENABLE: %08lx", CLOCK_ENABLE
);
1278 lcd_puts(0, line
++, buf
);
1279 snprintf(buf
, sizeof(buf
), "CLOCK_SOURCE: %08lx", CLOCK_SOURCE
);
1280 lcd_puts(0, line
++, buf
);
1281 snprintf(buf
, sizeof(buf
), "PLL_CONTROL: %08lx", PLL_CONTROL
);
1282 lcd_puts(0, line
++, buf
);
1283 snprintf(buf
, sizeof(buf
), "PLL_DIV: %08lx", PLL_DIV
);
1284 lcd_puts(0, line
++, buf
);
1285 snprintf(buf
, sizeof(buf
), "PLL_MULT: %08lx", PLL_MULT
);
1286 lcd_puts(0, line
++, buf
);
1287 snprintf(buf
, sizeof(buf
), "TIMING1_CTL: %08lx", TIMING1_CTL
);
1288 lcd_puts(0, line
++, buf
);
1289 snprintf(buf
, sizeof(buf
), "TIMING2_CTL: %08lx", TIMING2_CTL
);
1290 lcd_puts(0, line
++, buf
);
1293 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1296 #elif CONFIG_CPU == S3C2440
1300 lcd_setmargins(0, 0);
1301 lcd_clear_display();
1302 lcd_setfont(FONT_SYSFIXED
);
1307 snprintf(buf
, sizeof(buf
), "[Ports and Registers]"); lcd_puts(0, line
++, buf
);
1309 snprintf(buf
, sizeof(buf
), "GPACON: %08x GPBCON: %08x", GPACON
, GPBCON
); lcd_puts(0, line
++, buf
);
1310 snprintf(buf
, sizeof(buf
), "GPADAT: %08x GPBDAT: %08x", GPADAT
, GPBDAT
); lcd_puts(0, line
++, buf
);
1311 snprintf(buf
, sizeof(buf
), "GPAUP: %08x GPBUP: %08x", 0, GPBUP
); lcd_puts(0, line
++, buf
);
1312 snprintf(buf
, sizeof(buf
), "GPCCON: %08x GPDCON: %08x", GPCCON
, GPDCON
); lcd_puts(0, line
++, buf
);
1313 snprintf(buf
, sizeof(buf
), "GPCDAT: %08x GPDDAT: %08x", GPCDAT
, GPDDAT
); lcd_puts(0, line
++, buf
);
1314 snprintf(buf
, sizeof(buf
), "GPCUP: %08x GPDUP: %08x", GPCUP
, GPDUP
); lcd_puts(0, line
++, buf
);
1316 snprintf(buf
, sizeof(buf
), "GPCCON: %08x GPDCON: %08x", GPCCON
, GPDCON
); lcd_puts(0, line
++, buf
);
1317 snprintf(buf
, sizeof(buf
), "GPCDAT: %08x GPDDAT: %08x", GPCDAT
, GPDDAT
); lcd_puts(0, line
++, buf
);
1318 snprintf(buf
, sizeof(buf
), "GPCUP: %08x GPDUP: %08x", GPCUP
, GPDUP
); lcd_puts(0, line
++, buf
);
1320 snprintf(buf
, sizeof(buf
), "GPECON: %08x GPFCON: %08x", GPECON
, GPFCON
); lcd_puts(0, line
++, buf
);
1321 snprintf(buf
, sizeof(buf
), "GPEDAT: %08x GPFDAT: %08x", GPEDAT
, GPFDAT
); lcd_puts(0, line
++, buf
);
1322 snprintf(buf
, sizeof(buf
), "GPEUP: %08x GPFUP: %08x", GPEUP
, GPFUP
); lcd_puts(0, line
++, buf
);
1324 snprintf(buf
, sizeof(buf
), "GPGCON: %08x GPHCON: %08x", GPGCON
, GPHCON
); lcd_puts(0, line
++, buf
);
1325 snprintf(buf
, sizeof(buf
), "GPGDAT: %08x GPHDAT: %08x", GPGDAT
, GPHDAT
); lcd_puts(0, line
++, buf
);
1326 snprintf(buf
, sizeof(buf
), "GPGUP: %08x GPHUP: %08x", GPGUP
, GPHUP
); lcd_puts(0, line
++, buf
);
1328 snprintf(buf
, sizeof(buf
), "GPJCON: %08x", GPJCON
); lcd_puts(0, line
++, buf
);
1329 snprintf(buf
, sizeof(buf
), "GPJDAT: %08x", GPJDAT
); lcd_puts(0, line
++, buf
);
1330 snprintf(buf
, sizeof(buf
), "GPJUP: %08x", GPJUP
); lcd_puts(0, line
++, buf
);
1334 snprintf(buf
, sizeof(buf
), "SRCPND: %08x INTMOD: %08x", SRCPND
, INTMOD
); lcd_puts(0, line
++, buf
);
1335 snprintf(buf
, sizeof(buf
), "INTMSK: %08x INTPND: %08x", INTMSK
, INTPND
); lcd_puts(0, line
++, buf
);
1336 snprintf(buf
, sizeof(buf
), "CLKCON: %08x CLKSLOW: %08x", CLKCON
, CLKSLOW
); lcd_puts(0, line
++, buf
);
1337 snprintf(buf
, sizeof(buf
), "MPLLCON: %08x UPLLCON: %08x", MPLLCON
, UPLLCON
); lcd_puts(0, line
++, buf
);
1338 snprintf(buf
, sizeof(buf
), "CLKDIVN: %08x", CLKDIVN
); lcd_puts(0, line
++, buf
);
1341 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1347 #else /* !HAVE_LCD_BITMAP */
1348 bool dbg_ports(void)
1350 unsigned short porta
;
1351 unsigned short portb
;
1352 unsigned char portc
;
1355 int adc_battery_voltage
;
1358 lcd_clear_display();
1369 snprintf(buf
, 32, "PADR: %04x", porta
);
1372 snprintf(buf
, 32, "PBDR: %04x", portb
);
1375 snprintf(buf
, 32, "AN0: %03x", adc_read(0));
1378 snprintf(buf
, 32, "AN1: %03x", adc_read(1));
1381 snprintf(buf
, 32, "AN2: %03x", adc_read(2));
1384 snprintf(buf
, 32, "AN3: %03x", adc_read(3));
1387 snprintf(buf
, 32, "AN4: %03x", adc_read(4));
1390 snprintf(buf
, 32, "AN5: %03x", adc_read(5));
1393 snprintf(buf
, 32, "AN6: %03x", adc_read(6));
1396 snprintf(buf
, 32, "AN7: %03x", adc_read(7));
1400 lcd_puts(0, 0, buf
);
1402 battery_read_info(&adc_battery_voltage
, NULL
);
1403 snprintf(buf
, 32, "Batt: %d.%03dV", adc_battery_voltage
/ 1000,
1404 adc_battery_voltage
% 1000);
1405 lcd_puts(0, 1, buf
);
1408 button
= get_action(CONTEXT_SETTINGS
,HZ
/5);
1412 case ACTION_STD_CANCEL
:
1415 case ACTION_SETTINGS_DEC
:
1421 case ACTION_SETTINGS_INC
:
1430 #endif /* !HAVE_LCD_BITMAP */
1431 #endif /* !SIMULATOR */
1433 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
1434 static bool dbg_cpufreq(void)
1440 #ifdef HAVE_LCD_BITMAP
1441 lcd_setmargins(0, 0);
1442 lcd_setfont(FONT_SYSFIXED
);
1444 lcd_clear_display();
1450 snprintf(buf
, sizeof(buf
), "Frequency: %ld", FREQ
);
1451 lcd_puts(0, line
++, buf
);
1453 snprintf(buf
, sizeof(buf
), "boost_counter: %d", get_cpu_boost_counter());
1454 lcd_puts(0, line
++, buf
);
1457 button
= get_action(CONTEXT_STD
,HZ
/10);
1461 case ACTION_STD_PREV
:
1465 case ACTION_STD_NEXT
:
1470 while (get_cpu_boost_counter() > 0)
1472 set_cpu_frequency(CPUFREQ_DEFAULT
);
1475 case ACTION_STD_CANCEL
:
1482 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
1485 #ifdef HAVE_LCD_BITMAP
1487 * view_battery() shows a automatically scaled graph of the battery voltage
1488 * over time. Usable for estimating battery life / charging rate.
1489 * The power_history array is updated in power_thread of powermgmt.c.
1492 #define BAT_LAST_VAL MIN(LCD_WIDTH, POWER_HISTORY_LEN)
1493 #define BAT_YSPACE (LCD_HEIGHT - 20)
1495 static bool view_battery(void)
1499 unsigned short maxv
, minv
;
1502 lcd_setmargins(0, 0);
1503 lcd_setfont(FONT_SYSFIXED
);
1507 lcd_clear_display();
1509 case 0: /* voltage history graph */
1510 /* Find maximum and minimum voltage for scaling */
1511 minv
= power_history
[0];
1513 for (i
= 1; i
< BAT_LAST_VAL
&& power_history
[i
]; i
++) {
1514 if (power_history
[i
] > maxv
)
1515 maxv
= power_history
[i
];
1516 if (power_history
[i
] < minv
)
1517 minv
= power_history
[i
];
1520 snprintf(buf
, 30, "Battery %d.%03d", power_history
[0] / 1000,
1521 power_history
[0] % 1000);
1522 lcd_puts(0, 0, buf
);
1523 snprintf(buf
, 30, "scale %d.%03d-%d.%03dV",
1524 minv
/ 1000, minv
% 1000, maxv
/ 1000, maxv
% 1000);
1525 lcd_puts(0, 1, buf
);
1528 for (i
= BAT_LAST_VAL
- 1; i
>= 0; i
--) {
1529 y
= (power_history
[i
] - minv
) * BAT_YSPACE
/ (maxv
- minv
);
1530 lcd_set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
1531 lcd_vline(x
, LCD_HEIGHT
-1, 20);
1532 lcd_set_drawmode(DRMODE_SOLID
);
1533 lcd_vline(x
, LCD_HEIGHT
-1,
1534 MIN(MAX(LCD_HEIGHT
-1 - y
, 20), LCD_HEIGHT
-1));
1540 case 1: /* status: */
1541 lcd_puts(0, 0, "Power status:");
1543 battery_read_info(&y
, NULL
);
1544 snprintf(buf
, 30, "Battery: %d.%03d V", y
/ 1000, y
% 1000);
1545 lcd_puts(0, 1, buf
);
1546 #ifdef ADC_EXT_POWER
1547 y
= (adc_read(ADC_EXT_POWER
) * EXT_SCALE_FACTOR
) / 1000;
1548 snprintf(buf
, 30, "External: %d.%03d V", y
/ 1000, y
% 1000);
1549 lcd_puts(0, 2, buf
);
1552 #if CONFIG_CHARGING == CHARGING_CONTROL
1553 snprintf(buf
, 30, "Chgr: %s %s",
1554 charger_inserted() ? "present" : "absent",
1555 charger_enabled
? "on" : "off");
1556 lcd_puts(0, 3, buf
);
1557 snprintf(buf
, 30, "short delta: %d", short_delta
);
1558 lcd_puts(0, 5, buf
);
1559 snprintf(buf
, 30, "long delta: %d", long_delta
);
1560 lcd_puts(0, 6, buf
);
1561 lcd_puts(0, 7, power_message
);
1562 snprintf(buf
, 30, "USB Inserted: %s",
1563 usb_inserted() ? "yes" : "no");
1564 lcd_puts(0, 8, buf
);
1565 #if defined IRIVER_H300_SERIES
1566 snprintf(buf
, 30, "USB Charging Enabled: %s",
1567 usb_charging_enabled() ? "yes" : "no");
1568 lcd_puts(0, 9, buf
);
1570 #else /* CONFIG_CHARGING != CHARGING_CONTROL */
1571 #if defined IPOD_NANO || defined IPOD_VIDEO
1572 int usb_pwr
= (GPIOL_INPUT_VAL
& 0x10)?true:false;
1573 int ext_pwr
= (GPIOL_INPUT_VAL
& 0x08)?false:true;
1574 int dock
= (GPIOA_INPUT_VAL
& 0x10)?true:false;
1575 int charging
= (GPIOB_INPUT_VAL
& 0x01)?false:true;
1576 int headphone
= (GPIOA_INPUT_VAL
& 0x80)?true:false;
1578 snprintf(buf
, 30, "USB pwr: %s",
1579 usb_pwr
? "present" : "absent");
1580 lcd_puts(0, 3, buf
);
1581 snprintf(buf
, 30, "EXT pwr: %s",
1582 ext_pwr
? "present" : "absent");
1583 lcd_puts(0, 4, buf
);
1584 snprintf(buf
, 30, "Battery: %s",
1585 charging
? "charging" : (usb_pwr
||ext_pwr
) ? "charged" : "discharging");
1586 lcd_puts(0, 5, buf
);
1587 snprintf(buf
, 30, "Dock mode: %s",
1588 dock
? "enabled" : "disabled");
1589 lcd_puts(0, 6, buf
);
1590 snprintf(buf
, 30, "Headphone: %s",
1591 headphone
? "connected" : "disconnected");
1592 lcd_puts(0, 7, buf
);
1594 snprintf(buf
, 30, "Charger: %s",
1595 charger_inserted() ? "present" : "absent");
1596 lcd_puts(0, 3, buf
);
1598 #endif /* CONFIG_CHARGING != CHARGING_CONTROL */
1599 #endif /* CONFIG_CHARGING */
1602 case 2: /* voltage deltas: */
1603 lcd_puts(0, 0, "Voltage deltas:");
1605 for (i
= 0; i
<= 6; i
++) {
1606 y
= power_history
[i
] - power_history
[i
+1];
1607 snprintf(buf
, 30, "-%d min: %s%d.%03d V", i
,
1608 (y
< 0) ? "-" : "", ((y
< 0) ? y
* -1 : y
) / 1000,
1609 ((y
< 0) ? y
* -1 : y
) % 1000);
1610 lcd_puts(0, i
+1, buf
);
1614 case 3: /* remaining time estimation: */
1616 #if CONFIG_CHARGING == CHARGING_CONTROL
1617 snprintf(buf
, 30, "charge_state: %d", charge_state
);
1618 lcd_puts(0, 0, buf
);
1620 snprintf(buf
, 30, "Cycle time: %d m", powermgmt_last_cycle_startstop_min
);
1621 lcd_puts(0, 1, buf
);
1623 snprintf(buf
, 30, "Lvl@cyc st: %d%%", powermgmt_last_cycle_level
);
1624 lcd_puts(0, 2, buf
);
1626 snprintf(buf
, 30, "P=%2d I=%2d", pid_p
, pid_i
);
1627 lcd_puts(0, 3, buf
);
1629 snprintf(buf
, 30, "Trickle sec: %d/60", trickle_sec
);
1630 lcd_puts(0, 4, buf
);
1631 #endif /* CONFIG_CHARGING == CHARGING_CONTROL */
1633 snprintf(buf
, 30, "Last PwrHist: %d.%03dV",
1634 power_history
[0] / 1000,
1635 power_history
[0] % 1000);
1636 lcd_puts(0, 5, buf
);
1638 snprintf(buf
, 30, "battery level: %d%%", battery_level());
1639 lcd_puts(0, 6, buf
);
1641 snprintf(buf
, 30, "Est. remain: %d m", battery_time());
1642 lcd_puts(0, 7, buf
);
1648 switch(get_action(CONTEXT_SETTINGS
,HZ
/2))
1650 case ACTION_SETTINGS_DEC
:
1655 case ACTION_SETTINGS_INC
:
1660 case ACTION_STD_CANCEL
:
1667 #endif /* HAVE_LCD_BITMAP */
1671 #if defined(HAVE_MMC) || defined(HAVE_HOTSWAP)
1672 #if defined(HAVE_MMC)
1673 #define CARDTYPE "MMC"
1675 #define CARDTYPE "microSD"
1677 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1680 int *cardnum
= (int*)lists
->gui_list
[SCREEN_MAIN
].data
;
1681 unsigned char card_name
[7];
1682 unsigned char pbuf
[32];
1683 char *title
= lists
->gui_list
[SCREEN_MAIN
].title
;
1684 static const unsigned char i_vmin
[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
1685 static const unsigned char i_vmax
[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
1686 static const unsigned char *kbit_units
[] = { "kBit/s", "MBit/s", "GBit/s" };
1687 static const unsigned char *nsec_units
[] = { "ns", "�s", "ms" };
1688 static const char *spec_vers
[] = { "1.0-1.2", "1.4", "2.0-2.2",
1689 "3.1-3.31", "4.0" };
1690 if ((btn
== ACTION_STD_OK
) || (btn
== SYS_FS_CHANGED
) || (btn
== ACTION_REDRAW
))
1692 if (btn
== ACTION_STD_OK
)
1694 *cardnum
^= 0x1; /* change cards */
1697 simplelist_set_line_count(0);
1699 card
= card_get_info(*cardnum
);
1701 if (card
->initialized
> 0)
1703 card_name
[6] = '\0';
1704 strncpy(card_name
, ((unsigned char*)card
->cid
) + 3, 6);
1705 simplelist_addline(SIMPLELIST_ADD_LINE
,
1706 "%s Rev %d.%d", card_name
,
1707 (int) card_extract_bits(card
->cid
, 72, 4),
1708 (int) card_extract_bits(card
->cid
, 76, 4));
1709 simplelist_addline(SIMPLELIST_ADD_LINE
,
1711 (int) card_extract_bits(card
->cid
, 112, 4),
1712 (int) card_extract_bits(card
->cid
, 116, 4) + 1997);
1713 simplelist_addline(SIMPLELIST_ADD_LINE
,
1715 card_extract_bits(card
->cid
, 80, 32));
1716 simplelist_addline(SIMPLELIST_ADD_LINE
,
1718 (int) card_extract_bits(card
->cid
, 0, 8),
1719 (int) card_extract_bits(card
->cid
, 8, 16));
1720 int temp
= card_extract_bits(card
->csd
, 2, 4);
1721 simplelist_addline(SIMPLELIST_ADD_LINE
,
1722 CARDTYPE
" v%s", temp
< 5 ?
1723 spec_vers
[temp
] : "?.?");
1724 simplelist_addline(SIMPLELIST_ADD_LINE
,
1725 "Blocks: 0x%06lx", card
->numblocks
);
1726 simplelist_addline(SIMPLELIST_ADD_LINE
,
1727 "Blksz.: %d P:%c%c", card
->blocksize
,
1728 card_extract_bits(card
->csd
, 48, 1) ? 'R' : '-',
1729 card_extract_bits(card
->csd
, 106, 1) ? 'W' : '-');
1730 output_dyn_value(pbuf
, sizeof pbuf
, card
->speed
/ 1000,
1732 simplelist_addline(SIMPLELIST_ADD_LINE
,
1734 output_dyn_value(pbuf
, sizeof pbuf
, card
->tsac
,
1736 simplelist_addline(SIMPLELIST_ADD_LINE
,
1738 simplelist_addline(SIMPLELIST_ADD_LINE
,
1739 "Nsac: %d clk", card
->nsac
);
1740 simplelist_addline(SIMPLELIST_ADD_LINE
,
1741 "R2W: *%d", card
->r2w_factor
);
1742 simplelist_addline(SIMPLELIST_ADD_LINE
,
1744 i_vmin
[card_extract_bits(card
->csd
, 66, 3)],
1745 i_vmax
[card_extract_bits(card
->csd
, 69, 3)]);
1746 simplelist_addline(SIMPLELIST_ADD_LINE
,
1748 i_vmin
[card_extract_bits(card
->csd
, 72, 3)],
1749 i_vmax
[card_extract_bits(card
->csd
, 75, 3)]);
1751 else if (card
->initialized
== 0)
1753 simplelist_addline(SIMPLELIST_ADD_LINE
, "Not Found!");
1756 else /* card->initialized < 0 */
1758 simplelist_addline(SIMPLELIST_ADD_LINE
, "Init Error! (%d)", card
->initialized
);
1761 snprintf(title
, 16, "[" CARDTYPE
" %d]", *cardnum
);
1762 gui_synclist_set_title(lists
, title
, Icon_NOICON
);
1763 gui_synclist_set_nb_items(lists
, simplelist_get_line_count());
1764 gui_synclist_select_item(lists
, 0);
1765 btn
= ACTION_REDRAW
;
1769 #else /* !defined(HAVE_MMC) && !defined(HAVE_HOTSWAP) */
1770 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1775 unsigned short* identify_info
= ata_get_identify();
1776 bool timing_info_present
= false;
1779 simplelist_set_line_count(0);
1781 for (i
=0; i
< 20; i
++)
1782 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+27]);
1784 /* kill trailing space */
1785 for (i
=39; i
&& buf
[i
]==' '; i
--)
1787 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", buf
);
1788 for (i
=0; i
< 4; i
++)
1789 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+23]);
1791 simplelist_addline(SIMPLELIST_ADD_LINE
,
1792 "Firmware: %s", buf
);
1793 snprintf(buf
, sizeof buf
, "%ld MB",
1794 ((unsigned long)identify_info
[61] << 16 |
1795 (unsigned long)identify_info
[60]) / 2048 );
1796 simplelist_addline(SIMPLELIST_ADD_LINE
,
1799 fat_size( IF_MV2(0,) NULL
, &free
);
1800 simplelist_addline(SIMPLELIST_ADD_LINE
,
1801 "Free: %ld MB", free
/ 1024);
1802 simplelist_addline(SIMPLELIST_ADD_LINE
,
1803 "Spinup time: %d ms", ata_spinup_time
* (1000/HZ
));
1804 i
= identify_info
[83] & (1<<3);
1805 simplelist_addline(SIMPLELIST_ADD_LINE
,
1806 "Power mgmt: %s", i
? "enabled" : "unsupported");
1807 i
= identify_info
[83] & (1<<9);
1808 simplelist_addline(SIMPLELIST_ADD_LINE
,
1809 "Noise mgmt: %s", i
? "enabled" : "unsupported");
1810 i
= identify_info
[82] & (1<<6);
1811 simplelist_addline(SIMPLELIST_ADD_LINE
,
1812 "Read-ahead: %s", i
? "enabled" : "unsupported");
1813 timing_info_present
= identify_info
[53] & (1<<1);
1814 if(timing_info_present
) {
1815 char pio3
[2], pio4
[2];pio3
[1] = 0;
1817 pio3
[0] = (identify_info
[64] & (1<<0)) ? '3' : 0;
1818 pio4
[0] = (identify_info
[64] & (1<<1)) ? '4' : 0;
1819 simplelist_addline(SIMPLELIST_ADD_LINE
,
1820 "PIO modes: 0 1 2 %s %s", pio3
, pio4
);
1823 simplelist_addline(SIMPLELIST_ADD_LINE
,
1824 "No PIO mode info");
1826 timing_info_present
= identify_info
[53] & (1<<1);
1827 if(timing_info_present
) {
1828 simplelist_addline(SIMPLELIST_ADD_LINE
,
1829 "Cycle times %dns/%dns",
1831 identify_info
[68] );
1833 simplelist_addline(SIMPLELIST_ADD_LINE
,
1836 timing_info_present
= identify_info
[53] & (1<<1);
1837 if(timing_info_present
) {
1838 i
= identify_info
[49] & (1<<11);
1839 simplelist_addline(SIMPLELIST_ADD_LINE
,
1840 "IORDY support: %s", i
? "yes" : "no");
1841 i
= identify_info
[49] & (1<<10);
1842 simplelist_addline(SIMPLELIST_ADD_LINE
,
1843 "IORDY disable: %s", i
? "yes" : "no");
1845 simplelist_addline(SIMPLELIST_ADD_LINE
,
1848 simplelist_addline(SIMPLELIST_ADD_LINE
,
1849 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
1852 #endif /* !defined(HAVE_MMC) && !defined(HAVE_HOTSWAP) */
1853 static bool dbg_disk_info(void)
1855 struct simplelist_info info
;
1856 simplelist_info_init(&info
, "Disk Info", 1, NULL
);
1857 #if defined(HAVE_MMC) || defined(HAVE_HOTSWAP)
1860 info
.callback_data
= (void*)&card
;
1863 info
.action_callback
= disk_callback
;
1864 info
.hide_selection
= true;
1865 return simplelist_show_list(&info
);
1867 #endif /* !SIMULATOR */
1869 #ifdef HAVE_DIRCACHE
1870 static int dircache_callback(int btn
, struct gui_synclist
*lists
)
1872 (void)btn
; (void)lists
;
1873 simplelist_set_line_count(0);
1874 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache initialized: %s",
1875 dircache_is_enabled() ? "Yes" : "No");
1876 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache size: %d B",
1877 dircache_get_cache_size());
1878 simplelist_addline(SIMPLELIST_ADD_LINE
, "Last size: %d B",
1879 global_status
.dircache_size
);
1880 simplelist_addline(SIMPLELIST_ADD_LINE
, "Limit: %d B",
1882 simplelist_addline(SIMPLELIST_ADD_LINE
, "Reserve: %d/%d B",
1883 dircache_get_reserve_used(), DIRCACHE_RESERVE
);
1884 simplelist_addline(SIMPLELIST_ADD_LINE
, "Scanning took: %d s",
1885 dircache_get_build_ticks() / HZ
);
1886 simplelist_addline(SIMPLELIST_ADD_LINE
, "Entry count: %d",
1887 dircache_get_entry_count());
1891 static bool dbg_dircache_info(void)
1893 struct simplelist_info info
;
1894 simplelist_info_init(&info
, "Dircache Info", 7, NULL
);
1895 info
.action_callback
= dircache_callback
;
1896 info
.hide_selection
= true;
1897 return simplelist_show_list(&info
);
1900 #endif /* HAVE_DIRCACHE */
1902 #ifdef HAVE_TAGCACHE
1903 static int database_callback(int btn
, struct gui_synclist
*lists
)
1906 struct tagcache_stat
*stat
= tagcache_get_stat();
1907 static bool synced
= false;
1909 simplelist_set_line_count(0);
1911 simplelist_addline(SIMPLELIST_ADD_LINE
, "Initialized: %s",
1912 stat
->initialized
? "Yes" : "No");
1913 simplelist_addline(SIMPLELIST_ADD_LINE
, "DB Ready: %s",
1914 stat
->ready
? "Yes" : "No");
1915 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM Cache: %s",
1916 stat
->ramcache
? "Yes" : "No");
1917 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM: %d/%d B",
1918 stat
->ramcache_used
, stat
->ramcache_allocated
);
1919 simplelist_addline(SIMPLELIST_ADD_LINE
, "Progress: %d%% (%d entries)",
1920 stat
->progress
, stat
->processed_entries
);
1921 simplelist_addline(SIMPLELIST_ADD_LINE
, "Curfile: %s",
1922 stat
->curentry
? stat
->curentry
: "---");
1923 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit step: %d",
1925 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit delayed: %s",
1926 stat
->commit_delayed
? "Yes" : "No");
1932 tagcache_screensync_event();
1935 if (!btn
&& stat
->curentry
)
1938 return ACTION_REDRAW
;
1941 if (btn
== ACTION_STD_CANCEL
)
1942 tagcache_screensync_enable(false);
1946 static bool dbg_tagcache_info(void)
1948 struct simplelist_info info
;
1949 simplelist_info_init(&info
, "Database Info", 8, NULL
);
1950 info
.action_callback
= database_callback
;
1951 info
.hide_selection
= true;
1952 info
.timeout
= TIMEOUT_NOBLOCK
;
1953 tagcache_screensync_enable(true);
1954 return simplelist_show_list(&info
);
1958 #if CONFIG_CPU == SH7034
1959 static bool dbg_save_roms(void)
1962 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
1964 fd
= creat("/internal_rom_0000-FFFF.bin");
1967 write(fd
, (void *)0, 0x10000);
1971 fd
= creat("/internal_rom_2000000-203FFFF.bin");
1974 write(fd
, (void *)0x2000000, 0x40000);
1978 system_memory_guard(oldmode
);
1981 #elif defined CPU_COLDFIRE
1982 static bool dbg_save_roms(void)
1985 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
1987 #if defined(IRIVER_H100_SERIES)
1988 fd
= creat("/internal_rom_000000-1FFFFF.bin");
1989 #elif defined(IRIVER_H300_SERIES)
1990 fd
= creat("/internal_rom_000000-3FFFFF.bin");
1991 #elif defined(IAUDIO_X5) || defined(IAUDIO_M5)
1992 fd
= creat("/internal_rom_000000-3FFFFF.bin");
1996 write(fd
, (void *)0, FLASH_SIZE
);
1999 system_memory_guard(oldmode
);
2002 fd
= creat("/internal_eeprom.bin");
2006 char buf
[EEPROM_SIZE
];
2009 old_irq_level
= set_irq_level(HIGHEST_IRQ_LEVEL
);
2011 err
= eeprom_24cxx_read(0, buf
, sizeof buf
);
2013 gui_syncsplash(HZ
*3, "Eeprom read failure (%d)",err
);
2016 write(fd
, buf
, sizeof buf
);
2019 set_irq_level(old_irq_level
);
2027 #elif defined(CPU_PP) && !(defined(SANSA_E200) || defined(SANSA_C200))
2028 static bool dbg_save_roms(void)
2032 fd
= creat("/internal_rom_000000-0FFFFF.bin");
2035 write(fd
, (void *)0x20000000, FLASH_SIZE
);
2045 static int radio_callback(int btn
, struct gui_synclist
*lists
)
2048 if (btn
== ACTION_STD_CANCEL
)
2050 simplelist_set_line_count(1);
2052 #if (CONFIG_TUNER & LV24020LP)
2053 simplelist_addline(SIMPLELIST_ADD_LINE
,
2054 "CTRL_STAT: %02X", lv24020lp_get(LV24020LP_CTRL_STAT
) );
2055 simplelist_addline(SIMPLELIST_ADD_LINE
,
2056 "RADIO_STAT: %02X", lv24020lp_get(LV24020LP_REG_STAT
) );
2057 simplelist_addline(SIMPLELIST_ADD_LINE
,
2058 "MSS_FM: %d kHz", lv24020lp_get(LV24020LP_MSS_FM
) );
2059 simplelist_addline(SIMPLELIST_ADD_LINE
,
2060 "MSS_IF: %d Hz", lv24020lp_get(LV24020LP_MSS_IF
) );
2061 simplelist_addline(SIMPLELIST_ADD_LINE
,
2062 "MSS_SD: %d Hz", lv24020lp_get(LV24020LP_MSS_SD
) );
2063 simplelist_addline(SIMPLELIST_ADD_LINE
,
2064 "if_set: %d Hz", lv24020lp_get(LV24020LP_IF_SET
) );
2065 simplelist_addline(SIMPLELIST_ADD_LINE
,
2066 "sd_set: %d Hz", lv24020lp_get(LV24020LP_SD_SET
) );
2068 #if (CONFIG_TUNER & S1A0903X01)
2069 simplelist_addline(SIMPLELIST_ADD_LINE
,
2070 "Samsung regs: %08X", s1a0903x01_get(RADIO_ALL
));
2071 /* This one doesn't return dynamic data atm */
2073 #if (CONFIG_TUNER & TEA5767)
2074 struct tea5767_dbg_info nfo
;
2075 tea5767_dbg_info(&nfo
);
2076 simplelist_addline(SIMPLELIST_ADD_LINE
, "Philips regs:");
2077 simplelist_addline(SIMPLELIST_ADD_LINE
,
2078 " Read: %02X %02X %02X %02X %02X",
2079 (unsigned)nfo
.read_regs
[0], (unsigned)nfo
.read_regs
[1],
2080 (unsigned)nfo
.read_regs
[2], (unsigned)nfo
.read_regs
[3],
2081 (unsigned)nfo
.read_regs
[4]);
2082 simplelist_addline(SIMPLELIST_ADD_LINE
,
2083 " Write: %02X %02X %02X %02X %02X",
2084 (unsigned)nfo
.write_regs
[0], (unsigned)nfo
.write_regs
[1],
2085 (unsigned)nfo
.write_regs
[2], (unsigned)nfo
.write_regs
[3],
2086 (unsigned)nfo
.write_regs
[4]);
2088 return ACTION_REDRAW
;
2090 static bool dbg_fm_radio(void)
2092 struct simplelist_info info
;
2093 simplelist_info_init(&info
, "FM Radio", 1, NULL
);
2094 simplelist_set_line_count(0);
2095 simplelist_addline(SIMPLELIST_ADD_LINE
, "HW detected: %s",
2096 radio_hardware_present() ? "yes" : "no");
2098 info
.action_callback
= radio_hardware_present()?radio_callback
: NULL
;
2099 info
.hide_selection
= true;
2100 return simplelist_show_list(&info
);
2102 #endif /* CONFIG_TUNER */
2103 #endif /* !SIMULATOR */
2105 #ifdef HAVE_LCD_BITMAP
2106 extern bool do_screendump_instead_of_usb
;
2108 static bool dbg_screendump(void)
2110 do_screendump_instead_of_usb
= !do_screendump_instead_of_usb
;
2111 gui_syncsplash(HZ
, "Screendump %s",
2112 do_screendump_instead_of_usb
?"enabled":"disabled");
2115 #endif /* HAVE_LCD_BITMAP */
2117 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2118 static bool dbg_set_memory_guard(void)
2120 static const struct opt_items names
[MAXMEMGUARD
] = {
2122 { "Flash ROM writes", -1 },
2123 { "Zero area (all)", -1 }
2125 int mode
= system_memory_guard(MEMGUARD_KEEP
);
2127 set_option( "Catch mem accesses", &mode
, INT
, names
, MAXMEMGUARD
, NULL
);
2128 system_memory_guard(mode
);
2132 #endif /* CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) */
2134 #if defined(TOSHIBA_GIGABEAT_F) && !defined(SIMULATOR)
2136 extern volatile bool lcd_poweroff
;
2138 static bool dbg_lcd_power_off(void)
2140 lcd_setmargins(0, 0);
2146 lcd_clear_display();
2147 lcd_puts(0, 0, "LCD Power Off");
2149 lcd_puts(1, 1, "Yes");
2151 lcd_puts(1, 1, "No");
2155 button
= get_action(CONTEXT_STD
,HZ
/5);
2158 case ACTION_STD_PREV
:
2159 case ACTION_STD_NEXT
:
2160 lcd_poweroff
= !lcd_poweroff
;
2163 case ACTION_STD_CANCEL
:
2174 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2175 static bool dbg_write_eeprom(void)
2180 char buf
[EEPROM_SIZE
];
2183 fd
= open("/internal_eeprom.bin", O_RDONLY
);
2187 rc
= read(fd
, buf
, EEPROM_SIZE
);
2189 if(rc
== EEPROM_SIZE
)
2191 old_irq_level
= set_irq_level(HIGHEST_IRQ_LEVEL
);
2193 err
= eeprom_24cxx_write(0, buf
, sizeof buf
);
2195 gui_syncsplash(HZ
*3, "Eeprom write failure (%d)",err
);
2197 gui_syncsplash(HZ
*3, "Eeprom written successfully");
2199 set_irq_level(old_irq_level
);
2203 gui_syncsplash(HZ
*3, "File read error (%d)",rc
);
2209 gui_syncsplash(HZ
*3, "Failed to open 'internal_eeprom.bin'");
2214 #endif /* defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS) */
2215 #ifdef CPU_BOOST_LOGGING
2216 static bool cpu_boost_log(void)
2219 int count
= cpu_boost_log_getcount();
2220 int lines
= LCD_HEIGHT
/SYSFONT_HEIGHT
;
2223 lcd_setmargins(0, 0);
2224 lcd_setfont(FONT_SYSFIXED
);
2225 str
= cpu_boost_log_getlog_first();
2228 lcd_clear_display();
2229 for(j
=0; j
<lines
; j
++,i
++)
2232 str
= cpu_boost_log_getlog_next();
2243 switch(get_action(CONTEXT_STD
,TIMEOUT_BLOCK
))
2246 case ACTION_STD_PREV
:
2247 case ACTION_STD_NEXT
:
2250 case ACTION_STD_CANCEL
:
2257 get_action(CONTEXT_STD
,TIMEOUT_BLOCK
);
2258 lcd_setfont(FONT_UI
);
2265 /****** The menu *********/
2266 struct the_menu_item
{
2267 unsigned char *desc
; /* string or ID */
2268 bool (*function
) (void); /* return true if USB was connected */
2270 static const struct the_menu_item menuitems
[] = {
2271 #if defined(TOSHIBA_GIGABEAT_F) && !defined(SIMULATOR)
2272 { "LCD Power Off", dbg_lcd_power_off
},
2274 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || \
2275 (defined(CPU_PP) && !(defined(SANSA_E200) || defined(SANSA_C200)))
2276 { "Dump ROM contents", dbg_save_roms
},
2278 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || defined(CPU_PP) || CONFIG_CPU == S3C2440
2279 { "View I/O ports", dbg_ports
},
2281 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
2282 { "CPU frequency", dbg_cpufreq
},
2284 #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR)
2285 { "S/PDIF analyzer", dbg_spdif
},
2287 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2288 { "Catch mem accesses", dbg_set_memory_guard
},
2290 { "View OS stacks", dbg_os
},
2291 #ifdef HAVE_LCD_BITMAP
2293 { "View battery", view_battery
},
2295 { "Screendump", dbg_screendump
},
2298 { "View HW info", dbg_hw_info
},
2301 { "View partitions", dbg_partitions
},
2304 { "View disk info", dbg_disk_info
},
2306 #ifdef HAVE_DIRCACHE
2307 { "View dircache info", dbg_dircache_info
},
2309 #ifdef HAVE_TAGCACHE
2310 { "View database info", dbg_tagcache_info
},
2312 #ifdef HAVE_LCD_BITMAP
2313 #if CONFIG_CODEC == SWCODEC || !defined(SIMULATOR)
2314 { "View audio thread", dbg_audio_thread
},
2315 { "View buffering thread", dbg_buffering_thread
},
2318 { "pm histogram", peak_meter_histogram
},
2319 #endif /* PM_DEBUG */
2320 #endif /* HAVE_LCD_BITMAP */
2323 { "FM Radio", dbg_fm_radio
},
2326 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2327 { "Write back EEPROM", dbg_write_eeprom
},
2329 #ifdef ROCKBOX_HAS_LOGF
2330 {"logf", logfdisplay
},
2331 {"logfdump", logfdump
},
2333 #ifdef CPU_BOOST_LOGGING
2334 {"cpu_boost log",cpu_boost_log
},
2337 static int menu_action_callback(int btn
, struct gui_synclist
*lists
)
2339 if (btn
== ACTION_STD_OK
)
2341 menuitems
[gui_synclist_get_sel_pos(lists
)].function();
2342 btn
= ACTION_REDRAW
;
2346 static char* dbg_menu_getname(int item
, void * data
, char *buffer
)
2348 (void)data
; (void)buffer
;
2349 return menuitems
[item
].desc
;
2351 bool debug_menu(void)
2353 struct simplelist_info info
;
2355 simplelist_info_init(&info
, "Debug Menu", ARRAYLEN(menuitems
), NULL
);
2356 info
.action_callback
= menu_action_callback
;
2357 info
.get_name
= dbg_menu_getname
;
2359 return simplelist_show_list(&info
);