1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Heikki Hannikainen
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
29 #include "debug_menu.h"
36 #include "powermgmt.h"
40 #include "mp3_playback.h"
43 #include "statusbar.h"
54 #include "lcd-remote.h"
66 #include "eeprom_24cxx.h"
67 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
70 #if (CONFIG_STORAGE & STORAGE_ATA)
79 #ifdef HAVE_LCD_BITMAP
80 #include "scrollbar.h"
81 #include "peakmeter.h"
84 #if CONFIG_CODEC == SWCODEC
86 #include "buffering.h"
88 #if defined(HAVE_SPDIF_OUT) || defined(HAVE_SPDIF_IN)
92 #ifdef IRIVER_H300_SERIES
93 #include "pcf50606.h" /* for pcf50606_read */
100 #if CONFIG_RTC == RTC_PCF50605
101 #include "pcf50605.h"
103 #include "appevents.h"
105 #if CONFIG_CPU == DM320 || CONFIG_CPU == S3C2440 || CONFIG_CPU == TCC7801 \
106 || CONFIG_CPU == IMX31L || CONFIG_CPU == AS3525 || CONFIG_CPU == JZ4732 \
107 || defined(CPU_S5L870X) || CONFIG_CPU == AS3525v2
108 #include "debug-target.h"
111 #if defined(SANSA_E200) || defined(SANSA_C200) || defined(PHILIPS_SA9200) \
112 || defined(SANSA_CLIP) || defined(SANSA_FUZE) || defined(SANSA_C200V2)
118 #include "pmu-target.h"
122 #include "usb_core.h"
125 /*---------------------------------------------------*/
126 /* SPECIAL DEBUG STUFF */
127 /*---------------------------------------------------*/
128 extern struct thread_entry threads
[MAXTHREADS
];
130 static char thread_status_char(unsigned status
)
132 static const char thread_status_chars
[THREAD_NUM_STATES
+1] =
134 [0 ... THREAD_NUM_STATES
] = '?',
135 [STATE_RUNNING
] = 'R',
136 [STATE_BLOCKED
] = 'B',
137 [STATE_SLEEPING
] = 'S',
138 [STATE_BLOCKED_W_TMO
] = 'T',
139 [STATE_FROZEN
] = 'F',
140 [STATE_KILLED
] = 'K',
143 if (status
> THREAD_NUM_STATES
)
144 status
= THREAD_NUM_STATES
;
146 return thread_status_chars
[status
];
149 static const char* threads_getname(int selected_item
, void *data
,
150 char *buffer
, size_t buffer_len
)
153 struct thread_entry
*thread
;
157 if (selected_item
< (int)NUM_CORES
)
159 snprintf(buffer
, buffer_len
, "Idle (%d): %2d%%", selected_item
,
160 idle_stack_usage(selected_item
));
164 selected_item
-= NUM_CORES
;
167 thread
= &threads
[selected_item
];
169 if (thread
->state
== STATE_KILLED
)
171 snprintf(buffer
, buffer_len
, "%2d: ---", selected_item
);
175 thread_get_name(name
, 32, thread
);
177 snprintf(buffer
, buffer_len
,
178 "%2d: " IF_COP("(%d) ") "%c%c " IF_PRIO("%d %d ") "%2d%% %s",
180 IF_COP(thread
->core
,)
181 #ifdef HAVE_SCHEDULER_BOOSTCTRL
182 (thread
->cpu_boost
) ? '+' :
184 ((thread
->state
== STATE_RUNNING
) ? '*' : ' '),
185 thread_status_char(thread
->state
),
186 IF_PRIO(thread
->base_priority
, thread
->priority
, )
187 thread_stack_usage(thread
), name
);
192 static int dbg_threads_action_callback(int action
, struct gui_synclist
*lists
)
195 #ifdef ROCKBOX_HAS_LOGF
196 if (action
== ACTION_STD_OK
)
198 int selpos
= gui_synclist_get_sel_pos(lists
);
200 if (selpos
>= NUM_CORES
)
201 remove_thread(threads
[selpos
- NUM_CORES
].id
);
203 remove_thread(threads
[selpos
].id
);
205 return ACTION_REDRAW
;
207 #endif /* ROCKBOX_HAS_LOGF */
208 if (action
== ACTION_NONE
)
209 action
= ACTION_REDRAW
;
213 static bool dbg_os(void)
215 struct simplelist_info info
;
216 simplelist_info_init(&info
, IF_COP("Core and ") "Stack usage:",
220 MAXTHREADS
+NUM_CORES
,
223 #ifndef ROCKBOX_HAS_LOGF
224 info
.hide_selection
= true;
225 info
.scroll_all
= true;
227 info
.action_callback
= dbg_threads_action_callback
;
228 info
.get_name
= threads_getname
;
229 return simplelist_show_list(&info
);
232 #ifdef HAVE_LCD_BITMAP
233 #if CONFIG_CODEC != SWCODEC
235 static bool dbg_audio_thread(void)
237 struct audio_debug d
;
239 lcd_setfont(FONT_SYSFIXED
);
243 if (action_userabort(HZ
/5))
246 audio_get_debugdata(&d
);
250 lcd_putsf(0, 0, "read: %x", d
.audiobuf_read
);
251 lcd_putsf(0, 1, "write: %x", d
.audiobuf_write
);
252 lcd_putsf(0, 2, "swap: %x", d
.audiobuf_swapwrite
);
253 lcd_putsf(0, 3, "playing: %d", d
.playing
);
254 lcd_putsf(0, 4, "playable: %x", d
.playable_space
);
255 lcd_putsf(0, 5, "unswapped: %x", d
.unswapped_space
);
257 /* Playable space left */
258 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8, 112, 4, d
.audiobuflen
, 0,
259 d
.playable_space
, HORIZONTAL
);
261 /* Show the watermark limit */
262 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8+4, 112, 4, d
.audiobuflen
, 0,
263 d
.low_watermark_level
, HORIZONTAL
);
265 lcd_putsf(0, 7, "wm: %x - %x",
266 d
.low_watermark_level
, d
.lowest_watermark_level
);
270 lcd_setfont(FONT_UI
);
273 #endif /* !SIMULATOR */
274 #else /* CONFIG_CODEC == SWCODEC */
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)
293 size_t bufsize
= pcmbuf_get_bufsize();
294 int pcmbufdescs
= pcmbuf_descs();
295 struct buffering_debug d
;
296 size_t filebuflen
= audio_get_filebuflen();
297 /* This is a size_t, but call it a long so it puts a - when it's bad. */
299 ticks
= boost_ticks
= freq_sum
= 0;
301 tick_add_task(dbg_audio_task
);
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 lcd_putsf(0, line
++, "pcm: %6ld/%ld", (long) bufused
, (long) bufsize
);
329 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
330 bufsize
, 0, bufused
, HORIZONTAL
);
333 lcd_putsf(0, line
++, "alloc: %6ld/%ld", audio_filebufused(),
337 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
338 filebuflen
, 0, audio_filebufused(), HORIZONTAL
);
341 lcd_putsf(0, line
++, "real: %6ld/%ld", (long)d
.buffered_data
,
344 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
345 filebuflen
, 0, (long)d
.buffered_data
, HORIZONTAL
);
349 lcd_putsf(0, line
++, "usefl: %6ld/%ld", (long)(d
.useful_data
),
353 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
354 filebuflen
, 0, d
.useful_data
, HORIZONTAL
);
358 lcd_putsf(0, line
++, "data_rem: %ld", (long)d
.data_rem
);
360 lcd_putsf(0, line
++, "track count: %2d", audio_track_count());
362 lcd_putsf(0, line
++, "handle count: %d", (int)d
.num_handles
);
365 lcd_putsf(0, line
++, "cpu freq: %3dMHz",
366 (int)((FREQ
+ 500000) / 1000000));
371 int boostquota
= boost_ticks
* 1000 / ticks
; /* in 0.1 % */
372 int avgclock
= freq_sum
* 10 / ticks
; /* in 100 kHz */
373 lcd_putsf(0, line
++, "boost:%3d.%d%% (%d.%dMHz)",
374 boostquota
/10, boostquota
%10, avgclock
/10, avgclock
%10);
377 lcd_putsf(0, line
++, "pcmbufdesc: %2d/%2d",
378 pcmbuf_used_descs(), pcmbufdescs
);
379 lcd_putsf(0, line
++, "watermark: %6d",
385 tick_remove_task(dbg_audio_task
);
386 lcd_setfont(FONT_UI
);
390 #endif /* CONFIG_CODEC */
391 #endif /* HAVE_LCD_BITMAP */
394 #if (CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE))
395 /* Tool function to read the flash manufacturer and type, if available.
396 Only chips which could be reprogrammed in system will return values.
397 (The mode switch addresses vary between flash manufacturers, hence addr1/2) */
398 /* In IRAM to avoid problems when running directly from Flash */
399 static bool dbg_flash_id(unsigned* p_manufacturer
, unsigned* p_device
,
400 unsigned addr1
, unsigned addr2
)
401 ICODE_ATTR
__attribute__((noinline
));
402 static bool dbg_flash_id(unsigned* p_manufacturer
, unsigned* p_device
,
403 unsigned addr1
, unsigned addr2
)
406 unsigned not_manu
, not_id
; /* read values before switching to ID mode */
407 unsigned manu
, id
; /* read values when in ID mode */
409 #if CONFIG_CPU == SH7034
410 volatile unsigned char* flash
= (unsigned char*)0x2000000; /* flash mapping */
411 #elif defined(CPU_COLDFIRE)
412 volatile unsigned short* flash
= (unsigned short*)0; /* flash mapping */
414 int old_level
; /* saved interrupt level */
416 not_manu
= flash
[0]; /* read the normal content */
417 not_id
= flash
[1]; /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */
419 /* disable interrupts, prevent any stray flash access */
420 old_level
= disable_irq_save();
422 flash
[addr1
] = 0xAA; /* enter command mode */
424 flash
[addr1
] = 0x90; /* ID command */
425 /* Atmel wants 20ms pause here */
426 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
428 manu
= flash
[0]; /* read the IDs */
431 flash
[0] = 0xF0; /* reset flash (back to normal read mode) */
432 /* Atmel wants 20ms pause here */
433 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
435 restore_irq(old_level
); /* enable interrupts again */
437 /* I assume success if the obtained values are different from
438 the normal flash content. This is not perfectly bulletproof, they
439 could theoretically be the same by chance, causing us to fail. */
440 if (not_manu
!= manu
|| not_id
!= id
) /* a value has changed */
442 *p_manufacturer
= manu
; /* return the results */
444 return true; /* success */
446 return false; /* fail */
448 #endif /* (CONFIG_CPU == SH7034 || CPU_COLDFIRE) */
452 static int perfcheck(void)
458 "orr r0, r2, #0xc0 \n" /* disable IRQ and FIQ */
461 "ldr r0, [%[timr]] \n"
462 "add r0, r0, %[tmo] \n"
464 "add %[res], %[res], #1 \n"
465 "ldr r1, [%[timr]] \n"
468 "msr CPSR_c, r2 \n" /* reset IRQ and FIQ state */
472 [timr
]"r"(&USEC_TIMER
),
474 #if CONFIG_CPU == PP5002
476 #else /* PP5020/5022/5024 */
487 #ifdef HAVE_LCD_BITMAP
488 static bool dbg_hw_info(void)
490 #if CONFIG_CPU == SH7034
491 int bitmask
= HW_MASK
;
492 int rom_version
= ROM_VERSION
;
493 unsigned manu
, id
; /* flash IDs */
494 bool got_id
; /* flag if we managed to get the flash IDs */
495 unsigned rom_crc
= 0xffffffff; /* CRC32 of the boot ROM */
496 bool has_bootrom
; /* flag for boot ROM present */
497 int oldmode
; /* saved memory guard mode */
499 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
501 /* get flash ROM type */
502 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
504 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
506 /* check if the boot ROM area is a flash mirror */
507 has_bootrom
= (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
508 if (has_bootrom
) /* if ROM and Flash different */
510 /* calculate CRC16 checksum of boot ROM */
511 rom_crc
= crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
514 system_memory_guard(oldmode
); /* re-enable memory guard */
516 lcd_setfont(FONT_SYSFIXED
);
519 lcd_puts(0, 0, "[Hardware info]");
521 lcd_putsf(0, 1, "ROM: %d.%02d", rom_version
/100, rom_version
%100);
523 lcd_putsf(0, 2, "Mask: 0x%04x", bitmask
);
526 lcd_putsf(0, 3, "Flash: M=%02x D=%02x", manu
, id
);
528 lcd_puts(0, 3, "Flash: M=?? D=??"); /* unknown, sorry */
532 if (rom_crc
== 0x56DBA4EE) /* known Version 1 */
533 lcd_puts(0, 4, "Boot ROM: V1");
535 lcd_putsf(0, 4, "ROMcrc: 0x%08x", rom_crc
);
539 lcd_puts(0, 4, "Boot ROM: none");
544 while (!(action_userabort(TIMEOUT_BLOCK
)));
546 #elif CONFIG_CPU == MCF5249 || CONFIG_CPU == MCF5250
547 unsigned manu
, id
; /* flash IDs */
548 int got_id
; /* flag if we managed to get the flash IDs */
549 int oldmode
; /* saved memory guard mode */
552 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
554 /* get flash ROM type */
555 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
557 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
559 system_memory_guard(oldmode
); /* re-enable memory guard */
561 lcd_setfont(FONT_SYSFIXED
);
564 lcd_puts(0, line
++, "[Hardware info]");
567 lcd_putsf(0, line
++, "Flash: M=%04x D=%04x", manu
, id
);
569 lcd_puts(0, line
++, "Flash: M=???? D=????"); /* unknown, sorry */
575 lcd_puts(0, ++line
, "Serial Number:");
577 got_id
= ds2411_read_id(&id
);
579 if (got_id
== DS2411_OK
)
581 lcd_putsf(0, ++line
, " FC=%02x", (unsigned)id
.family_code
);
582 lcd_putsf(0, ++line
, " ID=%02X %02X %02X %02X %02X %02X",
583 (unsigned)id
.uid
[0], (unsigned)id
.uid
[1], (unsigned)id
.uid
[2],
584 (unsigned)id
.uid
[3], (unsigned)id
.uid
[4], (unsigned)id
.uid
[5]);
585 lcd_putsf(0, ++line
, " CRC=%02X", (unsigned)id
.crc
);
589 lcd_putsf(0, ++line
, "READ ERR=%d", got_id
);
596 while (!(action_userabort(TIMEOUT_BLOCK
)));
598 #elif defined(CPU_PP502x)
600 char pp_version
[] = { (PP_VER2
>> 24) & 0xff, (PP_VER2
>> 16) & 0xff,
601 (PP_VER2
>> 8) & 0xff, (PP_VER2
) & 0xff,
602 (PP_VER1
>> 24) & 0xff, (PP_VER1
>> 16) & 0xff,
603 (PP_VER1
>> 8) & 0xff, (PP_VER1
) & 0xff, '\0' };
605 lcd_setfont(FONT_SYSFIXED
);
608 lcd_puts(0, line
++, "[Hardware info]");
611 lcd_putsf(0, line
++, "HW rev: 0x%08lx", IPOD_HW_REVISION
);
615 extern int lcd_type
; /* Defined in lcd-colornano.c */
617 lcd_putsf(0, line
++, "LCD type: %d", lcd_type
);
620 lcd_putsf(0, line
++, "PP version: %s", pp_version
);
622 lcd_putsf(0, line
++, "Est. clock (kHz): %d", perfcheck());
626 while (!(action_userabort(TIMEOUT_BLOCK
)));
628 #elif CONFIG_CPU == PP5002
630 char pp_version
[] = { (PP_VER4
>> 8) & 0xff, PP_VER4
& 0xff,
631 (PP_VER3
>> 8) & 0xff, PP_VER3
& 0xff,
632 (PP_VER2
>> 8) & 0xff, PP_VER2
& 0xff,
633 (PP_VER1
>> 8) & 0xff, PP_VER1
& 0xff, '\0' };
636 lcd_setfont(FONT_SYSFIXED
);
639 lcd_puts(0, line
++, "[Hardware info]");
642 lcd_putsf(0, line
++, "HW rev: 0x%08lx", IPOD_HW_REVISION
);
645 lcd_putsf(0, line
++, "PP version: %s", pp_version
);
647 lcd_putsf(0, line
++, "Est. clock (kHz): %d", perfcheck());
651 while (!(action_userabort(TIMEOUT_BLOCK
)));
654 /* Define this function in your target tree */
655 return __dbg_hw_info();
656 #endif /* CONFIG_CPU */
657 lcd_setfont(FONT_UI
);
660 #else /* !HAVE_LCD_BITMAP */
661 static bool dbg_hw_info(void)
665 int rom_version
= ROM_VERSION
;
666 unsigned manu
, id
; /* flash IDs */
667 bool got_id
; /* flag if we managed to get the flash IDs */
668 unsigned rom_crc
= 0xffffffff; /* CRC32 of the boot ROM */
669 bool has_bootrom
; /* flag for boot ROM present */
670 int oldmode
; /* saved memory guard mode */
672 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
674 /* get flash ROM type */
675 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
677 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
679 /* check if the boot ROM area is a flash mirror */
680 has_bootrom
= (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
681 if (has_bootrom
) /* if ROM and Flash different */
683 /* calculate CRC16 checksum of boot ROM */
684 rom_crc
= crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
687 system_memory_guard(oldmode
); /* re-enable memory guard */
691 lcd_puts(0, 0, "[HW Info]");
697 lcd_putsf(0, 1, "ROM: %d.%02d",
698 rom_version
/100, rom_version
%100);
702 lcd_putsf(0, 1, "Flash:%02x,%02x", manu
, id
);
704 lcd_puts(0, 1, "Flash:??,??"); /* unknown, sorry */
709 if (rom_crc
== 0x56DBA4EE) /* known Version 1 */
710 lcd_puts(0, 1, "BootROM: V1");
711 else if (rom_crc
== 0x358099E8)
712 lcd_puts(0, 1, "BootROM: V2");
713 /* alternative boot ROM found in one single player so far */
715 lcd_putsf(0, 1, "R: %08x", rom_crc
);
718 lcd_puts(0, 1, "BootROM: no");
723 button
= get_action(CONTEXT_SETTINGS
,TIMEOUT_BLOCK
);
727 case ACTION_STD_CANCEL
:
730 case ACTION_SETTINGS_DEC
:
736 case ACTION_SETTINGS_INC
:
745 #endif /* !HAVE_LCD_BITMAP */
746 #endif /* !SIMULATOR */
749 static const char* dbg_partitions_getname(int selected_item
, void *data
,
750 char *buffer
, size_t buffer_len
)
753 int partition
= selected_item
/2;
754 struct partinfo
* p
= disk_partinfo(partition
);
757 snprintf(buffer
, buffer_len
, " T:%x %ld MB", p
->type
, p
->size
/ ( 2048 / ( SECTOR_SIZE
/ 512 )));
761 snprintf(buffer
, buffer_len
, "P%d: S:%lx", partition
, p
->start
);
766 bool dbg_partitions(void)
768 struct simplelist_info info
;
769 simplelist_info_init(&info
, "Partition Info", 4, NULL
);
770 info
.selection_size
= 2;
771 info
.hide_selection
= true;
772 info
.scroll_all
= true;
773 info
.get_name
= dbg_partitions_getname
;
774 return simplelist_show_list(&info
);
778 #if defined(CPU_COLDFIRE) && defined(HAVE_SPDIF_OUT)
779 static bool dbg_spdif(void)
782 unsigned int control
;
787 unsigned int interruptstat
;
788 bool valnogood
, symbolerr
, parityerr
;
791 int spdif_source
= spdif_get_output_source(&spdif_src_on
);
792 spdif_set_output_source(AUDIO_SRC_SPDIF
IF_SPDIF_POWER_(, true));
795 lcd_setfont(FONT_SYSFIXED
);
797 #ifdef HAVE_SPDIF_POWER
798 spdif_power_enable(true); /* We need SPDIF power for both sending & receiving */
805 control
= EBU1RCVCCHANNEL1
;
806 interruptstat
= INTERRUPTSTAT
;
807 INTERRUPTCLEAR
= 0x03c00000;
809 valnogood
= (interruptstat
& 0x01000000)?true:false;
810 symbolerr
= (interruptstat
& 0x00800000)?true:false;
811 parityerr
= (interruptstat
& 0x00400000)?true:false;
813 lcd_putsf(0, line
++, "Val: %s Sym: %s Par: %s",
816 parityerr
?"--":"OK");
818 lcd_putsf(0, line
++, "Status word: %08x", (int)control
);
823 lcd_putsf(0, line
++, "PRO: %d (%s)",
824 x
, x
?"Professional":"Consumer");
826 x
= (control
>> 30) & 1;
827 lcd_putsf(0, line
++, "Audio: %d (%s)",
828 x
, x
?"Non-PCM":"PCM");
830 x
= (control
>> 29) & 1;
831 lcd_putsf(0, line
++, "Copy: %d (%s)",
832 x
, x
?"Permitted":"Inhibited");
834 x
= (control
>> 27) & 7;
847 lcd_putsf(0, line
++, "Preemphasis: %d (%s)", x
, s
);
849 x
= (control
>> 24) & 3;
850 lcd_putsf(0, line
++, "Mode: %d", x
);
852 category
= (control
>> 17) & 127;
864 lcd_putsf(0, line
++, "Category: 0x%02x (%s)", category
, s
);
866 x
= (control
>> 16) & 1;
868 if(((category
& 0x70) == 0x10) ||
869 ((category
& 0x70) == 0x40) ||
870 ((category
& 0x78) == 0x38))
872 generation
= !generation
;
874 lcd_putsf(0, line
++, "Generation: %d (%s)",
875 x
, generation
?"Original":"No ind.");
877 x
= (control
>> 12) & 15;
878 lcd_putsf(0, line
++, "Source: %d", x
);
881 x
= (control
>> 8) & 15;
897 lcd_putsf(0, line
++, "Channel: %d (%s)", x
, s
);
899 x
= (control
>> 4) & 15;
912 lcd_putsf(0, line
++, "Frequency: %d (%s)", x
, s
);
914 x
= (control
>> 2) & 3;
915 lcd_putsf(0, line
++, "Clock accuracy: %d", x
);
919 lcd_putsf(0, line
++, "Measured freq: %ldHz",
920 spdif_measure_frequency());
925 if (action_userabort(HZ
/10))
929 spdif_set_output_source(spdif_source
IF_SPDIF_POWER_(, spdif_src_on
));
931 #ifdef HAVE_SPDIF_POWER
932 spdif_power_enable(global_settings
.spdif_enable
);
935 lcd_setfont(FONT_UI
);
938 #endif /* CPU_COLDFIRE */
941 #ifdef HAVE_LCD_BITMAP
942 /* button definitions */
943 #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
944 (CONFIG_KEYPAD == IRIVER_H300_PAD)
945 # define DEBUG_CANCEL BUTTON_OFF
947 #elif CONFIG_KEYPAD == RECORDER_PAD
948 # define DEBUG_CANCEL BUTTON_OFF
950 #elif CONFIG_KEYPAD == ONDIO_PAD
951 # define DEBUG_CANCEL BUTTON_MENU
953 #elif (CONFIG_KEYPAD == IPOD_1G2G_PAD) || \
954 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
955 (CONFIG_KEYPAD == IPOD_4G_PAD)
956 # define DEBUG_CANCEL BUTTON_MENU
958 #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
959 # define DEBUG_CANCEL BUTTON_PLAY
961 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
962 # define DEBUG_CANCEL BUTTON_REC
964 #elif (CONFIG_KEYPAD == IAUDIO_M3_PAD)
965 # define DEBUG_CANCEL BUTTON_RC_REC
967 #elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
968 # define DEBUG_CANCEL BUTTON_REW
970 #elif (CONFIG_KEYPAD == MROBE100_PAD)
971 # define DEBUG_CANCEL BUTTON_MENU
973 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
974 (CONFIG_KEYPAD == SANSA_C200_PAD) || \
975 (CONFIG_KEYPAD == SANSA_FUZE_PAD)
976 # define DEBUG_CANCEL BUTTON_LEFT
978 /* This is temporary until the SA9200 touchpad works */
979 #elif (CONFIG_KEYPAD == PHILIPS_SA9200_PAD) || \
980 (CONFIG_KEYPAD == PHILIPS_HDD1630_PAD) || \
981 (CONFIG_KEYPAD == PHILIPS_HDD6330_PAD)
982 # define DEBUG_CANCEL BUTTON_POWER
984 #elif (CONFIG_KEYPAD == SAMSUNG_YH_PAD)
985 # define DEBUG_CANCEL BUTTON_PLAY
987 #elif (CONFIG_KEYPAD == PBELL_VIBE500_PAD)
988 # define DEBUG_CANCEL BUTTON_CANCEL
990 #endif /* key definitions */
995 #if CONFIG_CPU == SH7034
996 int adc_battery_voltage
, adc_battery_level
;
998 lcd_setfont(FONT_SYSFIXED
);
1003 lcd_putsf(0, 0, "PADR: %04x", (unsigned short)PADR
);
1004 lcd_putsf(0, 1, "PBDR: %04x", (unsigned short)PBDR
);
1006 lcd_putsf(0, 2, "AN0: %03x AN4: %03x", adc_read(0), adc_read(4));
1007 lcd_putsf(0, 3, "AN1: %03x AN5: %03x", adc_read(1), adc_read(5));
1008 lcd_putsf(0, 4, "AN2: %03x AN6: %03x", adc_read(2), adc_read(6));
1009 lcd_putsf(0, 5, "AN3: %03x AN7: %03x", adc_read(3), adc_read(7));
1011 battery_read_info(&adc_battery_voltage
, &adc_battery_level
);
1012 lcd_putsf(0, 6, "Batt: %d.%03dV %d%% ", adc_battery_voltage
/ 1000,
1013 adc_battery_voltage
% 1000, adc_battery_level
);
1016 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1018 lcd_setfont(FONT_UI
);
1022 #elif defined(CPU_COLDFIRE)
1023 unsigned int gpio_out
;
1024 unsigned int gpio1_out
;
1025 unsigned int gpio_read
;
1026 unsigned int gpio1_read
;
1027 unsigned int gpio_function
;
1028 unsigned int gpio1_function
;
1029 unsigned int gpio_enable
;
1030 unsigned int gpio1_enable
;
1031 int adc_buttons
, adc_remote
;
1032 int adc_battery_voltage
, adc_battery_level
;
1035 lcd_clear_display();
1036 lcd_setfont(FONT_SYSFIXED
);
1041 gpio_read
= GPIO_READ
;
1042 gpio1_read
= GPIO1_READ
;
1043 gpio_out
= GPIO_OUT
;
1044 gpio1_out
= GPIO1_OUT
;
1045 gpio_function
= GPIO_FUNCTION
;
1046 gpio1_function
= GPIO1_FUNCTION
;
1047 gpio_enable
= GPIO_ENABLE
;
1048 gpio1_enable
= GPIO1_ENABLE
;
1050 lcd_putsf(0, line
++, "GPIO_READ: %08x", gpio_read
);
1051 lcd_putsf(0, line
++, "GPIO_OUT: %08x", gpio_out
);
1052 lcd_putsf(0, line
++, "GPIO_FUNC: %08x", gpio_function
);
1053 lcd_putsf(0, line
++, "GPIO_ENA: %08x", gpio_enable
);
1055 lcd_putsf(0, line
++, "GPIO1_READ: %08x", gpio1_read
);
1056 lcd_putsf(0, line
++, "GPIO1_OUT: %08x", gpio1_out
);
1057 lcd_putsf(0, line
++, "GPIO1_FUNC: %08x", gpio1_function
);
1058 lcd_putsf(0, line
++, "GPIO1_ENA: %08x", gpio1_enable
);
1060 adc_buttons
= adc_read(ADC_BUTTONS
);
1061 adc_remote
= adc_read(ADC_REMOTE
);
1062 battery_read_info(&adc_battery_voltage
, &adc_battery_level
);
1063 #if defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IRIVER_H300_SERIES)
1064 lcd_putsf(0, line
++, "ADC_BUTTONS (%c): %02x",
1065 button_scan_enabled() ? '+' : '-', adc_buttons
);
1067 lcd_putsf(0, line
++, "ADC_BUTTONS: %02x", adc_buttons
);
1069 #if defined(IAUDIO_X5) || defined(IAUDIO_M5)
1070 lcd_putsf(0, line
++, "ADC_REMOTE (%c): %02x",
1071 remote_detect() ? '+' : '-', adc_remote
);
1073 lcd_putsf(0, line
++, "ADC_REMOTE: %02x", adc_remote
);
1075 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1076 lcd_putsf(0, line
++, "ADC_REMOTEDETECT: %02x",
1077 adc_read(ADC_REMOTEDETECT
));
1080 lcd_putsf(0, line
++, "Batt: %d.%03dV %d%% ", adc_battery_voltage
/ 1000,
1081 adc_battery_voltage
% 1000, adc_battery_level
);
1083 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1084 lcd_putsf(0, line
++, "remotetype: %d", remote_type());
1088 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1090 lcd_setfont(FONT_UI
);
1095 #elif defined(CPU_PP502x)
1098 lcd_clear_display();
1099 lcd_setfont(FONT_SYSFIXED
);
1104 #if (LCD_HEIGHT >= 176) /* Only for displays with appropriate height. */
1105 lcd_puts(0, line
++, "GPIO ENABLE:");
1106 lcd_putsf(0, line
++, "A: %02x E: %02x I: %02x",
1107 (unsigned int)GPIOA_ENABLE
,
1108 (unsigned int)GPIOE_ENABLE
,
1109 (unsigned int)GPIOI_ENABLE
);
1110 lcd_putsf(0, line
++, "B: %02x F: %02x J: %02x",
1111 (unsigned int)GPIOB_ENABLE
,
1112 (unsigned int)GPIOF_ENABLE
,
1113 (unsigned int)GPIOJ_ENABLE
);
1114 lcd_putsf(0, line
++, "C: %02x G: %02x K: %02x",
1115 (unsigned int)GPIOC_ENABLE
,
1116 (unsigned int)GPIOG_ENABLE
,
1117 (unsigned int)GPIOK_ENABLE
);
1118 lcd_putsf(0, line
++, "D: %02x H: %02x L: %02x",
1119 (unsigned int)GPIOD_ENABLE
,
1120 (unsigned int)GPIOH_ENABLE
,
1121 (unsigned int)GPIOL_ENABLE
);
1124 lcd_puts(0, line
++, "GPIO INPUT VAL:");
1125 lcd_putsf(0, line
++, "A: %02x E: %02x I: %02x",
1126 (unsigned int)GPIOA_INPUT_VAL
,
1127 (unsigned int)GPIOE_INPUT_VAL
,
1128 (unsigned int)GPIOI_INPUT_VAL
);
1129 lcd_putsf(0, line
++, "B: %02x F: %02x J: %02x",
1130 (unsigned int)GPIOB_INPUT_VAL
,
1131 (unsigned int)GPIOF_INPUT_VAL
,
1132 (unsigned int)GPIOJ_INPUT_VAL
);
1133 lcd_putsf(0, line
++, "C: %02x G: %02x K: %02x",
1134 (unsigned int)GPIOC_INPUT_VAL
,
1135 (unsigned int)GPIOG_INPUT_VAL
,
1136 (unsigned int)GPIOK_INPUT_VAL
);
1137 lcd_putsf(0, line
++, "D: %02x H: %02x L: %02x",
1138 (unsigned int)GPIOD_INPUT_VAL
,
1139 (unsigned int)GPIOH_INPUT_VAL
,
1140 (unsigned int)GPIOL_INPUT_VAL
);
1142 lcd_putsf(0, line
++, "GPO32_VAL: %08lx", GPO32_VAL
);
1143 lcd_putsf(0, line
++, "GPO32_EN: %08lx", GPO32_ENABLE
);
1144 lcd_putsf(0, line
++, "DEV_EN: %08lx", DEV_EN
);
1145 lcd_putsf(0, line
++, "DEV_EN2: %08lx", DEV_EN2
);
1146 lcd_putsf(0, line
++, "DEV_EN3: %08lx", inl(0x60006044)); /* to be verified */
1147 lcd_putsf(0, line
++, "DEV_INIT1: %08lx", DEV_INIT1
);
1148 lcd_putsf(0, line
++, "DEV_INIT2: %08lx", DEV_INIT2
);
1149 #ifdef ADC_ACCESSORY
1150 lcd_putsf(0, line
++, "ACCESSORY: %d", adc_read(ADC_ACCESSORY
));
1153 lcd_putsf(0, line
++, "4066_ISTAT: %d", adc_read(ADC_4066_ISTAT
));
1156 #if defined(IPOD_ACCESSORY_PROTOCOL)
1157 extern unsigned char serbuf
[];
1158 lcd_putsf(0, line
++, "IAP PACKET: %02x %02x %02x %02x %02x %02x %02x %02x",
1159 serbuf
[0], serbuf
[1], serbuf
[2], serbuf
[3], serbuf
[4], serbuf
[5],
1160 serbuf
[6], serbuf
[7]);
1163 #if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
1165 lcd_putsf(0, line
++, "BATT: %03x UNK1: %03x",
1166 adc_read(ADC_BATTERY
), adc_read(ADC_UNKNOWN_1
));
1167 lcd_putsf(0, line
++, "REM: %03x PAD: %03x",
1168 adc_read(ADC_REMOTE
), adc_read(ADC_SCROLLPAD
));
1169 #elif defined(PHILIPS_HDD1630) || defined(PHILIPS_HDD6330)
1171 lcd_putsf(0, line
++, "BATT: %03x UNK1: %03x",
1172 adc_read(ADC_BATTERY
), adc_read(ADC_UNKNOWN_1
));
1173 #elif defined(SANSA_E200) || defined(PHILIPS_SA9200)
1174 lcd_putsf(0, line
++, "ADC_BVDD: %4d", adc_read(ADC_BVDD
));
1175 lcd_putsf(0, line
++, "ADC_RTCSUP: %4d", adc_read(ADC_RTCSUP
));
1176 lcd_putsf(0, line
++, "ADC_UVDD: %4d", adc_read(ADC_UVDD
));
1177 lcd_putsf(0, line
++, "ADC_CHG_IN: %4d", adc_read(ADC_CHG_IN
));
1178 lcd_putsf(0, line
++, "ADC_CVDD: %4d", adc_read(ADC_CVDD
));
1179 lcd_putsf(0, line
++, "ADC_BATTEMP: %4d", adc_read(ADC_BATTEMP
));
1180 lcd_putsf(0, line
++, "ADC_MICSUP1: %4d", adc_read(ADC_MICSUP1
));
1181 lcd_putsf(0, line
++, "ADC_MICSUP2: %4d", adc_read(ADC_MICSUP2
));
1182 lcd_putsf(0, line
++, "ADC_VBE1: %4d", adc_read(ADC_VBE1
));
1183 lcd_putsf(0, line
++, "ADC_VBE2: %4d", adc_read(ADC_VBE2
));
1184 lcd_putsf(0, line
++, "ADC_I_MICSUP1:%4d", adc_read(ADC_I_MICSUP1
));
1185 #if !defined(PHILIPS_SA9200)
1186 lcd_putsf(0, line
++, "ADC_I_MICSUP2:%4d", adc_read(ADC_I_MICSUP2
));
1187 lcd_putsf(0, line
++, "ADC_VBAT: %4d", adc_read(ADC_VBAT
));
1191 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1193 lcd_setfont(FONT_UI
);
1198 #elif CONFIG_CPU == PP5002
1201 lcd_clear_display();
1202 lcd_setfont(FONT_SYSFIXED
);
1207 lcd_putsf(0, line
++, "GPIO_A: %02x GPIO_B: %02x",
1208 (unsigned int)GPIOA_INPUT_VAL
, (unsigned int)GPIOB_INPUT_VAL
);
1209 lcd_putsf(0, line
++, "GPIO_C: %02x GPIO_D: %02x",
1210 (unsigned int)GPIOC_INPUT_VAL
, (unsigned int)GPIOD_INPUT_VAL
);
1212 lcd_putsf(0, line
++, "DEV_EN: %08lx", DEV_EN
);
1213 lcd_putsf(0, line
++, "CLOCK_ENABLE: %08lx", CLOCK_ENABLE
);
1214 lcd_putsf(0, line
++, "CLOCK_SOURCE: %08lx", CLOCK_SOURCE
);
1215 lcd_putsf(0, line
++, "PLL_CONTROL: %08lx", PLL_CONTROL
);
1216 lcd_putsf(0, line
++, "PLL_DIV: %08lx", PLL_DIV
);
1217 lcd_putsf(0, line
++, "PLL_MULT: %08lx", PLL_MULT
);
1218 lcd_putsf(0, line
++, "TIMING1_CTL: %08lx", TIMING1_CTL
);
1219 lcd_putsf(0, line
++, "TIMING2_CTL: %08lx", TIMING2_CTL
);
1222 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1224 lcd_setfont(FONT_UI
);
1228 lcd_setfont(FONT_UI
);
1230 return __dbg_ports();
1234 #else /* !HAVE_LCD_BITMAP */
1235 bool dbg_ports(void)
1239 int adc_battery_voltage
;
1242 lcd_clear_display();
1249 snprintf(buf
, 32, "PADR: %04x", (unsigned short)PADR
);
1252 snprintf(buf
, 32, "PBDR: %04x", (unsigned short)PBDR
);
1255 snprintf(buf
, 32, "AN0: %03x", adc_read(0));
1258 snprintf(buf
, 32, "AN1: %03x", adc_read(1));
1261 snprintf(buf
, 32, "AN2: %03x", adc_read(2));
1264 snprintf(buf
, 32, "AN3: %03x", adc_read(3));
1267 snprintf(buf
, 32, "AN4: %03x", adc_read(4));
1270 snprintf(buf
, 32, "AN5: %03x", adc_read(5));
1273 snprintf(buf
, 32, "AN6: %03x", adc_read(6));
1276 snprintf(buf
, 32, "AN7: %03x", adc_read(7));
1279 lcd_puts(0, 0, buf
);
1281 battery_read_info(&adc_battery_voltage
, NULL
);
1282 lcd_putsf(0, 1, "Batt: %d.%03dV", adc_battery_voltage
/ 1000,
1283 adc_battery_voltage
% 1000);
1286 button
= get_action(CONTEXT_SETTINGS
,HZ
/5);
1290 case ACTION_STD_CANCEL
:
1293 case ACTION_SETTINGS_DEC
:
1299 case ACTION_SETTINGS_INC
:
1308 #endif /* !HAVE_LCD_BITMAP */
1309 #endif /* !SIMULATOR */
1311 #if (CONFIG_RTC == RTC_PCF50605) && !defined(SIMULATOR)
1312 static bool dbg_pcf(void)
1316 #ifdef HAVE_LCD_BITMAP
1317 lcd_setfont(FONT_SYSFIXED
);
1319 lcd_clear_display();
1325 lcd_putsf(0, line
++, "DCDC1: %02x", pcf50605_read(0x1b));
1326 lcd_putsf(0, line
++, "DCDC2: %02x", pcf50605_read(0x1c));
1327 lcd_putsf(0, line
++, "DCDC3: %02x", pcf50605_read(0x1d));
1328 lcd_putsf(0, line
++, "DCDC4: %02x", pcf50605_read(0x1e));
1329 lcd_putsf(0, line
++, "DCDEC1: %02x", pcf50605_read(0x1f));
1330 lcd_putsf(0, line
++, "DCDEC2: %02x", pcf50605_read(0x20));
1331 lcd_putsf(0, line
++, "DCUDC1: %02x", pcf50605_read(0x21));
1332 lcd_putsf(0, line
++, "DCUDC2: %02x", pcf50605_read(0x22));
1333 lcd_putsf(0, line
++, "IOREGC: %02x", pcf50605_read(0x23));
1334 lcd_putsf(0, line
++, "D1REGC: %02x", pcf50605_read(0x24));
1335 lcd_putsf(0, line
++, "D2REGC: %02x", pcf50605_read(0x25));
1336 lcd_putsf(0, line
++, "D3REGC: %02x", pcf50605_read(0x26));
1337 lcd_putsf(0, line
++, "LPREG1: %02x", pcf50605_read(0x27));
1339 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1341 lcd_setfont(FONT_UI
);
1346 lcd_setfont(FONT_UI
);
1351 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
1352 static bool dbg_cpufreq(void)
1357 #ifdef HAVE_LCD_BITMAP
1358 lcd_setfont(FONT_SYSFIXED
);
1360 lcd_clear_display();
1366 lcd_putsf(0, line
++, "Frequency: %ld", FREQ
);
1367 lcd_putsf(0, line
++, "boost_counter: %d", get_cpu_boost_counter());
1370 button
= get_action(CONTEXT_STD
,HZ
/10);
1374 case ACTION_STD_PREV
:
1378 case ACTION_STD_NEXT
:
1383 while (get_cpu_boost_counter() > 0)
1385 set_cpu_frequency(CPUFREQ_DEFAULT
);
1388 case ACTION_STD_CANCEL
:
1389 lcd_setfont(FONT_UI
);
1393 lcd_setfont(FONT_UI
);
1396 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
1398 #if defined(HAVE_TSC2100) && !defined(SIMULATOR)
1399 #include "tsc2100.h"
1400 static char *itob(int n
, int len
)
1402 static char binary
[64];
1404 for (i
=1, j
=0;i
<=len
;i
++)
1406 binary
[j
++] = n
&(1<<(len
-i
))?'1':'0';
1414 static const char* tsc2100_debug_getname(int selected_item
, void * data
,
1415 char *buffer
, size_t buffer_len
)
1417 int *page
= (int*)data
;
1418 bool reserved
= false;
1422 if ((selected_item
> 0x0a) ||
1423 (selected_item
== 0x04) ||
1424 (selected_item
== 0x08))
1428 if ((selected_item
> 0x05) ||
1429 (selected_item
== 0x02))
1433 if (selected_item
> 0x1e)
1438 snprintf(buffer
, buffer_len
, "%02x: RESERVED", selected_item
);
1440 snprintf(buffer
, buffer_len
, "%02x: %s", selected_item
,
1441 itob(tsc2100_readreg(*page
, selected_item
)&0xffff,16));
1444 static int tsc2100debug_action_callback(int action
, struct gui_synclist
*lists
)
1446 int *page
= (int*)lists
->data
;
1447 if (action
== ACTION_STD_OK
)
1449 *page
= (*page
+1)%3;
1450 snprintf(lists
->title
, 32,
1451 "tsc2100 registers - Page %d", *page
);
1452 return ACTION_REDRAW
;
1456 static bool tsc2100_debug(void)
1459 char title
[32] = "tsc2100 registers - Page 0";
1460 struct simplelist_info info
;
1461 simplelist_info_init(&info
, title
, 32, &page
);
1462 info
.timeout
= HZ
/100;
1463 info
.get_name
= tsc2100_debug_getname
;
1464 info
.action_callback
= tsc2100debug_action_callback
;
1465 return simplelist_show_list(&info
);
1469 #ifdef HAVE_LCD_BITMAP
1471 * view_battery() shows a automatically scaled graph of the battery voltage
1472 * over time. Usable for estimating battery life / charging rate.
1473 * The power_history array is updated in power_thread of powermgmt.c.
1476 #define BAT_LAST_VAL MIN(LCD_WIDTH, POWER_HISTORY_LEN)
1477 #define BAT_YSPACE (LCD_HEIGHT - 20)
1479 static bool view_battery(void)
1483 unsigned short maxv
, minv
;
1485 lcd_setfont(FONT_SYSFIXED
);
1489 lcd_clear_display();
1491 case 0: /* voltage history graph */
1492 /* Find maximum and minimum voltage for scaling */
1493 minv
= power_history
[0];
1495 for (i
= 1; i
< BAT_LAST_VAL
&& power_history
[i
]; i
++) {
1496 if (power_history
[i
] > maxv
)
1497 maxv
= power_history
[i
];
1498 if (power_history
[i
] < minv
)
1499 minv
= power_history
[i
];
1502 lcd_putsf(0, 0, "Battery %d.%03d", power_history
[0] / 1000,
1503 power_history
[0] % 1000);
1504 lcd_putsf(0, 1, "scale %d.%03d-%d.%03dV",
1505 minv
/ 1000, minv
% 1000, maxv
/ 1000, maxv
% 1000);
1508 for (i
= BAT_LAST_VAL
- 1; i
>= 0; i
--) {
1509 y
= (power_history
[i
] - minv
) * BAT_YSPACE
/ (maxv
- minv
);
1510 lcd_set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
1511 lcd_vline(x
, LCD_HEIGHT
-1, 20);
1512 lcd_set_drawmode(DRMODE_SOLID
);
1513 lcd_vline(x
, LCD_HEIGHT
-1,
1514 MIN(MAX(LCD_HEIGHT
-1 - y
, 20), LCD_HEIGHT
-1));
1520 case 1: /* status: */
1521 lcd_puts(0, 0, "Power status:");
1523 battery_read_info(&y
, NULL
);
1524 lcd_putsf(0, 1, "Battery: %d.%03d V", y
/ 1000, y
% 1000);
1525 #ifdef ADC_EXT_POWER
1526 y
= (adc_read(ADC_EXT_POWER
) * EXT_SCALE_FACTOR
) / 1000;
1527 lcd_putsf(0, 2, "External: %d.%03d V", y
/ 1000, y
% 1000);
1530 #if defined ARCHOS_RECORDER
1531 lcd_putsf(0, 3, "Chgr: %s %s",
1532 charger_inserted() ? "present" : "absent",
1533 charger_enabled() ? "on" : "off");
1534 lcd_putsf(0, 5, "short delta: %d", short_delta
);
1535 lcd_putsf(0, 6, "long delta: %d", long_delta
);
1536 lcd_puts(0, 7, power_message
);
1537 lcd_putsf(0, 8, "USB Inserted: %s",
1538 usb_inserted() ? "yes" : "no");
1539 #elif defined IRIVER_H300_SERIES
1540 lcd_putsf(0, 9, "USB Charging Enabled: %s",
1541 usb_charging_enabled() ? "yes" : "no");
1542 #elif defined IPOD_NANO || defined IPOD_VIDEO
1543 int usb_pwr
= (GPIOL_INPUT_VAL
& 0x10)?true:false;
1544 int ext_pwr
= (GPIOL_INPUT_VAL
& 0x08)?false:true;
1545 int dock
= (GPIOA_INPUT_VAL
& 0x10)?true:false;
1546 int charging
= (GPIOB_INPUT_VAL
& 0x01)?false:true;
1547 int headphone
= (GPIOA_INPUT_VAL
& 0x80)?true:false;
1549 lcd_putsf(0, 3, "USB pwr: %s",
1550 usb_pwr
? "present" : "absent");
1551 lcd_putsf(0, 4, "EXT pwr: %s",
1552 ext_pwr
? "present" : "absent");
1553 lcd_putsf(0, 5, "Battery: %s",
1554 charging
? "charging" : (usb_pwr
||ext_pwr
) ? "charged" : "discharging");
1555 lcd_putsf(0, 6, "Dock mode: %s",
1556 dock
? "enabled" : "disabled");
1557 lcd_putsf(0, 7, "Headphone: %s",
1558 headphone
? "connected" : "disconnected");
1560 x
= (adc_read(ADC_4066_ISTAT
) * 2400) /
1566 lcd_putsf(0, 8, "Ibat: %d mA", x
);
1567 lcd_putsf(0, 9, "Vbat * Ibat: %d mW", x
* y
/ 1000);
1569 #elif defined TOSHIBA_GIGABEAT_S
1573 static const unsigned char * const chrgstate_strings
[] =
1584 lcd_putsf(0, line
++, "Charger: %s",
1585 charger_inserted() ? "present" : "absent");
1587 st
= power_input_status() &
1588 (POWER_INPUT_CHARGER
| POWER_INPUT_BATTERY
);
1589 lcd_putsf(0, line
++, "%s%s",
1590 (st
& POWER_INPUT_MAIN_CHARGER
) ? " Main" : "",
1591 (st
& POWER_INPUT_USB_CHARGER
) ? " USB" : "");
1593 lcd_putsf(0, line
++, "IUSB Max: %d", usb_allowed_current());
1595 y
= ARRAYLEN(chrgstate_strings
) - 1;
1597 switch (charge_state
)
1599 case CHARGE_STATE_DISABLED
: y
--;
1600 case CHARGE_STATE_ERROR
: y
--;
1601 case DISCHARGING
: y
--;
1608 lcd_putsf(0, line
++, "State: %s", chrgstate_strings
[y
]);
1610 lcd_putsf(0, line
++, "Battery Switch: %s",
1611 (st
& POWER_INPUT_BATTERY
) ? "On" : "Off");
1613 y
= chrgraw_adc_voltage();
1614 lcd_putsf(0, line
++, "CHRGRAW: %d.%03d V",
1615 y
/ 1000, y
% 1000);
1617 y
= application_supply_adc_voltage();
1618 lcd_putsf(0, line
++, "BP : %d.%03d V",
1619 y
/ 1000, y
% 1000);
1621 y
= battery_adc_charge_current();
1622 if (y
< 0) x
= '-', y
= -y
;
1624 lcd_putsf(0, line
++, "CHRGISN:%c%d mA", x
, y
);
1626 y
= cccv_regulator_dissipation();
1627 lcd_putsf(0, line
++, "P CCCV : %d mW", y
);
1629 y
= battery_charge_current();
1630 if (y
< 0) x
= '-', y
= -y
;
1632 lcd_putsf(0, line
++, "I Charge:%c%d mA", x
, y
);
1634 y
= battery_adc_temp();
1637 lcd_putsf(0, line
++, "T Battery: %dC (%dF)", y
,
1640 /* Conversion disabled */
1641 lcd_puts(0, line
++, "T Battery: ?");
1644 #elif defined(SANSA_E200) || defined(SANSA_C200) || defined(SANSA_CLIP) || \
1645 defined(SANSA_FUZE) || defined (SANSA_C200V2)
1646 const int first
= CHARGE_STATE_DISABLED
;
1647 static const char * const chrgstate_strings
[] =
1649 [CHARGE_STATE_DISABLED
-first
] = "Disabled",
1650 [CHARGE_STATE_ERROR
-first
] = "Error",
1651 [DISCHARGING
-first
] = "Discharging",
1652 [CHARGING
-first
] = "Charging",
1654 const char *str
= NULL
;
1656 lcd_putsf(0, 3, "Charger: %s",
1657 charger_inserted() ? "present" : "absent");
1659 y
= charge_state
- first
;
1660 if ((unsigned)y
< ARRAYLEN(chrgstate_strings
))
1661 str
= chrgstate_strings
[y
];
1663 lcd_putsf(0, 4, "State: %s",
1664 str
? str
: "<unknown>");
1666 lcd_putsf(0, 5, "CHARGER: %02X",
1667 ascodec_read(AS3514_CHARGER
));
1668 #elif defined(IPOD_NANO2G)
1669 y
= pmu_read_battery_voltage();
1670 lcd_putsf(17, 1, "RAW: %d.%03d V", y
/ 1000, y
% 1000);
1671 y
= pmu_read_battery_current();
1672 lcd_putsf(0, 2, "Battery current: %d mA", y
);
1673 lcd_putsf(0, 3, "PWRCON: %8x", PWRCON
);
1674 lcd_putsf(0, 4, "PWRCONEXT: %8x", PWRCONEXT
);
1675 x
= pmu_read(0x1b) & 0xf;
1676 y
= pmu_read(0x1a) * 25 + 625;
1677 lcd_putsf(0, 5, "AUTO: %x / %d mV", x
, y
);
1678 x
= pmu_read(0x1f) & 0xf;
1679 y
= pmu_read(0x1e) * 25 + 625;
1680 lcd_putsf(0, 6, "DOWN1: %x / %d mV", x
, y
);
1681 x
= pmu_read(0x23) & 0xf;
1682 y
= pmu_read(0x22) * 25 + 625;
1683 lcd_putsf(0, 7, "DOWN2: %x / %d mV", x
, y
);
1684 x
= pmu_read(0x27) & 0xf;
1685 y
= pmu_read(0x26) * 100 + 900;
1686 lcd_putsf(0, 8, "MEMLDO: %x / %d mV", x
, y
);
1687 for (i
= 0; i
< 6; i
++)
1689 x
= pmu_read(0x2e + (i
<< 1)) & 0xf;
1690 y
= pmu_read(0x2d + (i
<< 1)) * 100 + 900;
1691 lcd_putsf(0, 9 + i
, "LDO%d: %x / %d mV", i
+ 1, x
, y
);
1693 lcd_putsf(0, 15, "CLKCON: %8x", CLKCON
);
1694 lcd_putsf(17, 15, "PLL0: %6x", PLL0PMS
);
1696 lcd_putsf(0, 3, "Charger: %s",
1697 charger_inserted() ? "present" : "absent");
1698 #endif /* target type */
1699 #endif /* CONFIG_CHARGING */
1702 case 2: /* voltage deltas: */
1703 lcd_puts(0, 0, "Voltage deltas:");
1705 for (i
= 0; i
<= 6; i
++) {
1706 y
= power_history
[i
] - power_history
[i
+1];
1707 lcd_putsf(0, i
+1, "-%d min: %s%d.%03d V", i
,
1708 (y
< 0) ? "-" : "", ((y
< 0) ? y
* -1 : y
) / 1000,
1709 ((y
< 0) ? y
* -1 : y
) % 1000);
1713 case 3: /* remaining time estimation: */
1715 #ifdef ARCHOS_RECORDER
1716 lcd_putsf(0, 0, "charge_state: %d", charge_state
);
1718 lcd_putsf(0, 1, "Cycle time: %d m", powermgmt_last_cycle_startstop_min
);
1720 lcd_putsf(0, 2, "Lvl@cyc st: %d%%", powermgmt_last_cycle_level
);
1722 lcd_putsf(0, 3, "P=%2d I=%2d", pid_p
, pid_i
);
1724 lcd_putsf(0, 4, "Trickle sec: %d/60", trickle_sec
);
1725 #endif /* ARCHOS_RECORDER */
1727 lcd_putsf(0, 5, "Last PwrHist: %d.%03dV",
1728 power_history
[0] / 1000,
1729 power_history
[0] % 1000);
1731 lcd_putsf(0, 6, "battery level: %d%%", battery_level());
1733 lcd_putsf(0, 7, "Est. remain: %d m", battery_time());
1739 switch(get_action(CONTEXT_STD
,HZ
/2))
1741 case ACTION_STD_PREV
:
1746 case ACTION_STD_NEXT
:
1751 case ACTION_STD_CANCEL
:
1752 lcd_setfont(FONT_UI
);
1756 lcd_setfont(FONT_UI
);
1760 #endif /* HAVE_LCD_BITMAP */
1764 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
1766 #if (CONFIG_STORAGE & STORAGE_MMC)
1767 #define CARDTYPE "MMC"
1768 #elif (CONFIG_STORAGE & STORAGE_SD)
1769 #define CARDTYPE "microSD"
1772 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1775 int *cardnum
= (int*)lists
->data
;
1776 unsigned char card_name
[6];
1777 unsigned char pbuf
[32];
1778 char *title
= lists
->title
;
1779 static const unsigned char i_vmin
[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
1780 static const unsigned char i_vmax
[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
1781 static const unsigned char * const kbit_units
[] = { "kBit/s", "MBit/s", "GBit/s" };
1782 static const unsigned char * const nsec_units
[] = { "ns", "µs", "ms" };
1783 #if (CONFIG_STORAGE & STORAGE_MMC)
1784 static const char * const mmc_spec_vers
[] = { "1.0-1.2", "1.4", "2.0-2.2",
1785 "3.1-3.31", "4.0" };
1788 if ((btn
== ACTION_STD_OK
) || (btn
== SYS_FS_CHANGED
) || (btn
== ACTION_REDRAW
))
1791 if (btn
== ACTION_STD_OK
)
1793 *cardnum
^= 0x1; /* change cards */
1797 simplelist_set_line_count(0);
1799 card
= card_get_info(*cardnum
);
1801 if (card
->initialized
> 0)
1804 for (i
=0; i
<sizeof(card_name
); i
++)
1806 card_name
[i
] = card_extract_bits(card
->cid
, (103-8*i
), 8);
1808 strlcpy(card_name
, card_name
, sizeof(card_name
));
1809 simplelist_addline(SIMPLELIST_ADD_LINE
,
1810 "%s Rev %d.%d", card_name
,
1811 (int) card_extract_bits(card
->cid
, 63, 4),
1812 (int) card_extract_bits(card
->cid
, 59, 4));
1813 simplelist_addline(SIMPLELIST_ADD_LINE
,
1815 #if (CONFIG_STORAGE & STORAGE_SD)
1816 (int) card_extract_bits(card
->cid
, 11, 4),
1817 (int) card_extract_bits(card
->cid
, 19, 8) + 2000
1818 #elif (CONFIG_STORAGE & STORAGE_MMC)
1819 (int) card_extract_bits(card
->cid
, 15, 4),
1820 (int) card_extract_bits(card
->cid
, 11, 4) + 1997
1823 simplelist_addline(SIMPLELIST_ADD_LINE
,
1824 #if (CONFIG_STORAGE & STORAGE_SD)
1826 card_extract_bits(card
->cid
, 55, 32)
1827 #elif (CONFIG_STORAGE & STORAGE_MMC)
1829 card_extract_bits(card
->cid
, 47, 16)
1833 simplelist_addline(SIMPLELIST_ADD_LINE
, "M=%02x, "
1834 #if (CONFIG_STORAGE & STORAGE_SD)
1836 (int) card_extract_bits(card
->cid
, 127, 8),
1837 card_extract_bits(card
->cid
, 119, 8),
1838 card_extract_bits(card
->cid
, 111, 8)
1839 #elif (CONFIG_STORAGE & STORAGE_MMC)
1841 (int) card_extract_bits(card
->cid
, 127, 8),
1842 (int) card_extract_bits(card
->cid
, 119, 16)
1846 #if (CONFIG_STORAGE & STORAGE_MMC)
1847 int temp
= card_extract_bits(card
->csd
, 125, 4);
1848 simplelist_addline(SIMPLELIST_ADD_LINE
,
1849 "MMC v%s", temp
< 5 ?
1850 mmc_spec_vers
[temp
] : "?.?");
1852 simplelist_addline(SIMPLELIST_ADD_LINE
,
1853 "Blocks: 0x%08lx", card
->numblocks
);
1854 output_dyn_value(pbuf
, sizeof pbuf
, card
->speed
/ 1000,
1856 simplelist_addline(SIMPLELIST_ADD_LINE
,
1858 output_dyn_value(pbuf
, sizeof pbuf
, card
->taac
,
1860 simplelist_addline(SIMPLELIST_ADD_LINE
,
1862 simplelist_addline(SIMPLELIST_ADD_LINE
,
1863 "Nsac: %d clk", card
->nsac
);
1864 simplelist_addline(SIMPLELIST_ADD_LINE
,
1865 "R2W: *%d", card
->r2w_factor
);
1866 simplelist_addline(SIMPLELIST_ADD_LINE
,
1868 i_vmin
[card_extract_bits(card
->csd
, 61, 3)],
1869 i_vmax
[card_extract_bits(card
->csd
, 58, 3)]);
1870 simplelist_addline(SIMPLELIST_ADD_LINE
,
1872 i_vmin
[card_extract_bits(card
->csd
, 55, 3)],
1873 i_vmax
[card_extract_bits(card
->csd
, 52, 3)]);
1875 else if (card
->initialized
== 0)
1877 simplelist_addline(SIMPLELIST_ADD_LINE
, "Not Found!");
1879 #if (CONFIG_STORAGE & STORAGE_SD)
1880 else /* card->initialized < 0 */
1882 simplelist_addline(SIMPLELIST_ADD_LINE
, "Init Error! (%d)", card
->initialized
);
1885 snprintf(title
, 16, "[" CARDTYPE
" %d]", *cardnum
);
1886 gui_synclist_set_title(lists
, title
, Icon_NOICON
);
1887 gui_synclist_set_nb_items(lists
, simplelist_get_line_count());
1888 gui_synclist_select_item(lists
, 0);
1889 btn
= ACTION_REDRAW
;
1893 #elif (CONFIG_STORAGE & STORAGE_ATA)
1894 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1899 unsigned short* identify_info
= ata_get_identify();
1900 bool timing_info_present
= false;
1903 simplelist_set_line_count(0);
1905 for (i
=0; i
< 20; i
++)
1906 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+27]);
1908 /* kill trailing space */
1909 for (i
=39; i
&& buf
[i
]==' '; i
--)
1911 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", buf
);
1912 for (i
=0; i
< 4; i
++)
1913 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+23]);
1915 simplelist_addline(SIMPLELIST_ADD_LINE
,
1916 "Firmware: %s", buf
);
1917 snprintf(buf
, sizeof buf
, "%ld MB",
1918 ((unsigned long)identify_info
[61] << 16 |
1919 (unsigned long)identify_info
[60]) / 2048 );
1920 simplelist_addline(SIMPLELIST_ADD_LINE
,
1923 fat_size( IF_MV2(0,) NULL
, &free
);
1924 simplelist_addline(SIMPLELIST_ADD_LINE
,
1925 "Free: %ld MB", free
/ 1024);
1926 simplelist_addline(SIMPLELIST_ADD_LINE
,
1927 "Spinup time: %d ms", storage_spinup_time() * (1000/HZ
));
1928 i
= identify_info
[83] & (1<<3);
1929 simplelist_addline(SIMPLELIST_ADD_LINE
,
1930 "Power mgmt: %s", i
? "enabled" : "unsupported");
1931 i
= identify_info
[83] & (1<<9);
1932 simplelist_addline(SIMPLELIST_ADD_LINE
,
1933 "Noise mgmt: %s", i
? "enabled" : "unsupported");
1934 i
= identify_info
[82] & (1<<6);
1935 simplelist_addline(SIMPLELIST_ADD_LINE
,
1936 "Read-ahead: %s", i
? "enabled" : "unsupported");
1937 timing_info_present
= identify_info
[53] & (1<<1);
1938 if(timing_info_present
) {
1939 char pio3
[2], pio4
[2];pio3
[1] = 0;
1941 pio3
[0] = (identify_info
[64] & (1<<0)) ? '3' : 0;
1942 pio4
[0] = (identify_info
[64] & (1<<1)) ? '4' : 0;
1943 simplelist_addline(SIMPLELIST_ADD_LINE
,
1944 "PIO modes: 0 1 2 %s %s", pio3
, pio4
);
1947 simplelist_addline(SIMPLELIST_ADD_LINE
,
1948 "No PIO mode info");
1950 timing_info_present
= identify_info
[53] & (1<<1);
1951 if(timing_info_present
) {
1952 simplelist_addline(SIMPLELIST_ADD_LINE
,
1953 "Cycle times %dns/%dns",
1955 identify_info
[68] );
1957 simplelist_addline(SIMPLELIST_ADD_LINE
,
1960 int sector_size
= 512;
1961 if((identify_info
[106] & 0xe000) == 0x6000)
1962 sector_size
*= BIT_N(identify_info
[106] & 0x000f);
1963 simplelist_addline(SIMPLELIST_ADD_LINE
,
1964 "Physical sector size: %d", sector_size
);
1966 if (identify_info
[63] & (1<<0)) {
1967 char mdma0
[2], mdma1
[2], mdma2
[2];
1968 mdma0
[1] = mdma1
[1] = mdma2
[1] = 0;
1969 mdma0
[0] = (identify_info
[63] & (1<<0)) ? '0' : 0;
1970 mdma1
[0] = (identify_info
[63] & (1<<1)) ? '1' : 0;
1971 mdma2
[0] = (identify_info
[63] & (1<<2)) ? '2' : 0;
1972 simplelist_addline(SIMPLELIST_ADD_LINE
,
1973 "MDMA modes: %s %s %s", mdma0
, mdma1
, mdma2
);
1974 simplelist_addline(SIMPLELIST_ADD_LINE
,
1975 "MDMA Cycle times %dns/%dns",
1977 identify_info
[66] );
1980 simplelist_addline(SIMPLELIST_ADD_LINE
,
1981 "No MDMA mode info");
1983 if (identify_info
[53] & (1<<2)) {
1984 char udma0
[2], udma1
[2], udma2
[2], udma3
[2], udma4
[2], udma5
[2], udma6
[2];
1985 udma0
[1] = udma1
[1] = udma2
[1] = udma3
[1] = udma4
[1] = udma5
[1] = udma6
[1] = 0;
1986 udma0
[0] = (identify_info
[88] & (1<<0)) ? '0' : 0;
1987 udma1
[0] = (identify_info
[88] & (1<<1)) ? '1' : 0;
1988 udma2
[0] = (identify_info
[88] & (1<<2)) ? '2' : 0;
1989 udma3
[0] = (identify_info
[88] & (1<<3)) ? '3' : 0;
1990 udma4
[0] = (identify_info
[88] & (1<<4)) ? '4' : 0;
1991 udma5
[0] = (identify_info
[88] & (1<<5)) ? '5' : 0;
1992 udma6
[0] = (identify_info
[88] & (1<<6)) ? '6' : 0;
1993 simplelist_addline(SIMPLELIST_ADD_LINE
,
1994 "UDMA modes: %s %s %s %s %s %s %s", udma0
, udma1
, udma2
,
1995 udma3
, udma4
, udma5
, udma6
);
1998 simplelist_addline(SIMPLELIST_ADD_LINE
,
1999 "No UDMA mode info");
2001 #endif /* HAVE_ATA_DMA */
2002 timing_info_present
= identify_info
[53] & (1<<1);
2003 if(timing_info_present
) {
2004 i
= identify_info
[49] & (1<<11);
2005 simplelist_addline(SIMPLELIST_ADD_LINE
,
2006 "IORDY support: %s", i
? "yes" : "no");
2007 i
= identify_info
[49] & (1<<10);
2008 simplelist_addline(SIMPLELIST_ADD_LINE
,
2009 "IORDY disable: %s", i
? "yes" : "no");
2011 simplelist_addline(SIMPLELIST_ADD_LINE
,
2014 simplelist_addline(SIMPLELIST_ADD_LINE
,
2015 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
2017 i
= ata_get_dma_mode();
2019 simplelist_addline(SIMPLELIST_ADD_LINE
,
2022 simplelist_addline(SIMPLELIST_ADD_LINE
,
2024 (i
& 0x40) ? "UDMA" : "MDMA",
2027 #endif /* HAVE_ATA_DMA */
2030 #else /* No SD, MMC or ATA */
2031 static int disk_callback(int btn
, struct gui_synclist
*lists
)
2035 struct storage_info info
;
2036 storage_get_info(0,&info
);
2037 simplelist_addline(SIMPLELIST_ADD_LINE
, "Vendor: %s", info
.vendor
);
2038 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", info
.product
);
2039 simplelist_addline(SIMPLELIST_ADD_LINE
, "Firmware: %s", info
.revision
);
2040 simplelist_addline(SIMPLELIST_ADD_LINE
,
2041 "Size: %ld MB", info
.num_sectors
*(info
.sector_size
/512)/2024);
2043 fat_size( IF_MV2(0,) NULL
, &free
);
2044 simplelist_addline(SIMPLELIST_ADD_LINE
,
2045 "Free: %ld MB", free
/ 1024);
2046 simplelist_addline(SIMPLELIST_ADD_LINE
,
2047 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
2052 #if (CONFIG_STORAGE & STORAGE_ATA)
2053 static bool dbg_identify_info(void)
2055 int fd
= creat("/identify_info.bin");
2058 #ifdef ROCKBOX_LITTLE_ENDIAN
2059 ecwrite(fd
, ata_get_identify(), SECTOR_SIZE
/2, "s", true);
2061 write(fd
, ata_get_identify(), SECTOR_SIZE
);
2069 static bool dbg_disk_info(void)
2071 struct simplelist_info info
;
2072 simplelist_info_init(&info
, "Disk Info", 1, NULL
);
2073 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
2076 info
.callback_data
= (void*)&card
;
2079 info
.action_callback
= disk_callback
;
2080 info
.hide_selection
= true;
2081 info
.scroll_all
= true;
2082 return simplelist_show_list(&info
);
2084 #endif /* !SIMULATOR */
2086 #ifdef HAVE_DIRCACHE
2087 static int dircache_callback(int btn
, struct gui_synclist
*lists
)
2089 (void)btn
; (void)lists
;
2090 simplelist_set_line_count(0);
2091 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache initialized: %s",
2092 dircache_is_enabled() ? "Yes" : "No");
2093 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache size: %d B",
2094 dircache_get_cache_size());
2095 simplelist_addline(SIMPLELIST_ADD_LINE
, "Last size: %d B",
2096 global_status
.dircache_size
);
2097 simplelist_addline(SIMPLELIST_ADD_LINE
, "Limit: %d B",
2099 simplelist_addline(SIMPLELIST_ADD_LINE
, "Reserve: %d/%d B",
2100 dircache_get_reserve_used(), DIRCACHE_RESERVE
);
2101 simplelist_addline(SIMPLELIST_ADD_LINE
, "Scanning took: %d s",
2102 dircache_get_build_ticks() / HZ
);
2103 simplelist_addline(SIMPLELIST_ADD_LINE
, "Entry count: %d",
2104 dircache_get_entry_count());
2108 static bool dbg_dircache_info(void)
2110 struct simplelist_info info
;
2111 simplelist_info_init(&info
, "Dircache Info", 7, NULL
);
2112 info
.action_callback
= dircache_callback
;
2113 info
.hide_selection
= true;
2114 info
.scroll_all
= true;
2115 return simplelist_show_list(&info
);
2118 #endif /* HAVE_DIRCACHE */
2120 #ifdef HAVE_TAGCACHE
2121 static int database_callback(int btn
, struct gui_synclist
*lists
)
2124 struct tagcache_stat
*stat
= tagcache_get_stat();
2125 static bool synced
= false;
2127 simplelist_set_line_count(0);
2129 simplelist_addline(SIMPLELIST_ADD_LINE
, "Initialized: %s",
2130 stat
->initialized
? "Yes" : "No");
2131 simplelist_addline(SIMPLELIST_ADD_LINE
, "DB Ready: %s",
2132 stat
->ready
? "Yes" : "No");
2133 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM Cache: %s",
2134 stat
->ramcache
? "Yes" : "No");
2135 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM: %d/%d B",
2136 stat
->ramcache_used
, stat
->ramcache_allocated
);
2137 simplelist_addline(SIMPLELIST_ADD_LINE
, "Progress: %d%% (%d entries)",
2138 stat
->progress
, stat
->processed_entries
);
2139 simplelist_addline(SIMPLELIST_ADD_LINE
, "Curfile: %s",
2140 stat
->curentry
? stat
->curentry
: "---");
2141 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit step: %d",
2143 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit delayed: %s",
2144 stat
->commit_delayed
? "Yes" : "No");
2146 simplelist_addline(SIMPLELIST_ADD_LINE
, "Queue length: %d",
2147 stat
->queue_length
);
2152 tagcache_screensync_event();
2155 if (!btn
&& stat
->curentry
)
2158 return ACTION_REDRAW
;
2161 if (btn
== ACTION_STD_CANCEL
)
2162 tagcache_screensync_enable(false);
2166 static bool dbg_tagcache_info(void)
2168 struct simplelist_info info
;
2169 simplelist_info_init(&info
, "Database Info", 8, NULL
);
2170 info
.action_callback
= database_callback
;
2171 info
.hide_selection
= true;
2172 info
.scroll_all
= true;
2174 /* Don't do nonblock here, must give enough processing time
2175 for tagcache thread. */
2176 /* info.timeout = TIMEOUT_NOBLOCK; */
2178 tagcache_screensync_enable(true);
2179 return simplelist_show_list(&info
);
2183 #if CONFIG_CPU == SH7034
2184 static bool dbg_save_roms(void)
2187 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
2189 fd
= creat("/internal_rom_0000-FFFF.bin");
2192 write(fd
, (void *)0, 0x10000);
2196 fd
= creat("/internal_rom_2000000-203FFFF.bin");
2199 write(fd
, (void *)0x2000000, 0x40000);
2203 system_memory_guard(oldmode
);
2206 #elif defined CPU_COLDFIRE
2207 static bool dbg_save_roms(void)
2210 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
2212 #if defined(IRIVER_H100_SERIES)
2213 fd
= creat("/internal_rom_000000-1FFFFF.bin");
2214 #elif defined(IRIVER_H300_SERIES)
2215 fd
= creat("/internal_rom_000000-3FFFFF.bin");
2216 #elif defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IAUDIO_M3)
2217 fd
= creat("/internal_rom_000000-3FFFFF.bin");
2221 write(fd
, (void *)0, FLASH_SIZE
);
2224 system_memory_guard(oldmode
);
2227 fd
= creat("/internal_eeprom.bin");
2231 char buf
[EEPROM_SIZE
];
2234 old_irq_level
= disable_irq_save();
2236 err
= eeprom_24cxx_read(0, buf
, sizeof buf
);
2238 restore_irq(old_irq_level
);
2241 splashf(HZ
*3, "Eeprom read failure (%d)", err
);
2244 write(fd
, buf
, sizeof buf
);
2253 #elif defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD)
2254 static bool dbg_save_roms(void)
2258 fd
= creat("/internal_rom_000000-0FFFFF.bin");
2261 write(fd
, (void *)0x20000000, FLASH_SIZE
);
2267 #elif CONFIG_CPU == IMX31L
2268 static bool dbg_save_roms(void)
2272 fd
= creat("/flash_rom_A0000000-A01FFFFF.bin");
2275 write(fd
, (void*)0xa0000000, FLASH_SIZE
);
2281 #elif defined(CPU_TCC780X)
2282 static bool dbg_save_roms(void)
2286 fd
= creat("/eeprom_E0000000-E0001FFF.bin");
2289 write(fd
, (void*)0xe0000000, 0x2000);
2299 static int radio_callback(int btn
, struct gui_synclist
*lists
)
2302 if (btn
== ACTION_STD_CANCEL
)
2304 simplelist_set_line_count(1);
2306 #if (CONFIG_TUNER & LV24020LP)
2307 simplelist_addline(SIMPLELIST_ADD_LINE
,
2308 "CTRL_STAT: %02X", lv24020lp_get(LV24020LP_CTRL_STAT
) );
2309 simplelist_addline(SIMPLELIST_ADD_LINE
,
2310 "RADIO_STAT: %02X", lv24020lp_get(LV24020LP_REG_STAT
) );
2311 simplelist_addline(SIMPLELIST_ADD_LINE
,
2312 "MSS_FM: %d kHz", lv24020lp_get(LV24020LP_MSS_FM
) );
2313 simplelist_addline(SIMPLELIST_ADD_LINE
,
2314 "MSS_IF: %d Hz", lv24020lp_get(LV24020LP_MSS_IF
) );
2315 simplelist_addline(SIMPLELIST_ADD_LINE
,
2316 "MSS_SD: %d Hz", lv24020lp_get(LV24020LP_MSS_SD
) );
2317 simplelist_addline(SIMPLELIST_ADD_LINE
,
2318 "if_set: %d Hz", lv24020lp_get(LV24020LP_IF_SET
) );
2319 simplelist_addline(SIMPLELIST_ADD_LINE
,
2320 "sd_set: %d Hz", lv24020lp_get(LV24020LP_SD_SET
) );
2321 #endif /* LV24020LP */
2322 #if (CONFIG_TUNER & S1A0903X01)
2323 simplelist_addline(SIMPLELIST_ADD_LINE
,
2324 "Samsung regs: %08X", s1a0903x01_get(RADIO_ALL
));
2325 /* This one doesn't return dynamic data atm */
2326 #endif /* S1A0903X01 */
2327 #if (CONFIG_TUNER & TEA5767)
2328 struct tea5767_dbg_info nfo
;
2329 tea5767_dbg_info(&nfo
);
2330 simplelist_addline(SIMPLELIST_ADD_LINE
, "Philips regs:");
2331 simplelist_addline(SIMPLELIST_ADD_LINE
,
2332 " Read: %02X %02X %02X %02X %02X",
2333 (unsigned)nfo
.read_regs
[0], (unsigned)nfo
.read_regs
[1],
2334 (unsigned)nfo
.read_regs
[2], (unsigned)nfo
.read_regs
[3],
2335 (unsigned)nfo
.read_regs
[4]);
2336 simplelist_addline(SIMPLELIST_ADD_LINE
,
2337 " Write: %02X %02X %02X %02X %02X",
2338 (unsigned)nfo
.write_regs
[0], (unsigned)nfo
.write_regs
[1],
2339 (unsigned)nfo
.write_regs
[2], (unsigned)nfo
.write_regs
[3],
2340 (unsigned)nfo
.write_regs
[4]);
2341 #endif /* TEA5767 */
2342 #if (CONFIG_TUNER & SI4700)
2343 struct si4700_dbg_info nfo
;
2344 si4700_dbg_info(&nfo
);
2345 simplelist_addline(SIMPLELIST_ADD_LINE
, "SI4700 regs:");
2347 simplelist_addline(SIMPLELIST_ADD_LINE
,
2348 "%04X %04X %04X %04X",
2349 (unsigned)nfo
.regs
[0], (unsigned)nfo
.regs
[1],
2350 (unsigned)nfo
.regs
[2], (unsigned)nfo
.regs
[3]);
2351 simplelist_addline(SIMPLELIST_ADD_LINE
,
2352 "%04X %04X %04X %04X",
2353 (unsigned)nfo
.regs
[4], (unsigned)nfo
.regs
[5],
2354 (unsigned)nfo
.regs
[6], (unsigned)nfo
.regs
[7]);
2355 simplelist_addline(SIMPLELIST_ADD_LINE
,
2356 "%04X %04X %04X %04X",
2357 (unsigned)nfo
.regs
[8], (unsigned)nfo
.regs
[9],
2358 (unsigned)nfo
.regs
[10], (unsigned)nfo
.regs
[11]);
2359 simplelist_addline(SIMPLELIST_ADD_LINE
,
2360 "%04X %04X %04X %04X",
2361 (unsigned)nfo
.regs
[12], (unsigned)nfo
.regs
[13],
2362 (unsigned)nfo
.regs
[14], (unsigned)nfo
.regs
[15]);
2364 return ACTION_REDRAW
;
2366 static bool dbg_fm_radio(void)
2368 struct simplelist_info info
;
2369 info
.scroll_all
= true;
2370 simplelist_info_init(&info
, "FM Radio", 1, NULL
);
2371 simplelist_set_line_count(0);
2372 simplelist_addline(SIMPLELIST_ADD_LINE
, "HW detected: %s",
2373 radio_hardware_present() ? "yes" : "no");
2375 info
.action_callback
= radio_hardware_present()?radio_callback
: NULL
;
2376 info
.hide_selection
= true;
2377 return simplelist_show_list(&info
);
2379 #endif /* CONFIG_TUNER */
2380 #endif /* !SIMULATOR */
2382 #ifdef HAVE_LCD_BITMAP
2383 extern bool do_screendump_instead_of_usb
;
2385 static bool dbg_screendump(void)
2387 do_screendump_instead_of_usb
= !do_screendump_instead_of_usb
;
2388 splashf(HZ
, "Screendump %s",
2389 do_screendump_instead_of_usb
?"enabled":"disabled");
2392 #endif /* HAVE_LCD_BITMAP */
2394 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2395 static bool dbg_set_memory_guard(void)
2397 static const struct opt_items names
[MAXMEMGUARD
] = {
2399 { "Flash ROM writes", -1 },
2400 { "Zero area (all)", -1 }
2402 int mode
= system_memory_guard(MEMGUARD_KEEP
);
2404 set_option( "Catch mem accesses", &mode
, INT
, names
, MAXMEMGUARD
, NULL
);
2405 system_memory_guard(mode
);
2409 #endif /* CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) */
2411 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2412 static bool dbg_write_eeprom(void)
2417 char buf
[EEPROM_SIZE
];
2420 fd
= open("/internal_eeprom.bin", O_RDONLY
);
2424 rc
= read(fd
, buf
, EEPROM_SIZE
);
2426 if(rc
== EEPROM_SIZE
)
2428 old_irq_level
= disable_irq_save();
2430 err
= eeprom_24cxx_write(0, buf
, sizeof buf
);
2432 splashf(HZ
*3, "Eeprom write failure (%d)", err
);
2434 splash(HZ
*3, "Eeprom written successfully");
2436 restore_irq(old_irq_level
);
2440 splashf(HZ
*3, "File read error (%d)",rc
);
2446 splash(HZ
*3, "Failed to open 'internal_eeprom.bin'");
2451 #endif /* defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS) */
2452 #ifdef CPU_BOOST_LOGGING
2453 static bool cpu_boost_log(void)
2456 int count
= cpu_boost_log_getcount();
2457 int lines
= LCD_HEIGHT
/SYSFONT_HEIGHT
;
2460 lcd_setfont(FONT_SYSFIXED
);
2461 str
= cpu_boost_log_getlog_first();
2464 lcd_clear_display();
2465 for(j
=0; j
<lines
; j
++,i
++)
2468 str
= cpu_boost_log_getlog_next();
2471 if(strlen(str
) > LCD_WIDTH
/SYSFONT_WIDTH
)
2472 lcd_puts_scroll(0, j
, str
);
2482 switch(get_action(CONTEXT_STD
,TIMEOUT_BLOCK
))
2485 case ACTION_STD_PREV
:
2486 case ACTION_STD_NEXT
:
2489 case ACTION_STD_CANCEL
:
2496 get_action(CONTEXT_STD
,TIMEOUT_BLOCK
);
2497 lcd_setfont(FONT_UI
);
2502 #if (defined(HAVE_WHEEL_ACCELERATION) && (CONFIG_KEYPAD==IPOD_4G_PAD) && !defined(SIMULATOR))
2503 extern bool wheel_is_touched
;
2504 extern int old_wheel_value
;
2505 extern int new_wheel_value
;
2506 extern int wheel_delta
;
2507 extern unsigned int accumulated_wheel_delta
;
2508 extern unsigned int wheel_velocity
;
2510 static bool dbg_scrollwheel(void)
2514 lcd_setfont(FONT_SYSFIXED
);
2518 if (action_userabort(HZ
/10))
2521 lcd_clear_display();
2523 /* show internal variables of scrollwheel driver */
2524 lcd_putsf(0, 0, "wheel touched: %s", (wheel_is_touched
) ? "true" : "false");
2525 lcd_putsf(0, 1, "new position: %2d", new_wheel_value
);
2526 lcd_putsf(0, 2, "old position: %2d", old_wheel_value
);
2527 lcd_putsf(0, 3, "wheel delta: %2d", wheel_delta
);
2528 lcd_putsf(0, 4, "accumulated delta: %2d", accumulated_wheel_delta
);
2529 lcd_putsf(0, 5, "velo [deg/s]: %4d", (int)wheel_velocity
);
2531 /* show effective accelerated scrollspeed */
2532 speed
= button_apply_acceleration( (1<<31)|(1<<24)|wheel_velocity
);
2533 lcd_putsf(0, 6, "accel. speed: %4d", speed
);
2537 lcd_setfont(FONT_UI
);
2542 #if defined (HAVE_USBSTACK)
2544 #if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL)
2545 static bool toggle_usb_core_driver(int driver
, char *msg
)
2547 bool enabled
= !usb_core_driver_enabled(driver
);
2549 usb_core_enable_driver(driver
,enabled
);
2550 splashf(HZ
, "%s %s", msg
, enabled
?"enabled":"disabled");
2555 static bool toggle_usb_serial(void)
2557 return toggle_usb_core_driver(USB_DRIVER_SERIAL
,"USB Serial");
2563 #if CONFIG_USBOTG == USBOTG_ISP1583
2564 extern int dbg_usb_num_items(void);
2565 extern const char* dbg_usb_item(int selected_item
, void *data
,
2566 char *buffer
, size_t buffer_len
);
2568 static int isp1583_action_callback(int action
, struct gui_synclist
*lists
)
2571 if (action
== ACTION_NONE
)
2572 action
= ACTION_REDRAW
;
2576 static bool dbg_isp1583(void)
2578 struct simplelist_info isp1583
;
2579 isp1583
.scroll_all
= true;
2580 simplelist_info_init(&isp1583
, "ISP1583", dbg_usb_num_items(), NULL
);
2581 isp1583
.timeout
= HZ
/100;
2582 isp1583
.hide_selection
= true;
2583 isp1583
.get_name
= dbg_usb_item
;
2584 isp1583
.action_callback
= isp1583_action_callback
;
2585 return simplelist_show_list(&isp1583
);
2589 #if defined(CREATIVE_ZVx) && !defined(SIMULATOR)
2590 extern int pic_dbg_num_items(void);
2591 extern const char* pic_dbg_item(int selected_item
, void *data
,
2592 char *buffer
, size_t buffer_len
);
2594 static int pic_action_callback(int action
, struct gui_synclist
*lists
)
2597 if (action
== ACTION_NONE
)
2598 action
= ACTION_REDRAW
;
2602 static bool dbg_pic(void)
2604 struct simplelist_info pic
;
2605 pic
.scroll_all
= true;
2606 simplelist_info_init(&pic
, "PIC", pic_dbg_num_items(), NULL
);
2607 pic
.timeout
= HZ
/100;
2608 pic
.hide_selection
= true;
2609 pic
.get_name
= pic_dbg_item
;
2610 pic
.action_callback
= pic_action_callback
;
2611 return simplelist_show_list(&pic
);
2616 /****** The menu *********/
2617 struct the_menu_item
{
2618 unsigned char *desc
; /* string or ID */
2619 bool (*function
) (void); /* return true if USB was connected */
2621 static const struct the_menu_item menuitems
[] = {
2622 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || \
2623 (defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD)) || \
2624 CONFIG_CPU == IMX31L || defined(CPU_TCC780X)
2625 { "Dump ROM contents", dbg_save_roms
},
2627 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || defined(CPU_PP) \
2628 || CONFIG_CPU == S3C2440 || CONFIG_CPU == IMX31L || CONFIG_CPU == AS3525 \
2629 || CONFIG_CPU == DM320 || defined(CPU_S5L870X) || CONFIG_CPU == AS3525v2
2630 { "View I/O ports", dbg_ports
},
2632 #if (CONFIG_RTC == RTC_PCF50605) && !defined(SIMULATOR)
2633 { "View PCF registers", dbg_pcf
},
2635 #if defined(HAVE_TSC2100) && !defined(SIMULATOR)
2636 { "TSC2100 debug", tsc2100_debug
},
2638 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
2639 { "CPU frequency", dbg_cpufreq
},
2641 #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR)
2642 { "S/PDIF analyzer", dbg_spdif
},
2644 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2645 { "Catch mem accesses", dbg_set_memory_guard
},
2647 { "View OS stacks", dbg_os
},
2648 #ifdef HAVE_LCD_BITMAP
2650 { "View battery", view_battery
},
2652 { "Screendump", dbg_screendump
},
2655 { "View HW info", dbg_hw_info
},
2658 { "View partitions", dbg_partitions
},
2661 { "View disk info", dbg_disk_info
},
2662 #if (CONFIG_STORAGE & STORAGE_ATA)
2663 { "Dump ATA identify info", dbg_identify_info
},
2666 #ifdef HAVE_DIRCACHE
2667 { "View dircache info", dbg_dircache_info
},
2669 #ifdef HAVE_TAGCACHE
2670 { "View database info", dbg_tagcache_info
},
2672 #ifdef HAVE_LCD_BITMAP
2673 #if CONFIG_CODEC == SWCODEC
2674 { "View buffering thread", dbg_buffering_thread
},
2675 #elif !defined(SIMULATOR)
2676 { "View audio thread", dbg_audio_thread
},
2679 { "pm histogram", peak_meter_histogram
},
2680 #endif /* PM_DEBUG */
2681 #endif /* HAVE_LCD_BITMAP */
2684 { "FM Radio", dbg_fm_radio
},
2687 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2688 { "Write back EEPROM", dbg_write_eeprom
},
2690 #if CONFIG_USBOTG == USBOTG_ISP1583
2691 { "View ISP1583 info", dbg_isp1583
},
2693 #if defined(CREATIVE_ZVx) && !defined(SIMULATOR)
2694 { "View PIC info", dbg_pic
},
2696 #ifdef ROCKBOX_HAS_LOGF
2697 {"Show Log File", logfdisplay
},
2698 {"Dump Log File", logfdump
},
2700 #if defined(HAVE_USBSTACK)
2701 #if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL)
2702 {"USB Serial driver (logf)", toggle_usb_serial
},
2704 #endif /* HAVE_USBSTACK */
2705 #ifdef CPU_BOOST_LOGGING
2706 {"cpu_boost log",cpu_boost_log
},
2708 #if (defined(HAVE_WHEEL_ACCELERATION) && (CONFIG_KEYPAD==IPOD_4G_PAD) && !defined(SIMULATOR))
2709 {"Debug scrollwheel", dbg_scrollwheel
},
2712 static int menu_action_callback(int btn
, struct gui_synclist
*lists
)
2715 if (btn
== ACTION_STD_OK
)
2718 viewportmanager_theme_enable(i
, false, NULL
);
2719 menuitems
[gui_synclist_get_sel_pos(lists
)].function();
2720 btn
= ACTION_REDRAW
;
2722 viewportmanager_theme_undo(i
, false);
2727 static const char* dbg_menu_getname(int item
, void * data
,
2728 char *buffer
, size_t buffer_len
)
2730 (void)data
; (void)buffer
; (void)buffer_len
;
2731 return menuitems
[item
].desc
;
2734 bool debug_menu(void)
2736 struct simplelist_info info
;
2738 simplelist_info_init(&info
, "Debug Menu", ARRAYLEN(menuitems
), NULL
);
2739 info
.action_callback
= menu_action_callback
;
2740 info
.get_name
= dbg_menu_getname
;
2741 return simplelist_show_list(&info
);