blob: b3252d8bd8d543beca07457e548df00359659704 [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"
22
Frank Gevaerts2f8a0082008-11-01 16:14:28 +000023#include "storage.h"
Björn Stenberge324db62002-05-17 19:50:37 +000024#include "disk.h"
25#include "fat.h"
26#include "lcd.h"
Linus Nielsen Feltzing9b3a3be2002-06-24 13:51:40 +000027#include "rtc.h"
Björn Stenberge324db62002-05-17 19:50:37 +000028#include "debug.h"
29#include "led.h"
30#include "kernel.h"
31#include "button.h"
Björn Stenberg82182852002-05-16 12:53:40 +000032#include "tree.h"
Jonathan Gordon21165a32007-03-29 06:16:00 +000033#include "filetypes.h"
Björn Stenberg55c7da22002-05-21 14:28:10 +000034#include "panic.h"
35#include "menu.h"
Linus Nielsen Feltzing0f607752002-05-29 09:14:38 +000036#include "system.h"
Linus Nielsen Feltzing6c77cc32002-06-30 13:24:29 +000037#include "usb.h"
Heikki Hannikainen6eb42542002-08-06 10:52:51 +000038#include "powermgmt.h"
Linus Nielsen Feltzing7d3c31b2002-06-30 20:25:37 +000039#include "adc.h"
Linus Nielsen Feltzing6d2e4922002-07-02 21:40:12 +000040#include "i2c.h"
Björn Stenberg18239b82002-08-12 12:44:18 +000041#ifndef DEBUG
42#include "serial.h"
43#endif
Linus Nielsen Feltzing8a237a82005-04-04 12:06:29 +000044#include "audio.h"
Jörg Hohensohnf9933652004-01-05 20:42:51 +000045#include "mp3_playback.h"
Felix Arendse096c862002-06-12 15:31:35 +000046#include "thread.h"
Linus Nielsen Feltzing31e20972002-06-20 08:59:54 +000047#include "settings.h"
Linus Nielsen Feltzing9b3a3be2002-06-24 13:51:40 +000048#include "backlight.h"
Linus Nielsen Feltzing97f94b42002-07-22 22:44:03 +000049#include "status.h"
Björn Stenberg6b25f792002-07-15 11:02:12 +000050#include "debug_menu.h"
Daniel Stenberg93b231c2002-09-12 13:33:59 +000051#include "font.h"
Daniel Stenberg5b662ff2002-09-25 11:42:10 +000052#include "language.h"
Jonathan Gordon3e7444f2009-08-03 04:43:34 +000053#include "wps.h"
Björn Stenberg7bb746b2003-04-24 17:31:36 +000054#include "playlist.h"
Linus Nielsen Feltzing20d031f2003-05-09 16:01:21 +000055#include "buffer.h"
Jörg Hohensohnc47f8c02003-07-03 22:13:39 +000056#include "rolo.h"
Tomer Shalev09de5972009-10-19 21:34:27 +000057#include "screens.h"
Tomer Shalev5d585f42009-10-19 21:19:30 +000058#include "usb_screen.h"
Jörg Hohensohn5dd17b12003-07-17 20:29:51 +000059#include "power.h"
Jörg Hohensohn4f36ea82004-03-14 21:33:53 +000060#include "talk.h"
Jörg Hohensohn6ff6d212004-06-19 15:50:02 +000061#include "plugin.h"
Linus Nielsen Feltzing3d217812005-04-06 11:12:22 +000062#include "misc.h"
Miika Pekkarinenab78b042005-10-07 17:38:05 +000063#include "dircache.h"
Jonathan Gordon710ccb72006-10-25 10:17:57 +000064#ifdef HAVE_TAGCACHE
Miika Pekkarinen7c4e0c82006-03-26 11:33:42 +000065#include "tagcache.h"
Miika Pekkarinen4a63c092006-04-04 19:28:13 +000066#include "tagtree.h"
Jonathan Gordon710ccb72006-10-25 10:17:57 +000067#endif
Miika Pekkarinenab78b042005-10-07 17:38:05 +000068#include "lang.h"
69#include "string.h"
Miika Pekkarinena6977172005-12-07 11:20:56 +000070#include "splash.h"
Miika Pekkarinen954b7322006-08-05 20:19:10 +000071#include "eeprom_settings.h"
Linus Nielsen Feltzingda153da2006-10-19 09:42:58 +000072#include "scrobbler.h"
Jonathan Gordon6a5cc0b2007-04-16 09:14:36 +000073#include "icon.h"
Thomas Martitz4c48b592009-08-16 22:20:11 +000074#include "viewport.h"
Thomas Martitz1016ee42009-10-19 15:28:15 +000075#include "statusbar-skinned.h"
Torne Wuff52e528e2010-04-01 16:27:21 +000076#include "bootchart.h"
Michiel Van Der Kolk451dd482005-03-28 00:00:24 +000077
Michael Giacomelli70e9c7a2008-12-25 01:46:16 +000078#ifdef IPOD_ACCESSORY_PROTOCOL
79#include "iap.h"
80#endif
81
Jens Arnoldd6c05452005-08-29 21:15:27 +000082#if (CONFIG_CODEC == SWCODEC)
Miika Pekkarinend3191162006-01-27 11:39:46 +000083#include "playback.h"
Steve Bavine8c825f2009-06-15 16:03:01 +000084#include "tdspeed.h"
Henrik Backec1a951f2005-03-28 13:00:22 +000085#endif
Linus Nielsen Feltzinged4d7a32006-07-21 08:42:28 +000086#if (CONFIG_CODEC == SWCODEC) && defined(HAVE_RECORDING) && !defined(SIMULATOR)
Andye5d08722005-06-19 03:05:53 +000087#include "pcm_record.h"
Barry Wardelldf0dc222006-12-18 01:52:21 +000088#endif
89
90#ifdef BUTTON_REC
Marcoen Hirschberg810f7172007-04-27 19:24:31 +000091 #define SETTINGS_RESET BUTTON_REC
92#elif (CONFIG_KEYPAD == GIGABEAT_PAD)
93 #define SETTINGS_RESET BUTTON_A
Andye5d08722005-06-19 03:05:53 +000094#endif
Michiel Van Der Kolk451dd482005-03-28 00:00:24 +000095
Jonathan Gordon8ff3a652007-02-18 02:04:47 +000096#if CONFIG_TUNER
Jörg Hohensohn8f8fbac2004-10-15 21:41:46 +000097#include "radio.h"
Jörg Hohensohn4a5df8e2004-10-15 22:10:55 +000098#endif
Frank Gevaerts19d1cac2008-10-31 21:25:04 +000099#if (CONFIG_STORAGE & STORAGE_MMC)
Jörg Hohensohnda848572004-12-28 22:16:07 +0000100#include "ata_mmc.h"
101#endif
Jörg Hohensohn6ff6d212004-06-19 15:50:02 +0000102
Christian Gmeiner7c1879b2005-04-15 12:08:49 +0000103#ifdef HAVE_REMOTE_LCD
104#include "lcd-remote.h"
105#endif
106
Jonathan Gordonac619512007-02-18 04:57:28 +0000107#if CONFIG_USBOTG == USBOTG_ISP1362
Jens Arnold977169e2006-06-16 17:34:18 +0000108#include "isp1362.h"
109#endif
110
Jonathan Gordonac619512007-02-18 04:57:28 +0000111#if CONFIG_USBOTG == USBOTG_M5636
Linus Nielsen Feltzing5f655c92006-07-13 07:40:30 +0000112#include "m5636.h"
113#endif
114
Michael Sevakisd6af2872007-10-26 23:11:18 +0000115#ifdef SIMULATOR
Jens Arnold3e67e3b2009-02-20 17:13:08 +0000116#include "sim_tasks.h"
Thomas Martitz35e8b142010-06-21 16:53:00 +0000117#endif
118#ifdef HAVE_SDL
Michael Sevakisd6af2872007-10-26 23:11:18 +0000119#include "system-sdl.h"
120#endif
121
Jörg Hohensohn6ff6d212004-06-19 15:50:02 +0000122/*#define AUTOROCK*/ /* define this to check for "autostart.rock" on boot */
Björn Stenberg18239b82002-08-12 12:44:18 +0000123
Jens Arnold314f3b52006-12-12 22:22:21 +0000124static void init(void);
Teruaki Kawashimaed940e82009-08-27 13:30:26 +0000125
Thomas Martitz3d0cee82010-05-15 21:02:47 +0000126#ifdef HAVE_SDL
127#if defined(WIN32) && defined(main)
128/* Don't use SDL_main on windows -> no more stdio redirection */
129#undef main
130#endif
131int main(int argc, char *argv[])
132{
133 sys_handle_argv(argc, argv);
Jens Arnold314f3b52006-12-12 22:22:21 +0000134#else
Thomas Martitza62eced2010-03-04 17:44:57 +0000135/* main(), and various functions called by main() and init() may be
136 * be INIT_ATTR. These functions must not be called after the final call
137 * to root_menu() at the end of main()
138 * see definition of INIT_ATTR in config.h */
Thomas Martitzf8edc322010-03-03 23:20:32 +0000139int main(void) INIT_ATTR __attribute__((noreturn));
Rafaël Carrébb9808b2009-11-03 12:20:54 +0000140int main(void)
Björn Stenberg55c7da22002-05-21 14:28:10 +0000141{
Thomas Martitz3d0cee82010-05-15 21:02:47 +0000142#endif
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000143 int i;
Torne Wuff52e528e2010-04-01 16:27:21 +0000144 CHART(">init");
Björn Stenbergad9829a2002-06-10 12:42:23 +0000145 init();
Torne Wuff52e528e2010-04-01 16:27:21 +0000146 CHART("<init");
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000147 FOR_NB_SCREENS(i)
148 {
149 screens[i].clear_display();
150 screens[i].update();
151 }
Thomas Martitz2eb1cb62009-09-07 17:37:06 +0000152#ifdef HAVE_LCD_BITMAP
153 list_init();
154#endif
Jonathan Gordon2cda9942007-06-10 10:41:27 +0000155 tree_gui_init();
Thomas Martitzc5b44822009-11-10 20:13:24 +0000156 /* Keep the order of this 3
157 * Must be done before any code uses the multi-screen API */
Frank Gevaertsc483efa2009-05-21 19:01:07 +0000158#ifdef HAVE_USBSTACK
159 /* All threads should be created and public queues registered by now */
160 usb_start_monitoring();
161#endif
Teruaki Kawashimaed940e82009-08-27 13:30:26 +0000162
163#ifdef AUTOROCK
164 {
165 static const char filename[] = PLUGIN_APPS_DIR "/autostart.rock";
166
167 if(file_exists(filename)) /* no complaint if it doesn't exist */
168 {
169 plugin_load((char*)filename, NULL); /* start if it does */
170 }
171 }
172#endif /* #ifdef AUTOROCK */
173
Jonathan Gordon235d1ae2009-11-01 02:36:51 +0000174 global_status.last_volume_change = 0;
Thomas Martitza62eced2010-03-04 17:44:57 +0000175 /* no calls INIT_ATTR functions after this point anymore!
176 * see definition of INIT_ATTR in config.h */
Torne Wuff52e528e2010-04-01 16:27:21 +0000177 CHART(">root_menu");
Jonathan Gordon2cda9942007-06-10 10:41:27 +0000178 root_menu();
Björn Stenberg55c7da22002-05-21 14:28:10 +0000179}
180
Thomas Martitzf8edc322010-03-03 23:20:32 +0000181static int init_dircache(bool preinit) INIT_ATTR;
Jens Arnold314f3b52006-12-12 22:22:21 +0000182static int init_dircache(bool preinit)
Miika Pekkarinenab78b042005-10-07 17:38:05 +0000183{
Miika Pekkarinen954b7322006-08-05 20:19:10 +0000184#ifdef HAVE_DIRCACHE
185 int result = 0;
Miika Pekkarinen69cdc752006-08-12 14:40:38 +0000186 bool clear = false;
Miika Pekkarinenab78b042005-10-07 17:38:05 +0000187
Miika Pekkarinen69cdc752006-08-12 14:40:38 +0000188 if (preinit)
189 dircache_init();
Jens Arnold8c6920e2008-03-08 23:50:55 +0000190
Miika Pekkarinenc8a9ca72006-12-22 09:11:09 +0000191 if (!global_settings.dircache)
192 return 0;
Jens Arnold8c6920e2008-03-08 23:50:55 +0000193
Peter D'Hoyec4a59a22006-08-15 22:54:06 +0000194# ifdef HAVE_EEPROM_SETTINGS
Miika Pekkarinenc8a9ca72006-12-22 09:11:09 +0000195 if (firmware_settings.initialized && firmware_settings.disk_clean
196 && preinit)
197 {
198 result = dircache_load();
Miika Pekkarinen69cdc752006-08-12 14:40:38 +0000199
Miika Pekkarinenc8a9ca72006-12-22 09:11:09 +0000200 if (result < 0)
201 {
202 firmware_settings.disk_clean = false;
Jonathan Gordon228d62d2007-01-24 02:19:22 +0000203 if (global_status.dircache_size <= 0)
Miika Pekkarinenc8a9ca72006-12-22 09:11:09 +0000204 {
205 /* This will be in default language, settings are not
206 applied yet. Not really any easy way to fix that. */
Nils Wallménius01729e72008-08-15 08:27:39 +0000207 splash(0, str(LANG_SCANNING_DISK));
Miika Pekkarinenc8a9ca72006-12-22 09:11:09 +0000208 clear = true;
209 }
210
Jonathan Gordon228d62d2007-01-24 02:19:22 +0000211 dircache_build(global_status.dircache_size);
Miika Pekkarinen196b7702006-05-27 11:21:08 +0000212 }
Miika Pekkarinenc8a9ca72006-12-22 09:11:09 +0000213 }
214 else
Miika Pekkarinen954b7322006-08-05 20:19:10 +0000215# endif
Miika Pekkarinenc8a9ca72006-12-22 09:11:09 +0000216 {
Miika Pekkarinen69cdc752006-08-12 14:40:38 +0000217 if (preinit)
218 return -1;
219
220 if (!dircache_is_enabled()
221 && !dircache_is_initializing())
222 {
Jonathan Gordon228d62d2007-01-24 02:19:22 +0000223 if (global_status.dircache_size <= 0)
Miika Pekkarinen69cdc752006-08-12 14:40:38 +0000224 {
Nils Wallménius01729e72008-08-15 08:27:39 +0000225 splash(0, str(LANG_SCANNING_DISK));
Miika Pekkarinen69cdc752006-08-12 14:40:38 +0000226 clear = true;
227 }
Jonathan Gordon228d62d2007-01-24 02:19:22 +0000228 result = dircache_build(global_status.dircache_size);
Miika Pekkarinen69cdc752006-08-12 14:40:38 +0000229 }
230
231 if (result < 0)
Miika Pekkarinen7b1e8272007-04-07 17:48:51 +0000232 {
233 /* Initialization of dircache failed. Manual action is
234 * necessary to enable dircache again.
235 */
Nils Wallménius01729e72008-08-15 08:27:39 +0000236 splashf(0, "Dircache failed, disabled. Result: %d", result);
Miika Pekkarinen7b1e8272007-04-07 17:48:51 +0000237 global_settings.dircache = false;
238 }
Miika Pekkarinenc8a9ca72006-12-22 09:11:09 +0000239 }
240
241 if (clear)
242 {
243 backlight_on();
244 show_logo();
Jonathan Gordon228d62d2007-01-24 02:19:22 +0000245 global_status.dircache_size = dircache_get_cache_size();
246 status_save();
Miika Pekkarinenab78b042005-10-07 17:38:05 +0000247 }
Miika Pekkarinen954b7322006-08-05 20:19:10 +0000248
249 return result;
Miika Pekkarinenab78b042005-10-07 17:38:05 +0000250#else
Miika Pekkarinen69cdc752006-08-12 14:40:38 +0000251 (void)preinit;
Miika Pekkarinen954b7322006-08-05 20:19:10 +0000252 return 0;
Miika Pekkarinenab78b042005-10-07 17:38:05 +0000253#endif
Miika Pekkarinen954b7322006-08-05 20:19:10 +0000254}
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;
Nils Wallménius18cf68e2009-10-25 10:20:15 +0000261#if CONFIG_CODEC == SWCODEC
262 long talked_tick = 0;
263#endif
Miika Pekkarinen7c4e0c82006-03-26 11:33:42 +0000264 tagcache_init();
Miika Pekkarinen1b18dd02006-04-12 10:31:24 +0000265
266 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 {
Jens Arnold916a5632007-08-28 18:08:48 +0000272#if CONFIG_CODEC == SWCODEC
273 /* 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);
Nils Wallméniusf34a8412009-10-17 18:02:48 +0000299 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 Martitz3d0cee82010-05-15 21:02:47 +0000321 system_init();
Michael Sevakis27cf6772008-03-25 02:34:12 +0000322 kernel_init();
Linus Nielsen Feltzing20d031f2003-05-09 16:01:21 +0000323 buffer_init();
Michael Sevakisaf395f42008-03-26 01:50:41 +0000324 enable_irq();
Björn Stenbergad9829a2002-06-10 12:42:23 +0000325 lcd_init();
Jens Arnold3a5bd7a2005-07-07 21:03:58 +0000326#ifdef HAVE_REMOTE_LCD
327 lcd_remote_init();
328#endif
Kjell Ericsonfd9f8642002-10-28 19:52:22 +0000329 font_init();
Björn Stenbergad9829a2002-06-10 12:42:23 +0000330 show_logo();
Jens Arnoldb51f7df2005-11-21 23:55:39 +0000331 button_init();
332 backlight_init();
Jens Arnold3e67e3b2009-02-20 17:13:08 +0000333 sim_tasks_init();
Tom Rossec2737b2009-10-18 00:56:42 +0000334 lang_init(core_language_builtin, language_strings,
335 LANG_LAST_INDEX_IN_ARRAY);
Jens Arnold2fd7c3c2007-04-19 20:17:24 +0000336#ifdef DEBUG
337 debug_init();
338#endif
Thomas Martitzc5b44822009-11-10 20:13:24 +0000339 /* Keep the order of this 3 (viewportmanager handles statusbars)
340 * Must be done before any code uses the multi-screen API */
Jens Arnoldbaef5362009-10-03 22:09:27 +0000341 gui_syncstatusbar_init(&statusbars);
Thomas Martitzed6c1432010-03-04 01:04:43 +0000342 gui_sync_wps_init();
Thomas Martitzc5b44822009-11-10 20:13:24 +0000343 sb_skin_init();
344 viewportmanager_init();
345
Frank Gevaerts2f8a0082008-11-01 16:14:28 +0000346 storage_init();
Björn Stenberg6b25f792002-07-15 11:02:12 +0000347 settings_reset();
Jörg Hohensohn6ff6d212004-06-19 15:50:02 +0000348 settings_load(SETTINGS_ALL);
Jonathan Gordon792f7332010-03-07 03:20:34 +0000349 settings_apply(true);
Miika Pekkarinen69cdc752006-08-12 14:40:38 +0000350 init_dircache(true);
351 init_dircache(false);
Jonathan Gordon710ccb72006-10-25 10:17:57 +0000352#ifdef HAVE_TAGCACHE
Miika Pekkarinen7c4e0c82006-03-26 11:33:42 +0000353 init_tagcache();
Jonathan Gordon710ccb72006-10-25 10:17:57 +0000354#endif
Björn Stenbergad9829a2002-06-10 12:42:23 +0000355 sleep(HZ/2);
Jonathan Gordon2cda9942007-06-10 10:41:27 +0000356 tree_mem_init();
Jonathan Gordon21165a32007-03-29 06:16:00 +0000357 filetype_init();
Linus Nielsen Feltzingfe6cf2d2003-05-17 22:25:52 +0000358 playlist_init();
Michael Sevakis98cd3e82007-03-09 12:30:14 +0000359
360#if CONFIG_CODEC != SWCODEC
Jörg Hohensohnf9933652004-01-05 20:42:51 +0000361 mp3_init( global_settings.volume,
362 global_settings.bass,
363 global_settings.treble,
364 global_settings.balance,
365 global_settings.loudness,
Jörg Hohensohnf9933652004-01-05 20:42:51 +0000366 global_settings.avc,
Linus Nielsen Feltzing7bade1a2004-07-06 12:17:14 +0000367 global_settings.channel_config,
Jens Arnold76b257f2005-01-12 00:24:15 +0000368 global_settings.stereo_width,
Linus Nielsen Feltzing7bade1a2004-07-06 12:17:14 +0000369 global_settings.mdb_strength,
370 global_settings.mdb_harmonics,
371 global_settings.mdb_center,
372 global_settings.mdb_shape,
373 global_settings.mdb_enable,
374 global_settings.superbass);
Peter D'Hoye64881772006-05-01 12:54:21 +0000375
Michael Sevakis98cd3e82007-03-09 12:30:14 +0000376 /* audio_init must to know the size of voice buffer so init voice first */
377 talk_init();
378#endif /* CONFIG_CODEC != SWCODEC */
379
Linus Nielsen Feltzingda153da2006-10-19 09:42:58 +0000380 scrobbler_init();
Steve Bavin77f6f4c2009-06-15 15:46:09 +0000381#if CONFIG_CODEC == SWCODEC
382 tdspeed_init();
383#endif /* CONFIG_CODEC == SWCODEC */
Nicolas Pennequin9f4bd872007-02-14 14:40:24 +0000384
Peter D'Hoye64881772006-05-01 12:54:21 +0000385 audio_init();
386 button_clear_queue(); /* Empty the keyboard buffer */
Jonathan Gordonb2eb44c2009-12-09 07:25:46 +0000387
Jonathan Gordon4c6b3552010-02-26 08:01:41 +0000388 settings_apply_skins();
Björn Stenbergad9829a2002-06-10 12:42:23 +0000389}
390
391#else
Björn Stenberg88f7fb02002-05-24 15:40:14 +0000392
Thomas Martitzf8edc322010-03-03 23:20:32 +0000393static void init(void) INIT_ATTR;
Jens Arnold314f3b52006-12-12 22:22:21 +0000394static void init(void)
Björn Stenberge324db62002-05-17 19:50:37 +0000395{
Jörg Hohensohn7ee03d02004-12-29 22:33:32 +0000396 int rc;
Jens Arnold27abc2a2005-05-17 22:10:51 +0000397 bool mounted = false;
Jonathan Gordon9a6f4192007-02-18 05:32:06 +0000398#if CONFIG_CHARGING && (CONFIG_CPU == SH7034)
Jörg Hohensohn5dd17b12003-07-17 20:29:51 +0000399 /* if nobody initialized ATA before, I consider this a cold start */
400 bool coldstart = (PACR2 & 0x4000) != 0; /* starting from Flash */
Daniel Stenberg8ef88a12005-02-03 08:36:43 +0000401#endif
Michael Sevakis7914e902007-09-28 10:20:02 +0000402
Linus Nielsen Feltzing0f607752002-05-29 09:14:38 +0000403 system_init();
Linus Nielsen Feltzing8c00b4c2002-06-10 14:44:15 +0000404 kernel_init();
Linus Nielsen Feltzing31e20972002-06-20 08:59:54 +0000405
Linus Nielsen Feltzinge7b993f2005-03-18 11:38:15 +0000406#ifdef HAVE_ADJUSTABLE_CPU_FREQ
407 set_cpu_frequency(CPUFREQ_NORMAL);
Michael Sevakis0f5cb942006-11-06 18:07:30 +0000408#ifdef CPU_COLDFIRE
409 coldfire_set_pllcr_audio_bits(DEFAULT_PLLCR_AUDIO_BITS);
410#endif
Miika Pekkarinen86d0d912006-12-05 20:20:00 +0000411 cpu_boost(true);
Linus Nielsen Feltzinge7b993f2005-03-18 11:38:15 +0000412#endif
413
Linus Nielsen Feltzing20d031f2003-05-09 16:01:21 +0000414 buffer_init();
415
Björn Stenberg6b25f792002-07-15 11:02:12 +0000416 settings_reset();
Linus Nielsen Feltzinge16ebf12005-11-18 14:55:51 +0000417
Michael Giacomelli054447f2008-02-10 05:39:20 +0000418 i2c_init();
419
Linus Nielsen Feltzinge16ebf12005-11-18 14:55:51 +0000420 power_init();
421
Michael Sevakisaf395f42008-03-26 01:50:41 +0000422 enable_irq();
Michael Sevakis6077e5b2007-10-06 22:27:27 +0000423#ifdef CPU_ARM
Michael Sevakisaf395f42008-03-26 01:50:41 +0000424 enable_fiq();
Michael Sevakis6077e5b2007-10-06 22:27:27 +0000425#endif
Torne Wuff52e528e2010-04-01 16:27:21 +0000426 /* current_tick should be ticking by now */
427 CHART("ticking");
428
Björn Stenberg4afa7092002-05-30 12:17:18 +0000429 lcd_init();
Jens Arnold3a5bd7a2005-07-07 21:03:58 +0000430#ifdef HAVE_REMOTE_LCD
Christian Gmeiner7c1879b2005-04-15 12:08:49 +0000431 lcd_remote_init();
432#endif
Björn Stenbergbed3d3f2002-09-20 08:07:51 +0000433 font_init();
Karl Kurbjun8a1fd8c2007-04-21 04:48:20 +0000434
Torne Wuff52e528e2010-04-01 16:27:21 +0000435 CHART(">show_logo");
Linus Nielsen Feltzing219944f2005-11-08 23:51:36 +0000436 show_logo();
Torne Wuff52e528e2010-04-01 16:27:21 +0000437 CHART("<show_logo");
Tom Rossec2737b2009-10-18 00:56:42 +0000438 lang_init(core_language_builtin, language_strings,
439 LANG_LAST_INDEX_IN_ARRAY);
Daniel Stenberg75e09a82002-06-11 08:24:33 +0000440
Björn Stenbergf43b27a2002-05-27 09:53:28 +0000441#ifdef DEBUG
Björn Stenberge324db62002-05-17 19:50:37 +0000442 debug_init();
Björn Stenberg18239b82002-08-12 12:44:18 +0000443#else
Bertrik Sikken3c7e2992009-02-07 11:15:30 +0000444#ifdef HAVE_SERIAL
Björn Stenberg18239b82002-08-12 12:44:18 +0000445 serial_setup();
Björn Stenbergf43b27a2002-05-27 09:53:28 +0000446#endif
Jens Arnold2d875f82004-09-20 22:15:35 +0000447#endif
Björn Stenberge324db62002-05-17 19:50:37 +0000448
Jens Arnold2c7b1272007-03-16 23:47:03 +0000449#if CONFIG_RTC
Linus Nielsen Feltzing76759e02002-08-06 08:14:08 +0000450 rtc_init();
Dave Chapman5009c9c2005-12-04 13:05:56 +0000451#endif
452#ifdef HAVE_RTC_RAM
Torne Wuff52e528e2010-04-01 16:27:21 +0000453 CHART(">settings_load(RTC)");
Jörg Hohensohn6ff6d212004-06-19 15:50:02 +0000454 settings_load(SETTINGS_RTC); /* early load parts of global_settings */
Torne Wuff52e528e2010-04-01 16:27:21 +0000455 CHART("<settings_load(RTC)");
Linus Nielsen Feltzing76759e02002-08-06 08:14:08 +0000456#endif
457
Linus Nielsen Feltzing7d3c31b2002-06-30 20:25:37 +0000458 adc_init();
Christian Gmeiner8181a0c2007-08-27 16:04:32 +0000459
Linus Nielsen Feltzing219944f2005-11-08 23:51:36 +0000460 usb_init();
Jonathan Gordonac619512007-02-18 04:57:28 +0000461#if CONFIG_USBOTG == USBOTG_ISP1362
Jens Arnold977169e2006-06-16 17:34:18 +0000462 isp1362_init();
Jonathan Gordonac619512007-02-18 04:57:28 +0000463#elif CONFIG_USBOTG == USBOTG_M5636
Linus Nielsen Feltzing5f655c92006-07-13 07:40:30 +0000464 m5636_init();
Jens Arnold977169e2006-06-16 17:34:18 +0000465#endif
Linus Nielsen Feltzinge16ebf12005-11-18 14:55:51 +0000466
Linus Nielsen Feltzinga844a182007-03-07 14:49:20 +0000467 backlight_init();
468
Björn Stenberge324db62002-05-17 19:50:37 +0000469 button_init();
Linus Nielsen Feltzing4b545592002-07-02 17:59:10 +0000470
Linus Nielsen Feltzing219944f2005-11-08 23:51:36 +0000471 powermgmt_init();
Peter D'Hoye3c1e9ca2008-09-07 20:09:11 +0000472
Jonathan Gordon8ff3a652007-02-18 02:04:47 +0000473#if CONFIG_TUNER
Linus Nielsen Feltzing219944f2005-11-08 23:51:36 +0000474 radio_init();
Jörg Hohensohnef8d5082004-10-19 08:20:38 +0000475#endif
476
Thomas Martitzc5b44822009-11-10 20:13:24 +0000477 /* Keep the order of this 3 (viewportmanager handles statusbars)
478 * Must be done before any code uses the multi-screen API */
Torne Wuff52e528e2010-04-01 16:27:21 +0000479 CHART(">gui_syncstatusbar_init");
Jens Arnoldbaef5362009-10-03 22:09:27 +0000480 gui_syncstatusbar_init(&statusbars);
Torne Wuff52e528e2010-04-01 16:27:21 +0000481 CHART("<gui_syncstatusbar_init");
482 CHART(">sb_skin_init");
Thomas Martitzc5b44822009-11-10 20:13:24 +0000483 sb_skin_init();
Torne Wuff52e528e2010-04-01 16:27:21 +0000484 CHART("<sb_skin_init");
485 CHART(">gui_sync_wps_init");
Thomas Martitzed6c1432010-03-04 01:04:43 +0000486 gui_sync_wps_init();
Torne Wuff52e528e2010-04-01 16:27:21 +0000487 CHART("<gui_sync_wps_init");
488 CHART(">viewportmanager_init");
Thomas Martitzc5b44822009-11-10 20:13:24 +0000489 viewportmanager_init();
Torne Wuff52e528e2010-04-01 16:27:21 +0000490 CHART("<viewportmanager_init");
Thomas Martitzc5b44822009-11-10 20:13:24 +0000491
Jonathan Gordon9a6f4192007-02-18 05:32:06 +0000492#if CONFIG_CHARGING && (CONFIG_CPU == SH7034)
Boris Gjenero02b9c652009-04-06 01:47:28 +0000493 /* charger_inserted() can't be used here because power_thread()
494 hasn't checked power_input_status() yet */
495 if (coldstart && (power_input_status() & POWER_INPUT_MAIN_CHARGER)
Jens Arnold7197edd2004-12-16 22:31:26 +0000496 && !global_settings.car_adapter_mode
497#ifdef ATA_POWER_PLAYERSTYLE
498 && !ide_powered() /* relies on probing result from bootloader */
499#endif
500 )
Jörg Hohensohn5dd17b12003-07-17 20:29:51 +0000501 {
502 rc = charging_screen(); /* display a "charging" screen */
Jens Arnold7c7dd432005-07-11 19:14:26 +0000503 if (rc == 1) /* charger removed */
Jörg Hohensohn5dd17b12003-07-17 20:29:51 +0000504 power_off();
505 /* "On" pressed or USB connected: proceed */
Jens Arnold67b17e12004-11-21 09:29:51 +0000506 show_logo(); /* again, to provide better visual feedback */
Jörg Hohensohn5dd17b12003-07-17 20:29:51 +0000507 }
Daniel Stenberg8e43ccb2003-12-12 13:34:27 +0000508#endif
Jörg Hohensohnc47f8c02003-07-03 22:13:39 +0000509
Frank Gevaerts9c43b2c2010-06-06 13:20:47 +0000510
511 disk_init_subsystem();
Torne Wuff52e528e2010-04-01 16:27:21 +0000512 CHART(">storage_init");
Frank Gevaerts2f8a0082008-11-01 16:14:28 +0000513 rc = storage_init();
Torne Wuff52e528e2010-04-01 16:27:21 +0000514 CHART("<storage_init");
Linus Nielsen Feltzing71ef31a2002-07-02 18:01:31 +0000515 if(rc)
Linus Nielsen Feltzing4b545592002-07-02 17:59:10 +0000516 {
Björn Stenbergb47e64e2002-08-08 20:44:25 +0000517#ifdef HAVE_LCD_BITMAP
Linus Nielsen Feltzing4b545592002-07-02 17:59:10 +0000518 lcd_clear_display();
Nils Wallméniusf34a8412009-10-17 18:02:48 +0000519 lcd_putsf(0, 1, "ATA error: %d", rc);
Linus Nielsen Feltzing4b545592002-07-02 17:59:10 +0000520 lcd_puts(0, 3, "Press ON to debug");
521 lcd_update();
Linus Nielsen Feltzing224c0a12006-08-15 12:27:07 +0000522 while(!(button_get(true) & BUTTON_REL)); /*DO NOT CHANGE TO ACTION SYSTEM */
Linus Nielsen Feltzing4b545592002-07-02 17:59:10 +0000523 dbg_ports();
524#endif
525 panicf("ata: %d", rc);
526 }
Jens Arnold2d875f82004-09-20 22:15:35 +0000527
Peter D'Hoyec4a59a22006-08-15 22:54:06 +0000528#ifdef HAVE_EEPROM_SETTINGS
Torne Wuff52e528e2010-04-01 16:27:21 +0000529 CHART(">eeprom_settings_init");
Miika Pekkarinen3b52bb92006-08-11 10:13:16 +0000530 eeprom_settings_init();
Torne Wuff52e528e2010-04-01 16:27:21 +0000531 CHART("<eeprom_settings_init");
Miika Pekkarinen3b52bb92006-08-11 10:13:16 +0000532#endif
Peter D'Hoye3c1e9ca2008-09-07 20:09:11 +0000533
Frank Gevaertsc483efa2009-05-21 19:01:07 +0000534#ifndef HAVE_USBSTACK
Michael Sevakisda76a342009-01-22 22:05:04 +0000535 usb_start_monitoring();
Dave Chapman16723502007-09-04 08:03:07 +0000536 while (usb_detect() == USB_INSERTED)
Peter D'Hoye3c1e9ca2008-09-07 20:09:11 +0000537 {
Peter D'Hoyec4a59a22006-08-15 22:54:06 +0000538#ifdef HAVE_EEPROM_SETTINGS
Miika Pekkarinen3b52bb92006-08-11 10:13:16 +0000539 firmware_settings.disk_clean = false;
540#endif
541 /* enter USB mode early, before trying to mount */
Jens Arnold27abc2a2005-05-17 22:10:51 +0000542 if (button_get_w_tmo(HZ/10) == SYS_USB_CONNECTED)
Frank Gevaerts19d1cac2008-10-31 21:25:04 +0000543#if (CONFIG_STORAGE & STORAGE_MMC)
Michael Sevakis1167e3c2007-06-30 02:08:27 +0000544 if (!mmc_touched() ||
545 (mmc_remove_request() == SYS_HOTSWAP_EXTRACTED))
Linus Nielsen Feltzing15124aa2004-07-05 22:13:20 +0000546#endif
Jens Arnold27abc2a2005-05-17 22:10:51 +0000547 {
Thomas Martitzc5b44822009-11-10 20:13:24 +0000548 gui_usb_screen_run();
Jens Arnold27abc2a2005-05-17 22:10:51 +0000549 mounted = true; /* mounting done @ end of USB mode */
550 }
Jens Arnold97a80492005-06-23 02:18:29 +0000551#ifdef HAVE_USB_POWER
552 if (usb_powered()) /* avoid deadlock */
553 break;
554#endif
Jens Arnold27abc2a2005-05-17 22:10:51 +0000555 }
Frank Gevaerts6f058992008-03-10 19:11:37 +0000556#endif
Linus Nielsen Feltzing55e96702005-12-06 10:06:40 +0000557
Jens Arnold27abc2a2005-05-17 22:10:51 +0000558 if (!mounted)
559 {
Torne Wuff52e528e2010-04-01 16:27:21 +0000560 CHART(">disk_mount_all");
Jens Arnold27abc2a2005-05-17 22:10:51 +0000561 rc = disk_mount_all();
Torne Wuff52e528e2010-04-01 16:27:21 +0000562 CHART("<disk_mount_all");
Jens Arnold27abc2a2005-05-17 22:10:51 +0000563 if (rc<=0)
564 {
565 lcd_clear_display();
566 lcd_puts(0, 0, "No partition");
567 lcd_puts(0, 1, "found.");
568#ifdef HAVE_LCD_BITMAP
569 lcd_puts(0, 2, "Insert USB cable");
570 lcd_puts(0, 3, "and fix it.");
Jens Arnold27abc2a2005-05-17 22:10:51 +0000571#endif
Jens Arnoldf9b90e92007-04-06 22:55:00 +0000572 lcd_update();
573
Jens Arnold27abc2a2005-05-17 22:10:51 +0000574 while(button_get(true) != SYS_USB_CONNECTED) {};
Thomas Martitzc5b44822009-11-10 20:13:24 +0000575 gui_usb_screen_run();
Jens Arnold27abc2a2005-05-17 22:10:51 +0000576 system_reboot();
577 }
Linus Nielsen Feltzing15124aa2004-07-05 22:13:20 +0000578 }
Björn Stenbergde943a52002-07-15 15:06:45 +0000579
Marcoen Hirschbergd2d695f2006-12-31 02:02:03 +0000580#if defined(SETTINGS_RESET) || (CONFIG_KEYPAD == IPOD_4G_PAD) || \
Marcoen Hirschberg810f7172007-04-27 19:24:31 +0000581 (CONFIG_KEYPAD == IRIVER_H10_PAD)
Miika Pekkarinen8e8c1a82005-12-07 12:35:54 +0000582#ifdef SETTINGS_RESET
Marcoen Hirschberg810f7172007-04-27 19:24:31 +0000583 /* Reset settings if holding the reset button. (Rec on Archos,
584 A on Gigabeat) */
Miika Pekkarinen8e8c1a82005-12-07 12:35:54 +0000585 if ((button_status() & SETTINGS_RESET) == SETTINGS_RESET)
Dave Chapman1272c8a2006-02-24 12:37:50 +0000586#else
587 /* Reset settings if the hold button is turned on */
588 if (button_hold())
589#endif
Miika Pekkarinena6977172005-12-07 11:20:56 +0000590 {
Nils Wallménius01729e72008-08-15 08:27:39 +0000591 splash(HZ*2, str(LANG_RESET_DONE_CLEAR));
Miika Pekkarinena6977172005-12-07 11:20:56 +0000592 settings_reset();
593 }
594 else
Miika Pekkarinen8e8c1a82005-12-07 12:35:54 +0000595#endif
Torne Wuff52e528e2010-04-01 16:27:21 +0000596 {
597 CHART(">settings_load(ALL)");
Miika Pekkarinena6977172005-12-07 11:20:56 +0000598 settings_load(SETTINGS_ALL);
Torne Wuff52e528e2010-04-01 16:27:21 +0000599 CHART("<settings_load(ALL)");
600 }
Miika Pekkarinen8e8c1a82005-12-07 12:35:54 +0000601
Torne Wuff52e528e2010-04-01 16:27:21 +0000602 CHART(">init_dircache(true)");
603 rc = init_dircache(true);
Torne Wuff59463ba2010-04-06 23:07:18 +0000604 CHART("<init_dircache(true)");
Torne Wuff52e528e2010-04-01 16:27:21 +0000605 if (rc < 0)
Miika Pekkarinen69cdc752006-08-12 14:40:38 +0000606 {
Jonathan Gordon710ccb72006-10-25 10:17:57 +0000607#ifdef HAVE_TAGCACHE
Miika Pekkarinen69cdc752006-08-12 14:40:38 +0000608 remove(TAGCACHE_STATEFILE);
Jonathan Gordon710ccb72006-10-25 10:17:57 +0000609#endif
Miika Pekkarinen69cdc752006-08-12 14:40:38 +0000610 }
Peter D'Hoye3c1e9ca2008-09-07 20:09:11 +0000611
Torne Wuff52e528e2010-04-01 16:27:21 +0000612 CHART(">settings_apply(true)");
Jonathan Gordon792f7332010-03-07 03:20:34 +0000613 settings_apply(true);
Torne Wuff52e528e2010-04-01 16:27:21 +0000614 CHART("<settings_apply(true)");
615 CHART(">init_dircache(false)");
Miika Pekkarinen69cdc752006-08-12 14:40:38 +0000616 init_dircache(false);
Torne Wuff52e528e2010-04-01 16:27:21 +0000617 CHART("<init_dircache(false)");
Jonathan Gordon710ccb72006-10-25 10:17:57 +0000618#ifdef HAVE_TAGCACHE
Torne Wuff52e528e2010-04-01 16:27:21 +0000619 CHART(">init_tagcache");
Miika Pekkarinen1b18dd02006-04-12 10:31:24 +0000620 init_tagcache();
Torne Wuff52e528e2010-04-01 16:27:21 +0000621 CHART("<init_tagcache");
Jonathan Gordon710ccb72006-10-25 10:17:57 +0000622#endif
Jens Arnoldc12e87d2004-09-28 18:09:10 +0000623
Peter D'Hoyec4a59a22006-08-15 22:54:06 +0000624#ifdef HAVE_EEPROM_SETTINGS
Miika Pekkarinen954b7322006-08-05 20:19:10 +0000625 if (firmware_settings.initialized)
626 {
627 /* In case we crash. */
628 firmware_settings.disk_clean = false;
Torne Wuff52e528e2010-04-01 16:27:21 +0000629 CHART(">eeprom_settings_store");
Miika Pekkarinen954b7322006-08-05 20:19:10 +0000630 eeprom_settings_store();
Torne Wuff52e528e2010-04-01 16:27:21 +0000631 CHART("<eeprom_settings_store");
Miika Pekkarinen954b7322006-08-05 20:19:10 +0000632 }
633#endif
Jens Arnold36056002004-09-29 21:41:10 +0000634 playlist_init();
Jonathan Gordon2cda9942007-06-10 10:41:27 +0000635 tree_mem_init();
Jonathan Gordon21165a32007-03-29 06:16:00 +0000636 filetype_init();
Linus Nielsen Feltzingda153da2006-10-19 09:42:58 +0000637 scrobbler_init();
Steve Bavin77f6f4c2009-06-15 15:46:09 +0000638#if CONFIG_CODEC == SWCODEC
639 tdspeed_init();
640#endif /* CONFIG_CODEC == SWCODEC */
Linus Nielsen Feltzingda153da2006-10-19 09:42:58 +0000641
Michael Sevakis98cd3e82007-03-09 12:30:14 +0000642#if CONFIG_CODEC != SWCODEC
Linus Nielsen Feltzing67bea322003-05-17 20:38:38 +0000643 /* No buffer allocation (see buffer.c) may take place after the call to
Linus Nielsen Feltzing8a237a82005-04-04 12:06:29 +0000644 audio_init() since the mpeg thread takes the rest of the buffer space */
Jörg Hohensohnf9933652004-01-05 20:42:51 +0000645 mp3_init( global_settings.volume,
646 global_settings.bass,
647 global_settings.treble,
648 global_settings.balance,
649 global_settings.loudness,
Jörg Hohensohnf9933652004-01-05 20:42:51 +0000650 global_settings.avc,
Linus Nielsen Feltzing7bade1a2004-07-06 12:17:14 +0000651 global_settings.channel_config,
Jens Arnold76b257f2005-01-12 00:24:15 +0000652 global_settings.stereo_width,
Linus Nielsen Feltzing7bade1a2004-07-06 12:17:14 +0000653 global_settings.mdb_strength,
654 global_settings.mdb_harmonics,
655 global_settings.mdb_center,
656 global_settings.mdb_shape,
657 global_settings.mdb_enable,
658 global_settings.superbass);
Peter D'Hoye64881772006-05-01 12:54:21 +0000659
660 /* audio_init must to know the size of voice buffer so init voice first */
661 talk_init();
Michael Sevakis98cd3e82007-03-09 12:30:14 +0000662#endif /* CONFIG_CODEC != SWCODEC */
Peter D'Hoye64881772006-05-01 12:54:21 +0000663
Torne Wuff52e528e2010-04-01 16:27:21 +0000664 CHART(">audio_init");
Magnus Holmgren62634a32005-10-16 08:01:02 +0000665 audio_init();
Torne Wuff52e528e2010-04-01 16:27:21 +0000666 CHART("<audio_init");
Michael Sevakis98cd3e82007-03-09 12:30:14 +0000667
Linus Nielsen Feltzinged4d7a32006-07-21 08:42:28 +0000668#if (CONFIG_CODEC == SWCODEC) && defined(HAVE_RECORDING) && !defined(SIMULATOR)
Andye6e54962005-11-12 04:00:56 +0000669 pcm_rec_init();
Jens Arnold65144352005-06-20 10:04:16 +0000670#endif
Peter D'Hoye64881772006-05-01 12:54:21 +0000671
Michiel Van Der Kolkd6ab7232005-07-04 22:10:42 +0000672 /* runtime database has to be initialized after audio_init() */
Miika Pekkarinen86d0d912006-12-05 20:20:00 +0000673 cpu_boost(false);
Linus Nielsen Feltzing67bea322003-05-17 20:38:38 +0000674
Jonathan Gordon9a6f4192007-02-18 05:32:06 +0000675#if CONFIG_CHARGING
Linus Nielsen Feltzing3d217812005-04-06 11:12:22 +0000676 car_adapter_mode_init();
677#endif
Michael Giacomelli70e9c7a2008-12-25 01:46:16 +0000678#ifdef IPOD_ACCESSORY_PROTOCOL
679 iap_setup(global_settings.serial_bitrate);
680#endif
Andree Buschmann850a1122008-04-20 18:28:25 +0000681#ifdef HAVE_ACCESSORY_SUPPLY
682 accessory_supply_set(global_settings.accessory_supply);
683#endif
Andree Buschmannb6c12a12010-03-20 15:02:29 +0000684#ifdef HAVE_LINEOUT_POWEROFF
685 lineout_set(global_settings.lineout_active);
686#endif
Thomas Martitzcfda0972009-11-25 22:54:36 +0000687#ifdef HAVE_HOTSWAP_STORAGE_AS_MAIN
Torne Wuff52e528e2010-04-01 16:27:21 +0000688 CHART("<check_bootfile(false)");
Thomas Martitzcfda0972009-11-25 22:54:36 +0000689 check_bootfile(false); /* remember write time and filesize */
Torne Wuff52e528e2010-04-01 16:27:21 +0000690 CHART(">check_bootfile(false)");
Thomas Martitzcfda0972009-11-25 22:54:36 +0000691#endif
Torne Wuff52e528e2010-04-01 16:27:21 +0000692 CHART("<settings_apply_skins");
Jonathan Gordon4c6b3552010-02-26 08:01:41 +0000693 settings_apply_skins();
Torne Wuff52e528e2010-04-01 16:27:21 +0000694 CHART(">settings_apply_skins");
Björn Stenberge324db62002-05-17 19:50:37 +0000695}
696
Daniel Ankers28575f62006-08-03 16:38:06 +0000697#ifdef CPU_PP
Michael Sevakis2b640ba2010-06-17 20:15:58 +0000698void __attribute__((noreturn)) cop_main(void)
Daniel Ankerscec7cdc2006-08-03 16:29:42 +0000699{
700/* This is the entry point for the coprocessor
701 Anyone not running an upgraded bootloader will never reach this point,
702 so it should not be assumed that the coprocessor be usable even on
703 platforms which support it.
704
Michael Sevakis7914e902007-09-28 10:20:02 +0000705 A kernel thread is initially setup on the coprocessor and immediately
706 destroyed for purposes of continuity. The cop sits idle until at least
707 one thread exists on it. */
Daniel Ankersb8566362007-02-27 22:55:12 +0000708
Michael Sevakis7914e902007-09-28 10:20:02 +0000709#if NUM_CORES > 1
710 system_init();
711 kernel_init();
712 /* This should never be reached */
713#endif
Daniel Ankerscc5de0e2007-02-27 23:21:38 +0000714 while(1) {
Jens Arnoldcea07eb2008-04-20 17:53:05 +0000715 sleep_core(COP);
Daniel Ankerscc5de0e2007-02-27 23:21:38 +0000716 }
Daniel Ankerscec7cdc2006-08-03 16:29:42 +0000717}
Daniel Ankerscc5de0e2007-02-27 23:21:38 +0000718#endif /* CPU_PP */
Daniel Ankerscec7cdc2006-08-03 16:29:42 +0000719
Michael Sevakis2b640ba2010-06-17 20:15:58 +0000720#endif /* SIMULATOR */