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 #if CONFIG_RTC == RTC_PCF50605
95 #if CONFIG_CPU == DM320 || CONFIG_CPU == S3C2440
96 #include "debug-target.h"
99 /*---------------------------------------------------*/
100 /* SPECIAL DEBUG STUFF */
101 /*---------------------------------------------------*/
102 extern struct thread_entry threads
[MAXTHREADS
];
104 static char thread_status_char(unsigned status
)
106 static const char thread_status_chars
[THREAD_NUM_STATES
+1] =
108 [0 ... THREAD_NUM_STATES
] = '?',
109 [STATE_RUNNING
] = 'R',
110 [STATE_BLOCKED
] = 'B',
111 [STATE_SLEEPING
] = 'S',
112 [STATE_BLOCKED_W_TMO
] = 'T',
113 [STATE_FROZEN
] = 'F',
114 [STATE_KILLED
] = 'K',
118 if (status
== STATE_BUSY
) /* Not a state index */
122 if (status
> THREAD_NUM_STATES
)
123 status
= THREAD_NUM_STATES
;
125 return thread_status_chars
[status
];
128 static char* threads_getname(int selected_item
, void * data
, char *buffer
)
131 struct thread_entry
*thread
;
135 if (selected_item
< (int)NUM_CORES
)
137 snprintf(buffer
, MAX_PATH
, "Idle (%d): %2d%%", selected_item
,
138 idle_stack_usage(selected_item
));
142 selected_item
-= NUM_CORES
;
145 thread
= &threads
[selected_item
];
147 if (thread
->state
== STATE_KILLED
)
149 snprintf(buffer
, MAX_PATH
, "%2d: ---", selected_item
);
153 thread_get_name(name
, 32, thread
);
155 snprintf(buffer
, MAX_PATH
,
156 "%2d: " IF_COP("(%d) ") "%c%c " IF_PRIO("%d ") "%2d%% %s",
158 IF_COP(thread
->core
,)
159 #ifdef HAVE_SCHEDULER_BOOSTCTRL
160 (thread
->boosted
) ? '+' :
162 ((thread
->state
== STATE_RUNNING
) ? '*' : ' '),
163 thread_status_char(thread
->state
),
164 IF_PRIO(thread
->priority
,)
165 thread_stack_usage(thread
), name
);
169 static int dbg_threads_action_callback(int action
, struct gui_synclist
*lists
)
172 #ifdef ROCKBOX_HAS_LOGF
173 if (action
== ACTION_STD_OK
)
175 int selpos
= gui_synclist_get_sel_pos(lists
);
177 if (selpos
>= NUM_CORES
)
178 remove_thread(&threads
[selpos
- NUM_CORES
]);
180 remove_thread(&threads
[selpos
]);
182 return ACTION_REDRAW
;
184 #endif /* ROCKBOX_HAS_LOGF */
188 static bool dbg_os(void)
190 struct simplelist_info info
;
191 simplelist_info_init(&info
, IF_COP("Core and ") "Stack usage:",
195 MAXTHREADS
+NUM_CORES
,
198 #ifndef ROCKBOX_HAS_LOGF
199 info
.hide_selection
= true;
201 info
.action_callback
= dbg_threads_action_callback
;
202 info
.get_name
= threads_getname
;
203 return simplelist_show_list(&info
);
206 #ifdef HAVE_LCD_BITMAP
207 #if CONFIG_CODEC != SWCODEC
209 static bool dbg_audio_thread(void)
212 struct audio_debug d
;
214 lcd_setmargins(0, 0);
215 lcd_setfont(FONT_SYSFIXED
);
219 if (action_userabort(HZ
/5))
222 audio_get_debugdata(&d
);
226 snprintf(buf
, sizeof(buf
), "read: %x", d
.audiobuf_read
);
228 snprintf(buf
, sizeof(buf
), "write: %x", d
.audiobuf_write
);
230 snprintf(buf
, sizeof(buf
), "swap: %x", d
.audiobuf_swapwrite
);
232 snprintf(buf
, sizeof(buf
), "playing: %d", d
.playing
);
234 snprintf(buf
, sizeof(buf
), "playable: %x", d
.playable_space
);
236 snprintf(buf
, sizeof(buf
), "unswapped: %x", d
.unswapped_space
);
239 /* Playable space left */
240 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8, 112, 4, d
.audiobuflen
, 0,
241 d
.playable_space
, HORIZONTAL
);
243 /* Show the watermark limit */
244 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8+4, 112, 4, d
.audiobuflen
, 0,
245 d
.low_watermark_level
, HORIZONTAL
);
247 snprintf(buf
, sizeof(buf
), "wm: %x - %x",
248 d
.low_watermark_level
, d
.lowest_watermark_level
);
255 #endif /* !SIMULATOR */
256 #else /* CONFIG_CODEC == SWCODEC */
257 extern size_t filebuflen
;
258 /* This is a size_t, but call it a long so it puts a - when it's bad. */
260 static unsigned int ticks
, boost_ticks
;
262 static void dbg_audio_task(void)
265 if(FREQ
> CPUFREQ_NORMAL
)
272 static bool dbg_buffering_thread(void)
279 size_t bufsize
= pcmbuf_get_bufsize();
280 int pcmbufdescs
= pcmbuf_descs();
281 struct buffering_debug d
;
283 ticks
= boost_ticks
= 0;
285 tick_add_task(dbg_audio_task
);
287 lcd_setmargins(0, 0);
288 lcd_setfont(FONT_SYSFIXED
);
291 button
= get_action(CONTEXT_STD
,HZ
/5);
294 case ACTION_STD_NEXT
:
297 case ACTION_STD_PREV
:
300 case ACTION_STD_CANCEL
:
305 buffering_get_debugdata(&d
);
310 bufused
= bufsize
- pcmbuf_free();
312 snprintf(buf
, sizeof(buf
), "pcm: %7ld/%7ld", (long) bufused
, (long) bufsize
);
313 lcd_puts(0, line
++, buf
);
315 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
316 bufsize
, 0, bufused
, HORIZONTAL
);
319 snprintf(buf
, sizeof(buf
), "alloc: %8ld/%8ld", audio_filebufused(),
321 lcd_puts(0, line
++, buf
);
324 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
325 filebuflen
, 0, audio_filebufused(), HORIZONTAL
);
328 snprintf(buf
, sizeof(buf
), "real: %8ld/%8ld", (long)d
.buffered_data
,
330 lcd_puts(0, line
++, buf
);
332 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
333 filebuflen
, 0, (long)d
.buffered_data
, HORIZONTAL
);
337 snprintf(buf
, sizeof(buf
), "usefl: %8ld/%8ld", (long)(d
.useful_data
),
339 lcd_puts(0, line
++, buf
);
342 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
343 filebuflen
, 0, d
.useful_data
, HORIZONTAL
);
347 snprintf(buf
, sizeof(buf
), "data_rem: %ld", (long)d
.data_rem
);
348 lcd_puts(0, line
++, buf
);
350 snprintf(buf
, sizeof(buf
), "track count: %2d", audio_track_count());
351 lcd_puts(0, line
++, buf
);
353 snprintf(buf
, sizeof(buf
), "handle count: %d", (int)d
.num_handles
);
354 lcd_puts(0, line
++, buf
);
357 snprintf(buf
, sizeof(buf
), "cpu freq: %3dMHz",
358 (int)((FREQ
+ 500000) / 1000000));
359 lcd_puts(0, line
++, buf
);
364 snprintf(buf
, sizeof(buf
), "boost ratio: %3d%%",
365 boost_ticks
* 100 / ticks
);
366 lcd_puts(0, line
++, buf
);
369 snprintf(buf
, sizeof(buf
), "pcmbufdesc: %2d/%2d",
370 pcmbuf_used_descs(), pcmbufdescs
);
371 lcd_puts(0, line
++, buf
);
376 tick_remove_task(dbg_audio_task
);
380 #endif /* CONFIG_CODEC */
381 #endif /* HAVE_LCD_BITMAP */
384 #if (CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE))
385 /* Tool function to read the flash manufacturer and type, if available.
386 Only chips which could be reprogrammed in system will return values.
387 (The mode switch addresses vary between flash manufacturers, hence addr1/2) */
388 /* In IRAM to avoid problems when running directly from Flash */
389 static bool dbg_flash_id(unsigned* p_manufacturer
, unsigned* p_device
,
390 unsigned addr1
, unsigned addr2
)
391 ICODE_ATTR
__attribute__((noinline
));
392 static bool dbg_flash_id(unsigned* p_manufacturer
, unsigned* p_device
,
393 unsigned addr1
, unsigned addr2
)
396 unsigned not_manu
, not_id
; /* read values before switching to ID mode */
397 unsigned manu
, id
; /* read values when in ID mode */
399 #if CONFIG_CPU == SH7034
400 volatile unsigned char* flash
= (unsigned char*)0x2000000; /* flash mapping */
401 #elif defined(CPU_COLDFIRE)
402 volatile unsigned short* flash
= (unsigned short*)0; /* flash mapping */
404 int old_level
; /* saved interrupt level */
406 not_manu
= flash
[0]; /* read the normal content */
407 not_id
= flash
[1]; /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */
409 /* disable interrupts, prevent any stray flash access */
410 old_level
= set_irq_level(HIGHEST_IRQ_LEVEL
);
412 flash
[addr1
] = 0xAA; /* enter command mode */
414 flash
[addr1
] = 0x90; /* ID command */
415 /* Atmel wants 20ms pause here */
416 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
418 manu
= flash
[0]; /* read the IDs */
421 flash
[0] = 0xF0; /* reset flash (back to normal read mode) */
422 /* Atmel wants 20ms pause here */
423 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
425 set_irq_level(old_level
); /* enable interrupts again */
427 /* I assume success if the obtained values are different from
428 the normal flash content. This is not perfectly bulletproof, they
429 could theoretically be the same by chance, causing us to fail. */
430 if (not_manu
!= manu
|| not_id
!= id
) /* a value has changed */
432 *p_manufacturer
= manu
; /* return the results */
434 return true; /* success */
436 return false; /* fail */
438 #endif /* (CONFIG_CPU == SH7034 || CPU_COLDFIRE) */
442 static int perfcheck(void)
448 "orr r0, r2, #0xc0 \n" /* disable IRQ and FIQ */
451 "ldr r0, [%[timr]] \n"
452 "add r0, r0, %[tmo] \n"
454 "add %[res], %[res], #1 \n"
455 "ldr r1, [%[timr]] \n"
458 "msr CPSR_c, r2 \n" /* reset IRQ and FIQ state */
462 [timr
]"r"(&USEC_TIMER
),
464 #if CONFIG_CPU == PP5002
466 #else /* PP5020/5022/5024 */
477 #ifdef HAVE_LCD_BITMAP
478 static bool dbg_hw_info(void)
480 #if CONFIG_CPU == SH7034
482 int bitmask
= HW_MASK
;
483 int rom_version
= ROM_VERSION
;
484 unsigned manu
, id
; /* flash IDs */
485 bool got_id
; /* flag if we managed to get the flash IDs */
486 unsigned rom_crc
= 0xffffffff; /* CRC32 of the boot ROM */
487 bool has_bootrom
; /* flag for boot ROM present */
488 int oldmode
; /* saved memory guard mode */
490 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
492 /* get flash ROM type */
493 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
495 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
497 /* check if the boot ROM area is a flash mirror */
498 has_bootrom
= (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
499 if (has_bootrom
) /* if ROM and Flash different */
501 /* calculate CRC16 checksum of boot ROM */
502 rom_crc
= crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
505 system_memory_guard(oldmode
); /* re-enable memory guard */
507 lcd_setmargins(0, 0);
508 lcd_setfont(FONT_SYSFIXED
);
511 lcd_puts(0, 0, "[Hardware info]");
513 snprintf(buf
, 32, "ROM: %d.%02d", rom_version
/100, rom_version
%100);
516 snprintf(buf
, 32, "Mask: 0x%04x", bitmask
);
520 snprintf(buf
, 32, "Flash: M=%02x D=%02x", manu
, id
);
522 snprintf(buf
, 32, "Flash: M=?? D=??"); /* unknown, sorry */
527 if (rom_crc
== 0x56DBA4EE) /* known Version 1 */
528 snprintf(buf
, 32, "Boot ROM: V1");
530 snprintf(buf
, 32, "ROMcrc: 0x%08x", rom_crc
);
534 snprintf(buf
, 32, "Boot ROM: none");
540 while (!(action_userabort(TIMEOUT_BLOCK
)));
542 #elif CONFIG_CPU == MCF5249 || CONFIG_CPU == MCF5250
544 unsigned manu
, id
; /* flash IDs */
545 int got_id
; /* flag if we managed to get the flash IDs */
546 int oldmode
; /* saved memory guard mode */
549 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
551 /* get flash ROM type */
552 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
554 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
556 system_memory_guard(oldmode
); /* re-enable memory guard */
558 lcd_setmargins(0, 0);
559 lcd_setfont(FONT_SYSFIXED
);
562 lcd_puts(0, line
++, "[Hardware info]");
565 snprintf(buf
, 32, "Flash: M=%04x D=%04x", manu
, id
);
567 snprintf(buf
, 32, "Flash: M=???? D=????"); /* unknown, sorry */
568 lcd_puts(0, line
++, buf
);
574 lcd_puts(0, ++line
, "Serial Number:");
576 got_id
= ds2411_read_id(&id
);
578 if (got_id
== DS2411_OK
)
580 snprintf(buf
, 32, " FC=%02x", (unsigned)id
.family_code
);
581 lcd_puts(0, ++line
, buf
);
582 snprintf(buf
, 32, " ID=%02X %02X %02X %02X %02X %02X",
583 (unsigned)id
.uid
[0], (unsigned)id
.uid
[1], (unsigned)id
.uid
[2],
584 (unsigned)id
.uid
[3], (unsigned)id
.uid
[4], (unsigned)id
.uid
[5]);
585 lcd_puts(0, ++line
, buf
);
586 snprintf(buf
, 32, " CRC=%02X", (unsigned)id
.crc
);
590 snprintf(buf
, 32, "READ ERR=%d", got_id
);
593 lcd_puts(0, ++line
, buf
);
599 while (!(action_userabort(TIMEOUT_BLOCK
)));
601 #elif defined(CPU_PP502x)
604 char pp_version
[] = { (PP_VER2
>> 24) & 0xff, (PP_VER2
>> 16) & 0xff,
605 (PP_VER2
>> 8) & 0xff, (PP_VER2
) & 0xff,
606 (PP_VER1
>> 24) & 0xff, (PP_VER1
>> 16) & 0xff,
607 (PP_VER1
>> 8) & 0xff, (PP_VER1
) & 0xff, '\0' };
609 lcd_setmargins(0, 0);
610 lcd_setfont(FONT_SYSFIXED
);
613 lcd_puts(0, line
++, "[Hardware info]");
616 snprintf(buf
, sizeof(buf
), "HW rev: 0x%08lx", IPOD_HW_REVISION
);
617 lcd_puts(0, line
++, buf
);
621 extern int lcd_type
; /* Defined in lcd-colornano.c */
623 snprintf(buf
, sizeof(buf
), "LCD type: %d", lcd_type
);
624 lcd_puts(0, line
++, buf
);
627 snprintf(buf
, sizeof(buf
), "PP version: %s", pp_version
);
628 lcd_puts(0, line
++, buf
);
630 snprintf(buf
, sizeof(buf
), "Est. clock (kHz): %d", perfcheck());
631 lcd_puts(0, line
++, buf
);
635 while (!(action_userabort(TIMEOUT_BLOCK
)));
637 #elif CONFIG_CPU == PP5002
640 char pp_version
[] = { (PP_VER4
>> 8) & 0xff, PP_VER4
& 0xff,
641 (PP_VER3
>> 8) & 0xff, PP_VER3
& 0xff,
642 (PP_VER2
>> 8) & 0xff, PP_VER2
& 0xff,
643 (PP_VER1
>> 8) & 0xff, PP_VER1
& 0xff, '\0' };
646 lcd_setmargins(0, 0);
647 lcd_setfont(FONT_SYSFIXED
);
650 lcd_puts(0, line
++, "[Hardware info]");
653 snprintf(buf
, sizeof(buf
), "HW rev: 0x%08lx", IPOD_HW_REVISION
);
654 lcd_puts(0, line
++, buf
);
657 snprintf(buf
, sizeof(buf
), "PP version: %s", pp_version
);
658 lcd_puts(0, line
++, buf
);
660 snprintf(buf
, sizeof(buf
), "Est. clock (kHz): %d", perfcheck());
661 lcd_puts(0, line
++, buf
);
665 while (!(action_userabort(TIMEOUT_BLOCK
)));
667 /* Define this function in your target tree */
668 return __dbg_hw_info();
669 #endif /* CONFIG_CPU */
672 #else /* !HAVE_LCD_BITMAP */
673 static bool dbg_hw_info(void)
678 int rom_version
= ROM_VERSION
;
679 unsigned manu
, id
; /* flash IDs */
680 bool got_id
; /* flag if we managed to get the flash IDs */
681 unsigned rom_crc
= 0xffffffff; /* CRC32 of the boot ROM */
682 bool has_bootrom
; /* flag for boot ROM present */
683 int oldmode
; /* saved memory guard mode */
685 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
687 /* get flash ROM type */
688 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
690 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
692 /* check if the boot ROM area is a flash mirror */
693 has_bootrom
= (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
694 if (has_bootrom
) /* if ROM and Flash different */
696 /* calculate CRC16 checksum of boot ROM */
697 rom_crc
= crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
700 system_memory_guard(oldmode
); /* re-enable memory guard */
704 lcd_puts(0, 0, "[HW Info]");
710 snprintf(buf
, 32, "ROM: %d.%02d",
711 rom_version
/100, rom_version
%100);
715 snprintf(buf
, 32, "Flash:%02x,%02x", manu
, id
);
717 snprintf(buf
, 32, "Flash:??,??"); /* unknown, sorry */
722 if (rom_crc
== 0x56DBA4EE) /* known Version 1 */
723 snprintf(buf
, 32, "BootROM: V1");
724 else if (rom_crc
== 0x358099E8)
725 snprintf(buf
, 32, "BootROM: V2");
726 /* alternative boot ROM found in one single player so far */
728 snprintf(buf
, 32, "R: %08x", rom_crc
);
731 snprintf(buf
, 32, "BootROM: no");
737 button
= get_action(CONTEXT_SETTINGS
,TIMEOUT_BLOCK
);
741 case ACTION_STD_CANCEL
:
744 case ACTION_SETTINGS_DEC
:
750 case ACTION_SETTINGS_INC
:
759 #endif /* !HAVE_LCD_BITMAP */
760 #endif /* !SIMULATOR */
763 static char* dbg_partitions_getname(int selected_item
, void * data
, char *buffer
)
766 int partition
= selected_item
/2;
767 struct partinfo
* p
= disk_partinfo(partition
);
770 snprintf(buffer
, MAX_PATH
, " T:%x %ld MB", p
->type
, p
->size
/ 2048);
774 snprintf(buffer
, MAX_PATH
, "P%d: S:%lx", partition
, p
->start
);
779 bool dbg_partitions(void)
781 struct simplelist_info info
;
782 simplelist_info_init(&info
, "Partition Info", 4, NULL
);
783 info
.selection_size
= 2;
784 info
.hide_selection
= true;
785 info
.get_name
= dbg_partitions_getname
;
786 return simplelist_show_list(&info
);
790 #if defined(CPU_COLDFIRE) && defined(HAVE_SPDIF_OUT)
791 static bool dbg_spdif(void)
795 unsigned int control
;
800 unsigned int interruptstat
;
801 bool valnogood
, symbolerr
, parityerr
;
804 int spdif_source
= spdif_get_output_source(&spdif_src_on
);
805 spdif_set_output_source(AUDIO_SRC_SPDIF
IF_SPDIF_POWER_(, true));
807 lcd_setmargins(0, 0);
809 lcd_setfont(FONT_SYSFIXED
);
811 #ifdef HAVE_SPDIF_POWER
812 spdif_power_enable(true); /* We need SPDIF power for both sending & receiving */
819 control
= EBU1RCVCCHANNEL1
;
820 interruptstat
= INTERRUPTSTAT
;
821 INTERRUPTCLEAR
= 0x03c00000;
823 valnogood
= (interruptstat
& 0x01000000)?true:false;
824 symbolerr
= (interruptstat
& 0x00800000)?true:false;
825 parityerr
= (interruptstat
& 0x00400000)?true:false;
827 snprintf(buf
, sizeof(buf
), "Val: %s Sym: %s Par: %s",
830 parityerr
?"--":"OK");
831 lcd_puts(0, line
++, buf
);
833 snprintf(buf
, sizeof(buf
), "Status word: %08x", (int)control
);
834 lcd_puts(0, line
++, buf
);
839 snprintf(buf
, sizeof(buf
), "PRO: %d (%s)",
840 x
, x
?"Professional":"Consumer");
841 lcd_puts(0, line
++, buf
);
843 x
= (control
>> 30) & 1;
844 snprintf(buf
, sizeof(buf
), "Audio: %d (%s)",
845 x
, x
?"Non-PCM":"PCM");
846 lcd_puts(0, line
++, buf
);
848 x
= (control
>> 29) & 1;
849 snprintf(buf
, sizeof(buf
), "Copy: %d (%s)",
850 x
, x
?"Permitted":"Inhibited");
851 lcd_puts(0, line
++, buf
);
853 x
= (control
>> 27) & 7;
866 snprintf(buf
, sizeof(buf
), "Preemphasis: %d (%s)", x
, s
);
867 lcd_puts(0, line
++, buf
);
869 x
= (control
>> 24) & 3;
870 snprintf(buf
, sizeof(buf
), "Mode: %d", x
);
871 lcd_puts(0, line
++, buf
);
873 category
= (control
>> 17) & 127;
885 snprintf(buf
, sizeof(buf
), "Category: 0x%02x (%s)", category
, s
);
886 lcd_puts(0, line
++, buf
);
888 x
= (control
>> 16) & 1;
890 if(((category
& 0x70) == 0x10) ||
891 ((category
& 0x70) == 0x40) ||
892 ((category
& 0x78) == 0x38))
894 generation
= !generation
;
896 snprintf(buf
, sizeof(buf
), "Generation: %d (%s)",
897 x
, generation
?"Original":"No ind.");
898 lcd_puts(0, line
++, buf
);
900 x
= (control
>> 12) & 15;
901 snprintf(buf
, sizeof(buf
), "Source: %d", x
);
902 lcd_puts(0, line
++, buf
);
904 x
= (control
>> 8) & 15;
920 snprintf(buf
, sizeof(buf
), "Channel: %d (%s)", x
, s
);
921 lcd_puts(0, line
++, buf
);
923 x
= (control
>> 4) & 15;
936 snprintf(buf
, sizeof(buf
), "Frequency: %d (%s)", x
, s
);
937 lcd_puts(0, line
++, buf
);
939 x
= (control
>> 2) & 3;
940 snprintf(buf
, sizeof(buf
), "Clock accuracy: %d", x
);
941 lcd_puts(0, line
++, buf
);
945 snprintf(buf
, sizeof(buf
), "Measured freq: %ldHz",
946 spdif_measure_frequency());
947 lcd_puts(0, line
++, buf
);
952 if (action_userabort(HZ
/10))
956 spdif_set_output_source(spdif_source
IF_SPDIF_POWER_(, spdif_src_on
));
958 #ifdef HAVE_SPDIF_POWER
959 spdif_power_enable(global_settings
.spdif_enable
);
964 #endif /* CPU_COLDFIRE */
967 #ifdef HAVE_LCD_BITMAP
968 /* button definitions */
969 #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
970 (CONFIG_KEYPAD == IRIVER_H300_PAD)
971 # define DEBUG_CANCEL BUTTON_OFF
973 #elif CONFIG_KEYPAD == RECORDER_PAD
974 # define DEBUG_CANCEL BUTTON_OFF
976 #elif CONFIG_KEYPAD == ONDIO_PAD
977 # define DEBUG_CANCEL BUTTON_MENU
979 #elif (CONFIG_KEYPAD == IPOD_1G2G_PAD) || \
980 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
981 (CONFIG_KEYPAD == IPOD_4G_PAD)
982 # define DEBUG_CANCEL BUTTON_MENU
984 #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
985 # define DEBUG_CANCEL BUTTON_PLAY
987 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
988 # define DEBUG_CANCEL BUTTON_REC
990 #elif (CONFIG_KEYPAD == IRIVER_H10_PAD) || \
991 (CONFIG_KEYPAD == MROBE100_PAD)
992 # define DEBUG_CANCEL BUTTON_REW
994 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
995 (CONFIG_KEYPAD == SANSA_C200_PAD)
996 # define DEBUG_CANCEL BUTTON_LEFT
997 #endif /* key definitions */
1000 bool dbg_ports(void)
1002 #if CONFIG_CPU == SH7034
1004 int adc_battery_voltage
, adc_battery_level
;
1006 lcd_setfont(FONT_SYSFIXED
);
1007 lcd_setmargins(0, 0);
1008 lcd_clear_display();
1012 snprintf(buf
, 32, "PADR: %04x", (unsigned short)PADR
);
1013 lcd_puts(0, 0, buf
);
1014 snprintf(buf
, 32, "PBDR: %04x", (unsigned short)PBDR
);
1015 lcd_puts(0, 1, buf
);
1017 snprintf(buf
, 32, "AN0: %03x AN4: %03x", adc_read(0), adc_read(4));
1018 lcd_puts(0, 2, buf
);
1019 snprintf(buf
, 32, "AN1: %03x AN5: %03x", adc_read(1), adc_read(5));
1020 lcd_puts(0, 3, buf
);
1021 snprintf(buf
, 32, "AN2: %03x AN6: %03x", adc_read(2), adc_read(6));
1022 lcd_puts(0, 4, buf
);
1023 snprintf(buf
, 32, "AN3: %03x AN7: %03x", adc_read(3), adc_read(7));
1024 lcd_puts(0, 5, buf
);
1026 battery_read_info(&adc_battery_voltage
, &adc_battery_level
);
1027 snprintf(buf
, 32, "Batt: %d.%03dV %d%% ", adc_battery_voltage
/ 1000,
1028 adc_battery_voltage
% 1000, adc_battery_level
);
1029 lcd_puts(0, 6, buf
);
1032 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1035 #elif defined(CPU_COLDFIRE)
1036 unsigned int gpio_out
;
1037 unsigned int gpio1_out
;
1038 unsigned int gpio_read
;
1039 unsigned int gpio1_read
;
1040 unsigned int gpio_function
;
1041 unsigned int gpio1_function
;
1042 unsigned int gpio_enable
;
1043 unsigned int gpio1_enable
;
1044 int adc_buttons
, adc_remote
;
1045 int adc_battery_voltage
, adc_battery_level
;
1049 lcd_setmargins(0, 0);
1050 lcd_clear_display();
1051 lcd_setfont(FONT_SYSFIXED
);
1056 gpio_read
= GPIO_READ
;
1057 gpio1_read
= GPIO1_READ
;
1058 gpio_out
= GPIO_OUT
;
1059 gpio1_out
= GPIO1_OUT
;
1060 gpio_function
= GPIO_FUNCTION
;
1061 gpio1_function
= GPIO1_FUNCTION
;
1062 gpio_enable
= GPIO_ENABLE
;
1063 gpio1_enable
= GPIO1_ENABLE
;
1065 snprintf(buf
, sizeof(buf
), "GPIO_READ: %08x", gpio_read
);
1066 lcd_puts(0, line
++, buf
);
1067 snprintf(buf
, sizeof(buf
), "GPIO_OUT: %08x", gpio_out
);
1068 lcd_puts(0, line
++, buf
);
1069 snprintf(buf
, sizeof(buf
), "GPIO_FUNCTION: %08x", gpio_function
);
1070 lcd_puts(0, line
++, buf
);
1071 snprintf(buf
, sizeof(buf
), "GPIO_ENABLE: %08x", gpio_enable
);
1072 lcd_puts(0, line
++, buf
);
1074 snprintf(buf
, sizeof(buf
), "GPIO1_READ: %08x", gpio1_read
);
1075 lcd_puts(0, line
++, buf
);
1076 snprintf(buf
, sizeof(buf
), "GPIO1_OUT: %08x", gpio1_out
);
1077 lcd_puts(0, line
++, buf
);
1078 snprintf(buf
, sizeof(buf
), "GPIO1_FUNCTION: %08x", gpio1_function
);
1079 lcd_puts(0, line
++, buf
);
1080 snprintf(buf
, sizeof(buf
), "GPIO1_ENABLE: %08x", gpio1_enable
);
1081 lcd_puts(0, line
++, buf
);
1083 adc_buttons
= adc_read(ADC_BUTTONS
);
1084 adc_remote
= adc_read(ADC_REMOTE
);
1085 battery_read_info(&adc_battery_voltage
, &adc_battery_level
);
1086 #if defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IRIVER_H300_SERIES)
1087 snprintf(buf
, sizeof(buf
), "ADC_BUTTONS (%c): %02x",
1088 button_scan_enabled() ? '+' : '-', adc_buttons
);
1090 snprintf(buf
, sizeof(buf
), "ADC_BUTTONS: %02x", adc_buttons
);
1092 lcd_puts(0, line
++, buf
);
1093 #if defined(IAUDIO_X5) || defined(IAUDIO_M5)
1094 snprintf(buf
, sizeof(buf
), "ADC_REMOTE (%c): %02x",
1095 remote_detect() ? '+' : '-', adc_remote
);
1097 snprintf(buf
, sizeof(buf
), "ADC_REMOTE: %02x", adc_remote
);
1099 lcd_puts(0, line
++, buf
);
1100 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1101 snprintf(buf
, sizeof(buf
), "ADC_REMOTEDETECT: %02x",
1102 adc_read(ADC_REMOTEDETECT
));
1103 lcd_puts(0, line
++, buf
);
1106 snprintf(buf
, 32, "Batt: %d.%03dV %d%% ", adc_battery_voltage
/ 1000,
1107 adc_battery_voltage
% 1000, adc_battery_level
);
1108 lcd_puts(0, line
++, buf
);
1110 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1111 snprintf(buf
, sizeof(buf
), "remotetype: %d", remote_type());
1112 lcd_puts(0, line
++, buf
);
1116 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1120 #elif defined(CPU_PP502x)
1125 lcd_setmargins(0, 0);
1126 lcd_clear_display();
1127 lcd_setfont(FONT_SYSFIXED
);
1132 lcd_puts(0, line
++, "GPIO STATES:");
1133 snprintf(buf
, sizeof(buf
), "A: %02x E: %02x I: %02x",
1134 (unsigned int)GPIOA_INPUT_VAL
,
1135 (unsigned int)GPIOE_INPUT_VAL
,
1136 (unsigned int)GPIOI_INPUT_VAL
);
1137 lcd_puts(0, line
++, buf
);
1138 snprintf(buf
, sizeof(buf
), "B: %02x F: %02x J: %02x",
1139 (unsigned int)GPIOB_INPUT_VAL
,
1140 (unsigned int)GPIOF_INPUT_VAL
,
1141 (unsigned int)GPIOJ_INPUT_VAL
);
1142 lcd_puts(0, line
++, buf
);
1143 snprintf(buf
, sizeof(buf
), "C: %02x G: %02x K: %02x",
1144 (unsigned int)GPIOC_INPUT_VAL
,
1145 (unsigned int)GPIOG_INPUT_VAL
,
1146 (unsigned int)GPIOK_INPUT_VAL
);
1147 lcd_puts(0, line
++, buf
);
1148 snprintf(buf
, sizeof(buf
), "D: %02x H: %02x L: %02x",
1149 (unsigned int)GPIOD_INPUT_VAL
,
1150 (unsigned int)GPIOH_INPUT_VAL
,
1151 (unsigned int)GPIOL_INPUT_VAL
);
1152 lcd_puts(0, line
++, buf
);
1154 snprintf(buf
, sizeof(buf
), "GPO32_VAL: %08lx", GPO32_VAL
);
1155 lcd_puts(0, line
++, buf
);
1156 snprintf(buf
, sizeof(buf
), "GPO32_EN: %08lx", GPO32_ENABLE
);
1157 lcd_puts(0, line
++, buf
);
1158 snprintf(buf
, sizeof(buf
), "DEV_EN: %08lx", DEV_EN
);
1159 lcd_puts(0, line
++, buf
);
1160 snprintf(buf
, sizeof(buf
), "DEV_EN2: %08lx", DEV_EN2
);
1161 lcd_puts(0, line
++, buf
);
1162 snprintf(buf
, sizeof(buf
), "DEV_EN3: %08lx", inl(0x60006044));
1163 lcd_puts(0, line
++, buf
); /* to be verified */
1164 snprintf(buf
, sizeof(buf
), "DEV_INIT1: %08lx", DEV_INIT1
);
1165 lcd_puts(0, line
++, buf
);
1166 snprintf(buf
, sizeof(buf
), "DEV_INIT2: %08lx", DEV_INIT2
);
1167 lcd_puts(0, line
++, buf
);
1169 #if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
1171 snprintf(buf
, sizeof(buf
), "BATT: %03x UNK1: %03x",
1172 adc_read(ADC_BATTERY
), adc_read(ADC_UNKNOWN_1
));
1173 lcd_puts(0, line
++, buf
);
1174 snprintf(buf
, sizeof(buf
), "REM: %03x PAD: %03x",
1175 adc_read(ADC_REMOTE
), adc_read(ADC_SCROLLPAD
));
1176 lcd_puts(0, line
++, buf
);
1177 #elif defined(SANSA_E200)
1179 snprintf(buf
, sizeof(buf
), "ADC_BVDD: %4d", adc_read(ADC_BVDD
));
1180 lcd_puts(0, line
++, buf
);
1181 snprintf(buf
, sizeof(buf
), "ADC_RTCSUP: %4d", adc_read(ADC_RTCSUP
));
1182 lcd_puts(0, line
++, buf
);
1183 snprintf(buf
, sizeof(buf
), "ADC_UVDD: %4d", adc_read(ADC_UVDD
));
1184 lcd_puts(0, line
++, buf
);
1185 snprintf(buf
, sizeof(buf
), "ADC_CHG_IN: %4d", adc_read(ADC_CHG_IN
));
1186 lcd_puts(0, line
++, buf
);
1187 snprintf(buf
, sizeof(buf
), "ADC_CVDD: %4d", adc_read(ADC_CVDD
));
1188 lcd_puts(0, line
++, buf
);
1189 snprintf(buf
, sizeof(buf
), "ADC_BATTEMP: %4d", adc_read(ADC_BATTEMP
));
1190 lcd_puts(0, line
++, buf
);
1191 snprintf(buf
, sizeof(buf
), "ADC_MICSUP1: %4d", adc_read(ADC_MICSUP1
));
1192 lcd_puts(0, line
++, buf
);
1193 snprintf(buf
, sizeof(buf
), "ADC_MICSUP2: %4d", adc_read(ADC_MICSUP2
));
1194 lcd_puts(0, line
++, buf
);
1195 snprintf(buf
, sizeof(buf
), "ADC_VBE1: %4d", adc_read(ADC_VBE1
));
1196 lcd_puts(0, line
++, buf
);
1197 snprintf(buf
, sizeof(buf
), "ADC_VBE2: %4d", adc_read(ADC_VBE2
));
1198 lcd_puts(0, line
++, buf
);
1199 snprintf(buf
, sizeof(buf
), "ADC_I_MICSUP1:%4d", adc_read(ADC_I_MICSUP1
));
1200 lcd_puts(0, line
++, buf
);
1201 snprintf(buf
, sizeof(buf
), "ADC_I_MICSUP2:%4d", adc_read(ADC_I_MICSUP2
));
1202 lcd_puts(0, line
++, buf
);
1203 snprintf(buf
, sizeof(buf
), "ADC_VBAT: %4d", adc_read(ADC_VBAT
));
1204 lcd_puts(0, line
++, buf
);
1207 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1211 #elif CONFIG_CPU == PP5002
1212 unsigned int gpio_a
, gpio_b
, gpio_c
, gpio_d
;
1217 lcd_setmargins(0, 0);
1218 lcd_clear_display();
1219 lcd_setfont(FONT_SYSFIXED
);
1224 snprintf(buf
, sizeof(buf
), "GPIO_A: %02x GPIO_B: %02x",
1225 (unsigned int)GPIOA_INPUT_VAL
, (unsigned int)GPIOB_INPUT_VAL
);
1226 lcd_puts(0, line
++, buf
);
1227 snprintf(buf
, sizeof(buf
), "GPIO_C: %02x GPIO_D: %02x",
1228 (unsigned int)GPIOC_INPUT_VAL
, (unsigned int)GPIOD_INPUT_VAL
);
1229 lcd_puts(0, line
++, buf
);
1231 snprintf(buf
, sizeof(buf
), "DEV_EN: %08lx", DEV_EN
);
1232 lcd_puts(0, line
++, buf
);
1233 snprintf(buf
, sizeof(buf
), "CLOCK_ENABLE: %08lx", CLOCK_ENABLE
);
1234 lcd_puts(0, line
++, buf
);
1235 snprintf(buf
, sizeof(buf
), "CLOCK_SOURCE: %08lx", CLOCK_SOURCE
);
1236 lcd_puts(0, line
++, buf
);
1237 snprintf(buf
, sizeof(buf
), "PLL_CONTROL: %08lx", PLL_CONTROL
);
1238 lcd_puts(0, line
++, buf
);
1239 snprintf(buf
, sizeof(buf
), "PLL_DIV: %08lx", PLL_DIV
);
1240 lcd_puts(0, line
++, buf
);
1241 snprintf(buf
, sizeof(buf
), "PLL_MULT: %08lx", PLL_MULT
);
1242 lcd_puts(0, line
++, buf
);
1243 snprintf(buf
, sizeof(buf
), "TIMING1_CTL: %08lx", TIMING1_CTL
);
1244 lcd_puts(0, line
++, buf
);
1245 snprintf(buf
, sizeof(buf
), "TIMING2_CTL: %08lx", TIMING2_CTL
);
1246 lcd_puts(0, line
++, buf
);
1249 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1253 return __dbg_ports();
1257 #else /* !HAVE_LCD_BITMAP */
1258 bool dbg_ports(void)
1262 int adc_battery_voltage
;
1265 lcd_clear_display();
1272 snprintf(buf
, 32, "PADR: %04x", (unsigned short)PADR
);
1275 snprintf(buf
, 32, "PBDR: %04x", (unsigned short)PBDR
);
1278 snprintf(buf
, 32, "AN0: %03x", adc_read(0));
1281 snprintf(buf
, 32, "AN1: %03x", adc_read(1));
1284 snprintf(buf
, 32, "AN2: %03x", adc_read(2));
1287 snprintf(buf
, 32, "AN3: %03x", adc_read(3));
1290 snprintf(buf
, 32, "AN4: %03x", adc_read(4));
1293 snprintf(buf
, 32, "AN5: %03x", adc_read(5));
1296 snprintf(buf
, 32, "AN6: %03x", adc_read(6));
1299 snprintf(buf
, 32, "AN7: %03x", adc_read(7));
1303 lcd_puts(0, 0, buf
);
1305 battery_read_info(&adc_battery_voltage
, NULL
);
1306 snprintf(buf
, 32, "Batt: %d.%03dV", adc_battery_voltage
/ 1000,
1307 adc_battery_voltage
% 1000);
1308 lcd_puts(0, 1, buf
);
1311 button
= get_action(CONTEXT_SETTINGS
,HZ
/5);
1315 case ACTION_STD_CANCEL
:
1318 case ACTION_SETTINGS_DEC
:
1324 case ACTION_SETTINGS_INC
:
1333 #endif /* !HAVE_LCD_BITMAP */
1334 #endif /* !SIMULATOR */
1336 #if (CONFIG_RTC == RTC_PCF50605) && !defined(SIMULATOR)
1337 static bool dbg_pcf(void)
1342 #ifdef HAVE_LCD_BITMAP
1343 lcd_setmargins(0, 0);
1344 lcd_setfont(FONT_SYSFIXED
);
1346 lcd_clear_display();
1352 snprintf(buf
, sizeof(buf
), "DCDC1: %02x", pcf50605_read(0x1b));
1353 lcd_puts(0, line
++, buf
);
1354 snprintf(buf
, sizeof(buf
), "DCDC2: %02x", pcf50605_read(0x1c));
1355 lcd_puts(0, line
++, buf
);
1356 snprintf(buf
, sizeof(buf
), "DCDC3: %02x", pcf50605_read(0x1d));
1357 lcd_puts(0, line
++, buf
);
1358 snprintf(buf
, sizeof(buf
), "DCDC4: %02x", pcf50605_read(0x1e));
1359 lcd_puts(0, line
++, buf
);
1360 snprintf(buf
, sizeof(buf
), "DCDEC1: %02x", pcf50605_read(0x1f));
1361 lcd_puts(0, line
++, buf
);
1362 snprintf(buf
, sizeof(buf
), "DCDEC2: %02x", pcf50605_read(0x20));
1363 lcd_puts(0, line
++, buf
);
1364 snprintf(buf
, sizeof(buf
), "DCUDC1: %02x", pcf50605_read(0x21));
1365 lcd_puts(0, line
++, buf
);
1366 snprintf(buf
, sizeof(buf
), "DCUDC2: %02x", pcf50605_read(0x22));
1367 lcd_puts(0, line
++, buf
);
1368 snprintf(buf
, sizeof(buf
), "IOREGC: %02x", pcf50605_read(0x23));
1369 lcd_puts(0, line
++, buf
);
1370 snprintf(buf
, sizeof(buf
), "D1REGC: %02x", pcf50605_read(0x24));
1371 lcd_puts(0, line
++, buf
);
1372 snprintf(buf
, sizeof(buf
), "D2REGC: %02x", pcf50605_read(0x25));
1373 lcd_puts(0, line
++, buf
);
1374 snprintf(buf
, sizeof(buf
), "D3REGC: %02x", pcf50605_read(0x26));
1375 lcd_puts(0, line
++, buf
);
1376 snprintf(buf
, sizeof(buf
), "LPREG1: %02x", pcf50605_read(0x27));
1377 lcd_puts(0, line
++, buf
);
1380 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1390 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
1391 static bool dbg_cpufreq(void)
1397 #ifdef HAVE_LCD_BITMAP
1398 lcd_setmargins(0, 0);
1399 lcd_setfont(FONT_SYSFIXED
);
1401 lcd_clear_display();
1407 snprintf(buf
, sizeof(buf
), "Frequency: %ld", FREQ
);
1408 lcd_puts(0, line
++, buf
);
1410 snprintf(buf
, sizeof(buf
), "boost_counter: %d", get_cpu_boost_counter());
1411 lcd_puts(0, line
++, buf
);
1414 button
= get_action(CONTEXT_STD
,HZ
/10);
1418 case ACTION_STD_PREV
:
1422 case ACTION_STD_NEXT
:
1427 while (get_cpu_boost_counter() > 0)
1429 set_cpu_frequency(CPUFREQ_DEFAULT
);
1432 case ACTION_STD_CANCEL
:
1439 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
1441 #if defined(HAVE_TSC2100) && !defined(SIMULATOR)
1442 #include "tsc2100.h"
1443 char *itob(int n
, int len
)
1445 static char binary
[64];
1447 for (i
=1, j
=0;i
<=len
;i
++)
1449 binary
[j
++] = n
&(1<<(len
-i
))?'1':'0';
1456 static char* tsc2100_debug_getname(int selected_item
, void * data
, char *buffer
)
1458 int *page
= (int*)data
;
1459 bool reserved
= false;
1463 if ((selected_item
> 0x0a) ||
1464 (selected_item
== 0x04) ||
1465 (selected_item
== 0x08))
1469 if ((selected_item
> 0x05) ||
1470 (selected_item
== 0x02))
1474 if (selected_item
> 0x1e)
1479 snprintf(buffer
, MAX_PATH
, "%02x: RESERVED", selected_item
);
1481 snprintf(buffer
, MAX_PATH
, "%02x: %s", selected_item
,
1482 itob(tsc2100_readreg(*page
, selected_item
)&0xffff,16));
1485 static int tsc2100debug_action_callback(int action
, struct gui_synclist
*lists
)
1487 int *page
= (int*)lists
->data
;
1488 if (action
== ACTION_STD_OK
)
1490 *page
= (*page
+1)%3;
1491 snprintf(lists
->title
, 32,
1492 "tsc2100 registers - Page %d", *page
);
1493 return ACTION_REDRAW
;
1497 bool tsc2100_debug(void)
1500 char title
[32] = "tsc2100 registers - Page 0";
1501 struct simplelist_info info
;
1502 simplelist_info_init(&info
, title
, 32, &page
);
1503 info
.timeout
= HZ
/100;
1504 info
.get_name
= tsc2100_debug_getname
;
1505 info
.action_callback
= tsc2100debug_action_callback
;
1506 return simplelist_show_list(&info
);
1510 #ifdef HAVE_LCD_BITMAP
1512 * view_battery() shows a automatically scaled graph of the battery voltage
1513 * over time. Usable for estimating battery life / charging rate.
1514 * The power_history array is updated in power_thread of powermgmt.c.
1517 #define BAT_LAST_VAL MIN(LCD_WIDTH, POWER_HISTORY_LEN)
1518 #define BAT_YSPACE (LCD_HEIGHT - 20)
1520 static bool view_battery(void)
1524 unsigned short maxv
, minv
;
1527 lcd_setmargins(0, 0);
1528 lcd_setfont(FONT_SYSFIXED
);
1532 lcd_clear_display();
1534 case 0: /* voltage history graph */
1535 /* Find maximum and minimum voltage for scaling */
1536 minv
= power_history
[0];
1538 for (i
= 1; i
< BAT_LAST_VAL
&& power_history
[i
]; i
++) {
1539 if (power_history
[i
] > maxv
)
1540 maxv
= power_history
[i
];
1541 if (power_history
[i
] < minv
)
1542 minv
= power_history
[i
];
1545 snprintf(buf
, 30, "Battery %d.%03d", power_history
[0] / 1000,
1546 power_history
[0] % 1000);
1547 lcd_puts(0, 0, buf
);
1548 snprintf(buf
, 30, "scale %d.%03d-%d.%03dV",
1549 minv
/ 1000, minv
% 1000, maxv
/ 1000, maxv
% 1000);
1550 lcd_puts(0, 1, buf
);
1553 for (i
= BAT_LAST_VAL
- 1; i
>= 0; i
--) {
1554 y
= (power_history
[i
] - minv
) * BAT_YSPACE
/ (maxv
- minv
);
1555 lcd_set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
1556 lcd_vline(x
, LCD_HEIGHT
-1, 20);
1557 lcd_set_drawmode(DRMODE_SOLID
);
1558 lcd_vline(x
, LCD_HEIGHT
-1,
1559 MIN(MAX(LCD_HEIGHT
-1 - y
, 20), LCD_HEIGHT
-1));
1565 case 1: /* status: */
1566 lcd_puts(0, 0, "Power status:");
1568 battery_read_info(&y
, NULL
);
1569 snprintf(buf
, 30, "Battery: %d.%03d V", y
/ 1000, y
% 1000);
1570 lcd_puts(0, 1, buf
);
1571 #ifdef ADC_EXT_POWER
1572 y
= (adc_read(ADC_EXT_POWER
) * EXT_SCALE_FACTOR
) / 1000;
1573 snprintf(buf
, 30, "External: %d.%03d V", y
/ 1000, y
% 1000);
1574 lcd_puts(0, 2, buf
);
1577 #if CONFIG_CHARGING == CHARGING_CONTROL
1578 snprintf(buf
, 30, "Chgr: %s %s",
1579 charger_inserted() ? "present" : "absent",
1580 charger_enabled
? "on" : "off");
1581 lcd_puts(0, 3, buf
);
1582 snprintf(buf
, 30, "short delta: %d", short_delta
);
1583 lcd_puts(0, 5, buf
);
1584 snprintf(buf
, 30, "long delta: %d", long_delta
);
1585 lcd_puts(0, 6, buf
);
1586 lcd_puts(0, 7, power_message
);
1587 snprintf(buf
, 30, "USB Inserted: %s",
1588 usb_inserted() ? "yes" : "no");
1589 lcd_puts(0, 8, buf
);
1590 #if defined IRIVER_H300_SERIES
1591 snprintf(buf
, 30, "USB Charging Enabled: %s",
1592 usb_charging_enabled() ? "yes" : "no");
1593 lcd_puts(0, 9, buf
);
1595 #else /* CONFIG_CHARGING != CHARGING_CONTROL */
1596 #if defined IPOD_NANO || defined IPOD_VIDEO
1597 int usb_pwr
= (GPIOL_INPUT_VAL
& 0x10)?true:false;
1598 int ext_pwr
= (GPIOL_INPUT_VAL
& 0x08)?false:true;
1599 int dock
= (GPIOA_INPUT_VAL
& 0x10)?true:false;
1600 int charging
= (GPIOB_INPUT_VAL
& 0x01)?false:true;
1601 int headphone
= (GPIOA_INPUT_VAL
& 0x80)?true:false;
1603 snprintf(buf
, 30, "USB pwr: %s",
1604 usb_pwr
? "present" : "absent");
1605 lcd_puts(0, 3, buf
);
1606 snprintf(buf
, 30, "EXT pwr: %s",
1607 ext_pwr
? "present" : "absent");
1608 lcd_puts(0, 4, buf
);
1609 snprintf(buf
, 30, "Battery: %s",
1610 charging
? "charging" : (usb_pwr
||ext_pwr
) ? "charged" : "discharging");
1611 lcd_puts(0, 5, buf
);
1612 snprintf(buf
, 30, "Dock mode: %s",
1613 dock
? "enabled" : "disabled");
1614 lcd_puts(0, 6, buf
);
1615 snprintf(buf
, 30, "Headphone: %s",
1616 headphone
? "connected" : "disconnected");
1617 lcd_puts(0, 7, buf
);
1619 snprintf(buf
, 30, "Charger: %s",
1620 charger_inserted() ? "present" : "absent");
1621 lcd_puts(0, 3, buf
);
1623 #endif /* CONFIG_CHARGING != CHARGING_CONTROL */
1624 #endif /* CONFIG_CHARGING */
1627 case 2: /* voltage deltas: */
1628 lcd_puts(0, 0, "Voltage deltas:");
1630 for (i
= 0; i
<= 6; i
++) {
1631 y
= power_history
[i
] - power_history
[i
+1];
1632 snprintf(buf
, 30, "-%d min: %s%d.%03d V", i
,
1633 (y
< 0) ? "-" : "", ((y
< 0) ? y
* -1 : y
) / 1000,
1634 ((y
< 0) ? y
* -1 : y
) % 1000);
1635 lcd_puts(0, i
+1, buf
);
1639 case 3: /* remaining time estimation: */
1641 #if CONFIG_CHARGING == CHARGING_CONTROL
1642 snprintf(buf
, 30, "charge_state: %d", charge_state
);
1643 lcd_puts(0, 0, buf
);
1645 snprintf(buf
, 30, "Cycle time: %d m", powermgmt_last_cycle_startstop_min
);
1646 lcd_puts(0, 1, buf
);
1648 snprintf(buf
, 30, "Lvl@cyc st: %d%%", powermgmt_last_cycle_level
);
1649 lcd_puts(0, 2, buf
);
1651 snprintf(buf
, 30, "P=%2d I=%2d", pid_p
, pid_i
);
1652 lcd_puts(0, 3, buf
);
1654 snprintf(buf
, 30, "Trickle sec: %d/60", trickle_sec
);
1655 lcd_puts(0, 4, buf
);
1656 #endif /* CONFIG_CHARGING == CHARGING_CONTROL */
1658 snprintf(buf
, 30, "Last PwrHist: %d.%03dV",
1659 power_history
[0] / 1000,
1660 power_history
[0] % 1000);
1661 lcd_puts(0, 5, buf
);
1663 snprintf(buf
, 30, "battery level: %d%%", battery_level());
1664 lcd_puts(0, 6, buf
);
1666 snprintf(buf
, 30, "Est. remain: %d m", battery_time());
1667 lcd_puts(0, 7, buf
);
1673 switch(get_action(CONTEXT_SETTINGS
,HZ
/2))
1675 case ACTION_SETTINGS_DEC
:
1680 case ACTION_SETTINGS_INC
:
1685 case ACTION_STD_CANCEL
:
1692 #endif /* HAVE_LCD_BITMAP */
1696 #if defined(HAVE_MMC) || defined(HAVE_HOTSWAP)
1697 #if defined(HAVE_MMC)
1698 #define CARDTYPE "MMC"
1700 #define CARDTYPE "microSD"
1702 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1705 int *cardnum
= (int*)lists
->data
;
1706 unsigned char card_name
[7];
1707 unsigned char pbuf
[32];
1708 char *title
= lists
->title
;
1709 static const unsigned char i_vmin
[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
1710 static const unsigned char i_vmax
[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
1711 static const unsigned char *kbit_units
[] = { "kBit/s", "MBit/s", "GBit/s" };
1712 static const unsigned char *nsec_units
[] = { "ns", "�s", "ms" };
1713 static const char *spec_vers
[] = { "1.0-1.2", "1.4", "2.0-2.2",
1714 "3.1-3.31", "4.0" };
1715 if ((btn
== ACTION_STD_OK
) || (btn
== SYS_FS_CHANGED
) || (btn
== ACTION_REDRAW
))
1717 if (btn
== ACTION_STD_OK
)
1719 *cardnum
^= 0x1; /* change cards */
1722 simplelist_set_line_count(0);
1724 card
= card_get_info(*cardnum
);
1726 if (card
->initialized
> 0)
1728 card_name
[6] = '\0';
1729 strncpy(card_name
, ((unsigned char*)card
->cid
) + 3, 6);
1730 simplelist_addline(SIMPLELIST_ADD_LINE
,
1731 "%s Rev %d.%d", card_name
,
1732 (int) card_extract_bits(card
->cid
, 72, 4),
1733 (int) card_extract_bits(card
->cid
, 76, 4));
1734 simplelist_addline(SIMPLELIST_ADD_LINE
,
1736 (int) card_extract_bits(card
->cid
, 112, 4),
1737 (int) card_extract_bits(card
->cid
, 116, 4) + 1997);
1738 simplelist_addline(SIMPLELIST_ADD_LINE
,
1740 card_extract_bits(card
->cid
, 80, 32));
1741 simplelist_addline(SIMPLELIST_ADD_LINE
,
1743 (int) card_extract_bits(card
->cid
, 0, 8),
1744 (int) card_extract_bits(card
->cid
, 8, 16));
1745 int temp
= card_extract_bits(card
->csd
, 2, 4);
1746 simplelist_addline(SIMPLELIST_ADD_LINE
,
1747 CARDTYPE
" v%s", temp
< 5 ?
1748 spec_vers
[temp
] : "?.?");
1749 simplelist_addline(SIMPLELIST_ADD_LINE
,
1750 "Blocks: 0x%06lx", card
->numblocks
);
1751 simplelist_addline(SIMPLELIST_ADD_LINE
,
1752 "Blksz.: %d P:%c%c", card
->blocksize
,
1753 card_extract_bits(card
->csd
, 48, 1) ? 'R' : '-',
1754 card_extract_bits(card
->csd
, 106, 1) ? 'W' : '-');
1755 output_dyn_value(pbuf
, sizeof pbuf
, card
->speed
/ 1000,
1757 simplelist_addline(SIMPLELIST_ADD_LINE
,
1759 output_dyn_value(pbuf
, sizeof pbuf
, card
->tsac
,
1761 simplelist_addline(SIMPLELIST_ADD_LINE
,
1763 simplelist_addline(SIMPLELIST_ADD_LINE
,
1764 "Nsac: %d clk", card
->nsac
);
1765 simplelist_addline(SIMPLELIST_ADD_LINE
,
1766 "R2W: *%d", card
->r2w_factor
);
1767 simplelist_addline(SIMPLELIST_ADD_LINE
,
1769 i_vmin
[card_extract_bits(card
->csd
, 66, 3)],
1770 i_vmax
[card_extract_bits(card
->csd
, 69, 3)]);
1771 simplelist_addline(SIMPLELIST_ADD_LINE
,
1773 i_vmin
[card_extract_bits(card
->csd
, 72, 3)],
1774 i_vmax
[card_extract_bits(card
->csd
, 75, 3)]);
1776 else if (card
->initialized
== 0)
1778 simplelist_addline(SIMPLELIST_ADD_LINE
, "Not Found!");
1781 else /* card->initialized < 0 */
1783 simplelist_addline(SIMPLELIST_ADD_LINE
, "Init Error! (%d)", card
->initialized
);
1786 snprintf(title
, 16, "[" CARDTYPE
" %d]", *cardnum
);
1787 gui_synclist_set_title(lists
, title
, Icon_NOICON
);
1788 gui_synclist_set_nb_items(lists
, simplelist_get_line_count());
1789 gui_synclist_select_item(lists
, 0);
1790 btn
= ACTION_REDRAW
;
1794 #else /* !defined(HAVE_MMC) && !defined(HAVE_HOTSWAP) */
1795 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1800 unsigned short* identify_info
= ata_get_identify();
1801 bool timing_info_present
= false;
1804 simplelist_set_line_count(0);
1806 for (i
=0; i
< 20; i
++)
1807 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+27]);
1809 /* kill trailing space */
1810 for (i
=39; i
&& buf
[i
]==' '; i
--)
1812 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", buf
);
1813 for (i
=0; i
< 4; i
++)
1814 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+23]);
1816 simplelist_addline(SIMPLELIST_ADD_LINE
,
1817 "Firmware: %s", buf
);
1818 snprintf(buf
, sizeof buf
, "%ld MB",
1819 ((unsigned long)identify_info
[61] << 16 |
1820 (unsigned long)identify_info
[60]) / 2048 );
1821 simplelist_addline(SIMPLELIST_ADD_LINE
,
1824 fat_size( IF_MV2(0,) NULL
, &free
);
1825 simplelist_addline(SIMPLELIST_ADD_LINE
,
1826 "Free: %ld MB", free
/ 1024);
1827 simplelist_addline(SIMPLELIST_ADD_LINE
,
1828 "Spinup time: %d ms", ata_spinup_time
* (1000/HZ
));
1829 i
= identify_info
[83] & (1<<3);
1830 simplelist_addline(SIMPLELIST_ADD_LINE
,
1831 "Power mgmt: %s", i
? "enabled" : "unsupported");
1832 i
= identify_info
[83] & (1<<9);
1833 simplelist_addline(SIMPLELIST_ADD_LINE
,
1834 "Noise mgmt: %s", i
? "enabled" : "unsupported");
1835 i
= identify_info
[82] & (1<<6);
1836 simplelist_addline(SIMPLELIST_ADD_LINE
,
1837 "Read-ahead: %s", i
? "enabled" : "unsupported");
1838 timing_info_present
= identify_info
[53] & (1<<1);
1839 if(timing_info_present
) {
1840 char pio3
[2], pio4
[2];pio3
[1] = 0;
1842 pio3
[0] = (identify_info
[64] & (1<<0)) ? '3' : 0;
1843 pio4
[0] = (identify_info
[64] & (1<<1)) ? '4' : 0;
1844 simplelist_addline(SIMPLELIST_ADD_LINE
,
1845 "PIO modes: 0 1 2 %s %s", pio3
, pio4
);
1848 simplelist_addline(SIMPLELIST_ADD_LINE
,
1849 "No PIO mode info");
1851 timing_info_present
= identify_info
[53] & (1<<1);
1852 if(timing_info_present
) {
1853 simplelist_addline(SIMPLELIST_ADD_LINE
,
1854 "Cycle times %dns/%dns",
1856 identify_info
[68] );
1858 simplelist_addline(SIMPLELIST_ADD_LINE
,
1861 timing_info_present
= identify_info
[53] & (1<<1);
1862 if(timing_info_present
) {
1863 i
= identify_info
[49] & (1<<11);
1864 simplelist_addline(SIMPLELIST_ADD_LINE
,
1865 "IORDY support: %s", i
? "yes" : "no");
1866 i
= identify_info
[49] & (1<<10);
1867 simplelist_addline(SIMPLELIST_ADD_LINE
,
1868 "IORDY disable: %s", i
? "yes" : "no");
1870 simplelist_addline(SIMPLELIST_ADD_LINE
,
1873 simplelist_addline(SIMPLELIST_ADD_LINE
,
1874 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
1877 #endif /* !defined(HAVE_MMC) && !defined(HAVE_HOTSWAP) */
1878 static bool dbg_disk_info(void)
1880 struct simplelist_info info
;
1881 simplelist_info_init(&info
, "Disk Info", 1, NULL
);
1882 #if defined(HAVE_MMC) || defined(HAVE_HOTSWAP)
1885 info
.callback_data
= (void*)&card
;
1888 info
.action_callback
= disk_callback
;
1889 info
.hide_selection
= true;
1890 return simplelist_show_list(&info
);
1892 #endif /* !SIMULATOR */
1894 #ifdef HAVE_DIRCACHE
1895 static int dircache_callback(int btn
, struct gui_synclist
*lists
)
1897 (void)btn
; (void)lists
;
1898 simplelist_set_line_count(0);
1899 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache initialized: %s",
1900 dircache_is_enabled() ? "Yes" : "No");
1901 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache size: %d B",
1902 dircache_get_cache_size());
1903 simplelist_addline(SIMPLELIST_ADD_LINE
, "Last size: %d B",
1904 global_status
.dircache_size
);
1905 simplelist_addline(SIMPLELIST_ADD_LINE
, "Limit: %d B",
1907 simplelist_addline(SIMPLELIST_ADD_LINE
, "Reserve: %d/%d B",
1908 dircache_get_reserve_used(), DIRCACHE_RESERVE
);
1909 simplelist_addline(SIMPLELIST_ADD_LINE
, "Scanning took: %d s",
1910 dircache_get_build_ticks() / HZ
);
1911 simplelist_addline(SIMPLELIST_ADD_LINE
, "Entry count: %d",
1912 dircache_get_entry_count());
1916 static bool dbg_dircache_info(void)
1918 struct simplelist_info info
;
1919 simplelist_info_init(&info
, "Dircache Info", 7, NULL
);
1920 info
.action_callback
= dircache_callback
;
1921 info
.hide_selection
= true;
1922 return simplelist_show_list(&info
);
1925 #endif /* HAVE_DIRCACHE */
1927 #ifdef HAVE_TAGCACHE
1928 static int database_callback(int btn
, struct gui_synclist
*lists
)
1931 struct tagcache_stat
*stat
= tagcache_get_stat();
1932 static bool synced
= false;
1934 simplelist_set_line_count(0);
1936 simplelist_addline(SIMPLELIST_ADD_LINE
, "Initialized: %s",
1937 stat
->initialized
? "Yes" : "No");
1938 simplelist_addline(SIMPLELIST_ADD_LINE
, "DB Ready: %s",
1939 stat
->ready
? "Yes" : "No");
1940 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM Cache: %s",
1941 stat
->ramcache
? "Yes" : "No");
1942 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM: %d/%d B",
1943 stat
->ramcache_used
, stat
->ramcache_allocated
);
1944 simplelist_addline(SIMPLELIST_ADD_LINE
, "Progress: %d%% (%d entries)",
1945 stat
->progress
, stat
->processed_entries
);
1946 simplelist_addline(SIMPLELIST_ADD_LINE
, "Curfile: %s",
1947 stat
->curentry
? stat
->curentry
: "---");
1948 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit step: %d",
1950 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit delayed: %s",
1951 stat
->commit_delayed
? "Yes" : "No");
1957 tagcache_screensync_event();
1960 if (!btn
&& stat
->curentry
)
1963 return ACTION_REDRAW
;
1966 if (btn
== ACTION_STD_CANCEL
)
1967 tagcache_screensync_enable(false);
1971 static bool dbg_tagcache_info(void)
1973 struct simplelist_info info
;
1974 simplelist_info_init(&info
, "Database Info", 8, NULL
);
1975 info
.action_callback
= database_callback
;
1976 info
.hide_selection
= true;
1977 info
.timeout
= TIMEOUT_NOBLOCK
;
1978 tagcache_screensync_enable(true);
1979 return simplelist_show_list(&info
);
1983 #if CONFIG_CPU == SH7034
1984 static bool dbg_save_roms(void)
1987 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
1989 fd
= creat("/internal_rom_0000-FFFF.bin");
1992 write(fd
, (void *)0, 0x10000);
1996 fd
= creat("/internal_rom_2000000-203FFFF.bin");
1999 write(fd
, (void *)0x2000000, 0x40000);
2003 system_memory_guard(oldmode
);
2006 #elif defined CPU_COLDFIRE
2007 static bool dbg_save_roms(void)
2010 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
2012 #if defined(IRIVER_H100_SERIES)
2013 fd
= creat("/internal_rom_000000-1FFFFF.bin");
2014 #elif defined(IRIVER_H300_SERIES)
2015 fd
= creat("/internal_rom_000000-3FFFFF.bin");
2016 #elif defined(IAUDIO_X5) || defined(IAUDIO_M5)
2017 fd
= creat("/internal_rom_000000-3FFFFF.bin");
2021 write(fd
, (void *)0, FLASH_SIZE
);
2024 system_memory_guard(oldmode
);
2027 fd
= creat("/internal_eeprom.bin");
2031 char buf
[EEPROM_SIZE
];
2034 old_irq_level
= set_irq_level(HIGHEST_IRQ_LEVEL
);
2036 err
= eeprom_24cxx_read(0, buf
, sizeof buf
);
2038 gui_syncsplash(HZ
*3, "Eeprom read failure (%d)",err
);
2041 write(fd
, buf
, sizeof buf
);
2044 set_irq_level(old_irq_level
);
2052 #elif defined(CPU_PP) && !(defined(SANSA_E200) || defined(SANSA_C200))
2053 static bool dbg_save_roms(void)
2057 fd
= creat("/internal_rom_000000-0FFFFF.bin");
2060 write(fd
, (void *)0x20000000, FLASH_SIZE
);
2070 static int radio_callback(int btn
, struct gui_synclist
*lists
)
2073 if (btn
== ACTION_STD_CANCEL
)
2075 simplelist_set_line_count(1);
2077 #if (CONFIG_TUNER & LV24020LP)
2078 simplelist_addline(SIMPLELIST_ADD_LINE
,
2079 "CTRL_STAT: %02X", lv24020lp_get(LV24020LP_CTRL_STAT
) );
2080 simplelist_addline(SIMPLELIST_ADD_LINE
,
2081 "RADIO_STAT: %02X", lv24020lp_get(LV24020LP_REG_STAT
) );
2082 simplelist_addline(SIMPLELIST_ADD_LINE
,
2083 "MSS_FM: %d kHz", lv24020lp_get(LV24020LP_MSS_FM
) );
2084 simplelist_addline(SIMPLELIST_ADD_LINE
,
2085 "MSS_IF: %d Hz", lv24020lp_get(LV24020LP_MSS_IF
) );
2086 simplelist_addline(SIMPLELIST_ADD_LINE
,
2087 "MSS_SD: %d Hz", lv24020lp_get(LV24020LP_MSS_SD
) );
2088 simplelist_addline(SIMPLELIST_ADD_LINE
,
2089 "if_set: %d Hz", lv24020lp_get(LV24020LP_IF_SET
) );
2090 simplelist_addline(SIMPLELIST_ADD_LINE
,
2091 "sd_set: %d Hz", lv24020lp_get(LV24020LP_SD_SET
) );
2093 #if (CONFIG_TUNER & S1A0903X01)
2094 simplelist_addline(SIMPLELIST_ADD_LINE
,
2095 "Samsung regs: %08X", s1a0903x01_get(RADIO_ALL
));
2096 /* This one doesn't return dynamic data atm */
2098 #if (CONFIG_TUNER & TEA5767)
2099 struct tea5767_dbg_info nfo
;
2100 tea5767_dbg_info(&nfo
);
2101 simplelist_addline(SIMPLELIST_ADD_LINE
, "Philips regs:");
2102 simplelist_addline(SIMPLELIST_ADD_LINE
,
2103 " Read: %02X %02X %02X %02X %02X",
2104 (unsigned)nfo
.read_regs
[0], (unsigned)nfo
.read_regs
[1],
2105 (unsigned)nfo
.read_regs
[2], (unsigned)nfo
.read_regs
[3],
2106 (unsigned)nfo
.read_regs
[4]);
2107 simplelist_addline(SIMPLELIST_ADD_LINE
,
2108 " Write: %02X %02X %02X %02X %02X",
2109 (unsigned)nfo
.write_regs
[0], (unsigned)nfo
.write_regs
[1],
2110 (unsigned)nfo
.write_regs
[2], (unsigned)nfo
.write_regs
[3],
2111 (unsigned)nfo
.write_regs
[4]);
2113 return ACTION_REDRAW
;
2115 static bool dbg_fm_radio(void)
2117 struct simplelist_info info
;
2118 simplelist_info_init(&info
, "FM Radio", 1, NULL
);
2119 simplelist_set_line_count(0);
2120 simplelist_addline(SIMPLELIST_ADD_LINE
, "HW detected: %s",
2121 radio_hardware_present() ? "yes" : "no");
2123 info
.action_callback
= radio_hardware_present()?radio_callback
: NULL
;
2124 info
.hide_selection
= true;
2125 return simplelist_show_list(&info
);
2127 #endif /* CONFIG_TUNER */
2128 #endif /* !SIMULATOR */
2130 #ifdef HAVE_LCD_BITMAP
2131 extern bool do_screendump_instead_of_usb
;
2133 static bool dbg_screendump(void)
2135 do_screendump_instead_of_usb
= !do_screendump_instead_of_usb
;
2136 gui_syncsplash(HZ
, "Screendump %s",
2137 do_screendump_instead_of_usb
?"enabled":"disabled");
2140 #endif /* HAVE_LCD_BITMAP */
2142 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2143 static bool dbg_set_memory_guard(void)
2145 static const struct opt_items names
[MAXMEMGUARD
] = {
2147 { "Flash ROM writes", -1 },
2148 { "Zero area (all)", -1 }
2150 int mode
= system_memory_guard(MEMGUARD_KEEP
);
2152 set_option( "Catch mem accesses", &mode
, INT
, names
, MAXMEMGUARD
, NULL
);
2153 system_memory_guard(mode
);
2157 #endif /* CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) */
2159 #if defined(TOSHIBA_GIGABEAT_F) && !defined(SIMULATOR)
2161 extern volatile bool lcd_poweroff
;
2163 static bool dbg_lcd_power_off(void)
2165 lcd_setmargins(0, 0);
2171 lcd_clear_display();
2172 lcd_puts(0, 0, "LCD Power Off");
2174 lcd_puts(1, 1, "Yes");
2176 lcd_puts(1, 1, "No");
2180 button
= get_action(CONTEXT_STD
,HZ
/5);
2183 case ACTION_STD_PREV
:
2184 case ACTION_STD_NEXT
:
2185 lcd_poweroff
= !lcd_poweroff
;
2188 case ACTION_STD_CANCEL
:
2199 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2200 static bool dbg_write_eeprom(void)
2205 char buf
[EEPROM_SIZE
];
2208 fd
= open("/internal_eeprom.bin", O_RDONLY
);
2212 rc
= read(fd
, buf
, EEPROM_SIZE
);
2214 if(rc
== EEPROM_SIZE
)
2216 old_irq_level
= set_irq_level(HIGHEST_IRQ_LEVEL
);
2218 err
= eeprom_24cxx_write(0, buf
, sizeof buf
);
2220 gui_syncsplash(HZ
*3, "Eeprom write failure (%d)",err
);
2222 gui_syncsplash(HZ
*3, "Eeprom written successfully");
2224 set_irq_level(old_irq_level
);
2228 gui_syncsplash(HZ
*3, "File read error (%d)",rc
);
2234 gui_syncsplash(HZ
*3, "Failed to open 'internal_eeprom.bin'");
2239 #endif /* defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS) */
2240 #ifdef CPU_BOOST_LOGGING
2241 static bool cpu_boost_log(void)
2244 int count
= cpu_boost_log_getcount();
2245 int lines
= LCD_HEIGHT
/SYSFONT_HEIGHT
;
2248 lcd_setmargins(0, 0);
2249 lcd_setfont(FONT_SYSFIXED
);
2250 str
= cpu_boost_log_getlog_first();
2253 lcd_clear_display();
2254 for(j
=0; j
<lines
; j
++,i
++)
2257 str
= cpu_boost_log_getlog_next();
2268 switch(get_action(CONTEXT_STD
,TIMEOUT_BLOCK
))
2271 case ACTION_STD_PREV
:
2272 case ACTION_STD_NEXT
:
2275 case ACTION_STD_CANCEL
:
2282 get_action(CONTEXT_STD
,TIMEOUT_BLOCK
);
2283 lcd_setfont(FONT_UI
);
2288 #if (defined(HAVE_SCROLLWHEEL) && (CONFIG_KEYPAD==IPOD_4G_PAD) && !defined(SIMULATOR))
2289 extern bool wheel_is_touched
;
2290 extern int old_wheel_value
;
2291 extern int new_wheel_value
;
2292 extern int wheel_delta
;
2293 extern unsigned int accumulated_wheel_delta
;
2294 extern unsigned int wheel_velocity
;
2296 static bool dbg_scrollwheel(void)
2301 lcd_setmargins(0, 0);
2302 lcd_setfont(FONT_SYSFIXED
);
2306 if (action_userabort(HZ
/10))
2309 lcd_clear_display();
2311 /* show internal variables of scrollwheel driver */
2312 snprintf(buf
, sizeof(buf
), "wheel touched: %s", (wheel_is_touched
) ? "true" : "false");
2313 lcd_puts(0, 0, buf
);
2314 snprintf(buf
, sizeof(buf
), "new position: %2d", new_wheel_value
);
2315 lcd_puts(0, 1, buf
);
2316 snprintf(buf
, sizeof(buf
), "old position: %2d", old_wheel_value
);
2317 lcd_puts(0, 2, buf
);
2318 snprintf(buf
, sizeof(buf
), "wheel delta: %2d", wheel_delta
);
2319 lcd_puts(0, 3, buf
);
2320 snprintf(buf
, sizeof(buf
), "accumulated delta: %2d", accumulated_wheel_delta
);
2321 lcd_puts(0, 4, buf
);
2322 snprintf(buf
, sizeof(buf
), "velo [deg/s]: %4d", (int)wheel_velocity
);
2323 lcd_puts(0, 5, buf
);
2325 /* show effective accelerated scrollspeed */
2326 speed
= button_apply_acceleration( (1<<31)|(1<<24)|wheel_velocity
);
2327 snprintf(buf
, sizeof(buf
), "accel. speed: %4d", speed
);
2328 lcd_puts(0, 6, buf
);
2337 /****** The menu *********/
2338 struct the_menu_item
{
2339 unsigned char *desc
; /* string or ID */
2340 bool (*function
) (void); /* return true if USB was connected */
2342 static const struct the_menu_item menuitems
[] = {
2343 #if defined(TOSHIBA_GIGABEAT_F) && !defined(SIMULATOR)
2344 { "LCD Power Off", dbg_lcd_power_off
},
2346 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || \
2347 (defined(CPU_PP) && !(defined(SANSA_E200) || defined(SANSA_C200)))
2348 { "Dump ROM contents", dbg_save_roms
},
2350 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || defined(CPU_PP) || CONFIG_CPU == S3C2440
2351 { "View I/O ports", dbg_ports
},
2353 #if (CONFIG_RTC == RTC_PCF50605) && !defined(SIMULATOR)
2354 { "View PCF registers", dbg_pcf
},
2356 #if defined(HAVE_TSC2100) && !defined(SIMULATOR)
2357 { "TSC2100 debug", tsc2100_debug
},
2359 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
2360 { "CPU frequency", dbg_cpufreq
},
2362 #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR)
2363 { "S/PDIF analyzer", dbg_spdif
},
2365 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2366 { "Catch mem accesses", dbg_set_memory_guard
},
2368 { "View OS stacks", dbg_os
},
2369 #ifdef HAVE_LCD_BITMAP
2371 { "View battery", view_battery
},
2373 { "Screendump", dbg_screendump
},
2376 { "View HW info", dbg_hw_info
},
2379 { "View partitions", dbg_partitions
},
2382 { "View disk info", dbg_disk_info
},
2384 #ifdef HAVE_DIRCACHE
2385 { "View dircache info", dbg_dircache_info
},
2387 #ifdef HAVE_TAGCACHE
2388 { "View database info", dbg_tagcache_info
},
2390 #ifdef HAVE_LCD_BITMAP
2391 #if CONFIG_CODEC == SWCODEC
2392 { "View buffering thread", dbg_buffering_thread
},
2393 #elif !defined(SIMULATOR)
2394 { "View audio thread", dbg_audio_thread
},
2397 { "pm histogram", peak_meter_histogram
},
2398 #endif /* PM_DEBUG */
2399 #endif /* HAVE_LCD_BITMAP */
2402 { "FM Radio", dbg_fm_radio
},
2405 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2406 { "Write back EEPROM", dbg_write_eeprom
},
2408 #ifdef ROCKBOX_HAS_LOGF
2409 {"logf", logfdisplay
},
2410 {"logfdump", logfdump
},
2412 #ifdef CPU_BOOST_LOGGING
2413 {"cpu_boost log",cpu_boost_log
},
2415 #if (defined(HAVE_SCROLLWHEEL) && (CONFIG_KEYPAD==IPOD_4G_PAD) && !defined(SIMULATOR))
2416 {"Debug scrollwheel", dbg_scrollwheel
},
2419 static int menu_action_callback(int btn
, struct gui_synclist
*lists
)
2421 if (btn
== ACTION_STD_OK
)
2423 menuitems
[gui_synclist_get_sel_pos(lists
)].function();
2424 btn
= ACTION_REDRAW
;
2428 static char* dbg_menu_getname(int item
, void * data
, char *buffer
)
2430 (void)data
; (void)buffer
;
2431 return menuitems
[item
].desc
;
2433 bool debug_menu(void)
2435 struct simplelist_info info
;
2437 simplelist_info_init(&info
, "Debug Menu", ARRAYLEN(menuitems
), NULL
);
2438 info
.action_callback
= menu_action_callback
;
2439 info
.get_name
= dbg_menu_getname
;
2441 return simplelist_show_list(&info
);