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"
35 #include "powermgmt.h"
39 #include "mp3_playback.h"
42 #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"
102 #include "appevents.h"
104 #if CONFIG_CPU == DM320 || CONFIG_CPU == S3C2440 || CONFIG_CPU == TCC7801 \
105 || CONFIG_CPU == IMX31L || CONFIG_CPU == AS3525 || CONFIG_CPU == JZ4732 \
106 || defined(CPU_S5L870X) || CONFIG_CPU == AS3525v2
107 #include "debug-target.h"
110 #if defined(SANSA_E200) || defined(SANSA_C200) || defined(PHILIPS_SA9200) \
111 || (CONFIG_CPU == AS3525 && defined(CONFIG_CHARGING)) \
112 || CONFIG_CPU == AS3525v2
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
);
304 screens
[i
].setfont(FONT_SYSFIXED
);
308 button
= get_action(CONTEXT_STD
,HZ
/5);
311 case ACTION_STD_NEXT
:
314 case ACTION_STD_PREV
:
317 case ACTION_STD_CANCEL
:
322 buffering_get_debugdata(&d
);
323 bufused
= bufsize
- pcmbuf_free();
328 screens
[i
].clear_display();
331 screens
[i
].putsf(0, line
++, "pcm: %6ld/%ld", (long) bufused
, (long) bufsize
);
333 gui_scrollbar_draw(&screens
[i
],0, line
*8, screens
[i
].lcdwidth
, 6,
334 bufsize
, 0, bufused
, HORIZONTAL
);
337 screens
[i
].putsf(0, line
++, "alloc: %6ld/%ld", audio_filebufused(),
340 #if LCD_HEIGHT > 80 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_HEIGHT > 80)
341 if (screens
[i
].lcdheight
> 80)
343 gui_scrollbar_draw(&screens
[i
],0, line
*8, screens
[i
].lcdwidth
, 6,
344 filebuflen
, 0, audio_filebufused(), HORIZONTAL
);
347 screens
[i
].putsf(0, line
++, "real: %6ld/%ld", (long)d
.buffered_data
,
350 gui_scrollbar_draw(&screens
[i
],0, line
*8, screens
[i
].lcdwidth
, 6,
351 filebuflen
, 0, (long)d
.buffered_data
, HORIZONTAL
);
356 screens
[i
].putsf(0, line
++, "usefl: %6ld/%ld", (long)(d
.useful_data
),
359 #if LCD_HEIGHT > 80 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_HEIGHT > 80)
360 if (screens
[i
].lcdheight
> 80)
362 gui_scrollbar_draw(&screens
[i
],0, line
*8, screens
[i
].lcdwidth
, 6,
363 filebuflen
, 0, d
.useful_data
, HORIZONTAL
);
368 screens
[i
].putsf(0, line
++, "data_rem: %ld", (long)d
.data_rem
);
370 screens
[i
].putsf(0, line
++, "track count: %2d", audio_track_count());
372 screens
[i
].putsf(0, line
++, "handle count: %d", (int)d
.num_handles
);
375 screens
[i
].putsf(0, line
++, "cpu freq: %3dMHz",
376 (int)((FREQ
+ 500000) / 1000000));
381 int boostquota
= boost_ticks
* 1000 / ticks
; /* in 0.1 % */
382 int avgclock
= freq_sum
* 10 / ticks
; /* in 100 kHz */
383 screens
[i
].putsf(0, line
++, "boost:%3d.%d%% (%d.%dMHz)",
384 boostquota
/10, boostquota
%10, avgclock
/10, avgclock
%10);
387 screens
[i
].putsf(0, line
++, "pcmbufdesc: %2d/%2d",
388 pcmbuf_used_descs(), pcmbufdescs
);
389 screens
[i
].putsf(0, line
++, "watermark: %6d",
396 tick_remove_task(dbg_audio_task
);
399 screens
[i
].setfont(FONT_UI
);
403 #endif /* CONFIG_CODEC */
404 #endif /* HAVE_LCD_BITMAP */
407 #if (CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE))
408 /* Tool function to read the flash manufacturer and type, if available.
409 Only chips which could be reprogrammed in system will return values.
410 (The mode switch addresses vary between flash manufacturers, hence addr1/2) */
411 /* In IRAM to avoid problems when running directly from Flash */
412 static bool dbg_flash_id(unsigned* p_manufacturer
, unsigned* p_device
,
413 unsigned addr1
, unsigned addr2
)
414 ICODE_ATTR
__attribute__((noinline
));
415 static bool dbg_flash_id(unsigned* p_manufacturer
, unsigned* p_device
,
416 unsigned addr1
, unsigned addr2
)
419 unsigned not_manu
, not_id
; /* read values before switching to ID mode */
420 unsigned manu
, id
; /* read values when in ID mode */
422 #if CONFIG_CPU == SH7034
423 volatile unsigned char* flash
= (unsigned char*)0x2000000; /* flash mapping */
424 #elif defined(CPU_COLDFIRE)
425 volatile unsigned short* flash
= (unsigned short*)0; /* flash mapping */
427 int old_level
; /* saved interrupt level */
429 not_manu
= flash
[0]; /* read the normal content */
430 not_id
= flash
[1]; /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */
432 /* disable interrupts, prevent any stray flash access */
433 old_level
= disable_irq_save();
435 flash
[addr1
] = 0xAA; /* enter command mode */
437 flash
[addr1
] = 0x90; /* ID command */
438 /* Atmel wants 20ms pause here */
439 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
441 manu
= flash
[0]; /* read the IDs */
444 flash
[0] = 0xF0; /* reset flash (back to normal read mode) */
445 /* Atmel wants 20ms pause here */
446 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
448 restore_irq(old_level
); /* enable interrupts again */
450 /* I assume success if the obtained values are different from
451 the normal flash content. This is not perfectly bulletproof, they
452 could theoretically be the same by chance, causing us to fail. */
453 if (not_manu
!= manu
|| not_id
!= id
) /* a value has changed */
455 *p_manufacturer
= manu
; /* return the results */
457 return true; /* success */
459 return false; /* fail */
461 #endif /* (CONFIG_CPU == SH7034 || CPU_COLDFIRE) */
465 static int perfcheck(void)
471 "orr r0, r2, #0xc0 \n" /* disable IRQ and FIQ */
474 "ldr r0, [%[timr]] \n"
475 "add r0, r0, %[tmo] \n"
477 "add %[res], %[res], #1 \n"
478 "ldr r1, [%[timr]] \n"
481 "msr CPSR_c, r2 \n" /* reset IRQ and FIQ state */
485 [timr
]"r"(&USEC_TIMER
),
487 #if CONFIG_CPU == PP5002
489 #else /* PP5020/5022/5024 */
500 #ifdef HAVE_LCD_BITMAP
501 static bool dbg_hw_info(void)
503 #if CONFIG_CPU == SH7034
504 int bitmask
= HW_MASK
;
505 int rom_version
= ROM_VERSION
;
506 unsigned manu
, id
; /* flash IDs */
507 bool got_id
; /* flag if we managed to get the flash IDs */
508 unsigned rom_crc
= 0xffffffff; /* CRC32 of the boot ROM */
509 bool has_bootrom
; /* flag for boot ROM present */
510 int oldmode
; /* saved memory guard mode */
512 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
514 /* get flash ROM type */
515 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
517 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
519 /* check if the boot ROM area is a flash mirror */
520 has_bootrom
= (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
521 if (has_bootrom
) /* if ROM and Flash different */
523 /* calculate CRC16 checksum of boot ROM */
524 rom_crc
= crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
527 system_memory_guard(oldmode
); /* re-enable memory guard */
529 lcd_setfont(FONT_SYSFIXED
);
532 lcd_puts(0, 0, "[Hardware info]");
534 lcd_putsf(0, 1, "ROM: %d.%02d", rom_version
/100, rom_version
%100);
536 lcd_putsf(0, 2, "Mask: 0x%04x", bitmask
);
539 lcd_putsf(0, 3, "Flash: M=%02x D=%02x", manu
, id
);
541 lcd_puts(0, 3, "Flash: M=?? D=??"); /* unknown, sorry */
545 if (rom_crc
== 0x56DBA4EE) /* known Version 1 */
546 lcd_puts(0, 4, "Boot ROM: V1");
548 lcd_putsf(0, 4, "ROMcrc: 0x%08x", rom_crc
);
552 lcd_puts(0, 4, "Boot ROM: none");
557 while (!(action_userabort(TIMEOUT_BLOCK
)));
559 #elif CONFIG_CPU == MCF5249 || CONFIG_CPU == MCF5250
560 unsigned manu
, id
; /* flash IDs */
561 int got_id
; /* flag if we managed to get the flash IDs */
562 int oldmode
; /* saved memory guard mode */
565 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
567 /* get flash ROM type */
568 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
570 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
572 system_memory_guard(oldmode
); /* re-enable memory guard */
574 lcd_setfont(FONT_SYSFIXED
);
577 lcd_puts(0, line
++, "[Hardware info]");
580 lcd_putsf(0, line
++, "Flash: M=%04x D=%04x", manu
, id
);
582 lcd_puts(0, line
++, "Flash: M=???? D=????"); /* unknown, sorry */
588 lcd_puts(0, ++line
, "Serial Number:");
590 got_id
= ds2411_read_id(&id
);
592 if (got_id
== DS2411_OK
)
594 lcd_putsf(0, ++line
, " FC=%02x", (unsigned)id
.family_code
);
595 lcd_putsf(0, ++line
, " ID=%02X %02X %02X %02X %02X %02X",
596 (unsigned)id
.uid
[0], (unsigned)id
.uid
[1], (unsigned)id
.uid
[2],
597 (unsigned)id
.uid
[3], (unsigned)id
.uid
[4], (unsigned)id
.uid
[5]);
598 lcd_putsf(0, ++line
, " CRC=%02X", (unsigned)id
.crc
);
602 lcd_putsf(0, ++line
, "READ ERR=%d", got_id
);
609 while (!(action_userabort(TIMEOUT_BLOCK
)));
611 #elif defined(CPU_PP502x)
613 char pp_version
[] = { (PP_VER2
>> 24) & 0xff, (PP_VER2
>> 16) & 0xff,
614 (PP_VER2
>> 8) & 0xff, (PP_VER2
) & 0xff,
615 (PP_VER1
>> 24) & 0xff, (PP_VER1
>> 16) & 0xff,
616 (PP_VER1
>> 8) & 0xff, (PP_VER1
) & 0xff, '\0' };
618 lcd_setfont(FONT_SYSFIXED
);
621 lcd_puts(0, line
++, "[Hardware info]");
624 lcd_putsf(0, line
++, "HW rev: 0x%08lx", IPOD_HW_REVISION
);
628 extern int lcd_type
; /* Defined in lcd-colornano.c */
630 lcd_putsf(0, line
++, "LCD type: %d", lcd_type
);
633 lcd_putsf(0, line
++, "PP version: %s", pp_version
);
635 lcd_putsf(0, line
++, "Est. clock (kHz): %d", perfcheck());
639 while (!(action_userabort(TIMEOUT_BLOCK
)));
641 #elif CONFIG_CPU == PP5002
643 char pp_version
[] = { (PP_VER4
>> 8) & 0xff, PP_VER4
& 0xff,
644 (PP_VER3
>> 8) & 0xff, PP_VER3
& 0xff,
645 (PP_VER2
>> 8) & 0xff, PP_VER2
& 0xff,
646 (PP_VER1
>> 8) & 0xff, PP_VER1
& 0xff, '\0' };
649 lcd_setfont(FONT_SYSFIXED
);
652 lcd_puts(0, line
++, "[Hardware info]");
655 lcd_putsf(0, line
++, "HW rev: 0x%08lx", IPOD_HW_REVISION
);
658 lcd_putsf(0, line
++, "PP version: %s", pp_version
);
660 lcd_putsf(0, line
++, "Est. clock (kHz): %d", perfcheck());
664 while (!(action_userabort(TIMEOUT_BLOCK
)));
667 /* Define this function in your target tree */
668 return __dbg_hw_info();
669 #endif /* CONFIG_CPU */
670 lcd_setfont(FONT_UI
);
673 #else /* !HAVE_LCD_BITMAP */
674 static bool dbg_hw_info(void)
678 int rom_version
= ROM_VERSION
;
679 unsigned manu
, id
; /* flash IDs */
680 bool got_id
; /* flag if we managed to get the flash IDs */
681 unsigned rom_crc
= 0xffffffff; /* CRC32 of the boot ROM */
682 bool has_bootrom
; /* flag for boot ROM present */
683 int oldmode
; /* saved memory guard mode */
685 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
687 /* get flash ROM type */
688 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
690 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
692 /* check if the boot ROM area is a flash mirror */
693 has_bootrom
= (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
694 if (has_bootrom
) /* if ROM and Flash different */
696 /* calculate CRC16 checksum of boot ROM */
697 rom_crc
= crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
700 system_memory_guard(oldmode
); /* re-enable memory guard */
704 lcd_puts(0, 0, "[HW Info]");
710 lcd_putsf(0, 1, "ROM: %d.%02d",
711 rom_version
/100, rom_version
%100);
715 lcd_putsf(0, 1, "Flash:%02x,%02x", manu
, id
);
717 lcd_puts(0, 1, "Flash:??,??"); /* unknown, sorry */
722 if (rom_crc
== 0x56DBA4EE) /* known Version 1 */
723 lcd_puts(0, 1, "BootROM: V1");
724 else if (rom_crc
== 0x358099E8)
725 lcd_puts(0, 1, "BootROM: V2");
726 /* alternative boot ROM found in one single player so far */
728 lcd_putsf(0, 1, "R: %08x", rom_crc
);
731 lcd_puts(0, 1, "BootROM: no");
736 button
= get_action(CONTEXT_SETTINGS
,TIMEOUT_BLOCK
);
740 case ACTION_STD_CANCEL
:
743 case ACTION_SETTINGS_DEC
:
749 case ACTION_SETTINGS_INC
:
758 #endif /* !HAVE_LCD_BITMAP */
759 #endif /* !SIMULATOR */
762 static const char* dbg_partitions_getname(int selected_item
, void *data
,
763 char *buffer
, size_t buffer_len
)
766 int partition
= selected_item
/2;
767 struct partinfo
* p
= disk_partinfo(partition
);
770 snprintf(buffer
, buffer_len
, " T:%x %ld MB", p
->type
, p
->size
/ ( 2048 / ( SECTOR_SIZE
/ 512 )));
774 snprintf(buffer
, buffer_len
, "P%d: S:%lx", partition
, p
->start
);
779 bool dbg_partitions(void)
781 struct simplelist_info info
;
782 simplelist_info_init(&info
, "Partition Info", 4, NULL
);
783 info
.selection_size
= 2;
784 info
.hide_selection
= true;
785 info
.scroll_all
= true;
786 info
.get_name
= dbg_partitions_getname
;
787 return simplelist_show_list(&info
);
791 #if defined(CPU_COLDFIRE) && defined(HAVE_SPDIF_OUT)
792 static bool dbg_spdif(void)
795 unsigned int control
;
800 unsigned int interruptstat
;
801 bool valnogood
, symbolerr
, parityerr
;
804 int spdif_source
= spdif_get_output_source(&spdif_src_on
);
805 spdif_set_output_source(AUDIO_SRC_SPDIF
IF_SPDIF_POWER_(, true));
808 lcd_setfont(FONT_SYSFIXED
);
810 #ifdef HAVE_SPDIF_POWER
811 spdif_power_enable(true); /* We need SPDIF power for both sending & receiving */
818 control
= EBU1RCVCCHANNEL1
;
819 interruptstat
= INTERRUPTSTAT
;
820 INTERRUPTCLEAR
= 0x03c00000;
822 valnogood
= (interruptstat
& 0x01000000)?true:false;
823 symbolerr
= (interruptstat
& 0x00800000)?true:false;
824 parityerr
= (interruptstat
& 0x00400000)?true:false;
826 lcd_putsf(0, line
++, "Val: %s Sym: %s Par: %s",
829 parityerr
?"--":"OK");
831 lcd_putsf(0, line
++, "Status word: %08x", (int)control
);
836 lcd_putsf(0, line
++, "PRO: %d (%s)",
837 x
, x
?"Professional":"Consumer");
839 x
= (control
>> 30) & 1;
840 lcd_putsf(0, line
++, "Audio: %d (%s)",
841 x
, x
?"Non-PCM":"PCM");
843 x
= (control
>> 29) & 1;
844 lcd_putsf(0, line
++, "Copy: %d (%s)",
845 x
, x
?"Permitted":"Inhibited");
847 x
= (control
>> 27) & 7;
860 lcd_putsf(0, line
++, "Preemphasis: %d (%s)", x
, s
);
862 x
= (control
>> 24) & 3;
863 lcd_putsf(0, line
++, "Mode: %d", x
);
865 category
= (control
>> 17) & 127;
877 lcd_putsf(0, line
++, "Category: 0x%02x (%s)", category
, s
);
879 x
= (control
>> 16) & 1;
881 if(((category
& 0x70) == 0x10) ||
882 ((category
& 0x70) == 0x40) ||
883 ((category
& 0x78) == 0x38))
885 generation
= !generation
;
887 lcd_putsf(0, line
++, "Generation: %d (%s)",
888 x
, generation
?"Original":"No ind.");
890 x
= (control
>> 12) & 15;
891 lcd_putsf(0, line
++, "Source: %d", x
);
894 x
= (control
>> 8) & 15;
910 lcd_putsf(0, line
++, "Channel: %d (%s)", x
, s
);
912 x
= (control
>> 4) & 15;
925 lcd_putsf(0, line
++, "Frequency: %d (%s)", x
, s
);
927 x
= (control
>> 2) & 3;
928 lcd_putsf(0, line
++, "Clock accuracy: %d", x
);
932 lcd_putsf(0, line
++, "Measured freq: %ldHz",
933 spdif_measure_frequency());
938 if (action_userabort(HZ
/10))
942 spdif_set_output_source(spdif_source
IF_SPDIF_POWER_(, spdif_src_on
));
944 #ifdef HAVE_SPDIF_POWER
945 spdif_power_enable(global_settings
.spdif_enable
);
948 lcd_setfont(FONT_UI
);
951 #endif /* CPU_COLDFIRE */
954 #ifdef HAVE_LCD_BITMAP
955 /* button definitions */
956 #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
957 (CONFIG_KEYPAD == IRIVER_H300_PAD)
958 # define DEBUG_CANCEL BUTTON_OFF
960 #elif CONFIG_KEYPAD == RECORDER_PAD
961 # define DEBUG_CANCEL BUTTON_OFF
963 #elif CONFIG_KEYPAD == ONDIO_PAD
964 # define DEBUG_CANCEL BUTTON_MENU
966 #elif (CONFIG_KEYPAD == IPOD_1G2G_PAD) || \
967 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
968 (CONFIG_KEYPAD == IPOD_4G_PAD)
969 # define DEBUG_CANCEL BUTTON_MENU
971 #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
972 # define DEBUG_CANCEL BUTTON_PLAY
974 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
975 # define DEBUG_CANCEL BUTTON_REC
977 #elif (CONFIG_KEYPAD == IAUDIO_M3_PAD)
978 # define DEBUG_CANCEL BUTTON_RC_REC
980 #elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
981 # define DEBUG_CANCEL BUTTON_REW
983 #elif (CONFIG_KEYPAD == MROBE100_PAD)
984 # define DEBUG_CANCEL BUTTON_MENU
986 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
987 (CONFIG_KEYPAD == SANSA_C200_PAD) || \
988 (CONFIG_KEYPAD == SANSA_FUZE_PAD)
989 # define DEBUG_CANCEL BUTTON_LEFT
991 /* This is temporary until the SA9200 touchpad works */
992 #elif (CONFIG_KEYPAD == PHILIPS_SA9200_PAD) || \
993 (CONFIG_KEYPAD == PHILIPS_HDD1630_PAD) || \
994 (CONFIG_KEYPAD == PHILIPS_HDD6330_PAD)
995 # define DEBUG_CANCEL BUTTON_POWER
997 #elif (CONFIG_KEYPAD == SAMSUNG_YH_PAD)
998 # define DEBUG_CANCEL BUTTON_PLAY
1000 #elif (CONFIG_KEYPAD == PBELL_VIBE500_PAD)
1001 # define DEBUG_CANCEL BUTTON_CANCEL
1003 #elif (CONFIG_KEYPAD == MPIO_HD200_PAD)
1004 # define DEBUG_CANCEL BUTTON_REC
1006 #endif /* key definitions */
1009 bool dbg_ports(void)
1011 #if CONFIG_CPU == SH7034
1012 int adc_battery_voltage
, adc_battery_level
;
1014 lcd_setfont(FONT_SYSFIXED
);
1015 lcd_clear_display();
1019 lcd_putsf(0, 0, "PADR: %04x", (unsigned short)PADR
);
1020 lcd_putsf(0, 1, "PBDR: %04x", (unsigned short)PBDR
);
1022 lcd_putsf(0, 2, "AN0: %03x AN4: %03x", adc_read(0), adc_read(4));
1023 lcd_putsf(0, 3, "AN1: %03x AN5: %03x", adc_read(1), adc_read(5));
1024 lcd_putsf(0, 4, "AN2: %03x AN6: %03x", adc_read(2), adc_read(6));
1025 lcd_putsf(0, 5, "AN3: %03x AN7: %03x", adc_read(3), adc_read(7));
1027 battery_read_info(&adc_battery_voltage
, &adc_battery_level
);
1028 lcd_putsf(0, 6, "Batt: %d.%03dV %d%% ", adc_battery_voltage
/ 1000,
1029 adc_battery_voltage
% 1000, adc_battery_level
);
1032 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1034 lcd_setfont(FONT_UI
);
1038 #elif defined(CPU_COLDFIRE)
1039 unsigned int gpio_out
;
1040 unsigned int gpio1_out
;
1041 unsigned int gpio_read
;
1042 unsigned int gpio1_read
;
1043 unsigned int gpio_function
;
1044 unsigned int gpio1_function
;
1045 unsigned int gpio_enable
;
1046 unsigned int gpio1_enable
;
1047 int adc_buttons
, adc_remote
;
1048 int adc_battery_voltage
, adc_battery_level
;
1051 lcd_clear_display();
1052 lcd_setfont(FONT_SYSFIXED
);
1057 gpio_read
= GPIO_READ
;
1058 gpio1_read
= GPIO1_READ
;
1059 gpio_out
= GPIO_OUT
;
1060 gpio1_out
= GPIO1_OUT
;
1061 gpio_function
= GPIO_FUNCTION
;
1062 gpio1_function
= GPIO1_FUNCTION
;
1063 gpio_enable
= GPIO_ENABLE
;
1064 gpio1_enable
= GPIO1_ENABLE
;
1066 lcd_putsf(0, line
++, "GPIO_READ: %08x", gpio_read
);
1067 lcd_putsf(0, line
++, "GPIO_OUT: %08x", gpio_out
);
1068 lcd_putsf(0, line
++, "GPIO_FUNC: %08x", gpio_function
);
1069 lcd_putsf(0, line
++, "GPIO_ENA: %08x", gpio_enable
);
1071 lcd_putsf(0, line
++, "GPIO1_READ: %08x", gpio1_read
);
1072 lcd_putsf(0, line
++, "GPIO1_OUT: %08x", gpio1_out
);
1073 lcd_putsf(0, line
++, "GPIO1_FUNC: %08x", gpio1_function
);
1074 lcd_putsf(0, line
++, "GPIO1_ENA: %08x", gpio1_enable
);
1076 adc_buttons
= adc_read(ADC_BUTTONS
);
1077 adc_remote
= adc_read(ADC_REMOTE
);
1078 battery_read_info(&adc_battery_voltage
, &adc_battery_level
);
1079 #if defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IRIVER_H300_SERIES)
1080 lcd_putsf(0, line
++, "ADC_BUTTONS (%c): %02x",
1081 button_scan_enabled() ? '+' : '-', adc_buttons
);
1083 lcd_putsf(0, line
++, "ADC_BUTTONS: %02x", adc_buttons
);
1085 #if defined(IAUDIO_X5) || defined(IAUDIO_M5)
1086 lcd_putsf(0, line
++, "ADC_REMOTE (%c): %02x",
1087 remote_detect() ? '+' : '-', adc_remote
);
1089 lcd_putsf(0, line
++, "ADC_REMOTE: %02x", adc_remote
);
1091 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1092 lcd_putsf(0, line
++, "ADC_REMOTEDETECT: %02x",
1093 adc_read(ADC_REMOTEDETECT
));
1096 lcd_putsf(0, line
++, "Batt: %d.%03dV %d%% ", adc_battery_voltage
/ 1000,
1097 adc_battery_voltage
% 1000, adc_battery_level
);
1099 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1100 lcd_putsf(0, line
++, "remotetype: %d", remote_type());
1104 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1106 lcd_setfont(FONT_UI
);
1111 #elif defined(CPU_PP502x)
1114 lcd_clear_display();
1115 lcd_setfont(FONT_SYSFIXED
);
1120 #if (LCD_HEIGHT >= 176) /* Only for displays with appropriate height. */
1121 lcd_puts(0, line
++, "GPIO ENABLE:");
1122 lcd_putsf(0, line
++, "A: %02x E: %02x I: %02x",
1123 (unsigned int)GPIOA_ENABLE
,
1124 (unsigned int)GPIOE_ENABLE
,
1125 (unsigned int)GPIOI_ENABLE
);
1126 lcd_putsf(0, line
++, "B: %02x F: %02x J: %02x",
1127 (unsigned int)GPIOB_ENABLE
,
1128 (unsigned int)GPIOF_ENABLE
,
1129 (unsigned int)GPIOJ_ENABLE
);
1130 lcd_putsf(0, line
++, "C: %02x G: %02x K: %02x",
1131 (unsigned int)GPIOC_ENABLE
,
1132 (unsigned int)GPIOG_ENABLE
,
1133 (unsigned int)GPIOK_ENABLE
);
1134 lcd_putsf(0, line
++, "D: %02x H: %02x L: %02x",
1135 (unsigned int)GPIOD_ENABLE
,
1136 (unsigned int)GPIOH_ENABLE
,
1137 (unsigned int)GPIOL_ENABLE
);
1140 lcd_puts(0, line
++, "GPIO INPUT VAL:");
1141 lcd_putsf(0, line
++, "A: %02x E: %02x I: %02x",
1142 (unsigned int)GPIOA_INPUT_VAL
,
1143 (unsigned int)GPIOE_INPUT_VAL
,
1144 (unsigned int)GPIOI_INPUT_VAL
);
1145 lcd_putsf(0, line
++, "B: %02x F: %02x J: %02x",
1146 (unsigned int)GPIOB_INPUT_VAL
,
1147 (unsigned int)GPIOF_INPUT_VAL
,
1148 (unsigned int)GPIOJ_INPUT_VAL
);
1149 lcd_putsf(0, line
++, "C: %02x G: %02x K: %02x",
1150 (unsigned int)GPIOC_INPUT_VAL
,
1151 (unsigned int)GPIOG_INPUT_VAL
,
1152 (unsigned int)GPIOK_INPUT_VAL
);
1153 lcd_putsf(0, line
++, "D: %02x H: %02x L: %02x",
1154 (unsigned int)GPIOD_INPUT_VAL
,
1155 (unsigned int)GPIOH_INPUT_VAL
,
1156 (unsigned int)GPIOL_INPUT_VAL
);
1158 lcd_putsf(0, line
++, "GPO32_VAL: %08lx", GPO32_VAL
);
1159 lcd_putsf(0, line
++, "GPO32_EN: %08lx", GPO32_ENABLE
);
1160 lcd_putsf(0, line
++, "DEV_EN: %08lx", DEV_EN
);
1161 lcd_putsf(0, line
++, "DEV_EN2: %08lx", DEV_EN2
);
1162 lcd_putsf(0, line
++, "DEV_EN3: %08lx", inl(0x60006044)); /* to be verified */
1163 lcd_putsf(0, line
++, "DEV_INIT1: %08lx", DEV_INIT1
);
1164 lcd_putsf(0, line
++, "DEV_INIT2: %08lx", DEV_INIT2
);
1165 #ifdef ADC_ACCESSORY
1166 lcd_putsf(0, line
++, "ACCESSORY: %d", adc_read(ADC_ACCESSORY
));
1169 lcd_putsf(0, line
++, "4066_ISTAT: %d", adc_read(ADC_4066_ISTAT
));
1172 #if defined(IPOD_ACCESSORY_PROTOCOL)
1173 extern unsigned char serbuf
[];
1174 lcd_putsf(0, line
++, "IAP PACKET: %02x %02x %02x %02x %02x %02x %02x %02x",
1175 serbuf
[0], serbuf
[1], serbuf
[2], serbuf
[3], serbuf
[4], serbuf
[5],
1176 serbuf
[6], serbuf
[7]);
1179 #if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
1181 lcd_putsf(0, line
++, "BATT: %03x UNK1: %03x",
1182 adc_read(ADC_BATTERY
), adc_read(ADC_UNKNOWN_1
));
1183 lcd_putsf(0, line
++, "REM: %03x PAD: %03x",
1184 adc_read(ADC_REMOTE
), adc_read(ADC_SCROLLPAD
));
1185 #elif defined(PHILIPS_HDD1630) || defined(PHILIPS_HDD6330)
1187 lcd_putsf(0, line
++, "BATT: %03x UNK1: %03x",
1188 adc_read(ADC_BATTERY
), adc_read(ADC_UNKNOWN_1
));
1189 #elif defined(SANSA_E200) || defined(PHILIPS_SA9200)
1190 lcd_putsf(0, line
++, "ADC_BVDD: %4d", adc_read(ADC_BVDD
));
1191 lcd_putsf(0, line
++, "ADC_RTCSUP: %4d", adc_read(ADC_RTCSUP
));
1192 lcd_putsf(0, line
++, "ADC_UVDD: %4d", adc_read(ADC_UVDD
));
1193 lcd_putsf(0, line
++, "ADC_CHG_IN: %4d", adc_read(ADC_CHG_IN
));
1194 lcd_putsf(0, line
++, "ADC_CVDD: %4d", adc_read(ADC_CVDD
));
1195 lcd_putsf(0, line
++, "ADC_BATTEMP: %4d", adc_read(ADC_BATTEMP
));
1196 lcd_putsf(0, line
++, "ADC_MICSUP1: %4d", adc_read(ADC_MICSUP1
));
1197 lcd_putsf(0, line
++, "ADC_MICSUP2: %4d", adc_read(ADC_MICSUP2
));
1198 lcd_putsf(0, line
++, "ADC_VBE1: %4d", adc_read(ADC_VBE1
));
1199 lcd_putsf(0, line
++, "ADC_VBE2: %4d", adc_read(ADC_VBE2
));
1200 lcd_putsf(0, line
++, "ADC_I_MICSUP1:%4d", adc_read(ADC_I_MICSUP1
));
1201 #if !defined(PHILIPS_SA9200)
1202 lcd_putsf(0, line
++, "ADC_I_MICSUP2:%4d", adc_read(ADC_I_MICSUP2
));
1203 lcd_putsf(0, line
++, "ADC_VBAT: %4d", adc_read(ADC_VBAT
));
1207 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1209 lcd_setfont(FONT_UI
);
1214 #elif CONFIG_CPU == PP5002
1217 lcd_clear_display();
1218 lcd_setfont(FONT_SYSFIXED
);
1223 lcd_putsf(0, line
++, "GPIO_A: %02x GPIO_B: %02x",
1224 (unsigned int)GPIOA_INPUT_VAL
, (unsigned int)GPIOB_INPUT_VAL
);
1225 lcd_putsf(0, line
++, "GPIO_C: %02x GPIO_D: %02x",
1226 (unsigned int)GPIOC_INPUT_VAL
, (unsigned int)GPIOD_INPUT_VAL
);
1228 lcd_putsf(0, line
++, "DEV_EN: %08lx", DEV_EN
);
1229 lcd_putsf(0, line
++, "CLOCK_ENABLE: %08lx", CLOCK_ENABLE
);
1230 lcd_putsf(0, line
++, "CLOCK_SOURCE: %08lx", CLOCK_SOURCE
);
1231 lcd_putsf(0, line
++, "PLL_CONTROL: %08lx", PLL_CONTROL
);
1232 lcd_putsf(0, line
++, "PLL_DIV: %08lx", PLL_DIV
);
1233 lcd_putsf(0, line
++, "PLL_MULT: %08lx", PLL_MULT
);
1234 lcd_putsf(0, line
++, "TIMING1_CTL: %08lx", TIMING1_CTL
);
1235 lcd_putsf(0, line
++, "TIMING2_CTL: %08lx", TIMING2_CTL
);
1238 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1240 lcd_setfont(FONT_UI
);
1244 lcd_setfont(FONT_UI
);
1246 return __dbg_ports();
1250 #else /* !HAVE_LCD_BITMAP */
1251 bool dbg_ports(void)
1255 int adc_battery_voltage
;
1258 lcd_clear_display();
1265 snprintf(buf
, 32, "PADR: %04x", (unsigned short)PADR
);
1268 snprintf(buf
, 32, "PBDR: %04x", (unsigned short)PBDR
);
1271 snprintf(buf
, 32, "AN0: %03x", adc_read(0));
1274 snprintf(buf
, 32, "AN1: %03x", adc_read(1));
1277 snprintf(buf
, 32, "AN2: %03x", adc_read(2));
1280 snprintf(buf
, 32, "AN3: %03x", adc_read(3));
1283 snprintf(buf
, 32, "AN4: %03x", adc_read(4));
1286 snprintf(buf
, 32, "AN5: %03x", adc_read(5));
1289 snprintf(buf
, 32, "AN6: %03x", adc_read(6));
1292 snprintf(buf
, 32, "AN7: %03x", adc_read(7));
1295 lcd_puts(0, 0, buf
);
1297 battery_read_info(&adc_battery_voltage
, NULL
);
1298 lcd_putsf(0, 1, "Batt: %d.%03dV", adc_battery_voltage
/ 1000,
1299 adc_battery_voltage
% 1000);
1302 button
= get_action(CONTEXT_SETTINGS
,HZ
/5);
1306 case ACTION_STD_CANCEL
:
1309 case ACTION_SETTINGS_DEC
:
1315 case ACTION_SETTINGS_INC
:
1324 #endif /* !HAVE_LCD_BITMAP */
1325 #endif /* !SIMULATOR */
1327 #if (CONFIG_RTC == RTC_PCF50605) && !defined(SIMULATOR)
1328 static bool dbg_pcf(void)
1332 #ifdef HAVE_LCD_BITMAP
1333 lcd_setfont(FONT_SYSFIXED
);
1335 lcd_clear_display();
1341 lcd_putsf(0, line
++, "DCDC1: %02x", pcf50605_read(0x1b));
1342 lcd_putsf(0, line
++, "DCDC2: %02x", pcf50605_read(0x1c));
1343 lcd_putsf(0, line
++, "DCDC3: %02x", pcf50605_read(0x1d));
1344 lcd_putsf(0, line
++, "DCDC4: %02x", pcf50605_read(0x1e));
1345 lcd_putsf(0, line
++, "DCDEC1: %02x", pcf50605_read(0x1f));
1346 lcd_putsf(0, line
++, "DCDEC2: %02x", pcf50605_read(0x20));
1347 lcd_putsf(0, line
++, "DCUDC1: %02x", pcf50605_read(0x21));
1348 lcd_putsf(0, line
++, "DCUDC2: %02x", pcf50605_read(0x22));
1349 lcd_putsf(0, line
++, "IOREGC: %02x", pcf50605_read(0x23));
1350 lcd_putsf(0, line
++, "D1REGC: %02x", pcf50605_read(0x24));
1351 lcd_putsf(0, line
++, "D2REGC: %02x", pcf50605_read(0x25));
1352 lcd_putsf(0, line
++, "D3REGC: %02x", pcf50605_read(0x26));
1353 lcd_putsf(0, line
++, "LPREG1: %02x", pcf50605_read(0x27));
1355 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1357 lcd_setfont(FONT_UI
);
1362 lcd_setfont(FONT_UI
);
1367 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
1368 static bool dbg_cpufreq(void)
1373 #ifdef HAVE_LCD_BITMAP
1374 lcd_setfont(FONT_SYSFIXED
);
1376 lcd_clear_display();
1382 lcd_putsf(0, line
++, "Frequency: %ld", FREQ
);
1383 lcd_putsf(0, line
++, "boost_counter: %d", get_cpu_boost_counter());
1386 button
= get_action(CONTEXT_STD
,HZ
/10);
1390 case ACTION_STD_PREV
:
1394 case ACTION_STD_NEXT
:
1399 while (get_cpu_boost_counter() > 0)
1401 set_cpu_frequency(CPUFREQ_DEFAULT
);
1404 case ACTION_STD_CANCEL
:
1405 lcd_setfont(FONT_UI
);
1409 lcd_setfont(FONT_UI
);
1412 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
1414 #if defined(HAVE_TSC2100) && !defined(SIMULATOR)
1415 #include "tsc2100.h"
1416 static char *itob(int n
, int len
)
1418 static char binary
[64];
1420 for (i
=1, j
=0;i
<=len
;i
++)
1422 binary
[j
++] = n
&(1<<(len
-i
))?'1':'0';
1430 static const char* tsc2100_debug_getname(int selected_item
, void * data
,
1431 char *buffer
, size_t buffer_len
)
1433 int *page
= (int*)data
;
1434 bool reserved
= false;
1438 if ((selected_item
> 0x0a) ||
1439 (selected_item
== 0x04) ||
1440 (selected_item
== 0x08))
1444 if ((selected_item
> 0x05) ||
1445 (selected_item
== 0x02))
1449 if (selected_item
> 0x1e)
1454 snprintf(buffer
, buffer_len
, "%02x: RESERVED", selected_item
);
1456 snprintf(buffer
, buffer_len
, "%02x: %s", selected_item
,
1457 itob(tsc2100_readreg(*page
, selected_item
)&0xffff,16));
1460 static int tsc2100debug_action_callback(int action
, struct gui_synclist
*lists
)
1462 int *page
= (int*)lists
->data
;
1463 if (action
== ACTION_STD_OK
)
1465 *page
= (*page
+1)%3;
1466 snprintf(lists
->title
, 32,
1467 "tsc2100 registers - Page %d", *page
);
1468 return ACTION_REDRAW
;
1472 static bool tsc2100_debug(void)
1475 char title
[32] = "tsc2100 registers - Page 0";
1476 struct simplelist_info info
;
1477 simplelist_info_init(&info
, title
, 32, &page
);
1478 info
.timeout
= HZ
/100;
1479 info
.get_name
= tsc2100_debug_getname
;
1480 info
.action_callback
= tsc2100debug_action_callback
;
1481 return simplelist_show_list(&info
);
1485 #ifdef HAVE_LCD_BITMAP
1487 * view_battery() shows a automatically scaled graph of the battery voltage
1488 * over time. Usable for estimating battery life / charging rate.
1489 * The power_history array is updated in power_thread of powermgmt.c.
1492 #define BAT_LAST_VAL MIN(LCD_WIDTH, POWER_HISTORY_LEN)
1493 #define BAT_YSPACE (LCD_HEIGHT - 20)
1495 static bool view_battery(void)
1499 unsigned short maxv
, minv
;
1501 lcd_setfont(FONT_SYSFIXED
);
1505 lcd_clear_display();
1507 case 0: /* voltage history graph */
1508 /* Find maximum and minimum voltage for scaling */
1509 minv
= power_history
[0];
1511 for (i
= 1; i
< BAT_LAST_VAL
&& power_history
[i
]; i
++) {
1512 if (power_history
[i
] > maxv
)
1513 maxv
= power_history
[i
];
1514 if (power_history
[i
] < minv
)
1515 minv
= power_history
[i
];
1518 lcd_putsf(0, 0, "Battery %d.%03d", power_history
[0] / 1000,
1519 power_history
[0] % 1000);
1520 lcd_putsf(0, 1, "scale %d.%03d-%d.%03dV",
1521 minv
/ 1000, minv
% 1000, maxv
/ 1000, maxv
% 1000);
1524 for (i
= BAT_LAST_VAL
- 1; i
>= 0; i
--) {
1525 y
= (power_history
[i
] - minv
) * BAT_YSPACE
/ (maxv
- minv
);
1526 lcd_set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
1527 lcd_vline(x
, LCD_HEIGHT
-1, 20);
1528 lcd_set_drawmode(DRMODE_SOLID
);
1529 lcd_vline(x
, LCD_HEIGHT
-1,
1530 MIN(MAX(LCD_HEIGHT
-1 - y
, 20), LCD_HEIGHT
-1));
1536 case 1: /* status: */
1537 #if CONFIG_CHARGING >= CHARGING_MONITOR
1538 lcd_putsf(0, 0, "Pwr status: %s",
1539 charging_state() ? "charging" : "discharging");
1541 lcd_puts(0, 0, "Power status:");
1543 battery_read_info(&y
, NULL
);
1544 lcd_putsf(0, 1, "Battery: %d.%03d V", y
/ 1000, y
% 1000);
1545 #ifdef ADC_EXT_POWER
1546 y
= (adc_read(ADC_EXT_POWER
) * EXT_SCALE_FACTOR
) / 1000;
1547 lcd_putsf(0, 2, "External: %d.%03d V", y
/ 1000, y
% 1000);
1550 #if defined ARCHOS_RECORDER
1551 lcd_putsf(0, 3, "Chgr: %s %s",
1552 charger_inserted() ? "present" : "absent",
1553 charger_enabled() ? "on" : "off");
1554 lcd_putsf(0, 5, "short delta: %d", short_delta
);
1555 lcd_putsf(0, 6, "long delta: %d", long_delta
);
1556 lcd_puts(0, 7, power_message
);
1557 lcd_putsf(0, 8, "USB Inserted: %s",
1558 usb_inserted() ? "yes" : "no");
1559 #elif defined IPOD_NANO || defined IPOD_VIDEO
1560 int usb_pwr
= (GPIOL_INPUT_VAL
& 0x10)?true:false;
1561 int ext_pwr
= (GPIOL_INPUT_VAL
& 0x08)?false:true;
1562 int dock
= (GPIOA_INPUT_VAL
& 0x10)?true:false;
1563 int charging
= (GPIOB_INPUT_VAL
& 0x01)?false:true;
1564 int headphone
= (GPIOA_INPUT_VAL
& 0x80)?true:false;
1566 lcd_putsf(0, 3, "USB pwr: %s",
1567 usb_pwr
? "present" : "absent");
1568 lcd_putsf(0, 4, "EXT pwr: %s",
1569 ext_pwr
? "present" : "absent");
1570 lcd_putsf(0, 5, "Battery: %s",
1571 charging
? "charging" : (usb_pwr
||ext_pwr
) ? "charged" : "discharging");
1572 lcd_putsf(0, 6, "Dock mode: %s",
1573 dock
? "enabled" : "disabled");
1574 lcd_putsf(0, 7, "Headphone: %s",
1575 headphone
? "connected" : "disconnected");
1577 x
= (adc_read(ADC_4066_ISTAT
) * 2400) /
1583 lcd_putsf(0, 8, "Ibat: %d mA", x
);
1584 lcd_putsf(0, 9, "Vbat * Ibat: %d mW", x
* y
/ 1000);
1586 #elif defined TOSHIBA_GIGABEAT_S
1590 static const unsigned char * const chrgstate_strings
[] =
1601 lcd_putsf(0, line
++, "Charger: %s",
1602 charger_inserted() ? "present" : "absent");
1604 st
= power_input_status() &
1605 (POWER_INPUT_CHARGER
| POWER_INPUT_BATTERY
);
1606 lcd_putsf(0, line
++, "%s%s",
1607 (st
& POWER_INPUT_MAIN_CHARGER
) ? " Main" : "",
1608 (st
& POWER_INPUT_USB_CHARGER
) ? " USB" : "");
1610 y
= ARRAYLEN(chrgstate_strings
) - 1;
1612 switch (charge_state
)
1614 case CHARGE_STATE_DISABLED
: y
--;
1615 case CHARGE_STATE_ERROR
: y
--;
1616 case DISCHARGING
: y
--;
1623 lcd_putsf(0, line
++, "State: %s", chrgstate_strings
[y
]);
1625 lcd_putsf(0, line
++, "Battery Switch: %s",
1626 (st
& POWER_INPUT_BATTERY
) ? "On" : "Off");
1628 y
= chrgraw_adc_voltage();
1629 lcd_putsf(0, line
++, "CHRGRAW: %d.%03d V",
1630 y
/ 1000, y
% 1000);
1632 y
= application_supply_adc_voltage();
1633 lcd_putsf(0, line
++, "BP : %d.%03d V",
1634 y
/ 1000, y
% 1000);
1636 y
= battery_adc_charge_current();
1637 if (y
< 0) x
= '-', y
= -y
;
1639 lcd_putsf(0, line
++, "CHRGISN:%c%d mA", x
, y
);
1641 y
= cccv_regulator_dissipation();
1642 lcd_putsf(0, line
++, "P CCCV : %d mW", y
);
1644 y
= battery_charge_current();
1645 if (y
< 0) x
= '-', y
= -y
;
1647 lcd_putsf(0, line
++, "I Charge:%c%d mA", x
, y
);
1649 y
= battery_adc_temp();
1652 lcd_putsf(0, line
++, "T Battery: %dC (%dF)", y
,
1655 /* Conversion disabled */
1656 lcd_puts(0, line
++, "T Battery: ?");
1659 #elif defined(SANSA_E200) || defined(SANSA_C200) || CONFIG_CPU == AS3525 || \
1660 CONFIG_CPU == AS3525v2
1661 const int first
= CHARGE_STATE_DISABLED
;
1662 static const char * const chrgstate_strings
[] =
1664 [CHARGE_STATE_DISABLED
-first
] = "Disabled",
1665 [CHARGE_STATE_ERROR
-first
] = "Error",
1666 [DISCHARGING
-first
] = "Discharging",
1667 [CHARGING
-first
] = "Charging",
1669 const char *str
= NULL
;
1671 lcd_putsf(0, 3, "Charger: %s",
1672 charger_inserted() ? "present" : "absent");
1674 y
= charge_state
- first
;
1675 if ((unsigned)y
< ARRAYLEN(chrgstate_strings
))
1676 str
= chrgstate_strings
[y
];
1678 lcd_putsf(0, 4, "State: %s",
1679 str
? str
: "<unknown>");
1681 lcd_putsf(0, 5, "CHARGER: %02X", ascodec_read_charger());
1682 #elif defined(IPOD_NANO2G)
1683 y
= pmu_read_battery_voltage();
1684 lcd_putsf(17, 1, "RAW: %d.%03d V", y
/ 1000, y
% 1000);
1685 y
= pmu_read_battery_current();
1686 lcd_putsf(0, 2, "Battery current: %d mA", y
);
1687 lcd_putsf(0, 3, "PWRCON: %8x", PWRCON
);
1688 lcd_putsf(0, 4, "PWRCONEXT: %8x", PWRCONEXT
);
1689 x
= pmu_read(0x1b) & 0xf;
1690 y
= pmu_read(0x1a) * 25 + 625;
1691 lcd_putsf(0, 5, "AUTO: %x / %d mV", x
, y
);
1692 x
= pmu_read(0x1f) & 0xf;
1693 y
= pmu_read(0x1e) * 25 + 625;
1694 lcd_putsf(0, 6, "DOWN1: %x / %d mV", x
, y
);
1695 x
= pmu_read(0x23) & 0xf;
1696 y
= pmu_read(0x22) * 25 + 625;
1697 lcd_putsf(0, 7, "DOWN2: %x / %d mV", x
, y
);
1698 x
= pmu_read(0x27) & 0xf;
1699 y
= pmu_read(0x26) * 100 + 900;
1700 lcd_putsf(0, 8, "MEMLDO: %x / %d mV", x
, y
);
1701 for (i
= 0; i
< 6; i
++)
1703 x
= pmu_read(0x2e + (i
<< 1)) & 0xf;
1704 y
= pmu_read(0x2d + (i
<< 1)) * 100 + 900;
1705 lcd_putsf(0, 9 + i
, "LDO%d: %x / %d mV", i
+ 1, x
, y
);
1707 lcd_putsf(0, 15, "CLKCON: %8x", CLKCON
);
1708 lcd_putsf(17, 15, "PLL0: %6x", PLL0PMS
);
1710 lcd_putsf(0, 3, "Charger: %s",
1711 charger_inserted() ? "present" : "absent");
1712 #endif /* target type */
1713 #endif /* CONFIG_CHARGING */
1716 case 2: /* voltage deltas: */
1717 lcd_puts(0, 0, "Voltage deltas:");
1719 for (i
= 0; i
<= 6; i
++) {
1720 y
= power_history
[i
] - power_history
[i
+1];
1721 lcd_putsf(0, i
+1, "-%d min: %s%d.%03d V", i
,
1722 (y
< 0) ? "-" : "", ((y
< 0) ? y
* -1 : y
) / 1000,
1723 ((y
< 0) ? y
* -1 : y
) % 1000);
1727 case 3: /* remaining time estimation: */
1729 #ifdef ARCHOS_RECORDER
1730 lcd_putsf(0, 0, "charge_state: %d", charge_state
);
1732 lcd_putsf(0, 1, "Cycle time: %d m", powermgmt_last_cycle_startstop_min
);
1734 lcd_putsf(0, 2, "Lvl@cyc st: %d%%", powermgmt_last_cycle_level
);
1736 lcd_putsf(0, 3, "P=%2d I=%2d", pid_p
, pid_i
);
1738 lcd_putsf(0, 4, "Trickle sec: %d/60", trickle_sec
);
1739 #endif /* ARCHOS_RECORDER */
1741 lcd_putsf(0, 5, "Last PwrHist: %d.%03dV",
1742 power_history
[0] / 1000,
1743 power_history
[0] % 1000);
1745 lcd_putsf(0, 6, "battery level: %d%%", battery_level());
1747 lcd_putsf(0, 7, "Est. remain: %d m", battery_time());
1753 switch(get_action(CONTEXT_STD
,HZ
/2))
1755 case ACTION_STD_PREV
:
1760 case ACTION_STD_NEXT
:
1765 case ACTION_STD_CANCEL
:
1766 lcd_setfont(FONT_UI
);
1770 lcd_setfont(FONT_UI
);
1774 #endif /* HAVE_LCD_BITMAP */
1778 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
1780 #if (CONFIG_STORAGE & STORAGE_MMC)
1781 #define CARDTYPE "MMC"
1782 #elif (CONFIG_STORAGE & STORAGE_SD)
1783 #define CARDTYPE "microSD"
1786 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1789 int *cardnum
= (int*)lists
->data
;
1790 unsigned char card_name
[6];
1791 unsigned char pbuf
[32];
1792 char *title
= lists
->title
;
1793 static const unsigned char i_vmin
[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
1794 static const unsigned char i_vmax
[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
1795 static const unsigned char * const kbit_units
[] = { "kBit/s", "MBit/s", "GBit/s" };
1796 static const unsigned char * const nsec_units
[] = { "ns", "µs", "ms" };
1797 #if (CONFIG_STORAGE & STORAGE_MMC)
1798 static const char * const mmc_spec_vers
[] = { "1.0-1.2", "1.4", "2.0-2.2",
1799 "3.1-3.31", "4.0" };
1802 if ((btn
== ACTION_STD_OK
) || (btn
== SYS_FS_CHANGED
) || (btn
== ACTION_REDRAW
))
1805 if (btn
== ACTION_STD_OK
)
1807 *cardnum
^= 0x1; /* change cards */
1811 simplelist_set_line_count(0);
1813 card
= card_get_info(*cardnum
);
1815 if (card
->initialized
> 0)
1818 for (i
=0; i
<sizeof(card_name
); i
++)
1820 card_name
[i
] = card_extract_bits(card
->cid
, (103-8*i
), 8);
1822 strlcpy(card_name
, card_name
, sizeof(card_name
));
1823 simplelist_addline(SIMPLELIST_ADD_LINE
,
1824 "%s Rev %d.%d", card_name
,
1825 (int) card_extract_bits(card
->cid
, 63, 4),
1826 (int) card_extract_bits(card
->cid
, 59, 4));
1827 simplelist_addline(SIMPLELIST_ADD_LINE
,
1829 #if (CONFIG_STORAGE & STORAGE_SD)
1830 (int) card_extract_bits(card
->cid
, 11, 4),
1831 (int) card_extract_bits(card
->cid
, 19, 8) + 2000
1832 #elif (CONFIG_STORAGE & STORAGE_MMC)
1833 (int) card_extract_bits(card
->cid
, 15, 4),
1834 (int) card_extract_bits(card
->cid
, 11, 4) + 1997
1837 simplelist_addline(SIMPLELIST_ADD_LINE
,
1838 #if (CONFIG_STORAGE & STORAGE_SD)
1840 card_extract_bits(card
->cid
, 55, 32)
1841 #elif (CONFIG_STORAGE & STORAGE_MMC)
1843 card_extract_bits(card
->cid
, 47, 16)
1847 simplelist_addline(SIMPLELIST_ADD_LINE
, "M=%02x, "
1848 #if (CONFIG_STORAGE & STORAGE_SD)
1850 (int) card_extract_bits(card
->cid
, 127, 8),
1851 card_extract_bits(card
->cid
, 119, 8),
1852 card_extract_bits(card
->cid
, 111, 8)
1853 #elif (CONFIG_STORAGE & STORAGE_MMC)
1855 (int) card_extract_bits(card
->cid
, 127, 8),
1856 (int) card_extract_bits(card
->cid
, 119, 16)
1860 #if (CONFIG_STORAGE & STORAGE_MMC)
1861 int temp
= card_extract_bits(card
->csd
, 125, 4);
1862 simplelist_addline(SIMPLELIST_ADD_LINE
,
1863 "MMC v%s", temp
< 5 ?
1864 mmc_spec_vers
[temp
] : "?.?");
1866 simplelist_addline(SIMPLELIST_ADD_LINE
,
1867 "Blocks: 0x%08lx", card
->numblocks
);
1868 output_dyn_value(pbuf
, sizeof pbuf
, card
->speed
/ 1000,
1870 simplelist_addline(SIMPLELIST_ADD_LINE
,
1872 output_dyn_value(pbuf
, sizeof pbuf
, card
->taac
,
1874 simplelist_addline(SIMPLELIST_ADD_LINE
,
1876 simplelist_addline(SIMPLELIST_ADD_LINE
,
1877 "Nsac: %d clk", card
->nsac
);
1878 simplelist_addline(SIMPLELIST_ADD_LINE
,
1879 "R2W: *%d", card
->r2w_factor
);
1880 simplelist_addline(SIMPLELIST_ADD_LINE
,
1882 i_vmin
[card_extract_bits(card
->csd
, 61, 3)],
1883 i_vmax
[card_extract_bits(card
->csd
, 58, 3)]);
1884 simplelist_addline(SIMPLELIST_ADD_LINE
,
1886 i_vmin
[card_extract_bits(card
->csd
, 55, 3)],
1887 i_vmax
[card_extract_bits(card
->csd
, 52, 3)]);
1889 else if (card
->initialized
== 0)
1891 simplelist_addline(SIMPLELIST_ADD_LINE
, "Not Found!");
1893 #if (CONFIG_STORAGE & STORAGE_SD)
1894 else /* card->initialized < 0 */
1896 simplelist_addline(SIMPLELIST_ADD_LINE
, "Init Error! (%d)", card
->initialized
);
1899 snprintf(title
, 16, "[" CARDTYPE
" %d]", *cardnum
);
1900 gui_synclist_set_title(lists
, title
, Icon_NOICON
);
1901 gui_synclist_set_nb_items(lists
, simplelist_get_line_count());
1902 gui_synclist_select_item(lists
, 0);
1903 btn
= ACTION_REDRAW
;
1907 #elif (CONFIG_STORAGE & STORAGE_ATA)
1908 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1913 unsigned short* identify_info
= ata_get_identify();
1914 bool timing_info_present
= false;
1917 simplelist_set_line_count(0);
1919 for (i
=0; i
< 20; i
++)
1920 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+27]);
1922 /* kill trailing space */
1923 for (i
=39; i
&& buf
[i
]==' '; i
--)
1925 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", buf
);
1926 for (i
=0; i
< 4; i
++)
1927 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+23]);
1929 simplelist_addline(SIMPLELIST_ADD_LINE
,
1930 "Firmware: %s", buf
);
1931 snprintf(buf
, sizeof buf
, "%ld MB",
1932 ((unsigned long)identify_info
[61] << 16 |
1933 (unsigned long)identify_info
[60]) / 2048 );
1934 simplelist_addline(SIMPLELIST_ADD_LINE
,
1937 fat_size( IF_MV2(0,) NULL
, &free
);
1938 simplelist_addline(SIMPLELIST_ADD_LINE
,
1939 "Free: %ld MB", free
/ 1024);
1940 simplelist_addline(SIMPLELIST_ADD_LINE
,
1941 "Spinup time: %d ms", storage_spinup_time() * (1000/HZ
));
1942 i
= identify_info
[83] & (1<<3);
1943 simplelist_addline(SIMPLELIST_ADD_LINE
,
1944 "Power mgmt: %s", i
? "enabled" : "unsupported");
1945 i
= identify_info
[83] & (1<<9);
1946 simplelist_addline(SIMPLELIST_ADD_LINE
,
1947 "Noise mgmt: %s", i
? "enabled" : "unsupported");
1948 i
= identify_info
[82] & (1<<6);
1949 simplelist_addline(SIMPLELIST_ADD_LINE
,
1950 "Read-ahead: %s", i
? "enabled" : "unsupported");
1951 timing_info_present
= identify_info
[53] & (1<<1);
1952 if(timing_info_present
) {
1953 char pio3
[2], pio4
[2];pio3
[1] = 0;
1955 pio3
[0] = (identify_info
[64] & (1<<0)) ? '3' : 0;
1956 pio4
[0] = (identify_info
[64] & (1<<1)) ? '4' : 0;
1957 simplelist_addline(SIMPLELIST_ADD_LINE
,
1958 "PIO modes: 0 1 2 %s %s", pio3
, pio4
);
1961 simplelist_addline(SIMPLELIST_ADD_LINE
,
1962 "No PIO mode info");
1964 timing_info_present
= identify_info
[53] & (1<<1);
1965 if(timing_info_present
) {
1966 simplelist_addline(SIMPLELIST_ADD_LINE
,
1967 "Cycle times %dns/%dns",
1969 identify_info
[68] );
1971 simplelist_addline(SIMPLELIST_ADD_LINE
,
1974 int sector_size
= 512;
1975 if((identify_info
[106] & 0xe000) == 0x6000)
1976 sector_size
*= BIT_N(identify_info
[106] & 0x000f);
1977 simplelist_addline(SIMPLELIST_ADD_LINE
,
1978 "Physical sector size: %d", sector_size
);
1980 if (identify_info
[63] & (1<<0)) {
1981 char mdma0
[2], mdma1
[2], mdma2
[2];
1982 mdma0
[1] = mdma1
[1] = mdma2
[1] = 0;
1983 mdma0
[0] = (identify_info
[63] & (1<<0)) ? '0' : 0;
1984 mdma1
[0] = (identify_info
[63] & (1<<1)) ? '1' : 0;
1985 mdma2
[0] = (identify_info
[63] & (1<<2)) ? '2' : 0;
1986 simplelist_addline(SIMPLELIST_ADD_LINE
,
1987 "MDMA modes: %s %s %s", mdma0
, mdma1
, mdma2
);
1988 simplelist_addline(SIMPLELIST_ADD_LINE
,
1989 "MDMA Cycle times %dns/%dns",
1991 identify_info
[66] );
1994 simplelist_addline(SIMPLELIST_ADD_LINE
,
1995 "No MDMA mode info");
1997 if (identify_info
[53] & (1<<2)) {
1998 char udma0
[2], udma1
[2], udma2
[2], udma3
[2], udma4
[2], udma5
[2], udma6
[2];
1999 udma0
[1] = udma1
[1] = udma2
[1] = udma3
[1] = udma4
[1] = udma5
[1] = udma6
[1] = 0;
2000 udma0
[0] = (identify_info
[88] & (1<<0)) ? '0' : 0;
2001 udma1
[0] = (identify_info
[88] & (1<<1)) ? '1' : 0;
2002 udma2
[0] = (identify_info
[88] & (1<<2)) ? '2' : 0;
2003 udma3
[0] = (identify_info
[88] & (1<<3)) ? '3' : 0;
2004 udma4
[0] = (identify_info
[88] & (1<<4)) ? '4' : 0;
2005 udma5
[0] = (identify_info
[88] & (1<<5)) ? '5' : 0;
2006 udma6
[0] = (identify_info
[88] & (1<<6)) ? '6' : 0;
2007 simplelist_addline(SIMPLELIST_ADD_LINE
,
2008 "UDMA modes: %s %s %s %s %s %s %s", udma0
, udma1
, udma2
,
2009 udma3
, udma4
, udma5
, udma6
);
2012 simplelist_addline(SIMPLELIST_ADD_LINE
,
2013 "No UDMA mode info");
2015 #endif /* HAVE_ATA_DMA */
2016 timing_info_present
= identify_info
[53] & (1<<1);
2017 if(timing_info_present
) {
2018 i
= identify_info
[49] & (1<<11);
2019 simplelist_addline(SIMPLELIST_ADD_LINE
,
2020 "IORDY support: %s", i
? "yes" : "no");
2021 i
= identify_info
[49] & (1<<10);
2022 simplelist_addline(SIMPLELIST_ADD_LINE
,
2023 "IORDY disable: %s", i
? "yes" : "no");
2025 simplelist_addline(SIMPLELIST_ADD_LINE
,
2028 simplelist_addline(SIMPLELIST_ADD_LINE
,
2029 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
2031 i
= ata_get_dma_mode();
2033 simplelist_addline(SIMPLELIST_ADD_LINE
,
2036 simplelist_addline(SIMPLELIST_ADD_LINE
,
2038 (i
& 0x40) ? "UDMA" : "MDMA",
2041 #endif /* HAVE_ATA_DMA */
2044 #else /* No SD, MMC or ATA */
2045 static int disk_callback(int btn
, struct gui_synclist
*lists
)
2049 struct storage_info info
;
2050 storage_get_info(0,&info
);
2051 simplelist_addline(SIMPLELIST_ADD_LINE
, "Vendor: %s", info
.vendor
);
2052 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", info
.product
);
2053 simplelist_addline(SIMPLELIST_ADD_LINE
, "Firmware: %s", info
.revision
);
2054 simplelist_addline(SIMPLELIST_ADD_LINE
,
2055 "Size: %ld MB", info
.num_sectors
*(info
.sector_size
/512)/2024);
2057 fat_size( IF_MV2(0,) NULL
, &free
);
2058 simplelist_addline(SIMPLELIST_ADD_LINE
,
2059 "Free: %ld MB", free
/ 1024);
2060 simplelist_addline(SIMPLELIST_ADD_LINE
,
2061 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
2066 #if (CONFIG_STORAGE & STORAGE_ATA)
2067 static bool dbg_identify_info(void)
2069 int fd
= creat("/identify_info.bin", 0666);
2072 #ifdef ROCKBOX_LITTLE_ENDIAN
2073 ecwrite(fd
, ata_get_identify(), SECTOR_SIZE
/2, "s", true);
2075 write(fd
, ata_get_identify(), SECTOR_SIZE
);
2083 static bool dbg_disk_info(void)
2085 struct simplelist_info info
;
2086 simplelist_info_init(&info
, "Disk Info", 1, NULL
);
2087 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
2090 info
.callback_data
= (void*)&card
;
2093 info
.action_callback
= disk_callback
;
2094 info
.hide_selection
= true;
2095 info
.scroll_all
= true;
2096 return simplelist_show_list(&info
);
2098 #endif /* !SIMULATOR */
2100 #ifdef HAVE_DIRCACHE
2101 static int dircache_callback(int btn
, struct gui_synclist
*lists
)
2103 (void)btn
; (void)lists
;
2104 simplelist_set_line_count(0);
2105 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache initialized: %s",
2106 dircache_is_enabled() ? "Yes" : "No");
2107 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache size: %d B",
2108 dircache_get_cache_size());
2109 simplelist_addline(SIMPLELIST_ADD_LINE
, "Last size: %d B",
2110 global_status
.dircache_size
);
2111 simplelist_addline(SIMPLELIST_ADD_LINE
, "Limit: %d B",
2113 simplelist_addline(SIMPLELIST_ADD_LINE
, "Reserve: %d/%d B",
2114 dircache_get_reserve_used(), DIRCACHE_RESERVE
);
2115 simplelist_addline(SIMPLELIST_ADD_LINE
, "Scanning took: %d s",
2116 dircache_get_build_ticks() / HZ
);
2117 simplelist_addline(SIMPLELIST_ADD_LINE
, "Entry count: %d",
2118 dircache_get_entry_count());
2122 static bool dbg_dircache_info(void)
2124 struct simplelist_info info
;
2125 simplelist_info_init(&info
, "Dircache Info", 7, NULL
);
2126 info
.action_callback
= dircache_callback
;
2127 info
.hide_selection
= true;
2128 info
.scroll_all
= true;
2129 return simplelist_show_list(&info
);
2132 #endif /* HAVE_DIRCACHE */
2134 #ifdef HAVE_TAGCACHE
2135 static int database_callback(int btn
, struct gui_synclist
*lists
)
2138 struct tagcache_stat
*stat
= tagcache_get_stat();
2139 static bool synced
= false;
2141 simplelist_set_line_count(0);
2143 simplelist_addline(SIMPLELIST_ADD_LINE
, "Initialized: %s",
2144 stat
->initialized
? "Yes" : "No");
2145 simplelist_addline(SIMPLELIST_ADD_LINE
, "DB Ready: %s",
2146 stat
->ready
? "Yes" : "No");
2147 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM Cache: %s",
2148 stat
->ramcache
? "Yes" : "No");
2149 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM: %d/%d B",
2150 stat
->ramcache_used
, stat
->ramcache_allocated
);
2151 simplelist_addline(SIMPLELIST_ADD_LINE
, "Progress: %d%% (%d entries)",
2152 stat
->progress
, stat
->processed_entries
);
2153 simplelist_addline(SIMPLELIST_ADD_LINE
, "Curfile: %s",
2154 stat
->curentry
? stat
->curentry
: "---");
2155 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit step: %d",
2157 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit delayed: %s",
2158 stat
->commit_delayed
? "Yes" : "No");
2160 simplelist_addline(SIMPLELIST_ADD_LINE
, "Queue length: %d",
2161 stat
->queue_length
);
2166 tagcache_screensync_event();
2169 if (!btn
&& stat
->curentry
)
2172 return ACTION_REDRAW
;
2175 if (btn
== ACTION_STD_CANCEL
)
2176 tagcache_screensync_enable(false);
2180 static bool dbg_tagcache_info(void)
2182 struct simplelist_info info
;
2183 simplelist_info_init(&info
, "Database Info", 8, NULL
);
2184 info
.action_callback
= database_callback
;
2185 info
.hide_selection
= true;
2186 info
.scroll_all
= true;
2188 /* Don't do nonblock here, must give enough processing time
2189 for tagcache thread. */
2190 /* info.timeout = TIMEOUT_NOBLOCK; */
2192 tagcache_screensync_enable(true);
2193 return simplelist_show_list(&info
);
2197 #if CONFIG_CPU == SH7034
2198 static bool dbg_save_roms(void)
2201 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
2203 fd
= creat("/internal_rom_0000-FFFF.bin", 0666);
2206 write(fd
, (void *)0, 0x10000);
2210 fd
= creat("/internal_rom_2000000-203FFFF.bin", 0666);
2213 write(fd
, (void *)0x2000000, 0x40000);
2217 system_memory_guard(oldmode
);
2220 #elif defined CPU_COLDFIRE
2221 static bool dbg_save_roms(void)
2224 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
2226 #if defined(IRIVER_H100_SERIES)
2227 fd
= creat("/internal_rom_000000-1FFFFF.bin", 0666);
2228 #elif defined(IRIVER_H300_SERIES)
2229 fd
= creat("/internal_rom_000000-3FFFFF.bin", 0666);
2230 #elif defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IAUDIO_M3)
2231 fd
= creat("/internal_rom_000000-3FFFFF.bin", 0666);
2232 #elif defined(MPIO_HD200)
2233 fd
= creat("/internal_rom_000000-1FFFFF.bin", 0666);
2237 write(fd
, (void *)0, FLASH_SIZE
);
2240 system_memory_guard(oldmode
);
2243 fd
= creat("/internal_eeprom.bin", 0666);
2247 char buf
[EEPROM_SIZE
];
2250 old_irq_level
= disable_irq_save();
2252 err
= eeprom_24cxx_read(0, buf
, sizeof buf
);
2254 restore_irq(old_irq_level
);
2257 splashf(HZ
*3, "Eeprom read failure (%d)", err
);
2260 write(fd
, buf
, sizeof buf
);
2269 #elif defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD)
2270 static bool dbg_save_roms(void)
2274 fd
= creat("/internal_rom_000000-0FFFFF.bin", 0666);
2277 write(fd
, (void *)0x20000000, FLASH_SIZE
);
2283 #elif CONFIG_CPU == IMX31L
2284 static bool dbg_save_roms(void)
2288 fd
= creat("/flash_rom_A0000000-A01FFFFF.bin", 0666);
2291 write(fd
, (void*)0xa0000000, FLASH_SIZE
);
2297 #elif defined(CPU_TCC780X)
2298 static bool dbg_save_roms(void)
2302 fd
= creat("/eeprom_E0000000-E0001FFF.bin", 0666);
2305 write(fd
, (void*)0xe0000000, 0x2000);
2315 static int radio_callback(int btn
, struct gui_synclist
*lists
)
2318 if (btn
== ACTION_STD_CANCEL
)
2320 simplelist_set_line_count(1);
2322 #if (CONFIG_TUNER & LV24020LP)
2323 simplelist_addline(SIMPLELIST_ADD_LINE
,
2324 "CTRL_STAT: %02X", lv24020lp_get(LV24020LP_CTRL_STAT
) );
2325 simplelist_addline(SIMPLELIST_ADD_LINE
,
2326 "RADIO_STAT: %02X", lv24020lp_get(LV24020LP_REG_STAT
) );
2327 simplelist_addline(SIMPLELIST_ADD_LINE
,
2328 "MSS_FM: %d kHz", lv24020lp_get(LV24020LP_MSS_FM
) );
2329 simplelist_addline(SIMPLELIST_ADD_LINE
,
2330 "MSS_IF: %d Hz", lv24020lp_get(LV24020LP_MSS_IF
) );
2331 simplelist_addline(SIMPLELIST_ADD_LINE
,
2332 "MSS_SD: %d Hz", lv24020lp_get(LV24020LP_MSS_SD
) );
2333 simplelist_addline(SIMPLELIST_ADD_LINE
,
2334 "if_set: %d Hz", lv24020lp_get(LV24020LP_IF_SET
) );
2335 simplelist_addline(SIMPLELIST_ADD_LINE
,
2336 "sd_set: %d Hz", lv24020lp_get(LV24020LP_SD_SET
) );
2337 #endif /* LV24020LP */
2338 #if (CONFIG_TUNER & S1A0903X01)
2339 simplelist_addline(SIMPLELIST_ADD_LINE
,
2340 "Samsung regs: %08X", s1a0903x01_get(RADIO_ALL
));
2341 /* This one doesn't return dynamic data atm */
2342 #endif /* S1A0903X01 */
2343 #if (CONFIG_TUNER & TEA5767)
2344 struct tea5767_dbg_info nfo
;
2345 tea5767_dbg_info(&nfo
);
2346 simplelist_addline(SIMPLELIST_ADD_LINE
, "Philips regs:");
2347 simplelist_addline(SIMPLELIST_ADD_LINE
,
2348 " Read: %02X %02X %02X %02X %02X",
2349 (unsigned)nfo
.read_regs
[0], (unsigned)nfo
.read_regs
[1],
2350 (unsigned)nfo
.read_regs
[2], (unsigned)nfo
.read_regs
[3],
2351 (unsigned)nfo
.read_regs
[4]);
2352 simplelist_addline(SIMPLELIST_ADD_LINE
,
2353 " Write: %02X %02X %02X %02X %02X",
2354 (unsigned)nfo
.write_regs
[0], (unsigned)nfo
.write_regs
[1],
2355 (unsigned)nfo
.write_regs
[2], (unsigned)nfo
.write_regs
[3],
2356 (unsigned)nfo
.write_regs
[4]);
2357 #endif /* TEA5767 */
2358 #if (CONFIG_TUNER & SI4700)
2359 struct si4700_dbg_info nfo
;
2360 si4700_dbg_info(&nfo
);
2361 simplelist_addline(SIMPLELIST_ADD_LINE
, "SI4700 regs:");
2363 simplelist_addline(SIMPLELIST_ADD_LINE
,
2364 "%04X %04X %04X %04X",
2365 (unsigned)nfo
.regs
[0], (unsigned)nfo
.regs
[1],
2366 (unsigned)nfo
.regs
[2], (unsigned)nfo
.regs
[3]);
2367 simplelist_addline(SIMPLELIST_ADD_LINE
,
2368 "%04X %04X %04X %04X",
2369 (unsigned)nfo
.regs
[4], (unsigned)nfo
.regs
[5],
2370 (unsigned)nfo
.regs
[6], (unsigned)nfo
.regs
[7]);
2371 simplelist_addline(SIMPLELIST_ADD_LINE
,
2372 "%04X %04X %04X %04X",
2373 (unsigned)nfo
.regs
[8], (unsigned)nfo
.regs
[9],
2374 (unsigned)nfo
.regs
[10], (unsigned)nfo
.regs
[11]);
2375 simplelist_addline(SIMPLELIST_ADD_LINE
,
2376 "%04X %04X %04X %04X",
2377 (unsigned)nfo
.regs
[12], (unsigned)nfo
.regs
[13],
2378 (unsigned)nfo
.regs
[14], (unsigned)nfo
.regs
[15]);
2380 return ACTION_REDRAW
;
2382 static bool dbg_fm_radio(void)
2384 struct simplelist_info info
;
2385 info
.scroll_all
= true;
2386 simplelist_info_init(&info
, "FM Radio", 1, NULL
);
2387 simplelist_set_line_count(0);
2388 simplelist_addline(SIMPLELIST_ADD_LINE
, "HW detected: %s",
2389 radio_hardware_present() ? "yes" : "no");
2391 info
.action_callback
= radio_hardware_present()?radio_callback
: NULL
;
2392 info
.hide_selection
= true;
2393 return simplelist_show_list(&info
);
2395 #endif /* CONFIG_TUNER */
2396 #endif /* !SIMULATOR */
2398 #ifdef HAVE_LCD_BITMAP
2399 extern bool do_screendump_instead_of_usb
;
2401 static bool dbg_screendump(void)
2403 do_screendump_instead_of_usb
= !do_screendump_instead_of_usb
;
2404 splashf(HZ
, "Screendump %s",
2405 do_screendump_instead_of_usb
?"enabled":"disabled");
2408 #endif /* HAVE_LCD_BITMAP */
2410 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2411 static bool dbg_set_memory_guard(void)
2413 static const struct opt_items names
[MAXMEMGUARD
] = {
2415 { "Flash ROM writes", -1 },
2416 { "Zero area (all)", -1 }
2418 int mode
= system_memory_guard(MEMGUARD_KEEP
);
2420 set_option( "Catch mem accesses", &mode
, INT
, names
, MAXMEMGUARD
, NULL
);
2421 system_memory_guard(mode
);
2425 #endif /* CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) */
2427 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2428 static bool dbg_write_eeprom(void)
2433 char buf
[EEPROM_SIZE
];
2436 fd
= open("/internal_eeprom.bin", O_RDONLY
);
2440 rc
= read(fd
, buf
, EEPROM_SIZE
);
2442 if(rc
== EEPROM_SIZE
)
2444 old_irq_level
= disable_irq_save();
2446 err
= eeprom_24cxx_write(0, buf
, sizeof buf
);
2448 splashf(HZ
*3, "Eeprom write failure (%d)", err
);
2450 splash(HZ
*3, "Eeprom written successfully");
2452 restore_irq(old_irq_level
);
2456 splashf(HZ
*3, "File read error (%d)",rc
);
2462 splash(HZ
*3, "Failed to open 'internal_eeprom.bin'");
2467 #endif /* defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS) */
2468 #ifdef CPU_BOOST_LOGGING
2469 static bool cpu_boost_log(void)
2472 int count
= cpu_boost_log_getcount();
2473 int lines
= LCD_HEIGHT
/SYSFONT_HEIGHT
;
2476 lcd_setfont(FONT_SYSFIXED
);
2477 str
= cpu_boost_log_getlog_first();
2480 lcd_clear_display();
2481 for(j
=0; j
<lines
; j
++,i
++)
2484 str
= cpu_boost_log_getlog_next();
2487 if(strlen(str
) > LCD_WIDTH
/SYSFONT_WIDTH
)
2488 lcd_puts_scroll(0, j
, str
);
2498 switch(get_action(CONTEXT_STD
,TIMEOUT_BLOCK
))
2501 case ACTION_STD_PREV
:
2502 case ACTION_STD_NEXT
:
2505 case ACTION_STD_CANCEL
:
2513 get_action(CONTEXT_STD
,TIMEOUT_BLOCK
);
2514 lcd_setfont(FONT_UI
);
2519 #if (defined(HAVE_WHEEL_ACCELERATION) && (CONFIG_KEYPAD==IPOD_4G_PAD) && !defined(SIMULATOR))
2520 extern bool wheel_is_touched
;
2521 extern int old_wheel_value
;
2522 extern int new_wheel_value
;
2523 extern int wheel_delta
;
2524 extern unsigned int accumulated_wheel_delta
;
2525 extern unsigned int wheel_velocity
;
2527 static bool dbg_scrollwheel(void)
2531 lcd_setfont(FONT_SYSFIXED
);
2535 if (action_userabort(HZ
/10))
2538 lcd_clear_display();
2540 /* show internal variables of scrollwheel driver */
2541 lcd_putsf(0, 0, "wheel touched: %s", (wheel_is_touched
) ? "true" : "false");
2542 lcd_putsf(0, 1, "new position: %2d", new_wheel_value
);
2543 lcd_putsf(0, 2, "old position: %2d", old_wheel_value
);
2544 lcd_putsf(0, 3, "wheel delta: %2d", wheel_delta
);
2545 lcd_putsf(0, 4, "accumulated delta: %2d", accumulated_wheel_delta
);
2546 lcd_putsf(0, 5, "velo [deg/s]: %4d", (int)wheel_velocity
);
2548 /* show effective accelerated scrollspeed */
2549 speed
= button_apply_acceleration( (1<<31)|(1<<24)|wheel_velocity
);
2550 lcd_putsf(0, 6, "accel. speed: %4d", speed
);
2554 lcd_setfont(FONT_UI
);
2559 #if defined (HAVE_USBSTACK)
2561 #if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL)
2562 static bool toggle_usb_core_driver(int driver
, char *msg
)
2564 bool enabled
= !usb_core_driver_enabled(driver
);
2566 usb_core_enable_driver(driver
,enabled
);
2567 splashf(HZ
, "%s %s", msg
, enabled
?"enabled":"disabled");
2572 static bool toggle_usb_serial(void)
2574 return toggle_usb_core_driver(USB_DRIVER_SERIAL
,"USB Serial");
2580 #if CONFIG_USBOTG == USBOTG_ISP1583
2581 extern int dbg_usb_num_items(void);
2582 extern const char* dbg_usb_item(int selected_item
, void *data
,
2583 char *buffer
, size_t buffer_len
);
2585 static int isp1583_action_callback(int action
, struct gui_synclist
*lists
)
2588 if (action
== ACTION_NONE
)
2589 action
= ACTION_REDRAW
;
2593 static bool dbg_isp1583(void)
2595 struct simplelist_info isp1583
;
2596 isp1583
.scroll_all
= true;
2597 simplelist_info_init(&isp1583
, "ISP1583", dbg_usb_num_items(), NULL
);
2598 isp1583
.timeout
= HZ
/100;
2599 isp1583
.hide_selection
= true;
2600 isp1583
.get_name
= dbg_usb_item
;
2601 isp1583
.action_callback
= isp1583_action_callback
;
2602 return simplelist_show_list(&isp1583
);
2606 #if defined(CREATIVE_ZVx) && !defined(SIMULATOR)
2607 extern int pic_dbg_num_items(void);
2608 extern const char* pic_dbg_item(int selected_item
, void *data
,
2609 char *buffer
, size_t buffer_len
);
2611 static int pic_action_callback(int action
, struct gui_synclist
*lists
)
2614 if (action
== ACTION_NONE
)
2615 action
= ACTION_REDRAW
;
2619 static bool dbg_pic(void)
2621 struct simplelist_info pic
;
2622 pic
.scroll_all
= true;
2623 simplelist_info_init(&pic
, "PIC", pic_dbg_num_items(), NULL
);
2624 pic
.timeout
= HZ
/100;
2625 pic
.hide_selection
= true;
2626 pic
.get_name
= pic_dbg_item
;
2627 pic
.action_callback
= pic_action_callback
;
2628 return simplelist_show_list(&pic
);
2633 /****** The menu *********/
2634 struct the_menu_item
{
2635 unsigned char *desc
; /* string or ID */
2636 bool (*function
) (void); /* return true if USB was connected */
2638 static const struct the_menu_item menuitems
[] = {
2639 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || \
2640 (defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD)) || \
2641 CONFIG_CPU == IMX31L || defined(CPU_TCC780X)
2642 { "Dump ROM contents", dbg_save_roms
},
2644 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || defined(CPU_PP) \
2645 || CONFIG_CPU == S3C2440 || CONFIG_CPU == IMX31L || CONFIG_CPU == AS3525 \
2646 || CONFIG_CPU == DM320 || defined(CPU_S5L870X) || CONFIG_CPU == AS3525v2
2647 { "View I/O ports", dbg_ports
},
2649 #if (CONFIG_RTC == RTC_PCF50605) && !defined(SIMULATOR)
2650 { "View PCF registers", dbg_pcf
},
2652 #if defined(HAVE_TSC2100) && !defined(SIMULATOR)
2653 { "TSC2100 debug", tsc2100_debug
},
2655 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
2656 { "CPU frequency", dbg_cpufreq
},
2658 #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR)
2659 { "S/PDIF analyzer", dbg_spdif
},
2661 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2662 { "Catch mem accesses", dbg_set_memory_guard
},
2664 { "View OS stacks", dbg_os
},
2665 #ifdef HAVE_LCD_BITMAP
2667 { "View battery", view_battery
},
2669 { "Screendump", dbg_screendump
},
2672 { "View HW info", dbg_hw_info
},
2675 { "View partitions", dbg_partitions
},
2678 { "View disk info", dbg_disk_info
},
2679 #if (CONFIG_STORAGE & STORAGE_ATA)
2680 { "Dump ATA identify info", dbg_identify_info
},
2683 #ifdef HAVE_DIRCACHE
2684 { "View dircache info", dbg_dircache_info
},
2686 #ifdef HAVE_TAGCACHE
2687 { "View database info", dbg_tagcache_info
},
2689 #ifdef HAVE_LCD_BITMAP
2690 #if CONFIG_CODEC == SWCODEC
2691 { "View buffering thread", dbg_buffering_thread
},
2692 #elif !defined(SIMULATOR)
2693 { "View audio thread", dbg_audio_thread
},
2696 { "pm histogram", peak_meter_histogram
},
2697 #endif /* PM_DEBUG */
2698 #endif /* HAVE_LCD_BITMAP */
2701 { "FM Radio", dbg_fm_radio
},
2704 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2705 { "Write back EEPROM", dbg_write_eeprom
},
2707 #if CONFIG_USBOTG == USBOTG_ISP1583
2708 { "View ISP1583 info", dbg_isp1583
},
2710 #if defined(CREATIVE_ZVx) && !defined(SIMULATOR)
2711 { "View PIC info", dbg_pic
},
2713 #ifdef ROCKBOX_HAS_LOGF
2714 {"Show Log File", logfdisplay
},
2715 {"Dump Log File", logfdump
},
2717 #if defined(HAVE_USBSTACK)
2718 #if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL)
2719 {"USB Serial driver (logf)", toggle_usb_serial
},
2721 #endif /* HAVE_USBSTACK */
2722 #ifdef CPU_BOOST_LOGGING
2723 {"cpu_boost log",cpu_boost_log
},
2725 #if (defined(HAVE_WHEEL_ACCELERATION) && (CONFIG_KEYPAD==IPOD_4G_PAD) && !defined(SIMULATOR))
2726 {"Debug scrollwheel", dbg_scrollwheel
},
2729 static int menu_action_callback(int btn
, struct gui_synclist
*lists
)
2732 if (btn
== ACTION_STD_OK
)
2735 viewportmanager_theme_enable(i
, false, NULL
);
2736 menuitems
[gui_synclist_get_sel_pos(lists
)].function();
2737 btn
= ACTION_REDRAW
;
2739 viewportmanager_theme_undo(i
, false);
2744 static const char* dbg_menu_getname(int item
, void * data
,
2745 char *buffer
, size_t buffer_len
)
2747 (void)data
; (void)buffer
; (void)buffer_len
;
2748 return menuitems
[item
].desc
;
2751 bool debug_menu(void)
2753 struct simplelist_info info
;
2755 simplelist_info_init(&info
, "Debug Menu", ARRAYLEN(menuitems
), NULL
);
2756 info
.action_callback
= menu_action_callback
;
2757 info
.get_name
= dbg_menu_getname
;
2758 return simplelist_show_list(&info
);