blob: 7d9d859681684f9ed9d7c3317d7580ea97b7dd99 [file] [log] [blame]
Björn Stenberg82182852002-05-16 12:53:40 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
Nicolas Pennequin357ffb32008-05-05 10:32:46 +000010 * Copyright (C) 2002 Björn Stenberg
Björn Stenberg82182852002-05-16 12:53:40 +000011 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * 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 Stenberg82182852002-05-16 12:53:40 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
Linus Nielsen Feltzing688b4dd2004-10-15 02:16:31 +000021#include "config.h"
Michael Sevakis7d1a47c2013-08-05 22:02:45 -040022#include "system.h"
Linus Nielsen Feltzing688b4dd2004-10-15 02:16:31 +000023
Thomas Martitz0e2286f2010-08-12 13:38:25 +000024#include "gcc_extensions.h"
Frank Gevaerts2f8a0082008-11-01 16:14:28 +000025#include "storage.h"
Björn Stenberge324db62002-05-17 19:50:37 +000026#include "disk.h"
Michael Sevakis7d1a47c2013-08-05 22:02:45 -040027#include "file_internal.h"
Björn Stenberge324db62002-05-17 19:50:37 +000028#include "lcd.h"
Linus Nielsen Feltzing9b3a3be2002-06-24 13:51:40 +000029#include "rtc.h"
Björn Stenberge324db62002-05-17 19:50:37 +000030#include "debug.h"
31#include "led.h"
Michael Sevakis981d0282014-08-08 01:39:29 -040032#include "../kernel-internal.h"
Björn Stenberge324db62002-05-17 19:50:37 +000033#include "button.h"
Björn Stenberg82182852002-05-16 12:53:40 +000034#include "tree.h"
Jonathan Gordon21165a32007-03-29 06:16:00 +000035#include "filetypes.h"
Björn Stenberg55c7da22002-05-21 14:28:10 +000036#include "panic.h"
37#include "menu.h"
Linus Nielsen Feltzing6c77cc32002-06-30 13:24:29 +000038#include "usb.h"
Heikki Hannikainen6eb42542002-08-06 10:52:51 +000039#include "powermgmt.h"
Udo Schläpferdbabd0d2015-02-02 21:44:29 +010040#if !defined(DX50) && !defined(DX90)
Linus Nielsen Feltzing7d3c31b2002-06-30 20:25:37 +000041#include "adc.h"
Udo Schläpferdbabd0d2015-02-02 21:44:29 +010042#endif
Linus Nielsen Feltzing6d2e4922002-07-02 21:40:12 +000043#include "i2c.h"
Björn Stenberg18239b82002-08-12 12:44:18 +000044#ifndef DEBUG
45#include "serial.h"
46#endif
Linus Nielsen Feltzing8a237a82005-04-04 12:06:29 +000047#include "audio.h"
Jörg Hohensohnf9933652004-01-05 20:42:51 +000048#include "mp3_playback.h"
Linus Nielsen Feltzing31e20972002-06-20 08:59:54 +000049#include "settings.h"
Linus Nielsen Feltzing9b3a3be2002-06-24 13:51:40 +000050#include "backlight.h"
Linus Nielsen Feltzing97f94b42002-07-22 22:44:03 +000051#include "status.h"
Björn Stenberg6b25f792002-07-15 11:02:12 +000052#include "debug_menu.h"
Daniel Stenberg93b231c2002-09-12 13:33:59 +000053#include "font.h"
Daniel Stenberg5b662ff2002-09-25 11:42:10 +000054#include "language.h"
Jonathan Gordon3e7444f2009-08-03 04:43:34 +000055#include "wps.h"
Björn Stenberg7bb746b2003-04-24 17:31:36 +000056#include "playlist.h"
Thomas Martitzd0b72e22011-08-30 14:01:33 +000057#include "core_alloc.h"
Jörg Hohensohnc47f8c02003-07-03 22:13:39 +000058#include "rolo.h"
Tomer Shalev09de5972009-10-19 21:34:27 +000059#include "screens.h"
Tomer Shalev5d585f42009-10-19 21:19:30 +000060#include "usb_screen.h"
Jörg Hohensohn5dd17b12003-07-17 20:29:51 +000061#include "power.h"
Jörg Hohensohn4f36ea82004-03-14 21:33:53 +000062#include "talk.h"
Jörg Hohensohn6ff6d212004-06-19 15:50:02 +000063#include "plugin.h"
Linus Nielsen Feltzing3d217812005-04-06 11:12:22 +000064#include "misc.h"
Miika Pekkarinenab78b042005-10-07 17:38:05 +000065#include "dircache.h"
Jonathan Gordon710ccb72006-10-25 10:17:57 +000066#ifdef HAVE_TAGCACHE
Miika Pekkarinen7c4e0c82006-03-26 11:33:42 +000067#include "tagcache.h"
Miika Pekkarinen4a63c092006-04-04 19:28:13 +000068#include "tagtree.h"
Jonathan Gordon710ccb72006-10-25 10:17:57 +000069#endif
Miika Pekkarinenab78b042005-10-07 17:38:05 +000070#include "lang.h"
71#include "string.h"
Miika Pekkarinena6977172005-12-07 11:20:56 +000072#include "splash.h"
Miika Pekkarinen954b7322006-08-05 20:19:10 +000073#include "eeprom_settings.h"
Linus Nielsen Feltzingda153da2006-10-19 09:42:58 +000074#include "scrobbler.h"
Jonathan Gordon6a5cc0b2007-04-16 09:14:36 +000075#include "icon.h"
Thomas Martitz4c48b592009-08-16 22:20:11 +000076#include "viewport.h"
Jonathan Gordon71379ca2010-09-14 12:21:56 +000077#include "skin_engine/skin_engine.h"
Thomas Martitz1016ee42009-10-19 15:28:15 +000078#include "statusbar-skinned.h"
Torne Wuff52e528e2010-04-01 16:27:21 +000079#include "bootchart.h"
Michael Giacomellid46b0902012-07-03 21:45:29 -040080#include "logdiskf.h"
Dave Chapman793eab12011-02-28 12:05:22 +000081#if (CONFIG_PLATFORM & PLATFORM_ANDROID)
Thomas Martitzf5a461d2010-12-10 18:41:09 +000082#include "notification.h"
83#endif
Jonathan Gordon101693f2011-11-15 13:22:02 +000084#include "shortcuts.h"
Michiel Van Der Kolk451dd482005-03-28 00:00:24 +000085
Michael Giacomelli70e9c7a2008-12-25 01:46:16 +000086#ifdef IPOD_ACCESSORY_PROTOCOL
87#include "iap.h"
88#endif
89
Jens Arnoldd6c05452005-08-29 21:15:27 +000090#if (CONFIG_CODEC == SWCODEC)
Michael Sevakis5857c442013-05-31 02:41:02 -040091#include "audio_thread.h"
Miika Pekkarinend3191162006-01-27 11:39:46 +000092#include "playback.h"
Steve Bavine8c825f2009-06-15 16:03:01 +000093#include "tdspeed.h"
Henrik Backec1a951f2005-03-28 13:00:22 +000094#endif
Linus Nielsen Feltzinged4d7a32006-07-21 08:42:28 +000095#if (CONFIG_CODEC == SWCODEC) && defined(HAVE_RECORDING) && !defined(SIMULATOR)
Andye5d08722005-06-19 03:05:53 +000096#include "pcm_record.h"
Barry Wardelldf0dc222006-12-18 01:52:21 +000097#endif
98
99#ifdef BUTTON_REC
Marcoen Hirschberg810f7172007-04-27 19:24:31 +0000100 #define SETTINGS_RESET BUTTON_REC
101#elif (CONFIG_KEYPAD == GIGABEAT_PAD)
102 #define SETTINGS_RESET BUTTON_A
Andye5d08722005-06-19 03:05:53 +0000103#endif
Michiel Van Der Kolk451dd482005-03-28 00:00:24 +0000104
Jonathan Gordon8ff3a652007-02-18 02:04:47 +0000105#if CONFIG_TUNER
Jörg Hohensohn8f8fbac2004-10-15 21:41:46 +0000106#include "radio.h"
Jörg Hohensohn4a5df8e2004-10-15 22:10:55 +0000107#endif
Frank Gevaerts19d1cac2008-10-31 21:25:04 +0000108#if (CONFIG_STORAGE & STORAGE_MMC)
Jörg Hohensohnda848572004-12-28 22:16:07 +0000109#include "ata_mmc.h"
110#endif
Jörg Hohensohn6ff6d212004-06-19 15:50:02 +0000111
Christian Gmeiner7c1879b2005-04-15 12:08:49 +0000112#ifdef HAVE_REMOTE_LCD
113#include "lcd-remote.h"
114#endif
115
Jonathan Gordonac619512007-02-18 04:57:28 +0000116#if CONFIG_USBOTG == USBOTG_ISP1362
Jens Arnold977169e2006-06-16 17:34:18 +0000117#include "isp1362.h"
118#endif
119
Jonathan Gordonac619512007-02-18 04:57:28 +0000120#if CONFIG_USBOTG == USBOTG_M5636
Linus Nielsen Feltzing5f655c92006-07-13 07:40:30 +0000121#include "m5636.h"
122#endif
123
Jonathan Gordonbe716c02011-11-16 10:25:43 +0000124#ifdef HAVE_HARDWARE_CLICK
125#include "piezo.h"
126#endif
127
Thomas Martitz0e2286f2010-08-12 13:38:25 +0000128#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 Jarosch6e9e6a72011-02-27 23:42:37 +0000136#if (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA))
Thomas Martitz71d73fd2011-11-17 19:52:59 +0000137#ifdef SIMULATOR
Thomas Martitzc00fbc42010-09-01 22:09:43 +0000138#include "sim_tasks.h"
Thomas Martitz71d73fd2011-11-17 19:52:59 +0000139#endif
Michael Sevakisd6af2872007-10-26 23:11:18 +0000140#include "system-sdl.h"
Thomas Martitz0e2286f2010-08-12 13:38:25 +0000141#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 Sevakisd6af2872007-10-26 23:11:18 +0000146#endif
147
Jörg Hohensohn6ff6d212004-06-19 15:50:02 +0000148/*#define AUTOROCK*/ /* define this to check for "autostart.rock" on boot */
Björn Stenberg18239b82002-08-12 12:44:18 +0000149
Jens Arnold314f3b52006-12-12 22:22:21 +0000150static void init(void);
Thomas Martitza62eced2010-03-04 17:44:57 +0000151/* 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 Martitz0e2286f2010-08-12 13:38:25 +0000155#ifdef HAVE_ARGV_MAIN
156int main(int argc, char *argv[]) INIT_ATTR MAIN_NORETURN_ATTR ;
157int main(int argc, char *argv[])
158{
159 sys_handle_argv(argc, argv);
160#else
161int main(void) INIT_ATTR MAIN_NORETURN_ATTR;
Rafaël Carrébb9808b2009-11-03 12:20:54 +0000162int main(void)
Björn Stenberg55c7da22002-05-21 14:28:10 +0000163{
Thomas Martitz3d0cee82010-05-15 21:02:47 +0000164#endif
Torne Wuff52e528e2010-04-01 16:27:21 +0000165 CHART(">init");
Björn Stenbergad9829a2002-06-10 12:42:23 +0000166 init();
Torne Wuff52e528e2010-04-01 16:27:21 +0000167 CHART("<init");
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000168 FOR_NB_SCREENS(i)
169 {
170 screens[i].clear_display();
171 screens[i].update();
172 }
Thomas Martitz2eb1cb62009-09-07 17:37:06 +0000173#ifdef HAVE_LCD_BITMAP
174 list_init();
175#endif
Jonathan Gordon2cda9942007-06-10 10:41:27 +0000176 tree_gui_init();
Thomas Martitzc5b44822009-11-10 20:13:24 +0000177 /* Keep the order of this 3
178 * Must be done before any code uses the multi-screen API */
Frank Gevaertsc483efa2009-05-21 19:01:07 +0000179#ifdef HAVE_USBSTACK
180 /* All threads should be created and public queues registered by now */
181 usb_start_monitoring();
182#endif
Teruaki Kawashimaed940e82009-08-27 13:30:26 +0000183
184#ifdef AUTOROCK
185 {
Thomas Martitz9c0b2472010-08-01 16:15:27 +0000186 char filename[MAX_PATH];
Michael Sevakisffa86262013-07-12 12:03:20 -0400187 const char *file =
Thomas Martitz9c0b2472010-08-01 16:15:27 +0000188#ifdef APPLICATION
189 ROCKBOX_DIR
190#else
191 PLUGIN_APPS_DIR
192#endif
Thomas Martitz2c241602010-12-06 22:26:31 +0000193 "/autostart.rock";
Thomas Martitz9c0b2472010-08-01 16:15:27 +0000194 if(file_exists(file)) /* no complaint if it doesn't exist */
Teruaki Kawashimaed940e82009-08-27 13:30:26 +0000195 {
Thomas Martitz9c0b2472010-08-01 16:15:27 +0000196 plugin_load(file, NULL); /* start if it does */
Teruaki Kawashimaed940e82009-08-27 13:30:26 +0000197 }
198 }
199#endif /* #ifdef AUTOROCK */
200
Jonathan Gordon235d1ae2009-11-01 02:36:51 +0000201 global_status.last_volume_change = 0;
Thomas Martitza62eced2010-03-04 17:44:57 +0000202 /* no calls INIT_ATTR functions after this point anymore!
203 * see definition of INIT_ATTR in config.h */
Torne Wuff52e528e2010-04-01 16:27:21 +0000204 CHART(">root_menu");
Jonathan Gordon2cda9942007-06-10 10:41:27 +0000205 root_menu();
Björn Stenberg55c7da22002-05-21 14:28:10 +0000206}
207
Miika Pekkarinen954b7322006-08-05 20:19:10 +0000208#ifdef HAVE_DIRCACHE
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400209static int INIT_ATTR init_dircache(bool preinit)
210{
Miika Pekkarinen69cdc752006-08-12 14:40:38 +0000211 if (preinit)
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400212 dircache_init(MAX(global_status.dircache_size, 0));
Michael Sevakisffa86262013-07-12 12:03:20 -0400213
Miika Pekkarinenc8a9ca72006-12-22 09:11:09 +0000214 if (!global_settings.dircache)
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400215 return -1;
Michael Sevakisffa86262013-07-12 12:03:20 -0400216
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400217 int result = -1;
218
219#ifdef HAVE_EEPROM_SETTINGS
220 if (firmware_settings.initialized &&
221 firmware_settings.disk_clean &&
222 preinit)
Miika Pekkarinenc8a9ca72006-12-22 09:11:09 +0000223 {
224 result = dircache_load();
Miika Pekkarinenc8a9ca72006-12-22 09:11:09 +0000225 if (result < 0)
Miika Pekkarinenc8a9ca72006-12-22 09:11:09 +0000226 firmware_settings.disk_clean = false;
Miika Pekkarinenc8a9ca72006-12-22 09:11:09 +0000227 }
228 else
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400229#endif /* HAVE_EEPROM_SETTINGS */
230 if (!preinit)
Miika Pekkarinenc8a9ca72006-12-22 09:11:09 +0000231 {
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400232 result = dircache_enable();
233 if (result != 0)
Miika Pekkarinen69cdc752006-08-12 14:40:38 +0000234 {
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400235 if (result > 0)
Miika Pekkarinen69cdc752006-08-12 14:40:38 +0000236 {
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400237 /* Print "Scanning disk..." to the display. */
Nils Wallménius01729e72008-08-15 08:27:39 +0000238 splash(0, str(LANG_SCANNING_DISK));
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400239 dircache_wait();
240 backlight_on();
241 show_logo();
Miika Pekkarinen69cdc752006-08-12 14:40:38 +0000242 }
Michael Sevakisffa86262013-07-12 12:03:20 -0400243
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400244 struct dircache_info info;
245 dircache_get_info(&info);
246 global_status.dircache_size = info.size;
247 status_save();
Miika Pekkarinen7b1e8272007-04-07 17:48:51 +0000248 }
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400249 /* else don't wait or already enabled by load */
Miika Pekkarinenab78b042005-10-07 17:38:05 +0000250 }
Michael Sevakisffa86262013-07-12 12:03:20 -0400251
Miika Pekkarinen954b7322006-08-05 20:19:10 +0000252 return result;
Miika Pekkarinen954b7322006-08-05 20:19:10 +0000253}
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400254#endif /* HAVE_DIRCACHE */
Miika Pekkarinenab78b042005-10-07 17:38:05 +0000255
Jonathan Gordon710ccb72006-10-25 10:17:57 +0000256#ifdef HAVE_TAGCACHE
Thomas Martitzf8edc322010-03-03 23:20:32 +0000257static void init_tagcache(void) INIT_ATTR;
Jens Arnold314f3b52006-12-12 22:22:21 +0000258static void init_tagcache(void)
Miika Pekkarinen7c4e0c82006-03-26 11:33:42 +0000259{
Jens Arnoldb09df802006-05-24 07:31:23 +0000260 bool clear = false;
Michael Sevakisba8e4362012-05-30 18:42:16 -0400261#if 0 /* CONFIG_CODEC == SWCODEC */
Nils Wallménius18cf68e2009-10-25 10:20:15 +0000262 long talked_tick = 0;
263#endif
Miika Pekkarinen7c4e0c82006-03-26 11:33:42 +0000264 tagcache_init();
Michael Sevakisffa86262013-07-12 12:03:20 -0400265
Miika Pekkarinen1b18dd02006-04-12 10:31:24 +0000266 while (!tagcache_is_initialized())
267 {
Jens Arnoldb09df802006-05-24 07:31:23 +0000268 int ret = tagcache_get_commit_step();
269
Miika Pekkarinen1b18dd02006-04-12 10:31:24 +0000270 if (ret > 0)
271 {
Michael Sevakisba8e4362012-05-30 18:42:16 -0400272#if 0 /* FIXME: Audio isn't even initialized yet! */ /* CONFIG_CODEC == SWCODEC */
Jens Arnold916a5632007-08-28 18:08:48 +0000273 /* hwcodec can't use voice here, as the database commit
274 * uses the audio buffer. */
Steve Bavin32a95752007-10-19 15:31:42 +0000275 if(global_settings.talk_menu
Nils Wallménius5b769362007-08-06 13:08:36 +0000276 && (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 Arnold916a5632007-08-28 18:08:48 +0000285#endif
Jens Arnoldb09df802006-05-24 07:31:23 +0000286#ifdef HAVE_LCD_BITMAP
Tomer Shalevd7cdd082009-10-08 22:40:38 +0000287 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 Arnoldb09df802006-05-24 07:31:23 +0000297#else
298 lcd_double_height(false);
Michael Sevakisffa86262013-07-12 12:03:20 -0400299 lcd_putsf(0, 1, " DB [%d/%d]", ret,
Steve Bavin81374892007-03-07 19:56:15 +0000300 tagcache_get_max_commit_step());
Jens Arnold900ced22007-05-17 06:37:25 +0000301 lcd_update();
Miika Pekkarinen1b18dd02006-04-12 10:31:24 +0000302#endif
Jens Arnoldb09df802006-05-24 07:31:23 +0000303 clear = true;
304 }
Miika Pekkarinen1b18dd02006-04-12 10:31:24 +0000305 sleep(HZ/4);
306 }
Miika Pekkarinen4a63c092006-04-04 19:28:13 +0000307 tagtree_init();
Miika Pekkarinen7c4e0c82006-03-26 11:33:42 +0000308
Jens Arnoldb09df802006-05-24 07:31:23 +0000309 if (clear)
Miika Pekkarinen196b7702006-05-27 11:21:08 +0000310 {
311 backlight_on();
Jens Arnoldb09df802006-05-24 07:31:23 +0000312 show_logo();
Miika Pekkarinen196b7702006-05-27 11:21:08 +0000313 }
Miika Pekkarinen7c4e0c82006-03-26 11:33:42 +0000314}
Jonathan Gordon710ccb72006-10-25 10:17:57 +0000315#endif
Miika Pekkarinen7c4e0c82006-03-26 11:33:42 +0000316
Thomas Martitz35e8b142010-06-21 16:53:00 +0000317#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
Björn Stenbergad9829a2002-06-10 12:42:23 +0000318
Jens Arnold314f3b52006-12-12 22:22:21 +0000319static void init(void)
Björn Stenbergad9829a2002-06-10 12:42:23 +0000320{
Thomas Martitzf5a461d2010-12-10 18:41:09 +0000321 system_init();
Thomas Martitzd0b72e22011-08-30 14:01:33 +0000322 core_allocator_init();
Thomas Martitzf5a461d2010-12-10 18:41:09 +0000323 kernel_init();
Thomas Martitz0e2286f2010-08-12 13:38:25 +0000324#ifdef APPLICATION
325 paths_init();
326#endif
Michael Sevakisaf395f42008-03-26 01:50:41 +0000327 enable_irq();
Björn Stenbergad9829a2002-06-10 12:42:23 +0000328 lcd_init();
Jens Arnold3a5bd7a2005-07-07 21:03:58 +0000329#ifdef HAVE_REMOTE_LCD
330 lcd_remote_init();
331#endif
Jonathan Gordonaa0f4a42011-09-24 13:19:34 +0000332#ifdef HAVE_LCD_BITMAP
333 FOR_NB_SCREENS(i)
334 global_status.font_id[i] = FONT_SYSFIXED;
Kjell Ericsonfd9f8642002-10-28 19:52:22 +0000335 font_init();
Jonathan Gordonaa0f4a42011-09-24 13:19:34 +0000336#endif
Björn Stenbergad9829a2002-06-10 12:42:23 +0000337 show_logo();
Marcin Bukat76925582018-03-13 21:24:56 +0100338#ifndef USB_NONE
339 usb_init();
340 usb_start_monitoring();
341#endif
Jens Arnoldb51f7df2005-11-21 23:55:39 +0000342 button_init();
Thomas Jarosch15a35802011-03-02 19:12:55 +0000343 powermgmt_init();
Jens Arnoldb51f7df2005-11-21 23:55:39 +0000344 backlight_init();
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400345 unicode_init();
Thomas Martitz71d73fd2011-11-17 19:52:59 +0000346#ifdef SIMULATOR
Jens Arnold3e67e3b2009-02-20 17:13:08 +0000347 sim_tasks_init();
Thomas Martitzc00fbc42010-09-01 22:09:43 +0000348#endif
Udo Schläpferdbabd0d2015-02-02 21:44:29 +0100349#if (CONFIG_PLATFORM & PLATFORM_ANDROID)
Thomas Martitzf5a461d2010-12-10 18:41:09 +0000350 notification_init();
351#endif
Michael Sevakisffa86262013-07-12 12:03:20 -0400352 lang_init(core_language_builtin, language_strings,
Tom Rossec2737b2009-10-18 00:56:42 +0000353 LANG_LAST_INDEX_IN_ARRAY);
Jens Arnold2fd7c3c2007-04-19 20:17:24 +0000354#ifdef DEBUG
355 debug_init();
356#endif
Thomas Martitza5b0a1d2012-04-10 10:34:36 +0200357#if CONFIG_TUNER
358 radio_init();
359#endif
Thomas Martitzc5b44822009-11-10 20:13:24 +0000360 /* Keep the order of this 3 (viewportmanager handles statusbars)
361 * Must be done before any code uses the multi-screen API */
Jens Arnoldbaef5362009-10-03 22:09:27 +0000362 gui_syncstatusbar_init(&statusbars);
Jonathan Gordon9928e342010-09-14 11:56:50 +0000363 gui_sync_skin_init();
Thomas Martitzc5b44822009-11-10 20:13:24 +0000364 sb_skin_init();
365 viewportmanager_init();
366
Frank Gevaerts2f8a0082008-11-01 16:14:28 +0000367 storage_init();
Michael Sevakisc9bcbe22012-03-27 19:52:15 -0400368#if CONFIG_CODEC == SWCODEC
Michael Sevakis5857c442013-05-31 02:41:02 -0400369 pcm_init();
Michael Sevakisc9bcbe22012-03-27 19:52:15 -0400370 dsp_init();
371#endif
Björn Stenberg6b25f792002-07-15 11:02:12 +0000372 settings_reset();
Jörg Hohensohn6ff6d212004-06-19 15:50:02 +0000373 settings_load(SETTINGS_ALL);
Jonathan Gordon792f7332010-03-07 03:20:34 +0000374 settings_apply(true);
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400375#ifdef HAVE_DIRCACHE
Miika Pekkarinen69cdc752006-08-12 14:40:38 +0000376 init_dircache(true);
377 init_dircache(false);
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400378#endif
Jonathan Gordon710ccb72006-10-25 10:17:57 +0000379#ifdef HAVE_TAGCACHE
Miika Pekkarinen7c4e0c82006-03-26 11:33:42 +0000380 init_tagcache();
Jonathan Gordon710ccb72006-10-25 10:17:57 +0000381#endif
Jonathan Gordon2cda9942007-06-10 10:41:27 +0000382 tree_mem_init();
Jonathan Gordon21165a32007-03-29 06:16:00 +0000383 filetype_init();
Linus Nielsen Feltzingfe6cf2d2003-05-17 22:25:52 +0000384 playlist_init();
Jonathan Gordon101693f2011-11-15 13:22:02 +0000385 shortcuts_init();
Michael Sevakis98cd3e82007-03-09 12:30:14 +0000386
387#if CONFIG_CODEC != SWCODEC
Jörg Hohensohnf9933652004-01-05 20:42:51 +0000388 mp3_init( global_settings.volume,
389 global_settings.bass,
390 global_settings.treble,
391 global_settings.balance,
392 global_settings.loudness,
Jörg Hohensohnf9933652004-01-05 20:42:51 +0000393 global_settings.avc,
Linus Nielsen Feltzing7bade1a2004-07-06 12:17:14 +0000394 global_settings.channel_config,
Jens Arnold76b257f2005-01-12 00:24:15 +0000395 global_settings.stereo_width,
Linus Nielsen Feltzing7bade1a2004-07-06 12:17:14 +0000396 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 Sevakis98cd3e82007-03-09 12:30:14 +0000402#endif /* CONFIG_CODEC != SWCODEC */
403
Michael Sevakis023f6b62013-07-12 12:06:38 -0400404 if (global_settings.audioscrobbler)
405 scrobbler_init();
Nicolas Pennequin9f4bd872007-02-14 14:40:24 +0000406
Peter D'Hoye64881772006-05-01 12:54:21 +0000407 audio_init();
Thomas Martitzd3c21022011-10-26 18:28:45 +0000408
Jonathan Gordon4c6b3552010-02-26 08:01:41 +0000409 settings_apply_skins();
Björn Stenbergad9829a2002-06-10 12:42:23 +0000410}
411
412#else
Björn Stenberg88f7fb02002-05-24 15:40:14 +0000413
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400414#include "errno.h"
415
Thomas Martitzf8edc322010-03-03 23:20:32 +0000416static void init(void) INIT_ATTR;
Jens Arnold314f3b52006-12-12 22:22:21 +0000417static void init(void)
Björn Stenberge324db62002-05-17 19:50:37 +0000418{
Jörg Hohensohn7ee03d02004-12-29 22:33:32 +0000419 int rc;
Jens Arnold27abc2a2005-05-17 22:10:51 +0000420 bool mounted = false;
Jonathan Gordon9a6f4192007-02-18 05:32:06 +0000421#if CONFIG_CHARGING && (CONFIG_CPU == SH7034)
Jörg Hohensohn5dd17b12003-07-17 20:29:51 +0000422 /* if nobody initialized ATA before, I consider this a cold start */
423 bool coldstart = (PACR2 & 0x4000) != 0; /* starting from Flash */
Daniel Stenberg8ef88a12005-02-03 08:36:43 +0000424#endif
Michael Sevakis7914e902007-09-28 10:20:02 +0000425
Linus Nielsen Feltzing0f607752002-05-29 09:14:38 +0000426 system_init();
Thomas Martitzd0b72e22011-08-30 14:01:33 +0000427 core_allocator_init();
Linus Nielsen Feltzing8c00b4c2002-06-10 14:44:15 +0000428 kernel_init();
Linus Nielsen Feltzing31e20972002-06-20 08:59:54 +0000429
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400430 /* early early early! */
431 filesystem_init();
432
Linus Nielsen Feltzinge7b993f2005-03-18 11:38:15 +0000433#ifdef HAVE_ADJUSTABLE_CPU_FREQ
434 set_cpu_frequency(CPUFREQ_NORMAL);
Michael Sevakis0f5cb942006-11-06 18:07:30 +0000435#ifdef CPU_COLDFIRE
436 coldfire_set_pllcr_audio_bits(DEFAULT_PLLCR_AUDIO_BITS);
437#endif
Miika Pekkarinen86d0d912006-12-05 20:20:00 +0000438 cpu_boost(true);
Linus Nielsen Feltzinge7b993f2005-03-18 11:38:15 +0000439#endif
Jonathan Gordonf7c29782011-09-25 12:55:40 +0000440
Michael Giacomelli054447f2008-02-10 05:39:20 +0000441 i2c_init();
Michael Sevakisffa86262013-07-12 12:03:20 -0400442
Linus Nielsen Feltzinge16ebf12005-11-18 14:55:51 +0000443 power_init();
444
Michael Sevakisaf395f42008-03-26 01:50:41 +0000445 enable_irq();
Michael Sevakis6077e5b2007-10-06 22:27:27 +0000446#ifdef CPU_ARM
Michael Sevakisaf395f42008-03-26 01:50:41 +0000447 enable_fiq();
Michael Sevakis6077e5b2007-10-06 22:27:27 +0000448#endif
Torne Wuff52e528e2010-04-01 16:27:21 +0000449 /* current_tick should be ticking by now */
450 CHART("ticking");
451
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400452 unicode_init();
Björn Stenberg4afa7092002-05-30 12:17:18 +0000453 lcd_init();
Jens Arnold3a5bd7a2005-07-07 21:03:58 +0000454#ifdef HAVE_REMOTE_LCD
Christian Gmeiner7c1879b2005-04-15 12:08:49 +0000455 lcd_remote_init();
456#endif
Jonathan Gordonaa0f4a42011-09-24 13:19:34 +0000457#ifdef HAVE_LCD_BITMAP
Björn Stenberg0942e2a2011-10-15 19:35:02 +0000458 FOR_NB_SCREENS(i)
459 global_status.font_id[i] = FONT_SYSFIXED;
Björn Stenbergbed3d3f2002-09-20 08:07:51 +0000460 font_init();
Jonathan Gordonaa0f4a42011-09-24 13:19:34 +0000461#endif
Michael Sevakisffa86262013-07-12 12:03:20 -0400462
Fred Bauera1d3a1d2011-09-27 21:06:12 +0000463 settings_reset();
Karl Kurbjun8a1fd8c2007-04-21 04:48:20 +0000464
Torne Wuff52e528e2010-04-01 16:27:21 +0000465 CHART(">show_logo");
Linus Nielsen Feltzing219944f2005-11-08 23:51:36 +0000466 show_logo();
Torne Wuff52e528e2010-04-01 16:27:21 +0000467 CHART("<show_logo");
Michael Sevakisffa86262013-07-12 12:03:20 -0400468 lang_init(core_language_builtin, language_strings,
Tom Rossec2737b2009-10-18 00:56:42 +0000469 LANG_LAST_INDEX_IN_ARRAY);
Daniel Stenberg75e09a82002-06-11 08:24:33 +0000470
Björn Stenbergf43b27a2002-05-27 09:53:28 +0000471#ifdef DEBUG
Björn Stenberge324db62002-05-17 19:50:37 +0000472 debug_init();
Björn Stenberg18239b82002-08-12 12:44:18 +0000473#else
Bertrik Sikken3c7e2992009-02-07 11:15:30 +0000474#ifdef HAVE_SERIAL
Björn Stenberg18239b82002-08-12 12:44:18 +0000475 serial_setup();
Björn Stenbergf43b27a2002-05-27 09:53:28 +0000476#endif
Jens Arnold2d875f82004-09-20 22:15:35 +0000477#endif
Björn Stenberge324db62002-05-17 19:50:37 +0000478
Jens Arnold2c7b1272007-03-16 23:47:03 +0000479#if CONFIG_RTC
Linus Nielsen Feltzing76759e02002-08-06 08:14:08 +0000480 rtc_init();
Dave Chapman5009c9c2005-12-04 13:05:56 +0000481#endif
482#ifdef HAVE_RTC_RAM
Torne Wuff52e528e2010-04-01 16:27:21 +0000483 CHART(">settings_load(RTC)");
Jörg Hohensohn6ff6d212004-06-19 15:50:02 +0000484 settings_load(SETTINGS_RTC); /* early load parts of global_settings */
Torne Wuff52e528e2010-04-01 16:27:21 +0000485 CHART("<settings_load(RTC)");
Linus Nielsen Feltzing76759e02002-08-06 08:14:08 +0000486#endif
487
Linus Nielsen Feltzing7d3c31b2002-06-30 20:25:37 +0000488 adc_init();
Christian Gmeiner8181a0c2007-08-27 16:04:32 +0000489
Linus Nielsen Feltzing219944f2005-11-08 23:51:36 +0000490 usb_init();
Jonathan Gordonac619512007-02-18 04:57:28 +0000491#if CONFIG_USBOTG == USBOTG_ISP1362
Jens Arnold977169e2006-06-16 17:34:18 +0000492 isp1362_init();
Jonathan Gordonac619512007-02-18 04:57:28 +0000493#elif CONFIG_USBOTG == USBOTG_M5636
Linus Nielsen Feltzing5f655c92006-07-13 07:40:30 +0000494 m5636_init();
Jens Arnold977169e2006-06-16 17:34:18 +0000495#endif
Linus Nielsen Feltzinge16ebf12005-11-18 14:55:51 +0000496
Linus Nielsen Feltzinga844a182007-03-07 14:49:20 +0000497 backlight_init();
498
Björn Stenberge324db62002-05-17 19:50:37 +0000499 button_init();
Linus Nielsen Feltzing4b545592002-07-02 17:59:10 +0000500
Boris Gjenero5cd8aec2011-12-31 18:31:47 +0000501 /* 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 Feltzing219944f2005-11-08 23:51:36 +0000505 powermgmt_init();
Boris Gjenero5cd8aec2011-12-31 18:31:47 +0000506#endif
Peter D'Hoye3c1e9ca2008-09-07 20:09:11 +0000507
Jonathan Gordon8ff3a652007-02-18 02:04:47 +0000508#if CONFIG_TUNER
Linus Nielsen Feltzing219944f2005-11-08 23:51:36 +0000509 radio_init();
Jörg Hohensohnef8d5082004-10-19 08:20:38 +0000510#endif
511
Jonathan Gordonbe716c02011-11-16 10:25:43 +0000512#ifdef HAVE_HARDWARE_CLICK
513 piezo_init();
514#endif
515
Thomas Martitzc5b44822009-11-10 20:13:24 +0000516 /* Keep the order of this 3 (viewportmanager handles statusbars)
517 * Must be done before any code uses the multi-screen API */
Torne Wuff52e528e2010-04-01 16:27:21 +0000518 CHART(">gui_syncstatusbar_init");
Jens Arnoldbaef5362009-10-03 22:09:27 +0000519 gui_syncstatusbar_init(&statusbars);
Torne Wuff52e528e2010-04-01 16:27:21 +0000520 CHART("<gui_syncstatusbar_init");
521 CHART(">sb_skin_init");
Thomas Martitzc5b44822009-11-10 20:13:24 +0000522 sb_skin_init();
Torne Wuff52e528e2010-04-01 16:27:21 +0000523 CHART("<sb_skin_init");
524 CHART(">gui_sync_wps_init");
Jonathan Gordon9928e342010-09-14 11:56:50 +0000525 gui_sync_skin_init();
Torne Wuff52e528e2010-04-01 16:27:21 +0000526 CHART("<gui_sync_wps_init");
527 CHART(">viewportmanager_init");
Thomas Martitzc5b44822009-11-10 20:13:24 +0000528 viewportmanager_init();
Torne Wuff52e528e2010-04-01 16:27:21 +0000529 CHART("<viewportmanager_init");
Thomas Martitzc5b44822009-11-10 20:13:24 +0000530
Jonathan Gordon9a6f4192007-02-18 05:32:06 +0000531#if CONFIG_CHARGING && (CONFIG_CPU == SH7034)
Boris Gjenero02b9c652009-04-06 01:47:28 +0000532 /* 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 Arnold7197edd2004-12-16 22:31:26 +0000535 && !global_settings.car_adapter_mode
536#ifdef ATA_POWER_PLAYERSTYLE
537 && !ide_powered() /* relies on probing result from bootloader */
538#endif
539 )
Jörg Hohensohn5dd17b12003-07-17 20:29:51 +0000540 {
541 rc = charging_screen(); /* display a "charging" screen */
Jens Arnold7c7dd432005-07-11 19:14:26 +0000542 if (rc == 1) /* charger removed */
Jörg Hohensohn5dd17b12003-07-17 20:29:51 +0000543 power_off();
544 /* "On" pressed or USB connected: proceed */
Jens Arnold67b17e12004-11-21 09:29:51 +0000545 show_logo(); /* again, to provide better visual feedback */
Jörg Hohensohn5dd17b12003-07-17 20:29:51 +0000546 }
Daniel Stenberg8e43ccb2003-12-12 13:34:27 +0000547#endif
Jörg Hohensohnc47f8c02003-07-03 22:13:39 +0000548
Torne Wuff52e528e2010-04-01 16:27:21 +0000549 CHART(">storage_init");
Frank Gevaerts2f8a0082008-11-01 16:14:28 +0000550 rc = storage_init();
Torne Wuff52e528e2010-04-01 16:27:21 +0000551 CHART("<storage_init");
Linus Nielsen Feltzing71ef31a2002-07-02 18:01:31 +0000552 if(rc)
Linus Nielsen Feltzing4b545592002-07-02 17:59:10 +0000553 {
Björn Stenbergb47e64e2002-08-08 20:44:25 +0000554#ifdef HAVE_LCD_BITMAP
Linus Nielsen Feltzing4b545592002-07-02 17:59:10 +0000555 lcd_clear_display();
Nils Wallméniusf34a8412009-10-17 18:02:48 +0000556 lcd_putsf(0, 1, "ATA error: %d", rc);
Linus Nielsen Feltzing4b545592002-07-02 17:59:10 +0000557 lcd_puts(0, 3, "Press ON to debug");
558 lcd_update();
Michael Sparmann886e9722011-01-02 22:22:51 +0000559 while(!(button_get(true) & BUTTON_REL)); /* DO NOT CHANGE TO ACTION SYSTEM */
Linus Nielsen Feltzing4b545592002-07-02 17:59:10 +0000560 dbg_ports();
561#endif
562 panicf("ata: %d", rc);
563 }
Jens Arnold2d875f82004-09-20 22:15:35 +0000564
Boris Gjenero5cd8aec2011-12-31 18:31:47 +0000565#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'Hoyec4a59a22006-08-15 22:54:06 +0000571#ifdef HAVE_EEPROM_SETTINGS
Torne Wuff52e528e2010-04-01 16:27:21 +0000572 CHART(">eeprom_settings_init");
Miika Pekkarinen3b52bb92006-08-11 10:13:16 +0000573 eeprom_settings_init();
Torne Wuff52e528e2010-04-01 16:27:21 +0000574 CHART("<eeprom_settings_init");
Miika Pekkarinen3b52bb92006-08-11 10:13:16 +0000575#endif
Peter D'Hoye3c1e9ca2008-09-07 20:09:11 +0000576
Frank Gevaertsc483efa2009-05-21 19:01:07 +0000577#ifndef HAVE_USBSTACK
Michael Sevakisda76a342009-01-22 22:05:04 +0000578 usb_start_monitoring();
Dave Chapman16723502007-09-04 08:03:07 +0000579 while (usb_detect() == USB_INSERTED)
Peter D'Hoye3c1e9ca2008-09-07 20:09:11 +0000580 {
Peter D'Hoyec4a59a22006-08-15 22:54:06 +0000581#ifdef HAVE_EEPROM_SETTINGS
Miika Pekkarinen3b52bb92006-08-11 10:13:16 +0000582 firmware_settings.disk_clean = false;
583#endif
584 /* enter USB mode early, before trying to mount */
Jens Arnold27abc2a2005-05-17 22:10:51 +0000585 if (button_get_w_tmo(HZ/10) == SYS_USB_CONNECTED)
Frank Gevaerts19d1cac2008-10-31 21:25:04 +0000586#if (CONFIG_STORAGE & STORAGE_MMC)
Michael Sevakis1167e3c2007-06-30 02:08:27 +0000587 if (!mmc_touched() ||
588 (mmc_remove_request() == SYS_HOTSWAP_EXTRACTED))
Linus Nielsen Feltzing15124aa2004-07-05 22:13:20 +0000589#endif
Jens Arnold27abc2a2005-05-17 22:10:51 +0000590 {
Frank Gevaertsc8c40c52010-10-10 13:17:39 +0000591 gui_usb_screen_run(true);
Jens Arnold27abc2a2005-05-17 22:10:51 +0000592 mounted = true; /* mounting done @ end of USB mode */
593 }
Jens Arnold97a80492005-06-23 02:18:29 +0000594#ifdef HAVE_USB_POWER
Amaury Poulydc127f22015-01-02 22:15:31 +0100595 /* if there is no host or user requested no USB, skip this */
596 if (usb_powered_only())
Jens Arnold97a80492005-06-23 02:18:29 +0000597 break;
598#endif
Jens Arnold27abc2a2005-05-17 22:10:51 +0000599 }
Frank Gevaerts6f058992008-03-10 19:11:37 +0000600#endif
Linus Nielsen Feltzing55e96702005-12-06 10:06:40 +0000601
Jens Arnold27abc2a2005-05-17 22:10:51 +0000602 if (!mounted)
603 {
Torne Wuff52e528e2010-04-01 16:27:21 +0000604 CHART(">disk_mount_all");
Jens Arnold27abc2a2005-05-17 22:10:51 +0000605 rc = disk_mount_all();
Torne Wuff52e528e2010-04-01 16:27:21 +0000606 CHART("<disk_mount_all");
Jens Arnold27abc2a2005-05-17 22:10:51 +0000607 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 Arnold27abc2a2005-05-17 22:10:51 +0000615#endif
Jens Arnoldf9b90e92007-04-06 22:55:00 +0000616 lcd_update();
617
Jens Arnold27abc2a2005-05-17 22:10:51 +0000618 while(button_get(true) != SYS_USB_CONNECTED) {};
Frank Gevaertsc8c40c52010-10-10 13:17:39 +0000619 gui_usb_screen_run(true);
Jens Arnold27abc2a2005-05-17 22:10:51 +0000620 system_reboot();
621 }
Linus Nielsen Feltzing15124aa2004-07-05 22:13:20 +0000622 }
Björn Stenbergde943a52002-07-15 15:06:45 +0000623
Michael Sevakisc9bcbe22012-03-27 19:52:15 -0400624#if CONFIG_CODEC == SWCODEC
Michael Sevakis5857c442013-05-31 02:41:02 -0400625 pcm_init();
Michael Sevakisc9bcbe22012-03-27 19:52:15 -0400626 dsp_init();
627#endif
628
Marcoen Hirschbergd2d695f2006-12-31 02:02:03 +0000629#if defined(SETTINGS_RESET) || (CONFIG_KEYPAD == IPOD_4G_PAD) || \
Marcoen Hirschberg810f7172007-04-27 19:24:31 +0000630 (CONFIG_KEYPAD == IRIVER_H10_PAD)
Miika Pekkarinen8e8c1a82005-12-07 12:35:54 +0000631#ifdef SETTINGS_RESET
Marcoen Hirschberg810f7172007-04-27 19:24:31 +0000632 /* Reset settings if holding the reset button. (Rec on Archos,
633 A on Gigabeat) */
Miika Pekkarinen8e8c1a82005-12-07 12:35:54 +0000634 if ((button_status() & SETTINGS_RESET) == SETTINGS_RESET)
Dave Chapman1272c8a2006-02-24 12:37:50 +0000635#else
636 /* Reset settings if the hold button is turned on */
637 if (button_hold())
638#endif
Miika Pekkarinena6977172005-12-07 11:20:56 +0000639 {
Nils Wallménius01729e72008-08-15 08:27:39 +0000640 splash(HZ*2, str(LANG_RESET_DONE_CLEAR));
Miika Pekkarinena6977172005-12-07 11:20:56 +0000641 settings_reset();
642 }
643 else
Miika Pekkarinen8e8c1a82005-12-07 12:35:54 +0000644#endif
Torne Wuff52e528e2010-04-01 16:27:21 +0000645 {
646 CHART(">settings_load(ALL)");
Miika Pekkarinena6977172005-12-07 11:20:56 +0000647 settings_load(SETTINGS_ALL);
Torne Wuff52e528e2010-04-01 16:27:21 +0000648 CHART("<settings_load(ALL)");
649 }
Miika Pekkarinen8e8c1a82005-12-07 12:35:54 +0000650
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400651#ifdef HAVE_DIRCACHE
Torne Wuff52e528e2010-04-01 16:27:21 +0000652 CHART(">init_dircache(true)");
653 rc = init_dircache(true);
Torne Wuff59463ba2010-04-06 23:07:18 +0000654 CHART("<init_dircache(true)");
Jonathan Gordon710ccb72006-10-25 10:17:57 +0000655#ifdef HAVE_TAGCACHE
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400656 if (rc < 0)
Miika Pekkarinen69cdc752006-08-12 14:40:38 +0000657 remove(TAGCACHE_STATEFILE);
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400658#endif /* HAVE_TAGCACHE */
659#endif /* HAVE_DIRCACHE */
Peter D'Hoye3c1e9ca2008-09-07 20:09:11 +0000660
Torne Wuff52e528e2010-04-01 16:27:21 +0000661 CHART(">settings_apply(true)");
Michael Sevakisffa86262013-07-12 12:03:20 -0400662 settings_apply(true);
Torne Wuff52e528e2010-04-01 16:27:21 +0000663 CHART("<settings_apply(true)");
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400664#ifdef HAVE_DIRCACHE
Torne Wuff52e528e2010-04-01 16:27:21 +0000665 CHART(">init_dircache(false)");
Miika Pekkarinen69cdc752006-08-12 14:40:38 +0000666 init_dircache(false);
Torne Wuff52e528e2010-04-01 16:27:21 +0000667 CHART("<init_dircache(false)");
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400668#endif
Jonathan Gordon710ccb72006-10-25 10:17:57 +0000669#ifdef HAVE_TAGCACHE
Torne Wuff52e528e2010-04-01 16:27:21 +0000670 CHART(">init_tagcache");
Miika Pekkarinen1b18dd02006-04-12 10:31:24 +0000671 init_tagcache();
Torne Wuff52e528e2010-04-01 16:27:21 +0000672 CHART("<init_tagcache");
Jonathan Gordon710ccb72006-10-25 10:17:57 +0000673#endif
Jens Arnoldc12e87d2004-09-28 18:09:10 +0000674
Peter D'Hoyec4a59a22006-08-15 22:54:06 +0000675#ifdef HAVE_EEPROM_SETTINGS
Miika Pekkarinen954b7322006-08-05 20:19:10 +0000676 if (firmware_settings.initialized)
677 {
678 /* In case we crash. */
679 firmware_settings.disk_clean = false;
Torne Wuff52e528e2010-04-01 16:27:21 +0000680 CHART(">eeprom_settings_store");
Miika Pekkarinen954b7322006-08-05 20:19:10 +0000681 eeprom_settings_store();
Torne Wuff52e528e2010-04-01 16:27:21 +0000682 CHART("<eeprom_settings_store");
Miika Pekkarinen954b7322006-08-05 20:19:10 +0000683 }
684#endif
Jens Arnold36056002004-09-29 21:41:10 +0000685 playlist_init();
Jonathan Gordon2cda9942007-06-10 10:41:27 +0000686 tree_mem_init();
Jonathan Gordon21165a32007-03-29 06:16:00 +0000687 filetype_init();
Michael Sevakis023f6b62013-07-12 12:06:38 -0400688
689 if (global_settings.audioscrobbler)
690 scrobbler_init();
691
Jonathan Gordon101693f2011-11-15 13:22:02 +0000692 shortcuts_init();
Linus Nielsen Feltzingda153da2006-10-19 09:42:58 +0000693
Michael Sevakis98cd3e82007-03-09 12:30:14 +0000694#if CONFIG_CODEC != SWCODEC
Linus Nielsen Feltzing67bea322003-05-17 20:38:38 +0000695 /* No buffer allocation (see buffer.c) may take place after the call to
Linus Nielsen Feltzing8a237a82005-04-04 12:06:29 +0000696 audio_init() since the mpeg thread takes the rest of the buffer space */
Jörg Hohensohnf9933652004-01-05 20:42:51 +0000697 mp3_init( global_settings.volume,
698 global_settings.bass,
699 global_settings.treble,
700 global_settings.balance,
701 global_settings.loudness,
Jörg Hohensohnf9933652004-01-05 20:42:51 +0000702 global_settings.avc,
Linus Nielsen Feltzing7bade1a2004-07-06 12:17:14 +0000703 global_settings.channel_config,
Jens Arnold76b257f2005-01-12 00:24:15 +0000704 global_settings.stereo_width,
Linus Nielsen Feltzing7bade1a2004-07-06 12:17:14 +0000705 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 Sevakis98cd3e82007-03-09 12:30:14 +0000711#endif /* CONFIG_CODEC != SWCODEC */
Peter D'Hoye64881772006-05-01 12:54:21 +0000712
Torne Wuff52e528e2010-04-01 16:27:21 +0000713 CHART(">audio_init");
Magnus Holmgren62634a32005-10-16 08:01:02 +0000714 audio_init();
Torne Wuff52e528e2010-04-01 16:27:21 +0000715 CHART("<audio_init");
Michael Sevakis98cd3e82007-03-09 12:30:14 +0000716
Michiel Van Der Kolkd6ab7232005-07-04 22:10:42 +0000717 /* runtime database has to be initialized after audio_init() */
Miika Pekkarinen86d0d912006-12-05 20:20:00 +0000718 cpu_boost(false);
Linus Nielsen Feltzing67bea322003-05-17 20:38:38 +0000719
Jonathan Gordon9a6f4192007-02-18 05:32:06 +0000720#if CONFIG_CHARGING
Linus Nielsen Feltzing3d217812005-04-06 11:12:22 +0000721 car_adapter_mode_init();
722#endif
Michael Giacomelli70e9c7a2008-12-25 01:46:16 +0000723#ifdef IPOD_ACCESSORY_PROTOCOL
724 iap_setup(global_settings.serial_bitrate);
725#endif
Andree Buschmann850a1122008-04-20 18:28:25 +0000726#ifdef HAVE_ACCESSORY_SUPPLY
727 accessory_supply_set(global_settings.accessory_supply);
728#endif
Andree Buschmannb6c12a12010-03-20 15:02:29 +0000729#ifdef HAVE_LINEOUT_POWEROFF
730 lineout_set(global_settings.lineout_active);
731#endif
Thomas Martitzcfda0972009-11-25 22:54:36 +0000732#ifdef HAVE_HOTSWAP_STORAGE_AS_MAIN
Torne Wuff52e528e2010-04-01 16:27:21 +0000733 CHART("<check_bootfile(false)");
Thomas Martitzcfda0972009-11-25 22:54:36 +0000734 check_bootfile(false); /* remember write time and filesize */
Torne Wuff52e528e2010-04-01 16:27:21 +0000735 CHART(">check_bootfile(false)");
Thomas Martitzcfda0972009-11-25 22:54:36 +0000736#endif
Torne Wuff52e528e2010-04-01 16:27:21 +0000737 CHART("<settings_apply_skins");
Jonathan Gordon4c6b3552010-02-26 08:01:41 +0000738 settings_apply_skins();
Torne Wuff52e528e2010-04-01 16:27:21 +0000739 CHART(">settings_apply_skins");
Björn Stenberge324db62002-05-17 19:50:37 +0000740}
741
Daniel Ankers28575f62006-08-03 16:38:06 +0000742#ifdef CPU_PP
Thomas Martitz0e2286f2010-08-12 13:38:25 +0000743void cop_main(void) MAIN_NORETURN_ATTR;
744void cop_main(void)
Daniel Ankerscec7cdc2006-08-03 16:29:42 +0000745{
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 Sevakis7914e902007-09-28 10:20:02 +0000751 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 Ankersb8566362007-02-27 22:55:12 +0000754
Michael Sevakis7914e902007-09-28 10:20:02 +0000755#if NUM_CORES > 1
756 system_init();
757 kernel_init();
758 /* This should never be reached */
759#endif
Daniel Ankerscc5de0e2007-02-27 23:21:38 +0000760 while(1) {
Jens Arnoldcea07eb2008-04-20 17:53:05 +0000761 sleep_core(COP);
Daniel Ankerscc5de0e2007-02-27 23:21:38 +0000762 }
Daniel Ankerscec7cdc2006-08-03 16:29:42 +0000763}
Daniel Ankerscc5de0e2007-02-27 23:21:38 +0000764#endif /* CPU_PP */
Daniel Ankerscec7cdc2006-08-03 16:29:42 +0000765
Michael Sevakis2b640ba2010-06-17 20:15:58 +0000766#endif /* SIMULATOR */