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 ****************************************************************************/
27 #include "debug_menu.h"
34 #include "powermgmt.h"
38 #include "mp3_playback.h"
41 #include "statusbar.h"
51 #include "lcd-remote.h"
63 #include "eeprom_24cxx.h"
64 #if defined(HAVE_MMC) || defined(HAVE_ATA_SD)
73 #ifdef HAVE_LCD_BITMAP
74 #include "scrollbar.h"
75 #include "peakmeter.h"
78 #if CONFIG_CODEC == SWCODEC
80 #include "buffering.h"
82 #if defined(HAVE_SPDIF_OUT) || defined(HAVE_SPDIF_IN)
86 #ifdef IRIVER_H300_SERIES
87 #include "pcf50606.h" /* for pcf50606_read */
94 #if CONFIG_RTC == RTC_PCF50605
98 #if CONFIG_CPU == DM320 || CONFIG_CPU == S3C2440 || CONFIG_CPU == TCC7801 \
99 || CONFIG_CPU == IMX31L
100 #include "debug-target.h"
103 #if defined(SANSA_E200) || defined(PHILIPS_SA9200)
108 #if defined(HAVE_USBSTACK)
109 #include "usb_core.h"
112 #include "../firmware/usbstack/usb_storage.h"
115 /*---------------------------------------------------*/
116 /* SPECIAL DEBUG STUFF */
117 /*---------------------------------------------------*/
118 extern struct thread_entry threads
[MAXTHREADS
];
120 static char thread_status_char(unsigned status
)
122 static const char thread_status_chars
[THREAD_NUM_STATES
+1] =
124 [0 ... THREAD_NUM_STATES
] = '?',
125 [STATE_RUNNING
] = 'R',
126 [STATE_BLOCKED
] = 'B',
127 [STATE_SLEEPING
] = 'S',
128 [STATE_BLOCKED_W_TMO
] = 'T',
129 [STATE_FROZEN
] = 'F',
130 [STATE_KILLED
] = 'K',
133 if (status
> THREAD_NUM_STATES
)
134 status
= THREAD_NUM_STATES
;
136 return thread_status_chars
[status
];
139 static char* threads_getname(int selected_item
, void *data
,
140 char *buffer
, size_t buffer_len
)
143 struct thread_entry
*thread
;
147 if (selected_item
< (int)NUM_CORES
)
149 snprintf(buffer
, buffer_len
, "Idle (%d): %2d%%", selected_item
,
150 idle_stack_usage(selected_item
));
154 selected_item
-= NUM_CORES
;
157 thread
= &threads
[selected_item
];
159 if (thread
->state
== STATE_KILLED
)
161 snprintf(buffer
, buffer_len
, "%2d: ---", selected_item
);
165 thread_get_name(name
, 32, thread
);
167 snprintf(buffer
, buffer_len
,
168 "%2d: " IF_COP("(%d) ") "%c%c " IF_PRIO("%d %d ") "%2d%% %s",
170 IF_COP(thread
->core
,)
171 #ifdef HAVE_SCHEDULER_BOOSTCTRL
172 (thread
->cpu_boost
) ? '+' :
174 ((thread
->state
== STATE_RUNNING
) ? '*' : ' '),
175 thread_status_char(thread
->state
),
176 IF_PRIO(thread
->base_priority
, thread
->priority
, )
177 thread_stack_usage(thread
), name
);
181 static int dbg_threads_action_callback(int action
, struct gui_synclist
*lists
)
184 #ifdef ROCKBOX_HAS_LOGF
185 if (action
== ACTION_STD_OK
)
187 int selpos
= gui_synclist_get_sel_pos(lists
);
189 if (selpos
>= NUM_CORES
)
190 remove_thread(&threads
[selpos
- NUM_CORES
]);
192 remove_thread(&threads
[selpos
]);
194 return ACTION_REDRAW
;
196 #endif /* ROCKBOX_HAS_LOGF */
197 if (action
== ACTION_NONE
)
198 action
= ACTION_REDRAW
;
202 static bool dbg_os(void)
204 struct simplelist_info info
;
205 simplelist_info_init(&info
, IF_COP("Core and ") "Stack usage:",
209 MAXTHREADS
+NUM_CORES
,
212 #ifndef ROCKBOX_HAS_LOGF
213 info
.hide_selection
= true;
214 info
.scroll_all
= true;
216 info
.action_callback
= dbg_threads_action_callback
;
217 info
.get_name
= threads_getname
;
218 return simplelist_show_list(&info
);
221 #ifdef HAVE_LCD_BITMAP
222 #if CONFIG_CODEC != SWCODEC
224 static bool dbg_audio_thread(void)
227 struct audio_debug d
;
229 lcd_setmargins(0, 0);
230 lcd_setfont(FONT_SYSFIXED
);
234 if (action_userabort(HZ
/5))
237 audio_get_debugdata(&d
);
241 snprintf(buf
, sizeof(buf
), "read: %x", d
.audiobuf_read
);
243 snprintf(buf
, sizeof(buf
), "write: %x", d
.audiobuf_write
);
245 snprintf(buf
, sizeof(buf
), "swap: %x", d
.audiobuf_swapwrite
);
247 snprintf(buf
, sizeof(buf
), "playing: %d", d
.playing
);
249 snprintf(buf
, sizeof(buf
), "playable: %x", d
.playable_space
);
251 snprintf(buf
, sizeof(buf
), "unswapped: %x", d
.unswapped_space
);
254 /* Playable space left */
255 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8, 112, 4, d
.audiobuflen
, 0,
256 d
.playable_space
, HORIZONTAL
);
258 /* Show the watermark limit */
259 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8+4, 112, 4, d
.audiobuflen
, 0,
260 d
.low_watermark_level
, HORIZONTAL
);
262 snprintf(buf
, sizeof(buf
), "wm: %x - %x",
263 d
.low_watermark_level
, d
.lowest_watermark_level
);
270 #endif /* !SIMULATOR */
271 #else /* CONFIG_CODEC == SWCODEC */
272 extern size_t filebuflen
;
273 /* This is a size_t, but call it a long so it puts a - when it's bad. */
275 static unsigned int ticks
, boost_ticks
, freq_sum
;
277 static void dbg_audio_task(void)
280 if(FREQ
> CPUFREQ_NORMAL
)
282 freq_sum
+= FREQ
/1000000; /* in MHz */
287 static bool dbg_buffering_thread(void)
294 size_t bufsize
= pcmbuf_get_bufsize();
295 int pcmbufdescs
= pcmbuf_descs();
296 struct buffering_debug d
;
298 ticks
= boost_ticks
= freq_sum
= 0;
300 tick_add_task(dbg_audio_task
);
302 lcd_setmargins(0, 0);
303 lcd_setfont(FONT_SYSFIXED
);
306 button
= get_action(CONTEXT_STD
,HZ
/5);
309 case ACTION_STD_NEXT
:
312 case ACTION_STD_PREV
:
315 case ACTION_STD_CANCEL
:
320 buffering_get_debugdata(&d
);
325 bufused
= bufsize
- pcmbuf_free();
327 snprintf(buf
, sizeof(buf
), "pcm: %7ld/%7ld", (long) bufused
, (long) bufsize
);
328 lcd_puts(0, line
++, buf
);
330 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
331 bufsize
, 0, bufused
, HORIZONTAL
);
334 snprintf(buf
, sizeof(buf
), "alloc: %8ld/%8ld", audio_filebufused(),
336 lcd_puts(0, line
++, buf
);
339 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
340 filebuflen
, 0, audio_filebufused(), HORIZONTAL
);
343 snprintf(buf
, sizeof(buf
), "real: %8ld/%8ld", (long)d
.buffered_data
,
345 lcd_puts(0, line
++, buf
);
347 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
348 filebuflen
, 0, (long)d
.buffered_data
, HORIZONTAL
);
352 snprintf(buf
, sizeof(buf
), "usefl: %8ld/%8ld", (long)(d
.useful_data
),
354 lcd_puts(0, line
++, buf
);
357 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
358 filebuflen
, 0, d
.useful_data
, HORIZONTAL
);
362 snprintf(buf
, sizeof(buf
), "data_rem: %ld", (long)d
.data_rem
);
363 lcd_puts(0, line
++, buf
);
365 snprintf(buf
, sizeof(buf
), "track count: %2d", audio_track_count());
366 lcd_puts(0, line
++, buf
);
368 snprintf(buf
, sizeof(buf
), "handle count: %d", (int)d
.num_handles
);
369 lcd_puts(0, line
++, buf
);
372 snprintf(buf
, sizeof(buf
), "cpu freq: %3dMHz",
373 (int)((FREQ
+ 500000) / 1000000));
374 lcd_puts(0, line
++, buf
);
379 int boostquota
= boost_ticks
* 1000 / ticks
; /* in 0.1 % */
380 int avgclock
= freq_sum
* 10 / ticks
; /* in 100 kHz */
381 snprintf(buf
, sizeof(buf
), "boost ratio: %3d.%d%% (%2d.%dMHz)",
382 boostquota
/10, boostquota
%10, avgclock
/10, avgclock
%10);
383 lcd_puts(0, line
++, buf
);
386 snprintf(buf
, sizeof(buf
), "pcmbufdesc: %2d/%2d",
387 pcmbuf_used_descs(), pcmbufdescs
);
388 lcd_puts(0, line
++, buf
);
393 tick_remove_task(dbg_audio_task
);
397 #endif /* CONFIG_CODEC */
398 #endif /* HAVE_LCD_BITMAP */
401 #if (CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE))
402 /* Tool function to read the flash manufacturer and type, if available.
403 Only chips which could be reprogrammed in system will return values.
404 (The mode switch addresses vary between flash manufacturers, hence addr1/2) */
405 /* In IRAM to avoid problems when running directly from Flash */
406 static bool dbg_flash_id(unsigned* p_manufacturer
, unsigned* p_device
,
407 unsigned addr1
, unsigned addr2
)
408 ICODE_ATTR
__attribute__((noinline
));
409 static bool dbg_flash_id(unsigned* p_manufacturer
, unsigned* p_device
,
410 unsigned addr1
, unsigned addr2
)
413 unsigned not_manu
, not_id
; /* read values before switching to ID mode */
414 unsigned manu
, id
; /* read values when in ID mode */
416 #if CONFIG_CPU == SH7034
417 volatile unsigned char* flash
= (unsigned char*)0x2000000; /* flash mapping */
418 #elif defined(CPU_COLDFIRE)
419 volatile unsigned short* flash
= (unsigned short*)0; /* flash mapping */
421 int old_level
; /* saved interrupt level */
423 not_manu
= flash
[0]; /* read the normal content */
424 not_id
= flash
[1]; /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */
426 /* disable interrupts, prevent any stray flash access */
427 old_level
= disable_irq_save();
429 flash
[addr1
] = 0xAA; /* enter command mode */
431 flash
[addr1
] = 0x90; /* ID command */
432 /* Atmel wants 20ms pause here */
433 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
435 manu
= flash
[0]; /* read the IDs */
438 flash
[0] = 0xF0; /* reset flash (back to normal read mode) */
439 /* Atmel wants 20ms pause here */
440 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
442 restore_irq(old_level
); /* enable interrupts again */
444 /* I assume success if the obtained values are different from
445 the normal flash content. This is not perfectly bulletproof, they
446 could theoretically be the same by chance, causing us to fail. */
447 if (not_manu
!= manu
|| not_id
!= id
) /* a value has changed */
449 *p_manufacturer
= manu
; /* return the results */
451 return true; /* success */
453 return false; /* fail */
455 #endif /* (CONFIG_CPU == SH7034 || CPU_COLDFIRE) */
459 static int perfcheck(void)
465 "orr r0, r2, #0xc0 \n" /* disable IRQ and FIQ */
468 "ldr r0, [%[timr]] \n"
469 "add r0, r0, %[tmo] \n"
471 "add %[res], %[res], #1 \n"
472 "ldr r1, [%[timr]] \n"
475 "msr CPSR_c, r2 \n" /* reset IRQ and FIQ state */
479 [timr
]"r"(&USEC_TIMER
),
481 #if CONFIG_CPU == PP5002
483 #else /* PP5020/5022/5024 */
494 #ifdef HAVE_LCD_BITMAP
495 static bool dbg_hw_info(void)
497 #if CONFIG_CPU == SH7034
499 int bitmask
= HW_MASK
;
500 int rom_version
= ROM_VERSION
;
501 unsigned manu
, id
; /* flash IDs */
502 bool got_id
; /* flag if we managed to get the flash IDs */
503 unsigned rom_crc
= 0xffffffff; /* CRC32 of the boot ROM */
504 bool has_bootrom
; /* flag for boot ROM present */
505 int oldmode
; /* saved memory guard mode */
507 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
509 /* get flash ROM type */
510 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
512 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
514 /* check if the boot ROM area is a flash mirror */
515 has_bootrom
= (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
516 if (has_bootrom
) /* if ROM and Flash different */
518 /* calculate CRC16 checksum of boot ROM */
519 rom_crc
= crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
522 system_memory_guard(oldmode
); /* re-enable memory guard */
524 lcd_setmargins(0, 0);
525 lcd_setfont(FONT_SYSFIXED
);
528 lcd_puts(0, 0, "[Hardware info]");
530 snprintf(buf
, 32, "ROM: %d.%02d", rom_version
/100, rom_version
%100);
533 snprintf(buf
, 32, "Mask: 0x%04x", bitmask
);
537 snprintf(buf
, 32, "Flash: M=%02x D=%02x", manu
, id
);
539 snprintf(buf
, 32, "Flash: M=?? D=??"); /* unknown, sorry */
544 if (rom_crc
== 0x56DBA4EE) /* known Version 1 */
545 snprintf(buf
, 32, "Boot ROM: V1");
547 snprintf(buf
, 32, "ROMcrc: 0x%08x", rom_crc
);
551 snprintf(buf
, 32, "Boot ROM: none");
557 while (!(action_userabort(TIMEOUT_BLOCK
)));
559 #elif CONFIG_CPU == MCF5249 || CONFIG_CPU == MCF5250
561 unsigned manu
, id
; /* flash IDs */
562 int got_id
; /* flag if we managed to get the flash IDs */
563 int oldmode
; /* saved memory guard mode */
566 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
568 /* get flash ROM type */
569 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
571 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
573 system_memory_guard(oldmode
); /* re-enable memory guard */
575 lcd_setmargins(0, 0);
576 lcd_setfont(FONT_SYSFIXED
);
579 lcd_puts(0, line
++, "[Hardware info]");
582 snprintf(buf
, 32, "Flash: M=%04x D=%04x", manu
, id
);
584 snprintf(buf
, 32, "Flash: M=???? D=????"); /* unknown, sorry */
585 lcd_puts(0, line
++, buf
);
591 lcd_puts(0, ++line
, "Serial Number:");
593 got_id
= ds2411_read_id(&id
);
595 if (got_id
== DS2411_OK
)
597 snprintf(buf
, 32, " FC=%02x", (unsigned)id
.family_code
);
598 lcd_puts(0, ++line
, buf
);
599 snprintf(buf
, 32, " ID=%02X %02X %02X %02X %02X %02X",
600 (unsigned)id
.uid
[0], (unsigned)id
.uid
[1], (unsigned)id
.uid
[2],
601 (unsigned)id
.uid
[3], (unsigned)id
.uid
[4], (unsigned)id
.uid
[5]);
602 lcd_puts(0, ++line
, buf
);
603 snprintf(buf
, 32, " CRC=%02X", (unsigned)id
.crc
);
607 snprintf(buf
, 32, "READ ERR=%d", got_id
);
610 lcd_puts(0, ++line
, buf
);
616 while (!(action_userabort(TIMEOUT_BLOCK
)));
618 #elif defined(CPU_PP502x)
621 char pp_version
[] = { (PP_VER2
>> 24) & 0xff, (PP_VER2
>> 16) & 0xff,
622 (PP_VER2
>> 8) & 0xff, (PP_VER2
) & 0xff,
623 (PP_VER1
>> 24) & 0xff, (PP_VER1
>> 16) & 0xff,
624 (PP_VER1
>> 8) & 0xff, (PP_VER1
) & 0xff, '\0' };
626 lcd_setmargins(0, 0);
627 lcd_setfont(FONT_SYSFIXED
);
630 lcd_puts(0, line
++, "[Hardware info]");
633 snprintf(buf
, sizeof(buf
), "HW rev: 0x%08lx", IPOD_HW_REVISION
);
634 lcd_puts(0, line
++, buf
);
638 extern int lcd_type
; /* Defined in lcd-colornano.c */
640 snprintf(buf
, sizeof(buf
), "LCD type: %d", lcd_type
);
641 lcd_puts(0, line
++, buf
);
644 snprintf(buf
, sizeof(buf
), "PP version: %s", pp_version
);
645 lcd_puts(0, line
++, buf
);
647 snprintf(buf
, sizeof(buf
), "Est. clock (kHz): %d", perfcheck());
648 lcd_puts(0, line
++, buf
);
652 while (!(action_userabort(TIMEOUT_BLOCK
)));
654 #elif CONFIG_CPU == PP5002
657 char pp_version
[] = { (PP_VER4
>> 8) & 0xff, PP_VER4
& 0xff,
658 (PP_VER3
>> 8) & 0xff, PP_VER3
& 0xff,
659 (PP_VER2
>> 8) & 0xff, PP_VER2
& 0xff,
660 (PP_VER1
>> 8) & 0xff, PP_VER1
& 0xff, '\0' };
663 lcd_setmargins(0, 0);
664 lcd_setfont(FONT_SYSFIXED
);
667 lcd_puts(0, line
++, "[Hardware info]");
670 snprintf(buf
, sizeof(buf
), "HW rev: 0x%08lx", IPOD_HW_REVISION
);
671 lcd_puts(0, line
++, buf
);
674 snprintf(buf
, sizeof(buf
), "PP version: %s", pp_version
);
675 lcd_puts(0, line
++, buf
);
677 snprintf(buf
, sizeof(buf
), "Est. clock (kHz): %d", perfcheck());
678 lcd_puts(0, line
++, buf
);
682 while (!(action_userabort(TIMEOUT_BLOCK
)));
684 /* Define this function in your target tree */
685 return __dbg_hw_info();
686 #endif /* CONFIG_CPU */
689 #else /* !HAVE_LCD_BITMAP */
690 static bool dbg_hw_info(void)
695 int rom_version
= ROM_VERSION
;
696 unsigned manu
, id
; /* flash IDs */
697 bool got_id
; /* flag if we managed to get the flash IDs */
698 unsigned rom_crc
= 0xffffffff; /* CRC32 of the boot ROM */
699 bool has_bootrom
; /* flag for boot ROM present */
700 int oldmode
; /* saved memory guard mode */
702 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
704 /* get flash ROM type */
705 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
707 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
709 /* check if the boot ROM area is a flash mirror */
710 has_bootrom
= (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
711 if (has_bootrom
) /* if ROM and Flash different */
713 /* calculate CRC16 checksum of boot ROM */
714 rom_crc
= crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
717 system_memory_guard(oldmode
); /* re-enable memory guard */
721 lcd_puts(0, 0, "[HW Info]");
727 snprintf(buf
, 32, "ROM: %d.%02d",
728 rom_version
/100, rom_version
%100);
732 snprintf(buf
, 32, "Flash:%02x,%02x", manu
, id
);
734 snprintf(buf
, 32, "Flash:??,??"); /* unknown, sorry */
739 if (rom_crc
== 0x56DBA4EE) /* known Version 1 */
740 snprintf(buf
, 32, "BootROM: V1");
741 else if (rom_crc
== 0x358099E8)
742 snprintf(buf
, 32, "BootROM: V2");
743 /* alternative boot ROM found in one single player so far */
745 snprintf(buf
, 32, "R: %08x", rom_crc
);
748 snprintf(buf
, 32, "BootROM: no");
754 button
= get_action(CONTEXT_SETTINGS
,TIMEOUT_BLOCK
);
758 case ACTION_STD_CANCEL
:
761 case ACTION_SETTINGS_DEC
:
767 case ACTION_SETTINGS_INC
:
776 #endif /* !HAVE_LCD_BITMAP */
777 #endif /* !SIMULATOR */
780 static char* dbg_partitions_getname(int selected_item
, void *data
,
781 char *buffer
, size_t buffer_len
)
784 int partition
= selected_item
/2;
785 struct partinfo
* p
= disk_partinfo(partition
);
788 snprintf(buffer
, buffer_len
, " T:%x %ld MB", p
->type
, p
->size
/ 2048);
792 snprintf(buffer
, buffer_len
, "P%d: S:%lx", partition
, p
->start
);
797 bool dbg_partitions(void)
799 struct simplelist_info info
;
800 simplelist_info_init(&info
, "Partition Info", 4, NULL
);
801 info
.selection_size
= 2;
802 info
.hide_selection
= true;
803 info
.scroll_all
= true;
804 info
.get_name
= dbg_partitions_getname
;
805 return simplelist_show_list(&info
);
809 #if defined(CPU_COLDFIRE) && defined(HAVE_SPDIF_OUT)
810 static bool dbg_spdif(void)
814 unsigned int control
;
819 unsigned int interruptstat
;
820 bool valnogood
, symbolerr
, parityerr
;
823 int spdif_source
= spdif_get_output_source(&spdif_src_on
);
824 spdif_set_output_source(AUDIO_SRC_SPDIF
IF_SPDIF_POWER_(, true));
826 lcd_setmargins(0, 0);
828 lcd_setfont(FONT_SYSFIXED
);
830 #ifdef HAVE_SPDIF_POWER
831 spdif_power_enable(true); /* We need SPDIF power for both sending & receiving */
838 control
= EBU1RCVCCHANNEL1
;
839 interruptstat
= INTERRUPTSTAT
;
840 INTERRUPTCLEAR
= 0x03c00000;
842 valnogood
= (interruptstat
& 0x01000000)?true:false;
843 symbolerr
= (interruptstat
& 0x00800000)?true:false;
844 parityerr
= (interruptstat
& 0x00400000)?true:false;
846 snprintf(buf
, sizeof(buf
), "Val: %s Sym: %s Par: %s",
849 parityerr
?"--":"OK");
850 lcd_puts(0, line
++, buf
);
852 snprintf(buf
, sizeof(buf
), "Status word: %08x", (int)control
);
853 lcd_puts(0, line
++, buf
);
858 snprintf(buf
, sizeof(buf
), "PRO: %d (%s)",
859 x
, x
?"Professional":"Consumer");
860 lcd_puts(0, line
++, buf
);
862 x
= (control
>> 30) & 1;
863 snprintf(buf
, sizeof(buf
), "Audio: %d (%s)",
864 x
, x
?"Non-PCM":"PCM");
865 lcd_puts(0, line
++, buf
);
867 x
= (control
>> 29) & 1;
868 snprintf(buf
, sizeof(buf
), "Copy: %d (%s)",
869 x
, x
?"Permitted":"Inhibited");
870 lcd_puts(0, line
++, buf
);
872 x
= (control
>> 27) & 7;
885 snprintf(buf
, sizeof(buf
), "Preemphasis: %d (%s)", x
, s
);
886 lcd_puts(0, line
++, buf
);
888 x
= (control
>> 24) & 3;
889 snprintf(buf
, sizeof(buf
), "Mode: %d", x
);
890 lcd_puts(0, line
++, buf
);
892 category
= (control
>> 17) & 127;
904 snprintf(buf
, sizeof(buf
), "Category: 0x%02x (%s)", category
, s
);
905 lcd_puts(0, line
++, buf
);
907 x
= (control
>> 16) & 1;
909 if(((category
& 0x70) == 0x10) ||
910 ((category
& 0x70) == 0x40) ||
911 ((category
& 0x78) == 0x38))
913 generation
= !generation
;
915 snprintf(buf
, sizeof(buf
), "Generation: %d (%s)",
916 x
, generation
?"Original":"No ind.");
917 lcd_puts(0, line
++, buf
);
919 x
= (control
>> 12) & 15;
920 snprintf(buf
, sizeof(buf
), "Source: %d", x
);
921 lcd_puts(0, line
++, buf
);
923 x
= (control
>> 8) & 15;
939 snprintf(buf
, sizeof(buf
), "Channel: %d (%s)", x
, s
);
940 lcd_puts(0, line
++, buf
);
942 x
= (control
>> 4) & 15;
955 snprintf(buf
, sizeof(buf
), "Frequency: %d (%s)", x
, s
);
956 lcd_puts(0, line
++, buf
);
958 x
= (control
>> 2) & 3;
959 snprintf(buf
, sizeof(buf
), "Clock accuracy: %d", x
);
960 lcd_puts(0, line
++, buf
);
964 snprintf(buf
, sizeof(buf
), "Measured freq: %ldHz",
965 spdif_measure_frequency());
966 lcd_puts(0, line
++, buf
);
971 if (action_userabort(HZ
/10))
975 spdif_set_output_source(spdif_source
IF_SPDIF_POWER_(, spdif_src_on
));
977 #ifdef HAVE_SPDIF_POWER
978 spdif_power_enable(global_settings
.spdif_enable
);
983 #endif /* CPU_COLDFIRE */
986 #ifdef HAVE_LCD_BITMAP
987 /* button definitions */
988 #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
989 (CONFIG_KEYPAD == IRIVER_H300_PAD)
990 # define DEBUG_CANCEL BUTTON_OFF
992 #elif CONFIG_KEYPAD == RECORDER_PAD
993 # define DEBUG_CANCEL BUTTON_OFF
995 #elif CONFIG_KEYPAD == ONDIO_PAD
996 # define DEBUG_CANCEL BUTTON_MENU
998 #elif (CONFIG_KEYPAD == IPOD_1G2G_PAD) || \
999 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
1000 (CONFIG_KEYPAD == IPOD_4G_PAD)
1001 # define DEBUG_CANCEL BUTTON_MENU
1003 #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
1004 # define DEBUG_CANCEL BUTTON_PLAY
1006 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
1007 # define DEBUG_CANCEL BUTTON_REC
1009 #elif (CONFIG_KEYPAD == IAUDIO_M3_PAD)
1010 # define DEBUG_CANCEL BUTTON_RC_REC
1012 #elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
1013 # define DEBUG_CANCEL BUTTON_REW
1015 #elif (CONFIG_KEYPAD == MROBE100_PAD)
1016 # define DEBUG_CANCEL BUTTON_MENU
1018 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
1019 (CONFIG_KEYPAD == SANSA_C200_PAD)
1020 # define DEBUG_CANCEL BUTTON_LEFT
1022 /* This is temporary until the SA9200 touchpad works */
1023 #elif (CONFIG_KEYPAD == PHILIPS_SA9200_PAD)
1024 # define DEBUG_CANCEL BUTTON_POWER
1026 #endif /* key definitions */
1029 bool dbg_ports(void)
1031 #if CONFIG_CPU == SH7034
1033 int adc_battery_voltage
, adc_battery_level
;
1035 lcd_setfont(FONT_SYSFIXED
);
1036 lcd_setmargins(0, 0);
1037 lcd_clear_display();
1041 snprintf(buf
, 32, "PADR: %04x", (unsigned short)PADR
);
1042 lcd_puts(0, 0, buf
);
1043 snprintf(buf
, 32, "PBDR: %04x", (unsigned short)PBDR
);
1044 lcd_puts(0, 1, buf
);
1046 snprintf(buf
, 32, "AN0: %03x AN4: %03x", adc_read(0), adc_read(4));
1047 lcd_puts(0, 2, buf
);
1048 snprintf(buf
, 32, "AN1: %03x AN5: %03x", adc_read(1), adc_read(5));
1049 lcd_puts(0, 3, buf
);
1050 snprintf(buf
, 32, "AN2: %03x AN6: %03x", adc_read(2), adc_read(6));
1051 lcd_puts(0, 4, buf
);
1052 snprintf(buf
, 32, "AN3: %03x AN7: %03x", adc_read(3), adc_read(7));
1053 lcd_puts(0, 5, buf
);
1055 battery_read_info(&adc_battery_voltage
, &adc_battery_level
);
1056 snprintf(buf
, 32, "Batt: %d.%03dV %d%% ", adc_battery_voltage
/ 1000,
1057 adc_battery_voltage
% 1000, adc_battery_level
);
1058 lcd_puts(0, 6, buf
);
1061 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1064 #elif defined(CPU_COLDFIRE)
1065 unsigned int gpio_out
;
1066 unsigned int gpio1_out
;
1067 unsigned int gpio_read
;
1068 unsigned int gpio1_read
;
1069 unsigned int gpio_function
;
1070 unsigned int gpio1_function
;
1071 unsigned int gpio_enable
;
1072 unsigned int gpio1_enable
;
1073 int adc_buttons
, adc_remote
;
1074 int adc_battery_voltage
, adc_battery_level
;
1078 lcd_setmargins(0, 0);
1079 lcd_clear_display();
1080 lcd_setfont(FONT_SYSFIXED
);
1085 gpio_read
= GPIO_READ
;
1086 gpio1_read
= GPIO1_READ
;
1087 gpio_out
= GPIO_OUT
;
1088 gpio1_out
= GPIO1_OUT
;
1089 gpio_function
= GPIO_FUNCTION
;
1090 gpio1_function
= GPIO1_FUNCTION
;
1091 gpio_enable
= GPIO_ENABLE
;
1092 gpio1_enable
= GPIO1_ENABLE
;
1094 snprintf(buf
, sizeof(buf
), "GPIO_READ: %08x", gpio_read
);
1095 lcd_puts(0, line
++, buf
);
1096 snprintf(buf
, sizeof(buf
), "GPIO_OUT: %08x", gpio_out
);
1097 lcd_puts(0, line
++, buf
);
1098 snprintf(buf
, sizeof(buf
), "GPIO_FUNC: %08x", gpio_function
);
1099 lcd_puts(0, line
++, buf
);
1100 snprintf(buf
, sizeof(buf
), "GPIO_ENA: %08x", gpio_enable
);
1101 lcd_puts(0, line
++, buf
);
1103 snprintf(buf
, sizeof(buf
), "GPIO1_READ: %08x", gpio1_read
);
1104 lcd_puts(0, line
++, buf
);
1105 snprintf(buf
, sizeof(buf
), "GPIO1_OUT: %08x", gpio1_out
);
1106 lcd_puts(0, line
++, buf
);
1107 snprintf(buf
, sizeof(buf
), "GPIO1_FUNC: %08x", gpio1_function
);
1108 lcd_puts(0, line
++, buf
);
1109 snprintf(buf
, sizeof(buf
), "GPIO1_ENA: %08x", gpio1_enable
);
1110 lcd_puts(0, line
++, buf
);
1112 adc_buttons
= adc_read(ADC_BUTTONS
);
1113 adc_remote
= adc_read(ADC_REMOTE
);
1114 battery_read_info(&adc_battery_voltage
, &adc_battery_level
);
1115 #if defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IRIVER_H300_SERIES)
1116 snprintf(buf
, sizeof(buf
), "ADC_BUTTONS (%c): %02x",
1117 button_scan_enabled() ? '+' : '-', adc_buttons
);
1119 snprintf(buf
, sizeof(buf
), "ADC_BUTTONS: %02x", adc_buttons
);
1121 lcd_puts(0, line
++, buf
);
1122 #if defined(IAUDIO_X5) || defined(IAUDIO_M5)
1123 snprintf(buf
, sizeof(buf
), "ADC_REMOTE (%c): %02x",
1124 remote_detect() ? '+' : '-', adc_remote
);
1126 snprintf(buf
, sizeof(buf
), "ADC_REMOTE: %02x", adc_remote
);
1128 lcd_puts(0, line
++, buf
);
1129 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1130 snprintf(buf
, sizeof(buf
), "ADC_REMOTEDETECT: %02x",
1131 adc_read(ADC_REMOTEDETECT
));
1132 lcd_puts(0, line
++, buf
);
1135 snprintf(buf
, 32, "Batt: %d.%03dV %d%% ", adc_battery_voltage
/ 1000,
1136 adc_battery_voltage
% 1000, adc_battery_level
);
1137 lcd_puts(0, line
++, buf
);
1139 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1140 snprintf(buf
, sizeof(buf
), "remotetype: %d", remote_type());
1141 lcd_puts(0, line
++, buf
);
1145 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1149 #elif defined(CPU_PP502x)
1154 lcd_setmargins(0, 0);
1155 lcd_clear_display();
1156 lcd_setfont(FONT_SYSFIXED
);
1161 lcd_puts(0, line
++, "GPIO STATES:");
1162 snprintf(buf
, sizeof(buf
), "A: %02x E: %02x I: %02x",
1163 (unsigned int)GPIOA_INPUT_VAL
,
1164 (unsigned int)GPIOE_INPUT_VAL
,
1165 (unsigned int)GPIOI_INPUT_VAL
);
1166 lcd_puts(0, line
++, buf
);
1167 snprintf(buf
, sizeof(buf
), "B: %02x F: %02x J: %02x",
1168 (unsigned int)GPIOB_INPUT_VAL
,
1169 (unsigned int)GPIOF_INPUT_VAL
,
1170 (unsigned int)GPIOJ_INPUT_VAL
);
1171 lcd_puts(0, line
++, buf
);
1172 snprintf(buf
, sizeof(buf
), "C: %02x G: %02x K: %02x",
1173 (unsigned int)GPIOC_INPUT_VAL
,
1174 (unsigned int)GPIOG_INPUT_VAL
,
1175 (unsigned int)GPIOK_INPUT_VAL
);
1176 lcd_puts(0, line
++, buf
);
1177 snprintf(buf
, sizeof(buf
), "D: %02x H: %02x L: %02x",
1178 (unsigned int)GPIOD_INPUT_VAL
,
1179 (unsigned int)GPIOH_INPUT_VAL
,
1180 (unsigned int)GPIOL_INPUT_VAL
);
1181 lcd_puts(0, line
++, buf
);
1183 snprintf(buf
, sizeof(buf
), "GPO32_VAL: %08lx", GPO32_VAL
);
1184 lcd_puts(0, line
++, buf
);
1185 snprintf(buf
, sizeof(buf
), "GPO32_EN: %08lx", GPO32_ENABLE
);
1186 lcd_puts(0, line
++, buf
);
1187 snprintf(buf
, sizeof(buf
), "DEV_EN: %08lx", DEV_EN
);
1188 lcd_puts(0, line
++, buf
);
1189 snprintf(buf
, sizeof(buf
), "DEV_EN2: %08lx", DEV_EN2
);
1190 lcd_puts(0, line
++, buf
);
1191 snprintf(buf
, sizeof(buf
), "DEV_EN3: %08lx", inl(0x60006044));
1192 lcd_puts(0, line
++, buf
); /* to be verified */
1193 snprintf(buf
, sizeof(buf
), "DEV_INIT1: %08lx", DEV_INIT1
);
1194 lcd_puts(0, line
++, buf
);
1195 snprintf(buf
, sizeof(buf
), "DEV_INIT2: %08lx", DEV_INIT2
);
1196 lcd_puts(0, line
++, buf
);
1197 #ifdef ADC_ACCESSORY
1198 snprintf(buf
, sizeof(buf
), "ACCESSORY: %d", adc_read(ADC_ACCESSORY
));
1199 lcd_puts(0, line
++, buf
);
1202 #if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
1204 snprintf(buf
, sizeof(buf
), "BATT: %03x UNK1: %03x",
1205 adc_read(ADC_BATTERY
), adc_read(ADC_UNKNOWN_1
));
1206 lcd_puts(0, line
++, buf
);
1207 snprintf(buf
, sizeof(buf
), "REM: %03x PAD: %03x",
1208 adc_read(ADC_REMOTE
), adc_read(ADC_SCROLLPAD
));
1209 lcd_puts(0, line
++, buf
);
1210 #elif defined(SANSA_E200) || defined(PHILIPS_SA9200)
1211 snprintf(buf
, sizeof(buf
), "ADC_BVDD: %4d", adc_read(ADC_BVDD
));
1212 lcd_puts(0, line
++, buf
);
1213 snprintf(buf
, sizeof(buf
), "ADC_RTCSUP: %4d", adc_read(ADC_RTCSUP
));
1214 lcd_puts(0, line
++, buf
);
1215 snprintf(buf
, sizeof(buf
), "ADC_UVDD: %4d", adc_read(ADC_UVDD
));
1216 lcd_puts(0, line
++, buf
);
1217 snprintf(buf
, sizeof(buf
), "ADC_CHG_IN: %4d", adc_read(ADC_CHG_IN
));
1218 lcd_puts(0, line
++, buf
);
1219 snprintf(buf
, sizeof(buf
), "ADC_CVDD: %4d", adc_read(ADC_CVDD
));
1220 lcd_puts(0, line
++, buf
);
1221 snprintf(buf
, sizeof(buf
), "ADC_BATTEMP: %4d", adc_read(ADC_BATTEMP
));
1222 lcd_puts(0, line
++, buf
);
1223 snprintf(buf
, sizeof(buf
), "ADC_MICSUP1: %4d", adc_read(ADC_MICSUP1
));
1224 lcd_puts(0, line
++, buf
);
1225 snprintf(buf
, sizeof(buf
), "ADC_MICSUP2: %4d", adc_read(ADC_MICSUP2
));
1226 lcd_puts(0, line
++, buf
);
1227 snprintf(buf
, sizeof(buf
), "ADC_VBE1: %4d", adc_read(ADC_VBE1
));
1228 lcd_puts(0, line
++, buf
);
1229 snprintf(buf
, sizeof(buf
), "ADC_VBE2: %4d", adc_read(ADC_VBE2
));
1230 lcd_puts(0, line
++, buf
);
1231 snprintf(buf
, sizeof(buf
), "ADC_I_MICSUP1:%4d", adc_read(ADC_I_MICSUP1
));
1232 lcd_puts(0, line
++, buf
);
1233 #if !defined(PHILIPS_SA9200)
1234 snprintf(buf
, sizeof(buf
), "ADC_I_MICSUP2:%4d", adc_read(ADC_I_MICSUP2
));
1235 lcd_puts(0, line
++, buf
);
1236 snprintf(buf
, sizeof(buf
), "ADC_VBAT: %4d", adc_read(ADC_VBAT
));
1237 lcd_puts(0, line
++, buf
);
1238 snprintf(buf
, sizeof(buf
), "CHARGER: %02X/%02X", i2c_readbyte(AS3514_I2C_ADDR
, AS3514_CHARGER
), i2c_readbyte(AS3514_I2C_ADDR
, AS3514_IRQ_ENRD0
));
1239 lcd_puts(0, line
++, buf
);
1243 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1247 #elif CONFIG_CPU == PP5002
1251 lcd_setmargins(0, 0);
1252 lcd_clear_display();
1253 lcd_setfont(FONT_SYSFIXED
);
1258 snprintf(buf
, sizeof(buf
), "GPIO_A: %02x GPIO_B: %02x",
1259 (unsigned int)GPIOA_INPUT_VAL
, (unsigned int)GPIOB_INPUT_VAL
);
1260 lcd_puts(0, line
++, buf
);
1261 snprintf(buf
, sizeof(buf
), "GPIO_C: %02x GPIO_D: %02x",
1262 (unsigned int)GPIOC_INPUT_VAL
, (unsigned int)GPIOD_INPUT_VAL
);
1263 lcd_puts(0, line
++, buf
);
1265 snprintf(buf
, sizeof(buf
), "DEV_EN: %08lx", DEV_EN
);
1266 lcd_puts(0, line
++, buf
);
1267 snprintf(buf
, sizeof(buf
), "CLOCK_ENABLE: %08lx", CLOCK_ENABLE
);
1268 lcd_puts(0, line
++, buf
);
1269 snprintf(buf
, sizeof(buf
), "CLOCK_SOURCE: %08lx", CLOCK_SOURCE
);
1270 lcd_puts(0, line
++, buf
);
1271 snprintf(buf
, sizeof(buf
), "PLL_CONTROL: %08lx", PLL_CONTROL
);
1272 lcd_puts(0, line
++, buf
);
1273 snprintf(buf
, sizeof(buf
), "PLL_DIV: %08lx", PLL_DIV
);
1274 lcd_puts(0, line
++, buf
);
1275 snprintf(buf
, sizeof(buf
), "PLL_MULT: %08lx", PLL_MULT
);
1276 lcd_puts(0, line
++, buf
);
1277 snprintf(buf
, sizeof(buf
), "TIMING1_CTL: %08lx", TIMING1_CTL
);
1278 lcd_puts(0, line
++, buf
);
1279 snprintf(buf
, sizeof(buf
), "TIMING2_CTL: %08lx", TIMING2_CTL
);
1280 lcd_puts(0, line
++, buf
);
1283 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1287 return __dbg_ports();
1291 #else /* !HAVE_LCD_BITMAP */
1292 bool dbg_ports(void)
1296 int adc_battery_voltage
;
1299 lcd_clear_display();
1306 snprintf(buf
, 32, "PADR: %04x", (unsigned short)PADR
);
1309 snprintf(buf
, 32, "PBDR: %04x", (unsigned short)PBDR
);
1312 snprintf(buf
, 32, "AN0: %03x", adc_read(0));
1315 snprintf(buf
, 32, "AN1: %03x", adc_read(1));
1318 snprintf(buf
, 32, "AN2: %03x", adc_read(2));
1321 snprintf(buf
, 32, "AN3: %03x", adc_read(3));
1324 snprintf(buf
, 32, "AN4: %03x", adc_read(4));
1327 snprintf(buf
, 32, "AN5: %03x", adc_read(5));
1330 snprintf(buf
, 32, "AN6: %03x", adc_read(6));
1333 snprintf(buf
, 32, "AN7: %03x", adc_read(7));
1337 lcd_puts(0, 0, buf
);
1339 battery_read_info(&adc_battery_voltage
, NULL
);
1340 snprintf(buf
, 32, "Batt: %d.%03dV", adc_battery_voltage
/ 1000,
1341 adc_battery_voltage
% 1000);
1342 lcd_puts(0, 1, buf
);
1345 button
= get_action(CONTEXT_SETTINGS
,HZ
/5);
1349 case ACTION_STD_CANCEL
:
1352 case ACTION_SETTINGS_DEC
:
1358 case ACTION_SETTINGS_INC
:
1367 #endif /* !HAVE_LCD_BITMAP */
1368 #endif /* !SIMULATOR */
1370 #if (CONFIG_RTC == RTC_PCF50605) && !defined(SIMULATOR)
1371 static bool dbg_pcf(void)
1376 #ifdef HAVE_LCD_BITMAP
1377 lcd_setmargins(0, 0);
1378 lcd_setfont(FONT_SYSFIXED
);
1380 lcd_clear_display();
1386 snprintf(buf
, sizeof(buf
), "DCDC1: %02x", pcf50605_read(0x1b));
1387 lcd_puts(0, line
++, buf
);
1388 snprintf(buf
, sizeof(buf
), "DCDC2: %02x", pcf50605_read(0x1c));
1389 lcd_puts(0, line
++, buf
);
1390 snprintf(buf
, sizeof(buf
), "DCDC3: %02x", pcf50605_read(0x1d));
1391 lcd_puts(0, line
++, buf
);
1392 snprintf(buf
, sizeof(buf
), "DCDC4: %02x", pcf50605_read(0x1e));
1393 lcd_puts(0, line
++, buf
);
1394 snprintf(buf
, sizeof(buf
), "DCDEC1: %02x", pcf50605_read(0x1f));
1395 lcd_puts(0, line
++, buf
);
1396 snprintf(buf
, sizeof(buf
), "DCDEC2: %02x", pcf50605_read(0x20));
1397 lcd_puts(0, line
++, buf
);
1398 snprintf(buf
, sizeof(buf
), "DCUDC1: %02x", pcf50605_read(0x21));
1399 lcd_puts(0, line
++, buf
);
1400 snprintf(buf
, sizeof(buf
), "DCUDC2: %02x", pcf50605_read(0x22));
1401 lcd_puts(0, line
++, buf
);
1402 snprintf(buf
, sizeof(buf
), "IOREGC: %02x", pcf50605_read(0x23));
1403 lcd_puts(0, line
++, buf
);
1404 snprintf(buf
, sizeof(buf
), "D1REGC: %02x", pcf50605_read(0x24));
1405 lcd_puts(0, line
++, buf
);
1406 snprintf(buf
, sizeof(buf
), "D2REGC: %02x", pcf50605_read(0x25));
1407 lcd_puts(0, line
++, buf
);
1408 snprintf(buf
, sizeof(buf
), "D3REGC: %02x", pcf50605_read(0x26));
1409 lcd_puts(0, line
++, buf
);
1410 snprintf(buf
, sizeof(buf
), "LPREG1: %02x", pcf50605_read(0x27));
1411 lcd_puts(0, line
++, buf
);
1414 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1424 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
1425 static bool dbg_cpufreq(void)
1431 #ifdef HAVE_LCD_BITMAP
1432 lcd_setmargins(0, 0);
1433 lcd_setfont(FONT_SYSFIXED
);
1435 lcd_clear_display();
1441 snprintf(buf
, sizeof(buf
), "Frequency: %ld", FREQ
);
1442 lcd_puts(0, line
++, buf
);
1444 snprintf(buf
, sizeof(buf
), "boost_counter: %d", get_cpu_boost_counter());
1445 lcd_puts(0, line
++, buf
);
1448 button
= get_action(CONTEXT_STD
,HZ
/10);
1452 case ACTION_STD_PREV
:
1456 case ACTION_STD_NEXT
:
1461 while (get_cpu_boost_counter() > 0)
1463 set_cpu_frequency(CPUFREQ_DEFAULT
);
1466 case ACTION_STD_CANCEL
:
1473 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
1475 #if defined(HAVE_TSC2100) && !defined(SIMULATOR)
1476 #include "tsc2100.h"
1477 char *itob(int n
, int len
)
1479 static char binary
[64];
1481 for (i
=1, j
=0;i
<=len
;i
++)
1483 binary
[j
++] = n
&(1<<(len
-i
))?'1':'0';
1490 static char* tsc2100_debug_getname(int selected_item
, void * data
,
1491 char *buffer
, size_t buffer_len
)
1493 int *page
= (int*)data
;
1494 bool reserved
= false;
1498 if ((selected_item
> 0x0a) ||
1499 (selected_item
== 0x04) ||
1500 (selected_item
== 0x08))
1504 if ((selected_item
> 0x05) ||
1505 (selected_item
== 0x02))
1509 if (selected_item
> 0x1e)
1514 snprintf(buffer
, buffer_len
, "%02x: RESERVED", selected_item
);
1516 snprintf(buffer
, buffer_len
, "%02x: %s", selected_item
,
1517 itob(tsc2100_readreg(*page
, selected_item
)&0xffff,16));
1520 static int tsc2100debug_action_callback(int action
, struct gui_synclist
*lists
)
1522 int *page
= (int*)lists
->data
;
1523 if (action
== ACTION_STD_OK
)
1525 *page
= (*page
+1)%3;
1526 snprintf(lists
->title
, 32,
1527 "tsc2100 registers - Page %d", *page
);
1528 return ACTION_REDRAW
;
1532 bool tsc2100_debug(void)
1535 char title
[32] = "tsc2100 registers - Page 0";
1536 struct simplelist_info info
;
1537 simplelist_info_init(&info
, title
, 32, &page
);
1538 info
.timeout
= HZ
/100;
1539 info
.get_name
= tsc2100_debug_getname
;
1540 info
.action_callback
= tsc2100debug_action_callback
;
1541 return simplelist_show_list(&info
);
1545 #ifdef HAVE_LCD_BITMAP
1547 * view_battery() shows a automatically scaled graph of the battery voltage
1548 * over time. Usable for estimating battery life / charging rate.
1549 * The power_history array is updated in power_thread of powermgmt.c.
1552 #define BAT_LAST_VAL MIN(LCD_WIDTH, POWER_HISTORY_LEN)
1553 #define BAT_YSPACE (LCD_HEIGHT - 20)
1555 static bool view_battery(void)
1559 unsigned short maxv
, minv
;
1562 lcd_setmargins(0, 0);
1563 lcd_setfont(FONT_SYSFIXED
);
1567 lcd_clear_display();
1569 case 0: /* voltage history graph */
1570 /* Find maximum and minimum voltage for scaling */
1571 minv
= power_history
[0];
1573 for (i
= 1; i
< BAT_LAST_VAL
&& power_history
[i
]; i
++) {
1574 if (power_history
[i
] > maxv
)
1575 maxv
= power_history
[i
];
1576 if (power_history
[i
] < minv
)
1577 minv
= power_history
[i
];
1580 snprintf(buf
, 30, "Battery %d.%03d", power_history
[0] / 1000,
1581 power_history
[0] % 1000);
1582 lcd_puts(0, 0, buf
);
1583 snprintf(buf
, 30, "scale %d.%03d-%d.%03dV",
1584 minv
/ 1000, minv
% 1000, maxv
/ 1000, maxv
% 1000);
1585 lcd_puts(0, 1, buf
);
1588 for (i
= BAT_LAST_VAL
- 1; i
>= 0; i
--) {
1589 y
= (power_history
[i
] - minv
) * BAT_YSPACE
/ (maxv
- minv
);
1590 lcd_set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
1591 lcd_vline(x
, LCD_HEIGHT
-1, 20);
1592 lcd_set_drawmode(DRMODE_SOLID
);
1593 lcd_vline(x
, LCD_HEIGHT
-1,
1594 MIN(MAX(LCD_HEIGHT
-1 - y
, 20), LCD_HEIGHT
-1));
1600 case 1: /* status: */
1601 lcd_puts(0, 0, "Power status:");
1603 battery_read_info(&y
, NULL
);
1604 snprintf(buf
, 30, "Battery: %d.%03d V", y
/ 1000, y
% 1000);
1605 lcd_puts(0, 1, buf
);
1606 #ifdef ADC_EXT_POWER
1607 y
= (adc_read(ADC_EXT_POWER
) * EXT_SCALE_FACTOR
) / 1000;
1608 snprintf(buf
, 30, "External: %d.%03d V", y
/ 1000, y
% 1000);
1609 lcd_puts(0, 2, buf
);
1612 #if CONFIG_CHARGING == CHARGING_CONTROL
1613 snprintf(buf
, 30, "Chgr: %s %s",
1614 charger_inserted() ? "present" : "absent",
1615 charger_enabled
? "on" : "off");
1616 lcd_puts(0, 3, buf
);
1617 snprintf(buf
, 30, "short delta: %d", short_delta
);
1618 lcd_puts(0, 5, buf
);
1619 snprintf(buf
, 30, "long delta: %d", long_delta
);
1620 lcd_puts(0, 6, buf
);
1621 lcd_puts(0, 7, power_message
);
1622 snprintf(buf
, 30, "USB Inserted: %s",
1623 usb_inserted() ? "yes" : "no");
1624 lcd_puts(0, 8, buf
);
1625 #if defined IRIVER_H300_SERIES
1626 snprintf(buf
, 30, "USB Charging Enabled: %s",
1627 usb_charging_enabled() ? "yes" : "no");
1628 lcd_puts(0, 9, buf
);
1630 #else /* CONFIG_CHARGING != CHARGING_CONTROL */
1631 #if defined IPOD_NANO || defined IPOD_VIDEO
1632 int usb_pwr
= (GPIOL_INPUT_VAL
& 0x10)?true:false;
1633 int ext_pwr
= (GPIOL_INPUT_VAL
& 0x08)?false:true;
1634 int dock
= (GPIOA_INPUT_VAL
& 0x10)?true:false;
1635 int charging
= (GPIOB_INPUT_VAL
& 0x01)?false:true;
1636 int headphone
= (GPIOA_INPUT_VAL
& 0x80)?true:false;
1638 snprintf(buf
, 30, "USB pwr: %s",
1639 usb_pwr
? "present" : "absent");
1640 lcd_puts(0, 3, buf
);
1641 snprintf(buf
, 30, "EXT pwr: %s",
1642 ext_pwr
? "present" : "absent");
1643 lcd_puts(0, 4, buf
);
1644 snprintf(buf
, 30, "Battery: %s",
1645 charging
? "charging" : (usb_pwr
||ext_pwr
) ? "charged" : "discharging");
1646 lcd_puts(0, 5, buf
);
1647 snprintf(buf
, 30, "Dock mode: %s",
1648 dock
? "enabled" : "disabled");
1649 lcd_puts(0, 6, buf
);
1650 snprintf(buf
, 30, "Headphone: %s",
1651 headphone
? "connected" : "disconnected");
1652 lcd_puts(0, 7, buf
);
1654 snprintf(buf
, 30, "Charger: %s",
1655 charger_inserted() ? "present" : "absent");
1656 lcd_puts(0, 3, buf
);
1657 #if defined TOSHIBA_GIGABEAT_S
1658 y
= battery_adc_charge_current();
1659 x
= y
< 0 ? '-' : ' ';
1661 snprintf(buf
, 30, "I Charge:%c%d.%03d A", (char)x
, y
/ 1000, y
% 1000);
1662 lcd_puts(0, 4, buf
);
1664 y
= battery_adc_temp();
1665 snprintf(buf
, 30, "T Battery: %dC (%dF)", y
, (9*y
+ 160) / 5);
1666 lcd_puts(0, 5, buf
);
1667 #endif /* defined TOSHIBA_GIGABEAT_S */
1668 #endif /* defined IPOD_NANO || defined IPOD_VIDEO */
1669 #endif /* CONFIG_CHARGING != CHARGING_CONTROL */
1670 #endif /* CONFIG_CHARGING */
1673 case 2: /* voltage deltas: */
1674 lcd_puts(0, 0, "Voltage deltas:");
1676 for (i
= 0; i
<= 6; i
++) {
1677 y
= power_history
[i
] - power_history
[i
+1];
1678 snprintf(buf
, 30, "-%d min: %s%d.%03d V", i
,
1679 (y
< 0) ? "-" : "", ((y
< 0) ? y
* -1 : y
) / 1000,
1680 ((y
< 0) ? y
* -1 : y
) % 1000);
1681 lcd_puts(0, i
+1, buf
);
1685 case 3: /* remaining time estimation: */
1687 #if CONFIG_CHARGING == CHARGING_CONTROL
1688 snprintf(buf
, 30, "charge_state: %d", charge_state
);
1689 lcd_puts(0, 0, buf
);
1691 snprintf(buf
, 30, "Cycle time: %d m", powermgmt_last_cycle_startstop_min
);
1692 lcd_puts(0, 1, buf
);
1694 snprintf(buf
, 30, "Lvl@cyc st: %d%%", powermgmt_last_cycle_level
);
1695 lcd_puts(0, 2, buf
);
1697 snprintf(buf
, 30, "P=%2d I=%2d", pid_p
, pid_i
);
1698 lcd_puts(0, 3, buf
);
1700 snprintf(buf
, 30, "Trickle sec: %d/60", trickle_sec
);
1701 lcd_puts(0, 4, buf
);
1702 #endif /* CONFIG_CHARGING == CHARGING_CONTROL */
1704 snprintf(buf
, 30, "Last PwrHist: %d.%03dV",
1705 power_history
[0] / 1000,
1706 power_history
[0] % 1000);
1707 lcd_puts(0, 5, buf
);
1709 snprintf(buf
, 30, "battery level: %d%%", battery_level());
1710 lcd_puts(0, 6, buf
);
1712 snprintf(buf
, 30, "Est. remain: %d m", battery_time());
1713 lcd_puts(0, 7, buf
);
1719 switch(get_action(CONTEXT_STD
,HZ
/2))
1721 case ACTION_STD_PREV
:
1726 case ACTION_STD_NEXT
:
1731 case ACTION_STD_CANCEL
:
1738 #endif /* HAVE_LCD_BITMAP */
1742 #if defined(HAVE_MMC) || defined(HAVE_ATA_SD)
1743 #if defined(HAVE_MMC)
1744 #define CARDTYPE "MMC"
1746 #define CARDTYPE "microSD"
1748 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1751 int *cardnum
= (int*)lists
->data
;
1752 unsigned char card_name
[7];
1753 unsigned char pbuf
[32];
1754 char *title
= lists
->title
;
1755 static const unsigned char i_vmin
[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
1756 static const unsigned char i_vmax
[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
1757 static const unsigned char *kbit_units
[] = { "kBit/s", "MBit/s", "GBit/s" };
1758 static const unsigned char *nsec_units
[] = { "ns", "µs", "ms" };
1759 static const char *spec_vers
[] = { "1.0-1.2", "1.4", "2.0-2.2",
1760 "3.1-3.31", "4.0" };
1761 if ((btn
== ACTION_STD_OK
) || (btn
== SYS_FS_CHANGED
) || (btn
== ACTION_REDRAW
))
1764 if (btn
== ACTION_STD_OK
)
1766 *cardnum
^= 0x1; /* change cards */
1770 simplelist_set_line_count(0);
1772 card
= card_get_info(*cardnum
);
1774 if (card
->initialized
> 0)
1776 card_name
[6] = '\0';
1777 strncpy(card_name
, ((unsigned char*)card
->cid
) + 3, 6);
1778 simplelist_addline(SIMPLELIST_ADD_LINE
,
1779 "%s Rev %d.%d", card_name
,
1780 (int) card_extract_bits(card
->cid
, 72, 4),
1781 (int) card_extract_bits(card
->cid
, 76, 4));
1782 simplelist_addline(SIMPLELIST_ADD_LINE
,
1784 (int) card_extract_bits(card
->cid
, 112, 4),
1785 (int) card_extract_bits(card
->cid
, 116, 4) + 1997);
1786 simplelist_addline(SIMPLELIST_ADD_LINE
,
1788 card_extract_bits(card
->cid
, 80, 32));
1789 simplelist_addline(SIMPLELIST_ADD_LINE
,
1791 (int) card_extract_bits(card
->cid
, 0, 8),
1792 (int) card_extract_bits(card
->cid
, 8, 16));
1793 int temp
= card_extract_bits(card
->csd
, 2, 4);
1794 simplelist_addline(SIMPLELIST_ADD_LINE
,
1795 CARDTYPE
" v%s", temp
< 5 ?
1796 spec_vers
[temp
] : "?.?");
1797 simplelist_addline(SIMPLELIST_ADD_LINE
,
1798 "Blocks: 0x%06lx", card
->numblocks
);
1799 simplelist_addline(SIMPLELIST_ADD_LINE
,
1800 "Blksz.: %d P:%c%c", card
->blocksize
,
1801 card_extract_bits(card
->csd
, 48, 1) ? 'R' : '-',
1802 card_extract_bits(card
->csd
, 106, 1) ? 'W' : '-');
1803 output_dyn_value(pbuf
, sizeof pbuf
, card
->speed
/ 1000,
1805 simplelist_addline(SIMPLELIST_ADD_LINE
,
1807 output_dyn_value(pbuf
, sizeof pbuf
, card
->tsac
,
1809 simplelist_addline(SIMPLELIST_ADD_LINE
,
1811 simplelist_addline(SIMPLELIST_ADD_LINE
,
1812 "Nsac: %d clk", card
->nsac
);
1813 simplelist_addline(SIMPLELIST_ADD_LINE
,
1814 "R2W: *%d", card
->r2w_factor
);
1815 simplelist_addline(SIMPLELIST_ADD_LINE
,
1817 i_vmin
[card_extract_bits(card
->csd
, 66, 3)],
1818 i_vmax
[card_extract_bits(card
->csd
, 69, 3)]);
1819 simplelist_addline(SIMPLELIST_ADD_LINE
,
1821 i_vmin
[card_extract_bits(card
->csd
, 72, 3)],
1822 i_vmax
[card_extract_bits(card
->csd
, 75, 3)]);
1824 else if (card
->initialized
== 0)
1826 simplelist_addline(SIMPLELIST_ADD_LINE
, "Not Found!");
1829 else /* card->initialized < 0 */
1831 simplelist_addline(SIMPLELIST_ADD_LINE
, "Init Error! (%d)", card
->initialized
);
1834 snprintf(title
, 16, "[" CARDTYPE
" %d]", *cardnum
);
1835 gui_synclist_set_title(lists
, title
, Icon_NOICON
);
1836 gui_synclist_set_nb_items(lists
, simplelist_get_line_count());
1837 gui_synclist_select_item(lists
, 0);
1838 btn
= ACTION_REDRAW
;
1842 #else /* !defined(HAVE_MMC) && !defined(HAVE_ATA_SD) */
1843 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1848 unsigned short* identify_info
= ata_get_identify();
1849 bool timing_info_present
= false;
1852 simplelist_set_line_count(0);
1854 for (i
=0; i
< 20; i
++)
1855 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+27]);
1857 /* kill trailing space */
1858 for (i
=39; i
&& buf
[i
]==' '; i
--)
1860 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", buf
);
1861 for (i
=0; i
< 4; i
++)
1862 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+23]);
1864 simplelist_addline(SIMPLELIST_ADD_LINE
,
1865 "Firmware: %s", buf
);
1866 snprintf(buf
, sizeof buf
, "%ld MB",
1867 ((unsigned long)identify_info
[61] << 16 |
1868 (unsigned long)identify_info
[60]) / 2048 );
1869 simplelist_addline(SIMPLELIST_ADD_LINE
,
1872 fat_size( IF_MV2(0,) NULL
, &free
);
1873 simplelist_addline(SIMPLELIST_ADD_LINE
,
1874 "Free: %ld MB", free
/ 1024);
1875 simplelist_addline(SIMPLELIST_ADD_LINE
,
1876 "Spinup time: %d ms", ata_spinup_time
* (1000/HZ
));
1877 i
= identify_info
[83] & (1<<3);
1878 simplelist_addline(SIMPLELIST_ADD_LINE
,
1879 "Power mgmt: %s", i
? "enabled" : "unsupported");
1880 i
= identify_info
[83] & (1<<9);
1881 simplelist_addline(SIMPLELIST_ADD_LINE
,
1882 "Noise mgmt: %s", i
? "enabled" : "unsupported");
1883 i
= identify_info
[82] & (1<<6);
1884 simplelist_addline(SIMPLELIST_ADD_LINE
,
1885 "Read-ahead: %s", i
? "enabled" : "unsupported");
1886 timing_info_present
= identify_info
[53] & (1<<1);
1887 if(timing_info_present
) {
1888 char pio3
[2], pio4
[2];pio3
[1] = 0;
1890 pio3
[0] = (identify_info
[64] & (1<<0)) ? '3' : 0;
1891 pio4
[0] = (identify_info
[64] & (1<<1)) ? '4' : 0;
1892 simplelist_addline(SIMPLELIST_ADD_LINE
,
1893 "PIO modes: 0 1 2 %s %s", pio3
, pio4
);
1896 simplelist_addline(SIMPLELIST_ADD_LINE
,
1897 "No PIO mode info");
1899 timing_info_present
= identify_info
[53] & (1<<1);
1900 if(timing_info_present
) {
1901 simplelist_addline(SIMPLELIST_ADD_LINE
,
1902 "Cycle times %dns/%dns",
1904 identify_info
[68] );
1906 simplelist_addline(SIMPLELIST_ADD_LINE
,
1909 #if defined (TOSHIBA_GIGABEAT_F) || defined (TOSHIBA_GIGABEAT_S)
1910 if (identify_info
[63] & (1<<0)) {
1911 char mdma0
[2], mdma1
[2], mdma2
[2];
1912 mdma0
[1] = mdma1
[1] = mdma2
[1] = 0;
1913 mdma0
[0] = (identify_info
[63] & (1<<0)) ? '0' : 0;
1914 mdma1
[0] = (identify_info
[63] & (1<<1)) ? '1' : 0;
1915 mdma2
[0] = (identify_info
[63] & (1<<2)) ? '2' : 0;
1916 simplelist_addline(SIMPLELIST_ADD_LINE
,
1917 "MDMA modes: %s %s %s", mdma0
, mdma1
, mdma2
);
1918 simplelist_addline(SIMPLELIST_ADD_LINE
,
1919 "MDMA Cycle times %dns/%dns",
1921 identify_info
[66] );
1924 simplelist_addline(SIMPLELIST_ADD_LINE
,
1925 "No MDMA mode info");
1927 if (identify_info
[88] & (1<<0)) {
1928 char udma0
[2], udma1
[2], udma2
[2], udma3
[2], udma4
[2], udma5
[2];
1929 udma0
[1] = udma1
[1] = udma2
[1] = udma3
[1] = udma4
[1] = udma5
[1] = 0;
1930 udma0
[0] = (identify_info
[88] & (1<<0)) ? '0' : 0;
1931 udma1
[0] = (identify_info
[88] & (1<<1)) ? '1' : 0;
1932 udma2
[0] = (identify_info
[88] & (1<<2)) ? '2' : 0;
1933 udma3
[0] = (identify_info
[88] & (1<<3)) ? '3' : 0;
1934 udma4
[0] = (identify_info
[88] & (1<<4)) ? '4' : 0;
1935 udma5
[0] = (identify_info
[88] & (1<<5)) ? '5' : 0;
1936 simplelist_addline(SIMPLELIST_ADD_LINE
,
1937 "UDMA modes: %s %s %s %s %s %s", udma0
, udma1
, udma2
,
1938 udma3
, udma4
, udma5
);
1941 simplelist_addline(SIMPLELIST_ADD_LINE
,
1942 "No UDMA mode info");
1944 #endif /* defined (TOSHIBA_GIGABEAT_F) || defined (TOSHIBA_GIGABEAT_S) */
1945 timing_info_present
= identify_info
[53] & (1<<1);
1946 if(timing_info_present
) {
1947 i
= identify_info
[49] & (1<<11);
1948 simplelist_addline(SIMPLELIST_ADD_LINE
,
1949 "IORDY support: %s", i
? "yes" : "no");
1950 i
= identify_info
[49] & (1<<10);
1951 simplelist_addline(SIMPLELIST_ADD_LINE
,
1952 "IORDY disable: %s", i
? "yes" : "no");
1954 simplelist_addline(SIMPLELIST_ADD_LINE
,
1957 simplelist_addline(SIMPLELIST_ADD_LINE
,
1958 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
1962 static bool dbg_identify_info(void)
1964 int fd
= creat("/identify_info.bin");
1967 #ifdef ROCKBOX_LITTLE_ENDIAN
1968 ecwrite(fd
, ata_get_identify(), SECTOR_SIZE
/2, "s", true);
1970 write(fd
, ata_get_identify(), SECTOR_SIZE
);
1976 #endif /* !defined(HAVE_MMC) && !defined(HAVE_ATA_SD) */
1978 static bool dbg_disk_info(void)
1980 struct simplelist_info info
;
1981 simplelist_info_init(&info
, "Disk Info", 1, NULL
);
1982 #if defined(HAVE_MMC) || defined(HAVE_ATA_SD)
1985 info
.callback_data
= (void*)&card
;
1988 info
.action_callback
= disk_callback
;
1989 info
.hide_selection
= true;
1990 info
.scroll_all
= true;
1991 return simplelist_show_list(&info
);
1993 #endif /* !SIMULATOR */
1995 #ifdef HAVE_DIRCACHE
1996 static int dircache_callback(int btn
, struct gui_synclist
*lists
)
1998 (void)btn
; (void)lists
;
1999 simplelist_set_line_count(0);
2000 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache initialized: %s",
2001 dircache_is_enabled() ? "Yes" : "No");
2002 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache size: %d B",
2003 dircache_get_cache_size());
2004 simplelist_addline(SIMPLELIST_ADD_LINE
, "Last size: %d B",
2005 global_status
.dircache_size
);
2006 simplelist_addline(SIMPLELIST_ADD_LINE
, "Limit: %d B",
2008 simplelist_addline(SIMPLELIST_ADD_LINE
, "Reserve: %d/%d B",
2009 dircache_get_reserve_used(), DIRCACHE_RESERVE
);
2010 simplelist_addline(SIMPLELIST_ADD_LINE
, "Scanning took: %d s",
2011 dircache_get_build_ticks() / HZ
);
2012 simplelist_addline(SIMPLELIST_ADD_LINE
, "Entry count: %d",
2013 dircache_get_entry_count());
2017 static bool dbg_dircache_info(void)
2019 struct simplelist_info info
;
2020 simplelist_info_init(&info
, "Dircache Info", 7, NULL
);
2021 info
.action_callback
= dircache_callback
;
2022 info
.hide_selection
= true;
2023 info
.scroll_all
= true;
2024 return simplelist_show_list(&info
);
2027 #endif /* HAVE_DIRCACHE */
2029 #ifdef HAVE_TAGCACHE
2030 static int database_callback(int btn
, struct gui_synclist
*lists
)
2033 struct tagcache_stat
*stat
= tagcache_get_stat();
2034 static bool synced
= false;
2036 simplelist_set_line_count(0);
2038 simplelist_addline(SIMPLELIST_ADD_LINE
, "Initialized: %s",
2039 stat
->initialized
? "Yes" : "No");
2040 simplelist_addline(SIMPLELIST_ADD_LINE
, "DB Ready: %s",
2041 stat
->ready
? "Yes" : "No");
2042 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM Cache: %s",
2043 stat
->ramcache
? "Yes" : "No");
2044 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM: %d/%d B",
2045 stat
->ramcache_used
, stat
->ramcache_allocated
);
2046 simplelist_addline(SIMPLELIST_ADD_LINE
, "Progress: %d%% (%d entries)",
2047 stat
->progress
, stat
->processed_entries
);
2048 simplelist_addline(SIMPLELIST_ADD_LINE
, "Curfile: %s",
2049 stat
->curentry
? stat
->curentry
: "---");
2050 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit step: %d",
2052 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit delayed: %s",
2053 stat
->commit_delayed
? "Yes" : "No");
2055 simplelist_addline(SIMPLELIST_ADD_LINE
, "Queue length: %d",
2056 stat
->queue_length
);
2061 tagcache_screensync_event();
2064 if (!btn
&& stat
->curentry
)
2067 return ACTION_REDRAW
;
2070 if (btn
== ACTION_STD_CANCEL
)
2071 tagcache_screensync_enable(false);
2075 static bool dbg_tagcache_info(void)
2077 struct simplelist_info info
;
2078 simplelist_info_init(&info
, "Database Info", 8, NULL
);
2079 info
.action_callback
= database_callback
;
2080 info
.hide_selection
= true;
2081 info
.scroll_all
= true;
2083 /* Don't do nonblock here, must give enough processing time
2084 for tagcache thread. */
2085 /* info.timeout = TIMEOUT_NOBLOCK; */
2087 tagcache_screensync_enable(true);
2088 return simplelist_show_list(&info
);
2092 #if CONFIG_CPU == SH7034
2093 static bool dbg_save_roms(void)
2096 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
2098 fd
= creat("/internal_rom_0000-FFFF.bin");
2101 write(fd
, (void *)0, 0x10000);
2105 fd
= creat("/internal_rom_2000000-203FFFF.bin");
2108 write(fd
, (void *)0x2000000, 0x40000);
2112 system_memory_guard(oldmode
);
2115 #elif defined CPU_COLDFIRE
2116 static bool dbg_save_roms(void)
2119 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
2121 #if defined(IRIVER_H100_SERIES)
2122 fd
= creat("/internal_rom_000000-1FFFFF.bin");
2123 #elif defined(IRIVER_H300_SERIES)
2124 fd
= creat("/internal_rom_000000-3FFFFF.bin");
2125 #elif defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IAUDIO_M3)
2126 fd
= creat("/internal_rom_000000-3FFFFF.bin");
2130 write(fd
, (void *)0, FLASH_SIZE
);
2133 system_memory_guard(oldmode
);
2136 fd
= creat("/internal_eeprom.bin");
2140 char buf
[EEPROM_SIZE
];
2143 old_irq_level
= disable_irq_save();
2145 err
= eeprom_24cxx_read(0, buf
, sizeof buf
);
2147 restore_irq(old_irq_level
);
2150 gui_syncsplash(HZ
*3, "Eeprom read failure (%d)",err
);
2153 write(fd
, buf
, sizeof buf
);
2162 #elif defined(CPU_PP) && !defined(HAVE_ATA_SD)
2163 static bool dbg_save_roms(void)
2167 fd
= creat("/internal_rom_000000-0FFFFF.bin");
2170 write(fd
, (void *)0x20000000, FLASH_SIZE
);
2180 static int radio_callback(int btn
, struct gui_synclist
*lists
)
2183 if (btn
== ACTION_STD_CANCEL
)
2185 simplelist_set_line_count(1);
2187 #if (CONFIG_TUNER & LV24020LP)
2188 simplelist_addline(SIMPLELIST_ADD_LINE
,
2189 "CTRL_STAT: %02X", lv24020lp_get(LV24020LP_CTRL_STAT
) );
2190 simplelist_addline(SIMPLELIST_ADD_LINE
,
2191 "RADIO_STAT: %02X", lv24020lp_get(LV24020LP_REG_STAT
) );
2192 simplelist_addline(SIMPLELIST_ADD_LINE
,
2193 "MSS_FM: %d kHz", lv24020lp_get(LV24020LP_MSS_FM
) );
2194 simplelist_addline(SIMPLELIST_ADD_LINE
,
2195 "MSS_IF: %d Hz", lv24020lp_get(LV24020LP_MSS_IF
) );
2196 simplelist_addline(SIMPLELIST_ADD_LINE
,
2197 "MSS_SD: %d Hz", lv24020lp_get(LV24020LP_MSS_SD
) );
2198 simplelist_addline(SIMPLELIST_ADD_LINE
,
2199 "if_set: %d Hz", lv24020lp_get(LV24020LP_IF_SET
) );
2200 simplelist_addline(SIMPLELIST_ADD_LINE
,
2201 "sd_set: %d Hz", lv24020lp_get(LV24020LP_SD_SET
) );
2203 #if (CONFIG_TUNER & S1A0903X01)
2204 simplelist_addline(SIMPLELIST_ADD_LINE
,
2205 "Samsung regs: %08X", s1a0903x01_get(RADIO_ALL
));
2206 /* This one doesn't return dynamic data atm */
2208 #if (CONFIG_TUNER & TEA5767)
2209 struct tea5767_dbg_info nfo
;
2210 tea5767_dbg_info(&nfo
);
2211 simplelist_addline(SIMPLELIST_ADD_LINE
, "Philips regs:");
2212 simplelist_addline(SIMPLELIST_ADD_LINE
,
2213 " Read: %02X %02X %02X %02X %02X",
2214 (unsigned)nfo
.read_regs
[0], (unsigned)nfo
.read_regs
[1],
2215 (unsigned)nfo
.read_regs
[2], (unsigned)nfo
.read_regs
[3],
2216 (unsigned)nfo
.read_regs
[4]);
2217 simplelist_addline(SIMPLELIST_ADD_LINE
,
2218 " Write: %02X %02X %02X %02X %02X",
2219 (unsigned)nfo
.write_regs
[0], (unsigned)nfo
.write_regs
[1],
2220 (unsigned)nfo
.write_regs
[2], (unsigned)nfo
.write_regs
[3],
2221 (unsigned)nfo
.write_regs
[4]);
2223 return ACTION_REDRAW
;
2225 static bool dbg_fm_radio(void)
2227 struct simplelist_info info
;
2228 info
.scroll_all
= true;
2229 simplelist_info_init(&info
, "FM Radio", 1, NULL
);
2230 simplelist_set_line_count(0);
2231 simplelist_addline(SIMPLELIST_ADD_LINE
, "HW detected: %s",
2232 radio_hardware_present() ? "yes" : "no");
2234 info
.action_callback
= radio_hardware_present()?radio_callback
: NULL
;
2235 info
.hide_selection
= true;
2236 return simplelist_show_list(&info
);
2238 #endif /* CONFIG_TUNER */
2239 #endif /* !SIMULATOR */
2241 #ifdef HAVE_LCD_BITMAP
2242 extern bool do_screendump_instead_of_usb
;
2244 static bool dbg_screendump(void)
2246 do_screendump_instead_of_usb
= !do_screendump_instead_of_usb
;
2247 gui_syncsplash(HZ
, "Screendump %s",
2248 do_screendump_instead_of_usb
?"enabled":"disabled");
2251 #endif /* HAVE_LCD_BITMAP */
2253 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2254 static bool dbg_set_memory_guard(void)
2256 static const struct opt_items names
[MAXMEMGUARD
] = {
2258 { "Flash ROM writes", -1 },
2259 { "Zero area (all)", -1 }
2261 int mode
= system_memory_guard(MEMGUARD_KEEP
);
2263 set_option( "Catch mem accesses", &mode
, INT
, names
, MAXMEMGUARD
, NULL
);
2264 system_memory_guard(mode
);
2268 #endif /* CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) */
2270 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2271 static bool dbg_write_eeprom(void)
2276 char buf
[EEPROM_SIZE
];
2279 fd
= open("/internal_eeprom.bin", O_RDONLY
);
2283 rc
= read(fd
, buf
, EEPROM_SIZE
);
2285 if(rc
== EEPROM_SIZE
)
2287 old_irq_level
= disable_irq_save();
2289 err
= eeprom_24cxx_write(0, buf
, sizeof buf
);
2291 gui_syncsplash(HZ
*3, "Eeprom write failure (%d)",err
);
2293 gui_syncsplash(HZ
*3, "Eeprom written successfully");
2295 restore_irq(old_irq_level
);
2299 gui_syncsplash(HZ
*3, "File read error (%d)",rc
);
2305 gui_syncsplash(HZ
*3, "Failed to open 'internal_eeprom.bin'");
2310 #endif /* defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS) */
2311 #ifdef CPU_BOOST_LOGGING
2312 static bool cpu_boost_log(void)
2315 int count
= cpu_boost_log_getcount();
2316 int lines
= LCD_HEIGHT
/SYSFONT_HEIGHT
;
2319 lcd_setmargins(0, 0);
2320 lcd_setfont(FONT_SYSFIXED
);
2321 str
= cpu_boost_log_getlog_first();
2324 lcd_clear_display();
2325 for(j
=0; j
<lines
; j
++,i
++)
2328 str
= cpu_boost_log_getlog_next();
2339 switch(get_action(CONTEXT_STD
,TIMEOUT_BLOCK
))
2342 case ACTION_STD_PREV
:
2343 case ACTION_STD_NEXT
:
2346 case ACTION_STD_CANCEL
:
2353 get_action(CONTEXT_STD
,TIMEOUT_BLOCK
);
2354 lcd_setfont(FONT_UI
);
2359 #if (defined(HAVE_SCROLLWHEEL) && (CONFIG_KEYPAD==IPOD_4G_PAD) && !defined(SIMULATOR))
2360 extern bool wheel_is_touched
;
2361 extern int old_wheel_value
;
2362 extern int new_wheel_value
;
2363 extern int wheel_delta
;
2364 extern unsigned int accumulated_wheel_delta
;
2365 extern unsigned int wheel_velocity
;
2367 static bool dbg_scrollwheel(void)
2372 lcd_setmargins(0, 0);
2373 lcd_setfont(FONT_SYSFIXED
);
2377 if (action_userabort(HZ
/10))
2380 lcd_clear_display();
2382 /* show internal variables of scrollwheel driver */
2383 snprintf(buf
, sizeof(buf
), "wheel touched: %s", (wheel_is_touched
) ? "true" : "false");
2384 lcd_puts(0, 0, buf
);
2385 snprintf(buf
, sizeof(buf
), "new position: %2d", new_wheel_value
);
2386 lcd_puts(0, 1, buf
);
2387 snprintf(buf
, sizeof(buf
), "old position: %2d", old_wheel_value
);
2388 lcd_puts(0, 2, buf
);
2389 snprintf(buf
, sizeof(buf
), "wheel delta: %2d", wheel_delta
);
2390 lcd_puts(0, 3, buf
);
2391 snprintf(buf
, sizeof(buf
), "accumulated delta: %2d", accumulated_wheel_delta
);
2392 lcd_puts(0, 4, buf
);
2393 snprintf(buf
, sizeof(buf
), "velo [deg/s]: %4d", (int)wheel_velocity
);
2394 lcd_puts(0, 5, buf
);
2396 /* show effective accelerated scrollspeed */
2397 speed
= button_apply_acceleration( (1<<31)|(1<<24)|wheel_velocity
);
2398 snprintf(buf
, sizeof(buf
), "accel. speed: %4d", speed
);
2399 lcd_puts(0, 6, buf
);
2407 #if defined(HAVE_USBSTACK) && defined(ROCKBOX_HAS_LOGF) && defined(USB_SERIAL)
2408 static bool logf_usb_serial(void)
2410 bool serial_enabled
= !usb_core_driver_enabled(USB_DRIVER_SERIAL
);
2411 usb_core_enable_driver(USB_DRIVER_SERIAL
,serial_enabled
);
2412 gui_syncsplash(HZ
, "USB logf %s",
2413 serial_enabled
?"enabled":"disabled");
2418 #if defined(HAVE_USBSTACK) && defined(USB_STORAGE)
2419 static bool usb_reconnect(void)
2421 gui_syncsplash(HZ
, "Reconnect mass storage");
2422 usb_storage_reconnect();
2427 #if CONFIG_USBOTG == USBOTG_ISP1583
2428 extern int dbg_usb_num_items(void);
2429 extern char* dbg_usb_item(int selected_item
, void *data
, char *buffer
, size_t buffer_len
);
2431 static int isp1583_action_callback(int action
, struct gui_synclist
*lists
)
2434 if (action
== ACTION_NONE
)
2435 action
= ACTION_REDRAW
;
2439 static bool dbg_isp1583(void)
2441 struct simplelist_info isp1583
;
2442 isp1583
.scroll_all
= true;
2443 simplelist_info_init(&isp1583
, "ISP1583", dbg_usb_num_items(), NULL
);
2444 isp1583
.timeout
= HZ
/100;
2445 isp1583
.hide_selection
= true;
2446 isp1583
.get_name
= dbg_usb_item
;
2447 isp1583
.action_callback
= isp1583_action_callback
;
2448 return simplelist_show_list(&isp1583
);
2452 #if defined(CREATIVE_ZVx) && !defined(SIMULATOR)
2453 extern int pic_dbg_num_items(void);
2454 extern char* pic_dbg_item(int selected_item
, void *data
, char *buffer
, size_t buffer_len
);
2456 static int pic_action_callback(int action
, struct gui_synclist
*lists
)
2459 if (action
== ACTION_NONE
)
2460 action
= ACTION_REDRAW
;
2464 static bool dbg_pic(void)
2466 struct simplelist_info pic
;
2467 pic
.scroll_all
= true;
2468 simplelist_info_init(&pic
, "PIC", pic_dbg_num_items(), NULL
);
2469 pic
.timeout
= HZ
/100;
2470 pic
.hide_selection
= true;
2471 pic
.get_name
= pic_dbg_item
;
2472 pic
.action_callback
= pic_action_callback
;
2473 return simplelist_show_list(&pic
);
2478 /****** The menu *********/
2479 struct the_menu_item
{
2480 unsigned char *desc
; /* string or ID */
2481 bool (*function
) (void); /* return true if USB was connected */
2483 static const struct the_menu_item menuitems
[] = {
2484 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || \
2485 (defined(CPU_PP) && !defined(HAVE_ATA_SD))
2486 { "Dump ROM contents", dbg_save_roms
},
2488 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || defined(CPU_PP) \
2489 || CONFIG_CPU == S3C2440 || CONFIG_CPU == IMX31L
2490 { "View I/O ports", dbg_ports
},
2492 #if (CONFIG_RTC == RTC_PCF50605) && !defined(SIMULATOR)
2493 { "View PCF registers", dbg_pcf
},
2495 #if defined(HAVE_TSC2100) && !defined(SIMULATOR)
2496 { "TSC2100 debug", tsc2100_debug
},
2498 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
2499 { "CPU frequency", dbg_cpufreq
},
2501 #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR)
2502 { "S/PDIF analyzer", dbg_spdif
},
2504 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2505 { "Catch mem accesses", dbg_set_memory_guard
},
2507 { "View OS stacks", dbg_os
},
2508 #ifdef HAVE_LCD_BITMAP
2510 { "View battery", view_battery
},
2512 { "Screendump", dbg_screendump
},
2515 { "View HW info", dbg_hw_info
},
2518 { "View partitions", dbg_partitions
},
2521 { "View disk info", dbg_disk_info
},
2522 #if !defined(HAVE_MMC) && !defined(HAVE_ATA_SD)
2523 { "Dump ATA identify info", dbg_identify_info
},
2526 #ifdef HAVE_DIRCACHE
2527 { "View dircache info", dbg_dircache_info
},
2529 #ifdef HAVE_TAGCACHE
2530 { "View database info", dbg_tagcache_info
},
2532 #ifdef HAVE_LCD_BITMAP
2533 #if CONFIG_CODEC == SWCODEC
2534 { "View buffering thread", dbg_buffering_thread
},
2535 #elif !defined(SIMULATOR)
2536 { "View audio thread", dbg_audio_thread
},
2539 { "pm histogram", peak_meter_histogram
},
2540 #endif /* PM_DEBUG */
2541 #endif /* HAVE_LCD_BITMAP */
2544 { "FM Radio", dbg_fm_radio
},
2547 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2548 { "Write back EEPROM", dbg_write_eeprom
},
2550 #if CONFIG_USBOTG == USBOTG_ISP1583
2551 { "View ISP1583 info", dbg_isp1583
},
2553 #if defined(CREATIVE_ZVx) && !defined(SIMULATOR)
2554 { "View PIC info", dbg_pic
},
2556 #ifdef ROCKBOX_HAS_LOGF
2557 {"logf", logfdisplay
},
2558 {"logfdump", logfdump
},
2560 #if defined(HAVE_USBSTACK) && defined(ROCKBOX_HAS_LOGF) && defined(USB_SERIAL)
2561 {"logf over usb",logf_usb_serial
},
2563 #if defined(HAVE_USBSTACK) && defined(USB_STORAGE)
2564 {"reconnect usb storage",usb_reconnect
},
2566 #ifdef CPU_BOOST_LOGGING
2567 {"cpu_boost log",cpu_boost_log
},
2569 #if (defined(HAVE_SCROLLWHEEL) && (CONFIG_KEYPAD==IPOD_4G_PAD) && !defined(SIMULATOR))
2570 {"Debug scrollwheel", dbg_scrollwheel
},
2573 static int menu_action_callback(int btn
, struct gui_synclist
*lists
)
2575 if (btn
== ACTION_STD_OK
)
2577 menuitems
[gui_synclist_get_sel_pos(lists
)].function();
2578 btn
= ACTION_REDRAW
;
2582 static char* dbg_menu_getname(int item
, void * data
,
2583 char *buffer
, size_t buffer_len
)
2585 (void)data
; (void)buffer
; (void)buffer_len
;
2586 return menuitems
[item
].desc
;
2588 bool debug_menu(void)
2590 struct simplelist_info info
;
2592 simplelist_info_init(&info
, "Debug Menu", ARRAYLEN(menuitems
), NULL
);
2593 info
.action_callback
= menu_action_callback
;
2594 info
.get_name
= dbg_menu_getname
;
2596 return simplelist_show_list(&info
);