1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Heikki Hannikainen
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
26 #include "debug_menu.h"
33 #include "powermgmt.h"
37 #include "mp3_playback.h"
40 #include "statusbar.h"
50 #include "lcd-remote.h"
62 #include "eeprom_24cxx.h"
63 #if defined(HAVE_MMC) || defined(HAVE_HOTSWAP)
72 #ifdef HAVE_LCD_BITMAP
73 #include "scrollbar.h"
74 #include "peakmeter.h"
77 #if CONFIG_CODEC == SWCODEC
79 #include "buffering.h"
81 #if defined(HAVE_SPDIF_OUT) || defined(HAVE_SPDIF_IN)
85 #ifdef IRIVER_H300_SERIES
86 #include "pcf50606.h" /* for pcf50606_read */
93 #if CONFIG_RTC == RTC_PCF50605
97 #if CONFIG_CPU == DM320 || CONFIG_CPU == S3C2440 || CONFIG_CPU == TCC7801 \
98 || CONFIG_CPU == IMX31L
99 #include "debug-target.h"
102 #if defined(SANSA_E200)
107 #if defined(HAVE_USBSTACK)
108 #include "usb_core.h"
111 #include "../firmware/usbstack/usb_storage.h"
114 /*---------------------------------------------------*/
115 /* SPECIAL DEBUG STUFF */
116 /*---------------------------------------------------*/
117 extern struct thread_entry threads
[MAXTHREADS
];
119 static char thread_status_char(unsigned status
)
121 static const char thread_status_chars
[THREAD_NUM_STATES
+1] =
123 [0 ... THREAD_NUM_STATES
] = '?',
124 [STATE_RUNNING
] = 'R',
125 [STATE_BLOCKED
] = 'B',
126 [STATE_SLEEPING
] = 'S',
127 [STATE_BLOCKED_W_TMO
] = 'T',
128 [STATE_FROZEN
] = 'F',
129 [STATE_KILLED
] = 'K',
132 if (status
> THREAD_NUM_STATES
)
133 status
= THREAD_NUM_STATES
;
135 return thread_status_chars
[status
];
138 static char* threads_getname(int selected_item
, void *data
,
139 char *buffer
, size_t buffer_len
)
142 struct thread_entry
*thread
;
146 if (selected_item
< (int)NUM_CORES
)
148 snprintf(buffer
, buffer_len
, "Idle (%d): %2d%%", selected_item
,
149 idle_stack_usage(selected_item
));
153 selected_item
-= NUM_CORES
;
156 thread
= &threads
[selected_item
];
158 if (thread
->state
== STATE_KILLED
)
160 snprintf(buffer
, buffer_len
, "%2d: ---", selected_item
);
164 thread_get_name(name
, 32, thread
);
166 snprintf(buffer
, buffer_len
,
167 "%2d: " IF_COP("(%d) ") "%c%c " IF_PRIO("%d %d ") "%2d%% %s",
169 IF_COP(thread
->core
,)
170 #ifdef HAVE_SCHEDULER_BOOSTCTRL
171 (thread
->cpu_boost
) ? '+' :
173 ((thread
->state
== STATE_RUNNING
) ? '*' : ' '),
174 thread_status_char(thread
->state
),
175 IF_PRIO(thread
->base_priority
, thread
->priority
, )
176 thread_stack_usage(thread
), name
);
180 static int dbg_threads_action_callback(int action
, struct gui_synclist
*lists
)
183 #ifdef ROCKBOX_HAS_LOGF
184 if (action
== ACTION_STD_OK
)
186 int selpos
= gui_synclist_get_sel_pos(lists
);
188 if (selpos
>= NUM_CORES
)
189 remove_thread(&threads
[selpos
- NUM_CORES
]);
191 remove_thread(&threads
[selpos
]);
193 return ACTION_REDRAW
;
195 #endif /* ROCKBOX_HAS_LOGF */
196 if (action
== ACTION_NONE
)
197 action
= ACTION_REDRAW
;
201 static bool dbg_os(void)
203 struct simplelist_info info
;
204 simplelist_info_init(&info
, IF_COP("Core and ") "Stack usage:",
208 MAXTHREADS
+NUM_CORES
,
211 #ifndef ROCKBOX_HAS_LOGF
212 info
.hide_selection
= true;
214 info
.action_callback
= dbg_threads_action_callback
;
215 info
.get_name
= threads_getname
;
216 return simplelist_show_list(&info
);
219 #ifdef HAVE_LCD_BITMAP
220 #if CONFIG_CODEC != SWCODEC
222 static bool dbg_audio_thread(void)
225 struct audio_debug d
;
227 lcd_setmargins(0, 0);
228 lcd_setfont(FONT_SYSFIXED
);
232 if (action_userabort(HZ
/5))
235 audio_get_debugdata(&d
);
239 snprintf(buf
, sizeof(buf
), "read: %x", d
.audiobuf_read
);
241 snprintf(buf
, sizeof(buf
), "write: %x", d
.audiobuf_write
);
243 snprintf(buf
, sizeof(buf
), "swap: %x", d
.audiobuf_swapwrite
);
245 snprintf(buf
, sizeof(buf
), "playing: %d", d
.playing
);
247 snprintf(buf
, sizeof(buf
), "playable: %x", d
.playable_space
);
249 snprintf(buf
, sizeof(buf
), "unswapped: %x", d
.unswapped_space
);
252 /* Playable space left */
253 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8, 112, 4, d
.audiobuflen
, 0,
254 d
.playable_space
, HORIZONTAL
);
256 /* Show the watermark limit */
257 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8+4, 112, 4, d
.audiobuflen
, 0,
258 d
.low_watermark_level
, HORIZONTAL
);
260 snprintf(buf
, sizeof(buf
), "wm: %x - %x",
261 d
.low_watermark_level
, d
.lowest_watermark_level
);
268 #endif /* !SIMULATOR */
269 #else /* CONFIG_CODEC == SWCODEC */
270 extern size_t filebuflen
;
271 /* This is a size_t, but call it a long so it puts a - when it's bad. */
273 static unsigned int ticks
, boost_ticks
, freq_sum
;
275 static void dbg_audio_task(void)
278 if(FREQ
> CPUFREQ_NORMAL
)
280 freq_sum
+= FREQ
/1000000; /* in MHz */
285 static bool dbg_buffering_thread(void)
292 size_t bufsize
= pcmbuf_get_bufsize();
293 int pcmbufdescs
= pcmbuf_descs();
294 struct buffering_debug d
;
296 ticks
= boost_ticks
= freq_sum
= 0;
298 tick_add_task(dbg_audio_task
);
300 lcd_setmargins(0, 0);
301 lcd_setfont(FONT_SYSFIXED
);
304 button
= get_action(CONTEXT_STD
,HZ
/5);
307 case ACTION_STD_NEXT
:
310 case ACTION_STD_PREV
:
313 case ACTION_STD_CANCEL
:
318 buffering_get_debugdata(&d
);
323 bufused
= bufsize
- pcmbuf_free();
325 snprintf(buf
, sizeof(buf
), "pcm: %7ld/%7ld", (long) bufused
, (long) bufsize
);
326 lcd_puts(0, line
++, buf
);
328 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
329 bufsize
, 0, bufused
, HORIZONTAL
);
332 snprintf(buf
, sizeof(buf
), "alloc: %8ld/%8ld", audio_filebufused(),
334 lcd_puts(0, line
++, buf
);
337 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
338 filebuflen
, 0, audio_filebufused(), HORIZONTAL
);
341 snprintf(buf
, sizeof(buf
), "real: %8ld/%8ld", (long)d
.buffered_data
,
343 lcd_puts(0, line
++, buf
);
345 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
346 filebuflen
, 0, (long)d
.buffered_data
, HORIZONTAL
);
350 snprintf(buf
, sizeof(buf
), "usefl: %8ld/%8ld", (long)(d
.useful_data
),
352 lcd_puts(0, line
++, buf
);
355 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
356 filebuflen
, 0, d
.useful_data
, HORIZONTAL
);
360 snprintf(buf
, sizeof(buf
), "data_rem: %ld", (long)d
.data_rem
);
361 lcd_puts(0, line
++, buf
);
363 snprintf(buf
, sizeof(buf
), "track count: %2d", audio_track_count());
364 lcd_puts(0, line
++, buf
);
366 snprintf(buf
, sizeof(buf
), "handle count: %d", (int)d
.num_handles
);
367 lcd_puts(0, line
++, buf
);
370 snprintf(buf
, sizeof(buf
), "cpu freq: %3dMHz",
371 (int)((FREQ
+ 500000) / 1000000));
372 lcd_puts(0, line
++, buf
);
377 int boostquota
= boost_ticks
* 1000 / ticks
; /* in °/oo */
378 int avgclock
= freq_sum
* 10 / ticks
; /* in 100 kHz */
379 snprintf(buf
, sizeof(buf
), "boost ratio: %3d.%d%% (%2d.%dMHz)",
380 boostquota
/10, boostquota
%10, avgclock
/10, avgclock
%10);
381 lcd_puts(0, line
++, buf
);
384 snprintf(buf
, sizeof(buf
), "pcmbufdesc: %2d/%2d",
385 pcmbuf_used_descs(), pcmbufdescs
);
386 lcd_puts(0, line
++, buf
);
391 tick_remove_task(dbg_audio_task
);
395 #endif /* CONFIG_CODEC */
396 #endif /* HAVE_LCD_BITMAP */
399 #if (CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE))
400 /* Tool function to read the flash manufacturer and type, if available.
401 Only chips which could be reprogrammed in system will return values.
402 (The mode switch addresses vary between flash manufacturers, hence addr1/2) */
403 /* In IRAM to avoid problems when running directly from Flash */
404 static bool dbg_flash_id(unsigned* p_manufacturer
, unsigned* p_device
,
405 unsigned addr1
, unsigned addr2
)
406 ICODE_ATTR
__attribute__((noinline
));
407 static bool dbg_flash_id(unsigned* p_manufacturer
, unsigned* p_device
,
408 unsigned addr1
, unsigned addr2
)
411 unsigned not_manu
, not_id
; /* read values before switching to ID mode */
412 unsigned manu
, id
; /* read values when in ID mode */
414 #if CONFIG_CPU == SH7034
415 volatile unsigned char* flash
= (unsigned char*)0x2000000; /* flash mapping */
416 #elif defined(CPU_COLDFIRE)
417 volatile unsigned short* flash
= (unsigned short*)0; /* flash mapping */
419 int old_level
; /* saved interrupt level */
421 not_manu
= flash
[0]; /* read the normal content */
422 not_id
= flash
[1]; /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */
424 /* disable interrupts, prevent any stray flash access */
425 old_level
= disable_irq_save();
427 flash
[addr1
] = 0xAA; /* enter command mode */
429 flash
[addr1
] = 0x90; /* ID command */
430 /* Atmel wants 20ms pause here */
431 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
433 manu
= flash
[0]; /* read the IDs */
436 flash
[0] = 0xF0; /* reset flash (back to normal read mode) */
437 /* Atmel wants 20ms pause here */
438 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
440 restore_irq(old_level
); /* enable interrupts again */
442 /* I assume success if the obtained values are different from
443 the normal flash content. This is not perfectly bulletproof, they
444 could theoretically be the same by chance, causing us to fail. */
445 if (not_manu
!= manu
|| not_id
!= id
) /* a value has changed */
447 *p_manufacturer
= manu
; /* return the results */
449 return true; /* success */
451 return false; /* fail */
453 #endif /* (CONFIG_CPU == SH7034 || CPU_COLDFIRE) */
457 static int perfcheck(void)
463 "orr r0, r2, #0xc0 \n" /* disable IRQ and FIQ */
466 "ldr r0, [%[timr]] \n"
467 "add r0, r0, %[tmo] \n"
469 "add %[res], %[res], #1 \n"
470 "ldr r1, [%[timr]] \n"
473 "msr CPSR_c, r2 \n" /* reset IRQ and FIQ state */
477 [timr
]"r"(&USEC_TIMER
),
479 #if CONFIG_CPU == PP5002
481 #else /* PP5020/5022/5024 */
492 #ifdef HAVE_LCD_BITMAP
493 static bool dbg_hw_info(void)
495 #if CONFIG_CPU == SH7034
497 int bitmask
= HW_MASK
;
498 int rom_version
= ROM_VERSION
;
499 unsigned manu
, id
; /* flash IDs */
500 bool got_id
; /* flag if we managed to get the flash IDs */
501 unsigned rom_crc
= 0xffffffff; /* CRC32 of the boot ROM */
502 bool has_bootrom
; /* flag for boot ROM present */
503 int oldmode
; /* saved memory guard mode */
505 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
507 /* get flash ROM type */
508 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
510 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
512 /* check if the boot ROM area is a flash mirror */
513 has_bootrom
= (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
514 if (has_bootrom
) /* if ROM and Flash different */
516 /* calculate CRC16 checksum of boot ROM */
517 rom_crc
= crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
520 system_memory_guard(oldmode
); /* re-enable memory guard */
522 lcd_setmargins(0, 0);
523 lcd_setfont(FONT_SYSFIXED
);
526 lcd_puts(0, 0, "[Hardware info]");
528 snprintf(buf
, 32, "ROM: %d.%02d", rom_version
/100, rom_version
%100);
531 snprintf(buf
, 32, "Mask: 0x%04x", bitmask
);
535 snprintf(buf
, 32, "Flash: M=%02x D=%02x", manu
, id
);
537 snprintf(buf
, 32, "Flash: M=?? D=??"); /* unknown, sorry */
542 if (rom_crc
== 0x56DBA4EE) /* known Version 1 */
543 snprintf(buf
, 32, "Boot ROM: V1");
545 snprintf(buf
, 32, "ROMcrc: 0x%08x", rom_crc
);
549 snprintf(buf
, 32, "Boot ROM: none");
555 while (!(action_userabort(TIMEOUT_BLOCK
)));
557 #elif CONFIG_CPU == MCF5249 || CONFIG_CPU == MCF5250
559 unsigned manu
, id
; /* flash IDs */
560 int got_id
; /* flag if we managed to get the flash IDs */
561 int oldmode
; /* saved memory guard mode */
564 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
566 /* get flash ROM type */
567 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
569 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
571 system_memory_guard(oldmode
); /* re-enable memory guard */
573 lcd_setmargins(0, 0);
574 lcd_setfont(FONT_SYSFIXED
);
577 lcd_puts(0, line
++, "[Hardware info]");
580 snprintf(buf
, 32, "Flash: M=%04x D=%04x", manu
, id
);
582 snprintf(buf
, 32, "Flash: M=???? D=????"); /* unknown, sorry */
583 lcd_puts(0, line
++, buf
);
589 lcd_puts(0, ++line
, "Serial Number:");
591 got_id
= ds2411_read_id(&id
);
593 if (got_id
== DS2411_OK
)
595 snprintf(buf
, 32, " FC=%02x", (unsigned)id
.family_code
);
596 lcd_puts(0, ++line
, buf
);
597 snprintf(buf
, 32, " ID=%02X %02X %02X %02X %02X %02X",
598 (unsigned)id
.uid
[0], (unsigned)id
.uid
[1], (unsigned)id
.uid
[2],
599 (unsigned)id
.uid
[3], (unsigned)id
.uid
[4], (unsigned)id
.uid
[5]);
600 lcd_puts(0, ++line
, buf
);
601 snprintf(buf
, 32, " CRC=%02X", (unsigned)id
.crc
);
605 snprintf(buf
, 32, "READ ERR=%d", got_id
);
608 lcd_puts(0, ++line
, buf
);
614 while (!(action_userabort(TIMEOUT_BLOCK
)));
616 #elif defined(CPU_PP502x)
619 char pp_version
[] = { (PP_VER2
>> 24) & 0xff, (PP_VER2
>> 16) & 0xff,
620 (PP_VER2
>> 8) & 0xff, (PP_VER2
) & 0xff,
621 (PP_VER1
>> 24) & 0xff, (PP_VER1
>> 16) & 0xff,
622 (PP_VER1
>> 8) & 0xff, (PP_VER1
) & 0xff, '\0' };
624 lcd_setmargins(0, 0);
625 lcd_setfont(FONT_SYSFIXED
);
628 lcd_puts(0, line
++, "[Hardware info]");
631 snprintf(buf
, sizeof(buf
), "HW rev: 0x%08lx", IPOD_HW_REVISION
);
632 lcd_puts(0, line
++, buf
);
636 extern int lcd_type
; /* Defined in lcd-colornano.c */
638 snprintf(buf
, sizeof(buf
), "LCD type: %d", lcd_type
);
639 lcd_puts(0, line
++, buf
);
642 snprintf(buf
, sizeof(buf
), "PP version: %s", pp_version
);
643 lcd_puts(0, line
++, buf
);
645 snprintf(buf
, sizeof(buf
), "Est. clock (kHz): %d", perfcheck());
646 lcd_puts(0, line
++, buf
);
650 while (!(action_userabort(TIMEOUT_BLOCK
)));
652 #elif CONFIG_CPU == PP5002
655 char pp_version
[] = { (PP_VER4
>> 8) & 0xff, PP_VER4
& 0xff,
656 (PP_VER3
>> 8) & 0xff, PP_VER3
& 0xff,
657 (PP_VER2
>> 8) & 0xff, PP_VER2
& 0xff,
658 (PP_VER1
>> 8) & 0xff, PP_VER1
& 0xff, '\0' };
661 lcd_setmargins(0, 0);
662 lcd_setfont(FONT_SYSFIXED
);
665 lcd_puts(0, line
++, "[Hardware info]");
668 snprintf(buf
, sizeof(buf
), "HW rev: 0x%08lx", IPOD_HW_REVISION
);
669 lcd_puts(0, line
++, buf
);
672 snprintf(buf
, sizeof(buf
), "PP version: %s", pp_version
);
673 lcd_puts(0, line
++, buf
);
675 snprintf(buf
, sizeof(buf
), "Est. clock (kHz): %d", perfcheck());
676 lcd_puts(0, line
++, buf
);
680 while (!(action_userabort(TIMEOUT_BLOCK
)));
682 /* Define this function in your target tree */
683 return __dbg_hw_info();
684 #endif /* CONFIG_CPU */
687 #else /* !HAVE_LCD_BITMAP */
688 static bool dbg_hw_info(void)
693 int rom_version
= ROM_VERSION
;
694 unsigned manu
, id
; /* flash IDs */
695 bool got_id
; /* flag if we managed to get the flash IDs */
696 unsigned rom_crc
= 0xffffffff; /* CRC32 of the boot ROM */
697 bool has_bootrom
; /* flag for boot ROM present */
698 int oldmode
; /* saved memory guard mode */
700 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
702 /* get flash ROM type */
703 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
705 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
707 /* check if the boot ROM area is a flash mirror */
708 has_bootrom
= (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
709 if (has_bootrom
) /* if ROM and Flash different */
711 /* calculate CRC16 checksum of boot ROM */
712 rom_crc
= crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
715 system_memory_guard(oldmode
); /* re-enable memory guard */
719 lcd_puts(0, 0, "[HW Info]");
725 snprintf(buf
, 32, "ROM: %d.%02d",
726 rom_version
/100, rom_version
%100);
730 snprintf(buf
, 32, "Flash:%02x,%02x", manu
, id
);
732 snprintf(buf
, 32, "Flash:??,??"); /* unknown, sorry */
737 if (rom_crc
== 0x56DBA4EE) /* known Version 1 */
738 snprintf(buf
, 32, "BootROM: V1");
739 else if (rom_crc
== 0x358099E8)
740 snprintf(buf
, 32, "BootROM: V2");
741 /* alternative boot ROM found in one single player so far */
743 snprintf(buf
, 32, "R: %08x", rom_crc
);
746 snprintf(buf
, 32, "BootROM: no");
752 button
= get_action(CONTEXT_SETTINGS
,TIMEOUT_BLOCK
);
756 case ACTION_STD_CANCEL
:
759 case ACTION_SETTINGS_DEC
:
765 case ACTION_SETTINGS_INC
:
774 #endif /* !HAVE_LCD_BITMAP */
775 #endif /* !SIMULATOR */
778 static char* dbg_partitions_getname(int selected_item
, void *data
,
779 char *buffer
, size_t buffer_len
)
782 int partition
= selected_item
/2;
783 struct partinfo
* p
= disk_partinfo(partition
);
786 snprintf(buffer
, buffer_len
, " T:%x %ld MB", p
->type
, p
->size
/ 2048);
790 snprintf(buffer
, buffer_len
, "P%d: S:%lx", partition
, p
->start
);
795 bool dbg_partitions(void)
797 struct simplelist_info info
;
798 simplelist_info_init(&info
, "Partition Info", 4, NULL
);
799 info
.selection_size
= 2;
800 info
.hide_selection
= true;
801 info
.get_name
= dbg_partitions_getname
;
802 return simplelist_show_list(&info
);
806 #if defined(CPU_COLDFIRE) && defined(HAVE_SPDIF_OUT)
807 static bool dbg_spdif(void)
811 unsigned int control
;
816 unsigned int interruptstat
;
817 bool valnogood
, symbolerr
, parityerr
;
820 int spdif_source
= spdif_get_output_source(&spdif_src_on
);
821 spdif_set_output_source(AUDIO_SRC_SPDIF
IF_SPDIF_POWER_(, true));
823 lcd_setmargins(0, 0);
825 lcd_setfont(FONT_SYSFIXED
);
827 #ifdef HAVE_SPDIF_POWER
828 spdif_power_enable(true); /* We need SPDIF power for both sending & receiving */
835 control
= EBU1RCVCCHANNEL1
;
836 interruptstat
= INTERRUPTSTAT
;
837 INTERRUPTCLEAR
= 0x03c00000;
839 valnogood
= (interruptstat
& 0x01000000)?true:false;
840 symbolerr
= (interruptstat
& 0x00800000)?true:false;
841 parityerr
= (interruptstat
& 0x00400000)?true:false;
843 snprintf(buf
, sizeof(buf
), "Val: %s Sym: %s Par: %s",
846 parityerr
?"--":"OK");
847 lcd_puts(0, line
++, buf
);
849 snprintf(buf
, sizeof(buf
), "Status word: %08x", (int)control
);
850 lcd_puts(0, line
++, buf
);
855 snprintf(buf
, sizeof(buf
), "PRO: %d (%s)",
856 x
, x
?"Professional":"Consumer");
857 lcd_puts(0, line
++, buf
);
859 x
= (control
>> 30) & 1;
860 snprintf(buf
, sizeof(buf
), "Audio: %d (%s)",
861 x
, x
?"Non-PCM":"PCM");
862 lcd_puts(0, line
++, buf
);
864 x
= (control
>> 29) & 1;
865 snprintf(buf
, sizeof(buf
), "Copy: %d (%s)",
866 x
, x
?"Permitted":"Inhibited");
867 lcd_puts(0, line
++, buf
);
869 x
= (control
>> 27) & 7;
882 snprintf(buf
, sizeof(buf
), "Preemphasis: %d (%s)", x
, s
);
883 lcd_puts(0, line
++, buf
);
885 x
= (control
>> 24) & 3;
886 snprintf(buf
, sizeof(buf
), "Mode: %d", x
);
887 lcd_puts(0, line
++, buf
);
889 category
= (control
>> 17) & 127;
901 snprintf(buf
, sizeof(buf
), "Category: 0x%02x (%s)", category
, s
);
902 lcd_puts(0, line
++, buf
);
904 x
= (control
>> 16) & 1;
906 if(((category
& 0x70) == 0x10) ||
907 ((category
& 0x70) == 0x40) ||
908 ((category
& 0x78) == 0x38))
910 generation
= !generation
;
912 snprintf(buf
, sizeof(buf
), "Generation: %d (%s)",
913 x
, generation
?"Original":"No ind.");
914 lcd_puts(0, line
++, buf
);
916 x
= (control
>> 12) & 15;
917 snprintf(buf
, sizeof(buf
), "Source: %d", x
);
918 lcd_puts(0, line
++, buf
);
920 x
= (control
>> 8) & 15;
936 snprintf(buf
, sizeof(buf
), "Channel: %d (%s)", x
, s
);
937 lcd_puts(0, line
++, buf
);
939 x
= (control
>> 4) & 15;
952 snprintf(buf
, sizeof(buf
), "Frequency: %d (%s)", x
, s
);
953 lcd_puts(0, line
++, buf
);
955 x
= (control
>> 2) & 3;
956 snprintf(buf
, sizeof(buf
), "Clock accuracy: %d", x
);
957 lcd_puts(0, line
++, buf
);
961 snprintf(buf
, sizeof(buf
), "Measured freq: %ldHz",
962 spdif_measure_frequency());
963 lcd_puts(0, line
++, buf
);
968 if (action_userabort(HZ
/10))
972 spdif_set_output_source(spdif_source
IF_SPDIF_POWER_(, spdif_src_on
));
974 #ifdef HAVE_SPDIF_POWER
975 spdif_power_enable(global_settings
.spdif_enable
);
980 #endif /* CPU_COLDFIRE */
983 #ifdef HAVE_LCD_BITMAP
984 /* button definitions */
985 #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
986 (CONFIG_KEYPAD == IRIVER_H300_PAD)
987 # define DEBUG_CANCEL BUTTON_OFF
989 #elif CONFIG_KEYPAD == RECORDER_PAD
990 # define DEBUG_CANCEL BUTTON_OFF
992 #elif CONFIG_KEYPAD == ONDIO_PAD
993 # define DEBUG_CANCEL BUTTON_MENU
995 #elif (CONFIG_KEYPAD == IPOD_1G2G_PAD) || \
996 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
997 (CONFIG_KEYPAD == IPOD_4G_PAD)
998 # define DEBUG_CANCEL BUTTON_MENU
1000 #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
1001 # define DEBUG_CANCEL BUTTON_PLAY
1003 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
1004 # define DEBUG_CANCEL BUTTON_REC
1006 #elif (CONFIG_KEYPAD == IAUDIO_M3_PAD)
1007 # define DEBUG_CANCEL BUTTON_RC_REC
1009 #elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
1010 # define DEBUG_CANCEL BUTTON_REW
1012 #elif (CONFIG_KEYPAD == MROBE100_PAD)
1013 # define DEBUG_CANCEL BUTTON_MENU
1015 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
1016 (CONFIG_KEYPAD == SANSA_C200_PAD)
1017 # define DEBUG_CANCEL BUTTON_LEFT
1018 #endif /* key definitions */
1021 bool dbg_ports(void)
1023 #if CONFIG_CPU == SH7034
1025 int adc_battery_voltage
, adc_battery_level
;
1027 lcd_setfont(FONT_SYSFIXED
);
1028 lcd_setmargins(0, 0);
1029 lcd_clear_display();
1033 snprintf(buf
, 32, "PADR: %04x", (unsigned short)PADR
);
1034 lcd_puts(0, 0, buf
);
1035 snprintf(buf
, 32, "PBDR: %04x", (unsigned short)PBDR
);
1036 lcd_puts(0, 1, buf
);
1038 snprintf(buf
, 32, "AN0: %03x AN4: %03x", adc_read(0), adc_read(4));
1039 lcd_puts(0, 2, buf
);
1040 snprintf(buf
, 32, "AN1: %03x AN5: %03x", adc_read(1), adc_read(5));
1041 lcd_puts(0, 3, buf
);
1042 snprintf(buf
, 32, "AN2: %03x AN6: %03x", adc_read(2), adc_read(6));
1043 lcd_puts(0, 4, buf
);
1044 snprintf(buf
, 32, "AN3: %03x AN7: %03x", adc_read(3), adc_read(7));
1045 lcd_puts(0, 5, buf
);
1047 battery_read_info(&adc_battery_voltage
, &adc_battery_level
);
1048 snprintf(buf
, 32, "Batt: %d.%03dV %d%% ", adc_battery_voltage
/ 1000,
1049 adc_battery_voltage
% 1000, adc_battery_level
);
1050 lcd_puts(0, 6, buf
);
1053 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1056 #elif defined(CPU_COLDFIRE)
1057 unsigned int gpio_out
;
1058 unsigned int gpio1_out
;
1059 unsigned int gpio_read
;
1060 unsigned int gpio1_read
;
1061 unsigned int gpio_function
;
1062 unsigned int gpio1_function
;
1063 unsigned int gpio_enable
;
1064 unsigned int gpio1_enable
;
1065 int adc_buttons
, adc_remote
;
1066 int adc_battery_voltage
, adc_battery_level
;
1070 lcd_setmargins(0, 0);
1071 lcd_clear_display();
1072 lcd_setfont(FONT_SYSFIXED
);
1077 gpio_read
= GPIO_READ
;
1078 gpio1_read
= GPIO1_READ
;
1079 gpio_out
= GPIO_OUT
;
1080 gpio1_out
= GPIO1_OUT
;
1081 gpio_function
= GPIO_FUNCTION
;
1082 gpio1_function
= GPIO1_FUNCTION
;
1083 gpio_enable
= GPIO_ENABLE
;
1084 gpio1_enable
= GPIO1_ENABLE
;
1086 snprintf(buf
, sizeof(buf
), "GPIO_READ: %08x", gpio_read
);
1087 lcd_puts(0, line
++, buf
);
1088 snprintf(buf
, sizeof(buf
), "GPIO_OUT: %08x", gpio_out
);
1089 lcd_puts(0, line
++, buf
);
1090 snprintf(buf
, sizeof(buf
), "GPIO_FUNC: %08x", gpio_function
);
1091 lcd_puts(0, line
++, buf
);
1092 snprintf(buf
, sizeof(buf
), "GPIO_ENA: %08x", gpio_enable
);
1093 lcd_puts(0, line
++, buf
);
1095 snprintf(buf
, sizeof(buf
), "GPIO1_READ: %08x", gpio1_read
);
1096 lcd_puts(0, line
++, buf
);
1097 snprintf(buf
, sizeof(buf
), "GPIO1_OUT: %08x", gpio1_out
);
1098 lcd_puts(0, line
++, buf
);
1099 snprintf(buf
, sizeof(buf
), "GPIO1_FUNC: %08x", gpio1_function
);
1100 lcd_puts(0, line
++, buf
);
1101 snprintf(buf
, sizeof(buf
), "GPIO1_ENA: %08x", gpio1_enable
);
1102 lcd_puts(0, line
++, buf
);
1104 adc_buttons
= adc_read(ADC_BUTTONS
);
1105 adc_remote
= adc_read(ADC_REMOTE
);
1106 battery_read_info(&adc_battery_voltage
, &adc_battery_level
);
1107 #if defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IRIVER_H300_SERIES)
1108 snprintf(buf
, sizeof(buf
), "ADC_BUTTONS (%c): %02x",
1109 button_scan_enabled() ? '+' : '-', adc_buttons
);
1111 snprintf(buf
, sizeof(buf
), "ADC_BUTTONS: %02x", adc_buttons
);
1113 lcd_puts(0, line
++, buf
);
1114 #if defined(IAUDIO_X5) || defined(IAUDIO_M5)
1115 snprintf(buf
, sizeof(buf
), "ADC_REMOTE (%c): %02x",
1116 remote_detect() ? '+' : '-', adc_remote
);
1118 snprintf(buf
, sizeof(buf
), "ADC_REMOTE: %02x", adc_remote
);
1120 lcd_puts(0, line
++, buf
);
1121 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1122 snprintf(buf
, sizeof(buf
), "ADC_REMOTEDETECT: %02x",
1123 adc_read(ADC_REMOTEDETECT
));
1124 lcd_puts(0, line
++, buf
);
1127 snprintf(buf
, 32, "Batt: %d.%03dV %d%% ", adc_battery_voltage
/ 1000,
1128 adc_battery_voltage
% 1000, adc_battery_level
);
1129 lcd_puts(0, line
++, buf
);
1131 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1132 snprintf(buf
, sizeof(buf
), "remotetype: %d", remote_type());
1133 lcd_puts(0, line
++, buf
);
1137 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1141 #elif defined(CPU_PP502x)
1146 lcd_setmargins(0, 0);
1147 lcd_clear_display();
1148 lcd_setfont(FONT_SYSFIXED
);
1153 lcd_puts(0, line
++, "GPIO STATES:");
1154 snprintf(buf
, sizeof(buf
), "A: %02x E: %02x I: %02x",
1155 (unsigned int)GPIOA_INPUT_VAL
,
1156 (unsigned int)GPIOE_INPUT_VAL
,
1157 (unsigned int)GPIOI_INPUT_VAL
);
1158 lcd_puts(0, line
++, buf
);
1159 snprintf(buf
, sizeof(buf
), "B: %02x F: %02x J: %02x",
1160 (unsigned int)GPIOB_INPUT_VAL
,
1161 (unsigned int)GPIOF_INPUT_VAL
,
1162 (unsigned int)GPIOJ_INPUT_VAL
);
1163 lcd_puts(0, line
++, buf
);
1164 snprintf(buf
, sizeof(buf
), "C: %02x G: %02x K: %02x",
1165 (unsigned int)GPIOC_INPUT_VAL
,
1166 (unsigned int)GPIOG_INPUT_VAL
,
1167 (unsigned int)GPIOK_INPUT_VAL
);
1168 lcd_puts(0, line
++, buf
);
1169 snprintf(buf
, sizeof(buf
), "D: %02x H: %02x L: %02x",
1170 (unsigned int)GPIOD_INPUT_VAL
,
1171 (unsigned int)GPIOH_INPUT_VAL
,
1172 (unsigned int)GPIOL_INPUT_VAL
);
1173 lcd_puts(0, line
++, buf
);
1175 snprintf(buf
, sizeof(buf
), "GPO32_VAL: %08lx", GPO32_VAL
);
1176 lcd_puts(0, line
++, buf
);
1177 snprintf(buf
, sizeof(buf
), "GPO32_EN: %08lx", GPO32_ENABLE
);
1178 lcd_puts(0, line
++, buf
);
1179 snprintf(buf
, sizeof(buf
), "DEV_EN: %08lx", DEV_EN
);
1180 lcd_puts(0, line
++, buf
);
1181 snprintf(buf
, sizeof(buf
), "DEV_EN2: %08lx", DEV_EN2
);
1182 lcd_puts(0, line
++, buf
);
1183 snprintf(buf
, sizeof(buf
), "DEV_EN3: %08lx", inl(0x60006044));
1184 lcd_puts(0, line
++, buf
); /* to be verified */
1185 snprintf(buf
, sizeof(buf
), "DEV_INIT1: %08lx", DEV_INIT1
);
1186 lcd_puts(0, line
++, buf
);
1187 snprintf(buf
, sizeof(buf
), "DEV_INIT2: %08lx", DEV_INIT2
);
1188 lcd_puts(0, line
++, buf
);
1190 #if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
1192 snprintf(buf
, sizeof(buf
), "BATT: %03x UNK1: %03x",
1193 adc_read(ADC_BATTERY
), adc_read(ADC_UNKNOWN_1
));
1194 lcd_puts(0, line
++, buf
);
1195 snprintf(buf
, sizeof(buf
), "REM: %03x PAD: %03x",
1196 adc_read(ADC_REMOTE
), adc_read(ADC_SCROLLPAD
));
1197 lcd_puts(0, line
++, buf
);
1198 #elif defined(SANSA_E200)
1199 snprintf(buf
, sizeof(buf
), "ADC_BVDD: %4d", adc_read(ADC_BVDD
));
1200 lcd_puts(0, line
++, buf
);
1201 snprintf(buf
, sizeof(buf
), "ADC_RTCSUP: %4d", adc_read(ADC_RTCSUP
));
1202 lcd_puts(0, line
++, buf
);
1203 snprintf(buf
, sizeof(buf
), "ADC_UVDD: %4d", adc_read(ADC_UVDD
));
1204 lcd_puts(0, line
++, buf
);
1205 snprintf(buf
, sizeof(buf
), "ADC_CHG_IN: %4d", adc_read(ADC_CHG_IN
));
1206 lcd_puts(0, line
++, buf
);
1207 snprintf(buf
, sizeof(buf
), "ADC_CVDD: %4d", adc_read(ADC_CVDD
));
1208 lcd_puts(0, line
++, buf
);
1209 snprintf(buf
, sizeof(buf
), "ADC_BATTEMP: %4d", adc_read(ADC_BATTEMP
));
1210 lcd_puts(0, line
++, buf
);
1211 snprintf(buf
, sizeof(buf
), "ADC_MICSUP1: %4d", adc_read(ADC_MICSUP1
));
1212 lcd_puts(0, line
++, buf
);
1213 snprintf(buf
, sizeof(buf
), "ADC_MICSUP2: %4d", adc_read(ADC_MICSUP2
));
1214 lcd_puts(0, line
++, buf
);
1215 snprintf(buf
, sizeof(buf
), "ADC_VBE1: %4d", adc_read(ADC_VBE1
));
1216 lcd_puts(0, line
++, buf
);
1217 snprintf(buf
, sizeof(buf
), "ADC_VBE2: %4d", adc_read(ADC_VBE2
));
1218 lcd_puts(0, line
++, buf
);
1219 snprintf(buf
, sizeof(buf
), "ADC_I_MICSUP1:%4d", adc_read(ADC_I_MICSUP1
));
1220 lcd_puts(0, line
++, buf
);
1221 snprintf(buf
, sizeof(buf
), "ADC_I_MICSUP2:%4d", adc_read(ADC_I_MICSUP2
));
1222 lcd_puts(0, line
++, buf
);
1223 snprintf(buf
, sizeof(buf
), "ADC_VBAT: %4d", adc_read(ADC_VBAT
));
1224 lcd_puts(0, line
++, buf
);
1225 snprintf(buf
, sizeof(buf
), "CHARGER: %02X/%02X", i2c_readbyte(AS3514_I2C_ADDR
, AS3514_CHARGER
), i2c_readbyte(AS3514_I2C_ADDR
, AS3514_IRQ_ENRD0
));
1226 lcd_puts(0, line
++, buf
);
1229 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1233 #elif CONFIG_CPU == PP5002
1237 lcd_setmargins(0, 0);
1238 lcd_clear_display();
1239 lcd_setfont(FONT_SYSFIXED
);
1244 snprintf(buf
, sizeof(buf
), "GPIO_A: %02x GPIO_B: %02x",
1245 (unsigned int)GPIOA_INPUT_VAL
, (unsigned int)GPIOB_INPUT_VAL
);
1246 lcd_puts(0, line
++, buf
);
1247 snprintf(buf
, sizeof(buf
), "GPIO_C: %02x GPIO_D: %02x",
1248 (unsigned int)GPIOC_INPUT_VAL
, (unsigned int)GPIOD_INPUT_VAL
);
1249 lcd_puts(0, line
++, buf
);
1251 snprintf(buf
, sizeof(buf
), "DEV_EN: %08lx", DEV_EN
);
1252 lcd_puts(0, line
++, buf
);
1253 snprintf(buf
, sizeof(buf
), "CLOCK_ENABLE: %08lx", CLOCK_ENABLE
);
1254 lcd_puts(0, line
++, buf
);
1255 snprintf(buf
, sizeof(buf
), "CLOCK_SOURCE: %08lx", CLOCK_SOURCE
);
1256 lcd_puts(0, line
++, buf
);
1257 snprintf(buf
, sizeof(buf
), "PLL_CONTROL: %08lx", PLL_CONTROL
);
1258 lcd_puts(0, line
++, buf
);
1259 snprintf(buf
, sizeof(buf
), "PLL_DIV: %08lx", PLL_DIV
);
1260 lcd_puts(0, line
++, buf
);
1261 snprintf(buf
, sizeof(buf
), "PLL_MULT: %08lx", PLL_MULT
);
1262 lcd_puts(0, line
++, buf
);
1263 snprintf(buf
, sizeof(buf
), "TIMING1_CTL: %08lx", TIMING1_CTL
);
1264 lcd_puts(0, line
++, buf
);
1265 snprintf(buf
, sizeof(buf
), "TIMING2_CTL: %08lx", TIMING2_CTL
);
1266 lcd_puts(0, line
++, buf
);
1269 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1273 return __dbg_ports();
1277 #else /* !HAVE_LCD_BITMAP */
1278 bool dbg_ports(void)
1282 int adc_battery_voltage
;
1285 lcd_clear_display();
1292 snprintf(buf
, 32, "PADR: %04x", (unsigned short)PADR
);
1295 snprintf(buf
, 32, "PBDR: %04x", (unsigned short)PBDR
);
1298 snprintf(buf
, 32, "AN0: %03x", adc_read(0));
1301 snprintf(buf
, 32, "AN1: %03x", adc_read(1));
1304 snprintf(buf
, 32, "AN2: %03x", adc_read(2));
1307 snprintf(buf
, 32, "AN3: %03x", adc_read(3));
1310 snprintf(buf
, 32, "AN4: %03x", adc_read(4));
1313 snprintf(buf
, 32, "AN5: %03x", adc_read(5));
1316 snprintf(buf
, 32, "AN6: %03x", adc_read(6));
1319 snprintf(buf
, 32, "AN7: %03x", adc_read(7));
1323 lcd_puts(0, 0, buf
);
1325 battery_read_info(&adc_battery_voltage
, NULL
);
1326 snprintf(buf
, 32, "Batt: %d.%03dV", adc_battery_voltage
/ 1000,
1327 adc_battery_voltage
% 1000);
1328 lcd_puts(0, 1, buf
);
1331 button
= get_action(CONTEXT_SETTINGS
,HZ
/5);
1335 case ACTION_STD_CANCEL
:
1338 case ACTION_SETTINGS_DEC
:
1344 case ACTION_SETTINGS_INC
:
1353 #endif /* !HAVE_LCD_BITMAP */
1354 #endif /* !SIMULATOR */
1356 #if (CONFIG_RTC == RTC_PCF50605) && !defined(SIMULATOR)
1357 static bool dbg_pcf(void)
1362 #ifdef HAVE_LCD_BITMAP
1363 lcd_setmargins(0, 0);
1364 lcd_setfont(FONT_SYSFIXED
);
1366 lcd_clear_display();
1372 snprintf(buf
, sizeof(buf
), "DCDC1: %02x", pcf50605_read(0x1b));
1373 lcd_puts(0, line
++, buf
);
1374 snprintf(buf
, sizeof(buf
), "DCDC2: %02x", pcf50605_read(0x1c));
1375 lcd_puts(0, line
++, buf
);
1376 snprintf(buf
, sizeof(buf
), "DCDC3: %02x", pcf50605_read(0x1d));
1377 lcd_puts(0, line
++, buf
);
1378 snprintf(buf
, sizeof(buf
), "DCDC4: %02x", pcf50605_read(0x1e));
1379 lcd_puts(0, line
++, buf
);
1380 snprintf(buf
, sizeof(buf
), "DCDEC1: %02x", pcf50605_read(0x1f));
1381 lcd_puts(0, line
++, buf
);
1382 snprintf(buf
, sizeof(buf
), "DCDEC2: %02x", pcf50605_read(0x20));
1383 lcd_puts(0, line
++, buf
);
1384 snprintf(buf
, sizeof(buf
), "DCUDC1: %02x", pcf50605_read(0x21));
1385 lcd_puts(0, line
++, buf
);
1386 snprintf(buf
, sizeof(buf
), "DCUDC2: %02x", pcf50605_read(0x22));
1387 lcd_puts(0, line
++, buf
);
1388 snprintf(buf
, sizeof(buf
), "IOREGC: %02x", pcf50605_read(0x23));
1389 lcd_puts(0, line
++, buf
);
1390 snprintf(buf
, sizeof(buf
), "D1REGC: %02x", pcf50605_read(0x24));
1391 lcd_puts(0, line
++, buf
);
1392 snprintf(buf
, sizeof(buf
), "D2REGC: %02x", pcf50605_read(0x25));
1393 lcd_puts(0, line
++, buf
);
1394 snprintf(buf
, sizeof(buf
), "D3REGC: %02x", pcf50605_read(0x26));
1395 lcd_puts(0, line
++, buf
);
1396 snprintf(buf
, sizeof(buf
), "LPREG1: %02x", pcf50605_read(0x27));
1397 lcd_puts(0, line
++, buf
);
1400 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1410 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
1411 static bool dbg_cpufreq(void)
1417 #ifdef HAVE_LCD_BITMAP
1418 lcd_setmargins(0, 0);
1419 lcd_setfont(FONT_SYSFIXED
);
1421 lcd_clear_display();
1427 snprintf(buf
, sizeof(buf
), "Frequency: %ld", FREQ
);
1428 lcd_puts(0, line
++, buf
);
1430 snprintf(buf
, sizeof(buf
), "boost_counter: %d", get_cpu_boost_counter());
1431 lcd_puts(0, line
++, buf
);
1434 button
= get_action(CONTEXT_STD
,HZ
/10);
1438 case ACTION_STD_PREV
:
1442 case ACTION_STD_NEXT
:
1447 while (get_cpu_boost_counter() > 0)
1449 set_cpu_frequency(CPUFREQ_DEFAULT
);
1452 case ACTION_STD_CANCEL
:
1459 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
1461 #if defined(HAVE_TSC2100) && !defined(SIMULATOR)
1462 #include "tsc2100.h"
1463 char *itob(int n
, int len
)
1465 static char binary
[64];
1467 for (i
=1, j
=0;i
<=len
;i
++)
1469 binary
[j
++] = n
&(1<<(len
-i
))?'1':'0';
1476 static char* tsc2100_debug_getname(int selected_item
, void * data
,
1477 char *buffer
, size_t buffer_len
)
1479 int *page
= (int*)data
;
1480 bool reserved
= false;
1484 if ((selected_item
> 0x0a) ||
1485 (selected_item
== 0x04) ||
1486 (selected_item
== 0x08))
1490 if ((selected_item
> 0x05) ||
1491 (selected_item
== 0x02))
1495 if (selected_item
> 0x1e)
1500 snprintf(buffer
, buffer_len
, "%02x: RESERVED", selected_item
);
1502 snprintf(buffer
, buffer_len
, "%02x: %s", selected_item
,
1503 itob(tsc2100_readreg(*page
, selected_item
)&0xffff,16));
1506 static int tsc2100debug_action_callback(int action
, struct gui_synclist
*lists
)
1508 int *page
= (int*)lists
->data
;
1509 if (action
== ACTION_STD_OK
)
1511 *page
= (*page
+1)%3;
1512 snprintf(lists
->title
, 32,
1513 "tsc2100 registers - Page %d", *page
);
1514 return ACTION_REDRAW
;
1518 bool tsc2100_debug(void)
1521 char title
[32] = "tsc2100 registers - Page 0";
1522 struct simplelist_info info
;
1523 simplelist_info_init(&info
, title
, 32, &page
);
1524 info
.timeout
= HZ
/100;
1525 info
.get_name
= tsc2100_debug_getname
;
1526 info
.action_callback
= tsc2100debug_action_callback
;
1527 return simplelist_show_list(&info
);
1531 #ifdef HAVE_LCD_BITMAP
1533 * view_battery() shows a automatically scaled graph of the battery voltage
1534 * over time. Usable for estimating battery life / charging rate.
1535 * The power_history array is updated in power_thread of powermgmt.c.
1538 #define BAT_LAST_VAL MIN(LCD_WIDTH, POWER_HISTORY_LEN)
1539 #define BAT_YSPACE (LCD_HEIGHT - 20)
1541 static bool view_battery(void)
1545 unsigned short maxv
, minv
;
1548 lcd_setmargins(0, 0);
1549 lcd_setfont(FONT_SYSFIXED
);
1553 lcd_clear_display();
1555 case 0: /* voltage history graph */
1556 /* Find maximum and minimum voltage for scaling */
1557 minv
= power_history
[0];
1559 for (i
= 1; i
< BAT_LAST_VAL
&& power_history
[i
]; i
++) {
1560 if (power_history
[i
] > maxv
)
1561 maxv
= power_history
[i
];
1562 if (power_history
[i
] < minv
)
1563 minv
= power_history
[i
];
1566 snprintf(buf
, 30, "Battery %d.%03d", power_history
[0] / 1000,
1567 power_history
[0] % 1000);
1568 lcd_puts(0, 0, buf
);
1569 snprintf(buf
, 30, "scale %d.%03d-%d.%03dV",
1570 minv
/ 1000, minv
% 1000, maxv
/ 1000, maxv
% 1000);
1571 lcd_puts(0, 1, buf
);
1574 for (i
= BAT_LAST_VAL
- 1; i
>= 0; i
--) {
1575 y
= (power_history
[i
] - minv
) * BAT_YSPACE
/ (maxv
- minv
);
1576 lcd_set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
1577 lcd_vline(x
, LCD_HEIGHT
-1, 20);
1578 lcd_set_drawmode(DRMODE_SOLID
);
1579 lcd_vline(x
, LCD_HEIGHT
-1,
1580 MIN(MAX(LCD_HEIGHT
-1 - y
, 20), LCD_HEIGHT
-1));
1586 case 1: /* status: */
1587 lcd_puts(0, 0, "Power status:");
1589 battery_read_info(&y
, NULL
);
1590 snprintf(buf
, 30, "Battery: %d.%03d V", y
/ 1000, y
% 1000);
1591 lcd_puts(0, 1, buf
);
1592 #ifdef ADC_EXT_POWER
1593 y
= (adc_read(ADC_EXT_POWER
) * EXT_SCALE_FACTOR
) / 1000;
1594 snprintf(buf
, 30, "External: %d.%03d V", y
/ 1000, y
% 1000);
1595 lcd_puts(0, 2, buf
);
1598 #if CONFIG_CHARGING == CHARGING_CONTROL
1599 snprintf(buf
, 30, "Chgr: %s %s",
1600 charger_inserted() ? "present" : "absent",
1601 charger_enabled
? "on" : "off");
1602 lcd_puts(0, 3, buf
);
1603 snprintf(buf
, 30, "short delta: %d", short_delta
);
1604 lcd_puts(0, 5, buf
);
1605 snprintf(buf
, 30, "long delta: %d", long_delta
);
1606 lcd_puts(0, 6, buf
);
1607 lcd_puts(0, 7, power_message
);
1608 snprintf(buf
, 30, "USB Inserted: %s",
1609 usb_inserted() ? "yes" : "no");
1610 lcd_puts(0, 8, buf
);
1611 #if defined IRIVER_H300_SERIES
1612 snprintf(buf
, 30, "USB Charging Enabled: %s",
1613 usb_charging_enabled() ? "yes" : "no");
1614 lcd_puts(0, 9, buf
);
1616 #else /* CONFIG_CHARGING != CHARGING_CONTROL */
1617 #if defined IPOD_NANO || defined IPOD_VIDEO
1618 int usb_pwr
= (GPIOL_INPUT_VAL
& 0x10)?true:false;
1619 int ext_pwr
= (GPIOL_INPUT_VAL
& 0x08)?false:true;
1620 int dock
= (GPIOA_INPUT_VAL
& 0x10)?true:false;
1621 int charging
= (GPIOB_INPUT_VAL
& 0x01)?false:true;
1622 int headphone
= (GPIOA_INPUT_VAL
& 0x80)?true:false;
1624 snprintf(buf
, 30, "USB pwr: %s",
1625 usb_pwr
? "present" : "absent");
1626 lcd_puts(0, 3, buf
);
1627 snprintf(buf
, 30, "EXT pwr: %s",
1628 ext_pwr
? "present" : "absent");
1629 lcd_puts(0, 4, buf
);
1630 snprintf(buf
, 30, "Battery: %s",
1631 charging
? "charging" : (usb_pwr
||ext_pwr
) ? "charged" : "discharging");
1632 lcd_puts(0, 5, buf
);
1633 snprintf(buf
, 30, "Dock mode: %s",
1634 dock
? "enabled" : "disabled");
1635 lcd_puts(0, 6, buf
);
1636 snprintf(buf
, 30, "Headphone: %s",
1637 headphone
? "connected" : "disconnected");
1638 lcd_puts(0, 7, buf
);
1640 snprintf(buf
, 30, "Charger: %s",
1641 charger_inserted() ? "present" : "absent");
1642 lcd_puts(0, 3, buf
);
1644 #endif /* CONFIG_CHARGING != CHARGING_CONTROL */
1645 #endif /* CONFIG_CHARGING */
1648 case 2: /* voltage deltas: */
1649 lcd_puts(0, 0, "Voltage deltas:");
1651 for (i
= 0; i
<= 6; i
++) {
1652 y
= power_history
[i
] - power_history
[i
+1];
1653 snprintf(buf
, 30, "-%d min: %s%d.%03d V", i
,
1654 (y
< 0) ? "-" : "", ((y
< 0) ? y
* -1 : y
) / 1000,
1655 ((y
< 0) ? y
* -1 : y
) % 1000);
1656 lcd_puts(0, i
+1, buf
);
1660 case 3: /* remaining time estimation: */
1662 #if CONFIG_CHARGING == CHARGING_CONTROL
1663 snprintf(buf
, 30, "charge_state: %d", charge_state
);
1664 lcd_puts(0, 0, buf
);
1666 snprintf(buf
, 30, "Cycle time: %d m", powermgmt_last_cycle_startstop_min
);
1667 lcd_puts(0, 1, buf
);
1669 snprintf(buf
, 30, "Lvl@cyc st: %d%%", powermgmt_last_cycle_level
);
1670 lcd_puts(0, 2, buf
);
1672 snprintf(buf
, 30, "P=%2d I=%2d", pid_p
, pid_i
);
1673 lcd_puts(0, 3, buf
);
1675 snprintf(buf
, 30, "Trickle sec: %d/60", trickle_sec
);
1676 lcd_puts(0, 4, buf
);
1677 #endif /* CONFIG_CHARGING == CHARGING_CONTROL */
1679 snprintf(buf
, 30, "Last PwrHist: %d.%03dV",
1680 power_history
[0] / 1000,
1681 power_history
[0] % 1000);
1682 lcd_puts(0, 5, buf
);
1684 snprintf(buf
, 30, "battery level: %d%%", battery_level());
1685 lcd_puts(0, 6, buf
);
1687 snprintf(buf
, 30, "Est. remain: %d m", battery_time());
1688 lcd_puts(0, 7, buf
);
1694 switch(get_action(CONTEXT_SETTINGS
,HZ
/2))
1696 case ACTION_SETTINGS_DEC
:
1701 case ACTION_SETTINGS_INC
:
1706 case ACTION_STD_CANCEL
:
1713 #endif /* HAVE_LCD_BITMAP */
1717 #if defined(HAVE_MMC) || defined(HAVE_HOTSWAP)
1718 #if defined(HAVE_MMC)
1719 #define CARDTYPE "MMC"
1721 #define CARDTYPE "microSD"
1723 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1726 int *cardnum
= (int*)lists
->data
;
1727 unsigned char card_name
[7];
1728 unsigned char pbuf
[32];
1729 char *title
= lists
->title
;
1730 static const unsigned char i_vmin
[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
1731 static const unsigned char i_vmax
[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
1732 static const unsigned char *kbit_units
[] = { "kBit/s", "MBit/s", "GBit/s" };
1733 static const unsigned char *nsec_units
[] = { "ns", "�s", "ms" };
1734 static const char *spec_vers
[] = { "1.0-1.2", "1.4", "2.0-2.2",
1735 "3.1-3.31", "4.0" };
1736 if ((btn
== ACTION_STD_OK
) || (btn
== SYS_FS_CHANGED
) || (btn
== ACTION_REDRAW
))
1738 if (btn
== ACTION_STD_OK
)
1740 *cardnum
^= 0x1; /* change cards */
1743 simplelist_set_line_count(0);
1745 card
= card_get_info(*cardnum
);
1747 if (card
->initialized
> 0)
1749 card_name
[6] = '\0';
1750 strncpy(card_name
, ((unsigned char*)card
->cid
) + 3, 6);
1751 simplelist_addline(SIMPLELIST_ADD_LINE
,
1752 "%s Rev %d.%d", card_name
,
1753 (int) card_extract_bits(card
->cid
, 72, 4),
1754 (int) card_extract_bits(card
->cid
, 76, 4));
1755 simplelist_addline(SIMPLELIST_ADD_LINE
,
1757 (int) card_extract_bits(card
->cid
, 112, 4),
1758 (int) card_extract_bits(card
->cid
, 116, 4) + 1997);
1759 simplelist_addline(SIMPLELIST_ADD_LINE
,
1761 card_extract_bits(card
->cid
, 80, 32));
1762 simplelist_addline(SIMPLELIST_ADD_LINE
,
1764 (int) card_extract_bits(card
->cid
, 0, 8),
1765 (int) card_extract_bits(card
->cid
, 8, 16));
1766 int temp
= card_extract_bits(card
->csd
, 2, 4);
1767 simplelist_addline(SIMPLELIST_ADD_LINE
,
1768 CARDTYPE
" v%s", temp
< 5 ?
1769 spec_vers
[temp
] : "?.?");
1770 simplelist_addline(SIMPLELIST_ADD_LINE
,
1771 "Blocks: 0x%06lx", card
->numblocks
);
1772 simplelist_addline(SIMPLELIST_ADD_LINE
,
1773 "Blksz.: %d P:%c%c", card
->blocksize
,
1774 card_extract_bits(card
->csd
, 48, 1) ? 'R' : '-',
1775 card_extract_bits(card
->csd
, 106, 1) ? 'W' : '-');
1776 output_dyn_value(pbuf
, sizeof pbuf
, card
->speed
/ 1000,
1778 simplelist_addline(SIMPLELIST_ADD_LINE
,
1780 output_dyn_value(pbuf
, sizeof pbuf
, card
->tsac
,
1782 simplelist_addline(SIMPLELIST_ADD_LINE
,
1784 simplelist_addline(SIMPLELIST_ADD_LINE
,
1785 "Nsac: %d clk", card
->nsac
);
1786 simplelist_addline(SIMPLELIST_ADD_LINE
,
1787 "R2W: *%d", card
->r2w_factor
);
1788 simplelist_addline(SIMPLELIST_ADD_LINE
,
1790 i_vmin
[card_extract_bits(card
->csd
, 66, 3)],
1791 i_vmax
[card_extract_bits(card
->csd
, 69, 3)]);
1792 simplelist_addline(SIMPLELIST_ADD_LINE
,
1794 i_vmin
[card_extract_bits(card
->csd
, 72, 3)],
1795 i_vmax
[card_extract_bits(card
->csd
, 75, 3)]);
1797 else if (card
->initialized
== 0)
1799 simplelist_addline(SIMPLELIST_ADD_LINE
, "Not Found!");
1802 else /* card->initialized < 0 */
1804 simplelist_addline(SIMPLELIST_ADD_LINE
, "Init Error! (%d)", card
->initialized
);
1807 snprintf(title
, 16, "[" CARDTYPE
" %d]", *cardnum
);
1808 gui_synclist_set_title(lists
, title
, Icon_NOICON
);
1809 gui_synclist_set_nb_items(lists
, simplelist_get_line_count());
1810 gui_synclist_select_item(lists
, 0);
1811 btn
= ACTION_REDRAW
;
1815 #else /* !defined(HAVE_MMC) && !defined(HAVE_HOTSWAP) */
1816 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1821 unsigned short* identify_info
= ata_get_identify();
1822 bool timing_info_present
= false;
1825 simplelist_set_line_count(0);
1827 for (i
=0; i
< 20; i
++)
1828 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+27]);
1830 /* kill trailing space */
1831 for (i
=39; i
&& buf
[i
]==' '; i
--)
1833 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", buf
);
1834 for (i
=0; i
< 4; i
++)
1835 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+23]);
1837 simplelist_addline(SIMPLELIST_ADD_LINE
,
1838 "Firmware: %s", buf
);
1839 snprintf(buf
, sizeof buf
, "%ld MB",
1840 ((unsigned long)identify_info
[61] << 16 |
1841 (unsigned long)identify_info
[60]) / 2048 );
1842 simplelist_addline(SIMPLELIST_ADD_LINE
,
1845 fat_size( IF_MV2(0,) NULL
, &free
);
1846 simplelist_addline(SIMPLELIST_ADD_LINE
,
1847 "Free: %ld MB", free
/ 1024);
1848 simplelist_addline(SIMPLELIST_ADD_LINE
,
1849 "Spinup time: %d ms", ata_spinup_time
* (1000/HZ
));
1850 i
= identify_info
[83] & (1<<3);
1851 simplelist_addline(SIMPLELIST_ADD_LINE
,
1852 "Power mgmt: %s", i
? "enabled" : "unsupported");
1853 i
= identify_info
[83] & (1<<9);
1854 simplelist_addline(SIMPLELIST_ADD_LINE
,
1855 "Noise mgmt: %s", i
? "enabled" : "unsupported");
1856 i
= identify_info
[82] & (1<<6);
1857 simplelist_addline(SIMPLELIST_ADD_LINE
,
1858 "Read-ahead: %s", i
? "enabled" : "unsupported");
1859 timing_info_present
= identify_info
[53] & (1<<1);
1860 if(timing_info_present
) {
1861 char pio3
[2], pio4
[2];pio3
[1] = 0;
1863 pio3
[0] = (identify_info
[64] & (1<<0)) ? '3' : 0;
1864 pio4
[0] = (identify_info
[64] & (1<<1)) ? '4' : 0;
1865 simplelist_addline(SIMPLELIST_ADD_LINE
,
1866 "PIO modes: 0 1 2 %s %s", pio3
, pio4
);
1869 simplelist_addline(SIMPLELIST_ADD_LINE
,
1870 "No PIO mode info");
1872 timing_info_present
= identify_info
[53] & (1<<1);
1873 if(timing_info_present
) {
1874 simplelist_addline(SIMPLELIST_ADD_LINE
,
1875 "Cycle times %dns/%dns",
1877 identify_info
[68] );
1879 simplelist_addline(SIMPLELIST_ADD_LINE
,
1882 timing_info_present
= identify_info
[53] & (1<<1);
1883 if(timing_info_present
) {
1884 i
= identify_info
[49] & (1<<11);
1885 simplelist_addline(SIMPLELIST_ADD_LINE
,
1886 "IORDY support: %s", i
? "yes" : "no");
1887 i
= identify_info
[49] & (1<<10);
1888 simplelist_addline(SIMPLELIST_ADD_LINE
,
1889 "IORDY disable: %s", i
? "yes" : "no");
1891 simplelist_addline(SIMPLELIST_ADD_LINE
,
1894 simplelist_addline(SIMPLELIST_ADD_LINE
,
1895 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
1899 static bool dbg_identify_info(void)
1901 int fd
= creat("/identify_info.bin");
1904 #ifdef ROCKBOX_LITTLE_ENDIAN
1905 ecwrite(fd
, ata_get_identify(), SECTOR_SIZE
/2, "s", true);
1907 write(fd
, ata_get_identify(), SECTOR_SIZE
);
1913 #endif /* !defined(HAVE_MMC) && !defined(HAVE_HOTSWAP) */
1914 static bool dbg_disk_info(void)
1916 struct simplelist_info info
;
1917 simplelist_info_init(&info
, "Disk Info", 1, NULL
);
1918 #if defined(HAVE_MMC) || defined(HAVE_HOTSWAP)
1921 info
.callback_data
= (void*)&card
;
1924 info
.action_callback
= disk_callback
;
1925 info
.hide_selection
= true;
1926 return simplelist_show_list(&info
);
1928 #endif /* !SIMULATOR */
1930 #ifdef HAVE_DIRCACHE
1931 static int dircache_callback(int btn
, struct gui_synclist
*lists
)
1933 (void)btn
; (void)lists
;
1934 simplelist_set_line_count(0);
1935 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache initialized: %s",
1936 dircache_is_enabled() ? "Yes" : "No");
1937 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache size: %d B",
1938 dircache_get_cache_size());
1939 simplelist_addline(SIMPLELIST_ADD_LINE
, "Last size: %d B",
1940 global_status
.dircache_size
);
1941 simplelist_addline(SIMPLELIST_ADD_LINE
, "Limit: %d B",
1943 simplelist_addline(SIMPLELIST_ADD_LINE
, "Reserve: %d/%d B",
1944 dircache_get_reserve_used(), DIRCACHE_RESERVE
);
1945 simplelist_addline(SIMPLELIST_ADD_LINE
, "Scanning took: %d s",
1946 dircache_get_build_ticks() / HZ
);
1947 simplelist_addline(SIMPLELIST_ADD_LINE
, "Entry count: %d",
1948 dircache_get_entry_count());
1952 static bool dbg_dircache_info(void)
1954 struct simplelist_info info
;
1955 simplelist_info_init(&info
, "Dircache Info", 7, NULL
);
1956 info
.action_callback
= dircache_callback
;
1957 info
.hide_selection
= true;
1958 return simplelist_show_list(&info
);
1961 #endif /* HAVE_DIRCACHE */
1963 #ifdef HAVE_TAGCACHE
1964 static int database_callback(int btn
, struct gui_synclist
*lists
)
1967 struct tagcache_stat
*stat
= tagcache_get_stat();
1968 static bool synced
= false;
1970 simplelist_set_line_count(0);
1972 simplelist_addline(SIMPLELIST_ADD_LINE
, "Initialized: %s",
1973 stat
->initialized
? "Yes" : "No");
1974 simplelist_addline(SIMPLELIST_ADD_LINE
, "DB Ready: %s",
1975 stat
->ready
? "Yes" : "No");
1976 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM Cache: %s",
1977 stat
->ramcache
? "Yes" : "No");
1978 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM: %d/%d B",
1979 stat
->ramcache_used
, stat
->ramcache_allocated
);
1980 simplelist_addline(SIMPLELIST_ADD_LINE
, "Progress: %d%% (%d entries)",
1981 stat
->progress
, stat
->processed_entries
);
1982 simplelist_addline(SIMPLELIST_ADD_LINE
, "Curfile: %s",
1983 stat
->curentry
? stat
->curentry
: "---");
1984 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit step: %d",
1986 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit delayed: %s",
1987 stat
->commit_delayed
? "Yes" : "No");
1989 simplelist_addline(SIMPLELIST_ADD_LINE
, "Queue length: %d",
1990 stat
->queue_length
);
1995 tagcache_screensync_event();
1998 if (!btn
&& stat
->curentry
)
2001 return ACTION_REDRAW
;
2004 if (btn
== ACTION_STD_CANCEL
)
2005 tagcache_screensync_enable(false);
2009 static bool dbg_tagcache_info(void)
2011 struct simplelist_info info
;
2012 simplelist_info_init(&info
, "Database Info", 8, NULL
);
2013 info
.action_callback
= database_callback
;
2014 info
.hide_selection
= true;
2016 /* Don't do nonblock here, must give enough processing time
2017 for tagcache thread. */
2018 /* info.timeout = TIMEOUT_NOBLOCK; */
2020 tagcache_screensync_enable(true);
2021 return simplelist_show_list(&info
);
2025 #if CONFIG_CPU == SH7034
2026 static bool dbg_save_roms(void)
2029 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
2031 fd
= creat("/internal_rom_0000-FFFF.bin");
2034 write(fd
, (void *)0, 0x10000);
2038 fd
= creat("/internal_rom_2000000-203FFFF.bin");
2041 write(fd
, (void *)0x2000000, 0x40000);
2045 system_memory_guard(oldmode
);
2048 #elif defined CPU_COLDFIRE
2049 static bool dbg_save_roms(void)
2052 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
2054 #if defined(IRIVER_H100_SERIES)
2055 fd
= creat("/internal_rom_000000-1FFFFF.bin");
2056 #elif defined(IRIVER_H300_SERIES)
2057 fd
= creat("/internal_rom_000000-3FFFFF.bin");
2058 #elif defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IAUDIO_M3)
2059 fd
= creat("/internal_rom_000000-3FFFFF.bin");
2063 write(fd
, (void *)0, FLASH_SIZE
);
2066 system_memory_guard(oldmode
);
2069 fd
= creat("/internal_eeprom.bin");
2073 char buf
[EEPROM_SIZE
];
2076 old_irq_level
= disable_irq_save();
2078 err
= eeprom_24cxx_read(0, buf
, sizeof buf
);
2080 restore_irq(old_irq_level
);
2083 gui_syncsplash(HZ
*3, "Eeprom read failure (%d)",err
);
2086 write(fd
, buf
, sizeof buf
);
2095 #elif defined(CPU_PP) && !(defined(SANSA_E200) || defined(SANSA_C200))
2096 static bool dbg_save_roms(void)
2100 fd
= creat("/internal_rom_000000-0FFFFF.bin");
2103 write(fd
, (void *)0x20000000, FLASH_SIZE
);
2113 static int radio_callback(int btn
, struct gui_synclist
*lists
)
2116 if (btn
== ACTION_STD_CANCEL
)
2118 simplelist_set_line_count(1);
2120 #if (CONFIG_TUNER & LV24020LP)
2121 simplelist_addline(SIMPLELIST_ADD_LINE
,
2122 "CTRL_STAT: %02X", lv24020lp_get(LV24020LP_CTRL_STAT
) );
2123 simplelist_addline(SIMPLELIST_ADD_LINE
,
2124 "RADIO_STAT: %02X", lv24020lp_get(LV24020LP_REG_STAT
) );
2125 simplelist_addline(SIMPLELIST_ADD_LINE
,
2126 "MSS_FM: %d kHz", lv24020lp_get(LV24020LP_MSS_FM
) );
2127 simplelist_addline(SIMPLELIST_ADD_LINE
,
2128 "MSS_IF: %d Hz", lv24020lp_get(LV24020LP_MSS_IF
) );
2129 simplelist_addline(SIMPLELIST_ADD_LINE
,
2130 "MSS_SD: %d Hz", lv24020lp_get(LV24020LP_MSS_SD
) );
2131 simplelist_addline(SIMPLELIST_ADD_LINE
,
2132 "if_set: %d Hz", lv24020lp_get(LV24020LP_IF_SET
) );
2133 simplelist_addline(SIMPLELIST_ADD_LINE
,
2134 "sd_set: %d Hz", lv24020lp_get(LV24020LP_SD_SET
) );
2136 #if (CONFIG_TUNER & S1A0903X01)
2137 simplelist_addline(SIMPLELIST_ADD_LINE
,
2138 "Samsung regs: %08X", s1a0903x01_get(RADIO_ALL
));
2139 /* This one doesn't return dynamic data atm */
2141 #if (CONFIG_TUNER & TEA5767)
2142 struct tea5767_dbg_info nfo
;
2143 tea5767_dbg_info(&nfo
);
2144 simplelist_addline(SIMPLELIST_ADD_LINE
, "Philips regs:");
2145 simplelist_addline(SIMPLELIST_ADD_LINE
,
2146 " Read: %02X %02X %02X %02X %02X",
2147 (unsigned)nfo
.read_regs
[0], (unsigned)nfo
.read_regs
[1],
2148 (unsigned)nfo
.read_regs
[2], (unsigned)nfo
.read_regs
[3],
2149 (unsigned)nfo
.read_regs
[4]);
2150 simplelist_addline(SIMPLELIST_ADD_LINE
,
2151 " Write: %02X %02X %02X %02X %02X",
2152 (unsigned)nfo
.write_regs
[0], (unsigned)nfo
.write_regs
[1],
2153 (unsigned)nfo
.write_regs
[2], (unsigned)nfo
.write_regs
[3],
2154 (unsigned)nfo
.write_regs
[4]);
2156 return ACTION_REDRAW
;
2158 static bool dbg_fm_radio(void)
2160 struct simplelist_info info
;
2161 simplelist_info_init(&info
, "FM Radio", 1, NULL
);
2162 simplelist_set_line_count(0);
2163 simplelist_addline(SIMPLELIST_ADD_LINE
, "HW detected: %s",
2164 radio_hardware_present() ? "yes" : "no");
2166 info
.action_callback
= radio_hardware_present()?radio_callback
: NULL
;
2167 info
.hide_selection
= true;
2168 return simplelist_show_list(&info
);
2170 #endif /* CONFIG_TUNER */
2171 #endif /* !SIMULATOR */
2173 #ifdef HAVE_LCD_BITMAP
2174 extern bool do_screendump_instead_of_usb
;
2176 static bool dbg_screendump(void)
2178 do_screendump_instead_of_usb
= !do_screendump_instead_of_usb
;
2179 gui_syncsplash(HZ
, "Screendump %s",
2180 do_screendump_instead_of_usb
?"enabled":"disabled");
2183 #endif /* HAVE_LCD_BITMAP */
2185 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2186 static bool dbg_set_memory_guard(void)
2188 static const struct opt_items names
[MAXMEMGUARD
] = {
2190 { "Flash ROM writes", -1 },
2191 { "Zero area (all)", -1 }
2193 int mode
= system_memory_guard(MEMGUARD_KEEP
);
2195 set_option( "Catch mem accesses", &mode
, INT
, names
, MAXMEMGUARD
, NULL
);
2196 system_memory_guard(mode
);
2200 #endif /* CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) */
2202 #if defined(TOSHIBA_GIGABEAT_F) && !defined(SIMULATOR)
2204 extern volatile bool lcd_poweroff
;
2206 static bool dbg_lcd_power_off(void)
2208 lcd_setmargins(0, 0);
2214 lcd_clear_display();
2215 lcd_puts(0, 0, "LCD Power Off");
2217 lcd_puts(1, 1, "Yes");
2219 lcd_puts(1, 1, "No");
2223 button
= get_action(CONTEXT_STD
,HZ
/5);
2226 case ACTION_STD_PREV
:
2227 case ACTION_STD_NEXT
:
2228 lcd_poweroff
= !lcd_poweroff
;
2231 case ACTION_STD_CANCEL
:
2242 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2243 static bool dbg_write_eeprom(void)
2248 char buf
[EEPROM_SIZE
];
2251 fd
= open("/internal_eeprom.bin", O_RDONLY
);
2255 rc
= read(fd
, buf
, EEPROM_SIZE
);
2257 if(rc
== EEPROM_SIZE
)
2259 old_irq_level
= disable_irq_save();
2261 err
= eeprom_24cxx_write(0, buf
, sizeof buf
);
2263 gui_syncsplash(HZ
*3, "Eeprom write failure (%d)",err
);
2265 gui_syncsplash(HZ
*3, "Eeprom written successfully");
2267 restore_irq(old_irq_level
);
2271 gui_syncsplash(HZ
*3, "File read error (%d)",rc
);
2277 gui_syncsplash(HZ
*3, "Failed to open 'internal_eeprom.bin'");
2282 #endif /* defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS) */
2283 #ifdef CPU_BOOST_LOGGING
2284 static bool cpu_boost_log(void)
2287 int count
= cpu_boost_log_getcount();
2288 int lines
= LCD_HEIGHT
/SYSFONT_HEIGHT
;
2291 lcd_setmargins(0, 0);
2292 lcd_setfont(FONT_SYSFIXED
);
2293 str
= cpu_boost_log_getlog_first();
2296 lcd_clear_display();
2297 for(j
=0; j
<lines
; j
++,i
++)
2300 str
= cpu_boost_log_getlog_next();
2311 switch(get_action(CONTEXT_STD
,TIMEOUT_BLOCK
))
2314 case ACTION_STD_PREV
:
2315 case ACTION_STD_NEXT
:
2318 case ACTION_STD_CANCEL
:
2325 get_action(CONTEXT_STD
,TIMEOUT_BLOCK
);
2326 lcd_setfont(FONT_UI
);
2331 #if (defined(HAVE_SCROLLWHEEL) && (CONFIG_KEYPAD==IPOD_4G_PAD) && !defined(SIMULATOR))
2332 extern bool wheel_is_touched
;
2333 extern int old_wheel_value
;
2334 extern int new_wheel_value
;
2335 extern int wheel_delta
;
2336 extern unsigned int accumulated_wheel_delta
;
2337 extern unsigned int wheel_velocity
;
2339 static bool dbg_scrollwheel(void)
2344 lcd_setmargins(0, 0);
2345 lcd_setfont(FONT_SYSFIXED
);
2349 if (action_userabort(HZ
/10))
2352 lcd_clear_display();
2354 /* show internal variables of scrollwheel driver */
2355 snprintf(buf
, sizeof(buf
), "wheel touched: %s", (wheel_is_touched
) ? "true" : "false");
2356 lcd_puts(0, 0, buf
);
2357 snprintf(buf
, sizeof(buf
), "new position: %2d", new_wheel_value
);
2358 lcd_puts(0, 1, buf
);
2359 snprintf(buf
, sizeof(buf
), "old position: %2d", old_wheel_value
);
2360 lcd_puts(0, 2, buf
);
2361 snprintf(buf
, sizeof(buf
), "wheel delta: %2d", wheel_delta
);
2362 lcd_puts(0, 3, buf
);
2363 snprintf(buf
, sizeof(buf
), "accumulated delta: %2d", accumulated_wheel_delta
);
2364 lcd_puts(0, 4, buf
);
2365 snprintf(buf
, sizeof(buf
), "velo [deg/s]: %4d", (int)wheel_velocity
);
2366 lcd_puts(0, 5, buf
);
2368 /* show effective accelerated scrollspeed */
2369 speed
= button_apply_acceleration( (1<<31)|(1<<24)|wheel_velocity
);
2370 snprintf(buf
, sizeof(buf
), "accel. speed: %4d", speed
);
2371 lcd_puts(0, 6, buf
);
2379 #if defined(HAVE_USBSTACK) && defined(ROCKBOX_HAS_LOGF) && defined(USB_SERIAL)
2380 static bool logf_usb_serial(void)
2382 bool serial_enabled
= !usb_core_driver_enabled(USB_DRIVER_SERIAL
);
2383 usb_core_enable_driver(USB_DRIVER_SERIAL
,serial_enabled
);
2384 gui_syncsplash(HZ
, "USB logf %s",
2385 serial_enabled
?"enabled":"disabled");
2390 #if defined(HAVE_USBSTACK) && defined(USB_STORAGE)
2391 static bool usb_reconnect(void)
2393 gui_syncsplash(HZ
, "Reconnect mass storage");
2394 usb_storage_reconnect();
2400 /****** The menu *********/
2401 struct the_menu_item
{
2402 unsigned char *desc
; /* string or ID */
2403 bool (*function
) (void); /* return true if USB was connected */
2405 static const struct the_menu_item menuitems
[] = {
2406 #if defined(TOSHIBA_GIGABEAT_F) && !defined(SIMULATOR)
2407 { "LCD Power Off", dbg_lcd_power_off
},
2409 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || \
2410 (defined(CPU_PP) && !(defined(SANSA_E200) || defined(SANSA_C200)))
2411 { "Dump ROM contents", dbg_save_roms
},
2413 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || defined(CPU_PP) \
2414 || CONFIG_CPU == S3C2440 || CONFIG_CPU == IMX31L
2415 { "View I/O ports", dbg_ports
},
2417 #if (CONFIG_RTC == RTC_PCF50605) && !defined(SIMULATOR)
2418 { "View PCF registers", dbg_pcf
},
2420 #if defined(HAVE_TSC2100) && !defined(SIMULATOR)
2421 { "TSC2100 debug", tsc2100_debug
},
2423 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
2424 { "CPU frequency", dbg_cpufreq
},
2426 #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR)
2427 { "S/PDIF analyzer", dbg_spdif
},
2429 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2430 { "Catch mem accesses", dbg_set_memory_guard
},
2432 { "View OS stacks", dbg_os
},
2433 #ifdef HAVE_LCD_BITMAP
2435 { "View battery", view_battery
},
2437 { "Screendump", dbg_screendump
},
2440 { "View HW info", dbg_hw_info
},
2443 { "View partitions", dbg_partitions
},
2446 { "View disk info", dbg_disk_info
},
2447 #if !defined(HAVE_MMC) && !defined(HAVE_HOTSWAP)
2448 { "Dump ATA identify info", dbg_identify_info
},
2451 #ifdef HAVE_DIRCACHE
2452 { "View dircache info", dbg_dircache_info
},
2454 #ifdef HAVE_TAGCACHE
2455 { "View database info", dbg_tagcache_info
},
2457 #ifdef HAVE_LCD_BITMAP
2458 #if CONFIG_CODEC == SWCODEC
2459 { "View buffering thread", dbg_buffering_thread
},
2460 #elif !defined(SIMULATOR)
2461 { "View audio thread", dbg_audio_thread
},
2464 { "pm histogram", peak_meter_histogram
},
2465 #endif /* PM_DEBUG */
2466 #endif /* HAVE_LCD_BITMAP */
2469 { "FM Radio", dbg_fm_radio
},
2472 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2473 { "Write back EEPROM", dbg_write_eeprom
},
2475 #ifdef ROCKBOX_HAS_LOGF
2476 {"logf", logfdisplay
},
2477 {"logfdump", logfdump
},
2479 #if defined(HAVE_USBSTACK) && defined(ROCKBOX_HAS_LOGF) && defined(USB_SERIAL)
2480 {"logf over usb",logf_usb_serial
},
2482 #if defined(HAVE_USBSTACK) && defined(USB_STORAGE)
2483 {"reconnect usb storage",usb_reconnect
},
2485 #ifdef CPU_BOOST_LOGGING
2486 {"cpu_boost log",cpu_boost_log
},
2488 #if (defined(HAVE_SCROLLWHEEL) && (CONFIG_KEYPAD==IPOD_4G_PAD) && !defined(SIMULATOR))
2489 {"Debug scrollwheel", dbg_scrollwheel
},
2492 static int menu_action_callback(int btn
, struct gui_synclist
*lists
)
2494 if (btn
== ACTION_STD_OK
)
2496 menuitems
[gui_synclist_get_sel_pos(lists
)].function();
2497 btn
= ACTION_REDRAW
;
2501 static char* dbg_menu_getname(int item
, void * data
,
2502 char *buffer
, size_t buffer_len
)
2504 (void)data
; (void)buffer
; (void)buffer_len
;
2505 return menuitems
[item
].desc
;
2507 bool debug_menu(void)
2509 struct simplelist_info info
;
2511 simplelist_info_init(&info
, "Debug Menu", ARRAYLEN(menuitems
), NULL
);
2512 info
.action_callback
= menu_action_callback
;
2513 info
.get_name
= dbg_menu_getname
;
2515 return simplelist_show_list(&info
);