1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Heikki Hannikainen
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
29 #include "debug_menu.h"
36 #include "powermgmt.h"
40 #include "mp3_playback.h"
43 #include "statusbar.h"
53 #include "lcd-remote.h"
65 #include "eeprom_24cxx.h"
66 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
69 #if (CONFIG_STORAGE & STORAGE_ATA)
78 #ifdef HAVE_LCD_BITMAP
79 #include "scrollbar.h"
80 #include "peakmeter.h"
83 #if CONFIG_CODEC == SWCODEC
85 #include "buffering.h"
87 #if defined(HAVE_SPDIF_OUT) || defined(HAVE_SPDIF_IN)
91 #ifdef IRIVER_H300_SERIES
92 #include "pcf50606.h" /* for pcf50606_read */
99 #if CONFIG_RTC == RTC_PCF50605
100 #include "pcf50605.h"
103 #if CONFIG_CPU == DM320 || CONFIG_CPU == S3C2440 || CONFIG_CPU == TCC7801 \
104 || CONFIG_CPU == IMX31L || CONFIG_CPU == AS3525
105 #include "debug-target.h"
108 #if defined(SANSA_E200) || defined(PHILIPS_SA9200)
113 #if defined(HAVE_USBSTACK)
114 #include "usb_core.h"
117 #include "usbstack/usb_storage.h"
120 /*---------------------------------------------------*/
121 /* SPECIAL DEBUG STUFF */
122 /*---------------------------------------------------*/
123 extern struct thread_entry threads
[MAXTHREADS
];
125 static char thread_status_char(unsigned status
)
127 static const char thread_status_chars
[THREAD_NUM_STATES
+1] =
129 [0 ... THREAD_NUM_STATES
] = '?',
130 [STATE_RUNNING
] = 'R',
131 [STATE_BLOCKED
] = 'B',
132 [STATE_SLEEPING
] = 'S',
133 [STATE_BLOCKED_W_TMO
] = 'T',
134 [STATE_FROZEN
] = 'F',
135 [STATE_KILLED
] = 'K',
138 if (status
> THREAD_NUM_STATES
)
139 status
= THREAD_NUM_STATES
;
141 return thread_status_chars
[status
];
144 static char* threads_getname(int selected_item
, void *data
,
145 char *buffer
, size_t buffer_len
)
148 struct thread_entry
*thread
;
152 if (selected_item
< (int)NUM_CORES
)
154 snprintf(buffer
, buffer_len
, "Idle (%d): %2d%%", selected_item
,
155 idle_stack_usage(selected_item
));
159 selected_item
-= NUM_CORES
;
162 thread
= &threads
[selected_item
];
164 if (thread
->state
== STATE_KILLED
)
166 snprintf(buffer
, buffer_len
, "%2d: ---", selected_item
);
170 thread_get_name(name
, 32, thread
);
172 snprintf(buffer
, buffer_len
,
173 "%2d: " IF_COP("(%d) ") "%c%c " IF_PRIO("%d %d ") "%2d%% %s",
175 IF_COP(thread
->core
,)
176 #ifdef HAVE_SCHEDULER_BOOSTCTRL
177 (thread
->cpu_boost
) ? '+' :
179 ((thread
->state
== STATE_RUNNING
) ? '*' : ' '),
180 thread_status_char(thread
->state
),
181 IF_PRIO(thread
->base_priority
, thread
->priority
, )
182 thread_stack_usage(thread
), name
);
186 static int dbg_threads_action_callback(int action
, struct gui_synclist
*lists
)
189 #ifdef ROCKBOX_HAS_LOGF
190 if (action
== ACTION_STD_OK
)
192 int selpos
= gui_synclist_get_sel_pos(lists
);
194 if (selpos
>= NUM_CORES
)
195 remove_thread(&threads
[selpos
- NUM_CORES
]);
197 remove_thread(&threads
[selpos
]);
199 return ACTION_REDRAW
;
201 #endif /* ROCKBOX_HAS_LOGF */
202 if (action
== ACTION_NONE
)
203 action
= ACTION_REDRAW
;
207 static bool dbg_os(void)
209 struct simplelist_info info
;
210 simplelist_info_init(&info
, IF_COP("Core and ") "Stack usage:",
214 MAXTHREADS
+NUM_CORES
,
217 #ifndef ROCKBOX_HAS_LOGF
218 info
.hide_selection
= true;
219 info
.scroll_all
= true;
221 info
.action_callback
= dbg_threads_action_callback
;
222 info
.get_name
= threads_getname
;
223 return simplelist_show_list(&info
);
226 #ifdef HAVE_LCD_BITMAP
227 #if CONFIG_CODEC != SWCODEC
229 static bool dbg_audio_thread(void)
232 struct audio_debug d
;
234 lcd_setfont(FONT_SYSFIXED
);
238 if (action_userabort(HZ
/5))
241 audio_get_debugdata(&d
);
245 snprintf(buf
, sizeof(buf
), "read: %x", d
.audiobuf_read
);
247 snprintf(buf
, sizeof(buf
), "write: %x", d
.audiobuf_write
);
249 snprintf(buf
, sizeof(buf
), "swap: %x", d
.audiobuf_swapwrite
);
251 snprintf(buf
, sizeof(buf
), "playing: %d", d
.playing
);
253 snprintf(buf
, sizeof(buf
), "playable: %x", d
.playable_space
);
255 snprintf(buf
, sizeof(buf
), "unswapped: %x", d
.unswapped_space
);
258 /* Playable space left */
259 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8, 112, 4, d
.audiobuflen
, 0,
260 d
.playable_space
, HORIZONTAL
);
262 /* Show the watermark limit */
263 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8+4, 112, 4, d
.audiobuflen
, 0,
264 d
.low_watermark_level
, HORIZONTAL
);
266 snprintf(buf
, sizeof(buf
), "wm: %x - %x",
267 d
.low_watermark_level
, d
.lowest_watermark_level
);
274 #endif /* !SIMULATOR */
275 #else /* CONFIG_CODEC == SWCODEC */
276 extern size_t filebuflen
;
277 /* This is a size_t, but call it a long so it puts a - when it's bad. */
279 static unsigned int ticks
, boost_ticks
, freq_sum
;
281 static void dbg_audio_task(void)
284 if(FREQ
> CPUFREQ_NORMAL
)
286 freq_sum
+= FREQ
/1000000; /* in MHz */
291 static bool dbg_buffering_thread(void)
298 size_t bufsize
= pcmbuf_get_bufsize();
299 int pcmbufdescs
= pcmbuf_descs();
300 struct buffering_debug d
;
302 ticks
= boost_ticks
= freq_sum
= 0;
304 tick_add_task(dbg_audio_task
);
306 lcd_setfont(FONT_SYSFIXED
);
309 button
= get_action(CONTEXT_STD
,HZ
/5);
312 case ACTION_STD_NEXT
:
315 case ACTION_STD_PREV
:
318 case ACTION_STD_CANCEL
:
323 buffering_get_debugdata(&d
);
328 bufused
= bufsize
- pcmbuf_free();
330 snprintf(buf
, sizeof(buf
), "pcm: %7ld/%7ld", (long) bufused
, (long) bufsize
);
331 lcd_puts(0, line
++, buf
);
333 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
334 bufsize
, 0, bufused
, HORIZONTAL
);
337 snprintf(buf
, sizeof(buf
), "alloc: %8ld/%8ld", audio_filebufused(),
339 lcd_puts(0, line
++, buf
);
342 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
343 filebuflen
, 0, audio_filebufused(), HORIZONTAL
);
346 snprintf(buf
, sizeof(buf
), "real: %8ld/%8ld", (long)d
.buffered_data
,
348 lcd_puts(0, line
++, buf
);
350 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
351 filebuflen
, 0, (long)d
.buffered_data
, HORIZONTAL
);
355 snprintf(buf
, sizeof(buf
), "usefl: %8ld/%8ld", (long)(d
.useful_data
),
357 lcd_puts(0, line
++, buf
);
360 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
361 filebuflen
, 0, d
.useful_data
, HORIZONTAL
);
365 snprintf(buf
, sizeof(buf
), "data_rem: %ld", (long)d
.data_rem
);
366 lcd_puts(0, line
++, buf
);
368 snprintf(buf
, sizeof(buf
), "track count: %2d", audio_track_count());
369 lcd_puts(0, line
++, buf
);
371 snprintf(buf
, sizeof(buf
), "handle count: %d", (int)d
.num_handles
);
372 lcd_puts(0, line
++, buf
);
375 snprintf(buf
, sizeof(buf
), "cpu freq: %3dMHz",
376 (int)((FREQ
+ 500000) / 1000000));
377 lcd_puts(0, line
++, buf
);
382 int boostquota
= boost_ticks
* 1000 / ticks
; /* in 0.1 % */
383 int avgclock
= freq_sum
* 10 / ticks
; /* in 100 kHz */
384 snprintf(buf
, sizeof(buf
), "boost ratio: %3d.%d%% (%2d.%dMHz)",
385 boostquota
/10, boostquota
%10, avgclock
/10, avgclock
%10);
386 lcd_puts(0, line
++, buf
);
389 snprintf(buf
, sizeof(buf
), "pcmbufdesc: %2d/%2d",
390 pcmbuf_used_descs(), pcmbufdescs
);
391 lcd_puts(0, line
++, buf
);
396 tick_remove_task(dbg_audio_task
);
400 #endif /* CONFIG_CODEC */
401 #endif /* HAVE_LCD_BITMAP */
404 #if (CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE))
405 /* Tool function to read the flash manufacturer and type, if available.
406 Only chips which could be reprogrammed in system will return values.
407 (The mode switch addresses vary between flash manufacturers, hence addr1/2) */
408 /* In IRAM to avoid problems when running directly from Flash */
409 static bool dbg_flash_id(unsigned* p_manufacturer
, unsigned* p_device
,
410 unsigned addr1
, unsigned addr2
)
411 ICODE_ATTR
__attribute__((noinline
));
412 static bool dbg_flash_id(unsigned* p_manufacturer
, unsigned* p_device
,
413 unsigned addr1
, unsigned addr2
)
416 unsigned not_manu
, not_id
; /* read values before switching to ID mode */
417 unsigned manu
, id
; /* read values when in ID mode */
419 #if CONFIG_CPU == SH7034
420 volatile unsigned char* flash
= (unsigned char*)0x2000000; /* flash mapping */
421 #elif defined(CPU_COLDFIRE)
422 volatile unsigned short* flash
= (unsigned short*)0; /* flash mapping */
424 int old_level
; /* saved interrupt level */
426 not_manu
= flash
[0]; /* read the normal content */
427 not_id
= flash
[1]; /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */
429 /* disable interrupts, prevent any stray flash access */
430 old_level
= disable_irq_save();
432 flash
[addr1
] = 0xAA; /* enter command mode */
434 flash
[addr1
] = 0x90; /* ID command */
435 /* Atmel wants 20ms pause here */
436 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
438 manu
= flash
[0]; /* read the IDs */
441 flash
[0] = 0xF0; /* reset flash (back to normal read mode) */
442 /* Atmel wants 20ms pause here */
443 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
445 restore_irq(old_level
); /* enable interrupts again */
447 /* I assume success if the obtained values are different from
448 the normal flash content. This is not perfectly bulletproof, they
449 could theoretically be the same by chance, causing us to fail. */
450 if (not_manu
!= manu
|| not_id
!= id
) /* a value has changed */
452 *p_manufacturer
= manu
; /* return the results */
454 return true; /* success */
456 return false; /* fail */
458 #endif /* (CONFIG_CPU == SH7034 || CPU_COLDFIRE) */
462 static int perfcheck(void)
468 "orr r0, r2, #0xc0 \n" /* disable IRQ and FIQ */
471 "ldr r0, [%[timr]] \n"
472 "add r0, r0, %[tmo] \n"
474 "add %[res], %[res], #1 \n"
475 "ldr r1, [%[timr]] \n"
478 "msr CPSR_c, r2 \n" /* reset IRQ and FIQ state */
482 [timr
]"r"(&USEC_TIMER
),
484 #if CONFIG_CPU == PP5002
486 #else /* PP5020/5022/5024 */
497 #ifdef HAVE_LCD_BITMAP
498 static bool dbg_hw_info(void)
500 #if CONFIG_CPU == SH7034
502 int bitmask
= HW_MASK
;
503 int rom_version
= ROM_VERSION
;
504 unsigned manu
, id
; /* flash IDs */
505 bool got_id
; /* flag if we managed to get the flash IDs */
506 unsigned rom_crc
= 0xffffffff; /* CRC32 of the boot ROM */
507 bool has_bootrom
; /* flag for boot ROM present */
508 int oldmode
; /* saved memory guard mode */
510 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
512 /* get flash ROM type */
513 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
515 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
517 /* check if the boot ROM area is a flash mirror */
518 has_bootrom
= (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
519 if (has_bootrom
) /* if ROM and Flash different */
521 /* calculate CRC16 checksum of boot ROM */
522 rom_crc
= crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
525 system_memory_guard(oldmode
); /* re-enable memory guard */
527 lcd_setfont(FONT_SYSFIXED
);
530 lcd_puts(0, 0, "[Hardware info]");
532 snprintf(buf
, 32, "ROM: %d.%02d", rom_version
/100, rom_version
%100);
535 snprintf(buf
, 32, "Mask: 0x%04x", bitmask
);
539 snprintf(buf
, 32, "Flash: M=%02x D=%02x", manu
, id
);
541 snprintf(buf
, 32, "Flash: M=?? D=??"); /* unknown, sorry */
546 if (rom_crc
== 0x56DBA4EE) /* known Version 1 */
547 snprintf(buf
, 32, "Boot ROM: V1");
549 snprintf(buf
, 32, "ROMcrc: 0x%08x", rom_crc
);
553 snprintf(buf
, 32, "Boot ROM: none");
559 while (!(action_userabort(TIMEOUT_BLOCK
)));
561 #elif CONFIG_CPU == MCF5249 || CONFIG_CPU == MCF5250
563 unsigned manu
, id
; /* flash IDs */
564 int got_id
; /* flag if we managed to get the flash IDs */
565 int oldmode
; /* saved memory guard mode */
568 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
570 /* get flash ROM type */
571 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
573 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
575 system_memory_guard(oldmode
); /* re-enable memory guard */
577 lcd_setfont(FONT_SYSFIXED
);
580 lcd_puts(0, line
++, "[Hardware info]");
583 snprintf(buf
, 32, "Flash: M=%04x D=%04x", manu
, id
);
585 snprintf(buf
, 32, "Flash: M=???? D=????"); /* unknown, sorry */
586 lcd_puts(0, line
++, buf
);
592 lcd_puts(0, ++line
, "Serial Number:");
594 got_id
= ds2411_read_id(&id
);
596 if (got_id
== DS2411_OK
)
598 snprintf(buf
, 32, " FC=%02x", (unsigned)id
.family_code
);
599 lcd_puts(0, ++line
, buf
);
600 snprintf(buf
, 32, " ID=%02X %02X %02X %02X %02X %02X",
601 (unsigned)id
.uid
[0], (unsigned)id
.uid
[1], (unsigned)id
.uid
[2],
602 (unsigned)id
.uid
[3], (unsigned)id
.uid
[4], (unsigned)id
.uid
[5]);
603 lcd_puts(0, ++line
, buf
);
604 snprintf(buf
, 32, " CRC=%02X", (unsigned)id
.crc
);
608 snprintf(buf
, 32, "READ ERR=%d", got_id
);
611 lcd_puts(0, ++line
, buf
);
617 while (!(action_userabort(TIMEOUT_BLOCK
)));
619 #elif defined(CPU_PP502x)
622 char pp_version
[] = { (PP_VER2
>> 24) & 0xff, (PP_VER2
>> 16) & 0xff,
623 (PP_VER2
>> 8) & 0xff, (PP_VER2
) & 0xff,
624 (PP_VER1
>> 24) & 0xff, (PP_VER1
>> 16) & 0xff,
625 (PP_VER1
>> 8) & 0xff, (PP_VER1
) & 0xff, '\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_setfont(FONT_SYSFIXED
);
666 lcd_puts(0, line
++, "[Hardware info]");
669 snprintf(buf
, sizeof(buf
), "HW rev: 0x%08lx", IPOD_HW_REVISION
);
670 lcd_puts(0, line
++, buf
);
673 snprintf(buf
, sizeof(buf
), "PP version: %s", pp_version
);
674 lcd_puts(0, line
++, buf
);
676 snprintf(buf
, sizeof(buf
), "Est. clock (kHz): %d", perfcheck());
677 lcd_puts(0, line
++, buf
);
681 while (!(action_userabort(TIMEOUT_BLOCK
)));
683 /* Define this function in your target tree */
684 return __dbg_hw_info();
685 #endif /* CONFIG_CPU */
688 #else /* !HAVE_LCD_BITMAP */
689 static bool dbg_hw_info(void)
694 int rom_version
= ROM_VERSION
;
695 unsigned manu
, id
; /* flash IDs */
696 bool got_id
; /* flag if we managed to get the flash IDs */
697 unsigned rom_crc
= 0xffffffff; /* CRC32 of the boot ROM */
698 bool has_bootrom
; /* flag for boot ROM present */
699 int oldmode
; /* saved memory guard mode */
701 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
703 /* get flash ROM type */
704 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
706 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
708 /* check if the boot ROM area is a flash mirror */
709 has_bootrom
= (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
710 if (has_bootrom
) /* if ROM and Flash different */
712 /* calculate CRC16 checksum of boot ROM */
713 rom_crc
= crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
716 system_memory_guard(oldmode
); /* re-enable memory guard */
720 lcd_puts(0, 0, "[HW Info]");
726 snprintf(buf
, 32, "ROM: %d.%02d",
727 rom_version
/100, rom_version
%100);
731 snprintf(buf
, 32, "Flash:%02x,%02x", manu
, id
);
733 snprintf(buf
, 32, "Flash:??,??"); /* unknown, sorry */
738 if (rom_crc
== 0x56DBA4EE) /* known Version 1 */
739 snprintf(buf
, 32, "BootROM: V1");
740 else if (rom_crc
== 0x358099E8)
741 snprintf(buf
, 32, "BootROM: V2");
742 /* alternative boot ROM found in one single player so far */
744 snprintf(buf
, 32, "R: %08x", rom_crc
);
747 snprintf(buf
, 32, "BootROM: no");
753 button
= get_action(CONTEXT_SETTINGS
,TIMEOUT_BLOCK
);
757 case ACTION_STD_CANCEL
:
760 case ACTION_SETTINGS_DEC
:
766 case ACTION_SETTINGS_INC
:
775 #endif /* !HAVE_LCD_BITMAP */
776 #endif /* !SIMULATOR */
779 static char* dbg_partitions_getname(int selected_item
, void *data
,
780 char *buffer
, size_t buffer_len
)
783 int partition
= selected_item
/2;
784 struct partinfo
* p
= disk_partinfo(partition
);
787 snprintf(buffer
, buffer_len
, " T:%x %ld MB", p
->type
, p
->size
/ 2048);
791 snprintf(buffer
, buffer_len
, "P%d: S:%lx", partition
, p
->start
);
796 bool dbg_partitions(void)
798 struct simplelist_info info
;
799 simplelist_info_init(&info
, "Partition Info", 4, NULL
);
800 info
.selection_size
= 2;
801 info
.hide_selection
= true;
802 info
.scroll_all
= true;
803 info
.get_name
= dbg_partitions_getname
;
804 return simplelist_show_list(&info
);
808 #if defined(CPU_COLDFIRE) && defined(HAVE_SPDIF_OUT)
809 static bool dbg_spdif(void)
813 unsigned int control
;
818 unsigned int interruptstat
;
819 bool valnogood
, symbolerr
, parityerr
;
822 int spdif_source
= spdif_get_output_source(&spdif_src_on
);
823 spdif_set_output_source(AUDIO_SRC_SPDIF
IF_SPDIF_POWER_(, true));
826 lcd_setfont(FONT_SYSFIXED
);
828 #ifdef HAVE_SPDIF_POWER
829 spdif_power_enable(true); /* We need SPDIF power for both sending & receiving */
836 control
= EBU1RCVCCHANNEL1
;
837 interruptstat
= INTERRUPTSTAT
;
838 INTERRUPTCLEAR
= 0x03c00000;
840 valnogood
= (interruptstat
& 0x01000000)?true:false;
841 symbolerr
= (interruptstat
& 0x00800000)?true:false;
842 parityerr
= (interruptstat
& 0x00400000)?true:false;
844 snprintf(buf
, sizeof(buf
), "Val: %s Sym: %s Par: %s",
847 parityerr
?"--":"OK");
848 lcd_puts(0, line
++, buf
);
850 snprintf(buf
, sizeof(buf
), "Status word: %08x", (int)control
);
851 lcd_puts(0, line
++, buf
);
856 snprintf(buf
, sizeof(buf
), "PRO: %d (%s)",
857 x
, x
?"Professional":"Consumer");
858 lcd_puts(0, line
++, buf
);
860 x
= (control
>> 30) & 1;
861 snprintf(buf
, sizeof(buf
), "Audio: %d (%s)",
862 x
, x
?"Non-PCM":"PCM");
863 lcd_puts(0, line
++, buf
);
865 x
= (control
>> 29) & 1;
866 snprintf(buf
, sizeof(buf
), "Copy: %d (%s)",
867 x
, x
?"Permitted":"Inhibited");
868 lcd_puts(0, line
++, buf
);
870 x
= (control
>> 27) & 7;
883 snprintf(buf
, sizeof(buf
), "Preemphasis: %d (%s)", x
, s
);
884 lcd_puts(0, line
++, buf
);
886 x
= (control
>> 24) & 3;
887 snprintf(buf
, sizeof(buf
), "Mode: %d", x
);
888 lcd_puts(0, line
++, buf
);
890 category
= (control
>> 17) & 127;
902 snprintf(buf
, sizeof(buf
), "Category: 0x%02x (%s)", category
, s
);
903 lcd_puts(0, line
++, buf
);
905 x
= (control
>> 16) & 1;
907 if(((category
& 0x70) == 0x10) ||
908 ((category
& 0x70) == 0x40) ||
909 ((category
& 0x78) == 0x38))
911 generation
= !generation
;
913 snprintf(buf
, sizeof(buf
), "Generation: %d (%s)",
914 x
, generation
?"Original":"No ind.");
915 lcd_puts(0, line
++, buf
);
917 x
= (control
>> 12) & 15;
918 snprintf(buf
, sizeof(buf
), "Source: %d", x
);
919 lcd_puts(0, line
++, buf
);
921 x
= (control
>> 8) & 15;
937 snprintf(buf
, sizeof(buf
), "Channel: %d (%s)", x
, s
);
938 lcd_puts(0, line
++, buf
);
940 x
= (control
>> 4) & 15;
953 snprintf(buf
, sizeof(buf
), "Frequency: %d (%s)", x
, s
);
954 lcd_puts(0, line
++, buf
);
956 x
= (control
>> 2) & 3;
957 snprintf(buf
, sizeof(buf
), "Clock accuracy: %d", x
);
958 lcd_puts(0, line
++, buf
);
962 snprintf(buf
, sizeof(buf
), "Measured freq: %ldHz",
963 spdif_measure_frequency());
964 lcd_puts(0, line
++, buf
);
969 if (action_userabort(HZ
/10))
973 spdif_set_output_source(spdif_source
IF_SPDIF_POWER_(, spdif_src_on
));
975 #ifdef HAVE_SPDIF_POWER
976 spdif_power_enable(global_settings
.spdif_enable
);
981 #endif /* CPU_COLDFIRE */
984 #ifdef HAVE_LCD_BITMAP
985 /* button definitions */
986 #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
987 (CONFIG_KEYPAD == IRIVER_H300_PAD)
988 # define DEBUG_CANCEL BUTTON_OFF
990 #elif CONFIG_KEYPAD == RECORDER_PAD
991 # define DEBUG_CANCEL BUTTON_OFF
993 #elif CONFIG_KEYPAD == ONDIO_PAD
994 # define DEBUG_CANCEL BUTTON_MENU
996 #elif (CONFIG_KEYPAD == IPOD_1G2G_PAD) || \
997 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
998 (CONFIG_KEYPAD == IPOD_4G_PAD)
999 # define DEBUG_CANCEL BUTTON_MENU
1001 #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
1002 # define DEBUG_CANCEL BUTTON_PLAY
1004 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
1005 # define DEBUG_CANCEL BUTTON_REC
1007 #elif (CONFIG_KEYPAD == IAUDIO_M3_PAD)
1008 # define DEBUG_CANCEL BUTTON_RC_REC
1010 #elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
1011 # define DEBUG_CANCEL BUTTON_REW
1013 #elif (CONFIG_KEYPAD == MROBE100_PAD)
1014 # define DEBUG_CANCEL BUTTON_MENU
1016 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
1017 (CONFIG_KEYPAD == SANSA_C200_PAD)
1018 # define DEBUG_CANCEL BUTTON_LEFT
1020 /* This is temporary until the SA9200 touchpad works */
1021 #elif (CONFIG_KEYPAD == PHILIPS_SA9200_PAD) || \
1022 (CONFIG_KEYPAD == PHILIPS_HDD1630_PAD)
1023 # define DEBUG_CANCEL BUTTON_POWER
1025 #endif /* key definitions */
1028 bool dbg_ports(void)
1030 #if CONFIG_CPU == SH7034
1032 int adc_battery_voltage
, adc_battery_level
;
1034 lcd_setfont(FONT_SYSFIXED
);
1035 lcd_clear_display();
1039 snprintf(buf
, 32, "PADR: %04x", (unsigned short)PADR
);
1040 lcd_puts(0, 0, buf
);
1041 snprintf(buf
, 32, "PBDR: %04x", (unsigned short)PBDR
);
1042 lcd_puts(0, 1, buf
);
1044 snprintf(buf
, 32, "AN0: %03x AN4: %03x", adc_read(0), adc_read(4));
1045 lcd_puts(0, 2, buf
);
1046 snprintf(buf
, 32, "AN1: %03x AN5: %03x", adc_read(1), adc_read(5));
1047 lcd_puts(0, 3, buf
);
1048 snprintf(buf
, 32, "AN2: %03x AN6: %03x", adc_read(2), adc_read(6));
1049 lcd_puts(0, 4, buf
);
1050 snprintf(buf
, 32, "AN3: %03x AN7: %03x", adc_read(3), adc_read(7));
1051 lcd_puts(0, 5, buf
);
1053 battery_read_info(&adc_battery_voltage
, &adc_battery_level
);
1054 snprintf(buf
, 32, "Batt: %d.%03dV %d%% ", adc_battery_voltage
/ 1000,
1055 adc_battery_voltage
% 1000, adc_battery_level
);
1056 lcd_puts(0, 6, buf
);
1059 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1062 #elif defined(CPU_COLDFIRE)
1063 unsigned int gpio_out
;
1064 unsigned int gpio1_out
;
1065 unsigned int gpio_read
;
1066 unsigned int gpio1_read
;
1067 unsigned int gpio_function
;
1068 unsigned int gpio1_function
;
1069 unsigned int gpio_enable
;
1070 unsigned int gpio1_enable
;
1071 int adc_buttons
, adc_remote
;
1072 int adc_battery_voltage
, adc_battery_level
;
1076 lcd_clear_display();
1077 lcd_setfont(FONT_SYSFIXED
);
1082 gpio_read
= GPIO_READ
;
1083 gpio1_read
= GPIO1_READ
;
1084 gpio_out
= GPIO_OUT
;
1085 gpio1_out
= GPIO1_OUT
;
1086 gpio_function
= GPIO_FUNCTION
;
1087 gpio1_function
= GPIO1_FUNCTION
;
1088 gpio_enable
= GPIO_ENABLE
;
1089 gpio1_enable
= GPIO1_ENABLE
;
1091 snprintf(buf
, sizeof(buf
), "GPIO_READ: %08x", gpio_read
);
1092 lcd_puts(0, line
++, buf
);
1093 snprintf(buf
, sizeof(buf
), "GPIO_OUT: %08x", gpio_out
);
1094 lcd_puts(0, line
++, buf
);
1095 snprintf(buf
, sizeof(buf
), "GPIO_FUNC: %08x", gpio_function
);
1096 lcd_puts(0, line
++, buf
);
1097 snprintf(buf
, sizeof(buf
), "GPIO_ENA: %08x", gpio_enable
);
1098 lcd_puts(0, line
++, buf
);
1100 snprintf(buf
, sizeof(buf
), "GPIO1_READ: %08x", gpio1_read
);
1101 lcd_puts(0, line
++, buf
);
1102 snprintf(buf
, sizeof(buf
), "GPIO1_OUT: %08x", gpio1_out
);
1103 lcd_puts(0, line
++, buf
);
1104 snprintf(buf
, sizeof(buf
), "GPIO1_FUNC: %08x", gpio1_function
);
1105 lcd_puts(0, line
++, buf
);
1106 snprintf(buf
, sizeof(buf
), "GPIO1_ENA: %08x", gpio1_enable
);
1107 lcd_puts(0, line
++, buf
);
1109 adc_buttons
= adc_read(ADC_BUTTONS
);
1110 adc_remote
= adc_read(ADC_REMOTE
);
1111 battery_read_info(&adc_battery_voltage
, &adc_battery_level
);
1112 #if defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IRIVER_H300_SERIES)
1113 snprintf(buf
, sizeof(buf
), "ADC_BUTTONS (%c): %02x",
1114 button_scan_enabled() ? '+' : '-', adc_buttons
);
1116 snprintf(buf
, sizeof(buf
), "ADC_BUTTONS: %02x", adc_buttons
);
1118 lcd_puts(0, line
++, buf
);
1119 #if defined(IAUDIO_X5) || defined(IAUDIO_M5)
1120 snprintf(buf
, sizeof(buf
), "ADC_REMOTE (%c): %02x",
1121 remote_detect() ? '+' : '-', adc_remote
);
1123 snprintf(buf
, sizeof(buf
), "ADC_REMOTE: %02x", adc_remote
);
1125 lcd_puts(0, line
++, buf
);
1126 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1127 snprintf(buf
, sizeof(buf
), "ADC_REMOTEDETECT: %02x",
1128 adc_read(ADC_REMOTEDETECT
));
1129 lcd_puts(0, line
++, buf
);
1132 snprintf(buf
, 32, "Batt: %d.%03dV %d%% ", adc_battery_voltage
/ 1000,
1133 adc_battery_voltage
% 1000, adc_battery_level
);
1134 lcd_puts(0, line
++, buf
);
1136 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1137 snprintf(buf
, sizeof(buf
), "remotetype: %d", remote_type());
1138 lcd_puts(0, line
++, buf
);
1142 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1146 #elif defined(CPU_PP502x)
1151 lcd_clear_display();
1152 lcd_setfont(FONT_SYSFIXED
);
1157 lcd_puts(0, line
++, "GPIO STATES:");
1158 snprintf(buf
, sizeof(buf
), "A: %02x E: %02x I: %02x",
1159 (unsigned int)GPIOA_INPUT_VAL
,
1160 (unsigned int)GPIOE_INPUT_VAL
,
1161 (unsigned int)GPIOI_INPUT_VAL
);
1162 lcd_puts(0, line
++, buf
);
1163 snprintf(buf
, sizeof(buf
), "B: %02x F: %02x J: %02x",
1164 (unsigned int)GPIOB_INPUT_VAL
,
1165 (unsigned int)GPIOF_INPUT_VAL
,
1166 (unsigned int)GPIOJ_INPUT_VAL
);
1167 lcd_puts(0, line
++, buf
);
1168 snprintf(buf
, sizeof(buf
), "C: %02x G: %02x K: %02x",
1169 (unsigned int)GPIOC_INPUT_VAL
,
1170 (unsigned int)GPIOG_INPUT_VAL
,
1171 (unsigned int)GPIOK_INPUT_VAL
);
1172 lcd_puts(0, line
++, buf
);
1173 snprintf(buf
, sizeof(buf
), "D: %02x H: %02x L: %02x",
1174 (unsigned int)GPIOD_INPUT_VAL
,
1175 (unsigned int)GPIOH_INPUT_VAL
,
1176 (unsigned int)GPIOL_INPUT_VAL
);
1177 lcd_puts(0, line
++, buf
);
1179 snprintf(buf
, sizeof(buf
), "GPO32_VAL: %08lx", GPO32_VAL
);
1180 lcd_puts(0, line
++, buf
);
1181 snprintf(buf
, sizeof(buf
), "GPO32_EN: %08lx", GPO32_ENABLE
);
1182 lcd_puts(0, line
++, buf
);
1183 snprintf(buf
, sizeof(buf
), "DEV_EN: %08lx", DEV_EN
);
1184 lcd_puts(0, line
++, buf
);
1185 snprintf(buf
, sizeof(buf
), "DEV_EN2: %08lx", DEV_EN2
);
1186 lcd_puts(0, line
++, buf
);
1187 snprintf(buf
, sizeof(buf
), "DEV_EN3: %08lx", inl(0x60006044));
1188 lcd_puts(0, line
++, buf
); /* to be verified */
1189 snprintf(buf
, sizeof(buf
), "DEV_INIT1: %08lx", DEV_INIT1
);
1190 lcd_puts(0, line
++, buf
);
1191 snprintf(buf
, sizeof(buf
), "DEV_INIT2: %08lx", DEV_INIT2
);
1192 lcd_puts(0, line
++, buf
);
1193 #ifdef ADC_ACCESSORY
1194 snprintf(buf
, sizeof(buf
), "ACCESSORY: %d", adc_read(ADC_ACCESSORY
));
1195 lcd_puts(0, line
++, buf
);
1198 #if defined(IPOD_ACCESSORY_PROTOCOL)
1199 extern unsigned char serbuf
[];
1200 snprintf(buf
, sizeof(buf
), "IAP PACKET: %02x %02x %02x %02x %02x %02x %02x %02x",
1201 serbuf
[0], serbuf
[1], serbuf
[2], serbuf
[3], serbuf
[4], serbuf
[5],
1202 serbuf
[6], serbuf
[7]);
1203 lcd_puts(0, line
++, buf
);
1206 #if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
1208 snprintf(buf
, sizeof(buf
), "BATT: %03x UNK1: %03x",
1209 adc_read(ADC_BATTERY
), adc_read(ADC_UNKNOWN_1
));
1210 lcd_puts(0, line
++, buf
);
1211 snprintf(buf
, sizeof(buf
), "REM: %03x PAD: %03x",
1212 adc_read(ADC_REMOTE
), adc_read(ADC_SCROLLPAD
));
1213 lcd_puts(0, line
++, buf
);
1214 #elif defined(SANSA_E200) || defined(PHILIPS_SA9200)
1215 snprintf(buf
, sizeof(buf
), "ADC_BVDD: %4d", adc_read(ADC_BVDD
));
1216 lcd_puts(0, line
++, buf
);
1217 snprintf(buf
, sizeof(buf
), "ADC_RTCSUP: %4d", adc_read(ADC_RTCSUP
));
1218 lcd_puts(0, line
++, buf
);
1219 snprintf(buf
, sizeof(buf
), "ADC_UVDD: %4d", adc_read(ADC_UVDD
));
1220 lcd_puts(0, line
++, buf
);
1221 snprintf(buf
, sizeof(buf
), "ADC_CHG_IN: %4d", adc_read(ADC_CHG_IN
));
1222 lcd_puts(0, line
++, buf
);
1223 snprintf(buf
, sizeof(buf
), "ADC_CVDD: %4d", adc_read(ADC_CVDD
));
1224 lcd_puts(0, line
++, buf
);
1225 snprintf(buf
, sizeof(buf
), "ADC_BATTEMP: %4d", adc_read(ADC_BATTEMP
));
1226 lcd_puts(0, line
++, buf
);
1227 snprintf(buf
, sizeof(buf
), "ADC_MICSUP1: %4d", adc_read(ADC_MICSUP1
));
1228 lcd_puts(0, line
++, buf
);
1229 snprintf(buf
, sizeof(buf
), "ADC_MICSUP2: %4d", adc_read(ADC_MICSUP2
));
1230 lcd_puts(0, line
++, buf
);
1231 snprintf(buf
, sizeof(buf
), "ADC_VBE1: %4d", adc_read(ADC_VBE1
));
1232 lcd_puts(0, line
++, buf
);
1233 snprintf(buf
, sizeof(buf
), "ADC_VBE2: %4d", adc_read(ADC_VBE2
));
1234 lcd_puts(0, line
++, buf
);
1235 snprintf(buf
, sizeof(buf
), "ADC_I_MICSUP1:%4d", adc_read(ADC_I_MICSUP1
));
1236 lcd_puts(0, line
++, buf
);
1237 #if !defined(PHILIPS_SA9200)
1238 snprintf(buf
, sizeof(buf
), "ADC_I_MICSUP2:%4d", adc_read(ADC_I_MICSUP2
));
1239 lcd_puts(0, line
++, buf
);
1240 snprintf(buf
, sizeof(buf
), "ADC_VBAT: %4d", adc_read(ADC_VBAT
));
1241 lcd_puts(0, line
++, buf
);
1242 snprintf(buf
, sizeof(buf
), "CHARGER: %02X/%02X",
1243 ascodec_read(AS3514_CHARGER
),
1244 ascodec_read(AS3514_IRQ_ENRD0
));
1245 lcd_puts(0, line
++, buf
);
1249 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1253 #elif CONFIG_CPU == PP5002
1257 lcd_clear_display();
1258 lcd_setfont(FONT_SYSFIXED
);
1263 snprintf(buf
, sizeof(buf
), "GPIO_A: %02x GPIO_B: %02x",
1264 (unsigned int)GPIOA_INPUT_VAL
, (unsigned int)GPIOB_INPUT_VAL
);
1265 lcd_puts(0, line
++, buf
);
1266 snprintf(buf
, sizeof(buf
), "GPIO_C: %02x GPIO_D: %02x",
1267 (unsigned int)GPIOC_INPUT_VAL
, (unsigned int)GPIOD_INPUT_VAL
);
1268 lcd_puts(0, line
++, buf
);
1270 snprintf(buf
, sizeof(buf
), "DEV_EN: %08lx", DEV_EN
);
1271 lcd_puts(0, line
++, buf
);
1272 snprintf(buf
, sizeof(buf
), "CLOCK_ENABLE: %08lx", CLOCK_ENABLE
);
1273 lcd_puts(0, line
++, buf
);
1274 snprintf(buf
, sizeof(buf
), "CLOCK_SOURCE: %08lx", CLOCK_SOURCE
);
1275 lcd_puts(0, line
++, buf
);
1276 snprintf(buf
, sizeof(buf
), "PLL_CONTROL: %08lx", PLL_CONTROL
);
1277 lcd_puts(0, line
++, buf
);
1278 snprintf(buf
, sizeof(buf
), "PLL_DIV: %08lx", PLL_DIV
);
1279 lcd_puts(0, line
++, buf
);
1280 snprintf(buf
, sizeof(buf
), "PLL_MULT: %08lx", PLL_MULT
);
1281 lcd_puts(0, line
++, buf
);
1282 snprintf(buf
, sizeof(buf
), "TIMING1_CTL: %08lx", TIMING1_CTL
);
1283 lcd_puts(0, line
++, buf
);
1284 snprintf(buf
, sizeof(buf
), "TIMING2_CTL: %08lx", TIMING2_CTL
);
1285 lcd_puts(0, line
++, buf
);
1288 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1292 return __dbg_ports();
1296 #else /* !HAVE_LCD_BITMAP */
1297 bool dbg_ports(void)
1301 int adc_battery_voltage
;
1304 lcd_clear_display();
1311 snprintf(buf
, 32, "PADR: %04x", (unsigned short)PADR
);
1314 snprintf(buf
, 32, "PBDR: %04x", (unsigned short)PBDR
);
1317 snprintf(buf
, 32, "AN0: %03x", adc_read(0));
1320 snprintf(buf
, 32, "AN1: %03x", adc_read(1));
1323 snprintf(buf
, 32, "AN2: %03x", adc_read(2));
1326 snprintf(buf
, 32, "AN3: %03x", adc_read(3));
1329 snprintf(buf
, 32, "AN4: %03x", adc_read(4));
1332 snprintf(buf
, 32, "AN5: %03x", adc_read(5));
1335 snprintf(buf
, 32, "AN6: %03x", adc_read(6));
1338 snprintf(buf
, 32, "AN7: %03x", adc_read(7));
1342 lcd_puts(0, 0, buf
);
1344 battery_read_info(&adc_battery_voltage
, NULL
);
1345 snprintf(buf
, 32, "Batt: %d.%03dV", adc_battery_voltage
/ 1000,
1346 adc_battery_voltage
% 1000);
1347 lcd_puts(0, 1, buf
);
1350 button
= get_action(CONTEXT_SETTINGS
,HZ
/5);
1354 case ACTION_STD_CANCEL
:
1357 case ACTION_SETTINGS_DEC
:
1363 case ACTION_SETTINGS_INC
:
1372 #endif /* !HAVE_LCD_BITMAP */
1373 #endif /* !SIMULATOR */
1375 #if (CONFIG_RTC == RTC_PCF50605) && !defined(SIMULATOR)
1376 static bool dbg_pcf(void)
1381 #ifdef HAVE_LCD_BITMAP
1382 lcd_setfont(FONT_SYSFIXED
);
1384 lcd_clear_display();
1390 snprintf(buf
, sizeof(buf
), "DCDC1: %02x", pcf50605_read(0x1b));
1391 lcd_puts(0, line
++, buf
);
1392 snprintf(buf
, sizeof(buf
), "DCDC2: %02x", pcf50605_read(0x1c));
1393 lcd_puts(0, line
++, buf
);
1394 snprintf(buf
, sizeof(buf
), "DCDC3: %02x", pcf50605_read(0x1d));
1395 lcd_puts(0, line
++, buf
);
1396 snprintf(buf
, sizeof(buf
), "DCDC4: %02x", pcf50605_read(0x1e));
1397 lcd_puts(0, line
++, buf
);
1398 snprintf(buf
, sizeof(buf
), "DCDEC1: %02x", pcf50605_read(0x1f));
1399 lcd_puts(0, line
++, buf
);
1400 snprintf(buf
, sizeof(buf
), "DCDEC2: %02x", pcf50605_read(0x20));
1401 lcd_puts(0, line
++, buf
);
1402 snprintf(buf
, sizeof(buf
), "DCUDC1: %02x", pcf50605_read(0x21));
1403 lcd_puts(0, line
++, buf
);
1404 snprintf(buf
, sizeof(buf
), "DCUDC2: %02x", pcf50605_read(0x22));
1405 lcd_puts(0, line
++, buf
);
1406 snprintf(buf
, sizeof(buf
), "IOREGC: %02x", pcf50605_read(0x23));
1407 lcd_puts(0, line
++, buf
);
1408 snprintf(buf
, sizeof(buf
), "D1REGC: %02x", pcf50605_read(0x24));
1409 lcd_puts(0, line
++, buf
);
1410 snprintf(buf
, sizeof(buf
), "D2REGC: %02x", pcf50605_read(0x25));
1411 lcd_puts(0, line
++, buf
);
1412 snprintf(buf
, sizeof(buf
), "D3REGC: %02x", pcf50605_read(0x26));
1413 lcd_puts(0, line
++, buf
);
1414 snprintf(buf
, sizeof(buf
), "LPREG1: %02x", pcf50605_read(0x27));
1415 lcd_puts(0, line
++, buf
);
1418 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1428 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
1429 static bool dbg_cpufreq(void)
1435 #ifdef HAVE_LCD_BITMAP
1436 lcd_setfont(FONT_SYSFIXED
);
1438 lcd_clear_display();
1444 snprintf(buf
, sizeof(buf
), "Frequency: %ld", FREQ
);
1445 lcd_puts(0, line
++, buf
);
1447 snprintf(buf
, sizeof(buf
), "boost_counter: %d", get_cpu_boost_counter());
1448 lcd_puts(0, line
++, buf
);
1451 button
= get_action(CONTEXT_STD
,HZ
/10);
1455 case ACTION_STD_PREV
:
1459 case ACTION_STD_NEXT
:
1464 while (get_cpu_boost_counter() > 0)
1466 set_cpu_frequency(CPUFREQ_DEFAULT
);
1469 case ACTION_STD_CANCEL
:
1476 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
1478 #if defined(HAVE_TSC2100) && !defined(SIMULATOR)
1479 #include "tsc2100.h"
1480 static char *itob(int n
, int len
)
1482 static char binary
[64];
1484 for (i
=1, j
=0;i
<=len
;i
++)
1486 binary
[j
++] = n
&(1<<(len
-i
))?'1':'0';
1493 static char* tsc2100_debug_getname(int selected_item
, void * data
,
1494 char *buffer
, size_t buffer_len
)
1496 int *page
= (int*)data
;
1497 bool reserved
= false;
1501 if ((selected_item
> 0x0a) ||
1502 (selected_item
== 0x04) ||
1503 (selected_item
== 0x08))
1507 if ((selected_item
> 0x05) ||
1508 (selected_item
== 0x02))
1512 if (selected_item
> 0x1e)
1517 snprintf(buffer
, buffer_len
, "%02x: RESERVED", selected_item
);
1519 snprintf(buffer
, buffer_len
, "%02x: %s", selected_item
,
1520 itob(tsc2100_readreg(*page
, selected_item
)&0xffff,16));
1523 static int tsc2100debug_action_callback(int action
, struct gui_synclist
*lists
)
1525 int *page
= (int*)lists
->data
;
1526 if (action
== ACTION_STD_OK
)
1528 *page
= (*page
+1)%3;
1529 snprintf(lists
->title
, 32,
1530 "tsc2100 registers - Page %d", *page
);
1531 return ACTION_REDRAW
;
1535 static bool tsc2100_debug(void)
1538 char title
[32] = "tsc2100 registers - Page 0";
1539 struct simplelist_info info
;
1540 simplelist_info_init(&info
, title
, 32, &page
);
1541 info
.timeout
= HZ
/100;
1542 info
.get_name
= tsc2100_debug_getname
;
1543 info
.action_callback
= tsc2100debug_action_callback
;
1544 return simplelist_show_list(&info
);
1548 #ifdef HAVE_LCD_BITMAP
1550 * view_battery() shows a automatically scaled graph of the battery voltage
1551 * over time. Usable for estimating battery life / charging rate.
1552 * The power_history array is updated in power_thread of powermgmt.c.
1555 #define BAT_LAST_VAL MIN(LCD_WIDTH, POWER_HISTORY_LEN)
1556 #define BAT_YSPACE (LCD_HEIGHT - 20)
1558 static bool view_battery(void)
1562 unsigned short maxv
, minv
;
1565 lcd_setfont(FONT_SYSFIXED
);
1569 lcd_clear_display();
1571 case 0: /* voltage history graph */
1572 /* Find maximum and minimum voltage for scaling */
1573 minv
= power_history
[0];
1575 for (i
= 1; i
< BAT_LAST_VAL
&& power_history
[i
]; i
++) {
1576 if (power_history
[i
] > maxv
)
1577 maxv
= power_history
[i
];
1578 if (power_history
[i
] < minv
)
1579 minv
= power_history
[i
];
1582 snprintf(buf
, 30, "Battery %d.%03d", power_history
[0] / 1000,
1583 power_history
[0] % 1000);
1584 lcd_puts(0, 0, buf
);
1585 snprintf(buf
, 30, "scale %d.%03d-%d.%03dV",
1586 minv
/ 1000, minv
% 1000, maxv
/ 1000, maxv
% 1000);
1587 lcd_puts(0, 1, buf
);
1590 for (i
= BAT_LAST_VAL
- 1; i
>= 0; i
--) {
1591 y
= (power_history
[i
] - minv
) * BAT_YSPACE
/ (maxv
- minv
);
1592 lcd_set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
1593 lcd_vline(x
, LCD_HEIGHT
-1, 20);
1594 lcd_set_drawmode(DRMODE_SOLID
);
1595 lcd_vline(x
, LCD_HEIGHT
-1,
1596 MIN(MAX(LCD_HEIGHT
-1 - y
, 20), LCD_HEIGHT
-1));
1602 case 1: /* status: */
1603 lcd_puts(0, 0, "Power status:");
1605 battery_read_info(&y
, NULL
);
1606 snprintf(buf
, 30, "Battery: %d.%03d V", y
/ 1000, y
% 1000);
1607 lcd_puts(0, 1, buf
);
1608 #ifdef ADC_EXT_POWER
1609 y
= (adc_read(ADC_EXT_POWER
) * EXT_SCALE_FACTOR
) / 1000;
1610 snprintf(buf
, 30, "External: %d.%03d V", y
/ 1000, y
% 1000);
1611 lcd_puts(0, 2, buf
);
1614 #if defined ARCHOS_RECORDER
1615 snprintf(buf
, 30, "Chgr: %s %s",
1616 charger_inserted() ? "present" : "absent",
1617 charger_enabled() ? "on" : "off");
1618 lcd_puts(0, 3, buf
);
1619 snprintf(buf
, 30, "short delta: %d", short_delta
);
1620 lcd_puts(0, 5, buf
);
1621 snprintf(buf
, 30, "long delta: %d", long_delta
);
1622 lcd_puts(0, 6, buf
);
1623 lcd_puts(0, 7, power_message
);
1624 snprintf(buf
, 30, "USB Inserted: %s",
1625 usb_inserted() ? "yes" : "no");
1626 lcd_puts(0, 8, buf
);
1627 #elif defined IRIVER_H300_SERIES
1628 snprintf(buf
, 30, "USB Charging Enabled: %s",
1629 usb_charging_enabled() ? "yes" : "no");
1630 lcd_puts(0, 9, buf
);
1631 #elif 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
);
1653 #elif defined TOSHIBA_GIGABEAT_S
1657 static const unsigned char * const chrgstate_strings
[] =
1668 snprintf(buf
, 30, "Charger: %s",
1669 charger_inserted() ? "present" : "absent");
1670 lcd_puts(0, line
++, buf
);
1672 st
= power_input_status() &
1673 (POWER_INPUT_CHARGER
| POWER_INPUT_BATTERY
);
1674 snprintf(buf
, 30, "%s%s",
1675 (st
& POWER_INPUT_MAIN_CHARGER
) ? " Main" : "",
1676 (st
& POWER_INPUT_USB_CHARGER
) ? " USB" : "");
1677 lcd_puts(0, line
++, buf
);
1679 snprintf(buf
, 30, "IUSB Max: %d", usb_allowed_current());
1680 lcd_puts(0, line
++, buf
);
1682 y
= ARRAYLEN(chrgstate_strings
) - 1;
1684 switch (charge_state
)
1686 case CHARGE_STATE_DISABLED
: y
--;
1687 case CHARGE_STATE_ERROR
: y
--;
1688 case DISCHARGING
: y
--;
1695 snprintf(buf
, 30, "State: %s", chrgstate_strings
[y
]);
1696 lcd_puts(0, line
++, buf
);
1698 snprintf(buf
, 30, "Battery Switch: %s",
1699 (st
& POWER_INPUT_BATTERY
) ? "On" : "Off");
1700 lcd_puts(0, line
++, buf
);
1702 y
= chrgraw_adc_voltage();
1703 snprintf(buf
, 30, "CHRGRAW: %d.%03d V",
1704 y
/ 1000, y
% 1000);
1705 lcd_puts(0, line
++, buf
);
1707 y
= application_supply_adc_voltage();
1708 snprintf(buf
, 30, "BP : %d.%03d V",
1709 y
/ 1000, y
% 1000);
1710 lcd_puts(0, line
++, buf
);
1712 y
= battery_adc_charge_current();
1713 if (y
< 0) x
= '-', y
= -y
;
1715 snprintf(buf
, 30, "CHRGISN:%c%d mA", x
, y
);
1716 lcd_puts(0, line
++, buf
);
1718 y
= cccv_regulator_dissipation();
1719 snprintf(buf
, 30, "P CCCV : %d mW", y
);
1720 lcd_puts(0, line
++, buf
);
1722 y
= battery_charge_current();
1723 if (y
< 0) x
= '-', y
= -y
;
1725 snprintf(buf
, 30, "I Charge:%c%d mA", x
, y
);
1726 lcd_puts(0, line
++, buf
);
1728 y
= battery_adc_temp();
1731 snprintf(buf
, 30, "T Battery: %dC (%dF)", y
,
1734 /* Conversion disabled */
1735 snprintf(buf
, 30, "T Battery: ?");
1738 lcd_puts(0, line
++, buf
);
1740 snprintf(buf
, 30, "Charger: %s",
1741 charger_inserted() ? "present" : "absent");
1742 lcd_puts(0, 3, buf
);
1743 #endif /* target type */
1744 #endif /* CONFIG_CHARGING */
1747 case 2: /* voltage deltas: */
1748 lcd_puts(0, 0, "Voltage deltas:");
1750 for (i
= 0; i
<= 6; i
++) {
1751 y
= power_history
[i
] - power_history
[i
+1];
1752 snprintf(buf
, 30, "-%d min: %s%d.%03d V", i
,
1753 (y
< 0) ? "-" : "", ((y
< 0) ? y
* -1 : y
) / 1000,
1754 ((y
< 0) ? y
* -1 : y
) % 1000);
1755 lcd_puts(0, i
+1, buf
);
1759 case 3: /* remaining time estimation: */
1761 #ifdef ARCHOS_RECORDER
1762 snprintf(buf
, 30, "charge_state: %d", charge_state
);
1763 lcd_puts(0, 0, buf
);
1765 snprintf(buf
, 30, "Cycle time: %d m", powermgmt_last_cycle_startstop_min
);
1766 lcd_puts(0, 1, buf
);
1768 snprintf(buf
, 30, "Lvl@cyc st: %d%%", powermgmt_last_cycle_level
);
1769 lcd_puts(0, 2, buf
);
1771 snprintf(buf
, 30, "P=%2d I=%2d", pid_p
, pid_i
);
1772 lcd_puts(0, 3, buf
);
1774 snprintf(buf
, 30, "Trickle sec: %d/60", trickle_sec
);
1775 lcd_puts(0, 4, buf
);
1776 #endif /* ARCHOS_RECORDER */
1778 snprintf(buf
, 30, "Last PwrHist: %d.%03dV",
1779 power_history
[0] / 1000,
1780 power_history
[0] % 1000);
1781 lcd_puts(0, 5, buf
);
1783 snprintf(buf
, 30, "battery level: %d%%", battery_level());
1784 lcd_puts(0, 6, buf
);
1786 snprintf(buf
, 30, "Est. remain: %d m", battery_time());
1787 lcd_puts(0, 7, buf
);
1793 switch(get_action(CONTEXT_STD
,HZ
/2))
1795 case ACTION_STD_PREV
:
1800 case ACTION_STD_NEXT
:
1805 case ACTION_STD_CANCEL
:
1812 #endif /* HAVE_LCD_BITMAP */
1816 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
1818 #if (CONFIG_STORAGE & STORAGE_MMC)
1819 #define CARDTYPE "MMC"
1820 #elif (CONFIG_STORAGE & STORAGE_SD)
1821 #define CARDTYPE "microSD"
1824 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1827 int *cardnum
= (int*)lists
->data
;
1828 unsigned char card_name
[7];
1829 unsigned char pbuf
[32];
1830 char *title
= lists
->title
;
1831 static const unsigned char i_vmin
[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
1832 static const unsigned char i_vmax
[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
1833 static const unsigned char *kbit_units
[] = { "kBit/s", "MBit/s", "GBit/s" };
1834 static const unsigned char *nsec_units
[] = { "ns", "µs", "ms" };
1835 static const char *spec_vers
[] = { "1.0-1.2", "1.4", "2.0-2.2",
1836 "3.1-3.31", "4.0" };
1837 if ((btn
== ACTION_STD_OK
) || (btn
== SYS_FS_CHANGED
) || (btn
== ACTION_REDRAW
))
1840 if (btn
== ACTION_STD_OK
)
1842 *cardnum
^= 0x1; /* change cards */
1846 simplelist_set_line_count(0);
1848 card
= card_get_info(*cardnum
);
1850 if (card
->initialized
> 0)
1852 card_name
[6] = '\0';
1853 strncpy(card_name
, ((unsigned char*)card
->cid
) + 3, 6);
1854 simplelist_addline(SIMPLELIST_ADD_LINE
,
1855 "%s Rev %d.%d", card_name
,
1856 (int) card_extract_bits(card
->cid
, 72, 4),
1857 (int) card_extract_bits(card
->cid
, 76, 4));
1858 simplelist_addline(SIMPLELIST_ADD_LINE
,
1860 (int) card_extract_bits(card
->cid
, 112, 4),
1861 (int) card_extract_bits(card
->cid
, 116, 4) + 1997);
1862 simplelist_addline(SIMPLELIST_ADD_LINE
,
1864 card_extract_bits(card
->cid
, 80, 32));
1865 simplelist_addline(SIMPLELIST_ADD_LINE
,
1867 (int) card_extract_bits(card
->cid
, 0, 8),
1868 (int) card_extract_bits(card
->cid
, 8, 16));
1869 int temp
= card_extract_bits(card
->csd
, 2, 4);
1870 simplelist_addline(SIMPLELIST_ADD_LINE
,
1871 CARDTYPE
" v%s", temp
< 5 ?
1872 spec_vers
[temp
] : "?.?");
1873 simplelist_addline(SIMPLELIST_ADD_LINE
,
1874 "Blocks: 0x%08lx", card
->numblocks
);
1875 output_dyn_value(pbuf
, sizeof pbuf
, card
->speed
/ 1000,
1877 simplelist_addline(SIMPLELIST_ADD_LINE
,
1879 output_dyn_value(pbuf
, sizeof pbuf
, card
->tsac
,
1881 simplelist_addline(SIMPLELIST_ADD_LINE
,
1883 simplelist_addline(SIMPLELIST_ADD_LINE
,
1884 "Nsac: %d clk", card
->nsac
);
1885 simplelist_addline(SIMPLELIST_ADD_LINE
,
1886 "R2W: *%d", card
->r2w_factor
);
1887 simplelist_addline(SIMPLELIST_ADD_LINE
,
1889 i_vmin
[card_extract_bits(card
->csd
, 66, 3)],
1890 i_vmax
[card_extract_bits(card
->csd
, 69, 3)]);
1891 simplelist_addline(SIMPLELIST_ADD_LINE
,
1893 i_vmin
[card_extract_bits(card
->csd
, 72, 3)],
1894 i_vmax
[card_extract_bits(card
->csd
, 75, 3)]);
1896 else if (card
->initialized
== 0)
1898 simplelist_addline(SIMPLELIST_ADD_LINE
, "Not Found!");
1900 #if (CONFIG_STORAGE & STORAGE_SD)
1901 else /* card->initialized < 0 */
1903 simplelist_addline(SIMPLELIST_ADD_LINE
, "Init Error! (%d)", card
->initialized
);
1906 snprintf(title
, 16, "[" CARDTYPE
" %d]", *cardnum
);
1907 gui_synclist_set_title(lists
, title
, Icon_NOICON
);
1908 gui_synclist_set_nb_items(lists
, simplelist_get_line_count());
1909 gui_synclist_select_item(lists
, 0);
1910 btn
= ACTION_REDRAW
;
1914 #elif (CONFIG_STORAGE & STORAGE_ATA)
1915 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1920 unsigned short* identify_info
= ata_get_identify();
1921 bool timing_info_present
= false;
1924 simplelist_set_line_count(0);
1926 for (i
=0; i
< 20; i
++)
1927 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+27]);
1929 /* kill trailing space */
1930 for (i
=39; i
&& buf
[i
]==' '; i
--)
1932 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", buf
);
1933 for (i
=0; i
< 4; i
++)
1934 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+23]);
1936 simplelist_addline(SIMPLELIST_ADD_LINE
,
1937 "Firmware: %s", buf
);
1938 snprintf(buf
, sizeof buf
, "%ld MB",
1939 ((unsigned long)identify_info
[61] << 16 |
1940 (unsigned long)identify_info
[60]) / 2048 );
1941 simplelist_addline(SIMPLELIST_ADD_LINE
,
1944 fat_size( IF_MV2(0,) NULL
, &free
);
1945 simplelist_addline(SIMPLELIST_ADD_LINE
,
1946 "Free: %ld MB", free
/ 1024);
1947 simplelist_addline(SIMPLELIST_ADD_LINE
,
1948 "Spinup time: %d ms", storage_spinup_time() * (1000/HZ
));
1949 i
= identify_info
[83] & (1<<3);
1950 simplelist_addline(SIMPLELIST_ADD_LINE
,
1951 "Power mgmt: %s", i
? "enabled" : "unsupported");
1952 i
= identify_info
[83] & (1<<9);
1953 simplelist_addline(SIMPLELIST_ADD_LINE
,
1954 "Noise mgmt: %s", i
? "enabled" : "unsupported");
1955 i
= identify_info
[82] & (1<<6);
1956 simplelist_addline(SIMPLELIST_ADD_LINE
,
1957 "Read-ahead: %s", i
? "enabled" : "unsupported");
1958 timing_info_present
= identify_info
[53] & (1<<1);
1959 if(timing_info_present
) {
1960 char pio3
[2], pio4
[2];pio3
[1] = 0;
1962 pio3
[0] = (identify_info
[64] & (1<<0)) ? '3' : 0;
1963 pio4
[0] = (identify_info
[64] & (1<<1)) ? '4' : 0;
1964 simplelist_addline(SIMPLELIST_ADD_LINE
,
1965 "PIO modes: 0 1 2 %s %s", pio3
, pio4
);
1968 simplelist_addline(SIMPLELIST_ADD_LINE
,
1969 "No PIO mode info");
1971 timing_info_present
= identify_info
[53] & (1<<1);
1972 if(timing_info_present
) {
1973 simplelist_addline(SIMPLELIST_ADD_LINE
,
1974 "Cycle times %dns/%dns",
1976 identify_info
[68] );
1978 simplelist_addline(SIMPLELIST_ADD_LINE
,
1981 #if defined (TOSHIBA_GIGABEAT_F) || defined (TOSHIBA_GIGABEAT_S)
1982 if (identify_info
[63] & (1<<0)) {
1983 char mdma0
[2], mdma1
[2], mdma2
[2];
1984 mdma0
[1] = mdma1
[1] = mdma2
[1] = 0;
1985 mdma0
[0] = (identify_info
[63] & (1<<0)) ? '0' : 0;
1986 mdma1
[0] = (identify_info
[63] & (1<<1)) ? '1' : 0;
1987 mdma2
[0] = (identify_info
[63] & (1<<2)) ? '2' : 0;
1988 simplelist_addline(SIMPLELIST_ADD_LINE
,
1989 "MDMA modes: %s %s %s", mdma0
, mdma1
, mdma2
);
1990 simplelist_addline(SIMPLELIST_ADD_LINE
,
1991 "MDMA Cycle times %dns/%dns",
1993 identify_info
[66] );
1996 simplelist_addline(SIMPLELIST_ADD_LINE
,
1997 "No MDMA mode info");
1999 if (identify_info
[88] & (1<<0)) {
2000 char udma0
[2], udma1
[2], udma2
[2], udma3
[2], udma4
[2], udma5
[2];
2001 udma0
[1] = udma1
[1] = udma2
[1] = udma3
[1] = udma4
[1] = udma5
[1] = 0;
2002 udma0
[0] = (identify_info
[88] & (1<<0)) ? '0' : 0;
2003 udma1
[0] = (identify_info
[88] & (1<<1)) ? '1' : 0;
2004 udma2
[0] = (identify_info
[88] & (1<<2)) ? '2' : 0;
2005 udma3
[0] = (identify_info
[88] & (1<<3)) ? '3' : 0;
2006 udma4
[0] = (identify_info
[88] & (1<<4)) ? '4' : 0;
2007 udma5
[0] = (identify_info
[88] & (1<<5)) ? '5' : 0;
2008 simplelist_addline(SIMPLELIST_ADD_LINE
,
2009 "UDMA modes: %s %s %s %s %s %s", udma0
, udma1
, udma2
,
2010 udma3
, udma4
, udma5
);
2013 simplelist_addline(SIMPLELIST_ADD_LINE
,
2014 "No UDMA mode info");
2016 #endif /* defined (TOSHIBA_GIGABEAT_F) || defined (TOSHIBA_GIGABEAT_S) */
2017 timing_info_present
= identify_info
[53] & (1<<1);
2018 if(timing_info_present
) {
2019 i
= identify_info
[49] & (1<<11);
2020 simplelist_addline(SIMPLELIST_ADD_LINE
,
2021 "IORDY support: %s", i
? "yes" : "no");
2022 i
= identify_info
[49] & (1<<10);
2023 simplelist_addline(SIMPLELIST_ADD_LINE
,
2024 "IORDY disable: %s", i
? "yes" : "no");
2026 simplelist_addline(SIMPLELIST_ADD_LINE
,
2029 simplelist_addline(SIMPLELIST_ADD_LINE
,
2030 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
2033 #else /* No SD, MMC or ATA */
2034 static int disk_callback(int btn
, struct gui_synclist
*lists
)
2038 struct storage_info info
;
2039 storage_get_info(0,&info
);
2040 simplelist_addline(SIMPLELIST_ADD_LINE
, "Vendor: %s", info
.vendor
);
2041 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", info
.product
);
2042 simplelist_addline(SIMPLELIST_ADD_LINE
, "Firmware: %s", info
.revision
);
2043 simplelist_addline(SIMPLELIST_ADD_LINE
,
2044 "Size: %ld MB", info
.num_sectors
*(info
.sector_size
/512)/2024);
2046 fat_size( IF_MV2(0,) NULL
, &free
);
2047 simplelist_addline(SIMPLELIST_ADD_LINE
,
2048 "Free: %ld MB", free
/ 1024);
2049 simplelist_addline(SIMPLELIST_ADD_LINE
,
2050 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
2055 #if (CONFIG_STORAGE & STORAGE_ATA)
2056 static bool dbg_identify_info(void)
2058 int fd
= creat("/identify_info.bin");
2061 #ifdef ROCKBOX_LITTLE_ENDIAN
2062 ecwrite(fd
, ata_get_identify(), SECTOR_SIZE
/2, "s", true);
2064 write(fd
, ata_get_identify(), SECTOR_SIZE
);
2072 static bool dbg_disk_info(void)
2074 struct simplelist_info info
;
2075 simplelist_info_init(&info
, "Disk Info", 1, NULL
);
2076 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
2079 info
.callback_data
= (void*)&card
;
2082 info
.action_callback
= disk_callback
;
2083 info
.hide_selection
= true;
2084 info
.scroll_all
= true;
2085 return simplelist_show_list(&info
);
2087 #endif /* !SIMULATOR */
2089 #ifdef HAVE_DIRCACHE
2090 static int dircache_callback(int btn
, struct gui_synclist
*lists
)
2092 (void)btn
; (void)lists
;
2093 simplelist_set_line_count(0);
2094 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache initialized: %s",
2095 dircache_is_enabled() ? "Yes" : "No");
2096 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache size: %d B",
2097 dircache_get_cache_size());
2098 simplelist_addline(SIMPLELIST_ADD_LINE
, "Last size: %d B",
2099 global_status
.dircache_size
);
2100 simplelist_addline(SIMPLELIST_ADD_LINE
, "Limit: %d B",
2102 simplelist_addline(SIMPLELIST_ADD_LINE
, "Reserve: %d/%d B",
2103 dircache_get_reserve_used(), DIRCACHE_RESERVE
);
2104 simplelist_addline(SIMPLELIST_ADD_LINE
, "Scanning took: %d s",
2105 dircache_get_build_ticks() / HZ
);
2106 simplelist_addline(SIMPLELIST_ADD_LINE
, "Entry count: %d",
2107 dircache_get_entry_count());
2111 static bool dbg_dircache_info(void)
2113 struct simplelist_info info
;
2114 simplelist_info_init(&info
, "Dircache Info", 7, NULL
);
2115 info
.action_callback
= dircache_callback
;
2116 info
.hide_selection
= true;
2117 info
.scroll_all
= true;
2118 return simplelist_show_list(&info
);
2121 #endif /* HAVE_DIRCACHE */
2123 #ifdef HAVE_TAGCACHE
2124 static int database_callback(int btn
, struct gui_synclist
*lists
)
2127 struct tagcache_stat
*stat
= tagcache_get_stat();
2128 static bool synced
= false;
2130 simplelist_set_line_count(0);
2132 simplelist_addline(SIMPLELIST_ADD_LINE
, "Initialized: %s",
2133 stat
->initialized
? "Yes" : "No");
2134 simplelist_addline(SIMPLELIST_ADD_LINE
, "DB Ready: %s",
2135 stat
->ready
? "Yes" : "No");
2136 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM Cache: %s",
2137 stat
->ramcache
? "Yes" : "No");
2138 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM: %d/%d B",
2139 stat
->ramcache_used
, stat
->ramcache_allocated
);
2140 simplelist_addline(SIMPLELIST_ADD_LINE
, "Progress: %d%% (%d entries)",
2141 stat
->progress
, stat
->processed_entries
);
2142 simplelist_addline(SIMPLELIST_ADD_LINE
, "Curfile: %s",
2143 stat
->curentry
? stat
->curentry
: "---");
2144 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit step: %d",
2146 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit delayed: %s",
2147 stat
->commit_delayed
? "Yes" : "No");
2149 simplelist_addline(SIMPLELIST_ADD_LINE
, "Queue length: %d",
2150 stat
->queue_length
);
2155 tagcache_screensync_event();
2158 if (!btn
&& stat
->curentry
)
2161 return ACTION_REDRAW
;
2164 if (btn
== ACTION_STD_CANCEL
)
2165 tagcache_screensync_enable(false);
2169 static bool dbg_tagcache_info(void)
2171 struct simplelist_info info
;
2172 simplelist_info_init(&info
, "Database Info", 8, NULL
);
2173 info
.action_callback
= database_callback
;
2174 info
.hide_selection
= true;
2175 info
.scroll_all
= true;
2177 /* Don't do nonblock here, must give enough processing time
2178 for tagcache thread. */
2179 /* info.timeout = TIMEOUT_NOBLOCK; */
2181 tagcache_screensync_enable(true);
2182 return simplelist_show_list(&info
);
2186 #if CONFIG_CPU == SH7034
2187 static bool dbg_save_roms(void)
2190 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
2192 fd
= creat("/internal_rom_0000-FFFF.bin");
2195 write(fd
, (void *)0, 0x10000);
2199 fd
= creat("/internal_rom_2000000-203FFFF.bin");
2202 write(fd
, (void *)0x2000000, 0x40000);
2206 system_memory_guard(oldmode
);
2209 #elif defined CPU_COLDFIRE
2210 static bool dbg_save_roms(void)
2213 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
2215 #if defined(IRIVER_H100_SERIES)
2216 fd
= creat("/internal_rom_000000-1FFFFF.bin");
2217 #elif defined(IRIVER_H300_SERIES)
2218 fd
= creat("/internal_rom_000000-3FFFFF.bin");
2219 #elif defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IAUDIO_M3)
2220 fd
= creat("/internal_rom_000000-3FFFFF.bin");
2224 write(fd
, (void *)0, FLASH_SIZE
);
2227 system_memory_guard(oldmode
);
2230 fd
= creat("/internal_eeprom.bin");
2234 char buf
[EEPROM_SIZE
];
2237 old_irq_level
= disable_irq_save();
2239 err
= eeprom_24cxx_read(0, buf
, sizeof buf
);
2241 restore_irq(old_irq_level
);
2244 splashf(HZ
*3, "Eeprom read failure (%d)", err
);
2247 write(fd
, buf
, sizeof buf
);
2256 #elif defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD)
2257 static bool dbg_save_roms(void)
2261 fd
= creat("/internal_rom_000000-0FFFFF.bin");
2264 write(fd
, (void *)0x20000000, FLASH_SIZE
);
2274 static int radio_callback(int btn
, struct gui_synclist
*lists
)
2277 if (btn
== ACTION_STD_CANCEL
)
2279 simplelist_set_line_count(1);
2281 #if (CONFIG_TUNER & LV24020LP)
2282 simplelist_addline(SIMPLELIST_ADD_LINE
,
2283 "CTRL_STAT: %02X", lv24020lp_get(LV24020LP_CTRL_STAT
) );
2284 simplelist_addline(SIMPLELIST_ADD_LINE
,
2285 "RADIO_STAT: %02X", lv24020lp_get(LV24020LP_REG_STAT
) );
2286 simplelist_addline(SIMPLELIST_ADD_LINE
,
2287 "MSS_FM: %d kHz", lv24020lp_get(LV24020LP_MSS_FM
) );
2288 simplelist_addline(SIMPLELIST_ADD_LINE
,
2289 "MSS_IF: %d Hz", lv24020lp_get(LV24020LP_MSS_IF
) );
2290 simplelist_addline(SIMPLELIST_ADD_LINE
,
2291 "MSS_SD: %d Hz", lv24020lp_get(LV24020LP_MSS_SD
) );
2292 simplelist_addline(SIMPLELIST_ADD_LINE
,
2293 "if_set: %d Hz", lv24020lp_get(LV24020LP_IF_SET
) );
2294 simplelist_addline(SIMPLELIST_ADD_LINE
,
2295 "sd_set: %d Hz", lv24020lp_get(LV24020LP_SD_SET
) );
2296 #endif /* LV24020LP */
2297 #if (CONFIG_TUNER & S1A0903X01)
2298 simplelist_addline(SIMPLELIST_ADD_LINE
,
2299 "Samsung regs: %08X", s1a0903x01_get(RADIO_ALL
));
2300 /* This one doesn't return dynamic data atm */
2301 #endif /* S1A0903X01 */
2302 #if (CONFIG_TUNER & TEA5767)
2303 struct tea5767_dbg_info nfo
;
2304 tea5767_dbg_info(&nfo
);
2305 simplelist_addline(SIMPLELIST_ADD_LINE
, "Philips regs:");
2306 simplelist_addline(SIMPLELIST_ADD_LINE
,
2307 " Read: %02X %02X %02X %02X %02X",
2308 (unsigned)nfo
.read_regs
[0], (unsigned)nfo
.read_regs
[1],
2309 (unsigned)nfo
.read_regs
[2], (unsigned)nfo
.read_regs
[3],
2310 (unsigned)nfo
.read_regs
[4]);
2311 simplelist_addline(SIMPLELIST_ADD_LINE
,
2312 " Write: %02X %02X %02X %02X %02X",
2313 (unsigned)nfo
.write_regs
[0], (unsigned)nfo
.write_regs
[1],
2314 (unsigned)nfo
.write_regs
[2], (unsigned)nfo
.write_regs
[3],
2315 (unsigned)nfo
.write_regs
[4]);
2316 #endif /* TEA5767 */
2317 #if (CONFIG_TUNER & SI4700)
2318 struct si4700_dbg_info nfo
;
2319 si4700_dbg_info(&nfo
);
2320 simplelist_addline(SIMPLELIST_ADD_LINE
, "SI4700 regs:");
2322 simplelist_addline(SIMPLELIST_ADD_LINE
,
2323 "%04X %04X %04X %04X",
2324 (unsigned)nfo
.regs
[0], (unsigned)nfo
.regs
[1],
2325 (unsigned)nfo
.regs
[2], (unsigned)nfo
.regs
[3]);
2326 simplelist_addline(SIMPLELIST_ADD_LINE
,
2327 "%04X %04X %04X %04X",
2328 (unsigned)nfo
.regs
[4], (unsigned)nfo
.regs
[5],
2329 (unsigned)nfo
.regs
[6], (unsigned)nfo
.regs
[7]);
2330 simplelist_addline(SIMPLELIST_ADD_LINE
,
2331 "%04X %04X %04X %04X",
2332 (unsigned)nfo
.regs
[8], (unsigned)nfo
.regs
[9],
2333 (unsigned)nfo
.regs
[10], (unsigned)nfo
.regs
[11]);
2334 simplelist_addline(SIMPLELIST_ADD_LINE
,
2335 "%04X %04X %04X %04X",
2336 (unsigned)nfo
.regs
[12], (unsigned)nfo
.regs
[13],
2337 (unsigned)nfo
.regs
[14], (unsigned)nfo
.regs
[15]);
2339 return ACTION_REDRAW
;
2341 static bool dbg_fm_radio(void)
2343 struct simplelist_info info
;
2344 info
.scroll_all
= true;
2345 simplelist_info_init(&info
, "FM Radio", 1, NULL
);
2346 simplelist_set_line_count(0);
2347 simplelist_addline(SIMPLELIST_ADD_LINE
, "HW detected: %s",
2348 radio_hardware_present() ? "yes" : "no");
2350 info
.action_callback
= radio_hardware_present()?radio_callback
: NULL
;
2351 info
.hide_selection
= true;
2352 return simplelist_show_list(&info
);
2354 #endif /* CONFIG_TUNER */
2355 #endif /* !SIMULATOR */
2357 #ifdef HAVE_LCD_BITMAP
2358 extern bool do_screendump_instead_of_usb
;
2360 static bool dbg_screendump(void)
2362 do_screendump_instead_of_usb
= !do_screendump_instead_of_usb
;
2363 splashf(HZ
, "Screendump %s",
2364 do_screendump_instead_of_usb
?"enabled":"disabled");
2367 #endif /* HAVE_LCD_BITMAP */
2369 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2370 static bool dbg_set_memory_guard(void)
2372 static const struct opt_items names
[MAXMEMGUARD
] = {
2374 { "Flash ROM writes", -1 },
2375 { "Zero area (all)", -1 }
2377 int mode
= system_memory_guard(MEMGUARD_KEEP
);
2379 set_option( "Catch mem accesses", &mode
, INT
, names
, MAXMEMGUARD
, NULL
);
2380 system_memory_guard(mode
);
2384 #endif /* CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) */
2386 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2387 static bool dbg_write_eeprom(void)
2392 char buf
[EEPROM_SIZE
];
2395 fd
= open("/internal_eeprom.bin", O_RDONLY
);
2399 rc
= read(fd
, buf
, EEPROM_SIZE
);
2401 if(rc
== EEPROM_SIZE
)
2403 old_irq_level
= disable_irq_save();
2405 err
= eeprom_24cxx_write(0, buf
, sizeof buf
);
2407 splashf(HZ
*3, "Eeprom write failure (%d)", err
);
2409 splash(HZ
*3, "Eeprom written successfully");
2411 restore_irq(old_irq_level
);
2415 splashf(HZ
*3, "File read error (%d)",rc
);
2421 splash(HZ
*3, "Failed to open 'internal_eeprom.bin'");
2426 #endif /* defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS) */
2427 #ifdef CPU_BOOST_LOGGING
2428 static bool cpu_boost_log(void)
2431 int count
= cpu_boost_log_getcount();
2432 int lines
= LCD_HEIGHT
/SYSFONT_HEIGHT
;
2435 lcd_setfont(FONT_SYSFIXED
);
2436 str
= cpu_boost_log_getlog_first();
2439 lcd_clear_display();
2440 for(j
=0; j
<lines
; j
++,i
++)
2443 str
= cpu_boost_log_getlog_next();
2454 switch(get_action(CONTEXT_STD
,TIMEOUT_BLOCK
))
2457 case ACTION_STD_PREV
:
2458 case ACTION_STD_NEXT
:
2461 case ACTION_STD_CANCEL
:
2468 get_action(CONTEXT_STD
,TIMEOUT_BLOCK
);
2469 lcd_setfont(FONT_UI
);
2474 #if (defined(HAVE_SCROLLWHEEL) && (CONFIG_KEYPAD==IPOD_4G_PAD) && !defined(SIMULATOR))
2475 extern bool wheel_is_touched
;
2476 extern int old_wheel_value
;
2477 extern int new_wheel_value
;
2478 extern int wheel_delta
;
2479 extern unsigned int accumulated_wheel_delta
;
2480 extern unsigned int wheel_velocity
;
2482 static bool dbg_scrollwheel(void)
2487 lcd_setfont(FONT_SYSFIXED
);
2491 if (action_userabort(HZ
/10))
2494 lcd_clear_display();
2496 /* show internal variables of scrollwheel driver */
2497 snprintf(buf
, sizeof(buf
), "wheel touched: %s", (wheel_is_touched
) ? "true" : "false");
2498 lcd_puts(0, 0, buf
);
2499 snprintf(buf
, sizeof(buf
), "new position: %2d", new_wheel_value
);
2500 lcd_puts(0, 1, buf
);
2501 snprintf(buf
, sizeof(buf
), "old position: %2d", old_wheel_value
);
2502 lcd_puts(0, 2, buf
);
2503 snprintf(buf
, sizeof(buf
), "wheel delta: %2d", wheel_delta
);
2504 lcd_puts(0, 3, buf
);
2505 snprintf(buf
, sizeof(buf
), "accumulated delta: %2d", accumulated_wheel_delta
);
2506 lcd_puts(0, 4, buf
);
2507 snprintf(buf
, sizeof(buf
), "velo [deg/s]: %4d", (int)wheel_velocity
);
2508 lcd_puts(0, 5, buf
);
2510 /* show effective accelerated scrollspeed */
2511 speed
= button_apply_acceleration( (1<<31)|(1<<24)|wheel_velocity
);
2512 snprintf(buf
, sizeof(buf
), "accel. speed: %4d", speed
);
2513 lcd_puts(0, 6, buf
);
2521 #if defined(HAVE_USBSTACK) && defined(ROCKBOX_HAS_LOGF) && defined(USB_SERIAL)
2522 static bool logf_usb_serial(void)
2524 bool serial_enabled
= !usb_core_driver_enabled(USB_DRIVER_SERIAL
);
2525 usb_core_enable_driver(USB_DRIVER_SERIAL
,serial_enabled
);
2526 splashf(HZ
, "USB logf %s",
2527 serial_enabled
?"enabled":"disabled");
2532 #if defined(HAVE_USBSTACK) && defined(USB_STORAGE)
2533 static bool usb_reconnect(void)
2535 splash(HZ
, "Reconnect mass storage");
2536 usb_storage_reconnect();
2541 #if CONFIG_USBOTG == USBOTG_ISP1583
2542 extern int dbg_usb_num_items(void);
2543 extern char* dbg_usb_item(int selected_item
, void *data
, char *buffer
, size_t buffer_len
);
2545 static int isp1583_action_callback(int action
, struct gui_synclist
*lists
)
2548 if (action
== ACTION_NONE
)
2549 action
= ACTION_REDRAW
;
2553 static bool dbg_isp1583(void)
2555 struct simplelist_info isp1583
;
2556 isp1583
.scroll_all
= true;
2557 simplelist_info_init(&isp1583
, "ISP1583", dbg_usb_num_items(), NULL
);
2558 isp1583
.timeout
= HZ
/100;
2559 isp1583
.hide_selection
= true;
2560 isp1583
.get_name
= dbg_usb_item
;
2561 isp1583
.action_callback
= isp1583_action_callback
;
2562 return simplelist_show_list(&isp1583
);
2566 #if defined(CREATIVE_ZVx) && !defined(SIMULATOR)
2567 extern int pic_dbg_num_items(void);
2568 extern char* pic_dbg_item(int selected_item
, void *data
, char *buffer
, size_t buffer_len
);
2570 static int pic_action_callback(int action
, struct gui_synclist
*lists
)
2573 if (action
== ACTION_NONE
)
2574 action
= ACTION_REDRAW
;
2578 static bool dbg_pic(void)
2580 struct simplelist_info pic
;
2581 pic
.scroll_all
= true;
2582 simplelist_info_init(&pic
, "PIC", pic_dbg_num_items(), NULL
);
2583 pic
.timeout
= HZ
/100;
2584 pic
.hide_selection
= true;
2585 pic
.get_name
= pic_dbg_item
;
2586 pic
.action_callback
= pic_action_callback
;
2587 return simplelist_show_list(&pic
);
2592 /****** The menu *********/
2593 struct the_menu_item
{
2594 unsigned char *desc
; /* string or ID */
2595 bool (*function
) (void); /* return true if USB was connected */
2597 static const struct the_menu_item menuitems
[] = {
2598 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || \
2599 (defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD))
2600 { "Dump ROM contents", dbg_save_roms
},
2602 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || defined(CPU_PP) \
2603 || CONFIG_CPU == S3C2440 || CONFIG_CPU == IMX31L
2604 { "View I/O ports", dbg_ports
},
2606 #if (CONFIG_RTC == RTC_PCF50605) && !defined(SIMULATOR)
2607 { "View PCF registers", dbg_pcf
},
2609 #if defined(HAVE_TSC2100) && !defined(SIMULATOR)
2610 { "TSC2100 debug", tsc2100_debug
},
2612 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
2613 { "CPU frequency", dbg_cpufreq
},
2615 #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR)
2616 { "S/PDIF analyzer", dbg_spdif
},
2618 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2619 { "Catch mem accesses", dbg_set_memory_guard
},
2621 { "View OS stacks", dbg_os
},
2622 #ifdef HAVE_LCD_BITMAP
2624 { "View battery", view_battery
},
2626 { "Screendump", dbg_screendump
},
2629 { "View HW info", dbg_hw_info
},
2632 { "View partitions", dbg_partitions
},
2635 { "View disk info", dbg_disk_info
},
2636 #if (CONFIG_STORAGE & STORAGE_ATA)
2637 { "Dump ATA identify info", dbg_identify_info
},
2640 #ifdef HAVE_DIRCACHE
2641 { "View dircache info", dbg_dircache_info
},
2643 #ifdef HAVE_TAGCACHE
2644 { "View database info", dbg_tagcache_info
},
2646 #ifdef HAVE_LCD_BITMAP
2647 #if CONFIG_CODEC == SWCODEC
2648 { "View buffering thread", dbg_buffering_thread
},
2649 #elif !defined(SIMULATOR)
2650 { "View audio thread", dbg_audio_thread
},
2653 { "pm histogram", peak_meter_histogram
},
2654 #endif /* PM_DEBUG */
2655 #endif /* HAVE_LCD_BITMAP */
2658 { "FM Radio", dbg_fm_radio
},
2661 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2662 { "Write back EEPROM", dbg_write_eeprom
},
2664 #if CONFIG_USBOTG == USBOTG_ISP1583
2665 { "View ISP1583 info", dbg_isp1583
},
2667 #if defined(CREATIVE_ZVx) && !defined(SIMULATOR)
2668 { "View PIC info", dbg_pic
},
2670 #ifdef ROCKBOX_HAS_LOGF
2671 {"logf", logfdisplay
},
2672 {"logfdump", logfdump
},
2674 #if defined(HAVE_USBSTACK) && defined(ROCKBOX_HAS_LOGF) && defined(USB_SERIAL)
2675 {"logf over usb",logf_usb_serial
},
2677 #if defined(HAVE_USBSTACK) && defined(USB_STORAGE)
2678 {"reconnect usb storage",usb_reconnect
},
2680 #ifdef CPU_BOOST_LOGGING
2681 {"cpu_boost log",cpu_boost_log
},
2683 #if (defined(HAVE_SCROLLWHEEL) && (CONFIG_KEYPAD==IPOD_4G_PAD) && !defined(SIMULATOR))
2684 {"Debug scrollwheel", dbg_scrollwheel
},
2687 static int menu_action_callback(int btn
, struct gui_synclist
*lists
)
2689 if (btn
== ACTION_STD_OK
)
2691 menuitems
[gui_synclist_get_sel_pos(lists
)].function();
2692 btn
= ACTION_REDRAW
;
2696 static char* dbg_menu_getname(int item
, void * data
,
2697 char *buffer
, size_t buffer_len
)
2699 (void)data
; (void)buffer
; (void)buffer_len
;
2700 return menuitems
[item
].desc
;
2702 bool debug_menu(void)
2704 struct simplelist_info info
;
2706 simplelist_info_init(&info
, "Debug Menu", ARRAYLEN(menuitems
), NULL
);
2707 info
.action_callback
= menu_action_callback
;
2708 info
.get_name
= dbg_menu_getname
;
2710 return simplelist_show_list(&info
);