Björn Stenberg | 8218285 | 2002-05-16 12:53:40 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
Nicolas Pennequin | 357ffb3 | 2008-05-05 10:32:46 +0000 | [diff] [blame] | 10 | * Copyright (C) 2002 Björn Stenberg |
Björn Stenberg | 8218285 | 2002-05-16 12:53:40 +0000 | [diff] [blame] | 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 | 8218285 | 2002-05-16 12:53:40 +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 | ****************************************************************************/ |
Linus Nielsen Feltzing | 688b4dd | 2004-10-15 02:16:31 +0000 | [diff] [blame] | 21 | #include "config.h" |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 22 | #include "system.h" |
Linus Nielsen Feltzing | 688b4dd | 2004-10-15 02:16:31 +0000 | [diff] [blame] | 23 | |
Thomas Martitz | 0e2286f | 2010-08-12 13:38:25 +0000 | [diff] [blame] | 24 | #include "gcc_extensions.h" |
Frank Gevaerts | 2f8a008 | 2008-11-01 16:14:28 +0000 | [diff] [blame] | 25 | #include "storage.h" |
Björn Stenberg | e324db6 | 2002-05-17 19:50:37 +0000 | [diff] [blame] | 26 | #include "disk.h" |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 27 | #include "file_internal.h" |
Björn Stenberg | e324db6 | 2002-05-17 19:50:37 +0000 | [diff] [blame] | 28 | #include "lcd.h" |
Linus Nielsen Feltzing | 9b3a3be | 2002-06-24 13:51:40 +0000 | [diff] [blame] | 29 | #include "rtc.h" |
Björn Stenberg | e324db6 | 2002-05-17 19:50:37 +0000 | [diff] [blame] | 30 | #include "debug.h" |
| 31 | #include "led.h" |
Michael Sevakis | 981d028 | 2014-08-08 01:39:29 -0400 | [diff] [blame] | 32 | #include "../kernel-internal.h" |
Björn Stenberg | e324db6 | 2002-05-17 19:50:37 +0000 | [diff] [blame] | 33 | #include "button.h" |
Björn Stenberg | 8218285 | 2002-05-16 12:53:40 +0000 | [diff] [blame] | 34 | #include "tree.h" |
Jonathan Gordon | 21165a3 | 2007-03-29 06:16:00 +0000 | [diff] [blame] | 35 | #include "filetypes.h" |
Björn Stenberg | 55c7da2 | 2002-05-21 14:28:10 +0000 | [diff] [blame] | 36 | #include "panic.h" |
| 37 | #include "menu.h" |
Linus Nielsen Feltzing | 6c77cc3 | 2002-06-30 13:24:29 +0000 | [diff] [blame] | 38 | #include "usb.h" |
Heikki Hannikainen | 6eb4254 | 2002-08-06 10:52:51 +0000 | [diff] [blame] | 39 | #include "powermgmt.h" |
Udo Schläpfer | dbabd0d | 2015-02-02 21:44:29 +0100 | [diff] [blame] | 40 | #if !defined(DX50) && !defined(DX90) |
Linus Nielsen Feltzing | 7d3c31b | 2002-06-30 20:25:37 +0000 | [diff] [blame] | 41 | #include "adc.h" |
Udo Schläpfer | dbabd0d | 2015-02-02 21:44:29 +0100 | [diff] [blame] | 42 | #endif |
Linus Nielsen Feltzing | 6d2e492 | 2002-07-02 21:40:12 +0000 | [diff] [blame] | 43 | #include "i2c.h" |
Björn Stenberg | 18239b8 | 2002-08-12 12:44:18 +0000 | [diff] [blame] | 44 | #ifndef DEBUG |
| 45 | #include "serial.h" |
| 46 | #endif |
Linus Nielsen Feltzing | 8a237a8 | 2005-04-04 12:06:29 +0000 | [diff] [blame] | 47 | #include "audio.h" |
Jörg Hohensohn | f993365 | 2004-01-05 20:42:51 +0000 | [diff] [blame] | 48 | #include "mp3_playback.h" |
Linus Nielsen Feltzing | 31e2097 | 2002-06-20 08:59:54 +0000 | [diff] [blame] | 49 | #include "settings.h" |
Linus Nielsen Feltzing | 9b3a3be | 2002-06-24 13:51:40 +0000 | [diff] [blame] | 50 | #include "backlight.h" |
Linus Nielsen Feltzing | 97f94b4 | 2002-07-22 22:44:03 +0000 | [diff] [blame] | 51 | #include "status.h" |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 52 | #include "debug_menu.h" |
Daniel Stenberg | 93b231c | 2002-09-12 13:33:59 +0000 | [diff] [blame] | 53 | #include "font.h" |
Daniel Stenberg | 5b662ff | 2002-09-25 11:42:10 +0000 | [diff] [blame] | 54 | #include "language.h" |
Jonathan Gordon | 3e7444f | 2009-08-03 04:43:34 +0000 | [diff] [blame] | 55 | #include "wps.h" |
Björn Stenberg | 7bb746b | 2003-04-24 17:31:36 +0000 | [diff] [blame] | 56 | #include "playlist.h" |
Thomas Martitz | d0b72e2 | 2011-08-30 14:01:33 +0000 | [diff] [blame] | 57 | #include "core_alloc.h" |
Jörg Hohensohn | c47f8c0 | 2003-07-03 22:13:39 +0000 | [diff] [blame] | 58 | #include "rolo.h" |
Tomer Shalev | 09de597 | 2009-10-19 21:34:27 +0000 | [diff] [blame] | 59 | #include "screens.h" |
Tomer Shalev | 5d585f4 | 2009-10-19 21:19:30 +0000 | [diff] [blame] | 60 | #include "usb_screen.h" |
Jörg Hohensohn | 5dd17b1 | 2003-07-17 20:29:51 +0000 | [diff] [blame] | 61 | #include "power.h" |
Jörg Hohensohn | 4f36ea8 | 2004-03-14 21:33:53 +0000 | [diff] [blame] | 62 | #include "talk.h" |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 63 | #include "plugin.h" |
Linus Nielsen Feltzing | 3d21781 | 2005-04-06 11:12:22 +0000 | [diff] [blame] | 64 | #include "misc.h" |
Miika Pekkarinen | ab78b04 | 2005-10-07 17:38:05 +0000 | [diff] [blame] | 65 | #include "dircache.h" |
Jonathan Gordon | 710ccb7 | 2006-10-25 10:17:57 +0000 | [diff] [blame] | 66 | #ifdef HAVE_TAGCACHE |
Miika Pekkarinen | 7c4e0c8 | 2006-03-26 11:33:42 +0000 | [diff] [blame] | 67 | #include "tagcache.h" |
Miika Pekkarinen | 4a63c09 | 2006-04-04 19:28:13 +0000 | [diff] [blame] | 68 | #include "tagtree.h" |
Jonathan Gordon | 710ccb7 | 2006-10-25 10:17:57 +0000 | [diff] [blame] | 69 | #endif |
Miika Pekkarinen | ab78b04 | 2005-10-07 17:38:05 +0000 | [diff] [blame] | 70 | #include "lang.h" |
| 71 | #include "string.h" |
Miika Pekkarinen | a697717 | 2005-12-07 11:20:56 +0000 | [diff] [blame] | 72 | #include "splash.h" |
Miika Pekkarinen | 954b732 | 2006-08-05 20:19:10 +0000 | [diff] [blame] | 73 | #include "eeprom_settings.h" |
Linus Nielsen Feltzing | da153da | 2006-10-19 09:42:58 +0000 | [diff] [blame] | 74 | #include "scrobbler.h" |
Jonathan Gordon | 6a5cc0b | 2007-04-16 09:14:36 +0000 | [diff] [blame] | 75 | #include "icon.h" |
Thomas Martitz | 4c48b59 | 2009-08-16 22:20:11 +0000 | [diff] [blame] | 76 | #include "viewport.h" |
Jonathan Gordon | 71379ca | 2010-09-14 12:21:56 +0000 | [diff] [blame] | 77 | #include "skin_engine/skin_engine.h" |
Thomas Martitz | 1016ee4 | 2009-10-19 15:28:15 +0000 | [diff] [blame] | 78 | #include "statusbar-skinned.h" |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 79 | #include "bootchart.h" |
Michael Giacomelli | d46b090 | 2012-07-03 21:45:29 -0400 | [diff] [blame] | 80 | #include "logdiskf.h" |
Dave Chapman | 793eab1 | 2011-02-28 12:05:22 +0000 | [diff] [blame] | 81 | #if (CONFIG_PLATFORM & PLATFORM_ANDROID) |
Thomas Martitz | f5a461d | 2010-12-10 18:41:09 +0000 | [diff] [blame] | 82 | #include "notification.h" |
| 83 | #endif |
Jonathan Gordon | 101693f | 2011-11-15 13:22:02 +0000 | [diff] [blame] | 84 | #include "shortcuts.h" |
Michiel Van Der Kolk | 451dd48 | 2005-03-28 00:00:24 +0000 | [diff] [blame] | 85 | |
Michael Giacomelli | 70e9c7a | 2008-12-25 01:46:16 +0000 | [diff] [blame] | 86 | #ifdef IPOD_ACCESSORY_PROTOCOL |
| 87 | #include "iap.h" |
| 88 | #endif |
| 89 | |
Jens Arnold | d6c0545 | 2005-08-29 21:15:27 +0000 | [diff] [blame] | 90 | #if (CONFIG_CODEC == SWCODEC) |
Michael Sevakis | 5857c44 | 2013-05-31 02:41:02 -0400 | [diff] [blame] | 91 | #include "audio_thread.h" |
Miika Pekkarinen | d319116 | 2006-01-27 11:39:46 +0000 | [diff] [blame] | 92 | #include "playback.h" |
Steve Bavin | e8c825f | 2009-06-15 16:03:01 +0000 | [diff] [blame] | 93 | #include "tdspeed.h" |
Henrik Backe | c1a951f | 2005-03-28 13:00:22 +0000 | [diff] [blame] | 94 | #endif |
Linus Nielsen Feltzing | ed4d7a3 | 2006-07-21 08:42:28 +0000 | [diff] [blame] | 95 | #if (CONFIG_CODEC == SWCODEC) && defined(HAVE_RECORDING) && !defined(SIMULATOR) |
Andy | e5d0872 | 2005-06-19 03:05:53 +0000 | [diff] [blame] | 96 | #include "pcm_record.h" |
Barry Wardell | df0dc22 | 2006-12-18 01:52:21 +0000 | [diff] [blame] | 97 | #endif |
| 98 | |
| 99 | #ifdef BUTTON_REC |
Marcoen Hirschberg | 810f717 | 2007-04-27 19:24:31 +0000 | [diff] [blame] | 100 | #define SETTINGS_RESET BUTTON_REC |
| 101 | #elif (CONFIG_KEYPAD == GIGABEAT_PAD) |
| 102 | #define SETTINGS_RESET BUTTON_A |
Andy | e5d0872 | 2005-06-19 03:05:53 +0000 | [diff] [blame] | 103 | #endif |
Michiel Van Der Kolk | 451dd48 | 2005-03-28 00:00:24 +0000 | [diff] [blame] | 104 | |
Jonathan Gordon | 8ff3a65 | 2007-02-18 02:04:47 +0000 | [diff] [blame] | 105 | #if CONFIG_TUNER |
Jörg Hohensohn | 8f8fbac | 2004-10-15 21:41:46 +0000 | [diff] [blame] | 106 | #include "radio.h" |
Jörg Hohensohn | 4a5df8e | 2004-10-15 22:10:55 +0000 | [diff] [blame] | 107 | #endif |
Frank Gevaerts | 19d1cac | 2008-10-31 21:25:04 +0000 | [diff] [blame] | 108 | #if (CONFIG_STORAGE & STORAGE_MMC) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 109 | #include "ata_mmc.h" |
| 110 | #endif |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 111 | |
Christian Gmeiner | 7c1879b | 2005-04-15 12:08:49 +0000 | [diff] [blame] | 112 | #ifdef HAVE_REMOTE_LCD |
| 113 | #include "lcd-remote.h" |
| 114 | #endif |
| 115 | |
Jonathan Gordon | ac61951 | 2007-02-18 04:57:28 +0000 | [diff] [blame] | 116 | #if CONFIG_USBOTG == USBOTG_ISP1362 |
Jens Arnold | 977169e | 2006-06-16 17:34:18 +0000 | [diff] [blame] | 117 | #include "isp1362.h" |
| 118 | #endif |
| 119 | |
Jonathan Gordon | ac61951 | 2007-02-18 04:57:28 +0000 | [diff] [blame] | 120 | #if CONFIG_USBOTG == USBOTG_M5636 |
Linus Nielsen Feltzing | 5f655c9 | 2006-07-13 07:40:30 +0000 | [diff] [blame] | 121 | #include "m5636.h" |
| 122 | #endif |
| 123 | |
Jonathan Gordon | be716c0 | 2011-11-16 10:25:43 +0000 | [diff] [blame] | 124 | #ifdef HAVE_HARDWARE_CLICK |
| 125 | #include "piezo.h" |
| 126 | #endif |
| 127 | |
Thomas Martitz | 0e2286f | 2010-08-12 13:38:25 +0000 | [diff] [blame] | 128 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) |
| 129 | #define MAIN_NORETURN_ATTR NORETURN_ATTR |
| 130 | #else |
| 131 | /* gcc adds an implicit 'return 0;' at the end of main(), causing a warning |
| 132 | * with noreturn attribute */ |
| 133 | #define MAIN_NORETURN_ATTR |
| 134 | #endif |
| 135 | |
Thomas Jarosch | 6e9e6a7 | 2011-02-27 23:42:37 +0000 | [diff] [blame] | 136 | #if (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA)) |
Thomas Martitz | 71d73fd | 2011-11-17 19:52:59 +0000 | [diff] [blame] | 137 | #ifdef SIMULATOR |
Thomas Martitz | c00fbc4 | 2010-09-01 22:09:43 +0000 | [diff] [blame] | 138 | #include "sim_tasks.h" |
Thomas Martitz | 71d73fd | 2011-11-17 19:52:59 +0000 | [diff] [blame] | 139 | #endif |
Michael Sevakis | d6af287 | 2007-10-26 23:11:18 +0000 | [diff] [blame] | 140 | #include "system-sdl.h" |
Thomas Martitz | 0e2286f | 2010-08-12 13:38:25 +0000 | [diff] [blame] | 141 | #define HAVE_ARGV_MAIN |
| 142 | /* Don't use SDL_main on windows -> no more stdio redirection */ |
| 143 | #if defined(WIN32) |
| 144 | #undef main |
| 145 | #endif |
Michael Sevakis | d6af287 | 2007-10-26 23:11:18 +0000 | [diff] [blame] | 146 | #endif |
| 147 | |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 148 | /*#define AUTOROCK*/ /* define this to check for "autostart.rock" on boot */ |
Björn Stenberg | 18239b8 | 2002-08-12 12:44:18 +0000 | [diff] [blame] | 149 | |
Jens Arnold | 314f3b5 | 2006-12-12 22:22:21 +0000 | [diff] [blame] | 150 | static void init(void); |
Thomas Martitz | a62eced | 2010-03-04 17:44:57 +0000 | [diff] [blame] | 151 | /* main(), and various functions called by main() and init() may be |
| 152 | * be INIT_ATTR. These functions must not be called after the final call |
| 153 | * to root_menu() at the end of main() |
| 154 | * see definition of INIT_ATTR in config.h */ |
Thomas Martitz | 0e2286f | 2010-08-12 13:38:25 +0000 | [diff] [blame] | 155 | #ifdef HAVE_ARGV_MAIN |
| 156 | int main(int argc, char *argv[]) INIT_ATTR MAIN_NORETURN_ATTR ; |
| 157 | int main(int argc, char *argv[]) |
| 158 | { |
| 159 | sys_handle_argv(argc, argv); |
| 160 | #else |
| 161 | int main(void) INIT_ATTR MAIN_NORETURN_ATTR; |
Rafaël Carré | bb9808b | 2009-11-03 12:20:54 +0000 | [diff] [blame] | 162 | int main(void) |
Björn Stenberg | 55c7da2 | 2002-05-21 14:28:10 +0000 | [diff] [blame] | 163 | { |
Thomas Martitz | 3d0cee8 | 2010-05-15 21:02:47 +0000 | [diff] [blame] | 164 | #endif |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 165 | CHART(">init"); |
Björn Stenberg | ad9829a | 2002-06-10 12:42:23 +0000 | [diff] [blame] | 166 | init(); |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 167 | CHART("<init"); |
Jonathan Gordon | 0e5cec2 | 2008-03-05 09:58:30 +0000 | [diff] [blame] | 168 | FOR_NB_SCREENS(i) |
| 169 | { |
| 170 | screens[i].clear_display(); |
| 171 | screens[i].update(); |
| 172 | } |
Thomas Martitz | 2eb1cb6 | 2009-09-07 17:37:06 +0000 | [diff] [blame] | 173 | #ifdef HAVE_LCD_BITMAP |
| 174 | list_init(); |
| 175 | #endif |
Jonathan Gordon | 2cda994 | 2007-06-10 10:41:27 +0000 | [diff] [blame] | 176 | tree_gui_init(); |
Thomas Martitz | c5b4482 | 2009-11-10 20:13:24 +0000 | [diff] [blame] | 177 | /* Keep the order of this 3 |
| 178 | * Must be done before any code uses the multi-screen API */ |
Frank Gevaerts | c483efa | 2009-05-21 19:01:07 +0000 | [diff] [blame] | 179 | #ifdef HAVE_USBSTACK |
| 180 | /* All threads should be created and public queues registered by now */ |
| 181 | usb_start_monitoring(); |
| 182 | #endif |
Teruaki Kawashima | ed940e8 | 2009-08-27 13:30:26 +0000 | [diff] [blame] | 183 | |
| 184 | #ifdef AUTOROCK |
| 185 | { |
Thomas Martitz | 9c0b247 | 2010-08-01 16:15:27 +0000 | [diff] [blame] | 186 | char filename[MAX_PATH]; |
Michael Sevakis | ffa8626 | 2013-07-12 12:03:20 -0400 | [diff] [blame] | 187 | const char *file = |
Thomas Martitz | 9c0b247 | 2010-08-01 16:15:27 +0000 | [diff] [blame] | 188 | #ifdef APPLICATION |
| 189 | ROCKBOX_DIR |
| 190 | #else |
| 191 | PLUGIN_APPS_DIR |
| 192 | #endif |
Thomas Martitz | 2c24160 | 2010-12-06 22:26:31 +0000 | [diff] [blame] | 193 | "/autostart.rock"; |
Thomas Martitz | 9c0b247 | 2010-08-01 16:15:27 +0000 | [diff] [blame] | 194 | if(file_exists(file)) /* no complaint if it doesn't exist */ |
Teruaki Kawashima | ed940e8 | 2009-08-27 13:30:26 +0000 | [diff] [blame] | 195 | { |
Thomas Martitz | 9c0b247 | 2010-08-01 16:15:27 +0000 | [diff] [blame] | 196 | plugin_load(file, NULL); /* start if it does */ |
Teruaki Kawashima | ed940e8 | 2009-08-27 13:30:26 +0000 | [diff] [blame] | 197 | } |
| 198 | } |
| 199 | #endif /* #ifdef AUTOROCK */ |
| 200 | |
Jonathan Gordon | 235d1ae | 2009-11-01 02:36:51 +0000 | [diff] [blame] | 201 | global_status.last_volume_change = 0; |
Thomas Martitz | a62eced | 2010-03-04 17:44:57 +0000 | [diff] [blame] | 202 | /* no calls INIT_ATTR functions after this point anymore! |
| 203 | * see definition of INIT_ATTR in config.h */ |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 204 | CHART(">root_menu"); |
Jonathan Gordon | 2cda994 | 2007-06-10 10:41:27 +0000 | [diff] [blame] | 205 | root_menu(); |
Björn Stenberg | 55c7da2 | 2002-05-21 14:28:10 +0000 | [diff] [blame] | 206 | } |
| 207 | |
Miika Pekkarinen | 954b732 | 2006-08-05 20:19:10 +0000 | [diff] [blame] | 208 | #ifdef HAVE_DIRCACHE |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 209 | static int INIT_ATTR init_dircache(bool preinit) |
| 210 | { |
Miika Pekkarinen | 69cdc75 | 2006-08-12 14:40:38 +0000 | [diff] [blame] | 211 | if (preinit) |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 212 | dircache_init(MAX(global_status.dircache_size, 0)); |
Michael Sevakis | ffa8626 | 2013-07-12 12:03:20 -0400 | [diff] [blame] | 213 | |
Miika Pekkarinen | c8a9ca7 | 2006-12-22 09:11:09 +0000 | [diff] [blame] | 214 | if (!global_settings.dircache) |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 215 | return -1; |
Michael Sevakis | ffa8626 | 2013-07-12 12:03:20 -0400 | [diff] [blame] | 216 | |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 217 | int result = -1; |
| 218 | |
| 219 | #ifdef HAVE_EEPROM_SETTINGS |
| 220 | if (firmware_settings.initialized && |
| 221 | firmware_settings.disk_clean && |
| 222 | preinit) |
Miika Pekkarinen | c8a9ca7 | 2006-12-22 09:11:09 +0000 | [diff] [blame] | 223 | { |
| 224 | result = dircache_load(); |
Miika Pekkarinen | c8a9ca7 | 2006-12-22 09:11:09 +0000 | [diff] [blame] | 225 | if (result < 0) |
Miika Pekkarinen | c8a9ca7 | 2006-12-22 09:11:09 +0000 | [diff] [blame] | 226 | firmware_settings.disk_clean = false; |
Miika Pekkarinen | c8a9ca7 | 2006-12-22 09:11:09 +0000 | [diff] [blame] | 227 | } |
| 228 | else |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 229 | #endif /* HAVE_EEPROM_SETTINGS */ |
| 230 | if (!preinit) |
Miika Pekkarinen | c8a9ca7 | 2006-12-22 09:11:09 +0000 | [diff] [blame] | 231 | { |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 232 | result = dircache_enable(); |
| 233 | if (result != 0) |
Miika Pekkarinen | 69cdc75 | 2006-08-12 14:40:38 +0000 | [diff] [blame] | 234 | { |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 235 | if (result > 0) |
Miika Pekkarinen | 69cdc75 | 2006-08-12 14:40:38 +0000 | [diff] [blame] | 236 | { |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 237 | /* Print "Scanning disk..." to the display. */ |
Nils Wallménius | 01729e7 | 2008-08-15 08:27:39 +0000 | [diff] [blame] | 238 | splash(0, str(LANG_SCANNING_DISK)); |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 239 | dircache_wait(); |
| 240 | backlight_on(); |
| 241 | show_logo(); |
Miika Pekkarinen | 69cdc75 | 2006-08-12 14:40:38 +0000 | [diff] [blame] | 242 | } |
Michael Sevakis | ffa8626 | 2013-07-12 12:03:20 -0400 | [diff] [blame] | 243 | |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 244 | struct dircache_info info; |
| 245 | dircache_get_info(&info); |
| 246 | global_status.dircache_size = info.size; |
| 247 | status_save(); |
Miika Pekkarinen | 7b1e827 | 2007-04-07 17:48:51 +0000 | [diff] [blame] | 248 | } |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 249 | /* else don't wait or already enabled by load */ |
Miika Pekkarinen | ab78b04 | 2005-10-07 17:38:05 +0000 | [diff] [blame] | 250 | } |
Michael Sevakis | ffa8626 | 2013-07-12 12:03:20 -0400 | [diff] [blame] | 251 | |
Miika Pekkarinen | 954b732 | 2006-08-05 20:19:10 +0000 | [diff] [blame] | 252 | return result; |
Miika Pekkarinen | 954b732 | 2006-08-05 20:19:10 +0000 | [diff] [blame] | 253 | } |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 254 | #endif /* HAVE_DIRCACHE */ |
Miika Pekkarinen | ab78b04 | 2005-10-07 17:38:05 +0000 | [diff] [blame] | 255 | |
Jonathan Gordon | 710ccb7 | 2006-10-25 10:17:57 +0000 | [diff] [blame] | 256 | #ifdef HAVE_TAGCACHE |
Thomas Martitz | f8edc32 | 2010-03-03 23:20:32 +0000 | [diff] [blame] | 257 | static void init_tagcache(void) INIT_ATTR; |
Jens Arnold | 314f3b5 | 2006-12-12 22:22:21 +0000 | [diff] [blame] | 258 | static void init_tagcache(void) |
Miika Pekkarinen | 7c4e0c8 | 2006-03-26 11:33:42 +0000 | [diff] [blame] | 259 | { |
Jens Arnold | b09df80 | 2006-05-24 07:31:23 +0000 | [diff] [blame] | 260 | bool clear = false; |
Michael Sevakis | ba8e436 | 2012-05-30 18:42:16 -0400 | [diff] [blame] | 261 | #if 0 /* CONFIG_CODEC == SWCODEC */ |
Nils Wallménius | 18cf68e | 2009-10-25 10:20:15 +0000 | [diff] [blame] | 262 | long talked_tick = 0; |
| 263 | #endif |
Miika Pekkarinen | 7c4e0c8 | 2006-03-26 11:33:42 +0000 | [diff] [blame] | 264 | tagcache_init(); |
Michael Sevakis | ffa8626 | 2013-07-12 12:03:20 -0400 | [diff] [blame] | 265 | |
Miika Pekkarinen | 1b18dd0 | 2006-04-12 10:31:24 +0000 | [diff] [blame] | 266 | while (!tagcache_is_initialized()) |
| 267 | { |
Jens Arnold | b09df80 | 2006-05-24 07:31:23 +0000 | [diff] [blame] | 268 | int ret = tagcache_get_commit_step(); |
| 269 | |
Miika Pekkarinen | 1b18dd0 | 2006-04-12 10:31:24 +0000 | [diff] [blame] | 270 | if (ret > 0) |
| 271 | { |
Michael Sevakis | ba8e436 | 2012-05-30 18:42:16 -0400 | [diff] [blame] | 272 | #if 0 /* FIXME: Audio isn't even initialized yet! */ /* CONFIG_CODEC == SWCODEC */ |
Jens Arnold | 916a563 | 2007-08-28 18:08:48 +0000 | [diff] [blame] | 273 | /* hwcodec can't use voice here, as the database commit |
| 274 | * uses the audio buffer. */ |
Steve Bavin | 32a9575 | 2007-10-19 15:31:42 +0000 | [diff] [blame] | 275 | if(global_settings.talk_menu |
Nils Wallménius | 5b76936 | 2007-08-06 13:08:36 +0000 | [diff] [blame] | 276 | && (talked_tick == 0 |
| 277 | || TIME_AFTER(current_tick, talked_tick+7*HZ))) |
| 278 | { |
| 279 | talked_tick = current_tick; |
| 280 | talk_id(LANG_TAGCACHE_INIT, false); |
| 281 | talk_number(ret, true); |
| 282 | talk_id(VOICE_OF, true); |
| 283 | talk_number(tagcache_get_max_commit_step(), true); |
| 284 | } |
Jens Arnold | 916a563 | 2007-08-28 18:08:48 +0000 | [diff] [blame] | 285 | #endif |
Jens Arnold | b09df80 | 2006-05-24 07:31:23 +0000 | [diff] [blame] | 286 | #ifdef HAVE_LCD_BITMAP |
Tomer Shalev | d7cdd08 | 2009-10-08 22:40:38 +0000 | [diff] [blame] | 287 | if (lang_is_rtl()) |
| 288 | { |
| 289 | splashf(0, "[%d/%d] %s", ret, tagcache_get_max_commit_step(), |
| 290 | str(LANG_TAGCACHE_INIT)); |
| 291 | } |
| 292 | else |
| 293 | { |
| 294 | splashf(0, "%s [%d/%d]", str(LANG_TAGCACHE_INIT), ret, |
| 295 | tagcache_get_max_commit_step()); |
| 296 | } |
Jens Arnold | b09df80 | 2006-05-24 07:31:23 +0000 | [diff] [blame] | 297 | #else |
| 298 | lcd_double_height(false); |
Michael Sevakis | ffa8626 | 2013-07-12 12:03:20 -0400 | [diff] [blame] | 299 | lcd_putsf(0, 1, " DB [%d/%d]", ret, |
Steve Bavin | 8137489 | 2007-03-07 19:56:15 +0000 | [diff] [blame] | 300 | tagcache_get_max_commit_step()); |
Jens Arnold | 900ced2 | 2007-05-17 06:37:25 +0000 | [diff] [blame] | 301 | lcd_update(); |
Miika Pekkarinen | 1b18dd0 | 2006-04-12 10:31:24 +0000 | [diff] [blame] | 302 | #endif |
Jens Arnold | b09df80 | 2006-05-24 07:31:23 +0000 | [diff] [blame] | 303 | clear = true; |
| 304 | } |
Miika Pekkarinen | 1b18dd0 | 2006-04-12 10:31:24 +0000 | [diff] [blame] | 305 | sleep(HZ/4); |
| 306 | } |
Miika Pekkarinen | 4a63c09 | 2006-04-04 19:28:13 +0000 | [diff] [blame] | 307 | tagtree_init(); |
Miika Pekkarinen | 7c4e0c8 | 2006-03-26 11:33:42 +0000 | [diff] [blame] | 308 | |
Jens Arnold | b09df80 | 2006-05-24 07:31:23 +0000 | [diff] [blame] | 309 | if (clear) |
Miika Pekkarinen | 196b770 | 2006-05-27 11:21:08 +0000 | [diff] [blame] | 310 | { |
| 311 | backlight_on(); |
Jens Arnold | b09df80 | 2006-05-24 07:31:23 +0000 | [diff] [blame] | 312 | show_logo(); |
Miika Pekkarinen | 196b770 | 2006-05-27 11:21:08 +0000 | [diff] [blame] | 313 | } |
Miika Pekkarinen | 7c4e0c8 | 2006-03-26 11:33:42 +0000 | [diff] [blame] | 314 | } |
Jonathan Gordon | 710ccb7 | 2006-10-25 10:17:57 +0000 | [diff] [blame] | 315 | #endif |
Miika Pekkarinen | 7c4e0c8 | 2006-03-26 11:33:42 +0000 | [diff] [blame] | 316 | |
Thomas Martitz | 35e8b14 | 2010-06-21 16:53:00 +0000 | [diff] [blame] | 317 | #if (CONFIG_PLATFORM & PLATFORM_HOSTED) |
Björn Stenberg | ad9829a | 2002-06-10 12:42:23 +0000 | [diff] [blame] | 318 | |
Jens Arnold | 314f3b5 | 2006-12-12 22:22:21 +0000 | [diff] [blame] | 319 | static void init(void) |
Björn Stenberg | ad9829a | 2002-06-10 12:42:23 +0000 | [diff] [blame] | 320 | { |
Thomas Martitz | f5a461d | 2010-12-10 18:41:09 +0000 | [diff] [blame] | 321 | system_init(); |
Thomas Martitz | d0b72e2 | 2011-08-30 14:01:33 +0000 | [diff] [blame] | 322 | core_allocator_init(); |
Thomas Martitz | f5a461d | 2010-12-10 18:41:09 +0000 | [diff] [blame] | 323 | kernel_init(); |
Thomas Martitz | 0e2286f | 2010-08-12 13:38:25 +0000 | [diff] [blame] | 324 | #ifdef APPLICATION |
| 325 | paths_init(); |
| 326 | #endif |
Michael Sevakis | af395f4 | 2008-03-26 01:50:41 +0000 | [diff] [blame] | 327 | enable_irq(); |
Björn Stenberg | ad9829a | 2002-06-10 12:42:23 +0000 | [diff] [blame] | 328 | lcd_init(); |
Jens Arnold | 3a5bd7a | 2005-07-07 21:03:58 +0000 | [diff] [blame] | 329 | #ifdef HAVE_REMOTE_LCD |
| 330 | lcd_remote_init(); |
| 331 | #endif |
Jonathan Gordon | aa0f4a4 | 2011-09-24 13:19:34 +0000 | [diff] [blame] | 332 | #ifdef HAVE_LCD_BITMAP |
| 333 | FOR_NB_SCREENS(i) |
| 334 | global_status.font_id[i] = FONT_SYSFIXED; |
Kjell Ericson | fd9f864 | 2002-10-28 19:52:22 +0000 | [diff] [blame] | 335 | font_init(); |
Jonathan Gordon | aa0f4a4 | 2011-09-24 13:19:34 +0000 | [diff] [blame] | 336 | #endif |
Björn Stenberg | ad9829a | 2002-06-10 12:42:23 +0000 | [diff] [blame] | 337 | show_logo(); |
Marcin Bukat | 7692558 | 2018-03-13 21:24:56 +0100 | [diff] [blame] | 338 | #ifndef USB_NONE |
| 339 | usb_init(); |
| 340 | usb_start_monitoring(); |
| 341 | #endif |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 342 | button_init(); |
Thomas Jarosch | 15a3580 | 2011-03-02 19:12:55 +0000 | [diff] [blame] | 343 | powermgmt_init(); |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 344 | backlight_init(); |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 345 | unicode_init(); |
Thomas Martitz | 71d73fd | 2011-11-17 19:52:59 +0000 | [diff] [blame] | 346 | #ifdef SIMULATOR |
Jens Arnold | 3e67e3b | 2009-02-20 17:13:08 +0000 | [diff] [blame] | 347 | sim_tasks_init(); |
Thomas Martitz | c00fbc4 | 2010-09-01 22:09:43 +0000 | [diff] [blame] | 348 | #endif |
Udo Schläpfer | dbabd0d | 2015-02-02 21:44:29 +0100 | [diff] [blame] | 349 | #if (CONFIG_PLATFORM & PLATFORM_ANDROID) |
Thomas Martitz | f5a461d | 2010-12-10 18:41:09 +0000 | [diff] [blame] | 350 | notification_init(); |
| 351 | #endif |
Michael Sevakis | ffa8626 | 2013-07-12 12:03:20 -0400 | [diff] [blame] | 352 | lang_init(core_language_builtin, language_strings, |
Tom Ross | ec2737b | 2009-10-18 00:56:42 +0000 | [diff] [blame] | 353 | LANG_LAST_INDEX_IN_ARRAY); |
Jens Arnold | 2fd7c3c | 2007-04-19 20:17:24 +0000 | [diff] [blame] | 354 | #ifdef DEBUG |
| 355 | debug_init(); |
| 356 | #endif |
Thomas Martitz | a5b0a1d | 2012-04-10 10:34:36 +0200 | [diff] [blame] | 357 | #if CONFIG_TUNER |
| 358 | radio_init(); |
| 359 | #endif |
Thomas Martitz | c5b4482 | 2009-11-10 20:13:24 +0000 | [diff] [blame] | 360 | /* Keep the order of this 3 (viewportmanager handles statusbars) |
| 361 | * Must be done before any code uses the multi-screen API */ |
Jens Arnold | baef536 | 2009-10-03 22:09:27 +0000 | [diff] [blame] | 362 | gui_syncstatusbar_init(&statusbars); |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 363 | gui_sync_skin_init(); |
Thomas Martitz | c5b4482 | 2009-11-10 20:13:24 +0000 | [diff] [blame] | 364 | sb_skin_init(); |
| 365 | viewportmanager_init(); |
| 366 | |
Frank Gevaerts | 2f8a008 | 2008-11-01 16:14:28 +0000 | [diff] [blame] | 367 | storage_init(); |
Michael Sevakis | c9bcbe2 | 2012-03-27 19:52:15 -0400 | [diff] [blame] | 368 | #if CONFIG_CODEC == SWCODEC |
Michael Sevakis | 5857c44 | 2013-05-31 02:41:02 -0400 | [diff] [blame] | 369 | pcm_init(); |
Michael Sevakis | c9bcbe2 | 2012-03-27 19:52:15 -0400 | [diff] [blame] | 370 | dsp_init(); |
| 371 | #endif |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 372 | settings_reset(); |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 373 | settings_load(SETTINGS_ALL); |
Jonathan Gordon | 792f733 | 2010-03-07 03:20:34 +0000 | [diff] [blame] | 374 | settings_apply(true); |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 375 | #ifdef HAVE_DIRCACHE |
Miika Pekkarinen | 69cdc75 | 2006-08-12 14:40:38 +0000 | [diff] [blame] | 376 | init_dircache(true); |
| 377 | init_dircache(false); |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 378 | #endif |
Jonathan Gordon | 710ccb7 | 2006-10-25 10:17:57 +0000 | [diff] [blame] | 379 | #ifdef HAVE_TAGCACHE |
Miika Pekkarinen | 7c4e0c8 | 2006-03-26 11:33:42 +0000 | [diff] [blame] | 380 | init_tagcache(); |
Jonathan Gordon | 710ccb7 | 2006-10-25 10:17:57 +0000 | [diff] [blame] | 381 | #endif |
Jonathan Gordon | 2cda994 | 2007-06-10 10:41:27 +0000 | [diff] [blame] | 382 | tree_mem_init(); |
Jonathan Gordon | 21165a3 | 2007-03-29 06:16:00 +0000 | [diff] [blame] | 383 | filetype_init(); |
Linus Nielsen Feltzing | fe6cf2d | 2003-05-17 22:25:52 +0000 | [diff] [blame] | 384 | playlist_init(); |
Jonathan Gordon | 101693f | 2011-11-15 13:22:02 +0000 | [diff] [blame] | 385 | shortcuts_init(); |
Michael Sevakis | 98cd3e8 | 2007-03-09 12:30:14 +0000 | [diff] [blame] | 386 | |
| 387 | #if CONFIG_CODEC != SWCODEC |
Jörg Hohensohn | f993365 | 2004-01-05 20:42:51 +0000 | [diff] [blame] | 388 | mp3_init( global_settings.volume, |
| 389 | global_settings.bass, |
| 390 | global_settings.treble, |
| 391 | global_settings.balance, |
| 392 | global_settings.loudness, |
Jörg Hohensohn | f993365 | 2004-01-05 20:42:51 +0000 | [diff] [blame] | 393 | global_settings.avc, |
Linus Nielsen Feltzing | 7bade1a | 2004-07-06 12:17:14 +0000 | [diff] [blame] | 394 | global_settings.channel_config, |
Jens Arnold | 76b257f | 2005-01-12 00:24:15 +0000 | [diff] [blame] | 395 | global_settings.stereo_width, |
Linus Nielsen Feltzing | 7bade1a | 2004-07-06 12:17:14 +0000 | [diff] [blame] | 396 | global_settings.mdb_strength, |
| 397 | global_settings.mdb_harmonics, |
| 398 | global_settings.mdb_center, |
| 399 | global_settings.mdb_shape, |
| 400 | global_settings.mdb_enable, |
| 401 | global_settings.superbass); |
Michael Sevakis | 98cd3e8 | 2007-03-09 12:30:14 +0000 | [diff] [blame] | 402 | #endif /* CONFIG_CODEC != SWCODEC */ |
| 403 | |
Michael Sevakis | 023f6b6 | 2013-07-12 12:06:38 -0400 | [diff] [blame] | 404 | if (global_settings.audioscrobbler) |
| 405 | scrobbler_init(); |
Nicolas Pennequin | 9f4bd87 | 2007-02-14 14:40:24 +0000 | [diff] [blame] | 406 | |
Peter D'Hoye | 6488177 | 2006-05-01 12:54:21 +0000 | [diff] [blame] | 407 | audio_init(); |
Thomas Martitz | d3c2102 | 2011-10-26 18:28:45 +0000 | [diff] [blame] | 408 | |
Jonathan Gordon | 4c6b355 | 2010-02-26 08:01:41 +0000 | [diff] [blame] | 409 | settings_apply_skins(); |
Björn Stenberg | ad9829a | 2002-06-10 12:42:23 +0000 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | #else |
Björn Stenberg | 88f7fb0 | 2002-05-24 15:40:14 +0000 | [diff] [blame] | 413 | |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 414 | #include "errno.h" |
| 415 | |
Thomas Martitz | f8edc32 | 2010-03-03 23:20:32 +0000 | [diff] [blame] | 416 | static void init(void) INIT_ATTR; |
Jens Arnold | 314f3b5 | 2006-12-12 22:22:21 +0000 | [diff] [blame] | 417 | static void init(void) |
Björn Stenberg | e324db6 | 2002-05-17 19:50:37 +0000 | [diff] [blame] | 418 | { |
Jörg Hohensohn | 7ee03d0 | 2004-12-29 22:33:32 +0000 | [diff] [blame] | 419 | int rc; |
Jens Arnold | 27abc2a | 2005-05-17 22:10:51 +0000 | [diff] [blame] | 420 | bool mounted = false; |
Jonathan Gordon | 9a6f419 | 2007-02-18 05:32:06 +0000 | [diff] [blame] | 421 | #if CONFIG_CHARGING && (CONFIG_CPU == SH7034) |
Jörg Hohensohn | 5dd17b1 | 2003-07-17 20:29:51 +0000 | [diff] [blame] | 422 | /* if nobody initialized ATA before, I consider this a cold start */ |
| 423 | bool coldstart = (PACR2 & 0x4000) != 0; /* starting from Flash */ |
Daniel Stenberg | 8ef88a1 | 2005-02-03 08:36:43 +0000 | [diff] [blame] | 424 | #endif |
Michael Sevakis | 7914e90 | 2007-09-28 10:20:02 +0000 | [diff] [blame] | 425 | |
Linus Nielsen Feltzing | 0f60775 | 2002-05-29 09:14:38 +0000 | [diff] [blame] | 426 | system_init(); |
Thomas Martitz | d0b72e2 | 2011-08-30 14:01:33 +0000 | [diff] [blame] | 427 | core_allocator_init(); |
Linus Nielsen Feltzing | 8c00b4c | 2002-06-10 14:44:15 +0000 | [diff] [blame] | 428 | kernel_init(); |
Linus Nielsen Feltzing | 31e2097 | 2002-06-20 08:59:54 +0000 | [diff] [blame] | 429 | |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 430 | /* early early early! */ |
| 431 | filesystem_init(); |
| 432 | |
Linus Nielsen Feltzing | e7b993f | 2005-03-18 11:38:15 +0000 | [diff] [blame] | 433 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
| 434 | set_cpu_frequency(CPUFREQ_NORMAL); |
Michael Sevakis | 0f5cb94 | 2006-11-06 18:07:30 +0000 | [diff] [blame] | 435 | #ifdef CPU_COLDFIRE |
| 436 | coldfire_set_pllcr_audio_bits(DEFAULT_PLLCR_AUDIO_BITS); |
| 437 | #endif |
Miika Pekkarinen | 86d0d91 | 2006-12-05 20:20:00 +0000 | [diff] [blame] | 438 | cpu_boost(true); |
Linus Nielsen Feltzing | e7b993f | 2005-03-18 11:38:15 +0000 | [diff] [blame] | 439 | #endif |
Jonathan Gordon | f7c2978 | 2011-09-25 12:55:40 +0000 | [diff] [blame] | 440 | |
Michael Giacomelli | 054447f | 2008-02-10 05:39:20 +0000 | [diff] [blame] | 441 | i2c_init(); |
Michael Sevakis | ffa8626 | 2013-07-12 12:03:20 -0400 | [diff] [blame] | 442 | |
Linus Nielsen Feltzing | e16ebf1 | 2005-11-18 14:55:51 +0000 | [diff] [blame] | 443 | power_init(); |
| 444 | |
Michael Sevakis | af395f4 | 2008-03-26 01:50:41 +0000 | [diff] [blame] | 445 | enable_irq(); |
Michael Sevakis | 6077e5b | 2007-10-06 22:27:27 +0000 | [diff] [blame] | 446 | #ifdef CPU_ARM |
Michael Sevakis | af395f4 | 2008-03-26 01:50:41 +0000 | [diff] [blame] | 447 | enable_fiq(); |
Michael Sevakis | 6077e5b | 2007-10-06 22:27:27 +0000 | [diff] [blame] | 448 | #endif |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 449 | /* current_tick should be ticking by now */ |
| 450 | CHART("ticking"); |
| 451 | |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 452 | unicode_init(); |
Björn Stenberg | 4afa709 | 2002-05-30 12:17:18 +0000 | [diff] [blame] | 453 | lcd_init(); |
Jens Arnold | 3a5bd7a | 2005-07-07 21:03:58 +0000 | [diff] [blame] | 454 | #ifdef HAVE_REMOTE_LCD |
Christian Gmeiner | 7c1879b | 2005-04-15 12:08:49 +0000 | [diff] [blame] | 455 | lcd_remote_init(); |
| 456 | #endif |
Jonathan Gordon | aa0f4a4 | 2011-09-24 13:19:34 +0000 | [diff] [blame] | 457 | #ifdef HAVE_LCD_BITMAP |
Björn Stenberg | 0942e2a | 2011-10-15 19:35:02 +0000 | [diff] [blame] | 458 | FOR_NB_SCREENS(i) |
| 459 | global_status.font_id[i] = FONT_SYSFIXED; |
Björn Stenberg | bed3d3f | 2002-09-20 08:07:51 +0000 | [diff] [blame] | 460 | font_init(); |
Jonathan Gordon | aa0f4a4 | 2011-09-24 13:19:34 +0000 | [diff] [blame] | 461 | #endif |
Michael Sevakis | ffa8626 | 2013-07-12 12:03:20 -0400 | [diff] [blame] | 462 | |
Fred Bauer | a1d3a1d | 2011-09-27 21:06:12 +0000 | [diff] [blame] | 463 | settings_reset(); |
Karl Kurbjun | 8a1fd8c | 2007-04-21 04:48:20 +0000 | [diff] [blame] | 464 | |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 465 | CHART(">show_logo"); |
Linus Nielsen Feltzing | 219944f | 2005-11-08 23:51:36 +0000 | [diff] [blame] | 466 | show_logo(); |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 467 | CHART("<show_logo"); |
Michael Sevakis | ffa8626 | 2013-07-12 12:03:20 -0400 | [diff] [blame] | 468 | lang_init(core_language_builtin, language_strings, |
Tom Ross | ec2737b | 2009-10-18 00:56:42 +0000 | [diff] [blame] | 469 | LANG_LAST_INDEX_IN_ARRAY); |
Daniel Stenberg | 75e09a8 | 2002-06-11 08:24:33 +0000 | [diff] [blame] | 470 | |
Björn Stenberg | f43b27a | 2002-05-27 09:53:28 +0000 | [diff] [blame] | 471 | #ifdef DEBUG |
Björn Stenberg | e324db6 | 2002-05-17 19:50:37 +0000 | [diff] [blame] | 472 | debug_init(); |
Björn Stenberg | 18239b8 | 2002-08-12 12:44:18 +0000 | [diff] [blame] | 473 | #else |
Bertrik Sikken | 3c7e299 | 2009-02-07 11:15:30 +0000 | [diff] [blame] | 474 | #ifdef HAVE_SERIAL |
Björn Stenberg | 18239b8 | 2002-08-12 12:44:18 +0000 | [diff] [blame] | 475 | serial_setup(); |
Björn Stenberg | f43b27a | 2002-05-27 09:53:28 +0000 | [diff] [blame] | 476 | #endif |
Jens Arnold | 2d875f8 | 2004-09-20 22:15:35 +0000 | [diff] [blame] | 477 | #endif |
Björn Stenberg | e324db6 | 2002-05-17 19:50:37 +0000 | [diff] [blame] | 478 | |
Jens Arnold | 2c7b127 | 2007-03-16 23:47:03 +0000 | [diff] [blame] | 479 | #if CONFIG_RTC |
Linus Nielsen Feltzing | 76759e0 | 2002-08-06 08:14:08 +0000 | [diff] [blame] | 480 | rtc_init(); |
Dave Chapman | 5009c9c | 2005-12-04 13:05:56 +0000 | [diff] [blame] | 481 | #endif |
| 482 | #ifdef HAVE_RTC_RAM |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 483 | CHART(">settings_load(RTC)"); |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 484 | settings_load(SETTINGS_RTC); /* early load parts of global_settings */ |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 485 | CHART("<settings_load(RTC)"); |
Linus Nielsen Feltzing | 76759e0 | 2002-08-06 08:14:08 +0000 | [diff] [blame] | 486 | #endif |
| 487 | |
Linus Nielsen Feltzing | 7d3c31b | 2002-06-30 20:25:37 +0000 | [diff] [blame] | 488 | adc_init(); |
Christian Gmeiner | 8181a0c | 2007-08-27 16:04:32 +0000 | [diff] [blame] | 489 | |
Linus Nielsen Feltzing | 219944f | 2005-11-08 23:51:36 +0000 | [diff] [blame] | 490 | usb_init(); |
Jonathan Gordon | ac61951 | 2007-02-18 04:57:28 +0000 | [diff] [blame] | 491 | #if CONFIG_USBOTG == USBOTG_ISP1362 |
Jens Arnold | 977169e | 2006-06-16 17:34:18 +0000 | [diff] [blame] | 492 | isp1362_init(); |
Jonathan Gordon | ac61951 | 2007-02-18 04:57:28 +0000 | [diff] [blame] | 493 | #elif CONFIG_USBOTG == USBOTG_M5636 |
Linus Nielsen Feltzing | 5f655c9 | 2006-07-13 07:40:30 +0000 | [diff] [blame] | 494 | m5636_init(); |
Jens Arnold | 977169e | 2006-06-16 17:34:18 +0000 | [diff] [blame] | 495 | #endif |
Linus Nielsen Feltzing | e16ebf1 | 2005-11-18 14:55:51 +0000 | [diff] [blame] | 496 | |
Linus Nielsen Feltzing | a844a18 | 2007-03-07 14:49:20 +0000 | [diff] [blame] | 497 | backlight_init(); |
| 498 | |
Björn Stenberg | e324db6 | 2002-05-17 19:50:37 +0000 | [diff] [blame] | 499 | button_init(); |
Linus Nielsen Feltzing | 4b54559 | 2002-07-02 17:59:10 +0000 | [diff] [blame] | 500 | |
Boris Gjenero | 5cd8aec | 2011-12-31 18:31:47 +0000 | [diff] [blame] | 501 | /* Don't initialize power management here if it could incorrectly |
| 502 | * measure battery voltage, and it's not needed for charging. */ |
| 503 | #if !defined(NEED_ATA_POWER_BATT_MEASURE) || \ |
| 504 | (CONFIG_CHARGING > CHARGING_MONITOR) |
Linus Nielsen Feltzing | 219944f | 2005-11-08 23:51:36 +0000 | [diff] [blame] | 505 | powermgmt_init(); |
Boris Gjenero | 5cd8aec | 2011-12-31 18:31:47 +0000 | [diff] [blame] | 506 | #endif |
Peter D'Hoye | 3c1e9ca | 2008-09-07 20:09:11 +0000 | [diff] [blame] | 507 | |
Jonathan Gordon | 8ff3a65 | 2007-02-18 02:04:47 +0000 | [diff] [blame] | 508 | #if CONFIG_TUNER |
Linus Nielsen Feltzing | 219944f | 2005-11-08 23:51:36 +0000 | [diff] [blame] | 509 | radio_init(); |
Jörg Hohensohn | ef8d508 | 2004-10-19 08:20:38 +0000 | [diff] [blame] | 510 | #endif |
| 511 | |
Jonathan Gordon | be716c0 | 2011-11-16 10:25:43 +0000 | [diff] [blame] | 512 | #ifdef HAVE_HARDWARE_CLICK |
| 513 | piezo_init(); |
| 514 | #endif |
| 515 | |
Thomas Martitz | c5b4482 | 2009-11-10 20:13:24 +0000 | [diff] [blame] | 516 | /* Keep the order of this 3 (viewportmanager handles statusbars) |
| 517 | * Must be done before any code uses the multi-screen API */ |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 518 | CHART(">gui_syncstatusbar_init"); |
Jens Arnold | baef536 | 2009-10-03 22:09:27 +0000 | [diff] [blame] | 519 | gui_syncstatusbar_init(&statusbars); |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 520 | CHART("<gui_syncstatusbar_init"); |
| 521 | CHART(">sb_skin_init"); |
Thomas Martitz | c5b4482 | 2009-11-10 20:13:24 +0000 | [diff] [blame] | 522 | sb_skin_init(); |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 523 | CHART("<sb_skin_init"); |
| 524 | CHART(">gui_sync_wps_init"); |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 525 | gui_sync_skin_init(); |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 526 | CHART("<gui_sync_wps_init"); |
| 527 | CHART(">viewportmanager_init"); |
Thomas Martitz | c5b4482 | 2009-11-10 20:13:24 +0000 | [diff] [blame] | 528 | viewportmanager_init(); |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 529 | CHART("<viewportmanager_init"); |
Thomas Martitz | c5b4482 | 2009-11-10 20:13:24 +0000 | [diff] [blame] | 530 | |
Jonathan Gordon | 9a6f419 | 2007-02-18 05:32:06 +0000 | [diff] [blame] | 531 | #if CONFIG_CHARGING && (CONFIG_CPU == SH7034) |
Boris Gjenero | 02b9c65 | 2009-04-06 01:47:28 +0000 | [diff] [blame] | 532 | /* charger_inserted() can't be used here because power_thread() |
| 533 | hasn't checked power_input_status() yet */ |
| 534 | if (coldstart && (power_input_status() & POWER_INPUT_MAIN_CHARGER) |
Jens Arnold | 7197edd | 2004-12-16 22:31:26 +0000 | [diff] [blame] | 535 | && !global_settings.car_adapter_mode |
| 536 | #ifdef ATA_POWER_PLAYERSTYLE |
| 537 | && !ide_powered() /* relies on probing result from bootloader */ |
| 538 | #endif |
| 539 | ) |
Jörg Hohensohn | 5dd17b1 | 2003-07-17 20:29:51 +0000 | [diff] [blame] | 540 | { |
| 541 | rc = charging_screen(); /* display a "charging" screen */ |
Jens Arnold | 7c7dd43 | 2005-07-11 19:14:26 +0000 | [diff] [blame] | 542 | if (rc == 1) /* charger removed */ |
Jörg Hohensohn | 5dd17b1 | 2003-07-17 20:29:51 +0000 | [diff] [blame] | 543 | power_off(); |
| 544 | /* "On" pressed or USB connected: proceed */ |
Jens Arnold | 67b17e1 | 2004-11-21 09:29:51 +0000 | [diff] [blame] | 545 | show_logo(); /* again, to provide better visual feedback */ |
Jörg Hohensohn | 5dd17b1 | 2003-07-17 20:29:51 +0000 | [diff] [blame] | 546 | } |
Daniel Stenberg | 8e43ccb | 2003-12-12 13:34:27 +0000 | [diff] [blame] | 547 | #endif |
Jörg Hohensohn | c47f8c0 | 2003-07-03 22:13:39 +0000 | [diff] [blame] | 548 | |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 549 | CHART(">storage_init"); |
Frank Gevaerts | 2f8a008 | 2008-11-01 16:14:28 +0000 | [diff] [blame] | 550 | rc = storage_init(); |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 551 | CHART("<storage_init"); |
Linus Nielsen Feltzing | 71ef31a | 2002-07-02 18:01:31 +0000 | [diff] [blame] | 552 | if(rc) |
Linus Nielsen Feltzing | 4b54559 | 2002-07-02 17:59:10 +0000 | [diff] [blame] | 553 | { |
Björn Stenberg | b47e64e | 2002-08-08 20:44:25 +0000 | [diff] [blame] | 554 | #ifdef HAVE_LCD_BITMAP |
Linus Nielsen Feltzing | 4b54559 | 2002-07-02 17:59:10 +0000 | [diff] [blame] | 555 | lcd_clear_display(); |
Nils Wallménius | f34a841 | 2009-10-17 18:02:48 +0000 | [diff] [blame] | 556 | lcd_putsf(0, 1, "ATA error: %d", rc); |
Linus Nielsen Feltzing | 4b54559 | 2002-07-02 17:59:10 +0000 | [diff] [blame] | 557 | lcd_puts(0, 3, "Press ON to debug"); |
| 558 | lcd_update(); |
Michael Sparmann | 886e972 | 2011-01-02 22:22:51 +0000 | [diff] [blame] | 559 | while(!(button_get(true) & BUTTON_REL)); /* DO NOT CHANGE TO ACTION SYSTEM */ |
Linus Nielsen Feltzing | 4b54559 | 2002-07-02 17:59:10 +0000 | [diff] [blame] | 560 | dbg_ports(); |
| 561 | #endif |
| 562 | panicf("ata: %d", rc); |
| 563 | } |
Jens Arnold | 2d875f8 | 2004-09-20 22:15:35 +0000 | [diff] [blame] | 564 | |
Boris Gjenero | 5cd8aec | 2011-12-31 18:31:47 +0000 | [diff] [blame] | 565 | #if defined(NEED_ATA_POWER_BATT_MEASURE) && \ |
| 566 | (CONFIG_CHARGING <= CHARGING_MONITOR) |
| 567 | /* After storage_init(), ATA power must be on, so battery voltage |
| 568 | * can be measured. Initialize power management if it was delayed. */ |
| 569 | powermgmt_init(); |
| 570 | #endif |
Peter D'Hoye | c4a59a2 | 2006-08-15 22:54:06 +0000 | [diff] [blame] | 571 | #ifdef HAVE_EEPROM_SETTINGS |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 572 | CHART(">eeprom_settings_init"); |
Miika Pekkarinen | 3b52bb9 | 2006-08-11 10:13:16 +0000 | [diff] [blame] | 573 | eeprom_settings_init(); |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 574 | CHART("<eeprom_settings_init"); |
Miika Pekkarinen | 3b52bb9 | 2006-08-11 10:13:16 +0000 | [diff] [blame] | 575 | #endif |
Peter D'Hoye | 3c1e9ca | 2008-09-07 20:09:11 +0000 | [diff] [blame] | 576 | |
Frank Gevaerts | c483efa | 2009-05-21 19:01:07 +0000 | [diff] [blame] | 577 | #ifndef HAVE_USBSTACK |
Michael Sevakis | da76a34 | 2009-01-22 22:05:04 +0000 | [diff] [blame] | 578 | usb_start_monitoring(); |
Dave Chapman | 1672350 | 2007-09-04 08:03:07 +0000 | [diff] [blame] | 579 | while (usb_detect() == USB_INSERTED) |
Peter D'Hoye | 3c1e9ca | 2008-09-07 20:09:11 +0000 | [diff] [blame] | 580 | { |
Peter D'Hoye | c4a59a2 | 2006-08-15 22:54:06 +0000 | [diff] [blame] | 581 | #ifdef HAVE_EEPROM_SETTINGS |
Miika Pekkarinen | 3b52bb9 | 2006-08-11 10:13:16 +0000 | [diff] [blame] | 582 | firmware_settings.disk_clean = false; |
| 583 | #endif |
| 584 | /* enter USB mode early, before trying to mount */ |
Jens Arnold | 27abc2a | 2005-05-17 22:10:51 +0000 | [diff] [blame] | 585 | if (button_get_w_tmo(HZ/10) == SYS_USB_CONNECTED) |
Frank Gevaerts | 19d1cac | 2008-10-31 21:25:04 +0000 | [diff] [blame] | 586 | #if (CONFIG_STORAGE & STORAGE_MMC) |
Michael Sevakis | 1167e3c | 2007-06-30 02:08:27 +0000 | [diff] [blame] | 587 | if (!mmc_touched() || |
| 588 | (mmc_remove_request() == SYS_HOTSWAP_EXTRACTED)) |
Linus Nielsen Feltzing | 15124aa | 2004-07-05 22:13:20 +0000 | [diff] [blame] | 589 | #endif |
Jens Arnold | 27abc2a | 2005-05-17 22:10:51 +0000 | [diff] [blame] | 590 | { |
Frank Gevaerts | c8c40c5 | 2010-10-10 13:17:39 +0000 | [diff] [blame] | 591 | gui_usb_screen_run(true); |
Jens Arnold | 27abc2a | 2005-05-17 22:10:51 +0000 | [diff] [blame] | 592 | mounted = true; /* mounting done @ end of USB mode */ |
| 593 | } |
Jens Arnold | 97a8049 | 2005-06-23 02:18:29 +0000 | [diff] [blame] | 594 | #ifdef HAVE_USB_POWER |
Amaury Pouly | dc127f2 | 2015-01-02 22:15:31 +0100 | [diff] [blame] | 595 | /* if there is no host or user requested no USB, skip this */ |
| 596 | if (usb_powered_only()) |
Jens Arnold | 97a8049 | 2005-06-23 02:18:29 +0000 | [diff] [blame] | 597 | break; |
| 598 | #endif |
Jens Arnold | 27abc2a | 2005-05-17 22:10:51 +0000 | [diff] [blame] | 599 | } |
Frank Gevaerts | 6f05899 | 2008-03-10 19:11:37 +0000 | [diff] [blame] | 600 | #endif |
Linus Nielsen Feltzing | 55e9670 | 2005-12-06 10:06:40 +0000 | [diff] [blame] | 601 | |
Jens Arnold | 27abc2a | 2005-05-17 22:10:51 +0000 | [diff] [blame] | 602 | if (!mounted) |
| 603 | { |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 604 | CHART(">disk_mount_all"); |
Jens Arnold | 27abc2a | 2005-05-17 22:10:51 +0000 | [diff] [blame] | 605 | rc = disk_mount_all(); |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 606 | CHART("<disk_mount_all"); |
Jens Arnold | 27abc2a | 2005-05-17 22:10:51 +0000 | [diff] [blame] | 607 | if (rc<=0) |
| 608 | { |
| 609 | lcd_clear_display(); |
| 610 | lcd_puts(0, 0, "No partition"); |
| 611 | lcd_puts(0, 1, "found."); |
| 612 | #ifdef HAVE_LCD_BITMAP |
| 613 | lcd_puts(0, 2, "Insert USB cable"); |
| 614 | lcd_puts(0, 3, "and fix it."); |
Jens Arnold | 27abc2a | 2005-05-17 22:10:51 +0000 | [diff] [blame] | 615 | #endif |
Jens Arnold | f9b90e9 | 2007-04-06 22:55:00 +0000 | [diff] [blame] | 616 | lcd_update(); |
| 617 | |
Jens Arnold | 27abc2a | 2005-05-17 22:10:51 +0000 | [diff] [blame] | 618 | while(button_get(true) != SYS_USB_CONNECTED) {}; |
Frank Gevaerts | c8c40c5 | 2010-10-10 13:17:39 +0000 | [diff] [blame] | 619 | gui_usb_screen_run(true); |
Jens Arnold | 27abc2a | 2005-05-17 22:10:51 +0000 | [diff] [blame] | 620 | system_reboot(); |
| 621 | } |
Linus Nielsen Feltzing | 15124aa | 2004-07-05 22:13:20 +0000 | [diff] [blame] | 622 | } |
Björn Stenberg | de943a5 | 2002-07-15 15:06:45 +0000 | [diff] [blame] | 623 | |
Michael Sevakis | c9bcbe2 | 2012-03-27 19:52:15 -0400 | [diff] [blame] | 624 | #if CONFIG_CODEC == SWCODEC |
Michael Sevakis | 5857c44 | 2013-05-31 02:41:02 -0400 | [diff] [blame] | 625 | pcm_init(); |
Michael Sevakis | c9bcbe2 | 2012-03-27 19:52:15 -0400 | [diff] [blame] | 626 | dsp_init(); |
| 627 | #endif |
| 628 | |
Marcoen Hirschberg | d2d695f | 2006-12-31 02:02:03 +0000 | [diff] [blame] | 629 | #if defined(SETTINGS_RESET) || (CONFIG_KEYPAD == IPOD_4G_PAD) || \ |
Marcoen Hirschberg | 810f717 | 2007-04-27 19:24:31 +0000 | [diff] [blame] | 630 | (CONFIG_KEYPAD == IRIVER_H10_PAD) |
Miika Pekkarinen | 8e8c1a8 | 2005-12-07 12:35:54 +0000 | [diff] [blame] | 631 | #ifdef SETTINGS_RESET |
Marcoen Hirschberg | 810f717 | 2007-04-27 19:24:31 +0000 | [diff] [blame] | 632 | /* Reset settings if holding the reset button. (Rec on Archos, |
| 633 | A on Gigabeat) */ |
Miika Pekkarinen | 8e8c1a8 | 2005-12-07 12:35:54 +0000 | [diff] [blame] | 634 | if ((button_status() & SETTINGS_RESET) == SETTINGS_RESET) |
Dave Chapman | 1272c8a | 2006-02-24 12:37:50 +0000 | [diff] [blame] | 635 | #else |
| 636 | /* Reset settings if the hold button is turned on */ |
| 637 | if (button_hold()) |
| 638 | #endif |
Miika Pekkarinen | a697717 | 2005-12-07 11:20:56 +0000 | [diff] [blame] | 639 | { |
Nils Wallménius | 01729e7 | 2008-08-15 08:27:39 +0000 | [diff] [blame] | 640 | splash(HZ*2, str(LANG_RESET_DONE_CLEAR)); |
Miika Pekkarinen | a697717 | 2005-12-07 11:20:56 +0000 | [diff] [blame] | 641 | settings_reset(); |
| 642 | } |
| 643 | else |
Miika Pekkarinen | 8e8c1a8 | 2005-12-07 12:35:54 +0000 | [diff] [blame] | 644 | #endif |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 645 | { |
| 646 | CHART(">settings_load(ALL)"); |
Miika Pekkarinen | a697717 | 2005-12-07 11:20:56 +0000 | [diff] [blame] | 647 | settings_load(SETTINGS_ALL); |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 648 | CHART("<settings_load(ALL)"); |
| 649 | } |
Miika Pekkarinen | 8e8c1a8 | 2005-12-07 12:35:54 +0000 | [diff] [blame] | 650 | |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 651 | #ifdef HAVE_DIRCACHE |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 652 | CHART(">init_dircache(true)"); |
| 653 | rc = init_dircache(true); |
Torne Wuff | 59463ba | 2010-04-06 23:07:18 +0000 | [diff] [blame] | 654 | CHART("<init_dircache(true)"); |
Jonathan Gordon | 710ccb7 | 2006-10-25 10:17:57 +0000 | [diff] [blame] | 655 | #ifdef HAVE_TAGCACHE |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 656 | if (rc < 0) |
Miika Pekkarinen | 69cdc75 | 2006-08-12 14:40:38 +0000 | [diff] [blame] | 657 | remove(TAGCACHE_STATEFILE); |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 658 | #endif /* HAVE_TAGCACHE */ |
| 659 | #endif /* HAVE_DIRCACHE */ |
Peter D'Hoye | 3c1e9ca | 2008-09-07 20:09:11 +0000 | [diff] [blame] | 660 | |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 661 | CHART(">settings_apply(true)"); |
Michael Sevakis | ffa8626 | 2013-07-12 12:03:20 -0400 | [diff] [blame] | 662 | settings_apply(true); |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 663 | CHART("<settings_apply(true)"); |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 664 | #ifdef HAVE_DIRCACHE |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 665 | CHART(">init_dircache(false)"); |
Miika Pekkarinen | 69cdc75 | 2006-08-12 14:40:38 +0000 | [diff] [blame] | 666 | init_dircache(false); |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 667 | CHART("<init_dircache(false)"); |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 668 | #endif |
Jonathan Gordon | 710ccb7 | 2006-10-25 10:17:57 +0000 | [diff] [blame] | 669 | #ifdef HAVE_TAGCACHE |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 670 | CHART(">init_tagcache"); |
Miika Pekkarinen | 1b18dd0 | 2006-04-12 10:31:24 +0000 | [diff] [blame] | 671 | init_tagcache(); |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 672 | CHART("<init_tagcache"); |
Jonathan Gordon | 710ccb7 | 2006-10-25 10:17:57 +0000 | [diff] [blame] | 673 | #endif |
Jens Arnold | c12e87d | 2004-09-28 18:09:10 +0000 | [diff] [blame] | 674 | |
Peter D'Hoye | c4a59a2 | 2006-08-15 22:54:06 +0000 | [diff] [blame] | 675 | #ifdef HAVE_EEPROM_SETTINGS |
Miika Pekkarinen | 954b732 | 2006-08-05 20:19:10 +0000 | [diff] [blame] | 676 | if (firmware_settings.initialized) |
| 677 | { |
| 678 | /* In case we crash. */ |
| 679 | firmware_settings.disk_clean = false; |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 680 | CHART(">eeprom_settings_store"); |
Miika Pekkarinen | 954b732 | 2006-08-05 20:19:10 +0000 | [diff] [blame] | 681 | eeprom_settings_store(); |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 682 | CHART("<eeprom_settings_store"); |
Miika Pekkarinen | 954b732 | 2006-08-05 20:19:10 +0000 | [diff] [blame] | 683 | } |
| 684 | #endif |
Jens Arnold | 3605600 | 2004-09-29 21:41:10 +0000 | [diff] [blame] | 685 | playlist_init(); |
Jonathan Gordon | 2cda994 | 2007-06-10 10:41:27 +0000 | [diff] [blame] | 686 | tree_mem_init(); |
Jonathan Gordon | 21165a3 | 2007-03-29 06:16:00 +0000 | [diff] [blame] | 687 | filetype_init(); |
Michael Sevakis | 023f6b6 | 2013-07-12 12:06:38 -0400 | [diff] [blame] | 688 | |
| 689 | if (global_settings.audioscrobbler) |
| 690 | scrobbler_init(); |
| 691 | |
Jonathan Gordon | 101693f | 2011-11-15 13:22:02 +0000 | [diff] [blame] | 692 | shortcuts_init(); |
Linus Nielsen Feltzing | da153da | 2006-10-19 09:42:58 +0000 | [diff] [blame] | 693 | |
Michael Sevakis | 98cd3e8 | 2007-03-09 12:30:14 +0000 | [diff] [blame] | 694 | #if CONFIG_CODEC != SWCODEC |
Linus Nielsen Feltzing | 67bea32 | 2003-05-17 20:38:38 +0000 | [diff] [blame] | 695 | /* No buffer allocation (see buffer.c) may take place after the call to |
Linus Nielsen Feltzing | 8a237a8 | 2005-04-04 12:06:29 +0000 | [diff] [blame] | 696 | audio_init() since the mpeg thread takes the rest of the buffer space */ |
Jörg Hohensohn | f993365 | 2004-01-05 20:42:51 +0000 | [diff] [blame] | 697 | mp3_init( global_settings.volume, |
| 698 | global_settings.bass, |
| 699 | global_settings.treble, |
| 700 | global_settings.balance, |
| 701 | global_settings.loudness, |
Jörg Hohensohn | f993365 | 2004-01-05 20:42:51 +0000 | [diff] [blame] | 702 | global_settings.avc, |
Linus Nielsen Feltzing | 7bade1a | 2004-07-06 12:17:14 +0000 | [diff] [blame] | 703 | global_settings.channel_config, |
Jens Arnold | 76b257f | 2005-01-12 00:24:15 +0000 | [diff] [blame] | 704 | global_settings.stereo_width, |
Linus Nielsen Feltzing | 7bade1a | 2004-07-06 12:17:14 +0000 | [diff] [blame] | 705 | global_settings.mdb_strength, |
| 706 | global_settings.mdb_harmonics, |
| 707 | global_settings.mdb_center, |
| 708 | global_settings.mdb_shape, |
| 709 | global_settings.mdb_enable, |
| 710 | global_settings.superbass); |
Michael Sevakis | 98cd3e8 | 2007-03-09 12:30:14 +0000 | [diff] [blame] | 711 | #endif /* CONFIG_CODEC != SWCODEC */ |
Peter D'Hoye | 6488177 | 2006-05-01 12:54:21 +0000 | [diff] [blame] | 712 | |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 713 | CHART(">audio_init"); |
Magnus Holmgren | 62634a3 | 2005-10-16 08:01:02 +0000 | [diff] [blame] | 714 | audio_init(); |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 715 | CHART("<audio_init"); |
Michael Sevakis | 98cd3e8 | 2007-03-09 12:30:14 +0000 | [diff] [blame] | 716 | |
Michiel Van Der Kolk | d6ab723 | 2005-07-04 22:10:42 +0000 | [diff] [blame] | 717 | /* runtime database has to be initialized after audio_init() */ |
Miika Pekkarinen | 86d0d91 | 2006-12-05 20:20:00 +0000 | [diff] [blame] | 718 | cpu_boost(false); |
Linus Nielsen Feltzing | 67bea32 | 2003-05-17 20:38:38 +0000 | [diff] [blame] | 719 | |
Jonathan Gordon | 9a6f419 | 2007-02-18 05:32:06 +0000 | [diff] [blame] | 720 | #if CONFIG_CHARGING |
Linus Nielsen Feltzing | 3d21781 | 2005-04-06 11:12:22 +0000 | [diff] [blame] | 721 | car_adapter_mode_init(); |
| 722 | #endif |
Michael Giacomelli | 70e9c7a | 2008-12-25 01:46:16 +0000 | [diff] [blame] | 723 | #ifdef IPOD_ACCESSORY_PROTOCOL |
| 724 | iap_setup(global_settings.serial_bitrate); |
| 725 | #endif |
Andree Buschmann | 850a112 | 2008-04-20 18:28:25 +0000 | [diff] [blame] | 726 | #ifdef HAVE_ACCESSORY_SUPPLY |
| 727 | accessory_supply_set(global_settings.accessory_supply); |
| 728 | #endif |
Andree Buschmann | b6c12a1 | 2010-03-20 15:02:29 +0000 | [diff] [blame] | 729 | #ifdef HAVE_LINEOUT_POWEROFF |
| 730 | lineout_set(global_settings.lineout_active); |
| 731 | #endif |
Thomas Martitz | cfda097 | 2009-11-25 22:54:36 +0000 | [diff] [blame] | 732 | #ifdef HAVE_HOTSWAP_STORAGE_AS_MAIN |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 733 | CHART("<check_bootfile(false)"); |
Thomas Martitz | cfda097 | 2009-11-25 22:54:36 +0000 | [diff] [blame] | 734 | check_bootfile(false); /* remember write time and filesize */ |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 735 | CHART(">check_bootfile(false)"); |
Thomas Martitz | cfda097 | 2009-11-25 22:54:36 +0000 | [diff] [blame] | 736 | #endif |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 737 | CHART("<settings_apply_skins"); |
Jonathan Gordon | 4c6b355 | 2010-02-26 08:01:41 +0000 | [diff] [blame] | 738 | settings_apply_skins(); |
Torne Wuff | 52e528e | 2010-04-01 16:27:21 +0000 | [diff] [blame] | 739 | CHART(">settings_apply_skins"); |
Björn Stenberg | e324db6 | 2002-05-17 19:50:37 +0000 | [diff] [blame] | 740 | } |
| 741 | |
Daniel Ankers | 28575f6 | 2006-08-03 16:38:06 +0000 | [diff] [blame] | 742 | #ifdef CPU_PP |
Thomas Martitz | 0e2286f | 2010-08-12 13:38:25 +0000 | [diff] [blame] | 743 | void cop_main(void) MAIN_NORETURN_ATTR; |
| 744 | void cop_main(void) |
Daniel Ankers | cec7cdc | 2006-08-03 16:29:42 +0000 | [diff] [blame] | 745 | { |
| 746 | /* This is the entry point for the coprocessor |
| 747 | Anyone not running an upgraded bootloader will never reach this point, |
| 748 | so it should not be assumed that the coprocessor be usable even on |
| 749 | platforms which support it. |
| 750 | |
Michael Sevakis | 7914e90 | 2007-09-28 10:20:02 +0000 | [diff] [blame] | 751 | A kernel thread is initially setup on the coprocessor and immediately |
| 752 | destroyed for purposes of continuity. The cop sits idle until at least |
| 753 | one thread exists on it. */ |
Daniel Ankers | b856636 | 2007-02-27 22:55:12 +0000 | [diff] [blame] | 754 | |
Michael Sevakis | 7914e90 | 2007-09-28 10:20:02 +0000 | [diff] [blame] | 755 | #if NUM_CORES > 1 |
| 756 | system_init(); |
| 757 | kernel_init(); |
| 758 | /* This should never be reached */ |
| 759 | #endif |
Daniel Ankers | cc5de0e | 2007-02-27 23:21:38 +0000 | [diff] [blame] | 760 | while(1) { |
Jens Arnold | cea07eb | 2008-04-20 17:53:05 +0000 | [diff] [blame] | 761 | sleep_core(COP); |
Daniel Ankers | cc5de0e | 2007-02-27 23:21:38 +0000 | [diff] [blame] | 762 | } |
Daniel Ankers | cec7cdc | 2006-08-03 16:29:42 +0000 | [diff] [blame] | 763 | } |
Daniel Ankers | cc5de0e | 2007-02-27 23:21:38 +0000 | [diff] [blame] | 764 | #endif /* CPU_PP */ |
Daniel Ankers | cec7cdc | 2006-08-03 16:29:42 +0000 | [diff] [blame] | 765 | |
Michael Sevakis | 2b640ba | 2010-06-17 20:15:58 +0000 | [diff] [blame] | 766 | #endif /* SIMULATOR */ |