Björn Stenberg | 803f47b | 2002-07-15 11:23:24 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2002 Heikki Hannikainen |
| 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame] | 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. |
Björn Stenberg | 803f47b | 2002-07-15 11:23:24 +0000 | [diff] [blame] | 16 | * |
| 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 18 | * KIND, either express or implied. |
| 19 | * |
| 20 | ****************************************************************************/ |
| 21 | |
| 22 | #include "config.h" |
Michael Sevakis | d892214 | 2008-05-25 01:38:08 +0000 | [diff] [blame] | 23 | #include <stdlib.h> |
Björn Stenberg | 803f47b | 2002-07-15 11:23:24 +0000 | [diff] [blame] | 24 | #include <stdio.h> |
| 25 | #include <stdbool.h> |
Hardeep Sidhu | 9513236 | 2003-08-01 16:05:40 +0000 | [diff] [blame] | 26 | #include <string.h> |
Björn Stenberg | 803f47b | 2002-07-15 11:23:24 +0000 | [diff] [blame] | 27 | #include "lcd.h" |
Jonathan Gordon | 101693f | 2011-11-15 13:22:02 +0000 | [diff] [blame] | 28 | #include "lang.h" |
Björn Stenberg | 803f47b | 2002-07-15 11:23:24 +0000 | [diff] [blame] | 29 | #include "menu.h" |
| 30 | #include "debug_menu.h" |
| 31 | #include "kernel.h" |
Jens Arnold | dfac61e | 2008-03-01 10:47:21 +0000 | [diff] [blame] | 32 | #include "structec.h" |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 33 | #include "action.h" |
Björn Stenberg | 803f47b | 2002-07-15 11:23:24 +0000 | [diff] [blame] | 34 | #include "debug.h" |
Linus Nielsen Feltzing | 7fef58a | 2002-07-15 22:25:45 +0000 | [diff] [blame] | 35 | #include "thread.h" |
Heikki Hannikainen | 6eb4254 | 2002-08-06 10:52:51 +0000 | [diff] [blame] | 36 | #include "powermgmt.h" |
| 37 | #include "system.h" |
Linus Nielsen Feltzing | 91b26f2 | 2002-10-08 10:52:46 +0000 | [diff] [blame] | 38 | #include "font.h" |
Linus Nielsen Feltzing | 8a237a8 | 2005-04-04 12:06:29 +0000 | [diff] [blame] | 39 | #include "audio.h" |
Linus Nielsen Feltzing | f1f7bbe | 2004-03-22 11:48:13 +0000 | [diff] [blame] | 40 | #include "mp3_playback.h" |
Björn Stenberg | ae22de2 | 2002-12-02 16:07:56 +0000 | [diff] [blame] | 41 | #include "settings.h" |
Jonathan Gordon | cd1ccad | 2007-03-26 12:09:08 +0000 | [diff] [blame] | 42 | #include "list.h" |
| 43 | #include "statusbar.h" |
Linus Nielsen Feltzing | f3ad619 | 2004-02-16 12:04:55 +0000 | [diff] [blame] | 44 | #include "dir.h" |
| 45 | #include "panic.h" |
Linus Nielsen Feltzing | b81a3c5 | 2004-03-25 12:29:34 +0000 | [diff] [blame] | 46 | #include "screens.h" |
Linus Nielsen Feltzing | ade5d7b | 2004-07-26 16:06:59 +0000 | [diff] [blame] | 47 | #include "misc.h" |
Kevin Ferrare | e991bee | 2005-11-16 15:12:15 +0000 | [diff] [blame] | 48 | #include "splash.h" |
Jonathan Gordon | 101693f | 2011-11-15 13:22:02 +0000 | [diff] [blame] | 49 | #include "shortcuts.h" |
Miika Pekkarinen | 7c4e0c8 | 2006-03-26 11:33:42 +0000 | [diff] [blame] | 50 | #include "dircache.h" |
Jonathan Gordon | e385ee1 | 2008-12-31 05:59:26 +0000 | [diff] [blame] | 51 | #include "viewport.h" |
Jonathan Gordon | 710ccb7 | 2006-10-25 10:17:57 +0000 | [diff] [blame] | 52 | #ifdef HAVE_TAGCACHE |
Miika Pekkarinen | 7c4e0c8 | 2006-03-26 11:33:42 +0000 | [diff] [blame] | 53 | #include "tagcache.h" |
Jonathan Gordon | 710ccb7 | 2006-10-25 10:17:57 +0000 | [diff] [blame] | 54 | #endif |
Rafaël Carré | b612263 | 2012-01-07 19:35:46 +0000 | [diff] [blame] | 55 | #ifdef HAVE_REMOTE_LCD |
Linus Nielsen Feltzing | 0081184 | 2006-02-17 22:38:38 +0000 | [diff] [blame] | 56 | #include "lcd-remote.h" |
Rafaël Carré | b612263 | 2012-01-07 19:35:46 +0000 | [diff] [blame] | 57 | #endif |
Jens Arnold | 106f773 | 2006-05-07 22:19:29 +0000 | [diff] [blame] | 58 | #include "crc32.h" |
Miika Pekkarinen | 954b732 | 2006-08-05 20:19:10 +0000 | [diff] [blame] | 59 | #include "logf.h" |
Thomas Martitz | 35e8b14 | 2010-06-21 16:53:00 +0000 | [diff] [blame] | 60 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) |
Steve Bavin | 2c2b50a | 2006-10-04 07:29:50 +0000 | [diff] [blame] | 61 | #include "disk.h" |
| 62 | #include "adc.h" |
Steve Bavin | 2c2b50a | 2006-10-04 07:29:50 +0000 | [diff] [blame] | 63 | #include "usb.h" |
| 64 | #include "rtc.h" |
Frank Gevaerts | 2f8a008 | 2008-11-01 16:14:28 +0000 | [diff] [blame] | 65 | #include "storage.h" |
Michael Sevakis | 6db8002 | 2017-03-12 22:05:44 -0400 | [diff] [blame] | 66 | #include "fs_defines.h" |
Steve Bavin | 2c2b50a | 2006-10-04 07:29:50 +0000 | [diff] [blame] | 67 | #include "eeprom_24cxx.h" |
Frank Gevaerts | 19d1cac | 2008-10-31 21:25:04 +0000 | [diff] [blame] | 68 | #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD) |
Frank Gevaerts | a0557b2 | 2010-06-05 21:12:16 +0000 | [diff] [blame] | 69 | #include "sdmmc.h" |
Linus Nielsen Feltzing | 875bf5e | 2002-10-15 08:08:35 +0000 | [diff] [blame] | 70 | #endif |
Frank Gevaerts | 2f8a008 | 2008-11-01 16:14:28 +0000 | [diff] [blame] | 71 | #if (CONFIG_STORAGE & STORAGE_ATA) |
| 72 | #include "ata.h" |
| 73 | #endif |
Thomas Martitz | 77f19f7 | 2014-02-07 18:12:31 +0100 | [diff] [blame] | 74 | #endif /* CONFIG_PLATFORM & PLATFORM_NATIVE */ |
Thomas Martitz | 05f12e0 | 2011-12-31 13:34:56 +0000 | [diff] [blame] | 75 | #include "power.h" |
Steve Bavin | 2c2b50a | 2006-10-04 07:29:50 +0000 | [diff] [blame] | 76 | |
Amaury Pouly | 0fe7b8b | 2017-11-03 20:14:01 +0100 | [diff] [blame] | 77 | #if ((CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1) \ |
| 78 | || defined(SONY_NWZ_LINUX)) \ |
Amaury Pouly | 1015e1f | 2017-11-06 21:53:03 +0100 | [diff] [blame] | 79 | && CONFIG_TUNER != 0 |
Lorenzo Miori | 3cad557 | 2012-04-07 10:30:23 +0200 | [diff] [blame] | 80 | #include "tuner.h" |
| 81 | #include "radio.h" |
| 82 | #endif |
| 83 | |
Steve Bavin | 2c2b50a | 2006-10-04 07:29:50 +0000 | [diff] [blame] | 84 | #ifdef HAVE_LCD_BITMAP |
Jonathan Gordon | 6288523 | 2006-11-19 14:11:42 +0000 | [diff] [blame] | 85 | #include "scrollbar.h" |
Steve Bavin | 2c2b50a | 2006-10-04 07:29:50 +0000 | [diff] [blame] | 86 | #include "peakmeter.h" |
Jonathan Gordon | aaf3065 | 2013-02-12 21:00:05 +1100 | [diff] [blame] | 87 | #include "skin_engine/skin_engine.h" |
Jens Arnold | 6f9a7eb | 2004-10-06 20:43:12 +0000 | [diff] [blame] | 88 | #endif |
Daniel Stenberg | edc0792 | 2005-05-30 13:00:43 +0000 | [diff] [blame] | 89 | #include "logfdisp.h" |
Thomas Martitz | d0b72e2 | 2011-08-30 14:01:33 +0000 | [diff] [blame] | 90 | #include "core_alloc.h" |
Jens Arnold | d6c0545 | 2005-08-29 21:15:27 +0000 | [diff] [blame] | 91 | #if CONFIG_CODEC == SWCODEC |
Miika Pekkarinen | b0e78a4 | 2005-07-13 13:13:10 +0000 | [diff] [blame] | 92 | #include "pcmbuf.h" |
Nicolas Pennequin | 3e3c43c | 2007-10-25 21:27:45 +0000 | [diff] [blame] | 93 | #include "buffering.h" |
Steve Bavin | c9df8fd | 2008-03-28 11:24:24 +0000 | [diff] [blame] | 94 | #include "playback.h" |
Michael Sevakis | cc50c14 | 2006-11-13 23:21:54 +0000 | [diff] [blame] | 95 | #if defined(HAVE_SPDIF_OUT) || defined(HAVE_SPDIF_IN) |
| 96 | #include "spdif.h" |
| 97 | #endif |
Linus Nielsen Feltzing | b5a0f70 | 2005-06-22 14:03:04 +0000 | [diff] [blame] | 98 | #endif |
Steve Bavin | 338d94f | 2007-02-01 10:47:22 +0000 | [diff] [blame] | 99 | #ifdef IRIVER_H300_SERIES |
| 100 | #include "pcf50606.h" /* for pcf50606_read */ |
| 101 | #endif |
Michael Sevakis | 89a38d4 | 2007-03-11 13:59:31 +0000 | [diff] [blame] | 102 | #ifdef IAUDIO_X5 |
| 103 | #include "ds2411.h" |
| 104 | #endif |
Jens Arnold | 8636e69 | 2007-04-11 23:51:00 +0000 | [diff] [blame] | 105 | #include "hwcompat.h" |
Michael Giacomelli | 054447f | 2008-02-10 05:39:20 +0000 | [diff] [blame] | 106 | #include "button.h" |
| 107 | #if CONFIG_RTC == RTC_PCF50605 |
| 108 | #include "pcf50605.h" |
| 109 | #endif |
Thomas Martitz | 4c48b59 | 2009-08-16 22:20:11 +0000 | [diff] [blame] | 110 | #include "appevents.h" |
Karl Kurbjun | d3c0a7f | 2007-11-10 22:12:54 +0000 | [diff] [blame] | 111 | |
Mihail Zenkov | ce90c04 | 2016-03-30 12:50:40 +0000 | [diff] [blame] | 112 | #if defined(HAVE_AS3514) && CONFIG_CHARGING |
Dave Chapman | 42f77d4 | 2008-10-31 00:16:42 +0000 | [diff] [blame] | 113 | #include "ascodec.h" |
Barry Wardell | 46973f7 | 2008-03-04 14:36:22 +0000 | [diff] [blame] | 114 | #endif |
Barry Wardell | 0449c0e | 2008-03-04 14:31:14 +0000 | [diff] [blame] | 115 | |
Michael Sparmann | 30d664b | 2009-10-10 22:02:23 +0000 | [diff] [blame] | 116 | #ifdef IPOD_NANO2G |
| 117 | #include "pmu-target.h" |
| 118 | #endif |
| 119 | |
Mihail Zenkov | ce90c04 | 2016-03-30 12:50:40 +0000 | [diff] [blame] | 120 | #ifdef HAVE_USBSTACK |
| 121 | #include "usb_core.h" |
Frank Gevaerts | 49bca7f | 2009-07-18 13:27:41 +0000 | [diff] [blame] | 122 | #endif |
| 123 | |
Bertrik Sikken | c0edce8 | 2010-09-20 19:37:17 +0000 | [diff] [blame] | 124 | #if defined(IPOD_ACCESSORY_PROTOCOL) |
| 125 | #include "iap.h" |
| 126 | #endif |
| 127 | |
Thomas Martitz | dac40fd | 2013-07-02 08:24:00 +0200 | [diff] [blame] | 128 | #include "talk.h" |
| 129 | |
William Wilgus | 41869a6 | 2017-02-05 21:07:20 +0100 | [diff] [blame] | 130 | #if defined(HAVE_BOOTDATA) && !defined(SIMULATOR) |
| 131 | #include "bootdata.h" |
| 132 | #endif |
| 133 | |
Nils Wallménius | 3200d04 | 2009-08-20 16:47:44 +0000 | [diff] [blame] | 134 | static const char* threads_getname(int selected_item, void *data, |
| 135 | char *buffer, size_t buffer_len) |
Jonathan Gordon | cd1ccad | 2007-03-26 12:09:08 +0000 | [diff] [blame] | 136 | { |
| 137 | (void)data; |
Michael Sevakis | 7914e90 | 2007-09-28 10:20:02 +0000 | [diff] [blame] | 138 | |
| 139 | #if NUM_CORES > 1 |
| 140 | if (selected_item < (int)NUM_CORES) |
| 141 | { |
Michael Sevakis | 981d028 | 2014-08-08 01:39:29 -0400 | [diff] [blame] | 142 | struct core_debug_info coreinfo; |
| 143 | core_get_debug_info(selected_item, &coreinfo); |
Nils Wallménius | 6848961 | 2008-04-09 15:25:17 +0000 | [diff] [blame] | 144 | snprintf(buffer, buffer_len, "Idle (%d): %2d%%", selected_item, |
Michael Sevakis | 981d028 | 2014-08-08 01:39:29 -0400 | [diff] [blame] | 145 | coreinfo.idle_stack_usage); |
Michael Sevakis | 7914e90 | 2007-09-28 10:20:02 +0000 | [diff] [blame] | 146 | return buffer; |
| 147 | } |
| 148 | |
| 149 | selected_item -= NUM_CORES; |
| 150 | #endif |
| 151 | |
Michael Sevakis | 6ed0087 | 2014-08-08 06:33:51 -0400 | [diff] [blame] | 152 | const char *fmtstr = "%2d: ---"; |
| 153 | |
Michael Sevakis | 981d028 | 2014-08-08 01:39:29 -0400 | [diff] [blame] | 154 | struct thread_debug_info threadinfo; |
Michael Sevakis | 6ed0087 | 2014-08-08 06:33:51 -0400 | [diff] [blame] | 155 | if (thread_get_debug_info(selected_item, &threadinfo) > 0) |
Miika Pekkarinen | 66258a3 | 2007-03-26 16:55:17 +0000 | [diff] [blame] | 156 | { |
Michael Sevakis | 6ed0087 | 2014-08-08 06:33:51 -0400 | [diff] [blame] | 157 | fmtstr = "%2d:" IF_COP(" (%d)") " %s" IF_PRIO(" %d %d") |
| 158 | IFN_SDL(" %2d%%") " %s"; |
Miika Pekkarinen | 66258a3 | 2007-03-26 16:55:17 +0000 | [diff] [blame] | 159 | } |
Michael Sevakis | 7914e90 | 2007-09-28 10:20:02 +0000 | [diff] [blame] | 160 | |
Michael Sevakis | 6ed0087 | 2014-08-08 06:33:51 -0400 | [diff] [blame] | 161 | snprintf(buffer, buffer_len, fmtstr, |
Miika Pekkarinen | 66258a3 | 2007-03-26 16:55:17 +0000 | [diff] [blame] | 162 | selected_item, |
Michael Sevakis | 6ed0087 | 2014-08-08 06:33:51 -0400 | [diff] [blame] | 163 | IF_COP(threadinfo.core,) |
Michael Sevakis | 981d028 | 2014-08-08 01:39:29 -0400 | [diff] [blame] | 164 | threadinfo.statusstr, |
Michael Sevakis | 6ed0087 | 2014-08-08 06:33:51 -0400 | [diff] [blame] | 165 | IF_PRIO(threadinfo.base_priority, threadinfo.current_priority,) |
| 166 | IFN_SDL(threadinfo.stack_usage,) |
Michael Sevakis | 981d028 | 2014-08-08 01:39:29 -0400 | [diff] [blame] | 167 | threadinfo.name); |
Michael Sevakis | 7914e90 | 2007-09-28 10:20:02 +0000 | [diff] [blame] | 168 | |
Jonathan Gordon | cd1ccad | 2007-03-26 12:09:08 +0000 | [diff] [blame] | 169 | return buffer; |
| 170 | } |
Nils Wallménius | 3200d04 | 2009-08-20 16:47:44 +0000 | [diff] [blame] | 171 | |
Jonathan Gordon | 5f893be | 2007-10-20 12:32:55 +0000 | [diff] [blame] | 172 | static int dbg_threads_action_callback(int action, struct gui_synclist *lists) |
Jonathan Gordon | cd41bfa | 2007-04-05 04:52:53 +0000 | [diff] [blame] | 173 | { |
Jonathan Gordon | 5f893be | 2007-10-20 12:32:55 +0000 | [diff] [blame] | 174 | (void)lists; |
Michael Sevakis | 7cbf70c | 2008-02-28 16:48:18 +0000 | [diff] [blame] | 175 | if (action == ACTION_NONE) |
| 176 | action = ACTION_REDRAW; |
Jonathan Gordon | cd41bfa | 2007-04-05 04:52:53 +0000 | [diff] [blame] | 177 | return action; |
| 178 | } |
Linus Nielsen Feltzing | 7fef58a | 2002-07-15 22:25:45 +0000 | [diff] [blame] | 179 | /* Test code!!! */ |
Jens Arnold | 314f3b5 | 2006-12-12 22:22:21 +0000 | [diff] [blame] | 180 | static bool dbg_os(void) |
Linus Nielsen Feltzing | 7fef58a | 2002-07-15 22:25:45 +0000 | [diff] [blame] | 181 | { |
Jonathan Gordon | 5f893be | 2007-10-20 12:32:55 +0000 | [diff] [blame] | 182 | struct simplelist_info info; |
Jonathan Gordon | 616971c | 2007-10-21 06:42:52 +0000 | [diff] [blame] | 183 | simplelist_info_init(&info, IF_COP("Core and ") "Stack usage:", |
Michael Sevakis | 6ed0087 | 2014-08-08 06:33:51 -0400 | [diff] [blame] | 184 | MAXTHREADS IF_COP( + NUM_CORES ), NULL); |
Jonathan Gordon | 5f893be | 2007-10-20 12:32:55 +0000 | [diff] [blame] | 185 | info.hide_selection = true; |
Jonathan Gordon | 82c1aa8 | 2008-05-05 07:11:27 +0000 | [diff] [blame] | 186 | info.scroll_all = true; |
Michael Sevakis | a16035d | 2007-07-15 18:25:39 +0000 | [diff] [blame] | 187 | info.action_callback = dbg_threads_action_callback; |
Jonathan Gordon | 5f893be | 2007-10-20 12:32:55 +0000 | [diff] [blame] | 188 | info.get_name = threads_getname; |
Jonathan Gordon | 5f893be | 2007-10-20 12:32:55 +0000 | [diff] [blame] | 189 | return simplelist_show_list(&info); |
Linus Nielsen Feltzing | 7fef58a | 2002-07-15 22:25:45 +0000 | [diff] [blame] | 190 | } |
Jonathan Gordon | cd1ccad | 2007-03-26 12:09:08 +0000 | [diff] [blame] | 191 | |
Thomas Martitz | 287454d | 2011-12-19 15:42:04 +0000 | [diff] [blame] | 192 | #ifdef __linux__ |
| 193 | #include "cpuinfo-linux.h" |
| 194 | |
| 195 | #define MAX_STATES 16 |
| 196 | static struct time_state states[MAX_STATES]; |
| 197 | |
| 198 | static const char* get_cpuinfo(int selected_item, void *data, |
| 199 | char *buffer, size_t buffer_len) |
| 200 | { |
| 201 | (void)data;(void)buffer_len; |
| 202 | const char* text; |
| 203 | long time, diff; |
| 204 | struct cpuusage us; |
| 205 | static struct cpuusage last_us; |
| 206 | int state_count = *(int*)data; |
| 207 | |
| 208 | if (cpuusage_linux(&us) != 0) |
| 209 | return NULL; |
| 210 | |
| 211 | switch(selected_item) |
| 212 | { |
| 213 | case 0: |
| 214 | diff = abs(last_us.usage - us.usage); |
| 215 | sprintf(buffer, "Usage: %ld.%02ld%% (%c %ld.%02ld)", |
| 216 | us.usage/100, us.usage%100, |
| 217 | (us.usage >= last_us.usage) ? '+':'-', |
| 218 | diff/100, diff%100); |
| 219 | last_us.usage = us.usage; |
| 220 | return buffer; |
| 221 | case 1: |
| 222 | text = "User"; |
| 223 | time = us.utime; |
| 224 | diff = us.utime - last_us.utime; |
| 225 | last_us.utime = us.utime; |
| 226 | break; |
| 227 | case 2: |
| 228 | text = "Sys"; |
| 229 | time = us.stime; |
| 230 | diff = us.stime - last_us.stime; |
| 231 | last_us.stime = us.stime; |
| 232 | break; |
| 233 | case 3: |
| 234 | text = "Real"; |
| 235 | time = us.rtime; |
| 236 | diff = us.rtime - last_us.rtime; |
| 237 | last_us.rtime = us.rtime; |
| 238 | break; |
| 239 | case 4: |
| 240 | return "*** Per CPU freq stats ***"; |
| 241 | default: |
| 242 | { |
| 243 | int cpu = (selected_item - 5) / (state_count + 1); |
| 244 | int cpu_line = (selected_item - 5) % (state_count + 1); |
Amaury Pouly | 4382f87 | 2017-10-06 18:31:35 +0200 | [diff] [blame] | 245 | |
| 246 | /* scaling info */ |
Udo Schläpfer | 6d3dc8f | 2014-12-13 20:45:03 +0100 | [diff] [blame] | 247 | int min_freq = min_scaling_frequency(cpu); |
| 248 | int cur_freq = current_scaling_frequency(cpu); |
Amaury Pouly | 4382f87 | 2017-10-06 18:31:35 +0200 | [diff] [blame] | 249 | /* fallback if scaling frequency is not available */ |
| 250 | if(cur_freq <= 0) |
| 251 | cur_freq = frequency_linux(cpu); |
Udo Schläpfer | 6d3dc8f | 2014-12-13 20:45:03 +0100 | [diff] [blame] | 252 | int max_freq = max_scaling_frequency(cpu); |
| 253 | char governor[20]; |
| 254 | bool have_governor = current_scaling_governor(cpu, governor, sizeof(governor)); |
| 255 | if(cpu_line == 0) |
| 256 | { |
| 257 | sprintf(buffer, |
| 258 | " CPU%d: %s: %d/%d/%d MHz", |
| 259 | cpu, |
| 260 | have_governor ? governor : "Min/Cur/Max freq", |
| 261 | min_freq > 0 ? min_freq/1000 : -1, |
| 262 | cur_freq > 0 ? cur_freq/1000 : -1, |
| 263 | max_freq > 0 ? max_freq/1000 : -1); |
| 264 | } |
Thomas Martitz | 287454d | 2011-12-19 15:42:04 +0000 | [diff] [blame] | 265 | else |
| 266 | { |
| 267 | cpustatetimes_linux(cpu, states, ARRAYLEN(states)); |
| 268 | snprintf(buffer, buffer_len, " %ld %ld", |
| 269 | states[cpu_line-1].frequency, |
| 270 | states[cpu_line-1].time); |
| 271 | } |
| 272 | return buffer; |
| 273 | } |
| 274 | } |
| 275 | sprintf(buffer, "%s: %ld.%02lds (+ %ld.%02ld)", text, |
| 276 | time / us.hz, time % us.hz, |
| 277 | diff / us.hz, diff % us.hz); |
| 278 | return buffer; |
| 279 | } |
| 280 | |
| 281 | static int cpuinfo_cb(int action, struct gui_synclist *lists) |
| 282 | { |
| 283 | (void)lists; |
| 284 | if (action == ACTION_NONE) |
| 285 | action = ACTION_REDRAW; |
| 286 | return action; |
| 287 | } |
| 288 | |
| 289 | static bool dbg_cpuinfo(void) |
| 290 | { |
| 291 | struct simplelist_info info; |
| 292 | int cpu_count = MAX(cpucount_linux(), 1); |
| 293 | int state_count = cpustatetimes_linux(0, states, ARRAYLEN(states)); |
| 294 | printf("%s(): %d %d\n", __func__, cpu_count, state_count); |
| 295 | simplelist_info_init(&info, "CPU info:", 5 + cpu_count*(state_count+1), &state_count); |
| 296 | info.get_name = get_cpuinfo; |
| 297 | info.action_callback = cpuinfo_cb; |
| 298 | info.timeout = HZ; |
| 299 | info.hide_selection = true; |
| 300 | info.scroll_all = true; |
| 301 | return simplelist_show_list(&info); |
| 302 | } |
| 303 | |
| 304 | #endif |
| 305 | |
Linus Nielsen Feltzing | b5a0f70 | 2005-06-22 14:03:04 +0000 | [diff] [blame] | 306 | #ifdef HAVE_LCD_BITMAP |
Jens Arnold | d6c0545 | 2005-08-29 21:15:27 +0000 | [diff] [blame] | 307 | #if CONFIG_CODEC != SWCODEC |
Steve Bavin | 2c2b50a | 2006-10-04 07:29:50 +0000 | [diff] [blame] | 308 | #ifndef SIMULATOR |
Jens Arnold | 314f3b5 | 2006-12-12 22:22:21 +0000 | [diff] [blame] | 309 | static bool dbg_audio_thread(void) |
Linus Nielsen Feltzing | 2f74eaa | 2002-10-14 14:13:48 +0000 | [diff] [blame] | 310 | { |
Linus Nielsen Feltzing | 8a237a8 | 2005-04-04 12:06:29 +0000 | [diff] [blame] | 311 | struct audio_debug d; |
Linus Nielsen Feltzing | 2f74eaa | 2002-10-14 14:13:48 +0000 | [diff] [blame] | 312 | |
Linus Nielsen Feltzing | 44bba0f | 2005-06-22 21:37:00 +0000 | [diff] [blame] | 313 | lcd_setfont(FONT_SYSFIXED); |
Daniel Ankers | 0aec12f | 2006-08-21 17:35:35 +0000 | [diff] [blame] | 314 | |
Linus Nielsen Feltzing | 2f74eaa | 2002-10-14 14:13:48 +0000 | [diff] [blame] | 315 | while(1) |
| 316 | { |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 317 | if (action_userabort(HZ/5)) |
| 318 | return false; |
Linus Nielsen Feltzing | 2f74eaa | 2002-10-14 14:13:48 +0000 | [diff] [blame] | 319 | |
Linus Nielsen Feltzing | 8a237a8 | 2005-04-04 12:06:29 +0000 | [diff] [blame] | 320 | audio_get_debugdata(&d); |
Daniel Ankers | 0aec12f | 2006-08-21 17:35:35 +0000 | [diff] [blame] | 321 | |
Linus Nielsen Feltzing | 2f74eaa | 2002-10-14 14:13:48 +0000 | [diff] [blame] | 322 | lcd_clear_display(); |
| 323 | |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 324 | lcd_putsf(0, 0, "read: %x", d.audiobuf_read); |
| 325 | lcd_putsf(0, 1, "write: %x", d.audiobuf_write); |
| 326 | lcd_putsf(0, 2, "swap: %x", d.audiobuf_swapwrite); |
| 327 | lcd_putsf(0, 3, "playing: %d", d.playing); |
| 328 | lcd_putsf(0, 4, "playable: %x", d.playable_space); |
| 329 | lcd_putsf(0, 5, "unswapped: %x", d.unswapped_space); |
Linus Nielsen Feltzing | bf303de | 2002-10-15 07:23:18 +0000 | [diff] [blame] | 330 | |
Linus Nielsen Feltzing | 2441061 | 2004-07-08 13:14:44 +0000 | [diff] [blame] | 331 | /* Playable space left */ |
Jonathan Gordon | 6288523 | 2006-11-19 14:11:42 +0000 | [diff] [blame] | 332 | gui_scrollbar_draw(&screens[SCREEN_MAIN],0, 6*8, 112, 4, d.audiobuflen, 0, |
Linus Nielsen Feltzing | 2441061 | 2004-07-08 13:14:44 +0000 | [diff] [blame] | 333 | d.playable_space, HORIZONTAL); |
Linus Nielsen Feltzing | bf303de | 2002-10-15 07:23:18 +0000 | [diff] [blame] | 334 | |
Linus Nielsen Feltzing | 2441061 | 2004-07-08 13:14:44 +0000 | [diff] [blame] | 335 | /* Show the watermark limit */ |
Jonathan Gordon | 6288523 | 2006-11-19 14:11:42 +0000 | [diff] [blame] | 336 | gui_scrollbar_draw(&screens[SCREEN_MAIN],0, 6*8+4, 112, 4, d.audiobuflen, 0, |
Linus Nielsen Feltzing | 2441061 | 2004-07-08 13:14:44 +0000 | [diff] [blame] | 337 | d.low_watermark_level, HORIZONTAL); |
Linus Nielsen Feltzing | bf303de | 2002-10-15 07:23:18 +0000 | [diff] [blame] | 338 | |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 339 | lcd_putsf(0, 7, "wm: %x - %x", |
Nils Wallménius | a971334 | 2009-10-17 13:00:58 +0000 | [diff] [blame] | 340 | d.low_watermark_level, d.lowest_watermark_level); |
Daniel Ankers | 0aec12f | 2006-08-21 17:35:35 +0000 | [diff] [blame] | 341 | |
Linus Nielsen Feltzing | 2f74eaa | 2002-10-14 14:13:48 +0000 | [diff] [blame] | 342 | lcd_update(); |
| 343 | } |
Jonathan Gordon | 8b9fdb5 | 2009-01-05 09:59:11 +0000 | [diff] [blame] | 344 | lcd_setfont(FONT_UI); |
Linus Nielsen Feltzing | 2f74eaa | 2002-10-14 14:13:48 +0000 | [diff] [blame] | 345 | return false; |
| 346 | } |
Steve Bavin | 2c2b50a | 2006-10-04 07:29:50 +0000 | [diff] [blame] | 347 | #endif /* !SIMULATOR */ |
Jens Arnold | 5fd58dc | 2005-10-10 19:43:07 +0000 | [diff] [blame] | 348 | #else /* CONFIG_CODEC == SWCODEC */ |
Michael Sevakis | 6d2e776 | 2011-01-22 18:30:24 +0000 | [diff] [blame] | 349 | static unsigned int ticks, freq_sum; |
| 350 | #ifndef CPU_MULTI_FREQUENCY |
| 351 | static unsigned int boost_ticks; |
| 352 | #endif |
Linus Nielsen Feltzing | b5a0f70 | 2005-06-22 14:03:04 +0000 | [diff] [blame] | 353 | |
Jens Arnold | 314f3b5 | 2006-12-12 22:22:21 +0000 | [diff] [blame] | 354 | static void dbg_audio_task(void) |
Linus Nielsen Feltzing | b5a0f70 | 2005-06-22 14:03:04 +0000 | [diff] [blame] | 355 | { |
Thomas Martitz | 35e8b14 | 2010-06-21 16:53:00 +0000 | [diff] [blame] | 356 | #ifdef CPUFREQ_NORMAL |
Michael Sevakis | 6d2e776 | 2011-01-22 18:30:24 +0000 | [diff] [blame] | 357 | #ifndef CPU_MULTI_FREQUENCY |
Linus Nielsen Feltzing | b5a0f70 | 2005-06-22 14:03:04 +0000 | [diff] [blame] | 358 | if(FREQ > CPUFREQ_NORMAL) |
| 359 | boost_ticks++; |
Michael Sevakis | 6d2e776 | 2011-01-22 18:30:24 +0000 | [diff] [blame] | 360 | #endif |
Andree Buschmann | 23ee774 | 2008-04-19 10:43:00 +0000 | [diff] [blame] | 361 | freq_sum += FREQ/1000000; /* in MHz */ |
Andree Buschmann | 6592f94 | 2008-04-19 11:17:06 +0000 | [diff] [blame] | 362 | #endif |
Linus Nielsen Feltzing | b5a0f70 | 2005-06-22 14:03:04 +0000 | [diff] [blame] | 363 | ticks++; |
| 364 | } |
| 365 | |
Nicolas Pennequin | 3e3c43c | 2007-10-25 21:27:45 +0000 | [diff] [blame] | 366 | static bool dbg_buffering_thread(void) |
Linus Nielsen Feltzing | b5a0f70 | 2005-06-22 14:03:04 +0000 | [diff] [blame] | 367 | { |
Linus Nielsen Feltzing | b5a0f70 | 2005-06-22 14:03:04 +0000 | [diff] [blame] | 368 | int button; |
Mihail Zenkov | ce90c04 | 2016-03-30 12:50:40 +0000 | [diff] [blame] | 369 | int line; |
Linus Nielsen Feltzing | fcc282c | 2005-06-22 14:09:07 +0000 | [diff] [blame] | 370 | bool done = false; |
Brandon Low | 75de60b | 2006-04-25 20:32:38 +0000 | [diff] [blame] | 371 | size_t bufused; |
Brandon Low | 413da2a | 2006-02-07 20:38:55 +0000 | [diff] [blame] | 372 | size_t bufsize = pcmbuf_get_bufsize(); |
| 373 | int pcmbufdescs = pcmbuf_descs(); |
Nicolas Pennequin | 3e3c43c | 2007-10-25 21:27:45 +0000 | [diff] [blame] | 374 | struct buffering_debug d; |
Jeffrey Goode | 9a4420b | 2009-10-31 19:17:36 +0000 | [diff] [blame] | 375 | size_t filebuflen = audio_get_filebuflen(); |
| 376 | /* This is a size_t, but call it a long so it puts a - when it's bad. */ |
Linus Nielsen Feltzing | b5a0f70 | 2005-06-22 14:03:04 +0000 | [diff] [blame] | 377 | |
Michael Sevakis | 6d2e776 | 2011-01-22 18:30:24 +0000 | [diff] [blame] | 378 | #ifndef CPU_MULTI_FREQUENCY |
| 379 | boost_ticks = 0; |
| 380 | #endif |
| 381 | ticks = freq_sum = 0; |
Linus Nielsen Feltzing | b5a0f70 | 2005-06-22 14:03:04 +0000 | [diff] [blame] | 382 | |
| 383 | tick_add_task(dbg_audio_task); |
Mihail Zenkov | ce90c04 | 2016-03-30 12:50:40 +0000 | [diff] [blame] | 384 | |
Jonathan Gordon | 341cb85 | 2010-04-25 12:01:25 +0000 | [diff] [blame] | 385 | FOR_NB_SCREENS(i) |
| 386 | screens[i].setfont(FONT_SYSFIXED); |
Mihail Zenkov | ce90c04 | 2016-03-30 12:50:40 +0000 | [diff] [blame] | 387 | |
Linus Nielsen Feltzing | fcc282c | 2005-06-22 14:09:07 +0000 | [diff] [blame] | 388 | while(!done) |
Linus Nielsen Feltzing | b5a0f70 | 2005-06-22 14:03:04 +0000 | [diff] [blame] | 389 | { |
Michael Giacomelli | b9eb182 | 2008-07-17 18:36:47 +0000 | [diff] [blame] | 390 | button = get_action(CONTEXT_STD,HZ/5); |
Linus Nielsen Feltzing | b5a0f70 | 2005-06-22 14:03:04 +0000 | [diff] [blame] | 391 | switch(button) |
| 392 | { |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 393 | case ACTION_STD_NEXT: |
Brandon Low | 413da2a | 2006-02-07 20:38:55 +0000 | [diff] [blame] | 394 | audio_next(); |
| 395 | break; |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 396 | case ACTION_STD_PREV: |
Brandon Low | 413da2a | 2006-02-07 20:38:55 +0000 | [diff] [blame] | 397 | audio_prev(); |
| 398 | break; |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 399 | case ACTION_STD_CANCEL: |
Linus Nielsen Feltzing | fcc282c | 2005-06-22 14:09:07 +0000 | [diff] [blame] | 400 | done = true; |
Michael Sevakis | 9e8fe0e | 2006-10-30 11:33:38 +0000 | [diff] [blame] | 401 | break; |
Linus Nielsen Feltzing | b5a0f70 | 2005-06-22 14:03:04 +0000 | [diff] [blame] | 402 | } |
Nicolas Pennequin | 3e3c43c | 2007-10-25 21:27:45 +0000 | [diff] [blame] | 403 | |
| 404 | buffering_get_debugdata(&d); |
Brandon Low | 75de60b | 2006-04-25 20:32:38 +0000 | [diff] [blame] | 405 | bufused = bufsize - pcmbuf_free(); |
| 406 | |
Mihail Zenkov | ce90c04 | 2016-03-30 12:50:40 +0000 | [diff] [blame] | 407 | FOR_NB_SCREENS(i) |
Jonathan Gordon | 341cb85 | 2010-04-25 12:01:25 +0000 | [diff] [blame] | 408 | { |
| 409 | line = 0; |
| 410 | screens[i].clear_display(); |
Linus Nielsen Feltzing | b5a0f70 | 2005-06-22 14:03:04 +0000 | [diff] [blame] | 411 | |
Linus Nielsen Feltzing | b5a0f70 | 2005-06-22 14:03:04 +0000 | [diff] [blame] | 412 | |
Jonathan Gordon | 341cb85 | 2010-04-25 12:01:25 +0000 | [diff] [blame] | 413 | screens[i].putsf(0, line++, "pcm: %6ld/%ld", (long) bufused, (long) bufsize); |
Linus Nielsen Feltzing | b5a0f70 | 2005-06-22 14:03:04 +0000 | [diff] [blame] | 414 | |
Jonathan Gordon | 341cb85 | 2010-04-25 12:01:25 +0000 | [diff] [blame] | 415 | gui_scrollbar_draw(&screens[i],0, line*8, screens[i].lcdwidth, 6, |
| 416 | bufsize, 0, bufused, HORIZONTAL); |
| 417 | line++; |
Linus Nielsen Feltzing | b5a0f70 | 2005-06-22 14:03:04 +0000 | [diff] [blame] | 418 | |
Jonathan Gordon | 341cb85 | 2010-04-25 12:01:25 +0000 | [diff] [blame] | 419 | screens[i].putsf(0, line++, "alloc: %6ld/%ld", audio_filebufused(), |
| 420 | (long) filebuflen); |
Nicolas Pennequin | 3e3c43c | 2007-10-25 21:27:45 +0000 | [diff] [blame] | 421 | |
Jonathan Gordon | 44e51ce | 2010-04-25 12:14:28 +0000 | [diff] [blame] | 422 | #if LCD_HEIGHT > 80 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_HEIGHT > 80) |
Jonathan Gordon | 341cb85 | 2010-04-25 12:01:25 +0000 | [diff] [blame] | 423 | if (screens[i].lcdheight > 80) |
| 424 | { |
| 425 | gui_scrollbar_draw(&screens[i],0, line*8, screens[i].lcdwidth, 6, |
| 426 | filebuflen, 0, audio_filebufused(), HORIZONTAL); |
| 427 | line++; |
| 428 | |
| 429 | screens[i].putsf(0, line++, "real: %6ld/%ld", (long)d.buffered_data, |
| 430 | (long)filebuflen); |
| 431 | |
| 432 | gui_scrollbar_draw(&screens[i],0, line*8, screens[i].lcdwidth, 6, |
| 433 | filebuflen, 0, (long)d.buffered_data, HORIZONTAL); |
| 434 | line++; |
| 435 | } |
Nicolas Pennequin | 3e3c43c | 2007-10-25 21:27:45 +0000 | [diff] [blame] | 436 | #endif |
| 437 | |
Jonathan Gordon | 341cb85 | 2010-04-25 12:01:25 +0000 | [diff] [blame] | 438 | screens[i].putsf(0, line++, "usefl: %6ld/%ld", (long)(d.useful_data), |
Nicolas Pennequin | 3e3c43c | 2007-10-25 21:27:45 +0000 | [diff] [blame] | 439 | (long)filebuflen); |
Nicolas Pennequin | 3e3c43c | 2007-10-25 21:27:45 +0000 | [diff] [blame] | 440 | |
Jonathan Gordon | 44e51ce | 2010-04-25 12:14:28 +0000 | [diff] [blame] | 441 | #if LCD_HEIGHT > 80 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_HEIGHT > 80) |
Jonathan Gordon | 341cb85 | 2010-04-25 12:01:25 +0000 | [diff] [blame] | 442 | if (screens[i].lcdheight > 80) |
| 443 | { |
| 444 | gui_scrollbar_draw(&screens[i],0, line*8, screens[i].lcdwidth, 6, |
| 445 | filebuflen, 0, d.useful_data, HORIZONTAL); |
| 446 | line++; |
| 447 | } |
Nicolas Pennequin | 3e3c43c | 2007-10-25 21:27:45 +0000 | [diff] [blame] | 448 | #endif |
| 449 | |
Jonathan Gordon | 341cb85 | 2010-04-25 12:01:25 +0000 | [diff] [blame] | 450 | screens[i].putsf(0, line++, "data_rem: %ld", (long)d.data_rem); |
Nicolas Pennequin | 3e3c43c | 2007-10-25 21:27:45 +0000 | [diff] [blame] | 451 | |
William Wilgus | 7a132a2 | 2018-10-18 09:57:20 -0400 | [diff] [blame] | 452 | screens[i].putsf(0, line++, "track count: %2u", audio_track_count()); |
Nicolas Pennequin | 3e3c43c | 2007-10-25 21:27:45 +0000 | [diff] [blame] | 453 | |
Jonathan Gordon | 341cb85 | 2010-04-25 12:01:25 +0000 | [diff] [blame] | 454 | screens[i].putsf(0, line++, "handle count: %d", (int)d.num_handles); |
Linus Nielsen Feltzing | 17098e1 | 2005-06-22 20:37:31 +0000 | [diff] [blame] | 455 | |
Thomas Martitz | 35e8b14 | 2010-06-21 16:53:00 +0000 | [diff] [blame] | 456 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) |
Jonathan Gordon | 341cb85 | 2010-04-25 12:01:25 +0000 | [diff] [blame] | 457 | screens[i].putsf(0, line++, "cpu freq: %3dMHz", |
| 458 | (int)((FREQ + 500000) / 1000000)); |
Steve Bavin | 2c2b50a | 2006-10-04 07:29:50 +0000 | [diff] [blame] | 459 | #endif |
Linus Nielsen Feltzing | b5a0f70 | 2005-06-22 14:03:04 +0000 | [diff] [blame] | 460 | |
Jonathan Gordon | 341cb85 | 2010-04-25 12:01:25 +0000 | [diff] [blame] | 461 | if (ticks > 0) |
| 462 | { |
Jonathan Gordon | 341cb85 | 2010-04-25 12:01:25 +0000 | [diff] [blame] | 463 | int avgclock = freq_sum * 10 / ticks; /* in 100 kHz */ |
Michael Sevakis | 6d2e776 | 2011-01-22 18:30:24 +0000 | [diff] [blame] | 464 | #ifdef CPU_MULTI_FREQUENCY |
| 465 | int boostquota = (avgclock * 100 - CPUFREQ_NORMAL/1000) / |
| 466 | ((CPUFREQ_MAX - CPUFREQ_NORMAL) / 1000000); /* in 0.1 % */ |
| 467 | #else |
| 468 | int boostquota = boost_ticks * 1000 / ticks; /* in 0.1 % */ |
| 469 | #endif |
Jonathan Gordon | 341cb85 | 2010-04-25 12:01:25 +0000 | [diff] [blame] | 470 | screens[i].putsf(0, line++, "boost:%3d.%d%% (%d.%dMHz)", |
| 471 | boostquota/10, boostquota%10, avgclock/10, avgclock%10); |
| 472 | } |
| 473 | |
| 474 | screens[i].putsf(0, line++, "pcmbufdesc: %2d/%2d", |
| 475 | pcmbuf_used_descs(), pcmbufdescs); |
| 476 | screens[i].putsf(0, line++, "watermark: %6d", |
| 477 | (int)(d.watermark)); |
| 478 | |
| 479 | screens[i].update(); |
Steve Bavin | 21d538b | 2007-05-14 09:56:55 +0000 | [diff] [blame] | 480 | } |
Linus Nielsen Feltzing | b5a0f70 | 2005-06-22 14:03:04 +0000 | [diff] [blame] | 481 | } |
| 482 | |
| 483 | tick_remove_task(dbg_audio_task); |
Mihail Zenkov | ce90c04 | 2016-03-30 12:50:40 +0000 | [diff] [blame] | 484 | |
Jonathan Gordon | 341cb85 | 2010-04-25 12:01:25 +0000 | [diff] [blame] | 485 | FOR_NB_SCREENS(i) |
| 486 | screens[i].setfont(FONT_UI); |
Daniel Ankers | 0aec12f | 2006-08-21 17:35:35 +0000 | [diff] [blame] | 487 | |
Linus Nielsen Feltzing | b5a0f70 | 2005-06-22 14:03:04 +0000 | [diff] [blame] | 488 | return false; |
| 489 | } |
Jens Arnold | 5fd58dc | 2005-10-10 19:43:07 +0000 | [diff] [blame] | 490 | #endif /* CONFIG_CODEC */ |
| 491 | #endif /* HAVE_LCD_BITMAP */ |
Jörg Hohensohn | b218882 | 2003-08-01 08:00:54 +0000 | [diff] [blame] | 492 | |
Thomas Martitz | d0b72e2 | 2011-08-30 14:01:33 +0000 | [diff] [blame] | 493 | static const char* bf_getname(int selected_item, void *data, |
| 494 | char *buffer, size_t buffer_len) |
| 495 | { |
| 496 | (void)data; |
| 497 | core_print_block_at(selected_item, buffer, buffer_len); |
| 498 | return buffer; |
| 499 | } |
| 500 | |
Thomas Martitz | baa070c | 2011-08-30 14:01:45 +0000 | [diff] [blame] | 501 | static int bf_action_cb(int action, struct gui_synclist* list) |
| 502 | { |
| 503 | if (action == ACTION_STD_OK) |
| 504 | { |
Thomas Martitz | 4478b25 | 2011-10-05 18:32:19 +0000 | [diff] [blame] | 505 | if (gui_synclist_get_sel_pos(list) == 0 && core_test_free()) |
| 506 | { |
| 507 | splash(HZ, "Freed test handle. New alloc should trigger compact"); |
| 508 | } |
| 509 | else |
| 510 | { |
| 511 | splash(HZ/1, "Attempting a 64k allocation"); |
| 512 | int handle = core_alloc("test", 64<<10); |
| 513 | splash(HZ/2, (handle > 0) ? "Success":"Fail"); |
| 514 | /* for some reason simplelist doesn't allow adding items here if |
| 515 | * info.get_name is given, so use normal list api */ |
| 516 | gui_synclist_set_nb_items(list, core_get_num_blocks()); |
| 517 | if (handle > 0) |
| 518 | core_free(handle); |
| 519 | } |
Thomas Martitz | baa070c | 2011-08-30 14:01:45 +0000 | [diff] [blame] | 520 | action = ACTION_REDRAW; |
| 521 | } |
Thomas Martitz | baa070c | 2011-08-30 14:01:45 +0000 | [diff] [blame] | 522 | return action; |
| 523 | } |
| 524 | |
Thomas Martitz | d0b72e2 | 2011-08-30 14:01:33 +0000 | [diff] [blame] | 525 | static bool dbg_buflib_allocs(void) |
| 526 | { |
| 527 | struct simplelist_info info; |
| 528 | simplelist_info_init(&info, "mem allocs", core_get_num_blocks(), NULL); |
| 529 | info.get_name = bf_getname; |
Thomas Martitz | baa070c | 2011-08-30 14:01:45 +0000 | [diff] [blame] | 530 | info.action_callback = bf_action_cb; |
Jonathan Gordon | aaf3065 | 2013-02-12 21:00:05 +1100 | [diff] [blame] | 531 | info.timeout = HZ; |
Thomas Martitz | d0b72e2 | 2011-08-30 14:01:33 +0000 | [diff] [blame] | 532 | return simplelist_show_list(&info); |
| 533 | } |
| 534 | |
Thomas Martitz | 35e8b14 | 2010-06-21 16:53:00 +0000 | [diff] [blame] | 535 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) |
Nils Wallménius | 3200d04 | 2009-08-20 16:47:44 +0000 | [diff] [blame] | 536 | static const char* dbg_partitions_getname(int selected_item, void *data, |
| 537 | char *buffer, size_t buffer_len) |
Jonathan Gordon | cd41bfa | 2007-04-05 04:52:53 +0000 | [diff] [blame] | 538 | { |
| 539 | (void)data; |
| 540 | int partition = selected_item/2; |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 541 | |
| 542 | struct partinfo p; |
| 543 | if (!disk_partinfo(partition, &p)) |
| 544 | return buffer; |
| 545 | |
Jonathan Gordon | cd41bfa | 2007-04-05 04:52:53 +0000 | [diff] [blame] | 546 | if (selected_item%2) |
| 547 | { |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 548 | snprintf(buffer, buffer_len, " T:%x %ld MB", p.type, |
| 549 | p.size / ( 2048 / ( SECTOR_SIZE / 512 ))); |
Jonathan Gordon | cd41bfa | 2007-04-05 04:52:53 +0000 | [diff] [blame] | 550 | } |
| 551 | else |
| 552 | { |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 553 | snprintf(buffer, buffer_len, "P%d: S:%lx", partition, p.start); |
Jonathan Gordon | cd41bfa | 2007-04-05 04:52:53 +0000 | [diff] [blame] | 554 | } |
| 555 | return buffer; |
| 556 | } |
| 557 | |
Rafaël Carré | af76067 | 2012-01-04 05:21:31 +0000 | [diff] [blame] | 558 | static bool dbg_partitions(void) |
Björn Stenberg | 4d55c2f | 2002-10-10 12:01:58 +0000 | [diff] [blame] | 559 | { |
Jonathan Gordon | 5f893be | 2007-10-20 12:32:55 +0000 | [diff] [blame] | 560 | struct simplelist_info info; |
Solomon Peachy | 4f469e9 | 2019-07-29 21:25:37 -0400 | [diff] [blame] | 561 | simplelist_info_init(&info, "Partition Info", NUM_DRIVES * 4, NULL); |
Jonathan Gordon | 616971c | 2007-10-21 06:42:52 +0000 | [diff] [blame] | 562 | info.selection_size = 2; |
Jonathan Gordon | 5f893be | 2007-10-20 12:32:55 +0000 | [diff] [blame] | 563 | info.hide_selection = true; |
Jonathan Gordon | 82c1aa8 | 2008-05-05 07:11:27 +0000 | [diff] [blame] | 564 | info.scroll_all = true; |
Jonathan Gordon | 5f893be | 2007-10-20 12:32:55 +0000 | [diff] [blame] | 565 | info.get_name = dbg_partitions_getname; |
Jonathan Gordon | 5f893be | 2007-10-20 12:32:55 +0000 | [diff] [blame] | 566 | return simplelist_show_list(&info); |
Björn Stenberg | 4d55c2f | 2002-10-10 12:01:58 +0000 | [diff] [blame] | 567 | } |
Thomas Martitz | 35e8b14 | 2010-06-21 16:53:00 +0000 | [diff] [blame] | 568 | #endif /* PLATFORM_NATIVE */ |
Björn Stenberg | 4d55c2f | 2002-10-10 12:01:58 +0000 | [diff] [blame] | 569 | |
Linus Nielsen Feltzing | a6fb393 | 2006-03-18 23:42:34 +0000 | [diff] [blame] | 570 | #if defined(CPU_COLDFIRE) && defined(HAVE_SPDIF_OUT) |
Jens Arnold | 314f3b5 | 2006-12-12 22:22:21 +0000 | [diff] [blame] | 571 | static bool dbg_spdif(void) |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 572 | { |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 573 | int line; |
| 574 | unsigned int control; |
| 575 | int x; |
| 576 | char *s; |
| 577 | int category; |
| 578 | int generation; |
| 579 | unsigned int interruptstat; |
| 580 | bool valnogood, symbolerr, parityerr; |
Jens Arnold | 073f197 | 2006-05-12 01:10:18 +0000 | [diff] [blame] | 581 | bool done = false; |
Michael Sevakis | cc50c14 | 2006-11-13 23:21:54 +0000 | [diff] [blame] | 582 | bool spdif_src_on; |
| 583 | int spdif_source = spdif_get_output_source(&spdif_src_on); |
Michael Sevakis | 2d48d0f | 2007-06-08 23:42:04 +0000 | [diff] [blame] | 584 | spdif_set_output_source(AUDIO_SRC_SPDIF IF_SPDIF_POWER_(, true)); |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 585 | |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 586 | lcd_clear_display(); |
| 587 | lcd_setfont(FONT_SYSFIXED); |
Michael Sevakis | cc50c14 | 2006-11-13 23:21:54 +0000 | [diff] [blame] | 588 | |
Jens Arnold | 073f197 | 2006-05-12 01:10:18 +0000 | [diff] [blame] | 589 | #ifdef HAVE_SPDIF_POWER |
| 590 | spdif_power_enable(true); /* We need SPDIF power for both sending & receiving */ |
| 591 | #endif |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 592 | |
Jens Arnold | 073f197 | 2006-05-12 01:10:18 +0000 | [diff] [blame] | 593 | while (!done) |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 594 | { |
| 595 | line = 0; |
| 596 | |
| 597 | control = EBU1RCVCCHANNEL1; |
| 598 | interruptstat = INTERRUPTSTAT; |
| 599 | INTERRUPTCLEAR = 0x03c00000; |
| 600 | |
| 601 | valnogood = (interruptstat & 0x01000000)?true:false; |
| 602 | symbolerr = (interruptstat & 0x00800000)?true:false; |
| 603 | parityerr = (interruptstat & 0x00400000)?true:false; |
Jens Arnold | cfb073c | 2005-10-03 09:24:36 +0000 | [diff] [blame] | 604 | |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 605 | lcd_putsf(0, line++, "Val: %s Sym: %s Par: %s", |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 606 | valnogood?"--":"OK", |
| 607 | symbolerr?"--":"OK", |
| 608 | parityerr?"--":"OK"); |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 609 | |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 610 | lcd_putsf(0, line++, "Status word: %08x", (int)control); |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 611 | |
| 612 | line++; |
Daniel Ankers | 0aec12f | 2006-08-21 17:35:35 +0000 | [diff] [blame] | 613 | |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 614 | x = control >> 31; |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 615 | lcd_putsf(0, line++, "PRO: %d (%s)", |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 616 | x, x?"Professional":"Consumer"); |
Daniel Ankers | 0aec12f | 2006-08-21 17:35:35 +0000 | [diff] [blame] | 617 | |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 618 | x = (control >> 30) & 1; |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 619 | lcd_putsf(0, line++, "Audio: %d (%s)", |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 620 | x, x?"Non-PCM":"PCM"); |
Daniel Ankers | 0aec12f | 2006-08-21 17:35:35 +0000 | [diff] [blame] | 621 | |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 622 | x = (control >> 29) & 1; |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 623 | lcd_putsf(0, line++, "Copy: %d (%s)", |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 624 | x, x?"Permitted":"Inhibited"); |
Daniel Ankers | 0aec12f | 2006-08-21 17:35:35 +0000 | [diff] [blame] | 625 | |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 626 | x = (control >> 27) & 7; |
| 627 | switch(x) |
| 628 | { |
| 629 | case 0: |
| 630 | s = "None"; |
| 631 | break; |
| 632 | case 1: |
| 633 | s = "50/15us"; |
| 634 | break; |
| 635 | default: |
| 636 | s = "Reserved"; |
| 637 | break; |
| 638 | } |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 639 | lcd_putsf(0, line++, "Preemphasis: %d (%s)", x, s); |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 640 | |
| 641 | x = (control >> 24) & 3; |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 642 | lcd_putsf(0, line++, "Mode: %d", x); |
Daniel Ankers | 0aec12f | 2006-08-21 17:35:35 +0000 | [diff] [blame] | 643 | |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 644 | category = (control >> 17) & 127; |
| 645 | switch(category) |
| 646 | { |
| 647 | case 0x00: |
| 648 | s = "General"; |
| 649 | break; |
| 650 | case 0x40: |
| 651 | s = "Audio CD"; |
| 652 | break; |
| 653 | default: |
| 654 | s = "Unknown"; |
| 655 | } |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 656 | lcd_putsf(0, line++, "Category: 0x%02x (%s)", category, s); |
Daniel Ankers | 0aec12f | 2006-08-21 17:35:35 +0000 | [diff] [blame] | 657 | |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 658 | x = (control >> 16) & 1; |
| 659 | generation = x; |
| 660 | if(((category & 0x70) == 0x10) || |
| 661 | ((category & 0x70) == 0x40) || |
| 662 | ((category & 0x78) == 0x38)) |
| 663 | { |
| 664 | generation = !generation; |
| 665 | } |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 666 | lcd_putsf(0, line++, "Generation: %d (%s)", |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 667 | x, generation?"Original":"No ind."); |
Daniel Ankers | 0aec12f | 2006-08-21 17:35:35 +0000 | [diff] [blame] | 668 | |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 669 | x = (control >> 12) & 15; |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 670 | lcd_putsf(0, line++, "Source: %d", x); |
Nils Wallménius | a971334 | 2009-10-17 13:00:58 +0000 | [diff] [blame] | 671 | |
Daniel Ankers | 0aec12f | 2006-08-21 17:35:35 +0000 | [diff] [blame] | 672 | |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 673 | x = (control >> 8) & 15; |
| 674 | switch(x) |
| 675 | { |
| 676 | case 0: |
| 677 | s = "Unspecified"; |
| 678 | break; |
| 679 | case 8: |
| 680 | s = "A (Left)"; |
| 681 | break; |
| 682 | case 4: |
| 683 | s = "B (Right)"; |
| 684 | break; |
| 685 | default: |
| 686 | s = ""; |
| 687 | break; |
| 688 | } |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 689 | lcd_putsf(0, line++, "Channel: %d (%s)", x, s); |
Daniel Ankers | 0aec12f | 2006-08-21 17:35:35 +0000 | [diff] [blame] | 690 | |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 691 | x = (control >> 4) & 15; |
| 692 | switch(x) |
| 693 | { |
| 694 | case 0: |
| 695 | s = "44.1kHz"; |
| 696 | break; |
| 697 | case 0x4: |
| 698 | s = "48kHz"; |
| 699 | break; |
| 700 | case 0xc: |
| 701 | s = "32kHz"; |
| 702 | break; |
| 703 | } |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 704 | lcd_putsf(0, line++, "Frequency: %d (%s)", x, s); |
Jens Arnold | 073f197 | 2006-05-12 01:10:18 +0000 | [diff] [blame] | 705 | |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 706 | x = (control >> 2) & 3; |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 707 | lcd_putsf(0, line++, "Clock accuracy: %d", x); |
Jens Arnold | 073f197 | 2006-05-12 01:10:18 +0000 | [diff] [blame] | 708 | line++; |
Daniel Ankers | 0aec12f | 2006-08-21 17:35:35 +0000 | [diff] [blame] | 709 | |
Thomas Martitz | 35e8b14 | 2010-06-21 16:53:00 +0000 | [diff] [blame] | 710 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 711 | lcd_putsf(0, line++, "Measured freq: %ldHz", |
Michael Sevakis | cc50c14 | 2006-11-13 23:21:54 +0000 | [diff] [blame] | 712 | spdif_measure_frequency()); |
Steve Bavin | 2c2b50a | 2006-10-04 07:29:50 +0000 | [diff] [blame] | 713 | #endif |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 714 | |
Jens Arnold | 073f197 | 2006-05-12 01:10:18 +0000 | [diff] [blame] | 715 | lcd_update(); |
| 716 | |
Jonathan Gordon | 475be66 | 2006-08-16 04:27:33 +0000 | [diff] [blame] | 717 | if (action_userabort(HZ/10)) |
Michael Sevakis | cc50c14 | 2006-11-13 23:21:54 +0000 | [diff] [blame] | 718 | break; |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 719 | } |
Michael Sevakis | cc50c14 | 2006-11-13 23:21:54 +0000 | [diff] [blame] | 720 | |
Michael Sevakis | 2d48d0f | 2007-06-08 23:42:04 +0000 | [diff] [blame] | 721 | spdif_set_output_source(spdif_source IF_SPDIF_POWER_(, spdif_src_on)); |
Michael Sevakis | cc50c14 | 2006-11-13 23:21:54 +0000 | [diff] [blame] | 722 | |
Jens Arnold | 073f197 | 2006-05-12 01:10:18 +0000 | [diff] [blame] | 723 | #ifdef HAVE_SPDIF_POWER |
| 724 | spdif_power_enable(global_settings.spdif_enable); |
| 725 | #endif |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 726 | |
Jonathan Gordon | 8b9fdb5 | 2009-01-05 09:59:11 +0000 | [diff] [blame] | 727 | lcd_setfont(FONT_UI); |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 728 | return false; |
| 729 | } |
Jens Arnold | 5fd58dc | 2005-10-10 19:43:07 +0000 | [diff] [blame] | 730 | #endif /* CPU_COLDFIRE */ |
Linus Nielsen Feltzing | 3c82b84 | 2005-07-18 18:28:49 +0000 | [diff] [blame] | 731 | |
Thomas Martitz | 35e8b14 | 2010-06-21 16:53:00 +0000 | [diff] [blame] | 732 | #if (CONFIG_RTC == RTC_PCF50605) && (CONFIG_PLATFORM & PLATFORM_NATIVE) |
Michael Giacomelli | 054447f | 2008-02-10 05:39:20 +0000 | [diff] [blame] | 733 | static bool dbg_pcf(void) |
| 734 | { |
Michael Giacomelli | 054447f | 2008-02-10 05:39:20 +0000 | [diff] [blame] | 735 | int line; |
| 736 | |
| 737 | #ifdef HAVE_LCD_BITMAP |
Michael Giacomelli | 054447f | 2008-02-10 05:39:20 +0000 | [diff] [blame] | 738 | lcd_setfont(FONT_SYSFIXED); |
| 739 | #endif |
| 740 | lcd_clear_display(); |
| 741 | |
| 742 | while(1) |
| 743 | { |
| 744 | line = 0; |
| 745 | |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 746 | lcd_putsf(0, line++, "DCDC1: %02x", pcf50605_read(0x1b)); |
| 747 | lcd_putsf(0, line++, "DCDC2: %02x", pcf50605_read(0x1c)); |
| 748 | lcd_putsf(0, line++, "DCDC3: %02x", pcf50605_read(0x1d)); |
| 749 | lcd_putsf(0, line++, "DCDC4: %02x", pcf50605_read(0x1e)); |
| 750 | lcd_putsf(0, line++, "DCDEC1: %02x", pcf50605_read(0x1f)); |
| 751 | lcd_putsf(0, line++, "DCDEC2: %02x", pcf50605_read(0x20)); |
| 752 | lcd_putsf(0, line++, "DCUDC1: %02x", pcf50605_read(0x21)); |
| 753 | lcd_putsf(0, line++, "DCUDC2: %02x", pcf50605_read(0x22)); |
| 754 | lcd_putsf(0, line++, "IOREGC: %02x", pcf50605_read(0x23)); |
| 755 | lcd_putsf(0, line++, "D1REGC: %02x", pcf50605_read(0x24)); |
| 756 | lcd_putsf(0, line++, "D2REGC: %02x", pcf50605_read(0x25)); |
| 757 | lcd_putsf(0, line++, "D3REGC: %02x", pcf50605_read(0x26)); |
| 758 | lcd_putsf(0, line++, "LPREG1: %02x", pcf50605_read(0x27)); |
Michael Giacomelli | 054447f | 2008-02-10 05:39:20 +0000 | [diff] [blame] | 759 | lcd_update(); |
Rafaël Carré | 02c79d3 | 2012-01-04 06:21:16 +0000 | [diff] [blame] | 760 | if (action_userabort(HZ/10)) |
Michael Giacomelli | 054447f | 2008-02-10 05:39:20 +0000 | [diff] [blame] | 761 | { |
Jonathan Gordon | 8b9fdb5 | 2009-01-05 09:59:11 +0000 | [diff] [blame] | 762 | lcd_setfont(FONT_UI); |
Michael Giacomelli | 054447f | 2008-02-10 05:39:20 +0000 | [diff] [blame] | 763 | return false; |
| 764 | } |
| 765 | } |
| 766 | |
Jonathan Gordon | 8b9fdb5 | 2009-01-05 09:59:11 +0000 | [diff] [blame] | 767 | lcd_setfont(FONT_UI); |
Michael Giacomelli | 054447f | 2008-02-10 05:39:20 +0000 | [diff] [blame] | 768 | return false; |
| 769 | } |
| 770 | #endif |
| 771 | |
Linus Nielsen Feltzing | 213d34e | 2005-03-07 10:51:43 +0000 | [diff] [blame] | 772 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
Jens Arnold | 314f3b5 | 2006-12-12 22:22:21 +0000 | [diff] [blame] | 773 | static bool dbg_cpufreq(void) |
Linus Nielsen Feltzing | 213d34e | 2005-03-07 10:51:43 +0000 | [diff] [blame] | 774 | { |
Linus Nielsen Feltzing | 213d34e | 2005-03-07 10:51:43 +0000 | [diff] [blame] | 775 | int line; |
| 776 | int button; |
William Wilgus | 056d4b0 | 2017-11-14 05:17:02 +0100 | [diff] [blame] | 777 | int x = 0; |
| 778 | bool done = false; |
Linus Nielsen Feltzing | 213d34e | 2005-03-07 10:51:43 +0000 | [diff] [blame] | 779 | |
| 780 | #ifdef HAVE_LCD_BITMAP |
Linus Nielsen Feltzing | 57d8e8f | 2005-08-18 07:16:53 +0000 | [diff] [blame] | 781 | lcd_setfont(FONT_SYSFIXED); |
Linus Nielsen Feltzing | 213d34e | 2005-03-07 10:51:43 +0000 | [diff] [blame] | 782 | #endif |
| 783 | lcd_clear_display(); |
Linus Nielsen Feltzing | 213d34e | 2005-03-07 10:51:43 +0000 | [diff] [blame] | 784 | |
William Wilgus | 056d4b0 | 2017-11-14 05:17:02 +0100 | [diff] [blame] | 785 | while(!done) |
Linus Nielsen Feltzing | 213d34e | 2005-03-07 10:51:43 +0000 | [diff] [blame] | 786 | { |
| 787 | line = 0; |
Daniel Ankers | 0aec12f | 2006-08-21 17:35:35 +0000 | [diff] [blame] | 788 | |
William Wilgus | 056d4b0 | 2017-11-14 05:17:02 +0100 | [diff] [blame] | 789 | int temp = FREQ / 1000; |
| 790 | lcd_putsf(x, line++, "Frequency: %ld.%ld MHz", temp / 1000, temp % 1000); |
| 791 | lcd_putsf(x, line++, "boost_counter: %d", get_cpu_boost_counter()); |
Michael Giacomelli | 46c0c3a | 2008-02-10 05:56:35 +0000 | [diff] [blame] | 792 | |
Michael Sevakis | 783c775 | 2017-01-21 08:04:43 -0500 | [diff] [blame] | 793 | #ifdef HAVE_ADJUSTABLE_CPU_VOLTAGE |
| 794 | extern int get_cpu_voltage_setting(void); |
| 795 | temp = get_cpu_voltage_setting(); |
William Wilgus | 056d4b0 | 2017-11-14 05:17:02 +0100 | [diff] [blame] | 796 | lcd_putsf(x, line++, "CPU voltage: %d.%03dV", temp / 1000, temp % 1000); |
Michael Sevakis | 783c775 | 2017-01-21 08:04:43 -0500 | [diff] [blame] | 797 | #endif |
| 798 | |
Linus Nielsen Feltzing | 213d34e | 2005-03-07 10:51:43 +0000 | [diff] [blame] | 799 | lcd_update(); |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 800 | button = get_action(CONTEXT_STD,HZ/10); |
Linus Nielsen Feltzing | 213d34e | 2005-03-07 10:51:43 +0000 | [diff] [blame] | 801 | |
| 802 | switch(button) |
| 803 | { |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 804 | case ACTION_STD_PREV: |
Miika Pekkarinen | c5d57f0 | 2006-12-05 20:01:48 +0000 | [diff] [blame] | 805 | cpu_boost(true); |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 806 | break; |
Steve Bavin | d49c810 | 2006-10-05 10:07:03 +0000 | [diff] [blame] | 807 | |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 808 | case ACTION_STD_NEXT: |
Miika Pekkarinen | c5d57f0 | 2006-12-05 20:01:48 +0000 | [diff] [blame] | 809 | cpu_boost(false); |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 810 | break; |
William Wilgus | 056d4b0 | 2017-11-14 05:17:02 +0100 | [diff] [blame] | 811 | case ACTION_STD_MENU: |
| 812 | x--; |
| 813 | break; |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 814 | case ACTION_STD_OK: |
William Wilgus | 056d4b0 | 2017-11-14 05:17:02 +0100 | [diff] [blame] | 815 | x = 0; |
Steve Bavin | d49c810 | 2006-10-05 10:07:03 +0000 | [diff] [blame] | 816 | while (get_cpu_boost_counter() > 0) |
Miika Pekkarinen | c5d57f0 | 2006-12-05 20:01:48 +0000 | [diff] [blame] | 817 | cpu_boost(false); |
Steve Bavin | 3ad89d2 | 2006-11-01 11:12:21 +0000 | [diff] [blame] | 818 | set_cpu_frequency(CPUFREQ_DEFAULT); |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 819 | break; |
Thom Johansen | f6e8567 | 2006-03-17 02:02:13 +0000 | [diff] [blame] | 820 | |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 821 | case ACTION_STD_CANCEL: |
William Wilgus | 056d4b0 | 2017-11-14 05:17:02 +0100 | [diff] [blame] | 822 | done = true;; |
Linus Nielsen Feltzing | 213d34e | 2005-03-07 10:51:43 +0000 | [diff] [blame] | 823 | } |
William Wilgus | 056d4b0 | 2017-11-14 05:17:02 +0100 | [diff] [blame] | 824 | lcd_clear_display(); |
Linus Nielsen Feltzing | 213d34e | 2005-03-07 10:51:43 +0000 | [diff] [blame] | 825 | } |
Jonathan Gordon | 8b9fdb5 | 2009-01-05 09:59:11 +0000 | [diff] [blame] | 826 | lcd_setfont(FONT_UI); |
Linus Nielsen Feltzing | 213d34e | 2005-03-07 10:51:43 +0000 | [diff] [blame] | 827 | return false; |
| 828 | } |
Jens Arnold | 5fd58dc | 2005-10-10 19:43:07 +0000 | [diff] [blame] | 829 | #endif /* HAVE_ADJUSTABLE_CPU_FREQ */ |
Daniel Ankers | 0aec12f | 2006-08-21 17:35:35 +0000 | [diff] [blame] | 830 | |
Thomas Martitz | 35e8b14 | 2010-06-21 16:53:00 +0000 | [diff] [blame] | 831 | #if defined(HAVE_TSC2100) && (CONFIG_PLATFORM & PLATFORM_NATIVE) |
Jonathan Gordon | 13343c0 | 2007-11-02 06:17:53 +0000 | [diff] [blame] | 832 | #include "tsc2100.h" |
Nils Wallménius | c9d0961 | 2009-08-20 17:03:50 +0000 | [diff] [blame] | 833 | static const char* tsc2100_debug_getname(int selected_item, void * data, |
| 834 | char *buffer, size_t buffer_len) |
Jonathan Gordon | 13343c0 | 2007-11-02 06:17:53 +0000 | [diff] [blame] | 835 | { |
| 836 | int *page = (int*)data; |
| 837 | bool reserved = false; |
| 838 | switch (*page) |
| 839 | { |
| 840 | case 0: |
| 841 | if ((selected_item > 0x0a) || |
| 842 | (selected_item == 0x04) || |
| 843 | (selected_item == 0x08)) |
| 844 | reserved = true; |
| 845 | break; |
| 846 | case 1: |
| 847 | if ((selected_item > 0x05) || |
| 848 | (selected_item == 0x02)) |
| 849 | reserved = true; |
| 850 | break; |
| 851 | case 2: |
| 852 | if (selected_item > 0x1e) |
| 853 | reserved = true; |
| 854 | break; |
| 855 | } |
| 856 | if (reserved) |
Karl Kurbjun | 243aede | 2011-02-06 19:11:29 +0000 | [diff] [blame] | 857 | snprintf(buffer, buffer_len, "%02x: RSVD", selected_item); |
Jonathan Gordon | 13343c0 | 2007-11-02 06:17:53 +0000 | [diff] [blame] | 858 | else |
Karl Kurbjun | 243aede | 2011-02-06 19:11:29 +0000 | [diff] [blame] | 859 | snprintf(buffer, buffer_len, "%02x: %04x", selected_item, |
| 860 | tsc2100_readreg(*page, selected_item)&0xffff); |
Jonathan Gordon | 13343c0 | 2007-11-02 06:17:53 +0000 | [diff] [blame] | 861 | return buffer; |
| 862 | } |
| 863 | static int tsc2100debug_action_callback(int action, struct gui_synclist *lists) |
| 864 | { |
Jonathan Gordon | f5ec3e4 | 2007-12-17 02:37:21 +0000 | [diff] [blame] | 865 | int *page = (int*)lists->data; |
Jonathan Gordon | 13343c0 | 2007-11-02 06:17:53 +0000 | [diff] [blame] | 866 | if (action == ACTION_STD_OK) |
| 867 | { |
| 868 | *page = (*page+1)%3; |
Michael Giacomelli | 46c0c3a | 2008-02-10 05:56:35 +0000 | [diff] [blame] | 869 | snprintf(lists->title, 32, |
Jonathan Gordon | 13343c0 | 2007-11-02 06:17:53 +0000 | [diff] [blame] | 870 | "tsc2100 registers - Page %d", *page); |
| 871 | return ACTION_REDRAW; |
| 872 | } |
| 873 | return action; |
| 874 | } |
Bertrik Sikken | 37a384c | 2008-09-10 20:14:22 +0000 | [diff] [blame] | 875 | static bool tsc2100_debug(void) |
Jonathan Gordon | 13343c0 | 2007-11-02 06:17:53 +0000 | [diff] [blame] | 876 | { |
| 877 | int page = 0; |
| 878 | char title[32] = "tsc2100 registers - Page 0"; |
| 879 | struct simplelist_info info; |
| 880 | simplelist_info_init(&info, title, 32, &page); |
| 881 | info.timeout = HZ/100; |
| 882 | info.get_name = tsc2100_debug_getname; |
| 883 | info.action_callback= tsc2100debug_action_callback; |
| 884 | return simplelist_show_list(&info); |
| 885 | } |
| 886 | #endif |
Thomas Martitz | c1bd9b0 | 2012-01-03 23:44:38 +0000 | [diff] [blame] | 887 | #if (CONFIG_BATTERY_MEASURE != 0) && defined(HAVE_LCD_BITMAP) && !defined(SIMULATOR) |
Heikki Hannikainen | 6eb4254 | 2002-08-06 10:52:51 +0000 | [diff] [blame] | 888 | /* |
| 889 | * view_battery() shows a automatically scaled graph of the battery voltage |
| 890 | * over time. Usable for estimating battery life / charging rate. |
| 891 | * The power_history array is updated in power_thread of powermgmt.c. |
| 892 | */ |
| 893 | |
Jörg Hohensohn | 2584896 | 2005-03-03 07:25:43 +0000 | [diff] [blame] | 894 | #define BAT_LAST_VAL MIN(LCD_WIDTH, POWER_HISTORY_LEN) |
Thomas Martitz | c1bd9b0 | 2012-01-03 23:44:38 +0000 | [diff] [blame] | 895 | #define BAT_TSPACE 20 |
| 896 | #define BAT_YSPACE (LCD_HEIGHT - BAT_TSPACE) |
Heikki Hannikainen | 6eb4254 | 2002-08-06 10:52:51 +0000 | [diff] [blame] | 897 | |
Marcin Bukat | 47d7be5 | 2010-07-17 11:29:06 +0000 | [diff] [blame] | 898 | |
Jens Arnold | 314f3b5 | 2006-12-12 22:22:21 +0000 | [diff] [blame] | 899 | static bool view_battery(void) |
Heikki Hannikainen | 6eb4254 | 2002-08-06 10:52:51 +0000 | [diff] [blame] | 900 | { |
| 901 | int view = 0; |
Thomas Martitz | c1bd9b0 | 2012-01-03 23:44:38 +0000 | [diff] [blame] | 902 | int i, x, y, z, y1, y2, grid, graph; |
Jean-Philippe Bernardy | ed7c635 | 2005-02-08 15:12:25 +0000 | [diff] [blame] | 903 | unsigned short maxv, minv; |
Daniel Ankers | 0aec12f | 2006-08-21 17:35:35 +0000 | [diff] [blame] | 904 | |
Linus Nielsen Feltzing | f22eeee | 2005-08-14 08:43:05 +0000 | [diff] [blame] | 905 | lcd_setfont(FONT_SYSFIXED); |
Jens Arnold | 5fd58dc | 2005-10-10 19:43:07 +0000 | [diff] [blame] | 906 | |
Heikki Hannikainen | 6eb4254 | 2002-08-06 10:52:51 +0000 | [diff] [blame] | 907 | while(1) |
| 908 | { |
Jens Arnold | f9b90e9 | 2007-04-06 22:55:00 +0000 | [diff] [blame] | 909 | lcd_clear_display(); |
Heikki Hannikainen | 6eb4254 | 2002-08-06 10:52:51 +0000 | [diff] [blame] | 910 | switch (view) { |
Björn Stenberg | fe97b57 | 2002-08-10 08:57:47 +0000 | [diff] [blame] | 911 | case 0: /* voltage history graph */ |
| 912 | /* Find maximum and minimum voltage for scaling */ |
Jens Arnold | 1d1d9a8 | 2007-08-15 23:57:27 +0000 | [diff] [blame] | 913 | minv = power_history[0]; |
| 914 | maxv = minv + 1; |
| 915 | for (i = 1; i < BAT_LAST_VAL && power_history[i]; i++) { |
Björn Stenberg | fe97b57 | 2002-08-10 08:57:47 +0000 | [diff] [blame] | 916 | if (power_history[i] > maxv) |
| 917 | maxv = power_history[i]; |
Jens Arnold | 1d1d9a8 | 2007-08-15 23:57:27 +0000 | [diff] [blame] | 918 | if (power_history[i] < minv) |
Björn Stenberg | fe97b57 | 2002-08-10 08:57:47 +0000 | [diff] [blame] | 919 | minv = power_history[i]; |
Heikki Hannikainen | 6eb4254 | 2002-08-06 10:52:51 +0000 | [diff] [blame] | 920 | } |
Thomas Martitz | c1bd9b0 | 2012-01-03 23:44:38 +0000 | [diff] [blame] | 921 | /* print header */ |
| 922 | #if (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE) |
Mihail Zenkov | ce90c04 | 2016-03-30 12:50:40 +0000 | [diff] [blame] | 923 | /* adjust grid scale */ |
Marcin Bukat | 47d7be5 | 2010-07-17 11:29:06 +0000 | [diff] [blame] | 924 | if ((maxv - minv) > 50) |
| 925 | grid = 50; |
| 926 | else |
| 927 | grid = 5; |
Thomas Martitz | c1bd9b0 | 2012-01-03 23:44:38 +0000 | [diff] [blame] | 928 | |
Marcin Bukat | 47d7be5 | 2010-07-17 11:29:06 +0000 | [diff] [blame] | 929 | lcd_putsf(0, 0, "battery %d.%03dV", power_history[0] / 1000, |
Jens Arnold | 1d1d9a8 | 2007-08-15 23:57:27 +0000 | [diff] [blame] | 930 | power_history[0] % 1000); |
Marcin Bukat | 47d7be5 | 2010-07-17 11:29:06 +0000 | [diff] [blame] | 931 | lcd_putsf(0, 1, "%d.%03d-%d.%03dV (%2dmV)", |
| 932 | minv / 1000, minv % 1000, maxv / 1000, maxv % 1000, |
| 933 | grid); |
Thomas Martitz | c1bd9b0 | 2012-01-03 23:44:38 +0000 | [diff] [blame] | 934 | #elif (CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE) |
Mihail Zenkov | ce90c04 | 2016-03-30 12:50:40 +0000 | [diff] [blame] | 935 | /* adjust grid scale */ |
Thomas Martitz | c1bd9b0 | 2012-01-03 23:44:38 +0000 | [diff] [blame] | 936 | if ((maxv - minv) > 10) |
| 937 | grid = 10; |
| 938 | else |
| 939 | grid = 1; |
| 940 | lcd_putsf(0, 0, "battery %d%%", power_history[0]); |
| 941 | lcd_putsf(0, 1, "%d%%-%d%% (%d %%)", minv, maxv, grid); |
| 942 | #endif |
Mihail Zenkov | ce90c04 | 2016-03-30 12:50:40 +0000 | [diff] [blame] | 943 | |
Marcin Bukat | 47d7be5 | 2010-07-17 11:29:06 +0000 | [diff] [blame] | 944 | i = 1; |
| 945 | while ((y = (minv - (minv % grid)+i*grid)) < maxv) |
| 946 | { |
| 947 | graph = ((y-minv)*BAT_YSPACE)/(maxv-minv); |
| 948 | graph = LCD_HEIGHT-1 - graph; |
Mihail Zenkov | ce90c04 | 2016-03-30 12:50:40 +0000 | [diff] [blame] | 949 | |
| 950 | /* draw dotted horizontal grid line */ |
Marcin Bukat | 47d7be5 | 2010-07-17 11:29:06 +0000 | [diff] [blame] | 951 | for (x=0; x<LCD_WIDTH;x=x+2) |
| 952 | lcd_drawpixel(x,graph); |
Daniel Ankers | 0aec12f | 2006-08-21 17:35:35 +0000 | [diff] [blame] | 953 | |
Marcin Bukat | 47d7be5 | 2010-07-17 11:29:06 +0000 | [diff] [blame] | 954 | i++; |
Björn Stenberg | fe97b57 | 2002-08-10 08:57:47 +0000 | [diff] [blame] | 955 | } |
Mihail Zenkov | ce90c04 | 2016-03-30 12:50:40 +0000 | [diff] [blame] | 956 | |
Marcin Bukat | 47d7be5 | 2010-07-17 11:29:06 +0000 | [diff] [blame] | 957 | x = 0; |
| 958 | /* draw plot of power history |
| 959 | * skip empty entries |
| 960 | */ |
Mihail Zenkov | ce90c04 | 2016-03-30 12:50:40 +0000 | [diff] [blame] | 961 | for (i = BAT_LAST_VAL - 1; i > 0; i--) |
Marcin Bukat | 47d7be5 | 2010-07-17 11:29:06 +0000 | [diff] [blame] | 962 | { |
| 963 | if (power_history[i] && power_history[i-1]) |
| 964 | { |
Mihail Zenkov | ce90c04 | 2016-03-30 12:50:40 +0000 | [diff] [blame] | 965 | y1 = (power_history[i] - minv) * BAT_YSPACE / |
Marcin Bukat | 47d7be5 | 2010-07-17 11:29:06 +0000 | [diff] [blame] | 966 | (maxv - minv); |
Mihail Zenkov | ce90c04 | 2016-03-30 12:50:40 +0000 | [diff] [blame] | 967 | y1 = MIN(MAX(LCD_HEIGHT-1 - y1, BAT_TSPACE), |
Marcin Bukat | 47d7be5 | 2010-07-17 11:29:06 +0000 | [diff] [blame] | 968 | LCD_HEIGHT-1); |
| 969 | y2 = (power_history[i-1] - minv) * BAT_YSPACE / |
| 970 | (maxv - minv); |
Thomas Martitz | c1bd9b0 | 2012-01-03 23:44:38 +0000 | [diff] [blame] | 971 | y2 = MIN(MAX(LCD_HEIGHT-1 - y2, BAT_TSPACE), |
Marcin Bukat | 47d7be5 | 2010-07-17 11:29:06 +0000 | [diff] [blame] | 972 | LCD_HEIGHT-1); |
Björn Stenberg | fe97b57 | 2002-08-10 08:57:47 +0000 | [diff] [blame] | 973 | |
Marcin Bukat | 47d7be5 | 2010-07-17 11:29:06 +0000 | [diff] [blame] | 974 | lcd_set_drawmode(DRMODE_SOLID); |
| 975 | |
| 976 | /* make line thicker */ |
Mihail Zenkov | ce90c04 | 2016-03-30 12:50:40 +0000 | [diff] [blame] | 977 | lcd_drawline(((x*LCD_WIDTH)/(BAT_LAST_VAL)), |
| 978 | y1, |
| 979 | (((x+1)*LCD_WIDTH)/(BAT_LAST_VAL)), |
Marcin Bukat | 47d7be5 | 2010-07-17 11:29:06 +0000 | [diff] [blame] | 980 | y2); |
Mihail Zenkov | ce90c04 | 2016-03-30 12:50:40 +0000 | [diff] [blame] | 981 | lcd_drawline(((x*LCD_WIDTH)/(BAT_LAST_VAL))+1, |
| 982 | y1+1, |
| 983 | (((x+1)*LCD_WIDTH)/(BAT_LAST_VAL))+1, |
Marcin Bukat | 47d7be5 | 2010-07-17 11:29:06 +0000 | [diff] [blame] | 984 | y2+1); |
| 985 | x++; |
| 986 | } |
| 987 | } |
Björn Stenberg | fe97b57 | 2002-08-10 08:57:47 +0000 | [diff] [blame] | 988 | break; |
Daniel Ankers | 0aec12f | 2006-08-21 17:35:35 +0000 | [diff] [blame] | 989 | |
Björn Stenberg | fe97b57 | 2002-08-10 08:57:47 +0000 | [diff] [blame] | 990 | case 1: /* status: */ |
Marcin Bukat | dd8e8a7 | 2010-05-19 13:24:18 +0000 | [diff] [blame] | 991 | #if CONFIG_CHARGING >= CHARGING_MONITOR |
| 992 | lcd_putsf(0, 0, "Pwr status: %s", |
| 993 | charging_state() ? "charging" : "discharging"); |
Mihail Zenkov | ce90c04 | 2016-03-30 12:50:40 +0000 | [diff] [blame] | 994 | #else |
Thomas Martitz | c1bd9b0 | 2012-01-03 23:44:38 +0000 | [diff] [blame] | 995 | lcd_puts(0, 0, "Power status: unknown"); |
Marcin Bukat | dd8e8a7 | 2010-05-19 13:24:18 +0000 | [diff] [blame] | 996 | #endif |
Thomas Martitz | c1bd9b0 | 2012-01-03 23:44:38 +0000 | [diff] [blame] | 997 | battery_read_info(&y, &z); |
| 998 | if (y > 0) |
| 999 | lcd_putsf(0, 1, "Battery: %d.%03d V (%d %%)", y / 1000, y % 1000, z); |
| 1000 | else if (z > 0) |
| 1001 | lcd_putsf(0, 1, "Battery: %d %%", z); |
Jens Arnold | 303b4ab | 2004-12-01 00:33:18 +0000 | [diff] [blame] | 1002 | #ifdef ADC_EXT_POWER |
Jens Arnold | 1d1d9a8 | 2007-08-15 23:57:27 +0000 | [diff] [blame] | 1003 | y = (adc_read(ADC_EXT_POWER) * EXT_SCALE_FACTOR) / 1000; |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 1004 | lcd_putsf(0, 2, "External: %d.%03d V", y / 1000, y % 1000); |
Jens Arnold | 303b4ab | 2004-12-01 00:33:18 +0000 | [diff] [blame] | 1005 | #endif |
Jonathan Gordon | 9a6f419 | 2007-02-18 05:32:06 +0000 | [diff] [blame] | 1006 | #if CONFIG_CHARGING |
Michael Sevakis | 3157e13 | 2008-12-24 16:58:41 +0000 | [diff] [blame] | 1007 | #if defined ARCHOS_RECORDER |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 1008 | lcd_putsf(0, 3, "Chgr: %s %s", |
Michiel Van Der Kolk | 9d2531a | 2005-03-28 00:47:09 +0000 | [diff] [blame] | 1009 | charger_inserted() ? "present" : "absent", |
Michael Sevakis | 3157e13 | 2008-12-24 16:58:41 +0000 | [diff] [blame] | 1010 | charger_enabled() ? "on" : "off"); |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 1011 | lcd_putsf(0, 5, "short delta: %d", short_delta); |
| 1012 | lcd_putsf(0, 6, "long delta: %d", long_delta); |
Björn Stenberg | fe97b57 | 2002-08-10 08:57:47 +0000 | [diff] [blame] | 1013 | lcd_puts(0, 7, power_message); |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 1014 | lcd_putsf(0, 8, "USB Inserted: %s", |
Steve Bavin | 338d94f | 2007-02-01 10:47:22 +0000 | [diff] [blame] | 1015 | usb_inserted() ? "yes" : "no"); |
Michael Sevakis | 3157e13 | 2008-12-24 16:58:41 +0000 | [diff] [blame] | 1016 | #elif defined IPOD_NANO || defined IPOD_VIDEO |
Brandon Low | d00d588 | 2006-03-18 09:13:55 +0000 | [diff] [blame] | 1017 | int usb_pwr = (GPIOL_INPUT_VAL & 0x10)?true:false; |
| 1018 | int ext_pwr = (GPIOL_INPUT_VAL & 0x08)?false:true; |
| 1019 | int dock = (GPIOA_INPUT_VAL & 0x10)?true:false; |
| 1020 | int charging = (GPIOB_INPUT_VAL & 0x01)?false:true; |
| 1021 | int headphone= (GPIOA_INPUT_VAL & 0x80)?true:false; |
| 1022 | |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 1023 | lcd_putsf(0, 3, "USB pwr: %s", |
Nils Wallménius | a971334 | 2009-10-17 13:00:58 +0000 | [diff] [blame] | 1024 | usb_pwr ? "present" : "absent"); |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 1025 | lcd_putsf(0, 4, "EXT pwr: %s", |
Nils Wallménius | a971334 | 2009-10-17 13:00:58 +0000 | [diff] [blame] | 1026 | ext_pwr ? "present" : "absent"); |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 1027 | lcd_putsf(0, 5, "Battery: %s", |
Michael Sevakis | 1d4a9c6 | 2006-10-27 05:31:28 +0000 | [diff] [blame] | 1028 | charging ? "charging" : (usb_pwr||ext_pwr) ? "charged" : "discharging"); |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 1029 | lcd_putsf(0, 6, "Dock mode: %s", |
Brandon Low | d00d588 | 2006-03-18 09:13:55 +0000 | [diff] [blame] | 1030 | dock ? "enabled" : "disabled"); |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 1031 | lcd_putsf(0, 7, "Headphone: %s", |
Brandon Low | d00d588 | 2006-03-18 09:13:55 +0000 | [diff] [blame] | 1032 | headphone ? "connected" : "disconnected"); |
Torne Wuff | 2d0af6f | 2009-11-03 20:35:04 +0000 | [diff] [blame] | 1033 | #ifdef IPOD_VIDEO |
Frank Gevaerts | a1cf4ce | 2010-08-31 19:06:04 +0000 | [diff] [blame] | 1034 | if(probed_ramsize == 64) |
| 1035 | x = (adc_read(ADC_4066_ISTAT) * 2400) / (1024 * 2); |
| 1036 | else |
Bertrik Sikken | 0157c62 | 2011-07-24 17:32:50 +0000 | [diff] [blame] | 1037 | #endif |
Frank Gevaerts | a1cf4ce | 2010-08-31 19:06:04 +0000 | [diff] [blame] | 1038 | x = (adc_read(ADC_4066_ISTAT) * 2400) / (1024 * 3); |
Torne Wuff | 2d0af6f | 2009-11-03 20:35:04 +0000 | [diff] [blame] | 1039 | lcd_putsf(0, 8, "Ibat: %d mA", x); |
| 1040 | lcd_putsf(0, 9, "Vbat * Ibat: %d mW", x * y / 1000); |
Michael Sevakis | 3157e13 | 2008-12-24 16:58:41 +0000 | [diff] [blame] | 1041 | #elif defined TOSHIBA_GIGABEAT_S |
| 1042 | int line = 3; |
Michael Sevakis | 5667682 | 2008-12-21 18:10:36 +0000 | [diff] [blame] | 1043 | unsigned int st; |
| 1044 | |
| 1045 | static const unsigned char * const chrgstate_strings[] = |
| 1046 | { |
| 1047 | "Disabled", |
| 1048 | "Error", |
| 1049 | "Discharging", |
| 1050 | "Precharge", |
| 1051 | "Constant Voltage", |
| 1052 | "Constant Current", |
| 1053 | "<unknown>", |
| 1054 | }; |
| 1055 | |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 1056 | lcd_putsf(0, line++, "Charger: %s", |
Michael Sevakis | 3157e13 | 2008-12-24 16:58:41 +0000 | [diff] [blame] | 1057 | charger_inserted() ? "present" : "absent"); |
Michael Sevakis | 3157e13 | 2008-12-24 16:58:41 +0000 | [diff] [blame] | 1058 | |
Michael Sevakis | 5667682 | 2008-12-21 18:10:36 +0000 | [diff] [blame] | 1059 | st = power_input_status() & |
| 1060 | (POWER_INPUT_CHARGER | POWER_INPUT_BATTERY); |
Michael Sevakis | aced667 | 2017-09-18 06:00:05 -0400 | [diff] [blame] | 1061 | |
| 1062 | lcd_putsf(0, line++, "%.*s%.*s", |
| 1063 | !!(st & POWER_INPUT_MAIN_CHARGER)*5, " Main", |
| 1064 | !!(st & POWER_INPUT_USB_CHARGER)*4, " USB"); |
Michael Sevakis | 5667682 | 2008-12-21 18:10:36 +0000 | [diff] [blame] | 1065 | |
Michael Sevakis | 5667682 | 2008-12-21 18:10:36 +0000 | [diff] [blame] | 1066 | y = ARRAYLEN(chrgstate_strings) - 1; |
| 1067 | |
| 1068 | switch (charge_state) |
| 1069 | { |
| 1070 | case CHARGE_STATE_DISABLED: y--; |
| 1071 | case CHARGE_STATE_ERROR: y--; |
| 1072 | case DISCHARGING: y--; |
| 1073 | case TRICKLE: y--; |
| 1074 | case TOPOFF: y--; |
| 1075 | case CHARGING: y--; |
| 1076 | default:; |
| 1077 | } |
| 1078 | |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 1079 | lcd_putsf(0, line++, "State: %s", chrgstate_strings[y]); |
Michael Sevakis | 5667682 | 2008-12-21 18:10:36 +0000 | [diff] [blame] | 1080 | |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 1081 | lcd_putsf(0, line++, "Battery Switch: %s", |
Michael Sevakis | 5667682 | 2008-12-21 18:10:36 +0000 | [diff] [blame] | 1082 | (st & POWER_INPUT_BATTERY) ? "On" : "Off"); |
Michael Sevakis | 5667682 | 2008-12-21 18:10:36 +0000 | [diff] [blame] | 1083 | |
| 1084 | y = chrgraw_adc_voltage(); |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 1085 | lcd_putsf(0, line++, "CHRGRAW: %d.%03d V", |
Michael Sevakis | 5667682 | 2008-12-21 18:10:36 +0000 | [diff] [blame] | 1086 | y / 1000, y % 1000); |
Michael Sevakis | 5667682 | 2008-12-21 18:10:36 +0000 | [diff] [blame] | 1087 | |
| 1088 | y = application_supply_adc_voltage(); |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 1089 | lcd_putsf(0, line++, "BP : %d.%03d V", |
Michael Sevakis | 5667682 | 2008-12-21 18:10:36 +0000 | [diff] [blame] | 1090 | y / 1000, y % 1000); |
Michael Sevakis | 5667682 | 2008-12-21 18:10:36 +0000 | [diff] [blame] | 1091 | |
Michael Sevakis | d892214 | 2008-05-25 01:38:08 +0000 | [diff] [blame] | 1092 | y = battery_adc_charge_current(); |
Michael Sevakis | aced667 | 2017-09-18 06:00:05 -0400 | [diff] [blame] | 1093 | lcd_putsf(0, line++, "CHRGISN:% d mA", y); |
Michael Sevakis | 5667682 | 2008-12-21 18:10:36 +0000 | [diff] [blame] | 1094 | |
| 1095 | y = cccv_regulator_dissipation(); |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 1096 | lcd_putsf(0, line++, "P CCCV : %d mW", y); |
Michael Sevakis | 5667682 | 2008-12-21 18:10:36 +0000 | [diff] [blame] | 1097 | |
| 1098 | y = battery_charge_current(); |
Michael Sevakis | aced667 | 2017-09-18 06:00:05 -0400 | [diff] [blame] | 1099 | lcd_putsf(0, line++, "I Charge:% d mA", y); |
Michael Sevakis | d892214 | 2008-05-25 01:38:08 +0000 | [diff] [blame] | 1100 | |
| 1101 | y = battery_adc_temp(); |
Michael Sevakis | 5667682 | 2008-12-21 18:10:36 +0000 | [diff] [blame] | 1102 | |
| 1103 | if (y != INT_MIN) { |
Michael Sevakis | aced667 | 2017-09-18 06:00:05 -0400 | [diff] [blame] | 1104 | lcd_putsf(0, line++, "T Battery: %d\u00b0C (%d\u00b0F)", y, |
Nils Wallménius | a971334 | 2009-10-17 13:00:58 +0000 | [diff] [blame] | 1105 | (9*y + 160) / 5); |
Michael Sevakis | 5667682 | 2008-12-21 18:10:36 +0000 | [diff] [blame] | 1106 | } else { |
| 1107 | /* Conversion disabled */ |
Nils Wallménius | a971334 | 2009-10-17 13:00:58 +0000 | [diff] [blame] | 1108 | lcd_puts(0, line++, "T Battery: ?"); |
Michael Sevakis | 5667682 | 2008-12-21 18:10:36 +0000 | [diff] [blame] | 1109 | } |
Mihail Zenkov | ce90c04 | 2016-03-30 12:50:40 +0000 | [diff] [blame] | 1110 | #elif defined(HAVE_AS3514) && CONFIG_CHARGING |
Michael Sevakis | 7d79691 | 2009-01-11 10:07:22 +0000 | [diff] [blame] | 1111 | static const char * const chrgstate_strings[] = |
| 1112 | { |
Rafaël Carré | a2ab719 | 2010-06-21 00:03:15 +0000 | [diff] [blame] | 1113 | [CHARGE_STATE_DISABLED - CHARGE_STATE_DISABLED]= "Disabled", |
| 1114 | [CHARGE_STATE_ERROR - CHARGE_STATE_DISABLED] = "Error", |
| 1115 | [DISCHARGING - CHARGE_STATE_DISABLED] = "Discharging", |
| 1116 | [CHARGING - CHARGE_STATE_DISABLED] = "Charging", |
Michael Sevakis | 7d79691 | 2009-01-11 10:07:22 +0000 | [diff] [blame] | 1117 | }; |
| 1118 | const char *str = NULL; |
| 1119 | |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 1120 | lcd_putsf(0, 3, "Charger: %s", |
Michael Sevakis | 7d79691 | 2009-01-11 10:07:22 +0000 | [diff] [blame] | 1121 | charger_inserted() ? "present" : "absent"); |
Michael Sevakis | 7d79691 | 2009-01-11 10:07:22 +0000 | [diff] [blame] | 1122 | |
Rafaël Carré | a2ab719 | 2010-06-21 00:03:15 +0000 | [diff] [blame] | 1123 | y = charge_state - CHARGE_STATE_DISABLED; |
Michael Sevakis | 7d79691 | 2009-01-11 10:07:22 +0000 | [diff] [blame] | 1124 | if ((unsigned)y < ARRAYLEN(chrgstate_strings)) |
| 1125 | str = chrgstate_strings[y]; |
| 1126 | |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 1127 | lcd_putsf(0, 4, "State: %s", |
Michael Sevakis | 7d79691 | 2009-01-11 10:07:22 +0000 | [diff] [blame] | 1128 | str ? str : "<unknown>"); |
Michael Sevakis | 7d79691 | 2009-01-11 10:07:22 +0000 | [diff] [blame] | 1129 | |
Rafaël Carré | 88c55d7 | 2010-05-17 20:53:25 +0000 | [diff] [blame] | 1130 | lcd_putsf(0, 5, "CHARGER: %02X", ascodec_read_charger()); |
Michael Sparmann | 30d664b | 2009-10-10 22:02:23 +0000 | [diff] [blame] | 1131 | #elif defined(IPOD_NANO2G) |
Michael Sparmann | f61fb37 | 2010-03-10 03:18:58 +0000 | [diff] [blame] | 1132 | y = pmu_read_battery_voltage(); |
| 1133 | lcd_putsf(17, 1, "RAW: %d.%03d V", y / 1000, y % 1000); |
Michael Sparmann | 30d664b | 2009-10-10 22:02:23 +0000 | [diff] [blame] | 1134 | y = pmu_read_battery_current(); |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 1135 | lcd_putsf(0, 2, "Battery current: %d mA", y); |
Michael Sparmann | 59d9361 | 2010-11-14 15:08:38 +0000 | [diff] [blame] | 1136 | lcd_putsf(0, 3, "PWRCON: %08x %08x", PWRCON, PWRCONEXT); |
| 1137 | lcd_putsf(0, 4, "CLKCON: %08x %03x %03x", CLKCON, CLKCON2, CLKCON3); |
| 1138 | lcd_putsf(0, 5, "PLL: %06x %06x %06x", PLL0PMS, PLL1PMS, PLL2PMS); |
Michael Sparmann | e5c8152 | 2010-02-17 15:57:53 +0000 | [diff] [blame] | 1139 | x = pmu_read(0x1b) & 0xf; |
| 1140 | y = pmu_read(0x1a) * 25 + 625; |
Michael Sparmann | 59d9361 | 2010-11-14 15:08:38 +0000 | [diff] [blame] | 1141 | lcd_putsf(0, 6, "AUTO: %x / %d mV", x, y); |
Michael Sparmann | e5c8152 | 2010-02-17 15:57:53 +0000 | [diff] [blame] | 1142 | x = pmu_read(0x1f) & 0xf; |
| 1143 | y = pmu_read(0x1e) * 25 + 625; |
Michael Sparmann | 59d9361 | 2010-11-14 15:08:38 +0000 | [diff] [blame] | 1144 | lcd_putsf(0, 7, "DOWN1: %x / %d mV", x, y); |
Michael Sparmann | e5c8152 | 2010-02-17 15:57:53 +0000 | [diff] [blame] | 1145 | x = pmu_read(0x23) & 0xf; |
| 1146 | y = pmu_read(0x22) * 25 + 625; |
Michael Sparmann | 59d9361 | 2010-11-14 15:08:38 +0000 | [diff] [blame] | 1147 | lcd_putsf(0, 8, "DOWN2: %x / %d mV", x, y); |
Michael Sparmann | e5c8152 | 2010-02-17 15:57:53 +0000 | [diff] [blame] | 1148 | x = pmu_read(0x27) & 0xf; |
| 1149 | y = pmu_read(0x26) * 100 + 900; |
Michael Sparmann | 59d9361 | 2010-11-14 15:08:38 +0000 | [diff] [blame] | 1150 | lcd_putsf(0, 9, "MEMLDO: %x / %d mV", x, y); |
Michael Sparmann | e5c8152 | 2010-02-17 15:57:53 +0000 | [diff] [blame] | 1151 | for (i = 0; i < 6; i++) |
| 1152 | { |
| 1153 | x = pmu_read(0x2e + (i << 1)) & 0xf; |
| 1154 | y = pmu_read(0x2d + (i << 1)) * 100 + 900; |
Michael Sparmann | 59d9361 | 2010-11-14 15:08:38 +0000 | [diff] [blame] | 1155 | lcd_putsf(0, 10 + i, "LDO%d: %x / %d mV", i + 1, x, y); |
Michael Sparmann | e5c8152 | 2010-02-17 15:57:53 +0000 | [diff] [blame] | 1156 | } |
Michael Sevakis | 3157e13 | 2008-12-24 16:58:41 +0000 | [diff] [blame] | 1157 | #else |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 1158 | lcd_putsf(0, 3, "Charger: %s", |
Michael Sevakis | 3157e13 | 2008-12-24 16:58:41 +0000 | [diff] [blame] | 1159 | charger_inserted() ? "present" : "absent"); |
Michael Sevakis | 3157e13 | 2008-12-24 16:58:41 +0000 | [diff] [blame] | 1160 | #endif /* target type */ |
Jens Arnold | 0dd1f8e | 2006-06-06 22:23:52 +0000 | [diff] [blame] | 1161 | #endif /* CONFIG_CHARGING */ |
Björn Stenberg | fe97b57 | 2002-08-10 08:57:47 +0000 | [diff] [blame] | 1162 | break; |
Björn Stenberg | fe97b57 | 2002-08-10 08:57:47 +0000 | [diff] [blame] | 1163 | case 2: /* voltage deltas: */ |
Thomas Martitz | c1bd9b0 | 2012-01-03 23:44:38 +0000 | [diff] [blame] | 1164 | #if (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE) |
Björn Stenberg | fe97b57 | 2002-08-10 08:57:47 +0000 | [diff] [blame] | 1165 | lcd_puts(0, 0, "Voltage deltas:"); |
Thomas Martitz | c1bd9b0 | 2012-01-03 23:44:38 +0000 | [diff] [blame] | 1166 | for (i = 0; i < POWER_HISTORY_LEN-1; i++) { |
Jens Arnold | 1d1d9a8 | 2007-08-15 23:57:27 +0000 | [diff] [blame] | 1167 | y = power_history[i] - power_history[i+1]; |
Thomas Martitz | c1bd9b0 | 2012-01-03 23:44:38 +0000 | [diff] [blame] | 1168 | lcd_putsf(0, i+1, "-%d min: %c%d.%03d V", i, |
| 1169 | (y < 0) ? '-' : ' ', ((y < 0) ? y * -1 : y) / 1000, |
Jens Arnold | 1d1d9a8 | 2007-08-15 23:57:27 +0000 | [diff] [blame] | 1170 | ((y < 0) ? y * -1 : y ) % 1000); |
Björn Stenberg | fe97b57 | 2002-08-10 08:57:47 +0000 | [diff] [blame] | 1171 | } |
Thomas Martitz | c1bd9b0 | 2012-01-03 23:44:38 +0000 | [diff] [blame] | 1172 | #elif (CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE) |
| 1173 | lcd_puts(0, 0, "Percentage deltas:"); |
| 1174 | for (i = 0; i < POWER_HISTORY_LEN-1; i++) { |
| 1175 | y = power_history[i] - power_history[i+1]; |
| 1176 | lcd_putsf(0, i+1, "-%d min: %c%d%%", i, |
| 1177 | (y < 0) ? '-' : ' ', ((y < 0) ? y * -1 : y)); |
| 1178 | } |
| 1179 | #endif |
Björn Stenberg | fe97b57 | 2002-08-10 08:57:47 +0000 | [diff] [blame] | 1180 | break; |
Björn Stenberg | f09c5f4 | 2002-12-03 14:18:51 +0000 | [diff] [blame] | 1181 | |
Michiel Van Der Kolk | 9d2531a | 2005-03-28 00:47:09 +0000 | [diff] [blame] | 1182 | case 3: /* remaining time estimation: */ |
Uwe Freese | c83374b | 2002-12-15 18:10:19 +0000 | [diff] [blame] | 1183 | |
Michael Sevakis | 3157e13 | 2008-12-24 16:58:41 +0000 | [diff] [blame] | 1184 | #ifdef ARCHOS_RECORDER |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 1185 | lcd_putsf(0, 0, "charge_state: %d", charge_state); |
Uwe Freese | c83374b | 2002-12-15 18:10:19 +0000 | [diff] [blame] | 1186 | |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 1187 | lcd_putsf(0, 1, "Cycle time: %d m", powermgmt_last_cycle_startstop_min); |
Björn Stenberg | f09c5f4 | 2002-12-03 14:18:51 +0000 | [diff] [blame] | 1188 | |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 1189 | lcd_putsf(0, 2, "Lvl@cyc st: %d%%", powermgmt_last_cycle_level); |
Michiel Van Der Kolk | 9d2531a | 2005-03-28 00:47:09 +0000 | [diff] [blame] | 1190 | |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 1191 | lcd_putsf(0, 3, "P=%2d I=%2d", pid_p, pid_i); |
Michiel Van Der Kolk | 9d2531a | 2005-03-28 00:47:09 +0000 | [diff] [blame] | 1192 | |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 1193 | lcd_putsf(0, 4, "Trickle sec: %d/60", trickle_sec); |
Michael Sevakis | 3157e13 | 2008-12-24 16:58:41 +0000 | [diff] [blame] | 1194 | #endif /* ARCHOS_RECORDER */ |
Björn Stenberg | f09c5f4 | 2002-12-03 14:18:51 +0000 | [diff] [blame] | 1195 | |
Thomas Martitz | c1bd9b0 | 2012-01-03 23:44:38 +0000 | [diff] [blame] | 1196 | #if (CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE) |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 1197 | lcd_putsf(0, 5, "Last PwrHist: %d.%03dV", |
Jens Arnold | 1d1d9a8 | 2007-08-15 23:57:27 +0000 | [diff] [blame] | 1198 | power_history[0] / 1000, |
| 1199 | power_history[0] % 1000); |
Thomas Martitz | c1bd9b0 | 2012-01-03 23:44:38 +0000 | [diff] [blame] | 1200 | #endif |
Björn Stenberg | f09c5f4 | 2002-12-03 14:18:51 +0000 | [diff] [blame] | 1201 | |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 1202 | lcd_putsf(0, 6, "battery level: %d%%", battery_level()); |
Michiel Van Der Kolk | 451dd48 | 2005-03-28 00:00:24 +0000 | [diff] [blame] | 1203 | |
Thomas Martitz | c1bd9b0 | 2012-01-03 23:44:38 +0000 | [diff] [blame] | 1204 | int time_left = battery_time(); |
| 1205 | if (time_left >= 0) |
| 1206 | lcd_putsf(0, 7, "Est. remain: %d m", time_left); |
| 1207 | else |
| 1208 | lcd_puts(0, 7, "Estimation n/a"); |
Björn Stenberg | f09c5f4 | 2002-12-03 14:18:51 +0000 | [diff] [blame] | 1209 | break; |
Heikki Hannikainen | 6eb4254 | 2002-08-06 10:52:51 +0000 | [diff] [blame] | 1210 | } |
Daniel Ankers | 0aec12f | 2006-08-21 17:35:35 +0000 | [diff] [blame] | 1211 | |
Heikki Hannikainen | 6eb4254 | 2002-08-06 10:52:51 +0000 | [diff] [blame] | 1212 | lcd_update(); |
Daniel Ankers | 0aec12f | 2006-08-21 17:35:35 +0000 | [diff] [blame] | 1213 | |
Bertrik Sikken | 5381647 | 2008-04-19 17:54:12 +0000 | [diff] [blame] | 1214 | switch(get_action(CONTEXT_STD,HZ/2)) |
Heikki Hannikainen | 6eb4254 | 2002-08-06 10:52:51 +0000 | [diff] [blame] | 1215 | { |
Bertrik Sikken | 5381647 | 2008-04-19 17:54:12 +0000 | [diff] [blame] | 1216 | case ACTION_STD_PREV: |
Björn Stenberg | fe97b57 | 2002-08-10 08:57:47 +0000 | [diff] [blame] | 1217 | if (view) |
| 1218 | view--; |
| 1219 | break; |
Daniel Ankers | 0aec12f | 2006-08-21 17:35:35 +0000 | [diff] [blame] | 1220 | |
Bertrik Sikken | 5381647 | 2008-04-19 17:54:12 +0000 | [diff] [blame] | 1221 | case ACTION_STD_NEXT: |
Björn Stenberg | f09c5f4 | 2002-12-03 14:18:51 +0000 | [diff] [blame] | 1222 | if (view < 3) |
Björn Stenberg | fe97b57 | 2002-08-10 08:57:47 +0000 | [diff] [blame] | 1223 | view++; |
| 1224 | break; |
Daniel Ankers | 0aec12f | 2006-08-21 17:35:35 +0000 | [diff] [blame] | 1225 | |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 1226 | case ACTION_STD_CANCEL: |
Jonathan Gordon | 8b9fdb5 | 2009-01-05 09:59:11 +0000 | [diff] [blame] | 1227 | lcd_setfont(FONT_UI); |
Björn Stenberg | b1b8bd4 | 2002-09-24 17:22:12 +0000 | [diff] [blame] | 1228 | return false; |
Heikki Hannikainen | 6eb4254 | 2002-08-06 10:52:51 +0000 | [diff] [blame] | 1229 | } |
| 1230 | } |
Jonathan Gordon | 8b9fdb5 | 2009-01-05 09:59:11 +0000 | [diff] [blame] | 1231 | lcd_setfont(FONT_UI); |
Björn Stenberg | b1b8bd4 | 2002-09-24 17:22:12 +0000 | [diff] [blame] | 1232 | return false; |
Heikki Hannikainen | 6eb4254 | 2002-08-06 10:52:51 +0000 | [diff] [blame] | 1233 | } |
| 1234 | |
Thomas Martitz | c1bd9b0 | 2012-01-03 23:44:38 +0000 | [diff] [blame] | 1235 | #endif /* (CONFIG_BATTERY_MEASURE != 0) && HAVE_LCD_BITMAP */ |
Daniel Ankers | 0aec12f | 2006-08-21 17:35:35 +0000 | [diff] [blame] | 1236 | |
Thomas Martitz | 35e8b14 | 2010-06-21 16:53:00 +0000 | [diff] [blame] | 1237 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) |
Frank Gevaerts | 19d1cac | 2008-10-31 21:25:04 +0000 | [diff] [blame] | 1238 | #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD) |
Frank Gevaerts | 2f8a008 | 2008-11-01 16:14:28 +0000 | [diff] [blame] | 1239 | |
Frank Gevaerts | 19d1cac | 2008-10-31 21:25:04 +0000 | [diff] [blame] | 1240 | #if (CONFIG_STORAGE & STORAGE_MMC) |
Jonathan Gordon | 5890f60 | 2007-07-14 08:55:47 +0000 | [diff] [blame] | 1241 | #define CARDTYPE "MMC" |
Frank Gevaerts | 2f8a008 | 2008-11-01 16:14:28 +0000 | [diff] [blame] | 1242 | #elif (CONFIG_STORAGE & STORAGE_SD) |
Jonathan Gordon | 5890f60 | 2007-07-14 08:55:47 +0000 | [diff] [blame] | 1243 | #define CARDTYPE "microSD" |
| 1244 | #endif |
Frank Gevaerts | 2f8a008 | 2008-11-01 16:14:28 +0000 | [diff] [blame] | 1245 | |
Jonathan Gordon | 5f893be | 2007-10-20 12:32:55 +0000 | [diff] [blame] | 1246 | static int disk_callback(int btn, struct gui_synclist *lists) |
Jens Arnold | 6f9a7eb | 2004-10-06 20:43:12 +0000 | [diff] [blame] | 1247 | { |
Jens Arnold | 6f9a7eb | 2004-10-06 20:43:12 +0000 | [diff] [blame] | 1248 | tCardInfo *card; |
Jonathan Gordon | f5ec3e4 | 2007-12-17 02:37:21 +0000 | [diff] [blame] | 1249 | int *cardnum = (int*)lists->data; |
Michael Chicoine | 887d818 | 2009-12-09 15:32:22 +0000 | [diff] [blame] | 1250 | unsigned char card_name[6]; |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1251 | unsigned char pbuf[32]; |
Jonathan Gordon | f5ec3e4 | 2007-12-17 02:37:21 +0000 | [diff] [blame] | 1252 | char *title = lists->title; |
Jens Arnold | 6f9a7eb | 2004-10-06 20:43:12 +0000 | [diff] [blame] | 1253 | static const unsigned char i_vmin[] = { 0, 1, 5, 10, 25, 35, 60, 100 }; |
| 1254 | static const unsigned char i_vmax[] = { 1, 5, 10, 25, 35, 45, 80, 200 }; |
Nils Wallménius | 79f19b9 | 2009-10-17 13:40:42 +0000 | [diff] [blame] | 1255 | static const unsigned char * const kbit_units[] = { "kBit/s", "MBit/s", "GBit/s" }; |
| 1256 | static const unsigned char * const nsec_units[] = { "ns", "µs", "ms" }; |
Rafaël Carré | c0eb9ae | 2009-07-01 21:49:13 +0000 | [diff] [blame] | 1257 | #if (CONFIG_STORAGE & STORAGE_MMC) |
Nils Wallménius | a971334 | 2009-10-17 13:00:58 +0000 | [diff] [blame] | 1258 | static const char * const mmc_spec_vers[] = { "1.0-1.2", "1.4", "2.0-2.2", |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1259 | "3.1-3.31", "4.0" }; |
Rafaël Carré | c0eb9ae | 2009-07-01 21:49:13 +0000 | [diff] [blame] | 1260 | #endif |
| 1261 | |
Michael Sevakis | a16035d | 2007-07-15 18:25:39 +0000 | [diff] [blame] | 1262 | if ((btn == ACTION_STD_OK) || (btn == SYS_FS_CHANGED) || (btn == ACTION_REDRAW)) |
Jens Arnold | 6f9a7eb | 2004-10-06 20:43:12 +0000 | [diff] [blame] | 1263 | { |
Mark Arigo | 3e743ec | 2008-05-13 02:50:31 +0000 | [diff] [blame] | 1264 | #ifdef HAVE_HOTSWAP |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1265 | if (btn == ACTION_STD_OK) |
Jonathan Gordon | 5f893be | 2007-10-20 12:32:55 +0000 | [diff] [blame] | 1266 | { |
| 1267 | *cardnum ^= 0x1; /* change cards */ |
| 1268 | } |
Mark Arigo | 3e743ec | 2008-05-13 02:50:31 +0000 | [diff] [blame] | 1269 | #endif |
Michael Sevakis | a16035d | 2007-07-15 18:25:39 +0000 | [diff] [blame] | 1270 | |
Jonathan Gordon | 5f893be | 2007-10-20 12:32:55 +0000 | [diff] [blame] | 1271 | simplelist_set_line_count(0); |
Michael Sevakis | a16035d | 2007-07-15 18:25:39 +0000 | [diff] [blame] | 1272 | |
Jonathan Gordon | 5f893be | 2007-10-20 12:32:55 +0000 | [diff] [blame] | 1273 | card = card_get_info(*cardnum); |
Michael Sevakis | a16035d | 2007-07-15 18:25:39 +0000 | [diff] [blame] | 1274 | |
Michael Sevakis | ea0d2cf | 2007-07-25 06:15:07 +0000 | [diff] [blame] | 1275 | if (card->initialized > 0) |
Jens Arnold | 6f9a7eb | 2004-10-06 20:43:12 +0000 | [diff] [blame] | 1276 | { |
Michael Chicoine | 887d818 | 2009-12-09 15:32:22 +0000 | [diff] [blame] | 1277 | unsigned i; |
| 1278 | for (i=0; i<sizeof(card_name); i++) |
| 1279 | { |
Michael Chicoine | a47601a | 2009-12-09 17:10:48 +0000 | [diff] [blame] | 1280 | card_name[i] = card_extract_bits(card->cid, (103-8*i), 8); |
Michael Chicoine | 887d818 | 2009-12-09 15:32:22 +0000 | [diff] [blame] | 1281 | } |
Michael Chicoine | a47601a | 2009-12-09 17:10:48 +0000 | [diff] [blame] | 1282 | strlcpy(card_name, card_name, sizeof(card_name)); |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1283 | simplelist_addline( |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1284 | "%s Rev %d.%d", card_name, |
Michael Chicoine | 887d818 | 2009-12-09 15:32:22 +0000 | [diff] [blame] | 1285 | (int) card_extract_bits(card->cid, 63, 4), |
| 1286 | (int) card_extract_bits(card->cid, 59, 4)); |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1287 | simplelist_addline( |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1288 | "Prod: %d/%d", |
Rafaël Carré | c0eb9ae | 2009-07-01 21:49:13 +0000 | [diff] [blame] | 1289 | #if (CONFIG_STORAGE & STORAGE_SD) |
Michael Chicoine | 887d818 | 2009-12-09 15:32:22 +0000 | [diff] [blame] | 1290 | (int) card_extract_bits(card->cid, 11, 4), |
Rafaël Carré | c0eb9ae | 2009-07-01 21:49:13 +0000 | [diff] [blame] | 1291 | (int) card_extract_bits(card->cid, 19, 8) + 2000 |
| 1292 | #elif (CONFIG_STORAGE & STORAGE_MMC) |
Rafaël Carré | 93f6e3d | 2009-07-01 19:13:01 +0000 | [diff] [blame] | 1293 | (int) card_extract_bits(card->cid, 15, 4), |
Rafaël Carré | c0eb9ae | 2009-07-01 21:49:13 +0000 | [diff] [blame] | 1294 | (int) card_extract_bits(card->cid, 11, 4) + 1997 |
| 1295 | #endif |
| 1296 | ); |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1297 | simplelist_addline( |
Rafaël Carré | c0eb9ae | 2009-07-01 21:49:13 +0000 | [diff] [blame] | 1298 | #if (CONFIG_STORAGE & STORAGE_SD) |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1299 | "Ser#: 0x%08lx", |
Rafaël Carré | c0eb9ae | 2009-07-01 21:49:13 +0000 | [diff] [blame] | 1300 | card_extract_bits(card->cid, 55, 32) |
| 1301 | #elif (CONFIG_STORAGE & STORAGE_MMC) |
| 1302 | "Ser#: 0x%04lx", |
| 1303 | card_extract_bits(card->cid, 47, 16) |
| 1304 | #endif |
| 1305 | ); |
| 1306 | |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1307 | simplelist_addline("M=%02x, " |
Rafaël Carré | c0eb9ae | 2009-07-01 21:49:13 +0000 | [diff] [blame] | 1308 | #if (CONFIG_STORAGE & STORAGE_SD) |
| 1309 | "O=%c%c", |
Rafaël Carré | 93f6e3d | 2009-07-01 19:13:01 +0000 | [diff] [blame] | 1310 | (int) card_extract_bits(card->cid, 127, 8), |
Rafaël Carré | c0eb9ae | 2009-07-01 21:49:13 +0000 | [diff] [blame] | 1311 | card_extract_bits(card->cid, 119, 8), |
| 1312 | card_extract_bits(card->cid, 111, 8) |
| 1313 | #elif (CONFIG_STORAGE & STORAGE_MMC) |
| 1314 | "O=%04x", |
| 1315 | (int) card_extract_bits(card->cid, 127, 8), |
| 1316 | (int) card_extract_bits(card->cid, 119, 16) |
| 1317 | #endif |
| 1318 | ); |
| 1319 | |
| 1320 | #if (CONFIG_STORAGE & STORAGE_MMC) |
Rafaël Carré | 93f6e3d | 2009-07-01 19:13:01 +0000 | [diff] [blame] | 1321 | int temp = card_extract_bits(card->csd, 125, 4); |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1322 | simplelist_addline( |
Rafaël Carré | c0eb9ae | 2009-07-01 21:49:13 +0000 | [diff] [blame] | 1323 | "MMC v%s", temp < 5 ? |
| 1324 | mmc_spec_vers[temp] : "?.?"); |
| 1325 | #endif |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1326 | simplelist_addline( |
Jens Arnold | b1a584a | 2008-09-14 20:33:24 +0000 | [diff] [blame] | 1327 | "Blocks: 0x%08lx", card->numblocks); |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1328 | output_dyn_value(pbuf, sizeof pbuf, card->speed / 1000, |
William Wilgus | 62a5ed4 | 2018-12-09 12:09:40 -0600 | [diff] [blame] | 1329 | kbit_units, 3, false); |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1330 | simplelist_addline( |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1331 | "Speed: %s", pbuf); |
Rafaël Carré | e0e24cb | 2009-07-01 10:07:22 +0000 | [diff] [blame] | 1332 | output_dyn_value(pbuf, sizeof pbuf, card->taac, |
William Wilgus | 62a5ed4 | 2018-12-09 12:09:40 -0600 | [diff] [blame] | 1333 | nsec_units, 3, false); |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1334 | simplelist_addline( |
Rafaël Carré | e0e24cb | 2009-07-01 10:07:22 +0000 | [diff] [blame] | 1335 | "Taac: %s", pbuf); |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1336 | simplelist_addline( |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1337 | "Nsac: %d clk", card->nsac); |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1338 | simplelist_addline( |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1339 | "R2W: *%d", card->r2w_factor); |
Bertrik Sikken | fa068bb | 2011-04-11 19:11:39 +0000 | [diff] [blame] | 1340 | #if (CONFIG_STORAGE & STORAGE_SD) |
| 1341 | int csd_structure = card_extract_bits(card->csd, 127, 2); |
| 1342 | if (csd_structure == 0) /* CSD version 1.0 */ |
| 1343 | #endif |
| 1344 | { |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1345 | simplelist_addline( |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1346 | "IRmax: %d..%d mA", |
Rafaël Carré | 93f6e3d | 2009-07-01 19:13:01 +0000 | [diff] [blame] | 1347 | i_vmin[card_extract_bits(card->csd, 61, 3)], |
| 1348 | i_vmax[card_extract_bits(card->csd, 58, 3)]); |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1349 | simplelist_addline( |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1350 | "IWmax: %d..%d mA", |
Rafaël Carré | 93f6e3d | 2009-07-01 19:13:01 +0000 | [diff] [blame] | 1351 | i_vmin[card_extract_bits(card->csd, 55, 3)], |
| 1352 | i_vmax[card_extract_bits(card->csd, 52, 3)]); |
Bertrik Sikken | fa068bb | 2011-04-11 19:11:39 +0000 | [diff] [blame] | 1353 | } |
Jens Arnold | 6f9a7eb | 2004-10-06 20:43:12 +0000 | [diff] [blame] | 1354 | } |
Michael Sevakis | ea0d2cf | 2007-07-25 06:15:07 +0000 | [diff] [blame] | 1355 | else if (card->initialized == 0) |
Jens Arnold | 6f9a7eb | 2004-10-06 20:43:12 +0000 | [diff] [blame] | 1356 | { |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1357 | simplelist_addline("Not Found!"); |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1358 | } |
Frank Gevaerts | 19d1cac | 2008-10-31 21:25:04 +0000 | [diff] [blame] | 1359 | #if (CONFIG_STORAGE & STORAGE_SD) |
Michael Sevakis | ea0d2cf | 2007-07-25 06:15:07 +0000 | [diff] [blame] | 1360 | else /* card->initialized < 0 */ |
| 1361 | { |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1362 | simplelist_addline("Init Error! (%d)", card->initialized); |
Michael Sevakis | ea0d2cf | 2007-07-25 06:15:07 +0000 | [diff] [blame] | 1363 | } |
| 1364 | #endif |
Jonathan Gordon | 5f893be | 2007-10-20 12:32:55 +0000 | [diff] [blame] | 1365 | snprintf(title, 16, "[" CARDTYPE " %d]", *cardnum); |
| 1366 | gui_synclist_set_title(lists, title, Icon_NOICON); |
| 1367 | gui_synclist_set_nb_items(lists, simplelist_get_line_count()); |
| 1368 | gui_synclist_select_item(lists, 0); |
Jonathan Gordon | 7d04c81 | 2007-07-14 15:08:46 +0000 | [diff] [blame] | 1369 | btn = ACTION_REDRAW; |
Jens Arnold | 6f9a7eb | 2004-10-06 20:43:12 +0000 | [diff] [blame] | 1370 | } |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1371 | return btn; |
| 1372 | } |
Mihail Zenkov | ce90c04 | 2016-03-30 12:50:40 +0000 | [diff] [blame] | 1373 | #elif (CONFIG_STORAGE & STORAGE_ATA) |
Jonathan Gordon | 5f893be | 2007-10-20 12:32:55 +0000 | [diff] [blame] | 1374 | static int disk_callback(int btn, struct gui_synclist *lists) |
Björn Stenberg | 45d32ce | 2002-12-03 13:12:55 +0000 | [diff] [blame] | 1375 | { |
Michael Sevakis | aced667 | 2017-09-18 06:00:05 -0400 | [diff] [blame] | 1376 | static const char atanums[] = { " 0 1 2 3 4 5 6" }; |
| 1377 | |
Jonathan Gordon | 5f893be | 2007-10-20 12:32:55 +0000 | [diff] [blame] | 1378 | (void)lists; |
Björn Stenberg | 45d32ce | 2002-12-03 13:12:55 +0000 | [diff] [blame] | 1379 | int i; |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1380 | char buf[128]; |
Björn Stenberg | 45d32ce | 2002-12-03 13:12:55 +0000 | [diff] [blame] | 1381 | unsigned short* identify_info = ata_get_identify(); |
Linus Nielsen Feltzing | f3ad619 | 2004-02-16 12:04:55 +0000 | [diff] [blame] | 1382 | bool timing_info_present = false; |
Michael Sevakis | a16035d | 2007-07-15 18:25:39 +0000 | [diff] [blame] | 1383 | (void)btn; |
| 1384 | |
Jonathan Gordon | 5f893be | 2007-10-20 12:32:55 +0000 | [diff] [blame] | 1385 | simplelist_set_line_count(0); |
Michael Sevakis | a16035d | 2007-07-15 18:25:39 +0000 | [diff] [blame] | 1386 | |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1387 | for (i=0; i < 20; i++) |
| 1388 | ((unsigned short*)buf)[i]=htobe16(identify_info[i+27]); |
| 1389 | buf[40]=0; |
| 1390 | /* kill trailing space */ |
| 1391 | for (i=39; i && buf[i]==' '; i--) |
| 1392 | buf[i] = 0; |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1393 | simplelist_addline("Model: %s", buf); |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1394 | for (i=0; i < 4; i++) |
| 1395 | ((unsigned short*)buf)[i]=htobe16(identify_info[i+23]); |
| 1396 | buf[8]=0; |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1397 | simplelist_addline( |
Robert Keevil | 227a733 | 2007-07-14 12:32:37 +0000 | [diff] [blame] | 1398 | "Firmware: %s", buf); |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1399 | snprintf(buf, sizeof buf, "%ld MB", |
| 1400 | ((unsigned long)identify_info[61] << 16 | |
| 1401 | (unsigned long)identify_info[60]) / 2048 ); |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1402 | simplelist_addline( |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1403 | "Size: %s", buf); |
| 1404 | unsigned long free; |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 1405 | volume_size( IF_MV(0,) NULL, &free ); |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1406 | simplelist_addline( |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1407 | "Free: %ld MB", free / 1024); |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1408 | simplelist_addline( |
Frank Gevaerts | 2f8a008 | 2008-11-01 16:14:28 +0000 | [diff] [blame] | 1409 | "Spinup time: %d ms", storage_spinup_time() * (1000/HZ)); |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1410 | i = identify_info[83] & (1<<3); |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1411 | simplelist_addline( |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1412 | "Power mgmt: %s", i ? "enabled" : "unsupported"); |
| 1413 | i = identify_info[83] & (1<<9); |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1414 | simplelist_addline( |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1415 | "Noise mgmt: %s", i ? "enabled" : "unsupported"); |
| 1416 | i = identify_info[82] & (1<<6); |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1417 | simplelist_addline( |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1418 | "Read-ahead: %s", i ? "enabled" : "unsupported"); |
| 1419 | timing_info_present = identify_info[53] & (1<<1); |
| 1420 | if(timing_info_present) { |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1421 | simplelist_addline( |
Michael Sevakis | aced667 | 2017-09-18 06:00:05 -0400 | [diff] [blame] | 1422 | "PIO modes: 0 1 2%.*s%.*s", |
| 1423 | (identify_info[64] & (1<<0)) << 1, &atanums[3*2], |
| 1424 | (identify_info[64] & (1<<1)) , &atanums[4*2]); |
Björn Stenberg | 45d32ce | 2002-12-03 13:12:55 +0000 | [diff] [blame] | 1425 | } |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1426 | else { |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1427 | simplelist_addline( |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1428 | "No PIO mode info"); |
| 1429 | } |
| 1430 | timing_info_present = identify_info[53] & (1<<1); |
| 1431 | if(timing_info_present) { |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1432 | simplelist_addline( |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1433 | "Cycle times %dns/%dns", |
| 1434 | identify_info[67], |
| 1435 | identify_info[68] ); |
| 1436 | } else { |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1437 | simplelist_addline( |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1438 | "No timing info"); |
| 1439 | } |
Torne Wuff | 4290051 | 2010-04-09 11:55:57 +0000 | [diff] [blame] | 1440 | int sector_size = 512; |
| 1441 | if((identify_info[106] & 0xe000) == 0x6000) |
| 1442 | sector_size *= BIT_N(identify_info[106] & 0x000f); |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1443 | simplelist_addline( |
Torne Wuff | 4290051 | 2010-04-09 11:55:57 +0000 | [diff] [blame] | 1444 | "Physical sector size: %d", sector_size); |
Michael Sevakis | bc8cab4 | 2009-03-12 02:01:25 +0000 | [diff] [blame] | 1445 | #ifdef HAVE_ATA_DMA |
Michael Sevakis | 6dd14d4 | 2008-05-04 15:27:10 +0000 | [diff] [blame] | 1446 | if (identify_info[63] & (1<<0)) { |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1447 | simplelist_addline( |
Michael Sevakis | aced667 | 2017-09-18 06:00:05 -0400 | [diff] [blame] | 1448 | "MDMA modes:%.*s%.*s%.*s", |
| 1449 | (identify_info[63] & (1<<0)) << 1, &atanums[0*2], |
| 1450 | (identify_info[63] & (1<<1)) , &atanums[1*2], |
| 1451 | (identify_info[63] & (1<<2)) >> 1, &atanums[2*2]); |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1452 | simplelist_addline( |
Michael Sevakis | 6dd14d4 | 2008-05-04 15:27:10 +0000 | [diff] [blame] | 1453 | "MDMA Cycle times %dns/%dns", |
| 1454 | identify_info[65], |
| 1455 | identify_info[66] ); |
| 1456 | } |
| 1457 | else { |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1458 | simplelist_addline( |
Michael Sevakis | 6dd14d4 | 2008-05-04 15:27:10 +0000 | [diff] [blame] | 1459 | "No MDMA mode info"); |
| 1460 | } |
Michael Sevakis | bc8cab4 | 2009-03-12 02:01:25 +0000 | [diff] [blame] | 1461 | if (identify_info[53] & (1<<2)) { |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1462 | simplelist_addline( |
Michael Sevakis | aced667 | 2017-09-18 06:00:05 -0400 | [diff] [blame] | 1463 | "UDMA modes:%.*s%.*s%.*s%.*s%.*s%.*s%.*s", |
| 1464 | (identify_info[88] & (1<<0)) << 1, &atanums[0*2], |
| 1465 | (identify_info[88] & (1<<1)) , &atanums[1*2], |
| 1466 | (identify_info[88] & (1<<2)) >> 1, &atanums[2*2], |
| 1467 | (identify_info[88] & (1<<3)) >> 2, &atanums[3*2], |
| 1468 | (identify_info[88] & (1<<4)) >> 3, &atanums[4*2], |
| 1469 | (identify_info[88] & (1<<5)) >> 4, &atanums[5*2], |
| 1470 | (identify_info[88] & (1<<6)) >> 5, &atanums[6*2]); |
Michael Sevakis | 6dd14d4 | 2008-05-04 15:27:10 +0000 | [diff] [blame] | 1471 | } |
| 1472 | else { |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1473 | simplelist_addline( |
Michael Sevakis | 6dd14d4 | 2008-05-04 15:27:10 +0000 | [diff] [blame] | 1474 | "No UDMA mode info"); |
| 1475 | } |
Michael Sevakis | bc8cab4 | 2009-03-12 02:01:25 +0000 | [diff] [blame] | 1476 | #endif /* HAVE_ATA_DMA */ |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1477 | timing_info_present = identify_info[53] & (1<<1); |
| 1478 | if(timing_info_present) { |
| 1479 | i = identify_info[49] & (1<<11); |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1480 | simplelist_addline( |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1481 | "IORDY support: %s", i ? "yes" : "no"); |
| 1482 | i = identify_info[49] & (1<<10); |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1483 | simplelist_addline( |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1484 | "IORDY disable: %s", i ? "yes" : "no"); |
| 1485 | } else { |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1486 | simplelist_addline( |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1487 | "No timing info"); |
| 1488 | } |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1489 | simplelist_addline( |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 1490 | "Cluster size: %d bytes", volume_get_cluster_size(IF_MV(0))); |
Michael Sevakis | bc8cab4 | 2009-03-12 02:01:25 +0000 | [diff] [blame] | 1491 | #ifdef HAVE_ATA_DMA |
| 1492 | i = ata_get_dma_mode(); |
| 1493 | if (i == 0) { |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1494 | simplelist_addline( |
Michael Sevakis | bc8cab4 | 2009-03-12 02:01:25 +0000 | [diff] [blame] | 1495 | "DMA not enabled"); |
| 1496 | } else { |
Jonathan Gordon | 69228f9 | 2013-02-12 20:35:11 +1100 | [diff] [blame] | 1497 | simplelist_addline( |
Michael Sevakis | bc8cab4 | 2009-03-12 02:01:25 +0000 | [diff] [blame] | 1498 | "DMA mode: %s %c", |
| 1499 | (i & 0x40) ? "UDMA" : "MDMA", |
| 1500 | '0' + (i & 7)); |
| 1501 | } |
| 1502 | #endif /* HAVE_ATA_DMA */ |
Jonathan Gordon | d7dd239 | 2007-07-12 09:58:54 +0000 | [diff] [blame] | 1503 | return btn; |
| 1504 | } |
Cástor Muñoz | d20185a | 2014-12-09 19:38:47 +0100 | [diff] [blame] | 1505 | |
| 1506 | #ifdef HAVE_ATA_SMART |
Cástor Muñoz | e9497db | 2016-02-13 18:28:46 +0100 | [diff] [blame] | 1507 | static struct ata_smart_values smart_data STORAGE_ALIGN_ATTR; |
Cástor Muñoz | d20185a | 2014-12-09 19:38:47 +0100 | [diff] [blame] | 1508 | |
| 1509 | static const char * ata_smart_get_attr_name(unsigned char id) |
| 1510 | { |
Cástor Muñoz | ff637c7 | 2016-02-16 20:42:42 +0100 | [diff] [blame] | 1511 | if (id == 1) return "Raw Read Error Rate"; |
| 1512 | if (id == 2) return "Throughput Performance"; |
| 1513 | if (id == 3) return "Spin-Up Time"; |
| 1514 | if (id == 4) return "Start/Stop Count"; |
| 1515 | if (id == 5) return "Reallocated Sector Count"; |
| 1516 | if (id == 7) return "Seek Error Rate"; |
| 1517 | if (id == 8) return "Seek Time Performance"; |
| 1518 | if (id == 9) return "Power-On Hours Count"; |
| 1519 | if (id == 10) return "Spin-Up Retry Count"; |
| 1520 | if (id == 12) return "Power Cycle Count"; |
| 1521 | if (id == 191) return "G-Sense Error Rate"; |
| 1522 | if (id == 192) return "Power-Off Retract Count"; |
| 1523 | if (id == 193) return "Load/Unload Cycle Count"; |
| 1524 | if (id == 194) return "HDA Temperature"; |
| 1525 | if (id == 195) return "Hardware ECC Recovered"; |
| 1526 | if (id == 196) return "Reallocated Event Count"; |
| 1527 | if (id == 197) return "Current Pending Sector Count"; |
| 1528 | if (id == 198) return "Uncorrectable Sector Count"; |
| 1529 | if (id == 199) return "UDMA CRC Error Count"; |
| 1530 | if (id == 200) return "Write Error Rate"; |
| 1531 | if (id == 201) return "TA Counter Detected"; |
| 1532 | if (id == 220) return "Disk Shift"; |
| 1533 | if (id == 222) return "Loaded Hours"; |
| 1534 | if (id == 223) return "Load/Unload Retry Count"; |
| 1535 | if (id == 224) return "Load Friction"; |
| 1536 | if (id == 225) return "Load Cycle Count"; |
| 1537 | if (id == 226) return "Load-In Time"; |
| 1538 | if (id == 240) return "Transfer Error Rate"; /* Fujitsu */ |
| 1539 | return "Unknown Attribute"; |
Cástor Muñoz | d20185a | 2014-12-09 19:38:47 +0100 | [diff] [blame] | 1540 | }; |
| 1541 | |
| 1542 | static int ata_smart_get_attr_rawfmt(unsigned char id) |
| 1543 | { |
Cástor Muñoz | ff637c7 | 2016-02-16 20:42:42 +0100 | [diff] [blame] | 1544 | if (id == 3) /* Spin-up time */ |
| 1545 | return RAWFMT_RAW16_OPT_AVG16; |
Cástor Muñoz | d20185a | 2014-12-09 19:38:47 +0100 | [diff] [blame] | 1546 | |
Cástor Muñoz | ff637c7 | 2016-02-16 20:42:42 +0100 | [diff] [blame] | 1547 | if (id == 5 || /* Reallocated sector count */ |
| 1548 | id == 196) /* Reallocated event count */ |
| 1549 | return RAWFMT_RAW16_OPT_RAW16; |
Cástor Muñoz | d20185a | 2014-12-09 19:38:47 +0100 | [diff] [blame] | 1550 | |
Cástor Muñoz | ff637c7 | 2016-02-16 20:42:42 +0100 | [diff] [blame] | 1551 | if (id == 190 || /* Airflow Temperature */ |
| 1552 | id == 194) /* HDA Temperature */ |
| 1553 | return RAWFMT_TEMPMINMAX; |
Cástor Muñoz | d20185a | 2014-12-09 19:38:47 +0100 | [diff] [blame] | 1554 | |
Cástor Muñoz | ff637c7 | 2016-02-16 20:42:42 +0100 | [diff] [blame] | 1555 | return RAWFMT_RAW48; |
Cástor Muñoz | d20185a | 2014-12-09 19:38:47 +0100 | [diff] [blame] | 1556 | }; |
| 1557 | |
| 1558 | static int ata_smart_attr_to_string( |
| 1559 | struct ata_smart_attribute *attr, char *str, int size) |
| 1560 | { |
| 1561 | uint16_t w[3]; /* 3 words to store 6 bytes of raw data */ |
| 1562 | char buf[size]; /* temp string to store attribute data */ |
| 1563 | int len, slen; |
| 1564 | int id = attr->id; |
| 1565 | |
| 1566 | if (id == 0) |
| 1567 | return 0; /* null attribute */ |
| 1568 | |
| 1569 | /* align and convert raw data */ |
| 1570 | memcpy(w, attr->raw, 6); |
| 1571 | w[0] = letoh16(w[0]); |
| 1572 | w[1] = letoh16(w[1]); |
| 1573 | w[2] = letoh16(w[2]); |
| 1574 | |
| 1575 | len = snprintf(buf, size, ": %u,%u ", attr->current, attr->worst); |
| 1576 | |
| 1577 | switch (ata_smart_get_attr_rawfmt(id)) |
| 1578 | { |
| 1579 | case RAWFMT_RAW16_OPT_RAW16: |
| 1580 | len += snprintf(buf+len, size-len, "%u", w[0]); |
| 1581 | if ((w[1] || w[2]) && (len < size)) |
| 1582 | len += snprintf(buf+len, size-len, " %u %u", w[1],w[2]); |
| 1583 | break; |
| 1584 | |
| 1585 | case RAWFMT_RAW16_OPT_AVG16: |
| 1586 | len += snprintf(buf+len, size-len, "%u", w[0]); |
| 1587 | if (w[1] && (len < size)) |
| 1588 | len += snprintf(buf+len, size-len, " Avg: %u", w[1]); |
| 1589 | break; |
| 1590 | |
|