diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2007-07-11 13:27:15 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2007-07-11 13:27:15 +0000 |
commit | ed4df23e98096d84eca65625e5a1cd14072a4223 (patch) | |
tree | 173df4c772c342832835a9cdd630b4978473a95f | |
parent | f115804694eb77ddf343ac41000ac4479f1615a0 (diff) | |
download | rockbox-ed4df23e98096d84eca65625e5a1cd14072a4223.tar.gz rockbox-ed4df23e98096d84eca65625e5a1cd14072a4223.zip |
convert the tagcache, database and radio debug screens to nice lists
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13853 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/debug_menu.c | 257 |
1 files changed, 100 insertions, 157 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 8dc3a347ab..f7b022dbb3 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -88,6 +88,17 @@ | |||
88 | #endif | 88 | #endif |
89 | #include "hwcompat.h" | 89 | #include "hwcompat.h" |
90 | 90 | ||
91 | #if defined(HAVE_DIRCACHE) || defined(HAVE_TAGCACHE) || CONFIG_TUNER | ||
92 | #define MAX_DEBUG_MESSAGES 8 | ||
93 | #define DEBUG_MSG_LEN 32 | ||
94 | char debug_list_messages[MAX_DEBUG_MESSAGES][DEBUG_MSG_LEN]; | ||
95 | static char* dbg_listmessage_getname(int item, void * data, char *buffer) | ||
96 | { | ||
97 | (void)buffer; (void)data; | ||
98 | return debug_list_messages[item]; | ||
99 | } | ||
100 | #endif | ||
101 | |||
91 | static char* dbg_menu_getname(int item, void * data, char *buffer); | 102 | static char* dbg_menu_getname(int item, void * data, char *buffer); |
92 | static bool dbg_list(char *title, int count, int selection_size, | 103 | static bool dbg_list(char *title, int count, int selection_size, |
93 | int (*action_callback)(int btn, struct gui_synclist *lists), | 104 | int (*action_callback)(int btn, struct gui_synclist *lists), |
@@ -1874,104 +1885,63 @@ static bool dbg_disk_info(void) | |||
1874 | #endif /* !SIMULATOR */ | 1885 | #endif /* !SIMULATOR */ |
1875 | 1886 | ||
1876 | #ifdef HAVE_DIRCACHE | 1887 | #ifdef HAVE_DIRCACHE |
1888 | static int dircache_callback(int btn, struct gui_synclist *lists) | ||
1889 | { | ||
1890 | (void)btn; (void)lists; | ||
1891 | snprintf(debug_list_messages[0], DEBUG_MSG_LEN, "Cache initialized: %s", | ||
1892 | dircache_is_enabled() ? "Yes" : "No"); | ||
1893 | snprintf(debug_list_messages[1], DEBUG_MSG_LEN, "Cache size: %d B", | ||
1894 | dircache_get_cache_size()); | ||
1895 | snprintf(debug_list_messages[2], DEBUG_MSG_LEN, "Last size: %d B", | ||
1896 | global_status.dircache_size); | ||
1897 | snprintf(debug_list_messages[3], DEBUG_MSG_LEN, "Limit: %d B", | ||
1898 | DIRCACHE_LIMIT); | ||
1899 | snprintf(debug_list_messages[4], DEBUG_MSG_LEN, "Reserve: %d/%d B", | ||
1900 | dircache_get_reserve_used(), DIRCACHE_RESERVE); | ||
1901 | snprintf(debug_list_messages[5], DEBUG_MSG_LEN, "Scanning took: %d s", | ||
1902 | dircache_get_build_ticks() / HZ); | ||
1903 | snprintf(debug_list_messages[6], DEBUG_MSG_LEN, "Entry count: %d", | ||
1904 | dircache_get_entry_count()); | ||
1905 | return btn; | ||
1906 | } | ||
1907 | |||
1877 | static bool dbg_dircache_info(void) | 1908 | static bool dbg_dircache_info(void) |
1878 | { | 1909 | { |
1879 | bool done = false; | 1910 | dircache_callback(0,0); |
1880 | int line; | 1911 | dbg_list("Dircache Info",7, 1, dircache_callback, dbg_listmessage_getname); |
1881 | char buf[32]; | ||
1882 | |||
1883 | lcd_setmargins(0, 0); | ||
1884 | lcd_setfont(FONT_SYSFIXED); | ||
1885 | |||
1886 | while (!done) | ||
1887 | { | ||
1888 | line = 0; | ||
1889 | |||
1890 | lcd_clear_display(); | ||
1891 | snprintf(buf, sizeof(buf), "Cache initialized: %s", | ||
1892 | dircache_is_enabled() ? "Yes" : "No"); | ||
1893 | lcd_puts(0, line++, buf); | ||
1894 | |||
1895 | snprintf(buf, sizeof(buf), "Cache size: %d B", | ||
1896 | dircache_get_cache_size()); | ||
1897 | lcd_puts(0, line++, buf); | ||
1898 | |||
1899 | snprintf(buf, sizeof(buf), "Last size: %d B", | ||
1900 | global_status.dircache_size); | ||
1901 | lcd_puts(0, line++, buf); | ||
1902 | |||
1903 | snprintf(buf, sizeof(buf), "Limit: %d B", DIRCACHE_LIMIT); | ||
1904 | lcd_puts(0, line++, buf); | ||
1905 | |||
1906 | snprintf(buf, sizeof(buf), "Reserve: %d/%d B", | ||
1907 | dircache_get_reserve_used(), DIRCACHE_RESERVE); | ||
1908 | lcd_puts(0, line++, buf); | ||
1909 | |||
1910 | snprintf(buf, sizeof(buf), "Scanning took: %d s", | ||
1911 | dircache_get_build_ticks() / HZ); | ||
1912 | lcd_puts(0, line++, buf); | ||
1913 | |||
1914 | snprintf(buf, sizeof(buf), "Entry count: %d", | ||
1915 | dircache_get_entry_count()); | ||
1916 | lcd_puts(0, line++, buf); | ||
1917 | |||
1918 | lcd_update(); | ||
1919 | |||
1920 | if (action_userabort(HZ/2)) | ||
1921 | return false; | ||
1922 | } | ||
1923 | |||
1924 | return false; | 1912 | return false; |
1925 | } | 1913 | } |
1926 | 1914 | ||
1927 | #endif /* HAVE_DIRCACHE */ | 1915 | #endif /* HAVE_DIRCACHE */ |
1928 | 1916 | ||
1929 | #ifdef HAVE_LCD_BITMAP | ||
1930 | #ifdef HAVE_TAGCACHE | 1917 | #ifdef HAVE_TAGCACHE |
1918 | static int database_callback(int btn, struct gui_synclist *lists) | ||
1919 | { | ||
1920 | (void)btn; (void)lists; | ||
1921 | struct tagcache_stat *stat = tagcache_get_stat(); | ||
1922 | snprintf(debug_list_messages[0], DEBUG_MSG_LEN, "Initialized: %s", | ||
1923 | stat->initialized ? "Yes" : "No"); | ||
1924 | snprintf(debug_list_messages[1], DEBUG_MSG_LEN, "DB Ready: %s", | ||
1925 | stat->ready ? "Yes" : "No"); | ||
1926 | snprintf(debug_list_messages[2], DEBUG_MSG_LEN, "RAM Cache: %s", | ||
1927 | stat->ramcache ? "Yes" : "No"); | ||
1928 | snprintf(debug_list_messages[3], DEBUG_MSG_LEN, "RAM: %d/%d B", | ||
1929 | stat->ramcache_used, stat->ramcache_allocated); | ||
1930 | snprintf(debug_list_messages[4], DEBUG_MSG_LEN, "Progress: %d%% (%d entries)", | ||
1931 | stat->progress, stat->processed_entries); | ||
1932 | snprintf(debug_list_messages[5], DEBUG_MSG_LEN, "Commit step: %d", | ||
1933 | stat->commit_step); | ||
1934 | snprintf(debug_list_messages[6], DEBUG_MSG_LEN, "Commit delayed: %s", | ||
1935 | stat->commit_delayed ? "Yes" : "No"); | ||
1936 | return btn; | ||
1937 | } | ||
1931 | static bool dbg_tagcache_info(void) | 1938 | static bool dbg_tagcache_info(void) |
1932 | { | 1939 | { |
1933 | bool done = false; | 1940 | database_callback(0,0); |
1934 | int line; | 1941 | dbg_list("Database Info",7, 1, database_callback, dbg_listmessage_getname); |
1935 | char buf[32]; | ||
1936 | struct tagcache_stat *stat; | ||
1937 | |||
1938 | lcd_setmargins(0, 0); | ||
1939 | lcd_setfont(FONT_SYSFIXED); | ||
1940 | |||
1941 | while (!done) | ||
1942 | { | ||
1943 | line = 0; | ||
1944 | |||
1945 | lcd_clear_display(); | ||
1946 | stat = tagcache_get_stat(); | ||
1947 | snprintf(buf, sizeof(buf), "Initialized: %s", stat->initialized ? "Yes" : "No"); | ||
1948 | lcd_puts(0, line++, buf); | ||
1949 | snprintf(buf, sizeof(buf), "DB Ready: %s", stat->ready ? "Yes" : "No"); | ||
1950 | lcd_puts(0, line++, buf); | ||
1951 | snprintf(buf, sizeof(buf), "RAM Cache: %s", stat->ramcache ? "Yes" : "No"); | ||
1952 | lcd_puts(0, line++, buf); | ||
1953 | snprintf(buf, sizeof(buf), "RAM: %d/%d B", | ||
1954 | stat->ramcache_used, stat->ramcache_allocated); | ||
1955 | lcd_puts(0, line++, buf); | ||
1956 | snprintf(buf, sizeof(buf), "Progress: %d%% (%d entries)", | ||
1957 | stat->progress, stat->processed_entries); | ||
1958 | lcd_puts(0, line++, buf); | ||
1959 | snprintf(buf, sizeof(buf), "Commit step: %d", stat->commit_step); | ||
1960 | lcd_puts(0, line++, buf); | ||
1961 | snprintf(buf, sizeof(buf), "Commit delayed: %s", | ||
1962 | stat->commit_delayed ? "Yes" : "No"); | ||
1963 | lcd_puts(0, line++, buf); | ||
1964 | |||
1965 | lcd_update(); | ||
1966 | |||
1967 | if (action_userabort(HZ/2)) | ||
1968 | return false; | ||
1969 | } | ||
1970 | |||
1971 | return false; | 1942 | return false; |
1972 | } | 1943 | } |
1973 | #endif | 1944 | #endif |
1974 | #endif | ||
1975 | 1945 | ||
1976 | #if CONFIG_CPU == SH7034 | 1946 | #if CONFIG_CPU == SH7034 |
1977 | static bool dbg_save_roms(void) | 1947 | static bool dbg_save_roms(void) |
@@ -2060,86 +2030,59 @@ static bool dbg_save_roms(void) | |||
2060 | 2030 | ||
2061 | #ifndef SIMULATOR | 2031 | #ifndef SIMULATOR |
2062 | #if CONFIG_TUNER | 2032 | #if CONFIG_TUNER |
2063 | static bool dbg_fm_radio(void) | 2033 | int radio_lines = 0; |
2034 | static int radio_callback(int btn, struct gui_synclist *lists) | ||
2064 | { | 2035 | { |
2065 | char buf[32]; | 2036 | (void)btn; (void)lists; |
2066 | bool fm_detected; | 2037 | if (radio_hardware_present()) |
2067 | |||
2068 | lcd_setmargins(0, 0); | ||
2069 | |||
2070 | fm_detected = radio_hardware_present(); | ||
2071 | |||
2072 | while(1) | ||
2073 | { | 2038 | { |
2074 | int row = 0; | 2039 | snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, |
2075 | 2040 | "HW detected: yes"); | |
2076 | lcd_clear_display(); | ||
2077 | |||
2078 | snprintf(buf, sizeof buf, "HW detected: %s", fm_detected?"yes":"no"); | ||
2079 | lcd_puts(0, row++, buf); | ||
2080 | #if (CONFIG_TUNER & LV24020LP) | 2041 | #if (CONFIG_TUNER & LV24020LP) |
2081 | if (fm_detected) | 2042 | snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, |
2082 | { | 2043 | "CTRL_STAT: %02X", sanyo_get(RADIO_ALL) ); |
2083 | snprintf(buf, sizeof buf, "CTRL_STAT: %02X", | 2044 | snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, |
2084 | sanyo_get(RADIO_ALL) ); | 2045 | "RADIO_STAT: %02X", sanyo_get(RADIO_REG_STAT)); |
2085 | lcd_puts(0, row++, buf); | 2046 | snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, |
2086 | 2047 | "MSS_FM: %d kHz", sanyo_get(RADIO_MSS_FM) ); | |
2087 | snprintf(buf, sizeof buf, "RADIO_STAT: %02X", | 2048 | snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, |
2088 | sanyo_get(RADIO_REG_STAT)); | 2049 | "MSS_IF: %d Hz", (sanyo_get(RADIO_MSS_IF) ) ); |
2089 | lcd_puts(0, row++, buf); | 2050 | snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, |
2090 | 2051 | "MSS_SD: %d Hz", (sanyo_get(RADIO_MSS_SD) ) ); | |
2091 | snprintf(buf, sizeof buf, "MSS_FM: %d kHz", | 2052 | snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, |
2092 | (sanyo_get(RADIO_MSS_FM) ) ); | 2053 | "if_set: %d Hz", (sanyo_get(RADIO_IF_SET) ) ); |
2093 | lcd_puts(0, row++, buf); | 2054 | snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, |
2094 | 2055 | "sd_set: %d Hz", (sanyo_get(RADIO_SD_SET) ) ); | |
2095 | snprintf(buf, sizeof buf, "MSS_IF: %d Hz", | ||
2096 | (sanyo_get(RADIO_MSS_IF) ) ); | ||
2097 | lcd_puts(0, row++, buf); | ||
2098 | |||
2099 | snprintf(buf, sizeof buf, "MSS_SD: %d Hz", | ||
2100 | (sanyo_get(RADIO_MSS_SD) ) ); | ||
2101 | lcd_puts(0, row++, buf); | ||
2102 | |||
2103 | snprintf(buf, sizeof buf, "if_set: %d Hz", | ||
2104 | (sanyo_get(RADIO_IF_SET) ) ); | ||
2105 | lcd_puts(0, row++, buf); | ||
2106 | |||
2107 | snprintf(buf, sizeof buf, "sd_set: %d Hz", | ||
2108 | (sanyo_get(RADIO_SD_SET) ) ); | ||
2109 | lcd_puts(0, row++, buf); | ||
2110 | } | ||
2111 | #endif | 2056 | #endif |
2112 | #if (CONFIG_TUNER & S1A0903X01) | 2057 | #if (CONFIG_TUNER & S1A0903X01) |
2113 | snprintf(buf, sizeof buf, "Samsung regs: %08X", | 2058 | snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, |
2114 | samsung_get(RADIO_ALL)); | 2059 | "Samsung regs: %08X", samsung_get(RADIO_ALL)); |
2115 | lcd_puts(0, row++, buf); | ||
2116 | #endif | 2060 | #endif |
2117 | #if (CONFIG_TUNER & TEA5767) | 2061 | #if (CONFIG_TUNER & TEA5767) |
2118 | { | 2062 | struct philips_dbg_info info; |
2119 | struct philips_dbg_info info; | 2063 | philips_dbg_info(&info); |
2120 | philips_dbg_info(&info); | 2064 | snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, "Philips regs:"); |
2121 | 2065 | snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, | |
2122 | snprintf(buf, sizeof buf, "Philips regs:"); | 2066 | " Read: %02X %02X %02X %02X %02X", |
2123 | lcd_puts(0, row++, buf); | 2067 | (unsigned)info.read_regs[0], (unsigned)info.read_regs[1], |
2124 | 2068 | (unsigned)info.read_regs[2], (unsigned)info.read_regs[3], | |
2125 | snprintf(buf, sizeof buf, " Read: %02X %02X %02X %02X %02X", | 2069 | (unsigned)info.read_regs[4]); |
2126 | (unsigned)info.read_regs[0], (unsigned)info.read_regs[1], | 2070 | snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, |
2127 | (unsigned)info.read_regs[2], (unsigned)info.read_regs[3], | 2071 | " Write: %02X %02X %02X %02X %02X", |
2128 | (unsigned)info.read_regs[4]); | 2072 | (unsigned)info.write_regs[0], (unsigned)info.write_regs[1], |
2129 | lcd_puts(0, row++, buf); | 2073 | (unsigned)info.write_regs[2], (unsigned)info.write_regs[3], |
2130 | 2074 | (unsigned)info.write_regs[4]); | |
2131 | snprintf(buf, sizeof buf, " Write: %02X %02X %02X %02X %02X", | ||
2132 | (unsigned)info.write_regs[0], (unsigned)info.write_regs[1], | ||
2133 | (unsigned)info.write_regs[2], (unsigned)info.write_regs[3], | ||
2134 | (unsigned)info.write_regs[4]); | ||
2135 | lcd_puts(0, row++, buf); | ||
2136 | } | ||
2137 | #endif | 2075 | #endif |
2138 | lcd_update(); | ||
2139 | |||
2140 | if (action_userabort(HZ)) | ||
2141 | return false; | ||
2142 | } | 2076 | } |
2077 | else | ||
2078 | snprintf(debug_list_messages[radio_lines++], DEBUG_MSG_LEN, "HW detected: no"); | ||
2079 | return btn; | ||
2080 | } | ||
2081 | static bool dbg_fm_radio(void) | ||
2082 | { | ||
2083 | radio_callback(0,0); | ||
2084 | dbg_list("FM Radio",radio_lines, 1, | ||
2085 | radio_callback, dbg_listmessage_getname); | ||
2143 | return false; | 2086 | return false; |
2144 | } | 2087 | } |
2145 | #endif /* CONFIG_TUNER */ | 2088 | #endif /* CONFIG_TUNER */ |
@@ -2360,10 +2303,10 @@ static const struct the_menu_item menuitems[] = { | |||
2360 | #ifdef HAVE_DIRCACHE | 2303 | #ifdef HAVE_DIRCACHE |
2361 | { "View dircache info", dbg_dircache_info }, | 2304 | { "View dircache info", dbg_dircache_info }, |
2362 | #endif | 2305 | #endif |
2363 | #ifdef HAVE_LCD_BITMAP | ||
2364 | #ifdef HAVE_TAGCACHE | 2306 | #ifdef HAVE_TAGCACHE |
2365 | { "View database info", dbg_tagcache_info }, | 2307 | { "View database info", dbg_tagcache_info }, |
2366 | #endif | 2308 | #endif |
2309 | #ifdef HAVE_LCD_BITMAP | ||
2367 | #if CONFIG_CODEC == SWCODEC || !defined(SIMULATOR) | 2310 | #if CONFIG_CODEC == SWCODEC || !defined(SIMULATOR) |
2368 | { "View audio thread", dbg_audio_thread }, | 2311 | { "View audio thread", dbg_audio_thread }, |
2369 | #endif | 2312 | #endif |